refactor: rework meson options, fix ENABLE_VSYNC

This commit is contained in:
Tropical 2026-03-28 02:13:27 -05:00
parent da7cbcb4b6
commit 939310be64
4 changed files with 32 additions and 22 deletions

View file

@ -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

View file

@ -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<int>::max();
#endif
return maxFps;
}

View file

@ -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],

View file

@ -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.')