minesweeper_game_screen.h 2.9 KB

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