Skip to content

Commit

Permalink
feat(settings): token resources (#1405)
Browse files Browse the repository at this point in the history
* feat(settings): token resources

* show wounds/stats by default

#1357

* fix(settings): merge existing settings

#1357

* fix(settings): update default display mode

#1357
  • Loading branch information
wrycu authored Apr 6, 2024
1 parent 8b040f8 commit a06228c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
9 changes: 8 additions & 1 deletion modules/settings/settings-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ export default class SettingsHelpers {
},
});


// Increase compatibility with old versions (likely to make new games kinda weird as it updates items from chat data)
game.settings.register("starwarsffg", "oldWorldCompatability", {
name: game.i18n.localize("SWFFG.OldWorld.CompatLabel"),
Expand All @@ -297,6 +296,14 @@ export default class SettingsHelpers {
type: Boolean,
onChange: this.debouncedReload,
});

// auto-configure the default values of tokens - once
game.settings.register("starwarsffg", "token_configured", {
scope: "world",
config: false,
default: false,
type: Boolean,
});
}

// Initialize System Settings after the Ready Hook
Expand Down
17 changes: 17 additions & 0 deletions modules/swffg-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,23 @@ function isCurrentVersionNullOrBlank(currentVersion) {
Hooks.once("ready", async () => {
SettingsHelpers.readyLevelSetting();

if (!game.settings.get("starwarsffg", "token_configured")) {
const tokenData = {
bar1: {
attribute: "stats.wounds",
},
bar2: {
attribute: "stats.strain",
},
displayBars: 20, // hovered by owner
};
const existingSettings = game.settings.get("core", "defaultToken");
const updateData = foundry.utils.mergeObject(existingSettings, tokenData);
game.settings.set("core", "defaultToken", updateData);
game.settings.set("starwarsffg", "token_configured", true);
}


const currentVersion = game.settings.get("starwarsffg", "systemMigrationVersion");

const version = game.system.version;
Expand Down

0 comments on commit a06228c

Please sign in to comment.