diff options
| author | Linnea Gräf <roman.graef@gmail.com> | 2023-10-02 17:36:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-10-02 17:36:27 +0200 |
| commit | f4f7ec10fd724b05d922204ac1739536b1ec9caa (patch) | |
| tree | 57e8fb9f98721c7ec8d9a9fec263b1a1523878fc /src/main/java | |
| parent | 3a957574b11d4a3b897ac6b6519ed5689dda2b44 (diff) | |
| download | notenoughupdates-f4f7ec10fd724b05d922204ac1739536b1ec9caa.tar.gz notenoughupdates-f4f7ec10fd724b05d922204ac1739536b1ec9caa.tar.bz2 notenoughupdates-f4f7ec10fd724b05d922204ac1739536b1ec9caa.zip | |
Moul Config (#814)
* Moul Config
* Bump version
* Fix IQ test and oneconfig
* Add version to title
* Fix NPE
* Fix merge
Diffstat (limited to 'src/main/java')
76 files changed, 524 insertions, 3693 deletions
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 <https://www.gnu.org/licenses/>. - */ - -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/struct/GuiOptionEditorBlocked.java b/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiOptionEditorBlocked.java index 11112782..5b1caed8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/core/config/struct/GuiOptionEditorBlocked.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/core/config/GuiOptionEditorBlocked.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -17,9 +17,9 @@ * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. */ -package io.github.moulberry.notenoughupdates.core.config.struct; +package io.github.moulberry.notenoughupdates.core.config; -import io.github.moulberry.notenoughupdates.core.config.gui.GuiOptionEditor; +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; @@ -34,7 +34,7 @@ public class GuiOptionEditorBlocked extends GuiOptionEditor { private final GuiOptionEditor base; public GuiOptionEditorBlocked(GuiOptionEditor base) { - super(base.option); + super(base.getOption()); this.base = base; } 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<Position> positions; + private final ArrayList<Position> originalPositions; + private final ArrayList<Integer> elementWidths; + private final ArrayList<Integer> elementHeights; + private final ArrayList<Supplier<Boolean>> 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<TextOverlay, Position> overlayPositions, + Runnable positionChangedCallback, + Runnable closedCallback + ) { + shouldRenderSupplier = new ArrayList<>(); + ArrayList<Position> pos = new ArrayList<>(); + ArrayList<Position> ogPos = 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); + 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; |
