diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ee1d3e99..0ab08b165 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## In progress - Add Starforged setting-truths dialog([#178](https://github.com/ben/foundry-ironsworn/pull/178)) +- Add Starforged character sheet ([#179](https://github.com/ben/foundry-ironsworn/pull/179)) ## 1.9.0 diff --git a/src/index.ts b/src/index.ts index f95280528..9e15b4ece 100644 --- a/src/index.ts +++ b/src/index.ts @@ -7,6 +7,7 @@ import { IronswornActor } from './module/actor/actor' import { IronswornCharacterSheet } from './module/actor/sheets/charactersheet' import { IronswornCharacterSheetV2 } from './module/actor/sheets/charactersheet-v2' import { IronswornCompactCharacterSheet } from './module/actor/sheets/compactsheet' +import { StarforgedCharacterSheet } from './module/actor/sheets/sf-charactersheet' import { IronswornSharedSheet } from './module/actor/sheets/sharedsheet' import { IronswornSharedSheetV2 } from './module/actor/sheets/sharedsheet-v2' import { IronswornSiteSheet } from './module/actor/sheets/sitesheet' @@ -65,6 +66,12 @@ Hooks.once('init', async () => { types: ['character'], makeDefault: true, }) + if (CONFIG.IRONSWORN.IronswornSettings.starforgedBeta) { + Actors.registerSheet('ironsworn', StarforgedCharacterSheet, { + label: 'Starforged character sheet', + types: ['character'], + }) + } Actors.registerSheet('ironsworn', IronswornCompactCharacterSheet, { label: 'Compact sheet', types: ['character'], diff --git a/src/module/actor/sheets/sf-charactersheet.ts b/src/module/actor/sheets/sf-charactersheet.ts new file mode 100644 index 000000000..d3870d507 --- /dev/null +++ b/src/module/actor/sheets/sf-charactersheet.ts @@ -0,0 +1,72 @@ +import { IronswornSettings } from '../../helpers/settings' +import { IronswornVueActorSheet } from '../vueactorsheet' +// import { CharacterMoveSheet } from './charactermovesheet' + +export class StarforgedCharacterSheet extends IronswornVueActorSheet { + static get defaultOptions() { + return mergeObject(super.defaultOptions, { + classes: ['ironsworn', 'sheet', 'actor', `theme-${IronswornSettings.theme}`], + width: 630, + height: 800, + left: 50, + submitOnClose: true, + submitOnChange: true, + template: 'systems/foundry-ironsworn/templates/actor/sf-character.hbs', + }) + } + + getData() { + let data: any = super.getData() + + // Allow every itemtype to add data to the actorsheet + for (const itemType of CONFIG.IRONSWORN.itemClasses) { + data = itemType.getActorSheetData(data, this) + } + + data.actor = this.actor.toObject(false) + data.data = data.actor.data + + return data + } + + // render(...args) { + // if (this._state <= Application.RENDER_STATES.NONE) this._openMoveSheet() + // return super.render(...args) + // } + + // close(...args) { + // this.actor.moveSheet?.close(...args) + // return super.close(...args) + // } + + _getHeaderButtons() { + return [ + { + class: 'ironsworn-toggle-edit-mode', + label: 'Edit', + icon: 'fas fa-edit', + onclick: (e) => this._toggleEditMode(e), + }, + { + class: 'ironsworn-open-move-sheet', + label: 'Moves', + icon: 'fas fa-directions', + onclick: console.log // (e) => this._openMoveSheet(e), + }, + ...super._getHeaderButtons(), + ] + } + + _toggleEditMode(_e: JQuery.ClickEvent) { + const currentValue = this.actor.getFlag('foundry-ironsworn', 'edit-mode') + this.actor.setFlag('foundry-ironsworn', 'edit-mode', !currentValue) + } + + // _openMoveSheet(_e?: JQuery.ClickEvent) { + // if (this.actor.moveSheet) { + // this.actor.moveSheet.render(true, { focus: true }) + // } else { + // new CharacterMoveSheet(this.actor).render(true) + // } + // } +} diff --git a/src/module/features/changelog.ts b/src/module/features/changelog.ts index ebaa4c316..2917245ab 100644 --- a/src/module/features/changelog.ts +++ b/src/module/features/changelog.ts @@ -85,7 +85,7 @@ const ACTOR_TYPE_HANDLERS: { [key: string]: ActorTypeHandler } = { } for (const debility of ['corrupted', 'cursed', 'encumbered', 'maimed', 'shaken', 'tormented', 'unprepared', 'wounded']) { - const newValue = get(data.data.debility, debility) + const newValue = get(data.data?.debility, debility) if (newValue !== undefined) { const oldValue = characterData.data.debility[debility] if (oldValue === newValue) continue diff --git a/src/module/helpers/settings.ts b/src/module/helpers/settings.ts index 6b2b7b78b..3e3035f68 100644 --- a/src/module/helpers/settings.ts +++ b/src/module/helpers/settings.ts @@ -64,6 +64,10 @@ export class IronswornSettings { return game.settings.get('foundry-ironsworn', 'theme') as string } + static get starforgedBeta(): boolean { + return game.settings.get('foundry-ironsworn', 'starforged-beta') as boolean + } + static get logCharacterChanges(): boolean { return game.settings.get('foundry-ironsworn', 'log-changes') as boolean } diff --git a/src/module/vue/components/document-img.vue b/src/module/vue/components/document-img.vue index 7665e2f1c..193f1b273 100644 --- a/src/module/vue/components/document-img.vue +++ b/src/module/vue/components/document-img.vue @@ -2,7 +2,7 @@ -

+ -

+ diff --git a/src/module/vue/sf-charactersheet.vue b/src/module/vue/sf-charactersheet.vue new file mode 100644 index 000000000..2bc7d3547 --- /dev/null +++ b/src/module/vue/sf-charactersheet.vue @@ -0,0 +1,145 @@ + + + + + diff --git a/system/lang/en.json b/system/lang/en.json index 1f9f898fe..432d5cfa8 100644 --- a/system/lang/en.json +++ b/system/lang/en.json @@ -40,6 +40,9 @@ "Asset": "Asset", "Assets": "Assets", "Bonds": "Bonds", + "Legacies": "Legacies", + "Clocks": "Clocks", + "Scenes": "Scenes", "Debilities": "Debilities", "Conditions": "Conditions", "Banes": "Banes", @@ -82,6 +85,9 @@ "Reset": "Reset", "Max": "Max", "Name": "Name", + "Pronouns": "Pronouns", + "Callsign": "Callsign", + "Characteristics": "Characteristics", "Summary": "Summary", "Description": "Description", "Fields": "Fields", diff --git a/system/template.json b/system/template.json index 27af232be..c2f7cae90 100644 --- a/system/template.json +++ b/system/template.json @@ -7,6 +7,8 @@ ], "character": { "biography": "", + "pronouns": "", + "callsign": "", "edge": 1, "heart": 1, "iron": 1, @@ -17,6 +19,11 @@ "supply": 5, "experience": 0, "momentum": 2, + "legacies": { + "quests": 0, + "bonds": 0, + "discoveries": 0 + }, "debility": { "corrupted": false, "cursed": false, diff --git a/system/templates/actor/sf-character.hbs b/system/templates/actor/sf-character.hbs new file mode 100644 index 000000000..4b92b2bc1 --- /dev/null +++ b/system/templates/actor/sf-character.hbs @@ -0,0 +1,5 @@ +
+ + Loading… + +