From 150a0ea487d9379026ce3351d1fdc05c8318f8ca Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 01:24:37 +0100 Subject: [PATCH 01/11] added talents overview and sheet - added talents item type: - added scss - added to template.json (Item.types, Item.talent) - added to config.ts itemTypes - added type definition - added localizations - added talent overview tab to actor sheet - made total rank calculated upon data preparation by adding a prepareData method to DS4Item --- src/ds4.scss | 1 + src/lang/en.json | 10 +- src/module/config.ts | 1 + src/module/ds4.ts | 1 + src/module/item/item-data.ts | 12 ++- src/module/item/item.ts | 10 +- src/scss/components/_talents.scss | 3 + src/template.json | 10 +- src/templates/actor/actor-sheet.hbs | 8 +- .../actor/partials/talents-overview.hbs | 95 +++++++++++++++++++ src/templates/item/talent-sheet.hbs | 63 ++++++++++++ 11 files changed, 208 insertions(+), 6 deletions(-) create mode 100644 src/scss/components/_talents.scss create mode 100644 src/templates/actor/partials/talents-overview.hbs create mode 100644 src/templates/item/talent-sheet.hbs diff --git a/src/ds4.scss b/src/ds4.scss index 2fedca1f..b69bbd1f 100644 --- a/src/ds4.scss +++ b/src/ds4.scss @@ -16,6 +16,7 @@ @import "scss/components/basic_property"; @import "scss/components/tabs"; @import "scss/components/items"; + @import "scss/components/talents"; @import "scss/components/description"; @import "scss/components/character_values"; @import "scss/components/attributes_traits"; diff --git a/src/lang/en.json b/src/lang/en.json index de17c09b..5227291e 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -5,6 +5,8 @@ "DS4.DescriptionAbbr": "Desc", "DS4.Details": "Details", "DS4.Effects": "Effects", + "DS4.Items": "Items", + "DS4.Talents": "Talents & Abilities", "DS4.AttackType": "Attack Type", "DS4.AttackTypeAbbr": "AT", "DS4.WeaponBonus": "Weapon Bonus", @@ -33,6 +35,7 @@ "DS4.ItemTypeShield": "Shield", "DS4.ItemTypeTrinket": "Trinket", "DS4.ItemTypeEquipment": "Equipment", + "DS4.ItemTypeTalent": "Talent", "DS4.ArmorType": "Armor Type", "DS4.ArmorTypeAbbr": "AT", "DS4.ArmorMaterialType": "Material Type", @@ -81,5 +84,10 @@ "DS4.ProgressionLevel": "Level", "DS4.ProgressionExperiencePoints": "Experience Points", "DS4.ProgressionTalentPoints": "Talent Points", - "DS4.ProgressionProgressPoints": "Progress Points" + "DS4.ProgressionProgressPoints": "Progress Points", + "DS4.TalentRank": "Rank", + "DS4.TalentRankBase": "Acquired Ranks", + "DS4.TalentRankMax": "Maximum Ranks", + "DS4.TalentRankMod": "Additional Ranks", + "DS4.TalentRankTotal": "Total Ranks" } diff --git a/src/module/config.ts b/src/module/config.ts index 89d285cf..502927ef 100644 --- a/src/module/config.ts +++ b/src/module/config.ts @@ -48,6 +48,7 @@ export const DS4 = { shield: "DS4.ItemTypeShield", trinket: "DS4.ItemTypeTrinket", equipment: "DS4.ItemTypeEquipment", + talent: "DS4.ItemTypeTalent", }, /** diff --git a/src/module/ds4.ts b/src/module/ds4.ts index 358074b0..4bcf2223 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -37,6 +37,7 @@ async function registerHandlebarsPartials() { "systems/ds4/templates/item/partials/effects.hbs", "systems/ds4/templates/item/partials/body.hbs", "systems/ds4/templates/actor/partials/items-overview.hbs", + "systems/ds4/templates/actor/partials/talents-overview.hbs", "systems/ds4/templates/actor/partials/attributes-traits.hbs", "systems/ds4/templates/actor/partials/combat-values.hbs", ]; diff --git a/src/module/item/item-data.ts b/src/module/item/item-data.ts index 58f4dc90..a2cbc61b 100644 --- a/src/module/item/item-data.ts +++ b/src/module/item/item-data.ts @@ -1,5 +1,7 @@ +import { ModifiableData } from "../actor/actor-data"; + // TODO: Actually add a type for data -export type DS4ItemDataType = DS4Weapon | DS4Armor | DS4Shield | DS4Trinket | DS4Equipment; +export type DS4ItemDataType = DS4Weapon | DS4Armor | DS4Shield | DS4Trinket | DS4Equipment | DS4Talent; // types @@ -14,6 +16,14 @@ interface DS4Armor extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable, DS4It armorType: "body" | "helmet" | "vambrace" | "greaves" | "vambraceGreaves"; } +export interface DS4Talent extends DS4ItemBase { + talentRank: DS4TalentRank; +} + +interface DS4TalentRank extends ModifiableData { + max: number; +} + interface DS4Shield extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable, DS4ItemProtective {} interface DS4Trinket extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable {} interface DS4Equipment extends DS4ItemBase, DS4ItemPhysical {} diff --git a/src/module/item/item.ts b/src/module/item/item.ts index c32f0cfe..814a6e15 100644 --- a/src/module/item/item.ts +++ b/src/module/item/item.ts @@ -1,6 +1,6 @@ import { DS4Actor } from "../actor/actor"; import { DS4ActorDataType } from "../actor/actor-data"; -import { DS4ItemDataType } from "./item-data"; +import { DS4ItemDataType, DS4Talent } from "./item-data"; /** * Extend the basic Item with some very simple modifications. @@ -12,10 +12,18 @@ export class DS4Item extends Item { */ prepareData(): void { super.prepareData(); + this.prepareDerivedData(); // Get the Item's data // const itemData = this.data; // const actorData = this.actor ? this.actor.data : {}; // const data = itemData.data; } + + prepareDerivedData(): void { + if (this.type === "talent") { + const data: DS4Talent = this.data.data as DS4Talent; + data.talentRank.total = data.talentRank.base + data.talentRank.mod; + } + } } diff --git a/src/scss/components/_talents.scss b/src/scss/components/_talents.scss new file mode 100644 index 00000000..2f8db41b --- /dev/null +++ b/src/scss/components/_talents.scss @@ -0,0 +1,3 @@ +.talent-ranks-equation { + text-align: center; +} diff --git a/src/template.json b/src/template.json index b78fd3e1..f412936e 100644 --- a/src/template.json +++ b/src/template.json @@ -100,7 +100,7 @@ } }, "Item": { - "types": ["weapon", "armor", "shield", "trinket", "equipment"], + "types": ["weapon", "armor", "shield", "trinket", "equipment", "talent"], "templates": { "base": { "description": "" @@ -137,6 +137,14 @@ }, "equipment": { "templates": ["base", "physical"] + }, + "talent": { + "templates": ["base"], + "talentRank": { + "base": 0, + "max": 0, + "mod": 0 + } } } } diff --git a/src/templates/actor/actor-sheet.hbs b/src/templates/actor/actor-sheet.hbs index 475ce2fd..b22aae3b 100644 --- a/src/templates/actor/actor-sheet.hbs +++ b/src/templates/actor/actor-sheet.hbs @@ -90,8 +90,9 @@ {{!-- Sheet Tab Navigation --}} {{!-- Sheet Body --}} @@ -101,6 +102,9 @@ {{editor content=data.biography target="data.biography" button=true owner=owner editable=editable}} + {{!-- Talents Tab --}} + {{> systems/ds4/templates/actor/partials/talents-overview.hbs}} + {{!-- Items Tab --}} {{> systems/ds4/templates/actor/partials/items-overview.hbs}} diff --git a/src/templates/actor/partials/talents-overview.hbs b/src/templates/actor/partials/talents-overview.hbs new file mode 100644 index 00000000..03a9335d --- /dev/null +++ b/src/templates/actor/partials/talents-overview.hbs @@ -0,0 +1,95 @@ +{{!-- ======================================================================== --}} +{{!-- INLINE PARTIAL DEFINITIONS --}} +{{!-- ======================================================================== --}} + +{{!-- +!-- Render an "add" button for a given data type. +!-- +!-- @param datType: hand over the dataType to the partial as hash parameter +--}} +{{#*inline "addItemButton"}} + +{{/inline}} +{{!-- +!-- Render a group of an "edit" and a "delete" button for the current item. +!-- The current item is defined by the data-item-id HTML property of the parent li element. +--}} +{{#*inline "itemControlButtons"}} +
+ + +
+{{/inline}} + + +{{#*inline "talentRankValue"}} + +{{/inline}} + +{{!-- +!-- Render a talent list row from a given item. +!-- It is a flexbox with a child for each item value of interest. +!-- The partial assumes a variable item to be given in the context. +!-- +!-- @param item: hand over the item to the partial as hash parameter +!-- @param partial-block: hand over custom children of the flexbox in the partial block. +--}} +{{#*inline "talentListEntry"}} +
  • + {{!-- image --}} +
    + +
    + {{!-- name --}} + +
    + {{!-- acquired rank --}} + {{> talentRankValue item=item property='base' localizeString='DS4.TalentRankBase'}} + ( of + {{!-- maximum acquirable rank --}} + {{> talentRankValue item=item property='max' localizeString='DS4.TalentRankMax'}} + ) + + {{!-- additional ranks --}} + {{> talentRankValue item=item property='mod' localizeString='DS4.TalentRankMod'}} + = + {{!-- derived total rank --}} + {{item.data.data.talentRank.total}} +
    + {{!-- description --}} +
    {{{item.data.data.description}}}
    + {{!-- control buttons --}} + {{> itemControlButtons}} +
  • +{{/inline}} + + +{{!-- ======================================================================== --}} + + +
    +
      +
    1. + {{!-- image --}} +
      + {{!-- name --}} +
      {{localize 'DS4.ItemName'}}
      + {{!-- rank info --}} +
      {{localize 'DS4.TalentRank'}}
      + {{!-- description --}} +
      {{localize 'DS4.Description'}}
      + {{!-- add button --}} + {{> addItemButton dataType='talent' }} +
    2. + {{#each itemsByType.talent as |item id|}} + {{> talentListEntry item=item}} + {{/each}} +
    +
    \ No newline at end of file diff --git a/src/templates/item/talent-sheet.hbs b/src/templates/item/talent-sheet.hbs new file mode 100644 index 00000000..400999c7 --- /dev/null +++ b/src/templates/item/talent-sheet.hbs @@ -0,0 +1,63 @@ + +{{#*inline "talentRankSideProperty" }} +
    + + +
    +{{/inline}} + + +
    +
    + +
    +

    +

    {{localize (lookup config.itemTypes item.type)}}

    +
    +
    + + {{!-- Sheet Tab Navigation --}} + + + {{!-- Sheet Body --}} +
    + {{!-- The item tab for details. --}} +
    + {{!-- As you add new fields, add them in here! --}} +
    + {{!-- TODO: remove duplication of isOwned section here and in description.hbs--}} + {{#if isOwned}} + {{#if (ne data.equipped undefined)}}
    + + +
    + {{/if}} +
    + + {{actor.name}} +
    + {{else}} + {{localize "DS4.NotOwned"}} + {{/if}} + {{> talentRankSideProperty data=data property='base' localizeString='DS4.TalentRankBase' }} + {{> talentRankSideProperty data=data property='max' localizeString='DS4.TalentRankMax'}} + {{> talentRankSideProperty data=data property='mod' localizeString='DS4.TalentRankMod'}} + {{> talentRankSideProperty data=data property='total' localizeString='DS4.TalentRankTotal' disabled='disabled'}} +
    +
    + {{editor content=data.description target="data.description" button=true owner=owner editable=editable}} +
    +
    + +
    + + {{!-- Effects Tab --}} + {{> systems/ds4/templates/item/partials/effects.hbs}} + +
    From 637b70c5d2364c51007f93e506c3d3247481a6e8 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 11:39:39 +0100 Subject: [PATCH 02/11] added invalidity hints to item side-properties - added :invalid definition to side-properties CSS - defined common color for invalidity - now using disabled input for automatically calculated properties --- src/scss/components/_description.scss | 7 ++++++- src/scss/components/_items.scss | 7 ++++--- src/scss/utils/_colors.scss | 1 + src/templates/actor/partials/talents-overview.hbs | 3 ++- src/templates/item/partials/description.hbs | 4 ++-- src/templates/item/talent-sheet.hbs | 7 +++++++ 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/scss/components/_description.scss b/src/scss/components/_description.scss index 8bd3b18b..72080381 100644 --- a/src/scss/components/_description.scss +++ b/src/scss/components/_description.scss @@ -22,7 +22,12 @@ text-align: left; width: calc(100% - 2px); } - + input:invalid { + background-color: $c-invalid-input; + } + input:disabled { + background-color: transparent; + } input[type="checkbox"] { width: auto; height: 100%; diff --git a/src/scss/components/_items.scss b/src/scss/components/_items.scss index 4dd97f78..fea61e0c 100644 --- a/src/scss/components/_items.scss +++ b/src/scss/components/_items.scss @@ -31,6 +31,7 @@ input { border: 0; padding: 0; + background-color: transparent; } input[type="checkbox"] { @@ -38,6 +39,9 @@ height: 100%; margin: 0px; } + input:invalid { + background-color: $c-invalid-input; + } } .item-name { @@ -54,9 +58,6 @@ width: 2.5em; padding: 0; } - .item-num-val:invalid { - background-color: color.mix(lightcoral, $c-light-grey, 25%); - } .item-description { font-size: 75%; diff --git a/src/scss/utils/_colors.scss b/src/scss/utils/_colors.scss index 7a2200d1..55fb8c0a 100644 --- a/src/scss/utils/_colors.scss +++ b/src/scss/utils/_colors.scss @@ -2,3 +2,4 @@ $c-white: #fff; $c-black: #000; $c-light-grey: #777; $c-border-groove: #eeede0; +$c-invalid-input: rgba(lightcoral, 50%); diff --git a/src/templates/actor/partials/talents-overview.hbs b/src/templates/actor/partials/talents-overview.hbs index 03a9335d..81839750 100644 --- a/src/templates/actor/partials/talents-overview.hbs +++ b/src/templates/actor/partials/talents-overview.hbs @@ -29,6 +29,7 @@ {{#*inline "talentRankValue"}} {{/inline}} @@ -61,7 +62,7 @@ {{> talentRankValue item=item property='mod' localizeString='DS4.TalentRankMod'}} = {{!-- derived total rank --}} - {{item.data.data.talentRank.total}} + {{> talentRankValue item=item property='total' localizeString='DS4.TalentRankTotal' disabled='disabled'}} {{!-- description --}}
    {{{item.data.data.description}}}
    diff --git a/src/templates/item/partials/description.hbs b/src/templates/item/partials/description.hbs index 1776f1f2..c1c7ae26 100644 --- a/src/templates/item/partials/description.hbs +++ b/src/templates/item/partials/description.hbs @@ -20,10 +20,10 @@ {{else}} - {{localize "DS4.NotOwned"}} + {{localize "DS4.NotOwned"}} {{/if}} -
    +
    {{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
    \ No newline at end of file diff --git a/src/templates/item/talent-sheet.hbs b/src/templates/item/talent-sheet.hbs index 400999c7..27529f06 100644 --- a/src/templates/item/talent-sheet.hbs +++ b/src/templates/item/talent-sheet.hbs @@ -1,3 +1,7 @@ +{{!-- ======================================================================== --}} +{{!-- INLINE PARTIAL DEFINITIONS --}} +{{!-- ======================================================================== --}} + {{#*inline "talentRankSideProperty" }}
    @@ -9,6 +13,9 @@ {{/inline}} +{{!-- ======================================================================== --}} + +
    From c98c64de1ef74bcdb72a1bbe41db478e6ad5971a Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 11:35:56 +0100 Subject: [PATCH 03/11] Apply 1 suggestion(s) to 1 file(s) --- src/module/item/item-data.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/module/item/item-data.ts b/src/module/item/item-data.ts index a2cbc61b..4bf5f16d 100644 --- a/src/module/item/item-data.ts +++ b/src/module/item/item-data.ts @@ -1,6 +1,5 @@ import { ModifiableData } from "../actor/actor-data"; -// TODO: Actually add a type for data export type DS4ItemDataType = DS4Weapon | DS4Armor | DS4Shield | DS4Trinket | DS4Equipment | DS4Talent; // types From 17b5eee90250afbc9d4dee3943dcfe660d9653f5 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 11:36:06 +0100 Subject: [PATCH 04/11] Apply 1 suggestion(s) to 1 file(s) --- src/module/item/item.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/item/item.ts b/src/module/item/item.ts index 814a6e15..2859aedf 100644 --- a/src/module/item/item.ts +++ b/src/module/item/item.ts @@ -22,7 +22,7 @@ export class DS4Item extends Item { prepareDerivedData(): void { if (this.type === "talent") { - const data: DS4Talent = this.data.data as DS4Talent; + const data = this.data.data as DS4Talent; data.talentRank.total = data.talentRank.base + data.talentRank.mod; } } From 98f31d9e8c13c9d613c3999b66c3229686370e08 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 11:52:11 +0100 Subject: [PATCH 05/11] renamed talent property from talentRank to rank --- src/module/item/item-data.ts | 2 +- src/module/item/item.ts | 2 +- src/template.json | 2 +- src/templates/actor/partials/talents-overview.hbs | 5 +++-- src/templates/item/talent-sheet.hbs | 6 +++--- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/module/item/item-data.ts b/src/module/item/item-data.ts index 4bf5f16d..be1a0042 100644 --- a/src/module/item/item-data.ts +++ b/src/module/item/item-data.ts @@ -16,7 +16,7 @@ interface DS4Armor extends DS4ItemBase, DS4ItemPhysical, DS4ItemEquipable, DS4It } export interface DS4Talent extends DS4ItemBase { - talentRank: DS4TalentRank; + rank: DS4TalentRank; } interface DS4TalentRank extends ModifiableData { diff --git a/src/module/item/item.ts b/src/module/item/item.ts index 2859aedf..e9a1aa3e 100644 --- a/src/module/item/item.ts +++ b/src/module/item/item.ts @@ -23,7 +23,7 @@ export class DS4Item extends Item { prepareDerivedData(): void { if (this.type === "talent") { const data = this.data.data as DS4Talent; - data.talentRank.total = data.talentRank.base + data.talentRank.mod; + data.rank.total = data.rank.base + data.rank.mod; } } } diff --git a/src/template.json b/src/template.json index f412936e..39b96699 100644 --- a/src/template.json +++ b/src/template.json @@ -140,7 +140,7 @@ }, "talent": { "templates": ["base"], - "talentRank": { + "rank": { "base": 0, "max": 0, "mod": 0 diff --git a/src/templates/actor/partials/talents-overview.hbs b/src/templates/actor/partials/talents-overview.hbs index 81839750..f70421e3 100644 --- a/src/templates/actor/partials/talents-overview.hbs +++ b/src/templates/actor/partials/talents-overview.hbs @@ -1,6 +1,7 @@ {{!-- ======================================================================== --}} {{!-- INLINE PARTIAL DEFINITIONS --}} {{!-- ======================================================================== --}} +{{!-- TODO: remove duplicate add and delete button definition --}} {{!-- !-- Render an "add" button for a given data type. @@ -28,9 +29,9 @@ {{#*inline "talentRankValue"}} {{/inline}} diff --git a/src/templates/item/talent-sheet.hbs b/src/templates/item/talent-sheet.hbs index 27529f06..0c9dc198 100644 --- a/src/templates/item/talent-sheet.hbs +++ b/src/templates/item/talent-sheet.hbs @@ -5,10 +5,10 @@ {{#*inline "talentRankSideProperty" }}
    - + + {{#if (eq property 'base') }}max="{{data.rank.max}}"{{/if}} + name="data.rank.{{property}}" value="{{lookup data.rank property}}" />
    {{/inline}} From fb711bc02451fdb5643bc8d16c90f8dd4ce3e00f Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 12:02:40 +0100 Subject: [PATCH 06/11] unified keys for localizations for headings - keys now start with 'DS4.Heading' - removed unused DS4.DescriptionAbbr --- src/lang/en.json | 11 +++++------ src/templates/actor/actor-sheet.hbs | 6 +++--- src/templates/actor/partials/items-overview.hbs | 2 +- src/templates/actor/partials/talents-overview.hbs | 2 +- src/templates/item/partials/body.hbs | 6 +++--- src/templates/item/partials/description.hbs | 2 +- src/templates/item/talent-sheet.hbs | 6 +++--- 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/lang/en.json b/src/lang/en.json index 5227291e..c77f7b2b 100644 --- a/src/lang/en.json +++ b/src/lang/en.json @@ -1,12 +1,11 @@ { "DS4.UserInteractionAddItem": "Add item", "DS4.NotOwned": "No owner", - "DS4.Description": "Description", - "DS4.DescriptionAbbr": "Desc", - "DS4.Details": "Details", - "DS4.Effects": "Effects", - "DS4.Items": "Items", - "DS4.Talents": "Talents & Abilities", + "DS4.HeadingDescription": "Description", + "DS4.HeadingDetails": "Details", + "DS4.HeadingEffects": "Effects", + "DS4.HeadingItems": "Items", + "DS4.HeadingTalents": "Talents & Abilities", "DS4.AttackType": "Attack Type", "DS4.AttackTypeAbbr": "AT", "DS4.WeaponBonus": "Weapon Bonus", diff --git a/src/templates/actor/actor-sheet.hbs b/src/templates/actor/actor-sheet.hbs index b22aae3b..be40d1fd 100644 --- a/src/templates/actor/actor-sheet.hbs +++ b/src/templates/actor/actor-sheet.hbs @@ -90,9 +90,9 @@ {{!-- Sheet Tab Navigation --}} {{!-- Sheet Body --}} diff --git a/src/templates/actor/partials/items-overview.hbs b/src/templates/actor/partials/items-overview.hbs index 0cc57faf..f3e5415d 100644 --- a/src/templates/actor/partials/items-overview.hbs +++ b/src/templates/actor/partials/items-overview.hbs @@ -55,7 +55,7 @@ {{!-- item type specifics --}} {{> @partial-block }} {{!-- description --}} -
    {{localize 'DS4.Description'}}
    +
    {{localize 'DS4.HeadingDescription'}}
    {{!-- add button --}} {{> addItemButton dataType=dataType }} diff --git a/src/templates/actor/partials/talents-overview.hbs b/src/templates/actor/partials/talents-overview.hbs index f70421e3..af259410 100644 --- a/src/templates/actor/partials/talents-overview.hbs +++ b/src/templates/actor/partials/talents-overview.hbs @@ -86,7 +86,7 @@ {{!-- rank info --}}
    {{localize 'DS4.TalentRank'}}
    {{!-- description --}} -
    {{localize 'DS4.Description'}}
    +
    {{localize 'DS4.HeadingDescription'}}
    {{!-- add button --}} {{> addItemButton dataType='talent' }} diff --git a/src/templates/item/partials/body.hbs b/src/templates/item/partials/body.hbs index 9b5cde20..9770815b 100644 --- a/src/templates/item/partials/body.hbs +++ b/src/templates/item/partials/body.hbs @@ -2,9 +2,9 @@ {{!-- Sheet Tab Navigation --}} {{!-- Sheet Body --}} diff --git a/src/templates/item/partials/description.hbs b/src/templates/item/partials/description.hbs index c1c7ae26..db3253bc 100644 --- a/src/templates/item/partials/description.hbs +++ b/src/templates/item/partials/description.hbs @@ -23,7 +23,7 @@ {{localize "DS4.NotOwned"}} {{/if}}
    -
    +
    {{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
    \ No newline at end of file diff --git a/src/templates/item/talent-sheet.hbs b/src/templates/item/talent-sheet.hbs index 0c9dc198..44bd17b0 100644 --- a/src/templates/item/talent-sheet.hbs +++ b/src/templates/item/talent-sheet.hbs @@ -27,8 +27,8 @@ {{!-- Sheet Tab Navigation --}} {{!-- Sheet Body --}} @@ -57,7 +57,7 @@ {{> talentRankSideProperty data=data property='mod' localizeString='DS4.TalentRankMod'}} {{> talentRankSideProperty data=data property='total' localizeString='DS4.TalentRankTotal' disabled='disabled'}} -
    +
    {{editor content=data.description target="data.description" button=true owner=owner editable=editable}}
    From 3ba5efb8a7755a0b234489eb8c0cc4a9c0795aa6 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 14:19:18 +0100 Subject: [PATCH 07/11] fixed wrong positioning of effects tab content --- src/templates/item/talent-sheet.hbs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/templates/item/talent-sheet.hbs b/src/templates/item/talent-sheet.hbs index 44bd17b0..0c987467 100644 --- a/src/templates/item/talent-sheet.hbs +++ b/src/templates/item/talent-sheet.hbs @@ -62,9 +62,9 @@ + {{!-- Effects Tab --}} + {{> systems/ds4/templates/item/partials/effects.hbs }} + - {{!-- Effects Tab --}} - {{> systems/ds4/templates/item/partials/effects.hbs}} - From 874692ed5ceb889e89646432b0f23cb65cecc431 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 15:25:55 +0100 Subject: [PATCH 08/11] moved basic talent properties in talent-sheet head - a little bit better gridding of side-properties (still needs a rewrite) - common SCSS mixin for input field marking --- src/scss/components/_basic_property.scss | 11 +++++++++-- src/scss/components/_description.scss | 11 ++++------- src/scss/components/_items.scss | 5 ++--- src/scss/utils/_mixins.scss | 9 +++++++++ src/templates/item/talent-sheet.hbs | 16 +++++++++------- 5 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/scss/components/_basic_property.scss b/src/scss/components/_basic_property.scss index 6f725dad..813bf9b7 100644 --- a/src/scss/components/_basic_property.scss +++ b/src/scss/components/_basic_property.scss @@ -1,13 +1,20 @@ .basic-properties { flex: 0 0 100%; .basic-property { - .basic-property-label { + display: grid; + align-content: end; + + .basic-property-label, + & > label { font-weight: bold; } - .basic-property-select { + .basic-property-select, + & > select { display: block; width: 100%; } + + @include mark-invalid-or-disabled-input; } } diff --git a/src/scss/components/_description.scss b/src/scss/components/_description.scss index 72080381..084b1796 100644 --- a/src/scss/components/_description.scss +++ b/src/scss/components/_description.scss @@ -9,7 +9,7 @@ .side-property { margin: 2px 0; display: grid; - grid-template-columns: 40% auto; + grid-template-columns: minmax(30%, auto) auto; justify-content: left; label { @@ -22,12 +22,9 @@ text-align: left; width: calc(100% - 2px); } - input:invalid { - background-color: $c-invalid-input; - } - input:disabled { - background-color: transparent; - } + + @include mark-invalid-or-disabled-input; + input[type="checkbox"] { width: auto; height: 100%; diff --git a/src/scss/components/_items.scss b/src/scss/components/_items.scss index fea61e0c..6382c587 100644 --- a/src/scss/components/_items.scss +++ b/src/scss/components/_items.scss @@ -39,9 +39,8 @@ height: 100%; margin: 0px; } - input:invalid { - background-color: $c-invalid-input; - } + + @include mark-invalid-or-disabled-input; } .item-name { diff --git a/src/scss/utils/_mixins.scss b/src/scss/utils/_mixins.scss index 7e028c29..adc2e69a 100644 --- a/src/scss/utils/_mixins.scss +++ b/src/scss/utils/_mixins.scss @@ -19,3 +19,12 @@ display: grid; place-items: center; } + +@mixin mark-invalid-or-disabled-input { + input:invalid { + background-color: $c-invalid-input; + } + input:disabled { + background-color: transparent; + } +} diff --git a/src/templates/item/talent-sheet.hbs b/src/templates/item/talent-sheet.hbs index 0c987467..d68f66c2 100644 --- a/src/templates/item/talent-sheet.hbs +++ b/src/templates/item/talent-sheet.hbs @@ -3,9 +3,9 @@ {{!-- ======================================================================== --}} -{{#*inline "talentRankSideProperty" }} -
    - +{{#*inline "talentRankBasicProperty" }} +
    + @@ -22,6 +22,12 @@

    {{localize (lookup config.itemTypes item.type)}}

    +
    + {{> talentRankBasicProperty data=data property='base' localizeString='DS4.TalentRankBase' }} + {{> talentRankBasicProperty data=data property='max' localizeString='DS4.TalentRankMax'}} + {{> talentRankBasicProperty data=data property='mod' localizeString='DS4.TalentRankMod'}} + {{> talentRankBasicProperty data=data property='total' localizeString='DS4.TalentRankTotal' disabled='disabled'}} +
    @@ -52,10 +58,6 @@ {{else}} {{localize "DS4.NotOwned"}} {{/if}} - {{> talentRankSideProperty data=data property='base' localizeString='DS4.TalentRankBase' }} - {{> talentRankSideProperty data=data property='max' localizeString='DS4.TalentRankMax'}} - {{> talentRankSideProperty data=data property='mod' localizeString='DS4.TalentRankMod'}} - {{> talentRankSideProperty data=data property='total' localizeString='DS4.TalentRankTotal' disabled='disabled'}}
    {{editor content=data.description target="data.description" button=true owner=owner editable=editable}} From 5bdfdd410b3ac62deffafb97abca91d7d9dd8e72 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 15:30:20 +0100 Subject: [PATCH 09/11] replace basic-property-* css classes by selectors --- src/scss/components/_basic_property.scss | 2 -- src/templates/item/armor-sheet.hbs | 12 ++++++------ src/templates/item/shield-sheet.hbs | 4 ++-- src/templates/item/talent-sheet.hbs | 2 +- src/templates/item/weapon-sheet.hbs | 12 ++++++------ 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/scss/components/_basic_property.scss b/src/scss/components/_basic_property.scss index 813bf9b7..c253964e 100644 --- a/src/scss/components/_basic_property.scss +++ b/src/scss/components/_basic_property.scss @@ -4,12 +4,10 @@ display: grid; align-content: end; - .basic-property-label, & > label { font-weight: bold; } - .basic-property-select, & > select { display: block; width: 100%; diff --git a/src/templates/item/armor-sheet.hbs b/src/templates/item/armor-sheet.hbs index a0a671dc..b7887131 100644 --- a/src/templates/item/armor-sheet.hbs +++ b/src/templates/item/armor-sheet.hbs @@ -6,8 +6,8 @@

    {{localize (lookup config.itemTypes item.type)}}

    - - {{#select data.armorType}} {{#each config.armorTypes as |value key|}} @@ -16,8 +16,8 @@
    - - {{#select data.armorMaterialType}} {{#each config.armorMaterialTypes as |value key|}} @@ -26,8 +26,8 @@
    - - {{localize "DS4.ArmorValue"}} +
    diff --git a/src/templates/item/shield-sheet.hbs b/src/templates/item/shield-sheet.hbs index 1e893d2a..ede89655 100644 --- a/src/templates/item/shield-sheet.hbs +++ b/src/templates/item/shield-sheet.hbs @@ -6,8 +6,8 @@

    {{localize (lookup config.itemTypes item.type)}}

    - - {{localize "DS4.ArmorValue"}} +
    diff --git a/src/templates/item/talent-sheet.hbs b/src/templates/item/talent-sheet.hbs index d68f66c2..69c24137 100644 --- a/src/templates/item/talent-sheet.hbs +++ b/src/templates/item/talent-sheet.hbs @@ -5,7 +5,7 @@ {{#*inline "talentRankBasicProperty" }}
    - + diff --git a/src/templates/item/weapon-sheet.hbs b/src/templates/item/weapon-sheet.hbs index 7a7efcfd..24a5f2d7 100644 --- a/src/templates/item/weapon-sheet.hbs +++ b/src/templates/item/weapon-sheet.hbs @@ -6,8 +6,8 @@

    {{localize (lookup config.itemTypes item.type)}}

    - - {{#select data.attackType}} {{#each config.attackTypes as |value key|}} @@ -16,13 +16,13 @@
    - - {{localize "DS4.WeaponBonus"}} +
    - - {{localize "DS4.OpponentDefense"}} +
    From e6b51c66a643a431766843f4b6f04aec47bd6bd8 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 16:10:56 +0100 Subject: [PATCH 10/11] removed code duplication of item body from talent - added isPhysical boolean to getData output of item-sheet.ts - added isPhysical checks for displays of physical-only information in templates --- src/module/item/item-data.ts | 4 ++ src/module/item/item-sheet.ts | 10 ++++- src/templates/item/partials/body.hbs | 10 +++-- src/templates/item/partials/description.hbs | 18 +++++---- src/templates/item/talent-sheet.hbs | 41 ++------------------- 5 files changed, 32 insertions(+), 51 deletions(-) diff --git a/src/module/item/item-data.ts b/src/module/item/item-data.ts index be1a0042..3af52fd2 100644 --- a/src/module/item/item-data.ts +++ b/src/module/item/item-data.ts @@ -39,6 +39,10 @@ interface DS4ItemPhysical { storageLocation: string; } +export function isDS4ItemDataTypePhysical(input: DS4ItemDataType): boolean { + return "quantity" in input && "price" in input && "availability" in input && "storageLocation" in input; +} + interface DS4ItemEquipable { equipped: boolean; } diff --git a/src/module/item/item-sheet.ts b/src/module/item/item-sheet.ts index ac8197aa..8670dc3e 100644 --- a/src/module/item/item-sheet.ts +++ b/src/module/item/item-sheet.ts @@ -1,5 +1,5 @@ import { DS4Item } from "./item"; -import { DS4ItemDataType } from "./item-data"; +import { DS4ItemDataType, isDS4ItemDataTypePhysical } from "./item-data"; /** * Extend the basic ItemSheet with some very simple modifications @@ -26,7 +26,13 @@ export class DS4ItemSheet extends ItemSheet { /** @override */ getData(): ItemSheetData { - const data = { ...super.getData(), config: CONFIG.DS4, isOwned: this.item.isOwned, actor: this.item.actor }; + const data = { + ...super.getData(), + config: CONFIG.DS4, + isOwned: this.item.isOwned, + actor: this.item.actor, + isPhysical: isDS4ItemDataTypePhysical(this.item.data.data), + }; console.log(data); return data; } diff --git a/src/templates/item/partials/body.hbs b/src/templates/item/partials/body.hbs index 9770815b..1f465d9f 100644 --- a/src/templates/item/partials/body.hbs +++ b/src/templates/item/partials/body.hbs @@ -4,7 +4,9 @@ {{!-- Sheet Body --}} @@ -13,10 +15,12 @@ {{!-- Description Tab --}} {{> systems/ds4/templates/item/partials/description.hbs}} - {{!-- Details Tab --}} - {{> systems/ds4/templates/item/partials/details.hbs}} - {{!-- Effects Tab --}} {{> systems/ds4/templates/item/partials/effects.hbs}} + {{#if isPhysical}} + {{!-- Details Tab --}} + {{> systems/ds4/templates/item/partials/details.hbs}} + {{/if}} + \ No newline at end of file diff --git a/src/templates/item/partials/description.hbs b/src/templates/item/partials/description.hbs index db3253bc..d7088a30 100644 --- a/src/templates/item/partials/description.hbs +++ b/src/templates/item/partials/description.hbs @@ -11,14 +11,16 @@ {{actor.name}}
    -
    - - -
    -
    - - -
    + {{#if isPhysical}} +
    + + +
    +
    + + +
    + {{/if}} {{else}} {{localize "DS4.NotOwned"}} {{/if}} diff --git a/src/templates/item/talent-sheet.hbs b/src/templates/item/talent-sheet.hbs index 69c24137..a4be9b03 100644 --- a/src/templates/item/talent-sheet.hbs +++ b/src/templates/item/talent-sheet.hbs @@ -30,43 +30,8 @@
    - - {{!-- Sheet Tab Navigation --}} - - - {{!-- Sheet Body --}} -
    - {{!-- The item tab for details. --}} -
    - {{!-- As you add new fields, add them in here! --}} -
    - {{!-- TODO: remove duplication of isOwned section here and in description.hbs--}} - {{#if isOwned}} - {{#if (ne data.equipped undefined)}}
    - - -
    - {{/if}} -
    - - {{actor.name}} -
    - {{else}} - {{localize "DS4.NotOwned"}} - {{/if}} -
    -
    - {{editor content=data.description target="data.description" button=true owner=owner editable=editable}} -
    -
    - - {{!-- Effects Tab --}} - {{> systems/ds4/templates/item/partials/effects.hbs }} - -
    + + {{!-- Common Item body --}} + {{> systems/ds4/templates/item/partials/body.hbs}} From 177de1a486674157c402183fb38f395badddf8d8 Mon Sep 17 00:00:00 2001 From: Gesina Schwalbe Date: Wed, 6 Jan 2021 16:29:02 +0100 Subject: [PATCH 11/11] extracted item control buttons to own templates - removed code duplication of inline button templates for item and talent overview --- src/module/ds4.ts | 2 ++ .../actor/partials/items-overview.hbs | 27 ++------------- .../actor/partials/overview-add-button.hbs | 11 ++++++ .../partials/overview-control-buttons.hbs | 8 +++++ .../actor/partials/talents-overview.hbs | 34 ++++++------------- 5 files changed, 33 insertions(+), 49 deletions(-) create mode 100644 src/templates/actor/partials/overview-add-button.hbs create mode 100644 src/templates/actor/partials/overview-control-buttons.hbs diff --git a/src/module/ds4.ts b/src/module/ds4.ts index 4bcf2223..f8d88667 100644 --- a/src/module/ds4.ts +++ b/src/module/ds4.ts @@ -38,6 +38,8 @@ async function registerHandlebarsPartials() { "systems/ds4/templates/item/partials/body.hbs", "systems/ds4/templates/actor/partials/items-overview.hbs", "systems/ds4/templates/actor/partials/talents-overview.hbs", + "systems/ds4/templates/actor/partials/overview-add-button.hbs", + "systems/ds4/templates/actor/partials/overview-control-buttons.hbs", "systems/ds4/templates/actor/partials/attributes-traits.hbs", "systems/ds4/templates/actor/partials/combat-values.hbs", ]; diff --git a/src/templates/actor/partials/items-overview.hbs b/src/templates/actor/partials/items-overview.hbs index f3e5415d..da54d2e8 100644 --- a/src/templates/actor/partials/items-overview.hbs +++ b/src/templates/actor/partials/items-overview.hbs @@ -5,29 +5,6 @@ {{!-- INLINE PARTIAL DEFINITIONS --}} {{!-- ======================================================================== --}} -{{!-- -!-- Render an "add" button for a given data type. -!-- -!-- @param datType: hand over the dataType to the partial as hash parameter ---}} -{{#*inline "addItemButton"}} - -{{/inline}} -{{!-- -!-- Render a group of an "edit" and a "delete" button for the current item. -!-- The current item is defined by the data-item-id HTML property of the parent li element. ---}} -{{#*inline "itemControlButtons"}} -
    - - -
    -{{/inline}} - {{!-- !-- Render a header row for a given data type. @@ -57,7 +34,7 @@ {{!-- description --}}
    {{localize 'DS4.HeadingDescription'}}
    {{!-- add button --}} - {{> addItemButton dataType=dataType }} + {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType=dataType }} {{/inline}} @@ -94,7 +71,7 @@ {{!-- description --}}
    {{{item.data.data.description}}}
    {{!-- control buttons --}} - {{> itemControlButtons}} + {{> systems/ds4/templates/actor/partials/overview-control-buttons.hbs }} {{/inline}} diff --git a/src/templates/actor/partials/overview-add-button.hbs b/src/templates/actor/partials/overview-add-button.hbs new file mode 100644 index 00000000..86e5d774 --- /dev/null +++ b/src/templates/actor/partials/overview-add-button.hbs @@ -0,0 +1,11 @@ +{{! +!-- Render an "add" button for adding an item of given data type. +!-- +!-- @param datType: hand over the dataType to the partial as hash parameter +}} + \ No newline at end of file diff --git a/src/templates/actor/partials/overview-control-buttons.hbs b/src/templates/actor/partials/overview-control-buttons.hbs new file mode 100644 index 00000000..d10dbc3f --- /dev/null +++ b/src/templates/actor/partials/overview-control-buttons.hbs @@ -0,0 +1,8 @@ +{{!-- +!-- Render a group of an "edit" and a "delete" button for the current item. +!-- The current item is defined by the data-item-id HTML property of the parent li element. +--}} +
    + + +
    diff --git a/src/templates/actor/partials/talents-overview.hbs b/src/templates/actor/partials/talents-overview.hbs index af259410..3c2cfeac 100644 --- a/src/templates/actor/partials/talents-overview.hbs +++ b/src/templates/actor/partials/talents-overview.hbs @@ -3,30 +3,15 @@ {{!-- ======================================================================== --}} {{!-- TODO: remove duplicate add and delete button definition --}} -{{!-- -!-- Render an "add" button for a given data type. + +{{!-- +!-- Render an input element for a rank value property of an item. !-- -!-- @param datType: hand over the dataType to the partial as hash parameter +!-- @param item: the item +!-- @param property: the key of the property in item.data.data (if 'base', the max value is set automatically) +!-- @param disabled: if given, is placed plainly into the input as HTML property; +!-- meant to be set to "disabled" to disable the input element --}} -{{#*inline "addItemButton"}} - -{{/inline}} -{{!-- -!-- Render a group of an "edit" and a "delete" button for the current item. -!-- The current item is defined by the data-item-id HTML property of the parent li element. ---}} -{{#*inline "itemControlButtons"}} -
    - - -
    -{{/inline}} - - {{#*inline "talentRankValue"}} {{/inline}} + {{!-- !-- Render a talent list row from a given item. !-- It is a flexbox with a child for each item value of interest. @@ -68,7 +54,7 @@ {{!-- description --}}
    {{{item.data.data.description}}}
    {{!-- control buttons --}} - {{> itemControlButtons}} + {{> systems/ds4/templates/actor/partials/overview-control-buttons.hbs }} {{/inline}} @@ -88,7 +74,7 @@ {{!-- description --}}
    {{localize 'DS4.HeadingDescription'}}
    {{!-- add button --}} - {{> addItemButton dataType='talent' }} + {{> systems/ds4/templates/actor/partials/overview-add-button.hbs dataType='talent' }} {{#each itemsByType.talent as |item id|}} {{> talentListEntry item=item}}