aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorNopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com>2022-12-24 03:48:50 +1100
committerGitHub <noreply@github.com>2022-12-23 17:48:50 +0100
commitdf8663e5958fe43d0c68fde3f4d31e45b2f15da1 (patch)
treebcc848f0fd714dd83d298d12799c65bc5fb83389 /src/main/java
parent7535b1f9c24d56522fd9526a8b9ad8940d130995 (diff)
downloadNotEnoughUpdates-df8663e5958fe43d0c68fde3f4d31e45b2f15da1.tar.gz
NotEnoughUpdates-df8663e5958fe43d0c68fde3f4d31e45b2f15da1.tar.bz2
NotEnoughUpdates-df8663e5958fe43d0c68fde3f4d31e45b2f15da1.zip
Gui element scale (#485)
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java36
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/LocationEdit.java12
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java5
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java22
5 files changed, 55 insertions, 28 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java
index 6fb8f353..1b71e3ce 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java
@@ -19,6 +19,7 @@
package io.github.moulberry.notenoughupdates.core.config.gui;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.config.Position;
import io.github.moulberry.notenoughupdates.overlays.OverlayManager;
import io.github.moulberry.notenoughupdates.overlays.TextOverlay;
@@ -27,6 +28,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.client.renderer.GlStateManager;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
@@ -45,10 +47,9 @@ public class GuiPositionEditor extends GuiScreen {
private int grabbedX = 0;
private int grabbedY = 0;
private int clickedPos = -1;
-
+ private int oldGuiScale = -1;
public static boolean renderDrill = false;
- private int guiScaleOverride = -1;
public GuiPositionEditor(
LinkedHashMap<TextOverlay, Position> overlayPositions,
@@ -83,6 +84,16 @@ public class GuiPositionEditor extends GuiScreen {
this.elementHeights = height;
this.positionChangedCallback = positionChangedCallback;
this.closedCallback = closedCallback;
+ int newGuiScale = NotEnoughUpdates.INSTANCE.config.locationedit.guiScale;
+ if (newGuiScale != 0) {
+ if (Minecraft.getMinecraft().gameSettings.guiScale != 0) {
+ this.oldGuiScale = Minecraft.getMinecraft().gameSettings.guiScale;
+ } else {
+ this.oldGuiScale = 4;
+ }
+ if (newGuiScale == 4) Minecraft.getMinecraft().gameSettings.guiScale = 0;
+ else Minecraft.getMinecraft().gameSettings.guiScale = NotEnoughUpdates.INSTANCE.config.locationedit.guiScale;
+ }
}
@Override
@@ -91,17 +102,14 @@ public class GuiPositionEditor extends GuiScreen {
closedCallback.run();
renderDrill = false;
clickedPos = -1;
+ if (this.oldGuiScale != -1) Minecraft.getMinecraft().gameSettings.guiScale = this.oldGuiScale;
}
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
super.drawScreen(mouseX, mouseY, partialTicks);
- ScaledResolution scaledResolution;
- if (guiScaleOverride >= 0) {
- scaledResolution = Utils.pushGuiScale(guiScaleOverride);
- } else {
- scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- }
+ GlStateManager.pushMatrix();
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
this.width = scaledResolution.getScaledWidth();
this.height = scaledResolution.getScaledHeight();
@@ -127,9 +135,6 @@ public class GuiPositionEditor extends GuiScreen {
if (position.isCenterY()) y -= elementHeight / 2;
Gui.drawRect(x, y, x + elementWidth, y + elementHeight, 0x80404040);
- Utils.pushGuiScale(-1);
-
- scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
Utils.drawStringCentered("Position Editor", Minecraft.getMinecraft().fontRendererObj,
scaledResolution.getScaledWidth() / 2, 8, true, 0xffffff
);
@@ -137,6 +142,7 @@ public class GuiPositionEditor extends GuiScreen {
scaledResolution.getScaledWidth() / 2, 18, true, 0xffffff
);
}
+ GlStateManager.popMatrix();
}
@Override
@@ -144,12 +150,7 @@ public class GuiPositionEditor extends GuiScreen {
super.mouseClicked(mouseX, mouseY, mouseButton);
if (mouseButton == 0) {
- ScaledResolution scaledResolution;
- if (guiScaleOverride >= 0) {
- scaledResolution = Utils.pushGuiScale(guiScaleOverride);
- } else {
- scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- }
+ ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth;
mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1;
for (int i = positions.size() - 1; i >= 0; i--) {
@@ -171,7 +172,6 @@ public class GuiPositionEditor extends GuiScreen {
}
}
- Utils.pushGuiScale(-1);
}
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
index 61ebf7b5..13179179 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscfeatures/PetInfoOverlay.java
@@ -661,7 +661,7 @@ public class PetInfoOverlay extends TextOverlay {
JsonObject petItem = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get("ROCK;0");
if (petItem != null) {
- Vector2f position = getPosition(overlayWidth, overlayHeight);
+ Vector2f position = getPosition(overlayWidth, overlayHeight, false);
int x = (int) position.x;
int y = (int) position.y;
@@ -700,16 +700,18 @@ public class PetInfoOverlay extends TextOverlay {
}
if (petItem != null) {
- Vector2f position = getPosition(overlayWidth, overlayHeight);
+ Vector2f position = getPosition(overlayWidth, overlayHeight, true);
int x = (int) position.x;
int y = (int) position.y;
ItemStack stack = NotEnoughUpdates.INSTANCE.manager.jsonToStack(petItem);
GlStateManager.enableDepth();
GlStateManager.pushMatrix();
+ Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.locationedit.guiScale);
GlStateManager.translate(x - 2, y - 2, 0);
GlStateManager.scale(2, 2, 1);
Utils.drawItemStack(stack, 0, 0);
+ Utils.pushGuiScale(0);
GlStateManager.popMatrix();
}
@@ -718,7 +720,7 @@ public class PetInfoOverlay extends TextOverlay {
JsonObject petItem2 = NotEnoughUpdates.INSTANCE.manager.getItemInformation().get(
currentPet2.skin != null ? currentPet2.skin : (currentPet2.petType + ";" + currentPet2.rarity.petId));
if (petItem2 != null) {
- Vector2f position = getPosition(overlayWidth, overlayHeight);
+ Vector2f position = getPosition(overlayWidth, overlayHeight, false);
int x = (int) position.x;
int y = (int) position.y + NotEnoughUpdates.INSTANCE.config.petOverlay.petOverlayText.size() * 10 + 10;
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/LocationEdit.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/LocationEdit.java
index fdfb6f93..52fd0c4a 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/LocationEdit.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/LocationEdit.java
@@ -19,10 +19,12 @@
package io.github.moulberry.notenoughupdates.options.seperateSections;
+import com.google.gson.annotations.Expose;
import io.github.moulberry.notenoughupdates.core.config.Position;
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigAccordionId;
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorAccordion;
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorButton;
+import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorDropdown;
import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption;
public class LocationEdit {
@@ -37,6 +39,16 @@ public class LocationEdit {
)
public Position positions = new Position(-1, -1);
+ @Expose
+ @ConfigOption(
+ name = "Edit Gui Scale",
+ desc = "Change the size of NEU's overlays"
+ )
+ @ConfigEditorDropdown(
+ values = {"Default", "Small", "Normal", "Large", "Auto"}
+ )
+ public int guiScale = 0;
+
@ConfigOption(
name = "Edit Dungeon Map",
desc = "The NEU dungeon map has it's own editor (/neumap).\n" +
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java
index a70035f1..f2e485f2 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java
@@ -100,7 +100,8 @@ public class FuelBar {
fuelAmount = .3f;
}
if (event.type == RenderGameOverlayEvent.ElementType.ALL) {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ GlStateManager.pushMatrix();
+ ScaledResolution scaledResolution = Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.locationedit.guiScale);
Position position = NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarPosition;
int x = position.getAbsX(scaledResolution, NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth);
@@ -139,6 +140,8 @@ public class FuelBar {
Minecraft.getMinecraft().fontRendererObj.drawString(str,
x + 2, y, 0xffffff, false
);
+ Utils.pushGuiScale(0);
+ GlStateManager.popMatrix();
}
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java
index 7884b2ac..2fbbe27d 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java
@@ -19,6 +19,7 @@
package io.github.moulberry.notenoughupdates.overlays;
+import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.core.config.Position;
import io.github.moulberry.notenoughupdates.util.Utils;
import net.minecraft.client.Minecraft;
@@ -120,12 +121,15 @@ public abstract class TextOverlay {
return new Vector2f();
}
- protected Vector2f getPosition(int overlayWidth, int overlayHeight) {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ protected Vector2f getPosition(int overlayWidth, int overlayHeight, boolean scaled) {
+ GlStateManager.pushMatrix();
+ ScaledResolution scaledResolution;
+ if (!scaled) scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
+ else scaledResolution = Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.locationedit.guiScale);
int x = position.getAbsX(scaledResolution, overlayWidth);
int y = position.getAbsY(scaledResolution, overlayHeight);
-
+ GlStateManager.popMatrix();
return new Vector2f(x, y);
}
@@ -138,17 +142,19 @@ public abstract class TextOverlay {
private void render(List<String> strings, boolean dummy) {
if (strings == null) return;
-
+ if (!dummy) {
+ GlStateManager.pushMatrix();
+ Utils.pushGuiScale(NotEnoughUpdates.INSTANCE.config.locationedit.guiScale);
+ }
Vector2f size = getSize(strings);
overlayHeight = (int) size.y;
overlayWidth = (int) size.x;
- Vector2f position = getPosition(overlayWidth, overlayHeight);
+ Vector2f position = getPosition(overlayWidth, overlayHeight, !dummy);
int x = (int) position.x;
int y = (int) position.y;
TextOverlayStyle style = styleSupplier.get();
-
if (style == TextOverlayStyle.BACKGROUND) Gui.drawRect(x, y, x + overlayWidth, y + overlayHeight, 0x80000000);
GlStateManager.enableBlend();
@@ -204,5 +210,9 @@ public abstract class TextOverlay {
}
}
}
+ if (!dummy) {
+ Utils.pushGuiScale(0);
+ GlStateManager.popMatrix();
+ }
}
}