diff options
Diffstat (limited to 'src/main/java/io')
21 files changed, 538 insertions, 442 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java b/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java index 3967edb4..d52ed196 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/commands/dungeon/MapCommand.java @@ -33,14 +33,10 @@ import net.minecraft.item.ItemMap; import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.ResourceLocation; import net.minecraft.world.storage.MapData; import java.awt.*; -import java.io.BufferedReader; import java.io.File; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; import java.util.Map; public class MapCommand extends ClientCommandBase { @@ -52,35 +48,8 @@ public class MapCommand extends ClientCommandBase { @Override public void processCommand(ICommandSender sender, String[] args) throws CommandException { - if (NotEnoughUpdates.INSTANCE.colourMap == null) { - try ( - BufferedReader reader = new BufferedReader(new InputStreamReader(Minecraft - .getMinecraft() - .getResourceManager() - .getResource( - new ResourceLocation("notenoughupdates:maps/F1Full.json")) - .getInputStream(), StandardCharsets.UTF_8)) - ) { - JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class); - - NotEnoughUpdates.INSTANCE.colourMap = new Color[128][128]; - for (int x = 0; x < 128; x++) { - for (int y = 0; y < 128; y++) { - NotEnoughUpdates.INSTANCE.colourMap[x][y] = new Color(0, 0, 0, 0); - } - } - for (Map.Entry<String, JsonElement> entry : json.entrySet()) { - int x = Integer.parseInt(entry.getKey().split(":")[0]); - int y = Integer.parseInt(entry.getKey().split(":")[1]); - - NotEnoughUpdates.INSTANCE.colourMap[x][y] = new Color(entry.getValue().getAsInt(), true); - } - } catch (Exception ignored) { - } - } - if (!NotEnoughUpdates.INSTANCE.config.hidden.dev) { - NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(); + NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(null); return; } @@ -90,7 +59,7 @@ public class MapCommand extends ClientCommandBase { } if (args.length != 2) { - NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(); + NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(null); return; } @@ -157,6 +126,6 @@ public class MapCommand extends ClientCommandBase { return; } - NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(); + NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(null); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java index 535c92bf..57b2bed7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/Position.java @@ -31,6 +31,7 @@ public class Position { private boolean centerX; @Expose private boolean centerY; + private boolean clicked = false; private static final int EDGE_OFFSET = 0; @@ -72,6 +73,13 @@ public class Position { return y; } + public void setClicked(boolean state) { + this.clicked = state; + } + public boolean getClicked() { + return clicked; + } + public int getAbsX(ScaledResolution scaledResolution, int objWidth) { int width = scaledResolution.getScaledWidth(); 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 ed45bab6..6fb8f353 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 @@ -20,6 +20,8 @@ package io.github.moulberry.notenoughupdates.core.config.gui; import io.github.moulberry.notenoughupdates.core.config.Position; +import io.github.moulberry.notenoughupdates.overlays.OverlayManager; +import io.github.moulberry.notenoughupdates.overlays.TextOverlay; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; @@ -29,45 +31,66 @@ import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; public class GuiPositionEditor extends GuiScreen { - private final Position position; - private final Position originalPosition; - private final int elementWidth; - private final int elementHeight; - private final Runnable renderCallback; + private final ArrayList<Position> positions; + private final ArrayList<Position> originalPositions; + private final ArrayList<Integer> elementWidths; + private final ArrayList<Integer> elementHeights; + private final ArrayList<Runnable> renderCallback; private final Runnable positionChangedCallback; private final Runnable closedCallback; - private boolean clicked = false; private int grabbedX = 0; private int grabbedY = 0; + private int clickedPos = -1; + + public static boolean renderDrill = false; private int guiScaleOverride = -1; public GuiPositionEditor( - Position position, int elementWidth, int elementHeight, + LinkedHashMap<TextOverlay, Position> overlayPositions, Runnable renderCallback, Runnable positionChangedCallback, Runnable closedCallback ) { - this.position = position; - this.originalPosition = position.clone(); - this.elementWidth = elementWidth; - this.elementHeight = elementHeight; - this.renderCallback = renderCallback; + ArrayList<Position> pos = new ArrayList<>(); + ArrayList<Position> ogPos = new ArrayList<>(); + ArrayList<Runnable> renderCallbac = new ArrayList<>(); + ArrayList<Integer> width = new ArrayList<>(); + ArrayList<Integer> height = new ArrayList<>(); + for (int i = 0; i < overlayPositions.size(); i++) { + TextOverlay overlay = new ArrayList<>(overlayPositions.keySet()).get(i); + pos.add(overlayPositions.get(overlay)); + ogPos.add(pos.get(i).clone()); + width.add((int) overlay.getDummySize().x); + height.add((int) overlay.getDummySize().y); + renderCallbac.add(() -> { + if (overlay.shouldRenderInGuiEditor) { + overlay.renderDummy(); + OverlayManager.dontRenderOverlay.add(overlay.getClass()); + } + }); + } + + + this.positions = pos; + this.originalPositions = ogPos; + this.renderCallback = renderCallbac; + this.elementWidths = width; + this.elementHeights = height; this.positionChangedCallback = positionChangedCallback; this.closedCallback = closedCallback; } - public GuiPositionEditor withScale(int scale) { - this.guiScaleOverride = scale; - return this; - } - @Override public void onGuiClosed() { super.onGuiClosed(); closedCallback.run(); + renderDrill = false; + clickedPos = -1; } @Override @@ -86,32 +109,34 @@ public class GuiPositionEditor extends GuiScreen { mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; drawDefaultBackground(); + renderDrill = true; + for (Position position : positions) { + int elementHeight = elementHeights.get(positions.indexOf(position)); + int elementWidth = elementWidths.get(positions.indexOf(position)); + if (position.getClicked()) { + grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); + grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); + } - if (clicked) { - grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); - grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); - } - - renderCallback.run(); + renderCallback.get(positions.indexOf(position)).run(); - int x = position.getAbsX(scaledResolution, elementWidth); - int y = position.getAbsY(scaledResolution, elementHeight); + int x = position.getAbsX(scaledResolution, elementWidth); + int y = position.getAbsY(scaledResolution, elementHeight); - if (position.isCenterX()) x -= elementWidth / 2; - if (position.isCenterY()) y -= elementHeight / 2; - Gui.drawRect(x, y, x + elementWidth, y + elementHeight, 0x80404040); + if (position.isCenterX()) x -= elementWidth / 2; + if (position.isCenterY()) y -= elementHeight / 2; + Gui.drawRect(x, y, x + elementWidth, y + elementHeight, 0x80404040); - if (guiScaleOverride >= 0) { Utils.pushGuiScale(-1); - } - scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - Utils.drawStringCentered("Position Editor", Minecraft.getMinecraft().fontRendererObj, - scaledResolution.getScaledWidth() / 2, 8, true, 0xffffff - ); - Utils.drawStringCentered("R to Reset - Arrow keys/mouse to move", Minecraft.getMinecraft().fontRendererObj, - scaledResolution.getScaledWidth() / 2, 18, true, 0xffffff - ); + scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + Utils.drawStringCentered("Position Editor", Minecraft.getMinecraft().fontRendererObj, + scaledResolution.getScaledWidth() / 2, 8, true, 0xffffff + ); + Utils.drawStringCentered("R to Reset - Arrow keys/mouse to move", Minecraft.getMinecraft().fontRendererObj, + scaledResolution.getScaledWidth() / 2, 18, true, 0xffffff + ); + } } @Override @@ -127,20 +152,25 @@ public class GuiPositionEditor extends GuiScreen { } 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--) { + Position position = positions.get(i); + int elementHeight = elementHeights.get(positions.indexOf(position)); + int elementWidth = elementWidths.get(positions.indexOf(position)); + int x = position.getAbsX(scaledResolution, elementWidth); + int y = position.getAbsY(scaledResolution, elementHeight); + if (position.isCenterX()) x -= elementWidth / 2; + if (position.isCenterY()) y -= elementHeight / 2; + if (!position.getClicked()) { + if (mouseX >= x && mouseY >= y && + mouseX <= x + elementWidth && mouseY <= y + elementHeight) { + clickedPos = i; + position.setClicked(true); + grabbedX = mouseX; + grabbedY = mouseY; + break; + } + } - int x = position.getAbsX(scaledResolution, elementWidth); - int y = position.getAbsY(scaledResolution, elementHeight); - if (position.isCenterX()) x -= elementWidth / 2; - if (position.isCenterY()) y -= elementHeight / 2; - - if (mouseX >= x && mouseY >= y && - mouseX <= x + elementWidth && mouseY <= y + elementHeight) { - clicked = true; - grabbedX = mouseX; - grabbedY = mouseY; - } - - if (guiScaleOverride >= 0) { Utils.pushGuiScale(-1); } } @@ -148,19 +178,24 @@ public class GuiPositionEditor extends GuiScreen { @Override protected void keyTyped(char typedChar, int keyCode) throws IOException { - if (keyCode == Keyboard.KEY_R) { - position.set(originalPosition); - } else if (!clicked) { - boolean shiftHeld = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); - int dist = shiftHeld ? 10 : 1; - if (keyCode == Keyboard.KEY_DOWN) { - position.moveY(dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft())); - } else if (keyCode == Keyboard.KEY_UP) { - position.moveY(-dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft())); - } else if (keyCode == Keyboard.KEY_LEFT) { - position.moveX(-dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft())); - } else if (keyCode == Keyboard.KEY_RIGHT) { - position.moveX(dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft())); + if (clickedPos != -1) { + Position position = positions.get(clickedPos); + int elementHeight = elementHeights.get(positions.indexOf(position)); + int elementWidth = elementWidths.get(positions.indexOf(position)); + if (keyCode == Keyboard.KEY_R) { + position.set(originalPositions.get(positions.indexOf(position))); + } else if (!position.getClicked()) { + boolean shiftHeld = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + int dist = shiftHeld ? 10 : 1; + if (keyCode == Keyboard.KEY_DOWN) { + position.moveY(dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft())); + } else if (keyCode == Keyboard.KEY_UP) { + position.moveY(-dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft())); + } else if (keyCode == Keyboard.KEY_LEFT) { + position.moveX(-dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft())); + } else if (keyCode == Keyboard.KEY_RIGHT) { + position.moveX(dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft())); + } } } super.keyTyped(typedChar, keyCode); @@ -169,28 +204,26 @@ public class GuiPositionEditor extends GuiScreen { @Override protected void mouseReleased(int mouseX, int mouseY, int state) { super.mouseReleased(mouseX, mouseY, state); - clicked = false; + for (Position position : positions) { + position.setClicked(false); + } } @Override protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); + for (Position position : positions) { + int elementHeight = elementHeights.get(positions.indexOf(position)); + int elementWidth = elementWidths.get(positions.indexOf(position)); + if (position.getClicked()) { + ScaledResolution scaledResolution = Utils.pushGuiScale(-1); + mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; + + grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); + grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); + positionChangedCallback.run(); - if (clicked) { - ScaledResolution scaledResolution; - if (guiScaleOverride >= 0) { - scaledResolution = Utils.pushGuiScale(guiScaleOverride); - } else { - scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - } - mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; - mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; - - grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); - grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); - positionChangedCallback.run(); - - if (guiScaleOverride >= 0) { Utils.pushGuiScale(-1); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditorButForTheDungeonMap.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditorButForTheDungeonMap.java new file mode 100644 index 00000000..b334418c --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditorButForTheDungeonMap.java @@ -0,0 +1,198 @@ +/* + * Copyright (C) 2022 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.core.config.gui; + +import io.github.moulberry.notenoughupdates.core.config.Position; +import io.github.moulberry.notenoughupdates.util.Utils; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.gui.ScaledResolution; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; + +import java.io.IOException; + +public class GuiPositionEditorButForTheDungeonMap extends GuiScreen { // nea is gonna LOVE this file's existence + private final Position position; + private final Position originalPosition; + private final int elementWidth; + private final int elementHeight; + private final Runnable renderCallback; + private final Runnable positionChangedCallback; + private final Runnable closedCallback; + private boolean clicked = false; + private int grabbedX = 0; + private int grabbedY = 0; + + private int guiScaleOverride = -1; + + public GuiPositionEditorButForTheDungeonMap( + Position position, int elementWidth, int elementHeight, + Runnable renderCallback, + Runnable positionChangedCallback, + Runnable closedCallback + ) { + this.position = position; + this.originalPosition = position.clone(); + this.elementWidth = elementWidth; + this.elementHeight = elementHeight; + this.renderCallback = renderCallback; + this.positionChangedCallback = positionChangedCallback; + this.closedCallback = closedCallback; + } + + public GuiPositionEditorButForTheDungeonMap withScale(int scale) { + this.guiScaleOverride = scale; + return this; + } + + @Override + public void onGuiClosed() { + super.onGuiClosed(); + closedCallback.run(); + } + + @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()); + } + + this.width = scaledResolution.getScaledWidth(); + this.height = scaledResolution.getScaledHeight(); + mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; + + drawDefaultBackground(); + + if (clicked) { + grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); + grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); + } + + renderCallback.run(); + + int x = position.getAbsX(scaledResolution, elementWidth); + int y = position.getAbsY(scaledResolution, elementHeight); + + if (position.isCenterX()) x -= elementWidth / 2; + if (position.isCenterY()) y -= elementHeight / 2; + Gui.drawRect(x, y, x + elementWidth, y + elementHeight, 0x80404040); + + if (guiScaleOverride >= 0) { + Utils.pushGuiScale(-1); + } + + scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + Utils.drawStringCentered("Position Editor", Minecraft.getMinecraft().fontRendererObj, + scaledResolution.getScaledWidth() / 2, 8, true, 0xffffff + ); + Utils.drawStringCentered("R to Reset - Arrow keys/mouse to move", Minecraft.getMinecraft().fontRendererObj, + scaledResolution.getScaledWidth() / 2, 18, true, 0xffffff + ); + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { + super.mouseClicked(mouseX, mouseY, mouseButton); + + if (mouseButton == 0) { + ScaledResolution scaledResolution; + if (guiScaleOverride >= 0) { + scaledResolution = Utils.pushGuiScale(guiScaleOverride); + } else { + scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + } + mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; + + int x = position.getAbsX(scaledResolution, elementWidth); + int y = position.getAbsY(scaledResolution, elementHeight); + if (position.isCenterX()) x -= elementWidth / 2; + if (position.isCenterY()) y -= elementHeight / 2; + + if (mouseX >= x && mouseY >= y && + mouseX <= x + elementWidth && mouseY <= y + elementHeight) { + clicked = true; + grabbedX = mouseX; + grabbedY = mouseY; + } + + if (guiScaleOverride >= 0) { + Utils.pushGuiScale(-1); + } + } + } + + @Override + protected void keyTyped(char typedChar, int keyCode) throws IOException { + if (keyCode == Keyboard.KEY_R) { + position.set(originalPosition); + } else if (!clicked) { + boolean shiftHeld = Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT); + int dist = shiftHeld ? 10 : 1; + if (keyCode == Keyboard.KEY_DOWN) { + position.moveY(dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft())); + } else if (keyCode == Keyboard.KEY_UP) { + position.moveY(-dist, elementHeight, new ScaledResolution(Minecraft.getMinecraft())); + } else if (keyCode == Keyboard.KEY_LEFT) { + position.moveX(-dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft())); + } else if (keyCode == Keyboard.KEY_RIGHT) { + position.moveX(dist, elementWidth, new ScaledResolution(Minecraft.getMinecraft())); + } + } + super.keyTyped(typedChar, keyCode); + } + + @Override + protected void mouseReleased(int mouseX, int mouseY, int state) { + super.mouseReleased(mouseX, mouseY, state); + clicked = false; + } + + @Override + protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { + super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick); + + if (clicked) { + ScaledResolution scaledResolution; + if (guiScaleOverride >= 0) { + scaledResolution = Utils.pushGuiScale(guiScaleOverride); + } else { + scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); + } + mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; + + grabbedX += position.moveX(mouseX - grabbedX, elementWidth, scaledResolution); + grabbedY += position.moveY(mouseY - grabbedY, elementHeight, scaledResolution); + positionChangedCallback.run(); + + if (guiScaleOverride >= 0) { + Utils.pushGuiScale(-1); + } + } + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java index 88c89773..e15168f5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/DungeonMap.java @@ -65,8 +65,13 @@ import java.awt.*; import java.io.BufferedReader; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; import java.util.List; -import java.util.*; +import java.util.Map; +import java.util.Objects; +import java.util.Set; public class DungeonMap { private static final ResourceLocation GREEN_CHECK = new ResourceLocation( @@ -498,8 +503,8 @@ public class DungeonMap { mapSizeX = borderSizeOption == 0 ? 90 : borderSizeOption == 1 ? 120 : borderSizeOption == 2 ? 160 : 240; } mapSizeY = mapSizeX; - int roomsSizeX = (maxRoomX - minRoomX) * (renderRoomSize + renderConnSize) + renderRoomSize; - int roomsSizeY = (maxRoomY - minRoomY) * (renderRoomSize + renderConnSize) + renderRoomSize; + int roomsSizeX = (maxRoomX - minRoomX) * (renderRoomSize + renderConnSize) + renderRoomSize + (isFloorOne ? getRenderRoomSize() : 0); + int roomsSizeY = (maxRoomY - minRoomY) * (renderRoomSize + renderConnSize) + renderRoomSize + (isEntrance ? getRenderRoomSize() : 0); int mapCenterX = mapSizeX / 2; int mapCenterY = mapSizeY / 2; int scaleFactor = 8; @@ -669,12 +674,12 @@ public class DungeonMap { float angle = pos.rotation; boolean doInterp = NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPlayerInterp; - if (!isFloorOne && playerEntityMapPositions.containsKey(name)) { + if (playerEntityMapPositions.containsKey(name)) { MapPosition entityPos = playerEntityMapPositions.get(name); angle = entityPos.rotation; - float deltaX = entityPos.getRenderX() - pos.getRenderX(); - float deltaY = entityPos.getRenderY() - pos.getRenderY(); + float deltaX = entityPos.getRenderX() - pos.getRenderX() + (isFloorOne ? getRenderRoomSize() : 0); + float deltaY = entityPos.getRenderY() - pos.getRenderY() + (isEntrance ? getRenderRoomSize() : 0); x += deltaX; y += deltaY; @@ -1119,6 +1124,7 @@ public class DungeonMap { } private boolean isFloorOne = false; + private boolean isEntrance = false; private boolean failMap = false; private long lastClearCache = 0; @@ -1160,6 +1166,9 @@ public class DungeonMap { if (line.contains("(F1)") || line.contains("(E)") || line.contains("(M1)")) { isFloorOne = true; + if (line.contains("(E)")) { + isEntrance = true; + } break; } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java index 735fa3e6..98d36f2b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/dungeons/GuiDungeonMapEditor.java @@ -19,11 +19,13 @@ package io.github.moulberry.notenoughupdates.dungeons; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.GuiElementColour; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditorSlider; import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiPositionEditor; +import io.github.moulberry.notenoughupdates.core.config.gui.GuiPositionEditorButForTheDungeonMap; import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField; @@ -46,8 +48,11 @@ import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import java.awt.*; +import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStreamReader; import java.lang.reflect.Field; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; @@ -80,6 +85,8 @@ public class GuiDungeonMapEditor extends GuiScreen { private Field clickedSlider; + private Runnable closedCallback; + class Button { private final int id; private final int x; @@ -150,8 +157,34 @@ public class GuiDungeonMapEditor extends GuiScreen { } - public GuiDungeonMapEditor() { - DungeonMapConfig options = NotEnoughUpdates.INSTANCE.config.dungeonMap; + public GuiDungeonMapEditor(Runnable closedCallback) { + + if (NotEnoughUpdates.INSTANCE.colourMap == null) { + try ( + BufferedReader reader = new BufferedReader(new InputStreamReader(Minecraft + .getMinecraft() + .getResourceManager() + .getResource( + new ResourceLocation("notenoughupdates:maps/F1Full.json")) + .getInputStream(), StandardCharsets.UTF_8)) + ) { + JsonObject json = NotEnoughUpdates.INSTANCE.manager.gson.fromJson(reader, JsonObject.class); + + NotEnoughUpdates.INSTANCE.colourMap = new Color[128][128]; + for (int x = 0; x < 128; x++) { + for (int y = 0; y < 128; y++) { + NotEnoughUpdates.INSTANCE.colourMap[x][y] = new Color(0, 0, 0, 0); + } + } + for (Map.Entry<String, JsonElement> entry : json.entrySet()) { + int x = Integer.parseInt(entry.getKey().split(":")[0]); + int y = Integer.parseInt(entry.getKey().split(":")[1]); + + NotEnoughUpdates.INSTANCE.colourMap[x][y] = new Color(entry.getValue().getAsInt(), true); + } + } catch (Exception ignored) { + } + } //Map Border Styles buttons.add(new Button(6, 6, 97 + 30, "None")); @@ -244,6 +277,7 @@ public class GuiDungeonMapEditor extends GuiScreen { } blurField.setText(strVal); } + this.closedCallback = closedCallback; } @Override @@ -589,8 +623,9 @@ public class GuiDungeonMapEditor extends GuiScreen { HashSet<String> players = new HashSet<>(); players.add(Minecraft.getMinecraft().thePlayer.getName()); GlStateManager.color(1, 1, 1, 1); - - Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor( + Runnable runnable = this.closedCallback; + this.closedCallback = null; + Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditorButForTheDungeonMap( NotEnoughUpdates.INSTANCE.config.dungeonMap.dmPosition, size, size, () -> { ScaledResolution scaledResolution = Utils.pushGuiScale(2); @@ -605,7 +640,7 @@ public class GuiDungeonMapEditor extends GuiScreen { 0 ); Utils.pushGuiScale(-1); - }, () -> {}, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor() + }, () -> {}, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(runnable) ).withScale(2)); return; } @@ -856,4 +891,11 @@ public class GuiDungeonMapEditor extends GuiScreen { Utils.drawTexturedRect(x, y, blurWidth, blurHeight, uMin, uMax, vMin, vMax); blurOutputVert.unbindFramebufferTexture(); } + + @Override + public void onGuiClosed() { + if (this.closedCallback != null) { + this.closedCallback.run(); + } + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java index ca841590..191567a1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/listener/RenderListener.java @@ -184,17 +184,21 @@ public class RenderListener { DungeonWin.render(event.partialTicks); GlStateManager.pushMatrix(); GlStateManager.translate(0, 0, -200); + label: for (TextOverlay overlay : OverlayManager.textOverlays) { - if (OverlayManager.dontRenderOverlay != null && - OverlayManager.dontRenderOverlay.isAssignableFrom(overlay.getClass())) { - continue; + for (Class<? extends TextOverlay> dontRender : OverlayManager.dontRenderOverlay) { + if (dontRender != null && + dontRender.isAssignableFrom(overlay.getClass())) { + continue label; + } } + GlStateManager.translate(0, 0, -1); GlStateManager.enableDepth(); overlay.render(); } GlStateManager.popMatrix(); - OverlayManager.dontRenderOverlay = null; + OverlayManager.dontRenderOverlay = new ArrayList<>(); } if (Keyboard.isKeyDown(Keyboard.KEY_X)) { NotificationHandler.notificationDisplayMillis = 0; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java index e1e18940..35f219e0 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -28,6 +28,7 @@ import io.github.moulberry.notenoughupdates.core.config.Config; import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.core.config.annotations.Category; import io.github.moulberry.notenoughupdates.core.config.gui.GuiPositionEditor; +import io.github.moulberry.notenoughupdates.dungeons.GuiDungeonMapEditor; import io.github.moulberry.notenoughupdates.miscfeatures.FairySouls; import io.github.moulberry.notenoughupdates.miscgui.GuiEnchantColour; import io.github.moulberry.notenoughupdates.miscgui.GuiInvButtonEditor; @@ -71,24 +72,25 @@ import io.github.moulberry.notenoughupdates.util.NotificationHandler; import io.github.moulberry.notenoughupdates.util.SBInfo; import net.minecraft.client.Minecraft; import net.minecraftforge.client.ClientCommandHandler; -import org.lwjgl.util.vector.Vector2f; import java.util.ArrayList; import java.util.EnumSet; import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; public class NEUConfig extends Config { - private void editOverlay(String activeConfig, TextOverlay overlay, Position position) { - Vector2f size = overlay.getDummySize(); - int width = (int) size.x; - int height = (int) size.y; - Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor(position, width, height, () -> { - overlay.renderDummy(); - OverlayManager.dontRenderOverlay = overlay.getClass(); + public void editOverlay() { + final LinkedHashMap<TextOverlay, Position> overlayPositions = new LinkedHashMap<TextOverlay, Position>(); + for (TextOverlay overlay : OverlayManager.textOverlays) { + overlayPositions.put(overlay, overlay.getPosition()); + } + Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor(overlayPositions, () -> { + }, () -> { }, () -> { - }, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor))); + NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor); + })); } @Override @@ -105,28 +107,13 @@ public class NEUConfig extends Config { case -1: return; case 0: - ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/neumap"); + NotEnoughUpdates.INSTANCE.openGui = new GuiDungeonMapEditor(() -> { + NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor); + }); return; case 1: - editOverlay(activeConfigCategory, OverlayManager.miningOverlay, mining.overlayPosition); - return; - case 2: - Minecraft.getMinecraft().displayGuiScreen(new GuiPositionEditor( - NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarPosition, - NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth, 12, () -> { - }, - () -> { - }, () -> NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor) - )); - return; - case 3: - editOverlay(activeConfigCategory, OverlayManager.farmingOverlay, skillOverlays.farmingPosition); - return; case 4: - editOverlay(activeConfigCategory, OverlayManager.petInfoOverlay, petOverlay.petInfoPosition); - return; - case 5: - editOverlay(activeConfigCategory, OverlayManager.timersOverlay, miscOverlays.todoPosition); + editOverlay(); return; case 6: NotEnoughUpdates.INSTANCE.openGui = new NEUOverlayPlacements(); @@ -137,24 +124,12 @@ public class NEUConfig extends Config { case 8: NotEnoughUpdates.INSTANCE.openGui = new GuiEnchantColour(); return; - case 9: - editOverlay(activeConfigCategory, OverlayManager.bonemerangOverlay, itemOverlays.bonemerangPosition); - return; - case 10: - editOverlay(activeConfigCategory, OverlayManager.crystalHollowOverlay, mining.crystalHollowOverlayPosition); - return; - case 11: - editOverlay(activeConfigCategory, OverlayManager.miningSkillOverlay, skillOverlays.miningPosition); - return; case 12: ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/dn"); return; case 13: ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/pv"); return; - case 14: - editOverlay(activeConfigCategory, OverlayManager.fishingSkillOverlay, skillOverlays.fishingPosition); - return; case 15: String command = NotEnoughUpdates.INSTANCE.config.misc.fariySoul ? "/neusouls on" : "/neusouls off"; ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, command); @@ -165,12 +140,6 @@ public class NEUConfig extends Config { case 17: ClientCommandHandler.instance.executeCommand(Minecraft.getMinecraft().thePlayer, "/neusouls unclear"); return; - case 18: - editOverlay(activeConfigCategory, OverlayManager.slayerOverlay, slayerOverlay.slayerPosition); - return; - case 19: - editOverlay(activeConfigCategory, OverlayManager.combatSkillOverlay, skillOverlays.combatPosition); - return; case 20: FairySouls.getInstance().setTrackFairySouls(NotEnoughUpdates.INSTANCE.config.misc.trackFairySouls); return; @@ -198,9 +167,6 @@ public class NEUConfig extends Config { NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(new NEUConfigEditor(NotEnoughUpdates.INSTANCE.config, "apis")); return; - case 25: - editOverlay(activeConfigCategory, OverlayManager.powderGrindingOverlay, mining.powderGrindingTrackerPosition); - return; case 26: OverlayManager.powderGrindingOverlay.reset(); return; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java index 9179c6ea..cbe7af1a 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Dungeons.java @@ -41,18 +41,6 @@ public class Dungeons { @Expose @ConfigOption( - name = "\u00A7cWarning", - desc = "If you are on Entrance, Floor 1 or Master 1 the map wont work properly" - ) - @ConfigEditorFSR( - runnableId = 12, - buttonText = "" - ) - @ConfigAccordionId(id = 0) - public boolean dungeonF1Warning = false; - - @Expose - @ConfigOption( name = "Edit Dungeon Map", desc = "The NEU dungeon map has its own editor (/neumap).\n" + "Click the button on the left to open it" diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java index ee1e9992..84bce030 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/ItemOverlays.java @@ -282,15 +282,6 @@ public class ItemOverlays { public boolean highlightTargeted = true; @Expose - @ConfigOption( - name = "Bonemerang Overlay Position", - desc = "Change the position of the Bonemerang overlay." - ) - @ConfigEditorButton( - runnableId = 9, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 4) public Position bonemerangPosition = new Position(-1, -1); @Expose 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 78b4cfd4..fdfb6f93 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 @@ -26,56 +26,27 @@ import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigEditor import io.github.moulberry.notenoughupdates.core.config.annotations.ConfigOption; public class LocationEdit { - @ConfigOption( - name = "Edit Dungeon Map", - desc = "The NEU dungeon map has it's own editor (/neumap).\n" + - "Click the button on the left to open it" - ) - @ConfigEditorButton( - runnableId = 0, - buttonText = "Edit" - ) - public int editDungeonMap = 0; @ConfigOption( - name = "Edit Pet Info Position", - desc = "Change the position of the pet info overlay" + name = "Edit GUI locations", + desc = "Change the position of NEU's overlays" ) @ConfigEditorButton( runnableId = 4, buttonText = "Edit" ) - public Position petInfoPosition = new Position(-1, -1); - - @ConfigOption( - name = "Edit Todo Position", - desc = "Change the position of the Todo overlay" - ) - @ConfigEditorButton( - runnableId = 5, - buttonText = "Edit" - ) - public Position todoPosition = new Position(100, 0); - - @ConfigOption( - name = "Edit Bonemerang Overlay Position", - desc = "Change the position of the Bonemerang overlay" - ) - @ConfigEditorButton( - runnableId = 9, - buttonText = "Edit" - ) - public Position bonemerangPosition = new Position(-1, -1); + public Position positions = new Position(-1, -1); @ConfigOption( - name = "Edit Slayer Overlay Position", - desc = "Change the position of the Slayer overlay" + name = "Edit Dungeon Map", + desc = "The NEU dungeon map has it's own editor (/neumap).\n" + + "Click the button on the left to open it" ) @ConfigEditorButton( - runnableId = 18, + runnableId = 0, buttonText = "Edit" ) - public Position slayerPosition = new Position(10, 200); + public int editDungeonMap = 0; @ConfigOption( name = "Inventory", @@ -99,106 +70,4 @@ public class LocationEdit { @ConfigAccordionId(id = 1) @ConfigEditorButton(runnableId = 7, buttonText = "Open") public boolean openEditorButton = true; - - @ConfigOption( - name = "Mining Overlays", - desc = "" - ) - @ConfigEditorAccordion(id = 2) - public boolean miningoverlayAccordion = false; - - @ConfigOption( - name = "Edit Dwarven Overlay Position", - desc = "Change the position of the Dwarven Mines information Overlay (commissions, powder & forge statuses)" - ) - @ConfigEditorButton( - runnableId = 1, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 2) - public Position overlayPosition = new Position(10, 100); - - @ConfigOption( - name = "Edit Crystal Overlay Position", - desc = "Change the position of the Crystal Hollows Overlay" - ) - @ConfigEditorButton( - runnableId = 10, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 2) - public Position crystalHollowOverlayPosition = new Position(200, 0); - - @ConfigOption( - name = "Edit Fuel Bar Position", - desc = "Change the position of the drill fuel bar" - ) - @ConfigEditorButton( - runnableId = 2, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 2) - public Position drillFuelBarPosition = new Position(0, -100, true, false); - - @ConfigOption( - name = "Edit Tracker Position", - desc = "Change the position of the Powder Grinding Tracker Overlay (chests and gained powder)" - ) - @ConfigEditorButton( - runnableId = 25, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 2) - public Position powderGrindingTrackerPosition = new Position(10, 265); - - @ConfigOption( - name = "Skill Overlays", - desc = "" - ) - @ConfigEditorAccordion(id = 3) - public boolean skilloverlayAccordion = false; - - @ConfigOption( - name = "Edit Farming Overlay Position", - desc = "Change the position of the Farming overlay" - ) - @ConfigEditorButton( - runnableId = 3, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 3) - public Position farmingPosition = new Position(10, 200); - - @ConfigOption( - name = "Edit Mining Overlay Position", - desc = "Change the position of the Mining overlay" - ) - @ConfigEditorButton( - runnableId = 11, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 3) - public Position miningPosition = new Position(10, 200); - - @ConfigOption( - name = "Edit Fishing Overlay Position", - desc = "Change the position of the Fishing overlay" - ) - @ConfigEditorButton( - runnableId = 14, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 3) - public Position fishingPosition = new Position(10, 200); - - @ConfigOption( - name = "Edit Combat Overlay Position", - desc = "Change the position of the Combat overlay" - ) - @ConfigEditorButton( - runnableId = 19, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 3) - public Position combatPosition = new Position(10, 200); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java index 7a6b07fd..da84e32e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/Mining.java @@ -108,15 +108,6 @@ public class Mining { public int drillFuelBarWidth = 200; @Expose - @ConfigOption( - name = "Edit Fuel Bar Position", - desc = "Change the position of the drill fuel bar" - ) - @ConfigEditorButton( - runnableId = 2, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 1) public Position drillFuelBarPosition = new Position(0, -100, true, false); @ConfigOption( @@ -154,15 +145,6 @@ public class Mining { public List<Integer> dwarvenText2 = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4)); @Expose - @ConfigOption( - name = "Edit Dwarven Overlay Position", - desc = "Change the position of the Dwarven Mines information Overlay (commissions, powder & forge statuses)" - ) - @ConfigEditorButton( - runnableId = 1, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 2) public Position overlayPosition = new Position(10, 100); @Expose @@ -261,15 +243,6 @@ public class Mining { public boolean crystalHollowOverlay = true; @Expose - @ConfigOption( - name = "Edit Crystal Overlay Position", - desc = "Change the position of the Crystal Hollows Overlay." - ) - @ConfigEditorButton( - runnableId = 10, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 4) public Position crystalHollowOverlayPosition = new Position(200, 0); @Expose @@ -290,13 +263,13 @@ public class Mining { "\u00a73Electron Transmitter: \u00a7aDone\n" + "\u00a73Robotron Reflector: \u00a7eIn Storage\n" + "\u00a73Superlite Motor: \u00a7eIn Inventory\n" + - "\u00a73Synthetic Hearth: \u00a7cMissing\n" + + "\u00a73Synthetic Heart: \u00a7cMissing\n" + "\u00a73Control Switch: \u00a7cMissing\n" + "\u00a73FTX 3070: \u00a7cMissing", "\u00a73Electron Transmitter: \u00a7a3\n" + "\u00a73Robotron Reflector: \u00a7e2\n" + "\u00a73Superlite Motor: \u00a7e1\n" + - "\u00a73Synthetic Hearth: \u00a7c0\n" + + "\u00a73Synthetic Heart: \u00a7c0\n" + "\u00a73Control Switch: \u00a7c0\n" + "\u00a73FTX 3070: \u00a7c0", "\u00a73Automaton parts: \u00a7a5/6", @@ -753,15 +726,6 @@ public class Mining { public List<Integer> powderGrindingTrackerText = new ArrayList<>(Arrays.asList(0, 1, 2, 3, 4, 5, 6)); @Expose - @ConfigOption( - name = "Edit Tracker Position", - desc = "Change the position of the Powder Grinding Tracker Overlay (chests and gained powder)" - ) - @ConfigEditorButton( - runnableId = 25, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 9) public Position powderGrindingTrackerPosition = new Position(10, 265); @Expose diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java index e73614d1..714dd7b7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/MiscOverlays.java @@ -410,15 +410,6 @@ public class MiscOverlays { public int defaultColour = 15; @Expose - @ConfigOption( - name = "Edit Todo Overlay Position", - desc = "Change the position of the Todo overlay" - ) - @ConfigEditorButton( - runnableId = 5, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 0) public Position todoPosition = new Position(100, 0); @Expose diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java index 6f0d5341..fce1f9af 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/PetOverlay.java @@ -41,14 +41,6 @@ public class PetOverlay { public boolean enablePetInfo = false; @Expose - @ConfigOption( - name = "Edit Pet Info Position", - desc = "Change the position of the pet info overlay" - ) - @ConfigEditorButton( - runnableId = 4, - buttonText = "Edit" - ) public Position petInfoPosition = new Position(-1, -1); @Expose diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java index 2925887f..db0a0e94 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SkillOverlays.java @@ -112,15 +112,6 @@ public class SkillOverlays { public int farmingPauseTimer = 3; @Expose - @ConfigOption( - name = "Edit Farming Overlay Position", - desc = "Change the position of the Farming overlay" - ) - @ConfigEditorButton( - runnableId = 3, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 0) public Position farmingPosition = new Position(10, 200); @Expose @@ -184,15 +175,6 @@ public class SkillOverlays { public int miningPauseTimer = 3; @Expose - @ConfigOption( - name = "Edit Mining Overlay Position", - desc = "Change the position of the Mining overlay" - ) - @ConfigEditorButton( - runnableId = 11, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 1) public Position miningPosition = new Position(10, 200); @Expose @@ -258,15 +240,6 @@ public class SkillOverlays { public int fishingPauseTimer = 3; @Expose - @ConfigOption( - name = "Edit Fishing Overlay Position", - desc = "Change the position of the Fishing overlay" - ) - @ConfigEditorButton( - runnableId = 14, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 3) public Position fishingPosition = new Position(10, 200); @Expose @@ -366,15 +339,6 @@ public class SkillOverlays { public int combatPauseTimer = 3; @Expose - @ConfigOption( - name = "Edit Combat Overlay Position", - desc = "Change the position of the Combat overlay" - ) - @ConfigEditorButton( - runnableId = 19, - buttonText = "Edit" - ) - @ConfigAccordionId(id = 4) public Position combatPosition = new Position(10, 200); @Expose diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlayerOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlayerOverlay.java index 927d00e5..25bd680b 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlayerOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/seperateSections/SlayerOverlay.java @@ -78,14 +78,6 @@ public class SlayerOverlay { public List<Integer> slayerText = new ArrayList<>(Arrays.asList(0, 1, 4, 5, 3, 6)); @Expose - @ConfigOption( - name = "Edit Slayer Overlay Position", - desc = "Change the position of the Slayer overlay" - ) - @ConfigEditorButton( - runnableId = 18, - buttonText = "Edit" - ) public Position slayerPosition = new Position(10, 200); @Expose 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 d180efcf..a70035f1 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBar.java @@ -21,6 +21,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.core.config.gui.GuiPositionEditor; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; @@ -92,8 +93,12 @@ public class FuelBar { @SubscribeEvent public void onRenderScreen(RenderGameOverlayEvent.Post event) { - if (fuelAmount < 0) return; - if (!NotEnoughUpdates.INSTANCE.config.mining.drillFuelBar) return; + if (!GuiPositionEditor.renderDrill) { + if (fuelAmount < 0) return; + if (!NotEnoughUpdates.INSTANCE.config.mining.drillFuelBar) return; + } else { + fuelAmount = .3f; + } if (event.type == RenderGameOverlayEvent.ElementType.ALL) { ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBarDummy.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBarDummy.java new file mode 100644 index 00000000..f1cf4878 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/FuelBarDummy.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2022 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.overlays; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.core.config.Position; +import org.lwjgl.util.vector.Vector2f; + +import java.util.List; +import java.util.function.Supplier; + +public class FuelBarDummy extends TextOverlay { + public FuelBarDummy( + Position position, + Supplier<List<String>> dummyStrings, + Supplier<TextOverlayStyle> styleSupplier + ) { + super(position, dummyStrings, styleSupplier); + super.shouldRenderInGuiEditor = false; + } + + @Override + public void update() { + + } + @Override + public Vector2f getDummySize() { + return new Vector2f(NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarWidth, 12); + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/MapDummy.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MapDummy.java new file mode 100644 index 00000000..9b00829a --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/MapDummy.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2022 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.overlays; + +import io.github.moulberry.notenoughupdates.NotEnoughUpdates; +import io.github.moulberry.notenoughupdates.core.config.Position; +import org.lwjgl.util.vector.Vector2f; + +import java.util.List; +import java.util.function.Supplier; + +public class MapDummy extends TextOverlay { + public MapDummy( + Position position, + Supplier<List<String>> dummyStrings, + Supplier<TextOverlayStyle> styleSupplier + ) { + super(position, dummyStrings, styleSupplier); + } + + @Override + public void update() { + } + + @Override + public Vector2f getDummySize() { + int mapSize = 80 + Math.round(40 * NotEnoughUpdates.INSTANCE.config.dungeonMap.dmBorderSize); + return new Vector2f(mapSize, mapSize); + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java index 5047882d..edb86337 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/OverlayManager.java @@ -27,7 +27,7 @@ import java.util.ArrayList; import java.util.List; public class OverlayManager { - public static Class<? extends TextOverlay> dontRenderOverlay = null; + public static ArrayList<Class<? extends TextOverlay>> dontRenderOverlay = new ArrayList<>(); public static MiningOverlay miningOverlay; public static PowderGrindingOverlay powderGrindingOverlay; @@ -40,6 +40,7 @@ public class OverlayManager { public static BonemerangOverlay bonemerangOverlay; public static CrystalHollowOverlay crystalHollowOverlay; public static SlayerOverlay slayerOverlay; + public static FuelBarDummy fuelBar; public static final List<TextOverlay> textOverlays = new ArrayList<>(); static { @@ -254,13 +255,13 @@ public class OverlayManager { "\u00a73Electron Transmitter: \u00a7aDone\n" + "\u00a73Robotron Reflector: \u00a7eIn Storage\n" + "\u00a73Superlite Motor: \u00a7eIn Inventory\n" + - "\u00a73Synthetic Hearth: \u00a7cMissing\n" + + "\u00a73Synthetic Heart: \u00a7cMissing\n" + "\u00a73Control Switch: \u00a7cMissing\n" + "\u00a73FTX 3070: \u00a7cMissing", "\u00a73Electron Transmitter: \u00a7a3\n" + "\u00a73Robotron Reflector: \u00a7e2\n" + "\u00a73Superlite Motor: \u00a7e1\n" + - "\u00a73Synthetic Hearth: \u00a7c0\n" + + "\u00a73Synthetic Heart: \u00a7c0\n" + "\u00a73Control Switch: \u00a7c0\n" + "\u00a73FTX 3070: \u00a7c0", "\u00a73Automaton parts: \u00a7a5/6", @@ -313,6 +314,15 @@ public class OverlayManager { return TextOverlayStyle.BACKGROUND; }); + List<String> fuelDummy = Lists.newArrayList( + "\u00a73This is a fuel bar" + ); + fuelBar = new FuelBarDummy(NotEnoughUpdates.INSTANCE.config.mining.drillFuelBarPosition, () -> { + List<String> strings = new ArrayList<>(); + strings.add(fuelDummy.get(0)); + return strings; + }, () -> TextOverlayStyle.BACKGROUND); + textOverlays.add(miningOverlay); textOverlays.add(powderGrindingOverlay); textOverlays.add(farmingOverlay); @@ -323,6 +333,7 @@ public class OverlayManager { textOverlays.add(bonemerangOverlay); textOverlays.add(crystalHollowOverlay); textOverlays.add(slayerOverlay); + textOverlays.add(fuelBar); } } 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 f8e02fef..7884b2ac 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java @@ -43,6 +43,8 @@ public abstract class TextOverlay { public boolean shouldUpdateFrequent = false; + public boolean shouldRenderInGuiEditor = true; + private static final int PADDING_X = 5; private static final int PADDING_Y = 5; @@ -127,6 +129,10 @@ public abstract class TextOverlay { return new Vector2f(x, y); } + public Position getPosition() { + return position; + } + protected void renderLine(String line, Vector2f position, boolean dummy) { } |