diff --git a/daggerheart.mjs b/daggerheart.mjs index 651736a4..f497b766 100644 --- a/daggerheart.mjs +++ b/daggerheart.mjs @@ -167,12 +167,14 @@ Hooks.on('setup', () => { }); Hooks.on('ready', async () => { + const appearanceSettings = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.appearance); ui.resources = new CONFIG.ui.resources(); - if (game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.appearance).displayFear !== 'hide') - ui.resources.render({ force: true }); + if (appearanceSettings.displayFear !== 'hide') ui.resources.render({ force: true }); - ui.countdowns = new CONFIG.ui.countdowns(); - ui.countdowns.render({ force: true }); + if (appearanceSettings.displayCountdownUI) { + ui.countdowns = new CONFIG.ui.countdowns(); + ui.countdowns.render({ force: true }); + } if (!(ui.compendiumBrowser instanceof applications.ui.ItemBrowser)) ui.compendiumBrowser = new applications.ui.ItemBrowser(); diff --git a/lang/en.json b/lang/en.json index b63a3aac..14faa9d8 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2219,6 +2219,9 @@ "displayFear": { "label": "Display Fear" }, + "displayCountdownUI": { + "label": "Display Countdown UI" + }, "showGenericStatusEffects": { "label": "Show Foundry Status Effects" }, @@ -2344,6 +2347,9 @@ }, "Homebrew": { "newDowntimeMove": "Downtime Move", + "downtimeMove": "Downtime Move", + "armorFeature": "Armor Feature", + "weaponFeature": "Weapon Feaure", "newFeature": "New ItemFeature", "downtimeMoves": "Downtime Moves", "itemFeatures": "Item Features", diff --git a/module/applications/hud/tokenHUD.mjs b/module/applications/hud/tokenHUD.mjs index bd846da5..a5fd719f 100644 --- a/module/applications/hud/tokenHUD.mjs +++ b/module/applications/hud/tokenHUD.mjs @@ -89,7 +89,7 @@ export default class DHTokenHUD extends foundry.applications.hud.TokenHUD { setTimeout(() => token.document.delete(), animationDuration); } } else { - const activeScene = game.scenes.find(x => x.active); + const activeScene = game.scenes.find(x => x.id === game.user.viewedScene); const partyTokenData = []; for (let member of this.actor.system.partyMembers) { const data = await member.getTokenDocument(); diff --git a/module/applications/settings/homebrewSettings.mjs b/module/applications/settings/homebrewSettings.mjs index e880f7ee..8e566106 100644 --- a/module/applications/settings/homebrewSettings.mjs +++ b/module/applications/settings/homebrewSettings.mjs @@ -147,7 +147,14 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli const path = isDowntime ? `restMoves.${type}.moves.${id}` : `itemFeatures.${type}.${id}`; const featureBase = isDowntime ? this.settings.restMoves[type].moves[id] : this.settings.itemFeatures[type][id]; + const configTitle = isDowntime + ? game.i18n.localize('DAGGERHEART.SETTINGS.Homebrew.downtimeMove') + : type === 'armorFeatures' + ? game.i18n.localize('DAGGERHEART.SETTINGS.Homebrew.armorFeature') + : game.i18n.localize('DAGGERHEART.SETTINGS.Homebrew.weaponFeature'); + const editedBase = await game.system.api.applications.sheetConfigs.SettingFeatureConfig.configure( + configTitle, featureBase, path, this.settings, diff --git a/module/applications/sheets-configs/setting-feature-config.mjs b/module/applications/sheets-configs/setting-feature-config.mjs index e775f93d..832954ad 100644 --- a/module/applications/sheets-configs/setting-feature-config.mjs +++ b/module/applications/sheets-configs/setting-feature-config.mjs @@ -4,9 +4,10 @@ import DHActionConfig from './action-config.mjs'; const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api; export default class SettingFeatureConfig extends HandlebarsApplicationMixin(ApplicationV2) { - constructor(move, movePath, settings, optionalParts, options) { + constructor(configTitle, move, movePath, settings, optionalParts, options) { super(options); + this.configTitle = configTitle; this.move = move; this.movePath = movePath; @@ -19,7 +20,7 @@ export default class SettingFeatureConfig extends HandlebarsApplicationMixin(App } get title() { - return game.i18n.localize('DAGGERHEART.SETTINGS.Homebrew.downtimeMoves'); + return this.configTitle; } static DEFAULT_OPTIONS = { @@ -200,9 +201,9 @@ export default class SettingFeatureConfig extends HandlebarsApplicationMixin(App if (!options.submitted) this.move = null; } - static async configure(move, movePath, settings, optionalParts, options = {}) { + static async configure(configTitle, move, movePath, settings, optionalParts, options = {}) { return new Promise(resolve => { - const app = new this(move, movePath, settings, optionalParts, options); + const app = new this(configTitle, move, movePath, settings, optionalParts, options); app.addEventListener('close', () => resolve(app.move), { once: true }); app.render({ force: true }); }); diff --git a/module/applications/sheets/items/class.mjs b/module/applications/sheets/items/class.mjs index b88e6ca3..e7e00c42 100644 --- a/module/applications/sheets/items/class.mjs +++ b/module/applications/sheets/items/class.mjs @@ -203,10 +203,10 @@ export default class ClassSheet extends DHBaseItemSheet { if (target === 'subclasses') { const subclass = await foundry.utils.fromUuid(uuid); - await subclass.update({ 'system.linkedClass': null }); + await subclass?.update({ 'system.linkedClass': null }); } - await this.document.update({ [`system.${target}`]: prop.filter(i => i.uuid !== uuid).map(x => x.uuid) }); + await this.document.update({ [`system.${target}`]: prop.filter(i => i && i.uuid !== uuid).map(x => x.uuid) }); } /** diff --git a/module/applications/ui/countdowns.mjs b/module/applications/ui/countdowns.mjs index 3d0b32ae..b7d19ede 100644 --- a/module/applications/ui/countdowns.mjs +++ b/module/applications/ui/countdowns.mjs @@ -81,6 +81,13 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application return frame; } + /**@inheritdoc */ + async _onFirstRender(context, options) { + await super._onFirstRender(context, options); + + this.toggleCollapsedPosition(undefined, !ui.sidebar.expanded); + } + /** @override */ async _prepareContext(options) { const context = await super._prepareContext(options); @@ -124,6 +131,8 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application } toggleCollapsedPosition = async (_, collapsed) => { + if (!this.element) return; + this.sidebarCollapsed = collapsed; if (!collapsed) this.element.classList.add('expanded'); else this.element.classList.remove('expanded'); @@ -188,10 +197,13 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application Hooks.on(socketEvent.Refresh, this.cooldownRefresh.bind()); } - close(options) { + async close(options) { + /* Opt out of Foundry's standard behavior of closing all application windows marked as UI when Escape is pressed */ + if (options.closeKey) return; + Hooks.off('collapseSidebar', this.toggleCollapsedPosition); Hooks.off(socketEvent.Refresh, this.cooldownRefresh); - super.close(options); + return super.close(options); } static async updateCountdowns(progressType) { diff --git a/module/data/settings/Appearance.mjs b/module/data/settings/Appearance.mjs index 47909b2c..7a5c730a 100644 --- a/module/data/settings/Appearance.mjs +++ b/module/data/settings/Appearance.mjs @@ -24,6 +24,7 @@ export default class DhAppearance extends foundry.abstract.DataModel { choices: CONFIG.DH.GENERAL.fearDisplay, initial: CONFIG.DH.GENERAL.fearDisplay.token.value }), + displayCountdownUI: new BooleanField({ initial: true }), diceSoNice: new SchemaField({ hope: diceStyle({ fg: '#ffffff', bg: '#ffe760', outline: '#000000', edge: '#ffffff' }), fear: diceStyle({ fg: '#000000', bg: '#0032b1', outline: '#ffffff', edge: '#000000' }), diff --git a/module/systemRegistration/migrations.mjs b/module/systemRegistration/migrations.mjs index 98a9a7e6..e3777a94 100644 --- a/module/systemRegistration/migrations.mjs +++ b/module/systemRegistration/migrations.mjs @@ -1,3 +1,5 @@ +import { RefreshType, socketEvent } from './socket.mjs'; + export async function runMigrations() { let lastMigrationVersion = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.LastMigrationVersion); if (!lastMigrationVersion) lastMigrationVersion = game.system.version; @@ -158,7 +160,8 @@ export async function runMigrations() { ...countdown, type: type, ownership: Object.keys(countdown.ownership.players).reduce((acc, key) => { - acc[key] = countdown.ownership.players[key].type; + acc[key] = + countdown.ownership.players[key].type === 1 ? 2 : countdown.ownership.players[key].type; return acc; }, {}), progress: { @@ -179,6 +182,12 @@ export async function runMigrations() { }); await game.settings.set(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns, countdownSettings); + game.socket.emit(`system.${CONFIG.DH.id}`, { + action: socketEvent.Refresh, + data: { refreshType: RefreshType.Countdown } + }); + Hooks.callAll(socketEvent.Refresh, { refreshType: RefreshType.Countdown }); + lastMigrationVersion = '1.2.0'; } diff --git a/styles/less/ui/countdown/countdown.less b/styles/less/ui/countdown/countdown.less index 9fa42ec7..0f91bad4 100644 --- a/styles/less/ui/countdown/countdown.less +++ b/styles/less/ui/countdown/countdown.less @@ -18,7 +18,7 @@ box-shadow: none; width: 300px; top: 16px; - right: 64px; + right: calc(64px * var(--ui-scale)); transition: right ease 250ms, opacity var(--ui-fade-duration) ease, @@ -29,7 +29,7 @@ } &.expanded { - right: 364px; + right: calc(364px * var(--ui-scale)); } &.icon-only { diff --git a/system.json b/system.json index a16b3562..a7c79226 100644 --- a/system.json +++ b/system.json @@ -2,7 +2,7 @@ "id": "daggerheart", "title": "Daggerheart", "description": "An unofficial implementation of the Daggerheart system", - "version": "1.2.0", + "version": "1.2.1", "compatibility": { "minimum": "13", "verified": "13.350", diff --git a/templates/settings/appearance-settings/main.hbs b/templates/settings/appearance-settings/main.hbs index fda6243b..75a7e634 100644 --- a/templates/settings/appearance-settings/main.hbs +++ b/templates/settings/appearance-settings/main.hbs @@ -8,6 +8,10 @@ value=setting.displayFear localize=true}} {{formGroup + fields.displayCountdownUI + value=setting.displayCountdownUI + localize=true}} + {{formGroup fields.showGenericStatusEffects value=setting.showGenericStatusEffects localize=true}} diff --git a/templates/sheets/items/class/features.hbs b/templates/sheets/items/class/features.hbs index 6ed449dc..ef940730 100644 --- a/templates/sheets/items/class/features.hbs +++ b/templates/sheets/items/class/features.hbs @@ -50,7 +50,7 @@ class='effect-control' data-action='removeItemFromCollection' data-target="subclasses" - data-uuid={{subclass.uuid}} + data-uuid="{{subclass.uuid}}" data-tooltip='{{localize "CONTROLS.CommonDelete"}}' >