From bf8440e53d2ae5637f41e4ee828dc42d7c7b1e7c Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Sat, 28 Dec 2024 17:14:43 -0700 Subject: [PATCH] RC-30 | Weapons | Table Setup --- Apps/HeroSummaryCardV1/content.hbs | 26 ++++++++++++++++- Apps/HeroSummaryCardV1/style.css | 24 ++++++++++++++- Apps/common.css | 16 ++++++++++ langs/en-ca.json | 15 +++++++--- module/Apps/ActorSheets/HeroSummaryCardV1.mjs | 29 ++++++++++++++----- 5 files changed, 97 insertions(+), 13 deletions(-) diff --git a/Apps/HeroSummaryCardV1/content.hbs b/Apps/HeroSummaryCardV1/content.hbs index 4e92245..155eec3 100644 --- a/Apps/HeroSummaryCardV1/content.hbs +++ b/Apps/HeroSummaryCardV1/content.hbs @@ -33,6 +33,30 @@ {{!-- * Weapons --}} + + + + + + + + + + + {{#each weapons as | slot |}} + {{#if slot.empty}} + + + + + + + {{else}} + + {{/if}} + {{/each}} + +
{{ rc-i18n "RipCrypt.common.weapon.plural" }}{{ rc-i18n "RipCrypt.Apps.traits-range" }}{{ rc-i18n "RipCrypt.common.wear" }}{{ rc-i18n "RipCrypt.common.damage" }}
---
{{!-- * Abilities --}}
@@ -77,7 +101,7 @@ {{speed.run}}
diff --git a/Apps/HeroSummaryCardV1/style.css b/Apps/HeroSummaryCardV1/style.css index 1005652..4559f0c 100644 --- a/Apps/HeroSummaryCardV1/style.css +++ b/Apps/HeroSummaryCardV1/style.css @@ -4,7 +4,7 @@ --input-height: 1rem; display: grid; - grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) minmax(0, 2fr) minmax(0, 1fr) minmax(0, 2.5fr); + grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) minmax(0, 2fr) minmax(0, 1.25fr) minmax(0, 2.5fr); grid-template-rows: repeat(15, minmax(0, 1fr)); column-gap: var(--col-gap); @@ -23,6 +23,10 @@ box-sizing: border-box; padding: 2px 4px; text-transform: uppercase; + font-size: var(--font-size-14); + overflow: hidden; + text-overflow: ellipsis; + font-weight: bold; } .header { @@ -53,6 +57,24 @@ grid-template-rows: subgrid; } + .weapons { + grid-column: 1 / span 4; + grid-row: 7 / span 5; + display: grid; + grid-template-columns: subgrid; + grid-auto-rows: min-content; + overflow-y: auto; + + thead, + tbody, + tr { + display: contents; + } + .row-alt > * { + background: inherit; + } + } + .abilities { grid-column: 1 / span 4; grid-row: 12 / span 4; diff --git a/Apps/common.css b/Apps/common.css index a1da70a..c463636 100644 --- a/Apps/common.css +++ b/Apps/common.css @@ -10,6 +10,22 @@ --col-gap: 2px; } + table { + all: revert; + box-sizing: border-box; + border-collapse: collapse; + + thead, tbody, tr { + all: revert; + } + td, th { + all: revert; + padding: 2px 4px; + font-weight: initial; + text-align: left; + } + } + input { all: revert; box-sizing: border-box; diff --git a/langs/en-ca.json b/langs/en-ca.json index 20b6d86..c24df1e 100644 --- a/langs/en-ca.json +++ b/langs/en-ca.json @@ -26,7 +26,15 @@ "gait": "Gait", "grip": "Grip", "glim": "Glim" - } + }, + "traits": "Traits", + "range": "Range", + "weapon": { + "singular": "Weapon", + "plural": "Weapons" + }, + "wear": "Wear", + "damage": "Damage" }, "setting": { "abbrAccess": { @@ -35,9 +43,8 @@ } }, "Apps": { - "HeroSummaryCardV1": { - "move-run": "@RipCrypt.common.move • @RipCrypt.common.run" - } + "move-run": "@RipCrypt.common.move • @RipCrypt.common.run", + "traits-range": "@RipCrypt.common.traits • @RipCrypt.common.range" } } } diff --git a/module/Apps/ActorSheets/HeroSummaryCardV1.mjs b/module/Apps/ActorSheets/HeroSummaryCardV1.mjs index 596ab13..021e9bc 100644 --- a/module/Apps/ActorSheets/HeroSummaryCardV1.mjs +++ b/module/Apps/ActorSheets/HeroSummaryCardV1.mjs @@ -46,9 +46,10 @@ export class HeroSummaryCardV1 extends HandlebarsApplicationMixin(ActorSheetV2) ctx.actor = this.document; - ctx = await this.prepareFatePath(ctx); - ctx = await this.prepareAbilityRow(ctx); - ctx = await this.prepareSpeed(ctx); + ctx = await HeroSummaryCardV1.prepareWeapons(ctx); + ctx = await HeroSummaryCardV1.prepareFatePath(ctx); + ctx = await HeroSummaryCardV1.prepareAbilityRow(ctx); + ctx = await HeroSummaryCardV1.prepareSpeed(ctx); partId = partId.slice(0,1).toUpperCase() + partId.slice(1); if (this[`_prepare${partId}Context`] != null) { @@ -59,7 +60,7 @@ export class HeroSummaryCardV1 extends HandlebarsApplicationMixin(ActorSheetV2) return ctx; }; - async prepareFatePath(ctx) { + static async prepareFatePath(ctx) { ctx.fate = {}; ctx.fate.selected = ctx.actor.system.fate; ctx.fate.options = [ @@ -70,7 +71,7 @@ export class HeroSummaryCardV1 extends HandlebarsApplicationMixin(ActorSheetV2) return ctx; }; - async prepareAbilityRow(ctx) { + static async prepareAbilityRow(ctx) { ctx.abilities = []; for (const key in ctx.actor.system.ability) { ctx.abilities.push({ @@ -80,16 +81,30 @@ export class HeroSummaryCardV1 extends HandlebarsApplicationMixin(ActorSheetV2) { value: ctx.actor.system.ability[key] }, ), value: ctx.actor.system.ability[key], - readonly: !this.isEditable, + readonly: !ctx.editable, }); }; return ctx; }; - async prepareSpeed(ctx) { + static async prepareSpeed(ctx) { ctx.speed = ctx.actor.system.speed; return ctx; }; + + static async prepareWeapons(ctx) { + const limit = ctx.actor.system.limit.weapons; + ctx.weapons = []; + for (let i = 0; i < limit; i++) { + ctx.weapons.push({ + data: null, + empty: true, + index: i + 1, + class: i % 2 === 1 ? `row-alt` : ``, + }); + }; + return ctx; + } // #endregion // #region Actions