Skip to content

Commit 5994bbb

Browse files
committed
Added padding to panic/alert/confirm dialogs
1 parent e17fb26 commit 5994bbb

File tree

12 files changed

+43
-58
lines changed

12 files changed

+43
-58
lines changed

components/retro-go/rg_gui.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ void rg_gui_draw_dialog(const char *header, dialog_choice_t *options, int sel)
295295

296296
for (int i = 0; i < options_count; i++)
297297
{
298+
if (options[i].label == NULL) {
299+
options[i].label = "";
300+
}
298301
if (options[i].value[0]) {
299302
len = strlen(options[i].label);
300303
padding = (len > padding) ? len : padding;
@@ -450,23 +453,27 @@ int rg_gui_dialog(const char *header, dialog_choice_t *options, int selected)
450453
return sel < 0 ? sel : options[sel].id;
451454
}
452455

453-
int rg_gui_confirm(const char *text, bool yes_selected)
456+
bool rg_gui_confirm(const char *title, const char *message, bool yes_selected)
454457
{
455458
dialog_choice_t choices[] = {
459+
{0, message, "", -1, NULL},
460+
{0, "", "", -1, NULL},
456461
{1, "Yes", "", 1, NULL},
457462
{0, "No ", "", 1, NULL},
458463
RG_DIALOG_CHOICE_LAST
459464
};
460-
return rg_gui_dialog(text, choices, yes_selected ? 0 : 1);
465+
return rg_gui_dialog(title, message ? choices : choices + 1, yes_selected ? -2 : -1) == 1;
461466
}
462467

463-
void rg_gui_alert(const char *text)
468+
void rg_gui_alert(const char *title, const char *message)
464469
{
465470
dialog_choice_t choices[] = {
471+
{0, message, "", -1, NULL},
472+
{0, "", "", -1, NULL},
466473
{1, "OK", "", 1, NULL},
467474
RG_DIALOG_CHOICE_LAST
468475
};
469-
rg_gui_dialog(text, choices, 0);
476+
rg_gui_dialog(title, message ? choices : choices + 1, -1);
470477
}
471478

472479
static bool volume_update_cb(dialog_choice_t *option, dialog_event_t event)

components/retro-go/rg_gui.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ void rg_gui_draw_image(int x, int y, int width, int height, const rg_image_t *im
211211
void rg_gui_free_image(rg_image_t *img);
212212

213213
int rg_gui_dialog(const char *header, dialog_choice_t *options, int selected_initial);
214-
int rg_gui_confirm(const char *text, bool yes_selected);
215-
void rg_gui_alert(const char *text);
214+
bool rg_gui_confirm(const char *title, const char *message, bool yes_selected);
215+
void rg_gui_alert(const char *title, const char *message);
216216

217217
int rg_gui_settings_menu(dialog_choice_t *extra_options);
218218
int rg_gui_game_settings_menu(dialog_choice_t *extra_options);

components/retro-go/rg_netplay.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ bool rg_netplay_quick_start(void)
390390
{
391391
case NETPLAY_STATUS_CONNECTED:
392392
return remote_player->game_id == local_player->game_id
393-
|| rg_gui_confirm("ROMs not identical. Continue?", 1);
393+
|| rg_gui_confirm("Netplay", "ROMs not identical. Continue?", 1);
394394
break;
395395

396396
case NETPLAY_STATUS_HANDSHAKE:

components/retro-go/rg_system.c

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
typedef struct
3434
{
3535
uint32_t magicWord;
36-
char message[128];
37-
char function[128];
38-
char file[128];
36+
char message[256];
37+
char function[64];
38+
char file[256];
3939
} panic_trace_t;
4040

4141
// This is a direct pointer to rtc slow ram which isn't cleared on
@@ -102,7 +102,7 @@ static void system_monitor_task(void *arg)
102102
// Applications should never stop polling input. If they do, they're probably unresponsive...
103103
if (statistics.lastTickTime > 0 && rg_input_gamepad_last_read() > 5000000)
104104
{
105-
RG_PANIC("Application is unresponsive!");
105+
RG_PANIC("Application unresponsive");
106106
}
107107

108108
if (statistics.battery.percentage < 2)
@@ -243,9 +243,14 @@ void rg_system_init(int appId, int sampleRate)
243243
if (esp_reset_reason() == ESP_RST_PANIC)
244244
{
245245
if (panicTrace->magicWord == PANIC_TRACE_MAGIC)
246-
rg_system_panic_dialog(panicTrace->message);
247-
else
248-
rg_system_panic_dialog("Reason unknown");
246+
printf(" *** PREVIOUS PANIC: %s *** \n", panicTrace->message);
247+
else // Presumably abort()
248+
strcpy(panicTrace->message, "Application crashed");
249+
panicTrace->magicWord = 0;
250+
rg_audio_deinit();
251+
rg_display_clear(C_BLUE);
252+
rg_gui_alert("System Panic!", panicTrace->message);
253+
rg_system_switch_app(RG_APP_LAUNCHER);
249254
}
250255

251256
if (esp_reset_reason() != ESP_RST_SW)
@@ -302,7 +307,7 @@ void rg_emu_init(state_handler_t load, state_handler_t save, netplay_callback_t
302307
currentApp.romPath = rg_settings_RomFilePath_get();
303308
if (!currentApp.romPath || strlen(currentApp.romPath) < 4)
304309
{
305-
RG_PANIC("Invalid ROM Path!");
310+
RG_PANIC("Invalid ROM path!");
306311
}
307312

308313
if (netplay_cb)
@@ -384,7 +389,7 @@ char* rg_emu_get_path(emu_path_type_t type, const char *_romPath)
384389
break;
385390

386391
default:
387-
RG_PANIC("Unknown Type");
392+
RG_PANIC("Unknown path type");
388393
}
389394

390395
return strdup(buffer);
@@ -457,7 +462,7 @@ bool rg_emu_save_state(int slot)
457462
if (!success)
458463
{
459464
printf("%s: Save failed!\n", __func__);
460-
rg_gui_alert("Save failed");
465+
rg_gui_alert("Save failed", NULL);
461466
}
462467

463468
free(saveName);
@@ -524,31 +529,6 @@ void rg_system_panic(const char *reason, const char *function, const char *file)
524529
abort();
525530
}
526531

527-
void rg_system_panic_dialog(const char *reason)
528-
{
529-
printf(" *** PREVIOUS PANIC: %s *** \n", reason);
530-
531-
// Clear the trace to avoid a boot loop
532-
panicTrace->magicWord = 0;
533-
534-
rg_audio_deinit();
535-
536-
// In case we panicked from inside a dialog
537-
rg_spi_lock_release(SPI_LOCK_ANY);
538-
539-
// Blue screen of death!
540-
rg_display_clear(C_BLUE);
541-
542-
dialog_choice_t choices[] = {
543-
{0, reason, "", -1, NULL},
544-
{1, "OK", "", 1, NULL},
545-
RG_DIALOG_CHOICE_LAST
546-
};
547-
rg_gui_dialog("The application crashed!", choices, 1);
548-
549-
rg_system_switch_app(RG_APP_LAUNCHER);
550-
}
551-
552532
void rg_system_halt()
553533
{
554534
printf("%s: Halting system!\n", __func__);

components/retro-go/rg_system.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ typedef struct
8686
} runtime_stats_t;
8787

8888
void rg_system_init(int app_id, int sampleRate);
89-
void rg_system_panic_dialog(const char *reason);
9089
void rg_system_panic(const char *reason, const char *function, const char *file) __attribute__((noreturn));
9190
void rg_system_halt() __attribute__((noreturn));
9291
void rg_system_sleep() __attribute__((noreturn));

gnuboy-go/main/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static void netplay_callback(netplay_event_t event, void *arg)
5151

5252
if (netplay && !new_netplay)
5353
{
54-
rg_gui_alert("Connection lost!");
54+
rg_gui_alert("Netplay", "Connection lost!");
5555
}
5656
netplay = new_netplay;
5757
break;

huexpress-go/components/huexpress/engine/pce.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "pce.h"
44
#include "romdb.h"
55

6-
struct host_machine host;
6+
host_machine_t host;
77

88
const char SAVESTATE_HEADER[8] = "PCE_V004";
99

huexpress-go/components/huexpress/engine/pce.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void ShutdownPCE();
2525
int InitPCE(const char *name);
2626
int LoadCard(const char *name);
2727

28-
struct host_machine {
28+
typedef struct {
2929
bool paused;
3030
bool netplay;
3131

@@ -44,9 +44,9 @@ struct host_machine {
4444
struct {
4545
bool splatterhouse;
4646
} hacks;
47-
};
47+
} host_machine_t;
4848

49-
extern struct host_machine host;
49+
extern host_machine_t host;
5050

5151
typedef struct
5252
{

nofrendo-go/main/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static void netplay_callback(netplay_event_t event, void *arg)
5959

6060
if (netplay && !new_netplay)
6161
{
62-
rg_gui_alert("Connection lost!");
62+
rg_gui_alert("Netplay", "Connection lost!");
6363
}
6464
else if (!netplay && new_netplay)
6565
{

retro-go/main/emulators.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ void emulator_show_file_menu(retro_emulator_file_t *file)
319319
emulator_start(file, sel == 0);
320320
}
321321
else if (sel == 2) {
322-
if (rg_gui_confirm("Delete save file?", false) == 1) {
322+
if (rg_gui_confirm("Delete save file?", NULL, false)) {
323323
if (has_save) {
324324
rg_unlink(save_path);
325325
}

retro-go/main/main.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ void retro_loop()
204204
rg_system_switch_app(RG_APP_FACTORY);
205205
}
206206
else if (sel == 2) {
207-
if (rg_gui_confirm("Reset all settings?", false) == 1) {
207+
if (rg_gui_confirm("Reset all settings?", NULL, false)) {
208208
rg_settings_reset();
209209
rg_system_restart();
210210
}
@@ -213,14 +213,13 @@ void retro_loop()
213213
}
214214
else if (last_key == GAMEPAD_KEY_VOLUME) {
215215
dialog_choice_t choices[] = {
216-
{0, "---", "", -1, NULL},
217-
{0, "Color theme", "...", 1, &color_shift_cb},
218-
{0, "Font size ", "...", 1, &font_size_cb},
216+
{0, "---", "", -1, NULL},
217+
{0, "Color theme", "...", 1, &color_shift_cb},
218+
{0, "Font size ", "...", 1, &font_size_cb},
219219
{0, "Empty tabs ", "...", 1, &show_empty_cb},
220220
{0, "Preview ", "...", 1, &show_preview_cb},
221-
{0, " Delay", "...", 1, &show_preview_speed_cb},
222-
{0, "---", "", -1, NULL},
223-
{0, "Startup app", "...", 1, &startup_app_cb},
221+
{0, " - Delay", "...", 1, &show_preview_speed_cb},
222+
{0, "Startup app", "...", 1, &startup_app_cb},
224223
RG_DIALOG_CHOICE_LAST
225224
};
226225
rg_gui_settings_menu(choices);

smsplusgx-go/main/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static void netplay_callback(netplay_event_t event, void *arg)
5252

5353
if (netplay && !new_netplay)
5454
{
55-
rg_gui_alert("Connection lost!");
55+
rg_gui_alert("Netplay", "Connection lost!");
5656
}
5757
else if (!netplay && new_netplay)
5858
{

0 commit comments

Comments
 (0)