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 b67fc61c6..d0d93c783 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 @@ -23,6 +23,7 @@ public interface FTBQuestsClientConfig { EnumValue PINNED_QUESTS_POS = UI.addEnum("pinned_quests_pos", PanelPositioning.NAME_MAP, PanelPositioning.RIGHT); IntValue PINNED_QUESTS_INSET_X = UI.addInt("pinned_quests_inset_x", 2); IntValue PINNED_QUESTS_INSET_Y = UI.addInt("pinned_quests_inset_y", 2); + BooleanValue SHOW_LOCK_ICON = UI.addBoolean("show_lock_icon", true); SNBTConfig XLATE = CONFIG.addGroup("xlate", 1); StringValue EDITING_LOCALE = XLATE.add(new LocaleValue(XLATE,"editing_locale", "")); 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 aeec77e8d..8c860353c 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 @@ -12,6 +12,7 @@ import dev.ftb.mods.ftblibrary.ui.input.MouseButton; import dev.ftb.mods.ftblibrary.util.TooltipList; import dev.ftb.mods.ftblibrary.util.client.PositionedIngredient; +import dev.ftb.mods.ftbquests.client.FTBQuestsClientConfig; import dev.ftb.mods.ftbquests.client.gui.ContextMenuBuilder; import dev.ftb.mods.ftbquests.net.CreateObjectMessage; import dev.ftb.mods.ftbquests.net.DeleteObjectMessage; @@ -325,6 +326,7 @@ public void draw(GuiGraphics graphics, Theme theme, int x, int y, int w, int h) Color4I outlineColor = ThemeProperties.QUEST_NOT_STARTED_COLOR.get(quest); Icon questIcon = Color4I.empty() ; Icon hiddenIcon = Color4I.empty(); + Icon lockIcon = Color4I.empty(); TeamData teamData = questScreen.file.selfTeamData; boolean isCompleted = teamData.isCompleted(quest); @@ -364,9 +366,11 @@ public void draw(GuiGraphics graphics, Theme theme, int x, int y, int w, int h) QuestShape shape = QuestShape.get(getShape()); - shape.getShape().withColor(Color4I.DARK_GRAY).draw(graphics, x, y, w, h); - shape.getBackground().withColor(Color4I.WHITE.withAlpha(150)).draw(graphics, x, y, w, h); - shape.getOutline().withColor(outlineColor).draw(graphics, x, y, w, h); + if (shape.shouldDraw()) { + shape.getShape().withColor(Color4I.DARK_GRAY).draw(graphics, x, y, w, h); + shape.getBackground().withColor(Color4I.WHITE.withAlpha(150)).draw(graphics, x, y, w, h); + shape.getOutline().withColor(outlineColor).draw(graphics, x, y, w, h); + } PoseStack poseStack = graphics.pose(); @@ -392,7 +396,12 @@ public void draw(GuiGraphics graphics, Theme theme, int x, int y, int w, int h) } if (!canStart || !teamData.areDependenciesComplete(quest)) { - shape.getShape().withColor(Color4I.BLACK.withAlpha(100)).draw(graphics, x, y, w, h); + if (shape.shouldDraw()) { + shape.getShape().withColor(Color4I.BLACK.withAlpha(100)).draw(graphics, x, y, w, h); + } + if (quest.getQuestFile().showLockIcons() && FTBQuestsClientConfig.SHOW_LOCK_ICON.get()) { + lockIcon = ThemeProperties.LOCK_ICON.get(); + } } if (isMouseOver()) { @@ -414,6 +423,14 @@ public void draw(GuiGraphics graphics, Theme theme, int x, int y, int w, int h) hiddenIcon.draw(graphics, 0, 0, s, s); poseStack.popPose(); } + + if (!lockIcon.isEmpty()) { + int s = (int) (w / 8F * 3F); + poseStack.pushPose(); + poseStack.translate(x + w - s, y + h - 1 - s, QuestScreen.Z_LEVEL); + lockIcon.draw(graphics, 0, 0, s, s); + poseStack.popPose(); + } } protected String getShape() { diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/quest/BaseQuestFile.java b/common/src/main/java/dev/ftb/mods/ftbquests/quest/BaseQuestFile.java index d06713b0d..b173fc087 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/quest/BaseQuestFile.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/quest/BaseQuestFile.java @@ -101,6 +101,7 @@ public void encode(RegistryFriendlyByteBuf buf, BaseQuestFile file) { protected String lockMessage; private ProgressionMode progressionMode; private int detectionDelay; + private boolean showLockIcons; private List allTasks; private List submitTasks; @@ -423,6 +424,7 @@ public final void writeData(CompoundTag nbt, HolderLookup.Provider provider) { nbt.putString("lock_message", lockMessage); nbt.putString("progression_mode", progressionMode.getId()); nbt.putInt("detection_delay", detectionDelay); + nbt.putBoolean("show_lock_icons", showLockIcons); } @Override @@ -460,6 +462,7 @@ public final void readData(CompoundTag nbt, HolderLookup.Provider provider) { if (nbt.contains("detection_delay")) { detectionDelay = nbt.getInt("detection_delay"); } + showLockIcons = !nbt.contains("show_lock_icons") || nbt.getBoolean("show_lock_icons"); } public final void writeDataFull(Path folder, HolderLookup.Provider provider) { @@ -831,6 +834,7 @@ public final void writeNetData(RegistryFriendlyByteBuf buffer) { buffer.writeUtf(lockMessage, Short.MAX_VALUE); ProgressionMode.NAME_MAP_NO_DEFAULT.write(buffer, progressionMode); buffer.writeVarInt(detectionDelay); + buffer.writeBoolean(showLockIcons); } @Override @@ -853,6 +857,7 @@ public final void readNetData(RegistryFriendlyByteBuf buffer) { lockMessage = buffer.readUtf(Short.MAX_VALUE); progressionMode = ProgressionMode.NAME_MAP_NO_DEFAULT.read(buffer); detectionDelay = buffer.readVarInt(); + showLockIcons = buffer.readBoolean(); } public final void writeNetDataFull(RegistryFriendlyByteBuf buffer) { @@ -1125,6 +1130,7 @@ public void fillConfigGroup(ConfigGroup config) { config.addEnum("progression_mode", progressionMode, v -> progressionMode = v, ProgressionMode.NAME_MAP_NO_DEFAULT); config.addInt("detection_delay", detectionDelay, v -> detectionDelay = v, 20, 0, 200); config.addBool("pause_game", pauseGame, v -> pauseGame = v, false); + config.addBool("show_lock_icons", showLockIcons, v -> showLockIcons = v, true).setNameKey("ftbquests.ui.show_lock_icon"); ConfigGroup defaultsGroup = config.getOrCreateSubgroup("defaults"); defaultsGroup.addBool("reward_team", defaultPerTeamReward, v -> defaultPerTeamReward = v, false); @@ -1407,6 +1413,10 @@ public RewardAutoClaim getDefaultRewardAutoClaim() { return defaultRewardAutoClaim; } + public boolean showLockIcons() { + return showLockIcons; + } + public List getEmergencyItems() { return Collections.unmodifiableList(emergencyItems); } diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/quest/QuestShape.java b/common/src/main/java/dev/ftb/mods/ftbquests/quest/QuestShape.java index bd2870004..8d466db9d 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/quest/QuestShape.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/quest/QuestShape.java @@ -27,6 +27,7 @@ public final class QuestShape extends Icon { private final String id; private final ImageIcon background, outline, shape; + private final boolean shouldDraw; private PixelBuffer shapePixels; public QuestShape(String id) { @@ -34,6 +35,7 @@ public QuestShape(String id) { background = new ImageIcon(FTBQuestsAPI.rl("textures/shapes/" + this.id + "/background.png")); outline = new ImageIcon(FTBQuestsAPI.rl("textures/shapes/" + this.id + "/outline.png")); shape = new ImageIcon(FTBQuestsAPI.rl("textures/shapes/" + this.id + "/shape.png")); + shouldDraw = !id.equals("none"); } public static void reload(List list) { @@ -99,6 +101,10 @@ public PixelBuffer getShapePixels() { return shapePixels; } + public boolean shouldDraw() { + return shouldDraw; + } + public static Map map() { return Collections.unmodifiableMap(MAP); } diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/quest/theme/ThemeLoader.java b/common/src/main/java/dev/ftb/mods/ftbquests/quest/theme/ThemeLoader.java index ad293daa1..fdf0e0ef3 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/quest/theme/ThemeLoader.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/quest/theme/ThemeLoader.java @@ -89,6 +89,8 @@ public static void loadTheme(ResourceManager resourceManager) { list.add(s.trim()); } + list.add("none"); + QuestShape.reload(new ArrayList<>(list)); } 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 d6d161986..fd4ecacd4 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 @@ -123,6 +123,7 @@ public boolean equals(Object o) { IconProperty EDIT_ICON = new IconProperty("edit_icon"); IconProperty MOVE_UP_ICON = new IconProperty("move_up_icon"); IconProperty MOVE_DOWN_ICON = new IconProperty("move_down_icon"); + IconProperty LOCK_ICON = new IconProperty("lock_icon"); // Quest window // IconProperty ICON = new IconProperty("icon"); diff --git a/common/src/main/java/dev/ftb/mods/ftbquests/quest/translation/TranslationManager.java b/common/src/main/java/dev/ftb/mods/ftbquests/quest/translation/TranslationManager.java index 082d05543..6744f9195 100644 --- a/common/src/main/java/dev/ftb/mods/ftbquests/quest/translation/TranslationManager.java +++ b/common/src/main/java/dev/ftb/mods/ftbquests/quest/translation/TranslationManager.java @@ -69,9 +69,9 @@ public void loadFromNBT(Path langFolder) { } } - public void saveToNBT(Path langFolder) { + public void saveToNBT(Path langFolder, boolean force) { map.forEach((locale, table) -> { - if (table.isSaveNeeded()) { + if (force || table.isSaveNeeded()) { boolean prevSort = SNBT.setShouldSortKeysOnWrite(true); Path savePath = langFolder.resolve(locale + ".snbt"); if (!SNBT.write(savePath, table.saveToNBT())) { 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 05f809f4a..1fbd82704 100644 --- a/common/src/main/resources/assets/ftbquests/ftb_quests_theme.txt +++ b/common/src/main/resources/assets/ftbquests/ftb_quests_theme.txt @@ -44,6 +44,7 @@ modpack_icon: ftbquests:textures/item/book.png reward_table_icon: ftblibrary:icons/money_bag shop_icon: ftbquests:textures/gui/shop.png; color=#EF9E1A collect_rewards_icon: ftbquests:textures/gui/collect_rewards.png; color=#EF9E1A +lock_icon: ftbquests:textures/gui/quest_locked.png delete_icon: ftblibrary:icons/remove reload_icon: ftblibrary:icons/refresh download_icon: ftblibrary:icons/down 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 c4b014024..ad45a2409 100644 --- a/common/src/main/resources/assets/ftbquests/lang/en_us.json +++ b/common/src/main/resources/assets/ftbquests/lang/en_us.json @@ -188,6 +188,7 @@ "ftbquests.quest.shape.octagon": "Octagon", "ftbquests.quest.shape.heart": "Heart", "ftbquests.quest.shape.gear": "Gear", + "ftbquests.quest.shape.none": "", "ftbquests.quest.misc.can_repeat": "Repeatable Quest", "ftbquests.quest.tasks_ignore_dependencies": "Tasks Ignore Dependencies", "ftbquests.quest.tasks_ignore_dependencies.tooltip": "Allow to start tasks without completing dependencies", @@ -543,6 +544,8 @@ "ftbquests.ui.pinned_quests_inset_x.tooltip": "Inset is toward center of screen.\nIgnored if X pos is center.", "ftbquests.ui.pinned_quests_inset_y": "Pinned Quests Panel Y Inset", "ftbquests.ui.pinned_quests_inset_y.tooltip": "Inset is toward center of screen.\nIgnored if Y pos is center.", + "ftbquests.ui.show_lock_icon": "Show Icon for Locked Quests", + "ftbquests.ui.show_lock_icon.tooltip": "Show a padlock icon on any quests which can't yet be started due to dependency restrictions.", "ftbquests.xlate": "Translations", "ftbquests.xlate.editing_locale": "Locale Override", "ftbquests.xlate.editing_locale.tooltip": "The language used for editing FTB Quests text: title text for chapters, quests, tasks and reward tables, subtitles for chapters and quests, and quest description text.\nIf empty, use the current Minecraft language setting.", diff --git a/common/src/main/resources/assets/ftbquests/textures/gui/quest_locked.png b/common/src/main/resources/assets/ftbquests/textures/gui/quest_locked.png new file mode 100644 index 000000000..8fa948bf5 Binary files /dev/null and b/common/src/main/resources/assets/ftbquests/textures/gui/quest_locked.png differ diff --git a/common/src/main/resources/assets/ftbquests/textures/shapes/none/background.png b/common/src/main/resources/assets/ftbquests/textures/shapes/none/background.png new file mode 100644 index 000000000..4ab95c9b7 Binary files /dev/null and b/common/src/main/resources/assets/ftbquests/textures/shapes/none/background.png differ diff --git a/common/src/main/resources/assets/ftbquests/textures/shapes/none/outline.png b/common/src/main/resources/assets/ftbquests/textures/shapes/none/outline.png new file mode 100644 index 000000000..4ab95c9b7 Binary files /dev/null and b/common/src/main/resources/assets/ftbquests/textures/shapes/none/outline.png differ diff --git a/common/src/main/resources/assets/ftbquests/textures/shapes/none/shape.png b/common/src/main/resources/assets/ftbquests/textures/shapes/none/shape.png new file mode 100644 index 000000000..49a711107 Binary files /dev/null and b/common/src/main/resources/assets/ftbquests/textures/shapes/none/shape.png differ diff --git a/common/src/main/resources/assets/ftbquests/textures/shapes/none/shape.png.mcmeta b/common/src/main/resources/assets/ftbquests/textures/shapes/none/shape.png.mcmeta new file mode 100644 index 000000000..a39ce83c2 --- /dev/null +++ b/common/src/main/resources/assets/ftbquests/textures/shapes/none/shape.png.mcmeta @@ -0,0 +1,5 @@ +{ + "texture": { + "blur": true + } +} \ No newline at end of file