Skip to content

Commit 02c4e45

Browse files
authored
Merge pull request #18 from Tangos-Mods/v4
Implementing ScamScreener to Wizard and Fixed persistence of background image
2 parents 25e0983 + 9a4ded4 commit 02c4e45

14 files changed

Lines changed: 782 additions & 25 deletions

File tree

build.gradle.kts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ dependencies {
3333
modImplementation("com.daqem.uilib:uilib-fabric:${property("deps.uilib_version")}")
3434

3535
modImplementation("maven.modrinth:modmenu:${property("deps.modmenu_version")}")
36+
modCompileOnly("maven.modrinth:scamscreener:${property("deps.scamscreener_version")}")
3637

3738
modImplementation("net.azureaaron:hm-api:${property("deps.hm_api_version")}")
3839
include("net.azureaaron:hm-api:${property("deps.hm_api_version")}")
@@ -42,6 +43,8 @@ dependencies {
4243

4344
modRuntimeOnly("me.djtheredstoner:DevAuth-fabric:1.2.2")
4445
modRuntimeOnly("maven.modrinth:modmenu:${property("deps.modmenu_version")}")
46+
47+
modRuntimeOnly("maven.modrinth:scamscreener:${property("deps.scamscreener_version")}")
4548
}
4649

4750
loom {
@@ -141,6 +144,9 @@ publishMods {
141144
optional {
142145
slug = "mOgUt4GM" // ModMenu
143146
}
147+
optional {
148+
slug = "scamscreener"
149+
}
144150
}
145151

146152
curseforge {
@@ -157,4 +163,4 @@ publishMods {
157163
slug = "modmenu"
158164
}
159165
}
160-
}
166+
}

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ deps.moulconfig_version=[VERSIONED]
1919
deps.midnightlib_version=[VERSIONED]
2020
deps.hm_api_version=[VERSIONED]
2121
deps.modmenu_version=[VERSIONED]
22+
deps.scamscreener_version=[VERSIONED]
2223

2324
deps.sodium_version=[VERSIONED]
2425
deps.iris_version=[VERSIONED]
2526

2627
publish.modrinth=V3FnL7QV
27-
publish.curseforge=1375477
28+
publish.curseforge=1375477

src/main/java/com/github/kd_gaming1/packcore/gui/component/MarkdownComponent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public MarkdownComponent(int x, int y, int maxWidth, String markdown) {
8383

8484
public MarkdownComponent(int x, int y, int maxWidth, String markdown, int defaultColor) {
8585
super(x, y, maxWidth, 0);
86-
this.markdown = markdown;
86+
this.markdown = markdown != null ? markdown : "";
8787
this.maxWidth = maxWidth;
8888
this.defaultColor = defaultColor;
8989
rebuild();
@@ -597,4 +597,4 @@ private int getHeadingColor(int level) {
597597
default -> defaultColor;
598598
};
599599
}
600-
}
600+
}

src/main/java/com/github/kd_gaming1/packcore/gui/screen/SBETitleScreen.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,12 @@ protected void init() {
139139
int overlayX = (this.width - overlayW) / 2;
140140
int overlayY = (this.height - overlayH) / 2 + 25;
141141

142-
String changelogMarkdown = updateStatus.changelog();
142+
String changelogVersion = resolveChangelogVersion(updateStatus);
143+
String changelogMarkdown = resolveChangelogMarkdown(updateStatus);
143144

144145
changelogOverlay = new OverlayComponent(
145146
overlayX, overlayY, overlayW, overlayH,
146-
Component.translatable("gui.packcore.overlay.changelog.title", updateStatus.latestVersion()),
147+
Component.translatable("gui.packcore.overlay.changelog.title", changelogVersion),
147148
changelogMarkdown
148149
);
149150
changelogOverlay.setOnClose(() -> setMenuButtonsVisible(true));
@@ -358,6 +359,26 @@ private static Component buildVersionText(UpdateStatus status) {
358359
return Component.literal("v" + installed);
359360
}
360361

362+
private static String resolveChangelogVersion(UpdateStatus status) {
363+
if (status.latestVersion() != null && !status.latestVersion().isBlank()) {
364+
return status.latestVersion();
365+
}
366+
if (status.installedVersion() != null && !status.installedVersion().isBlank()) {
367+
return status.installedVersion();
368+
}
369+
return ModpackMetadata.getInstance().getModpackVersion();
370+
}
371+
372+
private static String resolveChangelogMarkdown(UpdateStatus status) {
373+
if (status.changelog() != null && !status.changelog().isBlank()) {
374+
return status.changelog();
375+
}
376+
377+
return Component.translatable("gui.packcore.overlay.changelog.empty").getString()
378+
+ "\n\n"
379+
+ Component.translatable("gui.packcore.overlay.changelog.empty.hint").getString();
380+
}
381+
361382
private void setMenuButtonsVisible(boolean visible) {
362383
joinHypixelButton.visible = visible;
363384
joinHypixelButton.active = visible;
@@ -399,4 +420,4 @@ public boolean keyPressed(KeyEvent keyEvent) {
399420
}
400421
return super.keyPressed(keyEvent);
401422
}
402-
}
423+
}

