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