Duality Roll Followup (#65)

* Moved the roll total to bottom right. A bunch of label fixes
* Fixed broken attack-roll damage button
* Added AppearanceMenu allowing modification of DiceSoNice Duality presets
This commit is contained in:
WBHarry 2025-05-27 20:07:47 +02:00 committed by GitHub
parent 6fcfce227a
commit c4a03b2d54
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 685 additions and 400 deletions

View file

@ -1,5 +1,5 @@
import { DualityRollColor } from '../config/settingsConfig.mjs';
import DhpDualityRoll from '../data/dualityRoll.mjs';
import { DualityRollColor } from '../data/settings/Appearance.mjs';
export default class DhpChatMesssage extends ChatMessage {
async renderHTML() {
@ -16,7 +16,7 @@ export default class DhpChatMesssage extends ChatMessage {
const html = await super.renderHTML();
if (
this.type === 'dualityRoll' &&
game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.DualityRollColor) ===
game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.appearance).dualityColorScheme ===
DualityRollColor.colorful.value
) {
html.classList.add('duality');

View file

@ -1,4 +1,5 @@
import { DualityRollColor } from '../config/settingsConfig.mjs';
import DhAppearance from '../data/settings/Appearance.mjs';
import DHAppearanceSettings from './settings/appearanceSettings.mjs';
class DhpAutomationSettings extends FormApplication {
constructor(object = {}, options = {}) {
@ -160,7 +161,7 @@ class DhpRangeSettings extends FormApplication {
}
}
export const registerDHPSettings = () => {
export const registerDHSettings = () => {
// const debouncedReload = foundry.utils.debounce(() => window.location.reload(), 100);
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.General.AbilityArray, {
@ -215,14 +216,11 @@ export const registerDHPSettings = () => {
}
});
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: true,
type: Number,
choices: Object.values(DualityRollColor),
default: DualityRollColor.colorful.value
game.settings.register(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.appearance, {
scope: 'client',
config: false,
type: DhAppearance,
default: DhAppearance.defaultSchema
});
game.settings.registerMenu(SYSTEM.id, SYSTEM.SETTINGS.menu.Automation.Name, {
@ -249,53 +247,13 @@ export const registerDHPSettings = () => {
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
});
};
// const {HandlebarsApplicationMixin, ApplicationV2} = foundry.applications.api;
// export default class DhpSettings extends HandlebarsApplicationMixin(ApplicationV2) {
// constructor(actor, shortrest){
// super({});
// this.actor = actor;
// this.selectedActivity = null;
// this.shortrest = shortrest;
// this.customActivity = SYSTEM.GENERAL.downtime.custom;
// }
// get title(){
// return game.i18n.localize("DAGGERHEART.Application.Settings.Title");
// }
// static DEFAULT_OPTIONS = {
// tag: 'form',
// classes: ["daggerheart", "application", "settings"],
// position: { width: 800, height: 'auto' },
// actions: {
// selectActivity: this.selectActivity,
// },
// form: { handler: this.updateData }
// };
// static PARTS = {
// application: {
// id: "settings",
// template: "systems/daggerheart/templates/application/settings.hbs"
// }
// }
// async _prepareContext(_options) {
// const context = await super._prepareContext(_options);
// return context;
// }
// static async updateData(event, element, formData){
// this.render();
// }
// static close(){
// super.close();
// }
// }

View file

@ -0,0 +1,59 @@
import DhAppearance from '../../data/settings/Appearance.mjs';
const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
export default class DHAppearanceSettings extends HandlebarsApplicationMixin(ApplicationV2) {
constructor() {
super({});
this.settings = new DhAppearance(
game.settings.get(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.appearance).toObject()
);
}
get title() {
return game.i18n.localize('DAGGERHEART.Settings.Menu.Appearance.name');
}
static DEFAULT_OPTIONS = {
tag: 'form',
id: 'daggerheart-appearance-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/appearance-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 DhAppearance();
this.render();
}
static async save() {
await game.settings.set(SYSTEM.id, SYSTEM.SETTINGS.gameSettings.appearance, this.settings.toObject());
this.close();
}
}

View file

@ -489,7 +489,7 @@ export default class PCSheet extends DaggerheartSheet(ActorSheetV2) {
static async rollAttribute(event, button) {
const { roll, hope, fear, advantage, disadvantage, modifiers } = await this.document.dualityRoll(
{ title: 'Attribute Bonus', value: button.dataset.value },
{ title: game.i18n.localize(abilities[button.dataset.attribute].label), value: button.dataset.value },
event.shiftKey
);