aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig
diff options
context:
space:
mode:
authorsyeyoung <cyong06@naver.com>2021-08-03 17:23:41 +0900
committersyeyoung <cyong06@naver.com>2021-08-03 17:23:41 +0900
commit982e460c861579f49959c08e25505a27e9c6b3f0 (patch)
tree4cccbe086fd69f5f5be138a3eb24237e0211b76e /src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig
parentd1c36c2412b98350f8336e38361e49b3655982d5 (diff)
downloadSkyblock-Dungeons-Guide-982e460c861579f49959c08e25505a27e9c6b3f0.tar.gz
Skyblock-Dungeons-Guide-982e460c861579f49959c08e25505a27e9c6b3f0.tar.bz2
Skyblock-Dungeons-Guide-982e460c861579f49959c08e25505a27e9c6b3f0.zip
Too many changes to describe
Config gui overhaul. v2
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig')
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/GuiConfigV2.java1
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategoryElement.java8
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MFeature.java10
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MFeatureEdit.java30
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MPanelCategory.java16
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/NestedCategory.java8
-rw-r--r--src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/RootConfigPanel.java79
7 files changed, 134 insertions, 18 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/GuiConfigV2.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/GuiConfigV2.java
index 267d9a5a..8b3e3eb4 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/GuiConfigV2.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/GuiConfigV2.java
@@ -31,7 +31,6 @@ public class GuiConfigV2 extends MGui {
public GuiConfigV2() {
rootConfigPanel = new RootConfigPanel(this);
- rootConfigPanel.setPageGenerator(ConfigPanelCreator.INSTANCE);
getMainPanel().add(rootConfigPanel);
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategoryElement.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategoryElement.java
index 67087dd8..7df00626 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategoryElement.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategoryElement.java
@@ -22,8 +22,10 @@ import kr.syeyoung.dungeonsguide.gui.MPanel;
import kr.syeyoung.dungeonsguide.utils.RenderUtils;
import kr.syeyoung.dungeonsguide.utils.cursor.EnumCursor;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
+import net.minecraft.util.ResourceLocation;
import org.lwjgl.opengl.GL11;
import java.awt.*;
@@ -48,7 +50,7 @@ public class MCategoryElement extends MPanel {
if (rootConfigPanel.getCurrentPage().equals(category)) {
clip(0,scissor.y, Minecraft.getMinecraft().displayWidth, scissor.height);
Gui.drawRect(leftPad - offsetX, 0, getBounds().width, getBounds().height, RenderUtils.blendAlpha(0x141414, 0.13f));
- } else if (lastAbsClip.contains(absMousex, absMousey)) {
+ } else if (lastAbsClip.contains(absMousex, absMousey) && getTooltipsOpen() == 0) {
clip(0,scissor.y, Minecraft.getMinecraft().displayWidth, scissor.height);
Gui.drawRect(leftPad - offsetX, 0, getBounds().width, getBounds().height, RenderUtils.blendAlpha(0x141414, 0.09f));
}
@@ -69,8 +71,10 @@ public class MCategoryElement extends MPanel {
@Override
public void mouseClicked(int absMouseX, int absMouseY, int relMouseX, int relMouseY, int mouseButton) {
- if (!lastAbsClip.contains(absMouseX, absMouseY)) { return; }
+ if (!lastAbsClip.contains(absMouseX, absMouseY) || getTooltipsOpen() > 0) { return; }
if (onClick != null) onClick.run();
+ Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(new ResourceLocation("gui.button.press"), 1.0F));
+
}
@Override
public void mouseMoved(int absMouseX, int absMouseY, int relMouseX0, int relMouseY0) {
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MFeature.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MFeature.java
index 15b36216..7585d56c 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MFeature.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MFeature.java
@@ -106,9 +106,15 @@ public class MFeature extends MPanel {
@Override
public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
- Gui.drawRect(0,0,getBounds().width, getBounds().height, RenderUtils.blendAlpha(0x141414, 0.12f));
+
+ int border = RenderUtils.blendAlpha(0x141414, 0.12f);
+ if (!panel.getSearchWord().isEmpty() && (feature.getName().contains(panel.getSearchWord()) || feature.getDescription().contains(panel.getSearchWord()))) {
+ border = 0xFF02EE67;
+ }
+
+ Gui.drawRect(0,0,getBounds().width, getBounds().height,border);
Gui.drawRect(1,18,getBounds().width -1, getBounds().height-1, RenderUtils.blendAlpha(0x141414, 0.15f));
- Gui.drawRect(0,17,getBounds().width, 18,RenderUtils.blendAlpha(0x141414, 0.12f));
+ Gui.drawRect(1,1,getBounds().width-1, 18, RenderUtils.blendAlpha(0x141414, 0.12f));
FontRenderer fr = Minecraft.getMinecraft().fontRendererObj;
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MFeatureEdit.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MFeatureEdit.java
index 3256c408..fbc1924f 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MFeatureEdit.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MFeatureEdit.java
@@ -23,6 +23,8 @@ import kr.syeyoung.dungeonsguide.features.FeatureParameter;
import kr.syeyoung.dungeonsguide.gui.MPanel;
import kr.syeyoung.dungeonsguide.gui.elements.MButton;
import kr.syeyoung.dungeonsguide.gui.elements.MList;
+import kr.syeyoung.dungeonsguide.gui.elements.MModal;
+import kr.syeyoung.dungeonsguide.gui.elements.MModalConfirmation;
import java.awt.*;
import java.util.HashMap;
@@ -30,7 +32,7 @@ import java.util.Map;
public class MFeatureEdit extends MPanel {
private MList list;
- private MButton goBack;
+ private MButton goBack, resetToDefault;
private RootConfigPanel rootConfigPanel;
private AbstractFeature abstractFeature;
@@ -48,6 +50,30 @@ public class MFeatureEdit extends MPanel {
goBack.setText("< Go Back");
goBack.setOnActionPerformed(rootConfigPanel::goBack);
add(goBack);
+ resetToDefault = new MButton();
+ resetToDefault.setText("Reset To Default");
+ resetToDefault.setForeground(Color.red);
+ resetToDefault.setOnActionPerformed(() -> {
+ openResetConfirmation();
+ });
+ add(resetToDefault);
+ }
+
+ public void openResetConfirmation() {
+ MModalConfirmation mModal = new MModalConfirmation("Are you sure?",
+ "Resetting to default will reset your configuration for the selected feature to default",
+ () -> {
+ for (FeatureParameter parameter : abstractFeature.getParameters()) {
+ parameter.setToDefault();
+ }
+ abstractFeature.onParameterReset();
+ rootConfigPanel.invalidatePage(abstractFeature.getEditRoute(rootConfigPanel));
+ }, () -> {});
+ mModal.setScale(getScale());
+ mModal.getYes().setBorder(0xFFFF0000);
+ mModal.getYes().setText("Yes, Reset it");
+ mModal.getNo().setText("Cancel");
+ mModal.open(MFeatureEdit.this);
}
public void addParameterEdit(String name, MPanel paramEdit) {
@@ -73,9 +99,11 @@ public class MFeatureEdit extends MPanel {
public void setBounds(Rectangle bounds) {
super.setBounds(bounds);
goBack.setBounds(new Rectangle(5,5,75,15));
+ resetToDefault.setBounds(new Rectangle(bounds.width - 105, 5, 100, 15));
list.setBounds(new Rectangle(5,25,bounds.width - 10, bounds.height - 10));
list.realignChildren();
+
}
@Override
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MPanelCategory.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MPanelCategory.java
index 5df29c3b..c2033f7a 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MPanelCategory.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MPanelCategory.java
@@ -45,13 +45,15 @@ public class MPanelCategory extends MPanel {
for (NestedCategory value : nestedCategory.children().values()) {
list.add(new MCategory(value, rootConfigPanel));
}
- String actualCategory = nestedCategory.categoryFull().substring(5);
- if (FeatureRegistry.getFeaturesByCategory().containsKey(actualCategory))
- for (AbstractFeature abstractFeature : FeatureRegistry.getFeaturesByCategory().get(actualCategory)) {
- MFeature mFeature = new MFeature(abstractFeature, rootConfigPanel);
- list.add(mFeature);
- mFeature.setHover(new Color(94, 94, 94, 255));
- }
+ if (nestedCategory.parent() != null) {
+ String actualCategory = nestedCategory.categoryFull().substring(5);
+ if (FeatureRegistry.getFeaturesByCategory().containsKey(actualCategory))
+ for (AbstractFeature abstractFeature : FeatureRegistry.getFeaturesByCategory().get(actualCategory)) {
+ MFeature mFeature = new MFeature(abstractFeature, rootConfigPanel);
+ list.add(mFeature);
+ mFeature.setHover(new Color(94, 94, 94, 255));
+ }
+ }
list.realignChildren();
}
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/NestedCategory.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/NestedCategory.java
index ac3b8f49..25e262b3 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/NestedCategory.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/NestedCategory.java
@@ -19,6 +19,8 @@
package kr.syeyoung.dungeonsguide.config.guiconfig.nyu;
import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
import lombok.experimental.Accessors;
import java.util.HashMap;
@@ -26,9 +28,13 @@ import java.util.Map;
@Data
@Accessors(chain = true, fluent = true)
+public
class NestedCategory {
private final String categoryFull;
+ @EqualsAndHashCode.Exclude
private String categoryName;
+ @EqualsAndHashCode.Exclude
+ @ToString.Exclude
private NestedCategory parent;
public NestedCategory(String categoryFull) {
@@ -36,6 +42,8 @@ class NestedCategory {
this.categoryName = categoryFull.substring(categoryFull.lastIndexOf(".") + 1);
}
+ @EqualsAndHashCode.Exclude
+ @ToString.Exclude
private Map<String, NestedCategory> children = new HashMap<>();
public NestedCategory child(NestedCategory child) {
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/RootConfigPanel.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/RootConfigPanel.java
index e2b97b7f..d43a45da 100644
--- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/RootConfigPanel.java
+++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/RootConfigPanel.java
@@ -32,9 +32,7 @@ import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.Gui;
import java.awt.*;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Stack;
+import java.util.*;
public class RootConfigPanel extends MPanelScaledGUI {
private MScrollablePanel navigationScroll;
@@ -47,7 +45,7 @@ public class RootConfigPanel extends MPanelScaledGUI {
private final Map<String, MPanel> pages = new HashMap<String, MPanel>();
@Getter
@Setter
- private Function<String, MPanel> pageGenerator;
+ private Function<String, MPanel> pageGenerator = ConfigPanelCreator.INSTANCE;
@Getter
private String currentPage = "";
@@ -60,12 +58,34 @@ public class RootConfigPanel extends MPanelScaledGUI {
private final Stack<String> history = new Stack<String>();
+ public String getSearchWord() {
+ return search.getText().trim();
+ }
+
public RootConfigPanel(GuiConfigV2 guiConfigV2) {
this.gui = guiConfigV2;
search = new MTextField() {
@Override
public void edit(String str) {
+ setupNavigation();
+
+ setCurrentPageAndPushHistory("");
+ if (!categoryMap.containsKey(lastOpenCategory)) {
+ for (Map.Entry<NestedCategory, MPanel> nestedCategoryMPanelEntry : categoryMap.entrySet()) {
+ if (nestedCategoryMPanelEntry.getValue() instanceof MCategoryElement) {
+ setCurrentPageAndPushHistory(nestedCategoryMPanelEntry.getKey().categoryFull());
+ lastOpenCategory = nestedCategoryMPanelEntry.getKey();
+ break;
+ }
+ }
+ }
+ for (Map.Entry<NestedCategory, MPanel> nestedCategoryMPanelEntry : categoryMap.entrySet()) {
+ if (nestedCategoryMPanelEntry.getValue() instanceof MCollapsable) {
+ ((MCollapsable) nestedCategoryMPanelEntry.getValue()).setCollapsed(false);
+ }
+ }
+ rePlaceElements();
}
};
search.setPlaceHolder("Search...");
@@ -95,18 +115,49 @@ public class RootConfigPanel extends MPanelScaledGUI {
navigation.setDrawLine(false);
+ setCurrentPageAndPushHistory("ROOT");
rePlaceElements();
}
+
+ private Map<NestedCategory, MPanel> categoryMap = new HashMap<>();
+ private NestedCategory lastOpenCategory;
private void setupNavigation() {
+ categoryMap.clear();
+ for (MPanel childComponent : navigation.getChildComponents()) {
+ navigation.remove(childComponent);
+ }
NestedCategory root = new NestedCategory("ROOT");
+ Set<String> categoryAllowed = new HashSet<>();
+ String search = this.search.getText().trim();
+ for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) {
+ if (search.isEmpty()) {
+ categoryAllowed.add("ROOT."+abstractFeature.getCategory());
+ } else if (abstractFeature.getName().contains(search)) {
+ categoryAllowed.add("ROOT."+abstractFeature.getCategory());
+ } else if (abstractFeature.getDescription().contains(search)) {
+ categoryAllowed.add("ROOT."+abstractFeature.getCategory());
+ }
+ }
for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) {
String category = abstractFeature.getCategory();
+ boolean test =false;
+ for (String s : categoryAllowed) {
+ if (("ROOT."+category).startsWith(s)) {
+ test = true;
+ break;
+ }
+ }
+ if (!test) continue;
NestedCategory currentRoot = root;
for (String s : category.split("\\.")) {
NestedCategory finalCurrentRoot = currentRoot;
- currentRoot = currentRoot.children().computeIfAbsent(s, k -> new NestedCategory(finalCurrentRoot.categoryFull()+"."+k));
+ if (currentRoot.children().containsKey(s))
+ currentRoot = currentRoot.children().get(s);
+ else {
+ currentRoot.child(currentRoot = new NestedCategory(finalCurrentRoot.categoryFull()+"."+s));
+ }
}
}
@@ -114,6 +165,7 @@ public class RootConfigPanel extends MPanelScaledGUI {
for (NestedCategory value : root.children().values()) {
setupNavigationRecursive(value, navigation, 0, 17);
}
+ ConfigPanelCreator.map.put("ROOT", () -> new MPanelCategory(root, this));
}
private void setupNavigationRecursive(NestedCategory nestedCategory, MPanel parent, int depth, int offset) {
ConfigPanelCreator.map.put(nestedCategory.categoryFull(), () -> new MPanelCategory(nestedCategory, this));
@@ -121,11 +173,14 @@ public class RootConfigPanel extends MPanelScaledGUI {
if (nestedCategory.children().size() == 0) {
MCategoryElement current = new MCategoryElement(nestedCategory.categoryFull(),() -> {
setCurrentPageAndPushHistory(nestedCategory.categoryFull());
+ lastOpenCategory = nestedCategory;
}, 13 * depth + 17, offset, this);
parent.add(current);
+ categoryMap.put(nestedCategory, current);
} else {
MCategoryElement current = new MCategoryElement(nestedCategory.categoryFull(),() -> {
setCurrentPageAndPushHistory(nestedCategory.categoryFull());
+ lastOpenCategory = nestedCategory;
}, 3,offset, this);
MCollapsable mCollapsable = new MCollapsable(current, this::rePlaceElements);
mCollapsable.setLeftPad(offset-13);
@@ -133,6 +188,7 @@ public class RootConfigPanel extends MPanelScaledGUI {
mCollapsable.getLowerElements().setGap(0);
mCollapsable.setLeftPadElements(0);
parent.add(mCollapsable);
+ categoryMap.put(nestedCategory, mCollapsable);
for (NestedCategory value : nestedCategory.children().values()) {
setupNavigationRecursive(value, mCollapsable, depth+1, offset+13);
@@ -144,6 +200,7 @@ public class RootConfigPanel extends MPanelScaledGUI {
public void setCurrentPageAndPushHistory(String currentPage) {
if (!this.currentPage.equals(currentPage))
history.push(this.currentPage);
+ lastOpenCategory = null;
this.currentPage = currentPage;
setupPage();
}
@@ -164,6 +221,12 @@ public class RootConfigPanel extends MPanelScaledGUI {
rePlaceElements();
}
+ public void invalidatePage(String page) {
+ pages.remove(page);
+ if (page.equals(currentPage))
+ setupPage();
+ }
+
@Override
public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) {
Dimension effectiveDim = getEffectiveDimension();
@@ -190,6 +253,12 @@ public class RootConfigPanel extends MPanelScaledGUI {
rePlaceElements();
}
+ @Override
+ public void setScale(double scale) {
+ super.setScale(scale);
+ rePlaceElements();
+ }
+
private void rePlaceElements() {
Dimension effectiveDim = getEffectiveDimension();