Add saving and editing of default attributes and their values (closes #29)
This commit is contained in:
parent
5159db3d33
commit
d540cc72f6
6 changed files with 178 additions and 34 deletions
38
module/hooks/renderSettingsConfig.mjs
Normal file
38
module/hooks/renderSettingsConfig.mjs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
import { __ID__ } from "../consts.mjs";
|
||||
|
||||
Hooks.on(`renderSettingsConfig`, (app, html, context, options) => {
|
||||
/*
|
||||
This section is used to insert a button into the settings config that unsets
|
||||
a world setting when it exists but doesn't allow any other form of editing it.
|
||||
*/
|
||||
if (game.user.isGM && game.settings.get(__ID__, `actorDefaultAttributes`)) {
|
||||
const formGroup = document.createElement(`div`);
|
||||
formGroup.classList = `form-group`;
|
||||
|
||||
const label = document.createElement(`div`);
|
||||
label.innerHTML = _loc(`taf.settings.actorDefaultAttributes.name`);
|
||||
|
||||
const formFields = document.createElement(`div`);
|
||||
formFields.classList = `form-fields`;
|
||||
|
||||
const button = document.createElement(`button`);
|
||||
button.type = `button`;
|
||||
button.innerHTML = _loc(`taf.settings.actorDefaultAttributes.label`);
|
||||
button.addEventListener(`click`, () => {
|
||||
game.settings.set(__ID__, `actorDefaultAttributes`, undefined);
|
||||
});
|
||||
|
||||
const hint = document.createElement(`p`);
|
||||
hint.classList = `hint`;
|
||||
hint.innerHTML = _loc(`taf.settings.actorDefaultAttributes.hint`);
|
||||
|
||||
formFields.appendChild(button);
|
||||
formGroup.appendChild(label);
|
||||
formGroup.appendChild(formFields);
|
||||
formGroup.appendChild(hint);
|
||||
|
||||
/** @type {HTMLElement|undefined} */
|
||||
const tab = html.querySelector(`.tab[data-group="categories"][data-tab="system"]`);
|
||||
tab?.insertAdjacentElement(`afterbegin`, formGroup);
|
||||
};
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue