Skip to content

Commit

Permalink
Merge pull request #115 from Cussa/master
Browse files Browse the repository at this point in the history
Use Foundry's tooltip + Adjust conditions name in changelog
  • Loading branch information
DrOgres committed Feb 7, 2024
2 parents 852593e + 18c8be7 commit 76a97e8
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 18 deletions.
11 changes: 7 additions & 4 deletions README.md
Expand Up @@ -29,15 +29,18 @@ This system provides character sheets and items for your play, if you would lik


## Release Notes
=======

4.5.3
v4.6.0
- ✨ Use Foundry's tooltip instead of browser `title`
- 🐛 Conditions was showing as `undefined` in changelog

v4.5.3
- 🐛 Fix: Fixed CSS on member data tab for lists to populate correctly

4.5.2
v4.5.2
- 🐛 Fix: Removed rollable tag from skills on member data tab of headquarter sheet

4.5.1
v4.5.1
- 🐛 Fix: HQ was losing data when updating ownership, editor for notes was hidden.

v4.5.0
Expand Down
2 changes: 1 addition & 1 deletion script/actor/vaesen-actor-sheet.js
Expand Up @@ -518,7 +518,7 @@ export class VaesenActorSheet extends ActorSheet {
.localize("HEADER.CRITICAL_INJURIES")
.toLowerCase()
.replace(/\b(\w)/g, (x) => x.toUpperCase());
return { name: label, value: bonus, tooltip: tooltip.join("\n") };
return { name: label, value: bonus, tooltip: tooltip.join("<br>") };
}

