Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(settings): token resources #1405

Merged
merged 5 commits into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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