This commit is contained in:
WBHarry 2025-09-14 23:32:53 +02:00
parent 3c8116c4dc
commit dcd42656f0
9 changed files with 135 additions and 15 deletions

View file

@ -2472,7 +2472,7 @@
},
"Countdowns": {
"title": "Countdowns",
"minimize": "Minimize"
"toggleIconMode": "Toggle Icon Only"
},
"ItemBrowser": {
"title": "Daggerheart Compendium Browser",
@ -2581,7 +2581,8 @@
"subclassesAlreadyPresent": "You already have a class and multiclass subclass",
"noDiceSystem": "Your selected dice {system} does not have a {faces} dice",
"gmMenuRefresh": "You refreshed all actions and resources {types}",
"subclassAlreadyLinked": "{name} is already a subclass in the class {class}. Remove it from there if you want it to be a subclass to this class."
"subclassAlreadyLinked": "{name} is already a subclass in the class {class}. Remove it from there if you want it to be a subclass to this class.",
"gmRequired": "This action requires an online GM"
},
"Sidebar": {
"daggerheartMenu": {

View file

@ -1,10 +1,49 @@
export default class DhSidebar extends Sidebar {
/** @override */
static TABS = {
...super.TABS,
chat: {
documentName: 'ChatMessage'
},
combat: {
documentName: 'Combat'
},
scenes: {
documentName: 'Scene',
gmOnly: true
},
actors: {
documentName: 'Actor'
},
items: {
documentName: 'Item'
},
journal: {
documentName: 'JournalEntry',
tooltip: 'SIDEBAR.TabJournal'
},
tables: {
documentName: 'RollTable'
},
cards: {
documentName: 'Cards'
},
macros: {
documentName: 'Macro'
},
playlists: {
documentName: 'Playlist'
},
compendium: {
tooltip: 'SIDEBAR.TabCompendium',
icon: 'fa-solid fa-book-atlas'
},
daggerheartMenu: {
tooltip: 'DAGGERHEART.UI.Sidebar.daggerheartMenu.title',
img: 'systems/daggerheart/assets/logos/FoundryBorneLogoWhite.svg'
},
settings: {
tooltip: 'SIDEBAR.TabSettings',
icon: 'fa-solid fa-gears'
}
};

View file

@ -39,6 +39,7 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio
async _prepareContext(_options) {
const context = await super._prepareContext(_options);
context.isGM = game.user.isGM;
context.ownershipDefaultOptions = CONFIG.DH.GENERAL.basicOwnershiplevels;
context.defaultOwnership = this.data.defaultOwnership;
context.countdownBaseTypes = CONFIG.DH.GENERAL.countdownBaseTypes;
@ -61,7 +62,25 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio
return context;
}
canPerformEdit() {
if (game.user.isGM) return true;
const noGM = !game.users.find(x => x.isGM && x.active);
if (noGM) {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.gmRequired'));
return false;
}
return true;
}
async updateSetting(update) {
const noGM = !game.users.find(x => x.isGM && x.active);
if (noGM) {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.gmRequired'));
return;
}
await this.data.updateSource(update);
await emitAsGM(GMUpdateEvent.UpdateCountdowns, this.gmSetSetting.bind(this.data), this.data, null, {
refreshType: RefreshType.Countdown

View file

@ -31,6 +31,7 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
minimizable: false
},
actions: {
toggleViewMode: DhCountdowns.#toggleViewMode,
decreaseCountdown: (_, target) => this.editCountdown(false, target),
increaseCountdown: (_, target) => this.editCountdown(true, target)
},
@ -60,11 +61,18 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
/**@inheritdoc */
async _renderFrame(options) {
const frame = await super._renderFrame(options);
const iconOnly =
game.user.getFlag(CONFIG.DH.id, CONFIG.DH.FLAGS.userFlags.countdownMode) ===
CONFIG.DH.GENERAL.countdownAppMode.iconOnly;
if (iconOnly) frame.classList.add('icon-only');
else frame.classList.remove('icon-only');
const header = frame.querySelector('.window-header');
header.querySelector('button[data-action="close"]').remove();
const minimizeTooltip = game.i18n.localize('DAGGERHEART.UI.Countdowns.minimize');
const minimizeButton = `<a class="header-control" data-tooltip="${minimizeTooltip}" aria-label="${minimizeTooltip}" data-action="minimize"><i class="fa-solid fa-down-left-and-up-right-to-center"></i></a>`;
const minimizeTooltip = game.i18n.localize('DAGGERHEART.UI.Countdowns.toggleIconMode');
const minimizeButton = `<a class="header-control" data-tooltip="${minimizeTooltip}" aria-label="${minimizeTooltip}" data-action="toggleViewMode"><i class="fa-solid fa-down-left-and-up-right-to-center"></i></a>`;
header.insertAdjacentHTML('beforeEnd', minimizeButton);
return frame;
@ -74,6 +82,9 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
async _prepareContext(options) {
const context = await super._prepareContext(options);
context.sidebarCollapsed = this.sidebarCollapsed;
context.iconOnly =
game.user.getFlag(CONFIG.DH.id, CONFIG.DH.FLAGS.userFlags.countdownMode) ===
CONFIG.DH.GENERAL.countdownAppMode.iconOnly;
const setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns);
context.countdowns = Object.keys(setting.countdowns).reduce((acc, key) => {
@ -105,7 +116,32 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
if (refreshType === RefreshType.Countdown) this.render();
};
canPerformEdit() {
if (game.user.isGM) return true;
const noGM = !game.users.find(x => x.isGM && x.active);
if (noGM) {
ui.notifications.warn(game.i18n.localize('DAGGERHEART.UI.Notifications.gmRequired'));
return false;
}
return true;
}
static async #toggleViewMode() {
const currentMode = game.user.getFlag(CONFIG.DH.id, CONFIG.DH.FLAGS.userFlags.countdownMode);
const appMode = CONFIG.DH.GENERAL.countdownAppMode;
const newMode = currentMode === appMode.textIcon ? appMode.iconOnly : appMode.textIcon;
await game.user.setFlag(CONFIG.DH.id, CONFIG.DH.FLAGS.userFlags.countdownMode, newMode);
if (newMode === appMode.iconOnly) this.element.classList.add('icon-only');
else this.element.classList.remove('icon-only');
this.render();
}
static async editCountdown(increase, target) {
if (!this.canPerformEdit()) return;
const settings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns);
const countdown = settings.countdowns[target.id];
const newCurrent = increase

View file

@ -11,5 +11,6 @@ export const encounterCountdown = {
export const itemAttachmentSource = 'attachmentSource';
export const userFlags = {
welcomeMessage: 'welcome-message'
welcomeMessage: 'welcome-message',
countdownMode: 'countdown-mode'
};

View file

@ -672,3 +672,8 @@ export const countdownBaseTypes = {
name: 'DAGGERHEART.APPLICATIONS.Countdown.types.encounter'
}
};
export const countdownAppMode = {
textIcon: 'text-icon',
iconOnly: 'icon-only'
};

View file

@ -22,6 +22,11 @@
right: 364px;
}
&.icon-only {
width: 180px;
min-width: 180px;
}
.window-header {
cursor: default;
border-bottom: 0;
@ -40,6 +45,18 @@
display: flex;
gap: 16px;
&.icon-only {
gap: 8px;
.countdown-content {
justify-content: center;
.countdown-tools {
gap: 8px;
}
}
}
img {
width: 44px;
height: 44px;

View file

@ -4,12 +4,14 @@
<div class="header-tools">
<button class="header-main-button" data-action="addCountdown">{{localize "DAGGERHEART.APPLICATIONS.CountdownEdit.newCountdown"}}</button>
<div class="default-ownership-tools">
<i class="fa-solid fa-eye" data-tooltip={{localize "DAGGERHEART.APPLICATIONS.CountdownEdit.defaultOwnershipTooltip"}}></i>
<select name="defaultOwnership">
{{selectOptions ownershipDefaultOptions selected=defaultOwnership labelAttr="label" valueAttr="value" localize=true}}
</select>
</div>
{{#if isGM}}
<div class="default-ownership-tools">
<i class="fa-solid fa-eye" data-tooltip="{{localize "DAGGERHEART.APPLICATIONS.CountdownEdit.defaultOwnershipTooltip"}}"></i>
<select name="defaultOwnership">
{{selectOptions ownershipDefaultOptions selected=defaultOwnership labelAttr="label" valueAttr="value" localize=true}}
</select>
</div>
{{/if}}
</div>
<div class="edit-content">

View file

@ -1,10 +1,10 @@
<div>
<div class="countdowns-container">
{{#each countdowns as | countdown id |}}
<div class="countdown-container">
<img src="{{countdown.img}}" />
<div class="countdown-container {{#if ../iconOnly}}icon-only{{/if}}">
<img src="{{countdown.img}}" {{#if ../iconOnly}}data-tooltip="{{countdown.name}}"{{/if}}/>
<div class="countdown-content">
<label>{{countdown.name}}</label>
{{#unless ../iconOnly}}<label>{{countdown.name}}</label>{{/unless}}
<div class="countdown-tools">
{{#if countdown.editable}}<a data-action="decreaseCountdown" id="{{id}}"><i class="fa-solid fa-minus"></i></a>{{/if}}
<div class="progress-tag">