minesweeper_game_screen.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /**
  2. * @file minesweeper_game_screen_screen.h
  3. * GUI: Start Screen view module API
  4. */
  5. #ifndef MINEWEEPER_GAME_SCREEN_H
  6. #define MINEWEEPER_GAME_SCREEN_H
  7. #include <gui/view.h>
  8. #include "minesweeper_game_screen_i.h"
  9. #include "../helpers/mine_sweeper_haptic.h"
  10. #include "../helpers/mine_sweeper_led.h"
  11. #include "../helpers/mine_sweeper_speaker.h"
  12. // MAX TILES ALLOWED
  13. #define MINESWEEPER_BOARD_MAX_TILES (1 << 10)
  14. // These defines represent how many tiles
  15. // can be visually representen on the screen
  16. // due to icon sizes
  17. #define MINESWEEPER_SCREEN_TILE_HEIGHT 7
  18. #define MINESWEEPER_SCREEN_TILE_WIDTH 16
  19. #define MS_DEBUG_TAG "Mine Sweeper Module/View"
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. /** MineSweeperGameScreen anonymous structure */
  24. typedef struct MineSweeperGameScreen MineSweeperGameScreen;
  25. /** StartScreen callback types
  26. * @warning comes from GUI thread
  27. */
  28. typedef bool (*GameScreenInputCallback)(InputEvent* event, void* context);
  29. /** Allocate and initalize
  30. *
  31. * This view is used as the game screen of an application.
  32. *
  33. * @param width uint8_t width for board
  34. * @param height uint8_t height for board
  35. * @param difficulty uint8_t difficulty for board
  36. *
  37. * @return MineSweeperGameScreen* instance
  38. */
  39. MineSweeperGameScreen* mine_sweeper_game_screen_alloc(
  40. uint8_t width,
  41. uint8_t height,
  42. uint8_t difficulty,
  43. bool ensure_solvable);
  44. /** Deinitialize and free Start Screen view
  45. *
  46. * @param instsance MineSweeperGameScreen instance
  47. */
  48. void mine_sweeper_game_screen_free(MineSweeperGameScreen* instance);
  49. /** Reset MineSweeperGameScreen
  50. *
  51. * @param instance MineSweeperGameScreen* instance
  52. * @param width uint8_t width for board
  53. * @param height uint8_t height for board
  54. * @param difficulty uint8_t difficulty for board
  55. */
  56. void mine_sweeper_game_screen_reset(
  57. MineSweeperGameScreen* instance,
  58. uint8_t width,
  59. uint8_t height,
  60. uint8_t difficulty,
  61. bool ensure_solvable);
  62. /** Reset MineSweeperGameScreen clock
  63. *
  64. * @param instance MineSweeperGameScreen* instance
  65. */
  66. void mine_sweeper_game_screen_reset_clock(MineSweeperGameScreen* instance);
  67. /** Get MineSweeperGameScreen view
  68. *
  69. * @param instance MineSweeperGameScreen instance
  70. *
  71. * @return View* instance that can be used for embedding
  72. */
  73. View* mine_sweeper_game_screen_get_view(MineSweeperGameScreen* instance);
  74. /** Set MineSweeperGameScreen context
  75. *
  76. * @param instance MineSweeperGameScreen* instance
  77. * @param context void* context for MineSweeperGameScreen instance
  78. */
  79. void mine_sweeper_game_screen_set_context(MineSweeperGameScreen* instance, void* context);
  80. #define inverted_canvas_white_to_black(canvas, code) \
  81. { \
  82. canvas_set_color(canvas, ColorWhite); \
  83. {code}; \
  84. canvas_set_color(canvas, ColorBlack); \
  85. }
  86. #ifdef __cplusplus
  87. }
  88. #endif
  89. #endif