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