Skip to content

Commit

Permalink
Merge pull request #3 from kandashi/0.0.23
Browse files Browse the repository at this point in the history
optional close
  • Loading branch information
kandashi authored Jan 17, 2021
2 parents 0316bd9 + d19e37b commit 1ff0208
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Combat-Focus",
"title": "Combat Focus",
"description": "Auto focus to current combatant",
"version": "0.0.22",
"version": "0.0.23",
"authors": [
{
"name": "Kandashi",
Expand Down
16 changes: 14 additions & 2 deletions src/combatFocus.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ Hooks.on('init', () => {
default: "0",
config: true,
});

game.settings.register("Combat-Focus", "close-old", {
name: 'Close old combatant actor sheet',
hint: 'Close all previous combatants sheet on turn change',
scope: 'world',
type: Boolean,
default: false,
config: true,
});
game.settings.register("Combat-Focus", "close-all", {
name: 'Close all actor sheets',
hint: 'Close all open actor sheet on turn change',
Expand All @@ -20,6 +29,7 @@ Hooks.on('init', () => {
default: false,
config: true,
});

})

Hooks.on("updateCombat", async (combat, changed, options, userId) => {
Expand Down Expand Up @@ -54,6 +64,7 @@ Hooks.on('init', () => {

const combatFocus = game.settings.get('Combat-Focus', 'combatFocus')
const closeAll = game.settings.get('Combat-Focus', 'close-all')
const closeOld = game.settings.get('Combat-Focus', 'close-old')
let currentWindows = Object.values(ui.windows)
if (combatFocus !== "0") {
await sleep(5)
Expand All @@ -65,12 +76,13 @@ Hooks.on('init', () => {
if (combatFocus === "1") {
sheet.setPosition({ left: 107, top: 46 });
if (closeAll) for (let window of currentWindows) if (window.actor && window.actor.id !== currentToken.actor.id) window.close(true)
else await previousToken.actor.sheet.close(true)
if(closeOld) await previousToken.actor.sheet.close(true)

}
if (combatFocus === "2") {
sheet.setPosition({ left: rightPos, top: 46 });
if (closeAll) for (let window of currentWindows) if (window.actor && window.actor.id !== currentToken.actor.id) window.close(true)
else await previousToken.actor.sheet.close(true)
if(closeOld) await previousToken.actor.sheet.close(true)
}

async function sleep(millis) {
Expand Down

0 comments on commit 1ff0208

Please sign in to comment.