From f10a93fd4c7fd2f4016a10268444d178eebfa6d5 Mon Sep 17 00:00:00 2001 From: Plushtoast Date: Mon, 13 Dec 2021 21:23:57 +0100 Subject: [PATCH] #587, #738 --- lang/de.json | 3 ++- lang/en.json | 3 ++- modules/actor/actor-dsa5.js | 34 +++++++++++++++++++++++++++++ modules/hooks/journal.js | 10 +++++++++ modules/wizards/adventure_wizard.js | 16 +++++++++++++- styles/dsa5.css | 12 +++++----- 6 files changed, 68 insertions(+), 10 deletions(-) diff --git a/lang/de.json b/lang/de.json index ac8b9b51..9f18ddd3 100644 --- a/lang/de.json +++ b/lang/de.json @@ -761,7 +761,8 @@ "actorConfig": "Akteur konfigurieren", "weightOnActor": "Wird vom Akteur getragen", "tempRegeneration": "Temporär, wird bei Regenerationswurf verbraucht.", - "permRegeneration": "Permanent, wird bei jedem Regenerationswurf hinzugezählt" + "permRegeneration": "Permanent, wird bei jedem Regenerationswurf hinzugezählt", + "panMapNote": "Map Notiz fokussieren" }, "ITEMSHEET": { "offHandMod": "Bonus/Malus als Nebenhand (z.b. Parierwaffe)" diff --git a/lang/en.json b/lang/en.json index 9883280b..c445b486 100644 --- a/lang/en.json +++ b/lang/en.json @@ -732,7 +732,8 @@ "actorConfig": "Configure actor", "weightOnActor": "Being carried by the actor", "tempRegeneration": "Temporary, consumed on the next regeneration roll", - "permRegeneration": "Permanent, bonus for every regeneration roll" + "permRegeneration": "Permanent, bonus for every regeneration roll", + "panMapNote": "Focus map note" }, "ITEMSHEET": { "offHandMod": "Bonus/handicap offhand (e.g. parry weapon)" diff --git a/modules/actor/actor-dsa5.js b/modules/actor/actor-dsa5.js index dab3a352..06a05264 100644 --- a/modules/actor/actor-dsa5.js +++ b/modules/actor/actor-dsa5.js @@ -953,6 +953,40 @@ export default class Actordsa5 extends Actor { return Itemdsa5.getSubClass(skill.type).setupDialog(null, options, skill, this, tokenId) } + tokenScrollingText(texts) { + const tokens = this.isToken ? [this.token ? this.token.object : undefined] : this.getActiveTokens(true); + for (let t of tokens) { + if (!t || !t.hud) continue; + + let index = 0 + for (let k of texts) { + t.hud.createScrollingText(k.value, { + anchor: index, + direction: k.value > 0 ? 2 : 1, + fontSize: 16, + stroke: k.stroke, + strokeThickness: 1, + jitter: 0.25, + duration: 1000 + }) + index += 1 + } + } + } + + async _preUpdate(data, options, user) { + await super._preUpdate(data, options, user); + + const statusText = { wounds: 0x8b0000, astralenergy: 0x0b0bd9, karmaenergy: 0x04a236 } + const scolls = [] + for (let key of Object.keys(statusText)) { + const value = getProperty(data, `data.status.${key}.value`) + if (value) scolls.push({ value: value - this.data.data.status[key].value, stroke: statusText[key] }) + } + if (scolls.length) this.tokenScrollingText(scolls) + } + + async applyDamage(amount) { const newVal = Math.min(this.data.data.status.wounds.max, this.data.data.status.wounds.value - amount) await this.update({ "data.status.wounds.value": newVal }) diff --git a/modules/hooks/journal.js b/modules/hooks/journal.js index 1cc643a2..137b1710 100644 --- a/modules/hooks/journal.js +++ b/modules/hooks/journal.js @@ -12,6 +12,7 @@ export default function() { $(html).find(".entry-text").attr("title", game.i18n.localize("SHEET.textView")); $(html).find(".share-image").attr("title", game.i18n.localize("SHEET.showToPlayers")); $(html).find(".import").attr("title", game.i18n.localize("SHEET.import")); + $(html).find(".panMapNote").attr("title", game.i18n.localize("SHEET.panMapNote")); DSA5ChatAutoCompletion.bindRollCommands(html) @@ -26,6 +27,15 @@ export default function() { }) }) + Hooks.on("getJournalSheetHeaderButtons", (sheet, buttons) => { + if (sheet.document.sceneNote) + buttons.unshift({ + class: "panMapNote", + icon: "fas fa-map-pin", + onclick: async() => sheet.document.panToNote() + }) + }) + TextEditor._enrichHTML = TextEditor.enrichHTML TextEditor.enrichHTML = function(content, { secrets = false, documents = true, links = true, rolls = true, rollData = null } = {}) { let result = TextEditor._enrichHTML(content, { secrets, documents, links, rolls, rollData }) diff --git a/modules/wizards/adventure_wizard.js b/modules/wizards/adventure_wizard.js index 9e5365ce..ba44bcfc 100644 --- a/modules/wizards/adventure_wizard.js +++ b/modules/wizards/adventure_wizard.js @@ -78,6 +78,10 @@ export default class BookWizard extends Application { activateListeners(html) { super.activateListeners(html) + html.on('click', '.showMapNote', ev => { + game.journal.get(ev.currentTarget.dataset.entryid).panToNote() + }) + html.on("search", ".filterJournals", ev => { this.filterToc($(ev.currentTarget).val()) }) @@ -224,7 +228,9 @@ export default class BookWizard extends Application { let content = journal.data.content if (!content) content = `` - this.content = `

${journal.name}

${TextEditor.enrichHTML(content)}` + const pinIcon = this.findSceneNote(journal.getFlag("dsa5", "initId")) + + this.content = `

${journal.name}
${pinIcon}

${TextEditor.enrichHTML(content)}` const chapter = $(this._element).find('.chapter') chapter.html(this.content) chapter.find('.documentName-link, .entity-link').click(ev => { @@ -236,6 +242,14 @@ export default class BookWizard extends Application { }) } + findSceneNote(entryId) { + if (entryId) { + const importedJournalEntry = game.journal.find(x => x.getFlag("dsa5", "initId") == entryId) + if (importedJournalEntry && importedJournalEntry.sceneNote) return `` + } + return "" + } + async importBook() { if (game.user.isGM) new InitializerForm().render(this.bookData.moduleName) } diff --git a/styles/dsa5.css b/styles/dsa5.css index f84ce7e0..0debe2a7 100644 --- a/styles/dsa5.css +++ b/styles/dsa5.css @@ -2370,16 +2370,14 @@ select.noAppearance { max-width: 40%; } -.journalHeader .pinJournal, -.journalHeader .showJournal { - position: absolute; - right: 5px; - bottom: -3px; +.journalHeader .jrnIcons { color: rgb(92, 92, 92); + float: right; } -.journalHeader .pinJournal { - right: 45px; +.journalHeader .jrnIcons a { + display: inline-block; + margin-right: 10px; } .sound-name {