diff options
author | syeyoung <cyong06@naver.com> | 2021-08-03 18:51:07 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-08-03 18:51:07 +0900 |
commit | ecf7ff8db99a178dec09829abcc929a882a6bc01 (patch) | |
tree | f507ea19f77408132500f41756e2b925b0ad4dc9 /src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig | |
parent | 5f8c2788c2a7a62bf8b522ecfa39c6801333b577 (diff) | |
download | Skyblock-Dungeons-Guide-ecf7ff8db99a178dec09829abcc929a882a6bc01.tar.gz Skyblock-Dungeons-Guide-ecf7ff8db99a178dec09829abcc929a882a6bc01.tar.bz2 Skyblock-Dungeons-Guide-ecf7ff8db99a178dec09829abcc929a882a6bc01.zip |
- Convert to lowercase first before performing .contains for searching
- Social Media buttons on config
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig')
3 files changed, 44 insertions, 13 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategory.java b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategory.java index 7fbffbf8..aefc29a2 100644 --- a/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategory.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/config/guiconfig/nyu/MCategory.java @@ -47,10 +47,15 @@ public class MCategory 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 (!rootConfigPanel.getSearchWord().isEmpty() && (nestedCategory.categoryName().toLowerCase().contains(rootConfigPanel.getSearchWord()))) { + border = 0xFF02EE67; + } + + Gui.drawRect(0,0,getBounds().width, getBounds().height,border); if (getBounds().height >= 28) 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; @@ -75,7 +80,7 @@ public class MCategory extends MPanel { int descriptionHeight = FeatureRegistry.getCategoryDescription().containsKey(nestedCategory.categoryFull()) ? fr.listFormattedStringToWidth(FeatureRegistry.getCategoryDescription().get(nestedCategory.categoryFull()), Math.max(100, getBounds().width - 10)).size() * fr.FONT_HEIGHT - : -11; + : -9; return new Dimension(100, descriptionHeight + 28); } 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 7585d56c..94ce0ad4 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 @@ -108,7 +108,7 @@ public class MFeature extends MPanel { public void render(int absMousex, int absMousey, int relMousex0, int relMousey0, float partialTicks, Rectangle scissor) { int border = RenderUtils.blendAlpha(0x141414, 0.12f); - if (!panel.getSearchWord().isEmpty() && (feature.getName().contains(panel.getSearchWord()) || feature.getDescription().contains(panel.getSearchWord()))) { + if (!panel.getSearchWord().isEmpty() && (feature.getName().toLowerCase().contains(panel.getSearchWord()) || feature.getDescription().toLowerCase().contains(panel.getSearchWord()))) { border = 0xFF02EE67; } 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 d43a45da..62f16f2d 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,6 +32,9 @@ import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.Gui; import java.awt.*; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; import java.util.*; public class RootConfigPanel extends MPanelScaledGUI { @@ -56,10 +59,12 @@ public class RootConfigPanel extends MPanelScaledGUI { private MTextField search; private MButton guiRelocate; + private MButton github, discord; + private final Stack<String> history = new Stack<String>(); public String getSearchWord() { - return search.getText().trim(); + return search.getText().trim().toLowerCase(); } public RootConfigPanel(GuiConfigV2 guiConfigV2) { @@ -99,6 +104,26 @@ public class RootConfigPanel extends MPanelScaledGUI { guiRelocate.setBorder(RenderUtils.blendTwoColors(0xFF141414,0x7702EE67)); add(guiRelocate); + discord = new MButton(); github = new MButton(); + discord.setText("Discord"); github.setText("Github"); + discord.setBorder(RenderUtils.blendTwoColors(0xFF141414,0x7702EE67)); + github.setBorder(RenderUtils.blendTwoColors(0xFF141414,0x7702EE67)); + github.setOnActionPerformed(() -> { + try { + Desktop.getDesktop().browse(new URI("https://github.com/Dungeons-Guide/Skyblock-Dungeons-Guide/")); + } catch (IOException | URISyntaxException e) { + e.printStackTrace(); + } + }); + discord.setOnActionPerformed(() -> { + try { + Desktop.getDesktop().browse(new URI("https://discord.gg/VuxayCWGE8")); + } catch (IOException | URISyntaxException e) { + e.printStackTrace(); + } + }); + add(discord); add(github); + navigationScroll = new MScrollablePanel(1); navigationScroll.setHideScrollBarWhenNotNecessary(false); @@ -114,7 +139,6 @@ public class RootConfigPanel extends MPanelScaledGUI { navigation.setGap(0); navigation.setDrawLine(false); - setCurrentPageAndPushHistory("ROOT"); rePlaceElements(); } @@ -129,21 +153,21 @@ public class RootConfigPanel extends MPanelScaledGUI { } NestedCategory root = new NestedCategory("ROOT"); Set<String> categoryAllowed = new HashSet<>(); - String search = this.search.getText().trim(); + String search = this.search.getText().trim().toLowerCase(); 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()); + categoryAllowed.add("ROOT."+abstractFeature.getCategory()+"."); + } else if (abstractFeature.getName().toLowerCase().contains(search)) { + categoryAllowed.add("ROOT."+abstractFeature.getCategory()+"."); + } else if (abstractFeature.getDescription().toLowerCase().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)) { + if (s.startsWith("ROOT."+category+".")) { test = true; break; } @@ -273,5 +297,7 @@ public class RootConfigPanel extends MPanelScaledGUI { search.setBounds(new Rectangle(5,30,navBound.x + navBound.width - 10,15)); guiRelocate.setBounds(new Rectangle(5,5,100,15)); + github.setBounds(new Rectangle(effectiveDim.width - 80,5,75,15)); + discord.setBounds(new Rectangle(effectiveDim.width - 160,5,75,15)); } } |