Skip to content

Commit

Permalink
Prepare for a beta
Browse files Browse the repository at this point in the history
  • Loading branch information
EnnuiL committed Jun 26, 2022
1 parent 2d2b1f7 commit 8faa185
Show file tree
Hide file tree
Showing 38 changed files with 738 additions and 628 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ org.gradle.jvmargs = -Xmx1G
org.gradle.parallel = true

# Mod Properties
version = 5.0.0-beta.7+1.19
version = 5.0.0-beta.8+1.19
maven_group = io.github.ennuil
archives_base_name = ok_zoomer
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ minecraft = "1.19"
quilt_mappings = "1.19+build.1" # Latest version is available at https://lambdaurora.dev/tools/import_quilt.html
quilt_loader = "0.17.1-beta.4" # Latest version is available at https://fabricmc.net/versions.html

quilted_fabric_api = "2.0.0-alpha.4+0.56.1-1.19"
quilted_fabric_api = "2.0.0-beta.1+0.56.3-1.19"
libzoomer = "0.5.0+1.19"
mod_menu = "4.0.0"
spruceui = "4.0.0+1.19"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.ennuil.ok_zoomer;

import org.quiltmc.config.impl.builders.TrackedValueBuilderImpl;
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.client.ClientModInitializer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.loader.api.entrypoint.PreLaunchEntrypoint;

import io.github.ennuil.ok_zoomer.config.WidgetSize;
import com.llamalad7.mixinextras.MixinExtrasBootstrap;

import io.github.ennuil.ok_zoomer.config.metadata.WidgetSize;

