Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
theripper93 committed Dec 7, 2023
1 parent bd94134 commit 05238d9
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 1 deletion.
49 changes: 49 additions & 0 deletions scripts/core/components/portrait/portraitPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ export class PortraitPanel extends ArgonComponent {
return 0;
}

get configurationTemplate() {
return null;
}

async getData() {
const data = {
name: this.name,
Expand All @@ -61,6 +65,8 @@ export class PortraitPanel extends ArgonComponent {
async activateListeners(html) {
super.activateListeners(html);
html.querySelector(".death-save-btn").addEventListener("click", this._onDeathSave.bind(this));
if(this.configurationTemplate) html.querySelector("#argon-actor-config")?.addEventListener("click", this._onConfigure.bind(this));
else html.querySelector(".portrait-actor-configuration")?.remove();
const toggleMinimizeButton = this._buttons.find(button => button.id === "toggle-minimize");
if(toggleMinimizeButton) {
toggleMinimizeButton.element.addEventListener("click", (e) => {
Expand Down Expand Up @@ -143,4 +149,47 @@ export class PortraitPanel extends ArgonComponent {
}
}
}

async _onConfigure(event) {
event.preventDefault();
const template = this.configurationTemplate;


(new ArgonPortraitConfig(this.actor, template)).render(true);
}
}

class ArgonPortraitConfig extends FormApplication {
constructor(actor, template) {
super();
this.actor = actor;
this._template = template;
}

get title() {
return `Configure ${this.actor.name}`;
}

get template() {
return this._template;
}

static get defaultOptions() {
return mergeObject(super.defaultOptions, {
id: "argon-actor-config-form",
title: ``,
template: "",
width: 400,
height: "auto",
closeOnSubmit: true
});
}

getData() {
return {actor: this.actor, ...this.actor};
}

async _updateObject(event, formData) {
await this.actor.update(formData);
}
}
5 changes: 4 additions & 1 deletion styles/ActionHUD.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
text-transform: uppercase;
width: 100%;
text-align: center;
overflow: hidden;
}

.action-element.item-button .action-element-title {
Expand Down Expand Up @@ -126,8 +127,10 @@
}

.action-element-container .feature-element .feature-element-title {
max-height: 2.5rem;
max-height: 3rem;
text-align: center;
text-transform: uppercase;
font-size: small;
}

.features-container {
Expand Down
21 changes: 21 additions & 0 deletions styles/PortraitHUD.css
Original file line number Diff line number Diff line change
Expand Up @@ -459,3 +459,24 @@
max-width: 25px;
width: 100%;
}

/* Configuration Button */

.portrait-hud .portrait-actor-configuration{
position: absolute;
top: 0;
right: 0;
font-size: xxx-large;
padding: 1rem;
z-index: 1;
opacity: 0;
transition: opacity 0.3s ease-in-out;
}

.portrait-hud .portrait-actor-configuration:hover{
opacity: 1;
}

.portrait-hud .portrait-actor-configuration i{
cursor: pointer;
}
3 changes: 3 additions & 0 deletions templates/partials/PortraitPanel.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@


</div>
<div class="portrait-actor-configuration">
<i id="argon-actor-config" class="fa-solid fa-gear"></i>
</div>
</div>

0 comments on commit 05238d9

Please sign in to comment.