diff --git a/module/dialogs/DiceList.mjs b/module/dialogs/DiceList.mjs index 64d1091..0881a24 100644 --- a/module/dialogs/DiceList.mjs +++ b/module/dialogs/DiceList.mjs @@ -1,6 +1,7 @@ import { GenericDialog } from "./GenericDialog.mjs"; export class DiceList extends GenericDialog { + constructor(mobActor) { super({}, { title: `${mobActor.name}'s Dice List` }); this.actor = mobActor; @@ -14,22 +15,31 @@ export class DiceList extends GenericDialog { const opts = mergeObject({ ...super.defaultOptions, template: `systems/dotdungeon/templates/dialogs/diceList.hbs`, - width: 400, + width: 275, height: 400, - submitOnClose: true, + submitOnClose: false, + resizable: true, }); - opts.classes.push(`dotdungeon`); + opts.classes?.push(`dotdungeon`); return opts; }; async getData() { const ctx = await super.getData(); ctx.dice = this.dice; + console.debug(`DiceList context`, ctx); return ctx; }; - async _updateObject(event, formData) { - console.log(event, formData); + async _updateObject(_event, formData) { + const newDice = this.dice.map(d => { + return { + count: formData[`${d.id}.count`], + sides: formData[`${d.id}.sides`], + repeat: formData[`${d.id}.repeat`], + }; + }); + await this.actor.update({ "system.dice": newDice }); }; addDie() { @@ -41,4 +51,10 @@ export class DiceList extends GenericDialog { }); this.render(); }; + + deleteDie($e) { + const data = $e.currentTarget.dataset; + this.dice = this.dice.filter(d => d.id !== data.id); + this.render(); + }; }; diff --git a/module/dialogs/GenericDialog.mjs b/module/dialogs/GenericDialog.mjs index b7fba3f..1cd1c02 100644 --- a/module/dialogs/GenericDialog.mjs +++ b/module/dialogs/GenericDialog.mjs @@ -42,4 +42,8 @@ export class GenericDialog extends FormApplication { if (!this[data.action]) return; this[data.action].bind(this)($e); }; + + closeNoSave() { + this.close({ submit: false, }); + }; }; diff --git a/styles/_vars.scss b/styles/_vars.scss index 690dcae..ddb9cf1 100644 --- a/styles/_vars.scss +++ b/styles/_vars.scss @@ -8,7 +8,7 @@ $background: #f2f2f2; $colour-confirm: #048A81; $text-on-confirm: white; -$colour-neutral: #007ACC; +$colour-neutral: darkblue; $text-on-neutral: white; $colour-danger: #960200; diff --git a/styles/dialog/DiceList.scss b/styles/dialog/DiceList.scss index b7b66ab..469539e 100644 --- a/styles/dialog/DiceList.scss +++ b/styles/dialog/DiceList.scss @@ -1,3 +1,54 @@ -.dotdungeon.dialog--dice-list { - padding: 4px; +.dotdungeon:has(.dialog--dice-list) { + max-width: 275px; + min-width: 275px; +} + +.dotdungeon .dialog--dice-list { + padding: 8px; + + .dice { + display: flex; + flex-direction: column; + gap: 8px; + } + + .die { + align-items: center; + border: 2px solid; + border-radius: 4px; + display: grid; + gap: 4px; + grid-template-rows: 40px; + grid-template-columns: 1fr 15px 1fr 15px 1fr 15px 1fr; + padding: 4px; + text-align: center; + + label { + font-size: 0.8125rem; + } + + .large { font-size: 1.2rem; } + + .count { grid-column: 1; } + .sides { grid-column: 3; } + .repeat { grid-column: 5; } + + button { grid-column: 7; } + + input { + height: 100%; + font-size: 1.1rem; + } + } + + .actions { + margin-top: 8px; + display: flex; + flex-direction: row; + gap: 4px; + + button { + flex-grow: 1; + } + } } \ No newline at end of file diff --git a/styles/global/buttons.scss b/styles/global/buttons.scss index 04e809e..6364e93 100644 --- a/styles/global/buttons.scss +++ b/styles/global/buttons.scss @@ -8,7 +8,10 @@ border-color: transparent; border-width: 2px; border-radius: 4px; - transition: 400ms; + transition: + background-color 400ms ease-in-out, + color 400ms ease-in-out, + border-color 400ms ease-in-out; padding: 4px 8px; display: inline-flex; justify-content: center; diff --git a/styles/mixins/_partials.scss b/styles/mixins/_partials.scss index e5d897b..bc8e5e7 100644 --- a/styles/mixins/_partials.scss +++ b/styles/mixins/_partials.scss @@ -4,12 +4,12 @@ border-width: 2px; border-radius: 4px; border-style: solid; - border-color: rgba(0,0,0, 0.4); - background-color: rgba(0,0,0, 0.1); + border-color: black; font-family: $input-font; + box-shadow: none; &:focus, &:active { - border-color: rgba(0,0,0, 1); + transform: scale(103%); } } \ No newline at end of file diff --git a/styles/root.scss b/styles/root.scss index ac65ff7..5ee2a84 100644 --- a/styles/root.scss +++ b/styles/root.scss @@ -7,6 +7,8 @@ @use "./global/icons.scss"; @use "./global/buttons.scss"; +@use "./dialog/DiceList.scss"; + @use "./sheets/partials/stat.scss"; @use "./sheets/partials/skill.scss"; @use "./sheets/partials/panel.scss"; diff --git a/templates/actors/mobs/main.hbs b/templates/actors/mobs/main.hbs index d5b7432..10ae5cd 100644 --- a/templates/actors/mobs/main.hbs +++ b/templates/actors/mobs/main.hbs @@ -27,8 +27,8 @@