table.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #pragma once
  2. #include <furi.h>
  3. #include <vector>
  4. #include "objects.h"
  5. #define TABLE_SELECT 0
  6. #define TABLE_ERROR 1
  7. #define TABLE_INDEX_OFFSET 2
  8. // Defines all of the elements on a pinball table:
  9. // edges, bumpers, flipper locations, scoreboard
  10. // eventually read stae from file and dynamically allocate
  11. class Table {
  12. public:
  13. Table()
  14. : balls_released(false)
  15. , num_lives(1)
  16. , plunger(nullptr) {
  17. }
  18. ~Table();
  19. std::vector<FixedObject*> objects;
  20. std::vector<Ball> balls; // current state of balls
  21. std::vector<Ball> balls_initial; // original positions, before release
  22. std::vector<Flipper> flippers;
  23. bool balls_released; // is ball in play?
  24. size_t num_lives;
  25. Vec2 num_lives_pos;
  26. size_t score;
  27. Plunger* plunger;
  28. void draw(Canvas* canvas);
  29. };
  30. typedef struct {
  31. FuriString* name;
  32. FuriString* filename;
  33. } TableMenuItem;
  34. class TableList {
  35. public:
  36. ~TableList();
  37. std::vector<TableMenuItem> menu_items;
  38. size_t display_size; // how many can fit on screen
  39. size_t selected;
  40. };
  41. // Read the list tables from the data folder and store in the state
  42. void table_table_list_init(void* ctx);
  43. // Loads the index'th table from the list
  44. bool table_load_table(void* ctx, size_t index);