diff --git a/languages/en.json b/languages/en.json index dbd1449..214363c 100644 --- a/languages/en.json +++ b/languages/en.json @@ -10,5 +10,7 @@ "bossbar.settings.backgroundPath.name":"Background Image", "bossbar.settings.backgroundPath.hint":"Image to be placed as the healthbar background", "bossbar.settings.foregroundPath.name":"Foreground Image", - "bossbar.settings.foregroundPath.hint":"Image to be palced as the healthbar foreground, this image will be resized depending on hp %" + "bossbar.settings.foregroundPath.hint":"Image to be palced as the healthbar foreground, this image will be resized depending on hp %", + "bossbar.settings.textSize.name":"Font Size", + "bossbar.settings.textSize.hint":"Font Size in pixels" } \ No newline at end of file diff --git a/scripts/BossBar.js b/scripts/BossBar.js index 5327b2f..d23e770 100644 --- a/scripts/BossBar.js +++ b/scripts/BossBar.js @@ -4,6 +4,7 @@ class BossBar { this.token; this.bgPath = game.settings.get("bossbar", "backgroundPath"); this.fgPath = game.settings.get("bossbar", "foregroundPath"); + this.textSize = game.settings.get("bossbar", "textSize") } static async create(token, render = true) { @@ -13,7 +14,6 @@ class BossBar { this.addBossBar(instance) if (render) instance.draw(game.settings.get("bossbar", "barHeight")); if (game.user.isGM){ - debugger let oldBars = canvas.scene.getFlag("bossbar", "bossBarActive") if(Array.isArray(oldBars)){oldBars.push(token.id)}else{oldBars=[token.id]} await canvas.scene.setFlag("bossbar", "bossBarActive", oldBars); @@ -32,13 +32,14 @@ class BossBar { draw(h) { if($("body").find(`div[id="bossBar-${this.id}"]`).length > 0) return $("#navigation").append( - `
- ${this.name} + `
+ ${this.name}
test test
+
` ); this.update(); @@ -55,17 +56,17 @@ class BossBar { } static clearAll(){ - debugger if(!canvas.scene._bossBars) return for(let bar of Object.entries(canvas.scene._bossBars)){ $("body").find(`div[id="bossBar-${bar[1].id}"]`).remove(); + $("body").find(`div[id="bossBarSpacer-${bar[1].id}"]`).remove(); } } - remove() { + static remove() { canvas.scene.unsetFlag("bossbar", "bossBarActive").then(() => { - this.clear(); + this.clearAll(); }); } diff --git a/scripts/main.js b/scripts/main.js index 5f6d1f4..848fe5d 100644 --- a/scripts/main.js +++ b/scripts/main.js @@ -26,6 +26,15 @@ Hooks.once("init", function () { default: 20, }); + game.settings.register("bossbar", "textSize", { + name: game.i18n.localize("bossbar.settings.textSize.name"), + hint: game.i18n.localize("bossbar.settings.textSize.hint"), + scope: "world", + config: true, + type: Number, + default: 20, + }); + game.settings.register("bossbar", "backgroundPath", { name: game.i18n.localize("bossbar.settings.backgroundPath.name"), hint: game.i18n.localize("bossbar.settings.backgroundPath.hint"), @@ -51,7 +60,10 @@ Hooks.on("updateScene", async (scene, updates) => { if (!game.user.isGM) { if (updates.flags?.bossbar) { const ids = canvas.scene.getFlag("bossbar", "bossBarActive"); - if (!ids) return; + if (!ids){ + if(canvas.scene._bossBars) delete canvas.scene._bossBars + return; + } for (let id of ids) { if (canvas.scene._bossBars && canvas.scene._bossBars[id]) { canvas.scene._bossBars[id].draw( @@ -91,16 +103,18 @@ Hooks.on("getSceneControlButtons", (controls, b, c) => { controls .find((c) => c.name == "token") .tools.push({ - name: "toggleCylinder", + name: "bossBar", title: game.i18n.localize("bossbar.controls.bossUI.name"), icon: "fas fa-pastafarianism", toggle: true, visible: game.user.isGM, active: isBoss, - onClick: (toggle) => { + onClick: async (toggle) => { if (toggle) { if (canvas.tokens.controlled[0]) { - BossBar.create(canvas.tokens.controlled[0]); + for(let token of canvas.tokens.controlled){ + await BossBar.create(token); + } } else { ui.notifications.warn( game.i18n.localize("bossbar.controls.bossUI.warn") diff --git a/styles/module.css b/styles/module.css index 5202360..16a9802 100644 --- a/styles/module.css +++ b/styles/module.css @@ -1,7 +1,8 @@ .bossBarName { text-align: left; - font-size: large; - background: rgba(0, 0, 0, 0.5); + font-size: 10px; + filter: drop-shadow(0 0 0.2rem black); + font-family:'Times New Roman', Times, serif; padding: 3px; border-radius: 3px; } @@ -13,7 +14,7 @@ .bossBarMax { position: absolute; - transition: width 2s; + transition: width 4s; } .bossBar {