From e3d57c01cccb4cede4cd0bb62a1065062c9c3c39 Mon Sep 17 00:00:00 2001 From: eros71-dev <16540103+eros71-dev@users.noreply.github.com> Date: Thu, 23 Nov 2023 05:25:33 +0100 Subject: [PATCH 1/5] (WIP) DJUI Scaling setting, moved menu-related options to "menu options" instead of "misc" --- lang/Czech.ini | 1 + lang/Dutch.ini | 1 + lang/English.ini | 1 + lang/French.ini | 1 + lang/German.ini | 1 + lang/Italian.ini | 1 + lang/Polish.ini | 1 + lang/Portuguese.ini | 1 + lang/Russian.ini | 1 + lang/SpanishES.ini | 1 + lang/SpanishUS.ini | 1 + src/pc/configfile.c | 4 +- src/pc/configfile.h | 1 + src/pc/djui/djui_gfx.c | 25 ++++++++---- src/pc/djui/djui_panel_menu_options.c | 59 +++++++++++++++++++++++++++ src/pc/djui/djui_panel_misc.c | 30 +------------- src/pc/pc_main.c | 8 +++- src/pc/pc_main.h | 1 + 18 files changed, 101 insertions(+), 38 deletions(-) diff --git a/lang/Czech.ini b/lang/Czech.ini index 7174d6ca..b73f0aea 100644 --- a/lang/Czech.ini +++ b/lang/Czech.ini @@ -144,6 +144,7 @@ MUST_RESTART = "Musíte restartovat hru pro aplikování změn." DJUI_THEMES = "TÉMATA DJUI" CENTER = "Střed" DJUI_THEME = "Téma DJUI" +DJUI_SCALE = "Stupnice DJUI" CENTER = "Střed" LIGHT_THEME = "Světlo" DARK_THEME = "Tmavý" diff --git a/lang/Dutch.ini b/lang/Dutch.ini index 2f70a446..a998f5ea 100644 --- a/lang/Dutch.ini +++ b/lang/Dutch.ini @@ -144,6 +144,7 @@ MUST_RESTART = "Je moet de game opnieuw opstarten voor sommige veranderingen om DJUI_THEMES = "DJUI THEMA'S" CENTER = "Centreren" DJUI_THEME = "DJUI Thema" +DJUI_SCALE = "DJUI Schaal" CENTER = "Centreren" LIGHT_THEME = "Licht" DARK_THEME = "Donker" diff --git a/lang/English.ini b/lang/English.ini index f1c9ec3d..abc0356c 100644 --- a/lang/English.ini +++ b/lang/English.ini @@ -144,6 +144,7 @@ MUST_RESTART = "Restart the game to apply changes." DJUI_THEMES = "DJUI THEMES" CENTER = "Center" DJUI_THEME = "DJUI Theme" +DJUI_SCALE = "DJUI Scale" CENTER = "Center" LIGHT_THEME = "Light" DARK_THEME = "Dark" diff --git a/lang/French.ini b/lang/French.ini index f75d0f97..665d5352 100644 --- a/lang/French.ini +++ b/lang/French.ini @@ -145,6 +145,7 @@ MUST_RESTART = "Vous devez relancer le jeu pour que certains changements prennen DJUI_THEMES = "THÈMES DJUI" CENTER = "Centrer" DJUI_THEME = "Thème DJUI" +DJUI_SCALE = "Échelle DJUI" CENTER = "Centrer" LIGHT_THEME = "Lumière" DARK_THEME = "Sombre" diff --git a/lang/German.ini b/lang/German.ini index 0e0ec76c..e98332cf 100644 --- a/lang/German.ini +++ b/lang/German.ini @@ -144,6 +144,7 @@ MUST_RESTART = "Um einige Änderungen zu übernehmen, muss das Spiel neugestarte DJUI_THEMES = "DJUI-THEMEN" CENTER = "Zentrieren" DJUI_THEME = "DJUI-Thema" +DJUI_SCALE = "DJUI-Skala" CENTER = "Zentrieren" LIGHT_THEME = "Litch" DARK_THEME = "Dunkel" diff --git a/lang/Italian.ini b/lang/Italian.ini index 7b8c3268..1806ff76 100644 --- a/lang/Italian.ini +++ b/lang/Italian.ini @@ -142,6 +142,7 @@ MUST_RESTART = "You must restart the game for some changes to take effect." DJUI_THEMES = "TEMI DJUI" CENTER = "Centrare" DJUI_THEME = "Tema DJUI" +DJUI_SCALE = "Scala DJUI" CENTER = "Centrare" LIGHT_THEME = "Luce" DARK_THEME = "Scuro" diff --git a/lang/Polish.ini b/lang/Polish.ini index e4b40a2a..7ee8f9d0 100644 --- a/lang/Polish.ini +++ b/lang/Polish.ini @@ -144,6 +144,7 @@ MUST_RESTART = "Musisz zrestartowac gre, aby zmiany zaczely obowiazywac." DJUI_THEMES = "TEMATY DJUI" CENTER = "Środek" DJUI_THEME = "Motyw DJUI" +DJUI_SCALE = "Skala DJUI" CENTER = "Środek" LIGHT_THEME = "Światło" DARK_THEME = "Ciemny" diff --git a/lang/Portuguese.ini b/lang/Portuguese.ini index 1a439a12..511aa3d8 100644 --- a/lang/Portuguese.ini +++ b/lang/Portuguese.ini @@ -144,6 +144,7 @@ MUST_RESTART = "Você precisará reiniciar o jogo para algumas alterações sere DJUI_THEMES = "TEMAS DJUI" CENTER = "Centralizar" DJUI_THEME = "Tema DJUI" +DJUI_SCALE = "Tamanho da DJUI" CENTER = "Centralizar" LIGHT_THEME = "Claro" DARK_THEME = "Escuro" diff --git a/lang/Russian.ini b/lang/Russian.ini index 0d203031..02b25773 100644 --- a/lang/Russian.ini +++ b/lang/Russian.ini @@ -143,6 +143,7 @@ MUST_RESTART = "Перезапустите игру, чтобы изменени DJUI_THEMES = "ТЕМЫ DJUI" CENTER = "Центр" DJUI_THEME = "Темы DJUI" +DJUI_SCALE = "Шкала DJUI" CENTER = "Центр" LIGHT_THEME = "Свет" DARK_THEME = "Темный" diff --git a/lang/SpanishES.ini b/lang/SpanishES.ini index 970d4d28..0a32f80c 100644 --- a/lang/SpanishES.ini +++ b/lang/SpanishES.ini @@ -144,6 +144,7 @@ MUST_RESTART = "Tienes que reiniciar el juego para que algunos cambios surtan ef DJUI_THEMES = "TEMAS de DJUI" CENTER = "Centrar" DJUI_THEME = "Tema de DJUI" +DJUI_SCALE = "Tamaño de DJUI" CENTER = "Centrar" LIGHT_THEME = "Claro" DARK_THEME = "Oscuro" diff --git a/lang/SpanishUS.ini b/lang/SpanishUS.ini index afb434d7..ca3a1865 100644 --- a/lang/SpanishUS.ini +++ b/lang/SpanishUS.ini @@ -144,6 +144,7 @@ MUST_RESTART = "Tienes que reiniciar el juego para que algunos cambios surtan ef DJUI_THEMES = "TEMAS de DJUI" CENTER = "Centrar" DJUI_THEME = "Tema de DJUI" +DJUI_SCALE = "Tamaño de DJUI" CENTER = "Centrar" LIGHT_THEME = "Claro" DARK_THEME = "Oscuro" diff --git a/src/pc/configfile.c b/src/pc/configfile.c index a1fbd4b4..e0b168e2 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -161,6 +161,7 @@ char configDestId[MAX_CONFIG_STRING] = "0"; bool configFadeoutDistantSounds = false; unsigned int configDjuiTheme = DJUI_THEME_DARK; bool configDjuiThemeCenter = true; +unsigned int configDjuiScale = 1; bool configCoopCompatibility = true; static const struct ConfigOption options[] = { @@ -275,7 +276,8 @@ static const struct ConfigOption options[] = { {.name = "coopnet_dest", .type = CONFIG_TYPE_STRING, .stringValue = (char*)&configDestId, .maxStringLength = MAX_CONFIG_STRING}, {.name = "fade_distant_sounds", .type = CONFIG_TYPE_BOOL , .boolValue = &configFadeoutDistantSounds}, {.name = "djui_theme", .type = CONFIG_TYPE_UINT , .uintValue = &configDjuiTheme}, - {.name = "djui_theme_center", .type = CONFIG_TYPE_BOOL , .boolValue = &configDjuiThemeCenter} + {.name = "djui_theme_center", .type = CONFIG_TYPE_BOOL , .boolValue = &configDjuiThemeCenter}, + {.name = "djui_scale", .type = CONFIG_TYPE_UINT , .uintValue = &configDjuiScale} }; // FunctionConfigOption functions diff --git a/src/pc/configfile.h b/src/pc/configfile.h index e4adfd08..dc143a4f 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -118,6 +118,7 @@ extern char configDestId[]; extern bool configFadeoutDistantSounds; extern unsigned int configDjuiTheme; extern bool configDjuiThemeCenter; +extern unsigned int configDjuiScale; extern bool configCoopCompatibility; void enable_queued_mods(); diff --git a/src/pc/djui/djui_gfx.c b/src/pc/djui/djui_gfx.c index 6e7ee313..6200624e 100644 --- a/src/pc/djui/djui_gfx.c +++ b/src/pc/djui/djui_gfx.c @@ -47,13 +47,24 @@ const Gfx dl_djui_simple_rect[] = { f32 djui_gfx_get_scale(void) { u32 windowWidth, windowHeight; wm_api->get_dimensions(&windowWidth, &windowHeight); - if (windowHeight < 768) { - return 0.5f; - } else if (windowHeight < 1440) { - return 1.0f; - } else { - return 2.0f; - } + switch (gDjuiScale) + { + case 0: + return 0.85f; + break; + + case 1: + return 1.0f; + break; + + case 2: + return 1.5f; + break; + + default: + wm_api->get_dimensions(&windowWidth, &windowHeight); + break; + } } ///////////////////////////////////////////// diff --git a/src/pc/djui/djui_panel_menu_options.c b/src/pc/djui/djui_panel_menu_options.c index 5ba39669..79b12fd7 100644 --- a/src/pc/djui/djui_panel_menu_options.c +++ b/src/pc/djui/djui_panel_menu_options.c @@ -1,16 +1,49 @@ #include "djui.h" +#include "djui_theme.h" #include "djui_panel.h" #include "djui_panel_menu.h" +#include "djui_panel_pause.h" #include "src/pc/utils/misc.h" #include "src/pc/configfile.h" #include "src/game/level_update.h" +static struct DjuiText* sRestartText = NULL; + +bool changedScale = false; + static struct DjuiSelectionbox* sLevelBox = NULL; static void djui_panel_random_menu(UNUSED struct DjuiBase* caller) { djui_base_set_enabled(&sLevelBox->base, !configMenuRandom); } +static void djui_panel_misc_djui_theme_change(UNUSED struct DjuiBase* caller) { + // god this is so hacky and terrible - djoslin0, 2023 + if (gDjuiInMainMenu) { + djui_panel_shutdown(); + gDjuiInMainMenu = true; + djui_panel_main_create(NULL); + djui_panel_options_create(NULL); + djui_panel_misc_create(NULL); + } else if (gDjuiPanelPauseCreated) { + djui_panel_shutdown(); + djui_panel_pause_create(NULL); + djui_panel_options_create(NULL); + djui_panel_misc_create(NULL); + } else { + djui_panel_shutdown(); + } + +} + +static void djui_panel_misc_djui_scale_change(UNUSED struct DjuiBase* caller) { + if (changedScale) { + djui_text_set_text(sRestartText, DLANG(DISPLAY, MUST_RESTART)); + } else { + changedScale = true; + } +} + void djui_panel_main_menu_create(struct DjuiBase* caller) { struct DjuiThreePanel* panel = djui_panel_menu_create(DLANG(MENU_OPTIONS, MAIN_MENU)); struct DjuiBase* body = djui_three_panel_get_body(panel); @@ -36,6 +69,9 @@ void djui_panel_main_menu_create(struct DjuiBase* caller) { "TTC", "WDW" }; + + char* djuiScaleChoices[3] = {"x0.85", "x1.0", "x1.5"}; + struct DjuiSelectionbox* selectionbox1 = djui_selectionbox_create(body, DLANG(MENU_OPTIONS, LEVEL), levelChoices, 18, &configMenuLevel, NULL); djui_base_set_enabled(&selectionbox1->base, !configMenuRandom); sLevelBox = selectionbox1; @@ -44,8 +80,31 @@ void djui_panel_main_menu_create(struct DjuiBase* caller) { djui_checkbox_create(body, DLANG(MENU_OPTIONS, RANDOM_STAGE), &configMenuRandom, djui_panel_random_menu); djui_checkbox_create(body, DLANG(MENU_OPTIONS, PLAY_VANILLA_DEMOS), &configMenuDemos, stop_demo); + char* themeChoices[DJUI_THEME_MAX]; + for (int i = 0; i < DJUI_THEME_MAX; i++) { + themeChoices[i] = (char*)gDjuiThemes[i]->name; + } + djui_selectionbox_create(body, DLANG(DJUI_THEMES, DJUI_THEME), themeChoices, DJUI_THEME_MAX, &configDjuiTheme, djui_panel_misc_djui_theme_change); + + djui_checkbox_create(body, DLANG(DJUI_THEMES, CENTER), &configDjuiThemeCenter, djui_panel_misc_djui_theme_change); + + djui_selectionbox_create(body, DLANG(DJUI_THEMES, DJUI_SCALE), djuiScaleChoices, 3, &configDjuiScale, djui_panel_misc_djui_scale_change); djui_button_create(body, DLANG(MENU, BACK), DJUI_BUTTON_STYLE_BACK, djui_panel_menu_back); + + // Must restart text + sRestartText = djui_text_create(body, ""); + djui_text_set_alignment(sRestartText, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP); + djui_base_set_color(&sRestartText->base, 255, 100, 100, 255); + djui_base_set_size_type(&sRestartText->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); + djui_base_set_size(&sRestartText->base, 1.0f, 64); + + // force the restart text to update + if (changedScale) { + djui_text_set_text(sRestartText, DLANG(DISPLAY, MUST_RESTART)); + } else { + djui_text_set_text(sRestartText, ""); + } } djui_panel_add(caller, panel, NULL); diff --git a/src/pc/djui/djui_panel_misc.c b/src/pc/djui/djui_panel_misc.c index 7e493520..7cf07ec9 100644 --- a/src/pc/djui/djui_panel_misc.c +++ b/src/pc/djui/djui_panel_misc.c @@ -1,11 +1,10 @@ #include "djui.h" -#include "djui_theme.h" #include "djui_panel.h" #include "djui_panel_menu.h" #include "djui_panel_menu_options.h" #include "djui_panel_main.h" #include "djui_panel_options.h" -#include "djui_panel_pause.h" +//#include "djui_panel_pause.h" #include "djui_panel_language.h" #include "djui_panel_info.h" #include "pc/utils/misc.h" @@ -25,25 +24,6 @@ static void djui_panel_compatibility_checkbox_on_value_change(UNUSED struct Djui void djui_panel_misc_create(struct DjuiBase* caller); -static void djui_panel_misc_djui_theme_change(UNUSED struct DjuiBase* caller) { - // god this is so hacky and terrible - djoslin0, 2023 - if (gDjuiInMainMenu) { - djui_panel_shutdown(); - gDjuiInMainMenu = true; - djui_panel_main_create(NULL); - djui_panel_options_create(NULL); - djui_panel_misc_create(NULL); - } else if (gDjuiPanelPauseCreated) { - djui_panel_shutdown(); - djui_panel_pause_create(NULL); - djui_panel_options_create(NULL); - djui_panel_misc_create(NULL); - } else { - djui_panel_shutdown(); - } - -} - #ifdef DEVELOPMENT void djui_panel_options_debug_create(struct DjuiBase* caller) { struct DjuiThreePanel* panel = djui_panel_menu_create(DLANG(MISC, DEBUG_TITLE)); @@ -74,14 +54,6 @@ void djui_panel_misc_create(struct DjuiBase* caller) { djui_checkbox_create(body, DLANG(MISC, PAUSE_IN_SINGLEPLAYER), &configSingleplayerPause, NULL); djui_checkbox_create(body, DLANG(MISC, DISABLE_POPUPS), &configDisablePopups, NULL); - char* themeChoices[DJUI_THEME_MAX]; - for (int i = 0; i < DJUI_THEME_MAX; i++) { - themeChoices[i] = (char*)gDjuiThemes[i]->name; - } - djui_selectionbox_create(body, DLANG(DJUI_THEMES, DJUI_THEME), themeChoices, DJUI_THEME_MAX, &configDjuiTheme, djui_panel_misc_djui_theme_change); - - djui_checkbox_create(body, DLANG(DJUI_THEMES, CENTER), &configDjuiThemeCenter, djui_panel_misc_djui_theme_change); - djui_checkbox_create(body, DLANG(MISC, COOP_COMPATIBILITY), &configCoopCompatibility, djui_panel_compatibility_checkbox_on_value_change); djui_button_create(body, DLANG(MISC, LANGUAGE), DJUI_BUTTON_STYLE_NORMAL, djui_panel_language_create); diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index ce67cfd0..13c33521 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -73,6 +73,7 @@ u8 gRenderingInterpolated = 0; f32 gRenderingDelta = 0; f64 gGameSpeed = 1.0f; // TODO: should probably remove +u32 gDjuiScale = 1; //0 = 0.85, 1 = 1.0, 2 = 1.5 #define FRAMERATE 30 static const f64 sFrameTime = (1.0 / ((double)FRAMERATE)); @@ -262,7 +263,12 @@ void game_exit(void) { exit(0); } -void* main_game_init(UNUSED void* arg) { +void* main_game_init(UNUSED void* arg) { + if (gDjuiScale != 0 || gDjuiScale != 1 || gDjuiScale != 2) { + gDjuiScale = 1; + configDjuiScale = 1; + } + const char *gamedir = gCLIOpts.GameDir[0] ? gCLIOpts.GameDir : FS_BASEDIR; const char *userpath = gCLIOpts.SavePath[0] ? gCLIOpts.SavePath : sys_user_path(); fs_init(sys_ropaths, gamedir, userpath); diff --git a/src/pc/pc_main.h b/src/pc/pc_main.h index 94acdd89..12b4bced 100644 --- a/src/pc/pc_main.h +++ b/src/pc/pc_main.h @@ -16,6 +16,7 @@ extern "C" { #include "gfx/gfx_dummy.h" extern bool gCoopCompatibility; +extern u32 gDjuiScale; #if defined(WAPI_SDL1) || defined(WAPI_SDL2) # define WAPI gfx_sdl From 839d040cf9968220cf716b5722238572def4ddc0 Mon Sep 17 00:00:00 2001 From: eros71-dev <16540103+eros71-dev@users.noreply.github.com> Date: Fri, 24 Nov 2023 20:26:34 +0100 Subject: [PATCH 2/5] Review fixes --- src/pc/djui/djui_gfx.c | 151 +++++++++++++++--------- src/pc/djui/djui_panel_menu_options.c | 34 +----- src/pc/pc_main.c | 8 +- src/pc/pc_main.h | 1 - tools/ido5.3_compiler/usr/lib/libc.so.1 | Bin 1483100 -> 1483097 bytes 5 files changed, 98 insertions(+), 96 deletions(-) diff --git a/src/pc/djui/djui_gfx.c b/src/pc/djui/djui_gfx.c index 6200624e..1ba05dbd 100644 --- a/src/pc/djui/djui_gfx.c +++ b/src/pc/djui/djui_gfx.c @@ -28,10 +28,10 @@ void djui_gfx_displaylist_end(void) { } 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 }}}, - {{{ 1, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, - {{{ 0, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, + { { { 0, -1, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff } } }, + { { { 1, -1, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff } } }, + { { { 1, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff } } }, + { { { 0, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff } } }, }; const Gfx dl_djui_simple_rect[] = { @@ -40,39 +40,34 @@ const Gfx dl_djui_simple_rect[] = { gsDPSetCombineMode(G_CC_FADE, G_CC_FADE), gsDPSetRenderMode(G_RM_XLU_SURF, G_RM_XLU_SURF2), gsSPVertexNonGlobal(vertex_djui_simple_rect, 4, 0), - gsSP2Triangles(0, 1, 2, 0x0, 0, 2, 3, 0x0), + gsSP2Triangles(0, 1, 2, 0x0, 0, 2, 3, 0x0), gsSPEndDisplayList(), }; f32 djui_gfx_get_scale(void) { u32 windowWidth, windowHeight; wm_api->get_dimensions(&windowWidth, &windowHeight); - switch (gDjuiScale) - { + switch (configDjuiScale) { case 0: return 0.85f; - break; case 1: return 1.0f; - break; case 2: return 1.5f; - break; - + default: - wm_api->get_dimensions(&windowWidth, &windowHeight); - break; - } + return 1.0f; + } } ///////////////////////////////////////////// static const Vtx vertex_djui_image[] = { - {{{ 0, -1, 0 }, 0, { 0, 2048 }, { 0xff, 0xff, 0xff, 0xff }}}, - {{{ 1, -1, 0 }, 0, { 2048, 2048 }, { 0xff, 0xff, 0xff, 0xff }}}, - {{{ 1, 0, 0 }, 0, { 2048, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, - {{{ 0, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, + { { { 0, -1, 0 }, 0, { 0, 2048 }, { 0xff, 0xff, 0xff, 0xff } } }, + { { { 1, -1, 0 }, 0, { 2048, 2048 }, { 0xff, 0xff, 0xff, 0xff } } }, + { { { 1, 0, 0 }, 0, { 2048, 0 }, { 0xff, 0xff, 0xff, 0xff } } }, + { { { 0, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff } } }, }; const Gfx dl_djui_image[] = { @@ -81,11 +76,12 @@ const Gfx dl_djui_image[] = { gsDPSetCombineMode(G_CC_FADEA, G_CC_FADEA), gsDPSetRenderMode(G_RM_XLU_SURF, G_RM_XLU_SURF2), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), - gsDPLoadTextureBlock(NULL, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 64, 0, G_TX_CLAMP, G_TX_CLAMP, 0, 0, 0, 0), + gsDPLoadTextureBlock(NULL, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 64, 0, G_TX_CLAMP, G_TX_CLAMP, 0, 0, 0, + 0), gsSPExecuteDjui(G_TEXOVERRIDE_DJUI), gsSPVertexNonGlobal(vertex_djui_image, 4, 0), // gsSPExecuteDjui(G_TEXCLIP_DJUI), - gsSP2Triangles(0, 1, 2, 0x0, 0, 2, 3, 0x0), + gsSP2Triangles(0, 1, 2, 0x0, 0, 2, 3, 0x0), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF), gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), gsSPEndDisplayList(), @@ -93,27 +89,40 @@ const Gfx dl_djui_image[] = { static u8 djui_gfx_power_of_two(u32 value) { switch (value) { - case 2: return 1; - case 4: return 2; - case 8: return 3; - case 16: return 4; - case 32: return 5; - case 64: return 6; - case 128: return 7; - case 256: return 8; - case 512: return 9; - case 1024: return 10; - default: return 11; + case 2: + return 1; + case 4: + return 2; + case 8: + return 3; + case 16: + return 4; + case 32: + return 5; + case 64: + return 6; + case 128: + return 7; + case 256: + return 8; + case 512: + return 9; + case 1024: + return 10; + default: + return 11; } } -void djui_gfx_render_texture(const u8* texture, u32 w, u32 h, u32 bitSize, bool filter) { +void djui_gfx_render_texture(const u8 *texture, u32 w, u32 h, u32 bitSize, bool filter) { gDPSetTextureFilter(gDisplayListHead++, filter ? G_TF_BILERP : G_TF_POINT); - gDPSetTextureOverrideDjui(gDisplayListHead++, texture, djui_gfx_power_of_two(w), djui_gfx_power_of_two(h), bitSize); + gDPSetTextureOverrideDjui(gDisplayListHead++, texture, djui_gfx_power_of_two(w), + djui_gfx_power_of_two(h), bitSize); gSPDisplayList(gDisplayListHead++, dl_djui_image); } -void djui_gfx_render_texture_tile(const u8* texture, u32 w, u32 h, u32 bitSize, u32 tileX, u32 tileY, u32 tileW, u32 tileH, bool filter) { +void djui_gfx_render_texture_tile(const u8 *texture, u32 w, u32 h, u32 bitSize, u32 tileX, u32 tileY, + u32 tileW, u32 tileH, bool filter) { if (!gDisplayListHead) { LOG_ERROR("Retrieved a null displaylist head"); return; @@ -130,12 +139,24 @@ void djui_gfx_render_texture_tile(const u8* texture, u32 w, u32 h, u32 bitSize, return; } - f32 aspect = tileH ? ((f32)tileW / (f32)tileH) : 1; + f32 aspect = tileH ? ((f32) tileW / (f32) tileH) : 1; // I don't know why adding 1 to all of the UVs seems to fix rendering, but it does... - vtx[0] = (Vtx) {{{ 0, -1, 0 }, 0, { ( tileX * 2048.0f) / (f32)w, ((tileY + tileH) * 2048.0f) / (f32)h }, { 0xff, 0xff, 0xff, 0xff }}}; - vtx[1] = (Vtx) {{{ 1 * aspect, -1, 0 }, 0, { ((tileX + tileW) * 2048.0f) / (f32)w, ((tileY + tileH) * 2048.0f) / (f32)h }, { 0xff, 0xff, 0xff, 0xff }}}; - vtx[2] = (Vtx) {{{ 1 * aspect, 0, 0 }, 0, { ((tileX + tileW) * 2048.0f) / (f32)w, ( tileY * 2048.0f) / (f32)h }, { 0xff, 0xff, 0xff, 0xff }}}; - vtx[3] = (Vtx) {{{ 0, 0, 0 }, 0, { ( tileX * 2048.0f) / (f32)w, ( tileY * 2048.0f) / (f32)h }, { 0xff, 0xff, 0xff, 0xff }}}; + vtx[0] = (Vtx){ { { 0, -1, 0 }, + 0, + { (tileX * 2048.0f) / (f32) w, ((tileY + tileH) * 2048.0f) / (f32) h }, + { 0xff, 0xff, 0xff, 0xff } } }; + vtx[1] = (Vtx){ { { 1 * aspect, -1, 0 }, + 0, + { ((tileX + tileW) * 2048.0f) / (f32) w, ((tileY + tileH) * 2048.0f) / (f32) h }, + { 0xff, 0xff, 0xff, 0xff } } }; + vtx[2] = (Vtx){ { { 1 * aspect, 0, 0 }, + 0, + { ((tileX + tileW) * 2048.0f) / (f32) w, (tileY * 2048.0f) / (f32) h }, + { 0xff, 0xff, 0xff, 0xff } } }; + vtx[3] = (Vtx){ { { 0, 0, 0 }, + 0, + { (tileX * 2048.0f) / (f32) w, (tileY * 2048.0f) / (f32) h }, + { 0xff, 0xff, 0xff, 0xff } } }; gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); gDPSetCombineMode(gDisplayListHead++, G_CC_FADEA, G_CC_FADEA); @@ -144,14 +165,16 @@ void djui_gfx_render_texture_tile(const u8* texture, u32 w, u32 h, u32 bitSize, gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); - gDPSetTextureOverrideDjui(gDisplayListHead++, texture, djui_gfx_power_of_two(w), djui_gfx_power_of_two(h), bitSize); - gDPLoadTextureBlockWithoutTexture(gDisplayListHead++, NULL, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 64, 0, G_TX_CLAMP, G_TX_CLAMP, 0, 0, 0, 0); + gDPSetTextureOverrideDjui(gDisplayListHead++, texture, djui_gfx_power_of_two(w), + djui_gfx_power_of_two(h), bitSize); + gDPLoadTextureBlockWithoutTexture(gDisplayListHead++, NULL, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 64, 0, + G_TX_CLAMP, G_TX_CLAMP, 0, 0, 0, 0); *(gDisplayListHead++) = (Gfx) gsSPExecuteDjui(G_TEXOVERRIDE_DJUI); gSPVertexNonGlobal(gDisplayListHead++, vtx, 4, 0); *(gDisplayListHead++) = (Gfx) gsSPExecuteDjui(G_TEXCLIP_DJUI); - gSP2TrianglesDjui(gDisplayListHead++, 0, 1, 2, 0x0, 0, 2, 3, 0x0); + gSP2TrianglesDjui(gDisplayListHead++, 0, 1, 2, 0x0, 0, 2, 3, 0x0); gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF); gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE); @@ -159,30 +182,31 @@ void djui_gfx_render_texture_tile(const u8* texture, u32 w, u32 h, u32 bitSize, ///////////////////////////////////////////// -void djui_gfx_position_translate(f32* x, f32* y) { +void djui_gfx_position_translate(f32 *x, f32 *y) { u32 windowWidth, windowHeight; wm_api->get_dimensions(&windowWidth, &windowHeight); - *x = GFX_DIMENSIONS_FROM_LEFT_EDGE(0) + *x * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale(); - *y = SCREEN_HEIGHT - *y * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale(); + *x = GFX_DIMENSIONS_FROM_LEFT_EDGE(0) + + *x * ((f32) SCREEN_HEIGHT / (f32) windowHeight) * djui_gfx_get_scale(); + *y = SCREEN_HEIGHT - *y * ((f32) SCREEN_HEIGHT / (f32) windowHeight) * djui_gfx_get_scale(); } -void djui_gfx_scale_translate(f32* width, f32* height) { +void djui_gfx_scale_translate(f32 *width, f32 *height) { u32 windowWidth, windowHeight; wm_api->get_dimensions(&windowWidth, &windowHeight); - *width = *width * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale(); - *height = *height * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale(); + *width = *width * ((f32) SCREEN_HEIGHT / (f32) windowHeight) * djui_gfx_get_scale(); + *height = *height * ((f32) SCREEN_HEIGHT / (f32) windowHeight) * djui_gfx_get_scale(); } -void djui_gfx_size_translate(f32* size) { +void djui_gfx_size_translate(f32 *size) { u32 windowWidth, windowHeight; wm_api->get_dimensions(&windowWidth, &windowHeight); - *size = *size * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale(); + *size = *size * ((f32) SCREEN_HEIGHT / (f32) windowHeight) * djui_gfx_get_scale(); } -bool djui_gfx_add_clipping_specific(struct DjuiBase* base, f32 dX, f32 dY, f32 dW, f32 dH) { - struct DjuiBaseRect* clip = &base->clip; +bool djui_gfx_add_clipping_specific(struct DjuiBase *base, f32 dX, f32 dY, f32 dW, f32 dH) { + struct DjuiBaseRect *clip = &base->clip; f32 clipX2 = clip->x + clip->width; f32 clipY2 = clip->y + clip->height; @@ -191,10 +215,18 @@ bool djui_gfx_add_clipping_specific(struct DjuiBase* base, f32 dX, f32 dY, f32 d f32 dY2 = dY + dH; // completely clipped - if (dX2 < clip->x) { return true; } - if (dX > clipX2) { return true; } - if (dY2 < clip->y) { return true; } - if (dY > clipY2) { return true; } + if (dX2 < clip->x) { + return true; + } + if (dX > clipX2) { + return true; + } + if (dY2 < clip->y) { + return true; + } + if (dY > clipY2) { + return true; + } f32 dClipX1 = fmax((clip->x - dX) / dW, 0); f32 dClipY1 = fmax((clip->y - dY) / dH, 0); @@ -202,13 +234,14 @@ bool djui_gfx_add_clipping_specific(struct DjuiBase* base, f32 dX, f32 dY, f32 d f32 dClipY2 = fmax((dY - (clipY2 - dH)) / dH, 0); if ((dClipX1 != 0) || (dClipY1 != 0) || (dClipX2 != 0) || (dClipY2 != 0)) { - gDPSetTextureClippingDjui(gDisplayListHead++, (u8)(dClipX1 * 255), (u8)(dClipY1 * 255), (u8)(dClipX2 * 255), (u8)(dClipY2 * 255)); + gDPSetTextureClippingDjui(gDisplayListHead++, (u8) (dClipX1 * 255), (u8) (dClipY1 * 255), + (u8) (dClipX2 * 255), (u8) (dClipY2 * 255)); } return false; } -bool djui_gfx_add_clipping(struct DjuiBase* base) { - struct DjuiBaseRect* comp = &base->comp; +bool djui_gfx_add_clipping(struct DjuiBase *base) { + struct DjuiBaseRect *comp = &base->comp; return djui_gfx_add_clipping_specific(base, comp->x, comp->y, comp->width, comp->height); } diff --git a/src/pc/djui/djui_panel_menu_options.c b/src/pc/djui/djui_panel_menu_options.c index 79b12fd7..2b35eb88 100644 --- a/src/pc/djui/djui_panel_menu_options.c +++ b/src/pc/djui/djui_panel_menu_options.c @@ -7,9 +7,7 @@ #include "src/pc/configfile.h" #include "src/game/level_update.h" -static struct DjuiText* sRestartText = NULL; - -bool changedScale = false; +static bool sChangedScale = false; static struct DjuiSelectionbox* sLevelBox = NULL; @@ -17,7 +15,7 @@ static void djui_panel_random_menu(UNUSED struct DjuiBase* caller) { djui_base_set_enabled(&sLevelBox->base, !configMenuRandom); } -static void djui_panel_misc_djui_theme_change(UNUSED struct DjuiBase* caller) { +static void djui_panel_misc_djui_setting_change(UNUSED struct DjuiBase* caller) { // god this is so hacky and terrible - djoslin0, 2023 if (gDjuiInMainMenu) { djui_panel_shutdown(); @@ -36,14 +34,6 @@ static void djui_panel_misc_djui_theme_change(UNUSED struct DjuiBase* caller) { } -static void djui_panel_misc_djui_scale_change(UNUSED struct DjuiBase* caller) { - if (changedScale) { - djui_text_set_text(sRestartText, DLANG(DISPLAY, MUST_RESTART)); - } else { - changedScale = true; - } -} - void djui_panel_main_menu_create(struct DjuiBase* caller) { struct DjuiThreePanel* panel = djui_panel_menu_create(DLANG(MENU_OPTIONS, MAIN_MENU)); struct DjuiBase* body = djui_three_panel_get_body(panel); @@ -84,27 +74,13 @@ void djui_panel_main_menu_create(struct DjuiBase* caller) { for (int i = 0; i < DJUI_THEME_MAX; i++) { themeChoices[i] = (char*)gDjuiThemes[i]->name; } - djui_selectionbox_create(body, DLANG(DJUI_THEMES, DJUI_THEME), themeChoices, DJUI_THEME_MAX, &configDjuiTheme, djui_panel_misc_djui_theme_change); + djui_selectionbox_create(body, DLANG(DJUI_THEMES, DJUI_THEME), themeChoices, DJUI_THEME_MAX, &configDjuiTheme, djui_panel_misc_djui_setting_change); - djui_checkbox_create(body, DLANG(DJUI_THEMES, CENTER), &configDjuiThemeCenter, djui_panel_misc_djui_theme_change); + djui_checkbox_create(body, DLANG(DJUI_THEMES, CENTER), &configDjuiThemeCenter, djui_panel_misc_djui_setting_change); - djui_selectionbox_create(body, DLANG(DJUI_THEMES, DJUI_SCALE), djuiScaleChoices, 3, &configDjuiScale, djui_panel_misc_djui_scale_change); + djui_selectionbox_create(body, DLANG(DJUI_THEMES, DJUI_SCALE), djuiScaleChoices, 3, &configDjuiScale, djui_panel_misc_djui_setting_change); djui_button_create(body, DLANG(MENU, BACK), DJUI_BUTTON_STYLE_BACK, djui_panel_menu_back); - - // Must restart text - sRestartText = djui_text_create(body, ""); - djui_text_set_alignment(sRestartText, DJUI_HALIGN_CENTER, DJUI_VALIGN_TOP); - djui_base_set_color(&sRestartText->base, 255, 100, 100, 255); - djui_base_set_size_type(&sRestartText->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); - djui_base_set_size(&sRestartText->base, 1.0f, 64); - - // force the restart text to update - if (changedScale) { - djui_text_set_text(sRestartText, DLANG(DISPLAY, MUST_RESTART)); - } else { - djui_text_set_text(sRestartText, ""); - } } djui_panel_add(caller, panel, NULL); diff --git a/src/pc/pc_main.c b/src/pc/pc_main.c index 13c33521..ce67cfd0 100644 --- a/src/pc/pc_main.c +++ b/src/pc/pc_main.c @@ -73,7 +73,6 @@ u8 gRenderingInterpolated = 0; f32 gRenderingDelta = 0; f64 gGameSpeed = 1.0f; // TODO: should probably remove -u32 gDjuiScale = 1; //0 = 0.85, 1 = 1.0, 2 = 1.5 #define FRAMERATE 30 static const f64 sFrameTime = (1.0 / ((double)FRAMERATE)); @@ -263,12 +262,7 @@ void game_exit(void) { exit(0); } -void* main_game_init(UNUSED void* arg) { - if (gDjuiScale != 0 || gDjuiScale != 1 || gDjuiScale != 2) { - gDjuiScale = 1; - configDjuiScale = 1; - } - +void* main_game_init(UNUSED void* arg) { const char *gamedir = gCLIOpts.GameDir[0] ? gCLIOpts.GameDir : FS_BASEDIR; const char *userpath = gCLIOpts.SavePath[0] ? gCLIOpts.SavePath : sys_user_path(); fs_init(sys_ropaths, gamedir, userpath); diff --git a/src/pc/pc_main.h b/src/pc/pc_main.h index 12b4bced..94acdd89 100644 --- a/src/pc/pc_main.h +++ b/src/pc/pc_main.h @@ -16,7 +16,6 @@ extern "C" { #include "gfx/gfx_dummy.h" extern bool gCoopCompatibility; -extern u32 gDjuiScale; #if defined(WAPI_SDL1) || defined(WAPI_SDL2) # define WAPI gfx_sdl diff --git a/tools/ido5.3_compiler/usr/lib/libc.so.1 b/tools/ido5.3_compiler/usr/lib/libc.so.1 index 17495ef6c4f4a6c2202e582c1407bccef3fed845..28e2d8e12c2fbe85525484ff4777db1c8dbf10e4 100755 GIT binary patch delta 106 zcmWN=ISqg?06@_I<-X4m5!4NGV5ou$zyVwLDqvwC!2(ka@L%#?yFPY37q?4ir1P#r j3GFkWV91Cu6Q<0VvtY@JH5<0<*mE#KkK1R|Hr?|NpUx(U delta 130 zcmcb4DC*9ks0~J+8F`zHK5qxo7Z&pIaxpM41cy31y9Nilg-$>CN?5F2bt)4OGXpUT z5VHa?8xXStF$WNH0x=g5a|1CC5c2{t9}x2cu>cSY0QdTZi From 9dde4455b21c08c60afc939fd01d9bc0099fecef Mon Sep 17 00:00:00 2001 From: eros71-dev <16540103+eros71-dev@users.noreply.github.com> Date: Fri, 24 Nov 2023 20:33:10 +0100 Subject: [PATCH 3/5] Change x1.5 to x1.25, it was too big --- src/pc/djui/djui_gfx.c | 2 +- src/pc/djui/djui_panel_menu_options.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pc/djui/djui_gfx.c b/src/pc/djui/djui_gfx.c index 1ba05dbd..f17be23b 100644 --- a/src/pc/djui/djui_gfx.c +++ b/src/pc/djui/djui_gfx.c @@ -55,7 +55,7 @@ f32 djui_gfx_get_scale(void) { return 1.0f; case 2: - return 1.5f; + return 1.25f; default: return 1.0f; diff --git a/src/pc/djui/djui_panel_menu_options.c b/src/pc/djui/djui_panel_menu_options.c index 2b35eb88..d9576e54 100644 --- a/src/pc/djui/djui_panel_menu_options.c +++ b/src/pc/djui/djui_panel_menu_options.c @@ -60,7 +60,7 @@ void djui_panel_main_menu_create(struct DjuiBase* caller) { "WDW" }; - char* djuiScaleChoices[3] = {"x0.85", "x1.0", "x1.5"}; + char* djuiScaleChoices[3] = {"x0.85", "x1.0", "x1.25"}; struct DjuiSelectionbox* selectionbox1 = djui_selectionbox_create(body, DLANG(MENU_OPTIONS, LEVEL), levelChoices, 18, &configMenuLevel, NULL); djui_base_set_enabled(&selectionbox1->base, !configMenuRandom); From a4f7535a0338f16d8370ab55bd0dc368c6ffd674 Mon Sep 17 00:00:00 2001 From: eros71-dev <16540103+eros71-dev@users.noreply.github.com> Date: Fri, 24 Nov 2023 20:51:39 +0100 Subject: [PATCH 4/5] Fix syntax changes, re-add 1.5, add 1.25 I've also changed the switch I've added for the scaling to follow the same formatting as the other ones --- src/pc/djui/djui_gfx.c | 154 +++++++++----------------- src/pc/djui/djui_panel_menu_options.c | 4 +- 2 files changed, 57 insertions(+), 101 deletions(-) diff --git a/src/pc/djui/djui_gfx.c b/src/pc/djui/djui_gfx.c index f17be23b..4023492f 100644 --- a/src/pc/djui/djui_gfx.c +++ b/src/pc/djui/djui_gfx.c @@ -28,10 +28,10 @@ void djui_gfx_displaylist_end(void) { } 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 } } }, - { { { 1, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff } } }, - { { { 0, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff } } }, + {{{ 0, -1, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, + {{{ 1, -1, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, + {{{ 1, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, + {{{ 0, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, }; const Gfx dl_djui_simple_rect[] = { @@ -40,7 +40,7 @@ const Gfx dl_djui_simple_rect[] = { gsDPSetCombineMode(G_CC_FADE, G_CC_FADE), gsDPSetRenderMode(G_RM_XLU_SURF, G_RM_XLU_SURF2), gsSPVertexNonGlobal(vertex_djui_simple_rect, 4, 0), - gsSP2Triangles(0, 1, 2, 0x0, 0, 2, 3, 0x0), + gsSP2Triangles(0, 1, 2, 0x0, 0, 2, 3, 0x0), gsSPEndDisplayList(), }; @@ -48,26 +48,20 @@ f32 djui_gfx_get_scale(void) { u32 windowWidth, windowHeight; wm_api->get_dimensions(&windowWidth, &windowHeight); switch (configDjuiScale) { - case 0: - return 0.85f; - - case 1: - return 1.0f; - - case 2: - return 1.25f; - - default: - return 1.0f; + case 0: return 0.85f; + case 1: return 1.0f; + case 2: return 1.25f; + case 3: return 1.5f; + default: return 1.0f; } } ///////////////////////////////////////////// static const Vtx vertex_djui_image[] = { - { { { 0, -1, 0 }, 0, { 0, 2048 }, { 0xff, 0xff, 0xff, 0xff } } }, - { { { 1, -1, 0 }, 0, { 2048, 2048 }, { 0xff, 0xff, 0xff, 0xff } } }, - { { { 1, 0, 0 }, 0, { 2048, 0 }, { 0xff, 0xff, 0xff, 0xff } } }, - { { { 0, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff } } }, + {{{ 0, -1, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, + {{{ 1, -1, 0 }, 0, { 2048, 2048 }, { 0xff, 0xff, 0xff, 0xff }}}, + {{{ 1, 0, 0 }, 0, { 2048, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, + {{{ 0, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, }; const Gfx dl_djui_image[] = { @@ -76,12 +70,11 @@ const Gfx dl_djui_image[] = { gsDPSetCombineMode(G_CC_FADEA, G_CC_FADEA), gsDPSetRenderMode(G_RM_XLU_SURF, G_RM_XLU_SURF2), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON), - gsDPLoadTextureBlock(NULL, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 64, 0, G_TX_CLAMP, G_TX_CLAMP, 0, 0, 0, - 0), + gsDPLoadTextureBlock(NULL, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 64, 0, G_TX_CLAMP, G_TX_CLAMP, 0, 0, 0, 0), gsSPExecuteDjui(G_TEXOVERRIDE_DJUI), gsSPVertexNonGlobal(vertex_djui_image, 4, 0), // gsSPExecuteDjui(G_TEXCLIP_DJUI), - gsSP2Triangles(0, 1, 2, 0x0, 0, 2, 3, 0x0), + gsSP2Triangles(0, 1, 2, 0x0, 0, 2, 3, 0x0), gsSPTexture(0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF), gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), gsSPEndDisplayList(), @@ -89,40 +82,27 @@ const Gfx dl_djui_image[] = { static u8 djui_gfx_power_of_two(u32 value) { switch (value) { - case 2: - return 1; - case 4: - return 2; - case 8: - return 3; - case 16: - return 4; - case 32: - return 5; - case 64: - return 6; - case 128: - return 7; - case 256: - return 8; - case 512: - return 9; - case 1024: - return 10; - default: - return 11; + case 2: return 1; + case 4: return 2; + case 8: return 3; + case 16: return 4; + case 32: return 5; + case 64: return 6; + case 128: return 7; + case 256: return 8; + case 512: return 9; + case 1024: return 10; + default: return 11; } } -void djui_gfx_render_texture(const u8 *texture, u32 w, u32 h, u32 bitSize, bool filter) { +void djui_gfx_render_texture(const u8* texture, u32 w, u32 h, u32 bitSize, bool filter) { gDPSetTextureFilter(gDisplayListHead++, filter ? G_TF_BILERP : G_TF_POINT); - gDPSetTextureOverrideDjui(gDisplayListHead++, texture, djui_gfx_power_of_two(w), - djui_gfx_power_of_two(h), bitSize); + gDPSetTextureOverrideDjui(gDisplayListHead++, texture, djui_gfx_power_of_two(w), djui_gfx_power_of_two(h), bitSize); gSPDisplayList(gDisplayListHead++, dl_djui_image); } -void djui_gfx_render_texture_tile(const u8 *texture, u32 w, u32 h, u32 bitSize, u32 tileX, u32 tileY, - u32 tileW, u32 tileH, bool filter) { +void djui_gfx_render_texture_tile(const u8* texture, u32 w, u32 h, u32 bitSize, u32 tileX, u32 tileY, u32 tileW, u32 tileH, bool filter) { if (!gDisplayListHead) { LOG_ERROR("Retrieved a null displaylist head"); return; @@ -139,24 +119,12 @@ void djui_gfx_render_texture_tile(const u8 *texture, u32 w, u32 h, u32 bitSize, return; } - f32 aspect = tileH ? ((f32) tileW / (f32) tileH) : 1; + f32 aspect = tileH ? ((f32)tileW / (f32)tileH) : 1; // I don't know why adding 1 to all of the UVs seems to fix rendering, but it does... - vtx[0] = (Vtx){ { { 0, -1, 0 }, - 0, - { (tileX * 2048.0f) / (f32) w, ((tileY + tileH) * 2048.0f) / (f32) h }, - { 0xff, 0xff, 0xff, 0xff } } }; - vtx[1] = (Vtx){ { { 1 * aspect, -1, 0 }, - 0, - { ((tileX + tileW) * 2048.0f) / (f32) w, ((tileY + tileH) * 2048.0f) / (f32) h }, - { 0xff, 0xff, 0xff, 0xff } } }; - vtx[2] = (Vtx){ { { 1 * aspect, 0, 0 }, - 0, - { ((tileX + tileW) * 2048.0f) / (f32) w, (tileY * 2048.0f) / (f32) h }, - { 0xff, 0xff, 0xff, 0xff } } }; - vtx[3] = (Vtx){ { { 0, 0, 0 }, - 0, - { (tileX * 2048.0f) / (f32) w, (tileY * 2048.0f) / (f32) h }, - { 0xff, 0xff, 0xff, 0xff } } }; + vtx[0] = (Vtx) {{{ 0, -1, 0 }, 0, { ( tileX * 2048.0f) / (f32)w, ((tileY + tileH) * 2048.0f) / (f32)h }, { 0xff, 0xff, 0xff, 0xff }}}; + vtx[1] = (Vtx) {{{ 1 * aspect, -1, 0 }, 0, { ((tileX + tileW) * 2048.0f) / (f32)w, ((tileY + tileH) * 2048.0f) / (f32)h }, { 0xff, 0xff, 0xff, 0xff }}}; + vtx[2] = (Vtx) {{{ 1 * aspect, 0, 0 }, 0, { ((tileX + tileW) * 2048.0f) / (f32)w, ( tileY * 2048.0f) / (f32)h }, { 0xff, 0xff, 0xff, 0xff }}}; + vtx[3] = (Vtx) {{{ 0, 0, 0 }, 0, { ( tileX * 2048.0f) / (f32)w, ( tileY * 2048.0f) / (f32)h }, { 0xff, 0xff, 0xff, 0xff }}}; gSPClearGeometryMode(gDisplayListHead++, G_LIGHTING); gDPSetCombineMode(gDisplayListHead++, G_CC_FADEA, G_CC_FADEA); @@ -165,16 +133,14 @@ void djui_gfx_render_texture_tile(const u8 *texture, u32 w, u32 h, u32 bitSize, gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_ON); - gDPSetTextureOverrideDjui(gDisplayListHead++, texture, djui_gfx_power_of_two(w), - djui_gfx_power_of_two(h), bitSize); - gDPLoadTextureBlockWithoutTexture(gDisplayListHead++, NULL, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 64, 0, - G_TX_CLAMP, G_TX_CLAMP, 0, 0, 0, 0); + gDPSetTextureOverrideDjui(gDisplayListHead++, texture, djui_gfx_power_of_two(w), djui_gfx_power_of_two(h), bitSize); + gDPLoadTextureBlockWithoutTexture(gDisplayListHead++, NULL, G_IM_FMT_RGBA, G_IM_SIZ_16b, 64, 64, 0, G_TX_CLAMP, G_TX_CLAMP, 0, 0, 0, 0); *(gDisplayListHead++) = (Gfx) gsSPExecuteDjui(G_TEXOVERRIDE_DJUI); gSPVertexNonGlobal(gDisplayListHead++, vtx, 4, 0); *(gDisplayListHead++) = (Gfx) gsSPExecuteDjui(G_TEXCLIP_DJUI); - gSP2TrianglesDjui(gDisplayListHead++, 0, 1, 2, 0x0, 0, 2, 3, 0x0); + gSP2TrianglesDjui(gDisplayListHead++, 0, 1, 2, 0x0, 0, 2, 3, 0x0); gSPTexture(gDisplayListHead++, 0xFFFF, 0xFFFF, 0, G_TX_RENDERTILE, G_OFF); gDPSetCombineMode(gDisplayListHead++, G_CC_SHADE, G_CC_SHADE); @@ -182,31 +148,30 @@ void djui_gfx_render_texture_tile(const u8 *texture, u32 w, u32 h, u32 bitSize, ///////////////////////////////////////////// -void djui_gfx_position_translate(f32 *x, f32 *y) { +void djui_gfx_position_translate(f32* x, f32* y) { u32 windowWidth, windowHeight; wm_api->get_dimensions(&windowWidth, &windowHeight); - *x = GFX_DIMENSIONS_FROM_LEFT_EDGE(0) - + *x * ((f32) SCREEN_HEIGHT / (f32) windowHeight) * djui_gfx_get_scale(); - *y = SCREEN_HEIGHT - *y * ((f32) SCREEN_HEIGHT / (f32) windowHeight) * djui_gfx_get_scale(); + *x = GFX_DIMENSIONS_FROM_LEFT_EDGE(0) + *x * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale(); + *y = SCREEN_HEIGHT - *y * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale(); } -void djui_gfx_scale_translate(f32 *width, f32 *height) { +void djui_gfx_scale_translate(f32* width, f32* height) { u32 windowWidth, windowHeight; wm_api->get_dimensions(&windowWidth, &windowHeight); - *width = *width * ((f32) SCREEN_HEIGHT / (f32) windowHeight) * djui_gfx_get_scale(); - *height = *height * ((f32) SCREEN_HEIGHT / (f32) windowHeight) * djui_gfx_get_scale(); + *width = *width * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale(); + *height = *height * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale(); } -void djui_gfx_size_translate(f32 *size) { +void djui_gfx_size_translate(f32* size) { u32 windowWidth, windowHeight; wm_api->get_dimensions(&windowWidth, &windowHeight); - *size = *size * ((f32) SCREEN_HEIGHT / (f32) windowHeight) * djui_gfx_get_scale(); + *size = *size * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale() } -bool djui_gfx_add_clipping_specific(struct DjuiBase *base, f32 dX, f32 dY, f32 dW, f32 dH) { - struct DjuiBaseRect *clip = &base->clip; +bool djui_gfx_add_clipping_specific(struct DjuiBase* base, f32 dX, f32 dY, f32 dW, f32 dH) { + struct DjuiBaseRect* clip = &base->clip; f32 clipX2 = clip->x + clip->width; f32 clipY2 = clip->y + clip->height; @@ -215,18 +180,10 @@ bool djui_gfx_add_clipping_specific(struct DjuiBase *base, f32 dX, f32 dY, f32 d f32 dY2 = dY + dH; // completely clipped - if (dX2 < clip->x) { - return true; - } - if (dX > clipX2) { - return true; - } - if (dY2 < clip->y) { - return true; - } - if (dY > clipY2) { - return true; - } + if (dX2 < clip->x) { return true; } + if (dX > clipX2) { return true; } + if (dY2 < clip->y) { return true; } + if (dY > clipY2) { return true; } f32 dClipX1 = fmax((clip->x - dX) / dW, 0); f32 dClipY1 = fmax((clip->y - dY) / dH, 0); @@ -234,14 +191,13 @@ bool djui_gfx_add_clipping_specific(struct DjuiBase *base, f32 dX, f32 dY, f32 d f32 dClipY2 = fmax((dY - (clipY2 - dH)) / dH, 0); if ((dClipX1 != 0) || (dClipY1 != 0) || (dClipX2 != 0) || (dClipY2 != 0)) { - gDPSetTextureClippingDjui(gDisplayListHead++, (u8) (dClipX1 * 255), (u8) (dClipY1 * 255), - (u8) (dClipX2 * 255), (u8) (dClipY2 * 255)); + gDPSetTextureClippingDjui(gDisplayListHead++, (u8)(dClipX1 * 255), (u8)(dClipY1 * 255), (u8)(dClipX2 * 255), (u8)(dClipY2 * 255)); } return false; } -bool djui_gfx_add_clipping(struct DjuiBase *base) { - struct DjuiBaseRect *comp = &base->comp; +bool djui_gfx_add_clipping(struct DjuiBase* base) { + struct DjuiBaseRect* comp = &base->comp; return djui_gfx_add_clipping_specific(base, comp->x, comp->y, comp->width, comp->height); } diff --git a/src/pc/djui/djui_panel_menu_options.c b/src/pc/djui/djui_panel_menu_options.c index d9576e54..1bcaa324 100644 --- a/src/pc/djui/djui_panel_menu_options.c +++ b/src/pc/djui/djui_panel_menu_options.c @@ -60,7 +60,7 @@ void djui_panel_main_menu_create(struct DjuiBase* caller) { "WDW" }; - char* djuiScaleChoices[3] = {"x0.85", "x1.0", "x1.25"}; + char* djuiScaleChoices[4] = {"x0.85", "x1.0", "x1.25", "x1.5"}; struct DjuiSelectionbox* selectionbox1 = djui_selectionbox_create(body, DLANG(MENU_OPTIONS, LEVEL), levelChoices, 18, &configMenuLevel, NULL); djui_base_set_enabled(&selectionbox1->base, !configMenuRandom); @@ -78,7 +78,7 @@ void djui_panel_main_menu_create(struct DjuiBase* caller) { djui_checkbox_create(body, DLANG(DJUI_THEMES, CENTER), &configDjuiThemeCenter, djui_panel_misc_djui_setting_change); - djui_selectionbox_create(body, DLANG(DJUI_THEMES, DJUI_SCALE), djuiScaleChoices, 3, &configDjuiScale, djui_panel_misc_djui_setting_change); + djui_selectionbox_create(body, DLANG(DJUI_THEMES, DJUI_SCALE), djuiScaleChoices, 4, &configDjuiScale, djui_panel_misc_djui_setting_change); djui_button_create(body, DLANG(MENU, BACK), DJUI_BUTTON_STYLE_BACK, djui_panel_menu_back); } From e9beeee7beda25c7e5d12a3afd4aca6f5a3ec7a1 Mon Sep 17 00:00:00 2001 From: eros71-dev <16540103+eros71-dev@users.noreply.github.com> Date: Fri, 24 Nov 2023 21:13:28 +0100 Subject: [PATCH 5/5] All good now! Also removed an unused var. --- src/pc/djui/djui_gfx.c | 28 +++++++++++++-------------- src/pc/djui/djui_panel_menu_options.c | 2 -- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/pc/djui/djui_gfx.c b/src/pc/djui/djui_gfx.c index 4023492f..ed4f60e9 100644 --- a/src/pc/djui/djui_gfx.c +++ b/src/pc/djui/djui_gfx.c @@ -30,8 +30,8 @@ void djui_gfx_displaylist_end(void) { 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 }}}, - {{{ 1, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, - {{{ 0, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, + {{{ 1, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, + {{{ 0, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, }; const Gfx dl_djui_simple_rect[] = { @@ -58,10 +58,10 @@ f32 djui_gfx_get_scale(void) { ///////////////////////////////////////////// static const Vtx vertex_djui_image[] = { - {{{ 0, -1, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, + {{{ 0, -1, 0 }, 0, { 0, 2048 }, { 0xff, 0xff, 0xff, 0xff }}}, {{{ 1, -1, 0 }, 0, { 2048, 2048 }, { 0xff, 0xff, 0xff, 0xff }}}, - {{{ 1, 0, 0 }, 0, { 2048, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, - {{{ 0, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, + {{{ 1, 0, 0 }, 0, { 2048, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, + {{{ 0, 0, 0 }, 0, { 0, 0 }, { 0xff, 0xff, 0xff, 0xff }}}, }; const Gfx dl_djui_image[] = { @@ -85,14 +85,14 @@ static u8 djui_gfx_power_of_two(u32 value) { case 2: return 1; case 4: return 2; case 8: return 3; - case 16: return 4; - case 32: return 5; - case 64: return 6; - case 128: return 7; - case 256: return 8; - case 512: return 9; - case 1024: return 10; - default: return 11; + case 16: return 4; + case 32: return 5; + case 64: return 6; + case 128: return 7; + case 256: return 8; + case 512: return 9; + case 1024: return 10; + default: return 11; } } @@ -167,7 +167,7 @@ void djui_gfx_size_translate(f32* size) { u32 windowWidth, windowHeight; wm_api->get_dimensions(&windowWidth, &windowHeight); - *size = *size * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale() + *size = *size * ((f32)SCREEN_HEIGHT / (f32)windowHeight) * djui_gfx_get_scale(); } bool djui_gfx_add_clipping_specific(struct DjuiBase* base, f32 dX, f32 dY, f32 dW, f32 dH) { diff --git a/src/pc/djui/djui_panel_menu_options.c b/src/pc/djui/djui_panel_menu_options.c index 1bcaa324..550d77b7 100644 --- a/src/pc/djui/djui_panel_menu_options.c +++ b/src/pc/djui/djui_panel_menu_options.c @@ -7,8 +7,6 @@ #include "src/pc/configfile.h" #include "src/game/level_update.h" -static bool sChangedScale = false; - static struct DjuiSelectionbox* sLevelBox = NULL; static void djui_panel_random_menu(UNUSED struct DjuiBase* caller) {