From d0b9023302c99a971ead06513d7bc48754285c33 Mon Sep 17 00:00:00 2001 From: Dietrich Friday Date: Thu, 2 Nov 2023 20:18:32 +0900 Subject: [PATCH 1/4] Preserve FTBQ quest icon background shape choices In convertFtbQuests.ts: - Expands `QuestShape` type def. to include default FTBQ shape options. - Converts all those default FTBQ shape options to string to specify where to find matching textures.. In HeraclesQuest.ts: - Changes `HeraclesQuest` type's `icon_background?` element to be type `string` Note: Heracles currently ships with only two shapes; this patch is concerened only with Odysseus. It seemed better to preserve this information than to task a user with mapping the choices from FTQB chapter files to edits in corresponding multiple Heracles quest files. --- odysseus/HeraclesQuest.ts | 3 +-- odysseus/convertFtbQuests.ts | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/odysseus/HeraclesQuest.ts b/odysseus/HeraclesQuest.ts index a99af97..c6b9bc0 100644 --- a/odysseus/HeraclesQuest.ts +++ b/odysseus/HeraclesQuest.ts @@ -253,8 +253,7 @@ export type HeraclesQuestReward = HeraclesQuestElement & ({ export type HeraclesQuest = { display?: { icon?: HeraclesQuestIcon; - - icon_background?: 'heracles:textures/gui/quest_backgrounds/default.png' | 'heracles:textures/gui/quest_backgrounds/circles.png'; + icon_background?: string; title?: Component; subtitle?: Component; description?: string[]; diff --git a/odysseus/convertFtbQuests.ts b/odysseus/convertFtbQuests.ts index 8c1684c..d48ffbe 100644 --- a/odysseus/convertFtbQuests.ts +++ b/odysseus/convertFtbQuests.ts @@ -15,7 +15,7 @@ const enum ObserveType { ENTITY_TYPE_TAG } -type QuestShape = 'circle' | 'square' | 'pentagon' | 'hexagon' | 'gear'; +type QuestShape = 'circle' | 'square' | 'rsquare' | 'diamond' | 'pentagon' | 'hexagon' | 'octagon' | 'gear' | 'heart'; type FtbId = `ftbquests:${T}` | T; @@ -382,6 +382,21 @@ function truncateLong(value: Long | undefined) { return Number(value) } +function iconBackgroundTexture(iconBackground: QuestShape | undefined) { + switch (iconBackground) { + case 'circle': { return 'heracles:textures/gui/quest_backgrounds/circles.png' } + case 'square': { return 'heracles:textures/gui/quest_backgrounds/squares.png' } + case 'rsquare': { return 'heracles:textures/gui/quest_backgrounds/rsquares.png' } + case 'diamond': { return 'heracles:textures/gui/quest_backgrounds/diamonds.png' } + case 'pentagon':{ return 'heracles:textures/gui/quest_backgrounds/pentagons.png' } + case 'hexagon': { return 'heracles:textures/gui/quest_backgrounds/hexagons.png' } + case 'octagon': { return 'heracles:textures/gui/quest_backgrounds/octagons.png' } + case 'gear': { return 'heracles:textures/gui/quest_backgrounds/gears.png' } + case 'heart': { return 'heracles:textures/gui/quest_backgrounds/hearts.png' } + case undefined: { return undefined } + } +} + export const convertFtbQuests = async (input: QuestInputFileSystem, output: QuestOutputFileSystem) => { const readSNbtFile = async (name: string) => parseStringifiedNbt(await input.readFile(name), name); @@ -476,6 +491,8 @@ export const convertFtbQuests = async (input: QuestInputFileSystem, output: Ques const questSubtitle = quest.subtitle ? formatString(quest.subtitle) : undefined; const questIcon = quest.icon ? convertIcon(quest.icon) : inferredData?.icon; + const iconBackground = iconBackgroundTexture(quest.shape ?? chapter.default_quest_shape ?? questFile.default_quest_shape) + const heraclesQuest: HeraclesQuest = { settings: { hidden: quest.hide @@ -511,9 +528,7 @@ export const convertFtbQuests = async (input: QuestInputFileSystem, output: Ques icon: questIcon, - icon_background: (quest.shape ?? chapter.default_quest_shape ?? questFile.default_quest_shape) === 'circle' ? - 'heracles:textures/gui/quest_backgrounds/circles.png' : - undefined, + icon_background: iconBackground, subtitle: questSubtitle ? { text: questSubtitle From 50ad1bbffc8caaa763717f513365501787ee1f7d Mon Sep 17 00:00:00 2001 From: Dietrich Friday Date: Sat, 4 Nov 2023 09:46:24 +0900 Subject: [PATCH 2/4] Fix whitespacing issues --- odysseus/convertFtbQuests.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/odysseus/convertFtbQuests.ts b/odysseus/convertFtbQuests.ts index 1986146..fe3b557 100644 --- a/odysseus/convertFtbQuests.ts +++ b/odysseus/convertFtbQuests.ts @@ -385,15 +385,15 @@ function truncateLong(value: Long | undefined) { function iconBackgroundTexture(iconBackground: QuestShape | undefined) { switch (iconBackground) { - case 'circle': { return 'heracles:textures/gui/quest_backgrounds/circles.png' } - case 'square': { return 'heracles:textures/gui/quest_backgrounds/squares.png' } + case 'circle': { return 'heracles:textures/gui/quest_backgrounds/circles.png' } + case 'square': { return 'heracles:textures/gui/quest_backgrounds/squares.png' } case 'rsquare': { return 'heracles:textures/gui/quest_backgrounds/rsquares.png' } case 'diamond': { return 'heracles:textures/gui/quest_backgrounds/diamonds.png' } - case 'pentagon':{ return 'heracles:textures/gui/quest_backgrounds/pentagons.png' } + case 'pentagon': { return 'heracles:textures/gui/quest_backgrounds/pentagons.png' } case 'hexagon': { return 'heracles:textures/gui/quest_backgrounds/hexagons.png' } case 'octagon': { return 'heracles:textures/gui/quest_backgrounds/octagons.png' } - case 'gear': { return 'heracles:textures/gui/quest_backgrounds/gears.png' } - case 'heart': { return 'heracles:textures/gui/quest_backgrounds/hearts.png' } + case 'gear': { return 'heracles:textures/gui/quest_backgrounds/gears.png' } + case 'heart': { return 'heracles:textures/gui/quest_backgrounds/hearts.png' } case undefined: { return undefined } } } From 9072db1d45c3abc1d8b08e3fc66bce21123c097e Mon Sep 17 00:00:00 2001 From: Dietrich Friday Date: Sat, 4 Nov 2023 10:10:27 +0900 Subject: [PATCH 3/4] Type of `icon_background` now `ResourceLocation` --- odysseus/HeraclesQuest.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odysseus/HeraclesQuest.ts b/odysseus/HeraclesQuest.ts index 0c2908e..5e41fb3 100644 --- a/odysseus/HeraclesQuest.ts +++ b/odysseus/HeraclesQuest.ts @@ -253,7 +253,7 @@ export type HeraclesQuestReward = HeraclesQuestElement & ({ export type HeraclesQuest = { display?: { icon?: HeraclesQuestIcon; - icon_background?: string; + icon_background?: ResourceLocation; title?: Component; subtitle?: Component; description?: string[]; From 6fbf2ce8e624fe87c4c93f4a7cf99245be8765aa Mon Sep 17 00:00:00 2001 From: Dietrich Friday Date: Sat, 4 Nov 2023 15:20:59 +0900 Subject: [PATCH 4/4] Replaced switch statement with a single line. --- odysseus/convertFtbQuests.ts | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/odysseus/convertFtbQuests.ts b/odysseus/convertFtbQuests.ts index fe3b557..3fb2409 100644 --- a/odysseus/convertFtbQuests.ts +++ b/odysseus/convertFtbQuests.ts @@ -383,19 +383,8 @@ function truncateLong(value: Long | undefined) { return Number(value) } -function iconBackgroundTexture(iconBackground: QuestShape | undefined) { - switch (iconBackground) { - case 'circle': { return 'heracles:textures/gui/quest_backgrounds/circles.png' } - case 'square': { return 'heracles:textures/gui/quest_backgrounds/squares.png' } - case 'rsquare': { return 'heracles:textures/gui/quest_backgrounds/rsquares.png' } - case 'diamond': { return 'heracles:textures/gui/quest_backgrounds/diamonds.png' } - case 'pentagon': { return 'heracles:textures/gui/quest_backgrounds/pentagons.png' } - case 'hexagon': { return 'heracles:textures/gui/quest_backgrounds/hexagons.png' } - case 'octagon': { return 'heracles:textures/gui/quest_backgrounds/octagons.png' } - case 'gear': { return 'heracles:textures/gui/quest_backgrounds/gears.png' } - case 'heart': { return 'heracles:textures/gui/quest_backgrounds/hearts.png' } - case undefined: { return undefined } - } +function iconBackgroundTexture(iconBackground: QuestShape | undefined): ResourceLocation | undefined { + return iconBackground === undefined ? undefined : `heracles:textures/gui/quest_backgrounds/${iconBackground}s.png` } export const convertFtbQuests = async (input: QuestInputFileSystem, output: QuestOutputFileSystem) => {