Skip to content

Commit bef9a60

Browse files
committed
Searchbar and tabs, closes #15, closes #16
1 parent 952faaa commit bef9a60

7 files changed

Lines changed: 908 additions & 25 deletions

File tree

common/src/main/java/org/infernalstudios/questlog/client/gui/QuestlogGuiSet.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public class QuestlogGuiSet {
1414

1515
public final ResourceLocation backgroundLoc;
1616
public final ResourceLocation peripheralLoc;
17+
public final ResourceLocation searchTabButtonsLoc;
18+
1719
public final Texture detailBackground;
1820
public final Texture button;
1921
public final Texture buttonHovered;
@@ -25,9 +27,24 @@ public class QuestlogGuiSet {
2527
public final Texture bigHR;
2628
public final ScrollbarTexture scrollbar;
2729

30+
public final Texture searchTabMinimized;
31+
public final Texture searchTabMinimizedHovered;
32+
public final Texture searchTabExpanded;
33+
public final Texture searchTabExpandedHovered;
34+
public final Texture arrowLeft;
35+
public final Texture arrowLeftHovered;
36+
public final Texture arrowRight;
37+
public final Texture arrowRightHovered;
38+
public final Texture tabSecondary;
39+
public final Texture tabSecondaryActive;
40+
public final Texture tabMain;
41+
public final Texture tabMainActive;
42+
2843
public QuestlogGuiSet(ResourceLocation backgroundLoc, ResourceLocation peripheralLoc) {
2944
this.backgroundLoc = backgroundLoc;
3045
this.peripheralLoc = peripheralLoc;
46+
this.searchTabButtonsLoc = ResourceLocation.fromNamespaceAndPath(Questlog.MODID, "textures/gui/questlog_search_tab_buttons.png");
47+
3148
this.detailBackground = new Texture(backgroundLoc, 1024, 512, 0, 0, 1024, 512);
3249
this.button = new Texture(peripheralLoc, 74, 38, 36, 55, 256, 256);
3350
this.buttonHovered = new Texture(peripheralLoc, 74, 38, 112, 55, 256, 256);
@@ -43,5 +60,20 @@ public QuestlogGuiSet(ResourceLocation backgroundLoc, ResourceLocation periphera
4360
new Texture(peripheralLoc, 16, 1, 62, 19, 256, 256),
4461
new Texture(peripheralLoc, 16, 1, 62, 21, 256, 256)
4562
);
63+
64+
this.searchTabMinimized = new Texture(this.searchTabButtonsLoc, 28, 18, 17, 21, 256, 256);
65+
this.searchTabMinimizedHovered = new Texture(this.searchTabButtonsLoc, 28, 18, 77, 21, 256, 256);
66+
this.searchTabExpanded = new Texture(this.searchTabButtonsLoc, 193, 18, 32, 78, 256, 256);
67+
this.searchTabExpandedHovered = new Texture(this.searchTabButtonsLoc, 193, 18, 32, 135, 256, 256);
68+
69+
this.arrowLeft = new Texture(this.searchTabButtonsLoc, 8, 13, 11, 180, 256, 256);
70+
this.arrowLeftHovered = new Texture(this.searchTabButtonsLoc, 8, 13, 41, 180, 256, 256);
71+
this.arrowRight = new Texture(this.searchTabButtonsLoc, 8, 13, 12, 209, 256, 256);
72+
this.arrowRightHovered = new Texture(this.searchTabButtonsLoc, 8, 13, 42, 209, 256, 256);
73+
74+
this.tabSecondary = new Texture(this.searchTabButtonsLoc, 28, 23, 75, 174, 256, 256);
75+
this.tabSecondaryActive = new Texture(this.searchTabButtonsLoc, 28, 29, 75, 208, 256, 256);
76+
this.tabMain = new Texture(this.searchTabButtonsLoc, 28, 23, 131, 174, 256, 256);
77+
this.tabMainActive = new Texture(this.searchTabButtonsLoc, 28, 29, 131, 208, 256, 256);
4678
}
47-
}
79+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package org.infernalstudios.questlog.client.gui.components;
2+
3+
import net.minecraft.client.gui.GuiGraphics;
4+
import net.minecraft.client.gui.components.AbstractButton;
5+
import net.minecraft.client.gui.narration.NarrationElementOutput;
6+
import net.minecraft.network.chat.Component;
7+
import org.infernalstudios.questlog.client.gui.QuestlogGuiSet;
8+
import org.jetbrains.annotations.NotNull;
9+
10+
public class ChapterArrowButton extends AbstractButton {
11+
private final QuestlogGuiSet guiSet;
12+
private final boolean isLeft;
13+
private final Runnable onPress;
14+
15+
public ChapterArrowButton(int x, int y, boolean isLeft, Runnable onPress, QuestlogGuiSet guiSet) {
16+
super(x, y, 8, 13, Component.empty());
17+
this.isLeft = isLeft;
18+
this.onPress = onPress;
19+
this.guiSet = guiSet;
20+
}
21+
22+
@Override
23+
public void renderWidget(@NotNull GuiGraphics ps, int mouseX, int mouseY, float partialTicks) {
24+
boolean hovered = this.isMouseOver(mouseX, mouseY);
25+
if (this.isLeft) {
26+
(hovered ? this.guiSet.arrowLeftHovered : this.guiSet.arrowLeft).blit(ps, this.getX(), this.getY());
27+
} else {
28+
(hovered ? this.guiSet.arrowRightHovered : this.guiSet.arrowRight).blit(ps, this.getX(), this.getY());
29+
}
30+
}
31+
32+
@Override
33+
public void onPress() {
34+
this.onPress.run();
35+
}
36+
37+
@Override
38+
protected void updateWidgetNarration(@NotNull NarrationElementOutput output) {
39+
this.defaultButtonNarrationText(output);
40+
}
41+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package org.infernalstudios.questlog.client.gui.components;
2+
3+
import net.minecraft.client.gui.GuiGraphics;
4+
import net.minecraft.client.gui.components.AbstractButton;
5+
import net.minecraft.client.gui.narration.NarrationElementOutput;
6+
import net.minecraft.network.chat.Component;
7+
import org.infernalstudios.questlog.client.gui.QuestlogGuiSet;
8+
import org.infernalstudios.questlog.util.texture.Blittable;
9+
import org.jetbrains.annotations.NotNull;
10+
import org.jetbrains.annotations.Nullable;
11+
12+
public class ChapterTabButton extends AbstractButton {
13+
private final QuestlogGuiSet guiSet;
14+
@Nullable
15+
private final Blittable icon;
16+
private final boolean isSelected;
17+
private final boolean isPrimary;
18+
private final Runnable onPress;
19+
20+
public ChapterTabButton(int x, int y, @Nullable Blittable icon, boolean isSelected, boolean isPrimary, Runnable onPress, QuestlogGuiSet guiSet) {
21+
super(x, y, 28, isSelected ? 29 : 23, Component.empty());
22+
this.icon = icon;
23+
this.isSelected = isSelected;
24+
this.isPrimary = isPrimary;
25+
this.onPress = onPress;
26+
this.guiSet = guiSet;
27+
}
28+
29+
@Override
30+
public void renderWidget(@NotNull GuiGraphics ps, int mouseX, int mouseY, float partialTicks) {
31+
if (this.isPrimary) {
32+
if (this.isSelected) {
33+
this.guiSet.tabMainActive.blit(ps, this.getX(), this.getY());
34+
} else {
35+
this.guiSet.tabMain.blit(ps, this.getX(), this.getY());
36+
}
37+
} else {
38+
if (this.isSelected) {
39+
this.guiSet.tabSecondaryActive.blit(ps, this.getX(), this.getY());
40+
} else {
41+
this.guiSet.tabSecondary.blit(ps, this.getX(), this.getY());
42+
}
43+
}
44+
if (this.icon != null) {
45+
this.icon.blit(ps, this.getX() + 6, this.getY() + 2);
46+
}
47+
}
48+
49+
@Override
50+
public void onPress() {
51+
this.onPress.run();
52+
}
53+
54+
@Override
55+
protected void updateWidgetNarration(@NotNull NarrationElementOutput output) {
56+
this.defaultButtonNarrationText(output);
57+
}
58+
}

0 commit comments

Comments
 (0)