mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
144 - Update System Settings (#145)
* Updated SystemSettings to V2 and organized some * Corrected distance measuring labels * Raised system.json foundry version
This commit is contained in:
parent
f80a849b73
commit
7802d18a4d
32 changed files with 594 additions and 470 deletions
|
|
@ -50,7 +50,7 @@ export default class Resources extends HandlebarsApplicationMixin(ApplicationV2)
|
|||
}
|
||||
|
||||
get maxFear() {
|
||||
return game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Resources.MaxFear);
|
||||
return game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Homebrew).maxFear;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
|
@ -59,7 +59,7 @@ export default class Resources extends HandlebarsApplicationMixin(ApplicationV2)
|
|||
|
||||
/** @override */
|
||||
async _prepareContext(_options) {
|
||||
const display = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Resources.DisplayFear),
|
||||
const display = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.appearance).displayFear,
|
||||
current = this.currentFear,
|
||||
max = this.maxFear,
|
||||
percent = (current / max) * 100,
|
||||
|
|
|
|||
|
|
@ -1,178 +1,121 @@
|
|||
import { DualityRollColor } from '../config/settingsConfig.mjs';
|
||||
import { defaultLevelTiers, DhLevelTiers } from '../data/levelTier.mjs';
|
||||
import DhAppearance from '../data/settings/Appearance.mjs';
|
||||
import DHAppearanceSettings from './settings/appearanceSettings.mjs';
|
||||
import DhVariantRules from '../data/settings/VariantRules.mjs';
|
||||
import DHVariantRuleSettings from './settings/variantRuleSettings.mjs';
|
||||
|
||||
class DhpAutomationSettings extends FormApplication {
|
||||
constructor(object = {}, options = {}) {
|
||||
super(object, options);
|
||||
}
|
||||
|
||||
static get defaultOptions() {
|
||||
const defaults = super.defaultOptions;
|
||||
const overrides = {
|
||||
height: 'auto',
|
||||
width: 400,
|
||||
id: 'daggerheart-automation-settings',
|
||||
template: 'systems/daggerheart/templates/views/automation-settings.hbs',
|
||||
closeOnSubmit: true,
|
||||
submitOnChange: false,
|
||||
classes: ['daggerheart', 'views', 'settings']
|
||||
};
|
||||
|
||||
const mergedOptions = foundry.utils.mergeObject(defaults, overrides);
|
||||
|
||||
return mergedOptions;
|
||||
}
|
||||
|
||||
async getData() {
|
||||
const context = super.getData();
|
||||
context.settings = SYSTEM.SETTINGS.gameSettings.Automation;
|
||||
context.hope = await game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Automation.Hope);
|
||||
context.actionPoints = await game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Automation.ActionPoints);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
}
|
||||
|
||||
async _updateObject(_, formData) {
|
||||
const data = foundry.utils.expandObject(formData);
|
||||
const updateSettingsKeys = Object.keys(data);
|
||||
for (var i = 0; i < updateSettingsKeys.length; i++) {
|
||||
await game.settings.set(SYSTEM.id, updateSettingsKeys[i], data[updateSettingsKeys[i]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DhpHomebrewSettings extends FormApplication {
|
||||
constructor(object = {}, options = {}) {
|
||||
super(object, options);
|
||||
}
|
||||
|
||||
static get defaultOptions() {
|
||||
const defaults = super.defaultOptions;
|
||||
const overrides = {
|
||||
height: 'auto',
|
||||
width: 400,
|
||||
id: 'daggerheart-homebrew-settings',
|
||||
template: 'systems/daggerheart/templates/views/homebrew-settings.hbs',
|
||||
closeOnSubmit: true,
|
||||
submitOnChange: false,
|
||||
classes: ['daggerheart', 'views', 'settings']
|
||||
};
|
||||
|
||||
const mergedOptions = foundry.utils.mergeObject(defaults, overrides);
|
||||
|
||||
return mergedOptions;
|
||||
}
|
||||
|
||||
async getData() {
|
||||
const context = super.getData();
|
||||
context.settings = SYSTEM.SETTINGS.gameSettings.General;
|
||||
context.abilityArray = await game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.General.AbilityArray);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
}
|
||||
|
||||
async _updateObject(_, formData) {
|
||||
const data = foundry.utils.expandObject(formData);
|
||||
const updateSettingsKeys = Object.keys(data);
|
||||
for (var i = 0; i < updateSettingsKeys.length; i++) {
|
||||
await game.settings.set(SYSTEM.id, updateSettingsKeys[i], data[updateSettingsKeys[i]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class DhpRangeSettings extends FormApplication {
|
||||
constructor(object = {}, options = {}) {
|
||||
super(object, options);
|
||||
|
||||
this.range = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.General.RangeMeasurement);
|
||||
}
|
||||
|
||||
static get defaultOptions() {
|
||||
const defaults = super.defaultOptions;
|
||||
const overrides = {
|
||||
height: 'auto',
|
||||
width: 400,
|
||||
id: 'daggerheart-range-settings',
|
||||
template: 'systems/daggerheart/templates/views/range-settings.hbs',
|
||||
closeOnSubmit: false,
|
||||
submitOnChange: true,
|
||||
classes: ['daggerheart', 'views', 'settings']
|
||||
};
|
||||
|
||||
const mergedOptions = foundry.utils.mergeObject(defaults, overrides);
|
||||
|
||||
return mergedOptions;
|
||||
}
|
||||
|
||||
async getData() {
|
||||
const context = super.getData();
|
||||
context.settings = SYSTEM.SETTINGS.gameSettings.General;
|
||||
context.range = this.range;
|
||||
context.disabled =
|
||||
context.range.enabled &&
|
||||
[
|
||||
context.range.melee,
|
||||
context.range.veryClose,
|
||||
context.range.close,
|
||||
context.range.far,
|
||||
context.range.veryFar
|
||||
].some(x => x === null || x === false);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
html.find('.range-reset').click(this.reset.bind(this));
|
||||
html.find('.save').click(this.save.bind(this));
|
||||
html.find('.close').click(this.close.bind(this));
|
||||
}
|
||||
|
||||
async _updateObject(_, formData) {
|
||||
const data = foundry.utils.expandObject(formData, { disabled: true });
|
||||
this.range = foundry.utils.mergeObject(this.range, data);
|
||||
this.render(true);
|
||||
}
|
||||
|
||||
reset() {
|
||||
this.range = {
|
||||
enabled: false,
|
||||
melee: 5,
|
||||
veryClose: 15,
|
||||
close: 30,
|
||||
far: 60,
|
||||
veryFar: 120
|
||||
};
|
||||
this.render(true);
|
||||
}
|
||||
|
||||
async save() {
|
||||
await game.settings.set(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.General.RangeMeasurement, this.range);
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
import {
|
||||
DhAppearance,
|
||||
DhAutomation,
|
||||
DhHomebrew,
|
||||
DhRangeMeasurement,
|
||||
DhVariantRules
|
||||
} from '../data/settings/_module.mjs';
|
||||
import {
|
||||
DhAppearanceSettings,
|
||||
DhAutomationSettings,
|
||||
DhHomebrewSettings,
|
||||
DhRangeMeasurementSettings,
|
||||
DhVariantRuleSettings
|
||||
} from './settings/_module.mjs';
|
||||
|
||||
export const registerDHSettings = () => {
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.General.AbilityArray, {
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.General.AbilityArray.Name'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.General.AbilityArray.Hint'),
|
||||
registerMenuSettings();
|
||||
registerMenus();
|
||||
registerNonConfigSettings();
|
||||
};
|
||||
|
||||
const registerMenuSettings = () => {
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.variantRules, {
|
||||
scope: 'world',
|
||||
config: false,
|
||||
type: String,
|
||||
default: '[2,1,1,0,0,-1]'
|
||||
type: DhVariantRules
|
||||
});
|
||||
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Automation, {
|
||||
scope: 'world',
|
||||
config: false,
|
||||
type: DhAutomation
|
||||
});
|
||||
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Homebrew, {
|
||||
scope: 'world',
|
||||
config: false,
|
||||
type: DhHomebrew,
|
||||
onChange: value => {
|
||||
if (value.maxFear) {
|
||||
if (ui.resources) ui.resources.render({ force: true });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.appearance, {
|
||||
scope: 'client',
|
||||
config: false,
|
||||
type: DhAppearance,
|
||||
onChange: value => {
|
||||
if (value.displayFear) {
|
||||
if (ui.resources) {
|
||||
if (value.displayFear === 'hide') ui.resources.close({ allowed: true });
|
||||
else ui.resources.render({ force: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.RangeMeasurement, {
|
||||
scope: 'client',
|
||||
config: false,
|
||||
type: DhRangeMeasurement
|
||||
});
|
||||
};
|
||||
|
||||
const registerMenus = () => {
|
||||
game.settings.registerMenu(SYSTEM.id, SYSTEM.SETTINGS.menu.Automation.Name, {
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.Menu.Automation.Name'),
|
||||
label: game.i18n.localize('DAGGERHEART.Settings.Menu.Automation.Label'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.Menu.Automation.Hint'),
|
||||
icon: SYSTEM.SETTINGS.menu.Automation.Icon,
|
||||
type: DhAutomationSettings,
|
||||
restricted: true
|
||||
});
|
||||
game.settings.registerMenu(SYSTEM.id, SYSTEM.SETTINGS.menu.Homebrew.Name, {
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.Menu.Homebrew.Name'),
|
||||
label: game.i18n.localize('DAGGERHEART.Settings.Menu.Homebrew.Label'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.Menu.Homebrew.Hint'),
|
||||
icon: SYSTEM.SETTINGS.menu.Homebrew.Icon,
|
||||
type: DhHomebrewSettings,
|
||||
restricted: true
|
||||
});
|
||||
game.settings.registerMenu(SYSTEM.id, SYSTEM.SETTINGS.menu.Range.Name, {
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.Menu.Range.Name'),
|
||||
label: game.i18n.localize('DAGGERHEART.Settings.Menu.Range.Label'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.Menu.Range.Hint'),
|
||||
icon: SYSTEM.SETTINGS.menu.Range.Icon,
|
||||
type: DhRangeMeasurementSettings,
|
||||
restricted: true
|
||||
});
|
||||
|
||||
game.settings.registerMenu(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.appearance, {
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.Menu.Appearance.title'),
|
||||
label: game.i18n.localize('DAGGERHEART.Settings.Menu.Appearance.label'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.Menu.Appearance.hint'),
|
||||
icon: 'fa-solid fa-palette',
|
||||
type: DhAppearanceSettings,
|
||||
restricted: false
|
||||
});
|
||||
|
||||
game.settings.registerMenu(SYSTEM.id, SYSTEM.SETTINGS.menu.VariantRules.Name, {
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.Menu.VariantRules.title'),
|
||||
label: game.i18n.localize('DAGGERHEART.Settings.Menu.VariantRules.label'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.Menu.VariantRules.hint'),
|
||||
icon: SYSTEM.SETTINGS.menu.VariantRules.Icon,
|
||||
type: DhVariantRuleSettings,
|
||||
restricted: false
|
||||
});
|
||||
};
|
||||
|
||||
const registerNonConfigSettings = () => {
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.LevelTiers, {
|
||||
scope: 'world',
|
||||
config: false,
|
||||
type: DhLevelTiers,
|
||||
default: defaultLevelTiers
|
||||
});
|
||||
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Resources.Fear, {
|
||||
|
|
@ -187,144 +130,4 @@ export const registerDHSettings = () => {
|
|||
ui.combat.render({ force: true });
|
||||
}
|
||||
});
|
||||
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Resources.MaxFear, {
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.Resources.MaxFear.Name'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.Resources.MaxFear.Hint'),
|
||||
scope: 'world',
|
||||
config: true,
|
||||
type: Number,
|
||||
default: 12,
|
||||
onChange: () => {
|
||||
if (ui.resources) ui.resources.render({ force: true });
|
||||
}
|
||||
});
|
||||
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Resources.DisplayFear, {
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.Resources.DisplayFear.Name'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.Resources.DisplayFear.Hint'),
|
||||
scope: 'client',
|
||||
config: true,
|
||||
type: String,
|
||||
choices: {
|
||||
token: 'Tokens',
|
||||
bar: 'Bar',
|
||||
hide: 'Hide'
|
||||
},
|
||||
default: 'token',
|
||||
onChange: value => {
|
||||
if (ui.resources) {
|
||||
if (value === 'hide') ui.resources.close({ allowed: true });
|
||||
else ui.resources.render({ force: true });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Automation.Hope, {
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.Automation.Hope.Name'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.Automation.Hope.Hint'),
|
||||
scope: 'world',
|
||||
config: false,
|
||||
type: Boolean,
|
||||
default: false
|
||||
});
|
||||
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Automation.ActionPoints, {
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.Automation.ActionPoints.Name'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.Automation.ActionPoints.Hint'),
|
||||
scope: 'world',
|
||||
config: false,
|
||||
type: Boolean,
|
||||
default: true
|
||||
});
|
||||
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.General.RangeMeasurement, {
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.General.RangeMeasurement.Name'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.General.RangeMeasurement.Hint'),
|
||||
scope: 'world',
|
||||
config: false,
|
||||
type: Object,
|
||||
default: {
|
||||
enabled: true,
|
||||
melee: 5,
|
||||
veryClose: 15,
|
||||
close: 30,
|
||||
far: 60,
|
||||
veryFar: 120
|
||||
}
|
||||
});
|
||||
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.variantRules, {
|
||||
scope: 'world',
|
||||
config: false,
|
||||
type: DhVariantRules,
|
||||
default: DhVariantRules.defaultSchema
|
||||
});
|
||||
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.appearance, {
|
||||
scope: 'client',
|
||||
config: false,
|
||||
type: DhAppearance,
|
||||
default: DhAppearance.defaultSchema
|
||||
});
|
||||
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.DualityRollColor, {
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.DualityRollColor.Name'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.DualityRollColor.Hint'),
|
||||
scope: 'world',
|
||||
config: false,
|
||||
type: Number,
|
||||
choices: Object.values(DualityRollColor),
|
||||
default: DualityRollColor.colorful.value
|
||||
});
|
||||
|
||||
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.LevelTiers, {
|
||||
scope: 'world',
|
||||
config: false,
|
||||
type: DhLevelTiers,
|
||||
default: defaultLevelTiers
|
||||
});
|
||||
|
||||
game.settings.registerMenu(SYSTEM.id, SYSTEM.SETTINGS.menu.Automation.Name, {
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.Menu.Automation.Name'),
|
||||
label: game.i18n.localize('DAGGERHEART.Settings.Menu.Automation.Label'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.Menu.Automation.Hint'),
|
||||
icon: SYSTEM.SETTINGS.menu.Automation.Icon,
|
||||
type: DhpAutomationSettings,
|
||||
restricted: true
|
||||
});
|
||||
game.settings.registerMenu(SYSTEM.id, SYSTEM.SETTINGS.menu.Homebrew.Name, {
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.Menu.Homebrew.Name'),
|
||||
label: game.i18n.localize('DAGGERHEART.Settings.Menu.Homebrew.Label'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.Menu.Homebrew.Hint'),
|
||||
icon: SYSTEM.SETTINGS.menu.Homebrew.Icon,
|
||||
type: DhpHomebrewSettings,
|
||||
restricted: true
|
||||
});
|
||||
game.settings.registerMenu(SYSTEM.id, SYSTEM.SETTINGS.menu.Range.Name, {
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.Menu.Range.Name'),
|
||||
label: game.i18n.localize('DAGGERHEART.Settings.Menu.Range.Label'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.Menu.Range.Hint'),
|
||||
icon: SYSTEM.SETTINGS.menu.Range.Icon,
|
||||
type: DhpRangeSettings,
|
||||
restricted: true
|
||||
});
|
||||
|
||||
game.settings.registerMenu(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.appearance, {
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.Menu.Appearance.title'),
|
||||
label: game.i18n.localize('DAGGERHEART.Settings.Menu.Appearance.label'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.Menu.Appearance.hint'),
|
||||
icon: 'fa-solid fa-palette',
|
||||
type: DHAppearanceSettings,
|
||||
restricted: false
|
||||
});
|
||||
|
||||
game.settings.registerMenu(SYSTEM.id, SYSTEM.SETTINGS.menu.VariantRules.Name, {
|
||||
name: game.i18n.localize('DAGGERHEART.Settings.Menu.VariantRules.title'),
|
||||
label: game.i18n.localize('DAGGERHEART.Settings.Menu.VariantRules.label'),
|
||||
hint: game.i18n.localize('DAGGERHEART.Settings.Menu.VariantRules.hint'),
|
||||
icon: SYSTEM.SETTINGS.menu.VariantRules.Icon,
|
||||
type: DHVariantRuleSettings,
|
||||
restricted: false
|
||||
});
|
||||
};
|
||||
|
|
|
|||
13
module/applications/settings/_module.mjs
Normal file
13
module/applications/settings/_module.mjs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import DhAppearanceSettings from './appearanceSettings.mjs';
|
||||
import DhAutomationSettings from './automationSettings.mjs';
|
||||
import DhHomebrewSettings from './homebrewSettings.mjs';
|
||||
import DhRangeMeasurementSettings from './rangeMeasurementSettings.mjs';
|
||||
import DhVariantRuleSettings from './variantRuleSettings.mjs';
|
||||
|
||||
export {
|
||||
DhAppearanceSettings,
|
||||
DhAutomationSettings,
|
||||
DhHomebrewSettings,
|
||||
DhRangeMeasurementSettings,
|
||||
DhVariantRuleSettings
|
||||
};
|
||||
|
|
@ -54,20 +54,11 @@ export default class DHAppearanceSettings extends HandlebarsApplicationMixin(App
|
|||
|
||||
static async save() {
|
||||
await game.settings.set(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.appearance, this.settings.toObject());
|
||||
/* const reload = await foundry.applications.api.DialogV2.confirm({
|
||||
id: 'reload-world-confirm',
|
||||
modal: true,
|
||||
rejectClose: false,
|
||||
window: { title: 'SETTINGS.ReloadPromptTitle' },
|
||||
position: { width: 400 },
|
||||
content: `<p>${game.i18n.localize('SETTINGS.ReloadPromptBody')}</p>`
|
||||
});
|
||||
|
||||
if (reload) {
|
||||
await game.socket.emit('reload');
|
||||
foundry.utils.debouncedReload();
|
||||
} */
|
||||
document.body.classList.toggle('theme-colorful', game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.appearance).dualityColorScheme === DualityRollColor.colorful.value);
|
||||
document.body.classList.toggle(
|
||||
'theme-colorful',
|
||||
game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.appearance).dualityColorScheme ===
|
||||
DualityRollColor.colorful.value
|
||||
);
|
||||
|
||||
this.close();
|
||||
}
|
||||
|
|
|
|||
59
module/applications/settings/automationSettings.mjs
Normal file
59
module/applications/settings/automationSettings.mjs
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
import { DhAutomation } from '../../data/settings/_module.mjs';
|
||||
|
||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||
|
||||
export default class DhAutomationSettings extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
constructor() {
|
||||
super({});
|
||||
|
||||
this.settings = new DhAutomation(
|
||||
game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Automation).toObject()
|
||||
);
|
||||
}
|
||||
|
||||
get title() {
|
||||
return game.i18n.localize('DAGGERHEART.Settings.Menu.Automation.Name');
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
id: 'daggerheart-automation-settings',
|
||||
classes: ['daggerheart', 'setting', 'dh-style'],
|
||||
position: { width: '600', height: 'auto' },
|
||||
actions: {
|
||||
reset: this.reset,
|
||||
save: this.save
|
||||
},
|
||||
form: { handler: this.updateData, submitOnChange: true }
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
main: {
|
||||
template: 'systems/daggerheart/templates/settings/automation-settings.hbs'
|
||||
}
|
||||
};
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
context.settingFields = this.settings;
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
static async updateData(event, element, formData) {
|
||||
const updatedSettings = foundry.utils.expandObject(formData.object);
|
||||
|
||||
await this.settings.updateSource(updatedSettings);
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async reset() {
|
||||
this.settings = new DhAutomation();
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async save() {
|
||||
await game.settings.set(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Automation, this.settings.toObject());
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
60
module/applications/settings/homebrewSettings.mjs
Normal file
60
module/applications/settings/homebrewSettings.mjs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import { DhHomebrew } from '../../data/settings/_module.mjs';
|
||||
|
||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||
|
||||
export default class DhAutomationSettings extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
constructor() {
|
||||
super({});
|
||||
|
||||
this.settings = new DhHomebrew(game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Homebrew).toObject());
|
||||
}
|
||||
|
||||
get title() {
|
||||
return game.i18n.localize('DAGGERHEART.Settings.Menu.Homebrew.Name');
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
id: 'daggerheart-homebrew-settings',
|
||||
classes: ['daggerheart', 'setting', 'dh-style'],
|
||||
position: { width: '600', height: 'auto' },
|
||||
actions: {
|
||||
reset: this.reset,
|
||||
save: this.save
|
||||
},
|
||||
form: { handler: this.updateData, submitOnChange: true }
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
main: {
|
||||
template: 'systems/daggerheart/templates/settings/homebrew-settings.hbs'
|
||||
}
|
||||
};
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
context.settingFields = this.settings;
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
static async updateData(event, element, formData) {
|
||||
const updatedSettings = foundry.utils.expandObject(formData.object);
|
||||
|
||||
await this.settings.updateSource({
|
||||
...updatedSettings,
|
||||
traitArray: Object.values(updatedSettings.traitArray)
|
||||
});
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async reset() {
|
||||
this.settings = new DhHomebrew();
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async save() {
|
||||
await game.settings.set(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Homebrew, this.settings.toObject());
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
59
module/applications/settings/rangeMeasurementSettings.mjs
Normal file
59
module/applications/settings/rangeMeasurementSettings.mjs
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
import { DhRangeMeasurement } from '../../data/settings/_module.mjs';
|
||||
|
||||
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||
|
||||
export default class DhRangeMeasurementSettings extends HandlebarsApplicationMixin(ApplicationV2) {
|
||||
constructor() {
|
||||
super({});
|
||||
|
||||
this.settings = new DhRangeMeasurement(
|
||||
game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.RangeMeasurement).toObject()
|
||||
);
|
||||
}
|
||||
|
||||
get title() {
|
||||
return game.i18n.localize('DAGGERHEART.Settings.Menu.Automation.Name');
|
||||
}
|
||||
|
||||
static DEFAULT_OPTIONS = {
|
||||
tag: 'form',
|
||||
id: 'daggerheart-automation-settings',
|
||||
classes: ['daggerheart', 'setting', 'dh-style'],
|
||||
position: { width: '600', height: 'auto' },
|
||||
actions: {
|
||||
reset: this.reset,
|
||||
save: this.save
|
||||
},
|
||||
form: { handler: this.updateData, submitOnChange: true }
|
||||
};
|
||||
|
||||
static PARTS = {
|
||||
main: {
|
||||
template: 'systems/daggerheart/templates/settings/range-measurement-settings.hbs'
|
||||
}
|
||||
};
|
||||
|
||||
async _prepareContext(_options) {
|
||||
const context = await super._prepareContext(_options);
|
||||
context.settingFields = this.settings;
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
static async updateData(event, element, formData) {
|
||||
const updatedSettings = foundry.utils.expandObject(formData.object);
|
||||
|
||||
await this.settings.updateSource(updatedSettings);
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async reset() {
|
||||
this.settings = new DhRangeMeasurement();
|
||||
this.render();
|
||||
}
|
||||
|
||||
static async save() {
|
||||
await game.settings.set(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.RangeMeasurement, this.settings.toObject());
|
||||
this.close();
|
||||
}
|
||||
}
|
||||
|
|
@ -165,18 +165,18 @@ export default class CharacterSheet extends DaggerheartSheet(ActorSheetV2) {
|
|||
context.config = SYSTEM;
|
||||
|
||||
const selectedAttributes = Object.values(this.document.system.traits).map(x => x.base);
|
||||
context.abilityScoreArray = JSON.parse(
|
||||
await game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.General.AbilityArray)
|
||||
).reduce((acc, x) => {
|
||||
const selectedIndex = selectedAttributes.indexOf(x);
|
||||
if (selectedIndex !== -1) {
|
||||
selectedAttributes.splice(selectedIndex, 1);
|
||||
} else {
|
||||
acc.push({ name: x, value: x });
|
||||
}
|
||||
context.abilityScoreArray = await game.settings
|
||||
.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.Homebrew)
|
||||
.traitArray.reduce((acc, x) => {
|
||||
const selectedIndex = selectedAttributes.indexOf(x);
|
||||
if (selectedIndex !== -1) {
|
||||
selectedAttributes.splice(selectedIndex, 1);
|
||||
} else {
|
||||
acc.push({ name: x, value: x });
|
||||
}
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
return acc;
|
||||
}, []);
|
||||
if (!context.abilityScoreArray.includes(0)) context.abilityScoreArray.push({ name: 0, value: 0 });
|
||||
context.abilityScoresFinished = context.abilityScoreArray.every(x => x.value === 0);
|
||||
|
||||
|
|
|
|||
|
|
@ -337,3 +337,9 @@ export const rollTypes = {
|
|||
label: 'DAGGERHEART.RollTypes.ability.name'
|
||||
}
|
||||
};
|
||||
|
||||
export const fearDisplay = {
|
||||
token: { value: 'token', label: 'DAGGERHEART.Settings.Appearance.FearDisplay.Token' },
|
||||
bar: { value: 'bar', label: 'DAGGERHEART.Settings.Appearance.FearDisplay.Bar' },
|
||||
hide: { value: 'hide', label: 'DAGGERHEART.Settings.Appearance.FearDisplay.Hide' }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,23 +18,15 @@ export const menu = {
|
|||
};
|
||||
|
||||
export const gameSettings = {
|
||||
Automation: {
|
||||
Hope: 'AutomationHope',
|
||||
ActionPoints: 'AutomationActionPoints'
|
||||
},
|
||||
Resources: {
|
||||
Fear: 'ResourcesFear',
|
||||
MaxFear: 'ResourcesMaxFear',
|
||||
DisplayFear: 'DisplayFear'
|
||||
},
|
||||
General: {
|
||||
AbilityArray: 'AbilityArray',
|
||||
RangeMeasurement: 'RangeMeasurement'
|
||||
},
|
||||
DualityRollColor: 'DualityRollColor',
|
||||
LevelTiers: 'LevelTiers',
|
||||
Automation: 'Automation',
|
||||
Homebrew: 'Homebrew',
|
||||
RangeMeasurement: 'RangeMeasurement',
|
||||
appearance: 'Appearance',
|
||||
variantRules: 'VariantRules'
|
||||
variantRules: 'VariantRules',
|
||||
Resources: {
|
||||
Fear: 'ResourcesFear'
|
||||
},
|
||||
LevelTiers: 'LevelTiers'
|
||||
};
|
||||
|
||||
export const DualityRollColor = {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,15 @@
|
|||
import { fearDisplay } from '../../config/generalConfig.mjs';
|
||||
|
||||
export default class DhAppearance extends foundry.abstract.DataModel {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
displayFear: new fields.StringField({
|
||||
required: true,
|
||||
choices: fearDisplay,
|
||||
initial: fearDisplay.token.value,
|
||||
label: 'DAGGERHEART.Settings.Appearance.FIELDS.displayFear.label'
|
||||
}),
|
||||
dualityColorScheme: new fields.StringField({
|
||||
required: true,
|
||||
choices: DualityRollColor,
|
||||
|
|
@ -35,8 +43,6 @@ export default class DhAppearance extends foundry.abstract.DataModel {
|
|||
})
|
||||
};
|
||||
}
|
||||
|
||||
static defaultSchema = {};
|
||||
}
|
||||
|
||||
export const DualityRollColor = {
|
||||
|
|
|
|||
11
module/data/settings/Automation.mjs
Normal file
11
module/data/settings/Automation.mjs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
export default class DhAutomation extends foundry.abstract.DataModel {
|
||||
static LOCALIZATION_PREFIXES = ['DAGGERHEART.Settings.Automation']; // Doesn't work for some reason
|
||||
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
hope: new fields.BooleanField({ required: true, initial: false }),
|
||||
actionPoints: new fields.BooleanField({ required: true, initial: false })
|
||||
};
|
||||
}
|
||||
}
|
||||
19
module/data/settings/Homebrew.mjs
Normal file
19
module/data/settings/Homebrew.mjs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
export default class DhHomebrew extends foundry.abstract.DataModel {
|
||||
static LOCALIZATION_PREFIXES = ['DAGGERHEART.Settings.Homebrew']; // Doesn't work for some reason
|
||||
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
maxFear: new fields.NumberField({
|
||||
required: true,
|
||||
integer: true,
|
||||
min: 0,
|
||||
initial: 12,
|
||||
label: 'DAGGERHEART.Settings.Homebrew.FIELDS.maxFear.label'
|
||||
}),
|
||||
traitArray: new fields.ArrayField(new fields.NumberField({ required: true, integer: true }), {
|
||||
initial: () => [2, 1, 1, 0, 0, -1]
|
||||
})
|
||||
};
|
||||
}
|
||||
}
|
||||
17
module/data/settings/RangeMeasurement.mjs
Normal file
17
module/data/settings/RangeMeasurement.mjs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
export default class DhRangeMeasurement extends foundry.abstract.DataModel {
|
||||
static defineSchema() {
|
||||
const fields = foundry.data.fields;
|
||||
return {
|
||||
enabled: new fields.BooleanField({ required: true, initial: false, label: 'DAGGERHEART.General.Enabled' }),
|
||||
melee: new fields.NumberField({ required: true, initial: 5, label: 'DAGGERHEART.Range.melee.name' }),
|
||||
veryClose: new fields.NumberField({
|
||||
required: true,
|
||||
initial: 15,
|
||||
label: 'DAGGERHEART.Range.veryClose.name'
|
||||
}),
|
||||
close: new fields.NumberField({ required: true, initial: 30, label: 'DAGGERHEART.Range.close.name' }),
|
||||
far: new fields.NumberField({ required: true, initial: 60, label: 'DAGGERHEART.Range.far.name' }),
|
||||
veryFar: new fields.NumberField({ required: true, initial: 120, label: 'DAGGERHEART.Range.veryFar.name' })
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -5,12 +5,22 @@ export default class DhVariantRules extends foundry.abstract.DataModel {
|
|||
const fields = foundry.data.fields;
|
||||
return {
|
||||
actionTokens: new fields.SchemaField({
|
||||
enabled: new fields.BooleanField({ required: true, initial: false }),
|
||||
tokens: new fields.NumberField({ required: true, integer: true, initial: 3 })
|
||||
enabled: new fields.BooleanField({
|
||||
required: true,
|
||||
initial: false,
|
||||
label: 'DAGGERHEART.Settings.VariantRules.FIELDS.actionTokens.enabled.label'
|
||||
}),
|
||||
tokens: new fields.NumberField({
|
||||
required: true,
|
||||
integer: true,
|
||||
initial: 3,
|
||||
label: 'DAGGERHEART.Settings.VariantRules.FIELDS.actionTokens.tokens.label'
|
||||
})
|
||||
}),
|
||||
useCoins: new fields.BooleanField({ initial: false })
|
||||
useCoins: new fields.BooleanField({
|
||||
initial: false,
|
||||
label: 'DAGGERHEART.Settings.VariantRules.FIELDS.useCoins.label'
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
static defaultSchema = {};
|
||||
}
|
||||
|
|
|
|||
7
module/data/settings/_module.mjs
Normal file
7
module/data/settings/_module.mjs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import DhAppearance from './Appearance.mjs';
|
||||
import DhAutomation from './Automation.mjs';
|
||||
import DhHomebrew from './Homebrew.mjs';
|
||||
import DhRangeMeasurement from './RangeMeasurement.mjs';
|
||||
import DhVariantRules from './VariantRules.mjs';
|
||||
|
||||
export { DhAppearance, DhAutomation, DhHomebrew, DhRangeMeasurement, DhVariantRules };
|
||||
|
|
@ -3,7 +3,7 @@ export default class DhpRuler extends foundry.canvas.interaction.Ruler {
|
|||
const context = super._getWaypointLabelContext(waypoint, state);
|
||||
if (!context) return;
|
||||
|
||||
const range = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.General.RangeMeasurement);
|
||||
const range = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.RangeMeasurement);
|
||||
|
||||
if (range.enabled) {
|
||||
const distance = this.#getRangeLabel(waypoint.measurement.distance.toNearest(0.01), range);
|
||||
|
|
@ -16,19 +16,19 @@ export default class DhpRuler extends foundry.canvas.interaction.Ruler {
|
|||
|
||||
#getRangeLabel(distance, settings) {
|
||||
if (distance <= settings.melee) {
|
||||
return game.i18n.localize('DAGGERHEART.Range.Melee.Name');
|
||||
return game.i18n.localize('DAGGERHEART.Range.melee.name');
|
||||
}
|
||||
if (distance <= settings.veryClose) {
|
||||
return game.i18n.localize('DAGGERHEART.Range.VeryClose.Name');
|
||||
return game.i18n.localize('DAGGERHEART.Range.veryClose.name');
|
||||
}
|
||||
if (distance <= settings.close) {
|
||||
return game.i18n.localize('DAGGERHEART.Range.Close.Name');
|
||||
return game.i18n.localize('DAGGERHEART.Range.close.name');
|
||||
}
|
||||
if (distance <= settings.far) {
|
||||
return game.i18n.localize('DAGGERHEART.Range.Far.Name');
|
||||
return game.i18n.localize('DAGGERHEART.Range.far.name');
|
||||
}
|
||||
if (distance <= settings.veryFar) {
|
||||
return game.i18n.localize('DAGGERHEART.Range.VeryFar.Name');
|
||||
return game.i18n.localize('DAGGERHEART.Range.veryFar.name');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ export default class DhpTokenRuler extends foundry.canvas.placeables.tokens.Toke
|
|||
const context = super._getWaypointLabelContext(waypoint, state);
|
||||
if (!context) return;
|
||||
|
||||
const range = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.General.RangeMeasurement);
|
||||
const range = game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.RangeMeasurement);
|
||||
|
||||
if (range.enabled) {
|
||||
const distance = this.#getRangeLabel(waypoint.measurement.distance.toNearest(0.01), range);
|
||||
|
|
@ -16,19 +16,19 @@ export default class DhpTokenRuler extends foundry.canvas.placeables.tokens.Toke
|
|||
|
||||
#getRangeLabel(distance, settings) {
|
||||
if (distance <= settings.melee) {
|
||||
return game.i18n.localize('DAGGERHEART.Range.Melee.Name');
|
||||
return game.i18n.localize('DAGGERHEART.Range.melee.name');
|
||||
}
|
||||
if (distance <= settings.veryClose) {
|
||||
return game.i18n.localize('DAGGERHEART.Range.VeryClose.Name');
|
||||
return game.i18n.localize('DAGGERHEART.Range.veryClose.name');
|
||||
}
|
||||
if (distance <= settings.close) {
|
||||
return game.i18n.localize('DAGGERHEART.Range.Close.Name');
|
||||
return game.i18n.localize('DAGGERHEART.Range.close.name');
|
||||
}
|
||||
if (distance <= settings.far) {
|
||||
return game.i18n.localize('DAGGERHEART.Range.Far.Name');
|
||||
return game.i18n.localize('DAGGERHEART.Range.far.name');
|
||||
}
|
||||
if (distance <= settings.veryFar) {
|
||||
return game.i18n.localize('DAGGERHEART.Range.VeryFar.Name');
|
||||
return game.i18n.localize('DAGGERHEART.Range.veryFar.name');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue