Synced "Gm Monitor" with actor updates

This commit is contained in:
Vlyan
2021-08-13 17:00:22 +02:00
parent d7059f09fa
commit 14d89f6943
9 changed files with 30 additions and 42 deletions

View File

@@ -40,7 +40,6 @@
"global": {
"add": "Add",
"edit": "Edit",
"refresh": "Refresh",
"delete_confirm": "Are you sure you want to delete '{name}' ?",
"drop_here": "Drop here",
"send_to_chat": "To Chat",

View File

@@ -40,7 +40,6 @@
"global": {
"add": "Añadir",
"edit": "Editar",
"refresh": "Refresh",
"delete_confirm": "¿Estás seguro de que quieres borrar '{name}' ?",
"drop_here": "Dejar caer aquí",
"send_to_chat": "To Chat",

View File

@@ -40,7 +40,6 @@
"global": {
"add": "Ajouter",
"edit": "Modifier",
"refresh": "Actualiser",
"delete_confirm": "Etes-vous sûr de vouloir supprimer '{name}' ?",
"drop_here": "Déposez ici",
"send_to_chat": "Vers Conv.",

View File

@@ -186,7 +186,18 @@ export class BaseSheetL5r5e extends ActorSheet {
if (formData["data.description"]) {
formData["data.description"] = game.l5r5e.HelpersL5r5e.convertSymbols(formData["data.description"], true);
}
return super._updateObject(event, formData);
return super._updateObject(event, formData).then(() => {
// Notify the "Gm Monitor" if this actor is watched
if (game.settings.get("l5r5e", "gm-monitor-actors").find((e) => e === this.actor.id)) {
game.l5r5e.sockets.refreshAppId("l5r5e-gm-monitor");
if (game.user.isGM) {
Object.values(ui.windows)
.find((e) => e.id === "l5r5e-gm-monitor")
?.refresh();
}
}
});
}
/**

View File

@@ -25,29 +25,11 @@ export class GmMonitor extends FormApplication {
resizable: true,
closeOnSubmit: false,
submitOnClose: false,
submitOnChange: true,
submitOnChange: false,
dragDrop: [{ dragSelector: null, dropSelector: null }],
});
}
/**
* Add the Refresh button on top of sheet
* @override
*/
_getHeaderButtons() {
let buttons = super._getHeaderButtons();
// Send To Chat
buttons.unshift({
label: game.i18n.localize("l5r5e.global.refresh"),
class: "refresh",
icon: "fas fa-sync-alt",
onclick: async () => this.refresh(),
});
return buttons;
}
/**
* Constructor
* @param {ApplicationOptions} options
@@ -103,8 +85,6 @@ export class GmMonitor extends FormApplication {
if (!game.user.isGM) {
return false;
}
// this.position.width = "auto";
// this.position.height = "auto";
return super.render(force, options);
}
@@ -170,17 +150,6 @@ export class GmMonitor extends FormApplication {
}); // tooltips
}
/**
* This method is called upon form submission after form data is validated
* @param event The initial triggering submission event
* @param formData The object of validated form data with which to update the object
* @returns A Promise which resolves once the update operation has completed
* @override
*/
async _updateObject(event, formData) {
this.render(false);
}
/**
* Handle dropped data on the Actor sheet
* @param {DragEvent} event
@@ -258,8 +227,8 @@ export class GmMonitor extends FormApplication {
}
this.object.actors = this.object.actors.filter((e) => e.id !== id);
await this._saveActorsIds();
await this._saveActorsIds();
return this.refresh();
}

View File

@@ -241,5 +241,11 @@ export class GmToolbox extends FormApplication {
});
ui.notifications.info(game.i18n.localize(`l5r5e.gm_toolbox.${type}_info`));
// Refresh gm-monitor
Object.values(ui.windows)
.find((e) => e.id === "l5r5e-gm-monitor")
?.refresh();
game.l5r5e.sockets.refreshAppId("l5r5e-gm-monitor");
}
}

File diff suppressed because one or more lines are too long

View File

@@ -400,7 +400,7 @@
}
#l5r5e-gm-monitor {
min-height: 270px;
min-height: 170px;
min-width: 500px;
.window-content {
@@ -414,6 +414,9 @@
max-width: 28px;
max-height: 28px;
}
.overvalue {
color: $red-dice;
}
}
}

View File

@@ -32,9 +32,11 @@
<td>
{{actor.data.data.social.honor}} / {{actor.data.data.social.glory}} / {{actor.data.data.social.status}}
</td>
<td>{{actor.data.data.fatigue.value}} / {{actor.data.data.fatigue.max}}</td>
<td>{{actor.data.data.strife.value}} / {{actor.data.data.strife.max}}</td>
<td>{{actor.data.data.focus}} / {{actor.data.data.vigilance}}</td>
<td><span class="{{#ifCond actor.data.data.fatigue.value '>' actor.data.data.fatigue.max}}overvalue{{/ifCond}}">{{actor.data.data.fatigue.value}}</span> / {{actor.data.data.fatigue.max}}</td>
<td><span class="{{#ifCond actor.data.data.strife.value '>' actor.data.data.strife.max}}overvalue{{/ifCond}}">{{actor.data.data.strife.value}}</span> / {{actor.data.data.strife.max}}</td>
<td>
{{actor.data.data.focus}} / {{#if actor.data.data.is_compromised}}<span class="overvalue">1</span>{{else}}{{actor.data.data.vigilance}}{{/if}}
</td>
<td>{{actor.data.data.void_points.value}} / {{actor.data.data.void_points.max}}</td>
<td><i data-actor-id="{{actor.id}}" class="fas fa-question-circle actor-infos-control"></i></td>
<td><span data-actor-id="{{actor.id}}" class="actor-remove-control pointer" title="{{localize 'Delete'}}"><i class="fas fa-trash"></i></span></td>