Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve FTBQ quest icon background shape choices #25

Merged
merged 6 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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?: string;
title?: Component;
subtitle?: Component;
description?: string[];
Expand Down
23 changes: 19 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 @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down