aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-02-05 17:29:09 +0900
committersyeyoung <cyong06@naver.com>2021-02-05 17:29:09 +0900
commit6b4e2499ece7f4328381a88380baea85fe24246d (patch)
tree07a1da8b9d2b6f543d5905a29adc2a5a1c46736d /src
parent3d20d63e025b827ae9a8e7bd62b436fda7986071 (diff)
downloadSkyblock-Dungeons-Guide-6b4e2499ece7f4328381a88380baea85fe24246d.tar.gz
Skyblock-Dungeons-Guide-6b4e2499ece7f4328381a88380baea85fe24246d.tar.bz2
Skyblock-Dungeons-Guide-6b4e2499ece7f4328381a88380baea85fe24246d.zip
Gui Overhaul part 1
Diffstat (limited to 'src')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/ConfigPanelCreator.java22
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/FeatureEditPane.java66
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java30
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterConfig.java133
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java2
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java53
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameter.java6
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java74
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java11
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java17
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java7
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java2
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/gui/elements/MNavigatingPane.java171
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java28
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java2
-rwxr-xr-xsrc/main/java/kr/syeyoung/dungeonsguide/gui/elements/MToggleButton.java56
16 files changed, 472 insertions, 208 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/ConfigPanelCreator.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/ConfigPanelCreator.java
new file mode 100644
index 00000000..8b3ccaca
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/ConfigPanelCreator.java
@@ -0,0 +1,22 @@
+package kr.syeyoung.dungeonsguide.config.guiconfig;
+
+import com.google.common.base.Function;
+import com.google.common.base.Supplier;
+import kr.syeyoung.dungeonsguide.gui.MPanel;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class ConfigPanelCreator implements Function<String, MPanel> {
+ public static final ConfigPanelCreator INSTANCE = new ConfigPanelCreator();
+
+ public static final Map<String, Supplier<MPanel>> map = new HashMap<String, Supplier<MPanel>>();
+
+ @Nullable
+ @Override
+ public MPanel apply(@Nullable String input) {
+ if (!map.containsKey(input)) return null;
+ return map.get(input).get();
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/FeatureEditPane.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/FeatureEditPane.java
index 049808d9..4173b2ac 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/FeatureEditPane.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/FeatureEditPane.java
@@ -4,6 +4,7 @@ import kr.syeyoung.dungeonsguide.config.Config;
import kr.syeyoung.dungeonsguide.features.AbstractFeature;
import kr.syeyoung.dungeonsguide.gui.MPanel;
import kr.syeyoung.dungeonsguide.gui.elements.*;
+import kr.syeyoung.dungeonsguide.utils.TextUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.ScaledResolution;
@@ -21,83 +22,76 @@ import java.util.List;
public class FeatureEditPane extends MPanel {
private List<AbstractFeature> features;
- private MButton save;
private List<MFeature> le = new ArrayList<MFeature>();
private GuiConfig config;
+
+ private MTextField textField;
+ private String search = "";
+
public FeatureEditPane(List<AbstractFeature> features, GuiConfig config) {
this.features = features;
this.config = config;
buildElements();
+
}
public void buildElements() {
- {
- save = new MButton();
- save.setText("Save");
- save.setBackgroundColor(Color.green);
- save.setBounds(new Rectangle(0,0,100,20));
- save.setOnActionPerformed(new Runnable() {
- @Override
- public void run() {
- try {
- Config.saveConfig();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- });
- }
for (AbstractFeature feature : features) {
MFeature mFeature = new MFeature(feature, config);
- mFeature.setHover(new Color(100,100,100,200));
+ mFeature.setHover(new Color(94, 94, 94, 255));
le.add(mFeature);
add(mFeature);
}
+
+ textField = new MTextField() {
+ @Override
+ public void edit(String str) {
+ offsetY = 0;
+ search = str;
+ }
+ };
+ textField.setText("");
+ textField.setBounds(new Rectangle(getBounds().width - 200, 0, 200, 20));
+ add(textField);
}
@Override
public void onBoundsUpdate() {
for (MPanel panel :getChildComponents()){
- panel.setSize(new Dimension(getBounds().width, 20));
+ panel.setSize(new Dimension(getBounds().width, panel.getPreferredSize().height));
}
+ textField.setBounds(new Rectangle(getBounds().width - 200, 0, 200, 20));
}
@Override
public void resize(int parentWidth, int parentHeight) {
- this.setBounds(new Rectangle(5,5,parentWidth-10,parentHeight-10));
+ this.setBounds(new Rectangle(5,1,parentWidth-10,parentHeight-2));
}
@Override
public List<MPanel> getChildComponents() {
- ArrayList<MPanel> panels = new ArrayList<MPanel>(le);
- panels.add(save);
- return panels;
+ List<MPanel> comp = new ArrayList<MPanel>();
+ comp.add(textField);
+ for (MFeature feature:le) {
+ if (feature.getFeature().getName().toLowerCase().contains(search.toLowerCase()))
+ comp.add(feature);
+ }
+ return comp;
}
private int offsetY = 0;
- private MPanel within;
@Override
public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
int heights = 0;
- within = null;
for (MPanel panel:getChildComponents()) {
- panel.setPosition(new Point(0, -offsetY + heights));
- heights += panel.getBounds().height;
-
- if (panel.getBounds().contains(relMousex0, relMousey0)) within = panel;
+ panel.setPosition(new Point(panel.getBounds().x, -offsetY + heights));
+ heights += panel.getBounds().height + 5;
}
}
@Override
public void render0(ScaledResolution resolution, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) {
super.render0(resolution, parentPoint, parentClip, absMousex, absMousey, relMousex0, relMousey0, partialTicks);
-
- if (within instanceof MFeature) {
- AbstractFeature feature = ((MFeature) within).getFeature();
- GlStateManager.pushAttrib();
- drawHoveringText(new ArrayList<String>(Arrays.asList(feature.getDescription().split("\n"))), relMousex0, relMousey0, Minecraft.getMinecraft().fontRendererObj);
- GlStateManager.popAttrib();
- }
}
private static float zLevel = 0;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java
index 421bd918..628e80ef 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiConfig.java
@@ -1,9 +1,12 @@
package kr.syeyoung.dungeonsguide.config.guiconfig;
+import com.google.common.base.Supplier;
import kr.syeyoung.dungeonsguide.features.AbstractFeature;
import kr.syeyoung.dungeonsguide.features.FeatureRegistry;
import kr.syeyoung.dungeonsguide.gui.MPanel;
+import kr.syeyoung.dungeonsguide.gui.elements.MNavigatingPane;
import kr.syeyoung.dungeonsguide.gui.elements.MTabbedPane;
+import lombok.Getter;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution;
@@ -17,21 +20,36 @@ import java.io.IOException;
import java.nio.FloatBuffer;
import java.util.List;
import java.util.Map;
+import java.util.Stack;
public class GuiConfig extends GuiScreen {
private MPanel mainPanel = new MPanel();
- private MTabbedPane tabbedPane;
+ @Getter
+ private MNavigatingPane tabbedPane;
+
+ private Stack<String> history = new Stack();
public GuiConfig() {
- MTabbedPane tabbedPane = new MTabbedPane();
+ MNavigatingPane tabbedPane = new MNavigatingPane();
mainPanel.add(tabbedPane);
- tabbedPane.setBackground2(new Color(17, 17, 17, 179));
+ tabbedPane.setBackground2(new Color(38, 38, 38, 255));
+
+ tabbedPane.setPageGenerator(ConfigPanelCreator.INSTANCE);
+
+
+ for (final Map.Entry<String, List<AbstractFeature>> cate: FeatureRegistry.getFeaturesByCategory().entrySet())
+ if (!cate.getKey().equals("hidden")) {
+ tabbedPane.addBookmark(cate.getKey(), "base." + cate.getKey());
- for (Map.Entry<String, List<AbstractFeature>> cate: FeatureRegistry.getFeaturesByCategory().entrySet())
- if (!cate.getKey().equals("hidden"))
- tabbedPane.addTab(cate.getKey(), new FeatureEditPane(cate.getValue(), this));
+ ConfigPanelCreator.map.put("base." + cate.getKey(), new Supplier<MPanel>() {
+ @Override
+ public MPanel get() {
+ return new FeatureEditPane(cate.getValue(), GuiConfig.this);
+ }
+ });
+ }
this.tabbedPane = tabbedPane;
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterConfig.java
deleted file mode 100755
index 3e2309d0..00000000
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterConfig.java
+++ /dev/null
@@ -1,133 +0,0 @@
-package kr.syeyoung.dungeonsguide.config.guiconfig;
-
-import kr.syeyoung.dungeonsguide.features.AbstractFeature;
-import kr.syeyoung.dungeonsguide.features.FeatureParameter;
-import kr.syeyoung.dungeonsguide.gui.MPanel;
-import kr.syeyoung.dungeonsguide.gui.elements.MButton;
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.GuiScreen;
-import net.minecraft.client.gui.ScaledResolution;
-import net.minecraft.client.renderer.GlStateManager;
-import org.lwjgl.input.Mouse;
-import org.lwjgl.opengl.GL11;
-
-import java.awt.*;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-
-public class GuiParameterConfig extends GuiScreen {
-
- private MPanel mainPanel = new MPanel() {
- @Override
- public void onBoundsUpdate() {
- for (MPanel childComponent : getChildComponents()) {
- childComponent.setSize(new Dimension(getBounds().width - 10, childComponent.getSize().height));
- }
- }
- };
- private GuiScreen before;
- private AbstractFeature feature;
-
- public GuiParameterConfig(final GuiScreen before, AbstractFeature feature) {
- this.before = before;
- for (FeatureParameter parameter: feature.getParameters()) {
- mainPanel.add(new MParameter(feature, parameter, this));
- }
- MButton save = new MButton();
- save.setText("Back");
- save.setBackgroundColor(Color.green);
- save.setBounds(new Rectangle(0,0,100,20));
- save.setOnActionPerformed(new Runnable() {
- @Override
- public void run() {
- Minecraft.getMinecraft().displayGuiScreen(before);
- }
- });
- mainPanel.add(save);
- mainPanel.setBackgroundColor(new Color(17, 17, 17, 179));
-
- }
-
- @Override
- public void initGui() {
- super.initGui();
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- mainPanel.setBounds(new Rectangle(Math.min((scaledResolution.getScaledWidth() - 500) / 2, scaledResolution.getScaledWidth()), Math.min((scaledResolution.getScaledHeight() - 300) / 2, scaledResolution.getScaledHeight()),500,300));
- }
-
- MPanel within;
- @Override
- public void drawScreen(int mouseX, int mouseY, float partialTicks) {
- ScaledResolution scaledResolution = new ScaledResolution(Minecraft.getMinecraft());
- GlStateManager.pushMatrix();
- GlStateManager.pushAttrib();
- GlStateManager.disableLighting();
- GlStateManager.disableFog();GL11.glDisable(GL11.GL_FOG);
- GlStateManager.color(1,1,1,1);
- GlStateManager.disableDepth();
- GlStateManager.depthMask(false);
- int heights = 0;
- within = null;
- for (MPanel panel:mainPanel.getChildComponents()) {
- panel.setPosition(new Point(5, -offsetY + heights + 5));
- heights += panel.getBounds().height;
-
- if (panel.getBounds().contains(mouseX - mainPanel.getBounds().x, mouseY - mainPanel.getBounds().y)) within = panel;
- }
- mainPanel.render0(scaledResolution, new Point(0,0), new Rectangle(0,0,scaledResolution.getScaledWidth(),scaledResolution.getScaledHeight()), mouseX, mouseY, mouseX, mouseY, partialTicks);
- GlStateManager.popMatrix();
- GlStateManager.pushMatrix();
- GlStateManager.color(1,1,1,1);
- if (within instanceof MParameter) {
- FeatureParameter feature = ((MParameter) within).getParameter();
- GlStateManager.pushAttrib();
- drawHoveringText(new ArrayList<String>(Arrays.asList(feature.getDescription().split("\n"))), mouseX, mouseY, Minecraft.getMinecraft().fontRendererObj);
- GlStateManager.popAttrib();
- }
- GlStateManager.enableDepth();
- GlStateManager.depthMask(true);
- GlStateManager.popAttrib();
- GlStateManager.popMatrix();
- }
-
- @Override
- public void keyTyped(char typedChar, int keyCode) throws IOException {
- super.keyTyped(typedChar, keyCode);
- mainPanel.keyTyped0(typedChar, keyCode);
- }
-
- @Override
- public void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
- super.mouseClicked(mouseX, mouseY, mouseButton);
- mainPanel.mouseClicked0(mouseX, mouseY,mouseX,mouseY, mouseButton);
- }
-
- @Override
- public void mouseReleased(int mouseX, int mouseY, int state) {
- mainPanel.mouseReleased0(mouseX, mouseY,mouseX,mouseY, state);
- }
-
- @Override
- public void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
- mainPanel.mouseClickMove0(mouseX,mouseY,mouseX,mouseY,clickedMouseButton,timeSinceLastClick);
- }
-
- public int offsetY = 0;
- @Override
- public void handleMouseInput() throws IOException {
- super.handleMouseInput();
-
- int i = Mouse.getEventX() * this.width / this.mc.displayWidth;
- int j = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
-
- int wheel = Mouse.getDWheel();
- if (wheel != 0) {
- mainPanel.mouseScrolled0(i, j,i,j, wheel);
- }
-
- if (wheel > 0) offsetY -= 20;
- else if (wheel < 0) offsetY += 20;
- if (offsetY < 0) offsetY = 0;
- }
-}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java
index 90048a69..feceee7e 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/GuiParameterValueEdit.java
@@ -44,7 +44,7 @@ public class GuiParameterValueEdit extends GuiScreen {
@Getter
private Parameter parameter;
- public GuiParameterValueEdit(final Object object, final GuiParameterConfig prev) {
+ public GuiParameterValueEdit(final Object object, final GuiConfig prev) {
try {
this.editingObj = object;
mainPanel.setBackgroundColor(new Color(17, 17, 17, 179));
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java
index cdc15456..4281f6a3 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MFeature.java
@@ -6,10 +6,13 @@ import kr.syeyoung.dungeonsguide.gui.MPanel;
import kr.syeyoung.dungeonsguide.gui.elements.MButton;
import kr.syeyoung.dungeonsguide.gui.elements.MLabel;
import kr.syeyoung.dungeonsguide.gui.elements.MStringSelectionButton;
+import kr.syeyoung.dungeonsguide.gui.elements.MToggleButton;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
+import net.minecraft.client.renderer.GlStateManager;
import java.awt.*;
import java.util.Arrays;
@@ -17,7 +20,6 @@ import java.util.List;
import java.util.ArrayList;
public class MFeature extends MPanel {
- private MLabel label;
@Getter
private AbstractFeature feature;
@@ -33,31 +35,30 @@ public class MFeature extends MPanel {
this.config = config;
this.feature = abstractFeature;
- this.add(this.label = new MLabel());
- this.label.setText(abstractFeature.getName());
-
{
- final MStringSelectionButton mStringSelectionButton = new MStringSelectionButton(new ArrayList<String>(Arrays.asList(new String[] {"on", "off"})), abstractFeature.isEnabled() ? "on" : "off");
- mStringSelectionButton.setOnUpdate(new Runnable() {
+ final MToggleButton mStringSelectionButton = new MToggleButton();
+ mStringSelectionButton.setOnToggle(new Runnable() {
@Override
public void run() {
- String selected = mStringSelectionButton.getSelected();
- feature.setEnabled("on".equals(selected));
+ boolean selected = mStringSelectionButton.isEnabled();
+ feature.setEnabled(selected);
}
});
addons.add(mStringSelectionButton);
+ mStringSelectionButton.setSize(new Dimension(30, 15));
add(mStringSelectionButton);
}
- if (!abstractFeature.getParameters().isEmpty()) {
+ if (abstractFeature.getParameters().size() != 0) {
MButton button = new MButton();
button.setText("Edit");
button.setOnActionPerformed(new Runnable() {
@Override
public void run() {
- Minecraft.getMinecraft().displayGuiScreen(new GuiParameterConfig(config, abstractFeature));
+ config.getTabbedPane().setCurrentPage(abstractFeature.getEditRoute(config));
}
});
addons.add(button);
+ button.setSize(new Dimension(50, 15));
add(button);
}
if (abstractFeature instanceof GuiFeature) {
@@ -70,15 +71,30 @@ public class MFeature extends MPanel {
}
});
addons.add(button);
+ button.setSize(new Dimension(50, 15));
add(button);
}
}
@Override
public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
+ Gui.drawRect(0,0,getBounds().width, getBounds().height,0xFF444444);
if (hover != null && new Rectangle(new Point(0,0),getBounds().getSize()).contains(relMousex0, relMousey0)) {
- Gui.drawRect(0,0,getBounds().width, getBounds().height, hover.getRGB());
+ Gui.drawRect(1,18,getBounds().width -1, getBounds().height-1, hover.getRGB());
+ } else {
+ Gui.drawRect(1,18,getBounds().width -1, getBounds().height-1, 0xFF545454);
}
+ Gui.drawRect(0,17,getBounds().width, 18,0xFF444444);
+
+
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ GlStateManager.pushMatrix();
+ GlStateManager.translate(5,5,0);
+ GlStateManager.scale(1.0,1.0,0);
+ fr.drawString(feature.getName(), 0,0, 0xFFFFFFFF);
+ GlStateManager.popMatrix();
+
+ fr.drawSplitString(feature.getDescription(), 5, 23, getBounds().width -10, 0xFFBFBFBF);
}
@Override
@@ -87,12 +103,19 @@ public class MFeature extends MPanel {
}
@Override
+ public Dimension getPreferredSize() {
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ int descriptionHeight = fr.listFormattedStringToWidth(feature.getDescription(), Math.max(100, getBounds().width - 10)).size() * fr.FONT_HEIGHT;
+
+ return new Dimension(100, descriptionHeight + 28);
+ }
+
+ @Override
public void onBoundsUpdate() {
- int x = getBounds().width - 50;
+ int x = getBounds().width - 5;
for (MPanel panel : addons) {
- panel.setBounds(new Rectangle(x, 3, 50, getBounds().height - 6));
- x -= 50;
+ panel.setBounds(new Rectangle(x - panel.getPreferredSize().width, 3, panel.getPreferredSize().width, 12));
+ x -= panel.getPreferredSize().width + 5;
}
- label.setBounds(new Rectangle(0,0,x, getBounds().height));
}
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameter.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameter.java
index fc215a91..a712c08b 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameter.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/MParameter.java
@@ -28,10 +28,10 @@ public class MParameter extends MPanel {
@Getter @Setter
private Color hover;
- private GuiParameterConfig config;
+ private PanelDefaultParameterConfig config;
private MLabel label2;
- public MParameter(AbstractFeature abstractFeature, final FeatureParameter parameter, final GuiParameterConfig config) {
+ public MParameter(AbstractFeature abstractFeature, final FeatureParameter parameter, final PanelDefaultParameterConfig config, final GuiConfig config2) {
this.config = config;
this.parameter = parameter;
this.feature = abstractFeature;
@@ -45,7 +45,7 @@ public class MParameter extends MPanel {
button.setOnActionPerformed(new Runnable() {
@Override
public void run() {
- final GuiParameterValueEdit guiParameterValueEdit = new GuiParameterValueEdit(parameter.getValue(), config);
+ final GuiParameterValueEdit guiParameterValueEdit = new GuiParameterValueEdit(parameter.getValue(), config2);
guiParameterValueEdit.setOnUpdate(new Runnable() {
@Override
public void run() {
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java
new file mode 100755
index 00000000..708d510b
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/PanelDefaultParameterConfig.java
@@ -0,0 +1,74 @@
+package kr.syeyoung.dungeonsguide.config.guiconfig;
+
+import kr.syeyoung.dungeonsguide.features.AbstractFeature;
+import kr.syeyoung.dungeonsguide.features.FeatureParameter;
+import kr.syeyoung.dungeonsguide.gui.MPanel;
+import kr.syeyoung.dungeonsguide.gui.elements.MButton;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.GuiScreen;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.client.renderer.GlStateManager;
+import org.lwjgl.input.Mouse;
+import org.lwjgl.opengl.GL11;
+
+import java.awt.*;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+
+public class PanelDefaultParameterConfig extends MPanel {
+
+ private AbstractFeature feature;
+
+ @Override
+ public void onBoundsUpdate() {
+ for (MPanel childComponent : getChildComponents()) {
+ childComponent.setSize(new Dimension(getBounds().width - 10, childComponent.getSize().height));
+ }
+ }
+
+ @Override
+ public void resize(int parentWidth, int parentHeight) {
+ this.setBounds(new Rectangle(0,0,parentWidth, parentHeight));
+ }
+
+ private GuiConfig config;
+ public PanelDefaultParameterConfig(final GuiConfig config, AbstractFeature feature) {
+ this.config = config;
+ for (FeatureParameter parameter: feature.getParameters()) {
+ add(new MParameter(feature, parameter, this, config));
+ }
+ setBackgroundColor(new Color(38, 38, 38, 255));
+ }
+
+
+ MPanel within;
+ @Override
+ public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
+ int heights = 0;
+ within = null;
+ for (MPanel panel:getChildComponents()) {
+ panel.setPosition(new Point(5, -offsetY + heights + 5));
+ heights += panel.getBounds().height;
+
+ if (panel.getBounds().contains(relMousex0,relMousey0)) within = panel;
+ }
+ if (within instanceof MParameter) {
+ FeatureParameter feature = ((MParameter) within).getParameter();
+ GL11.glDisable(GL11.GL_SCISSOR_TEST);
+ FeatureEditPane.drawHoveringText(new ArrayList<String>(Arrays.asList(feature.getDescription().split("\n"))), relMousex0,relMousey0, Minecraft.getMinecraft().fontRendererObj);
+ GL11.glEnable(GL11.GL_SCISSOR_TEST);
+ }
+ }
+
+
+ public int offsetY = 0;
+
+ @Override
+ public void mouseScrolled(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0, int scrollAmount) {
+ if (scrollAmount > 0) offsetY -= 20;
+ else if (scrollAmount < 0) offsetY += 20;
+ if (offsetY < 0) offsetY = 0;
+ }
+
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java
index 1b9dd350..855c31c4 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/eventlistener/DungeonListener.java
@@ -34,6 +34,7 @@ import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
+import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent;
@@ -43,9 +44,19 @@ import org.lwjgl.opengl.GL11;
import scala.collection.parallel.ParIterableLike;
import java.awt.*;
+import java.io.IOException;
public class DungeonListener {
@SubscribeEvent
+ public void onWorldLoad(WorldEvent.Unload event) {
+ try {
+ Config.saveConfig();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @SubscribeEvent
public void onPostDraw(GuiScreenEvent.DrawScreenEvent.Post e) {
try {
SkyblockStatus skyblockStatus = (SkyblockStatus) kr.syeyoung.dungeonsguide.e.getDungeonsGuide().getSkyblockStatus();
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java
index 30b1a29a..77b852b0 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/features/AbstractFeature.java
@@ -1,12 +1,17 @@
package kr.syeyoung.dungeonsguide.features;
+import com.google.common.base.Supplier;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+import kr.syeyoung.dungeonsguide.config.guiconfig.ConfigPanelCreator;
+import kr.syeyoung.dungeonsguide.config.guiconfig.GuiConfig;
+import kr.syeyoung.dungeonsguide.config.guiconfig.PanelDefaultParameterConfig;
import kr.syeyoung.dungeonsguide.config.types.TypeConverter;
import kr.syeyoung.dungeonsguide.config.types.TypeConverterRegistry;
-import kr.syeyoung.dungeonsguide.features.FeatureParameter;
+import kr.syeyoung.dungeonsguide.gui.MPanel;
import lombok.Getter;
import lombok.Setter;
+import net.minecraft.client.Minecraft;
import java.util.*;
@@ -61,4 +66,14 @@ public abstract class AbstractFeature {
object.addProperty("$enabled", isEnabled());
return object;
}
+
+ public String getEditRoute(final GuiConfig config) {
+ ConfigPanelCreator.map.put("base." + key , new Supplier<MPanel>() {
+ @Override
+ public MPanel get() {
+ return new PanelDefaultParameterConfig(config, AbstractFeature.this);
+ }
+ });
+ return "base." + key ;
+ }
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java
index 4eae2298..50d5b85f 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/MPanel.java
@@ -42,6 +42,8 @@ public class MPanel {
return getBounds().getSize();
}
+ public Dimension getPreferredSize() { return getSize(); }
+
public void setBounds(Rectangle bounds) {
if (bounds == null) return;
this.bounds.x = bounds.x;
@@ -69,7 +71,6 @@ public class MPanel {
public void render0(ScaledResolution resolution, Point parentPoint, Rectangle parentClip, int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks) { // 0,0 - a a
-
int relMousex = relMousex0 - getBounds().x;
int relMousey = relMousey0 - getBounds().y;
@@ -97,7 +98,7 @@ public class MPanel {
GlStateManager.popMatrix();
GL11.glDisable(GL11.GL_SCISSOR_TEST);
- GL11.glPopAttrib();
+ GlStateManager.popAttrib();
Point newPt = new Point(parentPoint.x + getBounds().x, parentPoint.y + getBounds().y);
@@ -112,6 +113,8 @@ public class MPanel {
}
public void clip(ScaledResolution resolution, int x, int y, int width, int height) {
+ if (width < 0 || height < 0) return;
+
int scale = resolution.getScaleFactor();
GL11.glScissor((x ) * scale, Minecraft.getMinecraft().displayHeight - (y + height) * scale, (width) * scale, height * scale);
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java
index 17196ebc..ff420a32 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MButton.java
@@ -39,7 +39,7 @@ public class MButton extends MPanel {
FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj;
int width = renderer.getStringWidth(getText());
int x = (getBounds().width - width) / 2;
- int y = (getBounds().height - renderer.FONT_HEIGHT) / 2;
+ int y = (getBounds().height - renderer.FONT_HEIGHT) / 2 + 1;
renderer.drawString(getText(), x,y, foreground.getRGB());
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MNavigatingPane.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MNavigatingPane.java
new file mode 100755
index 00000000..c59b3b4f
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MNavigatingPane.java
@@ -0,0 +1,171 @@
+package kr.syeyoung.dungeonsguide.gui.elements;
+
+import com.google.common.base.Function;
+import kr.syeyoung.dungeonsguide.gui.MPanel;
+import lombok.Getter;
+import lombok.Setter;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.Gui;
+import scala.collection.mutable.Stack;
+
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class MNavigatingPane extends MPanel {
+
+ private Map<String, MPanel> pages = new HashMap<String, MPanel>();
+ private List<MTabButton> bookMarks = new ArrayList<MTabButton>();
+
+ @Getter
+ @Setter
+ private Function<String, MPanel> pageGenerator;
+
+ @Getter
+ private String currentPage = "";
+
+ public void setCurrentPage(String currentPage) {
+ this.history.push(this.currentPage);
+ this.currentPage = currentPage;
+ }
+
+ @Getter
+ private Color background2;
+
+ private Stack<String> history = new Stack<String>();
+
+ private MButton back = new MButton();
+
+ public MNavigatingPane() {
+ back.setText("<");
+ back.setOnActionPerformed(new Runnable() {
+ @Override
+ public void run() {
+ if (history.size() > 0)
+ currentPage = history.pop();
+ }
+ });
+ back.setBackgroundColor(Color.darkGray);
+ back.setBounds(new Rectangle(3,18,12,12));
+ add(back);
+ }
+
+ public void setBackground2(Color background2) {
+ this.background2 = background2;
+ for (MPanel value : pages.values()) {
+ value.setBackgroundColor(background2);
+ }
+ }
+
+ @Override
+ public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
+
+ Gui.drawRect(0, 15, getBounds().width, getBounds().height, 0xFF444444);
+ Gui.drawRect(1, 16, getBounds().width-1, getBounds().height-1, background2 != null ? background2.getRGB() : 0);
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+
+ fr.drawString(currentPage.replace(".", " > "), 20, 20, 0xFFFFFFFF);
+
+ }
+
+ public void addBookmark(String name, String addr) {
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ MTabButton button = new MTabButton(this, name, addr);
+ int totalX = 0;
+ for (MTabButton button1:bookMarks)
+ totalX += button1.getBounds().width;
+ button.setBounds(new Rectangle(totalX, 0, Math.max(25, fr.getStringWidth(name) + 6), 15));
+ bookMarks.add(button);
+ if (bookMarks.size() == 1)
+ currentPage = addr;
+ }
+
+ @Override
+ public List<MPanel> getChildComponents() {
+ ArrayList<MPanel> dynamic = new ArrayList<MPanel>(bookMarks);
+ if (!pages.containsKey(currentPage)) {
+ MPanel panel = pageGenerator.apply(currentPage);
+ MPanel panel2 = new MPanel() ;
+ panel2.add(panel);
+ panel2.setBackgroundColor(background2);
+ pages.put(currentPage, panel2);
+ panel2.setBounds(new Rectangle(1,30,getBounds().width-2, getBounds().height-31));
+ }
+ dynamic.add(pages.get(currentPage));
+ dynamic.add(back);
+ return dynamic;
+ }
+
+ @Override
+ public void resize(int parentWidth, int parentHeight) {
+ this.setBounds(new Rectangle(0,0,parentWidth, parentHeight));
+ for (MPanel ma:pages.values())
+ ma.setBounds(new Rectangle(1,30,getBounds().width-2, getBounds().height-31));
+ }
+
+ @Override
+ public void setBounds(Rectangle bounds) {
+ if (bounds == null) return;
+ this.bounds.x = bounds.x;
+ this.bounds.y = bounds.y;
+ this.bounds.width = bounds.width;
+ this.bounds.height = bounds.height;
+ }
+
+ @Getter
+ @Setter
+ public static class MTabButton extends MPanel {
+ private String text;
+ private String address;
+
+ private Color foreground = Color.white;
+ private Color hover = new Color(154, 154, 154, 255);
+ private Color clicked = new Color(88, 88, 88,255);
+ private Color selected = new Color(111, 111, 111,255);
+ private Color disabled = new Color(0,0,0);
+
+ private boolean enabled = true;
+
+ private MNavigatingPane tabbedPane;
+
+ public MTabButton(MNavigatingPane tabbedPane, String key, String address) {
+ this.tabbedPane = tabbedPane;
+ this.text = key;
+ this.address = address;
+ }
+
+ @Override
+ public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) {
+ Dimension bounds = getSize();
+
+ Color bg = null;
+ if (!enabled) {
+ bg = disabled;
+ } else if (tabbedPane.getCurrentPage().equals(address)) {
+ bg = selected;
+ } else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) {
+ bg = hover;
+ }
+ Gui.drawRect(0, tabbedPane.getCurrentPage().equals(address) ? 0 : 2, getBounds().width, getBounds().height, 0xFF444444);
+ if (bg != null)
+ Gui.drawRect(1,tabbedPane.getCurrentPage().equals(address) ? 1 : 3,getBounds().width - 1, getBounds().height, bg.getRGB());
+
+ FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj;
+ int width = renderer.getStringWidth(text);
+ int x = (getBounds().width - width) / 2;
+ int y = (getBounds().height - 3 - renderer.FONT_HEIGHT) / 2 + 3;
+
+ renderer.drawString(text, x,y, foreground.getRGB());
+ }
+
+ @Override
+ public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
+ if (lastAbsClip.contains(absMouseX, absMouseY)) {
+ tabbedPane.setCurrentPage(address);
+ }
+ }
+ }
+}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java
index ddf1c8a9..dc14264b 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTabbedPane.java
@@ -1,6 +1,7 @@
package kr.syeyoung.dungeonsguide.gui.elements;
import kr.syeyoung.dungeonsguide.gui.MPanel;
+import kr.syeyoung.dungeonsguide.utils.RenderUtils;
import lombok.Getter;
import lombok.Setter;
import net.minecraft.client.Minecraft;
@@ -35,16 +36,24 @@ public class MTabbedPane extends MPanel {
}
}
+ @Override
+ public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
+ Gui.drawRect(0, 15, getBounds().width, getBounds().height, 0xFF444444);
+ }
+
public void addTab(String tab, MPanel panel) {
MPanel panel2 = new MPanel() ;
panel2.add(panel);
panel2.setBackgroundColor(background2);
tabs.put(tab, panel2);
- panel2.setBounds(new Rectangle(0,15,getBounds().width, getBounds().height-15));
+ panel2.setBounds(new Rectangle(1,16,getBounds().width-2, getBounds().height-17));
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
MTabButton button = new MTabButton(this, tab);
- button.setBackgroundColor(background2.brighter());
- button.setBounds(new Rectangle(buttons.size()* 50, 0, 50, 15));
+ int totalX = 0;
+ for (MTabButton button1:buttons.values())
+ totalX += button1.getBounds().width;
+ button.setBounds(new Rectangle(totalX, 0, Math.max(25, fr.getStringWidth(tab) + 6), 15));
buttons.put(tab, button);
if (tabs.size() == 1)
selectedKey = tab;
@@ -61,7 +70,7 @@ public class MTabbedPane extends MPanel {
public void resize(int parentWidth, int parentHeight) {
this.setBounds(new Rectangle(0,0,parentWidth, parentHeight));
for (MPanel ma:tabs.values())
- ma.setBounds(new Rectangle(0,15,parentWidth, parentHeight-15));
+ ma.setBounds(new Rectangle(1,16,getBounds().width-2, getBounds().height-17));
}
@Override
@@ -79,9 +88,9 @@ public class MTabbedPane extends MPanel {
private String text;
private Color foreground = Color.white;
- private Color hover = new Color(236, 236, 236, 64);
- private Color clicked = new Color(30,30,30,0);
- private Color selected = new Color(0,0,0,255);
+ private Color hover = new Color(154, 154, 154, 255);
+ private Color clicked = new Color(88, 88, 88,255);
+ private Color selected = new Color(111, 111, 111,255);
private Color disabled = new Color(0,0,0);
private boolean enabled = true;
@@ -105,13 +114,14 @@ public class MTabbedPane extends MPanel {
} else if (new Rectangle(new Point(0,0),bounds).contains(relMousex0, relMousey0)) {
bg = hover;
}
+ Gui.drawRect(0, tabbedPane.getSelectedKey().equals(text) ? 0 : 2, getBounds().width, getBounds().height, 0xFF444444);
if (bg != null)
- Gui.drawRect(0,0,getBounds().width, getBounds().height, bg.getRGB());
+ Gui.drawRect(1,tabbedPane.getSelectedKey().equals(text) ? 1 : 3,getBounds().width - 1, getBounds().height, bg.getRGB());
FontRenderer renderer = Minecraft.getMinecraft().fontRendererObj;
int width = renderer.getStringWidth(text);
int x = (getBounds().width - width) / 2;
- int y = (getBounds().height - renderer.FONT_HEIGHT) / 2;
+ int y = (getBounds().height - 3 - renderer.FONT_HEIGHT) / 2 + 3;
renderer.drawString(text, x,y, foreground.getRGB());
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java
index 57232f7f..d3f2b2c0 100755
--- a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MTextField.java
@@ -43,7 +43,7 @@ public class MTextField extends MPanel {
@Override
public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) {
Gui.drawRect(0,0,getBounds().width, getBounds().height, isFocused ? Color.white.getRGB() : Color.gray.getRGB());
- Gui.drawRect(1,1,getBounds().width - 2, getBounds().height - 2, Color.black.getRGB());
+ Gui.drawRect(1,1,getBounds().width - 1, getBounds().height - 1, Color.black.getRGB());
Minecraft mc = Minecraft.getMinecraft();
clip(new ScaledResolution(mc), clip.x + 1, clip.y + 1, clip.width - 2, clip.height - 2);
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MToggleButton.java b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MToggleButton.java
new file mode 100755
index 00000000..5d2d4d67
--- /dev/null
+++ b/src/main/java/kr/syeyoung/dungeonsguide/gui/elements/MToggleButton.java
@@ -0,0 +1,56 @@
+package kr.syeyoung.dungeonsguide.gui.elements;
+
+import kr.syeyoung.dungeonsguide.gui.MPanel;
+import lombok.Getter;
+import lombok.Setter;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.FontRenderer;
+import net.minecraft.client.gui.Gui;
+import net.minecraft.client.renderer.GlStateManager;
+import org.lwjgl.opengl.GL11;
+
+import java.awt.*;
+
+@Getter
+@Setter
+public class MToggleButton extends MPanel {
+ private boolean enabled = true;
+ private Runnable onToggle;
+
+ @Override
+ public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle clip) {
+ Dimension bounds = getSize();
+
+ int gap = 1;
+
+ Gui.drawRect(0, 0, bounds.width, bounds.height, 0xFF333333);
+ Gui.drawRect(gap, gap, bounds.width-gap, bounds.height-gap, 0xFF171717);
+
+
+ FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
+ double scale = 2;
+ if (enabled) {
+ int x = (int) ((scale * bounds.height - fr.FONT_HEIGHT)/2 + gap);
+ GlStateManager.pushMatrix();
+ GlStateManager.scale(1.0/scale,1.0/scale,0);
+ fr.drawString("ON", x, x, 0xFF9B9B9B);
+ GlStateManager.popMatrix();
+ Gui.drawRect(bounds.width - bounds.height+gap,gap, bounds.width - gap, bounds.height - gap, 0xFF00B200);
+ } else {
+ GlStateManager.pushMatrix();
+ GlStateManager.scale(1.0/scale,1.0/scale,0);
+ int x = (int) ((scale * bounds.height - fr.FONT_HEIGHT)/2 + gap);
+ fr.drawString("OFF", (int) (scale * bounds.width - x - fr.getStringWidth("OFF")), x, 0xFF9B9B9B);
+ GlStateManager.popMatrix();
+ Gui.drawRect(gap,gap, bounds.height - gap, bounds.height - gap, 0xFFCD4000);
+ }
+ }
+
+ @Override
+ public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
+ if (onToggle != null && lastAbsClip.contains(absMouseX, absMouseY)) {
+ enabled = !enabled;
+ onToggle.run();
+ }
+ }
+}