From 14e70d422c4989155cb063bbf3d09c8a0dabfb6d Mon Sep 17 00:00:00 2001 From: Byroks Date: Mon, 19 Oct 2026 11:13:42 +0200 Subject: [PATCH] =?UTF-8?q?Gegenst=C3=A4nde?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lang/de.json | 6 +- src/data/item-data.mjs | 19 +++++- src/sheets/character-sheet.mjs | 18 +++++- .../components/spezialisierung-actions.mjs | 24 ++++---- src/sheets/item-sheet.mjs | 35 ++++++++--- src/styles/M6.scss | 1 + src/styles/header.scss | 59 ++++++++++++++----- src/styles/items-page.scss | 54 +++++++++++++++++ src/styles/tabs.scss | 2 +- src/templates/actor/header.hbs | 2 +- src/templates/actor/items.hbs | 9 +++ src/templates/item/description.hbs | 20 +++++++ src/templates/item/header.hbs | 42 +++++++++---- 13 files changed, 234 insertions(+), 57 deletions(-) create mode 100644 src/styles/items-page.scss create mode 100644 src/templates/item/description.hbs diff --git a/lang/de.json b/lang/de.json index c23507b..75ef8f2 100644 --- a/lang/de.json +++ b/lang/de.json @@ -1,7 +1,7 @@ { "Midgard6": { + "name": "Name", "Biography": { - "name": "Name", "spezies": "Spezies", "kultur": "Kultur", "abenteuertyp": "Abenteuertyp", @@ -14,6 +14,10 @@ "speichern": "Speichern", "löschen": "Löschen" }, + "Gegenstand": { + "wert": "Wert", + "gewicht": "Gewicht" + }, "Skills": { "gruppen": { "kampf": "Kampf", diff --git a/src/data/item-data.mjs b/src/data/item-data.mjs index 6658e41..ad8b6a0 100644 --- a/src/data/item-data.mjs +++ b/src/data/item-data.mjs @@ -1,13 +1,28 @@ function defineSchema() { const fields = foundry.data.fields; return { - description: new fields.HTMLField({ initial: "" }), - quantity: new fields.NumberField({ + beschreibung: new fields.HTMLField({ initial: "" }), + anzahl: new fields.NumberField({ required: true, nullable: false, integer: true, initial: 1, min: 0 + }), + wert: new fields.NumberField({ + required: true, + nullable: false, + integer: true, + initial: 1, + min: 0 + }), + gewicht: new fields.NumberField({ + required: true, + nullable: false, + integer: true, + initial: 1, + step: 1, + min: 0 }) }; } diff --git a/src/sheets/character-sheet.mjs b/src/sheets/character-sheet.mjs index e921d6c..08429d5 100644 --- a/src/sheets/character-sheet.mjs +++ b/src/sheets/character-sheet.mjs @@ -12,7 +12,6 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe static DEFAULT_OPTIONS = { classes: ["M6", "actor"], window: { - icon: "fa-solid fa-dice-d10", resizable: true }, position: { @@ -130,6 +129,7 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe break; case "items": context.itemTypes = this._getItems(); + context.gewicht = this._clacWeight(); context.tab = context.tabs[partId]; break; } @@ -284,6 +284,20 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe return types; } + _clacWeight() { + const items = this._getItems(); + let gewicht = items.item.items.reduce( + (accumulator, item) => accumulator + item.system.gewicht, + 0 + ); + + let traglast = Math.max(this.actor.system.skills.körper.athletik.value, 10); + return { + traglast, + gewicht + }; + } + /* -------------------------------------------------- */ /** @@ -425,8 +439,6 @@ export class M6ActorSheet extends api.HandlebarsApplicationMixin(sheets.ActorShe await roll.evaluate(); roll.toMessage(); - - roll.toAnchor(); } async rollDialog(rollDialogRequest) { diff --git a/src/sheets/components/spezialisierung-actions.mjs b/src/sheets/components/spezialisierung-actions.mjs index 156e58d..19775ce 100644 --- a/src/sheets/components/spezialisierung-actions.mjs +++ b/src/sheets/components/spezialisierung-actions.mjs @@ -5,19 +5,22 @@ export async function addSpezialisierung(event, target) { const dataset = target.dataset; const path = dataset.path.replace(".value", ""); const name = dataset.name; + const skill = foundry.utils.getProperty(this.actor, path); + let level = 1; + const templatePath = systemPath("templates/dialog/spezialisierung-dialog.hbs"); const templateData = { classes: ["M6", "dialog"], level }; - const skill = foundry.utils.getProperty(this.actor, path); - console.warn(skill); - // 2. Render the Handlebars template into an HTML string const content = await foundry.applications.handlebars.renderTemplate(templatePath, templateData); return foundry.applications.api.DialogV2.wait({ window: { - title: "Würfel Modifikatoren: " + game.i18n.localize(`Midgard6.Skills.${name}`) + title: + game.i18n.localize("Midgard6.Sheets.spezialisierung") + + " " + + game.i18n.localize(`Midgard6.Skills.${name}`) }, position: { width: 600 @@ -26,9 +29,8 @@ export async function addSpezialisierung(event, target) { actions: {}, render: (_event, dialog) => { const dialogHTML = dialog.element; - const display = dialogHTML.querySelector("#rollDisplay"); // Variable bei jeder Änderung aktualisieren - document.querySelectorAll('input[name="level-segment"]').forEach((radio) => { + dialogHTML.querySelectorAll('input[name="level-segment"]').forEach((radio) => { radio.addEventListener("change", (e) => { level = parseInt(e.target.value); }); @@ -61,16 +63,17 @@ export async function editSepzialisierung(event, target) { const dataset = target.dataset; const path = dataset.path; const name = dataset.name; + const skill = foundry.utils.getProperty(this.actor, path); + let level = 1; let spezName = dataset.name; + const templatePath = systemPath("templates/dialog/spezialisierung-dialog.hbs"); const templateData = { classes: ["M6", "dialog"], spezName, level }; - console.warn(path.replace(/^.*\.(?=[^.]+$)/g, "")); - const skill = foundry.utils.getProperty(this.actor, path); // 2. Render the Handlebars template into an HTML string const content = await foundry.applications.handlebars.renderTemplate(templatePath, templateData); return foundry.applications.api.DialogV2.wait({ @@ -87,9 +90,8 @@ export async function editSepzialisierung(event, target) { actions: {}, render: (_event, dialog) => { const dialogHTML = dialog.element; - const display = dialogHTML.querySelector("#rollDisplay"); - // Variable bei jeder Änderung aktualisieren - document.querySelectorAll('input[name="level-segment"]').forEach((radio) => { + + dialogHTML.querySelectorAll('input[name="level-segment"]').forEach((radio) => { radio.addEventListener("change", (e) => { level = parseInt(e.target.value); }); diff --git a/src/sheets/item-sheet.mjs b/src/sheets/item-sheet.mjs index d8f3533..2895f72 100644 --- a/src/sheets/item-sheet.mjs +++ b/src/sheets/item-sheet.mjs @@ -8,8 +8,12 @@ const { api, sheets } = foundry.applications; export class M6ItemSheet extends api.HandlebarsApplicationMixin(sheets.ItemSheet) { /** @inheritdoc */ static DEFAULT_OPTIONS = { + window: { + resizable: true + }, position: { - width: 600 + width: 600, + height: 400 }, classes: ["M6", "item", "standard-form"], actions: { @@ -31,13 +35,15 @@ export class M6ItemSheet extends api.HandlebarsApplicationMixin(sheets.ItemSheet primary: { tabs: [ { - id: "properties" + id: "description", + icon: "fa-feather-pointed" }, { - id: "effects" + id: "effects", + icon: "fa-bolt" } ], - initial: "properties", + initial: "description", labelPrefix: "M6.Sheets.Tabs" } }; @@ -50,11 +56,10 @@ export class M6ItemSheet extends api.HandlebarsApplicationMixin(sheets.ItemSheet template: systemPath("templates/item/header.hbs") }, tabs: { - // Foundry-provided generic template - template: "templates/generic/tab-navigation.hbs" + template: systemPath("templates/actor/tabs.hbs") }, - properties: { - template: systemPath("templates/shared/properties.hbs"), + description: { + template: systemPath("templates/item/description.hbs"), scrollable: [""] }, effects: { @@ -104,8 +109,20 @@ export class M6ItemSheet extends api.HandlebarsApplicationMixin(sheets.ItemSheet context.effects = prepareActiveEffectCategories(this.item.effects); context.tab = context.tabs[partId]; break; - case "properties": + case "description": context.fields = await this._getFields(); + context.enrichedBeschreibung = + await foundry.applications.ux.TextEditor.implementation.enrichHTML( + this.item.system.beschreibung, + { + // Whether to show secret blocks in the finished html + secrets: this.document.isOwner, + // Data to fill in for inline rolls + rollData: this.item.getRollData(), + // Relative UUID resolution + relativeTo: this.item + } + ); context.tab = context.tabs[partId]; break; } diff --git a/src/styles/M6.scss b/src/styles/M6.scss index da9e795..458b18f 100644 --- a/src/styles/M6.scss +++ b/src/styles/M6.scss @@ -3,6 +3,7 @@ @import url("./tabs.scss"); @import url("./resistenzen.scss"); @import url("./dialog.scss"); +@import url("./items-page.scss"); :root { --M6-background-grey: #d3d7d7; diff --git a/src/styles/header.scss b/src/styles/header.scss index f4a9027..fecd5d2 100644 --- a/src/styles/header.scss +++ b/src/styles/header.scss @@ -1,21 +1,48 @@ -.sheet-header { - margin-top: 8px; - margin-right: 12px; - .profile-img { - position: absolute; - top: 24px; - left: calc(50% - 50px - 6px); - background-color: var(--M6-background-white); - &:hover { - cursor: pointer; +.application.sheet.M6 { + .sheet-header { + margin-top: 8px; + margin-right: 12px; + .profile-img { + position: absolute; + top: 24px; + left: calc(50% - 50px - 6px); + background-color: var(--M6-background-white); + &:hover { + cursor: pointer; + } + } + .text { + margin-bottom: 4px; + } + + .container { + padding: 8px; + background-color: var(--M6-background-grey); } } - .text { - margin-bottom: 4px; - } + &.item { + .custom-input { + &.left { + padding-left: 30px; + } + &.right { + padding-right: 30px; + } + } - .container { - padding: 8px; - background-color: var(--M6-background-grey); + .input-icon { + position: absolute; + top: 40%; + transform: translateY(-50%); + color: #888; + /* Prevent the icon from blocking input clicks if it's purely decorative */ + pointer-events: none; + &.left { + left: 18px; + } + &.right { + right: 18px; + } + } } } diff --git a/src/styles/items-page.scss b/src/styles/items-page.scss new file mode 100644 index 0000000..6053313 --- /dev/null +++ b/src/styles/items-page.scss @@ -0,0 +1,54 @@ +.application.sheet.M6.actor { + .tab[data-tab="items"] { + ul { + padding-bottom: 20px; + margin: 0; + list-style: none; + padding-left: 5px; + } + + .sticky-progress-container { + position: fixed; + bottom: 0; + left: 0; + width: 100%; + background-color: #f1f1f1; + box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1); + padding: 10px 0; + display: flex; + justify-content: center; + align-items: center; + z-index: 9999; /* Bleibt immer im Vordergrund */ + } + + /* Der graue Hintergrund des Balkens */ + .progress-background { + width: 90%; /* Breite des Balkens auf dem Bildschirm */ + max-width: 800px; /* Maximale Breite auf großen Bildschirmen */ + background-color: #e0e0e0; + overflow: hidden; /* Schneidet den inneren Balken sauber ab */ + transform: skewX(-30deg); + } + + /* Der eigentliche, animierte Ladebalken */ + .progress-bar { + height: 20px; + background-color: var(--M6-background-brown); /* Grün */ + text-align: center; + line-height: 20px; + color: white; + font-size: 12px; + font-weight: bold; + width: 100%; + } + progress::-moz-progress-bar { + background: var(--M6-background-brown); + } + progress::-webkit-progress-value { + background: var(--M6-background-brown); + } + progress { + color: var(--M6-background-brown); + } + } +} diff --git a/src/styles/tabs.scss b/src/styles/tabs.scss index f807aad..e641609 100644 --- a/src/styles/tabs.scss +++ b/src/styles/tabs.scss @@ -1,4 +1,4 @@ -.application.sheet.M6.actor.character { +.application.sheet.M6 { section { &.window-content { backdrop-filter: blur(0rem); diff --git a/src/templates/actor/header.hbs b/src/templates/actor/header.hbs index e70ef65..e77986d 100644 --- a/src/templates/actor/header.hbs +++ b/src/templates/actor/header.hbs @@ -2,7 +2,7 @@
- +
diff --git a/src/templates/actor/items.hbs b/src/templates/actor/items.hbs index 7a9e368..e2445a5 100644 --- a/src/templates/actor/items.hbs +++ b/src/templates/actor/items.hbs @@ -49,4 +49,13 @@ {{/each}} +
+
+ 65% +
+
\ No newline at end of file diff --git a/src/templates/item/description.hbs b/src/templates/item/description.hbs new file mode 100644 index 0000000..aa50e85 --- /dev/null +++ b/src/templates/item/description.hbs @@ -0,0 +1,20 @@ +{{! Beschreibung Allgemein Tab }} +
+ {{! Editors must receive enriched text data from getData to properly handle rolls, UUID links, etc. }} +
+ {{#if editable}} + + {{{enrichedBeschreibung}}} + + {{else}} + {{{enrichedBeschreibung}}} + {{/if}} +
+
\ No newline at end of file diff --git a/src/templates/item/header.hbs b/src/templates/item/header.hbs index ac216ac..f6d393d 100644 --- a/src/templates/item/header.hbs +++ b/src/templates/item/header.hbs @@ -1,14 +1,30 @@ -
- {{item.name}} - {{formInput itemFields.name value=item.name}} +
+
+
+
+
+ + +
+
+ + +
+
+ +
+ {{actor.name}} +
+