Skip to content

Commit c56b74d

Browse files
committed
added some generic message_dialog functions
1 parent 409e6ea commit c56b74d

2 files changed

Lines changed: 98 additions & 8 deletions

File tree

β€Žmain/menu/message_dialog.cβ€Ž

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,55 @@ bsp_input_navigation_key_t message_dialog(pax_buf_t* buffer, gui_theme_t* theme,
231231
}
232232
}
233233
}
234+
235+
message_dialog_return_type_t message_dialog_ok(pax_buf_t* buffer, gui_theme_t* theme, const char* title, const char* message){
236+
bsp_input_navigation_key_t key;
237+
while(1){
238+
key = message_dialog(buffer, theme, title, message, MESSAGE_DIALOG_FOOTER_OK);
239+
switch(key){
240+
case BSP_INPUT_NAVIGATION_KEY_ESC:
241+
case BSP_INPUT_NAVIGATION_KEY_F1:
242+
case BSP_INPUT_NAVIGATION_KEY_GAMEPAD_A:
243+
return MSG_DIALOG_RETURN_OK;
244+
default:
245+
}
246+
}
247+
}
248+
249+
message_dialog_return_type_t message_dialog_yes_no(pax_buf_t* buffer, gui_theme_t* theme, const char* title, const char* message){
250+
bsp_input_navigation_key_t key;
251+
while(1){
252+
key = message_dialog(buffer, theme, title, message, MESSAGE_DIALOG_FOOTER_YES_NO);
253+
switch(key){
254+
case BSP_INPUT_NAVIGATION_KEY_ESC:
255+
case BSP_INPUT_NAVIGATION_KEY_F1:
256+
case BSP_INPUT_NAVIGATION_KEY_GAMEPAD_B:
257+
return MSG_DIALOG_RETURN_NO;
258+
case BSP_INPUT_NAVIGATION_KEY_F4:
259+
case BSP_INPUT_NAVIGATION_KEY_GAMEPAD_A:
260+
return MSG_DIALOG_RETURN_OK;
261+
default:
262+
}
263+
}
264+
}
265+
266+
message_dialog_return_type_t message_dialog_yes_no_cancel(pax_buf_t* buffer, gui_theme_t* theme, const char* title, const char* message){
267+
bsp_input_navigation_key_t key;
268+
while(1){
269+
key = message_dialog(buffer, theme, title, message, MESSAGE_DIALOG_FOOTER_YES_NO_CANCEL);
270+
switch(key){
271+
case BSP_INPUT_NAVIGATION_KEY_ESC:
272+
case BSP_INPUT_NAVIGATION_KEY_F1:
273+
case BSP_INPUT_NAVIGATION_KEY_GAMEPAD_B:
274+
return MSG_DIALOG_RETURN_NO;
275+
case BSP_INPUT_NAVIGATION_KEY_F4:
276+
case BSP_INPUT_NAVIGATION_KEY_GAMEPAD_A:
277+
return MSG_DIALOG_RETURN_OK;
278+
case BSP_INPUT_NAVIGATION_KEY_F6:
279+
case BSP_INPUT_NAVIGATION_KEY_MENU:
280+
return MSG_DIALOG_RETURN_CANCEL;
281+
default:
282+
}
283+
}
284+
}
285+

