add homebrew options to rename currency names

This commit is contained in:
IrkTheImp 2025-06-28 00:01:12 -05:00
parent c6cede40b2
commit a4c7533743
7 changed files with 91 additions and 16 deletions

View file

@ -1,5 +1,6 @@
import { DhHomebrew } from '../../data/settings/_module.mjs';
import DhSettingsActionView from './components/settingsActionsView.mjs';
import { defaultRestOptions } from '../../config/generalConfig.mjs';
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
@ -24,14 +25,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 +157,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() {
//For some reason this doesn't seem to localize any of the strings, so calling a recursive call to localize all strings. ¯\_(ツ)_/¯
const resetSettings = new DhHomebrew();
let localizedSettings = this.localizeObject(resetSettings);
await 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) {
} else {
if (typeof value === 'string' && value.startsWith('DAGGERHEART.')) {
obj[key] = game.i18n.localize(value);
}
}
}
}
return obj;
}
}

View file

@ -328,7 +328,8 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
quantity: game.i18n.localize('DAGGERHEART.Sheets.PC.InventoryTab.QuantityTitle')
},
items: this.document.items.filter(x => x.type === 'armor')
}
},
currency: game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Homebrew).currency
};
if (context.inventory.length === 0) {