diff --git a/src/pc/djui/djui.c b/src/pc/djui/djui.c index 97d3016e..5f573a64 100644 --- a/src/pc/djui/djui.c +++ b/src/pc/djui/djui.c @@ -24,11 +24,15 @@ static struct DjuiText* sDjuiLuaError = NULL; static u32 sDjuiLuaErrorTimeout = 0; bool gDjuiInMainMenu = true; bool gDjuiDisabled = false; +bool gDjuiShuttingDown = false; static bool sDjuiInited = false; bool sDjuiRendered60fps = false; void djui_shutdown(void) { + gDjuiShuttingDown = true; + djui_panel_shutdown(); + sSavedDisplayListHead = NULL; if (sDjuiPauseOptions) djui_base_destroy(&sDjuiPauseOptions->base); if (sDjuiLuaError) djui_base_destroy(&sDjuiLuaError->base); @@ -49,6 +53,7 @@ void djui_shutdown(void) { djui_fps_display_destroy(); + gDjuiShuttingDown = false; sDjuiInited = false; } diff --git a/src/pc/djui/djui_button.c b/src/pc/djui/djui_button.c index 6288514a..66438366 100644 --- a/src/pc/djui/djui_button.c +++ b/src/pc/djui/djui_button.c @@ -6,30 +6,30 @@ static void djui_button_update_style(struct DjuiBase* base) { struct DjuiTheme* theme = gDjuiThemes[configDjuiTheme]; if (!button->base.enabled) { - struct DjuiColor bc = button->style ? djui_theme_shade_color(theme->interactables.defaultBorderColor) : theme->interactables.defaultBorderColor; - struct DjuiColor rc = button->style ? djui_theme_shade_color(theme->interactables.defaultRectColor) : theme->interactables.defaultRectColor; - + struct DjuiColor bc = djui_theme_shade_color(theme->interactables.defaultBorderColor, button->style ? 0.3f : 0.6f); + struct DjuiColor rc = djui_theme_shade_color(theme->interactables.defaultRectColor, button->style ? 0.3f : 0.6f); + djui_base_set_border_color(base, bc.r, bc.g, bc.b, bc.a); djui_base_set_color(&button->rect->base, rc.r, rc.g, rc.b, rc.a); djui_base_set_location(&button->text->base, 0.0f, 0.0f); } else if (gDjuiCursorDownOn == base) { struct DjuiColor bc = theme->interactables.cursorDownBorderColor; struct DjuiColor rc = theme->interactables.cursorDownRectColor; - + djui_base_set_border_color(base, bc.r, bc.g, bc.b, bc.a); djui_base_set_color(&button->rect->base, rc.r, rc.g, rc.b, rc.a); djui_base_set_location(&button->text->base, 1.0f, 1.0f); } else if (gDjuiHovered == base) { struct DjuiColor bc = theme->interactables.hoveredBorderColor; struct DjuiColor rc = theme->interactables.hoveredRectColor; - + djui_base_set_border_color(base, bc.r, bc.g, bc.b, bc.a); djui_base_set_color(&button->rect->base, rc.r, rc.g, rc.b, rc.a); djui_base_set_location(&button->text->base, -1.0f, -1.0f); } else { - struct DjuiColor bc = button->style ? djui_theme_shade_color(theme->interactables.defaultBorderColor) : theme->interactables.defaultBorderColor; - struct DjuiColor rc = button->style ? djui_theme_shade_color(theme->interactables.defaultRectColor) : theme->interactables.defaultRectColor; - + struct DjuiColor bc = button->style ? djui_theme_shade_color(theme->interactables.defaultBorderColor, 0.6f) : theme->interactables.defaultBorderColor; + struct DjuiColor rc = button->style ? djui_theme_shade_color(theme->interactables.defaultRectColor, 0.6f) : theme->interactables.defaultRectColor; + djui_base_set_border_color(base, bc.r, bc.g, bc.b, bc.a); djui_base_set_color(&button->rect->base, rc.r, rc.g, rc.b, rc.a); djui_base_set_location(&button->text->base, 0.0f, 0.0f); @@ -63,7 +63,7 @@ struct DjuiButton* djui_button_create(struct DjuiBase* parent, const char* messa struct DjuiText* text = djui_text_create(&rect->base, message); struct DjuiColor color = gDjuiThemes[configDjuiTheme]->interactables.textColor; - + djui_base_set_size_type(&text->base, DJUI_SVT_RELATIVE, DJUI_SVT_RELATIVE); djui_base_set_size(&text->base, 1.0f, 1.0f); djui_base_set_color(&text->base, color.r, color.g, color.b, color.a); diff --git a/src/pc/djui/djui_lobby_entry.c b/src/pc/djui/djui_lobby_entry.c index ab638189..f991eefc 100644 --- a/src/pc/djui/djui_lobby_entry.c +++ b/src/pc/djui/djui_lobby_entry.c @@ -10,8 +10,8 @@ static void djui_lobby_entry_update_style(struct DjuiBase* base) { struct DjuiTheme* theme = gDjuiThemes[configDjuiTheme]; if (!entry->base.enabled) { - struct DjuiColor bc = djui_theme_shade_color(theme->interactables.defaultBorderColor); - struct DjuiColor rc = djui_theme_shade_color(theme->interactables.defaultRectColor); + struct DjuiColor bc = djui_theme_shade_color(theme->interactables.defaultBorderColor, 0.3f); + struct DjuiColor rc = djui_theme_shade_color(theme->interactables.defaultRectColor, 0.3f); djui_base_set_border_color(base, bc.r, bc.g, bc.b, bc.a); djui_base_set_color(&entry->base, rc.r, rc.g, rc.b, rc.a); diff --git a/src/pc/djui/djui_paginated.c b/src/pc/djui/djui_paginated.c index 24450f95..cc03f8ca 100644 --- a/src/pc/djui/djui_paginated.c +++ b/src/pc/djui/djui_paginated.c @@ -56,7 +56,6 @@ static void djui_paginated_next(struct DjuiBase* base) { if (paginated->startIndex >= count) { paginated->startIndex -= paginated->showCount; } djui_paginated_update_page_buttons(paginated); - } void djui_paginated_calculate_height(struct DjuiPaginated* paginated) { @@ -169,8 +168,10 @@ struct DjuiPaginated* djui_paginated_create(struct DjuiBase* parent, u32 showCou sPageNumText = djui_text_create(&paginated->base, ""); djui_base_set_color(&sPageNumText->base, 220, 220, 220, 255); djui_base_set_alignment(&sPageNumText->base, DJUI_HALIGN_CENTER, DJUI_VALIGN_BOTTOM); + djui_text_set_alignment(sPageNumText, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP); djui_text_set_drop_shadow(sPageNumText, 64, 64, 64, 100); sPageNumText->base.y.value -= 30; + sPageNumText->base.width.value += 30; sNextButton = djui_button_create(&paginated->base, ">", DJUI_BUTTON_STYLE_NORMAL, djui_paginated_next); djui_base_set_alignment(&sNextButton->base, DJUI_HALIGN_RIGHT, DJUI_VALIGN_BOTTOM); diff --git a/src/pc/djui/djui_panel.c b/src/pc/djui/djui_panel.c index cfc15731..95f31d05 100644 --- a/src/pc/djui/djui_panel.c +++ b/src/pc/djui/djui_panel.c @@ -56,6 +56,7 @@ struct DjuiPanel* djui_panel_add(struct DjuiBase* caller, struct DjuiThreePanel* panel->parent = sPanelList; panel->base = panelBase; panel->defaultElementBase = defaultElementBase; + panel->on_back = threePanel->on_back; panel->on_panel_destroy = NULL; sPanelList = panel; @@ -99,6 +100,13 @@ void djui_panel_back(void) { return; } + // call back hook, return true to cancel back + if (sPanelList->on_back) { + if (sPanelList->on_back(sPanelList->base)) { + return; + } + } + // deselect cursor input djui_cursor_input_controlled_center(NULL); @@ -177,6 +185,7 @@ void djui_panel_update(void) { } } +extern bool gDjuiShuttingDown; void djui_panel_shutdown(void) { static bool sShuttingDown = false; if (sShuttingDown) { return; } @@ -210,10 +219,12 @@ void djui_panel_shutdown(void) { gDjuiPanelMainCreated = false; gDjuiPanelPauseCreated = false; djui_cursor_set_visible(false); - configfile_save(configfile_name()); - if (gDjuiInMainMenu) { - gDjuiInMainMenu = false; - newcam_init_settings(); + if (!gDjuiShuttingDown) { + configfile_save(configfile_name()); + if (gDjuiInMainMenu) { + gDjuiInMainMenu = false; + newcam_init_settings(); + } } sShuttingDown = false; } \ No newline at end of file diff --git a/src/pc/djui/djui_panel.h b/src/pc/djui/djui_panel.h index fa5c22c6..0f01af37 100644 --- a/src/pc/djui/djui_panel.h +++ b/src/pc/djui/djui_panel.h @@ -10,6 +10,7 @@ struct DjuiPanel { struct DjuiPanel* parent; struct DjuiBase* defaultElementBase; bool temporary; + bool (*on_back)(struct DjuiBase*); void (*on_panel_destroy)(struct DjuiBase*); }; diff --git a/src/pc/djui/djui_panel_host_mods.c b/src/pc/djui/djui_panel_host_mods.c index f8fc0e3d..aab07ac4 100644 --- a/src/pc/djui/djui_panel_host_mods.c +++ b/src/pc/djui/djui_panel_host_mods.c @@ -17,7 +17,6 @@ static struct DjuiFlowLayout* sModLayout = NULL; static struct DjuiThreePanel* sDescriptionPanel = NULL; static struct DjuiText* sTooltip = NULL; -static s64 sTag = 0; static bool sWarned = false; void djui_panel_host_mods_create(struct DjuiBase* caller); @@ -115,13 +114,12 @@ static void djui_panel_host_mods_destroy(struct DjuiBase* base) { djui_base_destroy(&sDescriptionPanel->base); sDescriptionPanel = NULL; } + sModLayout = NULL; + sTooltip = NULL; } void djui_panel_host_mods_create(struct DjuiBase* caller) { - if (caller != NULL) { - sTag = caller->tag; - } - bool isRomHacks = sTag; + bool isRomHacks = caller != NULL ? caller->tag != 0 : false; mods_update_selectable(); djui_panel_host_mods_description_create(); diff --git a/src/pc/djui/djui_panel_host_save.c b/src/pc/djui/djui_panel_host_save.c index b2128a4e..79e4ba9d 100644 --- a/src/pc/djui/djui_panel_host_save.c +++ b/src/pc/djui/djui_panel_host_save.c @@ -22,9 +22,9 @@ static void djui_panel_host_save_save_name_change(UNUSED struct DjuiBase* caller } } -static void djui_panel_edit_back(struct DjuiBase* caller) { +static bool djui_panel_edit_back(UNUSED struct DjuiBase* caller) { djui_panel_host_save_update_button(sSaveButtons[sButtonTag], sButtonTag); - djui_panel_menu_back(caller); + return false; } static void djui_panel_edit_create(struct DjuiBase* caller) { @@ -52,9 +52,10 @@ static void djui_panel_edit_create(struct DjuiBase* caller) { djui_interactable_hook_value_change(&sSaveNameInputBox->base, djui_panel_host_save_save_name_change); } - djui_button_create(body, DLANG(MENU, BACK), DJUI_BUTTON_STYLE_BACK, djui_panel_edit_back); + djui_button_create(body, DLANG(MENU, BACK), DJUI_BUTTON_STYLE_BACK, djui_panel_menu_back); } - + + panel->on_back = djui_panel_edit_back; djui_panel_add(caller, panel, NULL); } diff --git a/src/pc/djui/djui_selectionbox.c b/src/pc/djui/djui_selectionbox.c index 0519fc8b..111c658b 100644 --- a/src/pc/djui/djui_selectionbox.c +++ b/src/pc/djui/djui_selectionbox.c @@ -13,8 +13,8 @@ static void djui_selectionbox_update_style(struct DjuiBase* base) { if (!selectionbox->base.enabled) { struct DjuiSelectionbox* selectionbox = (struct DjuiSelectionbox*)base; - struct DjuiColor bc = djui_theme_shade_color(theme->interactables.defaultBorderColor); - struct DjuiColor rc = djui_theme_shade_color(theme->interactables.defaultRectColor); + struct DjuiColor bc = djui_theme_shade_color(theme->interactables.defaultBorderColor, 0.6f); + struct DjuiColor rc = djui_theme_shade_color(theme->interactables.defaultRectColor, 0.6f); struct DjuiColor tc = theme->interactables.textColor; djui_base_set_border_color(&selectionbox->rect->base, bc.r, bc.g, bc.b, bc.a); diff --git a/src/pc/djui/djui_theme.c b/src/pc/djui/djui_theme.c index 636fb01c..ce3fab13 100644 --- a/src/pc/djui/djui_theme.c +++ b/src/pc/djui/djui_theme.c @@ -171,10 +171,10 @@ struct DjuiTheme* gDjuiThemes[] = { &sDjuiThemeMario }; -struct DjuiColor djui_theme_shade_color(struct DjuiColor color) { - color.r *= 0.6f; - color.g *= 0.6f; - color.b *= 0.6f; +struct DjuiColor djui_theme_shade_color(struct DjuiColor color, f32 mult) { + color.r *= mult; + color.g *= mult; + color.b *= mult; return color; } diff --git a/src/pc/djui/djui_theme.h b/src/pc/djui/djui_theme.h index d07a4edb..103d83a6 100644 --- a/src/pc/djui/djui_theme.h +++ b/src/pc/djui/djui_theme.h @@ -43,5 +43,5 @@ struct DjuiTheme { extern struct DjuiTheme* gDjuiThemes[]; -struct DjuiColor djui_theme_shade_color(struct DjuiColor color); +struct DjuiColor djui_theme_shade_color(struct DjuiColor color, f32 mult); void djui_themes_init(void); diff --git a/src/pc/djui/djui_three_panel.h b/src/pc/djui/djui_three_panel.h index 0d12f66e..c00515d5 100644 --- a/src/pc/djui/djui_three_panel.h +++ b/src/pc/djui/djui_three_panel.h @@ -6,6 +6,7 @@ struct DjuiThreePanel { struct DjuiScreenValue minHeaderSize; struct DjuiScreenValue bodySize; struct DjuiScreenValue minFooterSize; + bool (*on_back)(struct DjuiBase*); }; struct DjuiBase* djui_three_panel_get_header(struct DjuiThreePanel* threePanel);