mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Irk/83 homebrew currency (#193)
* add homebrew options to rename currency names * add title. remove localization from settings file since it didn't work. * use enabled toggle to use localized initial label values. * cleanup
This commit is contained in:
parent
778e569037
commit
b25e1cec78
8 changed files with 121 additions and 23 deletions
|
|
@ -24,14 +24,16 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
|
|||
editItem: this.editItem,
|
||||
removeItem: this.removeItem,
|
||||
resetMoves: this.resetMoves,
|
||||
save: this.save
|
||||
save: this.save,
|
||||
reset: this.reset
|
||||
},
|
||||
form: { handler: this.updateData, submitOnChange: true }
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
main: {
|
||||
template: 'systems/daggerheart/templates/settings/homebrew-settings.hbs'
|
||||
template: 'systems/daggerheart/templates/settings/homebrew-settings.hbs',
|
||||
scrollable: ['']
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -154,4 +156,27 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
|
|||
await game.settings.set(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Homebrew, this.settings.toObject());
|
||||
this.close();
|
||||
}
|
||||
|
||||
static async reset() {
|
||||
const resetSettings = new DhHomebrew();
|
||||
let localizedSettings = this.localizeObject(resetSettings);
|
||||
this.settings.updateSource(localizedSettings);
|
||||
this.render();
|
||||
}
|
||||
|
||||
localizeObject(obj) {
|
||||
for (let key in obj) {
|
||||
if (obj.hasOwnProperty(key)) {
|
||||
const value = obj[key];
|
||||
if (typeof value === 'object' && value !== null) {
|
||||
obj[key] = this.localizeObject(value);
|
||||
} else {
|
||||
if (typeof value === 'string' && value.startsWith('DAGGERHEART.')) {
|
||||
obj[key] = game.i18n.localize(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue