Skip to content

Commit

Permalink
fix: Enables a Fudge/Fate dice icon (toggleable in settings) (close #251
Browse files Browse the repository at this point in the history
)
  • Loading branch information
valentine195 committed Oct 16, 2023
1 parent 6ab60d9 commit fd5aabf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import { Round, ExpectedValue, RollerOptions } from "./types";
import { inlinePlugin } from "./live-preview";
import API from "./api/api";
/* import GenesysView, { GENESYS_VIEW_TYPE } from "./view/genesys"; */

String.prototype.matchAll =
String.prototype.matchAll ||
function* matchAll(regexp: RegExp): IterableIterator<RegExpMatchArray> {
Expand Down Expand Up @@ -128,6 +127,7 @@ declare global {
}
}
interface DiceRollerSettings {
showFudgeIcon: boolean;
rollLinksForTags: boolean;
copyContentButton: boolean;
displayResultsInline: boolean;
Expand Down Expand Up @@ -168,6 +168,7 @@ interface DiceRollerSettings {
}

export const DEFAULT_SETTINGS: DiceRollerSettings = {
showFudgeIcon: false,
rollLinksForTags: false,
copyContentButton: true,
customFormulas: [],
Expand Down
10 changes: 10 additions & 0 deletions src/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,16 @@ export default class SettingTab extends PluginSettingTab {
await this.plugin.saveSettings();
});
});
new Setting(containerEl)
.setName("Display Fudge/Fate Dice Icon")
.addToggle((t) => {
t.setValue(this.plugin.data.showFudgeIcon);
t.onChange(async (v) => {
this.plugin.data.showFudgeIcon = v;
this.plugin.view?.buildButtons();
await this.plugin.saveSettings();
});
});
}
buildRender(containerEl: HTMLDivElement) {
containerEl.empty();
Expand Down
4 changes: 4 additions & 0 deletions src/view/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const VIEW_TYPE = "DICE_ROLLER_VIEW";

const D4 = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><defs><style>.cls-1{fill:none;stroke: currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:15px !important;}</style></defs><g id="Shapes"><path class="cls-1" d="M244.62,49.31,40.31,403.19a6.21,6.21,0,0,0,5.38,9.31H454.31a6.21,6.21,0,0,0,5.38-9.31L255.38,49.31A6.21,6.21,0,0,0,244.62,49.31Z"/></g><g fill="currentColor" id="Layer_1" data-name="Layer 1"><path d="M270.21,278.16h21.7v16.22h-21.7v36.31h-20V294.38H179V282.67l70-108.39h21.16Zm-68.64,0h48.66v-76.7l-2.36,4.3Z"/></g></svg>`;
const D6 = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><defs><style>.cls-1{fill:none;stroke: currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:15px !important;}</style></defs><g id="Shapes"><rect class="cls-1" x="87.5" y="87.5" width="325" height="325" rx="10"/></g><g fill="currentColor" id="Layer_1" data-name="Layer 1"><path d="M279.22,174.18V191h-3.65q-23.2.44-37,13.75t-15.9,37.49q12.36-14.17,33.74-14.18,20.4,0,32.6,14.4t12.19,37.17q0,24.16-13.16,38.67t-35.29,14.5q-22.46,0-36.41-17.24t-14-44.42v-7.63q0-43.19,18.42-66t54.84-23.36Zm-26.1,70.47a33.41,33.41,0,0,0-30.73,21.48v7.31q0,19.33,8.7,31.15t21.7,11.81q13.43,0,21.11-9.88t7.68-25.89q0-16.11-7.79-26A25,25,0,0,0,253.12,244.65Z"/></g></svg>`;
const DF = `<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 500 500" style="enable-background:new 0 0 500 500;" xml:space="preserve"><style type="text/css">.st0{fill:none;stroke:currentColor;stroke-width:15;stroke-linecap:round;stroke-linejoin:round;}</style><g id="Shapes"><path class="st0" d="M97.5,87.5h305c5.5,0,10,4.5,10,10v305c0,5.5-4.5,10-10,10h-305c-5.5,0-10-4.5-10-10v-305 C87.5,92,92,87.5,97.5,87.5z"/></g><g fill="currentColor"><path d="M207.4,164.7h90.2v18.1H229v55.7h63.4v17.9H229v75.8h-21.6V164.7z"/></g></svg>`;
const D8 = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><defs><style>.cls-1{fill:none;stroke: currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:15px !important;}</style></defs><g id="Shapes"><rect class="cls-1" x="102.75" y="102.75" width="294.51" height="294.51" rx="9.8" transform="translate(-103.55 250) rotate(-45)"/></g><g fill="currentColor" id="Layer_1" data-name="Layer 1"><path d="M292.08,215.1a36.35,36.35,0,0,1-6.17,20.84,42.05,42.05,0,0,1-16.71,14.29,44.8,44.8,0,0,1,19.39,15.36,38.7,38.7,0,0,1,7.15,22.88q0,20.31-13.7,32.34t-36,12q-22.56,0-36.15-12.09t-13.59-32.28a39.84,39.84,0,0,1,6.93-22.88,43.14,43.14,0,0,1,19.18-15.47,40.88,40.88,0,0,1-16.44-14.28,36.85,36.85,0,0,1-6-20.74q0-19.75,12.67-31.36T246,172.14q20.63,0,33.35,11.6T292.08,215.1ZM275.86,288q0-13.1-8.32-21.37t-21.75-8.27q-13.44,0-21.54,8.16T216.14,288q0,13.33,7.89,20.95t22,7.63q14,0,21.91-7.68T275.86,288ZM246,188.46q-11.72,0-19,7.26t-7.25,19.71q0,11.92,7.14,19.28T246,242.07q11.92,0,19.07-7.36t7.14-19.28q0-11.93-7.41-19.45T246,188.46Z"/></g></svg>`;
const D10 = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><defs><style>.cls-1{fill:none;stroke: currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:15px !important;}</style></defs><g id="Shapes"><rect class="cls-1" x="102.75" y="102.75" width="294.51" height="294.51" rx="9.8" transform="translate(-103.55 250) rotate(-45)"/></g><g fill="currentColor" id="Layer_1" data-name="Layer 1"><path d="M219,330.69H199V198.24L158.92,213V194.91l56.93-21.38H219Z"/><path d="M344.47,264q0,34.92-11.93,51.89t-37.27,17q-25,0-37.06-16.6t-12.46-49.57V240.13q0-34.47,11.92-51.24t37.38-16.75q25.24,0,37.17,16.16t12.25,49.9ZM324.59,236.8q0-25.23-7.09-36.79t-22.45-11.55q-15.26,0-22.23,11.5t-7.2,35.34v31.8q0,25.35,7.36,37.43t22.29,12.09q14.72,0,21.86-11.39t7.46-35.88Z"/></g></svg>`;
const D12 = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><defs><style>.cls-1{fill:none;stroke: currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:15px !important;}</style></defs><g id="Shapes"><path class="cls-1" d="M244.31,29.14,52,168.87a9.72,9.72,0,0,0-3.52,10.84l73.47,226.1a9.69,9.69,0,0,0,9.21,6.69H368.87a9.69,9.69,0,0,0,9.21-6.69l73.47-226.1A9.72,9.72,0,0,0,448,168.87L255.69,29.14A9.66,9.66,0,0,0,244.31,29.14Z"/></g><g fill="currentColor" id="Layer_1" data-name="Layer 1"><path d="M208,330.69H188V198.24L147.93,213V194.91l56.93-21.38H208Z"/><path d="M342.28,330.69H239.8V316.4l54.14-60.15q12-13.65,16.6-22.19a37,37,0,0,0,4.56-17.67q0-12.24-7.41-20.08t-19.77-7.85q-14.82,0-23,8.44t-8.22,23.47H236.79q0-21.6,13.91-34.91t37.22-13.32q21.81,0,34.49,11.44T335.08,214q0,23.1-29.43,55l-41.9,45.44h78.53Z"/></g></svg>`;
Expand All @@ -27,6 +28,7 @@ const D100 = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500"><def

addIcon("d4", D4);
addIcon("d6", D6);
addIcon("dF", DF);
addIcon("d8", D8);
addIcon("d10", D10);
addIcon("d12", D12);
Expand Down Expand Up @@ -55,6 +57,7 @@ export default class DiceView extends ItemView {
return {
d4: 0,
d6: 0,
dF: 0,
d8: 0,
d10: 0,
d12: 0,
Expand Down Expand Up @@ -118,6 +121,7 @@ export default class DiceView extends ItemView {
const buttons = this.gridEl.createDiv("dice-buttons");

for (let type in this.dice) {
if (type === "dF" && !this.plugin.data.showFudgeIcon) continue;
const button = new ExtraButtonComponent(
buttons.createDiv("dice-button")
).setIcon(type);
Expand Down

0 comments on commit fd5aabf

Please sign in to comment.