From f4f7ec10fd724b05d922204ac1739536b1ec9caa Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Mon, 2 Oct 2023 17:36:27 +0200 Subject: Moul Config (#814) * Moul Config * Bump version * Fix IQ test and oneconfig * Add version to title * Fix NPE * Fix merge --- .../moulberry/notenoughupdates/NEUOverlay.java | 4 +- .../notenoughupdates/NotEnoughUpdates.java | 2 +- .../notenoughupdates/core/config/Config.java | 24 - .../core/config/GuiOptionEditorBlocked.java | 74 ++ .../core/config/GuiPositionEditor.java | 260 ++++-- .../GuiPositionEditorButForTheDungeonMap.java | 195 +++++ .../core/config/MoulConfigGuiForgeInterop.java | 6 +- .../core/config/annotations/Category.java | 33 - .../core/config/annotations/ConfigAccordionId.java | 31 - .../config/annotations/ConfigEditorAccordion.java | 31 - .../config/annotations/ConfigEditorBoolean.java | 31 - .../config/annotations/ConfigEditorButton.java | 33 - .../config/annotations/ConfigEditorColour.java | 29 - .../annotations/ConfigEditorDraggableList.java | 33 - .../config/annotations/ConfigEditorDropdown.java | 33 - .../core/config/annotations/ConfigEditorFSR.java | 33 - .../config/annotations/ConfigEditorKeybind.java | 31 - .../config/annotations/ConfigEditorSlider.java | 35 - .../core/config/annotations/ConfigEditorText.java | 29 - .../core/config/annotations/ConfigOption.java | 37 - .../core/config/gui/GuiOptionEditor.java | 83 -- .../core/config/gui/GuiOptionEditorAccordion.java | 96 --- .../core/config/gui/GuiOptionEditorBoolean.java | 71 -- .../core/config/gui/GuiOptionEditorButton.java | 87 -- .../core/config/gui/GuiOptionEditorColour.java | 87 -- .../config/gui/GuiOptionEditorDraggableList.java | 342 -------- .../core/config/gui/GuiOptionEditorDropdown.java | 185 ----- .../core/config/gui/GuiOptionEditorFSR.java | 82 -- .../core/config/gui/GuiOptionEditorKeybind.java | 111 --- .../core/config/gui/GuiOptionEditorSlider.java | 156 ---- .../core/config/gui/GuiOptionEditorText.java | 105 --- .../core/config/gui/GuiPositionEditor.java | 231 ------ .../gui/GuiPositionEditorButForTheDungeonMap.java | 196 ----- .../core/config/struct/ConfigProcessor.java | 250 ------ .../core/config/struct/GuiOptionEditorBlocked.java | 74 -- .../dungeons/GuiDungeonMapEditor.java | 6 +- .../oneconfig/IOneConfigCompat.java | 4 +- .../notenoughupdates/options/NEUConfig.java | 88 +- .../notenoughupdates/options/NEUConfigEditor.java | 916 --------------------- .../options/seperateSections/AHGraph.java | 29 +- .../options/seperateSections/AHTweaks.java | 10 +- .../options/seperateSections/AccessoryBag.java | 4 +- .../options/seperateSections/ApiData.java | 15 +- .../options/seperateSections/BazaarTweaks.java | 8 +- .../options/seperateSections/Calendar.java | 9 +- .../options/seperateSections/CustomArmour.java | 12 +- .../options/seperateSections/DungeonMapConfig.java | 10 +- .../options/seperateSections/Dungeons.java | 50 +- .../options/seperateSections/Enchanting.java | 31 +- .../options/seperateSections/Fishing.java | 35 +- .../options/seperateSections/Garden.java | 4 +- .../options/seperateSections/ImprovedSBMenu.java | 6 +- .../options/seperateSections/InventoryButtons.java | 10 +- .../options/seperateSections/ItemOverlays.java | 37 +- .../options/seperateSections/Itemlist.java | 22 +- .../options/seperateSections/LocationEdit.java | 10 +- .../options/seperateSections/Mining.java | 32 +- .../options/seperateSections/MinionHelper.java | 4 +- .../options/seperateSections/Misc.java | 22 +- .../options/seperateSections/MiscOverlays.java | 15 +- .../options/seperateSections/Museum.java | 8 +- .../options/seperateSections/Notifications.java | 14 +- .../options/seperateSections/PetOverlay.java | 11 +- .../options/seperateSections/ProfileViewer.java | 9 +- .../options/seperateSections/SkillOverlays.java | 31 +- .../options/seperateSections/SlayerOverlay.java | 15 +- .../options/seperateSections/SlotLocking.java | 14 +- .../options/seperateSections/StorageGUI.java | 38 +- .../options/seperateSections/Toolbar.java | 14 +- .../options/seperateSections/TooltipTweaks.java | 19 +- .../options/seperateSections/TradeMenu.java | 4 +- .../options/seperateSections/WardrobeKeybinds.java | 10 +- .../options/seperateSections/WorldConfig.java | 10 +- .../overlays/AuctionSearchOverlay.java | 6 +- .../overlays/BazaarSearchOverlay.java | 5 +- .../notenoughupdates/overlays/FuelBar.java | 2 +- .../notenoughupdates/overlays/FuelBarDummy.java | 2 +- .../profileviewer/bestiary/BestiaryData.kt | 2 +- 78 files changed, 787 insertions(+), 3956 deletions(-) delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/Config.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiOptionEditorBlocked.java create mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiPositionEditorButForTheDungeonMap.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/Category.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigAccordionId.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorAccordion.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorBoolean.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorButton.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorColour.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDraggableList.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDropdown.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorFSR.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorKeybind.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorSlider.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorText.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigOption.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorBoolean.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorButton.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorColour.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDraggableList.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorDropdown.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorFSR.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorKeybind.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorSlider.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorText.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditor.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiPositionEditorButForTheDungeonMap.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/ConfigProcessor.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/GuiOptionEditorBlocked.java delete mode 100644 src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfigEditor.java (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java index 88e7a205..792bbea4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUOverlay.java @@ -23,6 +23,7 @@ import com.google.common.collect.Lists; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import io.github.moulberry.notenoughupdates.commands.help.SettingsCommand; import io.github.moulberry.notenoughupdates.core.BackgroundBlur; import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger; @@ -38,7 +39,6 @@ import io.github.moulberry.notenoughupdates.miscfeatures.EnchantingSolvers; import io.github.moulberry.notenoughupdates.miscfeatures.SunTzu; import io.github.moulberry.notenoughupdates.miscgui.NeuSearchCalculator; import io.github.moulberry.notenoughupdates.miscgui.pricegraph.GuiPriceGraph; -import io.github.moulberry.notenoughupdates.options.NEUConfigEditor; import io.github.moulberry.notenoughupdates.util.Calculator; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.GuiTextures; @@ -402,7 +402,7 @@ public class NEUOverlay extends Gui { return; } if (Mouse.getEventButtonState()) { - NotEnoughUpdates.INSTANCE.openGui = new GuiScreenElementWrapper(NEUConfigEditor.editor); + NotEnoughUpdates.INSTANCE.openGui = SettingsCommand.INSTANCE.createConfigScreen(""); } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index 6105ddb8..f81331ea 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -274,7 +274,7 @@ public class NotEnoughUpdates { if (config.mining.powderGrindingTrackerResetMode == 2) OverlayManager.powderGrindingOverlay.load(); - IOneConfigCompat.getInstance().ifPresent(it -> it.initConfig(config, this::saveConfig)); + IOneConfigCompat.getInstance().ifPresent(it -> it.initConfig(config)); MinecraftForge.EVENT_BUS.register(new NEUEventListener(this)); MinecraftForge.EVENT_BUS.register(new RecipeGenerator(this)); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/Config.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/Config.java deleted file mode 100644 index 6bafb1fd..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/Config.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 . - */ - -package io.github.moulberry.notenoughupdates.core.config; - -public class Config { - public void executeRunnable(int runnableId) {} -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiOptionEditorBlocked.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiOptionEditorBlocked.java new file mode 100644 index 00000000..5b1caed8 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiOptionEditorBlocked.java @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2022-2023 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 . + */ + +package io.github.moulberry.notenoughupdates.core.config; + +import io.github.moulberry.moulconfig.gui.GuiOptionEditor; +import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; +import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; +import lombok.var; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.Gui; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.ResourceLocation; + +public class GuiOptionEditorBlocked extends GuiOptionEditor { + public static final ResourceLocation blockedTexture = new ResourceLocation( + "notenoughupdates:textures/gui/config_blocked.png"); + private final GuiOptionEditor base; + + public GuiOptionEditorBlocked(GuiOptionEditor base) { + super(base.getOption()); + this.base = base; + } + + @Override + public void render(int x, int y, int width) { + // No super. We delegate and overlay ourselves instead. + base.render(x, y, width); + + var mc = Minecraft.getMinecraft(); + + // Depress original option + Gui.drawRect(x, y, x + width, y + getHeight(), 0x80000000); + + GlStateManager.color(1, 1, 1, 1); + mc.getTextureManager().bindTexture(blockedTexture); + + float iconWidth = getHeight() * 96F / 64; + RenderUtils.drawTexturedRect(x, y, iconWidth, getHeight()); + + TextRenderUtils.drawStringScaledMaxWidth( + "This option is currently not available.", + x + iconWidth,y + getHeight() / 2F - mc.fontRendererObj.FONT_HEIGHT / 2F, + true, (int) (width - iconWidth), 0xFFFF4444 + ); + GlStateManager.color(1, 1, 1, 1); + } + + @Override + public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { + return false; + } + + @Override + public boolean keyboardInput() { + return false; + } +} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiPositionEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiPositionEditor.java index eac1e5cd..78cefdfb 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiPositionEditor.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiPositionEditor.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -19,121 +19,213 @@ package io.github.moulberry.notenoughupdates.core.config; +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; +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 net.minecraft.client.renderer.GlStateManager; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.function.Supplier; public class GuiPositionEditor extends GuiScreen { - public PositionNew position = new PositionNew(); + private final ArrayList positions; + private final ArrayList originalPositions; + private final ArrayList elementWidths; + private final ArrayList elementHeights; + private final ArrayList> shouldRenderSupplier; + private final Runnable positionChangedCallback; + private final Runnable closedCallback; + private int grabbedX = 0; + private int grabbedY = 0; + private int clickedPos = -1; + private int oldGuiScale = -1; + public static boolean renderDrill = false; + + + public GuiPositionEditor( + LinkedHashMap overlayPositions, + Runnable positionChangedCallback, + Runnable closedCallback + ) { + shouldRenderSupplier = new ArrayList<>(); + ArrayList pos = new ArrayList<>(); + ArrayList ogPos = new ArrayList<>(); + ArrayList width = new ArrayList<>(); + ArrayList 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); + shouldRenderSupplier.add(() -> { + if (overlay.isEnabled()) { + overlay.renderDummy(); + OverlayManager.dontRenderOverlay.add(overlay.getClass()); + return true; + } + return false; + }); + } + - public int clickedX; - public int clickedY; + this.positions = pos; + this.originalPositions = ogPos; + this.elementWidths = width; + 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 - public void drawScreen(int mouseX, int mouseY, float partialTicks) { - super.drawDefaultBackground(); + public void onGuiClosed() { + super.onGuiClosed(); + 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); + GlStateManager.pushMatrix(); ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - int width = scaledResolution.getScaledWidth(); - int height = scaledResolution.getScaledHeight(); - int x = position.resolveX(scaledResolution, 200); - int y = position.resolveY(scaledResolution, 100); + this.width = scaledResolution.getScaledWidth(); + this.height = scaledResolution.getScaledHeight(); + mouseX = Mouse.getX() * width / Minecraft.getMinecraft().displayWidth; + mouseY = height - Mouse.getY() * height / Minecraft.getMinecraft().displayHeight - 1; - int centerWidth = 176; - int centerHeight = 166; - - float centerWF = centerWidth / 2f / (float) width; - float centerHF = centerHeight / 2f / (float) height; - - float left = 0; - float top = 0; - float right = 0; - float bottom = 0; - - switch (position.getAnchorX()) { - case MIN: { - left = 0; - right = 0.5f - centerWF; - break; + drawDefaultBackground(); + renderDrill = true; + for (Position position : positions) { + if (!shouldRenderSupplier.get(positions.indexOf(position)).get()) { + continue; } - case MID: { - left = 0.5f - centerWF; - right = 0.5f + centerWF; - break; + 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); } - case MAX: { - left = 0.5f + centerWF; - right = 1; - break; - } - } - switch (position.getAnchorY()) { - case MIN: { - top = 0; - bottom = 0.5f - centerHF; - break; - } - case MID: { - top = 0.5f - centerHF; - bottom = 0.5f + centerHF; - break; - } - case MAX: { - top = 0.5f + centerHF; - bottom = 1; - break; - } - } - Gui.drawRect( - (int) (left * width), - (int) (top * height), - (int) (right * width), - (int) (bottom * height), - 0x40404040 + 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); + } + Utils.drawStringCentered("Position Editor", scaledResolution.getScaledWidth() / 2, 8, true, 0xffffff); + Utils.drawStringCentered( + "R to Reset - Arrow keys/mouse to move", + scaledResolution.getScaledWidth() / 2, 18, true, 0xffffff ); - Gui.drawRect(x, y, x + 200, y + 100, 0x80404040); + GlStateManager.popMatrix(); } @Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - int x = position.resolveX(scaledResolution, 200); - int y = position.resolveY(scaledResolution, 100); - - if (mouseX > x && mouseX < x + 200 && - mouseY > y && mouseY < y + 100) { - clickedX = mouseX; - clickedY = mouseY; - } else { - clickedX = -1; - clickedY = -1; + super.mouseClicked(mouseX, mouseY, mouseButton); + + if (mouseButton == 0) { + 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--) { + 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; + } + } + + } + } + } + + @Override + protected void keyTyped(char typedChar, int keyCode) throws IOException { + 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); } @Override protected void mouseReleased(int mouseX, int mouseY, int state) { - clickedX = -1; - clickedY = -1; + super.mouseReleased(mouseX, mouseY, state); + for (Position position : positions) { + position.setClicked(false); + } } @Override protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) { - if (clickedX >= 0 && clickedY >= 0) { - int deltaX = mouseX - clickedX; - int deltaY = mouseY - clickedY; - - ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft()); - - deltaX = position.moveX(scaledResolution, deltaX, 200); - deltaY = position.moveY(scaledResolution, deltaY, 100); - - clickedX += deltaX; - clickedY += deltaY; + 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(); + + Utils.pushGuiScale(-1); + } } } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiPositionEditorButForTheDungeonMap.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiPositionEditorButForTheDungeonMap.java new file mode 100644 index 00000000..aeb54f82 --- /dev/null +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiPositionEditorButForTheDungeonMap.java @@ -0,0 +1,195 @@ +/* + * Copyright (C) 2022-2023 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 . + */ + +package io.github.moulberry.notenoughupdates.core.config; + +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", scaledResolution.getScaledWidth() / 2, 8, true, 0xffffff); + Utils.drawStringCentered( + "R to Reset - Arrow keys/mouse to move", + 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/core/config/MoulConfigGuiForgeInterop.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/MoulConfigGuiForgeInterop.java index 40887e54..de659bcc 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/MoulConfigGuiForgeInterop.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/MoulConfigGuiForgeInterop.java @@ -19,8 +19,8 @@ package io.github.moulberry.notenoughupdates.core.config; -import io.github.moulberry.notenoughupdates.core.GuiScreenElementWrapper; -import io.github.moulberry.notenoughupdates.options.NEUConfigEditor; +import io.github.moulberry.moulconfig.gui.GuiScreenElementWrapper; +import io.github.moulberry.notenoughupdates.commands.help.SettingsCommand; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.fml.client.IModGuiFactory; @@ -53,7 +53,7 @@ public class MoulConfigGuiForgeInterop implements IModGuiFactory { private final GuiScreen parent; public WrappedMoulConfig(GuiScreen parent) { - super(NEUConfigEditor.editor); + super(SettingsCommand.INSTANCE.createConfigElement("")); this.parent = parent; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/Category.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/Category.java deleted file mode 100644 index e0a9585a..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/Category.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 . - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface Category { - String name(); - - String desc(); -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigAccordionId.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigAccordionId.java deleted file mode 100644 index b11f7651..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigAccordionId.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 . - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigAccordionId { - int id(); -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorAccordion.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorAccordion.java deleted file mode 100644 index 7491a94f..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorAccordion.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 . - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigEditorAccordion { - int id(); -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorBoolean.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorBoolean.java deleted file mode 100644 index 8e6f652c..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorBoolean.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 . - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigEditorBoolean { - int runnableId() default -1; -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorButton.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorButton.java deleted file mode 100644 index a2c56dc0..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorButton.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 . - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigEditorButton { - int runnableId(); - - String buttonText() default ""; -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorColour.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorColour.java deleted file mode 100644 index 824b2eec..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorColour.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 . - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigEditorColour {} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDraggableList.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDraggableList.java deleted file mode 100644 index d9707c9b..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDraggableList.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 . - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigEditorDraggableList { - String[] exampleText(); - - boolean allowDeleting() default true; -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDropdown.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDropdown.java deleted file mode 100644 index 8d870643..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorDropdown.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 . - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigEditorDropdown { - String[] values(); - - int initialIndex() default 0; -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorFSR.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorFSR.java deleted file mode 100644 index ba45ae68..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorFSR.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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 . - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigEditorFSR { - int runnableId(); - - String buttonText() default ""; -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorKeybind.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorKeybind.java deleted file mode 100644 index f1a3e329..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorKeybind.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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 . - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigEditorKeybind { - int defaultKey(); -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorSlider.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorSlider.java deleted file mode 100644 index b8db25bc..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorSlider.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 . - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigEditorSlider { - float minValue(); - - float maxValue(); - - float minStep(); -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorText.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorText.java deleted file mode 100644 index b6b32fb2..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigEditorText.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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 . - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigEditorText {} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigOption.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigOption.java deleted file mode 100644 index ddd1e71f..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/annotations/ConfigOption.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 . - */ - -package io.github.moulberry.notenoughupdates.core.config.annotations; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface ConfigOption { - String name(); - - String desc(); - - String[] searchTags() default ""; - - int subcategoryId() default -1; -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java deleted file mode 100644 index fd0946c9..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditor.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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 . - */ - -package io.github.moulberry.notenoughupdates.core.config.gui; - -import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor; -import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; -import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.renderer.GlStateManager; - -public abstract class GuiOptionEditor { - public final ConfigProcessor.ProcessedOption option; - private static final int HEIGHT = 45; - - public GuiOptionEditor(ConfigProcessor.ProcessedOption option) { - this.option = option; - } - - public void render(int x, int y, int width) { - int height = getHeight(); - - FontRenderer fr = Minecraft.getMinecraft().fontRendererObj; - RenderUtils.drawFloatingRectDark(x, y, width, height, true); - TextRenderUtils.drawStringCenteredScaledMaxWidth( - option.name, - x + width / 6, y + 13, true, width / 3 - 10, 0xc0c0c0 - ); - - int maxLines = 5; - float scale = 1; - int lineCount = fr.listFormattedStringToWidth(option.desc, width * 2 / 3 - 10).size(); - - if (lineCount <= 0) return; - - float paraHeight = 9 * lineCount - 1; - - while (paraHeight >= HEIGHT - 10) { - scale -= 1 / 8f; - lineCount = fr.listFormattedStringToWidth(option.desc, (int) (width * 2 / 3 / scale - 10)).size(); - paraHeight = (int) (9 * scale * lineCount - 1 * scale); - } - - GlStateManager.pushMatrix(); - GlStateManager.translate(x + 5 + width / 3f, y + HEIGHT / 2f - paraHeight / 2, 0); - GlStateManager.scale(scale, scale, 1); - - fr.drawSplitString(option.desc, 0, 0, (int) (width * 2 / 3 / scale - 10), 0xc0c0c0); - - GlStateManager.popMatrix(); - } - - public int getHeight() { - return HEIGHT; - } - - public abstract boolean mouseInput(int x, int y, int width, int mouseX, int mouseY); - - public abstract boolean keyboardInput(); - - public boolean mouseInputOverlay(int x, int y, int width, int mouseX, int mouseY) { - return false; - } - - public void renderOverlay(int x, int y, int width) {} -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java deleted file mode 100644 index a422a8ec..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorAccordion.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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 . - */ - -package io.github.moulberry.notenoughupdates.core.config.gui; - -import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor; -import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; -import io.github.moulberry.notenoughupdates.core.util.render.TextRenderUtils; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; - -public class GuiOptionEditorAccordion extends GuiOptionEditor { - private final int accordionId; - - public GuiOptionEditorAccordion(ConfigProcessor.ProcessedOption option, int accordionId) { - super(option); - this.accordionId = accordionId; - } - - @Override - public int getHeight() { - return 20; - } - - public int getAccordionId() { - return accordionId; - } - - public boolean getToggled() { - return (boolean) option.get(); - } - - @Override - public void render(int x, int y, int width) { - int height = getHeight(); - RenderUtils.drawFloatingRectDark(x, y, width, height, true); - - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - GlStateManager.enableBlend(); - GlStateManager.disableTexture2D(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - GlStateManager.color(1, 1, 1, 1); - worldrenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION); - if (getToggled()) { - worldrenderer.pos((double) x + 6, (double) y + 6, 0.0D).endVertex(); - worldrenderer.pos((double) x + 9.75f, (double) y + 13.5f, 0.0D).endVertex(); - worldrenderer.pos((double) x + 13.5f, (double) y + 6, 0.0D).endVertex(); - } else { - worldrenderer.pos((double) x + 6, (double) y + 13.5f, 0.0D).endVertex(); - worldrenderer.pos((double) x + 13.5f, (double) y + 9.75f, 0.0D).endVertex(); - worldrenderer.pos((double) x + 6, (double) y + 6, 0.0D).endVertex(); - } - tessellator.draw(); - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - - TextRenderUtils.drawStringScaledMaxWidth(option.name, x + 18, y + 6, false, width - 10, 0xc0c0c0); - } - - @Override - public boolean mouseInput(int x, int y, int width, int mouseX, int mouseY) { - if (Mouse.getEventButtonState() && mouseX > x && mouseX < x + width && - mouseY > y && mouseY < y + getHeight()) { - option.set(!getToggled()); - return true; - } - - return false; - } - - @Override - public boolean keyboardInput() { - return false; - } -} diff --git a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorBoolean.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorBoolean.java deleted file mode 100644 index 00907e9e..00000000 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/gui/GuiOptionEditorBoolean.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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 . - */ - -package io.github.moulberry.notenoughupdates.core.config.gui; - -import io.github.moulberry.notenoughupdates.core.GuiElementBoolean; -import io.github.moulberry.notenoughupdates.core.config.Config; -import io.github.moulberry.notenoughupdates.core.config.struct.ConfigProcessor; - -public class GuiOptionEditorBoolean extends GuiOptionEditor { - - private final GuiElementBoolean bool; - private final Config config; - private final int runnableId; - - public GuiOptionEditorBoolean( - ConfigProcessor.ProcessedOption option, - int runnableId, - Config config - ) { - super(option); - this.config = config; - this.runnableId = runnableId; - bool = new GuiElementBoolean(0, 0, (