β€Žmain/menu/message_dialog.hβ€Ž

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@
44
#include "gui_footer.h"
55
#include "gui_style.h"
66
#include "pax_types.h"
7+
8+
9+
10+
typedef enum {
11+
MSG_DIALOG_RETURN_OK,
12+
MSG_DIALOG_RETURN_NO,
13+
MSG_DIALOG_RETURN_CANCEL,
14+
} message_dialog_return_type_t;
15+
16+
17+
718
void render_base_screen(pax_buf_t* buffer, gui_theme_t* theme, bool background, bool header, bool footer,
819
gui_header_field_t* header_left, size_t header_left_count, gui_header_field_t* header_right,
920
size_t header_right_count, gui_header_field_t* footer_left, size_t footer_left_count,
@@ -16,20 +27,47 @@ void render_base_screen_statusbar(pax_buf_t* buffer, gui_theme_t* theme, bool ba
1627
bsp_input_navigation_key_t message_dialog(pax_buf_t* buffer, gui_theme_t* theme, const char* title, const char* message,
1728
gui_header_field_t* headers, int header_count);
1829

30+
31+
32+
message_dialog_return_type_t message_dialog_ok(pax_buf_t* buffer, gui_theme_t* theme, const char* title, const char* message);
33+
message_dialog_return_type_t message_dialog_yes_no(pax_buf_t* buffer, gui_theme_t* theme, const char* title, const char* message);
34+
message_dialog_return_type_t message_dialog_yes_no_cancel(pax_buf_t* buffer, gui_theme_t* theme, const char* title, const char* message);
35+
36+
1937
#if defined(CONFIG_BSP_TARGET_TANMATSU) || defined(CONFIG_BSP_TARGET_KONSOOL) || \
2038
defined(CONFIG_BSP_TARGET_HACKERHOTEL_2026)
21-
#define MESSAGE_DIALOG_FOOTER_OK ((gui_header_field_t[]){{get_icon(ICON_ESC), "/"}, {get_icon(ICON_F1), "OK"}}), 2
22-
#define MESSAGE_DIALOG_FOOTER_GOBACK \
23-
((gui_header_field_t[]){{get_icon(ICON_ESC), "/"}, {get_icon(ICON_F1), "Go back"}}), 2
24-
#define MESSAGE_DIALOG_FOOTER_YES_NO \
25-
((gui_header_field_t[]){{get_icon(ICON_ESC), "/"}, {get_icon(ICON_F1), "No"}, {get_icon(ICON_F4), "Yes"}}), 3
39+
#define MESSAGE_DIALOG_FOOTER_OK ((gui_header_field_t[]){ \
40+
{get_icon(ICON_ESC), "/"}, \
41+
{get_icon(ICON_F1), "OK"}}), 2
42+
#define MESSAGE_DIALOG_FOOTER_GOBACK ((gui_header_field_t[]){ \
43+
{get_icon(ICON_ESC), "/"}, \
44+
{get_icon(ICON_F1), "Go back"}}), 2
45+
#define MESSAGE_DIALOG_FOOTER_YES_NO ((gui_header_field_t[]){ \
46+
{get_icon(ICON_ESC), "/"}, \
47+
{get_icon(ICON_F1), "No"}, \
48+
{get_icon(ICON_F4), "Yes"}}), 3
49+
#define MESSAGE_DIALOG_FOOTER_YES_NO_CANCEL ((gui_header_field_t[]){ \
50+
{get_icon(ICON_ESC), "/"}, \
51+
{get_icon(ICON_F1), "No"}, \
52+
{get_icon(ICON_F4), "Yes"}, \
53+
{get_icon(ICON_F6), "Cancel"}}), 4
2654

2755
#elif defined(CONFIG_BSP_TARGET_MCH2022)
28-
#define MESSAGE_DIALOG_FOOTER_OK ((gui_header_field_t[]){{NULL, "πŸ…±"}, {NULL, "Ok"}}), 2
29-
#define MESSAGE_DIALOG_FOOTER_GOBACK ((gui_header_field_t[]){{NULL, "πŸ…±"}, {NULL, "Go back"}}), 2
30-
#define MESSAGE_DIALOG_FOOTER_YES_NO ((gui_header_field_t[]){{NULL, "πŸ…°"}, {NULL, "Yes"}, {NULL, "πŸ…±"}, {NULL, "No"}}), 4
56+
#define MESSAGE_DIALOG_FOOTER_OK ((gui_header_field_t[]){ \
57+
{NULL, "πŸ…±"}, {NULL, "Ok"}}), 2
58+
#define MESSAGE_DIALOG_FOOTER_GOBACK ((gui_header_field_t[]){ \
59+
{NULL, "πŸ…±"}, {NULL, "Go back"}}), 2
60+
#define MESSAGE_DIALOG_FOOTER_YES_NO ((gui_header_field_t[]){ \
61+
{NULL, "πŸ…°"}, {NULL, "Yes"}, \
62+
{NULL, "πŸ…±"}, {NULL, "No"}}), 4
63+
#define MESSAGE_DIALOG_FOOTER_YES_NO_CANCEL ((gui_header_field_t[]){ \
64+
{NULL, "πŸ…°"}, {NULL, "Yes"}, \
65+
{NULL, "πŸ…±"}, {NULL, "No"}, \
66+
{NULL, "Menu Cancel"}}), 5
67+
3168
#else
3269
#define MESSAGE_DIALOG_FOOTER_OK NULL, 0
3370
#define MESSAGE_DIALOG_FOOTER_GOBACK NULL, 0
3471
#define MESSAGE_DIALOG_FOOTER_YES_NO NULL, 0
72+
#define MESSAGE_DIALOG_FOOTER_YES_NO_CANCEL NULL, 0
3573
#endif

0 commit comments

Comments
Β (0)