Add basic support for registering custom icons that override icons provided by the system/modules
This commit is contained in:
parent
c90137b18f
commit
c7541db1d9
9 changed files with 279 additions and 6 deletions
44
module/tweaks/customStatusIcons.mjs
Normal file
44
module/tweaks/customStatusIcons.mjs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
import { SettingStatusEnum, status } from "../utils/SettingStatus.mjs";
|
||||
import { __ID__ } from "../consts.mjs";
|
||||
import { Logger } from "../utils/Logger.mjs";
|
||||
import { preventTweakRegistration } from "../utils/preRegisterTweak.mjs";
|
||||
import { StatusEffectIconConfig } from "../apps/StatusEffectIconConfig.mjs";
|
||||
|
||||
export const key = `customStatusIcons`;
|
||||
|
||||
export function customStatusIcons() {
|
||||
status[key] = SettingStatusEnum.Unknown;
|
||||
if (preventTweakRegistration(key)) { return };
|
||||
|
||||
// #region Registration
|
||||
Logger.log(`Registering tweak: ${key}`);
|
||||
game.settings.registerMenu(__ID__, `${key}Menu`, {
|
||||
name: `OFT.menu.${key}.name`,
|
||||
hint: `OFT.menu.${key}.hint`,
|
||||
label: `OFT.menu.${key}.label`,
|
||||
restricted: true,
|
||||
type: StatusEffectIconConfig,
|
||||
});
|
||||
game.settings.register(__ID__, key, {
|
||||
scope: `world`,
|
||||
config: false,
|
||||
type: Object,
|
||||
default: {},
|
||||
});
|
||||
// #endregion Registration
|
||||
|
||||
// #region Implementation
|
||||
Hooks.on(`ready`, () => {
|
||||
const value = game.settings.get(__ID__, key);
|
||||
|
||||
const effects = Object.values(CONFIG.statusEffects);
|
||||
for (const effect of effects) {
|
||||
if (value[effect.id] != null) {
|
||||
effect.img = value[effect.id];
|
||||
};
|
||||
};
|
||||
});
|
||||
// #endregion Implementation
|
||||
|
||||
status[key] = SettingStatusEnum.Registered;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue