diff --git a/MaterialDeck.js b/MaterialDeck.js
index 4b231b2..983f1e0 100644
--- a/MaterialDeck.js
+++ b/MaterialDeck.js
@@ -51,7 +51,7 @@ async function analyzeWSmessage(msg){
}
if (data == undefined || data.payload == undefined) return;
-
+ //console.log("Received",data);
const action = data.action;
const event = data.event;
const context = data.context;
@@ -70,6 +70,8 @@ async function analyzeWSmessage(msg){
tokenControl.active = true;
tokenControl.update(selectedTokenId);
}
+ else if (action == 'move')
+ move.update(settings,context);
else if (action == 'macro')
macroControl.update(settings,context);
else if (action == 'combattracker')
diff --git a/changelog.md b/changelog.md
index 61fe23e..dbfeba0 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,4 +1,24 @@
# Changelog Material Deck Module
+### v1.1.0 - 09-12-2020
+Fixes
+
+- Settings would not show for Combat Tracker action
+- Macro Action => Macro Board default settings fixed
+
+Additions/changes:
+
+- Added support for Pathfinder 1e and Shadow of the Demon Lord
+- All dialogs that are openable using the SD can now be closed by pressing the button while the dialog is open
+- Playlist Action & Soundboard Action => Stop All now indicates if there are tracks/playlists/sounds playing
+- Confirmed Foundry 0.7.8 compatibility
+- API has been improved, making integration with other hardware/software easier, and making future changes/additions easier
+- Moved default images to Foundry module side instead of Stream Deck plugin
+
+
+Compatible server app and SD plugin:
+Material Server v1.0.2 (unchanged): https://github.com/CDeenen/MaterialServer/releases
+SD plugin v1.1.0: https://github.com/CDeenen/MaterialDeck_SD/releases
+
### V1.0.1 - 26-11-2020
- Fixed issue where macro from macroboard wouldn't execute if furnace arguments were not defined
diff --git a/img/combattracker/.thumb/combattracker.png.jpg b/img/combattracker/.thumb/combattracker.png.jpg
new file mode 100644
index 0000000..bcf1382
Binary files /dev/null and b/img/combattracker/.thumb/combattracker.png.jpg differ
diff --git a/img/combattracker/.thumb/combattracker@2x.png.jpg b/img/combattracker/.thumb/combattracker@2x.png.jpg
new file mode 100644
index 0000000..ee5de79
Binary files /dev/null and b/img/combattracker/.thumb/combattracker@2x.png.jpg differ
diff --git a/img/combattracker/.thumb/nextround.png.jpg b/img/combattracker/.thumb/nextround.png.jpg
new file mode 100644
index 0000000..51df22e
Binary files /dev/null and b/img/combattracker/.thumb/nextround.png.jpg differ
diff --git a/img/combattracker/.thumb/nextturn.png.jpg b/img/combattracker/.thumb/nextturn.png.jpg
new file mode 100644
index 0000000..b96d84a
Binary files /dev/null and b/img/combattracker/.thumb/nextturn.png.jpg differ
diff --git a/img/combattracker/.thumb/previousround.png.jpg b/img/combattracker/.thumb/previousround.png.jpg
new file mode 100644
index 0000000..93d9480
Binary files /dev/null and b/img/combattracker/.thumb/previousround.png.jpg differ
diff --git a/img/combattracker/.thumb/previousturn.png.jpg b/img/combattracker/.thumb/previousturn.png.jpg
new file mode 100644
index 0000000..bc8c406
Binary files /dev/null and b/img/combattracker/.thumb/previousturn.png.jpg differ
diff --git a/img/combattracker/.thumb/startcombat.png.jpg b/img/combattracker/.thumb/startcombat.png.jpg
new file mode 100644
index 0000000..4b6f4c5
Binary files /dev/null and b/img/combattracker/.thumb/startcombat.png.jpg differ
diff --git a/img/combattracker/.thumb/stopcombat.png.jpg b/img/combattracker/.thumb/stopcombat.png.jpg
new file mode 100644
index 0000000..a8226fb
Binary files /dev/null and b/img/combattracker/.thumb/stopcombat.png.jpg differ
diff --git a/img/combattracker/SOURCES.txt b/img/combattracker/SOURCES.txt
new file mode 100644
index 0000000..c64488e
--- /dev/null
+++ b/img/combattracker/SOURCES.txt
@@ -0,0 +1,5 @@
+combattracker.png: Edited from https://fontawesome.com/icons/fist-raised?style=solid
+nextturn.png, previousturn.png: Edited from https://fontawesome.com/icons/arrow-right?style=solid
+nextround.png, previousround.png: Edited from https://fontawesome.com/icons/step-forward?style=solid
+startcombat.png: Edited from https://fontawesome.com/icons/play?style=solid
+stopcombat.png: Edited from https://fontawesome.com/icons/stop?style=solid
\ No newline at end of file
diff --git a/img/combattracker/combattracker.png b/img/combattracker/combattracker.png
new file mode 100644
index 0000000..7802025
Binary files /dev/null and b/img/combattracker/combattracker.png differ
diff --git a/img/combattracker/combattracker@2x.png b/img/combattracker/combattracker@2x.png
new file mode 100644
index 0000000..5cb3453
Binary files /dev/null and b/img/combattracker/combattracker@2x.png differ
diff --git a/img/combattracker/nextround.png b/img/combattracker/nextround.png
new file mode 100644
index 0000000..5444547
Binary files /dev/null and b/img/combattracker/nextround.png differ
diff --git a/img/combattracker/nextturn.png b/img/combattracker/nextturn.png
new file mode 100644
index 0000000..66912ad
Binary files /dev/null and b/img/combattracker/nextturn.png differ
diff --git a/img/combattracker/previousround.png b/img/combattracker/previousround.png
new file mode 100644
index 0000000..98901db
Binary files /dev/null and b/img/combattracker/previousround.png differ
diff --git a/img/combattracker/previousturn.png b/img/combattracker/previousturn.png
new file mode 100644
index 0000000..71835d4
Binary files /dev/null and b/img/combattracker/previousturn.png differ
diff --git a/img/combattracker/startcombat.png b/img/combattracker/startcombat.png
new file mode 100644
index 0000000..6ab73f3
Binary files /dev/null and b/img/combattracker/startcombat.png differ
diff --git a/img/combattracker/stopcombat.png b/img/combattracker/stopcombat.png
new file mode 100644
index 0000000..6fcad52
Binary files /dev/null and b/img/combattracker/stopcombat.png differ
diff --git a/img/macro/.thumb/macro.png.jpg b/img/macro/.thumb/macro.png.jpg
new file mode 100644
index 0000000..7180f57
Binary files /dev/null and b/img/macro/.thumb/macro.png.jpg differ
diff --git a/img/macro/.thumb/macro@2x.png.jpg b/img/macro/.thumb/macro@2x.png.jpg
new file mode 100644
index 0000000..12ff474
Binary files /dev/null and b/img/macro/.thumb/macro@2x.png.jpg differ
diff --git a/img/macro/SOURCES.txt b/img/macro/SOURCES.txt
new file mode 100644
index 0000000..571a666
--- /dev/null
+++ b/img/macro/SOURCES.txt
@@ -0,0 +1 @@
+macro.png: Foundry's icon folder, converted from .svg, original name: dice-target.svg
\ No newline at end of file
diff --git a/img/macro/macro.png b/img/macro/macro.png
new file mode 100644
index 0000000..eeaa697
Binary files /dev/null and b/img/macro/macro.png differ
diff --git a/img/macro/macro@2x.png b/img/macro/macro@2x.png
new file mode 100644
index 0000000..46adddf
Binary files /dev/null and b/img/macro/macro@2x.png differ
diff --git a/img/move/.thumb/center.png.jpg b/img/move/.thumb/center.png.jpg
new file mode 100644
index 0000000..e37f1c2
Binary files /dev/null and b/img/move/.thumb/center.png.jpg differ
diff --git a/img/move/.thumb/center@2x.png.jpg b/img/move/.thumb/center@2x.png.jpg
new file mode 100644
index 0000000..e37f1c2
Binary files /dev/null and b/img/move/.thumb/center@2x.png.jpg differ
diff --git a/img/move/.thumb/down.png.jpg b/img/move/.thumb/down.png.jpg
new file mode 100644
index 0000000..269fa21
Binary files /dev/null and b/img/move/.thumb/down.png.jpg differ
diff --git a/img/move/.thumb/downleft.png.jpg b/img/move/.thumb/downleft.png.jpg
new file mode 100644
index 0000000..628ac7f
Binary files /dev/null and b/img/move/.thumb/downleft.png.jpg differ
diff --git a/img/move/.thumb/downright.png.jpg b/img/move/.thumb/downright.png.jpg
new file mode 100644
index 0000000..e8b58f9
Binary files /dev/null and b/img/move/.thumb/downright.png.jpg differ
diff --git a/img/move/.thumb/left.png.jpg b/img/move/.thumb/left.png.jpg
new file mode 100644
index 0000000..3f98e5c
Binary files /dev/null and b/img/move/.thumb/left.png.jpg differ
diff --git a/img/move/.thumb/right.png.jpg b/img/move/.thumb/right.png.jpg
new file mode 100644
index 0000000..f1671a1
Binary files /dev/null and b/img/move/.thumb/right.png.jpg differ
diff --git a/img/move/.thumb/up.png.jpg b/img/move/.thumb/up.png.jpg
new file mode 100644
index 0000000..0009307
Binary files /dev/null and b/img/move/.thumb/up.png.jpg differ
diff --git a/img/move/.thumb/upleft.png.jpg b/img/move/.thumb/upleft.png.jpg
new file mode 100644
index 0000000..716b2d1
Binary files /dev/null and b/img/move/.thumb/upleft.png.jpg differ
diff --git a/img/move/.thumb/upright.png.jpg b/img/move/.thumb/upright.png.jpg
new file mode 100644
index 0000000..be8d7ab
Binary files /dev/null and b/img/move/.thumb/upright.png.jpg differ
diff --git a/img/move/.thumb/zoomin.png.jpg b/img/move/.thumb/zoomin.png.jpg
new file mode 100644
index 0000000..73c0b22
Binary files /dev/null and b/img/move/.thumb/zoomin.png.jpg differ
diff --git a/img/move/.thumb/zoomout.png.jpg b/img/move/.thumb/zoomout.png.jpg
new file mode 100644
index 0000000..603b24f
Binary files /dev/null and b/img/move/.thumb/zoomout.png.jpg differ
diff --git a/img/move/SOURCES.txt b/img/move/SOURCES.txt
new file mode 100644
index 0000000..b14fa8d
--- /dev/null
+++ b/img/move/SOURCES.txt
@@ -0,0 +1,2 @@
+center.png: made by me
+All other images taken from freepngimg.com, iverted color and rotated. Source: https://freepngimg.com/png/24691-right-arrow-hd
\ No newline at end of file
diff --git a/img/move/center.png b/img/move/center.png
new file mode 100644
index 0000000..c4208a8
Binary files /dev/null and b/img/move/center.png differ
diff --git a/img/move/center@2x.png b/img/move/center@2x.png
new file mode 100644
index 0000000..c4208a8
Binary files /dev/null and b/img/move/center@2x.png differ
diff --git a/img/move/down.png b/img/move/down.png
new file mode 100644
index 0000000..6ba4c12
Binary files /dev/null and b/img/move/down.png differ
diff --git a/img/move/downleft.png b/img/move/downleft.png
new file mode 100644
index 0000000..ab0b8e5
Binary files /dev/null and b/img/move/downleft.png differ
diff --git a/img/move/downright.png b/img/move/downright.png
new file mode 100644
index 0000000..462e7f2
Binary files /dev/null and b/img/move/downright.png differ
diff --git a/img/move/left.png b/img/move/left.png
new file mode 100644
index 0000000..0892adb
Binary files /dev/null and b/img/move/left.png differ
diff --git a/img/move/right.png b/img/move/right.png
new file mode 100644
index 0000000..da41a31
Binary files /dev/null and b/img/move/right.png differ
diff --git a/img/move/up.png b/img/move/up.png
new file mode 100644
index 0000000..87d1100
Binary files /dev/null and b/img/move/up.png differ
diff --git a/img/move/upleft.png b/img/move/upleft.png
new file mode 100644
index 0000000..c445180
Binary files /dev/null and b/img/move/upleft.png differ
diff --git a/img/move/upright.png b/img/move/upright.png
new file mode 100644
index 0000000..6645f60
Binary files /dev/null and b/img/move/upright.png differ
diff --git a/img/move/zoomin.png b/img/move/zoomin.png
new file mode 100644
index 0000000..ac3c8f0
Binary files /dev/null and b/img/move/zoomin.png differ
diff --git a/img/move/zoomout.png b/img/move/zoomout.png
new file mode 100644
index 0000000..f1f808a
Binary files /dev/null and b/img/move/zoomout.png differ
diff --git a/img/other/.thumb/other.png.jpg b/img/other/.thumb/other.png.jpg
new file mode 100644
index 0000000..ef6e494
Binary files /dev/null and b/img/other/.thumb/other.png.jpg differ
diff --git a/img/other/.thumb/other@2x.png.jpg b/img/other/.thumb/other@2x.png.jpg
new file mode 100644
index 0000000..ef6e494
Binary files /dev/null and b/img/other/.thumb/other@2x.png.jpg differ
diff --git a/img/other/SOURCES.txt b/img/other/SOURCES.txt
new file mode 100644
index 0000000..cd1781a
--- /dev/null
+++ b/img/other/SOURCES.txt
@@ -0,0 +1 @@
+other.png: Made using https://www.elgato.com/en/gaming/keycreator
\ No newline at end of file
diff --git a/img/other/darkness/.thumb/darkness.png.jpg b/img/other/darkness/.thumb/darkness.png.jpg
new file mode 100644
index 0000000..d46a86e
Binary files /dev/null and b/img/other/darkness/.thumb/darkness.png.jpg differ
diff --git a/img/other/darkness/.thumb/decreasedarkness.png.jpg b/img/other/darkness/.thumb/decreasedarkness.png.jpg
new file mode 100644
index 0000000..ec6c1e2
Binary files /dev/null and b/img/other/darkness/.thumb/decreasedarkness.png.jpg differ
diff --git a/img/other/darkness/.thumb/increasedarkness.png.jpg b/img/other/darkness/.thumb/increasedarkness.png.jpg
new file mode 100644
index 0000000..9fda9a2
Binary files /dev/null and b/img/other/darkness/.thumb/increasedarkness.png.jpg differ
diff --git a/img/other/darkness/SOURCES.txt b/img/other/darkness/SOURCES.txt
new file mode 100644
index 0000000..3484967
--- /dev/null
+++ b/img/other/darkness/SOURCES.txt
@@ -0,0 +1,2 @@
+decreasedarkness.png: Made using https://www.elgato.com/en/gaming/keycreator
+increasedarkness.png: Made using https://www.elgato.com/en/gaming/keycreator
\ No newline at end of file
diff --git a/img/other/darkness/darkness.png b/img/other/darkness/darkness.png
new file mode 100644
index 0000000..61b8fd2
Binary files /dev/null and b/img/other/darkness/darkness.png differ
diff --git a/img/other/darkness/decreasedarkness.png b/img/other/darkness/decreasedarkness.png
new file mode 100644
index 0000000..fcbabb0
Binary files /dev/null and b/img/other/darkness/decreasedarkness.png differ
diff --git a/img/other/darkness/increasedarkness.png b/img/other/darkness/increasedarkness.png
new file mode 100644
index 0000000..67b4502
Binary files /dev/null and b/img/other/darkness/increasedarkness.png differ
diff --git a/img/other/other.png b/img/other/other.png
new file mode 100644
index 0000000..bd19ba1
Binary files /dev/null and b/img/other/other.png differ
diff --git a/img/other/other@2x.png b/img/other/other@2x.png
new file mode 100644
index 0000000..bd19ba1
Binary files /dev/null and b/img/other/other@2x.png differ
diff --git a/img/other/pause/.thumb/pause.png.jpg b/img/other/pause/.thumb/pause.png.jpg
new file mode 100644
index 0000000..7a2ada6
Binary files /dev/null and b/img/other/pause/.thumb/pause.png.jpg differ
diff --git a/img/other/pause/.thumb/playpause.png.jpg b/img/other/pause/.thumb/playpause.png.jpg
new file mode 100644
index 0000000..d12d1f1
Binary files /dev/null and b/img/other/pause/.thumb/playpause.png.jpg differ
diff --git a/img/other/pause/.thumb/resume.png.jpg b/img/other/pause/.thumb/resume.png.jpg
new file mode 100644
index 0000000..4b6f4c5
Binary files /dev/null and b/img/other/pause/.thumb/resume.png.jpg differ
diff --git a/img/other/pause/SOURCES.txt b/img/other/pause/SOURCES.txt
new file mode 100644
index 0000000..f969b01
--- /dev/null
+++ b/img/other/pause/SOURCES.txt
@@ -0,0 +1,3 @@
+resume.png: Edited from https://fontawesome.com/icons/play?style=solid
+pause.png: Edited from https://fontawesome.com/icons/pause?style=solid
+playpause.png: Combined resume.png and pause.png
\ No newline at end of file
diff --git a/img/other/pause/pause.png b/img/other/pause/pause.png
new file mode 100644
index 0000000..9e1c7ff
Binary files /dev/null and b/img/other/pause/pause.png differ
diff --git a/img/other/pause/playpause.png b/img/other/pause/playpause.png
new file mode 100644
index 0000000..6c12522
Binary files /dev/null and b/img/other/pause/playpause.png differ
diff --git a/img/other/pause/resume.png b/img/other/pause/resume.png
new file mode 100644
index 0000000..6ab73f3
Binary files /dev/null and b/img/other/pause/resume.png differ
diff --git a/img/playlist/.thumb/play.png.jpg b/img/playlist/.thumb/play.png.jpg
new file mode 100644
index 0000000..4b6f4c5
Binary files /dev/null and b/img/playlist/.thumb/play.png.jpg differ
diff --git a/img/playlist/.thumb/play@2x.png.jpg b/img/playlist/.thumb/play@2x.png.jpg
new file mode 100644
index 0000000..4b6f4c5
Binary files /dev/null and b/img/playlist/.thumb/play@2x.png.jpg differ
diff --git a/img/playlist/.thumb/play_redBrightness.png.jpg b/img/playlist/.thumb/play_redBrightness.png.jpg
new file mode 100644
index 0000000..7e89310
Binary files /dev/null and b/img/playlist/.thumb/play_redBrightness.png.jpg differ
diff --git a/img/playlist/.thumb/stop.png.jpg b/img/playlist/.thumb/stop.png.jpg
new file mode 100644
index 0000000..a8226fb
Binary files /dev/null and b/img/playlist/.thumb/stop.png.jpg differ
diff --git a/img/playlist/SOURCES.txt b/img/playlist/SOURCES.txt
new file mode 100644
index 0000000..51f6fc6
--- /dev/null
+++ b/img/playlist/SOURCES.txt
@@ -0,0 +1,2 @@
+play.png: Edited from https://fontawesome.com/icons/play?style=solid
+stop.png: Edited from https://fontawesome.com/icons/stop?style=solid
\ No newline at end of file
diff --git a/img/playlist/play.png b/img/playlist/play.png
new file mode 100644
index 0000000..6ab73f3
Binary files /dev/null and b/img/playlist/play.png differ
diff --git a/img/playlist/play@2x.png b/img/playlist/play@2x.png
new file mode 100644
index 0000000..6ab73f3
Binary files /dev/null and b/img/playlist/play@2x.png differ
diff --git a/img/playlist/play_redBrightness.png b/img/playlist/play_redBrightness.png
new file mode 100644
index 0000000..ebd8bbc
Binary files /dev/null and b/img/playlist/play_redBrightness.png differ
diff --git a/img/playlist/stop.png b/img/playlist/stop.png
new file mode 100644
index 0000000..6fcad52
Binary files /dev/null and b/img/playlist/stop.png differ
diff --git a/img/soundboard/.thumb/soundboard.png.jpg b/img/soundboard/.thumb/soundboard.png.jpg
new file mode 100644
index 0000000..d62b135
Binary files /dev/null and b/img/soundboard/.thumb/soundboard.png.jpg differ
diff --git a/img/soundboard/.thumb/soundboard@2x.png.jpg b/img/soundboard/.thumb/soundboard@2x.png.jpg
new file mode 100644
index 0000000..4ea838a
Binary files /dev/null and b/img/soundboard/.thumb/soundboard@2x.png.jpg differ
diff --git a/img/soundboard/.thumb/stop.png.jpg b/img/soundboard/.thumb/stop.png.jpg
new file mode 100644
index 0000000..a8226fb
Binary files /dev/null and b/img/soundboard/.thumb/stop.png.jpg differ
diff --git a/img/soundboard/SOURCES.txt b/img/soundboard/SOURCES.txt
new file mode 100644
index 0000000..26fb58b
--- /dev/null
+++ b/img/soundboard/SOURCES.txt
@@ -0,0 +1,2 @@
+soundboard.png: Edited from https://fontawesome.com/icons/music?style=solid
+play.png: Edited from https://fontawesome.com/icons/play?style=solid
\ No newline at end of file
diff --git a/img/soundboard/soundboard.png b/img/soundboard/soundboard.png
new file mode 100644
index 0000000..a4b68a5
Binary files /dev/null and b/img/soundboard/soundboard.png differ
diff --git a/img/soundboard/soundboard@2x.png b/img/soundboard/soundboard@2x.png
new file mode 100644
index 0000000..08f50fe
Binary files /dev/null and b/img/soundboard/soundboard@2x.png differ
diff --git a/img/soundboard/stop.png b/img/soundboard/stop.png
new file mode 100644
index 0000000..6fcad52
Binary files /dev/null and b/img/soundboard/stop.png differ
diff --git a/img/token/.thumb/hp.png.jpg b/img/token/.thumb/hp.png.jpg
new file mode 100644
index 0000000..b6c3bee
Binary files /dev/null and b/img/token/.thumb/hp.png.jpg differ
diff --git a/img/token/.thumb/init.png.jpg b/img/token/.thumb/init.png.jpg
new file mode 100644
index 0000000..cecf4c8
Binary files /dev/null and b/img/token/.thumb/init.png.jpg differ
diff --git a/img/token/.thumb/mystery-man.png.jpg b/img/token/.thumb/mystery-man.png.jpg
new file mode 100644
index 0000000..63109e1
Binary files /dev/null and b/img/token/.thumb/mystery-man.png.jpg differ
diff --git a/img/token/.thumb/mystery-man@2x.png.jpg b/img/token/.thumb/mystery-man@2x.png.jpg
new file mode 100644
index 0000000..80563ad
Binary files /dev/null and b/img/token/.thumb/mystery-man@2x.png.jpg differ
diff --git a/img/token/SOURCES.txt b/img/token/SOURCES.txt
new file mode 100644
index 0000000..2a7ae56
--- /dev/null
+++ b/img/token/SOURCES.txt
@@ -0,0 +1,5 @@
+ac.webp: Foundry's icon folder, original name: heater-steel-worn.webp
+hp.png: made using Elgato's key creator: https://www.elgato.com/en/gaming/keycreator
+init.png: freepngimg.com, color inverted, from: https://freepngimg.com/png/81025-art-dice-dungeons-system-dragons-d20-triangle/icon
+speed.webp: Foundry's icon folder, original name: shoes-collared-leather-blue.webp
+mystery-man.png: Foundry's icon folder, converted from .svg
\ No newline at end of file
diff --git a/img/token/ac.webp b/img/token/ac.webp
new file mode 100644
index 0000000..42d71d3
Binary files /dev/null and b/img/token/ac.webp differ
diff --git a/img/token/hp.png b/img/token/hp.png
new file mode 100644
index 0000000..be633b6
Binary files /dev/null and b/img/token/hp.png differ
diff --git a/img/token/init.png b/img/token/init.png
new file mode 100644
index 0000000..bbfd9c7
Binary files /dev/null and b/img/token/init.png differ
diff --git a/img/token/mystery-man.png b/img/token/mystery-man.png
new file mode 100644
index 0000000..a9c357b
Binary files /dev/null and b/img/token/mystery-man.png differ
diff --git a/img/token/mystery-man@2x.png b/img/token/mystery-man@2x.png
new file mode 100644
index 0000000..088e9c0
Binary files /dev/null and b/img/token/mystery-man@2x.png differ
diff --git a/img/token/speed.webp b/img/token/speed.webp
new file mode 100644
index 0000000..facbf48
Binary files /dev/null and b/img/token/speed.webp differ
diff --git a/module.json b/module.json
index c151fdc..a6beab0 100644
--- a/module.json
+++ b/module.json
@@ -2,14 +2,14 @@
"name": "MaterialDeck",
"title": "Material Deck",
"description": "Material Deck allows you to control Foundry using an Elgato Stream Deck",
- "version": "1.0.1",
+ "version": "1.1.0",
"author": "CDeenen",
"esmodules": [
"./MaterialDeck.js"
],
"socket": true,
"minimumCoreVersion": "0.7.5",
- "compatibleCoreVersion": "0.7.7",
+ "compatibleCoreVersion": "0.7.8",
"languages": [
{
"lang": "en",
diff --git a/src/combattracker.js b/src/combattracker.js
index 56d8c38..37951fe 100644
--- a/src/combattracker.js
+++ b/src/combattracker.js
@@ -19,17 +19,17 @@ export class CombatTracker{
update(settings,context){
this.active = true;
let ctFunction = settings.combatTrackerFunction;
- if (ctFunction == undefined) ctFunction == 0;
+ if (ctFunction == undefined) ctFunction == 'startStop';
let combat = game.combat;
- let src = "action/images/black.png";
+ let src = "modules/MaterialDeck/img/black.png";
let txt = "";
let background = "#000000";
let mode = settings.combatTrackerMode;
- if (mode == undefined) mode = 0;
+ if (mode == undefined) mode = 'combatants';
- if (mode == 0){
+ if (mode == 'combatants'){
if (combat != null && combat != undefined && combat.turns.length != 0){
let initiativeOrder = combat.turns;
let nr = settings.combatantNr - 1;
@@ -44,57 +44,57 @@ export class CombatTracker{
return;
}
else {
- streamDeck.setIcon(0,context,src,background);
+ streamDeck.setIcon(context,src,background);
streamDeck.setTitle(txt,context);
}
}
else {
- streamDeck.setIcon(0,context,src,background);
+ streamDeck.setIcon(context,src,background);
streamDeck.setTitle(txt,context);
}
}
- else if (mode == 1){
+ else if (mode == 'currentCombatant'){
if (combat != null && combat != undefined && combat.started){
let tokenId = combat.combatant.tokenId;
tokenControl.pushData(tokenId,settings,context);
}
else {
- streamDeck.setIcon(0,context,src,background);
+ streamDeck.setIcon(context,src,background);
streamDeck.setTitle(txt,context);
}
}
- else if (mode == 2){
+ else if (mode == 'function'){
- if (ctFunction == 0) {
+ if (ctFunction == 'startStop') {
if (combat == null || combat == undefined || combat.combatants.length == 0) {
- src = "action/images/combattracker/startcombat.png";
+ src = "modules/MaterialDeck/img/combattracker/startcombat.png";
background = "#000000";
}
else {
if (combat.started == false) {
- src = "action/images/combattracker/startcombat.png";
+ src = "modules/MaterialDeck/img/combattracker/startcombat.png";
background = "#008000";
}
else {
- src = "action/images/combattracker/stopcombat.png";
+ src = "modules/MaterialDeck/img/combattracker/stopcombat.png";
background = "#FF0000";
}
}
}
- else if (ctFunction == 1) {
- src = "action/images/combattracker/nextturn.png";
+ else if (ctFunction == 'nextTurn') {
+ src = "modules/MaterialDeck/img/combattracker/nextturn.png";
}
- else if (ctFunction == 2) {
- src = "action/images/combattracker/previousturn.png";
+ else if (ctFunction == 'prevTurn') {
+ src = "modules/MaterialDeck/img/combattracker/previousturn.png";
}
- else if (ctFunction == 3) {
- src = "action/images/combattracker/nextround.png";
+ else if (ctFunction == 'nextRound') {
+ src = "modules/MaterialDeck/img/combattracker/nextround.png";
}
- else if (ctFunction == 4) {
- src = "action/images/combattracker/previousround.png";
+ else if (ctFunction == 'prevRound') {
+ src = "modules/MaterialDeck/img/combattracker/previousround.png";
}
- else if (ctFunction == 5){
- src = "action/images/black.png";
+ else if (ctFunction == 'turnDisplay'){
+ src = "modules/MaterialDeck/img/black.png";
let round = 0;
let turn = 0;
if (combat != null && combat != undefined && combat.started != false){
@@ -105,21 +105,50 @@ export class CombatTracker{
if (txt != "") txt += "\n";
if (settings.displayTurn) txt += "Turn\n"+turn;
}
- streamDeck.setIcon(0,context,src,background);
+ streamDeck.setIcon(context,src,background);
streamDeck.setTitle(txt,context);
}
}
keyPress(settings,context){
- let mode = parseInt(settings.combatTrackerMode);
- if (isNaN(mode)) mode = 0;
+ let mode = settings.combatTrackerMode;
+ if (mode == undefined) mode = 'combatants';
- if (mode < 2) {
+ if (mode == 'function'){
+ let combat = game.combat;
+ if (combat == null || combat == undefined) return;
+
+ let ctFunction = settings.combatTrackerFunction;
+ if (ctFunction == undefined) ctFunction == 'startStop';
+ if (ctFunction == 'startStop'){
+ let src;
+ let background;
+ if (game.combat.started){
+ game.combat.endCombat();
+ src = "modules/MaterialDeck/img/combattracker/startcombat.png";
+ background = "#000000";
+ }
+ else {
+ game.combat.startCombat();
+ src = "modules/MaterialDeck/img/combattracker/stopcombat.png";
+ background = "#FF0000";
+ }
+ streamDeck.setIcon(context,src,background);
+ return;
+ }
+ if (game.combat.started == false) return;
+
+ if (ctFunction == 'nextTurn') game.combat.nextTurn();
+ else if (ctFunction == 'prevTurn') game.combat.previousTurn();
+ else if (ctFunction == 'nextRound') game.combat.nextRound();
+ else if (ctFunction == 'prevRound') game.combat.previousRound();
+ }
+ else {
let onClick = settings.onClick;
- if (onClick == undefined) onClick = 0;
+ if (onClick == undefined) onClick = 'doNothing';
let tokenId;
let combat = game.combat;
- if (mode == 0) {
+ if (mode == 'combatants') {
if (combat != null && combat != undefined && combat.turns.length != 0){
let initiativeOrder = combat.turns;
let nr = settings.combatantNr - 1;
@@ -132,63 +161,38 @@ export class CombatTracker{
tokenId = combatant.tokenId;
}
}
- else if (mode == 1)
+ else if (mode == 'currentCombatant')
if (combat != null && combat != undefined && combat.started)
tokenId = combat.combatant.tokenId;
let token
if (canvas.tokens.children[0] != undefined) token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
if (token == undefined) return;
- if (onClick == 0) //Do nothing
+ if (onClick == 'doNothing') //Do nothing
return;
- else if (onClick == 1){ //select token
+ else if (onClick == 'select'){ //select token
token.control();
}
- else if (onClick == 2){ //center on token
+ else if (onClick == 'center'){ //center on token
let location = token.getCenter(token.x,token.y);
canvas.animatePan(location);
}
- else if (onClick == 3){ //center on token and select
+ else if (onClick == 'centerSelect'){ //center on token and select
let location = token.getCenter(token.x,token.y);
canvas.animatePan(location);
token.control();
}
- else if (onClick == 4){ //Open character sheet
- token.actor.sheet.render(true);
+ else if (onClick == 'charSheet'){ //Open character sheet
+ const element = document.getElementById(token.actor.sheet.id);
+ if (element == null) token.actor.sheet.render(true);
+ else token.actor.sheet.close();
}
- else { //Open token config
- token.sheet._render(true);
+ else if (onClick == 'tokenConfig'){ //Open token config
+ const element = document.getElementById(token.sheet.id);
+ if (element == null) token.sheet.render(true);
+ else token.sheet.close();
}
}
- else if (mode == 2){
- let combat = game.combat;
- if (combat == null || combat == undefined) return;
-
- let ctFunction = settings.combatTrackerFunction;
- if (ctFunction == undefined) ctFunction == 0;
-
- if (ctFunction == 0){
- let src;
- let background;
- if (game.combat.started){
- game.combat.endCombat();
- src = "action/images/combattracker/startcombat.png";
- background = "#000000";
- }
- else {
- game.combat.startCombat();
- src = "action/images/combattracker/stopcombat.png";
- background = "#FF0000";
- }
- streamDeck.setIcon(context,src,background);
- return;
- }
- if (game.combat.started == false) return;
-
- if (ctFunction == 1) game.combat.nextTurn();
- else if (ctFunction == 2) game.combat.previousTurn();
- else if (ctFunction == 3) game.combat.nextRound();
- else if (ctFunction == 4) game.combat.previousRound();
- }
+
}
}
\ No newline at end of file
diff --git a/src/macro.js b/src/macro.js
index cb83348..87a8f06 100644
--- a/src/macro.js
+++ b/src/macro.js
@@ -29,16 +29,57 @@ export class MacroControl{
if(macroNumber == undefined || isNaN(parseInt(macroNumber))){
macroNumber = 0;
}
- if (mode == undefined) mode = 0;
+ if (mode == undefined) mode = 'hotbar';
if (displayName == undefined) displayName = false;
if (background == undefined) background = '#000000';
macroNumber = parseInt(macroNumber);
+
+ if (mode == 'macroBoard') { //Macro board
+ let name = "";
+ let src = '';
+ if (settings.macroBoardMode == 'offset') { //Offset
+ let ringOffColor = settings.offRing;
+ if (ringOffColor == undefined) ringOffColor = '#000000';
- //Macro Hotbar
- if (mode < 2){
+ let ringOnColor = settings.onRing;
+ if (ringOnColor == undefined) ringOnColor = '#00FF00';
+
+ let macroOffset = parseInt(settings.macroOffset);
+ if (macroOffset == undefined || isNaN(macroOffset)) macroOffset = 0;
+
+ if (macroOffset == parseInt(this.offset)) ringColor = ringOnColor;
+ else ringColor = ringOffColor;
+
+ ring = 2;
+ //streamDeck.setIcon(context, "", background,ring,ringColor);
+ }
+ else { //Execute macro
+ macroNumber += this.offset - 1;
+ if (macroNumber < 0) macroNumber = 0;
+ var macroId = game.settings.get(MODULE.moduleName,'macroSettings').macros[macroNumber];
+ background = game.settings.get(MODULE.moduleName,'macroSettings').color[macroNumber];
+
+ if (background == undefined) background = '#000000';
+ src = "";
+ if (macroId != undefined){
+ let macro = game.macros._source.find(p => p._id == macroId);
+ if (macro != undefined) {
+ name += macro.name;
+ src += macro.img;
+ }
+ }
+ ring = 0;
+ }
+ if (icon) streamDeck.setIcon(context,src,background,ring,ringColor);
+ else streamDeck.setIcon(context, "", background,ring,ringColor);
+ if (displayName == 0) name = "";
+ streamDeck.setTitle(name,context);
+ }
+
+ else { //Macro Hotbar
let macroId
- if (mode == 0) macroId = game.user.data.hotbar[macroNumber];
+ if (mode == 'hotbar') macroId = game.user.data.hotbar[macroNumber];
else {
let macros = game.macros.apps[0].macros;
for (let j=0; j<10; j++){
@@ -58,56 +99,18 @@ export class MacroControl{
src += macro.img;
}
}
- if (icon) streamDeck.setIcon(1,context,src,background);
- else streamDeck.setIcon(0, context, "", background);
- if (displayName == 0) name = "";
- streamDeck.setTitle(name,context);
- }
- else { //Macro board
- let name = "";
- let src = '';
- if (settings.macroBoardMode == 0) { //Execute macro
- macroNumber += this.offset - 1;
- if (macroNumber < 0) macroNumber = 0;
- var macroId = game.settings.get(MODULE.moduleName,'macroSettings').macros[macroNumber];
- background = game.settings.get(MODULE.moduleName,'macroSettings').color[macroNumber];
-
- if (background == undefined) background = '#000000';
- src = "";
- if (macroId != undefined){
- let macro = game.macros._source.find(p => p._id == macroId);
- if (macro != undefined) {
- name += macro.name;
- src += macro.img;
- }
- }
- }
- else { //Offset
- let ringOffColor = settings.offRing;
- if (ringOffColor == undefined) ringOffColor = '#000000';
-
- let ringOnColor = settings.onRing;
- if (ringOnColor == undefined) ringOnColor = '#00FF00';
-
- let macroOffset = parseInt(settings.macroOffset);
- if (macroOffset == undefined || isNaN(macroOffset)) macroOffset = 0;
-
- if (macroOffset == parseInt(this.offset)) ringColor = ringOnColor;
- else ringColor = ringOffColor;
-
- ring = 2;
- }
- if (icon) streamDeck.setIcon(1, context,src,background,ring,ringColor);
- else streamDeck.setIcon(0, context, "", background,ring,ringColor);
+ if (icon) streamDeck.setIcon(context,src,background);
+ else streamDeck.setIcon(context, "", background);
if (displayName == 0) name = "";
streamDeck.setTitle(name,context);
}
+
}
hotbar(macros){
for (let i=0; i<32; i++){
let data = streamDeck.buttonContext[i];
- if (data == undefined || data.action != 'macro') continue;
+ if (data == undefined || data.action != 'macro' || data.settings.macroMode == 'macroBoard') continue;
let context = data.context;
let mode = data.settings.macroMode;
let displayName = data.settings.displayName;
@@ -141,7 +144,7 @@ export class MacroControl{
name += macro.name;
src += macro.img;
}
- streamDeck.setIcon(1,context,src,background);
+ streamDeck.setIcon(context,src,background);
if (displayName == 0) name = "";
streamDeck.setTitle(name,context);
}
@@ -149,24 +152,24 @@ export class MacroControl{
keyPress(settings){
let mode = settings.macroMode;
- if (mode == undefined) mode = 0;
+ if (mode == undefined) mode = 'hotbar';
let macroNumber = settings.macroNumber;
if(macroNumber == undefined || isNaN(parseInt(macroNumber))){
macroNumber = 0;
}
- if (mode == 0 || mode == 1)
+ if (mode == 'hotbar' || mode == 'visibleHotbar')
this.executeHotbar(macroNumber,mode);
else {
- if (settings.macroBoardMode == 0)
- this.executeBoard(macroNumber);
- else {
+ if (settings.macroBoardMode == 'offset') {
let macroOffset = settings.macroOffset;
if (macroOffset == undefined) macroOffset = 0;
this.offset = macroOffset;
this.updateAll();
}
+ else
+ this.executeBoard(macroNumber);
}
}
@@ -200,7 +203,7 @@ export class MacroControl{
let furnaceEnabled = false;
let furnace = game.modules.get("furnace");
if (furnace != undefined && furnace.active) furnaceEnabled = true;
- if (args == undefined || args[number] == undefined || args[macroNumber] == "") furnaceEnabled = false;
+ if (args == undefined || args[macroNumber] == undefined || args[macroNumber] == "") furnaceEnabled = false;
if (furnaceEnabled == false) macro.execute();
else {
let chatData = {
diff --git a/src/move.js b/src/move.js
index 9cf49a4..dfbaa89 100644
--- a/src/move.js
+++ b/src/move.js
@@ -1,34 +1,66 @@
import * as MODULE from "../MaterialDeck.js";
+import {streamDeck} from "../MaterialDeck.js";
export class Move{
constructor(){
this.active = false;
}
+ update(settings,context){
+ let background;
+ if (settings.background) background = settings.background;
+ else background = '#000000';
+
+ let url = '';
+ if (settings.dir == 'center') //center
+ url = "modules/MaterialDeck/img/move/center.png";
+ else if (settings.dir == 'up') //up
+ url = "modules/MaterialDeck/img/move/up.png";
+ else if (settings.dir == 'down') //down
+ url = "modules/MaterialDeck/img/move/down.png";
+ else if (settings.dir == 'right') //right
+ url = "modules/MaterialDeck/img/move/right.png";
+ else if (settings.dir == 'left') //left
+ url = "modules/MaterialDeck/img/move/left.png";
+ else if (settings.dir == 'upRight')
+ url = "modules/MaterialDeck/img/move/upright.png";
+ else if (settings.dir == 'upLeft')
+ url = "modules/MaterialDeck/img/move/upleft.png";
+ else if (settings.dir == 'downRight')
+ url = "modules/MaterialDeck/img/move/downright.png";
+ else if (settings.dir == 'downLeft')
+ url = "modules/MaterialDeck/img/move/downleft.png";
+ else if (settings.dir == 'zoomIn')
+ url = "modules/MaterialDeck/img/move/zoomin.png";
+ else if (settings.dir == 'zoomOut')
+ url = "modules/MaterialDeck/img/move/zoomout.png";
+ streamDeck.setIcon(context,url,background);
+ }
keyPress(settings){
if (canvas.scene == null) return;
let dir = settings.dir;
let mode = settings.mode;
- if (mode == undefined) mode = 0;
- if (dir == undefined) dir = 0;
- if (dir < 9){
- if (settings.mode == '1')
- this.moveToken(MODULE.selectedTokenId,dir);
- else
- this.moveCanvas(dir);
- }
- else if (dir == 9) {//zoom in
+ if (mode == undefined) mode = 'canvas';
+ if (dir == undefined) dir = 'center';
+
+ if (dir == 'zoomIn') {//zoom in
let viewPosition = canvas.scene._viewPosition;
viewPosition.scale = viewPosition.scale*1.05;
viewPosition.duration = 100;
canvas.animatePan(viewPosition);
}
- else if (dir == 10) {//zoom out
+ else if (dir == 'zoomOut') {//zoom out
let viewPosition = canvas.scene._viewPosition;
viewPosition.scale = viewPosition.scale*0.95;
viewPosition.duration = 100;
canvas.animatePan(viewPosition);
}
+ else {
+ if (settings.mode == 'selectedToken')
+ this.moveToken(MODULE.selectedTokenId,dir);
+ else
+ this.moveCanvas(dir);
+ }
}
async moveToken(tokenId,dir){
@@ -38,27 +70,27 @@ export class Move{
let x = token.x;
let y = token.y;
- if (dir == '1') y -= gridSize;
- else if (dir == '2') y += gridSize;
- else if (dir == '3') x += gridSize;
- else if (dir == '4') x -= gridSize;
- else if (dir == '5') {
+ if (dir == 'up') y -= gridSize;
+ else if (dir == 'down') y += gridSize;
+ else if (dir == 'right') x += gridSize;
+ else if (dir == 'left') x -= gridSize;
+ else if (dir == 'upRight') {
x += gridSize;
y -= gridSize;
}
- else if (dir == '6') {
+ else if (dir == 'upLeft') {
x -= gridSize;
y -= gridSize;
}
- else if (dir == '7') {
+ else if (dir == 'downRight') {
x += gridSize;
y += gridSize;
}
- else if (dir == '8') {
+ else if (dir == 'downLeft') {
x -= gridSize;
y += gridSize;
}
- else if (dir == '0') {
+ else if (dir == 'center') {
let location = token.getCenter(x,y);
canvas.animatePan(location);
}
@@ -71,27 +103,27 @@ export class Move{
const gridSize = canvas.scene.data.grid;
viewPosition.duration = 100;
- if (dir == '1') viewPosition.y -= gridSize;
- else if (dir == '2') viewPosition.y += gridSize;
- else if (dir == '3') viewPosition.x += gridSize;
- else if (dir == '4') viewPosition.x -= gridSize;
- else if (dir == '5') {
+ if (dir == 'up') viewPosition.y -= gridSize;
+ else if (dir == 'down') viewPosition.y += gridSize;
+ else if (dir == 'right') viewPosition.x += gridSize;
+ else if (dir == 'left') viewPosition.x -= gridSize;
+ else if (dir == 'upRight') {
viewPosition.x += gridSize;
viewPosition.y -= gridSize;
}
- else if (dir == '6') {
+ else if (dir == 'upLeft') {
viewPosition.x -= gridSize;
viewPosition.y -= gridSize;
}
- else if (dir == '7') {
+ else if (dir == 'downRight') {
viewPosition.x += gridSize;
viewPosition.y += gridSize;
}
- else if (dir == '8') {
+ else if (dir == 'downLeft') {
viewPosition.x -= gridSize;
viewPosition.y += gridSize;
}
- else if (dir == '0') {
+ else if (dir == 'center') {
viewPosition.x = (canvas.dimensions.sceneWidth+window.innerWidth)/2;
viewPosition.y = (canvas.dimensions.sceneHeight+window.innerHeight)/2;
}
diff --git a/src/othercontrols.js b/src/othercontrols.js
index 76e9db8..a14c2ba 100644
--- a/src/othercontrols.js
+++ b/src/othercontrols.js
@@ -19,60 +19,60 @@ export class OtherControls{
update(settings,context){
this.active = true;
let mode = settings.otherMode;
- if (mode == undefined) mode = 0;
+ if (mode == undefined) mode = 'pause';
- if (mode == 0) { //pause
+ if (mode == 'pause') { //pause
this.updatePause(settings.pauseFunction,context);
}
- else if (mode == 1) { //scene selection
+ else if (mode == 'sceneSelect') { //scene selection
this.updateScene(settings,context);
}
- else if (mode == 2){ //control buttons
+ else if (mode == 'controlButtons'){ //control buttons
this.updateControl(settings,context);
}
- else if (mode == 3){ //darkness
+ else if (mode == 'darkness'){ //darkness
this.updateDarkness(settings,context);
}
- else if (mode == 4){ //roll tables
+ else if (mode == 'rollTables'){ //roll tables
this.updateRollTable(settings,context);
}
- else if (mode == 5) { //open sidebar tab
+ else if (mode == 'sidebarTab') { //open sidebar tab
this.updateSidebar(settings,context);
}
- else if (mode == 6) { //open compendium
+ else if (mode == 'compendium') { //open compendium
this.updateCompendium(settings,context);
}
- else if (mode == 7) { //open journal
+ else if (mode == 'journal') { //open journal
this.updateJournal(settings,context);
}
}
keyPress(settings){
let mode = settings.otherMode;
- if (mode == undefined) mode = 0;
+ if (mode == undefined) mode = 'pause';
- if (mode == 0) { //pause
+ if (mode == 'pause') { //pause
this.keyPressPause(settings.pauseFunction);
}
- else if (mode == 1) { //scene
+ else if (mode == 'sceneSelect') { //scene
this.keyPressScene(settings);
}
- else if (mode == 2) { //control buttons
+ else if (mode == 'controlButtons') { //control buttons
this.keyPressControl(settings);
}
- else if (mode == 3) { //darkness controll
+ else if (mode == 'darkness') { //darkness controll
this.keyPressDarkness(settings);
}
- else if (mode == 4) { //roll tables
+ else if (mode == 'rollTables') { //roll tables
this.keyPressRollTable(settings);
}
- else if (mode == 5) { //sidebar
+ else if (mode == 'sidebarTab') { //sidebar
this.keyPressSidebar(settings);
}
- else if (mode == 6) { //open compendium
+ else if (mode == 'compendium') { //open compendium
this.keyPressCompendium(settings);
}
- else if (mode == 7) { //open journal
+ else if (mode == 'journal') { //open journal
this.keyPressJournal(settings);
}
}
@@ -81,7 +81,7 @@ export class OtherControls{
updatePause(pauseFunction,context){
let src = "";
- if (pauseFunction == undefined) pauseFunction = 0;
+ if (pauseFunction == undefined) pauseFunction = 'pause';
let background = settings.background;
if(background == undefined) background = '#000000';
@@ -97,35 +97,38 @@ export class OtherControls{
let playlistType = settings.playlistType;
if (playlistType == undefined) playlistType = 0;
- if (pauseFunction == 0){ //Pause game
+ if (pauseFunction == 'pause'){ //Pause game
if (game.paused) ringColor = ringOnColor;
else ringColor = ringOffColor;
- src = 'action/images/other/pause/pause.png';
+ src = 'modules/MaterialDeck/img/other/pause/pause.png';
+ //src = 'action/images/other/pause/pause.png';
}
- else if (pauseFunction == 1){ //Resume game
+ else if (pauseFunction == 'resume'){ //Resume game
if (game.paused == false) ringColor = ringOnColor;
else ringColor = ringOffColor;
- src = 'action/images/other/pause/resume.png';
+ src = 'modules/MaterialDeck/img/other/pause/resume.png';
+ //src = 'action/images/other/pause/resume.png';
}
- else if (pauseFunction == 2) { //toggle
+ else if (pauseFunction == 'toggle') { //toggle
if (game.paused == false) ringColor = ringOnColor;
else ringColor = ringOffColor;
- src = 'action/images/other/pause/playpause.png';
+ src = 'modules/MaterialDeck/img/other/pause/playpause.png';
+ //src = 'action/images/other/pause/playpause.png';
}
- streamDeck.setIcon(0,context,src,background,2,ringColor);
+ streamDeck.setIcon(context,src,background,2,ringColor,true);
}
keyPressPause(pauseFunction){
- if (pauseFunction == undefined) pauseFunction = 0;
- if (pauseFunction == 0){ //Pause game
+ if (pauseFunction == undefined) pauseFunction = 'pause';
+ if (pauseFunction == 'pause'){ //Pause game
if (game.paused) return;
game.togglePause();
}
- else if (pauseFunction == 1){ //Resume game
+ else if (pauseFunction == 'resume'){ //Resume game
if (game.paused == false) return;
game.togglePause();
}
- else if (pauseFunction == 2) { //toggle
+ else if (pauseFunction == 'toggle') { //toggle
game.togglePause();
}
}
@@ -135,7 +138,7 @@ export class OtherControls{
updateScene(settings,context){
if (canvas.scene == null) return;
let func = settings.sceneFunction;
- if (func == undefined) func = 0;
+ if (func == undefined) func = 'visible';
let background = settings.background;
if(background == undefined) background = '#000000';
@@ -148,12 +151,9 @@ export class OtherControls{
let ringOnColor = settings.onRing;
if (ringOnColor == undefined) ringOnColor = '#00FF00';
- let playlistType = settings.playlistType;
- if (playlistType == undefined) playlistType = 0;
-
let src = "";
let name = "";
- if (func == 0){ //visible scenes
+ if (func == 'visible'){ //visible scenes
let nr = parseInt(settings.sceneNr);
if (isNaN(nr)) nr = 1;
nr--;
@@ -170,7 +170,7 @@ export class OtherControls{
if (scene.active) name += "\n(Active)";
}
}
- else if (func == 1) { //all scenes
+ else if (func == 'any') { //all scenes
let scene = game.scenes.apps[1].entities.find(p=>p.data.name == name);
if (scene != undefined){
if (scene.isView)
@@ -183,15 +183,15 @@ export class OtherControls{
}
}
streamDeck.setTitle(name,context);
- streamDeck.setIcon(1, context,src,background,2,ringColor);
+ streamDeck.setIcon(context,src,background,2,ringColor);
}
keyPressScene(settings){
let func = settings.sceneFunction;
- if (func == undefined) func = 0;
- if (func == 0){ //visible scenes
+ if (func == undefined) func = 'visible';
+ if (func == 'visible'){ //visible scenes
let viewFunc = settings.sceneViewFunction;
- if (viewFunc == undefined) viewFunc = 0;
+ if (viewFunc == undefined) viewFunc = 'view';
let nr = parseInt(settings.sceneNr);
if (isNaN(nr)) nr = 1;
@@ -199,10 +199,10 @@ export class OtherControls{
let scene = game.scenes.apps[0].scenes[nr];
if (scene != undefined){
- if (viewFunc == 0){
+ if (viewFunc == 'view'){
scene.view();
}
- else if (viewFunc == 1){
+ else if (viewFunc == 'activate'){
scene.activate();
}
else {
@@ -217,32 +217,29 @@ export class OtherControls{
updateControl(settings,context){
let control = settings.control;
- if (control == undefined) control = 0;
+ if (control == undefined) control = 'dispControls';
let tool = settings.tool;
- if (tool == undefined) tool = 0;
+ if (tool == undefined) tool = 'open';
let background = settings.background;
if (background == undefined) background = '#000000';
let ringColor = '#000000'
- const controlName = this.getControlName(control);
- const toolName = this.getToolName(control,tool);
-
let txt = "";
let src = "";
const activeControl = ui.controls.activeControl;
const activeTool = ui.controls.activeTool;
- if (control == 0) { //displayed controls
+ if (control == 'dispControls') { //displayed controls
let controlNr = parseInt(settings.controlNr);
if (isNaN(controlNr)) controlNr = 1;
controlNr--;
const selectedControl = ui.controls.controls[controlNr];
if (selectedControl != undefined){
- if (tool == 0){ //open category
+ if (tool == 'open'){ //open category
txt = game.i18n.localize(selectedControl.title);
src = selectedControl.icon;
if (activeControl == selectedControl.name)
@@ -250,7 +247,7 @@ export class OtherControls{
}
}
}
- else if (control == 1){ //displayed tools
+ else if (control == 'dispTools'){ //displayed tools
let controlNr = parseInt(settings.controlNr);
if (isNaN(controlNr)) controlNr = 1;
controlNr--;
@@ -274,16 +271,16 @@ export class OtherControls{
}
}
else { // specific control/tool
- const selectedControl = ui.controls.controls.find(c => c.name == controlName);
+ const selectedControl = ui.controls.controls.find(c => c.name == control);
if (selectedControl != undefined){
- if (tool == 0){ //open category
+ if (tool == 'open'){ //open category
txt = game.i18n.localize(selectedControl.title);
src = selectedControl.icon;
if (activeControl == selectedControl.name)
ringColor = "#FF7B00";
}
else {
- const selectedTool = selectedControl.tools.find(t => t.name == toolName);
+ const selectedTool = selectedControl.tools.find(t => t.name == tool);
if (selectedTool != undefined){
txt = game.i18n.localize(selectedTool.title);
src = selectedTool.icon;
@@ -300,33 +297,30 @@ export class OtherControls{
}
}
}
- streamDeck.setIcon(1,context,src,background,2,ringColor);
+ streamDeck.setIcon(context,src,background,2,ringColor);
streamDeck.setTitle(txt,context);
}
keyPressControl(settings){
if (canvas.scene == null) return;
let control = settings.control;
- if (control == undefined) control = 0;
+ if (control == undefined) control = 'dispControls';
let tool = settings.tool;
- if (tool == undefined) tool = 0;
-
- const controlName = this.getControlName(control);
- const toolName = this.getToolName(control,tool);
+ if (tool == undefined) tool = 'open';
- if (control == 0){ //displayed controls
+ if (control == 'dispControls'){ //displayed controls
let controlNr = parseInt(settings.controlNr);
if (isNaN(controlNr)) controlNr = 1;
controlNr--;
const selectedControl = ui.controls.controls[controlNr];
if (selectedControl != undefined){
- ui.controls.activeControl = controlName;
+ ui.controls.activeControl = 'token';
selectedControl.activeTool = selectedControl.activeTool;
canvas.getLayer(selectedControl.layer).activate();
}
}
- else if (control == 1){ //displayed tools
+ else if (control == 'dispTools'){ //displayed tools
let controlNr = parseInt(settings.controlNr);
if (isNaN(controlNr)) controlNr = 1;
controlNr--;
@@ -347,17 +341,17 @@ export class OtherControls{
}
}
else { //select control
- const selectedControl = ui.controls.controls.find(c => c.name == controlName);
+ const selectedControl = ui.controls.controls.find(c => c.name == control);
if (selectedControl != undefined){
- if (tool == 0){ //open category
- ui.controls.activeControl = controlName;
+ if (tool == 'open'){ //open category
+ ui.controls.activeControl = 'token';
selectedControl.activeTool = selectedControl.activeTool;
canvas.getLayer(selectedControl.layer).activate();
}
else {
- const selectedTool = selectedControl.tools.find(t => t.name == toolName);
+ const selectedTool = selectedControl.tools.find(t => t.name == tool);
if (selectedTool != undefined){
- ui.controls.activeControl = controlName;
+ ui.controls.activeControl = control;
canvas.getLayer(selectedControl.layer).activate();
if (selectedTool.toggle) {
selectedTool.active = !selectedTool.active;
@@ -367,7 +361,7 @@ export class OtherControls{
selectedTool.onClick();
}
else
- selectedControl.activeTool = toolName;
+ selectedControl.activeTool = tool;
}
}
}
@@ -375,87 +369,11 @@ export class OtherControls{
ui.controls.render();
}
- getControlName(control){
- control -= 2;
- let name;
- if (control == 0) name = 'token';
- else if (control == 1) name = 'measure';
- else if (control == 2) name = 'tiles';
- else if (control == 3) name = 'drawings';
- else if (control == 4) name = 'walls';
- else if (control == 5) name = 'lighting';
- else if (control == 6) name = 'sounds';
- else if (control == 7) name = 'notes';
- return name;
- }
-
- getToolName(control,tool){
- control -= 2;
- tool--;
- let name;
- if (control == 0){ //basic controls
- if (tool == 0) name = 'select';
- else if (tool == 1) name = 'target';
- else if (tool == 2) name = 'ruler';
- }
- else if (control == 1){ //measurement controls
- if (tool == 0) name = 'circle';
- else if (tool == 1) name = 'cone';
- else if (tool == 2) name = 'rect';
- else if (tool == 3) name = 'ray';
- else if (tool == 4) name = 'clear';
- }
- else if (control == 2){ //tile controls
- if (tool == 0) name = 'select';
- else if (tool == 1) name = 'tile';
- else if (tool == 2) name = 'browse';
- }
- else if (control == 3){ //drawing tools
- if (tool == 0) name = 'select';
- else if (tool == 1) name = 'rect';
- else if (tool == 2) name = 'ellipse';
- else if (tool == 3) name = 'polygon';
- else if (tool == 4) name = 'freehand';
- else if (tool == 5) name = 'text';
- else if (tool == 6) name = 'configure';
- else if (tool == 7) name = 'clear';
- }
- else if (control == 4){ //wall controls
- if (tool == 0) name = 'select';
- else if (tool == 1) name = 'walls';
- else if (tool == 2) name = 'terrain';
- else if (tool == 3) name = 'invisible';
- else if (tool == 4) name = 'ethereal';
- else if (tool == 5) name = 'doors';
- else if (tool == 6) name = 'secret';
- else if (tool == 7) name = 'clone';
- else if (tool == 8) name = 'snap';
- else if (tool == 9) name = 'clear';
- }
- else if (control == 5){ //lighting controls
- if (tool == 0) name = 'light';
- else if (tool == 1) name = 'day';
- else if (tool == 2) name = 'night';
- else if (tool == 3) name = 'reset';
- else if (tool == 4) name = 'clear';
- }
- else if (control == 6){ //ambient sound controls
- if (tool == 0) name = 'sound';
- else if (tool == 1) name = 'clear';
- }
- else if (control == 7){ //journal notes
- if (tool == 0) name = 'select';
- else if (tool == 1) name = 'toggle';
- else if (tool == 2) name = 'clear';
- }
- return name;
- }
-
//////////////////////////////////////////////////////////////////////////////////////////
updateDarkness(settings,context){
let func = settings.darknessFunction;
- if (func == undefined) func = 0;
+ if (func == undefined) func = 'value';
let value = settings.darknessValue;
if (value == undefined) value = 0;
@@ -466,35 +384,34 @@ export class OtherControls{
let src = "";
let txt = "";
- if (func == 0){ //value
- src = 'action/images/other/darkness/darkness.png';
+ if (func == 'value'){ //value
+ src = 'modules/MaterialDeck/img/other/darkness/darkness.png';
}
- else if (func == 1){ //increase/decrease
- if (value < 0) src = 'action/images/other/darkness/decreasedarkness.png';
- else src = 'action/images/other/darkness/increasedarkness.png';
+ else if (func == 'incDec'){ //increase/decrease
+ if (value < 0) src = 'modules/MaterialDeck/img/other/darkness/decreasedarkness.png';
+ else src = 'modules/MaterialDeck/img/other/darkness/increasedarkness.png';
}
- else if (func == 2){ //display darkness
- src = 'action/images/other/darkness/darkness.png';
+ else if (func == 'display'){ //display darkness
+ src = 'modules/MaterialDeck/img/other/darkness/darkness.png';
let darkness = '';
if (canvas.scene != null) darkness = Math.floor(canvas.scene.data.darkness*100)/100;
txt += darkness;
}
streamDeck.setTitle(txt,context);
- streamDeck.setIcon(0, context,src,background);
+ streamDeck.setIcon(context,src,background);
}
keyPressDarkness(settings) {
if (canvas.scene == null) return;
let func = settings.darknessFunction;
- if (func == undefined) func = 0;
+ if (func == undefined) func = 'value';
let value = parseFloat(settings.darknessValue);
if (value == undefined) value = 0;
- if (func == 0){ //value
+ if (func == 'value') //value
canvas.scene.update({darkness: value});
- }
- else if (func == 1){ //increase/decrease
+ else if (func == 'incDec'){ //increase/decrease
let darkness = canvas.scene.data.darkness;
darkness += -1*value;
if (darkness > 1) darkness = 1;
@@ -522,12 +439,12 @@ export class OtherControls{
if (settings.displayRollName) txt = table.name;
}
streamDeck.setTitle(txt,context);
- streamDeck.setIcon(1, context,src,background);
+ streamDeck.setIcon(context,src,background);
}
keyPressRollTable(settings){
let func = settings.rolltableFunction;
- if (func == undefined) func = 0;
+ if (func == undefined) func = 'open';
let name = settings.rollTableName;
if (name == undefined) return;
@@ -538,71 +455,55 @@ export class OtherControls{
let table = game.tables.entities.find(p=>p.name == name);
if (table != undefined) {
- if (func == 0){ //open
- table.sheet.render(true);
+ if (func == 'open'){ //open
+ const element = document.getElementById(table.sheet.id);
+ if (element == null) table.sheet.render(true);
+ else table.sheet.close();
}
- else if (func == 1) {//Public roll
+ else if (func == 'public') //Public roll
table.draw({rollMode:"roll"});
- }
- else if (func == 2) {//private roll
+ else if (func == 'private') //private roll
table.draw({rollMode:"selfroll"});
- }
}
}
//////////////////////////////////////////////////////////////////////////////////////////
- getSidebarId(nr){
- let id;
- if (nr == 0) id = 'chat';
- else if (nr == 1) id = 'combat';
- else if (nr == 2) id = 'scenes';
- else if (nr == 3) id = 'actors';
- else if (nr == 4) id = 'items';
- else if (nr == 5) id = 'journal';
- else if (nr == 6) id = 'tables';
- else if (nr == 7) id = 'playlists';
- else if (nr == 8) id = 'compendium';
- else if (nr == 9) id = 'settings';
- else id = '';
- return id;
- }
-
getSidebarName(nr){
let name;
- if (nr == 0) name = game.i18n.localize("SIDEBAR.TabChat");
- else if (nr == 1) name = game.i18n.localize("SIDEBAR.TabCombat");
- else if (nr == 2) name = game.i18n.localize("SIDEBAR.TabScenes");
- else if (nr == 3) name = game.i18n.localize("SIDEBAR.TabActors");
- else if (nr == 4) name = game.i18n.localize("SIDEBAR.TabItems");
- else if (nr == 5) name = game.i18n.localize("SIDEBAR.TabJournal");
- else if (nr == 6) name = game.i18n.localize("SIDEBAR.TabTables");
- else if (nr == 7) name = game.i18n.localize("SIDEBAR.TabPlaylists");
- else if (nr == 8) name = game.i18n.localize("SIDEBAR.TabCompendium");
- else if (nr == 9) name = game.i18n.localize("SIDEBAR.TabSettings");
- else if (nr == 10) name = game.i18n.localize("SIDEBAR.CollapseToggle");
+ if (nr == 'chat') name = game.i18n.localize("SIDEBAR.TabChat");
+ else if (nr == 'combat') name = game.i18n.localize("SIDEBAR.TabCombat");
+ else if (nr == 'scenes') name = game.i18n.localize("SIDEBAR.TabScenes");
+ else if (nr == 'actors') name = game.i18n.localize("SIDEBAR.TabActors");
+ else if (nr == 'items') name = game.i18n.localize("SIDEBAR.TabItems");
+ else if (nr == 'journal') name = game.i18n.localize("SIDEBAR.TabJournal");
+ else if (nr == 'tables') name = game.i18n.localize("SIDEBAR.TabTables");
+ else if (nr == 'playlists') name = game.i18n.localize("SIDEBAR.TabPlaylists");
+ else if (nr == 'compendium') name = game.i18n.localize("SIDEBAR.TabCompendium");
+ else if (nr == 'settings') name = game.i18n.localize("SIDEBAR.TabSettings");
+ else if (nr == 'collapse') name = game.i18n.localize("SIDEBAR.CollapseToggle");
return name;
}
getSidebarIcon(nr){
let icon;
- if (nr == 0) icon = window.CONFIG.ChatMessage.sidebarIcon;
- else if (nr == 1) icon = window.CONFIG.Combat.sidebarIcon;
- else if (nr == 2) icon = window.CONFIG.Scene.sidebarIcon;
- else if (nr == 3) icon = window.CONFIG.Actor.sidebarIcon;
- else if (nr == 4) icon = window.CONFIG.Item.sidebarIcon;
- else if (nr == 5) icon = window.CONFIG.JournalEntry.sidebarIcon;
- else if (nr == 6) icon = window.CONFIG.RollTable.sidebarIcon;
- else if (nr == 7) icon = window.CONFIG.Playlist.sidebarIcon;
- else if (nr == 8) icon = "fas fa-atlas";
- else if (nr == 9) icon = "fas fa-cogs";
- else if (nr == 10) icon = "fas fa-caret-right";
+ if (nr == 'chat') icon = window.CONFIG.ChatMessage.sidebarIcon;
+ else if (nr == 'combat') icon = window.CONFIG.Combat.sidebarIcon;
+ else if (nr == 'scenes') icon = window.CONFIG.Scene.sidebarIcon;
+ else if (nr == 'actors') icon = window.CONFIG.Actor.sidebarIcon;
+ else if (nr == 'items') icon = window.CONFIG.Item.sidebarIcon;
+ else if (nr == 'journal') icon = window.CONFIG.JournalEntry.sidebarIcon;
+ else if (nr == 'tables') icon = window.CONFIG.RollTable.sidebarIcon;
+ else if (nr == 'playlists') icon = window.CONFIG.Playlist.sidebarIcon;
+ else if (nr == 'compendium') icon = "fas fa-atlas";
+ else if (nr == 'settings') icon = "fas fa-cogs";
+ else if (nr == 'collapse') icon = "fas fa-caret-right";
return icon;
}
updateSidebar(settings,context){
let sidebarTab = settings.sidebarTab;
- if (sidebarTab == undefined) sidebarTab = 0;
+ if (sidebarTab == undefined) sidebarTab = 'chat';
let activeTab = ui.sidebar.activeTab;
let collapsed = ui.sidebar._collapsed;
@@ -624,22 +525,24 @@ export class OtherControls{
if (settings.displaySidebarName) name = this.getSidebarName(sidebarTab);
if (settings.displaySidebarIcon) icon = this.getSidebarIcon(sidebarTab);
- if ((sidebarTab == 10 && collapsed))
+ if ((sidebarTab == 'collapse' && collapsed))
ringColor = ringOnColor;
else
ringColor = ringOffColor;
streamDeck.setTitle(name,context);
- streamDeck.setIcon(1,context,icon,background,2,ringColor);
+ streamDeck.setIcon(context,icon,background,2,ringColor);
}
keyPressSidebar(settings){
let sidebarTab = settings.sidebarTab;
- if (sidebarTab == undefined) sidebarTab = 0;
+ if (sidebarTab == undefined) sidebarTab = 'chat';
let collapsed = ui.sidebar._collapsed;
- if (sidebarTab < 10) ui.sidebar.activateTab(this.getSidebarId(sidebarTab));
- else if (collapsed) ui.sidebar.expand();
- else if (collapsed == false) ui.sidebar.collapse();
+ if (sidebarTab == 'collapse'){
+ if (collapsed) ui.sidebar.expand();
+ else if (collapsed == false) ui.sidebar.collapse();
+ }
+ else ui.sidebar.activateTab(sidebarTab);
}
//////////////////////////////////////////////////////////////////////////////////////////
@@ -666,7 +569,7 @@ export class OtherControls{
else ringColor = ringOffColor;
if (settings.displayCompendiumName) streamDeck.setTitle(name,context);
- streamDeck.setIcon(0,context,"",background,2,ringColor);
+ streamDeck.setIcon(context,"",background,2,ringColor);
}
keyPressCompendium(settings){
@@ -705,7 +608,7 @@ export class OtherControls{
else ringColor = ringOffColor;
if (settings.displayCompendiumName) streamDeck.setTitle(name,context);
- streamDeck.setIcon(0,context,"",background,2,ringColor);
+ streamDeck.setIcon(context,"",background,2,ringColor);
}
keyPressJournal(settings){
@@ -714,7 +617,8 @@ export class OtherControls{
const journal = game.journal.entries.find(p=>p.name == name);
if (journal == undefined) return;
-
- journal.render(true);
+ const element = document.getElementById("journal-"+journal.id);
+ if (element == null) journal.render(true);
+ else journal.sheet.close();
}
}
\ No newline at end of file
diff --git a/src/playlist.js b/src/playlist.js
index fe438e5..7e0bbaa 100644
--- a/src/playlist.js
+++ b/src/playlist.js
@@ -19,16 +19,19 @@ export class PlaylistControl{
update(settings,context){
this.active = true;
- if (settings.playlistMode == undefined) settings.playlistMode = 0;
- if (settings.playlistMode == 0){
+ if (settings.playlistMode == undefined) settings.playlistMode = 'playlist';
+ if (settings.playlistMode == 'playlist'){
this.updatePlaylist(settings,context);
}
- else if (settings.playlistMode == 1){
+ else if (settings.playlistMode == 'track'){
this.updateTrack(settings,context);
}
else {
- let src = 'action/images/playlist/stop.png';
- streamDeck.setIcon(0,context,src,settings.background);
+ let src = 'modules/MaterialDeck/img/playlist/stop.png';
+ if (game.playlists.playing.length > 0)
+ streamDeck.setIcon(context,src,settings.background,2,'#00FF00',true);
+ else
+ streamDeck.setIcon(context,src,settings.background,1,'#000000',true);
}
}
@@ -47,10 +50,10 @@ export class PlaylistControl{
if (ringOnColor == undefined) ringOnColor = '#00FF00';
let playlistType = settings.playlistType;
- if (playlistType == undefined) playlistType = 0;
+ if (playlistType == undefined) playlistType = 'playStop';
//Play/Stop
- if (playlistType == 0){
+ if (playlistType == 'playStop'){
let playlistNr = parseInt(settings.playlistNr);
if (isNaN(playlistNr) || playlistNr < 1) playlistNr = 1;
playlistNr--;
@@ -67,12 +70,12 @@ export class PlaylistControl{
}
}
//Offset
- else {
+ else if (playlistType == 'offset') {
let playlistOffset = parseInt(settings.offset);
if (isNaN(playlistOffset)) playlistOffset = 0;
if (playlistOffset == this.playlistOffset) ringColor = ringOnColor;
}
- streamDeck.setIcon(0,context,"",background,2,ringColor);
+ streamDeck.setIcon(context,"",background,2,ringColor);
streamDeck.setTitle(name,context);
}
@@ -91,10 +94,10 @@ export class PlaylistControl{
if (ringOnColor == undefined) ringOnColor = '#00FF00';
let playlistType = settings.playlistType;
- if (playlistType == undefined) playlistType = 0;
+ if (playlistType == undefined) playlistType = 'playStop';
//Play/Stop
- if (playlistType == 0){
+ if (playlistType == 'playStop'){
let playlistNr = parseInt(settings.playlistNr);
if (isNaN(playlistNr) || playlistNr < 1) playlistNr = 1;
playlistNr--;
@@ -123,7 +126,7 @@ export class PlaylistControl{
if (isNaN(trackOffset)) trackOffset = 0;
if (trackOffset == this.trackOffset) ringColor = ringOnColor;
}
- streamDeck.setIcon(0,context,"",background,2,ringColor);
+ streamDeck.setIcon(context,"",background,2,ringColor);
streamDeck.setTitle(name,context);
}
@@ -163,13 +166,16 @@ export class PlaylistControl{
trackNr--;
trackNr += this.trackOffset;
- if (settings.playlistMode == undefined) settings.playlistMode = 0;
- if (settings.playlistType == undefined) settings.playlistType = 0;
- if (settings.playlistMode < 2){
- if (settings.playlistType == 0) {
+ if (settings.playlistMode == undefined) settings.playlistMode = 'playlist';
+ if (settings.playlistType == undefined) settings.playlistType = 'playStop';
+ if (settings.playlistMode == 'stopAll') {
+ this.stopAll(true);
+ }
+ else {
+ if (settings.playlistType == 'playStop') {
let playlist = this.getPlaylist(playlistNr);
if (playlist != undefined){
- if (settings.playlistMode == 0)
+ if (settings.playlistMode == 'playlist')
this.playPlaylist(playlist,playlistNr);
else {
let track = playlist.data.sounds[trackNr];
@@ -180,7 +186,7 @@ export class PlaylistControl{
}
}
else {
- if (settings.playlistMode == 0) {
+ if (settings.playlistMode == 'playlist') {
this.playlistOffset = parseInt(settings.offset);
if (isNaN(this.playlistOffset)) this.playlistOffset = 0;
}
@@ -191,9 +197,7 @@ export class PlaylistControl{
this.updateAll();
}
}
- else {
- this.stopAll(true);
- }
+
}
async playPlaylist(playlist,playlistNr){
diff --git a/src/soundboard.js b/src/soundboard.js
index c2c3c64..8ff1a4a 100644
--- a/src/soundboard.js
+++ b/src/soundboard.js
@@ -22,7 +22,7 @@ export class SoundboardControl{
update(settings,context){
this.active = true;
let mode = settings.soundboardMode;
- if (mode == undefined) mode = 0;
+ if (mode == undefined) mode = 'playSound';
let txt = "";
let src = "";
@@ -32,7 +32,7 @@ export class SoundboardControl{
let ringColor = "#000000"
- if (mode == 0){ //play sound
+ if (mode == 'playSound'){ //play sound
let soundNr = parseInt(settings.soundNr);
if (isNaN(soundNr)) soundNr = 1;
soundNr--;
@@ -48,9 +48,9 @@ export class SoundboardControl{
if (settings.displayName && soundboardSettings.name != undefined) txt = soundboardSettings.name[soundNr];
if (settings.displayIcon && soundboardSettings.img != undefined) src = soundboardSettings.img[soundNr];
streamDeck.setTitle(txt,context);
- streamDeck.setIcon(1,context,src,background,2,ringColor);
+ streamDeck.setIcon(context,src,background,2,ringColor);
}
- else if (mode == 1) { //Offset
+ else if (mode == 'offset') { //Offset
let ringOffColor = settings.offRing;
if (ringOffColor == undefined) ringOffColor = '#000000';
@@ -62,18 +62,24 @@ export class SoundboardControl{
if (offset == this.offset) ringColor = ringOnColor;
else ringColor = ringOffColor;
streamDeck.setTitle(txt,context);
- streamDeck.setIcon(1,context,"",background,2,ringColor);
+ streamDeck.setIcon(context,"",background,2,ringColor);
}
- else if (mode == 2) { //Stop all sounds
- let src = 'action/images/soundboard/stop.png';
- streamDeck.setIcon(0,context,src,background);
+ else if (mode == 'stopAll') { //Stop all sounds
+ let src = 'modules/MaterialDeck/img/playlist/stop.png';
+ let soundPlaying = false;
+ for (let i=0; i {
@@ -373,6 +365,7 @@ export class StreamDeck{
}
ctx.drawImage(img, xStart+margin, yStart+margin, renderableWidth - 2*margin, renderableHeight - 2*margin);
var dataURL = canvas.toDataURL();
+ canvas.remove();
this.setImage(dataURL,data.context);
};
img.src = resImageURL;
diff --git a/src/token.js b/src/token.js
index ced6952..b78b1cb 100644
--- a/src/token.js
+++ b/src/token.js
@@ -23,7 +23,7 @@ export class TokenControl{
if (settings.displayIcon) icon = true;
if (settings.displayName) name = true;
- if (stats == undefined) stats = 0;
+ if (stats == undefined) stats = 'none';
if (settings.background) background = settings.background;
let system = settings.system;
@@ -32,16 +32,19 @@ export class TokenControl{
let tokenName = "";
let txt = "";
let iconSrc = "";
+ let overlay = false;
if (tokenId != undefined) {
let token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
tokenName = token.data.name;
if (name) txt += tokenName;
- if (name && stats != 0) txt += "\n";
- iconSrc += token.data.img;
+ if (name && stats != 'none') txt += "\n";
+ iconSrc = token.data.img;
let actor = canvas.tokens.children[0].children.find(p => p.id == tokenId).actor;
if (system == 'dnd5e' && game.system.id == 'dnd5e'){
let attributes = actor.data.data.attributes;
- if (stats == 'HP') txt += attributes.hp.value + "/" + attributes.hp.max;
+ if (stats == 'HP') {
+ txt += attributes.hp.value + "/" + attributes.hp.max;
+ }
else if (stats == 'TempHP') {
txt += attributes.hp.temp;
if (attributes.hp.tempmax != null)
@@ -83,7 +86,7 @@ export class TokenControl{
else if (stats == 'PassivePerception') txt += actor.data.data.skills.prc.passive;
else if (stats == 'PassiveInvestigation') txt += actor.data.data.skills.inv.passive;
}
- else if (system == 'dnd3.5e' && game.system.id == 'D35E'){
+ else if ((system == 'dnd3.5e' && game.system.id == 'D35E') || (system == 'pf1e' && game.system.id == 'pf1')){
let attributes = actor.data.data.attributes;
if (stats == 'HP') txt += attributes.hp.value + "/" + attributes.hp.max;
else if (stats == 'TempHP') {
@@ -138,6 +141,13 @@ export class TokenControl{
if (init != undefined) txt += init;
}
}
+ else if (system == 'demonlord' && game.system.id == 'demonlord'){
+ let characteristics = actor.data.data.characteristics;
+ if (stats == 'HP') txt += characteristics.health.value + "/" + characteristics.health.max;
+ else if (stats == 'AC') txt += characteristics.defense;
+ else if (stats == 'Speed') txt += characteristics.speed;
+ else if (stats == 'Init') txt += actor.data.data.fastturn ? "FAST" : "SLOW";
+ }
else {
//Other systems
@@ -146,7 +156,7 @@ export class TokenControl{
}
- if (settings.onClick == 4) { //toggle visibility
+ if (settings.onClick == 'visibility') { //toggle visibility
ring = 1;
if (token.data.hidden){
ring = 2;
@@ -154,10 +164,10 @@ export class TokenControl{
}
if (icon == false) {
iconSrc = window.CONFIG.controlIcons.visibility;
- streamDeck.setIcon(1,context,iconSrc,background,ring,ringColor,true);
+ overlay = true;
}
}
- else if (settings.onClick == 5) { //toggle combat state
+ else if (settings.onClick == 'combatState') { //toggle combat state
ring = 1;
if (token.inCombat){
ring = 2;
@@ -165,10 +175,10 @@ export class TokenControl{
}
if (icon == false) {
iconSrc = window.CONFIG.controlIcons.combat;
- streamDeck.setIcon(1,context,iconSrc,background,ring,ringColor,true);
+ overlay = true;
}
}
- else if (settings.onClick == 6) { //target token
+ else if (settings.onClick == 'target') { //target token
ring = 1;
if (token.isTargeted){
ring = 2;
@@ -176,78 +186,133 @@ export class TokenControl{
}
if (icon == false) {
iconSrc = "fas fa-bullseye";
- streamDeck.setIcon(1,context,iconSrc,background,ring,ringColor);
}
}
- else if (settings.onClick == 7) { //toggle condition
+ else if (settings.onClick == 'condition') { //toggle condition
ring = 1;
- let condition = settings.condition;
- if (condition == undefined) condition = 0;
- if (condition == 0 && icon == false){
- iconSrc = window.CONFIG.controlIcons.effects;
- }
- else if (icon == false) {
- if ((system == 'dnd5e' && game.system.id == 'dnd5e') || (system == 'dnd3.5e' && game.system.id == 'D35E')){
- let effect = CONFIG.statusEffects.find(e => e.id === this.getStatusId(condition));
+ if ((system == 'dnd5e' && game.system.id == 'dnd5e') || (system == 'dnd3.5e' && game.system.id == 'D35E') || (system == 'pf1e' && game.system.id == 'pf1')){
+ let condition = settings.condition;
+ if (condition == undefined) condition = 'removeAll';
+ if (condition == 'removeAll' && icon == false)
+ iconSrc = window.CONFIG.controlIcons.effects;
+ else if (icon == false) {
+ let effect = CONFIG.statusEffects.find(e => e.id === condition);
iconSrc = effect.icon;
let effects = token.actor.effects.entries;
- let active = effects.find(e => e.isTemporary === this.getStatusId(condition));
+ let active = effects.find(e => e.isTemporary === condition);
if (active != undefined){
ring = 2;
ringColor = "#FF7B00";
- }
- }
- else if (system == 'pf2e' && game.system.id == 'pf2e') {
+ }
+ }
+ }
+ else if (system == 'pf2e' && game.system.id == 'pf2e') {
+ let condition = settings.conditionPF2E;
+ if (condition == undefined) condition = 'removeAll';
+ if (condition == 'removeAll' && icon == false)
+ iconSrc = window.CONFIG.controlIcons.effects;
+ else if (icon == false) {
let effects = token.data.effects;
for (let i=0; i e.id === condition);
+ iconSrc = effect.icon;
+ let effects = token.actor.effects.entries;
+ let active = effects.find(e => e.isTemporary === condition);
+ if (active != undefined){
+ ring = 2;
+ ringColor = "#FF7B00";
+ }
+ }
+ }
+ else
+ iconSrc = "";
+ overlay = true;
}
}
else {
iconSrc += "";
- if (settings.onClick == 4) { //toggle visibility
+ if (settings.onClick == 'visibility') { //toggle visibility
if (icon == false) {
iconSrc = window.CONFIG.controlIcons.visibility;
- streamDeck.setIcon(1,context,iconSrc,background,1,'#000000',true);
+ ring = 2;
+ overlay = true;
}
}
- else if (settings.onClick == 5) { //toggle combat state
+ else if (settings.onClick == 'combatState') { //toggle combat state
if (icon == false) {
iconSrc = window.CONFIG.controlIcons.combat;
- streamDeck.setIcon(1,context,iconSrc,background,1,'#000000',true);
+ ring = 2;
+ overlay = true;
}
}
- else if (settings.onClick == 6) { //target token
+ else if (settings.onClick == 'target') { //target token
if (icon == false) {
iconSrc = "fas fa-bullseye";
- streamDeck.setIcon(1,context,iconSrc,background,1,'#000000');
+ ring = 2;
+ overlay = true;
}
}
- else if (settings.onClick == 7) { //toggle condition
- let condition = settings.condition;
- if (condition == undefined) condition = 0;
+ else if (settings.onClick == 'condition') { //toggle condition
+ if ((system == 'dnd5e' && game.system.id == 'dnd5e') || (system == 'dnd3.5e' && game.system.id == 'D35E') || (system == 'pf1e' && game.system.id == 'pf1')){
+ let condition = settings.condition;
+ if (condition == undefined) condition = 'removeAll';
- if (condition == 0 && icon == false){
- iconSrc = window.CONFIG.controlIcons.effects;
+ if (condition == 'removeAll' && icon == false)
+ iconSrc = window.CONFIG.controlIcons.effects;
+ else if (icon == false)
+ iconSrc = CONFIG.statusEffects.find(e => e.id === condition).icon;
}
- else if (icon == false) {
- if ((system == 'dnd5e' && game.system.id == 'dnd5e') || (system == 'dnd3.5e' && game.system.id == 'D35E'))
- iconSrc = CONFIG.statusEffects.find(e => e.id === this.getStatusId(condition)).icon;
- else if (system == 'pf2e' && game.system.id == 'pf2e')
- iconSrc = CONFIG.statusEffects[condition-1];
- }
- streamDeck.setIcon(1,context,iconSrc,background,1,'#000000',true);
+ else if (system == 'pf2e' && game.system.id == 'pf2e') {
+ let condition = settings.conditionPF2E;
+ if (condition == undefined) condition = 'removeAll';
+
+ if (condition == 'removeAll' && icon == false)
+ iconSrc = window.CONFIG.controlIcons.effects;
+ else if (icon == false)
+ iconSrc = this.pf2eCondition(condition);
+ }
+ else if (system == 'demonlord' && game.system.id == 'demonlord'){
+ let condition = settings.conditionDemonlord;
+ if (condition == undefined) condition = 'removeAll';
+
+ if (condition == 'removeAll' && icon == false)
+ iconSrc = window.CONFIG.controlIcons.effects;
+ else if (icon == false)
+ iconSrc = CONFIG.statusEffects.find(e => e.id === condition).icon;
+ }
+ ring = 1;
+ overlay = true;
}
}
- if (icon) streamDeck.setIcon(1,context,iconSrc,background,ring,ringColor);
+ if (icon == false){
+ if (stats == 'HP' || stats == 'TempHP') //HP
+ iconSrc = "modules/MaterialDeck/img/token/hp.png";
+ else if (stats == 'AC' || stats == 'ShieldHP') //AC
+ iconSrc = "modules/MaterialDeck/img/token/ac.webp";
+ else if (stats == 'Speed') //Speed
+ iconSrc = "modules/MaterialDeck/img/token/speed.webp";
+ else if (stats == 'Init') //Initiative
+ iconSrc = "modules/MaterialDeck/img/token/init.png";
+ else if (stats == 'PassivePerception')
+ iconSrc = "modules/MaterialDeck/img/black.png";
+ else if (stats == 'PassiveInvestigation')
+ iconSrc = "modules/MaterialDeck/img/black.png";
+ }
+ streamDeck.setIcon(context,iconSrc,background,ring,ringColor,overlay);
streamDeck.setTitle(txt,context);
}
@@ -257,7 +322,7 @@ export class TokenControl{
const tokenId = MODULE.selectedTokenId;
let onClick = settings.onClick;
- if (onClick == undefined) onClick = 0;
+ if (onClick == undefined) onClick = 'doNothing';
const token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
if (token == undefined) return;
@@ -265,89 +330,91 @@ export class TokenControl{
let system = settings.system;
if (system == undefined) system = 'dnd5e';
- if (onClick == 0) //Do nothing
+ if (onClick == 'doNothing') //Do nothing
return;
- else if (onClick == 1){ //center on token
+ else if (onClick == 'center'){ //center on token
let location = token.getCenter(token.x,token.y);
canvas.animatePan(location);
}
- else if (onClick == 2){ //Open character sheet
- token.actor.sheet.render(true);
+ else if (onClick == 'charSheet'){ //Open character sheet
+ const element = document.getElementById(token.actor.sheet.id);
+ if (element == null) token.actor.sheet.render(true);
+ else token.actor.sheet.close();
}
- else if (onClick == 3) { //Open token config
- token.sheet._render(true);
+ else if (onClick == 'tokenConfig') { //Open token config
+ const element = document.getElementById(token.sheet.id);
+ if (element == null) token.sheet.render(true);
+ else token.sheet.close();
}
- else if (onClick == 4) { //Toggle visibility
+ else if (onClick == 'visibility') { //Toggle visibility
token.toggleVisibility();
}
- else if (onClick == 5) { //Toggle combat state
+ else if (onClick == 'combatState') { //Toggle combat state
token.toggleCombat();
}
- else if (onClick == 6) { //Target token
+ else if (onClick == 'target') { //Target token
token.setTarget(!token.isTargeted,{releaseOthers:false});
}
- else if (onClick == 7) { //Toggle condition
- let condition = settings.condition;
- if (condition == undefined) condition = 0;
+ else if (onClick == 'condition') { //Toggle condition
+ if ((system == 'dnd5e' && game.system.id == 'dnd5e') || (system == 'dnd3.5e' && game.system.id == 'D35E') || (system == 'pf1e' && game.system.id == 'pf1')){
+ let condition = settings.condition;
+ if (condition == undefined) condition = 'removeAll';
- if (condition == 0){
- const effects = token.actor.effects.entries;
- for (let i=0; i e.icon === effects[i].data.icon);
- else if (system == 'pf2e' && game.system.id == 'pf2e')
- effect = CONFIG.statusEffects[condition-1];
- await token.toggleEffect(effect)
+ if (condition == 'removeAll'){
+ const effects = token.actor.effects.entries;
+ for (let i=0; i e.icon === effects[i].data.icon);
+ await token.toggleEffect(effect)
+ }
+ }
+ else {
+ const effect = CONFIG.statusEffects.find(e => e.id === condition);
+ await token.toggleEffect(effect);
}
}
- else {
- let effect;
- if ((system == 'dnd5e' && game.system.id == 'dnd5e') || (system == 'dnd3.5e' && game.system.id == 'D35E'))
- effect = CONFIG.statusEffects.find(e => e.id === this.getStatusId(condition));
- else if (system == 'pf2e' && game.system.id == 'pf2e')
- effect = CONFIG.statusEffects[condition-1];
- token.toggleEffect(effect);
- }
+ else if (system == 'pf2e' && game.system.id == 'pf2e'){
+ let condition = settings.conditionPF2E;
+ if (condition == undefined) condition = 'removeAll';
+ if (condition == 'removeAll'){
+ const effects = token.actor.effects.entries;
+ for (let i=0; i e.icon === effects[i].data.icon);
+ await token.toggleEffect(effect)
+ }
+ }
+ else {
+ const effect = CONFIG.statusEffects.find(e => e.id === condition);
+ await token.toggleEffect(effect);
+ }
+ }
+ this.update(tokenId);
+
+ }
+ else if (system == 'demonlord' && game.system.id == 'demonlord' && onClick == 'initiative'){
+ token.actor.update({
+ 'data.fastturn': !token.actor.data?.data?.fastturn
+ })
}
}
- getStatusId(nr){
- let id;
- if (nr == 1) id = 'dead';
- else if (nr == 2) id = 'unconscious';
- else if (nr == 3) id = 'sleep';
- else if (nr == 4) id = 'stun';
- else if (nr == 5) id = 'prone';
- else if (nr == 6) id = 'restrain';
- else if (nr == 7) id = 'paralysis';
- else if (nr == 8) id = 'fly';
- else if (nr == 9) id = 'bind';
- else if (nr == 10) id = 'deaf';
- else if (nr == 11) id = 'silence';
- else if (nr == 12) id = 'fear';
- else if (nr == 13) id = 'burning';
- else if (nr == 14) id = 'frozen';
- else if (nr == 15) id = 'shock';
- else if (nr == 16) id = 'corrode';
- else if (nr == 17) id = 'bleeding';
- else if (nr == 18) id = 'disease';
- else if (nr == 19) id = 'poison';
- else if (nr == 20) id = 'radiation';
- else if (nr == 21) id = 'regen';
- else if (nr == 22) id = 'degen';
- else if (nr == 23) id = 'upgrade';
- else if (nr == 24) id = 'downgrade';
- else if (nr == 25) id = 'target';
- else if (nr == 26) id = 'eye';
- else if (nr == 27) id = 'curse';
- else if (nr == 28) id = 'bless';
- else if (nr == 29) id = 'fireShield';
- else if (nr == 30) id = 'coldShield';
- else if (nr == 31) id = 'magicShield';
- else if (nr == 32) id = 'holyShield';
-
- return id;
+ pf2eCondition(condition){
+ return "systems/pf2e/icons/conditions-2/" + condition + ".png";
}
}
\ No newline at end of file