diff --git a/src/ActorSheet.hbs b/src/ActorSheet.hbs index 05432c7..4b3802d 100644 --- a/src/ActorSheet.hbs +++ b/src/ActorSheet.hbs @@ -312,7 +312,7 @@
{{localize "DSA41.inventar.bewaffnung"}}
-
{{localize "DSA41.weight"}}
+
{{localize "DSA41.weight.label"}}
@@ -347,7 +347,7 @@
{{localize "DSA41.inventar.ruestungen"}}
-
{{localize "DSA41.weight"}}
+
{{localize "DSA41.weight.label"}}
{{#unless (ne actor.itemTypes.Ruestung.length 0)}} @@ -373,7 +373,7 @@
{{localize "DSA41.inventar.gegenstaende"}}
-
{{localize "DSA41.weight"}}
+
{{localize "DSA41.weight.label"}}
{{#unless (ne actor.itemTypes.Gegenstand.length 0)}} diff --git a/src/ItemSheets/Bewaffnung.hbs b/src/ItemSheets/Bewaffnung.hbs index 63f2023..3cf3fe3 100644 --- a/src/ItemSheets/Bewaffnung.hbs +++ b/src/ItemSheets/Bewaffnung.hbs @@ -4,7 +4,7 @@
{{DSA41_input "name" subtitle="DSA41.name"}}
- {{DSA41_input "system.gewicht" subtitle="DSA41.weight"}} + {{DSA41_input "system.gewicht" subtitle="DSA41.weight.label"}} {{DSA41_input "system.preis" subtitle="DSA41.price"}}
diff --git a/src/ItemSheets/Gegenstand.hbs b/src/ItemSheets/Gegenstand.hbs index 6c7174e..d4c0360 100644 --- a/src/ItemSheets/Gegenstand.hbs +++ b/src/ItemSheets/Gegenstand.hbs @@ -4,7 +4,7 @@
{{DSA41_input "name" subtitle="DSA41.name"}}
- {{DSA41_input "system.gewicht" subtitle="DSA41.weight"}} + {{DSA41_input "system.gewicht" subtitle="DSA41.weight.label"}} {{DSA41_input "system.preis" subtitle="DSA41.price"}}
diff --git a/src/ItemSheets/Ruestung.hbs b/src/ItemSheets/Ruestung.hbs index b58d20c..6421ad7 100644 --- a/src/ItemSheets/Ruestung.hbs +++ b/src/ItemSheets/Ruestung.hbs @@ -4,7 +4,7 @@
{{DSA41_input "name" subtitle="DSA41.name"}}
- {{DSA41_input "system.gewicht" subtitle="DSA41.weight"}} + {{DSA41_input "system.gewicht" subtitle="DSA41.weight.label"}} {{DSA41_input "system.preis" subtitle="DSA41.price"}}
diff --git a/src/lang/de.json b/src/lang/de.json index bf608bf..ad40680 100644 --- a/src/lang/de.json +++ b/src/lang/de.json @@ -21,7 +21,6 @@ "culture": "Kultur", "profession": "Profession", "sozialstatus": "Sozialstatus", - "weight": "Gewicht", "price": "Preis", "abenteuerpunkte": "Abenteuerpunkte", @@ -34,6 +33,18 @@ "kreuzer": "Kreuzer" }, + "weight": { + "label": "Gewicht", + + "gran": "Gran", + "karat": "Karat", + "skrupel": "Skrupel", + "unze": "Unze", + "stein": "Stein", + "sack": "Sack", + "quader": "Quader" + }, + "steigerungskategorie": { "A_Star": "A*", "A": "A", diff --git a/src/main.css b/src/main.css index ad59665..af92826 100644 --- a/src/main.css +++ b/src/main.css @@ -132,6 +132,15 @@ html { } } + & .weight-input { + display: grid; + grid-template-columns: minmax(min-content, 1fr) max-content; + + & input { + padding: 0; + } + } + & .placeholder { font-size: 0.8em; border-top: 1px solid; diff --git a/src/main.mjs b/src/main.mjs index 307555a..2e3948c 100644 --- a/src/main.mjs +++ b/src/main.mjs @@ -313,6 +313,45 @@ class PreisField extends SchemaField { } } +class GewichtUnitField extends StringField { + constructor(options={}, context={}) { + return super({ + required: true, + choices: { + "gran": "DSA41.weight.gran", + "karat": "DSA41.weight.karat", + "skrupel": "DSA41.weight.skrupel", + "unze": "DSA41.weight.unze", + "stein": "DSA41.weight.stein", + "sack": "DSA41.weight.sack", + "quader": "DSA41.weight.quader", + }, + initial: "stein", + ...options + }, context); + } +} + +class GewichtField extends SchemaField { + constructor() { + return super({ + value: new NumberField({ initial: 0, min: 0 }), + unit: new GewichtUnitField(), + }); + } + + _toInput(config) { + const value_input = this.fields["value"].toInput({ value: config.value.value, }); + const unit_input = this.fields["unit"] .toInput({ value: config.value.unit, localize: true }); + + let outer_div = document.createElement("div"); + outer_div.className = "weight-input"; + outer_div.replaceChildren(value_input, unit_input); + + return outer_div; + } +} + class AttributeField extends SchemaField { constructor() { return super({ @@ -720,7 +759,7 @@ class DSA41_CharacterData extends TypeDataModel { class DSA41_GegenstandData extends TypeDataModel { static defineSchema() { return { - gewicht: new NumberField({ integer: false, initial: 0, min: 0 }), + gewicht: new GewichtField(), preis: new PreisField(), }; }