Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
TexBlock committed Feb 8, 2024
1 parent cf9873d commit 832b0aa
Show file tree
Hide file tree
Showing 19 changed files with 138 additions and 131 deletions.
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
package org.thinkingstudio.mio_zoomer;

import dev.architectury.event.EventResult;
import dev.architectury.event.events.client.ClientRawInputEvent;
import dev.architectury.platform.Platform;
import dev.architectury.registry.client.keymappings.KeyMappingRegistry;
import org.lwjgl.glfw.GLFW;
import org.thinkingstudio.mio_zoomer.config.ConfigEnums;

import org.thinkingstudio.mio_zoomer.config.MioZoomerConfigManager;
import org.thinkingstudio.mio_zoomer.config.screen.MioZoomerConfigScreen;
import org.thinkingstudio.mio_zoomer.key_binds.ZoomKeyBinds;
import org.thinkingstudio.mio_zoomer.packets.ZoomPackets;
import org.thinkingstudio.mio_zoomer.utils.ZoomUtils;


// This class is responsible for registering the commands and packets
public class MioZoomerClientMod {
public static final String MODID = "mio_zoomer";

public static void onInitClient() {
}

public void onInitializeClient() {
// Initialize the config
new MioZoomerConfigManager();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.thinkingstudio.mio_zoomer.config.metadata.WidgetSize;

public class MioZoomerPreLaunchMod {

public static void onPreLaunch() {
ConfigFieldAnnotationProcessor.register(WidgetSize.class, new WidgetSize.Processor());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package org.thinkingstudio.mio_zoomer.commands;

import org.thinkingstudio.mio_zoomer.config.MioZoomerConfigManager;
import org.thinkingstudio.mio_zoomer.config.screen.MioZoomerConfigScreen;
import org.thinkingstudio.mio_zoomer.config.screen.widgets.SpruceLabelOption;
import org.thinkingstudio.mio_zoomer.packets.ZoomPackets;

import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.text.Text;
import org.thinkingstudio.obsidianui.Position;
import org.thinkingstudio.obsidianui.SpruceTexts;
import org.thinkingstudio.obsidianui.background.SimpleColorBackground;
Expand All @@ -11,10 +15,6 @@
import org.thinkingstudio.obsidianui.screen.SpruceScreen;
import org.thinkingstudio.obsidianui.widget.SpruceButtonWidget;
import org.thinkingstudio.obsidianui.widget.container.SpruceOptionListWidget;
import org.thinkingstudio.mio_zoomer.config.MioZoomerConfigManager;

import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.text.Text;

public class MioZoomerCommandScreen extends SpruceScreen {
private static final SimpleColorBackground DARKENED_BACKGROUND = new SimpleColorBackground(0, 0, 0, 128);
Expand Down Expand Up @@ -87,11 +87,11 @@ protected void init() {

if (!ZoomPackets.getHasRestrictions()) {
boolean acknowledged = ZoomPackets.getAcknowledgement().equals(ZoomPackets.Acknowledgement.HAS_NO_RESTRICTIONS);
if (acknowledged) {
list.addSingleOptionEntry(new SpruceLabelOption("command.mio_zoomer.restrictions.no_restrictions.acknowledged", true));
} else {
list.addSingleOptionEntry(new SpruceLabelOption("command.mio_zoomer.restrictions.no_restrictions", true));
}
list.addSingleOptionEntry(new SpruceLabelOption(acknowledged
? "command.mio_zoomer.restrictions.no_restrictions.acknowledged"
: "command.mio_zoomer.restrictions.no_restrictions",
true)
);
}

this.addDrawableChild(list);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
import org.quiltmc.config.api.annotations.Comment;
import org.quiltmc.config.api.annotations.FloatRange;
import org.quiltmc.config.api.annotations.IntegerRange;

import org.quiltmc.config.api.values.TrackedValue;

import org.thinkingstudio.mio_zoomer.config.ConfigEnums.CinematicCameraOptions;
import org.thinkingstudio.mio_zoomer.config.ConfigEnums.SpyglassDependency;
import org.thinkingstudio.mio_zoomer.config.ConfigEnums.ZoomModes;
import org.thinkingstudio.mio_zoomer.config.ConfigEnums.ZoomOverlays;
import org.thinkingstudio.mio_zoomer.config.ConfigEnums.ZoomTransitionOptions;
import org.thinkingstudio.mio_zoomer.config.metadata.WidgetSize;
import org.thinkingstudio.mio_zoomer.config.metadata.WidgetSize.Size;

public class MioZoomerConfig extends ReflectiveConfig {
@Comment("Contains the main zoom features.")
Expand All @@ -19,145 +25,145 @@ public class MioZoomerConfig extends ReflectiveConfig {
public final TweaksConfig tweaks = new TweaksConfig();

public static class FeaturesConfig extends Section {
@WidgetSize(WidgetSize.Size.HALF)
@WidgetSize(Size.HALF)
@Comment("""
Defines the cinematic camera while zooming.
"OFF" disables the cinematic camera.
"VANILLA" uses Vanilla's cinematic camera.
"MULTIPLIED" is a multiplied variant of "VANILLA".
""")
public final TrackedValue<ConfigEnums.CinematicCameraOptions> cinematic_camera = this.value(ConfigEnums.CinematicCameraOptions.OFF);
public final TrackedValue<CinematicCameraOptions> cinematic_camera = this.value(CinematicCameraOptions.OFF);

@WidgetSize(WidgetSize.Size.HALF)
@WidgetSize(Size.HALF)
@Comment("Reduces the mouse sensitivity when zooming.")
public final TrackedValue<Boolean> reduce_sensitivity = this.value(true);

@WidgetSize(WidgetSize.Size.FULL)
@WidgetSize(Size.FULL)
@Comment("""
Adds transitions between zooms.
"OFF" disables transitions.
"SMOOTH" replicates Vanilla's dynamic FOV.
"LINEAR" removes the smoothiness.
""")
public final TrackedValue<ConfigEnums.ZoomTransitionOptions> zoom_transition = this.value(ConfigEnums.ZoomTransitionOptions.SMOOTH);
public final TrackedValue<ZoomTransitionOptions> zoom_transition = this.value(ZoomTransitionOptions.SMOOTH);

@WidgetSize(WidgetSize.Size.HALF)
@WidgetSize(Size.HALF)
@Comment("""
The behavior of the zoom key.
"HOLD" needs the zoom key to be hold.
"TOGGLE" has the zoom key toggle the zoom.
"PERSISTENT" makes the zoom permanent.
""")
public final TrackedValue<ConfigEnums.ZoomModes> zoom_mode = this.value(ConfigEnums.ZoomModes.HOLD);
public final TrackedValue<ZoomModes> zoom_mode = this.value(ZoomModes.HOLD);

@WidgetSize(WidgetSize.Size.HALF)
@WidgetSize(Size.HALF)
@Comment("Allows to increase or decrease zoom by scrolling.")
public final TrackedValue<Boolean> zoom_scrolling = this.value(true);

@WidgetSize(WidgetSize.Size.HALF)
@WidgetSize(Size.HALF)
@Comment("Adds zoom manipulation keys along with the zoom key.")
public final TrackedValue<Boolean> extra_key_binds = this.value(true);

@WidgetSize(WidgetSize.Size.HALF)
@WidgetSize(Size.HALF)
@Comment("""
Adds an overlay in the screen during zoom.
"VIGNETTE" uses a vignette as the overlay.
"SPYGLASS" uses the spyglass overlay with the vignette texture.
The vignette texture can be found at: assets/mio_zoomer/textures/misc/zoom_overlay.png
""")
public final TrackedValue<ConfigEnums.ZoomOverlays> zoom_overlay = this.value(ConfigEnums.ZoomOverlays.OFF);
public final TrackedValue<ZoomOverlays> zoom_overlay = this.value(ZoomOverlays.OFF);

@WidgetSize(WidgetSize.Size.FULL)
@WidgetSize(Size.FULL)
@Comment("""
Determines how the zoom will depend on the spyglass.
"REQUIRE_ITEM" will make zooming require a spyglass.
"REPLACE_ZOOM" will replace spyglass's zoom with Mio Zoomer's zoom.
"REPLACE_ZOOM" will replace spyglass's zoom with Ok Zoomer's zoom.
"BOTH" will apply both options at the same time.
The "REQUIRE_ITEM" option is configurable through the mio_zoomer:zoom_dependencies item tag.
""")
public final TrackedValue<ConfigEnums.SpyglassDependency> spyglass_dependency = this.value(ConfigEnums.SpyglassDependency.OFF);
public final TrackedValue<SpyglassDependency> spyglass_dependency = this.value(SpyglassDependency.OFF);
}

public static class ValuesConfig extends Section {
@WidgetSize(WidgetSize.Size.FULL)
public static class ValuesConfig extends Section {
@WidgetSize(Size.FULL)
@Comment("The divisor applied to the FOV when zooming.")
@FloatRange(min = Double.MIN_NORMAL, max = Double.MAX_VALUE)
public final TrackedValue<Double> zoom_divisor = this.value(4.0);

@WidgetSize(WidgetSize.Size.HALF)
@WidgetSize(Size.HALF)
@Comment("The minimum value that you can scroll down.")
@FloatRange(min = Double.MIN_NORMAL, max = Double.MAX_VALUE)
public final TrackedValue<Double> minimum_zoom_divisor = this.value(1.0);

@WidgetSize(WidgetSize.Size.HALF)
@WidgetSize(Size.HALF)
@Comment("The maximum value that you can scroll down.")
@FloatRange(min = Double.MIN_NORMAL, max = Double.MAX_VALUE)
public final TrackedValue<Double> maximum_zoom_divisor = this.value(50.0);

@WidgetSize(WidgetSize.Size.HALF)
@WidgetSize(Size.HALF)
@Comment("""
The number of steps between the zoom divisor and the maximum zoom divisor.
Used by zoom scrolling.
""")
@IntegerRange(min = 0, max = Integer.MAX_VALUE)
public final TrackedValue<Integer> upper_scroll_steps = this.value(10);

@WidgetSize(WidgetSize.Size.HALF)
@WidgetSize(Size.HALF)
@Comment("""
The number of steps between the zoom divisor and the minimum zoom divisor.
Used by zoom scrolling.
""")
@IntegerRange(min = 0, max = Integer.MAX_VALUE)
public final TrackedValue<Integer> lower_scroll_steps = this.value(5);

@WidgetSize(WidgetSize.Size.HALF)
@WidgetSize(Size.HALF)
@Comment("The multiplier used for smooth transitions.")
@FloatRange(min = Double.MIN_NORMAL, max = 1.0)
public final TrackedValue<Double> smooth_multiplier = this.value(0.75);

@WidgetSize(WidgetSize.Size.HALF)
@WidgetSize(Size.HALF)
@Comment("The multiplier used for the multiplied cinematic camera.")
@FloatRange(min = Double.MIN_NORMAL, max = 32.0)
public final TrackedValue<Double> cinematic_multiplier = this.value(4.0);

@WidgetSize(WidgetSize.Size.HALF)
@WidgetSize(Size.HALF)
@Comment("The minimum value which the linear transition step can reach.")
@FloatRange(min = 0.0, max = Double.MAX_VALUE)
public final TrackedValue<Double> minimum_linear_step = this.value(0.125);

@WidgetSize(WidgetSize.Size.HALF)
@WidgetSize(Size.HALF)
@Comment("The maximum value which the linear transition step can reach.")
@FloatRange(min = 0.0, max = Double.MAX_VALUE)
public final TrackedValue<Double> maximum_linear_step = this.value(0.25);
}

public static class TweaksConfig extends Section {
@WidgetSize(WidgetSize.Size.HALF)
public static class TweaksConfig extends Section {
@WidgetSize(Size.HALF)
@Comment("Allows for resetting the zoom with the middle mouse button.")
public final TrackedValue<Boolean> reset_zoom_with_mouse = this.value(true);

@WidgetSize(WidgetSize.Size.HALF)
@WidgetSize(Size.HALF)
@Comment("If enabled, the current zoom divisor is forgotten once zooming is done.")
public final TrackedValue<Boolean> forget_zoom_divisor = this.value(true);

@WidgetSize(WidgetSize.Size.FULL)
@WidgetSize(Size.FULL)
@Comment("If pressed, the \"Save Toolbar Activator\" keybind will be unbound if there's a conflict with the zoom key.")
public final TrackedValue<Boolean> unbind_conflicting_key = this.value(true);

@WidgetSize(WidgetSize.Size.HALF)
@Comment("If enabled, the spyglass overlay texture is used instead of Mio Zoomer's overlay texture.")
@WidgetSize(Size.HALF)
@Comment("If enabled, the spyglass overlay texture is used instead of Ok Zoomer's overlay texture.")
public final TrackedValue<Boolean> use_spyglass_texture = this.value(false);

@WidgetSize(WidgetSize.Size.HALF)
@WidgetSize(Size.HALF)
@Comment("If enabled, the zoom will use spyglass sounds on zooming in and out.")
public final TrackedValue<Boolean> use_spyglass_sounds = this.value(false);

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

// TODO - Enable it again during eternal betas!
@WidgetSize(WidgetSize.Size.HALF)
@WidgetSize(Size.HALF)
@Comment("Prints a random owo in the console when the game starts.")
public final TrackedValue<Boolean> print_owo_on_start = this.value(false);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
package org.thinkingstudio.mio_zoomer.config;

import ho.artisan.azusaconfig.api.config.v2.AzusaConfig;
import org.thinkingstudio.mio_zoomer.MioZoomerClientMod;
import org.thinkingstudio.mio_zoomer.config.ConfigEnums.CinematicCameraOptions;
import org.thinkingstudio.mio_zoomer.utils.ZoomUtils;
import org.thinkingstudio.mio_zoomer.zoom.LinearTransitionMode;
import org.thinkingstudio.mio_zoomer.zoom.MultipliedCinematicCameraMouseModifier;
import org.thinkingstudio.mio_zoomer.zoom.ZoomerZoomOverlay;
import net.minecraft.util.Identifier;
import org.thinkingstudio.zoomerlibrary.api.MouseModifier;
import org.thinkingstudio.zoomerlibrary.api.modifiers.CinematicCameraMouseModifier;
import org.thinkingstudio.zoomerlibrary.api.modifiers.ContainingMouseModifier;
import org.thinkingstudio.zoomerlibrary.api.modifiers.ZoomDivisorMouseModifier;
import org.thinkingstudio.zoomerlibrary.api.overlays.SpyglassZoomOverlay;
import org.thinkingstudio.zoomerlibrary.api.transitions.InstantTransitionMode;
import org.thinkingstudio.zoomerlibrary.api.transitions.SmoothTransitionMode;
import net.minecraft.util.Identifier;

@SuppressWarnings("unchecked")
public class MioZoomerConfigManager {
public static final MioZoomerConfig CONFIG = AzusaConfig.create("mio_zoomer", "config", MioZoomerConfig.class);
public static final MioZoomerConfig CONFIG = AzusaConfig.create(MioZoomerClientMod.MODID, "config", MioZoomerConfig.class);

public MioZoomerConfigManager() {
// On initialization, configure our zoom instance
Expand Down Expand Up @@ -45,7 +46,7 @@ public static void configureZoomInstance() {
Identifier overlayTextureId = new Identifier(
CONFIG.tweaks.use_spyglass_texture.value()
? "textures/misc/spyglass_scope.png"
: "mio_zoomer:textures/misc/zoom_overlay.png");
: MioZoomerClientMod.MODID + ":textures/misc/zoom_overlay.png");

ZoomUtils.ZOOMER_ZOOM.setZoomOverlay(
switch (CONFIG.features.zoom_overlay.value()) {
Expand All @@ -57,9 +58,9 @@ public static void configureZoomInstance() {
}

public static void configureZoomModifier() {
ConfigEnums.CinematicCameraOptions cinematicCamera = CONFIG.features.cinematic_camera.value();
CinematicCameraOptions cinematicCamera = CONFIG.features.cinematic_camera.value();
boolean reduceSensitivity = CONFIG.features.reduce_sensitivity.value();
if (cinematicCamera != ConfigEnums.CinematicCameraOptions.OFF) {
if (cinematicCamera != CinematicCameraOptions.OFF) {
MouseModifier cinematicModifier = switch (cinematicCamera) {
case VANILLA -> new CinematicCameraMouseModifier();
case MULTIPLIED -> new MultipliedCinematicCameraMouseModifier(CONFIG.values.cinematic_multiplier.value());
Expand Down
Loading

0 comments on commit 832b0aa

Please sign in to comment.