-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#1] New Tidy compatibility update #2
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,75 @@ | |
updateSheetForInspo(user); | ||
//updatePlayerListInspo(); | ||
}); | ||
|
||
Hooks.on("tidy5e-sheet.renderActorSheet", (app, element, data) => { | ||
if (app.actor.type !== "character") { | ||
return; | ||
} | ||
|
||
const html = $(element); | ||
|
||
const inspirationArea = html.find(".inspiration"); | ||
inspirationArea.hide(); | ||
|
||
let currentInspiration; | ||
const actorOwner = game.users.find( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For this PR, I just copied a lot of the functionality from the main logic. Please feel free to extract the common behaviors into functions if that works better for you. |
||
(u) => u.character?.uuid === app.actor.uuid | ||
); | ||
if (actorOwner) { | ||
currentInspiration = actorOwner.getFlag("so-inspired", "inspirationCount"); | ||
|
||
let newInspirationArea = ` | ||
<div | ||
data-tidy-render-scheme="handlebars" | ||
class="counter flexrow new-inspiration" | ||
style="width: 200px; height: 25px; display: flex; margin: 10px 10px 10px 10px" | ||
> | ||
<h4>Inspiration</h4> | ||
<div class="counter-value"> | ||
<button | ||
type="button" | ||
class="add-inspiration-btn" | ||
style="height: 20px; width: 20px; line-height: 0px; padding-left: 2px" | ||
> | ||
<i | ||
class="fa-solid fa-plus" | ||
style="color: var(--t5e-primary-font-color)" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This CSS variable reference makes So Inspired! work with Tidy's light and dark modes 💪💅 |
||
></i> | ||
</button> | ||
<button | ||
type="button" | ||
class="remove-inspiration-btn" | ||
style="height: 20px; width: 20px; line-height: 0px; padding-left: 2px" | ||
> | ||
<i | ||
class="fa-solid fa-minus" | ||
style="color: var(--t5e-primary-font-color)" | ||
></i> | ||
</button> | ||
<span class="inspiration-span" style="margin-left: 10px"> | ||
${currentInspiration} | ||
</span> | ||
</div> | ||
</div>`; | ||
|
||
html.find(".tidy5e-sheet-header").after(newInspirationArea); | ||
|
||
html | ||
.find(".add-inspiration-btn") | ||
.off("click") | ||
.on("click", function () { | ||
addInspiration(actorOwner, app); | ||
}); | ||
html | ||
.find(".remove-inspiration-btn") | ||
.off("click") | ||
.on("click", function () { | ||
removeInspiration(actorOwner, app); | ||
}); | ||
} | ||
}); | ||
|
||
/* | ||
async function updatePlayerListInspo() { | ||
const playerList = $(document) | ||
|
@@ -68,11 +137,7 @@ | |
let counterArea; | ||
let newInspirationArea; | ||
console.log(maxInspiration); | ||
if (_sheet.options.classes.includes("tidy5e")) { | ||
counterArea = $(html).find(".tidy5e-header"); | ||
newInspirationArea = `<div class="counter flexrow new-inspiration" style="width: 200px; height:25px; display:flex; margin: 10px 10px 10px 10px;"><h4>Inspiration</h4><div class="counter-value"><button type="button" class="add-inspiration-btn" style="height:20px;width:20px;line-height:0px;padding-left:2px;"><i class="fa-solid fa-plus" style="color: #000000;"></i></button><button type="button" class="remove-inspiration-btn" style="height:20px;width:20px;line-height:0px;padding-left:2px;"><i class="fa-solid fa-minus" style="color: #000000;"></i></button><span class="inspiration-span" style="margin-left:10px;">${currentInspiration}</span></div></div>`; | ||
counterArea.after(newInspirationArea); | ||
} else if (_sheet.options.classes.includes("dnd5e2")) { | ||
if (_sheet.options.classes.includes("dnd5e2")) { | ||
counterArea = $(html).find(".card .stats").children().last(); | ||
newInspirationArea = `<div class="meter-group"><div class="label roboto-condensed-upper"><span>Inspiration</span></div><div class="meter hit-dice progress" role="meter" aria-valuemin="0" aria-valuenow="${currentInspiration}" aria-valuemax="${maxInspiration}" style="--bar-percentage: ${ | ||
(currentInspiration / maxInspiration) * 100 | ||
|
@@ -139,6 +204,6 @@ | |
|
||
function updateSheetForInspo(user) { | ||
if (user?.character.sheet.rendered) { | ||
user.character.sheet.render(true); | ||
user.character.sheet.render(false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mysurvive this is mostly just a recommendation. |
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I'm running things in svelte, I have to post up my own lifecycle hook.