Skip to content

Commit

Permalink
Rework Presets
Browse files Browse the repository at this point in the history
They were quite messy!
(Also no, don't expect a new update today, but yes expect a new update today)
  • Loading branch information
EnnuiL committed Oct 17, 2024
1 parent fb87430 commit f929a89
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,6 @@ public static class TweaksConfig extends Section {
@Comment("If enabled, the zoom will use spyglass sounds on zooming in and out.")
public final TrackedValue<Boolean> useSpyglassSounds = this.value(false);

@WidgetSize(Size.HALF)
@Comment("Shows toasts when the server imposes a restriction.")
public final TrackedValue<Boolean> showRestrictionToasts = this.value(true);

// TODO - Disable it upon stable release!
@WidgetSize(Size.HALF)
@Comment("Prints a random owo in the console when the game starts.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,58 +261,14 @@ private void resetNewValues() {

@SuppressWarnings("unchecked")
public void resetToPreset(ConfigEnums.ZoomPresets preset) {
Map<TrackedValue<?>, Object> presets = Map.ofEntries(
Map.entry(OkZoomerConfigManager.CONFIG.features.cinematicCamera, preset == ConfigEnums.ZoomPresets.CLASSIC ? ConfigEnums.CinematicCameraOptions.VANILLA : ConfigEnums.CinematicCameraOptions.OFF),
Map.entry(OkZoomerConfigManager.CONFIG.features.reduceSensitivity, preset != ConfigEnums.ZoomPresets.CLASSIC),
Map.entry(OkZoomerConfigManager.CONFIG.features.zoomTransition, preset == ConfigEnums.ZoomPresets.CLASSIC ? ConfigEnums.ZoomTransitionOptions.OFF : ConfigEnums.ZoomTransitionOptions.SMOOTH),
Map.entry(OkZoomerConfigManager.CONFIG.features.reduceViewBobbing, switch (preset) {
case CLASSIC, COMPETITIVE, SPYGLASS -> false;
default -> true;
}),
Map.entry(OkZoomerConfigManager.CONFIG.features.zoomMode, preset == ConfigEnums.ZoomPresets.PERSISTENT ? ConfigEnums.ZoomModes.PERSISTENT : ConfigEnums.ZoomModes.HOLD),
Map.entry(OkZoomerConfigManager.CONFIG.features.zoomScrolling, switch (preset) {
case CLASSIC, SPYGLASS -> false;
default -> true;
}),
Map.entry(OkZoomerConfigManager.CONFIG.features.persistentInterface, preset != ConfigEnums.ZoomPresets.CAMERA),
Map.entry(OkZoomerConfigManager.CONFIG.features.extraKeyBinds, preset != ConfigEnums.ZoomPresets.CLASSIC),
Map.entry(OkZoomerConfigManager.CONFIG.features.zoomOverlay, preset == ConfigEnums.ZoomPresets.SPYGLASS ? ConfigEnums.ZoomOverlays.SPYGLASS : ConfigEnums.ZoomOverlays.OFF),
Map.entry(OkZoomerConfigManager.CONFIG.features.spyglassMode, preset == ConfigEnums.ZoomPresets.SPYGLASS ? ConfigEnums.SpyglassMode.BOTH : ConfigEnums.SpyglassMode.OFF),
Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.zoomDivisor, switch (preset) {
case PERSISTENT -> 1.0;
case SPYGLASS -> 10.0;
default -> 4.0;
}),
Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.minimumZoomDivisor, 1.0),
Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.maximumZoomDivisor, 50.0),
Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.upperScrollSteps, switch (preset) {
case PERSISTENT -> 38;
case SPYGLASS -> 16;
default -> 20;
}),
Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.lowerScrollSteps, switch (preset) {
case PERSISTENT -> 0;
case SPYGLASS -> 8;
default -> 4;
}),
Map.entry(OkZoomerConfigManager.CONFIG.transitionValues.smoothTransitionFactor, preset == ConfigEnums.ZoomPresets.SPYGLASS ? 0.5 : 0.6),
Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.cinematicMultiplier, 4.0),
Map.entry(OkZoomerConfigManager.CONFIG.transitionValues.minimumLinearStep, 0.16),
Map.entry(OkZoomerConfigManager.CONFIG.transitionValues.maximumLinearStep, 0.22),
Map.entry(OkZoomerConfigManager.CONFIG.tweaks.resetZoomWithMouse, preset != ConfigEnums.ZoomPresets.CLASSIC),
Map.entry(OkZoomerConfigManager.CONFIG.tweaks.hideCrosshair, preset == ConfigEnums.ZoomPresets.CAMERA),
Map.entry(OkZoomerConfigManager.CONFIG.tweaks.forgetZoomDivisor, true),
Map.entry(OkZoomerConfigManager.CONFIG.tweaks.unbindConflictingKey, false),
Map.entry(OkZoomerConfigManager.CONFIG.tweaks.useSpyglassSounds, preset == ConfigEnums.ZoomPresets.SPYGLASS),
Map.entry(OkZoomerConfigManager.CONFIG.tweaks.showRestrictionToasts, true),
Map.entry(OkZoomerConfigManager.CONFIG.tweaks.printOwoOnStart, true)
);

