Skip to content

Commit

Permalink
0.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Jul 15, 2021
1 parent 43aeb89 commit fb727db
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 33 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "initiative-tracker",
"name": "Initiative Tracker",
"version": "0.0.9",
"version": "0.0.10",
"minAppVersion": "0.12.5",
"author": "Jeremy Valentine",
"description": "TTRPG Initiative Tracker for Obsidian.md",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "initiative-tracker",
"version": "0.0.9",
"version": "0.0.10",
"description": "TTRPG Initiative Tracker for Obsidian.md",
"main": "main.js",
"scripts": {
Expand Down
29 changes: 12 additions & 17 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ declare module "obsidian" {
}
}
export default class InitiativeTracker extends Plugin {
public view: TrackerView;
public data: InitiativeTrackerData;
private _playercreatures: Creature[];
private _homebrewcreatures: Creature[];
Expand Down Expand Up @@ -94,6 +93,14 @@ export default class InitiativeTracker extends Plugin {
return [...BESTIARY, ...this.homebrew];
}

get view() {
let leaf = (
this.app.workspace.getLeavesOfType(INTIATIVE_TRACKER_VIEW) ?? []
).shift();
if (leaf && leaf.view && leaf.view instanceof TrackerView)
return leaf.view;
}

async onload() {
registerIcons();

Expand All @@ -103,7 +110,7 @@ export default class InitiativeTracker extends Plugin {

this.registerView(
INTIATIVE_TRACKER_VIEW,
(leaf: WorkspaceLeaf) => (this.view = new TrackerView(leaf, this))
(leaf: WorkspaceLeaf) => new TrackerView(leaf, this)
);

this.addCommand({
Expand All @@ -125,11 +132,7 @@ export default class InitiativeTracker extends Plugin {
name: "Toggle Encounter",
checkCallback: (checking) => {
if (checking) {
return (
this.app.workspace.getLeavesOfType(
INTIATIVE_TRACKER_VIEW
).length != 0
);
return this.view != undefined;
}
this.view.toggleState();
}
Expand All @@ -139,11 +142,7 @@ export default class InitiativeTracker extends Plugin {
name: "Next Combatant",
checkCallback: (checking) => {
if (checking) {
return (
this.app.workspace.getLeavesOfType(
INTIATIVE_TRACKER_VIEW
).length != 0 && this.view.state
);
return this.view != undefined && this.view.state;
}
this.view.goToNext();
}
Expand All @@ -153,11 +152,7 @@ export default class InitiativeTracker extends Plugin {
name: "Previous Combatant",
checkCallback: (checking) => {
if (checking) {
return (
this.app.workspace.getLeavesOfType(
INTIATIVE_TRACKER_VIEW
).length != 0 && this.view.state
);
return this.view != undefined && this.view.state;
}
this.view.goToPrevious();
}
Expand Down
3 changes: 2 additions & 1 deletion src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ export default class InitiativeTrackerSettings extends PluginSettingTab {
this.plugin.data.initiative = v;
});
t.inputEl.onblur = async () => {
this.plugin.view.rollInitiatives();
if (this.plugin.view)
this.plugin.view.rollInitiatives();
await this.plugin.saveSettings();
};
});
Expand Down
13 changes: 1 addition & 12 deletions src/view.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import { ItemView, WorkspaceLeaf } from "obsidian";
import {
BASE,
PLAY,
STOP,
INTIATIVE_TRACKER_VIEW,
MIN_WIDTH_FOR_HAMBURGER
} from "./utils";

import type InitiativeTracker from "./main";

/* import { createApp } from "vue";
import App from "./ui/App.vue"; */

import App from "./svelte/App.svelte";
import { Creature } from "./utils/creature";

Expand All @@ -32,13 +27,6 @@ export default class TrackerView extends ItemView {
this.newEncounter();
}

/* async buildCreatures() {
this.creatures = [...this.players];
await this.rollInitiatives();
} */

get ordered() {
this.creatures.sort((a, b) => b.initiative - a.initiative);

Expand Down Expand Up @@ -241,6 +229,7 @@ export default class TrackerView extends ItemView {
}
});
this._rendered = true;

}
async onClose() {
this._app.$destroy();
Expand Down
2 changes: 1 addition & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"0.0.9": "0.12.4"
"0.0.10": "0.12.4"
}

0 comments on commit fb727db

Please sign in to comment.