Skip to content

Commit

Permalink
fix: added global condense setting in Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
valentine195 committed Dec 14, 2021
1 parent 2f2dd10 commit 56df12a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,23 @@ export default class InitiativeTrackerSettings extends PluginSettingTab {
t.setValue(this.plugin.data.displayDifficulty).onChange(
async (v) => {
this.plugin.data.displayDifficulty = v;

await this.plugin.saveSettings();
}
);
});
new Setting(containerEl)
.setName("Roll Equivalent Creatures Together")
.setDesc(
"Equivalent creatures (same HP, AC and Name) will roll the same initiative by default."
)
.addToggle((t) => {
t.setValue(this.plugin.data.condense).onChange(
async (v) => {
this.plugin.data.condense = v;
const view = this.plugin.view;
if (view) {
view.setDisplayDifficulty(
this.plugin.data.displayDifficulty
);
view.setCondensed(this.plugin.data.condense);
}

await this.plugin.saveSettings();
}
);
Expand Down
4 changes: 4 additions & 0 deletions src/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export default class TrackerView extends ItemView {
this.condense = !this.condense;
this.setAppState({ creatures: this.ordered });
}
setCondensed(bool: boolean) {
this.condense = bool;
this.setAppState({ creatures: this.ordered });
}
async openCombatant(creature: Creature) {
const view = this.plugin.combatant;
if (!view) {
Expand Down

0 comments on commit 56df12a

Please sign in to comment.