From 4dcb02b6c20d1d04676939469f7d23e54e4b3ee4 Mon Sep 17 00:00:00 2001 From: Megastruktur Date: Wed, 4 Nov 2020 15:37:28 +0300 Subject: [PATCH] Clocks as Actors --- CHANGELOG.txt | 3 ++ README.md | 5 +- module/blades-actor-sheet.js | 9 ---- module/blades-clock-sheet.js | 52 +++++++++++++++++++ module/blades-crew-sheet.js | 2 +- module/blades.js | 2 + template.json | 13 ++--- .../🕛 clock.html => actors/clock-sheet.html} | 3 +- 8 files changed, 68 insertions(+), 21 deletions(-) create mode 100644 module/blades-clock-sheet.js rename templates/{items/🕛 clock.html => actors/clock-sheet.html} (84%) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 1d46ec3..e91e871 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,6 @@ +v2.8 +- Clocks rebuilt to be Actors. + v2.7 - Clocks added! diff --git a/README.md b/README.md index 6af7265..dedcb65 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/module/blades-actor-sheet.js b/module/blades-actor-sheet.js index f78767c..7c543ea 100644 --- a/module/blades-actor-sheet.js +++ b/module/blades-actor-sheet.js @@ -88,13 +88,4 @@ export class BladesActorSheet extends BladesSheet { /* -------------------------------------------- */ - /** @override */ - _updateObject(event, formData) { - - // Update the Actor - return this.object.update(formData); - } - - /* -------------------------------------------- */ - } diff --git a/module/blades-clock-sheet.js b/module/blades-clock-sheet.js new file mode 100644 index 0000000..2d22507 --- /dev/null +++ b/module/blades-clock-sheet.js @@ -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); + } + + /* -------------------------------------------- */ + +} diff --git a/module/blades-crew-sheet.js b/module/blades-crew-sheet.js index 5786832..e9ae64f 100644 --- a/module/blades-crew-sheet.js +++ b/module/blades-crew-sheet.js @@ -106,7 +106,7 @@ export class BladesCrewSheet extends BladesSheet { /* -------------------------------------------- */ /** @override */ - _updateObject(event, formData) { + async _updateObject(event, formData) { // Update the Item super._updateObject(event, formData); diff --git a/module/blades.js b/module/blades.js index 0a8afd3..6b4be65 100644 --- a/module/blades.js +++ b/module/blades.js @@ -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(); diff --git a/template.json b/template.json index 3b84c4a..8dfe309 100644 --- a/template.json +++ b/template.json @@ -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" } } } diff --git a/templates/items/🕛 clock.html b/templates/actors/clock-sheet.html similarity index 84% rename from templates/items/🕛 clock.html rename to templates/actors/clock-sheet.html index 5e1ab17..7ac1918 100644 --- a/templates/items/🕛 clock.html +++ b/templates/actors/clock-sheet.html @@ -1,9 +1,8 @@
- {{#if editable}} - +