src/main/java/com/github/kd_gaming1/packcore/gui/screen/WelcomeWizardScreen.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.github.kd_gaming1.packcore.metadata.ModpackMetadata;
99
import eu.midnightdust.lib.config.MidnightConfig;
1010
import com.github.kd_gaming1.packcore.gui.wizard.page.ConfirmApplyPage;
11+
import net.fabricmc.loader.api.FabricLoader;
1112
import net.minecraft.client.Minecraft;
1213
import net.minecraft.client.gui.screens.Screen;
1314
import net.minecraft.network.chat.Component;
@@ -63,6 +64,9 @@ private void registerPages() {
6364
navigator.addPage(new TabDesignPage(wizardState, navigator, contentWidth, contentHeight));
6465
navigator.addPage(new ItemBackgroundPage(wizardState, navigator, contentWidth, contentHeight));
6566
navigator.addPage(new StorageDesignPage(wizardState, navigator, contentWidth, contentHeight));
67+
if (FabricLoader.getInstance().isModLoaded("scamscreener")) {
68+
navigator.addPage(new ScamScreenerPage(wizardState, navigator, contentWidth, contentHeight));
69+
}
6670
navigator.addPage(new ResourcePackPage(wizardState, navigator, contentWidth, contentHeight));
6771

6872
confirmApplyPage = new ConfirmApplyPage(wizardState, navigator, contentWidth, contentHeight);
@@ -109,7 +113,7 @@ private void wireEvents() {
109113
// Finish — settings have been applied; mark complete and close
110114
buttonBar.setOnFinish(() -> {
111115
markWizardComplete();
112-
Minecraft.getInstance().setScreen(lastScreen);
116+
Minecraft.getInstance().setScreen(resolvePostWizardScreen());
113117
});
114118

115119
// Skip on the last page — close without applying; still marks complete
@@ -130,6 +134,14 @@ private void markWizardComplete() {
130134
MidnightConfig.write(MOD_ID);
131135
}
132136

137+
private Screen resolvePostWizardScreen() {
138+
return switch (PackCoreConfig.menuStyle) {
139+
case MODERN -> new SBETitleScreen();
140+
case MODERN_MINIMAL -> new SBETitleScreen(false);
141+
case MINIMAL -> new PackCoreTitleScreen();
142+
};
143+
}
144+
133145
@Override
134146
public boolean shouldCloseOnEsc() {
135147
if (navigator.hasPrevious()) {
@@ -143,4 +155,4 @@ public boolean shouldCloseOnEsc() {
143155
public void onClose() {
144156
Minecraft.getInstance().setScreen(lastScreen);
145157
}
146-
}
158+
}

src/main/java/com/github/kd_gaming1/packcore/gui/wizard/WizardButtonBar.java

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.daqem.uilib.gui.widget.ButtonWidget;
55
import com.daqem.uilib.gui.widget.CustomButtonWidget;
66
import com.github.kd_gaming1.packcore.gui.util.GuiHelper;
7+
import com.github.kd_gaming1.packcore.gui.wizard.page.ScamScreenerPage;
78
import com.github.kd_gaming1.packcore.metadata.ModpackMetadata;
89
import net.minecraft.client.gui.components.Tooltip;
910
import net.minecraft.client.gui.components.WidgetSprites;
@@ -32,6 +33,11 @@ public class WizardButtonBar extends EmptyComponent {
3233
Identifier.fromNamespaceAndPath(MOD_ID, "menu/buttons/disabled_continue_gray_button"),
3334
Identifier.fromNamespaceAndPath(MOD_ID, "menu/buttons/hover_continue_gray_button")
3435
);
36+
private static final WidgetSprites SCAM_SCREENER_CONTINUE_BUTTON = new WidgetSprites(
37+
Identifier.fromNamespaceAndPath(MOD_ID, "menu/buttons/continue_gray_button"),
38+
Identifier.fromNamespaceAndPath(MOD_ID, "menu/buttons/continue_gray_button"),
39+
Identifier.fromNamespaceAndPath(MOD_ID, "menu/buttons/hover_continue_gray_button")
40+
);
3541

3642
private static final WidgetSprites PREVIOUS_BUTTON = new WidgetSprites(
3743
Identifier.fromNamespaceAndPath(MOD_ID, "menu/buttons/previous_gray_button"),
@@ -64,6 +70,7 @@ public class WizardButtonBar extends EmptyComponent {
6470
private final ButtonWidget backButton;
6571
private final ButtonWidget skipButton;
6672
private final ButtonWidget continueButton;
73+
private final ButtonWidget scamScreenerContinueButton;
6774
private final ButtonWidget finishButton;
6875

6976
public WizardButtonBar(WizardNavigator navigator, int width, int height) {
@@ -99,6 +106,12 @@ public WizardButtonBar(WizardNavigator navigator, int width, int height) {
99106
CONTINUE_BUTTON,
100107
btn -> navigator.nextPage()
101108
);
109+
scamScreenerContinueButton = new CustomButtonWidget(
110+
width - BTN_WIDTH - BTN_GAP, btnY, BTN_WIDTH, BTN_HEIGHT,
111+
Component.translatable("gui.packcore.wizard.button.continue"),
112+
SCAM_SCREENER_CONTINUE_BUTTON,
113+
btn -> navigator.nextPage()
114+
);
102115

103116
backButton = new CustomButtonWidget(
104117
width - BTN_WIDTH * 2 - BTN_GAP * 2, btnY, BTN_WIDTH, BTN_HEIGHT,
@@ -132,6 +145,7 @@ public WizardButtonBar(WizardNavigator navigator, int width, int height) {
132145
this.addWidget(skipButton);
133146
this.addWidget(backButton);
134147
this.addWidget(continueButton);
148+
this.addWidget(scamScreenerContinueButton);
135149
this.addWidget(finishButton);
136150

137151
refresh();
@@ -141,12 +155,16 @@ public WizardButtonBar(WizardNavigator navigator, int width, int height) {
141155
public void refresh() {
142156
boolean hasBack = navigator.hasPrevious();
143157
boolean isLastPage = navigator.isOnLastPage();
158+
boolean isScamScreenerPage = navigator.getCurrentPage() instanceof ScamScreenerPage;
144159

145160
backButton.visible = hasBack;
146161
backButton.active = hasBack;
147162

148-
continueButton.visible = !isLastPage;
149-
continueButton.active = !isLastPage;
163+
continueButton.visible = !isLastPage && !isScamScreenerPage;
164+
continueButton.active = !isLastPage && !isScamScreenerPage;
165+
166+
scamScreenerContinueButton.visible = !isLastPage && isScamScreenerPage;
167+
scamScreenerContinueButton.active = !isLastPage && isScamScreenerPage;
150168

151169
skipButton.visible = isLastPage;
152170
skipButton.active = isLastPage;
@@ -192,4 +210,4 @@ private static void openUrlSafely(String url) {
192210
LOGGER.warn("Couldn't open uri '{}' ", url, e);
193211
}
194212
}
195-
}
213+
}

src/main/java/com/github/kd_gaming1/packcore/gui/wizard/WizardState.java

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
package com.github.kd_gaming1.packcore.gui.wizard;
22

3-
import java.util.*;
3+
import java.util.Collections;
4+
import java.util.HashMap;
5+
import java.util.HashSet;
6+
import java.util.LinkedHashSet;
7+
import java.util.Map;
8+
import java.util.Set;
49

510
public class WizardState {
611

712
private final Map<String, String> selections = new HashMap<>();
13+
private final Map<String, Set<String>> multiSelections = new HashMap<>();
814
private final Set<String> selectedResourcePacks = new HashSet<>();
915

1016
// Selections
@@ -16,6 +22,25 @@ public String getSelection(String key) {
1622
return selections.get(key);
1723
}
1824

25+
// Generic multi-select state
26+
public Set<String> getMultiSelection(String key) {
27+
return Collections.unmodifiableSet(multiSelections.getOrDefault(key, Set.of()));
28+
}
29+
30+
public void addMultiSelection(String key, String value) {
31+
multiSelections.computeIfAbsent(key, ignored -> new LinkedHashSet<>()).add(value);
32+
}
33+
34+
public void removeMultiSelection(String key, String value) {
35+
Set<String> values = multiSelections.get(key);
36+
if (values == null) return;
37+
38+
values.remove(value);
39+
if (values.isEmpty()) {
40+
multiSelections.remove(key);
41+
}
42+
}
43+
1944
// Resource Packs
2045
public Set<String> getSelectedResourcePacks() {
2146
return Collections.unmodifiableSet(selectedResourcePacks);
@@ -33,7 +58,8 @@ public void removeResourcePack(String packId) {
3358
public String toString() {
3459
return "WizardState{" +
3560
"selections=" + selections +
61+
", multiSelections=" + multiSelections +
3662
", resourcePacks=" + selectedResourcePacks +
3763
'}';
3864
}
39-
}
65+
}

0 commit comments

Comments
 (0)