From 939310be641fbf506eb34924f21c66e9c5be2c0f Mon Sep 17 00:00:00 2001 From: Tropical <42101043+tropicaaal@users.noreply.github.com> Date: Sat, 28 Mar 2026 02:13:27 -0500 Subject: [PATCH] refactor: rework meson options, fix ENABLE_VSYNC --- Minecraft.Client/GameState/Options.cpp | 23 +++++++++++++++------ Minecraft.Client/Rendering/GameRenderer.cpp | 9 +++++++- Minecraft.Client/meson.build | 8 ++----- meson.options | 14 +++++-------- 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/Minecraft.Client/GameState/Options.cpp b/Minecraft.Client/GameState/Options.cpp index e8e24827d..289fdecb0 100644 --- a/Minecraft.Client/GameState/Options.cpp +++ b/Minecraft.Client/GameState/Options.cpp @@ -89,8 +89,15 @@ const std::wstring Options::DIFFICULTY_NAMES[] = { const std::wstring Options::GUI_SCALE[] = { L"options.guiScale.auto", L"options.guiScale.small", L"options.guiScale.normal", L"options.guiScale.large"}; + +#ifdef ENABLE_VSYNC const std::wstring Options::FRAMERATE_LIMITS[] = { L"performance.max", L"performance.balanced", L"performance.powersaver"}; +#else +const std::wstring Options::FRAMERATE_LIMITS[] = { + L"performance.max", L"performance.balanced", L"performance.powersaver", + L"performance.unlimited"}; +#endif const std::wstring Options::PARTICLES[] = {L"options.particles.all", L"options.particles.decreased", @@ -237,15 +244,19 @@ void Options::toggle(const Options::Option* option, int dir) { if (option == Option::RENDER_CLOUDS) renderClouds = !renderClouds; if (option == Option::ADVANCED_OPENGL) { advancedOpengl = !advancedOpengl; - // 4jcraft: ensure level exists before applying - if(minecraft->level) minecraft->levelRenderer->allChanged(); + // 4jcraft: ensure level exists before applying + if (minecraft->level) minecraft->levelRenderer->allChanged(); } if (option == Option::ANAGLYPH) { anaglyph3d = !anaglyph3d; minecraft->textures->reloadAll(); } if (option == Option::FRAMERATE_LIMIT) +#ifdef ENABLE_VSYNC framerateLimit = (framerateLimit + dir + 3) % 3; +#else + framerateLimit = (framerateLimit + dir + 4) % 4; +#endif // 4J-PB - Change for Xbox // if (option == Option::DIFFICULTY) difficulty = (difficulty + dir) & 3; @@ -255,13 +266,13 @@ void Options::toggle(const Options::Option* option, int dir) { if (option == Option::GRAPHICS) { fancyGraphics = !fancyGraphics; - // 4jcraft: ensure level exists before applying - if(minecraft->level) minecraft->levelRenderer->allChanged(); + // 4jcraft: ensure level exists before applying + if (minecraft->level) minecraft->levelRenderer->allChanged(); } if (option == Option::AMBIENT_OCCLUSION) { ambientOcclusion = !ambientOcclusion; - // 4jcraft: ensure level exists before applying - if(minecraft->level) minecraft->levelRenderer->allChanged(); + // 4jcraft: ensure level exists before applying + if (minecraft->level) minecraft->levelRenderer->allChanged(); } // 4J-PB - don't do the file save on the xbox diff --git a/Minecraft.Client/Rendering/GameRenderer.cpp b/Minecraft.Client/Rendering/GameRenderer.cpp index d228b1030..a9f91daf6 100644 --- a/Minecraft.Client/Rendering/GameRenderer.cpp +++ b/Minecraft.Client/Rendering/GameRenderer.cpp @@ -1060,7 +1060,11 @@ void GameRenderer::render(float a, bool bFirst) { int maxFps = getFpsCap(mc->options->framerateLimit); if (mc->level != NULL) { - if (mc->options->framerateLimit == 0) { + if (mc->options->framerateLimit == 0 +#ifndef ENABLE_VSYNC + || mc->options->framerateLimit == 3 +#endif + ) { renderLevel(a, 0); } else { renderLevel(a, lastNsTime + 1000000000 / maxFps); @@ -2134,6 +2138,9 @@ int GameRenderer::getFpsCap(int option) { int maxFps = 200; if (option == 1) maxFps = 120; if (option == 2) maxFps = 35; +#ifndef ENABLE_VSYNC + if (option == 3) maxFps = std::numeric_limits::max(); +#endif return maxFps; } diff --git a/Minecraft.Client/meson.build b/Minecraft.Client/meson.build index f81dddddd..8bcc874b1 100644 --- a/Minecraft.Client/meson.build +++ b/Minecraft.Client/meson.build @@ -75,7 +75,7 @@ if get_option('enable_vsync') global_cpp_defs += '-DENABLE_VSYNC' endif -if get_option('enable_shiggy') +if get_option('ui_backend') == 'shiggy' shiggy_dep = dependency( 'shiggy', fallback : ['shiggy', 'shiggy_dep'], @@ -85,14 +85,10 @@ if get_option('enable_shiggy') client_dependencies += shiggy_dep endif -if get_option('enable_java_guis') +if get_option('ui_backend') == 'java' global_cpp_defs += '-DENABLE_JAVA_GUIS' endif -if get_option('enable_shiggy') and get_option('enable_java_guis') - error('You cannot use the Iggy and Java UI at the same time, please choose one.') -endif - client = executable('Minecraft.Client', client_sources + platform_sources + localisation[1], include_directories : [include_directories('Platform', 'Platform/Linux/Iggy/include'),stb], diff --git a/meson.options b/meson.options index 74de97f98..545d2a159 100644 --- a/meson.options +++ b/meson.options @@ -1,14 +1,10 @@ -option('enable_java_guis', - type : 'boolean', - value : false, - description : 'Re-enable the Java UI remnants in the code (for testing only)') +option('ui_backend', + type : 'combo', + choices: ['shiggy', 'java'], + value : 'shiggy', + description : 'Specifies a backend implementation for the game UI.') option('enable_vsync', type : 'boolean', value : true, description : 'Toggles V-Sync and adds options to unlock maximum in-game framerate.') - -option('enable_shiggy', - type : 'boolean', - value : true, - description : 'Toggles shimmed PS4 Iggy binaries and UI for x86_64 Linux.')