DJUI: Changed quit menu into confirm menu, confirmed save erase

This commit is contained in:
MysterD 2021-07-14 19:14:07 -07:00
parent 28d63b2c87
commit b0453da5e4
8 changed files with 41 additions and 30 deletions

View File

@ -3965,7 +3965,7 @@
<ClCompile Include="..\src\pc\djui\djui_panel_display.c" />
<ClCompile Include="..\src\pc\djui\djui_panel_main.c" />
<ClCompile Include="..\src\pc\djui\djui_panel_options.c" />
<ClCompile Include="..\src\pc\djui\djui_panel_quit.c" />
<ClCompile Include="..\src\pc\djui\djui_panel_confirm.c" />
<ClCompile Include="..\src\pc\djui\djui_panel_sound.c" />
<ClCompile Include="..\src\pc\djui\djui_rect.c" />
<ClCompile Include="..\src\pc\djui\djui_root.c" />
@ -4410,7 +4410,7 @@
<ClInclude Include="..\src\pc\djui\djui_panel_display.h" />
<ClInclude Include="..\src\pc\djui\djui_panel_main.h" />
<ClInclude Include="..\src\pc\djui\djui_panel_options.h" />
<ClInclude Include="..\src\pc\djui\djui_panel_quit.h" />
<ClInclude Include="..\src\pc\djui\djui_panel_confirm.h" />
<ClInclude Include="..\src\pc\djui\djui_panel_sound.h" />
<ClInclude Include="..\src\pc\djui\djui_rect.h" />
<ClInclude Include="..\src\pc\djui\djui_root.h" />

View File

@ -15183,9 +15183,6 @@
<ClCompile Include="..\src\pc\djui\djui_panel_main.c">
<Filter>Source Files\src\pc\djui\panel</Filter>
</ClCompile>
<ClCompile Include="..\src\pc\djui\djui_panel_quit.c">
<Filter>Source Files\src\pc\djui\panel</Filter>
</ClCompile>
<ClCompile Include="..\src\pc\utils\misc.c">
<Filter>Source Files\src\pc\utils</Filter>
</ClCompile>
@ -15258,6 +15255,9 @@
<ClCompile Include="..\src\pc\djui\djui_panel_host_save.c">
<Filter>Source Files\src\pc\djui\panel</Filter>
</ClCompile>
<ClCompile Include="..\src\pc\djui\djui_panel_confirm.c">
<Filter>Source Files\src\pc\djui\panel</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\actors\common0.h">
@ -16261,9 +16261,6 @@
<ClInclude Include="..\src\pc\djui\djui_panel_main.h">
<Filter>Source Files\src\pc\djui\panel</Filter>
</ClInclude>
<ClInclude Include="..\src\pc\djui\djui_panel_quit.h">
<Filter>Source Files\src\pc\djui\panel</Filter>
</ClInclude>
<ClInclude Include="..\src\pc\utils\misc.h">
<Filter>Source Files\src\pc\utils</Filter>
</ClInclude>
@ -16336,5 +16333,8 @@
<ClInclude Include="..\src\pc\djui\djui_panel_host_save.h">
<Filter>Source Files\src\pc\djui\panel</Filter>
</ClInclude>
<ClInclude Include="..\src\pc\djui\djui_panel_confirm.h">
<Filter>Source Files\src\pc\djui\panel</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -43,7 +43,7 @@
#include "djui_panel_controls.h"
#include "djui_panel_display.h"
#include "djui_panel_sound.h"
#include "djui_panel_quit.h"
#include "djui_panel_confirm.h"
extern struct DjuiRoot* gDjuiRoot;

View File

