Skip to content

Commit 39e151e

Browse files
authored
Merge pull request RobertSkalko#192 from TUsama/1.20-Forge
add search keywords
2 parents d90f8eb + e3d6386 commit 39e151e

File tree

8 files changed

+216
-168
lines changed

8 files changed

+216
-168
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ eclipse
3737
run
3838
ignore/
3939
remappedSrc
40-
remappedSrc/
40+
remappedSrc/
41+
/libs

src/main/java/com/robertx22/mine_and_slash/gui/screens/skill_tree/SkillTreeRenderType.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ public SkillTreeRenderType(String pName, Runnable pSetupState, Runnable pClearSt
1717
super(pName, pSetupState, pClearState);
1818
}
1919

20-
public static RenderType CONNECTION = getSkillTreeRenderType("connection", SlashRef.id("textures/gui/skill_tree/skill_connection.png"));
21-
22-
private static final TransparencyStateShard blend = new TransparencyStateShard("boring_blend", RenderSystem::enableBlend, RenderSystem::disableBlend);
23-
2420

2521

2622
public static RenderType getSkillTreeRenderType(String name, ResourceLocation texture) {

src/main/java/com/robertx22/mine_and_slash/gui/screens/skill_tree/SkillTreeScreen.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.robertx22.mine_and_slash.gui.screens.skill_tree.buttons.PerkConnectionRender;
1919
import com.robertx22.mine_and_slash.gui.screens.skill_tree.buttons.PerkPointPair;
2020
import com.robertx22.mine_and_slash.gui.screens.skill_tree.buttons.PerkScreenContext;
21+
import com.robertx22.mine_and_slash.gui.screens.skill_tree.component.TipsWidget;
2122
import com.robertx22.mine_and_slash.mmorpg.MMORPG;
2223
import com.robertx22.mine_and_slash.mmorpg.SlashRef;
2324
import com.robertx22.mine_and_slash.saveclasses.PointData;
@@ -49,6 +50,7 @@ public abstract class SkillTreeScreen extends BaseScreen implements INamedScreen
4950

5051
static ResourceLocation CON = SlashRef.id("textures/gui/skill_tree/skill_connection.png");
5152
public VertexContainer vertexContainer = new VertexContainer();
53+
private TipsWidget tips;
5254

5355

5456
private void renderConnection(GuiGraphics graphics, PerkConnectionRender renderer) {
@@ -237,7 +239,8 @@ protected void init() {
237239
this.school = ExileDB.TalentTrees().getFilterWrapped(x -> x.getSchool_type().equals(this.schoolType)).list.get(0);
238240

239241
refreshButtons();
240-
242+
this.tips = new TipsWidget(0, 0, 10, 10, Gui.TALENT_SCREEN_SEARCH_TIPS.locName(Gui.TALENT_SCREEN_SEARCH_KEYWORD_ALL.locName().withStyle(ChatFormatting.GOLD), Gui.TALENT_SCREEN_SEARCH_KEYWORD_GAME_CHANGER.locName().withStyle(ChatFormatting.GOLD)));
243+
addWidget(tips);
241244

242245
goToCenter();
243246
} catch (Exception e) {
@@ -439,6 +442,7 @@ public void render(GuiGraphics gui, int x, int y, float ticks) {
439442
renderBackgroundDirt(gui, this, 0);
440443
zoom = Mth.lerp(ClientConfigs.getConfig().SKILL_TREE_ZOOM_SPEED.get().floatValue(), zoom, targetZoom);
441444
renderPanels(gui);
445+
tips.render(gui, x, y, ticks);
442446
gui.pose().scale(zoom, zoom, zoom);
443447

444448
try {
@@ -548,6 +552,9 @@ private void renderPanels(GuiGraphics gui) {
548552
SkillTreeScreen.SEARCH.setY(yx);
549553
SkillTreeScreen.SEARCH.render(gui, 0, 0, 0);
550554

555+
tips.setX(tx + SkillTreeScreen.SEARCH.getWidth() - tips.getWidth() - 2);
556+
tips.setY(yx + (SkillTreeScreen.SEARCH.getHeight() - tips.getHeight()) / 2);
557+
551558

552559
if (MMORPG.RUN_DEV_TOOLS) {
553560
MutableComponent debug = Component.literal("Widgets: " + this.children().size() + " - " + msstring);

src/main/java/com/robertx22/mine_and_slash/gui/screens/skill_tree/buttons/PerkButton.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import com.robertx22.mine_and_slash.saveclasses.gearitem.gear_bases.ModRange;
1717
import com.robertx22.mine_and_slash.saveclasses.gearitem.gear_bases.StatRangeInfo;
1818
import com.robertx22.mine_and_slash.uncommon.MathHelper;
19+
import com.robertx22.mine_and_slash.uncommon.localization.Gui;
1920
import com.robertx22.mine_and_slash.vanilla_mc.packets.perks.PerkChangePacket;
2021
import com.robertx22.library_of_exile.main.Packets;
2122
import com.robertx22.library_of_exile.utils.GuiUtils;
@@ -188,21 +189,24 @@ public void renderWidget(GuiGraphics gui, int mouseX, int mouseY, float pPartial
188189
var search = SkillTreeScreen.SEARCH.getValue();
189190

190191

191-
float opacity;
192+
float opacity = 0.2f;
192193

193194
if (!search.isEmpty()) {
194-
if (search.equals("all")) {
195-
if (status != PerkStatus.CONNECTED) {
196-
opacity = 0.2F;
197-
} else {
195+
if (search.equals(Gui.TALENT_SCREEN_SEARCH_KEYWORD_ALL.locName().getString())) {
196+
if (status == PerkStatus.CONNECTED) {
198197
opacity = 1;
199198
}
200-
} else {
201-
boolean containsSearchStat = perk.stats.stream()
199+
} else if (perk.stats.stream()
200+
.anyMatch(item -> item.getStat().locName().getString().toLowerCase().contains(search.toLowerCase())) || perk.locName().getString().toLowerCase().contains(search.toLowerCase())){
201+
/*boolean containsSearchStat = perk.stats.stream()
202202
.anyMatch(item -> item.getStat().locName().getString().toLowerCase().contains(search.toLowerCase()));
203203
204-
boolean containsName = perk.locName().getString().toLowerCase().contains(search.toLowerCase());
205-
opacity = containsSearchStat || containsName ? 1F : 0.2f;
204+
boolean containsName = perk.locName().getString().toLowerCase().contains(search.toLowerCase());*/
205+
opacity = 1F;
206+
} else if (search.equals(Gui.TALENT_SCREEN_SEARCH_KEYWORD_GAME_CHANGER.locName().getString())) {
207+
if (perk.getType().equals(Perk.PerkType.MAJOR)){
208+
opacity = 1F;
209+
}
206210
}
207211
} else {
208212
opacity = status.getOpacity();
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.robertx22.mine_and_slash.gui.screens.skill_tree.component;
2+
3+
import com.mojang.blaze3d.vertex.PoseStack;
4+
import com.robertx22.mine_and_slash.mmorpg.SlashRef;
5+
import net.minecraft.client.gui.GuiGraphics;
6+
import net.minecraft.client.gui.components.AbstractWidget;
7+
import net.minecraft.client.gui.components.Tooltip;
8+
import net.minecraft.client.gui.narration.NarrationElementOutput;
9+
import net.minecraft.network.chat.Component;
10+
import net.minecraft.resources.ResourceLocation;
11+
12+
public class TipsWidget extends AbstractWidget {
13+
static ResourceLocation TIPS = SlashRef.id("textures/gui/skill_tree/tips.png");
14+
15+
public TipsWidget(int pX, int pY, int pWidth, int pHeight, Component pMessage) {
16+
super(pX, pY, pWidth, pHeight, pMessage);
17+
setTooltip(Tooltip.create(pMessage));
18+
}
19+
20+
@Override
21+
protected void renderWidget(GuiGraphics guiGraphics, int i, int i1, float v) {
22+
PoseStack pose = guiGraphics.pose();
23+
pose.pushPose();
24+
pose.translate(0, 0, 10);
25+
guiGraphics.blit(TIPS, getX(), getY(), getWidth(), getHeight(), 0, 0, 32, 32, 32, 32);
26+
pose.popPose();
27+
}
28+
29+
@Override
30+
protected void updateWidgetNarration(NarrationElementOutput narrationElementOutput) {
31+
32+
}
33+
}

src/main/java/com/robertx22/mine_and_slash/uncommon/localization/Gui.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import java.util.Locale;
88

99
public enum Gui implements IAutoLocName {
10+
TALENT_SCREEN_SEARCH_KEYWORD_GAME_CHANGER("game changer"),
11+
TALENT_SCREEN_SEARCH_KEYWORD_ALL("all"),
12+
TALENT_SCREEN_SEARCH_TIPS("Search Keywords: \n\n%1$s: show all allocated talents\n\n%2$s: show all game changer talents"),
1013
STATION_LOCK_RECIPE("Lock Recipe"),
1114
STATION_UNLOCK_RECIPE("Unlock Recipe"),
1215
STATION_START_CRAFTING("Start Crafting"),

0 commit comments

Comments
 (0)