this.newValues.clear();
this.invalidValues.clear();

for (TrackedValue<?> trackedValue : OkZoomerConfigManager.CONFIG.values()) {
this.newValues.put((TrackedValue<Object>) trackedValue, presets.get(trackedValue));
this.newValues.put(
(TrackedValue<Object>) trackedValue,
ZoomPresets.PRESET_ENUM_TO_PRESET.get(preset).getOrDefault(trackedValue, trackedValue.getDefaultValue())
);
}

this.refresh();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package io.github.ennuil.ok_zoomer.config.screen;

import io.github.ennuil.ok_zoomer.config.ConfigEnums;
import io.github.ennuil.ok_zoomer.config.OkZoomerConfigManager;
import org.quiltmc.config.api.values.TrackedValue;

import java.util.Map;

public class ZoomPresets {
public static final Map<TrackedValue<?>, Object> CAMERA = Map.of();

public static final Map<TrackedValue<?>, Object> COMPETITIVE = Map.of(
OkZoomerConfigManager.CONFIG.features.reduceViewBobbing, false,
OkZoomerConfigManager.CONFIG.features.persistentInterface, true,
OkZoomerConfigManager.CONFIG.tweaks.hideCrosshair, false
);

public static final Map<TrackedValue<?>, Object> CLASSIC = Map.of(
OkZoomerConfigManager.CONFIG.features.cinematicCamera, ConfigEnums.CinematicCameraOptions.VANILLA,
OkZoomerConfigManager.CONFIG.features.reduceSensitivity, false,
OkZoomerConfigManager.CONFIG.features.zoomTransition, ConfigEnums.ZoomTransitionOptions.OFF,
OkZoomerConfigManager.CONFIG.features.reduceViewBobbing, false,
OkZoomerConfigManager.CONFIG.features.zoomScrolling, false,
OkZoomerConfigManager.CONFIG.features.persistentInterface, true,
//OkZoomerConfigManager.CONFIG.features.extraKeyBinds, false - We'll maybe do that once we guarantee that is dynamic
OkZoomerConfigManager.CONFIG.tweaks.hideCrosshair, false
);

public static final Map<TrackedValue<?>, Object> PERSISTENT = Map.of(
OkZoomerConfigManager.CONFIG.features.zoomMode, ConfigEnums.ZoomModes.PERSISTENT,
OkZoomerConfigManager.CONFIG.features.persistentInterface, true,
OkZoomerConfigManager.CONFIG.zoomValues.zoomDivisor, 1.0,
OkZoomerConfigManager.CONFIG.zoomValues.lowerScrollSteps, 0,
OkZoomerConfigManager.CONFIG.zoomValues.upperScrollSteps, 38,
OkZoomerConfigManager.CONFIG.tweaks.hideCrosshair, false
);

public static final Map<TrackedValue<?>, Object> SPYGLASS = Map.ofEntries(
Map.entry(OkZoomerConfigManager.CONFIG.features.reduceViewBobbing, false),
Map.entry(OkZoomerConfigManager.CONFIG.features.zoomScrolling, false),
Map.entry(OkZoomerConfigManager.CONFIG.features.persistentInterface, true),
Map.entry(OkZoomerConfigManager.CONFIG.features.zoomOverlay, ConfigEnums.ZoomOverlays.SPYGLASS),
Map.entry(OkZoomerConfigManager.CONFIG.features.spyglassMode, ConfigEnums.SpyglassMode.BOTH),
Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.zoomDivisor, 10.0),
Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.lowerScrollSteps, 8),
Map.entry(OkZoomerConfigManager.CONFIG.zoomValues.upperScrollSteps, 16),
Map.entry(OkZoomerConfigManager.CONFIG.transitionValues.smoothTransitionFactor, 0.5),
Map.entry(OkZoomerConfigManager.CONFIG.tweaks.hideCrosshair, false),
Map.entry(OkZoomerConfigManager.CONFIG.tweaks.useSpyglassSounds, true)
);

