table.h 1.3 KB

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