Skip to content

Commit 711ec24

Browse files
committed
rg_gui: Added rg_gui_error (rel #241)
Once properly tested this will replace RG_PANIC in many instances.
1 parent 5f4e8c7 commit 711ec24

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

components/retro-go/rg_gui.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,29 @@ void rg_gui_alert(const char *title, const char *message)
10391039
rg_gui_dialog(title, message ? options : options + 1, -1);
10401040
}
10411041

1042+
void rg_gui_error(const char *message, const char *object, int _errno, bool exit_program)
1043+
{
1044+
const char *title = exit_program ? _("Fatal Error") : _("Error");
1045+
const char *button = exit_program ? _("Exit") : _("OK");
1046+
char error_msg[128] = "";
1047+
1048+
const rg_gui_option_t options[] = {
1049+
{0, message, NULL, RG_DIALOG_FLAG_NORMAL, NULL},
1050+
{0, _("Obj"), (char *)object, object ? RG_DIALOG_FLAG_MESSAGE : RG_DIALOG_FLAG_HIDDEN, NULL},
1051+
{0, _("Err"), error_msg, _errno ? RG_DIALOG_FLAG_MESSAGE : RG_DIALOG_FLAG_HIDDEN, NULL},
1052+
{0, "", NULL, RG_DIALOG_FLAG_MESSAGE, NULL},
1053+
{1, button, NULL, RG_DIALOG_FLAG_NORMAL, NULL},
1054+
RG_DIALOG_END,
1055+
};
1056+
1057+
esp_err_to_name_r(_errno, error_msg, sizeof(error_msg));
1058+
1059+
// FIXME: show blue backdrop color and hide bars?
1060+
rg_gui_dialog(title, options, -1);
1061+
if (exit_program)
1062+
rg_system_exit();
1063+
}
1064+
10421065
typedef struct
10431066
{
10441067
rg_gui_option_t *options;

components/retro-go/rg_gui.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ void rg_gui_draw_input_screen(const char *title, const char *message, const char
133133
intptr_t rg_gui_dialog(const char *title, const rg_gui_option_t *options, int selected_index);
134134
bool rg_gui_confirm(const char *title, const char *message, bool default_yes);
135135
void rg_gui_alert(const char *title, const char *message);
136+
void rg_gui_error(const char *message, const char *object, int _errno, bool exit_program); // , bool allow_retry
136137
char *rg_gui_file_picker(const char *title, const char *path, bool (*validator)(const char *path), bool browse_tree, bool none_option);
137138
char *rg_gui_input_str(const char *title, const char *message, const char *default_value);
138139
int rg_gui_input_char(const rg_keyboard_layout_t *map);

0 commit comments

Comments
 (0)