Skip to content

Commit 426a50e

Browse files
committed
Move dice config settings to main settings menu
1 parent df5bab0 commit 426a50e

File tree

4 files changed

+22
-25
lines changed

4 files changed

+22
-25
lines changed

scripts/apps/dice-config.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ export default class DiceConfig extends FormApplication {
77
title: "Dice Configuration",
88
popOut: true,
99
width: 720,
10-
submitOnChange: true,
11-
submitOnClose: true,
12-
closeOnSubmit: false
10+
submitOnChange: false,
11+
submitOnClose: false,
12+
closeOnSubmit: true
1313
});
1414
}
1515

scripts/fulfillable-roll.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import ManualResolver from "./apps/manual-resolver.mjs";
22
const _rollEvaluateOriginal = Roll.prototype._evaluate;
3+
const _dieEvaluateOriginal = Die.prototype._evaluate;
34

45
/**
56
* Patch the asynchronous Roll#_evaluate method to handle logistics of manual fulfillment.
@@ -34,6 +35,7 @@ export async function _rollEvaluate(options) {
3435
* @returns {Promise<Die>} The evaluated Die term
3536
*/
3637
export async function _dieEvaluate(options) {
38+
if ( !this._fulfilled?.length > 0 ) return _dieEvaluateOriginal.call(this, options);
3739
if ( this.number > 999 ) throw new Error("You may not evaluate a DiceTerm with more than 999 requested results.");
3840
for ( let n=0; n < this.number; n++ ) {
3941
const v = this._fulfilled[n];

scripts/unfulfilled-rolls.mjs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ Hooks.once('init', async function() {
1010
type: Object,
1111
scope: "client"
1212
});
13+
game.settings.registerMenu("unfulfilled-rolls", "configuration", {
14+
name: "Dice Configuration",
15+
label: "Configure Dice",
16+
icon: "fa-solid fa-dice-d20",
17+
type: DiceConfig,
18+
restricted: false
19+
});
1320

1421
CONFIG.Dice.DieTypes = [
1522
{ id: "d4", faces: 4, icon: "fa-dice-d4" },
@@ -36,15 +43,3 @@ Hooks.once('init', async function() {
3643
Roll.prototype._evaluate = _rollEvaluate;
3744
Die.prototype._evaluate = _dieEvaluate;
3845
});
39-
40-
Hooks.on("renderSettings", (app, html, data) => {
41-
const diceConfigButton = document.createElement("button");
42-
diceConfigButton.type = "button";
43-
diceConfigButton.classList.add("open-dice-config");
44-
diceConfigButton.innerHTML = `<i class="fas fa-dice-d20"></i> Open Dice Configuration`;
45-
diceConfigButton.addEventListener("click", () => {
46-
const diceConfig = new DiceConfig();
47-
diceConfig.render(true);
48-
});
49-
html.find("button[data-action='controls']").after(diceConfigButton);
50-
});

templates/dice-config.hbs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
<div class="form-group">
44
<label>Bluetooth Die Provider</label>
55
<select name="bluetoothDieProvider">
6-
{{!-- Render an option for each provider --}}
76
{{selectOptions bluetoothDieProviders selected=this.bluetoothDieProvider labelAttr="label"}}
87
</select>
98
</div>
109

1110
<section>
12-
{{!-- Render an option for each die size (d4, d6, d8, d10, d12, d20, percentile) --}}
1311
{{#each dieTypes}}
14-
<div class="form-group" data-die="{{this.id}}">
15-
{{!-- For each die, display its name, an icon representing it, and a dropdown to select how it's fulfilled --}}
16-
<label><i class="far {{this.icon}}"></i> {{this.id}}</label>
17-
<select name="{{this.id}}">
18-
{{!-- Render an option for each fulfillment method --}}
19-
{{selectOptions ../fulfillmentMethods selected=this.fulfillmentMethod}}
20-
</select>
21-
</div>
12+
<div class="form-group" data-die="{{this.id}}">
13+
<label><i class="far {{this.icon}}"></i> {{this.id}}</label>
14+
<select name="{{this.id}}">
15+
{{selectOptions ../fulfillmentMethods selected=this.fulfillmentMethod}}
16+
</select>
17+
</div>
2218
{{/each}}
2319
</section>
20+
21+
<footer>
22+
<button type="submit"><i class="fa-solid fa-save"></i> {{localize "Save"}}</button>
23+
</footer>
2424
</form>

0 commit comments

Comments
 (0)