Skip to content

Commit

Permalink
feat: add new "none" quest shape and lock icon
Browse files Browse the repository at this point in the history
Lock icon controllable via both a quest file setting and player preferences
Enabled by default

FTBTeam/FTB-Mods-Issues#1448
  • Loading branch information
desht committed Jan 7, 2025
1 parent e5c6dcf commit 98b385e
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public interface FTBQuestsClientConfig {
EnumValue<PanelPositioning> 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", ""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();

Expand All @@ -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()) {
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Task> allTasks;
private List<Task> submitTasks;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1407,6 +1413,10 @@ public RewardAutoClaim getDefaultRewardAutoClaim() {
return defaultRewardAutoClaim;
}

public boolean showLockIcons() {
return showLockIcons;
}

public List<ItemStack> getEmergencyItems() {
return Collections.unmodifiableList(emergencyItems);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@ 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) {
this.id = 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<String> list) {
Expand Down Expand Up @@ -99,6 +101,10 @@ public PixelBuffer getShapePixels() {
return shapePixels;
}

public boolean shouldDraw() {
return shouldDraw;
}

public static Map<String,QuestShape> map() {
return Collections.unmodifiableMap(MAP);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public static void loadTheme(ResourceManager resourceManager) {
list.add(s.trim());
}

list.add("none");

QuestShape.reload(new ArrayList<>(list));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/resources/assets/ftbquests/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
"ftbquests.quest.shape.octagon": "Octagon",
"ftbquests.quest.shape.heart": "Heart",
"ftbquests.quest.shape.gear": "Gear",
"ftbquests.quest.shape.none": "<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",
Expand Down Expand Up @@ -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.",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"texture": {
"blur": true
}
}

0 comments on commit 98b385e

Please sign in to comment.