Skip to content

Commit

Permalink
Prepare the 5.0.0-beta.2
Browse files Browse the repository at this point in the history
Brazilian Portuguese is once again back to 100%! About the other languages, sorry, but I needed to do few tweaks in order to keep them compatible with the new config screen
  • Loading branch information
EnnuiL committed Jun 21, 2021
1 parent 6e16e53 commit c6cf9fc
Show file tree
Hide file tree
Showing 24 changed files with 374 additions and 457 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ maven_group = io.github.ennuil
archives_base_name = okzoomer

# Dependencies
fabric_version = 0.35.2+1.17
fabric_version = 0.36.0+1.17
libzoomer_version = d3768b8f1f
mod_menu_version = 2.0.2
spruceui_version = 3.2.0+1.17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
import io.github.ennuil.okzoomer.packets.ZoomPackets;
import net.fabricmc.api.ClientModInitializer;

//This class is responsible for registering the events and packets.
// This class is responsible for registering the events and packets.
public class OkZoomerClientMod implements ClientModInitializer {
@Override
public void onInitializeClient() {
//Load the events.
// Load the events.
LoadConfigEvent.registerEvent();
ManageZoomEvent.registerEvent();
ManageExtraKeysEvent.registerEvent();

//Register the zoom-controlling packets.
// Register the zoom-controlling packets.
ZoomPackets.registerPackets();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import net.fabricmc.loader.api.FabricLoader;

// TODO - Move to whatever Config API gets standarized for Quilt
//The class responsible for loading and saving the config.
// The class responsible for loading and saving the config.
public class OkZoomerConfig {
public static boolean isConfigLoaded = false;
public static final Path CONFIG_PATH = FabricLoader.getInstance().getConfigDir().resolve("okzoomer.json5");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ public static class ValuesGroup {
public double maximumZoomedFOV = 110.0;

@Setting.Constrain.Range(min = 0.0)
@Setting(comment = "The number which is de/incremented by zoom scrolling. Used when the zoom divisor is above the starting point.")
@Setting(comment = "The number which is decremented or incremented by zoom scrolling. Used when the zoom divisor is above the starting point.")
public double scrollStep = 1.0;

@Setting(comment = "The number which is de/incremented by zoom scrolling. Used when the zoom divisor is below the starting point.")
@Setting(comment = "The number which is decremented or incremented by zoom scrolling. Used when the zoom divisor is below the starting point.")
public double lesserScrollStep = 0.5;

@Setting.Constrain.Range(min = Double.MIN_NORMAL, max = 1.0)
Expand Down Expand Up @@ -100,7 +100,7 @@ public static class TweaksGroup {
public boolean resetZoomWithMouse = true;
@Setting(comment = "If enabled, the \"Save Toolbar Activator\" keybind will be unbound if there's a conflict with the zoom key.")
public boolean unbindConflictingKey = true;
//TODO - Revert this once 5.0.0 is properly released
// TODO - Revert this once 5.0.0 is properly released
@Setting(comment = "Prints a random owo in the console when the game starts. Enabled by default until full release.")
public boolean printOwoOnStart = true;
@Setting(comment = "Hides the zoom overlay while the HUD's hidden.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;

// The lack of the yellow background is boring
// TODO - Restore the yellow background
public class OkZoomerConfigScreen extends SpruceScreen {
private final Screen parent;
private SpruceOptionListWidget list;
Expand Down Expand Up @@ -47,7 +49,10 @@ protected void init() {
this.list = new SpruceOptionListWidget(Position.of(0, 22), this.width, this.height - 36 - 22);

// "Features" category separator
var featuresSeparator = new SpruceSeparatorOption("config.okzoomer.category.features", true, null);
var featuresSeparator = new SpruceSeparatorOption(
"config.okzoomer.category.features",
true,
new TranslatableText("config.okzoomer.category.features.tooltip"));

// Cinematic Camera
var cinematicCameraOption = new SpruceCyclingOption(
Expand Down Expand Up @@ -129,7 +134,10 @@ protected void init() {
new TranslatableText("config.okzoomer.zoom_overlay.tooltip"));

// "Values" category separator
var valuesSeparator = new SpruceSeparatorOption("config.okzoomer.category.values", true, null);
var valuesSeparator = new SpruceSeparatorOption(
"config.okzoomer.category.values",
true,
new TranslatableText("config.okzoomer.category.values.tooltip"));

// Zoom Divisor
var zoomDivisorOption = new SpruceDoubleInputOption(
Expand Down Expand Up @@ -195,7 +203,10 @@ protected void init() {
new TranslatableText("config.okzoomer.maximum_linear_step.tooltip"));

// "Tweaks" category separator
var tweaksSeparator = new SpruceSeparatorOption("config.okzoomer.category.tweaks", true, null);
var tweaksSeparator = new SpruceSeparatorOption(
"config.okzoomer.category.tweaks",
true,
new TranslatableText("config.okzoomer.category.tweaks.tooltip"));

// Reset Zoom with Mouse
var resetZoomWithMouseOption = new SpruceBooleanOption(
Expand All @@ -218,8 +229,11 @@ protected void init() {
value -> OkZoomerConfigPojo.tweaks.printOwoOnStart = value,
new TranslatableText("config.okzoomer.print_owo_on_start.tooltip"));

// "Tweaks" category separator
var presetsSeparator = new SpruceSeparatorOption("config.okzoomer.category.presets", true, null);
// "Reset" category separator
var resetSeparator = new SpruceSeparatorOption(
"config.okzoomer.category.reset",
true,
new TranslatableText("config.okzoomer.category.reset.tooltip"));

// Preset
var presetOption = new SpruceCyclingOption(
Expand Down Expand Up @@ -267,7 +281,7 @@ protected void init() {
this.list.addOptionEntry(resetZoomWithMouseOption, unbindConflictingKeyOption);
this.list.addSingleOptionEntry(printOwoOnStartOption);

this.list.addSingleOptionEntry(presetsSeparator);
this.list.addSingleOptionEntry(resetSeparator);
this.list.addOptionEntry(presetOption, resetSettingsOption);

this.addDrawableChild(this.list);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@
import io.github.ennuil.okzoomer.utils.ZoomUtils;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;

//The event that makes sure to load the config and puts any load-once options in effect if enabled through the config file.
// The event that makes sure to load the config and puts any load-once options in effect if enabled through the config file.
public class LoadConfigEvent {
public static void registerEvent() {
ClientLifecycleEvents.CLIENT_STARTED.register(client -> {
//Attempt to load the config if it hasn't been loaded yet, which is unlikely due to extra keybinds.
// Attempt to load the config if it hasn't been loaded yet, which is unlikely due to extra keybinds.
if (!OkZoomerConfig.isConfigLoaded) {
OkZoomerConfig.loadModConfig();
}

//uwu
OwoUtils.printOwo();
// uwu
if (OkZoomerConfigPojo.tweaks.printOwoOnStart) {
OwoUtils.printOwo();
}

//This handles the hijacking of the "Save Toolbar Activator" key.
// This handles the unbinding of the "Save Toolbar Activator" key.
if (OkZoomerConfigPojo.tweaks.unbindConflictingKey) {
ZoomUtils.unbindConflictingKey(client, false);
OkZoomerConfigPojo.tweaks.unbindConflictingKey = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import io.github.ennuil.okzoomer.utils.ZoomUtils;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;

//This event manages the extra keybinds' behavior.
// This event manages the extra keybinds' behavior.
public class ManageExtraKeysEvent {
public static void registerEvent() {
//Register the event only if the "Extra Keybinds" option is enabled.
// Register the event only if the "Extra Keybinds" option is enabled.
if (ZoomKeybinds.areExtraKeybindsEnabled()) {
ClientTickEvents.END_CLIENT_TICK.register(client -> {
if (ZoomPackets.getDisableZoomScrolling()) return;
Expand Down
20 changes: 10 additions & 10 deletions src/main/java/io/github/ennuil/okzoomer/events/ManageZoomEvent.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
import io.github.ennuil.okzoomer.utils.ZoomUtils;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;

//This event is responsible for managing the zoom signal.
// This event is responsible for managing the zoom signal.
public class ManageZoomEvent {
//Used internally in order to make zoom toggling possible.
// Used internally in order to make zoom toggling possible.
private static boolean lastZoomPress = false;

//Used internally in order to make persistent zoom less buggy.
// Used internally in order to make persistent zoom less buggy.
private static boolean persistentZoom = false;

public static void registerEvent() {
ClientTickEvents.END_CLIENT_TICK.register(client -> {
//If zoom is disabled, do not allow for zooming at all.
// If zoom is disabled, do not allow for zooming at all.
if (ZoomPackets.getDisableZoom()) return;

//Handle zoom mode changes.
// Handle zoom mode changes.
if (!OkZoomerConfigPojo.features.zoomMode.equals(ZoomModes.HOLD)) {
if (!persistentZoom) {
persistentZoom = true;
Expand All @@ -34,29 +34,29 @@ public static void registerEvent() {
}
}

//If the press state is the same as the previous tick's, cancel the rest. Makes toggling usable and the zoom divisor adjustable.
// If the press state is the same as the previous tick's, cancel the rest. Makes toggling usable and the zoom divisor adjustable.
if (ZoomKeybinds.zoomKey.isPressed() == lastZoomPress) return;

switch (OkZoomerConfigPojo.features.zoomMode) {
case HOLD -> {
//If the zoom needs to be held, then the zoom signal is determined by if the key is pressed or not.
// If the zoom needs to be held, then the zoom signal is determined by if the key is pressed or not.
ZoomUtils.zoomerZoom.setZoom(ZoomKeybinds.zoomKey.isPressed());
ZoomUtils.zoomerZoom.resetZoomDivisor();
}
case TOGGLE -> {
//If the zoom needs to be toggled, toggle the zoom signal instead.
// If the zoom needs to be toggled, toggle the zoom signal instead.
if (ZoomKeybinds.zoomKey.isPressed()) {
ZoomUtils.zoomerZoom.setZoom(!ZoomUtils.zoomerZoom.getZoom());
ZoomUtils.zoomerZoom.resetZoomDivisor();
}
}
case PERSISTENT -> {
//If persistent zoom is enabled, just keep the zoom on.
// If persistent zoom is enabled, just keep the zoom on.
ZoomUtils.zoomerZoom.setZoom(true);
}
}

//Set the previous zoom signal for the next tick.
// Set the previous zoom signal for the next tick.
lastZoomPress = ZoomKeybinds.zoomKey.isPressed();
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;

//Manages the zoom keybinds themselves.
// Manages the zoom keybinds themselves.
public class ZoomKeybinds {
//The zoom keybinding, which will be registered.
// The zoom keybinding, which will be registered.
public static final KeyBinding zoomKey = KeyBindingHelper.registerKeyBinding(
new KeyBinding("key.okzoomer.zoom", GLFW.GLFW_KEY_C, "key.okzoomer.category"));

//The "Decrease Zoom" keybinding.
// The "Decrease Zoom" keybinding.
public static final KeyBinding decreaseZoomKey = getExtraKeybind("key.okzoomer.decrease_zoom");

//The "Increase Zoom" keybinding.
// The "Increase Zoom" keybinding.
public static final KeyBinding increaseZoomKey = getExtraKeybind("key.okzoomer.increase_zoom");

//The "Reset Zoom" keybinding.
// The "Reset Zoom" keybinding.
public static final KeyBinding resetZoomKey = getExtraKeybind("key.okzoomer.reset_zoom");

//The boolean used to keep track of the "Extra Keybinds" option's initial value.
// The boolean used to keep track of the "Extra Keybinds" option's initial value.
private static boolean extraKeybinds = false;

//The method used to check if the zoom manipulation keybinds should be disabled, can be used by other mods.
// The method used to check if the zoom manipulation keybinds should be disabled, can be used by other mods.
public static final boolean areExtraKeybindsEnabled() {
if (!OkZoomerConfig.isConfigLoaded) {
OkZoomerConfig.loadModConfig();
Expand All @@ -35,7 +35,7 @@ public static final boolean areExtraKeybindsEnabled() {
return extraKeybinds;
}

//The method used to get the extra keybinds, if disabled, return null.
// The method used to get the extra keybinds, if disabled, return null.
public static final KeyBinding getExtraKeybind(String translationKey) {
if (areExtraKeybindsEnabled()) {
return KeyBindingHelper.registerKeyBinding(
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/io/github/ennuil/okzoomer/mixin/MouseMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
import io.github.ennuil.okzoomer.utils.ZoomUtils;
import net.minecraft.client.Mouse;

//This mixin is responsible for the mouse-behavior-changing part of the zoom.
// This mixin is responsible for the mouse-behavior-changing part of the zoom.
@Mixin(Mouse.class)
public class MouseMixin {
@Shadow
private double eventDeltaWheel;

//Handles zoom scrolling.
// Handles zoom scrolling.
@Inject(
at = @At(value = "FIELD", target = "Lnet/minecraft/client/Mouse;eventDeltaWheel:D", ordinal = 7),
method = "onMouseScroll(JDD)V",
Expand All @@ -41,7 +41,7 @@ private void zoomerOnMouseScroll(CallbackInfo info) {
}
}

//Handles the zoom scrolling reset through the middle button.
// Handles the zoom scrolling reset through the middle button.
@Inject(
at = @At(value = "INVOKE", target = "net/minecraft/client/option/KeyBinding.setKeyPressed(Lnet/minecraft/client/util/InputUtil$Key;Z)V"),
method = "onMouseButton(JIII)V",
Expand Down
29 changes: 22 additions & 7 deletions src/main/java/io/github/ennuil/okzoomer/packets/ZoomPackets.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import io.github.ennuil.okzoomer.config.OkZoomerConfig;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
// import net.fabricmc.fabric.api.networking.v1.PacketByteBufs;
// import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.toast.SystemToast;
import net.minecraft.network.PacketByteBuf;
// import net.minecraft.network.PacketByteBuf;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.minecraft.util.Identifier;
Expand All @@ -16,14 +16,16 @@
These packets are intended to be used by the future "Zoomer Boomer" server-side mod,
although developers are welcome to independently transmit them for other loaders */
public class ZoomPackets {
//The IDs for packets that allows the server to have some control on the zoom.
// The IDs for packets that allows the server to have some control on the zoom.
public static final Identifier DISABLE_ZOOM_PACKET_ID = new Identifier("okzoomer", "disable_zoom");
public static final Identifier DISABLE_ZOOM_SCROLLING_PACKET_ID = new Identifier("okzoomer", "disable_zoom_scrolling");
public static final Identifier FORCE_CLASSIC_MODE_PACKET_ID = new Identifier("okzoomer", "force_classic_mode");
public static final Identifier FORCE_ZOOM_DIVISOR_PACKET_ID = new Identifier("okzoomer", "force_zoom_divisor");
public static final Identifier ACKNOWLEDGE_MOD_PACKET_ID = new Identifier("okzoomer", "acknowledge_mod");
// Reserved for later
public static final Identifier FORCE_SPYGLASS_PACKET_ID = new Identifier("okzoomer", "force_spyglass");

//The signals used by other parts of the zoom in order to enforce the packets.
// The signals used by other parts of the zoom in order to enforce the packets.
private static boolean disableZoom = false;
private static boolean disableZoomScrolling = false;
private static boolean forceClassicMode = false;
Expand All @@ -34,7 +36,7 @@ public class ZoomPackets {
private static TranslatableText toastTitle = new TranslatableText("toast.okzoomer.title");

private static void sendToast(MinecraftClient client, Text description) {
SystemToast.add(client.getToastManager(), SystemToast.Type.TUTORIAL_HINT, toastTitle, description);
client.getToastManager().add(SystemToast.create(client, SystemToast.Type.TUTORIAL_HINT, toastTitle, description));
}

//Registers all the packets
Expand Down Expand Up @@ -109,6 +111,18 @@ public static void registerPackets() {
});
});

/* TODO - The "Force Spyglass" packet,
This packet will let the server restrict the mod to spyglass-only usage
Not supported yet!
Arguments: probably some, we'll see */
ClientPlayNetworking.registerGlobalReceiver(ACKNOWLEDGE_MOD_PACKET_ID, (client, handler, buf, sender) -> {
client.execute(() -> {
sendToast(client, new TranslatableText("toast.okzoomer.disable_zoom"));
disableZoom = true;
});
});

/*
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
PacketByteBuf boolBuf = PacketByteBufs.create();
boolBuf.writeBoolean(true);
Expand All @@ -120,7 +134,8 @@ public static void registerPackets() {
PacketByteBuf buf = PacketByteBufs.create();
buf.writeDouble(4.0D);
sender.sendPacket(FORCE_ZOOM_DIVISOR_PACKET_ID, buf);
});
});
*/

ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> {
if (ZoomPackets.disableZoom || ZoomPackets.disableZoomScrolling || ZoomPackets.forceClassicMode) {
Expand Down
Loading

0 comments on commit c6cf9fc

Please sign in to comment.