Skip to content

Commit

Permalink
Fully working
Browse files Browse the repository at this point in the history
  • Loading branch information
PrototypeESBU committed Nov 14, 2024
1 parent 801d6f1 commit 27b2a7c
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 0 deletions.
8 changes: 8 additions & 0 deletions i18n/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ SHADOWDARK.apps.monster-importer.instruction2d: Main stat block
SHADOWDARK.apps.monster-importer.instruction2e: Feature
SHADOWDARK.apps.monster-importer.instruction3: 3. Click Import Monster.
SHADOWDARK.apps.monster-importer.title: Import Monster
SHADOWDARK.apps.request-check.copied: Copied to Clipboard
SHADOWDARK.apps.request-check.copy_to_clipboard: Copy to Clipboard
SHADOWDARK.apps.request-check.custom: Custom
SHADOWDARK.apps.request-check.easy: Easy
SHADOWDARK.apps.request-check.hard: Hard
SHADOWDARK.apps.request-check.extreme: Extreme
SHADOWDARK.apps.request-check.normal: Normal
SHADOWDARK.apps.request-check.title: Request Check
SHADOWDARK.apps.shadowdarkling-importer.errors: Items Not Found
SHADOWDARK.apps.shadowdarkling-importer.header: Shadowdarkling Importer
SHADOWDARK.apps.shadowdarkling-importer.import_button: Import
Expand Down
8 changes: 8 additions & 0 deletions scss/shadowdark.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
width: 100%;
}

input[type=radio] {
width: auto;
}

hr {
border: none;
border-top: solid 1px #{$primary-color};
Expand Down Expand Up @@ -79,4 +83,8 @@
}
}

.checkbox {
font-size:14px;
};

}
59 changes: 59 additions & 0 deletions system/src/apps/RequestCheckSD.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
export default class RequestCheckSD extends FormApplication {

static get defaultOptions() {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["shadowdark"],
template: "systems/shadowdark/templates/apps/request-check.hbs",
width: 400,
title: game.i18n.localize("SHADOWDARK.apps.request-check.title"),
closeOnSubmit: false,
});
}

activateListeners(html) {
super.activateListeners(html);

html.find(".custom-dc").click(
event => {
$(event.target).siblings()[0].checked=true;
}
);
}

/** @override */
async getData() {
return {
stats: CONFIG.SHADOWDARK.ABILITIES_LONG,
difficulty: {
9: `9 (${game.i18n.localize("SHADOWDARK.apps.request-check.easy")})`,
12: `12 (${game.i18n.localize("SHADOWDARK.apps.request-check.normal")})`,
15: `15 (${game.i18n.localize("SHADOWDARK.apps.request-check.hard")})`,
18: `18 (${game.i18n.localize("SHADOWDARK.apps.request-check.extreme")})`,
},
};
}

/** @inheritdoc */
async _updateObject(event, data) {

if (data.custom) {
data.difficulty = data.custom;
}
data.difficulty = parseInt(data.difficulty);

switch (event.submitter.name) {
case "request-copy":
let linkText = `[[request ${data.difficulty} ${data.stat}]]`;
await navigator.clipboard.writeText(linkText);
ui.notifications.info(game.i18n.localize("SHADOWDARK.apps.request-check.copied"));
break;
case "request-check":
shadowdark.checks.displayRequest(data.difficulty, data.stat);
this.close();
break;
default:
shadowdark.log("Request Check Error");
}
}

}
1 change: 1 addition & 0 deletions system/src/apps/_module.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export {default as LightSourceTrackerSD} from "./LightSourceTrackerSD.mjs";
export {default as LoadingSD} from "./LoadingSD.mjs";
export {default as MonsterImporterSD} from "./MonsterImporterSD.mjs";
export {default as NpcAttackRangesSD} from "./NpcAttackRangesSD.mjs";
export {default as RequestCheckSD} from "./RequestCheckSD.mjs";
export {default as ShadowdarklingImporterSD} from "./ShadowdarklingImporterSD.mjs";
export {default as SpellBookSD} from "./SpellBookSD.mjs";
export {default as SpellImporterSD} from "./SpellImporterSD.mjs";
Expand Down
32 changes: 32 additions & 0 deletions system/templates/apps/request-check.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<form autocomplete="off">
<div class="grid-2-columns">
{{#> ui/sd-box
header-label="Difficulty"
}}
<div class="grid-1-columns">
{{radioBoxes "difficulty" difficulty checked="12"}}
<hr>
<label class="checkbox">
<input type="radio" name="difficulty" value="0">
<input type="number" class="custom-dc" name="custom" style="width:2em;" maxlength="2">
({{localize "SHADOWDARK.apps.request-check.custom"}})
</label>
</div>
{{/ui/sd-box}}

{{#> ui/sd-box
header-label="Stat"
}}
<div class="grid-1-columns">
{{radioBoxes "stat" stats checked="str"}}
</div>
{{/ui/sd-box}}

<hr class="grid-colspan-2">

<button class="grid-colspan-2" type="submit" name="request-copy">{{localize "SHADOWDARK.apps.request-check.copy_to_clipboard"}}</button>
<button class="grid-colspan-2 larger" type="submit" name="request-check" style="font-family:'Old Newspaper Font';">
{{localize "SHADOWDARK.apps.request-check.title"}}
</button>
</div>
</form>

0 comments on commit 27b2a7c

Please sign in to comment.