minesweeper_game_screen.h 3.1 KB

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