Skip to content

Commit

Permalink
[REFACTOR] Disabled settings checkboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
gravit0 committed Aug 22, 2024
1 parent 2d4a122 commit 5ab93e0
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,18 @@ public void reset() {
settingsList.getChildren().add(settingsListHeader);
}

public void add(String languageName, boolean value, Consumer<Boolean> onChanged) {
public void add(String languageName, boolean value, Consumer<Boolean> onChanged, boolean disabled) {
String nameKey = "runtime.scenes.settings.properties.%s.name".formatted(languageName.toLowerCase());
String descriptionKey = "runtime.scenes.settings.properties.%s.description".formatted(
languageName.toLowerCase());
add(application.getTranslation(nameKey, languageName), application.getTranslation(descriptionKey, languageName),
value, onChanged);
}
public void addDisabled(String languageName, String transferredTo, boolean value) {
String nameKey = "runtime.scenes.settings.properties.%s.name".formatted(languageName.toLowerCase());
String descriptionKey = "runtime.scenes.settings.properties.%s.disabled".formatted(
transferredTo.toLowerCase());
String descriptionKey;
if(disabled) {
descriptionKey = "runtime.scenes.settings.properties.%s.disabled".formatted(
languageName.toLowerCase());
} else {
descriptionKey = "runtime.scenes.settings.properties.%s.description".formatted(
languageName.toLowerCase());
}
add(application.getTranslation(nameKey, languageName), application.getTranslation(descriptionKey, languageName),
value, unused -> {}, true);
}
public void add(String name, String description, boolean value, Consumer<Boolean> onChanged) {
add(name, description, value, onChanged, false);
value, onChanged, disabled);
}

public void add(String name, String description, boolean value, Consumer<Boolean> onChanged, boolean disabled) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected void doInit() {
public void reset() {
super.reset();
RuntimeSettings.GlobalSettings settings = application.runtimeSettings.globalSettings;
add("PrismVSync", settings.prismVSync, (value) -> settings.prismVSync = value);
add("DebugAllClients", settings.debugAllClients, (value) -> settings.debugAllClients = value);
add("PrismVSync", settings.prismVSync, (value) -> settings.prismVSync = value, false);
add("DebugAllClients", settings.debugAllClients, (value) -> settings.debugAllClients = value, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,17 @@ public void reset() {
}
});
serverButton.enableResetButton(null, (e) -> reset());
if (!application.runtimeSettings.globalSettings.debugAllClients) {
add("Debug", profileSettings.debug, (value) -> profileSettings.debug = value);
} else {
addDisabled("Debug", application.gui.globalSettingsScene.getName(), profileSettings.debug);
}
add("AutoEnter", profileSettings.autoEnter, (value) -> profileSettings.autoEnter = value);
add("Fullscreen", profileSettings.fullScreen, (value) -> profileSettings.fullScreen = value);
add("Debug", profileSettings.debug, (value) -> profileSettings.debug = value, application.runtimeSettings.globalSettings.debugAllClients);
add("AutoEnter", profileSettings.autoEnter, (value) -> profileSettings.autoEnter = value, false);
add("Fullscreen", profileSettings.fullScreen, (value) -> profileSettings.fullScreen = value, false);
if(JVMHelper.OS_TYPE == JVMHelper.OS.LINUX) {
add("WaylandSupport", profileSettings.waylandSupport, (value) -> profileSettings.waylandSupport = value);
add("WaylandSupport", profileSettings.waylandSupport, (value) -> profileSettings.waylandSupport = value, false);
}
if(application.authService.checkDebugPermission("skipupdate")) {
add("DebugSkipUpdate", profileSettings.debugSkipUpdate, (value) -> profileSettings.debugSkipUpdate = value);
add("DebugSkipUpdate", profileSettings.debugSkipUpdate, (value) -> profileSettings.debugSkipUpdate = value, false);
}
if(application.authService.checkDebugPermission("skipfilemonitor")) {
add("DebugSkipFileMonitor", profileSettings.debugSkipFileMonitor, (value) -> profileSettings.debugSkipFileMonitor = value);
add("DebugSkipFileMonitor", profileSettings.debugSkipFileMonitor, (value) -> profileSettings.debugSkipFileMonitor = value, false);
}
userBlock.reset();
}
Expand Down

0 comments on commit 5ab93e0

Please sign in to comment.