Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Plushtoast committed Dec 13, 2021
1 parent e5148cb commit f10a93f
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 10 deletions.
3 changes: 2 additions & 1 deletion lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
3 changes: 2 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down
34 changes: 34 additions & 0 deletions modules/actor/actor-dsa5.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand Down
10 changes: 10 additions & 0 deletions modules/hooks/journal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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 })
Expand Down
16 changes: 15 additions & 1 deletion modules/wizards/adventure_wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})
Expand Down Expand Up @@ -224,7 +228,9 @@ export default class BookWizard extends Application {
let content = journal.data.content
if (!content) content = `<img src="${journal.data.img}"/>`

this.content = `<div><h1 class="journalHeader" data-uuid="${journal.uuid}">${journal.name}<a class="pinJournal"><i class="fas fa-thumbtack"></i></a><a class="showJournal"><i class="fas fa-eye"></i></a></h1>${TextEditor.enrichHTML(content)}`
const pinIcon = this.findSceneNote(journal.getFlag("dsa5", "initId"))

this.content = `<div><h1 class="journalHeader" data-uuid="${journal.uuid}">${journal.name}<div class="jrnIcons">${pinIcon}<a class="pinJournal"><i class="fas fa-thumbtack"></i></a><a class="showJournal"><i class="fas fa-eye"></i></a></div></h1>${TextEditor.enrichHTML(content)}`
const chapter = $(this._element).find('.chapter')
chapter.html(this.content)
chapter.find('.documentName-link, .entity-link').click(ev => {
Expand All @@ -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 `<a class="showMapNote" data-entryId="${importedJournalEntry.id}"><i class="fas fa-map-pin"></i></a>`
}
return ""
}

async importBook() {
if (game.user.isGM) new InitializerForm().render(this.bookData.moduleName)
}
Expand Down
12 changes: 5 additions & 7 deletions styles/dsa5.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f10a93f

Please sign in to comment.