Skip to content

Commit

Permalink
Preserve FTBQ quest icon background shape choices (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
SubordinalBlue authored Nov 4, 2023
1 parent f860d45 commit c7f53fb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 1 addition & 2 deletions odysseus/HeraclesQuest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?: ResourceLocation;
title?: Component;
subtitle?: Component;
description?: string[];
Expand Down
12 changes: 8 additions & 4 deletions odysseus/convertFtbQuests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T extends string> = `ftbquests:${T}` | T;

Expand Down Expand Up @@ -383,6 +383,10 @@ function truncateLong(value: Long | undefined) {
return Number(value)
}

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) => {
const readSNbtFile = async (name: string) =>
parseStringifiedNbt(await input.readFile(name), name);
Expand Down Expand Up @@ -484,6 +488,8 @@ export const convertFtbQuests = async (input: QuestInputFileSystem, output: Ques
hidden = "IN_PROGRESS";
}

const iconBackground = iconBackgroundTexture(quest.shape ?? chapter.default_quest_shape ?? questFile.default_quest_shape)

const heraclesQuest: HeraclesQuest = {
settings: {
hidden
Expand Down Expand Up @@ -519,9 +525,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
Expand Down

0 comments on commit c7f53fb

Please sign in to comment.