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 @@ -