public static final Map<ConfigEnums.ConfigEnum, Map<TrackedValue<?>, Object>> PRESET_ENUM_TO_PRESET = Map.of(
ConfigEnums.ZoomPresets.CAMERA, CAMERA,
ConfigEnums.ZoomPresets.COMPETITIVE, COMPETITIVE,
ConfigEnums.ZoomPresets.CLASSIC, CLASSIC,
ConfigEnums.ZoomPresets.PERSISTENT, PERSISTENT,
ConfigEnums.ZoomPresets.SPYGLASS, SPYGLASS
);
}
2 changes: 0 additions & 2 deletions src/main/resources/assets/ok_zoomer/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@
"config.ok_zoomer.tweaks.forget_zoom_divisor.tooltip": "If enabled, the current zoom divisor is forgotten once zooming is finished.",
"config.ok_zoomer.tweaks.use_spyglass_sounds": "Use Spyglass Sounds",
"config.ok_zoomer.tweaks.use_spyglass_sounds.tooltip": "If enabled, the zoom will use spyglass sounds on zooming in and out.",
"config.ok_zoomer.tweaks.show_restriction_toasts": "Show Restriction Toasts",
"config.ok_zoomer.tweaks.show_restriction_toasts.tooltip": "Shows toasts when the server imposes a restriction.",
"config.ok_zoomer.tweaks.print_owo_on_start": "Print owo on Start",
"config.ok_zoomer.tweaks.print_owo_on_start.tooltip": "Prints a random owo in the console when the game starts.",
"config.ok_zoomer.presets": "Presets",
Expand Down
4 changes: 1 addition & 3 deletions src/main/resources/assets/ok_zoomer/lang/pt_br.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,8 @@
"config.ok_zoomer.tweaks.forget_zoom_divisor.tooltip": "Se ativado, o divisor de zoom atual será esquecido quando o zoom terminar.",
"config.ok_zoomer.tweaks.use_spyglass_sounds": "Usar sons da luneta",
"config.ok_zoomer.tweaks.use_spyglass_sounds.tooltip": "Se ativado, o zoom irá usar os sons da luneta ao alternar o zoom.",
"config.ok_zoomer.tweaks.show_restriction_toasts": "Notificações de restrições",
"config.ok_zoomer.tweaks.show_restriction_toasts.tooltip": "Mostra notificações quando o servidor impor uma restrição.",
"config.ok_zoomer.tweaks.print_owo_on_start": "Imprimir owo ao iniciar",
"config.ok_zoomer.tweaks.print_owo_on_start.tooltip": "Imprime um owo aleatório no console quando o jogo iniciar",
"config.ok_zoomer.tweaks.print_owo_on_start.tooltip": "Imprime um owo aleatório no console quando o jogo inicia.",
"config.ok_zoomer.presets": "Predefinições",
"config.ok_zoomer.presets.preset": "Predefinição",
"config.ok_zoomer.presets.preset.camera": "Câmera",
Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/assets/ok_zoomer/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@
"config.ok_zoomer.tweaks.forget_zoom_divisor.tooltip": "如果启用,缩放完成后将遗忘当前缩放倍数。",
"config.ok_zoomer.tweaks.use_spyglass_sounds": "使用望远镜音效",
"config.ok_zoomer.tweaks.use_spyglass_sounds.tooltip": "如果启用,缩放时将使用望远镜的音效。",
"config.ok_zoomer.tweaks.show_restriction_toasts": "显示限制提示",
"config.ok_zoomer.tweaks.show_restriction_toasts.tooltip": "当服务器施加限制时显示提示。",
"config.ok_zoomer.tweaks.print_owo_on_start": "启动时打印owo",
"config.ok_zoomer.tweaks.print_owo_on_start.tooltip": "游戏启动时在控制台中随机打印一个owo。",
"config.ok_zoomer.presets": "预设",
Expand Down
2 changes: 0 additions & 2 deletions src/main/resources/assets/ok_zoomer/lang/zh_tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@
"config.ok_zoomer.tweaks.forget_zoom_divisor.tooltip": "如果啟用,則在縮放完成後忘記當前的縮放除數。",
"config.ok_zoomer.tweaks.use_spyglass_sounds": "使用望遠鏡音效",
"config.ok_zoomer.tweaks.use_spyglass_sounds.tooltip": "如果啟用,縮放將在放大和縮小時使用望遠鏡音效。",
"config.ok_zoomer.tweaks.show_restriction_toasts": "顯示限制快顯",
"config.ok_zoomer.tweaks.show_restriction_toasts.tooltip": "當伺服器強制執行限制時顯示快顯。",
"config.ok_zoomer.tweaks.print_owo_on_start": "啟動時列印 owo",
"config.ok_zoomer.tweaks.print_owo_on_start.tooltip": "遊戲啟動時在主控台中列印一個隨機的 owo。",
"config.ok_zoomer.presets": "預設",
Expand Down

0 comments on commit f929a89

Please sign in to comment.