mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
[PR] [Feature] 590 - Daggerheart Menu (#1007)
* Added menu with refresh tools * Replaced menu icon
This commit is contained in:
parent
eefb28c312
commit
f1b6d3851d
53 changed files with 730 additions and 350 deletions
|
|
@ -33,7 +33,7 @@ export default class DHAppearanceSettings extends HandlebarsApplicationMixin(App
|
|||
tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' },
|
||||
main: { template: 'systems/daggerheart/templates/settings/appearance-settings/main.hbs' },
|
||||
diceSoNice: { template: 'systems/daggerheart/templates/settings/appearance-settings/diceSoNice.hbs' },
|
||||
footer: { template: "templates/generic/form-footer.hbs" }
|
||||
footer: { template: 'templates/generic/form-footer.hbs' }
|
||||
};
|
||||
|
||||
/** @inheritdoc */
|
||||
|
|
@ -41,7 +41,7 @@ export default class DHAppearanceSettings extends HandlebarsApplicationMixin(App
|
|||
general: {
|
||||
tabs: [
|
||||
{ id: 'main', label: 'DAGGERHEART.GENERAL.Tabs.general' },
|
||||
{ id: 'diceSoNice', label: 'DAGGERHEART.SETTINGS.Menu.appearance.diceSoNice.title' },
|
||||
{ id: 'diceSoNice', label: 'DAGGERHEART.SETTINGS.Menu.appearance.diceSoNice.title' }
|
||||
],
|
||||
initial: 'main'
|
||||
},
|
||||
|
|
@ -73,7 +73,7 @@ export default class DHAppearanceSettings extends HandlebarsApplicationMixin(App
|
|||
/** @inheritdoc */
|
||||
_configureRenderParts(options) {
|
||||
const parts = super._configureRenderParts(options);
|
||||
if (!game.modules.get('dice-so-nice')?.active){
|
||||
if (!game.modules.get('dice-so-nice')?.active) {
|
||||
delete parts.diceSoNice;
|
||||
delete parts.tabs;
|
||||
}
|
||||
|
|
@ -83,7 +83,8 @@ export default class DHAppearanceSettings extends HandlebarsApplicationMixin(App
|
|||
/**@inheritdoc */
|
||||
async _prepareContext(options) {
|
||||
const context = await super._prepareContext(options);
|
||||
if (options.isFirstRender) this.setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance);
|
||||
if (options.isFirstRender)
|
||||
this.setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance);
|
||||
|
||||
context.setting = this.setting;
|
||||
context.fields = this.setting.schema.fields;
|
||||
|
|
@ -99,18 +100,17 @@ export default class DHAppearanceSettings extends HandlebarsApplicationMixin(App
|
|||
const partContext = await super._preparePartContext(partId, context, options);
|
||||
if (partId in context.tabs) partContext.tab = partContext.tabs[partId];
|
||||
switch (partId) {
|
||||
case "diceSoNice":
|
||||
case 'diceSoNice':
|
||||
await this.prepareDiceSoNiceContext(partContext);
|
||||
break;
|
||||
case "footer":
|
||||
case 'footer':
|
||||
partContext.buttons = [
|
||||
{ type: "button", action: "reset", icon: "fa-solid fa-arrow-rotate-left", label: "Reset" },
|
||||
{ type: "submit", icon: "fa-solid fa-floppy-disk", label: "Save Changes" }
|
||||
{ type: 'button', action: 'reset', icon: 'fa-solid fa-arrow-rotate-left', label: 'Reset' },
|
||||
{ type: 'submit', icon: 'fa-solid fa-floppy-disk', label: 'Save Changes' }
|
||||
];
|
||||
break;
|
||||
}
|
||||
return partContext;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -120,32 +120,44 @@ export default class DHAppearanceSettings extends HandlebarsApplicationMixin(App
|
|||
* @protected
|
||||
*/
|
||||
async prepareDiceSoNiceContext(context) {
|
||||
context.diceSoNiceTextures = Object.entries(game.dice3d.exports.TEXTURELIST).reduce((acc, [k, v]) => ({
|
||||
...acc,
|
||||
[k]: v.name
|
||||
}), {});
|
||||
context.diceSoNiceColorsets = Object.values(game.dice3d.exports.COLORSETS).reduce((acc, v) => ({
|
||||
...acc,
|
||||
[v.id]: v.description
|
||||
}), {});
|
||||
context.diceSoNiceMaterials = Object.keys(game.dice3d.DiceFactory.material_options).reduce((acc, key) => ({
|
||||
...acc,
|
||||
[key]: `DICESONICE.Material${key.capitalize()}`
|
||||
}), {});
|
||||
context.diceSoNiceSystems = Object.fromEntries([...game.dice3d.DiceFactory.systems].map(([k, v]) => [k, v.name]));
|
||||
context.diceSoNiceTextures = Object.entries(game.dice3d.exports.TEXTURELIST).reduce(
|
||||
(acc, [k, v]) => ({
|
||||
...acc,
|
||||
[k]: v.name
|
||||
}),
|
||||
{}
|
||||
);
|
||||
context.diceSoNiceColorsets = Object.values(game.dice3d.exports.COLORSETS).reduce(
|
||||
(acc, v) => ({
|
||||
...acc,
|
||||
[v.id]: v.description
|
||||
}),
|
||||
{}
|
||||
);
|
||||
context.diceSoNiceMaterials = Object.keys(game.dice3d.DiceFactory.material_options).reduce(
|
||||
(acc, key) => ({
|
||||
...acc,
|
||||
[key]: `DICESONICE.Material${key.capitalize()}`
|
||||
}),
|
||||
{}
|
||||
);
|
||||
context.diceSoNiceSystems = Object.fromEntries(
|
||||
[...game.dice3d.DiceFactory.systems].map(([k, v]) => [k, v.name])
|
||||
);
|
||||
|
||||
foundry.utils.mergeObject(context.dsnTabs, [
|
||||
"hope",
|
||||
"fear",
|
||||
"advantage",
|
||||
"disadvantage",
|
||||
].reduce((acc, key) => ({
|
||||
...acc,
|
||||
[key]: {
|
||||
values: this.setting.diceSoNice[key],
|
||||
fields: this.setting.schema.getField(`diceSoNice.${key}`).fields,
|
||||
}
|
||||
}), {}));
|
||||
foundry.utils.mergeObject(
|
||||
context.dsnTabs,
|
||||
['hope', 'fear', 'advantage', 'disadvantage'].reduce(
|
||||
(acc, key) => ({
|
||||
...acc,
|
||||
[key]: {
|
||||
values: this.setting.diceSoNice[key],
|
||||
fields: this.setting.schema.getField(`diceSoNice.${key}`).fields
|
||||
}
|
||||
}),
|
||||
{}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -169,7 +181,7 @@ export default class DHAppearanceSettings extends HandlebarsApplicationMixin(App
|
|||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #onPreview(_, target) {
|
||||
const formData = new foundry.applications.ux.FormDataExtended(target.closest("form"));
|
||||
const formData = new foundry.applications.ux.FormDataExtended(target.closest('form'));
|
||||
const { diceSoNice } = foundry.utils.expandObject(formData.object);
|
||||
const { key } = target.dataset;
|
||||
const faces = ['advantage', 'disadvantage'].includes(key) ? 'd6' : 'd12';
|
||||
|
|
@ -181,10 +193,10 @@ export default class DHAppearanceSettings extends HandlebarsApplicationMixin(App
|
|||
}
|
||||
|
||||
/**
|
||||
* Reset the form back to default values.
|
||||
* @this {DHAppearanceSettings}
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
* Reset the form back to default values.
|
||||
* @this {DHAppearanceSettings}
|
||||
* @type {ApplicationClickAction}
|
||||
*/
|
||||
static async #onReset() {
|
||||
this.setting = new this.setting.constructor();
|
||||
this.render({ force: false });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue