minesweeper_game_screen.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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(uint8_t width, uint8_t height, uint8_t difficulty, bool ensure_solvable);
  40. /** Deinitialize and free Start Screen view
  41. *
  42. * @param instsance MineSweeperGameScreen instance
  43. */
  44. void mine_sweeper_game_screen_free(MineSweeperGameScreen* instance);
  45. /** Reset MineSweeperGameScreen
  46. *
  47. * @param instance MineSweeperGameScreen* instance
  48. * @param width uint8_t width for board
  49. * @param height uint8_t height for board
  50. * @param difficulty uint8_t difficulty for board
  51. */
  52. void mine_sweeper_game_screen_reset(
  53. MineSweeperGameScreen* instance,
  54. uint8_t width,
  55. uint8_t height,
  56. uint8_t difficulty,
  57. bool ensure_solvable);
  58. /** Reset MineSweeperGameScreen clock
  59. *
  60. * @param instance MineSweeperGameScreen* instance
  61. */
  62. void mine_sweeper_game_screen_reset_clock(MineSweeperGameScreen* instance);
  63. /** Get MineSweeperGameScreen view
  64. *
  65. * @param instance MineSweeperGameScreen instance
  66. *
  67. * @return View* instance that can be used for embedding
  68. */
  69. View* mine_sweeper_game_screen_get_view(MineSweeperGameScreen* instance);
  70. /** Set MineSweeperGameScreen context
  71. *
  72. * @param instance MineSweeperGameScreen* instance
  73. * @param context void* context for MineSweeperGameScreen instance
  74. */
  75. void mine_sweeper_game_screen_set_context(MineSweeperGameScreen* instance, void* context);
  76. #define inverted_canvas_white_to_black(canvas, code) \
  77. { \
  78. canvas_set_color(canvas, ColorWhite); \
  79. {code}; \
  80. canvas_set_color(canvas, ColorBlack); \
  81. }
  82. #ifdef __cplusplus
  83. }
  84. #endif
  85. #endif