diff --git a/lang/Czech.ini b/lang/Czech.ini index 0ec2d435e..5de09d308 100644 --- a/lang/Czech.ini +++ b/lang/Czech.ini @@ -166,6 +166,7 @@ DJUI_SCALE = "Stupnice DJUI" DJUI_FONT = "DJUI Font" AUTO = "Automatický" CENTER = "Střed" +GRADIENTS = "Gradienty" FONT_NORMAL = "Normální" FONT_ALIASED = "Hladký" LIGHT_THEME = "Světlo" diff --git a/lang/Dutch.ini b/lang/Dutch.ini index c5d0b92f4..08f8af180 100644 --- a/lang/Dutch.ini +++ b/lang/Dutch.ini @@ -166,6 +166,7 @@ DJUI_SCALE = "DJUI Schaal" DJUI_FONT = "DJUI-lettertype" AUTO = "Automatisch" CENTER = "Centreren" +GRADIENTS = "Kleurverlopen" FONT_NORMAL = "Normaal" FONT_ALIASED = "Glad" LIGHT_THEME = "Licht" diff --git a/lang/English.ini b/lang/English.ini index 3ade8a708..e9e40c151 100644 --- a/lang/English.ini +++ b/lang/English.ini @@ -166,6 +166,7 @@ DJUI_SCALE = "DJUI Scale" DJUI_FONT = "DJUI Font" AUTO = "Auto" CENTER = "DJUI Center" +GRADIENTS = "DJUI Gradients" FONT_NORMAL = "Normal" FONT_ALIASED = "Aliased" LIGHT_THEME = "Light" diff --git a/lang/French.ini b/lang/French.ini index 3fad36c7c..6c09b6801 100644 --- a/lang/French.ini +++ b/lang/French.ini @@ -166,6 +166,7 @@ DJUI_SCALE = "Échelle DJUI" DJUI_FONT = "Police DJUI" AUTO = "Automatique" CENTER = "Centrer le menu" +GRADIENTS = "Dégradés" FONT_NORMAL = "Normal" FONT_ALIASED = "Lisse" LIGHT_THEME = "Clair" diff --git a/lang/German.ini b/lang/German.ini index f56199f43..e543ee769 100644 --- a/lang/German.ini +++ b/lang/German.ini @@ -166,6 +166,7 @@ DJUI_SCALE = "DJUI-Skala" DJUI_FONT = "DJUI-Schriftart" AUTO = "Automatisch" CENTER = "Zentrieren" +GRADIENTS = "Farbverläufe" FONT_NORMAL = "Normal" FONT_ALIASED = "Glatt" LIGHT_THEME = "Litch" diff --git a/lang/Italian.ini b/lang/Italian.ini index a1402fef7..029a2bb54 100644 --- a/lang/Italian.ini +++ b/lang/Italian.ini @@ -164,6 +164,7 @@ DJUI_SCALE = "Scala DJUI" DJUI_FONT = "Font DJUI" AUTO = "Automatico" CENTER = "Centrare" +GRADIENTS = "Gradienti" FONT_NORMAL = "Normale" FONT_ALIASED = "Liscio" LIGHT_THEME = "Luce" diff --git a/lang/Japanese.ini b/lang/Japanese.ini index 94d8269f3..ace8d3888 100644 --- a/lang/Japanese.ini +++ b/lang/Japanese.ini @@ -166,6 +166,7 @@ DJUI_SCALE = "DJUIのサイズ" DJUI_FONT = "DJUIのフォント" AUTO = "自動" CENTER = "中心にDJUIを表示" +GRADIENTS = "グラデーション" FONT_NORMAL = "普通" FONT_ALIASED = "エイリアス" LIGHT_THEME = "ライト" diff --git a/lang/Polish.ini b/lang/Polish.ini index 59a90b1ff..4f181ff66 100644 --- a/lang/Polish.ini +++ b/lang/Polish.ini @@ -166,6 +166,7 @@ DJUI_SCALE = "Skala DJUI" DJUI_FONT = "Czcionka DJUI" AUTO = "Automatyczna" CENTER = "Wyśrodkowane" +GRADIENTS = "Gradienty" FONT_NORMAL = "Normalna" FONT_ALIASED = "Wygładzona" LIGHT_THEME = "Jasny" diff --git a/lang/Portuguese.ini b/lang/Portuguese.ini index 8ab289b31..5052fe77f 100644 --- a/lang/Portuguese.ini +++ b/lang/Portuguese.ini @@ -166,6 +166,7 @@ DJUI_SCALE = "Tamanho da DJUI" DJUI_FONT = "Fonte da DJUI" AUTO = "Automático" CENTER = "Centralizar" +GRADIENTS = "Gradientes" FONT_NORMAL = "Normal" FONT_ALIASED = "Suave" LIGHT_THEME = "Claro" diff --git a/lang/Russian.ini b/lang/Russian.ini index 3766988f6..3ebe88253 100644 --- a/lang/Russian.ini +++ b/lang/Russian.ini @@ -165,6 +165,7 @@ DJUI_SCALE = "Шкала DJUI" DJUI_FONT = "Шрифт DJUI" AUTO = "Автоматический" CENTER = "Центр" +GRADIENTS = "Градиенты" FONT_NORMAL = "Обычный" FONT_ALIASED = "Гладкий" LIGHT_THEME = "Свет" diff --git a/lang/Spanish.ini b/lang/Spanish.ini index 17f1e7994..562d90d94 100644 --- a/lang/Spanish.ini +++ b/lang/Spanish.ini @@ -166,6 +166,7 @@ DJUI_SCALE = "Tamaño de DJUI" DJUI_FONT = "Fuente DJUI" AUTO = "Automático" CENTER = "Centrar" +GRADIENTS = "Gradientes" FONT_NORMAL = "Normal" FONT_ALIASED = "Alias" LIGHT_THEME = "Claro" diff --git a/src/pc/configfile.c b/src/pc/configfile.c index d4f334ada..5387f2aeb 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -199,6 +199,7 @@ bool configDjuiThemeCenter = false; #else bool configDjuiThemeCenter = true; #endif +bool configDjuiThemeGradients = true; unsigned int configDjuiThemeFont = FONT_NORMAL; unsigned int configDjuiScale = 0; // other @@ -344,6 +345,7 @@ static const struct ConfigOption options[] = { // DJUI settings {.name = "djui_theme", .type = CONFIG_TYPE_UINT, .uintValue = &configDjuiTheme}, {.name = "djui_theme_center", .type = CONFIG_TYPE_BOOL, .boolValue = &configDjuiThemeCenter}, + {.name = "djui_theme_gradients", .type = CONFIG_TYPE_BOOL, .boolValue = &configDjuiThemeGradients}, {.name = "djui_theme_font", .type = CONFIG_TYPE_UINT, .uintValue = &configDjuiThemeFont}, {.name = "djui_scale", .type = CONFIG_TYPE_UINT, .uintValue = &configDjuiScale}, // other diff --git a/src/pc/configfile.h b/src/pc/configfile.h index ba5335eba..c9a43fb7d 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -145,6 +145,7 @@ extern char configDestId[MAX_CONFIG_STRING]; // DJUI settings extern unsigned int configDjuiTheme; extern bool configDjuiThemeCenter; +extern bool configDjuiThemeGradients; extern unsigned int configDjuiThemeFont; extern unsigned int configDjuiScale; // other diff --git a/src/pc/djui/djui.c b/src/pc/djui/djui.c index 88fcde443..7a88a8b58 100644 --- a/src/pc/djui/djui.c +++ b/src/pc/djui/djui.c @@ -27,6 +27,7 @@ bool gDjuiInMainMenu = true; bool gDjuiInPlayerMenu = false; bool gDjuiDisabled = false; bool gDjuiShuttingDown = false; +bool gDjuiChangingTheme = false; static bool sDjuiInited = false; static struct DjuiRoot* sDjuiRootBehind = NULL; diff --git a/src/pc/djui/djui_base.c b/src/pc/djui/djui_base.c index 9438985a8..e4d85a506 100644 --- a/src/pc/djui/djui_base.c +++ b/src/pc/djui/djui_base.c @@ -82,6 +82,10 @@ void djui_base_set_alignment(struct DjuiBase* base, enum DjuiHAlign hAlign, enum base->vAlign = vAlign; } +void djui_base_set_gradient(struct DjuiBase* base, bool gradient) { + base->gradient = gradient; +} + ///////////// // utility // ///////////// @@ -441,6 +445,7 @@ void djui_base_init(struct DjuiBase* parent, struct DjuiBase* base, bool (*rende djui_base_set_enabled(base, true); djui_base_set_size(base, 64, 64); djui_base_set_color(base, 255, 255, 255, 255); + djui_base_set_gradient(base, configDjuiThemeGradients); base->get_cursor_hover_location = djui_base_get_cursor_hover_location; base->render = render; base->destroy = destroy; diff --git a/src/pc/djui/djui_base.h b/src/pc/djui/djui_base.h index 7be447c1a..60174824e 100644 --- a/src/pc/djui/djui_base.h +++ b/src/pc/djui/djui_base.h @@ -41,6 +41,7 @@ struct DjuiBase { struct DjuiInteractable* interactable; bool addChildrenToHead; bool abandonAfterChildRenderFail; + bool gradient; s64 tag; bool bTag; void (*get_cursor_hover_location)(struct DjuiBase*, f32* x, f32* y); @@ -63,6 +64,7 @@ void djui_base_set_border_color(struct DjuiBase* base, u8 r, u8 g, u8 b, u8 a); void djui_base_set_padding(struct DjuiBase* base, f32 top, f32 right, f32 bottom, f32 left); void djui_base_set_padding_type(struct DjuiBase* base, enum DjuiScreenValueType topType, enum DjuiScreenValueType rightType, enum DjuiScreenValueType bottomType, enum DjuiScreenValueType leftType); void djui_base_set_alignment(struct DjuiBase* base, enum DjuiHAlign hAlign, enum DjuiVAlign vAlign); +void djui_base_set_gradient(struct DjuiBase* base, bool gradient); void djui_base_compute(struct DjuiBase* base); void djui_base_compute_tree(struct DjuiBase* base); diff --git a/src/pc/djui/djui_gfx.c b/src/pc/djui/djui_gfx.c index 42c2c5b73..06f0c787b 100644 --- a/src/pc/djui/djui_gfx.c +++ b/src/pc/djui/djui_gfx.c @@ -27,6 +27,13 @@ void djui_gfx_displaylist_end(void) { gSPDisplayList(gDisplayListHead++, dl_djui_display_list_end); } +static const Vtx vertex_djui_menu_rect[] = { + {{{ 0, -1, 0 }, 0, { 0, 0 }, { 0x96, 0x96, 0x96, 0xff }}}, + {{{ 1, -1, 0 }, 0, { 0, 0 }, { 0x96, 0x96, 0x96, 0xff }}}, + {{{ 1, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, + {{{ 0, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, +}; + static const Vtx vertex_djui_simple_rect[] = { {{{ 0, -1, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, {{{ 1, -1, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, @@ -34,6 +41,16 @@ static const Vtx vertex_djui_simple_rect[] = { {{{ 0, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, }; +const Gfx dl_djui_menu_rect[] = { + gsDPPipeSync(), + gsSPClearGeometryMode(G_LIGHTING), + gsDPSetCombineMode(G_CC_FADE, G_CC_FADE), + gsDPSetRenderMode(G_RM_XLU_SURF, G_RM_XLU_SURF2), + gsSPVertexNonGlobal(vertex_djui_menu_rect, 4, 0), + gsSP2Triangles(0, 1, 2, 0x0, 0, 2, 3, 0x0), + gsSPEndDisplayList(), +}; + const Gfx dl_djui_simple_rect[] = { gsDPPipeSync(), gsSPClearGeometryMode(G_LIGHTING), @@ -134,8 +151,8 @@ void djui_gfx_render_texture_tile(const u8* texture, u32 w, u32 h, u32 bitSize, // I don't know why adding 1 to all of the UVs seems to fix rendering, but it does... // this should be tested carefully. it definitely fixes some stuff, but what does it break? - f32 offsetX = font ? -1024.0f / (f32)w : 1; - f32 offsetY = font ? -1024.0f / (f32)h : 1; + f32 offsetX = (font ? -1024.0f / (f32)w : 0) + 1; + f32 offsetY = (font ? -1024.0f / (f32)h : 0) + 1; vtx[0] = (Vtx) {{{ 0, -1, 0 }, 0, { ( tileX * 2048.0f) / (f32)w + offsetX, ((tileY + tileH) * 2048.0f) / (f32)h + offsetY }, { 0xff, 0xff, 0xff, 0xff }}}; vtx[2] = (Vtx) {{{ 1 * aspect, 0, 0 }, 0, { ((tileX + tileW) * 2048.0f) / (f32)w + offsetX, ( tileY * 2048.0f) / (f32)h + offsetY }, { 0xff, 0xff, 0xff, 0xff }}}; vtx[1] = (Vtx) {{{ 1 * aspect, -1, 0 }, 0, { ((tileX + tileW) * 2048.0f) / (f32)w + offsetX, ((tileY + tileH) * 2048.0f) / (f32)h + offsetY }, { 0xff, 0xff, 0xff, 0xff }}}; diff --git a/src/pc/djui/djui_gfx.h b/src/pc/djui/djui_gfx.h index 6739e1467..a49227983 100644 --- a/src/pc/djui/djui_gfx.h +++ b/src/pc/djui/djui_gfx.h @@ -5,6 +5,7 @@ #define DJUI_MTX_PUSH 1 #define DJUI_MTX_NOPUSH 2 +extern const Gfx dl_djui_menu_rect[]; extern const Gfx dl_djui_simple_rect[]; extern const Gfx dl_djui_img_begin[]; extern const Gfx dl_djui_img_end[]; diff --git a/src/pc/djui/djui_inputbox.c b/src/pc/djui/djui_inputbox.c index efb1082e8..878a3a94d 100644 --- a/src/pc/djui/djui_inputbox.c +++ b/src/pc/djui/djui_inputbox.c @@ -638,6 +638,7 @@ struct DjuiInputbox* djui_inputbox_create(struct DjuiBase* parent, u16 bufferSiz djui_base_init(parent, base, djui_inputbox_render, djui_inputbox_destroy); djui_base_set_size(base, 200, 32); djui_base_set_border_width(base, 2); + djui_base_set_gradient(base, false); djui_inputbox_set_text_color(inputbox, 0, 0, 0, 255); djui_interactable_create(base, djui_inputbox_update_style); djui_interactable_hook_cursor_down(base, djui_inputbox_on_cursor_down_begin, djui_inputbox_on_cursor_down, NULL); diff --git a/src/pc/djui/djui_panel.c b/src/pc/djui/djui_panel.c index 452a12b3a..b25a251d2 100644 --- a/src/pc/djui/djui_panel.c +++ b/src/pc/djui/djui_panel.c @@ -191,6 +191,7 @@ void djui_panel_update(void) { } extern bool gDjuiShuttingDown; +extern bool gDjuiChangingTheme; void djui_panel_shutdown(void) { static bool sShuttingDown = false; if (sShuttingDown) { return; } @@ -224,7 +225,7 @@ void djui_panel_shutdown(void) { gDjuiPanelMainCreated = false; gDjuiPanelPauseCreated = false; djui_cursor_set_visible(false); - if (!gDjuiShuttingDown) { + if (!gDjuiShuttingDown && !gDjuiChangingTheme) { configfile_save(configfile_name()); if (gDjuiInMainMenu) { gDjuiInMainMenu = false; diff --git a/src/pc/djui/djui_panel_menu_options.c b/src/pc/djui/djui_panel_menu_options.c index bddf4193a..d85aa1d43 100644 --- a/src/pc/djui/djui_panel_menu_options.c +++ b/src/pc/djui/djui_panel_menu_options.c @@ -37,6 +37,27 @@ struct MainMenuSounds gMainMenuSounds[] = { { "Stage Music", STAGE_MUSIC }, }; +static char* sLevelChoices[18] = { + "CG", + "BOB", + "WF", + "WMOTR", + "JRB", + "SSL", + "TTM", + "SL", + "BBH", + "LLL", + "THI", + "HMC", + "CCM", + "RR", + "BITDW", + "PSS", + "TTC", + "WDW" +}; + void djui_panel_main_menu_create(struct DjuiBase* caller); static void djui_panel_level_menu(UNUSED struct DjuiBase* caller) { @@ -65,7 +86,9 @@ static void djui_panel_staff_roll(UNUSED struct DjuiBase* caller) { djui_panel_main_menu_create(NULL); } +extern bool gDjuiChangingTheme; static void djui_panel_menu_options_djui_setting_change(UNUSED struct DjuiBase* caller) { + gDjuiChangingTheme = true; if (gDjuiInMainMenu) { djui_panel_shutdown(); gDjuiInMainMenu = true; @@ -87,6 +110,7 @@ static void djui_panel_menu_options_djui_setting_change(UNUSED struct DjuiBase* djui_text_set_font(gDjuiPauseOptions, gDjuiFonts[configDjuiThemeFont == 0 ? FONT_NORMAL : FONT_ALIASED]); djui_text_set_text(gDjuiPauseOptions, DLANG(MISC, R_BUTTON)); } + gDjuiChangingTheme = false; smlua_call_event_hooks(HOOK_ON_DJUI_THEME_CHANGED); } @@ -99,6 +123,7 @@ void djui_panel_main_menu_create(struct DjuiBase* caller) { { djui_checkbox_create(body, DLANG(DJUI_THEMES, CENTER), &configDjuiThemeCenter, djui_panel_menu_options_djui_setting_change); + djui_checkbox_create(body, DLANG(DJUI_THEMES, GRADIENTS), &configDjuiThemeGradients, djui_panel_menu_options_djui_setting_change); char* themeChoices[DJUI_THEME_MAX]; for (int i = 0; i < DJUI_THEME_MAX; i++) { @@ -113,28 +138,6 @@ void djui_panel_main_menu_create(struct DjuiBase* caller) { djui_selectionbox_create(body, DLANG(DJUI_THEMES, DJUI_FONT), djuiFontChoices, 2, &configDjuiThemeFont, djui_panel_menu_options_djui_setting_change); if (gDjuiInMainMenu) { - // get level choices - char* levelChoices[18] = { - "CG", - "BOB", - "WF", - "WMOTR", - "JRB", - "SSL", - "TTM", - "SL", - "BBH", - "LLL", - "THI", - "HMC", - "CCM", - "RR", - "BITDW", - "PSS", - "TTC", - "WDW" - }; - // copy sound choices from gMainMenuSounds int numSounds = sizeof(gMainMenuSounds) / sizeof(gMainMenuSounds[0]); // if stage roll is on, we shouldn't be allowed to use Stage Music, so remove the entry @@ -148,7 +151,7 @@ void djui_panel_main_menu_create(struct DjuiBase* caller) { soundChoices[i] = gMainMenuSounds[i].name; } - struct DjuiSelectionbox* selectionbox1 = djui_selectionbox_create(body, DLANG(MENU_OPTIONS, LEVEL), levelChoices, 18, &configMenuLevel, NULL); + struct DjuiSelectionbox* selectionbox1 = djui_selectionbox_create(body, DLANG(MENU_OPTIONS, LEVEL), sLevelChoices, 18, &configMenuLevel, NULL); djui_base_set_enabled(&selectionbox1->base, !(configMenuRandom || configMenuStaffRoll)); sLevelBox = selectionbox1; djui_selectionbox_create(body, DLANG(MENU_OPTIONS, MUSIC), soundChoices, numSounds, &configMenuSound, NULL); diff --git a/src/pc/djui/djui_panel_player.c b/src/pc/djui/djui_panel_player.c index eac2bd5c2..e4f375757 100644 --- a/src/pc/djui/djui_panel_player.c +++ b/src/pc/djui/djui_panel_player.c @@ -261,12 +261,15 @@ static void djui_panel_player_edit_palette_create(struct DjuiBase* caller) { sSliderR = djui_slider_create(body, DLANG(PLAYER, RED), &sSliderChannels[0], 0, 255, djui_panel_player_edit_palette_red_changed); djui_base_set_color(&sSliderR->rectValue->base, 255, 0, 0, 255); + djui_base_set_gradient(&sSliderR->rectValue->base, false); sSliderR->updateRectValueColor = false; sSliderG = djui_slider_create(body, DLANG(PLAYER, GREEN), &sSliderChannels[1], 0, 255, djui_panel_player_edit_palette_green_changed); djui_base_set_color(&sSliderG->rectValue->base, 0, 255, 0, 255); + djui_base_set_gradient(&sSliderG->rectValue->base, false); sSliderG->updateRectValueColor = false; sSliderB = djui_slider_create(body, DLANG(PLAYER, BLUE), &sSliderChannels[2], 0, 255, djui_panel_player_edit_palette_blue_changed); djui_base_set_color(&sSliderB->rectValue->base, 0, 0, 255, 255); + djui_base_set_gradient(&sSliderB->rectValue->base, false); sSliderB->updateRectValueColor = false; struct DjuiRect* space = djui_rect_create(body); @@ -280,6 +283,7 @@ static void djui_panel_player_edit_palette_create(struct DjuiBase* caller) { struct DjuiRect* rectValue = djui_rect_create(&space->base); djui_base_set_size_type(&rectValue->base, DJUI_SVT_RELATIVE, DJUI_SVT_RELATIVE); djui_base_set_color(&rectValue->base, sSliderChannels[0], sSliderChannels[1], sSliderChannels[2], 255); + djui_base_set_gradient(&rectValue->base, false); sColorRect = rectValue; struct DjuiRect* rect2 = djui_rect_container_create(body, 32); diff --git a/src/pc/djui/djui_rect.c b/src/pc/djui/djui_rect.c index c6fb7f061..97383c65a 100644 --- a/src/pc/djui/djui_rect.c +++ b/src/pc/djui/djui_rect.c @@ -21,7 +21,7 @@ bool djui_rect_render(struct DjuiBase* base) { // render gDPSetEnvColor(gDisplayListHead++, base->color.r, base->color.g, base->color.b, base->color.a); - gSPDisplayList(gDisplayListHead++, dl_djui_simple_rect); + gSPDisplayList(gDisplayListHead++, base->gradient ? dl_djui_menu_rect : dl_djui_simple_rect); gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW); return true; diff --git a/src/pc/djui/djui_theme.h b/src/pc/djui/djui_theme.h index 89bc2089b..ecac05d97 100644 --- a/src/pc/djui/djui_theme.h +++ b/src/pc/djui/djui_theme.h @@ -2,7 +2,7 @@ #include "djui.h" #define DJUI_THEME_CENTERED_WIDTH 1.3f -#define DJUI_THEME_CENTERED_HEIGHT 0.9f +#define DJUI_THEME_CENTERED_HEIGHT 0.921f enum DjuiThemeType { DJUI_THEME_LIGHT,