commit
bfcd843c4e
10 changed files with 90 additions and 22 deletions
|
|
@ -21,6 +21,12 @@
|
|||
<div class="armour"></div>
|
||||
|
||||
{{!-- * Fate & Advancement --}}
|
||||
<div class="fate">
|
||||
<label for="{{meta.idp}}-fate-path" class="col-header">Fate</label>
|
||||
<select class="row-alt" id="{{meta.idp}}-fate-path" name="system.fate">
|
||||
{{rc-options fate.selected fate.options localize=true}}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{{!-- * Weapons --}}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
.ripcrypt .HeroSummaryCardV1 {
|
||||
|
||||
/* Foundry Variable Tweaks */
|
||||
--input-height: 1rem;
|
||||
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) minmax(0, 2fr) minmax(0, 1fr) minmax(0, 2.5fr);
|
||||
grid-template-rows: repeat(15, minmax(0, 1fr));
|
||||
|
|
@ -7,6 +11,10 @@
|
|||
background: white;
|
||||
color: black;
|
||||
|
||||
.col-header {
|
||||
background: black;
|
||||
color: white;
|
||||
}
|
||||
.row-alt {
|
||||
background: rgba(0,0,0, 0.3);
|
||||
}
|
||||
|
|
@ -16,12 +24,6 @@
|
|||
padding: 2px 4px;
|
||||
}
|
||||
|
||||
.hero_name {
|
||||
grid-column: span 3;
|
||||
margin-left: calc(var(--col-gap) * -1);
|
||||
padding-left: var(--col-gap);
|
||||
}
|
||||
|
||||
.header {
|
||||
grid-row: span 2;
|
||||
grid-column: span 1;
|
||||
|
|
@ -36,4 +38,17 @@
|
|||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.hero_name {
|
||||
grid-column: span 3;
|
||||
margin-left: calc(var(--col-gap) * -1);
|
||||
padding-left: var(--col-gap);
|
||||
}
|
||||
|
||||
.fate {
|
||||
grid-column: 1 / span 1;
|
||||
grid-row: 4 / span 2;
|
||||
display: grid;
|
||||
grid-template-rows: subgrid;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
}
|
||||
|
||||
input {
|
||||
all: initial;
|
||||
all: revert;
|
||||
box-sizing: border-box;
|
||||
border: none;
|
||||
outline: none;
|
||||
|
|
@ -23,4 +23,20 @@
|
|||
border-bottom: 2px dashed purple;
|
||||
}
|
||||
}
|
||||
|
||||
select {
|
||||
all: revert;
|
||||
appearance: auto;
|
||||
box-sizing: border-box;
|
||||
border: none;
|
||||
outline: none;
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
label, input, select {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,13 @@
|
|||
"HeroSummaryCardV1": "Hero Stat Card"
|
||||
},
|
||||
"common": {
|
||||
"empty": "---"
|
||||
"empty": "---",
|
||||
"fate": {
|
||||
"North": "North",
|
||||
"East": "East",
|
||||
"South": "South",
|
||||
"West": "West"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
import { filePath } from "../../consts.mjs";
|
||||
import { gameTerms } from "../../gameTerms.mjs";
|
||||
import { Logger } from "../../utils/Logger.mjs";
|
||||
|
||||
const { HandlebarsApplicationMixin } = foundry.applications.api;
|
||||
const { ActorSheetV2 } = foundry.applications.sheets;
|
||||
|
|
@ -43,10 +45,25 @@ export class HeroSummaryCardV1 extends HandlebarsApplicationMixin(ActorSheetV2)
|
|||
|
||||
ctx.actor = this.document;
|
||||
|
||||
ctx = await this._prepareFatePath(ctx);
|
||||
|
||||
partId = partId.slice(0,1).toUpperCase() + partId.slice(1);
|
||||
if (this[`_prepare${partId}Context`] != null) {
|
||||
ctx = await this[`_prepare${partId}Context`](ctx, opts);
|
||||
};
|
||||
|
||||
Logger.debug(`Context:`, ctx);
|
||||
return ctx;
|
||||
};
|
||||
|
||||
async _prepareFatePath(ctx) {
|
||||
ctx.fate = {};
|
||||
ctx.fate.selected = ctx.actor.system.fate;
|
||||
ctx.fate.options = [
|
||||
{ label: `RipCrypt.common.empty`, v: `` },
|
||||
...gameTerms.FatePath
|
||||
.map(v => ({ label: `RipCrypt.common.fate.${v}`, value: v })),
|
||||
];
|
||||
return ctx;
|
||||
};
|
||||
// #endregion
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { FatePath } from "../../gameTerms.mjs";
|
||||
import { gameTerms } from "../../gameTerms.mjs";
|
||||
|
||||
const { fields } = foundry.data;
|
||||
|
||||
|
|
@ -61,7 +61,7 @@ export class HeroData extends foundry.abstract.TypeDataModel {
|
|||
trim: true,
|
||||
nullable: false,
|
||||
choices: () => {
|
||||
return Object.values(FatePath).concat(``);
|
||||
return gameTerms.FatePath.concat(``);
|
||||
},
|
||||
}),
|
||||
level: new fields.SchemaField({
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
export const FatePath = {
|
||||
NORTH: `North`,
|
||||
EAST: `East`,
|
||||
SOUTH: `South`,
|
||||
WEST: `West`,
|
||||
};
|
||||
export const gameTerms = Object.preventExtensions({
|
||||
FatePath: [
|
||||
`North`,
|
||||
`East`,
|
||||
`South`,
|
||||
`West`,
|
||||
],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -13,9 +13,8 @@ import { localizer } from "../utils/Localizer.mjs";
|
|||
* @param {any} meta
|
||||
*/
|
||||
export function options(selected, opts, meta) {
|
||||
const { localize = false } = meta;
|
||||
const { localize = false } = meta.hash;
|
||||
selected = Handlebars.escapeExpression(selected);
|
||||
|
||||
const htmlOptions = [];
|
||||
|
||||
for (let opt of opts) {
|
||||
|
|
@ -33,4 +32,5 @@ export function options(selected, opts, meta) {
|
|||
</option>`,
|
||||
);
|
||||
};
|
||||
return new Handlebars.SafeString(htmlOptions.join(`\n`));
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import { registerDevSettings } from "../settings/devSettings.mjs";
|
|||
import { CryptDie } from "../dice/CryptDie.mjs";
|
||||
|
||||
// Misc
|
||||
import helpers from "../handlebarHelpers/_index.mjs";
|
||||
import { Logger } from "../utils/Logger.mjs";
|
||||
|
||||
Hooks.once(`init`, () => {
|
||||
|
|
@ -35,4 +36,6 @@ Hooks.once(`init`, () => {
|
|||
});
|
||||
// #endregion
|
||||
// #endregion
|
||||
|
||||
Handlebars.registerHelper(helpers);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
import { localizerConfig } from "../config.mjs";
|
||||
const config = Object.preventExtensions({
|
||||
subKeyPattern: /@(?<key>[a-zA-Z.]+)/gm,
|
||||
maxDepth: 10,
|
||||
});
|
||||
|
||||
export function handlebarsLocalizer(key, ...args) {
|
||||
let data = args[0];
|
||||
|
|
@ -11,10 +14,10 @@ export function handlebarsLocalizer(key, ...args) {
|
|||
export function localizer(key, args = {}, depth = 0) {
|
||||
/** @type {string} */
|
||||
let localized = game.i18n.format(key, args);
|
||||
const subkeys = localized.matchAll(localizerConfig.subKeyPattern);
|
||||
const subkeys = localized.matchAll(config.subKeyPattern);
|
||||
|
||||
// Short-cut to help prevent infinite recursion
|
||||
if (depth > localizerConfig.maxDepth) {
|
||||
if (depth > config.maxDepth) {
|
||||
return localized;
|
||||
};
|
||||
|
||||
|
|
@ -29,7 +32,7 @@ export function localizer(key, args = {}, depth = 0) {
|
|||
};
|
||||
|
||||
return localized.replace(
|
||||
localizerConfig.subKeyPattern,
|
||||
config.subKeyPattern,
|
||||
(_fullMatch, subkey) => {
|
||||
return localizedSubkeys.get(subkey);
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue