Conformed to Changed recommended

This commit is contained in:
Daniel Stirba 2023-02-24 19:57:22 +11:00
parent c1e4a15c6a
commit a105b6f288
3 changed files with 12 additions and 21 deletions

View file

@ -35,9 +35,9 @@ In the settings of the plugin you will Find settings and options to add your own
## Inline Generator ## Inline Generator
If you found yourself needing a quick name for an Elf or really wanting a quick dungeon description then look no further then the Inline generator. You can activate this by using the Callout token (Default is set to '@', can be changed in settings)and scrolling through the list of generators possible. If you found yourself needing a quick name for an Elf or really wanting a quick dungeon description then look no further then the Inline generator. You can activate this by using the Callout token (Default is set to '@', can be changed in settings) and scrolling through the list of generators possible.
### Example ### Inline Example
![Example](Obsidian_mrGSNRjLpe.gif) ![Example](Obsidian_mrGSNRjLpe.gif)
@ -67,4 +67,4 @@ Below is a table for all the settings in this plugin
- ~~Randomization within a note.~~ - ~~Randomization within a note.~~
- Possibly more Generation type. - Possibly more Generation type.
- Better UI - Better UI
- JSON Import And Export - ~~JSON Import And Export~~

View file

@ -119,7 +119,7 @@ export class GeneratorModal extends Modal {
multiNames: false multiNames: false
} }
genSettings.race = raceSelected; genSettings.race = raceSelected;
settingsdiv.innerHTML = ""; settingsdiv.empty();
settingsdiv.createEl("h3", { text: "Customise The Generation" }); settingsdiv.createEl("h3", { text: "Customise The Generation" });
new Setting(settingsdiv) new Setting(settingsdiv)
.setName("Male or Female?") .setName("Male or Female?")
@ -197,7 +197,7 @@ export class GeneratorModal extends Modal {
} }
generatorInnSettings(settingsdiv: HTMLElement, genAmount: number, generatorFunction: (settings: innGeneratorSettings) => {name:string,description:string,rumors:string[]}) { generatorInnSettings(settingsdiv: HTMLElement, genAmount: number, generatorFunction: (settings: innGeneratorSettings) => {name:string,description:string,rumors:string[]}) {
settingsdiv.innerHTML = ""; settingsdiv.empty();
settingsdiv.createEl("h3", { text: "Customise The Generation" }); settingsdiv.createEl("h3", { text: "Customise The Generation" });
genAmount = 1; genAmount = 1;
let innList = ''; let innList = '';
@ -245,7 +245,7 @@ export class GeneratorModal extends Modal {
} }
generatorLootSettings(settingsdiv: HTMLElement, genAmount: number, generatorFunction: (enableCurrency:boolean, currencyFrequency: number, currencyTypes: object[], lootTable: lootTables) => string, enableCurrency:boolean, currencyFrequency: number, currencyTypes: object[]) { generatorLootSettings(settingsdiv: HTMLElement, genAmount: number, generatorFunction: (enableCurrency:boolean, currencyFrequency: number, currencyTypes: object[], lootTable: lootTables) => string, enableCurrency:boolean, currencyFrequency: number, currencyTypes: object[]) {
settingsdiv.innerHTML = ""; settingsdiv.empty();
settingsdiv.createEl("h3", { text: "Customise The Generation" }); settingsdiv.createEl("h3", { text: "Customise The Generation" });
genAmount = 1; genAmount = 1;
let list = ''; let list = '';
@ -292,7 +292,7 @@ export class GeneratorModal extends Modal {
} }
generatorFCGSettlementSettings(settingsdiv: HTMLElement, genAmount: number, generatorFunction: () => ISettlementDomainObject) { generatorFCGSettlementSettings(settingsdiv: HTMLElement, genAmount: number, generatorFunction: () => ISettlementDomainObject) {
settingsdiv.innerHTML = ""; settingsdiv.empty();
settingsdiv.createEl("h3", { text: "Customise The Generation" }); settingsdiv.createEl("h3", { text: "Customise The Generation" });
genAmount = 1; genAmount = 1;
let list = ''; let list = '';
@ -343,7 +343,7 @@ export class GeneratorModal extends Modal {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
generatorCustomSettings(settingsdiv: HTMLElement, genAmount: number, generatorFunction: (settings ?: any) => string, settings ?: any) { generatorCustomSettings(settingsdiv: HTMLElement, genAmount: number, generatorFunction: (settings ?: any) => string, settings ?: any) {
settingsdiv.innerHTML = ""; settingsdiv.empty();
settingsdiv.createEl("h3", { text: "Customise The Generation" }); settingsdiv.createEl("h3", { text: "Customise The Generation" });
genAmount = 1; genAmount = 1;
let list = ""; let list = "";

17
main.ts
View file

@ -1,5 +1,5 @@
import { GeneratorModal } from 'editor/GeneratorModal'; import { GeneratorModal } from 'editor/GeneratorModal';
import { MarkdownView, Notice, Plugin } from 'obsidian'; import { Notice, Plugin } from 'obsidian';
import { InlineGeneratorSuggester } from "editor/InlineGenerator"; import { InlineGeneratorSuggester } from "editor/InlineGenerator";
import { FantasyPluginSettings, possibleOptions } from 'settings/Datatypes'; import { FantasyPluginSettings, possibleOptions } from 'settings/Datatypes';
import { DEFAULT_SETTINGS } from 'settings/DefaultSetting'; import { DEFAULT_SETTINGS } from 'settings/DefaultSetting';
@ -16,20 +16,16 @@ export default class FantasyPlugin extends Plugin {
async onload() { async onload() {
await this.loadSettings(); await this.loadSettings();
app.workspace.onLayoutReady(() => { app.workspace.onLayoutReady(() => {
const view = this.app.workspace.getActiveViewOfType(MarkdownView); //Register the InlineGeneratorSuggester to the Editor suggester.
// Make sure the user is editing a Markdown file. this.registerEditorSuggest(new InlineGeneratorSuggester(this.getOptionsForSuggest, this));
if (view) {
//Register the InlineGeneratorSuggester to the Editor suggester.
this.registerEditorSuggest(new InlineGeneratorSuggester(this.getOptionsForSuggest, this));
}
}); });
// This creates an icon in the left ribbon to access the modal for the Fantasy Content Generator. // This creates an icon in the left ribbon to access the modal for the Fantasy Content Generator.
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const ribbonIconEl = this.addRibbonIcon('book', 'Fantasy Generators', (evt: MouseEvent) => { const ribbonIconEl = this.addRibbonIcon('book', 'Fantasy Generators', (evt: MouseEvent) => {
// Called when the user clicks the icon. // Called when the user clicks the icon.
new GeneratorModal(this.app, (result) => { new GeneratorModal(this.app, (result) => {
const copyContent = async () => { const copyContent = async () => {
console.log();
//Try to see if any generators spit out an Error or if copying the string fails. //Try to see if any generators spit out an Error or if copying the string fails.
try { try {
if (result instanceof Error) { if (result instanceof Error) {
@ -48,15 +44,10 @@ export default class FantasyPlugin extends Plugin {
}, this).open(); }, this).open();
}); });
// Perform additional things with the ribbon
ribbonIconEl.addClass('my-plugin-ribbon-class');
// This adds a settings tab so the user can configure various aspects of the plugin // This adds a settings tab so the user can configure various aspects of the plugin
this.addSettingTab(new SettingTab(this.app, this)); this.addSettingTab(new SettingTab(this.app, this));
// When registering intervals, this function will automatically clear the interval when the plugin is disabled.
this.registerInterval(window.setInterval(() => console.log('setInterval'), 5 * 60 * 1000));
console.log("loaded Fantasy Content Generator"); console.log("loaded Fantasy Content Generator");
} }