generated from League-of-Foundry-Developers/FoundryVTT-Module-Template
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/0.9.9' into main
- Loading branch information
Showing
11 changed files
with
203 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* globals | ||
game | ||
*/ | ||
/* eslint no-unused-vars: ["error", { "argsIgnorePattern": "^_" }] */ | ||
|
||
import { TEMPLATES, MODULE_ID, FLAGS } from "./const.js"; | ||
|
||
// Patches for the Combat tracker | ||
|
||
export const PATCHES = {}; | ||
PATCHES.BASIC = {}; | ||
|
||
import { injectConfiguration, renderTemplateSync } from "./util.js"; | ||
|
||
// ----- NOTE: Hooks ----- // | ||
|
||
/** | ||
* Hook renderCombatTracker | ||
* Add a button at the top left to clear the current token's movement. | ||
* @param {Application} application The Application instance being rendered | ||
* @param {jQuery} html The inner HTML of the document that will be displayed and may be modified | ||
* @param {object} data The object of data used when rendering the application | ||
*/ | ||
function renderCombatTracker(app, html, data) { | ||
if ( !game.user.isGM ) return; | ||
const encounterControlsDiv = html.find(".encounter-controls")[0]; | ||
if ( !encounterControlsDiv ) return; | ||
const combatButtons = encounterControlsDiv.getElementsByClassName("combat-button"); | ||
if ( !combatButtons.length ) return; | ||
const dividers = encounterControlsDiv.getElementsByTagName("h3"); | ||
if ( !dividers.length ) return; | ||
|
||
const myHtml = renderTemplateSync(TEMPLATES.COMBAT_TRACKER, data); | ||
// const aElem = document.createElement("a"); | ||
// aElem.innerHTML = myHtml; | ||
dividers[0].insertAdjacentHTML("beforebegin", myHtml); | ||
|
||
// const npcButton = Object.values(combatButtons).findIndex(b => b.dataset.control === "rollNPC"); | ||
// const findString = ".combat-button[data-control='rollNPC']"; | ||
// await injectConfiguration(app, html, data, template, findString); | ||
|
||
html.find(`.${MODULE_ID}`).click(ev => clearMovement.call(app, ev)); | ||
} | ||
|
||
PATCHES.BASIC.HOOKS = { renderCombatTracker }; | ||
|
||
async function clearMovement(event) { | ||
event.preventDefault(); | ||
event.stopPropagation(); | ||
const combat = this.viewed; | ||
const tokenD = combat?.combatant?.token; | ||
if ( !tokenD ) return; | ||
await tokenD.unsetFlag(MODULE_ID, FLAGS.MOVEMENT_HISTORY); | ||
ui.notifications.notify(`Combat movement history for ${tokenD.name} reset.`); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<a class="combat-button elevationruler" aria-label="{{localize 'elevationruler.clearMovement'}}" role="button" data-tooltip="elevationruler.clearMovement" data-control="clearMovement" {{#unless turns}}disabled{{/unless}}> | ||
<i class="fas fa-person-walking-arrow-loop-left"></i> | ||
</a> |