menu.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #include "gfx/shape.h"
  5. #include "gfx/image.h"
  6. #include "gfx/text.h"
  7. #include "gfx/SDL_easy.h"
  8. #include "util/error.h"
  9. enum
  10. {
  11. Font_Tetris_TL = 0xE020,
  12. Font_Tetris_T = 0xE021,
  13. Font_Tetris_TR = 0xE022,
  14. Font_Tetris_R = 0xE023,
  15. Font_Tetris_BR = 0xE024,
  16. Font_Tetris_B = 0xE025,
  17. Font_Tetris_BL = 0xE026,
  18. Font_Tetris_L = 0xE027,
  19. };
  20. // for colour pulsing boxes.
  21. typedef struct
  22. {
  23. SDL_Colour col;
  24. bool increase_blue;
  25. uint8_t delay;
  26. } PulseColour_t;
  27. typedef struct
  28. {
  29. PulseColour_t pulse;
  30. SDL_Rect rect;
  31. } PulseShape_t;
  32. typedef struct
  33. {
  34. shape_t empty_bar;
  35. shape_t filled_bar;
  36. text_t *text_header;
  37. text_t *text_warning1;
  38. text_t *text_warning2;
  39. text_t *text_name;
  40. text_t *text_speed;
  41. text_t *text_time;
  42. size_t speed;
  43. uint16_t eta_min;
  44. uint8_t eta_sec;
  45. } progress_bar_t;
  46. typedef struct
  47. {
  48. image_t *icon;
  49. text_t *title;
  50. text_t *author;
  51. text_t *text_app_id;
  52. text_t *text_key_gen;
  53. text_t *text_size;
  54. text_t *text_entry_contents;
  55. uint64_t app_id;
  56. uint8_t key_gen;
  57. size_t size;
  58. uint32_t total_count;
  59. uint16_t base_count;
  60. uint16_t upp_count;
  61. uint16_t dlc_count;
  62. } GameInfo_t;
  63. typedef struct
  64. {
  65. text_t *type;
  66. text_t *size;
  67. text_t *name;
  68. } GameInfoEntry_t;
  69. typedef struct
  70. {
  71. text_t *text_type;
  72. text_t *text_id;
  73. text_t *text_keygen;
  74. text_t *text_version;
  75. text_t *text_content_count;
  76. text_t *text_content_meta_count;
  77. uint8_t type;
  78. uint64_t id;
  79. uint8_t keygen;
  80. uint32_t version;
  81. uint16_t content_count;
  82. uint16_t content_meta_count;
  83. GameInfoEntry_t *entry; //array.
  84. } GameInfoDetailed_t;
  85. //
  86. bool init_menu(void);
  87. void exit_menu(void);
  88. /*
  89. *
  90. */
  91. /*
  92. //
  93. bool is_lower_key_gen_enabled(void);
  94. bool is_bl_enabled(void);
  95. void set_lower_key_gen(bool on);
  96. void set_bl(bool on);
  97. */
  98. /*
  99. *
  100. */
  101. //
  102. void update_button_spin(void);
  103. //
  104. void ui_display_error_box(ErrorCodes err, const char *func);
  105. //
  106. bool ui_display_yes_no_box(const char *message);
  107. //
  108. progress_bar_t *ui_init_progress_bar(const char *name, uint64_t speed, uint16_t eta_min, uint8_t eta_sec, size_t done, size_t remaining);
  109. void ui_free_progress_bar(progress_bar_t *p_bar);
  110. void ui_update_progress_bar(progress_bar_t *p_bar, uint64_t speed, uint16_t eta_min, uint8_t eta_sec, size_t done, size_t remaining);
  111. void ui_display_progress_bar(progress_bar_t *p_bar);
  112. void ui_display_dim_background(void);
  113. void ui_draw_highlight_box(PulseShape_t *pulse_shape, int x, int y, int w, int h);
  114. //
  115. void render_menu(void);
  116. // "main" for the menu.
  117. void start_menu(void);