diff options
author | syeyoung <cyoung06@naver.com> | 2023-02-27 20:04:21 +0900 |
---|---|---|
committer | syeyoung <cyoung06@naver.com> | 2023-02-27 20:04:33 +0900 |
commit | a2d6eb085cd199f63e97ad1632d4b47e5d94f6aa (patch) | |
tree | 59c840ef54b9adc34313eb477c289d37316ea2fa /mod/src/main | |
parent | 8a891463f2c593d71f02d6f585976cd75d3d98e1 (diff) | |
download | Skyblock-Dungeons-Guide-a2d6eb085cd199f63e97ad1632d4b47e5d94f6aa.tar.gz Skyblock-Dungeons-Guide-a2d6eb085cd199f63e97ad1632d4b47e5d94f6aa.tar.bz2 Skyblock-Dungeons-Guide-a2d6eb085cd199f63e97ad1632d4b47e5d94f6aa.zip |
- Search in config
Signed-off-by: syeyoung <cyoung06@naver.com>
Diffstat (limited to 'mod/src/main')
7 files changed, 219 insertions, 21 deletions
diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MainConfigWidget.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MainConfigWidget.java index 1dc6b5b9..2246c10d 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MainConfigWidget.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/MainConfigWidget.java @@ -23,9 +23,13 @@ import kr.syeyoung.dungeonsguide.mod.config.guiconfig.location2.HUDLocationConfi import kr.syeyoung.dungeonsguide.mod.features.AbstractFeature; import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute; +import kr.syeyoung.dungeonsguide.mod.guiv2.DomElement; import kr.syeyoung.dungeonsguide.mod.guiv2.Widget; import kr.syeyoung.dungeonsguide.mod.guiv2.elements.Navigator; import kr.syeyoung.dungeonsguide.mod.guiv2.elements.Text; +import kr.syeyoung.dungeonsguide.mod.guiv2.renderer.Renderer; +import kr.syeyoung.dungeonsguide.mod.guiv2.renderer.RenderingContext; +import kr.syeyoung.dungeonsguide.mod.guiv2.renderer.SingleChildRenderer; import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedImportOnlyWidget; import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind; import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.On; @@ -38,7 +42,7 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; -public class MainConfigWidget extends AnnotatedImportOnlyWidget { +public class MainConfigWidget extends AnnotatedImportOnlyWidget implements Renderer { @Bind(variableName = "menu") public final BindableAttribute menu = new BindableAttribute<>(WidgetList.class); @Bind(variableName = "relocate") @@ -49,13 +53,21 @@ public class MainConfigWidget extends AnnotatedImportOnlyWidget { @Bind(variableName = "sidebar") public final BindableAttribute<String> sidebar = new BindableAttribute<>(String.class, "hide"); + @Bind(variableName = "search") + public final BindableAttribute<String> search = new BindableAttribute<>(String.class, ""); @Bind(variableName = "mainpage") public final BindableAttribute<Widget> mainPage = new BindableAttribute<>(Widget.class, new MainPageWidget()); + + private long doSearch = Long.MAX_VALUE; public MainConfigWidget() { super(new ResourceLocation("dungeonsguide:gui/config/normalconfig.gui")); menu.setValue(buildMenu()); relocate.setValue(new GUIOpenItem("GUI Config", () -> new HUDLocationConfig(null))); + + search.addOnUpdate((old, neu) -> { + doSearch = System.currentTimeMillis() + 500; + }); } public List<Widget> buildMenu() { @@ -80,4 +92,24 @@ public class MainConfigWidget extends AnnotatedImportOnlyWidget { else this.sidebar.setValue("show"); } + + @Override + public void doRender(int absMouseX, int absMouseY, double relMouseX, double relMouseY, float partialTicks, RenderingContext context, DomElement buildContext) { + if (doSearch < System.currentTimeMillis()) { + doSearch = Long.MAX_VALUE; + + Navigator navigator = Navigator.getNavigator(getDomElement()); + if (search.getValue().isEmpty()) { + if (navigator.getCurrent() instanceof SearchPageWidget) + navigator.goBack(); + } else { + if (navigator.getCurrent() instanceof SearchPageWidget) + navigator.setPageWithoutPush(new SearchPageWidget(search.getValue())); + else + navigator.openPage(new SearchPageWidget(search.getValue())); + } + } + + SingleChildRenderer.INSTANCE.doRender(absMouseX,absMouseY,relMouseX,relMouseY,partialTicks,context,buildContext); + } } diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/SearchPageCategoryWidget.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/SearchPageCategoryWidget.java new file mode 100644 index 00000000..b666b3f6 --- /dev/null +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/SearchPageCategoryWidget.java @@ -0,0 +1,46 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2023 cyoung06 (syeyoung) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.mod.config.guiconfig.configv3; + +import kr.syeyoung.dungeonsguide.mod.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.features.IFeature; +import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute; +import kr.syeyoung.dungeonsguide.mod.guiv2.Widget; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedImportOnlyWidget; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.data.WidgetList; +import net.minecraft.util.ResourceLocation; + +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +public class SearchPageCategoryWidget extends AnnotatedImportOnlyWidget { + @Bind(variableName = "items") + public final BindableAttribute items = new BindableAttribute<>(WidgetList.class); + @Bind(variableName = "category") + public final BindableAttribute<String> category = new BindableAttribute<>(String.class); + public SearchPageCategoryWidget(String category, List<AbstractFeature> featureList) { + super(new ResourceLocation("dungeonsguide:gui/config/search/fromcategory.gui")); + items.setValue(featureList.stream().map(FeatureItem::new).collect(Collectors.toList())); + this.category.setValue(category.replace(".", " > ")); + } + +} diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/SearchPageWidget.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/SearchPageWidget.java new file mode 100644 index 00000000..917c8121 --- /dev/null +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/config/guiconfig/configv3/SearchPageWidget.java @@ -0,0 +1,60 @@ +/* + * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + * Copyright (C) 2023 cyoung06 (syeyoung) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ + +package kr.syeyoung.dungeonsguide.mod.config.guiconfig.configv3; + +import kr.syeyoung.dungeonsguide.mod.features.AbstractFeature; +import kr.syeyoung.dungeonsguide.mod.features.FeatureRegistry; +import kr.syeyoung.dungeonsguide.mod.guiv2.BindableAttribute; +import kr.syeyoung.dungeonsguide.mod.guiv2.Widget; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedImportOnlyWidget; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind; +import kr.syeyoung.dungeonsguide.mod.guiv2.xml.data.WidgetList; +import net.minecraft.util.ResourceLocation; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SearchPageWidget extends AnnotatedImportOnlyWidget { + @Bind(variableName = "items") + public final BindableAttribute items = new BindableAttribute<>(WidgetList.class); + @Bind(variableName = "resultShow") + public final BindableAttribute<String> resultShow = new BindableAttribute<>(String.class, "hide"); + public SearchPageWidget(String word) { + super(new ResourceLocation("dungeonsguide:gui/config/search/searchpage.gui")); + + Map<String, List<AbstractFeature>> categoryMap = new HashMap<>(); + for (AbstractFeature abstractFeature : FeatureRegistry.getFeatureList()) { + if (abstractFeature.getName().toLowerCase().contains(word.toLowerCase()) || abstractFeature.getDescription().toLowerCase().contains(word.toLowerCase())) { + if (!categoryMap.containsKey(abstractFeature.getCategory())) + categoryMap.put(abstractFeature.getCategory(), new ArrayList<>()); + categoryMap.get(abstractFeature.getCategory()).add(abstractFeature); + } + } + + resultShow.setValue(categoryMap.isEmpty() ? "hide" : "show"); + + List<Widget> widgets = new ArrayList<>(); + for (Map.Entry<String, List<AbstractFeature>> stringListEntry : categoryMap.entrySet()) { + widgets.add(new SearchPageCategoryWidget(stringListEntry.getKey(), stringListEntry.getValue())); + } + this.items.setValue(widgets); + } +} diff --git a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/Navigator.java b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/Navigator.java index 5126b7cb..718b1844 100644 --- a/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/Navigator.java +++ b/mod/src/main/java/kr/syeyoung/dungeonsguide/mod/guiv2/elements/Navigator.java @@ -24,6 +24,7 @@ import kr.syeyoung.dungeonsguide.mod.guiv2.Widget; import kr.syeyoung.dungeonsguide.mod.guiv2.xml.AnnotatedExportOnlyWidget; import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Bind; import kr.syeyoung.dungeonsguide.mod.guiv2.xml.annotations.Export; +import lombok.Getter; import java.util.Collections; import java.util.List; @@ -35,7 +36,8 @@ public class Navigator extends AnnotatedExportOnlyWidget { @Export(attributeName = "_") public final BindableAttribute<Widget> child = new BindableAttribute<>(Widget.class); - public Widget current; + @Getter + private Widget current; public Navigator() { child.addOnUpdate((old, a) -> { @@ -44,12 +46,19 @@ public class Navigator extends AnnotatedExportOnlyWidget { } public void openPage(Widget widget) { + if (widget.equals(current)) return; widgets.push(current); getDomElement().removeElement(getDomElement().getChildren().get(0)); getDomElement().addElement(widget.createDomElement(getDomElement())); current = widget; } + public void setPageWithoutPush(Widget widget) { + getDomElement().removeElement(getDomElement().getChildren().get(0)); + getDomElement().addElement(widget.createDomElement(getDomElement())); + current = widget; + } + public void goBack() { getDomElement().removeElement(getDomElement().getChildren().get(0)); Widget page; diff --git a/mod/src/main/resources/assets/dungeonsguide/gui/config/normalconfig.gui b/mod/src/main/resources/assets/dungeonsguide/gui/config/normalconfig.gui index 410b3423..3acb0660 100644 --- a/mod/src/main/resources/assets/dungeonsguide/gui/config/normalconfig.gui +++ b/mod/src/main/resources/assets/dungeonsguide/gui/config/normalconfig.gui @@ -49,25 +49,16 @@ <Text text=" By syeyoung" color="#FFFFFFFF"/> </row> </padding> -<!-- <size width="5"/>--> -<!-- <flexible>--> -<!-- <align hAlign="END">--> -<!-- <ConstrainedBox maxWidth="150">--> -<!-- <size height="19">--> -<!-- <TextField/>--> -<!-- </size>--> -<!-- </ConstrainedBox>--> -<!-- </align>--> -<!-- </flexible>--> -<!-- <aspectRatio width="1" height="1">--> -<!-- <ColorButton on:click="back" hPadding="1"--> -<!-- backgroundColor="#FF1C376E" textColor="#FFFFFFFF"--> -<!-- hoveredBackgroundColor="#FF1C5692" hoveredTextColor="#FFFFFFFF"--> -<!-- disabledBackgroundColor="0" disabledTextColor="0"--> -<!-- pressedBackgroundColor="#FF1D5F9C" pressedTextColor="#FFFFFFFF"--> -<!-- text="?"--> -<!-- />--> -<!-- </aspectRatio>--> + <size width="5"/> + <flexible> + <align hAlign="END"> + <ConstrainedBox maxWidth="150"> + <size height="19"> + <TextField bind:value="search"/> + </size> + </ConstrainedBox> + </align> + </flexible> </row> </bgcolor> </size> diff --git a/mod/src/main/resources/assets/dungeonsguide/gui/config/search/fromcategory.gui b/mod/src/main/resources/assets/dungeonsguide/gui/config/search/fromcategory.gui new file mode 100644 index 00000000..d8bc1817 --- /dev/null +++ b/mod/src/main/resources/assets/dungeonsguide/gui/config/search/fromcategory.gui @@ -0,0 +1,29 @@ + +<!-- + ~ Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + ~ Copyright (C) 2023 cyoung06 (syeyoung) + ~ + ~ This program is free software: you can redistribute it and/or modify + ~ it under the terms of the GNU Affero General Public License as published + ~ by the Free Software Foundation, either version 3 of the License, or + ~ (at your option) any later version. + ~ + ~ This program 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 Affero General Public License for more details. + ~ + ~ You should have received a copy of the GNU Affero General Public License + ~ along with this program. If not, see <https://www.gnu.org/licenses/>. + --> + +<col> + <padding top="5" left="5" right="5"> + <row> + <Text text="From: " size="16" color="#FFFFFFFF"/> + <Text bind:text="category" size="16" color="#FFFFFF00"/> + </row> + </padding> + <col mainAlign="START" crossAlign="STRETCH" bind:_="items"/> + <size width="0" height="10"/> +</col>
\ No newline at end of file diff --git a/mod/src/main/resources/assets/dungeonsguide/gui/config/search/searchpage.gui b/mod/src/main/resources/assets/dungeonsguide/gui/config/search/searchpage.gui new file mode 100644 index 00000000..e21bc8e1 --- /dev/null +++ b/mod/src/main/resources/assets/dungeonsguide/gui/config/search/searchpage.gui @@ -0,0 +1,31 @@ +<!-- + ~ Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod + ~ Copyright (C) 2023 cyoung06 (syeyoung) + ~ + ~ This program is free software: you can redistribute it and/or modify + ~ it under the terms of the GNU Affero General Public License as published + ~ by the Free Software Foundation, either version 3 of the License, or + ~ (at your option) any later version. + ~ + ~ This program 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 Affero General Public License for more details. + ~ + ~ You should have received a copy of the GNU Affero General Public License + ~ along with this program. If not, see <https://www.gnu.org/licenses/>. + --> + +<bgcolor backgroundColor="#FF111111"> + <SelectiveContainer bind:visible="resultShow"> + <ScrollablePanel direction="VERTICAL" slot="show"> + <padding top="5" left="5" bottom="5" right="5"> + <col crossAlign="STRETCH" mainAlign="START" bind:_="items"> + </col> + </padding> + </ScrollablePanel> + <align vAlign="CENTER" hAlign="CENTER" slot="hide"> + <Text text="Empty Result" color="#FFFFFFFF" size="16"/> + </align> + </SelectiveContainer> +</bgcolor>
\ No newline at end of file |