From 2ac6d3a919e02b235a5a10e57915bb287ed03ddc Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Tue, 29 Dec 2020 01:44:54 +0100 Subject: [PATCH] working weapons section in char sheet Additions: - re-added getData() method of actor sheet for sorted items - added an item-description CSS class for handling of overflow - added a 1.5 CSS flex box Changes: - restricted previous sample items section to only weapons (to be re-used for other item types) Fixes: - fixed input types in weapon sheet --- src/module/actor/actor-sheet.ts | 15 +++++++ src/scss/components/_items.scss | 11 +++++ src/scss/global/_flex.scss | 6 +++ src/templates/actor/partials/items.hbs | 57 +++++++++++++++++++++----- src/templates/item/weapon-sheet.hbs | 4 +- 5 files changed, 80 insertions(+), 13 deletions(-) diff --git a/src/module/actor/actor-sheet.ts b/src/module/actor/actor-sheet.ts index bdb89182..7f26c5b3 100644 --- a/src/module/actor/actor-sheet.ts +++ b/src/module/actor/actor-sheet.ts @@ -6,6 +6,21 @@ import { DS4ActorDataType } from "./actor-data"; * @extends {ActorSheet} */ export class DS4ActorSheet extends ActorSheet { + /** + * This method returns the data for the template of the actor sheet. + * It explicitly adds the items of the object sorted by type in the + * object itemsByType. + * @returns the data fed to the template of the actor sheet + */ + getData(): ActorSheetData { + const data = super.getData(); + // Add the items explicitly sorted by type to the data: + const itemsByType = this.actor.itemTypes; + data["itemsByType"] = itemsByType; + console.log("Shields:", data); + return data; + } + /** @override */ static get defaultOptions(): FormApplicationOptions { return mergeObject(super.defaultOptions, { diff --git a/src/scss/components/_items.scss b/src/scss/components/_items.scss index 7a2d860b..e13c8458 100644 --- a/src/scss/components/_items.scss +++ b/src/scss/components/_items.scss @@ -32,4 +32,15 @@ flex: 0 0 86px; text-align: right; } + + .item-description { + font-size: 75%; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + p { + text-overflow: ellipsis; + overflow: hidden; + } + } } diff --git a/src/scss/global/_flex.scss b/src/scss/global/_flex.scss index af5108e5..d96c79c5 100644 --- a/src/scss/global/_flex.scss +++ b/src/scss/global/_flex.scss @@ -15,6 +15,9 @@ .flex1 { flex: 1; } + .flex15 { + flex: 1.5; + } .flex2 { flex: 2; } @@ -38,6 +41,9 @@ .flex1 { flex: 1; } + .flex15 { + flex: 1.5; + } .flex2 { flex: 2; } diff --git a/src/templates/actor/partials/items.hbs b/src/templates/actor/partials/items.hbs index 4b75dd2e..50d5c817 100644 --- a/src/templates/actor/partials/items.hbs +++ b/src/templates/actor/partials/items.hbs @@ -1,26 +1,61 @@ +{{!-- TODO: add localization! --}} {{!-- Tab with overview and quick-actions on owned items --}}
+ + {{!-- WEAPONS --}} +

Weapons

  1. -
    -
    Name
    -
    - Add item +
    +
    {{!-- equipped --}} +
    +
    #
    {{!-- amount --}} +
    +
    Name
    +
    AT
    {{!-- attack type --}} {{!-- SPECIFIC --}} +
    +
    WB
    {{!-- weapon bonus --}} {{!-- SPECIFIC --}} +
    OD
    {{!-- opponent defence --}} {{!-- SPECIFIC --}} +
    +
    Desc
    {{!-- description --}} + {{!-- add button --}} +
    {{!-- SPECIFIC --}} + + Add item {{!-- SPECIFIC --}}
  2. - {{#each actor.items as |item id|}} + {{#each itemsByType.weapon as |item id|}} {{!-- SPECIFIC --}} + {{#with item.data.data as |itemData|}}
  3. -
    - +
    + {{!-- equipped? --}} + {{#if itemData.equipped}} + {{else}} + {{/if}} {{!--SPECIFIC --}} + {{!-- image --}} +
    + +
    + {{!-- amount --}} +
    {{itemData.quantity}}
    -

    {{item.name}}

    -
    + {{!-- name --}} +

    {{item.name}}

    + {{!-- item specifics --}} +
    {{itemData.attackType}}
    {{!-- SPECIFIC --}} +
    +
    {{itemData.weaponBonus}}
    {{!-- SPECIFIC --}} +
    {{itemData.opponentDefense}}
    {{!-- SPECIFIC --}} +
    + {{!-- description --}} +
    {{{itemData.description}}}
    + {{!-- edit & delete buttons --}} +
  4. + {{/with}} {{/each}}
\ No newline at end of file diff --git a/src/templates/item/weapon-sheet.hbs b/src/templates/item/weapon-sheet.hbs index 4c0f89be..ce77965e 100644 --- a/src/templates/item/weapon-sheet.hbs +++ b/src/templates/item/weapon-sheet.hbs @@ -17,12 +17,12 @@
-
-