mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
.
This commit is contained in:
parent
49adeed8c5
commit
83709e334d
8 changed files with 63 additions and 17 deletions
|
|
@ -360,7 +360,8 @@
|
|||
"currentCountdownMax": "Max: {value}",
|
||||
"category": "Category",
|
||||
"type": "Type",
|
||||
"defaultOwnershipTooltip": "The default player ownership of countdowns"
|
||||
"defaultOwnershipTooltip": "The default player ownership of countdowns",
|
||||
"hideNewCountdowns": "Hide New Countdowns"
|
||||
},
|
||||
"DaggerheartMenu": {
|
||||
"title": "GM Tools",
|
||||
|
|
@ -2473,7 +2474,8 @@
|
|||
},
|
||||
"Countdowns": {
|
||||
"title": "Countdowns",
|
||||
"toggleIconMode": "Toggle Icon Only"
|
||||
"toggleIconMode": "Toggle Icon Only",
|
||||
"noPlayerAccess": "This countdown isn't visible to any players"
|
||||
},
|
||||
"ItemBrowser": {
|
||||
"title": "Daggerheart Compendium Browser",
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio
|
|||
this.data = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns);
|
||||
this.editingCountdowns = new Set();
|
||||
this.currentEditCountdown = null;
|
||||
this.hideNewCountdowns = false;
|
||||
}
|
||||
|
||||
get title() {
|
||||
|
|
@ -45,6 +46,7 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio
|
|||
context.defaultOwnership = this.data.defaultOwnership;
|
||||
context.countdownBaseTypes = CONFIG.DH.GENERAL.countdownBaseTypes;
|
||||
context.countdownTypes = CONFIG.DH.GENERAL.countdownTypes;
|
||||
context.hideNewCountdowns = this.hideNewCountdowns;
|
||||
context.countdowns = Object.keys(this.data.countdowns).reduce((acc, key) => {
|
||||
const countdown = this.data.countdowns[key];
|
||||
acc[key] = {
|
||||
|
|
@ -107,7 +109,9 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio
|
|||
}
|
||||
|
||||
static async updateData(_event, _, formData) {
|
||||
this.updateSetting(foundry.utils.expandObject(formData.object));
|
||||
const { hideNewCountdowns, ...settingsData } = foundry.utils.expandObject(formData.object);
|
||||
this.hideNewCountdowns = hideNewCountdowns;
|
||||
this.updateSetting(settingsData);
|
||||
}
|
||||
|
||||
async gmSetSetting(data) {
|
||||
|
|
@ -124,7 +128,7 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio
|
|||
this.editingCountdowns.add(id);
|
||||
this.currentEditCountdown = id;
|
||||
this.updateSetting({
|
||||
[`countdowns.${id}`]: DhCountdown.defaultCountdown()
|
||||
[`countdowns.${id}`]: DhCountdown.defaultCountdown(null, this.hideNewCountdowns)
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -100,11 +100,12 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
|||
}
|
||||
return acc;
|
||||
}, []);
|
||||
const nonGmPlayers = game.users.filter(x => !x.isGM);
|
||||
acc[key] = {
|
||||
...countdown,
|
||||
editable: game.user.isGM || ownership === CONST.DOCUMENT_OWNERSHIP_LEVELS.OWNER,
|
||||
playerAccess:
|
||||
playersWithAccess.length !== game.users.filter(x => !x.isGM).length ? playersWithAccess : []
|
||||
playerAccess: playersWithAccess.length !== nonGmPlayers.length ? playersWithAccess : [],
|
||||
noPlayerAccess: nonGmPlayers.length && playersWithAccess.length === 0
|
||||
};
|
||||
return acc;
|
||||
}, {});
|
||||
|
|
@ -114,7 +115,9 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application
|
|||
|
||||
static #getPlayerOwnership(user, setting, countdown) {
|
||||
const playerOwnership = countdown.ownership[user.id];
|
||||
return playerOwnership === CONST.DOCUMENT_OWNERSHIP_LEVELS.INHERIT ? setting.defaultOwnership : playerOwnership;
|
||||
return playerOwnership === undefined || playerOwnership === CONST.DOCUMENT_OWNERSHIP_LEVELS.INHERIT
|
||||
? setting.defaultOwnership
|
||||
: playerOwnership;
|
||||
}
|
||||
|
||||
toggleCollapsedPosition = async (_, collapsed) => {
|
||||
|
|
|
|||
|
|
@ -181,11 +181,21 @@ export class DhCountdown extends foundry.abstract.DataModel {
|
|||
};
|
||||
}
|
||||
|
||||
static defaultCountdown(type) {
|
||||
static defaultCountdown(type, playerHidden) {
|
||||
const ownership = playerHidden
|
||||
? game.users.reduce((acc, user) => {
|
||||
if (!user.isGM) {
|
||||
acc[user.id] = CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE;
|
||||
}
|
||||
return acc;
|
||||
}, {})
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
type: type ?? CONFIG.DH.GENERAL.countdownBaseTypes.narrative.id,
|
||||
name: game.i18n.localize('DAGGERHEART.APPLICATIONS.Countdown.newCountdown'),
|
||||
img: 'icons/magic/time/hourglass-yellow-green.webp',
|
||||
ownership: ownership,
|
||||
progress: {
|
||||
current: 1,
|
||||
max: 1
|
||||
|
|
|
|||
|
|
@ -21,9 +21,21 @@
|
|||
|
||||
.header-tools {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 144px;
|
||||
grid-template-columns: 2fr 1fr 144px;
|
||||
gap: 8px;
|
||||
|
||||
.hide-tools {
|
||||
white-space: nowrap;
|
||||
flex-wrap: nowrap;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
input {
|
||||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.header-main-button {
|
||||
height: 32px;
|
||||
flex: 1;
|
||||
|
|
|
|||
|
|
@ -81,7 +81,6 @@
|
|||
}
|
||||
|
||||
.countdown-content {
|
||||
height: 44px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
|
|
@ -116,6 +115,13 @@
|
|||
content: '';
|
||||
}
|
||||
}
|
||||
|
||||
.countdown-no-access-container {
|
||||
width: 38px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,11 @@
|
|||
</header>
|
||||
|
||||
<div class="header-tools">
|
||||
<button class="header-main-button" data-action="addCountdown">{{localize "DAGGERHEART.APPLICATIONS.CountdownEdit.newCountdown"}}</button>
|
||||
<button class="header-main-button" data-action="addCountdown"><i class="fa-solid fa-plus"></i> {{localize "DAGGERHEART.APPLICATIONS.CountdownEdit.newCountdown"}}</button>
|
||||
<div class="hide-tools">
|
||||
<label>{{localize "DAGGERHEART.APPLICATIONS.CountdownEdit.hideNewCountdowns"}}</label>
|
||||
<input type="checkbox" name="hideNewCountdowns" {{checked hideNewCountdowns}} />
|
||||
</div>
|
||||
{{#if isGM}}
|
||||
<div class="default-ownership-tools">
|
||||
<i class="fa-solid fa-eye" data-tooltip="{{localize "DAGGERHEART.APPLICATIONS.CountdownEdit.defaultOwnershipTooltip"}}"></i>
|
||||
|
|
|
|||
|
|
@ -15,12 +15,17 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{#if (and @root.isGM (and (not ../iconOnly) (gt countdown.playerAccess.length 0)))}}
|
||||
<div class="countdown-access-container">
|
||||
{{#each countdown.playerAccess as |player|}}
|
||||
<div class="countdown-access" style="{{concat "background: " player.color.css ";"}}" data-tooltip="{{player.name}}"></div>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{#if (and @root.isGM (not ../iconOnly))}}
|
||||
{{#if (gt countdown.playerAccess.length 0)}}
|
||||
<div class="countdown-access-container">
|
||||
{{#each countdown.playerAccess as |player|}}
|
||||
<div class="countdown-access" style="{{concat "background: " player.color.css ";"}}" data-tooltip="{{player.name}}"></div>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/if}}
|
||||
{{#if countdown.noPlayerAccess}}
|
||||
<div class="countdown-no-access-container"><i class="fa-solid fa-eye-slash" data-tooltip="{{localize "DAGGERHEART.UI.Countdowns.noPlayerAccess"}}"></i></div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/each}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue