Add way to change whether heroes or geist go first in a combat
This commit is contained in:
parent
2a4ba73934
commit
5d8a4495a1
3 changed files with 65 additions and 3 deletions
4
assets/icons/evil.svg
Normal file
4
assets/icons/evil.svg
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="100pt" height="100pt" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m92.719 4.8594s-4.6914 7.8398-17.219 13.52c-7.1094-5.3203-15.941-8.4688-25.5-8.4688s-18.391 3.1484-25.5 8.4688c-12.531-5.6797-17.219-13.52-17.219-13.52s-6.9609 17.73 3.4297 31.109c-2.1289 5.0781-3.3203 10.691-3.3203 16.551 0 23.539 19.078 42.621 42.621 42.621 23.539 0 42.621-19.078 42.621-42.621 0-5.8594-1.1914-11.469-3.3203-16.551 10.379-13.379 3.4297-31.109 3.4297-31.109zm-56.719 57.762c-2.4609 1.1211-5.3086 1.2383-8.0391 0.32812-2.7305-0.91016-4.9414-2.7109-6.2305-5.0781-1.25-2.2891-1.5508-4.9805-0.89844-7.8516l20.602 6.8711c-1.1992 2.6914-3.0508 4.6602-5.4297 5.7383zm42.27-4.7617c-1.2891 2.3711-3.5117 4.1797-6.2305 5.0781s-5.5781 0.78906-8.0391-0.32812c-2.3789-1.0781-4.2305-3.0508-5.4297-5.7383l20.602-6.8711c0.66016 2.8711 0.35156 5.5586-0.89844 7.8516z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 933 B |
6
assets/icons/hero.svg
Normal file
6
assets/icons/hero.svg
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<svg width="100pt" height="100pt" version="1.1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m39.898 56.199-7.6992-10.801c-1.8984-2.6016-2-6.3008-0.19922-9 0.19922-0.30078 2.3984-3.5 6.8008-6.6992-16.5 7.3984-34.5 21.398-36 23.801-2.5 4 11.5 5.6016 14 19.199 2.1016 11.898 18 17.602 20.398 11.898 2.3008-5.6016 5-10.801 7.8984-15.398l0.80078-9.6992c-2.5-0.19922-4.5977-1.3984-6-3.3008z"/>
|
||||
<path d="m93.102 26.602h-33.102c-17 0-24.801 11.301-25.102 11.801-1 1.5-1 3.5 0.10156 5l7.6992 10.801c0.89844 1.1992 2.1992 1.8008 3.6016 1.8008 0.89844 0 1.8008-0.30078 2.5-0.80078 0.19922-0.19922 0.39844-0.39844 0.60156-0.60156v3.1016l-2.6992 32.602c-0.19922 2.6992 1.8008 5 4.5 5.3008 2.6992 0.19922 5-1.8008 5.3008-4.5l2.6016-31.301 1.8945-0.003907 2.6016 31.199c0.19922 2.5 2.3008 4.5 4.8984 4.5h0.39844c2.6992-0.19922 4.6992-2.6016 4.5-5.3008l-2.6992-32.602-0.19922-22.301h22.699c2.3984 0 4.3984-2 4.3984-4.3984-0.097656-2.3984-2.0977-4.2969-4.4961-4.2969zm-43.602 22-5.3008-7.3984c1.1992-1.1016 3-2.3984 5.3984-3.6016z"/>
|
||||
<path d="m69.801 14.199c0 5.4141-4.3867 9.8008-9.8008 9.8008s-9.8008-4.3867-9.8008-9.8008c0-5.4102 4.3867-9.8008 9.8008-9.8008s9.8008 4.3906 9.8008 9.8008z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.2 KiB |
|
|
@ -1,6 +1,38 @@
|
|||
const { CombatTracker } = foundry.applications.sidebar.tabs;
|
||||
|
||||
function createButtonInnerHTML() {
|
||||
const whoFirst = game.settings.get(`ripcrypt`, `whoFirst`);
|
||||
let icon = `evil`;
|
||||
let ariaLabel = `Geists go first, click to make heroes go first`;
|
||||
|
||||
if (whoFirst === `friendly`) {
|
||||
icon = `hero`;
|
||||
ariaLabel = `Heroes go first, click to make geists go first`;
|
||||
};
|
||||
|
||||
return `<rc-icon
|
||||
name="icons/${icon}"
|
||||
var:fill="currentColor"
|
||||
aria-label="${ariaLabel}"
|
||||
></rc-icon>`;
|
||||
};
|
||||
|
||||
function createButtonTooltip() {
|
||||
const whoFirst = game.settings.get(`ripcrypt`, `whoFirst`);
|
||||
if (whoFirst === `friendly`) {
|
||||
return `Heroes currently go first`;
|
||||
};
|
||||
return `Geists currently go first`;
|
||||
};
|
||||
|
||||
export class RipCryptCombatTracker extends CombatTracker {
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
actions: {
|
||||
toggleFirst: this.#toggleFirst,
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Changes the way the combat tracker renders combatant rows to account for
|
||||
* multiple combatants being in the same combat "group", thus all going at the
|
||||
|
|
@ -28,10 +60,30 @@ export class RipCryptCombatTracker extends CombatTracker {
|
|||
async _onRender(...args) {
|
||||
await super._onRender(...args);
|
||||
|
||||
const spacer = document.createElement(`div`);
|
||||
spacer.classList.add(`spacer`);
|
||||
|
||||
const button = document.createElement(`button`);
|
||||
button.classList.add(`inline-control`, `combat-control`, `icon`);
|
||||
button.type = `button`;
|
||||
button.dataset.tooltip = createButtonTooltip();
|
||||
button.dataset.action = `toggleFirst`;
|
||||
button.innerHTML = createButtonInnerHTML();
|
||||
button.disabled = !game.user.isGM;
|
||||
|
||||
// Purge the combat controls that I don't want to exist because they don't
|
||||
// make sense in the system.
|
||||
this.element?.querySelector(`[data-action="resetAll"]`)?.remove();
|
||||
this.element?.querySelector(`[data-action="rollNPC"]`)?.remove();
|
||||
this.element?.querySelector(`[data-action="rollAll"]`)?.remove();
|
||||
this.element?.querySelector(`[data-action="rollNPC"]`)?.replaceWith(spacer.cloneNode(true));
|
||||
this.element?.querySelector(`[data-action="rollAll"]`)?.replaceWith(button.cloneNode(true));
|
||||
};
|
||||
|
||||
static async #toggleFirst(_event, element) {
|
||||
game.tooltip.deactivate();
|
||||
const whoFirst = game.settings.get(`ripcrypt`, `whoFirst`);
|
||||
const otherFirst = whoFirst === `friendly` ? `hostile` : `friendly`;
|
||||
await game.settings.set(`ripcrypt`, `whoFirst`, otherFirst);
|
||||
element.innerHTML = createButtonInnerHTML();
|
||||
element.dataset.tooltip = createButtonTooltip();
|
||||
game.tooltip.activate(element);
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue