From b9377f36387b1e0e8e8bcdb695ed4eb65536e03b Mon Sep 17 00:00:00 2001 From: RappyTV Date: Thu, 21 Nov 2024 21:29:32 +0100 Subject: [PATCH 1/4] Rename and move sign search activity --- .../SignSearchSettingsActivity.java} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename core/src/main/java/com/rappytv/signsearch/gui/{navigation/SignSearchNavigationActivity.java => settings/SignSearchSettingsActivity.java} (96%) diff --git a/core/src/main/java/com/rappytv/signsearch/gui/navigation/SignSearchNavigationActivity.java b/core/src/main/java/com/rappytv/signsearch/gui/settings/SignSearchSettingsActivity.java similarity index 96% rename from core/src/main/java/com/rappytv/signsearch/gui/navigation/SignSearchNavigationActivity.java rename to core/src/main/java/com/rappytv/signsearch/gui/settings/SignSearchSettingsActivity.java index 9e5dc47..a057bb9 100644 --- a/core/src/main/java/com/rappytv/signsearch/gui/navigation/SignSearchNavigationActivity.java +++ b/core/src/main/java/com/rappytv/signsearch/gui/settings/SignSearchSettingsActivity.java @@ -1,4 +1,4 @@ -package com.rappytv.signsearch.gui.navigation; +package com.rappytv.signsearch.gui.settings; import com.rappytv.signsearch.utils.SignSearchSettings; import net.labymod.api.client.gui.screen.Parent; @@ -17,11 +17,11 @@ @Link("sign-search.lss") @AutoActivity -public class SignSearchNavigationActivity extends SimpleActivity { +public class SignSearchSettingsActivity extends SimpleActivity { private final SignSearchSettings settings; - public SignSearchNavigationActivity(SignSearchSettings settings) { + public SignSearchSettingsActivity(SignSearchSettings settings) { this.settings = settings; } From e5ef174e17176370601136676861caae858bc630 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Thu, 21 Nov 2024 21:30:56 +0100 Subject: [PATCH 2/4] Use pause menu button instead of navigation tab --- .../SignSearchNavigationElement.java | 33 ------------------- .../listeners/PauseMenuListener.java | 32 ++++++++++++++++++ 2 files changed, 32 insertions(+), 33 deletions(-) delete mode 100644 core/src/main/java/com/rappytv/signsearch/gui/navigation/SignSearchNavigationElement.java create mode 100644 core/src/main/java/com/rappytv/signsearch/listeners/PauseMenuListener.java diff --git a/core/src/main/java/com/rappytv/signsearch/gui/navigation/SignSearchNavigationElement.java b/core/src/main/java/com/rappytv/signsearch/gui/navigation/SignSearchNavigationElement.java deleted file mode 100644 index 18a71ec..0000000 --- a/core/src/main/java/com/rappytv/signsearch/gui/navigation/SignSearchNavigationElement.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.rappytv.signsearch.gui.navigation; - -import net.labymod.api.client.component.Component; -import net.labymod.api.client.gui.icon.Icon; -import net.labymod.api.client.gui.navigation.elements.ScreenNavigationElement; -import net.labymod.api.client.resources.ResourceLocation; - -public class SignSearchNavigationElement extends ScreenNavigationElement { - - private final Icon icon = Icon.texture(ResourceLocation.create( - "signsearch", - "textures/sign_search.png" - )); - - public SignSearchNavigationElement(SignSearchNavigationActivity activity) { - super(activity); - } - - @Override - public Component getDisplayName() { - return Component.translatable("signsearch.ui.title"); - } - - @Override - public Icon getIcon() { - return icon; - } - - @Override - public String getWidgetId() { - return "signsearch"; - } -} diff --git a/core/src/main/java/com/rappytv/signsearch/listeners/PauseMenuListener.java b/core/src/main/java/com/rappytv/signsearch/listeners/PauseMenuListener.java new file mode 100644 index 0000000..8ed6899 --- /dev/null +++ b/core/src/main/java/com/rappytv/signsearch/listeners/PauseMenuListener.java @@ -0,0 +1,32 @@ +package com.rappytv.signsearch.listeners; + +import com.rappytv.signsearch.gui.settings.SignSearchSettingsActivity; +import net.labymod.api.Laby; +import net.labymod.api.client.component.Component; +import net.labymod.api.client.gui.icon.Icon; +import net.labymod.api.client.resources.ResourceLocation; +import net.labymod.api.event.Subscribe; +import net.labymod.api.event.client.gui.screen.IngameMenuInitializeEvent; + +public class PauseMenuListener { + + private final Icon icon = Icon.texture(ResourceLocation.create( + "signsearch", + "textures/sign_search.png" + )); + private final SignSearchSettingsActivity activity; + + public PauseMenuListener(SignSearchSettingsActivity activity) { + this.activity = activity; + } + + @Subscribe + public void onMenuOpen(IngameMenuInitializeEvent event) { + event.addLeftButton( + Component.translatable("signsearch.ui.title"), + icon, + () -> Laby.labyAPI().minecraft().minecraftWindow().displayScreen(activity) + ); + } + +} From b8260a22b94c5a3074511020e71e08b26c5c4e90 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Thu, 21 Nov 2024 21:31:50 +0100 Subject: [PATCH 3/4] Register pause menu event and remove nav tab registration --- .../main/java/com/rappytv/signsearch/SignSearchAddon.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/com/rappytv/signsearch/SignSearchAddon.java b/core/src/main/java/com/rappytv/signsearch/SignSearchAddon.java index afa1e1b..b098c96 100644 --- a/core/src/main/java/com/rappytv/signsearch/SignSearchAddon.java +++ b/core/src/main/java/com/rappytv/signsearch/SignSearchAddon.java @@ -1,7 +1,7 @@ package com.rappytv.signsearch; -import com.rappytv.signsearch.gui.navigation.SignSearchNavigationActivity; -import com.rappytv.signsearch.gui.navigation.SignSearchNavigationElement; +import com.rappytv.signsearch.gui.settings.SignSearchSettingsActivity; +import com.rappytv.signsearch.listeners.PauseMenuListener; import com.rappytv.signsearch.utils.SignManager; import com.rappytv.signsearch.utils.SignSearchSettings; import net.labymod.api.addon.LabyAddon; @@ -20,8 +20,8 @@ protected void enable() { config = configuration(); signManager = new SignManager(); searchSettings = new SignSearchSettings(config.enabled()); - SignSearchNavigationActivity activity = new SignSearchNavigationActivity(searchSettings); - labyAPI().navigationService().register(new SignSearchNavigationElement(activity)); + SignSearchSettingsActivity activity = new SignSearchSettingsActivity(searchSettings); + registerListener(new PauseMenuListener(activity)); } @Override From dd40b5157ec4aedf98f5c1e10781772a0c420a31 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Thu, 21 Nov 2024 21:34:09 +0100 Subject: [PATCH 4/4] Bump version --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index bd7d148..b5642a6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,7 +6,7 @@ plugins { val versions = providers.gradleProperty("net.labymod.minecraft-versions").get().split(";") group = "com.rappytv.signsearch" -version = providers.environmentVariable("VERSION").getOrElse("1.0.2") +version = providers.environmentVariable("VERSION").getOrElse("1.0.3") labyMod { defaultPackageName = "com.rappytv.signsearch" //change this to your main package name (used by all modules)