Skip to content

Commit

Permalink
Added some more crit settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ChasarooniZ committed Sep 18, 2024
1 parent 70bcd97 commit 26599fc
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 38 deletions.
18 changes: 12 additions & 6 deletions scripts/helpers/settingsConfigForm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getSetting } from "./misc.js";
import { getSetting, MODULE_ID } from "./misc.js";

export class SettingsConfigForm extends FormApplication {
// lots of other things...
Expand All @@ -12,7 +12,7 @@ export class SettingsConfigForm extends FormApplication {
return mergeObject(super.defaultOptions, {
classes: ['form'],
popOut: true,
template: `modules/pf2e-rpg-numbers/templates/pf2e-rpg-settings-config.hbs`,
template: `modules/pf2e-rpg-numbers/templates/settings/pf2e-rpg-settings-config.hbs`,
id: 'pf2e-rpg-numbers-settings-form',
title: 'Pf2e RPG #s Config Menu',
width: 800,
Expand Down Expand Up @@ -97,10 +97,10 @@ export class SettingsConfigForm extends FormApplication {
scaleOnSize: getSetting("rotate-on-attack.scale-on-size"),
},
critical: {
critical: getSetting("critical.enabled"),
style: getSetting("critical.type"),
checksOrAttacks: getSetting("critical.show-on"),
pcOrNPC: getSetting("critical.show-on-token-type"),
enabled: getSetting("critical.enabled"),
style: convertChoicesGivenSetting("critical.type"),
checksOrAttacks: convertChoicesGivenSetting("critical.show-on"),
pcOrNPC: convertChoicesGivenSetting("critical.show-on-token-type"),
defImage: getSetting("critical.default-img"),
duration: getSetting("critical.duration"),
sound: getSetting("critical.sound"),
Expand Down Expand Up @@ -189,4 +189,10 @@ export class SettingsConfigForm extends FormApplication {
const data = expandObject(formData);
//game.settings.set('myModuleName', 'myComplexSettingName', data);
}
}

function convertChoicesGivenSetting(settingPath) {
const choices = game.settings.settings.get(MODULE_ID + "." + settingPath)?.choices;
const value = getSetting(settingPath);
return Object.entries(choices).map(([id, label]) => ({ id, label, selected: id === value }))
}
36 changes: 11 additions & 25 deletions templates/settings/pf2e-rpg-settings-config.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,47 +6,33 @@
</a>
{{/each}}
</nav>

<b>Fixed header</b><br>
{{header}}
<hr>

<section class="content">
{{#each tabs as |tab|}}
<div class="tab" data-tab="{{tab.id}}" data-group="primary-tabs">
Fixed content for tab {{tab.title}}<br>
{{#if home}}
{{> 'modules/pf2e-rpg-numbers/templates/settings/tabs/home.hbs' this}}
{{> 'modules/pf2e-rpg-numbers/templates/settings/tabs/home.hbs' this}}
{{/if}}
{{#if rolls}}
{{> 'modules/pf2e-rpg-numbers/templates/settings/tabs/rolls.hbs' this}}
{{> 'modules/pf2e-rpg-numbers/templates/settings/tabs/rolls.hbs' this}}
{{/if}}
{{#if token}}
{{> 'modules/pf2e-rpg-numbers/templates/settings/tabs/token.hbs' this}}
{{> 'modules/pf2e-rpg-numbers/templates/settings/tabs/token.hbs' this}}
{{/if}}
{{#if critical}}
{{> 'modules/pf2e-rpg-numbers/templates/settings/tabs/critical.hbs' this}}
{{> 'modules/pf2e-rpg-numbers/templates/settings/tabs/critical.hbs' this}}
{{/if}}
{{#if text}}
{{> 'modules/pf2e-rpg-numbers/templates/settings/tabs/text.hbs' this}}
{{> 'modules/pf2e-rpg-numbers/templates/settings/tabs/text.hbs' this}}
{{/if}}
{{#if misc}}
{{> 'modules/pf2e-rpg-numbers/templates/settings/tabs/misc.hbs' this}}
{{> 'modules/pf2e-rpg-numbers/templates/settings/tabs/misc.hbs' this}}
{{/if}}
</div>
{{/each}}
</section>

<hr>
<b>Fixed header</b><br>
{{header}}
<hr>
Fixed content<br>
{{{content}}}
<hr>
Fixed <em>footer</em><br>
{{footer}}
<button>Save</button>
<button>Submit</button>
<button>Cancel</button>
<footer>
<button>Save</button>
<button>Submit</button>
<button>Cancel</button>
</footer>
</form>
47 changes: 44 additions & 3 deletions templates/settings/tabs/critical.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,46 @@
<form>
<h2>Critical</h2>
<h3>{{localize "pf2e-rpg-numbers.module-settings.enabled.name"}}</h3>
{{localize "pf2e-rpg-numbers.module-settings.enabled.hint"}}
<h2>{{localize "pf2e-rpg-numbers.module-settings.headers.critical"}}</h2>
{{!-- Enabled --}}
<div class="form-group" data-tooltip="{{localize " pf2e-rpg-numbers.module-settings.critical.enabled.hint"}}">
<label for="settings.critical.enabled">{{localize
"pf2e-rpg-numbers.module-settings.critical.enabled.name"}}</label>
<input type="checkbox" id="settings.critical.enabled" name="settings.critical.enabled" {{#if settings.critical.enabled}} checked {{/if}} />
{{localize "pf2e-rpg-numbers.module-settings.critical.enabled.hint"}}
</div>
{{!-- Style --}}
<div class="form-group" data-tooltip="{{localize " pf2e-rpg-numbers.module-settings.critical.type.hint"}}">
<label for="settings.critical.style">{{localize
"pf2e-rpg-numbers.module-settings.critical.type.name"}}</label>
<select type="checkbox" id="settings.critical.style" name="settings.critical.style">
{{#each settings.critical.style as |option|}}
<option value="{{option.id}}" {{#if option.selected}}selected{{/if}}>{{localize "{{option.value}}"}}
</option>
{{/each}}
</select>
{{localize "pf2e-rpg-numbers.module-settings.critical.type.hint"}}
</div>
{{!-- Checks or Attacks --}}
<div class="form-group" data-tooltip="{{localize " pf2e-rpg-numbers.module-settings.critical.show-on.hint"}}">
<label for="settings.critical.show-on">{{localize
"pf2e-rpg-numbers.module-settings.critical.show-on.name"}}</label>
<select type="checkbox" id="settings.critical.show-on" name="settings.critical.show-on">
{{#each settings.critical.checksOrAttacks as |option|}}
<option value="{{option.id}}" {{#if option.selected}}selected{{/if}}>{{localize "{{option.value}}"}}
</option>
{{/each}}
</select>
{{localize "pf2e-rpg-numbers.module-settings.critical.show-on.hint"}}
</div>
{{!-- PC or NPC --}}
<div class="form-group" data-tooltip="{{localize " pf2e-rpg-numbers.module-settings.critical.show-on-token-type.hint"}}">
<label for="settings.critical.show-on-token-type">{{localize
"pf2e-rpg-numbers.module-settings.critical.show-on-token-type.name"}}</label>
<select type="checkbox" id="settings.critical.show-on-token-type" name="settings.critical.show-on-token-type">
{{#each settings.critical.pcOrNPC as |option|}}
<option value="{{option.id}}" {{#if option.selected}}selected{{/if}}>{{localize "{{option.value}}"}}
</option>
{{/each}}
</select>
{{localize "pf2e-rpg-numbers.module-settings.critical.show-on-token-type.hint"}}
</div>
</form>
7 changes: 3 additions & 4 deletions templates/settings/tabs/home.hbs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<form>
<h2>RPG #s</h2>
<div class="form-group">
<div class="form-group" data-tooltip="{{localize " pf2e-rpg-numbers.module-settings.enabled.hint"}}">
<label for="settings.enabled">{{localize "pf2e-rpg-numbers.module-settings.enabled.name"}}</label>
<input type="checkbox" id="settings.enabled" name="settings.enabled" value="{{settings.enabled}}" />
<input type="checkbox" id="settings.enabled" name="settings.enabled" {{#if settings.enabled}}checked{{/if}} />
{{localize "pf2e-rpg-numbers.module-settings.enabled.hint"}}
</div>
<h3></h3>
{{localize "pf2e-rpg-numbers.module-settings.enabled.hint"}}
</form>

0 comments on commit 26599fc

Please sign in to comment.