mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-15 13:11:08 +01:00
.
This commit is contained in:
parent
5a5e925e8b
commit
89b398c63b
3 changed files with 27 additions and 4 deletions
|
|
@ -9,6 +9,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
get title() {
|
get title() {
|
||||||
|
|
@ -62,6 +63,22 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @override */
|
||||||
|
async _postRender(_context, _options) {
|
||||||
|
if (this.currentEditCountdown) {
|
||||||
|
setTimeout(() => {
|
||||||
|
const input = this.element.querySelector(
|
||||||
|
`.countdown-edit-container[data-id="${this.currentEditCountdown}"] input`
|
||||||
|
);
|
||||||
|
if (input) {
|
||||||
|
input.focus();
|
||||||
|
input.selectionStart = input.value.length + 1;
|
||||||
|
this.currentEditCountdown = null;
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
canPerformEdit() {
|
canPerformEdit() {
|
||||||
if (game.user.isGM) return true;
|
if (game.user.isGM) return true;
|
||||||
|
|
||||||
|
|
@ -103,8 +120,11 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio
|
||||||
}
|
}
|
||||||
|
|
||||||
static #addCountdown() {
|
static #addCountdown() {
|
||||||
|
const id = foundry.utils.randomID();
|
||||||
|
this.editingCountdowns.add(id);
|
||||||
|
this.currentEditCountdown = id;
|
||||||
this.updateSetting({
|
this.updateSetting({
|
||||||
[`countdowns.${foundry.utils.randomID()}`]: DhCountdown.defaultCountdown()
|
[`countdowns.${id}`]: DhCountdown.defaultCountdown()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -125,7 +145,10 @@ export default class CountdownEdit extends HandlebarsApplicationMixin(Applicatio
|
||||||
|
|
||||||
const isEditing = this.editingCountdowns.has(countdownId);
|
const isEditing = this.editingCountdowns.has(countdownId);
|
||||||
if (isEditing) this.editingCountdowns.delete(countdownId);
|
if (isEditing) this.editingCountdowns.delete(countdownId);
|
||||||
else this.editingCountdowns.add(countdownId);
|
else {
|
||||||
|
this.editingCountdowns.add(countdownId);
|
||||||
|
this.currentEditCountdown = countdownId;
|
||||||
|
}
|
||||||
|
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
right: 64px;
|
right: 64px;
|
||||||
transition:
|
transition:
|
||||||
right ease 250ms,
|
right ease 250ms,
|
||||||
all var(--ui-fade-duration) ease,
|
opacity var(--ui-fade-duration) ease,
|
||||||
opacity var(--ui-fade-duration);
|
opacity var(--ui-fade-duration);
|
||||||
|
|
||||||
.window-title {
|
.window-title {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
<div class="edit-content">
|
<div class="edit-content">
|
||||||
{{#each countdowns as | countdown id | }}
|
{{#each countdowns as | countdown id | }}
|
||||||
<div class="countdown-edit-container {{#unless countdown.editing}}viewing{{/unless}}">
|
<div class="countdown-edit-container {{#unless countdown.editing}}viewing{{/unless}}" data-id="{{id}}">
|
||||||
<a data-action="editCountdownImage" id="{{id}}"><img src="{{countdown.img}}" /></a>
|
<a data-action="editCountdownImage" id="{{id}}"><img src="{{countdown.img}}" /></a>
|
||||||
{{#unless countdown.editing}}
|
{{#unless countdown.editing}}
|
||||||
<div class="countdown-edit-text">
|
<div class="countdown-edit-text">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue