#14 Update Roll Dialog

+ Hintergrundfarbe für ausgewählte Spezialisierung & Würfel
+ Maximale Anzahl an Spezialisierungen festgelt + Setting
This commit was merged in pull request #34.
This commit is contained in:
Byroks committed 2026-10-28 12:29:17 +01:00
1 parent e8caa591c4
commit 3406f2134c
6 files changed
+79 -72

No files matched your search

+7
View File
@@ -172,7 +172,14 @@
"beschreibungChatActive": { "beschreibungChatActive": {
"name": "Chat-Beschreibungen automatisch ausklappen", "name": "Chat-Beschreibungen automatisch ausklappen",
"hint": "Legt fest, ob Beschreibungen von Zaubern und Co. im Chat eingeklappt angezeigt werden oder vollständig." "hint": "Legt fest, ob Beschreibungen von Zaubern und Co. im Chat eingeklappt angezeigt werden oder vollständig."
},
"maxSpezialisierung": {
"name": "Maximale Anzahl an Spezialisierungen pro Skill",
"hint": "Legt die Maximale Anzahl der möglichen Spezialisierungen für einen Skill fest die man besitzen kann."
} }
},
"Warnings": {
"maxSpezReached": "Die Maximale Anzahl erlaubter Spezialisierungen für einen Skill sind erreicht"
} }
}, },
"TYPES": { "TYPES": {
+7 -7
View File
@@ -2,7 +2,7 @@ export const loadSettings = async function () {
game.settings.register("midgard6-lvd", "zauberAlsTag", { game.settings.register("midgard6-lvd", "zauberAlsTag", {
name: game.i18n.localize("Midgard6.Settings.zauberAlsTag.name"), name: game.i18n.localize("Midgard6.Settings.zauberAlsTag.name"),
hint: game.i18n.localize("Midgard6.Settings.zauberAlsTag.hint"), hint: game.i18n.localize("Midgard6.Settings.zauberAlsTag.hint"),
scope: "user", scope: "client",
config: true, config: true,
default: false, default: false,
type: Boolean, type: Boolean,
@@ -18,13 +18,13 @@ export const loadSettings = async function () {
type: Boolean type: Boolean
}); });
game.settings.register("midgard6-lvd", "beschreibungChatActive", { game.settings.register("midgard6-lvd", "maxSpezialisierung", {
name: game.i18n.localize("Midgard6.Settings.beschreibungChatActive.name"), name: game.i18n.localize("Midgard6.Settings.maxSpezialisierung.name"),
hint: game.i18n.localize("Midgard6.Settings.beschreibungChatActive.hint"), hint: game.i18n.localize("Midgard6.Settings.maxSpezialisierung.hint"),
scope: "client", scope: "world",
config: true, config: true,
default: false, default: 3,
type: Boolean type: Number
}); });
game.settings.register("midgard6-lvd", "colorSuccessBg", { game.settings.register("midgard6-lvd", "colorSuccessBg", {
+19 -7
View File
@@ -302,32 +302,44 @@ async function rollDialog(rollDialogRequest) {
const dialogHTML = dialog.element; const dialogHTML = dialog.element;
const display = dialogHTML.querySelector("#rollDisplay"); const display = dialogHTML.querySelector("#rollDisplay");
let mainRoll = `1d20 + ${skillValue}`;
let spezText = "";
// Variable bei jeder Änderung aktualisieren // Variable bei jeder Änderung aktualisieren
document.querySelectorAll('input[name="vorteil-segment"]').forEach((radio) => { document.querySelectorAll('input[name="vorteil-segment"]').forEach((radio) => {
radio.addEventListener("change", (e) => { radio.addEventListener("change", (e) => {
vorteil = parseInt(e.target.value); vorteil = parseInt(e.target.value);
switch (vorteil) { switch (vorteil) {
case 1: case 1:
display.placeholder = `2d20kh + ${skillValue} (Vorteil)`; mainRoll = `2d20kh + ${skillValue} (Vorteil)`;
break; break;
case -1: case -1:
display.placeholder = `2d20kl + ${skillValue} (Nachteil)`; mainRoll = `2d20kl + ${skillValue} (Nachteil)`;
break; break;
default: default:
display.placeholder = `1d20 + ${skillValue}`; mainRoll = `1d20 + ${skillValue}`;
break; break;
} }
display.placeholder = mainRoll + spezText;
}); });
}); });
document.querySelectorAll('input[name="spezialisierung-segment"]').forEach((radio) => { document.querySelectorAll('input[name="spezialisierung-segment"]').forEach((radio) => {
radio.addEventListener("change", (e) => { radio.addEventListener("click", (e) => {
spezLevel = parseInt(e.target.value); if (spezName !== e.target.dataset.name) {
spezName = e.target.dataset.name; spezLevel = parseInt(e.target.value);
spezName = e.target.dataset.name;
spezText = ` + ${spezLevel + 1}`;
} else {
spezLevel = null;
spezName = null;
e.target.checked = false;
spezText = "";
}
display.placeholder = mainRoll + spezText;
}); });
if (radio.dataset.name === preSelectedSpez) { if (radio.dataset.name === preSelectedSpez) {
radio.click(); radio.click();
display.placeholder = mainRoll + spezText;
} }
}); });
}, },
@@ -6,7 +6,12 @@ export async function addSpezialisierung(event, target) {
const path = dataset.path.replace(".value", ""); const path = dataset.path.replace(".value", "");
const name = dataset.name; const name = dataset.name;
const skill = foundry.utils.getProperty(this.actor, path); const skill = foundry.utils.getProperty(this.actor, path);
const maxSpez = game.settings.get("midgard6-lvd", "maxSpezialisierung");
if (skill.bonuses.length >= maxSpez) {
ui.notifications.warn(game.i18n.localize("Midgard6.Warnings.maxSpezReached"));
return;
}
let level = 1; let level = 1;
const templatePath = systemPath("templates/dialog/spezialisierung-dialog.hbs"); const templatePath = systemPath("templates/dialog/spezialisierung-dialog.hbs");
+6 -16
View File
@@ -59,22 +59,22 @@
} }
} }
/* Container für die gesamte Reihe */
.segmented-button-row { .segmented-button-row {
display: inline-flex; display: inline-flex;
overflow: hidden; overflow: visible;
height: 32px; height: 32px;
white-space: nowrap;
flex-wrap: wrap;
} }
/* Einzelnes Segment */
.segmented-button { .segmented-button {
position: relative; position: relative;
cursor: pointer; cursor: pointer;
display: flex; display: flex;
align-items: center; align-items: center;
height: 100%;
} }
/* Versteckt den echten Radio-Button, behält aber die Tastatur-Navigation */
.segmented-button input[type="radio"] { .segmented-button input[type="radio"] {
position: absolute; position: absolute;
opacity: 0; opacity: 0;
@@ -82,7 +82,6 @@
height: 0; height: 0;
} }
/* Inhalt des Segments (Layout & Abstände) */
.segmented-button__content { .segmented-button__content {
display: flex; display: flex;
align-items: center; align-items: center;
@@ -96,19 +95,11 @@
user-select: none; user-select: none;
} }
/* --- ZUSTÄNDE --- */
/* Selektiert (Selected State) */
.segmented-button input[type="radio"]:checked + .segmented-button__content { .segmented-button input[type="radio"]:checked + .segmented-button__content {
// background-color: #e8def8; /* M3 Secondary Container Color */ background-color: var(--M6-background-brown);
text-shadow: 0 0 10px var(--M6-text-brown) !important; color: #1d192b;
color: #1d192b; /* M3 On-Secondary Container Text */
.icon {
text-shadow: 0 0 10px var(--M6-text-brown) !important;
}
} }
/* Hover-Effekt */
.segmented-button:hover .segmented-button__content { .segmented-button:hover .segmented-button__content {
background-color: rgba(73, 69, 79, 0.08); background-color: rgba(73, 69, 79, 0.08);
} }
@@ -116,7 +107,6 @@
background-color: rgba(232, 222, 248, 0.85); background-color: rgba(232, 222, 248, 0.85);
} }
/* Tastatur-Fokus (Barrierefreiheit) */
.segmented-button input[type="radio"]:focus-visible + .segmented-button__content { .segmented-button input[type="radio"]:focus-visible + .segmented-button__content {
outline: 2px solid #6750a4; outline: 2px solid #6750a4;
outline-offset: -2px; outline-offset: -2px;
+35 -42
View File
@@ -3,25 +3,23 @@
<legend>Modifikation</legend> <legend>Modifikation</legend>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
{{! <div class="d-flex align-items-center"> }} <div class="col-6" style="margin-bottom: 4px">
<div class="col-6">
<input <input
type="text" type="text"
style="margin-left: 8px;"
name="customRoll" name="customRoll"
id="rollDisplay" id="rollDisplay"
placeholder="1d20 + {{skillValue}}" placeholder="1d20 + {{skillValue}}"
value="{{customRoll}}" value="{{customRoll}}"
/> />
</div> </div>
<div class="d-flex col-6" style="padding-left: 8px;"> <div class="col-6" style="margin-bottom: 4px">
<div class="segmented-button-row"> <div class="segmented-button-row">
<!-- Option 1 --> <!-- Option 1 -->
<label class="segmented-button"> <label class="segmented-button">
<input type="radio" name="vorteil-segment" value="-1" /> <input type="radio" name="vorteil-segment" value="-1" />
<span class="segmented-button__content"> <span class="segmented-button__content">
<i class="icon fa-solid fa-arrow-down" style="color:red"></i> <i class="icon fa-solid fa-caret-down"></i>
<i class="icon fa-solid fa-dice-d20" style=""></i> <i class="icon fa-solid fa-dice-d20"></i>
</span> </span>
</label> </label>
@@ -29,7 +27,7 @@
<label class="segmented-button"> <label class="segmented-button">
<input type="radio" name="vorteil-segment" value="0" checked /> <input type="radio" name="vorteil-segment" value="0" checked />
<span class="segmented-button__content"> <span class="segmented-button__content">
<i class="icon fa-solid fa-dice-d20" style=""></i> <i class="icon fa-solid fa-dice-d20" ></i>
</span> </span>
</label> </label>
@@ -37,55 +35,50 @@
<label class="segmented-button"> <label class="segmented-button">
<input type="radio" name="vorteil-segment" value="1" /> <input type="radio" name="vorteil-segment" value="1" />
<span class="segmented-button__content"> <span class="segmented-button__content">
<i class="icon fa-solid fa-dice-d20" style=""></i> <i class="icon fa-solid fa-dice-d20"></i>
<i class="icon fa-solid fa-arrow-up" style="color:blue"></i> <i class="icon fa-solid fa-caret-up"></i>
</span> </span>
</label> </label>
</div> </div>
</div> </div>
{{! </div> }} <div class="col-6" style="margin-bottom: 4px">
<div class="col-12 d-flex"> {{#if damageRoll}}
<div class="flexrow" style="padding-left: 8px">
<div class="segmented-button-row">
<!-- Option 1 -->
{{#each bonuses}}
<label class="segmented-button">
<input
type="radio"
name="spezialisierung-segment"
value="{{level}}"
data-name="{{name}}"
{{#ifeq name preSelectedSpez}}checked{{/ifeq}}
/>
<span class="segmented-button__content">
{{name}}:
{{level}}
</span>
</label>
{{/each}}
</div>
</div>
</div>
{{#if damageRoll}}
<div class="col-6">
<input <input
type="text" type="text"
style="margin-left: 8px;"
name="customRollDamage" name="customRollDamage"
id="rollDamageDisplay" id="rollDamageDisplay"
placeholder="{{damageRoll}}" placeholder="{{damageRoll}}"
value="{{customDamageRoll}}" value="{{customDamageRoll}}"
/> />
{{/if}}
</div> </div>
{{/if}} <div class="col-6 d-flex" style="margin-bottom: 4px">
</div> <div class="segmented-button-row">
<div class="d-flex"> <!-- Option 1 -->
<select style="max-width: 15rem; margin-left: 8px" name="rollMode" data-type="String"> {{#each bonuses}}
{{selectOptions rollModes selected=rollMode localize=true}} <label class="segmented-button">
</select> <input
type="radio"
name="spezialisierung-segment"
value="{{level}}"
data-name="{{name}}"
{{#ifeq name preSelectedSpez}}checked{{/ifeq}}
/>
<span class="segmented-button__content">
{{name}}:
{{level}}
</span>
</label>
{{/each}}
</div>
</div>
<div class="col-6" style="margin-bottom: 4px">
<select name="rollMode" data-type="String">
{{selectOptions rollModes selected=rollMode localize=true}}
</select>
</div>
</div> </div>
</div> </div>
</fieldset> </fieldset>
</section> </section>