Fix the localization function and provide a special placeholder for when the user doesn't have a die assigned to their stat
This commit is contained in:
parent
c1ee1a9ef8
commit
2065596686
6 changed files with 71 additions and 40 deletions
|
|
@ -43,6 +43,14 @@
|
|||
"d10": "d10",
|
||||
"d12": "d12",
|
||||
"d20": "d20"
|
||||
},
|
||||
"sheet": {
|
||||
"actor": {
|
||||
"v2": {
|
||||
"stat-not-chosen": "Select a dice to see the {name} skills",
|
||||
"skill-roll-locked": "@dotdungeon.trainingLevel.locked"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -87,7 +87,7 @@ export class PlayerSheetv2 extends GenericActorSheet {
|
|||
name: game.i18n.format(`dotdungeon.skills.${skill}`),
|
||||
value,
|
||||
formula: `1` + stat.value + modifierToString(value, { spaces: true }),
|
||||
rollDisabled: stat.value === `` || value === -1,
|
||||
rollDisabled: value === -1,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ export function localizer(key, args = {}, depth = 0) {
|
|||
const subkey = match.groups.key;
|
||||
localized =
|
||||
localized.slice(0, match.index)
|
||||
+ localizer(subkey.slice(1), args, depth + 1)
|
||||
+ localized.slice(match.index + subkey.length)
|
||||
+ localizer(subkey, args, depth + 1)
|
||||
+ localized.slice(match.index + subkey.length + 1)
|
||||
};
|
||||
return localized;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
.stat {
|
||||
border-radius: 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
select {
|
||||
height: 100%;
|
||||
|
|
@ -28,6 +30,9 @@
|
|||
}
|
||||
.dice-select {
|
||||
color: var(--stat-dice-select-text-color);
|
||||
option {
|
||||
background: var(--stat-dice-select-bg);
|
||||
}
|
||||
}
|
||||
.roll-stat {
|
||||
color: var(--stat-roll-button-text-color);
|
||||
|
|
@ -38,12 +43,20 @@
|
|||
}
|
||||
}
|
||||
|
||||
&__skills {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
gap: 8px;
|
||||
margin: 8px;
|
||||
&__empty {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
&__skills {
|
||||
align-items: center;
|
||||
box-sizing: border-box;
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
padding: 8px;
|
||||
|
||||
.skill {
|
||||
&__label {
|
||||
|
|
|
|||
|
|
@ -27,10 +27,12 @@ $on-secondary: $t;
|
|||
|
||||
--stat-header-text-color: #{$on-surface};
|
||||
--stat-dice-select-text-color: #{$on-surface};
|
||||
--stat-dice-select-bg: #{$surface};
|
||||
--stat-roll-button-text-color: #{$on-surface};
|
||||
--stat-divider-color: #{$secondary};
|
||||
--stat-not-chosen-placeholder-text-color: #{$on-surface};
|
||||
--skill-name-text-color: #{$on-surface};
|
||||
--skill-training-select: #{$surface};
|
||||
--skill-training-select-bg: #{$surface};
|
||||
--skill-training-select-text-color: #{$on-surface};
|
||||
--skill-roll-button-text-color: #{$on-surface};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,38 +17,46 @@
|
|||
</button>
|
||||
</div>
|
||||
{{#if stat.skills}}
|
||||
<div class="stat__skills skill">
|
||||
{{#each stat.skills as | skill |}}
|
||||
<label
|
||||
for="{{meta.idp}}-{{skill.key}}-training"
|
||||
class="skill__label"
|
||||
>
|
||||
{{skill.name}}
|
||||
</label>
|
||||
<select
|
||||
name="system.skills.{{stat.key}}.{{skill.key}}"
|
||||
id="{{meta.idp}}-{{skill.key}}-training"
|
||||
class="e-2dp skill__training"
|
||||
>
|
||||
{{{dd-options
|
||||
skill.value
|
||||
@root.config.trainingLevels
|
||||
localize=true
|
||||
}}}
|
||||
</select>
|
||||
<button
|
||||
type="button"
|
||||
class="e-2dp skill__roll"
|
||||
{{disabled skill.rollDisabled}}
|
||||
>
|
||||
{{#if skill.rollDisabled}}
|
||||
Locked
|
||||
{{else}}
|
||||
{{skill.formula}}
|
||||
{{/if}}
|
||||
</button>
|
||||
{{/each}}
|
||||
{{#if stat.value}}
|
||||
<div class="stat__skills skill">
|
||||
{{#each stat.skills as | skill |}}
|
||||
<label
|
||||
for="{{@root.meta.idp}}-{{skill.key}}-training"
|
||||
class="skill__label"
|
||||
>
|
||||
{{skill.name}}
|
||||
</label>
|
||||
<select
|
||||
name="system.skills.{{stat.key}}.{{skill.key}}"
|
||||
id="{{@root.meta.idp}}-{{skill.key}}-training"
|
||||
class="e-2dp skill__training"
|
||||
>
|
||||
{{{dd-options
|
||||
skill.value
|
||||
@root.config.trainingLevels
|
||||
localize=true
|
||||
}}}
|
||||
</select>
|
||||
<button
|
||||
type="button"
|
||||
class="e-2dp skill__roll"
|
||||
{{disabled skill.rollDisabled}}
|
||||
>
|
||||
{{#if skill.rollDisabled}}
|
||||
{{dd-i18n "dotdungeon.sheet.actor.v2.skill-roll-locked"}}
|
||||
{{else}}
|
||||
{{skill.formula}}
|
||||
{{/if}}
|
||||
</button>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="stat__empty">
|
||||
<p>
|
||||
{{dd-i18n "dotdungeon.sheet.actor.v2.stat-not-chosen" stat}}
|
||||
</p>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/each}}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue