minesweeper_game_screen.h 3.1 KB

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