Clocks as Actors

This commit is contained in:
Megastruktur 2020-11-04 15:37:28 +03:00
parent 7d437ecc39
commit 4dcb02b6c2
8 changed files with 68 additions and 21 deletions

View File

@ -1,3 +1,6 @@
v2.8
- Clocks rebuilt to be Actors.
v2.7
- Clocks added!

View File

@ -51,9 +51,8 @@ Crew Types:
## Clocks
Clocks are now here!
- To add clock go to Items tab and create a new Item of type "🕛 clock".
- To share it to other players rightclick, select "Configure Permissions" and set "Observer" permissions to all
desired players.
- To add clock go to Actors tab and create a new Actor of type "🕛 clock".
- To share it to other players just drag it to a scene.
## Logic field

View File

@ -88,13 +88,4 @@ export class BladesActorSheet extends BladesSheet {
/* -------------------------------------------- */
/** @override */
_updateObject(event, formData) {
// Update the Actor
return this.object.update(formData);
}
/* -------------------------------------------- */
}

View File

@ -0,0 +1,52 @@
import { BladesSheet } from "./blades-sheet.js";
/**
* Extend the basic ActorSheet with some very simple modifications
* @extends {BladesSheet}
*/
export class BladesClockSheet extends BladesSheet {
/** @override */
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
classes: ["blades-in-the-dark", "sheet", "actor"],
template: "systems/blades-in-the-dark/templates/actors/clock-sheet.html",
width: 700,
height: 970,
});
}
/* -------------------------------------------- */
/** @override */
async _updateObject(event, formData) {
let image_path = `/systems/blades-in-the-dark/styles/assets/progressclocks-svg/Progress Clock ${formData['data.type']}-${formData['data.value']}.svg`;
formData['img'] = image_path;
formData['token.img'] = image_path;
let data = {
img: image_path,
width: 1,
height: 1,
scale: 1,
mirrorX: false,
mirrorY: false,
tint: "",
displayName: 50
};
let tokens = this.actor.getActiveTokens();
tokens.forEach(function(token) {
token.update(data);
});
// Update the Actor
return this.object.update(formData);
}
/* -------------------------------------------- */
}

View File

@ -106,7 +106,7 @@ export class BladesCrewSheet extends BladesSheet {
/* -------------------------------------------- */
/** @override */
_updateObject(event, formData) {
async _updateObject(event, formData) {
// Update the Item
super._updateObject(event, formData);

View File

@ -14,6 +14,7 @@ import { BladesItem } from "./blades-item.js";
import { BladesItemSheet } from "./blades-item-sheet.js";
import { BladesActorSheet } from "./blades-actor-sheet.js";
import { BladesCrewSheet } from "./blades-crew-sheet.js";
import { BladesClockSheet } from "./blades-clock-sheet.js";
import * as migrations from "./migration.js";
window.BladesHelpers = BladesHelpers;
@ -42,6 +43,7 @@ Hooks.once("init", async function() {
Actors.unregisterSheet("core", ActorSheet);
Actors.registerSheet("blades", BladesActorSheet, { types: ["character"], makeDefault: true });
Actors.registerSheet("blades", BladesCrewSheet, { types: ["crew"], makeDefault: true });
Actors.registerSheet("blades", BladesClockSheet, { types: ["\uD83D\uDD5B clock"], makeDefault: true });
Items.unregisterSheet("core", ItemSheet);
Items.registerSheet("blades", BladesItemSheet, {makeDefault: true});
preloadHandlebarsTemplates();

View File

@ -1,6 +1,6 @@
{
"Actor": {
"types": ["character", "crew"],
"types": ["character", "crew", "\uD83D\uDD5B clock"],
"character": {
"alias": "",
"stress": {
@ -136,10 +136,15 @@
"features": [],
"heat": [0],
"wanted": [0]
},
"\uD83D\uDD5B clock": {
"name": "",
"type": 4,
"value": "0"
}
},
"Item": {
"types": ["item", "class", "ability", "heritage", "background", "vice", "crew_upgrade", "cohort", "crew_type", "crew_reputation", "crew_upgrade", "crew_ability", "\uD83D\uDD5B clock"],
"types": ["item", "class", "ability", "heritage", "background", "vice", "crew_upgrade", "cohort", "crew_type", "crew_reputation", "crew_upgrade", "crew_ability"],
"templates": {
"default": {
"description": ""
@ -401,10 +406,6 @@
"connects": []
}
}
},
"\uD83D\uDD5B clock": {
"type": 4,
"value": "0"
}
}
}

View File

@ -1,9 +1,8 @@
<form class="{{cssClass}} clock-block" autocomplete="off">
<div class="flexcol blades-clock-name-type">
{{#if editable}}
<input type="text" id="{{item._id}}-clock-name" name="name" value="{{item.name}}">
<input type="text" id="{{actor._id}}-clock-name" name="name" value="{{actor.name}}">
<select data-type="String" name="data.type">
{{#select data.type}}