aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/config
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2023-09-15 09:55:26 +0200
committerGitHub <noreply@github.com>2023-09-15 09:55:26 +0200
commitf5e2667e1ee0f8e663ae32f34f76e1a2bc0b6ada (patch)
tree6fb997272eab7c9d7e026bc865e873afdec4341e /src/main/java/at/hannibal2/skyhanni/config
parent54a5b0c591470cf0ee247977ecef7cbdcddc5172 (diff)
downloadskyhanni-f5e2667e1ee0f8e663ae32f34f76e1a2bc0b6ada.tar.gz
skyhanni-f5e2667e1ee0f8e663ae32f34f76e1a2bc0b6ada.tar.bz2
skyhanni-f5e2667e1ee0f8e663ae32f34f76e1a2bc0b6ada.zip
Feature: gui scaling (#464)
Add gui scaling #464
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/config')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java17
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt21
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java6
3 files changed, 44 insertions, 0 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java b/src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java
index 5ce2cafce..f63192cde 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/core/config/Position.java
@@ -19,6 +19,7 @@
package at.hannibal2.skyhanni.config.core.config;
+import at.hannibal2.skyhanni.SkyHanniMod;
import com.google.gson.annotations.Expose;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
@@ -29,6 +30,9 @@ public class Position {
@Expose
private int y;
@Expose
+ private float scale = 1F;
+
+ @Expose
private boolean centerX;
@Expose
private boolean centerY;
@@ -52,6 +56,19 @@ public class Position {
this.y = other.y;
this.centerX = other.centerX;
this.centerY = other.centerY;
+ this.scale = other.scale;
+ }
+
+ public float getEffectiveScale() {
+ return Math.max(Math.min(scale * SkyHanniMod.getFeature().gui.globalScale, 10F), 0.1F);
+ }
+
+ public float getScale() {
+ return scale;
+ }
+
+ public void setScale(float newScale) {
+ scale = Math.max(Math.min(10F, newScale), 0.1f);
}
public int getRawX() {
diff --git a/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt b/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt
index e3b828407..8dff4260b 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt
+++ b/src/main/java/at/hannibal2/skyhanni/config/core/config/gui/GuiPositionEditor.kt
@@ -212,4 +212,25 @@ class GuiPositionEditor(private val positions: List<Position>, private val borde
grabbedY += position.moveY(mouseY - grabbedY, elementHeight)
}
}
+
+ override fun handleMouseInput() {
+ super.handleMouseInput()
+ val mw = Mouse.getEventDWheel()
+ if (mw == 0) return
+ val mx = Mouse.getEventX() * width / mc.displayWidth
+ val my = height - Mouse.getEventY() * height / mc.displayHeight - 1
+ val hovered = positions.firstOrNull { it.clicked }
+ ?: positions.lastOrNull {
+ val size = it.getDummySize()
+ GuiRenderUtils.isPointInRect(
+ mx, my,
+ it.getAbsX() - border, it.getAbsY() - border,
+ size.x + border * 2, size.y + border * 2
+ )
+ } ?: return
+ if (mw < 0)
+ hovered.scale -= .1F
+ else
+ hovered.scale += .1F
+ }
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java
index 2e02156e3..cf9f0cc39 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/GUIConfig.java
@@ -4,6 +4,7 @@ import at.hannibal2.skyhanni.data.GuiEditManager;
import com.google.gson.annotations.Expose;
import io.github.moulberry.moulconfig.annotations.ConfigEditorButton;
import io.github.moulberry.moulconfig.annotations.ConfigEditorKeybind;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider;
import io.github.moulberry.moulconfig.annotations.ConfigOption;
import org.lwjgl.input.Keyboard;
@@ -17,4 +18,9 @@ public class GUIConfig {
@ConfigOption(name = "Open Hotkey", desc = "Press this key to open the GUI Editor.")
@ConfigEditorKeybind(defaultKey = Keyboard.KEY_NONE)
public int keyBindOpen = Keyboard.KEY_NONE;
+
+ @Expose
+ @ConfigOption(name = "Global GUI scale", desc = "Globally scale all SkyHanni GUIs")
+ @ConfigEditorSlider(minValue = 0.1F, maxValue = 10, minStep = 0.05F)
+ public float globalScale = 1F;
}