mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-13 12:11:07 +01:00
.
This commit is contained in:
parent
3c8116c4dc
commit
dcd42656f0
9 changed files with 135 additions and 15 deletions
|
|
@ -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'
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue