Skip to content

Commit

Permalink
Fix the edge case using new config
Browse files Browse the repository at this point in the history
Also, rearranged the config to be more neat and organized.
  • Loading branch information
Past Ennui committed Feb 4, 2020
1 parent c83c7bf commit 9398450
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 22 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ yarn_mappings=1.15.2+build.11
loader_version=0.7.6+build.181

# Mod Properties
mod_version = 2.1.0-beta.4
mod_version = 2.1.0
maven_group = io.github.joaoh1
archives_base_name = okzoomer

Expand Down
10 changes: 5 additions & 5 deletions src/main/java/io/github/joaoh1/okzoomer/OkZoomer.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static boolean shouldScrollZoom() {
double zoomDivisor = 4.0;

//Increases or decreases the zoom, used by zoom scrolling.
public static double scrollZoom(double providedZoomDivisor, double scrollAmount) {
public static double scrollZoom(double providedZoomDivisor, double scrollAmount, double minimumValue, double maximumValue) {
double generalAmount = 0.0;
if (providedZoomDivisor <= 5.0) {
generalAmount = 0.25;
Expand All @@ -77,12 +77,12 @@ public static double scrollZoom(double providedZoomDivisor, double scrollAmount)
if (shouldScrollZoom) {
providedZoomDivisor += scrollAmount;

if (providedZoomDivisor <= 1.0) {
return 1.0;
if (providedZoomDivisor <= minimumValue) {
return minimumValue;
}

if (providedZoomDivisor >= 50.0) {
return providedZoomDivisor -= scrollAmount;
if (providedZoomDivisor >= maximumValue) {
return maximumValue;
}

return providedZoomDivisor;
Expand Down
22 changes: 15 additions & 7 deletions src/main/java/io/github/joaoh1/okzoomer/OkZoomerConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,35 @@ public class OkZoomerConfig implements ConfigData {
@ConfigEntry.Gui.Tooltip(count = 2)
boolean smoothCamera = true;

@Comment("Reduces the mouse sensitivity when zooming.")
@ConfigEntry.Gui.Tooltip()
boolean reduceSensitivity = false;

@Comment("While enabled, zooming hides your hands.")
@ConfigEntry.Gui.Tooltip(count = 1)
@ConfigEntry.Gui.Tooltip()
boolean hideHands = true;

@Comment("Enables Smooth Transitions when zooming in and out.")
@ConfigEntry.Gui.Tooltip(count = 1)
@ConfigEntry.Gui.Tooltip()
boolean smoothTransition = false;

@Comment("Enables the ability to toggle zooming.")
@ConfigEntry.Gui.Tooltip()
boolean zoomToggle = false;

@Comment("Reduces the mouse sensitivity when zooming.")
@Comment("The divisor applied to the FOV when zooming.")
@ConfigEntry.Gui.Tooltip()
boolean reduceSensitivity = false;
public double zoomDivisor = 4.0;

@Comment("Allows to increase or decrease zoom by scrolling.")
@ConfigEntry.Gui.Tooltip()
boolean zoomScrolling = false;

@Comment("The divisor applied to the FOV when zooming.")
@ConfigEntry.Gui.Tooltip(count = 1)
public double zoomDivisor = 4.0;
@Comment("The minimum value that you can scroll down.")
@ConfigEntry.Gui.Tooltip()
public double minimumZoomDivisor = 1.0;

@Comment("The maximum value that you can scroll up.")
@ConfigEntry.Gui.Tooltip()
public double maximumZoomDivisor = 50.0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class MouseMixin {
@Inject(at = @At(value = "FIELD", target = "Lnet/minecraft/client/Mouse;eventDeltaWheel:D", ordinal = 7), method = "onMouseScroll(JDD)V", cancellable = true)
private void onMouseScroll(CallbackInfo info) {
if (OkZoomer.shouldScrollZoom()) {
double scrollAmount = OkZoomer.scrollZoom(config.zoomDivisor, this.eventDeltaWheel);
double scrollAmount = OkZoomer.scrollZoom(config.zoomDivisor, this.eventDeltaWheel, config.minimumZoomDivisor, config.maximumZoomDivisor);
config.zoomDivisor = scrollAmount;

this.eventDeltaWheel = (double)0.0;
Expand Down
12 changes: 8 additions & 4 deletions src/main/resources/assets/okzoomer/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@
"text.autoconfig.okzoomer.option.smoothCamera": "Smooth Camera",
"text.autoconfig.okzoomer.option.smoothCamera.@Tooltip[0]": "Enables Smooth Camera while zooming,",
"text.autoconfig.okzoomer.option.smoothCamera.@Tooltip[1]": "interfers with Cinematic Mode but it shouldn't be anything negative.",
"text.autoconfig.okzoomer.option.reduceSensitivity": "Reduce Sensitivity",
"text.autoconfig.okzoomer.option.reduceSensitivity.@Tooltip": "Reduces the mouse sensitivity when zooming.",
"text.autoconfig.okzoomer.option.hideHands": "Hide Hands",
"text.autoconfig.okzoomer.option.hideHands.@Tooltip": "While enabled, zooming hides your hands.",
"text.autoconfig.okzoomer.option.smoothTransition": "Smooth Transition",
"text.autoconfig.okzoomer.option.smoothTransition.@Tooltip": "Enables smooth transitions when zooming in and out.",
"text.autoconfig.okzoomer.option.reduceSensitivity": "Reduce Sensitivity",
"text.autoconfig.okzoomer.option.reduceSensitivity.@Tooltip": "Reduces the mouse sensitivity when zooming.",
"text.autoconfig.okzoomer.option.zoomToggle": "Zoom Toggle",
"text.autoconfig.okzoomer.option.zoomToggle.@Tooltip": "Enables the ability to toggle zooming.",
"text.autoconfig.okzoomer.option.zoomScrolling": "Zoom Scrolling",
"text.autoconfig.okzoomer.option.zoomScrolling.@Tooltip": "Allows to increase or decrease zoom by scrolling.",
"text.autoconfig.okzoomer.option.zoomDivisor": "Zoom Divisor",
"text.autoconfig.okzoomer.option.zoomDivisor.@Tooltip": "The divisor applied to the FOV's zoom multiplier.",
"text.autoconfig.okzoomer.option.zoomScrolling": "Zoom Scrolling",
"text.autoconfig.okzoomer.option.zoomScrolling.@Tooltip": "Allows to increase or decrease zoom by scrolling.",
"text.autoconfig.okzoomer.option.minimumZoomDivisor": "Minimum Zoom Divisor",
"text.autoconfig.okzoomer.option.minimumZoomDivisor.@Tooltip": "The minimum value that you can scroll down.",
"text.autoconfig.okzoomer.option.maximumZoomDivisor": "Maximum Zoom Divisor",
"text.autoconfig.okzoomer.option.maximumZoomDivisor.@Tooltip": "The maximum value that you can scroll up.",
"text.autoconfig.okzoomer.title": "Ok Zoomer Config"
}
12 changes: 8 additions & 4 deletions src/main/resources/assets/okzoomer/lang/pt_br.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@
"text.autoconfig.okzoomer.option.smoothCamera": "Câmera suave",
"text.autoconfig.okzoomer.option.smoothCamera.@Tooltip[0]": "Ativa a câmera suave enquanto dar zoom, interfere com",
"text.autoconfig.okzoomer.option.smoothCamera.@Tooltip[1]": "a câmera cinematográfica mas isso não deve ser nada negativo.",
"text.autoconfig.okzoomer.option.reduceSensitivity": "Reduzir sensibilidade",
"text.autoconfig.okzoomer.option.reduceSensitivity.@Tooltip": "Reduz a sensibilidade do mouse enquanto dar zoom.",
"text.autoconfig.okzoomer.option.hideHands": "Esconder mãos",
"text.autoconfig.okzoomer.option.hideHands.@Tooltip": "Enquanto ativado, o zoom esconde as suas mãos.",
"text.autoconfig.okzoomer.option.smoothTransition": "Transição suave",
"text.autoconfig.okzoomer.option.smoothTransition.@Tooltip": "Ativa transições suaves enquanto entra e sai do zoom.",
"text.autoconfig.okzoomer.option.reduceSensitivity": "Reduzir sensibilidade",
"text.autoconfig.okzoomer.option.reduceSensitivity.@Tooltip": "Reduz a sensibilidade do mouse enquanto dar zoom.",
"text.autoconfig.okzoomer.option.zoomToggle": "Alternar zoom",
"text.autoconfig.okzoomer.option.zoomToggle.@Tooltip": "Ativa a habilidade de alternar o zoom.",
"text.autoconfig.okzoomer.option.zoomScrolling": "Rolagem do zoom",
"text.autoconfig.okzoomer.option.zoomScrolling.@Tooltip": "Permite o aumento ou a diminuição do zoom pela rolagem do mouse.",
"text.autoconfig.okzoomer.option.zoomDivisor": "Divisor do zoom",
"text.autoconfig.okzoomer.option.zoomDivisor.@Tooltip": "O divisor aplicado no multiplicador do zoom do campo visual.",
"text.autoconfig.okzoomer.option.zoomScrolling": "Rolagem do zoom",
"text.autoconfig.okzoomer.option.zoomScrolling.@Tooltip": "Permite o aumento ou a diminuição do zoom pela rolagem do mouse.",
"text.autoconfig.okzoomer.option.minimumZoomDivisor": "Divisor do zoom mínimo",
"text.autoconfig.okzoomer.option.minimumZoomDivisor.@Tooltip": "O valor mínimo que você pode rolar pra baixo.",
"text.autoconfig.okzoomer.option.maximumZoomDivisor": "Divisor do zoom máximo",
"text.autoconfig.okzoomer.option.maximumZoomDivisor.@Tooltip": "O valor máximo que você pode rolar pra cima.",
"text.autoconfig.okzoomer.title": "Configurações do Ok Zoomer"
}

0 comments on commit 9398450

Please sign in to comment.