From cd70174aa0dd9a28d60064c87e07cf2f766ceea0 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Wed, 7 Feb 2024 08:39:08 +0000 Subject: [PATCH 1/8] fix: client-side user preferences weren't persisted properly https://github.com/FTBTeam/FTB-Mods-Issues/issues/1091 --- .../ftb/mods/ftbquests/client/FTBQuestsClient.java | 4 +++- .../mods/ftbquests/client/FTBQuestsClientConfig.java | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/client/FTBQuestsClient.java b/common/src/main/java/dev/ftb/mods/ftbquests/client/FTBQuestsClient.java index 031254bc..932a83a4 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/client/FTBQuestsClient.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/client/FTBQuestsClient.java @@ -19,7 +19,6 @@ import dev.ftb.mods.ftbquests.item.FTBQuestsItems; import dev.ftb.mods.ftbquests.net.SetCustomImageMessage; import dev.ftb.mods.ftbquests.quest.BaseQuestFile; -import dev.ftb.mods.ftbquests.quest.Quest; import dev.ftb.mods.ftbquests.quest.QuestObjectBase; import dev.ftb.mods.ftbquests.quest.TeamData; import dev.ftb.mods.ftbquests.quest.reward.ItemReward; @@ -62,10 +61,13 @@ public class FTBQuestsClient { public static KeyMapping KEY_QUESTS; public static void init() { + FTBQuestsClientConfig.init(); + ClientLifecycleEvent.CLIENT_SETUP.register(FTBQuestsClient::onClientSetup); ReloadListenerRegistry.register(PackType.CLIENT_RESOURCES, new QuestFileCacheReloader()); ReloadListenerRegistry.register(PackType.CLIENT_RESOURCES, new ThemeLoader()); KeyMappingRegistry.register(KEY_QUESTS = new KeyMapping("key.ftbquests.quests", InputConstants.Type.KEYSYM, -1, "key.categories.ftbquests")); + new FTBQuestsClientEventHandler().init(); } diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/client/FTBQuestsClientConfig.java b/common/src/main/java/dev/ftb/mods/ftbquests/client/FTBQuestsClientConfig.java index 988388ed..b5f1bfff 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/client/FTBQuestsClientConfig.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/client/FTBQuestsClientConfig.java @@ -1,6 +1,5 @@ package dev.ftb.mods.ftbquests.client; -import dev.architectury.platform.Platform; import dev.ftb.mods.ftblibrary.config.ConfigGroup; import dev.ftb.mods.ftblibrary.config.ui.EditConfigScreen; import dev.ftb.mods.ftblibrary.snbt.config.BooleanValue; @@ -9,8 +8,12 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; +import static dev.ftb.mods.ftblibrary.snbt.config.ConfigUtil.LOCAL_DIR; +import static dev.ftb.mods.ftblibrary.snbt.config.ConfigUtil.loadDefaulted; + public interface FTBQuestsClientConfig { SNBTConfig CONFIG = SNBTConfig.create(FTBQuestsAPI.MOD_ID + "-client"); + String CLIENT_CONFIG = "client-config.snbt"; SNBTConfig UI = CONFIG.addGroup("ui", 0); BooleanValue OLD_SCROLL_WHEEL = UI.addBoolean("old_scroll_wheel", false); @@ -30,7 +33,11 @@ static void openSettings(Screen screen) { gui.openGui(); } + static void init() { + loadDefaulted(CONFIG, LOCAL_DIR.resolve(FTBQuestsAPI.MOD_ID), FTBQuestsAPI.MOD_ID, CLIENT_CONFIG); + } + static void saveConfig() { - CONFIG.save(Platform.getGameFolder().resolve("local/ftbquests/client-config.snbt")); + CONFIG.save(LOCAL_DIR.resolve(FTBQuestsAPI.MOD_ID).resolve(CLIENT_CONFIG)); } } From a68dc46e3bcd21d9a03bcc81cb8a24fd6612635c Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Wed, 7 Feb 2024 08:40:08 +0000 Subject: [PATCH 2/8] build: version -> 2001.3.4, changelog updated --- CHANGELOG.md | 5 +++++ gradle.properties | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03eb63bd..3e14897e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [2001.3.4] + +### Fixed +* Fixed client-side config (from "User Preferences" button) not getting properly persisted + ## [2001.3.3] ### Added diff --git a/gradle.properties b/gradle.properties index e1980cd6..f29dba7e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ mod_id=ftbquests archives_base_name=ftb-quests minecraft_version=1.20.1 # Build time -mod_version=2001.3.3 +mod_version=2001.3.4 maven_group=dev.ftb.mods mod_author=FTB Team # Curse release From bc3fb98be24b20542adf43fb86f4ccfbbe9f0cee Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Wed, 7 Feb 2024 09:33:24 +0000 Subject: [PATCH 3/8] fix: player prefs screen follows main screen's SSP pause behaviour --- .../ftb/mods/ftbquests/client/FTBQuestsClientConfig.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/client/FTBQuestsClientConfig.java b/common/src/main/java/dev/ftb/mods/ftbquests/client/FTBQuestsClientConfig.java index b5f1bfff..83c75944 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/client/FTBQuestsClientConfig.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/client/FTBQuestsClientConfig.java @@ -28,7 +28,12 @@ static void openSettings(Screen screen) { Minecraft.getInstance().setScreen(screen); }); CONFIG.createClientConfig(group); - EditConfigScreen gui = new EditConfigScreen(group); + EditConfigScreen gui = new EditConfigScreen(group) { + @Override + public boolean doesGuiPauseGame() { + return screen.isPauseScreen(); + } + }; gui.openGui(); } From c75b35a3f29b08668f45cd692daebd29aca7840a Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Mon, 19 Feb 2024 12:14:06 +0000 Subject: [PATCH 4/8] fix: image buttons shouldn't override shouldDraw() to return false --- .../mods/ftbquests/client/gui/quests/ChapterImageButton.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/client/gui/quests/ChapterImageButton.java b/common/src/main/java/dev/ftb/mods/ftbquests/client/gui/quests/ChapterImageButton.java index 8f410ece..ec126eb3 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/client/gui/quests/ChapterImageButton.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/client/gui/quests/ChapterImageButton.java @@ -128,11 +128,6 @@ public void addMouseOverText(TooltipList list) { chapterImage.addHoverText(list); } - @Override - public boolean shouldDraw() { - return false; - } - @Override public void draw(GuiGraphics graphics, Theme theme, int x, int y, int w, int h) { Icon image = chapterImage.getImage(); From 7122985d6e07d9f93ff89c99a81aa7b398a7f687 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Mon, 19 Feb 2024 12:17:08 +0000 Subject: [PATCH 5/8] chore: changelog updated --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e14897e..ef72f328 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed * Fixed client-side config (from "User Preferences" button) not getting properly persisted +* User Preferences screen SSP pause behaviour now follows main screen's pause behaviour ## [2001.3.3] From 18acae2cb205cd89ec626b9c11cbff403c146387 Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Mon, 19 Feb 2024 16:56:32 +0000 Subject: [PATCH 6/8] feat: added icon scaling setting for quests Useful for some quest shapes where the icon might extend beyond the shape edges (e.g. diamond shape) --- .../client/gui/quests/QuestButton.java | 2 +- .../dev/ftb/mods/ftbquests/quest/Quest.java | 18 ++++++++++++++++++ .../resources/assets/ftbquests/lang/en_us.json | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/client/gui/quests/QuestButton.java b/common/src/main/java/dev/ftb/mods/ftbquests/client/gui/quests/QuestButton.java index 99dfef82..3c910bba 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/client/gui/quests/QuestButton.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/client/gui/quests/QuestButton.java @@ -369,7 +369,7 @@ public void draw(GuiGraphics graphics, Theme theme, int x, int y, int w, int h) PoseStack poseStack = graphics.pose(); if (!icon.isEmpty()) { - float s = w * 2F / 3F; + float s = w * (2F / 3F) * (float) quest.getIconScale(); poseStack.pushPose(); poseStack.translate(x + (w - s) / 2D, y + (h - s) / 2D, 0); poseStack.scale(s, s, 1F); diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/quest/Quest.java b/common/src/main/java/dev/ftb/mods/ftbquests/quest/Quest.java index 2e39decb..819f4d4e 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/quest/Quest.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/quest/Quest.java @@ -68,6 +68,7 @@ public final class Quest extends QuestObject implements Movable { private boolean invisible; // invisible to players (not the same as hidden!) private int invisibleUntilTasks; // invisible until at least X number of tasks have been completed private Tristate requireSequentialTasks; + private double iconScale; private Component cachedSubtitle = null; private List cachedDescription = null; @@ -107,6 +108,7 @@ public Quest(long id, Chapter chapter) { progressionMode = ProgressionMode.DEFAULT; dependantIDs = new HashSet<>(); requireSequentialTasks = Tristate.DEFAULT; + iconScale = 1d; } @Override @@ -201,6 +203,10 @@ public List getRawDescription() { return rawDescription; } + public double getIconScale() { + return iconScale; + } + @Override public boolean isOptionalForProgression() { return isOptional(); @@ -270,6 +276,10 @@ public void writeData(CompoundTag nbt) { nbt.putDouble("size", size); } + if (iconScale != 1d) { + nbt.putDouble("icon_scale", iconScale); + } + if (optional) { nbt.putBoolean("optional", true); } @@ -350,6 +360,7 @@ public void readData(CompoundTag nbt) { dependencyRequirement = DependencyRequirement.NAME_MAP.get(nbt.getString("dependency_requirement")); hideTextUntilComplete = Tristate.read(nbt, "hide_text_until_complete"); size = nbt.getDouble("size"); + iconScale = nbt.contains("icon_scale", Tag.TAG_DOUBLE) ? nbt.getDouble("icon_scale") : 1f; optional = nbt.getBoolean("optional"); minWidth = nbt.getInt("min_width"); canRepeat = Tristate.read(nbt, "can_repeat"); @@ -383,6 +394,7 @@ public void writeNetData(FriendlyByteBuf buffer) { flags = Bits.setFlag(flags, 0x4000, canRepeat == Tristate.TRUE); flags = Bits.setFlag(flags, 0x8000, requireSequentialTasks != Tristate.DEFAULT); flags = Bits.setFlag(flags, 0x10000, requireSequentialTasks == Tristate.TRUE); + flags = Bits.setFlag(flags, 0x20000, iconScale != 1f); buffer.writeVarInt(flags); hideUntilDepsVisible.write(buffer); @@ -417,6 +429,10 @@ public void writeNetData(FriendlyByteBuf buffer) { buffer.writeDouble(size); } + if (iconScale != 1D) { + buffer.writeDouble(iconScale); + } + if (minWidth > 0) { buffer.writeVarInt(minWidth); } @@ -463,6 +479,7 @@ public void readNetData(FriendlyByteBuf buffer) { } size = Bits.getFlag(flags, 0x04) ? buffer.readDouble() : 0D; + iconScale = Bits.getFlag(flags, 0x20000) ? buffer.readDouble() : 1D; minWidth = Bits.getFlag(flags, 0x200) ? buffer.readVarInt() : 0; ignoreRewardBlocking = Bits.getFlag(flags, 0x10); hideDependentLines = Bits.getFlag(flags, 0x20); @@ -647,6 +664,7 @@ public void onClicked(MouseButton button, ConfigCallback callback) { appearance.addDouble("x", x, v -> x = v, 0, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY); appearance.addDouble("y", y, v -> y = v, 0, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY); appearance.addInt("min_width", minWidth, v -> minWidth = v, 0, 0, 3000); + appearance.addDouble("icon_scale", iconScale, v -> iconScale = v, 1f, 0.1, 2.0); ConfigGroup visibility = config.getOrCreateSubgroup("visibility"); visibility.addTristate("hide", hideUntilDepsVisible, v -> hideUntilDepsVisible = v); diff --git a/common/src/main/resources/assets/ftbquests/lang/en_us.json b/common/src/main/resources/assets/ftbquests/lang/en_us.json index ec64325d..6a53e721 100644 --- a/common/src/main/resources/assets/ftbquests/lang/en_us.json +++ b/common/src/main/resources/assets/ftbquests/lang/en_us.json @@ -166,6 +166,8 @@ "ftbquests.quest.appearance.y": "Y", "ftbquests.quest.appearance.size": "Size", "ftbquests.quest.appearance.size.tooltip": "0 means to use chapter default", + "ftbquests.quest.appearance.icon_scale": "Icon Scaling", + "ftbquests.quest.appearance.icon_scale.tooltip": "Independent of the overall button size", "ftbquests.quest.visibility.hide": "Hide Quest Until Dependencies are Visible", "ftbquests.quest.appearance.shape": "Shape", "ftbquests.quest_link.shape": "Shape", From 8537a764d310d584b3a4e68d1f4bdf841b5ddb1a Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Mon, 11 Mar 2024 11:34:21 +0000 Subject: [PATCH 7/8] feat: allow theming of uncompleted dependency lines Use 'dependency_line_uncompleted_color' setting in ftb_quests_theme.txt Default is #C4CCA3A3, which is the same as the colour used previously https://github.com/FTBTeam/FTB-Mods-Issues/issues/1106 --- .../client/gui/quests/QuestPanel.java | 21 ++++++------------- .../quest/theme/property/ThemeProperties.java | 1 + .../assets/ftbquests/ftb_quests_theme.txt | 1 + 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/client/gui/quests/QuestPanel.java b/common/src/main/java/dev/ftb/mods/ftbquests/client/gui/quests/QuestPanel.java index d6078fdf..c2346541 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/client/gui/quests/QuestPanel.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/client/gui/quests/QuestPanel.java @@ -199,24 +199,15 @@ public void drawOffsetBackground(GuiGraphics graphics, Theme theme, int x, int y if (widget.shouldDraw() && widget instanceof QuestButton qb && !qb.quest.shouldHideDependencyLines()) { boolean unavailable = !questScreen.file.selfTeamData.canStartTasks(qb.quest); boolean complete = !unavailable && questScreen.file.selfTeamData.isCompleted(qb.quest); + Color4I c = complete ? + ThemeProperties.DEPENDENCY_LINE_COMPLETED_COLOR.get(questScreen.selectedChapter) : + ThemeProperties.DEPENDENCY_LINE_UNCOMPLETED_COLOR.get(questScreen.selectedChapter); for (QuestButton button : qb.getDependencies()) { if (button.shouldDraw() && button.quest != selectedQuest && qb.quest != selectedQuest && !button.quest.shouldHideDependentLines()) { - int r, g, b, a; - if (complete) { - Color4I c = ThemeProperties.DEPENDENCY_LINE_COMPLETED_COLOR.get(questScreen.selectedChapter); - r = c.redi(); - g = c.greeni(); - b = c.bluei(); - a = c.alphai(); - } else { - Color4I c = Color4I.hsb(button.quest.id / 1000F, 0.2F, unavailable ? 0.3F : 0.8F); - r = c.redi(); - g = c.greeni(); - b = c.bluei(); - a = 180; - } - renderConnection(widget, button, graphics.pose(), buffer, lineWidth, r, g, b, a, a, mu, tesselator); + renderConnection(widget, button, graphics.pose(), buffer, lineWidth, + c.redi(), c.greeni(), c.bluei(), c.alphai(), c.alphai(), + mu, tesselator); } } } diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/quest/theme/property/ThemeProperties.java b/common/src/main/java/dev/ftb/mods/ftbquests/quest/theme/property/ThemeProperties.java index f336a340..b16b52a5 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/quest/theme/property/ThemeProperties.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/quest/theme/property/ThemeProperties.java @@ -143,6 +143,7 @@ public boolean equals(Object o) { ColorProperty QUEST_LOCKED_COLOR = new ColorProperty("quest_locked_color"); IconProperty DEPENDENCY_LINE_TEXTURE = new IconProperty("dependency_line_texture"); ColorProperty DEPENDENCY_LINE_COMPLETED_COLOR = new ColorProperty("dependency_line_completed_color"); + ColorProperty DEPENDENCY_LINE_UNCOMPLETED_COLOR = new ColorProperty("dependency_line_uncompleted_color"); ColorProperty DEPENDENCY_LINE_REQUIRES_COLOR = new ColorProperty("dependency_line_requires_color"); ColorProperty DEPENDENCY_LINE_REQUIRED_FOR_COLOR = new ColorProperty("dependency_line_required_for_color"); DoubleProperty DEPENDENCY_LINE_SELECTED_SPEED = new DoubleProperty("dependency_line_selected_speed", 0D, 1000D); diff --git a/common/src/main/resources/assets/ftbquests/ftb_quests_theme.txt b/common/src/main/resources/assets/ftbquests/ftb_quests_theme.txt index e872ba87..1ebb915d 100644 --- a/common/src/main/resources/assets/ftbquests/ftb_quests_theme.txt +++ b/common/src/main/resources/assets/ftbquests/ftb_quests_theme.txt @@ -65,6 +65,7 @@ quest_not_started_color: #96FFFFFF quest_locked_color: #FF999999 dependency_line_texture: ftbquests:textures/gui/dependency.png dependency_line_completed_color: #64DC64 +dependency_line_uncompleted_color: #B4CCA3A3 dependency_line_requires_color: #00C8C8 dependency_line_required_for_color: #C8C800 dependency_line_selected_speed: 1.0 From bd52665af85421fed1540650163d1d777f4b14de Mon Sep 17 00:00:00 2001 From: Des Herriott Date: Mon, 11 Mar 2024 11:37:38 +0000 Subject: [PATCH 8/8] build: updated changelog, fabric.mod.json & mods.toml Requires FTB Library < 2001.2.0 (the UI overhaul version) --- CHANGELOG.md | 7 +++++++ fabric/src/main/resources/fabric.mod.json | 1 + forge/src/main/resources/META-INF/mods.toml | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ef72f328..95e5d4c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [2001.3.4] +### Added +* The color of dependency lines for uncompleted quests is now themable + * Use the "dependency_line_uncompleted_color" setting in ftb_quests_theme.txt (a resource pack file) + * Default is #B4CCA3A3, which is the same as the previous color (a washed-out red tint) +* Added "Icon Scaling" property for quests (default: 1.0) + * Allows the quest icon to be scaled separately from the overall quest button size, which can be useful for a good appearance with some button shapes + ### Fixed * Fixed client-side config (from "User Preferences" button) not getting properly persisted * User Preferences screen SSP pause behaviour now follows main screen's pause behaviour diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 0c86c39e..339536c2 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -30,5 +30,6 @@ "ftbteams": ">=2001.1.4-build.1" }, "breaks": { + "ftblibrary": ">=2001.2.0" } } diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 58ac1969..b85791fd 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -29,7 +29,7 @@ side = "BOTH" [[dependencies.ftbquests]] modId = "ftblibrary" mandatory = true -versionRange = "[2001.1.4,)" +versionRange = "[2001.1.4,2001.2.0)" ordering = "AFTER" side = "BOTH"