Add functionality to the CryptApp to make it update/display the current difficulty, and rerender when it changes.
This commit is contained in:
parent
495dafaf12
commit
31033017f7
11 changed files with 125 additions and 11 deletions
|
|
@ -49,6 +49,12 @@
|
||||||
},
|
},
|
||||||
"damage": "Damage",
|
"damage": "Damage",
|
||||||
"delete": "Delete",
|
"delete": "Delete",
|
||||||
|
"difficulties": {
|
||||||
|
"easy": "Easy",
|
||||||
|
"normal": "Normal",
|
||||||
|
"tough": "Tough",
|
||||||
|
"hard": "Hard"
|
||||||
|
},
|
||||||
"edit": "Edit",
|
"edit": "Edit",
|
||||||
"empty": "---",
|
"empty": "---",
|
||||||
"equipped": "Equipped",
|
"equipped": "Equipped",
|
||||||
|
|
|
||||||
|
|
@ -7,19 +7,31 @@ const { HandlebarsApplicationMixin, ApplicationV2 } = foundry.applications.api;
|
||||||
export class CryptApp extends GenericAppMixin(HandlebarsApplicationMixin(ApplicationV2)) {
|
export class CryptApp extends GenericAppMixin(HandlebarsApplicationMixin(ApplicationV2)) {
|
||||||
// #region Options
|
// #region Options
|
||||||
static DEFAULT_OPTIONS = {
|
static DEFAULT_OPTIONS = {
|
||||||
|
classes: [
|
||||||
|
`ripcrypt--CryptApp`,
|
||||||
|
],
|
||||||
window: {
|
window: {
|
||||||
title: `Crypt Overview`,
|
title: `Crypt`,
|
||||||
frame: true,
|
frame: true,
|
||||||
positioned: true,
|
positioned: true,
|
||||||
resizable: false,
|
resizable: false,
|
||||||
minimizable: true,
|
minimizable: false,
|
||||||
|
},
|
||||||
|
position: {
|
||||||
|
width: 100,
|
||||||
},
|
},
|
||||||
actions: {},
|
actions: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
static PARTS = {
|
static PARTS = {
|
||||||
main: {
|
turnCount: {
|
||||||
template: filePath(`templates/Apps/CryptApp/main.hbs`),
|
template: filePath(`templates/Apps/CryptApp/turnCount.hbs`),
|
||||||
|
},
|
||||||
|
delveConditions: {
|
||||||
|
template: filePath(`templates/Apps/CryptApp/delveConditions.hbs`),
|
||||||
|
},
|
||||||
|
fate: {
|
||||||
|
template: filePath(`templates/Apps/CryptApp/fate.hbs`),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
@ -31,9 +43,49 @@ export class CryptApp extends GenericAppMixin(HandlebarsApplicationMixin(Applica
|
||||||
return frame;
|
return frame;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async _onRender(context, options) {
|
||||||
|
await super._onRender(context, options);
|
||||||
|
|
||||||
|
// Shortcut because users can't edit
|
||||||
|
if (!game.user.isGM) { return };
|
||||||
|
|
||||||
|
// Add event listener for the dropdown
|
||||||
|
if (options.parts.includes(`delveConditions`)) {
|
||||||
|
const select = this.element.querySelector(`#${this.id}-difficulty`);
|
||||||
|
select.addEventListener(`change`, async (ev) => {
|
||||||
|
const newDifficulty = parseInt(ev.target.value);
|
||||||
|
if (!Number.isNaN(newDifficulty)) {
|
||||||
|
await game.settings.set(`ripcrypt`, `dc`, newDifficulty);
|
||||||
|
};
|
||||||
|
this.render({ parts: [`delveConditions`] });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
async _preparePartContext(partId, ctx, opts) {
|
async _preparePartContext(partId, ctx, opts) {
|
||||||
ctx = await super._preparePartContext(partId, ctx, opts);
|
ctx = await super._preparePartContext(partId, ctx, opts);
|
||||||
Logger.log(`Context`, ctx);
|
|
||||||
|
ctx.meta.editable = game.user.isGM;
|
||||||
|
|
||||||
|
switch (partId) {
|
||||||
|
case `delveConditions`: {
|
||||||
|
ctx = this._prepareDifficulty(ctx);
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
Logger.log(`${partId} Context`, ctx);
|
||||||
|
return ctx;
|
||||||
|
};
|
||||||
|
|
||||||
|
_prepareDifficulty(ctx) {
|
||||||
|
ctx.options = [
|
||||||
|
{ label: `RipCrypt.common.difficulties.easy`, value: 4 },
|
||||||
|
{ label: `RipCrypt.common.difficulties.normal`, value: 5 },
|
||||||
|
{ label: `RipCrypt.common.difficulties.tough`, value: 6 },
|
||||||
|
{ label: `RipCrypt.common.difficulties.hard`, value: 7 },
|
||||||
|
];
|
||||||
|
ctx.difficulty = game.settings.get(`ripcrypt`, `dc`);
|
||||||
return ctx;
|
return ctx;
|
||||||
};
|
};
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,8 @@ export function registerMetaSettings() {
|
||||||
type: Number,
|
type: Number,
|
||||||
config: false,
|
config: false,
|
||||||
requiresReload: false,
|
requiresReload: false,
|
||||||
|
onChange: () => {
|
||||||
|
CONFIG.ui.crypt.render({ parts: [ `delveConditions` ]});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
17
templates/Apps/CryptApp/delveConditions.hbs
Normal file
17
templates/Apps/CryptApp/delveConditions.hbs
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
<div>
|
||||||
|
<rc-border
|
||||||
|
var:border-color="var(--accent-1)"
|
||||||
|
>
|
||||||
|
<div slot="title">
|
||||||
|
Difficulty
|
||||||
|
</div>
|
||||||
|
<div slot="content">
|
||||||
|
<span>{{ difficulty }}</span>
|
||||||
|
{{#if meta.editable}}
|
||||||
|
<select id="{{meta.idp}}-difficulty">
|
||||||
|
{{ rc-options difficulty options localize=true }}
|
||||||
|
</select>
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
</rc-border>
|
||||||
|
</div>
|
||||||
12
templates/Apps/CryptApp/fate.hbs
Normal file
12
templates/Apps/CryptApp/fate.hbs
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<div>
|
||||||
|
<rc-border
|
||||||
|
var:border-color="var(--accent-1)"
|
||||||
|
>
|
||||||
|
<div slot="title">
|
||||||
|
Fate
|
||||||
|
</div>
|
||||||
|
<div slot="content">
|
||||||
|
N
|
||||||
|
</div>
|
||||||
|
</rc-border>
|
||||||
|
</div>
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
<div>
|
|
||||||
Hello
|
|
||||||
</div>
|
|
||||||
13
templates/Apps/CryptApp/style.css
Normal file
13
templates/Apps/CryptApp/style.css
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
.ripcrypt.ripcrypt--CryptApp {
|
||||||
|
max-width: initial;
|
||||||
|
min-width: initial;
|
||||||
|
|
||||||
|
> .window-header .window-title {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
> .window-content {
|
||||||
|
background: var(--base-background);
|
||||||
|
padding: 4px;
|
||||||
|
};
|
||||||
|
}
|
||||||
12
templates/Apps/CryptApp/turnCount.hbs
Normal file
12
templates/Apps/CryptApp/turnCount.hbs
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
<div>
|
||||||
|
<rc-border
|
||||||
|
var:border-color="var(--accent-1)"
|
||||||
|
>
|
||||||
|
<div slot="title">
|
||||||
|
Turn
|
||||||
|
</div>
|
||||||
|
<div slot="content">
|
||||||
|
1
|
||||||
|
</div>
|
||||||
|
</rc-border>
|
||||||
|
</div>
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
@import url("./AllItemSheetV1/style.css");
|
@import url("./AllItemSheetV1/style.css");
|
||||||
@import url("./CombinedHeroSheet/style.css");
|
@import url("./CombinedHeroSheet/style.css");
|
||||||
|
@import url("./CryptApp/style.css");
|
||||||
@import url("./DicePool/style.css");
|
@import url("./DicePool/style.css");
|
||||||
@import url("./HeroSummaryCardV1/style.css");
|
@import url("./HeroSummaryCardV1/style.css");
|
||||||
@import url("./HeroSkillsCardV1/style.css");
|
@import url("./HeroSkillsCardV1/style.css");
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
:host {
|
:host {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
--vertical-displacement: 10px;
|
--vertical-displacement: 12.5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.rc-border {
|
.rc-border {
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-top: var(--margin-top, var(--vertical-displacement));
|
margin-top: var(--margin-top, var(--vertical-displacement));
|
||||||
padding-top: var(--padding-top, var(--vertical-displacement));
|
padding-top: var(--padding-top, calc(var(--vertical-displacement) + 4px));
|
||||||
|
|
||||||
&::before {
|
&::before {
|
||||||
display: block;
|
display: block;
|
||||||
|
|
@ -60,5 +60,6 @@
|
||||||
max-width: 75%;
|
max-width: 75%;
|
||||||
min-width: 50px;
|
min-width: 50px;
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
--alt-row-background: var(--accent-2);
|
--alt-row-background: var(--accent-2);
|
||||||
|
|
||||||
--input-underline: 2px dashed var(--accent-3);
|
--input-underline: 2px dashed var(--accent-3);
|
||||||
--input-background: inherit;
|
--input-background: var(--accent-2);
|
||||||
--input-text: white;
|
--input-text: white;
|
||||||
--input-placeholder-text: rgba(255,255,255, 0.5);
|
--input-placeholder-text: rgba(255,255,255, 0.5);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue