diff --git a/module.json b/module.json index cb6d185..6045a71 100644 --- a/module.json +++ b/module.json @@ -26,6 +26,16 @@ "verified": "3.1.2" } } + ], + "requires": [ + { + "id": "lib-wrapper", + "type": "module", + "compatibility": { + "minimum": "1.0.0.0", + "verified": "1.12.13.0" + } + } ] }, "esmodules": [ diff --git a/src/combat.mjs b/src/combat.mjs index 51a405e..d654ee9 100644 --- a/src/combat.mjs +++ b/src/combat.mjs @@ -1,4 +1,4 @@ -import {item_roll, Logger} from "./util.mjs"; +import {autoResizeApplicationExisting, item_roll, Logger} from "./util.mjs"; import {combat_hooks, socket} from "./module.mjs"; import {COMBAT_ENABLED, COMBAT_HEALTH_ESTIMATE, COMBAT_HEALTH_ESTIMATE_TYPE, ID_MAP, MODULE_ID} from "./constants.mjs"; import {actor_to_discord_ids} from "./sync.mjs"; @@ -181,6 +181,36 @@ function get_health(hp, combatHealthSetting, actorType) { } } +export function register_combat_settings_toggle() { + libWrapper.register('oronder', 'CombatTrackerConfig.prototype._updateObject', async function (wrapped, ...args) { + Logger.info(this) + Logger.info(this.form.elements.oronder_combat_tracker_toggle.checked) + Logger.info(game.settings.get(MODULE_ID, COMBAT_ENABLED)) + await game.settings.set(MODULE_ID, COMBAT_ENABLED, this.form.elements.oronder_combat_tracker_toggle.checked) + set_combat_hooks() + Logger.info(game.settings.get(MODULE_ID, COMBAT_ENABLED)) + return wrapped(...args) + }, 'WRAPPER') + + Hooks.on('renderCombatTrackerConfig', async (application, $html, data) => { + const $label = $("