diff --git a/lang/en.json b/lang/en.json index bb5c20ef..4afcd65c 100755 --- a/lang/en.json +++ b/lang/en.json @@ -328,19 +328,26 @@ }, "Countdown": { "addCountdown": "Add Countdown", + "loopingTypes": { + "noLooping": "No Looping", + "looping": "Looping", + "increasing": "Increasing", + "decreasing": "Decreasing" + }, "FIELDS": { "countdowns": { "element": { "name": { "label": "Name" }, "progress": { "current": { "label": "Current" }, + "looping": { "label": "Looping" }, "max": { "label": "Max" }, "type": { "label": { "label": "Label", "hint": "Used for custom" }, "value": { "label": "Value" } } }, - "type": { "label": "Countdown Type" } + "type": { "label": "Progression Type" } } } }, @@ -367,7 +374,9 @@ "currentCountdownValue": "Current: {value}", "currentCountdownMax": "Max: {value}", "category": "Category", - "type": "Type", + "progressionType": "Progression Type", + "decreasing": "Decreasing", + "looping": "Looping", "defaultOwnershipTooltip": "The default player ownership of countdowns", "hideNewCountdowns": "Hide New Countdowns" }, diff --git a/module/applications/sheets-configs/action-config.mjs b/module/applications/sheets-configs/action-config.mjs index 247e8345..81ade99b 100644 --- a/module/applications/sheets-configs/action-config.mjs +++ b/module/applications/sheets-configs/action-config.mjs @@ -267,4 +267,9 @@ export default class DHActionConfig extends DaggerheartSheet(ApplicationV2) { const id = event.target.closest('[data-effect-id]')?.dataset?.effectId; this.action.item.effects.get(id).sheet.render(true); } + + async close(options) { + this.tabGroups.primary = 'base'; + await super.close(options); + } } diff --git a/module/applications/ui/combatTracker.mjs b/module/applications/ui/combatTracker.mjs index b70f8c71..7b7d584a 100644 --- a/module/applications/ui/combatTracker.mjs +++ b/module/applications/ui/combatTracker.mjs @@ -136,7 +136,7 @@ export default class DhCombatTracker extends foundry.applications.sidebar.tabs.C if (this.viewed.turn !== toggleTurn) { const { updateCountdowns } = game.system.api.applications.ui.DhCountdowns; - await updateCountdowns(CONFIG.DH.GENERAL.countdownTypes.spotlight.id); + await updateCountdowns(CONFIG.DH.GENERAL.countdownProgressionTypes.spotlight.id); const autoPoints = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation).actionPoints; if (autoPoints) { diff --git a/module/applications/ui/countdownEdit.mjs b/module/applications/ui/countdownEdit.mjs index abaafb7e..5a9421d3 100644 --- a/module/applications/ui/countdownEdit.mjs +++ b/module/applications/ui/countdownEdit.mjs @@ -44,7 +44,8 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio context.ownershipDefaultOptions = CONFIG.DH.GENERAL.basicOwnershiplevels; context.defaultOwnership = this.data.defaultOwnership; context.countdownBaseTypes = CONFIG.DH.GENERAL.countdownBaseTypes; - context.countdownTypes = CONFIG.DH.GENERAL.countdownTypes; + context.countdownProgressionTypes = CONFIG.DH.GENERAL.countdownProgressionTypes; + context.countdownLoopingTypes = CONFIG.DH.GENERAL.countdownLoopingTypes; context.hideNewCountdowns = this.hideNewCountdowns; context.countdowns = Object.keys(this.data.countdowns).reduce((acc, key) => { const countdown = this.data.countdowns[key]; @@ -53,7 +54,9 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio typeName: game.i18n.localize(CONFIG.DH.GENERAL.countdownBaseTypes[countdown.type].label), progress: { ...countdown.progress, - typeName: game.i18n.localize(CONFIG.DH.GENERAL.countdownTypes[countdown.progress.type].label) + typeName: game.i18n.localize( + CONFIG.DH.GENERAL.countdownProgressionTypes[countdown.progress.type].label + ) }, editing: this.editingCountdowns.has(key) }; diff --git a/module/applications/ui/countdowns.mjs b/module/applications/ui/countdowns.mjs index 5631f246..fe0e2c09 100644 --- a/module/applications/ui/countdowns.mjs +++ b/module/applications/ui/countdowns.mjs @@ -33,6 +33,7 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application actions: { toggleViewMode: DhCountdowns.#toggleViewMode, editCountdowns: DhCountdowns.#editCountdowns, + loopCountdown: DhCountdowns.#loopCountdown, decreaseCountdown: (_, target) => this.editCountdown(false, target), increaseCountdown: (_, target) => this.editCountdown(true, target) }, @@ -121,7 +122,6 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application acc[key] = { ...countdown, editable: game.user.isGM || ownership === CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER, - playerAccess: playersWithAccess.length !== nonGmPlayers.length ? playersWithAccess : [], noPlayerAccess: nonGmPlayers.length && playersWithAccess.length === 0 }; return acc; @@ -176,6 +176,28 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application new game.system.api.applications.ui.CountdownEdit().render(true); } + static async #loopCountdown(_, target) { + if (!DhCountdowns.canPerformEdit()) return; + + const settings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns); + const countdown = settings.countdowns[target.id]; + const newMax = + countdown.progress.looping === CONFIG.DH.GENERAL.countdownLoopingTypes.increasing.id + ? countdown.progress.max + 1 + : countdown.progress.looping === CONFIG.DH.GENERAL.countdownLoopingTypes.decreasing.id + ? Math.max(countdown.progress.max - 1, 0) + : countdown.progress.max; + await settings.updateSource({ + [`countdowns.${target.id}.progress`]: { + current: newMax, + max: newMax + } + }); + await emitAsGM(GMUpdateEvent.UpdateCountdowns, DhCountdowns.gmSetSetting.bind(settings), settings, null, { + refreshType: RefreshType.Countdown + }); + } + static async editCountdown(increase, target) { if (!DhCountdowns.canPerformEdit()) return; diff --git a/module/config/generalConfig.mjs b/module/config/generalConfig.mjs index 9286c610..f6d864d0 100644 --- a/module/config/generalConfig.mjs +++ b/module/config/generalConfig.mjs @@ -611,7 +611,7 @@ export const abilityCosts = { resource: itemAbilityCosts.resource }; -export const countdownTypes = { +export const countdownProgressionTypes = { spotlight: { id: 'spotlight', label: 'DAGGERHEART.CONFIG.CountdownType.spotlight' @@ -681,6 +681,25 @@ export const countdownBaseTypes = { } }; +export const countdownLoopingTypes = { + noLooping: { + id: 'noLooping', + label: 'DAGGERHEART.APPLICATIONS.Countdown.loopingTypes.noLooping' + }, + looping: { + id: 'looping', + label: 'DAGGERHEART.APPLICATIONS.Countdown.loopingTypes.looping' + }, + increasing: { + id: 'increasing', + label: 'DAGGERHEART.APPLICATIONS.Countdown.loopingTypes.increasing' + }, + decreasing: { + id: 'decreasing', + label: 'DAGGERHEART.APPLICATIONS.Countdown.loopingTypes.decreasing' + } +}; + export const countdownAppMode = { textIcon: 'text-icon', iconOnly: 'icon-only' diff --git a/module/data/action/attackAction.mjs b/module/data/action/attackAction.mjs index 68afc23b..8f22ae83 100644 --- a/module/data/action/attackAction.mjs +++ b/module/data/action/attackAction.mjs @@ -38,7 +38,7 @@ export default class DHAttackAction extends DHDamageAction { const result = await super.use(event, options); const { updateCountdowns } = game.system.api.applications.ui.DhCountdowns; - await updateCountdowns(CONFIG.DH.GENERAL.countdownTypes.characterAttack.id); + await updateCountdowns(CONFIG.DH.GENERAL.countdownProgressionTypes.characterAttack.id); return result; } diff --git a/module/data/countdowns.mjs b/module/data/countdowns.mjs index 6db4cbeb..c288abb4 100644 --- a/module/data/countdowns.mjs +++ b/module/data/countdowns.mjs @@ -105,8 +105,8 @@ class DhOldCountdown extends foundry.abstract.DataModel { type: new fields.SchemaField({ value: new fields.StringField({ required: true, - choices: CONFIG.DH.GENERAL.countdownTypes, - initial: CONFIG.DH.GENERAL.countdownTypes.custom.id, + choices: CONFIG.DH.GENERAL.countdownProgressionTypes, + initial: CONFIG.DH.GENERAL.countdownProgressionTypes.custom.id, label: 'DAGGERHEART.GENERAL.type' }), label: new fields.StringField({ @@ -171,10 +171,16 @@ export class DhCountdown extends foundry.abstract.DataModel { initial: 1, label: 'DAGGERHEART.APPLICATIONS.Countdown.FIELDS.countdowns.element.progress.max.label' }), + looping: new fields.StringField({ + required: true, + choices: CONFIG.DH.GENERAL.countdownLoopingTypes, + initial: CONFIG.DH.GENERAL.countdownLoopingTypes.noLooping.id, + label: 'DAGGERHEART.APPLICATIONS.Countdown.FIELDS.countdowns.element.progress.looping.label' + }), type: new fields.StringField({ required: true, - choices: CONFIG.DH.GENERAL.countdownTypes, - initial: CONFIG.DH.GENERAL.countdownTypes.custom.id, + choices: CONFIG.DH.GENERAL.countdownProgressionTypes, + initial: CONFIG.DH.GENERAL.countdownProgressionTypes.custom.id, label: 'DAGGERHEART.APPLICATIONS.Countdown.FIELDS.countdowns.element.type.label' }) }) diff --git a/styles/less/ui/countdown/countdown-edit.less b/styles/less/ui/countdown/countdown-edit.less index 323ed5af..4099728b 100644 --- a/styles/less/ui/countdown/countdown-edit.less +++ b/styles/less/ui/countdown/countdown-edit.less @@ -63,58 +63,65 @@ scrollbar-width: thin; scrollbar-color: light-dark(@dark-blue, @golden) transparent; - .countdown-edit-container { - display: grid; - grid-template-columns: 48px 1fr 72px; - align-items: center; + .countdown-edit-outer-container { + display: flex; + flex-direction: column; + align-items: flex-start; gap: 8px; - img { - width: 52px; - height: 52px; - border-radius: 6px; - } - - .countdown-edit-text { - display: flex; - flex-direction: column; - justify-content: center; + .countdown-edit-container { + width: 100%; + display: grid; + grid-template-columns: 48px 1fr 72px; + align-items: center; gap: 8px; - .countdown-edit-subtext { + img { + width: 52px; + height: 52px; + border-radius: 6px; + } + + .countdown-edit-text { display: flex; - gap: 10px; + flex-direction: column; + justify-content: center; + gap: 8px; - .countdown-edit-sub-tag { - padding: 3px 5px; - font-size: var(--font-size-12); - font: @font-body; + .countdown-edit-subtext { + display: flex; + align-items: center; + gap: 10px; - background: light-dark(@dark-15, @beige-15); - border: 1px solid light-dark(@dark, @beige); - border-radius: 3px; + .countdown-edit-sub-tag { + padding: 3px 5px; + font-size: var(--font-size-12); + font: @font-body; + + background: light-dark(@dark-15, @beige-15); + border: 1px solid light-dark(@dark, @beige); + border-radius: 3px; + } + } + } + + .countdown-edit-tools { + display: flex; + gap: 8px; + + &.same-row { + margin-top: 17.5px; + } + + a { + font-size: 16px; } } } - - .countdown-edit-tools { - display: flex; - gap: 8px; - - &.same-row { - margin-top: 17.5px; - } - - a { - font-size: 16px; - } - } } - .countdown-edit-subrow { display: flex; - gap: 16px; - margin: 0 72px 0 56px; + gap: 8px; } .countdown-edit-input { @@ -124,11 +131,29 @@ align-items: flex-start; gap: 2px; + &.type-input { + min-width: 120px; + } + + &.looping-input { + min-width: 120px; + } + &.tiny { flex: 0; input { min-width: 2.5rem; } + + .checkbox { + width: 100%; + display: flex; + justify-content: center; + + input { + min-width: auto; + } + } } input, diff --git a/styles/less/ui/countdown/countdown.less b/styles/less/ui/countdown/countdown.less index 0f91bad4..d89a15ac 100644 --- a/styles/less/ui/countdown/countdown.less +++ b/styles/less/ui/countdown/countdown.less @@ -55,7 +55,7 @@ .countdown-container { display: flex; - justify-content: space-between; + width: 100%; &.icon-only { gap: 8px; @@ -72,6 +72,7 @@ } .countdown-main-container { + width: 100%; display: flex; align-items: center; gap: 16px; @@ -83,6 +84,7 @@ } .countdown-content { + flex: 1; display: flex; flex-direction: column; justify-content: space-between; @@ -90,7 +92,13 @@ .countdown-tools { display: flex; align-items: center; - gap: 16px; + justify-content: space-between; + + .countdown-tool-controls { + display: flex; + align-items: center; + gap: 16px; + } .progress-tag { border: 1px solid; @@ -98,32 +106,53 @@ padding: 2px 4px; background-color: light-dark(@beige, @dark-blue); } + + .countdown-tool-icons { + display: flex; + align-items: center; + gap: 8px; + + .looping-container { + position: relative; + border: 1px solid light-dark(white, white); + border-radius: 6px; + padding: 2px 4px; + + &.should-loop { + background: light-dark(@golden, @golden); + + .loop-marker { + color: light-dark(@dark-blue, @dark-blue); + } + } + + .direction-marker { + position: absolute; + font-size: 10px; + filter: drop-shadow(0 0 3px black); + top: -3px; + } + } + } } } } + /* Keep incase we want to reintroduce the player pips */ + // .countdown-access-container { + // display: grid; + // grid-template-columns: 1fr 1fr 1fr; + // grid-auto-rows: min-content; + // width: 38px; + // gap: 4px; - .countdown-access-container { - display: grid; - grid-template-columns: 1fr 1fr 1fr; - grid-auto-rows: min-content; - width: 38px; - gap: 4px; - - .countdown-access { - height: 10px; - width: 10px; - border-radius: 50%; - border: 1px solid light-dark(@dark-blue, @beige-80); - content: ''; - } - } - - .countdown-no-access-container { - width: 38px; - display: flex; - align-items: center; - justify-content: center; - } + // .countdown-access { + // height: 10px; + // width: 10px; + // border-radius: 50%; + // border: 1px solid light-dark(@dark-blue, @beige-80); + // content: ''; + // } + // } } } } diff --git a/templates/actionTypes/countdown.hbs b/templates/actionTypes/countdown.hbs index 1c2669b4..360b1172 100644 --- a/templates/actionTypes/countdown.hbs +++ b/templates/actionTypes/countdown.hbs @@ -14,6 +14,7 @@ {{formField ../fields.img value=countdown.img name=(concat "countdown." index ".img") label="DAGGERHEART.GENERAL.imagePath" localize=true}}