@ -1,22 +1,14 @@
#include "djui.h"
#include "src/pc/utils/misc.h"
static void djui_panel_quit_yes(struct DjuiBase* base) {
exit(0);
}
static void djui_panel_quit_no(struct DjuiBase* base) {
djui_panel_back();
}
void djui_panel_quit_create(struct DjuiBase* caller) {
void djui_panel_confirm_create(struct DjuiBase* caller, char* title, char* message, void (*on_yes_click)(struct DjuiBase*)) {
f32 bodyHeight = 64 * 2 + 16 * 1;
struct DjuiBase* defaultBase = NULL;
struct DjuiThreePanel* panel = djui_panel_menu_create(bodyHeight, "\\#ff0800\\Q\\#1be700\\U\\#00b3ff\\I\\#ffef00\\T");
struct DjuiThreePanel* panel = djui_panel_menu_create(bodyHeight, title);
struct DjuiFlowLayout* body = (struct DjuiFlowLayout*)djui_three_panel_get_body(panel);
{
struct DjuiText* text = djui_text_create(&body->base, "Are you sure you want to quit?");
struct DjuiText* text = djui_text_create(&body->base, message);
djui_base_set_size_type(&text->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&text->base, 1.0f, 64);
djui_base_set_color(&text->base, 200, 200, 200, 255);
@ -31,14 +23,14 @@ void djui_panel_quit_create(struct DjuiBase* caller) {
djui_base_set_size_type(&button1->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button1->base, 0.485f, 64);
djui_base_set_alignment(&button1->base, DJUI_HALIGN_LEFT, DJUI_VALIGN_TOP);
djui_interactable_hook_click(&button1->base, djui_panel_quit_no);
djui_interactable_hook_click(&button1->base, djui_panel_menu_back);
defaultBase = &button1->base;
struct DjuiButton* button2 = djui_button_create(&rect1->base, "Yes");
djui_base_set_size_type(&button2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button2->base, 0.485f, 64);
djui_base_set_alignment(&button2->base, DJUI_HALIGN_RIGHT, DJUI_VALIGN_TOP);
djui_interactable_hook_click(&button2->base, djui_panel_quit_yes);
djui_interactable_hook_click(&button2->base, on_yes_click);
}
}

View File

@ -0,0 +1,5 @@
#pragma once
#include "djui.h"
void djui_panel_confirm_create(struct DjuiBase* caller, char* title, char* message, void (*on_yes_click)(struct DjuiBase*));

View File

@ -18,9 +18,17 @@ static void djui_panel_host_save_button_click(struct DjuiBase* caller) {
djui_panel_menu_back(caller);
}
static void djui_panel_host_save_erase_button_click(struct DjuiBase* caller) {
static void djui_panel_host_save_erase_yes(struct DjuiBase* caller) {
save_file_erase(caller->tag);
djui_panel_host_save_update_button(sSaveButtons[caller->tag], caller->tag);
djui_panel_menu_back(caller);
}
static void djui_panel_host_save_erase(struct DjuiBase* caller) {
djui_panel_confirm_create(caller,
"\\#ff0800\\E\\#1be700\\R\\#00b3ff\\A\\#ffef00\\S\\#ff0800\\E",
"Are you sure you want to erase this save slot?",
djui_panel_host_save_erase_yes);
}
void djui_panel_host_save_create(struct DjuiBase* caller) {
@ -50,7 +58,7 @@ void djui_panel_host_save_create(struct DjuiBase* caller) {
djui_base_set_size_type(&button2->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button2->base, 0.24f, 32);
djui_base_set_alignment(&button2->base, DJUI_HALIGN_RIGHT, DJUI_VALIGN_TOP);
djui_interactable_hook_click(&button2->base, djui_panel_host_save_erase_button_click);
djui_interactable_hook_click(&button2->base, djui_panel_host_save_erase);
}
}
}

View File

@ -3,6 +3,17 @@
bool gDjuiPanelMainCreated = false;
static void djui_panel_main_quit_yes(struct DjuiBase* caller) {
exit(0);
}
static void djui_panel_main_quit(struct DjuiBase* caller) {
djui_panel_confirm_create(caller,
"\\#ff0800\\Q\\#1be700\\U\\#00b3ff\\I\\#ffef00\\T",
"Are you sure you want to quit?",
djui_panel_main_quit_yes);
}
void djui_panel_main_create(struct DjuiBase* caller) {
f32 bodyHeight = 64 * 4 + 16 * 3;
@ -32,7 +43,7 @@ void djui_panel_main_create(struct DjuiBase* caller) {
djui_base_set_size_type(&button4->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&button4->base, 1.0f, 64);
djui_button_set_style(button4, 1);
djui_interactable_hook_click(&button4->base, djui_panel_quit_create);
djui_interactable_hook_click(&button4->base, djui_panel_main_quit);
}
char* version = get_version();

View File

@ -1,5 +0,0 @@
#pragma once
#include "djui.h"
void djui_panel_quit_create(struct DjuiBase* caller);