Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc9bcf4770 | ||
|
|
7d4fd1e8b1 | ||
|
|
780e06d581 | ||
|
|
64983ca0cb | ||
|
|
dd534488da |
@@ -85,13 +85,13 @@ async function analyzeWSmessage(msg){
|
|||||||
const event = data.event;
|
const event = data.event;
|
||||||
const context = data.context;
|
const context = data.context;
|
||||||
const coordinates = data.payload.coordinates;
|
const coordinates = data.payload.coordinates;
|
||||||
if (coordinates == undefined) coordinates = 0;
|
|
||||||
const settings = data.payload.settings;
|
const settings = data.payload.settings;
|
||||||
|
|
||||||
if (data.data == 'init'){
|
if (data.data == 'init'){
|
||||||
|
|
||||||
}
|
}
|
||||||
if (event == 'willAppear' || event == 'didReceiveSettings'){
|
if (event == 'willAppear' || event == 'didReceiveSettings'){
|
||||||
|
if (coordinates == undefined) return;
|
||||||
streamDeck.setScreen(action);
|
streamDeck.setScreen(action);
|
||||||
streamDeck.setContext(action,context,coordinates,settings);
|
streamDeck.setContext(action,context,coordinates,settings);
|
||||||
|
|
||||||
@@ -118,7 +118,8 @@ async function analyzeWSmessage(msg){
|
|||||||
}
|
}
|
||||||
|
|
||||||
else if (event == 'willDisappear'){
|
else if (event == 'willDisappear'){
|
||||||
streamDeck.clearContext(action,coordinates);
|
if (coordinates == undefined) return;
|
||||||
|
streamDeck.clearContext(action,coordinates,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (event == 'keyDown'){
|
else if (event == 'keyDown'){
|
||||||
@@ -488,6 +489,16 @@ Hooks.on('NotYourTurn', ()=>{
|
|||||||
externalModules.updateAll();
|
externalModules.updateAll();
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Hooks.on('pseudoclockSet', ()=>{
|
||||||
|
if (enableModule == false || ready == false) return;
|
||||||
|
externalModules.updateAll();
|
||||||
|
})
|
||||||
|
|
||||||
|
Hooks.on('about-time.clockRunningStatus', ()=>{
|
||||||
|
if (enableModule == false || ready == false) return;
|
||||||
|
externalModules.updateAll();
|
||||||
|
})
|
||||||
|
|
||||||
Hooks.once('init', ()=>{
|
Hooks.once('init', ()=>{
|
||||||
//CONFIG.debug.hooks = true;
|
//CONFIG.debug.hooks = true;
|
||||||
registerSettings(); //in ./src/settings.js
|
registerSettings(); //in ./src/settings.js
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
<b>Note:</b><br>
|
<b>Note:</b> At the moment Windows and OSX support has been confirmed. Linux support is unknown, there is no official Linux support for the Stream Deck, but there exist a 3rd party <a href="https://timothycrosley.com/project-7-streamdeck_ui">Stream Deck UI</a> that might be compatible.<br>
|
||||||
At the moment Windows and OSX are supported. Linux has been reported to work, there is no official Linux support for the Stream Deck, but there exist a 3rd party <a href="https://timothycrosley.com/project-7-streamdeck_ui">Stream Deck UI</a> that appears be compatible. To get it working on Linux requires more work, and help I can personally offer is limited.<br>
|
|
||||||
The module works on the native Foundry application, Chrome and Firefox. Safari (you'll need the latest dev version to get Foundry to work on it) doesn't work if your Foundry server is secured, unless you use something like Nginx with which I cannot help you.<br>
|
|
||||||
<b>In any case: Proceed at your own risk, I will not take any responsibility if you spent money and the module doesn't work!</b>
|
<b>In any case: Proceed at your own risk, I will not take any responsibility if you spent money and the module doesn't work!</b>
|
||||||
|
|
||||||
<b>Please read the documentation carefully, especially if you want to modify the default profile!</b>
|
<b>Please read the documentation carefully, especially if you want to modify the default profile!</b>
|
||||||
@@ -74,7 +72,7 @@ Module manifest: https://raw.githubusercontent.com/CDeenen/MaterialDeck/Master/m
|
|||||||
|
|
||||||
## Software Versions & Module Incompatibilities
|
## Software Versions & Module Incompatibilities
|
||||||
<b>Foundry VTT:</b> Tested on 0.7.9<br>
|
<b>Foundry VTT:</b> Tested on 0.7.9<br>
|
||||||
<b>Module Incompatibilities:</b> Combat Utility Belt conditions do not work with the Token Action.<br>
|
<b>Module Incompatibilities:</b> None known.<br>
|
||||||
|
|
||||||
## Feedback
|
## Feedback
|
||||||
If you have any suggestions or bugs to report, feel free to create an issue, contact me on Discord (Cris#6864), or send me an email: cdeenen@outlook.com.
|
If you have any suggestions or bugs to report, feel free to create an issue, contact me on Discord (Cris#6864), or send me an email: cdeenen@outlook.com.
|
||||||
|
|||||||
51
changelog.md
51
changelog.md
@@ -1,4 +1,53 @@
|
|||||||
# Changelog Material Deck Module
|
# Changelog Material Deck Module
|
||||||
|
## v1.3.2 - 11-03-2021
|
||||||
|
Additions:
|
||||||
|
<ul>
|
||||||
|
<li>Added support for the Multi Action provided by the SD app</li>
|
||||||
|
<li>External Modules Action => Added support for About Time</li>
|
||||||
|
<li>Token Action => Stats: Added 'Ability Scores', 'Ability Score Modifiers', 'Ability Score Saves' (dnd5e only) and 'Proficiency Bonus'</li>
|
||||||
|
<li>Token Action => Stats: Added 'HP (box)' option that displays a box with color that changes depending on the HP</li>
|
||||||
|
<li>Move Action: You can now choose what token should be moved, similar to the Token Action</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
Fixes:
|
||||||
|
<ul>
|
||||||
|
<li>Playlist Action => Relative Offset: Fixed issue with displaying the target playlist name</li>
|
||||||
|
<li>Macro Action: Fixed Hotbar Uses for Shadow of the Demonlord</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
Other:
|
||||||
|
<ul>
|
||||||
|
<li>Macro Action: Improved the way Hotbar Uses are displayed, it is now displayed in a box similar to how the module looks in Foundry</li>
|
||||||
|
<li>Made the way images are generated more flexible to make future additions easier</li>
|
||||||
|
<li></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<b>Compatible server app and SD plugin:</b><br>
|
||||||
|
Material Server v1.0.2 (unchanged): https://github.com/CDeenen/MaterialServer/releases <br>
|
||||||
|
SD plugin v1.3.2 (<b>must be updated!</b>): https://github.com/CDeenen/MaterialDeck_SD/releases<br>
|
||||||
|
|
||||||
|
### v1.3.1 - 27-02-2021
|
||||||
|
Additions:
|
||||||
|
<ul>
|
||||||
|
<li>Token Action: You can now choose what token should be targeted with the action using: 'Selected Token', 'Token Name', 'Actor Name', 'Token Id' or 'Actor Id'. Added relevant user permissions to the permission configuration</li>
|
||||||
|
<li>Token Action => On Click: Added options 'Select Token' and 'Center on Token and Select Token'</li>
|
||||||
|
<li>Playlist Action: Added relative offset mode, with the option to display the offset target name for playlists</li>
|
||||||
|
<li>Playlist Action => Stop All: Added option to display the name of the playlist at the current offset</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
Fixes:
|
||||||
|
<ul>
|
||||||
|
<li>Default user permissions would not be loaded if no previously saved permissions were present, resulting in MD assuming nobody has any permissions</li>
|
||||||
|
<li>Other Actions => Control Buttons => Lighting Controls: Would create a button for ambient sound instead of lighting</li>
|
||||||
|
<li>Token Action => Display Token Icon: It used to show the icon, even if unchecked, if no stat with default icon was selected</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<b>Compatible server app and SD plugin:</b><br>
|
||||||
|
Material Server v1.0.2 (unchanged): https://github.com/CDeenen/MaterialServer/releases <br>
|
||||||
|
SD plugin v1.3.1 (<b>must be updated!</b>): https://github.com/CDeenen/MaterialDeck_SD/releases<br>
|
||||||
|
|
||||||
### v1.3.0 - 25-02-2021
|
### v1.3.0 - 25-02-2021
|
||||||
Additions:
|
Additions:
|
||||||
<ul>
|
<ul>
|
||||||
@@ -10,7 +59,7 @@ Additions:
|
|||||||
<li>External Modules => Added support for the 'Shared Vision' module</li>
|
<li>External Modules => Added support for the 'Shared Vision' module</li>
|
||||||
<li>External Modules => Added support for the 'Lock View' module</li>
|
<li>External Modules => Added support for the 'Lock View' module</li>
|
||||||
<li>External Modules => Added support for the 'Not Your Turn' module</li>
|
<li>External Modules => Added support for the 'Not Your Turn' module</li>
|
||||||
<ul>
|
</ul>
|
||||||
Fixes:
|
Fixes:
|
||||||
<ul>
|
<ul>
|
||||||
<li>Token Action => OnClick: Fixed conditions for pf1e and dnd3.5e</li>
|
<li>Token Action => OnClick: Fixed conditions for pf1e and dnd3.5e</li>
|
||||||
|
|||||||
12
lang/en.json
12
lang/en.json
@@ -164,6 +164,16 @@
|
|||||||
"MaterialDeck.Perm.TOKEN.CONDITIONS.label": "Set Conditions",
|
"MaterialDeck.Perm.TOKEN.CONDITIONS.label": "Set Conditions",
|
||||||
"MaterialDeck.Perm.TOKEN.CONDITIONS.hint": "Allow the users to set conditions for the controlled token",
|
"MaterialDeck.Perm.TOKEN.CONDITIONS.hint": "Allow the users to set conditions for the controlled token",
|
||||||
"MaterialDeck.Perm.TOKEN.CUSTOM.label": "Custom On-Click",
|
"MaterialDeck.Perm.TOKEN.CUSTOM.label": "Custom On-Click",
|
||||||
"MaterialDeck.Perm.TOKEN.CUSTOM.hint": "Allow the users to set custom on-click functions"
|
"MaterialDeck.Perm.TOKEN.CUSTOM.hint": "Allow the users to set custom on-click functions",
|
||||||
|
"MaterialDeck.Perm.TOKEN.NON_OWNED.label": "Non-Owned and Non-Observer Tokens",
|
||||||
|
"MaterialDeck.Perm.TOKEN.NON_OWNED.hint": "Allow users access to tokens with non-owned or limited permission",
|
||||||
|
"MaterialDeck.Perm.TOKEN.OBSERVER.label": "Observer",
|
||||||
|
"MaterialDeck.Perm.TOKEN.OBSERVER.hint": "Allow users access to tokens with observer permission",
|
||||||
|
|
||||||
|
"MaterialDeck.AboutTime.First": "st",
|
||||||
|
"MaterialDeck.AboutTime.Second": "nd",
|
||||||
|
"MaterialDeck.AboutTime.Third": "rd",
|
||||||
|
"MaterialDeck.AboutTime.Fourth": "th",
|
||||||
|
"MaterialDeck.AboutTime.Of": "of"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
"name": "MaterialDeck",
|
"name": "MaterialDeck",
|
||||||
"title": "Material Deck",
|
"title": "Material Deck",
|
||||||
"description": "Material Deck allows you to control Foundry using an Elgato Stream Deck",
|
"description": "Material Deck allows you to control Foundry using an Elgato Stream Deck",
|
||||||
"version": "1.3.0",
|
"version": "1.3.2",
|
||||||
"minimumSDversion": "1.3.0",
|
"minimumSDversion": "1.3.2",
|
||||||
"minimumMSversion": "1.0.2",
|
"minimumMSversion": "1.0.2",
|
||||||
"author": "CDeenen",
|
"author": "CDeenen",
|
||||||
"esmodules": [
|
"esmodules": [
|
||||||
|
|||||||
@@ -44,12 +44,12 @@ export class CombatTracker{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
streamDeck.setIcon(context,src,background);
|
streamDeck.setIcon(context,src,{background:background});
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
streamDeck.setIcon(context,src,background);
|
streamDeck.setIcon(context,src,{background:background});
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ export class CombatTracker{
|
|||||||
tokenControl.pushData(tokenId,settings,context);
|
tokenControl.pushData(tokenId,settings,context);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
streamDeck.setIcon(context,src,background);
|
streamDeck.setIcon(context,src,{background:background});
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,7 +125,7 @@ export class CombatTracker{
|
|||||||
if (txt != "") txt += "\n";
|
if (txt != "") txt += "\n";
|
||||||
if (settings.displayTurn) txt += "Turn\n"+turn;
|
if (settings.displayTurn) txt += "Turn\n"+turn;
|
||||||
}
|
}
|
||||||
streamDeck.setIcon(context,src,background);
|
streamDeck.setIcon(context,src,{background:background});
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,7 +164,7 @@ export class CombatTracker{
|
|||||||
src = "modules/MaterialDeck/img/combattracker/stopcombat.png";
|
src = "modules/MaterialDeck/img/combattracker/stopcombat.png";
|
||||||
background = "#FF0000";
|
background = "#FF0000";
|
||||||
}
|
}
|
||||||
streamDeck.setIcon(context,src,background);
|
streamDeck.setIcon(context,src,{background:background});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (game.combat.started == false) return;
|
if (game.combat.started == false) return;
|
||||||
|
|||||||
241
src/external.js
241
src/external.js
@@ -30,6 +30,7 @@ export class ExternalModules{
|
|||||||
else if (module == 'mookAI') this.updateMookAI(settings,context);
|
else if (module == 'mookAI') this.updateMookAI(settings,context);
|
||||||
else if (module == 'notYourTurn') this.updateNotYourTurn(settings,context);
|
else if (module == 'notYourTurn') this.updateNotYourTurn(settings,context);
|
||||||
else if (module == 'lockView') this.updateLockView(settings,context);
|
else if (module == 'lockView') this.updateLockView(settings,context);
|
||||||
|
else if (module == 'aboutTime') this.updateAboutTime(settings,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPress(settings,context){
|
keyPress(settings,context){
|
||||||
@@ -43,7 +44,7 @@ export class ExternalModules{
|
|||||||
else if (module == 'mookAI') this.keyPressMookAI(settings,context);
|
else if (module == 'mookAI') this.keyPressMookAI(settings,context);
|
||||||
else if (module == 'notYourTurn') this.keyPressNotYourTurn(settings,context);
|
else if (module == 'notYourTurn') this.keyPressNotYourTurn(settings,context);
|
||||||
else if (module == 'lockView') this.keyPressLockView(settings,context);
|
else if (module == 'lockView') this.keyPressLockView(settings,context);
|
||||||
|
else if (module == 'aboutTime') this.keyPressAboutTime(settings,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
getModuleEnable(moduleId){
|
getModuleEnable(moduleId){
|
||||||
@@ -124,8 +125,8 @@ export class ExternalModules{
|
|||||||
name = game.i18n.localize("MaterialDeck.FxMaster.Clear");
|
name = game.i18n.localize("MaterialDeck.FxMaster.Clear");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (displayIcon) streamDeck.setIcon(context,icon,background,ring,ringColor);
|
if (displayIcon) streamDeck.setIcon(context,icon,{background:background,ring:ring,ringColor:ringColor});
|
||||||
else streamDeck.setIcon(context, "", background,ring,ringColor);
|
else streamDeck.setIcon(context, "", {background:background,ring:ring,ringColor:ringColor});
|
||||||
if (displayName == 0) name = "";
|
if (displayName == 0) name = "";
|
||||||
streamDeck.setTitle(name,context);
|
streamDeck.setTitle(name,context);
|
||||||
}
|
}
|
||||||
@@ -269,7 +270,7 @@ export class ExternalModules{
|
|||||||
if (this.gmScreenOpen) ring = 2;
|
if (this.gmScreenOpen) ring = 2;
|
||||||
|
|
||||||
if (settings.displayGmScreenIcon) src = "fas fa-book-reader";
|
if (settings.displayGmScreenIcon) src = "fas fa-book-reader";
|
||||||
streamDeck.setIcon(context,src,background,ring,ringColor);
|
streamDeck.setIcon(context,src,{background:background,ring:ring,ringColor:ringColor});
|
||||||
if (settings.displayGmScreenName) txt = game.i18n.localize(`GMSCR.gmScreen.Open`);
|
if (settings.displayGmScreenName) txt = game.i18n.localize(`GMSCR.gmScreen.Open`);
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
@@ -295,8 +296,8 @@ export class ExternalModules{
|
|||||||
const ringColor = game.settings.get("trigger-happy", "enableTriggers") ? "#A600FF" : "#340057";
|
const ringColor = game.settings.get("trigger-happy", "enableTriggers") ? "#A600FF" : "#340057";
|
||||||
|
|
||||||
let txt = '';
|
let txt = '';
|
||||||
if (displayIcon) streamDeck.setIcon(context,"fas fa-grin-squint-tears",background,2,ringColor);
|
if (displayIcon) streamDeck.setIcon(context,"fas fa-grin-squint-tears",{background:background,ring:2,ringColor:ringColor});
|
||||||
else streamDeck.setIcon(context,'','#000000');
|
else streamDeck.setIcon(context,'',{background:'#000000'});
|
||||||
if (displayName) txt = 'Trigger Happy';
|
if (displayName) txt = 'Trigger Happy';
|
||||||
|
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
@@ -336,8 +337,8 @@ export class ExternalModules{
|
|||||||
const ringColor = game.settings.get("SharedVision", "enable") ? "#A600FF" : "#340057";
|
const ringColor = game.settings.get("SharedVision", "enable") ? "#A600FF" : "#340057";
|
||||||
|
|
||||||
let txt = '';
|
let txt = '';
|
||||||
if (displayIcon) streamDeck.setIcon(context,"fas fa-eye",background,2,ringColor);
|
if (displayIcon) streamDeck.setIcon(context,"fas fa-eye",{background:background,ring:2,ringColor:ringColor});
|
||||||
else streamDeck.setIcon(context,'','#000000');
|
else streamDeck.setIcon(context,'',{background:'#000000'});
|
||||||
if (displayName) txt = 'Shared Vision';
|
if (displayName) txt = 'Shared Vision';
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
@@ -366,8 +367,8 @@ export class ExternalModules{
|
|||||||
const background = "#000000";
|
const background = "#000000";
|
||||||
|
|
||||||
let txt = '';
|
let txt = '';
|
||||||
if (displayIcon) streamDeck.setIcon(context,"fas fa-brain",'#000000');
|
if (displayIcon) streamDeck.setIcon(context,"fas fa-brain",{background:'#000000'});
|
||||||
else streamDeck.setIcon(context,'','#000000');
|
else streamDeck.setIcon(context,'',{background:'#000000'});
|
||||||
if (displayName) txt = 'Mook AI';
|
if (displayName) txt = 'Mook AI';
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
@@ -408,8 +409,8 @@ export class ExternalModules{
|
|||||||
txt = "Block Non-Combat Movement";
|
txt = "Block Non-Combat Movement";
|
||||||
ringColor = game.settings.get('NotYourTurn','nonCombat') ? "#A600FF": "#340057" ;
|
ringColor = game.settings.get('NotYourTurn','nonCombat') ? "#A600FF": "#340057" ;
|
||||||
}
|
}
|
||||||
if (displayIcon) streamDeck.setIcon(context,icon,background,2,ringColor);
|
if (displayIcon) streamDeck.setIcon(context,icon,{background:background,ring:2,ringColor:ringColor});
|
||||||
else streamDeck.setIcon(context,'','#000000');
|
else streamDeck.setIcon(context,'',{background:'#000000'});
|
||||||
if (displayName == false) txt = '';
|
if (displayName == false) txt = '';
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
@@ -431,6 +432,7 @@ export class ExternalModules{
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//Lock View
|
//Lock View
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
updateLockView(settings,context) {
|
updateLockView(settings,context) {
|
||||||
|
|
||||||
if (this.getModuleEnable("LockView") == false) return;
|
if (this.getModuleEnable("LockView") == false) return;
|
||||||
@@ -461,8 +463,8 @@ export class ExternalModules{
|
|||||||
ringColor = canvas.scene.getFlag('LockView', 'boundingBox') ? "#A600FF": "#340057" ;
|
ringColor = canvas.scene.getFlag('LockView', 'boundingBox') ? "#A600FF": "#340057" ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (displayIcon) streamDeck.setIcon(context,icon,background,2,ringColor);
|
if (displayIcon) streamDeck.setIcon(context,icon,{background:background,ring:2,ringColor:ringColor});
|
||||||
else streamDeck.setIcon(context,'','#000000');
|
else streamDeck.setIcon(context,'',{background:'#000000'});
|
||||||
if (displayName == false) txt = '';
|
if (displayName == false) txt = '';
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
@@ -483,6 +485,217 @@ export class ExternalModules{
|
|||||||
|
|
||||||
Hooks.call("setLockView",msg);
|
Hooks.call("setLockView",msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//About Time
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
updateAboutTime(settings,context) {
|
||||||
|
if (this.getModuleEnable("about-time") == false) return;
|
||||||
|
if (game.user.isGM == false) return;
|
||||||
|
|
||||||
|
const displayTime = settings.aboutTimeDisplayTime ? settings.aboutTimeDisplayTime : 'none';
|
||||||
|
const displayDate = settings.aboutTimeDisplayDate ? settings.aboutTimeDisplayDate : 'none';
|
||||||
|
const background = settings.aboutTimeBackground ? settings.aboutTimeBackground : '#000000';
|
||||||
|
const ringOffColor = settings.aboutTimeOffRing ? settings.aboutTimeOffRing : '#000000';
|
||||||
|
const ringOnColor = settings.aboutTimeOnRing ? settings.aboutTimeOnRing : '#00FF00';
|
||||||
|
|
||||||
|
let ring = 0;
|
||||||
|
let ringColor = '#000000';
|
||||||
|
let txt = '';
|
||||||
|
let currentTime = game.Gametime.DTNow().longDateExtended();
|
||||||
|
let clock = 'none';
|
||||||
|
|
||||||
|
if (displayTime == 'clock') {
|
||||||
|
const hours = currentTime.hour > 12 ? currentTime.hour-12 : currentTime.hour;
|
||||||
|
clock = {
|
||||||
|
hours: hours,
|
||||||
|
minutes: currentTime.minute
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (displayTime != 'none') {
|
||||||
|
let hours;
|
||||||
|
let AMPM = "";
|
||||||
|
if ((displayTime == 'compact12h' || displayTime == 'full12h' || displayTime == 'hours12h') && currentTime.hour > 12) {
|
||||||
|
hours = currentTime.hour - 12;
|
||||||
|
AMPM = " PM";
|
||||||
|
}
|
||||||
|
else if ((displayTime == 'compact12h' || displayTime == 'full12h' || displayTime == 'hours12h') && currentTime.hour <= 12) {
|
||||||
|
hours = currentTime.hour;
|
||||||
|
AMPM = " AM";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
hours = currentTime.hour;
|
||||||
|
}
|
||||||
|
if (displayTime == 'hours24h' || displayTime == 'hours12h') txt = hours;
|
||||||
|
else if (displayTime == 'minutes') txt = currentTime.minute;
|
||||||
|
else if (displayTime == 'seconds') txt = currentTime.second;
|
||||||
|
else {
|
||||||
|
if (currentTime.minute < 10) currentTime.minute = '0' + currentTime.minute;
|
||||||
|
if (currentTime.second < 10) currentTime.second = '0' + currentTime.second;
|
||||||
|
txt += hours + ':' + currentTime.minute;
|
||||||
|
if (displayTime == 'full24h' || displayTime == 'full12h') txt += ':' + currentTime.second;
|
||||||
|
}
|
||||||
|
if (displayTime == 'compact12h' || displayTime == 'full12h' || displayTime == 'hours12h') txt += AMPM;
|
||||||
|
}
|
||||||
|
if (displayTime != 'none' && displayTime != 'clock' && displayDate != 'none') txt += '\n';
|
||||||
|
|
||||||
|
if (displayDate == 'day') txt += currentTime.day;
|
||||||
|
else if (displayDate == 'dayName') txt += currentTime.dowString;
|
||||||
|
else if (displayDate == 'month') txt += currentTime.month;
|
||||||
|
else if (displayDate == 'monthName') txt += currentTime.monthString;
|
||||||
|
else if (displayDate == 'year') txt += currentTime.year;
|
||||||
|
else if (displayDate == 'small') txt += currentTime.day + '-' + currentTime.month;
|
||||||
|
else if (displayDate == 'smallInv') txt += currentTime.month + '-' + currentTime.day;
|
||||||
|
else if (displayDate == 'full') txt += currentTime.day + '-' + currentTime.month + '-' + currentTime.year;
|
||||||
|
else if (displayDate == 'fullInv') txt += currentTime.month + '-' + currentTime.day + '-' + currentTime.year;
|
||||||
|
else if (displayDate == 'text' || displayDate == 'textDay') {
|
||||||
|
|
||||||
|
if (displayDate == 'textDay') txt += currentTime.dowString + ' ';
|
||||||
|
txt += currentTime.day;
|
||||||
|
if (currentTime.day % 10 == 1 && currentTime != 11) txt += game.i18n.localize("MaterialDeck.AboutTime.First");
|
||||||
|
else if (currentTime.day % 10 == 2 && currentTime != 12) txt += game.i18n.localize("MaterialDeck.AboutTime.Second");
|
||||||
|
else if (currentTime.day % 10 == 3 && currentTime != 13) txt += game.i18n.localize("MaterialDeck.AboutTime.Third");
|
||||||
|
else txt += game.i18n.localize("MaterialDeck.AboutTime.Fourth");
|
||||||
|
txt += ' ' + game.i18n.localize("MaterialDeck.AboutTime.Of") + ' ' + currentTime.monthString + ', ' + currentTime.year;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (settings.aboutTimeActive) {
|
||||||
|
const clockRunning = game.Gametime.isRunning();
|
||||||
|
ringColor = clockRunning ? ringOnColor : ringOffColor;
|
||||||
|
ring = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
streamDeck.setTitle(txt,context);
|
||||||
|
streamDeck.setIcon(context,'',{background:background,ring:ring,ringColor:ringColor, clock:clock});
|
||||||
|
}
|
||||||
|
|
||||||
|
keyPressAboutTime(settings,context) {
|
||||||
|
if (this.getModuleEnable("about-time") == false) return;
|
||||||
|
if (game.user.isGM == false) return;
|
||||||
|
|
||||||
|
const onClick = settings.aboutTimeOnClick ? settings.aboutTimeOnClick : 'none';
|
||||||
|
if (onClick == 'none') return;
|
||||||
|
else if (onClick == 'startStop') {
|
||||||
|
const clockRunning = game.Gametime.isRunning();
|
||||||
|
const startMode = settings.aboutTimeStartStopMode ? settings.aboutTimeStartStopMode : 'toggle';
|
||||||
|
if ((startMode == 'toggle' && clockRunning) || startMode == 'stop') game.Gametime.stopRunning();
|
||||||
|
else if ((startMode == 'toggle' && !clockRunning) || startMode == 'start') game.Gametime.startRunning();
|
||||||
|
}
|
||||||
|
else if (onClick == 'advance') {
|
||||||
|
const advanceMode = settings.aboutTimeAdvanceMode ? settings.aboutTimeAdvanceMode : 'dawn';
|
||||||
|
let now = Gametime.DTNow();
|
||||||
|
if (advanceMode == 'dawn') {
|
||||||
|
let newDT = now.add({
|
||||||
|
days: now.hours < 7 ? 0 : 1
|
||||||
|
}).setAbsolute({
|
||||||
|
hours: 7,
|
||||||
|
minutes: 0,
|
||||||
|
seconds: 0
|
||||||
|
});
|
||||||
|
Gametime.setAbsolute(newDT);
|
||||||
|
}
|
||||||
|
else if (advanceMode == 'noon') {
|
||||||
|
let newDT = now.add({
|
||||||
|
days: now.hours < 12 ? 0 : 1
|
||||||
|
}).setAbsolute({
|
||||||
|
hours: 12,
|
||||||
|
minutes: 0,
|
||||||
|
seconds: 0
|
||||||
|
});
|
||||||
|
Gametime.setAbsolute(newDT);
|
||||||
|
}
|
||||||
|
else if (advanceMode == 'dusk') {
|
||||||
|
let newDT = now.add({
|
||||||
|
days: now.hours < 20 ? 0 : 1
|
||||||
|
}).setAbsolute({
|
||||||
|
hours: 20,
|
||||||
|
minutes: 0,
|
||||||
|
seconds: 0
|
||||||
|
});
|
||||||
|
Gametime.setAbsolute(newDT);
|
||||||
|
}
|
||||||
|
else if (advanceMode == 'midnight') {
|
||||||
|
let newDT = Gametime.DTNow().add({
|
||||||
|
days: 1
|
||||||
|
}).setAbsolute({
|
||||||
|
hours: 0,
|
||||||
|
minutes: 0,
|
||||||
|
seconds: 0
|
||||||
|
});
|
||||||
|
Gametime.setAbsolute(newDT);
|
||||||
|
}
|
||||||
|
else if (advanceMode == '1s')
|
||||||
|
game.Gametime.advanceClock(1);
|
||||||
|
else if (advanceMode == '30s')
|
||||||
|
game.Gametime.advanceClock(30);
|
||||||
|
|
||||||
|
else if (advanceMode == '1m')
|
||||||
|
game.Gametime.advanceTime({ minutes: 1 });
|
||||||
|
else if (advanceMode == '5m')
|
||||||
|
game.Gametime.advanceTime({ minutes: 5 });
|
||||||
|
else if (advanceMode == '15m')
|
||||||
|
game.Gametime.advanceTime({ minutes: 15 });
|
||||||
|
else if (advanceMode == '1h')
|
||||||
|
game.Gametime.advanceTime({ hours: 1 });
|
||||||
|
}
|
||||||
|
else if (onClick == 'recede') {
|
||||||
|
const advanceMode = settings.aboutTimeAdvanceMode ? settings.aboutTimeAdvanceMode : 'dawn';
|
||||||
|
let now = Gametime.DTNow();
|
||||||
|
if (advanceMode == 'dawn') {
|
||||||
|
let newDT = now.add({
|
||||||
|
days: now.hours < 7 ? -1 : 0
|
||||||
|
}).setAbsolute({
|
||||||
|
hours: 7,
|
||||||
|
minutes: 0,
|
||||||
|
seconds: 0
|
||||||
|
});
|
||||||
|
Gametime.setAbsolute(newDT);
|
||||||
|
}
|
||||||
|
else if (advanceMode == 'noon') {
|
||||||
|
let newDT = now.add({
|
||||||
|
days: now.hours < 12 ? -1 : 0
|
||||||
|
}).setAbsolute({
|
||||||
|
hours: 12,
|
||||||
|
minutes: 0,
|
||||||
|
seconds: 0
|
||||||
|
});
|
||||||
|
Gametime.setAbsolute(newDT);
|
||||||
|
}
|
||||||
|
else if (advanceMode == 'dusk') {
|
||||||
|
let newDT = now.add({
|
||||||
|
days: now.hours < 20 ? -1 : 0
|
||||||
|
}).setAbsolute({
|
||||||
|
hours: 20,
|
||||||
|
minutes: 0,
|
||||||
|
seconds: 0
|
||||||
|
});
|
||||||
|
Gametime.setAbsolute(newDT);
|
||||||
|
}
|
||||||
|
else if (advanceMode == 'midnight') {
|
||||||
|
let newDT = Gametime.DTNow().add({
|
||||||
|
days: -1
|
||||||
|
}).setAbsolute({
|
||||||
|
hours: 0,
|
||||||
|
minutes: 0,
|
||||||
|
seconds: 0
|
||||||
|
});
|
||||||
|
Gametime.setAbsolute(newDT);
|
||||||
|
}
|
||||||
|
else if (advanceMode == '1s')
|
||||||
|
game.Gametime.advanceClock(-1);
|
||||||
|
else if (advanceMode == '30s')
|
||||||
|
game.Gametime.advanceClock(-30);
|
||||||
|
|
||||||
|
else if (advanceMode == '1m')
|
||||||
|
game.Gametime.advanceTime({ minutes: -1 });
|
||||||
|
else if (advanceMode == '5m')
|
||||||
|
game.Gametime.advanceTime({ minutes: -5 });
|
||||||
|
else if (advanceMode == '15m')
|
||||||
|
game.Gametime.advanceTime({ minutes: -15 });
|
||||||
|
else if (advanceMode == '1h')
|
||||||
|
game.Gametime.advanceTime({ hours: -1 });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
24
src/macro.js
24
src/macro.js
@@ -32,6 +32,7 @@ export class MacroControl{
|
|||||||
let name = "";
|
let name = "";
|
||||||
let src = "";
|
let src = "";
|
||||||
let macroId = undefined;
|
let macroId = undefined;
|
||||||
|
let uses = undefined;
|
||||||
|
|
||||||
if (mode == 'macroBoard') { //Macro board
|
if (mode == 'macroBoard') { //Macro board
|
||||||
if ((MODULE.getPermission('MACRO','MACROBOARD') == false )) {
|
if ((MODULE.getPermission('MACRO','MACROBOARD') == false )) {
|
||||||
@@ -83,19 +84,12 @@ export class MacroControl{
|
|||||||
if (macro != undefined) {
|
if (macro != undefined) {
|
||||||
if (displayName) name = macro.name;
|
if (displayName) name = macro.name;
|
||||||
if (displayIcon) src = macro.img;
|
if (displayIcon) src = macro.img;
|
||||||
if (MODULE.hotbarUses && displayUses) {
|
if (MODULE.hotbarUses && displayUses) uses = await this.getUses(macro);
|
||||||
const uses = await this.getUses(macro);
|
|
||||||
if (uses != null){
|
|
||||||
name += '\n(' + uses.available;
|
|
||||||
if (uses.maximum != undefined) name += '/' + uses.maximum;
|
|
||||||
name += ')';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
streamDeck.setIcon(context,src,background,ring,ringColor);
|
streamDeck.setIcon(context,src,{background:background,ring:ring,ringColor:ringColor,uses:uses});
|
||||||
streamDeck.setTitle(name,context);
|
streamDeck.setTitle(name,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,20 +138,14 @@ export class MacroControl{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let macro = undefined;
|
let macro = undefined;
|
||||||
|
let uses = undefined;
|
||||||
if (macroId != undefined) macro = game.macros._source.find(p => p._id == macroId);
|
if (macroId != undefined) macro = game.macros._source.find(p => p._id == macroId);
|
||||||
if (macro != undefined && macro != null) {
|
if (macro != undefined && macro != null) {
|
||||||
if (displayName) name += macro.name;
|
if (displayName) name += macro.name;
|
||||||
if (displayIcon) src += macro.img;
|
if (displayIcon) src += macro.img;
|
||||||
if (MODULE.hotbarUses && displayUses) {
|
if (MODULE.hotbarUses && displayUses) uses = await this.getUses(macro);
|
||||||
const uses = await this.getUses(macro);
|
|
||||||
if (uses != null){
|
|
||||||
name += '\n(' + uses.available;
|
|
||||||
if (uses.maximum != undefined) name += '/' + uses.maximum;
|
|
||||||
name += ')';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
streamDeck.setIcon(context,src,background);
|
streamDeck.setIcon(context,src,{background:background,uses:uses});
|
||||||
streamDeck.setTitle(name,context);
|
streamDeck.setTitle(name,context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
32
src/move.js
32
src/move.js
@@ -49,20 +49,33 @@ export class Move{
|
|||||||
else
|
else
|
||||||
url = "modules/MaterialDeck/img/move/rotateccw.png";
|
url = "modules/MaterialDeck/img/move/rotateccw.png";
|
||||||
}
|
}
|
||||||
streamDeck.setIcon(context,url,background);
|
streamDeck.setIcon(context,url,{background:background});
|
||||||
streamDeck.setTitle('',context);
|
streamDeck.setTitle('',context);
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPress(settings){
|
keyPress(settings){
|
||||||
if (canvas.scene == null) return;
|
if (canvas.scene == null) return;
|
||||||
|
if ((MODULE.getPermission('MOVE','TOKEN') == false && mode == 'selectedToken') || (MODULE.getPermission('MOVE','CANVAS') == false && mode == 'canvas')) {
|
||||||
|
streamDeck.noPermission(context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const dir = settings.dir ? settings.dir : 'center';
|
const dir = settings.dir ? settings.dir : 'center';
|
||||||
const mode = settings.mode ? settings.mode : 'canvas';
|
const mode = settings.mode ? settings.mode : 'canvas';
|
||||||
const type = settings.type ? settings.type : 'move';
|
const type = settings.type ? settings.type : 'move';
|
||||||
|
|
||||||
if ((MODULE.getPermission('MOVE','TOKEN') == false && mode == 'selectedToken') || (MODULE.getPermission('MOVE','CANVAS') == false && mode == 'canvas')) {
|
let token;
|
||||||
streamDeck.noPermission(context);
|
if (mode == 'selectedToken') {
|
||||||
return;
|
const selection = settings.selection ? settings.selection : 'selected';
|
||||||
|
const tokenIdentifier = settings.tokenName ? settings.tokenName : '';
|
||||||
|
|
||||||
|
if (selection == 'selected') token = canvas.tokens.children[0].children.find(p => p.id == MODULE.selectedTokenId);
|
||||||
|
else if (selection != 'selected' && tokenIdentifier == '') {}
|
||||||
|
else if (selection == 'tokenName') token = canvas.tokens.children[0].children.find(p => p.name == tokenIdentifier);
|
||||||
|
else if (selection == 'actorName') token = canvas.tokens.children[0].children.find(p => p.actor.name == tokenIdentifier);
|
||||||
|
else if (selection == 'tokenId') token = canvas.tokens.children[0].children.find(p => p.id == tokenIdentifier);
|
||||||
|
else if (selection == 'actorId') token = canvas.tokens.children[0].children.find(p => p.actor.id == tokenIdentifier);
|
||||||
|
if (token == undefined) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == 'move'){
|
if (type == 'move'){
|
||||||
@@ -80,15 +93,12 @@ export class Move{
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (settings.mode == 'selectedToken')
|
if (settings.mode == 'selectedToken')
|
||||||
this.moveToken(MODULE.selectedTokenId,dir);
|
this.moveToken(token,dir);
|
||||||
else
|
else
|
||||||
this.moveCanvas(dir);
|
this.moveCanvas(dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type == 'rotate' && mode == 'selectedToken'){
|
else if (type == 'rotate' && mode == 'selectedToken'){
|
||||||
const token = canvas.tokens.children[0].children.find(p => p.id == MODULE.selectedTokenId);
|
|
||||||
if (token == undefined) return;
|
|
||||||
|
|
||||||
const rotType = settings.rot ? settings.rot : 'to';
|
const rotType = settings.rot ? settings.rot : 'to';
|
||||||
const value = isNaN(parseInt(settings.rotValue)) ? 0 : parseInt(settings.rotValue);
|
const value = isNaN(parseInt(settings.rotValue)) ? 0 : parseInt(settings.rotValue);
|
||||||
|
|
||||||
@@ -100,9 +110,7 @@ export class Move{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async moveToken(tokenId,dir){
|
async moveToken(token,dir){
|
||||||
if (tokenId == undefined) return;
|
|
||||||
const token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
|
|
||||||
const gridSize = canvas.scene.data.grid;
|
const gridSize = canvas.scene.data.grid;
|
||||||
let x = token.x;
|
let x = token.x;
|
||||||
let y = token.y;
|
let y = token.y;
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ export class OtherControls{
|
|||||||
}
|
}
|
||||||
else if (pauseFunction == 'toggle') //toggle
|
else if (pauseFunction == 'toggle') //toggle
|
||||||
src = 'modules/MaterialDeck/img/other/pause/playpause.png';
|
src = 'modules/MaterialDeck/img/other/pause/playpause.png';
|
||||||
streamDeck.setIcon(context,src,background,2,ringColor,true);
|
streamDeck.setIcon(context,src,{background:background,ring:2,ringColor:ringColor,overlay:true});
|
||||||
streamDeck.setTitle('',context);
|
streamDeck.setTitle('',context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -199,7 +199,7 @@ export class OtherControls{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
streamDeck.setIcon(context,src,background,2,ringColor);
|
streamDeck.setIcon(context,src,{background:background,ring:2,ringColor:ringColor});
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,7 +316,7 @@ export class OtherControls{
|
|||||||
txt += darkness;
|
txt += darkness;
|
||||||
}
|
}
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
streamDeck.setIcon(context,src,background);
|
streamDeck.setIcon(context,src,{background:background});
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPressDarkness(settings) {
|
keyPressDarkness(settings) {
|
||||||
@@ -348,7 +348,7 @@ export class OtherControls{
|
|||||||
if (settings.displayDiceName) txt = 'Roll: ' + settings.rollDiceFormula;
|
if (settings.displayDiceName) txt = 'Roll: ' + settings.rollDiceFormula;
|
||||||
|
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
streamDeck.setIcon(context,'',background);
|
streamDeck.setIcon(context,'',{background:background});
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPressRollDice(settings,context){
|
keyPressRollDice(settings,context){
|
||||||
@@ -398,7 +398,7 @@ export class OtherControls{
|
|||||||
}
|
}
|
||||||
|
|
||||||
const background = settings.background ? settings.background : '#000000';
|
const background = settings.background ? settings.background : '#000000';
|
||||||
const table = game.tables.entities.find(p=>p.name == name);
|
const table = game.tables.getName(name);
|
||||||
|
|
||||||
let txt = settings.displayRollName ? table.name : '';
|
let txt = settings.displayRollName ? table.name : '';
|
||||||
let src = settings.displayRollIcon ? table.data.img : '';
|
let src = settings.displayRollIcon ? table.data.img : '';
|
||||||
@@ -415,7 +415,7 @@ export class OtherControls{
|
|||||||
}
|
}
|
||||||
|
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
streamDeck.setIcon(context,src,background);
|
streamDeck.setIcon(context,src,{background:background});
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPressRollTable(settings){
|
keyPressRollTable(settings){
|
||||||
@@ -424,7 +424,7 @@ export class OtherControls{
|
|||||||
if (name == undefined) return;
|
if (name == undefined) return;
|
||||||
|
|
||||||
const func = settings.rolltableFunction ? settings.rolltableFunction : 'open';
|
const func = settings.rolltableFunction ? settings.rolltableFunction : 'open';
|
||||||
const table = game.tables.entities.find(p=>p.name == name);
|
const table = game.tables.getName(name);
|
||||||
|
|
||||||
if (table != undefined) {
|
if (table != undefined) {
|
||||||
if (table.permission < 2 && MODULE.getPermission('OTHER','TABLES_ALL') == false ) return;
|
if (table.permission < 2 && MODULE.getPermission('OTHER','TABLES_ALL') == false ) return;
|
||||||
@@ -489,7 +489,7 @@ export class OtherControls{
|
|||||||
const icon = settings.displaySidebarIcon ? this.getSidebarIcon(sidebarTab) : '';
|
const icon = settings.displaySidebarIcon ? this.getSidebarIcon(sidebarTab) : '';
|
||||||
|
|
||||||
streamDeck.setTitle(name,context);
|
streamDeck.setTitle(name,context);
|
||||||
streamDeck.setIcon(context,icon,background,2,ringColor);
|
streamDeck.setIcon(context,icon,{background:background,ring:2,ringColor:ringColor});
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPressSidebar(settings){
|
keyPressSidebar(settings){
|
||||||
@@ -527,7 +527,7 @@ export class OtherControls{
|
|||||||
const txt = settings.displayCompendiumName ? name : '';
|
const txt = settings.displayCompendiumName ? name : '';
|
||||||
|
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
streamDeck.setIcon(context,"",background,2,ringColor);
|
streamDeck.setIcon(context,"",{background:background,ring:2,ringColor:ringColor});
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPressCompendium(settings){
|
keyPressCompendium(settings){
|
||||||
@@ -567,7 +567,7 @@ export class OtherControls{
|
|||||||
const txt = settings.displayCompendiumName ? name : '';
|
const txt = settings.displayCompendiumName ? name : '';
|
||||||
|
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
streamDeck.setIcon(context,"",background,2,ringColor);
|
streamDeck.setIcon(context,"",{background:background,ring:2,ringColor:ringColor});
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPressJournal(settings){
|
keyPressJournal(settings){
|
||||||
@@ -594,7 +594,7 @@ export class OtherControls{
|
|||||||
}
|
}
|
||||||
const background = settings.background ? settings.background : '#000000';
|
const background = settings.background ? settings.background : '#000000';
|
||||||
streamDeck.setTitle("",context);
|
streamDeck.setTitle("",context);
|
||||||
streamDeck.setIcon(context,"",background);
|
streamDeck.setIcon(context,"",{background:background});
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPressChatMessage(settings){
|
keyPressChatMessage(settings){
|
||||||
|
|||||||
107
src/playlist.js
107
src/playlist.js
@@ -23,38 +23,32 @@ export class PlaylistControl{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.active = true;
|
this.active = true;
|
||||||
if (settings.playlistMode == undefined) settings.playlistMode = 'playlist';
|
const mode = settings.playlistMode ? settings.playlistMode : 'playlist';
|
||||||
if (settings.playlistMode == 'playlist'){
|
|
||||||
|
if (mode == 'playlist'){
|
||||||
this.updatePlaylist(settings,context);
|
this.updatePlaylist(settings,context);
|
||||||
}
|
}
|
||||||
else if (settings.playlistMode == 'track'){
|
else if (mode == 'track'){
|
||||||
this.updateTrack(settings,context);
|
this.updateTrack(settings,context);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let src = 'modules/MaterialDeck/img/playlist/stop.png';
|
const src = 'modules/MaterialDeck/img/playlist/stop.png';
|
||||||
if (game.playlists.playing.length > 0)
|
const background = settings.background ? settings.background : '#000000';
|
||||||
streamDeck.setIcon(context,src,settings.background,2,'#00FF00',true);
|
const ringColor = (game.playlists.playing.length > 0) ? '#00FF00' : '#000000';
|
||||||
else
|
const ring = (game.playlists.playing.length > 0) ? 2 : 1;
|
||||||
streamDeck.setIcon(context,src,settings.background,1,'#000000',true);
|
const txt = settings.displayPlaylistName ? this.getPlaylist(this.playlistOffset).name : '';
|
||||||
|
streamDeck.setIcon(context,src,{background:background,ring:ring,ringColor:ringColor,overlay:true});
|
||||||
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePlaylist(settings,context){
|
updatePlaylist(settings,context){
|
||||||
let name = "";
|
let name = "";
|
||||||
|
|
||||||
let background = settings.background;
|
|
||||||
if(background == undefined) background = '#000000';
|
|
||||||
|
|
||||||
let ringColor = "#000000"
|
let ringColor = "#000000"
|
||||||
|
const background = settings.background ? settings.background : '#000000';
|
||||||
let ringOffColor = settings.offRing;
|
const ringOffColor = settings.offRing ? settings.offRing : '#FF0000';
|
||||||
if (ringOffColor == undefined) ringOffColor = '#FF0000';
|
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
|
||||||
|
const playlistType = settings.playlistType ? settings.playlistType : 'playStop';
|
||||||
let ringOnColor = settings.onRing;
|
|
||||||
if (ringOnColor == undefined) ringOnColor = '#00FF00';
|
|
||||||
|
|
||||||
let playlistType = settings.playlistType;
|
|
||||||
if (playlistType == undefined) playlistType = 'playStop';
|
|
||||||
|
|
||||||
//Play/Stop
|
//Play/Stop
|
||||||
if (playlistType == 'playStop'){
|
if (playlistType == 'playStop'){
|
||||||
@@ -79,26 +73,28 @@ export class PlaylistControl{
|
|||||||
if (isNaN(playlistOffset)) playlistOffset = 0;
|
if (isNaN(playlistOffset)) playlistOffset = 0;
|
||||||
if (playlistOffset == this.playlistOffset) ringColor = ringOnColor;
|
if (playlistOffset == this.playlistOffset) ringColor = ringOnColor;
|
||||||
}
|
}
|
||||||
streamDeck.setIcon(context,"",background,2,ringColor);
|
//Relative Offset
|
||||||
|
else if (playlistType == 'relativeOffset') {
|
||||||
|
let playlistOffset = parseInt(settings.offset);
|
||||||
|
if (isNaN(playlistOffset)) playlistOffset = 0;
|
||||||
|
let number = parseInt(this.playlistOffset + playlistOffset);
|
||||||
|
const nrOfPlaylists = parseInt(game.settings.get(MODULE.moduleName,'playlists').playlistNumber);
|
||||||
|
if (number < 0) number += nrOfPlaylists;
|
||||||
|
else if (number >= nrOfPlaylists) number -= nrOfPlaylists;
|
||||||
|
const targetPlaylist = this.getPlaylist(number);
|
||||||
|
if (targetPlaylist != undefined) name = targetPlaylist.name;
|
||||||
|
}
|
||||||
|
streamDeck.setIcon(context,"",{background:background,ring:2,ringColor:ringColor});
|
||||||
streamDeck.setTitle(name,context);
|
streamDeck.setTitle(name,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTrack(settings,context){
|
updateTrack(settings,context){
|
||||||
let name = "";
|
let name = "";
|
||||||
|
|
||||||
let background = settings.background;
|
|
||||||
if(background == undefined) background = '#000000';
|
|
||||||
|
|
||||||
let ringColor = "#000000"
|
let ringColor = "#000000"
|
||||||
|
const background = settings.background ? settings.background : '#000000';
|
||||||
let ringOffColor = settings.offRing;
|
const ringOffColor = settings.offRing ? settings.offRing : '#FF0000';
|
||||||
if (ringOffColor == undefined) ringOffColor = '#FF0000';
|
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
|
||||||
|
const playlistType = settings.playlistType ? settings.playlistType : 'playStop';
|
||||||
let ringOnColor = settings.onRing;
|
|
||||||
if (ringOnColor == undefined) ringOnColor = '#00FF00';
|
|
||||||
|
|
||||||
let playlistType = settings.playlistType;
|
|
||||||
if (playlistType == undefined) playlistType = 'playStop';
|
|
||||||
|
|
||||||
//Play/Stop
|
//Play/Stop
|
||||||
if (playlistType == 'playStop'){
|
if (playlistType == 'playStop'){
|
||||||
@@ -125,12 +121,15 @@ export class PlaylistControl{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Offset
|
//Offset
|
||||||
else {
|
else if (playlistType == 'offset') {
|
||||||
let trackOffset = parseInt(settings.offset);
|
let trackOffset = parseInt(settings.offset);
|
||||||
if (isNaN(trackOffset)) trackOffset = 0;
|
if (isNaN(trackOffset)) trackOffset = 0;
|
||||||
if (trackOffset == this.trackOffset) ringColor = ringOnColor;
|
if (trackOffset == this.trackOffset) ringColor = ringOnColor;
|
||||||
}
|
}
|
||||||
streamDeck.setIcon(context,"",background,2,ringColor);
|
//Relative Offset
|
||||||
|
else if (playlistType == 'relativeOffset') {
|
||||||
|
}
|
||||||
|
streamDeck.setIcon(context,"",{background:background,ring:2,ringColor:ringColor});
|
||||||
streamDeck.setTitle(name,context);
|
streamDeck.setTitle(name,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,16 +178,17 @@ export class PlaylistControl{
|
|||||||
trackNr--;
|
trackNr--;
|
||||||
trackNr += this.trackOffset;
|
trackNr += this.trackOffset;
|
||||||
|
|
||||||
if (settings.playlistMode == undefined) settings.playlistMode = 'playlist';
|
const playlistMode = settings.playlistMode ? settings.playlistMode : 'playlist';
|
||||||
if (settings.playlistType == undefined) settings.playlistType = 'playStop';
|
const playlistType = settings.playlistType ? settings.playlistType : 'playStop';
|
||||||
if (settings.playlistMode == 'stopAll') {
|
|
||||||
|
if (playlistMode == 'stopAll') {
|
||||||
this.stopAll(true);
|
this.stopAll(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (settings.playlistType == 'playStop') {
|
if (playlistType == 'playStop') {
|
||||||
let playlist = this.getPlaylist(playlistNr);
|
let playlist = this.getPlaylist(playlistNr);
|
||||||
if (playlist != undefined){
|
if (playlist != undefined){
|
||||||
if (settings.playlistMode == 'playlist')
|
if (playlistMode == 'playlist')
|
||||||
this.playPlaylist(playlist,playlistNr);
|
this.playPlaylist(playlist,playlistNr);
|
||||||
else {
|
else {
|
||||||
let track = playlist.data.sounds[trackNr];
|
let track = playlist.data.sounds[trackNr];
|
||||||
@@ -198,17 +198,34 @@ export class PlaylistControl{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else if (playlistType == 'offset'){
|
||||||
if (settings.playlistMode == 'playlist') {
|
if (playlistMode == 'playlist') {
|
||||||
this.playlistOffset = parseInt(settings.offset);
|
this.playlistOffset = parseInt(settings.offset);
|
||||||
if (isNaN(this.playlistOffset)) this.playlistOffset = 0;
|
if (isNaN(this.playlistOffset)) this.playlistOffset = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.trackOffset = parseInt(settings.offset);
|
this.trackOffset = parseInt(settings.offset);
|
||||||
if (isNaN(this.trackOffset)) this.trackOffset = 0;
|
if (isNaN(this.trackOffset)) this.trackOffset = 0;
|
||||||
}
|
}
|
||||||
this.updateAll();
|
this.updateAll();
|
||||||
}
|
}
|
||||||
|
else if (playlistType == 'relativeOffset'){
|
||||||
|
if (playlistMode == 'playlist') {
|
||||||
|
let playlistOffset = parseInt(settings.offset);
|
||||||
|
if (isNaN(playlistOffset)) playlistOffset = 0;
|
||||||
|
let number = parseInt(this.playlistOffset + playlistOffset);
|
||||||
|
const nrOfPlaylists = parseInt(game.settings.get(MODULE.moduleName,'playlists').playlistNumber);
|
||||||
|
if (number < 0) number += nrOfPlaylists;
|
||||||
|
else if (number >= nrOfPlaylists) number -= nrOfPlaylists;
|
||||||
|
this.playlistOffset = number;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let value = parseInt(settings.offset);
|
||||||
|
if (isNaN(value)) return;
|
||||||
|
this.trackOffset += value;
|
||||||
|
}
|
||||||
|
this.updateAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ export class SceneControl{
|
|||||||
else ringColor = ringOffColor;
|
else ringColor = ringOffColor;
|
||||||
}
|
}
|
||||||
streamDeck.setTitle(name,context);
|
streamDeck.setTitle(name,context);
|
||||||
streamDeck.setIcon(context,src,background,ring,ringColor);
|
streamDeck.setIcon(context,src,{background:background,ring:ring,ringColor:ringColor});
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPress(settings){
|
keyPress(settings){
|
||||||
|
|||||||
@@ -60,11 +60,13 @@ const defaultUserPermissions = {
|
|||||||
VISION: [false,true,true,true],
|
VISION: [false,true,true,true],
|
||||||
WILDCARD: [false,true,true,true],
|
WILDCARD: [false,true,true,true],
|
||||||
CONDITIONS: [false,true,true,true],
|
CONDITIONS: [false,true,true,true],
|
||||||
CUSTOM: [false,false,true,true]
|
CUSTOM: [false,false,true,true],
|
||||||
|
NON_OWNED: [false,false,true,true],
|
||||||
|
OBSERVER: [false,true,true,true]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const registerSettings = function() {
|
export const registerSettings = async function() {
|
||||||
/**
|
/**
|
||||||
* Main settings
|
* Main settings
|
||||||
*/
|
*/
|
||||||
@@ -75,7 +77,7 @@ export const registerSettings = function() {
|
|||||||
name: "MaterialDeck.Sett.Enable",
|
name: "MaterialDeck.Sett.Enable",
|
||||||
scope: "client",
|
scope: "client",
|
||||||
config: true,
|
config: true,
|
||||||
default: true,
|
default: false,
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
onChange: x => window.location.reload()
|
onChange: x => window.location.reload()
|
||||||
});
|
});
|
||||||
@@ -195,6 +197,21 @@ export const registerSettings = function() {
|
|||||||
type: soundboardConfigForm,
|
type: soundboardConfigForm,
|
||||||
restricted: false
|
restricted: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let permissionSettings = game.settings.get(MODULE.moduleName,'userPermission');
|
||||||
|
if (permissionSettings == undefined || permissionSettings == null || MODULE.isEmpty(permissionSettings)) {
|
||||||
|
permissionSettings = {
|
||||||
|
enable: defaultEnable,
|
||||||
|
permissions: defaultUserPermissions
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (permissionSettings.permissions.TOKEN.NON_OWNED == undefined) permissionSettings.permissions.TOKEN.NON_OWNED = [false,false,true,true];
|
||||||
|
if (permissionSettings.permissions.TOKEN.OBSERVER == undefined) permissionSettings.permissions.TOKEN.OBSERVER = [false,true,true,true];
|
||||||
|
}
|
||||||
|
game.settings.set(MODULE.moduleName,'userPermission',permissionSettings);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class helpMenu extends FormApplication {
|
export class helpMenu extends FormApplication {
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ export class SoundboardControl{
|
|||||||
if (settings.displayIcon && soundboardSettings.img != undefined) src = soundboardSettings.img[soundNr];
|
if (settings.displayIcon && soundboardSettings.img != undefined) src = soundboardSettings.img[soundNr];
|
||||||
|
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
streamDeck.setIcon(context,src,background,2,ringColor);
|
streamDeck.setIcon(context,src,{background:background,ring:2,ringColor:ringColor});
|
||||||
}
|
}
|
||||||
else if (mode == 'offset') { //Offset
|
else if (mode == 'offset') { //Offset
|
||||||
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
|
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
|
||||||
@@ -57,18 +57,19 @@ export class SoundboardControl{
|
|||||||
else ringColor = ringOffColor;
|
else ringColor = ringOffColor;
|
||||||
|
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
streamDeck.setIcon(context,"",background,2,ringColor);
|
streamDeck.setIcon(context,"",{background:background,ring:2,ringColor:ringColor});
|
||||||
}
|
}
|
||||||
else if (mode == 'stopAll') { //Stop all sounds
|
else if (mode == 'stopAll') { //Stop all sounds
|
||||||
let src = 'modules/MaterialDeck/img/playlist/stop.png';
|
let src = 'modules/MaterialDeck/img/playlist/stop.png';
|
||||||
let soundPlaying = false;
|
let soundPlaying = false;
|
||||||
|
const background = settings.background ? settings.background : '#000000';
|
||||||
for (let i=0; i<this.activeSounds.length; i++)
|
for (let i=0; i<this.activeSounds.length; i++)
|
||||||
if (this.activeSounds[i])
|
if (this.activeSounds[i])
|
||||||
soundPlaying = true;
|
soundPlaying = true;
|
||||||
if (soundPlaying)
|
if (soundPlaying)
|
||||||
streamDeck.setIcon(context,src,settings.background,2,'#00FF00',true);
|
streamDeck.setIcon(context,src,{background:background,ring:2,ringColor:'#00FF00',overlay:true});
|
||||||
else
|
else
|
||||||
streamDeck.setIcon(context,src,settings.background,1,'#000000',true);
|
streamDeck.setIcon(context,src,{background:background,ring:1,ringColor:'#000000',overlay:true});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export class StreamDeck{
|
|||||||
this.tokenNameContext;
|
this.tokenNameContext;
|
||||||
this.tokenACContext;
|
this.tokenACContext;
|
||||||
this.buttonContext = [];
|
this.buttonContext = [];
|
||||||
for (let i=0; i<23; i++){
|
for (let i=0; i<31; i++){
|
||||||
this.buttonContext[i] = undefined;
|
this.buttonContext[i] = undefined;
|
||||||
}
|
}
|
||||||
this.playlistTrackBuffer = [];
|
this.playlistTrackBuffer = [];
|
||||||
@@ -206,18 +206,26 @@ export class StreamDeck{
|
|||||||
MODULE.sendWS(JSON.stringify(json));
|
MODULE.sendWS(JSON.stringify(json));
|
||||||
}
|
}
|
||||||
|
|
||||||
setIcon(context,src='',background = '#000000',ring=0,ringColor = "#000000",overlay=false){
|
setIcon(context,src='',options = {}){
|
||||||
if (src == null || src == undefined) src = '';
|
if (src == null || src == undefined) src = '';
|
||||||
if (src == '') src = 'modules/MaterialDeck/img/black.png';
|
if (src == '') src = 'modules/MaterialDeck/img/black.png';
|
||||||
|
let background = options.background ? options.background : '#000000';
|
||||||
|
let ring = options.ring ? options.ring : 0;
|
||||||
|
let ringColor = options.ringColor ? options.ringColor : '#000000';
|
||||||
|
let overlay = options.overlay ? options.overlay : false;
|
||||||
|
let uses = options.uses ? options.uses : undefined;
|
||||||
|
let clock = options.clock ? options.clock : false;
|
||||||
for (let i=0; i<32; i++){
|
for (let i=0; i<32; i++){
|
||||||
|
if (clock != false) break;
|
||||||
if (this.buttonContext[i] == undefined) continue;
|
if (this.buttonContext[i] == undefined) continue;
|
||||||
if (this.buttonContext[i].context == context) {
|
if (this.buttonContext[i].context == context) {
|
||||||
if (this.buttonContext[i].icon == src && this.buttonContext[i].ring == ring && this.buttonContext[i].ringColor == ringColor && this.buttonContext[i].background == background)
|
if (this.buttonContext[i].icon == src && this.buttonContext[i].ring == ring && this.buttonContext[i].ringColor == ringColor && this.buttonContext[i].background == background && this.buttonContext[i].uses == uses)
|
||||||
return;
|
return;
|
||||||
this.buttonContext[i].icon = src;
|
this.buttonContext[i].icon = src;
|
||||||
this.buttonContext[i].ring = ring;
|
this.buttonContext[i].ring = ring;
|
||||||
this.buttonContext[i].ringColor = ringColor;
|
this.buttonContext[i].ringColor = ringColor;
|
||||||
this.buttonContext[i].background = background;
|
this.buttonContext[i].background = background;
|
||||||
|
this.buttonContext[i].uses = uses;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const data = {
|
const data = {
|
||||||
@@ -225,9 +233,11 @@ export class StreamDeck{
|
|||||||
background:background,
|
background:background,
|
||||||
ring:ring,
|
ring:ring,
|
||||||
ringColor:ringColor,
|
ringColor:ringColor,
|
||||||
overlay:overlay
|
overlay:overlay,
|
||||||
|
uses:uses,
|
||||||
|
options:options
|
||||||
}
|
}
|
||||||
const imgBuffer = this.checkImageBuffer(data);
|
const imgBuffer = (clock == false) ? this.checkImageBuffer(data) : false;
|
||||||
if (imgBuffer != false) {
|
if (imgBuffer != false) {
|
||||||
this.setBufferImage(context,imgBuffer,this.getImageBufferId(data))
|
this.setBufferImage(context,imgBuffer,this.getImageBufferId(data))
|
||||||
return;
|
return;
|
||||||
@@ -247,7 +257,9 @@ export class StreamDeck{
|
|||||||
background: background,
|
background: background,
|
||||||
ring: ring,
|
ring: ring,
|
||||||
ringColor: ringColor,
|
ringColor: ringColor,
|
||||||
overlay: overlay
|
overlay: overlay,
|
||||||
|
uses:uses,
|
||||||
|
options:options
|
||||||
};
|
};
|
||||||
this.getImage(msg);
|
this.getImage(msg);
|
||||||
}
|
}
|
||||||
@@ -299,12 +311,11 @@ export class StreamDeck{
|
|||||||
getImage(data){
|
getImage(data){
|
||||||
if (data == undefined)
|
if (data == undefined)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const context = data.context;
|
const context = data.context;
|
||||||
var url = data.url;
|
var url = data.url;
|
||||||
const format = data.format;
|
const format = data.format;
|
||||||
var background = data.background;
|
var background = data.background;
|
||||||
|
const uses = data.uses;
|
||||||
let BGvalid = true;
|
let BGvalid = true;
|
||||||
if (background.length != 7) BGvalid = false;
|
if (background.length != 7) BGvalid = false;
|
||||||
if (background[0] != '#') BGvalid = false;
|
if (background[0] != '#') BGvalid = false;
|
||||||
@@ -328,7 +339,8 @@ export class StreamDeck{
|
|||||||
ctx.filter = "none";
|
ctx.filter = "none";
|
||||||
|
|
||||||
let margin = 0;
|
let margin = 0;
|
||||||
|
ctx.fillStyle = background;
|
||||||
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
if (data.ring != undefined && data.ring > 0){
|
if (data.ring != undefined && data.ring > 0){
|
||||||
ctx.fillStyle = background;
|
ctx.fillStyle = background;
|
||||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
@@ -341,8 +353,7 @@ export class StreamDeck{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ctx.fillStyle = background;
|
|
||||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
||||||
}
|
}
|
||||||
if (format == 'icon' && url != ""){
|
if (format == 'icon' && url != ""){
|
||||||
ctx.font = '600 90px "Font Awesome 5 Free"';
|
ctx.font = '600 90px "Font Awesome 5 Free"';
|
||||||
@@ -400,6 +411,76 @@ export class StreamDeck{
|
|||||||
yStart = 0;
|
yStart = 0;
|
||||||
}
|
}
|
||||||
ctx.drawImage(img, xStart+margin, yStart+margin, renderableWidth - 2*margin, renderableHeight - 2*margin);
|
ctx.drawImage(img, xStart+margin, yStart+margin, renderableWidth - 2*margin, renderableHeight - 2*margin);
|
||||||
|
if (uses != undefined && (uses.available > 0 || uses.maximum != undefined)) {
|
||||||
|
let txt = uses.available;
|
||||||
|
if (uses.maximum != undefined) txt = uses.available + '/' + uses.maximum;
|
||||||
|
if (uses.maximum == undefined ) uses.maximum = 1;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.lineWidth = 4;
|
||||||
|
let green = Math.ceil(255*(uses.available/uses.maximum));
|
||||||
|
let red = 255-green;
|
||||||
|
green = green.toString(16);
|
||||||
|
if (green.length == 1) green = "0"+green;
|
||||||
|
red = red.toString(16);
|
||||||
|
if (red.length == 1) red = "0"+red;
|
||||||
|
if (uses.available == 0) ctx.strokeStyle = "#c80000";
|
||||||
|
else ctx.strokeStyle = "#"+red.toString(16)+green.toString(16)+"00";
|
||||||
|
const rect = {height:35, paddingSides:20, paddingBottom: 4}
|
||||||
|
ctx.rect(rect.paddingSides, 144-rect.height-rect.paddingBottom,144-2*rect.paddingSides,rect.height);
|
||||||
|
ctx.globalAlpha = 0.5;
|
||||||
|
ctx.fillRect(rect.paddingSides, 144-rect.height-rect.paddingBottom,144-2*rect.paddingSides,rect.height);
|
||||||
|
ctx.globalAlpha = 1;
|
||||||
|
ctx.fillStyle = "white";
|
||||||
|
ctx.font = "24px Arial";
|
||||||
|
ctx.fillText(txt, (canvas.width - ctx.measureText(txt).width) / 2, 144-rect.height-rect.paddingBottom+25);
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.options.clock != undefined) {
|
||||||
|
if (data.options.clock != false && data.options.clock != 'none') {
|
||||||
|
const hourAngle = (data.options.clock.hours+data.options.clock.minutes/60)*Math.PI/6;
|
||||||
|
const minuteAngle = data.options.clock.minutes*Math.PI/30;
|
||||||
|
|
||||||
|
ctx.translate(72,72);
|
||||||
|
//Draw outer circle
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.lineWidth = 6;
|
||||||
|
ctx.strokeStyle = "gray";
|
||||||
|
ctx.arc(0,0, 50, 0, 2 * Math.PI);
|
||||||
|
ctx.stroke();
|
||||||
|
|
||||||
|
//Draw hour marks
|
||||||
|
ctx.fillStyle = "gray";
|
||||||
|
ctx.beginPath();
|
||||||
|
for (let i=0; i<12; i++) {
|
||||||
|
ctx.fillRect(-2,40,4,10);
|
||||||
|
const angle = 2*Math.PI/12;
|
||||||
|
ctx.rotate(angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Draw hour arm
|
||||||
|
|
||||||
|
ctx.rotate(Math.PI + hourAngle);
|
||||||
|
ctx.rotate(0);
|
||||||
|
ctx.fillRect(-4,0,8,30);
|
||||||
|
ctx.stroke();
|
||||||
|
// ctx.rotate 8*Math.PI/12;
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.rotate(-hourAngle + minuteAngle);
|
||||||
|
ctx.fillStyle = "lightgray";
|
||||||
|
ctx.fillRect(-2,0,4,40);
|
||||||
|
ctx.rotate(2*Math.PI/12);
|
||||||
|
ctx.stroke();
|
||||||
|
|
||||||
|
//Draw inner circle
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(0,0, 5, 0, 2 * Math.PI);
|
||||||
|
ctx.fill();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var dataURL = canvas.toDataURL();
|
var dataURL = canvas.toDataURL();
|
||||||
canvas.remove();
|
canvas.remove();
|
||||||
const nr = this.addToImageBuffer(dataURL,data);
|
const nr = this.addToImageBuffer(dataURL,data);
|
||||||
@@ -409,7 +490,7 @@ export class StreamDeck{
|
|||||||
}
|
}
|
||||||
|
|
||||||
getImageBufferId(data){
|
getImageBufferId(data){
|
||||||
return data.url+data.background+data.ring+data.ringColor+data.overlay;
|
return data.url+data.background+data.ring+data.ringColor+data.overlay+data.uses?.available+data.uses?.maximum;
|
||||||
}
|
}
|
||||||
|
|
||||||
addToImageBuffer(img,data){
|
addToImageBuffer(img,data){
|
||||||
@@ -449,7 +530,7 @@ export class StreamDeck{
|
|||||||
const url = 'modules/MaterialDeck/img/black.png';
|
const url = 'modules/MaterialDeck/img/black.png';
|
||||||
const background = '#000000';
|
const background = '#000000';
|
||||||
const txt = showTxt ? 'no\npermission' : '';
|
const txt = showTxt ? 'no\npermission' : '';
|
||||||
this.setIcon(context,url,background);
|
this.setIcon(context,url,{background:background});
|
||||||
this.setTitle(txt,context);
|
this.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
123
src/token.js
123
src/token.js
@@ -7,7 +7,7 @@ export class TokenControl{
|
|||||||
this.wildcardOffset = 0;
|
this.wildcardOffset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
async update(tokenId){
|
async update(tokenId=null){
|
||||||
if (this.active == false) return;
|
if (this.active == false) return;
|
||||||
for (let i=0; i<32; i++){
|
for (let i=0; i<32; i++){
|
||||||
const data = streamDeck.buttonContext[i];
|
const data = streamDeck.buttonContext[i];
|
||||||
@@ -21,17 +21,38 @@ export class TokenControl{
|
|||||||
const icon = settings.displayIcon ? settings.displayIcon : false;
|
const icon = settings.displayIcon ? settings.displayIcon : false;
|
||||||
const background = settings.background ? settings.background : "#000000";
|
const background = settings.background ? settings.background : "#000000";
|
||||||
let stats = settings.stats ? settings.stats : 'none';
|
let stats = settings.stats ? settings.stats : 'none';
|
||||||
|
const selection = settings.selection ? settings.selection : 'selected';
|
||||||
|
const tokenIdentifier = settings.tokenName ? settings.tokenName : '';
|
||||||
|
|
||||||
|
let validToken = false;
|
||||||
|
let token;
|
||||||
|
if (selection == 'selected') token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
|
||||||
|
else if (selection != 'selected' && tokenIdentifier == '') {}
|
||||||
|
else if (selection == 'tokenName') token = canvas.tokens.children[0].children.find(p => p.name == tokenIdentifier);
|
||||||
|
else if (selection == 'actorName') token = canvas.tokens.children[0].children.find(p => p.actor.name == tokenIdentifier);
|
||||||
|
else if (selection == 'tokenId') token = canvas.tokens.children[0].children.find(p => p.id == tokenIdentifier);
|
||||||
|
else if (selection == 'actorId') token = canvas.tokens.children[0].children.find(p => p.actor.id == tokenIdentifier);
|
||||||
|
|
||||||
|
if (token != undefined) validToken = true;
|
||||||
|
|
||||||
let tokenName = "";
|
let tokenName = "";
|
||||||
let txt = "";
|
let txt = "";
|
||||||
let iconSrc = "";
|
let iconSrc = "";
|
||||||
let overlay = false;
|
let overlay = false;
|
||||||
let statsOld;
|
let statsOld;
|
||||||
if (tokenId != undefined) {
|
let uses = undefined;
|
||||||
const token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
|
if (validToken) {
|
||||||
|
if (token.owner == false && token.observer == true && MODULE.getPermission('TOKEN','OBSERVER') == false ) {
|
||||||
|
streamDeck.noPermission(context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (token.owner == false && token.observer == false && MODULE.getPermission('TOKEN','NON_OWNED') == false ) {
|
||||||
|
streamDeck.noPermission(context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tokenName = token.data.name;
|
tokenName = token.data.name;
|
||||||
if (name) txt += tokenName;
|
if (name) txt += tokenName;
|
||||||
if (name && stats != 'none') txt += "\n";
|
|
||||||
|
|
||||||
const permission = token.actor?.permission;
|
const permission = token.actor?.permission;
|
||||||
if (settings.combat){
|
if (settings.combat){
|
||||||
@@ -49,8 +70,8 @@ export class TokenControl{
|
|||||||
stats = 'none';
|
stats = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
iconSrc = token.data.img;
|
if (icon) iconSrc = token.data.img;
|
||||||
|
if (name && stats != 'none' && stats != 'HPbox') txt += "\n";
|
||||||
if (stats == 'custom'){
|
if (stats == 'custom'){
|
||||||
const custom = settings.custom ? settings.custom : '';
|
const custom = settings.custom ? settings.custom : '';
|
||||||
let split = custom.split('[');
|
let split = custom.split('[');
|
||||||
@@ -74,6 +95,12 @@ export class TokenControl{
|
|||||||
if (stats == 'HP') {
|
if (stats == 'HP') {
|
||||||
txt += attributes.hp.value + "/" + attributes.hp.max;
|
txt += attributes.hp.value + "/" + attributes.hp.max;
|
||||||
}
|
}
|
||||||
|
else if (stats == 'HPbox') {
|
||||||
|
uses = {
|
||||||
|
available: attributes.hp.value,
|
||||||
|
maximum: attributes.hp.max
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (stats == 'TempHP') {
|
else if (stats == 'TempHP') {
|
||||||
txt += attributes.hp.temp;
|
txt += attributes.hp.temp;
|
||||||
if (attributes.hp.tempmax != null)
|
if (attributes.hp.tempmax != null)
|
||||||
@@ -114,10 +141,30 @@ export class TokenControl{
|
|||||||
else if (stats == 'Init') txt += attributes.init.total;
|
else if (stats == 'Init') txt += attributes.init.total;
|
||||||
else if (stats == 'PassivePerception') txt += token.actor.data.data.skills.prc.passive;
|
else if (stats == 'PassivePerception') txt += token.actor.data.data.skills.prc.passive;
|
||||||
else if (stats == 'PassiveInvestigation') txt += token.actor.data.data.skills.inv.passive;
|
else if (stats == 'PassiveInvestigation') txt += token.actor.data.data.skills.inv.passive;
|
||||||
|
else if (stats == 'Ability') {
|
||||||
|
const ability = settings.ability ? settings.ability : 'str';
|
||||||
|
txt += token.actor.data.data.abilities?.[ability].value;
|
||||||
|
}
|
||||||
|
else if (stats == 'AbilityMod') {
|
||||||
|
const ability = settings.ability ? settings.ability : 'str';
|
||||||
|
txt += token.actor.data.data.abilities?.[ability].mod;
|
||||||
|
}
|
||||||
|
else if (stats == 'AbilitySave') {
|
||||||
|
const ability = settings.ability ? settings.ability : 'str';
|
||||||
|
txt += token.actor.data.data.abilities?.[ability].save;
|
||||||
|
}
|
||||||
|
else if (stats == 'Prof') txt += token.actor.data.data.attributes.prof;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (game.system.id == 'D35E' || game.system.id == 'pf1'){
|
else if (game.system.id == 'D35E' || game.system.id == 'pf1'){
|
||||||
let attributes = token.actor.data.data.attributes;
|
let attributes = token.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 == 'HPbox') {
|
||||||
|
uses = {
|
||||||
|
available: attributes.hp.value,
|
||||||
|
maximum: attributes.hp.max
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (stats == 'TempHP') {
|
else if (stats == 'TempHP') {
|
||||||
if (attributes.hp.temp == null) txt += '0';
|
if (attributes.hp.temp == null) txt += '0';
|
||||||
else txt += attributes.hp.temp;
|
else txt += attributes.hp.temp;
|
||||||
@@ -145,10 +192,29 @@ export class TokenControl{
|
|||||||
txt += speed;
|
txt += speed;
|
||||||
}
|
}
|
||||||
else if (stats == 'Init') txt += attributes.init.total;
|
else if (stats == 'Init') txt += attributes.init.total;
|
||||||
|
else if (stats == 'Ability') {
|
||||||
|
const ability = settings.ability ? settings.ability : 'str';
|
||||||
|
txt += token.actor.data.data.abilities?.[ability].value;
|
||||||
|
}
|
||||||
|
else if (stats == 'AbilityMod') {
|
||||||
|
const ability = settings.ability ? settings.ability : 'str';
|
||||||
|
txt += token.actor.data.data.abilities?.[ability].mod;
|
||||||
|
}
|
||||||
|
else if (stats == 'AbilitySave') {
|
||||||
|
const ability = settings.ability ? settings.ability : 'str';
|
||||||
|
txt += token.actor.data.data.abilities?.[ability].save;
|
||||||
|
}
|
||||||
|
else if (stats == 'Prof') txt += token.actor.data.data.attributes.prof;
|
||||||
}
|
}
|
||||||
else if (game.system.id == 'pf2e'){
|
else if (game.system.id == 'pf2e'){
|
||||||
let attributes = token.actor.data.data.attributes;
|
let attributes = token.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 == 'HPbox') {
|
||||||
|
uses = {
|
||||||
|
available: attributes.hp.value,
|
||||||
|
maximum: attributes.hp.max
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (stats == 'TempHP') {
|
else if (stats == 'TempHP') {
|
||||||
if (attributes.hp.temp == null) txt += '0';
|
if (attributes.hp.temp == null) txt += '0';
|
||||||
else {
|
else {
|
||||||
@@ -173,9 +239,23 @@ export class TokenControl{
|
|||||||
else if (game.system.id == 'demonlord'){
|
else if (game.system.id == 'demonlord'){
|
||||||
let characteristics = token.actor.data.data.characteristics;
|
let characteristics = token.actor.data.data.characteristics;
|
||||||
if (stats == 'HP') txt += characteristics.health.value + "/" + characteristics.health.max;
|
if (stats == 'HP') txt += characteristics.health.value + "/" + characteristics.health.max;
|
||||||
|
else if (stats == 'HPbox') {
|
||||||
|
uses = {
|
||||||
|
available: characteristics.health.value,
|
||||||
|
maximum: characteristics.health.max
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (stats == 'AC') txt += characteristics.defense;
|
else if (stats == 'AC') txt += characteristics.defense;
|
||||||
else if (stats == 'Speed') txt += characteristics.speed;
|
else if (stats == 'Speed') txt += characteristics.speed;
|
||||||
else if (stats == 'Init') txt += token.actor.data.data.fastturn ? "FAST" : "SLOW";
|
else if (stats == 'Init') txt += token.actor.data.data.fastturn ? "FAST" : "SLOW";
|
||||||
|
else if (stats == 'Ability') {
|
||||||
|
const ability = settings.ability ? settings.ability : 'strength';
|
||||||
|
txt += token.actor.data.data.attributes?.[ability].value;
|
||||||
|
}
|
||||||
|
else if (stats == 'AbilityMod') {
|
||||||
|
const ability = settings.ability ? settings.ability : 'strength';
|
||||||
|
txt += token.actor.data.data.attributes?.[ability].modifier;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//Other systems
|
//Other systems
|
||||||
@@ -427,25 +507,46 @@ export class TokenControl{
|
|||||||
else if (stats == 'PassiveInvestigation')
|
else if (stats == 'PassiveInvestigation')
|
||||||
iconSrc = "modules/MaterialDeck/img/black.png";
|
iconSrc = "modules/MaterialDeck/img/black.png";
|
||||||
}
|
}
|
||||||
streamDeck.setIcon(context,iconSrc,background,ring,ringColor,overlay);
|
streamDeck.setIcon(context,iconSrc,{background:background,ring:ring,ringColor:ringColor,overlay:overlay,uses:uses});
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
async keyPress(settings){
|
async keyPress(settings){
|
||||||
if (MODULE.selectedTokenId == undefined) return;
|
|
||||||
const tokenId = MODULE.selectedTokenId;
|
const tokenId = MODULE.selectedTokenId;
|
||||||
|
|
||||||
const token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
|
const selection = settings.selection ? settings.selection : 'selected';
|
||||||
|
const tokenIdentifier = settings.tokenName ? settings.tokenName : '';
|
||||||
|
|
||||||
|
let token;
|
||||||
|
if (selection == 'selected') token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
|
||||||
|
else if (selection != 'selected' && tokenIdentifier == '') {}
|
||||||
|
else if (selection == 'tokenName') token = canvas.tokens.children[0].children.find(p => p.name == tokenIdentifier);
|
||||||
|
else if (selection == 'actorName') token = canvas.tokens.children[0].children.find(p => p.actor.name == tokenIdentifier);
|
||||||
|
else if (selection == 'tokenId') token = canvas.tokens.children[0].children.find(p => p.id == tokenIdentifier);
|
||||||
|
else if (selection == 'actorId') token = canvas.tokens.children[0].children.find(p => p.actor.id == tokenIdentifier);
|
||||||
|
|
||||||
if (token == undefined) return;
|
if (token == undefined) return;
|
||||||
|
if (token.owner == false && token.observer == true && MODULE.getPermission('TOKEN','OBSERVER') == false ) return;
|
||||||
|
if (token.owner == false && token.observer == false && MODULE.getPermission('TOKEN','NON_OWNED') == false ) return;
|
||||||
|
|
||||||
const onClick = settings.onClick ? settings.onClick : 'doNothing';
|
const onClick = settings.onClick ? settings.onClick : 'doNothing';
|
||||||
|
|
||||||
if (onClick == 'doNothing') //Do nothing
|
if (onClick == 'doNothing') //Do nothing
|
||||||
return;
|
return;
|
||||||
|
else if (onClick == 'select'){ //select token
|
||||||
|
token.control();
|
||||||
|
}
|
||||||
else if (onClick == 'center'){ //center on token
|
else if (onClick == 'center'){ //center on token
|
||||||
let location = token.getCenter(token.x,token.y);
|
let location = token.getCenter(token.x,token.y);
|
||||||
canvas.animatePan(location);
|
canvas.animatePan(location);
|
||||||
}
|
}
|
||||||
|
else if (onClick == 'centerSelect'){ //center on token and select
|
||||||
|
const location = token.getCenter(token.x,token.y);
|
||||||
|
canvas.animatePan(location);
|
||||||
|
token.control();
|
||||||
|
}
|
||||||
else if (onClick == 'charSheet'){ //Open character sheet
|
else if (onClick == 'charSheet'){ //Open character sheet
|
||||||
const element = document.getElementById(token.actor.sheet.id);
|
const element = document.getElementById(token.actor.sheet.id);
|
||||||
if (element == null) token.actor.sheet.render(true);
|
if (element == null) token.actor.sheet.render(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user