computeInfoFromArmor(skillName) {
Expand Down
5 changes: 4 additions & 1 deletion script/actor/vaesen.js
Expand Up @@ -193,10 +193,13 @@ export class VaesenActor extends Actor {
const dateChanged = new Date().toLocaleString();
const userName = game.users.get(userId)?.name;
let changelogArray = this.system.changelog;
let documentType = document.type;
if (document.statuses)
documentType = "condition";

const log = {
name: document.name,
change: `${document.type} ${textType}`,
change: `${documentType} ${textType}`,
by: userName,
at: dateChanged,
};
Expand Down
4 changes: 2 additions & 2 deletions script/hooks.js
Expand Up @@ -3,7 +3,7 @@ import { PlayerCharacterSheet } from "./sheet/player.js";
import { NpcCharacterSheet } from "./sheet/npc.js";
import { VaesenCharacterSheet } from "./sheet/vaesen.js";
import { HeadquarterCharacterSheet } from "./sheet/headquarter.js";
import { prepareRollNewDialog, push, totalRoll as totalRoll } from "./util/roll.js";
import { prepareRollNewDialog, push, registerGearSelectTooltip, totalRoll as totalRoll } from "./util/roll.js";
import { registerSystemSettings } from "./util/settings.js";
import { vaesen } from "./config.js";
import { conditions } from "./util/conditions.js";
Expand Down Expand Up @@ -106,7 +106,7 @@ Hooks.once("ready", async function () {
Hooks.on("hotbarDrop", (bar, data, slot) => createRollMacro(data, slot));
Hooks.on("chatMessage", (_, messageText, chatData) => totalRoll(messageText, chatData));
migrate();

registerGearSelectTooltip();
});

Hooks.on('canvasReady', () => {
Expand Down
2 changes: 1 addition & 1 deletion script/sheet/player.js
Expand Up @@ -331,7 +331,7 @@ export class PlayerCharacterSheet extends VaesenActorSheet {
if (bonus === 0)
return null;
const conditionLabel = game.i18n.localize("HEADER.CONDITIONS").toLowerCase().replace(/\b(\w)/g, x => x.toUpperCase());
return { name: conditionLabel, value: bonus, tooltip: info.join("\n"), type: "conditions" };
return { name: conditionLabel, value: bonus, tooltip: info.join("<br>"), type: "conditions" };
}

computePossibleBonusFromUpgrades(recoveryType) {
Expand Down
24 changes: 16 additions & 8 deletions script/util/roll.js
Expand Up @@ -26,14 +26,14 @@ export function prepareRollNewDialog(
`: </p>
<input style="text-align: center" type="text" value="` +
element.value +
`" readonly title="` +
`" readonly data-tooltip="` +
tooltip +
`"/></div>`
`" data-tooltip-direction="RIGHT" data-tooltip-class="vaesen-tooltip"/></div>`
);

baseLinesDice += parseInt(element.value, 10);
var moreInfo = tooltip
? `<ul><li>${tooltip.replace("\n", "</li><li>")}</li></ul>`
? `<ul><li>${tooltip.replaceAll("<br>", "</li><li>")}</li></ul>`
: "";
breakdown.push(
`${element.name}: ${adjustBonusText(element.value)}${moreInfo}`
Expand Down Expand Up @@ -284,15 +284,15 @@ function buildGearSelectHtmlDialog(options) {
`: </p></div>`
);
html.push(`<div class="flex row" style="width: 100%;">`);
html.push(`<select id="gear" style="width: 100%;">`);
html.push(`<select id="gear" style="width: 100%;" data-tooltip-direction="RIGHT" data-tooltip-class="vaesen-tooltip">`);
html.push(`<option value="0">None (0)</option>`);
options.forEach((element) => {
let bonusValue = adjustBonusText(element.bonus);
var descriptionWithoutTags = $("<p>").html(element.description).text();
html.push(
`<option value="` +
element.bonus +
`" title="` +
`" data-tooltip="` +
descriptionWithoutTags +
`">` +
element.name +
Expand All @@ -318,7 +318,7 @@ function buildSelectMultipleHtmlDialog(options, name, id) {
`<p style="text-transform: capitalize; white-space:nowrap; margin-top: 4px;">${game.i18n.localize(name)}: </p></div>`
);
html.push(`<div class="flex row" style="width: 100%;">`);
html.push(`<select id="${id}" style="width: 100%;" multiple>`);
html.push(`<select id="${id}" style="width: 100%;" multiple data-tooltip-direction="RIGHT" data-tooltip-class="vaesen-tooltip">`);
options.forEach((element) => {
let descriptionWithoutTags = $("<p>").html(element.description).text();
let requiresBonus =
Expand All @@ -329,9 +329,9 @@ function buildSelectMultipleHtmlDialog(options, name, id) {
(element.bonusType
? game.i18n.localize(CONFIG.vaesen.bonusType[element.bonusType])
: "") + (bonusValue ?? "");
const fullDescription = `${element.name}\n${bonusInfo}\n${descriptionWithoutTags}`;
const fullDescription = `${element.name}<br>${bonusInfo}<br>${element.description}`;
html.push(
`<option value="${element.name}" title="${fullDescription}">${element.name} (${bonusInfo})</option>`
`<option value="${element.name}" data-tooltip="${fullDescription}">${element.name} (${bonusInfo})</option>`
);
});
html.push(`</select></div>`);
Expand Down Expand Up @@ -448,4 +448,12 @@ async function createCustomRoll(actor, formula, name) {
let rollMode = game.settings.get("core", "rollMode");

await roll.toMessage(messageData, { rollMode });
}

export function registerGearSelectTooltip() {
$("body").on("change", "#gear", function(e) {
var optionSelected = $("option:selected", this);
var tooltip = optionSelected.attr("data-tooltip") ?? "";
$(this).attr("data-tooltip", tooltip);
});
}
4 changes: 4 additions & 0 deletions style/dialog/roll.css
Expand Up @@ -25,3 +25,7 @@
flex-basis: 35px;
margin-bottom: 5px;
}

#tooltip.vaesen-tooltip {
text-align: left;
}
2 changes: 1 addition & 1 deletion system.json
@@ -1,7 +1,7 @@
{
"title": "Vaesen",
"description": "Nordic horror role-playing",
"version": "4.5.3",
"version": "4.6.0",
"esmodules": [
"script/hooks.js"
],
Expand Down

0 comments on commit 76a97e8

Please sign in to comment.