public class OkZoomerPreLaunchMod implements PreLaunchEntrypoint {
@Override
public void onPreLaunch(ModContainer mod) {
MixinExtrasBootstrap.init();
ConfigFieldAnnotationProcessors.register(WidgetSize.class, new WidgetSize.Processor());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import dev.lambdaurora.spruceui.screen.SpruceScreen;
import dev.lambdaurora.spruceui.widget.SpruceButtonWidget;
import dev.lambdaurora.spruceui.widget.container.SpruceOptionListWidget;
import io.github.ennuil.ok_zoomer.config.OkZoomerConfigManager;
import io.github.ennuil.ok_zoomer.config.screen.OkZoomerConfigScreen;
import io.github.ennuil.ok_zoomer.config.screen.SpruceLabelOption;
import io.github.ennuil.ok_zoomer.config.screen.widgets.SpruceLabelOption;
import io.github.ennuil.ok_zoomer.packets.ZoomPackets;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
Expand Down Expand Up @@ -40,7 +41,7 @@ protected void init() {
this.list.addSingleOptionEntry(configButton);
this.list.addSingleOptionEntry(restrictionsSeparator);

boolean acknoledged = false;
boolean acknowledged = false;

if (ZoomPackets.getHasRestrictions()) {
var textLabel = new SpruceLabelOption("command.ok_zoomer.restrictions.acknowledgement", true);
Expand All @@ -67,15 +68,15 @@ protected void init() {
double maximumZoomDivisor = ZoomPackets.getMaximumZoomDivisor();
var textLabel = new SpruceLabelOption(
"command.ok_zoomer.restrictions.force_zoom_divisors",
minimumZoomDivisor == maximumZoomDivisor
minimumZoomDivisor != maximumZoomDivisor
? Text.translatable("command.ok_zoomer.restrictions.force_zoom_divisors", minimumZoomDivisor, maximumZoomDivisor)
: Text.translatable("command.ok_zoomer.restrictions.force_zoom_divisor", minimumZoomDivisor),
true);
this.list.addSingleOptionEntry(textLabel);
}

if (ZoomPackets.getSpyglassDependency() != null) {
String key = switch (ZoomPackets.getSpyglassDependency()) {
if (ZoomPackets.getSpyglassDependency()) {
String key = switch (OkZoomerConfigManager.SPYGLASS_DEPENDENCY.value()) {
case REQUIRE_ITEM -> "command.ok_zoomer.restrictions.force_spyglass.require_item";
case REPLACE_ZOOM -> "command.ok_zoomer.restrictions.force_spyglass.replace_zoom";
case BOTH -> "command.ok_zoomer.restrictions.force_spyglass.both";
Expand All @@ -91,7 +92,7 @@ protected void init() {
}

if (!ZoomPackets.getHasRestrictions()) {
if (acknoledged) {
if (acknowledged) {
var textLabel = new SpruceLabelOption("command.ok_zoomer.restrictions.no_restrictions.acknowledged", true);
this.list.addSingleOptionEntry(textLabel);
} else {
Expand Down
57 changes: 52 additions & 5 deletions src/main/java/io/github/ennuil/ok_zoomer/config/ConfigEnums.java
Original file line number Diff line number Diff line change
@@ -1,34 +1,81 @@
package io.github.ennuil.ok_zoomer.config;

public class ConfigEnums {
public enum CinematicCameraOptions {
public enum CinematicCameraOptions implements ConfigEnum {
OFF,
VANILLA,
MULTIPLIED;

@Override
public Enum<?> next() {
var enumValues = this.getDeclaringClass().getEnumConstants();
return enumValues[this.ordinal() + 1 < enumValues.length ? this.ordinal() + 1 : 0];
}
}

public enum ZoomTransitionOptions {
public enum ZoomTransitionOptions implements ConfigEnum {
OFF,
SMOOTH,
LINEAR;

@Override
public Enum<?> next() {
var enumValues = this.getDeclaringClass().getEnumConstants();
return enumValues[this.ordinal() + 1 < enumValues.length ? this.ordinal() + 1 : 0];
}
}

public enum ZoomModes {
public enum ZoomModes implements ConfigEnum {
HOLD,
TOGGLE,
PERSISTENT;

@Override
public Enum<?> next() {
var enumValues = this.getDeclaringClass().getEnumConstants();
return enumValues[this.ordinal() + 1 < enumValues.length ? this.ordinal() + 1 : 0];
}
}

public enum ZoomOverlays {
public enum ZoomOverlays implements ConfigEnum {
OFF,
VIGNETTE,
SPYGLASS;

@Override
public Enum<?> next() {
var enumValues = this.getDeclaringClass().getEnumConstants();
return enumValues[this.ordinal() + 1 < enumValues.length ? this.ordinal() + 1 : 0];
}
}

public enum SpyglassDependency {
public enum SpyglassDependency implements ConfigEnum {
OFF,
REQUIRE_ITEM,
REPLACE_ZOOM,
BOTH;

@Override
public Enum<?> next() {
var enumValues = this.getDeclaringClass().getEnumConstants();
return enumValues[this.ordinal() + 1 < enumValues.length ? this.ordinal() + 1 : 0];
}
}

public enum ZoomPresets implements ConfigEnum {
DEFAULT,
CLASSIC,
PERSISTENT,
SPYGLASS;

@Override
public Enum<?> next() {
var enumValues = this.getDeclaringClass().getEnumConstants();
return enumValues[this.ordinal() + 1 < enumValues.length ? this.ordinal() + 1 : 0];
}
}

public interface ConfigEnum {
Enum<?> next();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import io.github.ennuil.ok_zoomer.config.ConfigEnums.ZoomModes;
import io.github.ennuil.ok_zoomer.config.ConfigEnums.ZoomOverlays;
import io.github.ennuil.ok_zoomer.config.ConfigEnums.ZoomTransitionOptions;
import io.github.ennuil.ok_zoomer.config.WidgetSize.Size;
import io.github.ennuil.ok_zoomer.config.metadata.WidgetSize;
import io.github.ennuil.ok_zoomer.config.metadata.WidgetSize.Size;

public class OkZoomerConfig extends WrappedConfig {
@Comment("Contains the main zoom features.")
Expand Down Expand Up @@ -165,4 +166,6 @@ public class TweaksConfig implements Section {
@Comment("Prints a random owo in the console when the game starts. Enabled by default until full release.")
public final boolean print_owo_on_start = true;
}

// TODO - What if we had a secret Debug section?
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.List;

import org.quiltmc.config.api.annotations.ConfigFieldAnnotationProcessors;
import org.quiltmc.config.api.values.TrackedValue;
import org.quiltmc.loader.api.config.QuiltConfig;

Expand All @@ -18,7 +17,6 @@
import io.github.ennuil.ok_zoomer.config.ConfigEnums.ZoomModes;
import io.github.ennuil.ok_zoomer.config.ConfigEnums.ZoomOverlays;
import io.github.ennuil.ok_zoomer.config.ConfigEnums.ZoomTransitionOptions;
import io.github.ennuil.ok_zoomer.packets.ZoomPackets;
import io.github.ennuil.ok_zoomer.utils.ZoomUtils;
import io.github.ennuil.ok_zoomer.zoom.LinearTransitionMode;
import io.github.ennuil.ok_zoomer.zoom.MultipliedCinematicCameraMouseModifier;
Expand Down Expand Up @@ -66,45 +64,6 @@ public OkZoomerConfigManager() {
});
}

public static void resetToPreset(ZoomPresets preset) {
CINEMATIC_CAMERA.setValue(preset == ZoomPresets.CLASSIC ? CinematicCameraOptions.VANILLA : CinematicCameraOptions.OFF, false);
REDUCE_SENSITIVITY.setValue(preset == ZoomPresets.CLASSIC ? false : true, false);
ZOOM_TRANSITION.setValue(preset == ZoomPresets.CLASSIC ? ZoomTransitionOptions.OFF : ZoomTransitionOptions.SMOOTH, false);
ZOOM_MODE.setValue(preset == ZoomPresets.PERSISTENT ? ZoomModes.PERSISTENT : ZoomModes.HOLD, false);
ZOOM_SCROLLING.setValue(switch (preset) {
case CLASSIC -> false;
case SPYGLASS -> false;
default -> true;
}, false);
EXTRA_KEY_BINDS.setValue(preset == ZoomPresets.CLASSIC ? false : true, false);
ZOOM_OVERLAY.setValue(preset == ZoomPresets.SPYGLASS ? ZoomOverlays.SPYGLASS : ZoomOverlays.OFF, false);
SPYGLASS_DEPENDENCY.setValue(preset == ZoomPresets.SPYGLASS ? SpyglassDependency.BOTH : SpyglassDependency.OFF, false);

ZOOM_DIVISOR.setValue(switch (preset) {
case PERSISTENT -> 1.0D;
case SPYGLASS -> 10.0D;
default -> 4.0D;
}, false);
MINIMUM_ZOOM_DIVISOR.setValue(1.0D, false);
MAXIMUM_ZOOM_DIVISOR.setValue(50.0D, false);
UPPER_SCROLL_STEPS.setValue(preset == ZoomPresets.SPYGLASS ? 16 : 20, false);
LOWER_SCROLL_STEPS.setValue(preset == ZoomPresets.SPYGLASS ? 8 : 4, false);
SMOOTH_MULTIPLIER.setValue(preset == ZoomPresets.SPYGLASS ? 0.5D : 0.75D, false);
CINEMATIC_MULTIPLIER.setValue(4.0D, false);
MINIMUM_LINEAR_STEP.setValue(0.125D, false);
MAXIMUM_LINEAR_STEP.setValue(0.25D, false);

RESET_ZOOM_WITH_MOUSE.setValue(preset == ZoomPresets.CLASSIC ? false : true, false);
UNBIND_CONFLICTING_KEY.setValue(false, false);
USE_SPYGLASS_TEXTURE.setValue(preset == ZoomPresets.SPYGLASS ? true : false, false);
USE_SPYGLASS_SOUNDS.setValue(preset == ZoomPresets.SPYGLASS ? true : false, false);
SHOW_RESTRICTION_TOASTS.setValue(true, false);
PRINT_OWO_ON_START.setValue(preset == ZoomPresets.CLASSIC ? false : true, false);

CONFIG.save();
}

// TODO - Use Quilt Config's Override system
public static void configureZoomInstance() {
// Sets zoom transition
ZoomUtils.ZOOMER_ZOOM.setTransitionMode(
Expand All @@ -115,14 +74,6 @@ public static void configureZoomInstance() {
}
);

// Forces Classic Mode settings
if (ZoomPackets.getForceClassicMode()) {
ZoomUtils.ZOOMER_ZOOM.setDefaultZoomDivisor(4.0D);
ZoomUtils.ZOOMER_ZOOM.setMouseModifier(new CinematicCameraMouseModifier());
ZoomUtils.ZOOMER_ZOOM.setZoomOverlay(null);
return;
}

// Sets zoom divisor
ZoomUtils.ZOOMER_ZOOM.setDefaultZoomDivisor(ZOOM_DIVISOR.value());

Expand All @@ -135,11 +86,8 @@ public static void configureZoomInstance() {
? "textures/misc/spyglass_scope.png"
: "ok_zoomer:textures/misc/zoom_overlay.png");

// Enforce spyglass overlay if necessary
ZoomOverlays overlay = ZoomPackets.getSpyglassOverlay() ? ZoomOverlays.SPYGLASS : ZOOM_OVERLAY.value();

ZoomUtils.ZOOMER_ZOOM.setZoomOverlay(
switch (overlay) {
switch (ZOOM_OVERLAY.value()) {
case VIGNETTE -> new ZoomerZoomOverlay(overlayTextureId);
case SPYGLASS -> new SpyglassZoomOverlay(overlayTextureId);
default -> null;
Expand All @@ -161,17 +109,7 @@ public static void configureZoomModifier() {
: cinematicModifier
);
} else {
ZoomUtils.ZOOMER_ZOOM.setMouseModifier(reduceSensitivity
? new ZoomDivisorMouseModifier()
: null
);
ZoomUtils.ZOOMER_ZOOM.setMouseModifier(reduceSensitivity ? new ZoomDivisorMouseModifier() : null);
}
}

public enum ZoomPresets {
DEFAULT,
CLASSIC,
PERSISTENT,
SPYGLASS
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.github.ennuil.ok_zoomer.config;
package io.github.ennuil.ok_zoomer.config.metadata;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
Expand Down
Loading

0 comments on commit 8faa185

Please sign in to comment.