Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e229abc3ee | ||
|
|
51119f42ea | ||
|
|
42e4f8f0d8 | ||
|
|
c3ee0a76aa | ||
|
|
2264d018c2 | ||
|
|
8fa32838d8 | ||
|
|
1552ae6fe8 | ||
|
|
cc9bcf4770 | ||
|
|
7d4fd1e8b1 | ||
|
|
780e06d581 | ||
|
|
64983ca0cb | ||
|
|
dd534488da |
154
MaterialDeck.js
@@ -9,6 +9,7 @@ import {SoundboardControl} from "./src/soundboard.js";
|
|||||||
import {OtherControls} from "./src/othercontrols.js";
|
import {OtherControls} from "./src/othercontrols.js";
|
||||||
import {ExternalModules} from "./src/external.js";
|
import {ExternalModules} from "./src/external.js";
|
||||||
import {SceneControl} from "./src/scene.js";
|
import {SceneControl} from "./src/scene.js";
|
||||||
|
import {compatibleCore} from "./src/misc.js";
|
||||||
export var streamDeck;
|
export var streamDeck;
|
||||||
export var tokenControl;
|
export var tokenControl;
|
||||||
var move;
|
var move;
|
||||||
@@ -29,6 +30,8 @@ let activeSounds = [];
|
|||||||
export let hotbarUses = false;
|
export let hotbarUses = false;
|
||||||
export let calculateHotbarUses;
|
export let calculateHotbarUses;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//CONFIG.debug.hooks = true;
|
//CONFIG.debug.hooks = true;
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@@ -69,14 +72,28 @@ async function analyzeWSmessage(msg){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (data.type == "version" && data.source == "SD") {
|
if (data.type == "version" && data.source == "SD") {
|
||||||
/*
|
|
||||||
console.log(data);
|
|
||||||
const minimumSDversion = game.modules.get("MaterialDeck").data.minimumSDversion.replace('v','');
|
const minimumSDversion = game.modules.get("MaterialDeck").data.minimumSDversion.replace('v','');
|
||||||
const minimumMSversion = game.modules.get("MaterialDeck").data.minimumMSversion;
|
const minimumMSversion = game.modules.get("MaterialDeck").data.minimumMSversion;
|
||||||
console.log('SD',minimumSDversion,data.version)
|
|
||||||
if (data.version < minimumSDversion) console.log('SD: nope')
|
if (data.version < minimumSDversion) {
|
||||||
else console.log('SD: yes');
|
let d = new Dialog({
|
||||||
*/
|
title: "Material Deck: Update Needed",
|
||||||
|
content: "<p>The Stream Deck plugin version you're using is v" + data.version + ", which is outdated.<br>Update to v" + minimumSDversion + " or newer.</p>",
|
||||||
|
buttons: {
|
||||||
|
download: {
|
||||||
|
icon: '<i class="fas fa-download"></i>',
|
||||||
|
label: "Update",
|
||||||
|
callback: () => window.open("https://github.com/CDeenen/MaterialDeck_SD/releases")
|
||||||
|
},
|
||||||
|
ignore: {
|
||||||
|
icon: '<i class="fas fa-times"></i>',
|
||||||
|
label: "Ignore"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
default: "download"
|
||||||
|
});
|
||||||
|
d.render(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data == undefined || data.payload == undefined) return;
|
if (data == undefined || data.payload == undefined) return;
|
||||||
@@ -85,40 +102,43 @@ 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;
|
||||||
|
const device = data.device;
|
||||||
|
|
||||||
|
|
||||||
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);
|
await streamDeck.setContext(device,data.size,data.deviceIteration,action,context,coordinates,settings);
|
||||||
|
|
||||||
if (action == 'token'){
|
if (action == 'token'){
|
||||||
tokenControl.active = true;
|
tokenControl.active = true;
|
||||||
tokenControl.update(selectedTokenId);
|
tokenControl.update(device,selectedTokenId,device);
|
||||||
}
|
}
|
||||||
else if (action == 'move')
|
else if (action == 'move')
|
||||||
move.update(settings,context);
|
move.update(settings,context,device);
|
||||||
else if (action == 'macro')
|
else if (action == 'macro')
|
||||||
macroControl.update(settings,context);
|
macroControl.update(settings,context,device);
|
||||||
else if (action == 'combattracker')
|
else if (action == 'combattracker')
|
||||||
combatTracker.update(settings,context);
|
combatTracker.update(settings,context,device);
|
||||||
else if (action == 'playlist')
|
else if (action == 'playlist')
|
||||||
playlistControl.update(settings,context);
|
playlistControl.update(settings,context,device);
|
||||||
else if (action == 'soundboard')
|
else if (action == 'soundboard')
|
||||||
soundboard.update(settings,context);
|
soundboard.update(settings,context,device);
|
||||||
else if (action == 'other')
|
else if (action == 'other')
|
||||||
otherControls.update(settings,context);
|
otherControls.update(settings,context,device);
|
||||||
else if (action == 'external')
|
else if (action == 'external')
|
||||||
externalModules.update(settings,context);
|
externalModules.update(settings,context,device);
|
||||||
else if (action == 'scene')
|
else if (action == 'scene')
|
||||||
sceneControl.update(settings,context);
|
sceneControl.update(settings,context,device);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (event == 'willDisappear'){
|
else if (event == 'willDisappear'){
|
||||||
streamDeck.clearContext(action,coordinates);
|
if (coordinates == undefined) return;
|
||||||
|
streamDeck.clearContext(device,action,coordinates,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (event == 'keyDown'){
|
else if (event == 'keyDown'){
|
||||||
@@ -129,15 +149,15 @@ async function analyzeWSmessage(msg){
|
|||||||
else if (action == 'macro')
|
else if (action == 'macro')
|
||||||
macroControl.keyPress(settings);
|
macroControl.keyPress(settings);
|
||||||
else if (action == 'combattracker')
|
else if (action == 'combattracker')
|
||||||
combatTracker.keyPress(settings,context);
|
combatTracker.keyPress(settings,context,device);
|
||||||
else if (action == 'playlist')
|
else if (action == 'playlist')
|
||||||
playlistControl.keyPress(settings,context);
|
playlistControl.keyPress(settings,context,device);
|
||||||
else if (action == 'soundboard')
|
else if (action == 'soundboard')
|
||||||
soundboard.keyPressDown(settings);
|
soundboard.keyPressDown(settings);
|
||||||
else if (action == 'other')
|
else if (action == 'other')
|
||||||
otherControls.keyPress(settings,context);
|
otherControls.keyPress(settings,context,device);
|
||||||
else if (action == 'external')
|
else if (action == 'external')
|
||||||
externalModules.keyPress(settings,context);
|
externalModules.keyPress(settings,context,device);
|
||||||
else if (action == 'scene')
|
else if (action == 'scene')
|
||||||
sceneControl.keyPress(settings);
|
sceneControl.keyPress(settings);
|
||||||
}
|
}
|
||||||
@@ -234,9 +254,9 @@ export function getPermission(action,func) {
|
|||||||
* Attempt to open the websocket
|
* Attempt to open the websocket
|
||||||
*/
|
*/
|
||||||
Hooks.once('ready', async()=>{
|
Hooks.once('ready', async()=>{
|
||||||
|
registerSettings();
|
||||||
enableModule = (game.settings.get(moduleName,'Enable')) ? true : false;
|
enableModule = (game.settings.get(moduleName,'Enable')) ? true : false;
|
||||||
|
|
||||||
|
|
||||||
soundboard = new SoundboardControl();
|
soundboard = new SoundboardControl();
|
||||||
streamDeck = new StreamDeck();
|
streamDeck = new StreamDeck();
|
||||||
tokenControl = new TokenControl();
|
tokenControl = new TokenControl();
|
||||||
@@ -250,7 +270,7 @@ Hooks.once('ready', async()=>{
|
|||||||
|
|
||||||
game.socket.on(`module.MaterialDeck`, async(payload) =>{
|
game.socket.on(`module.MaterialDeck`, async(payload) =>{
|
||||||
//console.log(payload);
|
//console.log(payload);
|
||||||
if (payload.msgType == "playSound") playTrack(payload.trackNr,payload.src,payload.play,payload.repeat,payload.volume);
|
if (payload.msgType == "playSound") soundboard.playSound(payload.trackNr,payload.src,payload.play,payload.repeat,payload.volume);
|
||||||
else if (game.user.isGM && payload.msgType == "playPlaylist") {
|
else if (game.user.isGM && payload.msgType == "playPlaylist") {
|
||||||
const playlist = playlistControl.getPlaylist(payload.playlistNr);
|
const playlist = playlistControl.getPlaylist(payload.playlistNr);
|
||||||
playlistControl.playPlaylist(playlist,payload.playlistNr);
|
playlistControl.playPlaylist(playlist,payload.playlistNr);
|
||||||
@@ -339,27 +359,6 @@ Hooks.once('ready', async()=>{
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export function playTrack(soundNr,src,play,repeat,volume){
|
|
||||||
if (play){
|
|
||||||
volume *= game.settings.get("core", "globalInterfaceVolume");
|
|
||||||
|
|
||||||
let howl = new Howl({src, volume, loop: repeat, onend: (id)=>{
|
|
||||||
if (repeat == false){
|
|
||||||
activeSounds[soundNr] = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onstop: (id)=>{
|
|
||||||
activeSounds[soundNr] = false;
|
|
||||||
}});
|
|
||||||
howl.play();
|
|
||||||
activeSounds[soundNr] = howl;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
activeSounds[soundNr].stop();
|
|
||||||
activeSounds[soundNr] = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Hooks.on('updateToken',(scene,token)=>{
|
Hooks.on('updateToken',(scene,token)=>{
|
||||||
if (enableModule == false || ready == false) return;
|
if (enableModule == false || ready == false) return;
|
||||||
let tokenId = token._id;
|
let tokenId = token._id;
|
||||||
@@ -398,10 +397,18 @@ Hooks.on('updateOwnedItem',()=>{
|
|||||||
})
|
})
|
||||||
|
|
||||||
Hooks.on('renderHotbar', (hotbar)=>{
|
Hooks.on('renderHotbar', (hotbar)=>{
|
||||||
|
if (compatibleCore("0.8.1")) return;
|
||||||
if (enableModule == false || ready == false) return;
|
if (enableModule == false || ready == false) return;
|
||||||
if (macroControl != undefined) macroControl.hotbar(hotbar.macros);
|
if (macroControl != undefined) macroControl.hotbar(hotbar.macros);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Hooks.on('render', (app)=>{
|
||||||
|
if (enableModule == false || ready == false) return;
|
||||||
|
if (compatibleCore("0.8.1") == false) return;
|
||||||
|
if (app.id == "hotbar" && macroControl != undefined) macroControl.hotbar(app.macros);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
Hooks.on('renderCombatTracker',()=>{
|
Hooks.on('renderCombatTracker',()=>{
|
||||||
if (enableModule == false || ready == false) return;
|
if (enableModule == false || ready == false) return;
|
||||||
if (combatTracker != undefined) combatTracker.updateAll();
|
if (combatTracker != undefined) combatTracker.updateAll();
|
||||||
@@ -424,10 +431,27 @@ Hooks.on('pauseGame',()=>{
|
|||||||
otherControls.updateAll();
|
otherControls.updateAll();
|
||||||
});
|
});
|
||||||
|
|
||||||
Hooks.on('renderSidebarTab',()=>{
|
Hooks.on('renderSidebarTab',(app)=>{
|
||||||
|
const options = {
|
||||||
|
sidebarTab: app.tabName,
|
||||||
|
renderPopout: app.popOut
|
||||||
|
}
|
||||||
|
if (enableModule == false || ready == false) return;
|
||||||
|
if (otherControls != undefined) otherControls.updateAll(options);
|
||||||
|
if (sceneControl != undefined) sceneControl.updateAll();
|
||||||
|
});
|
||||||
|
|
||||||
|
Hooks.on('closeSidebarTab',(app)=>{
|
||||||
|
const options = {
|
||||||
|
sidebarTab: app.tabName,
|
||||||
|
renderPopout: false
|
||||||
|
}
|
||||||
|
if (otherControls != undefined) otherControls.updateAll(options);
|
||||||
|
});
|
||||||
|
|
||||||
|
Hooks.on('changeSidebarTab',()=>{
|
||||||
if (enableModule == false || ready == false) return;
|
if (enableModule == false || ready == false) return;
|
||||||
if (otherControls != undefined) otherControls.updateAll();
|
if (otherControls != undefined) otherControls.updateAll();
|
||||||
if (sceneControl != undefined) sceneControl.updateAll();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Hooks.on('updateScene',()=>{
|
Hooks.on('updateScene',()=>{
|
||||||
@@ -463,14 +487,30 @@ Hooks.on('closeCompendium',()=>{
|
|||||||
otherControls.updateAll();
|
otherControls.updateAll();
|
||||||
});
|
});
|
||||||
|
|
||||||
Hooks.on('renderJournalSheet',()=>{
|
Hooks.on('renderCompendiumBrowser',()=>{
|
||||||
if (enableModule == false || ready == false) return;
|
if (enableModule == false || ready == false) return;
|
||||||
otherControls.updateAll();
|
otherControls.updateAll({renderCompendiumBrowser:true});
|
||||||
});
|
});
|
||||||
|
|
||||||
Hooks.on('closeJournalSheet',()=>{
|
Hooks.on('closeCompendiumBrowser',()=>{
|
||||||
if (enableModule == false || ready == false) return;
|
if (enableModule == false || ready == false) return;
|
||||||
otherControls.updateAll();
|
otherControls.updateAll({renderCompendiumBrowser:false});
|
||||||
|
});
|
||||||
|
|
||||||
|
Hooks.on('renderJournalSheet',(sheet)=>{
|
||||||
|
if (enableModule == false || ready == false) return;
|
||||||
|
otherControls.updateAll({
|
||||||
|
hook:'renderJournalSheet',
|
||||||
|
sheet:sheet
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
Hooks.on('closeJournalSheet',(sheet)=>{
|
||||||
|
if (enableModule == false || ready == false) return;
|
||||||
|
otherControls.updateAll({
|
||||||
|
hook:'closeJournalSheet',
|
||||||
|
sheet:sheet
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Hooks.on('gmScreenOpenClose',(html,isOpen)=>{
|
Hooks.on('gmScreenOpenClose',(html,isOpen)=>{
|
||||||
@@ -488,9 +528,19 @@ 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
|
||||||
});
|
});
|
||||||
|
|
||||||
Hooks.once('canvasReady',()=>{
|
Hooks.once('canvasReady',()=>{
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
111
changelog.md
@@ -1,4 +1,113 @@
|
|||||||
# Changelog Material Deck Module
|
# Changelog Material Deck Module
|
||||||
|
### v1.4.1 - 21-04-2021
|
||||||
|
Fixes:
|
||||||
|
<ul>
|
||||||
|
<li>Last update broke the combat tracker, should now be fixed</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
### v1.4.0 - 21-04-2021
|
||||||
|
Additions:
|
||||||
|
<ul>
|
||||||
|
<li>Support for connecting multiple Stream Decks at the same time. Please note that performance decreases with each extra Stream Deck</li>
|
||||||
|
<li>Other Actions: Added 'Token Roll Options'. This can toggle token rolls between showing a dialog and skipping the dialog and rolling normally or with advantage or disadvantage</li>
|
||||||
|
<li>If the SD plugin version you're using is outdated, you now get a pop-up to notify you of this and direct you to the download page</li>
|
||||||
|
<li>Added a module setting to set how dark the default white images should be. Can be lowered for improved readability of the text</li>
|
||||||
|
<li>Token Action => Stats: Added option to prepend text to the title, so you can set the stat to, for example, strength, and put 'STR: ' in the prepend textbox to display, for example, 'STR: +2'</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
Fixes:
|
||||||
|
<ul>
|
||||||
|
<li>Token Action => Skill Roll: Setting wasn't saved in SD app</li>
|
||||||
|
<li>Token Action => Roll Ability: Rolling ability checks was broken for some systems</li>
|
||||||
|
<li>Token Action => Stats => Display HP: Read overlay indicating HP in the heart icon was also drawn when 'Display Token Icon' was enabled</li>
|
||||||
|
<li>Token Action => Stats: Added default images for all dnd5e abilities, saves and skills</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.4.0 (<b>must be updated!</b>): https://github.com/CDeenen/MaterialDeck_SD/releases<br>
|
||||||
|
|
||||||
|
|
||||||
|
### v1.3.3 - 12-04-2021
|
||||||
|
Additions:
|
||||||
|
<ul>
|
||||||
|
<li>Other Actions => Open Sidebar Tab: Action now indicates which sidebar tab is open (only works on Foundry 0.8.x)</li>
|
||||||
|
<li>Other Actions => Open Sidebar Tab: Added option to create an pop-out (doesn't work for the chat)</li>
|
||||||
|
<li>Other Actions: Added option to open the pf2e compendium browser</li>
|
||||||
|
<li>Macro Action: Can now call macros by name</li>
|
||||||
|
<li>Token Action => On Click: Added option to call a macro. Currently the macro will be applied to the selected token</li>
|
||||||
|
<li>Token Action => Display Stats: Added saving throws and skill modifiers for most systems</li>
|
||||||
|
<li>Token Action => OnClick: Added 'Dice Roll' option, which allows you to roll ability checks, saving throws and other things (depending on game system)</li>
|
||||||
|
<li>Token Action => Stats => Display HP: Made the heart icon dynamic, so the amount that the heart is filled with red depends on the relative amount of hit points of the token. 25% hp means the lower 25% of the heart is red, 50% hp means the lower 50% of the heart is red, etc</li>
|
||||||
|
<li>Token Action => Stats => Added a '+' before all modifier stats that are bigger than 0</li>
|
||||||
|
<li>Token Action => Custom OnClick: Added support for calling macros. For instructions, please refer to the documentation: https://github.com/CDeenen/MaterialDeck/wiki/Token-Action#custom-on-click-function</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
Fixes:
|
||||||
|
<ul>
|
||||||
|
<li>Other Actions => Pause Game: Pause is now transmitted to all connected clients</li>
|
||||||
|
<li>Token Action => Display Stats: Fixed movement speed for pf2e</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
Other:
|
||||||
|
<ul>
|
||||||
|
<li>Should be compatible with Foundry 0.8.1. Only tested on DnD5e. Please note that any functions that rely on other modules do not work if the other modules are not compatible with 0.8.1</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.4 (<b>must be updated!</b>): https://github.com/CDeenen/MaterialDeck_SD/releases<br>
|
||||||
|
|
||||||
|
### 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>
|
||||||
|
</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 +119,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>
|
||||||
|
|||||||
BIN
img/.thumb/MaterialFoundry512x512.png.jpg
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
img/MaterialFoundry512x512.png
Normal file
|
After Width: | Height: | Size: 359 KiB |
@@ -1,2 +1,3 @@
|
|||||||
other.png: Made using https://www.elgato.com/en/gaming/keycreator
|
other.png: Made using https://www.elgato.com/en/gaming/keycreator
|
||||||
cogs.png: Edited from https://fontawesome.com/icons/cogs?style=solid
|
cogs.png: Edited from https://fontawesome.com/icons/cogs?style=solid
|
||||||
|
d20.png: Edited from https://game-icons.net/1x1/delapouite/dice-twenty-faces-twenty.html
|
||||||
BIN
img/other/d20.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
img/token/.thumb/hp_empty.png.jpg
Normal file
|
After Width: | Height: | Size: 16 KiB |
@@ -1,5 +1,5 @@
|
|||||||
ac.webp: Foundry's icon folder, original name: heater-steel-worn.webp
|
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
|
hp.png, hp_empty.png and temp_hp_empty.png: made using/modified from 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
|
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
|
speed.webp: Foundry's icon folder, original name: shoes-collared-leather-blue.webp
|
||||||
mystery-man.png: Foundry's icon folder, converted from .svg
|
mystery-man.png: Foundry's icon folder, converted from .svg
|
||||||
7
img/token/abilities/SOURCES.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
All images licenced under CC BY 3.0. Grabbed from game-icons.net
|
||||||
|
str.png: https://game-icons.net/1x1/delapouite/weight-lifting-up.html
|
||||||
|
dex.png: https://game-icons.net/1x1/darkzaitzev/acrobatic.html
|
||||||
|
cons.png: https://game-icons.net/1x1/zeromancer/heart-plus.html
|
||||||
|
int.png: https://game-icons.net/1x1/lorc/bookmarklet.html
|
||||||
|
wis.png: https://game-icons.net/1x1/delapouite/wisdom.html
|
||||||
|
cha.png: https://game-icons.net/1x1/lorc/icicles-aura.html
|
||||||
BIN
img/token/abilities/cha.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
img/token/abilities/cons.png
Normal file
|
After Width: | Height: | Size: 8.7 KiB |
BIN
img/token/abilities/dex.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
img/token/abilities/int.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
img/token/abilities/str.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
img/token/abilities/wis.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
img/token/hp_empty.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
19
img/token/skills/SOURCES.txt
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
All images licenced under CC BY 3.0. Grabbed from game-icons.net
|
||||||
|
acr.png: https://game-icons.net/1x1/delapouite/contortionist.html
|
||||||
|
ani.png: https://game-icons.net/1x1/delapouite/cavalry.html
|
||||||
|
arc.png: https://game-icons.net/1x1/delapouite/spell-book.html
|
||||||
|
ath.png: https://game-icons.net/1x1/lorc/muscle-up.html
|
||||||
|
dec.png: https://game-icons.net/1x1/delapouite/convince.html
|
||||||
|
his.png: https://game-icons.net/1x1/delapouite/backward-time.html
|
||||||
|
ins.png: https://game-icons.net/1x1/lorc/light-bulb.html
|
||||||
|
itm.png: https://game-icons.net/1x1/lorc/one-eyed.html
|
||||||
|
inv.png: https://game-icons.net/1x1/lorc/magnifying-glass.html
|
||||||
|
med.png: https://game-icons.net/1x1/delapouite/first-aid-kit.html
|
||||||
|
nat.png: https://game-icons.net/1x1/delapouite/forest.html
|
||||||
|
prc.png: https://game-icons.net/1x1/lorc/semi-closed-eye.html
|
||||||
|
prf.png: https://game-icons.net/1x1/lorc/sing.html
|
||||||
|
per.png: https://game-icons.net/1x1/delapouite/public-speaker.html
|
||||||
|
rel.png: https://game-icons.net/1x1/lorc/holy-grail.html
|
||||||
|
slt.png: https://game-icons.net/1x1/lorc/snatch.html
|
||||||
|
ste.png: https://game-icons.net/1x1/lorc/cloak-dagger.html
|
||||||
|
sur.png: https://game-icons.net/1x1/delapouite/pyre.html
|
||||||
BIN
img/token/skills/acr.png
Normal file
|
After Width: | Height: | Size: 9.1 KiB |
BIN
img/token/skills/ani.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
img/token/skills/arc.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
img/token/skills/ath.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
img/token/skills/dec.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
img/token/skills/his.png
Normal file
|
After Width: | Height: | Size: 9.6 KiB |
BIN
img/token/skills/ins.png
Normal file
|
After Width: | Height: | Size: 9.8 KiB |
BIN
img/token/skills/inv.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
img/token/skills/itm.png
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
img/token/skills/med.png
Normal file
|
After Width: | Height: | Size: 6.5 KiB |
BIN
img/token/skills/nat.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
img/token/skills/per.png
Normal file
|
After Width: | Height: | Size: 8.7 KiB |
BIN
img/token/skills/prc.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
img/token/skills/prf.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
img/token/skills/rel.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
img/token/skills/slt.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
img/token/skills/ste.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
img/token/skills/sur.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
img/token/temp_hp_empty.png
Normal file
|
After Width: | Height: | Size: 11 KiB |
16
lang/en.json
@@ -21,6 +21,8 @@
|
|||||||
"MaterialDeck.Sett.ServerAddrHint": "The IP address and port of Material Server. The default value will work for 99% of people, only change this if you know what you're doing. Must follow the format [ip_address]:[port], for example: 'localhost:3001' or '192.168.1.1:4000'.",
|
"MaterialDeck.Sett.ServerAddrHint": "The IP address and port of Material Server. The default value will work for 99% of people, only change this if you know what you're doing. Must follow the format [ip_address]:[port], for example: 'localhost:3001' or '192.168.1.1:4000'.",
|
||||||
"MaterialDeck.Sett.ImageBuffer": "Image Cache Size",
|
"MaterialDeck.Sett.ImageBuffer": "Image Cache Size",
|
||||||
"MaterialDeck.Sett.ImageBufferHint": "Sets the amount of images to store in the image cache. The image cache will locally store all images sent to the Stream Deck. This improves the update speed, but increases memory usage.",
|
"MaterialDeck.Sett.ImageBufferHint": "Sets the amount of images to store in the image cache. The image cache will locally store all images sent to the Stream Deck. This improves the update speed, but increases memory usage.",
|
||||||
|
"MaterialDeck.Sett.ImageBrightness": "Image Brightness",
|
||||||
|
"MaterialDeck.Sett.ImageBrightnessHint": "Sets the brightness of the default white images. If the Image Cache Size is bigger than 0, perform a refresh for instant results.",
|
||||||
|
|
||||||
"MaterialDeck.PL.Unrestricted": "Unrestricted",
|
"MaterialDeck.PL.Unrestricted": "Unrestricted",
|
||||||
"MaterialDeck.PL.OneTrackPlaylist": "One track per playlist",
|
"MaterialDeck.PL.OneTrackPlaylist": "One track per playlist",
|
||||||
@@ -91,6 +93,8 @@
|
|||||||
"MaterialDeck.Perm.MACRO.label": "Macros",
|
"MaterialDeck.Perm.MACRO.label": "Macros",
|
||||||
"MaterialDeck.Perm.MACRO.HOTBAR.label": "Hotbar Macros",
|
"MaterialDeck.Perm.MACRO.HOTBAR.label": "Hotbar Macros",
|
||||||
"MaterialDeck.Perm.MACRO.HOTBAR.hint": "Allow users to use hotbar macros",
|
"MaterialDeck.Perm.MACRO.HOTBAR.hint": "Allow users to use hotbar macros",
|
||||||
|
"MaterialDeck.Perm.MACRO.BY_NAME.label": "Macro by Name",
|
||||||
|
"MaterialDeck.Perm.MACRO.BY_NAME.hint": "Allow users to call macros by name",
|
||||||
"MaterialDeck.Perm.MACRO.MACROBOARD.label": "Macro Board",
|
"MaterialDeck.Perm.MACRO.MACROBOARD.label": "Macro Board",
|
||||||
"MaterialDeck.Perm.MACRO.MACROBOARD.hint": "Allow users to use the macro board",
|
"MaterialDeck.Perm.MACRO.MACROBOARD.hint": "Allow users to use the macro board",
|
||||||
"MaterialDeck.Perm.MACRO.MACROBOARD_CONFIGURE.label": "Configure the Macro Board",
|
"MaterialDeck.Perm.MACRO.MACROBOARD_CONFIGURE.label": "Configure the Macro Board",
|
||||||
@@ -164,6 +168,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.4.1",
|
||||||
"minimumSDversion": "1.3.0",
|
"minimumSDversion": "1.4.0",
|
||||||
"minimumMSversion": "1.0.2",
|
"minimumMSversion": "1.0.2",
|
||||||
"author": "CDeenen",
|
"author": "CDeenen",
|
||||||
"esmodules": [
|
"esmodules": [
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
],
|
],
|
||||||
"socket": true,
|
"socket": true,
|
||||||
"minimumCoreVersion": "0.7.5",
|
"minimumCoreVersion": "0.7.5",
|
||||||
"compatibleCoreVersion": "0.7.9",
|
"compatibleCoreVersion": "0.8.1",
|
||||||
"languages": [
|
"languages": [
|
||||||
{
|
{
|
||||||
"lang": "en",
|
"lang": "en",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import * as MODULE from "../MaterialDeck.js";
|
import * as MODULE from "../MaterialDeck.js";
|
||||||
import {streamDeck, tokenControl} from "../MaterialDeck.js";
|
import {streamDeck, tokenControl} from "../MaterialDeck.js";
|
||||||
|
import {compatibleCore} from "./misc.js";
|
||||||
|
|
||||||
export class CombatTracker{
|
export class CombatTracker{
|
||||||
constructor(){
|
constructor(){
|
||||||
@@ -9,14 +10,16 @@ export class CombatTracker{
|
|||||||
|
|
||||||
async updateAll(){
|
async updateAll(){
|
||||||
if (this.active == false) return;
|
if (this.active == false) return;
|
||||||
for (let i=0; i<32; i++){
|
for (let device of streamDeck.buttonContext) {
|
||||||
const data = streamDeck.buttonContext[i];
|
for (let i=0; i<device.buttons.length; i++){
|
||||||
|
const data = device.buttons[i];
|
||||||
if (data == undefined || data.action != 'combattracker') continue;
|
if (data == undefined || data.action != 'combattracker') continue;
|
||||||
await this.update(data.settings,data.context);
|
await this.update(data.settings,data.context,device.device);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update(settings,context){
|
update(settings,context,device){
|
||||||
this.active = true;
|
this.active = true;
|
||||||
const ctFunction = settings.combatTrackerFunction ? settings.combatTrackerFunction : 'startStop';
|
const ctFunction = settings.combatTrackerFunction ? settings.combatTrackerFunction : 'startStop';
|
||||||
const mode = settings.combatTrackerMode ? settings.combatTrackerMode : 'combatants';
|
const mode = settings.combatTrackerMode ? settings.combatTrackerMode : 'combatants';
|
||||||
@@ -28,7 +31,7 @@ export class CombatTracker{
|
|||||||
|
|
||||||
if (mode == 'combatants'){
|
if (mode == 'combatants'){
|
||||||
if (MODULE.getPermission('COMBAT','DISPLAY_COMBATANTS') == false) {
|
if (MODULE.getPermission('COMBAT','DISPLAY_COMBATANTS') == false) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device,device,false,"combat tracker");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (combat != null && combat != undefined && combat.turns.length != 0){
|
if (combat != null && combat != undefined && combat.turns.length != 0){
|
||||||
@@ -39,46 +42,46 @@ export class CombatTracker{
|
|||||||
const combatant = initiativeOrder[nr]
|
const combatant = initiativeOrder[nr]
|
||||||
|
|
||||||
if (combatant != undefined){
|
if (combatant != undefined){
|
||||||
const tokenId = combatant.tokenId;
|
const tokenId = compatibleCore("0.8.1") ? combatant.data.tokenId : combatant.tokenId;
|
||||||
tokenControl.pushData(tokenId,settings,context,combatantState,'#cccc00');
|
tokenControl.pushData(tokenId,settings,context,device,combatantState,'#cccc00');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
streamDeck.setIcon(context,src,background);
|
streamDeck.setIcon(context,device,src,{background:background});
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
streamDeck.setIcon(context,src,background);
|
streamDeck.setIcon(context,device,src,{background:background});
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mode == 'currentCombatant'){
|
else if (mode == 'currentCombatant'){
|
||||||
if (MODULE.getPermission('COMBAT','DISPLAY_COMBATANTS') == false) {
|
if (MODULE.getPermission('COMBAT','DISPLAY_COMBATANTS') == false) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (combat != null && combat != undefined && combat.started){
|
if (combat != null && combat != undefined && combat.started){
|
||||||
const tokenId = combat.combatant.tokenId;
|
const tokenId = compatibleCore("0.8.1") ? combat.combatant.data.tokenId : combat.combatant.tokenId;
|
||||||
tokenControl.pushData(tokenId,settings,context);
|
tokenControl.pushData(tokenId,settings,context,device);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
streamDeck.setIcon(context,src,background);
|
streamDeck.setIcon(context,device,src,{background:background});
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mode == 'function'){
|
else if (mode == 'function'){
|
||||||
|
|
||||||
if (ctFunction == 'turnDisplay' && MODULE.getPermission('COMBAT','TURN_DISPLAY') == false) {
|
if (ctFunction == 'turnDisplay' && MODULE.getPermission('COMBAT','TURN_DISPLAY') == false) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (ctFunction == 'endTurn' && MODULE.getPermission('COMBAT','END_TURN') == false) {
|
else if (ctFunction == 'endTurn' && MODULE.getPermission('COMBAT','END_TURN') == false) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (ctFunction != 'turnDisplay' && ctFunction != 'endTurn' && MODULE.getPermission('COMBAT','OTHER_FUNCTIONS') == false) {
|
else if (ctFunction != 'turnDisplay' && ctFunction != 'endTurn' && MODULE.getPermission('COMBAT','OTHER_FUNCTIONS') == false) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,12 +128,12 @@ 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,device,src,{background:background});
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPress(settings,context){
|
keyPress(settings,context,device){
|
||||||
const mode = settings.combatTrackerMode ? settings.combatTrackerMode : 'combatants';
|
const mode = settings.combatTrackerMode ? settings.combatTrackerMode : 'combatants';
|
||||||
const combat = game.combat;
|
const combat = game.combat;
|
||||||
|
|
||||||
@@ -139,15 +142,15 @@ export class CombatTracker{
|
|||||||
const ctFunction = settings.combatTrackerFunction ? settings.combatTrackerFunction : 'startStop';
|
const ctFunction = settings.combatTrackerFunction ? settings.combatTrackerFunction : 'startStop';
|
||||||
|
|
||||||
if (ctFunction == 'turnDisplay' && MODULE.getPermission('COMBAT','TURN_DISPLAY') == false) {
|
if (ctFunction == 'turnDisplay' && MODULE.getPermission('COMBAT','TURN_DISPLAY') == false) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (ctFunction == 'endTurn' && MODULE.getPermission('COMBAT','END_TURN') == false) {
|
else if (ctFunction == 'endTurn' && MODULE.getPermission('COMBAT','END_TURN') == false) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (ctFunction != 'turnDisplay' && ctFunction != 'endTurn' && MODULE.getPermission('COMBAT','OTHER_FUNCTIONS') == false) {
|
else if (ctFunction != 'turnDisplay' && ctFunction != 'endTurn' && MODULE.getPermission('COMBAT','OTHER_FUNCTIONS') == false) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,15 +159,10 @@ export class CombatTracker{
|
|||||||
let background;
|
let background;
|
||||||
if (game.combat.started){
|
if (game.combat.started){
|
||||||
game.combat.endCombat();
|
game.combat.endCombat();
|
||||||
src = "modules/MaterialDeck/img/combattracker/startcombat.png";
|
|
||||||
background = "#000000";
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
game.combat.startCombat();
|
game.combat.startCombat();
|
||||||
src = "modules/MaterialDeck/img/combattracker/stopcombat.png";
|
|
||||||
background = "#FF0000";
|
|
||||||
}
|
}
|
||||||
streamDeck.setIcon(context,src,background);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (game.combat.started == false) return;
|
if (game.combat.started == false) return;
|
||||||
@@ -185,12 +183,12 @@ export class CombatTracker{
|
|||||||
if (nr == undefined || nr < 1) nr = 0;
|
if (nr == undefined || nr < 1) nr = 0;
|
||||||
const combatant = initiativeOrder[nr]
|
const combatant = initiativeOrder[nr]
|
||||||
if (combatant == undefined) return;
|
if (combatant == undefined) return;
|
||||||
tokenId = combatant.tokenId;
|
tokenId = compatibleCore("0.8.1") ? combatant.data.tokenId : combatant.tokenId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mode == 'currentCombatant')
|
else if (mode == 'currentCombatant')
|
||||||
if (combat != null && combat != undefined && combat.started)
|
if (combat != null && combat != undefined && combat.started)
|
||||||
tokenId = combat.combatant.tokenId;
|
tokenId = compatibleCore("0.8.1") ? combat.combatant.data.tokenId : combat.combatant.tokenId;
|
||||||
|
|
||||||
let token = (canvas.tokens.children[0] != undefined) ? canvas.tokens.children[0].children.find(p => p.id == tokenId) : undefined;
|
let token = (canvas.tokens.children[0] != undefined) ? canvas.tokens.children[0].children.find(p => p.id == tokenId) : undefined;
|
||||||
if (token == undefined) return;
|
if (token == undefined) return;
|
||||||
|
|||||||
309
src/external.js
@@ -12,38 +12,41 @@ export class ExternalModules{
|
|||||||
this.gmScreenOpen = data.gmScreen.isOpen;
|
this.gmScreenOpen = data.gmScreen.isOpen;
|
||||||
}
|
}
|
||||||
if (this.active == false) return;
|
if (this.active == false) return;
|
||||||
for (let i=0; i<32; i++){
|
for (let device of streamDeck.buttonContext) {
|
||||||
const data = streamDeck.buttonContext[i];
|
for (let i=0; i<device.buttons.length; i++){
|
||||||
|
const data = device.buttons[i];
|
||||||
if (data == undefined || data.action != 'external') continue;
|
if (data == undefined || data.action != 'external') continue;
|
||||||
await this.update(data.settings,data.context);
|
await this.update(data.settings,data.context,device.device);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update(settings,context){
|
update(settings,context,device){
|
||||||
this.active = true;
|
this.active = true;
|
||||||
const module = settings.module ? settings.module : 'fxmaster';
|
const module = settings.module ? settings.module : 'fxmaster';
|
||||||
|
|
||||||
if (module == 'fxmaster') this.updateFxMaster(settings,context);
|
if (module == 'fxmaster') this.updateFxMaster(settings,context,device);
|
||||||
else if (module == 'gmscreen') this.updateGMScreen(settings,context);
|
else if (module == 'gmscreen') this.updateGMScreen(settings,context,device);
|
||||||
else if (module == 'triggerHappy') this.updateTriggerHappy(settings,context);
|
else if (module == 'triggerHappy') this.updateTriggerHappy(settings,context,device);
|
||||||
else if (module == 'sharedVision') this.updateSharedVision(settings,context);
|
else if (module == 'sharedVision') this.updateSharedVision(settings,context,device);
|
||||||
else if (module == 'mookAI') this.updateMookAI(settings,context);
|
else if (module == 'mookAI') this.updateMookAI(settings,context,device);
|
||||||
else if (module == 'notYourTurn') this.updateNotYourTurn(settings,context);
|
else if (module == 'notYourTurn') this.updateNotYourTurn(settings,context,device);
|
||||||
else if (module == 'lockView') this.updateLockView(settings,context);
|
else if (module == 'lockView') this.updateLockView(settings,context,device);
|
||||||
|
else if (module == 'aboutTime') this.updateAboutTime(settings,context,device);
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPress(settings,context){
|
keyPress(settings,context,device){
|
||||||
if (this.active == false) return;
|
if (this.active == false) return;
|
||||||
const module = settings.module ? settings.module : 'fxmaster';
|
const module = settings.module ? settings.module : 'fxmaster';
|
||||||
|
|
||||||
if (module == 'fxmaster') this.keyPressFxMaster(settings,context);
|
if (module == 'fxmaster') this.keyPressFxMaster(settings,context,device);
|
||||||
else if (module == 'gmscreen') this.keyPressGMScreen(settings,context);
|
else if (module == 'gmscreen') this.keyPressGMScreen(settings,context,device);
|
||||||
else if (module == 'triggerHappy') this.keyPressTriggerHappy(settings,context);
|
else if (module == 'triggerHappy') this.keyPressTriggerHappy(settings,context,device);
|
||||||
else if (module == 'sharedVision') this.keyPressSharedVision(settings,context);
|
else if (module == 'sharedVision') this.keyPressSharedVision(settings,context,device);
|
||||||
else if (module == 'mookAI') this.keyPressMookAI(settings,context);
|
else if (module == 'mookAI') this.keyPressMookAI(settings,context,device);
|
||||||
else if (module == 'notYourTurn') this.keyPressNotYourTurn(settings,context);
|
else if (module == 'notYourTurn') this.keyPressNotYourTurn(settings,context,device);
|
||||||
else if (module == 'lockView') this.keyPressLockView(settings,context);
|
else if (module == 'lockView') this.keyPressLockView(settings,context,device);
|
||||||
|
else if (module == 'aboutTime') this.keyPressAboutTime(settings,context,device);
|
||||||
}
|
}
|
||||||
|
|
||||||
getModuleEnable(moduleId){
|
getModuleEnable(moduleId){
|
||||||
@@ -55,7 +58,7 @@ export class ExternalModules{
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//FxMaster
|
//FxMaster
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
updateFxMaster(settings,context){
|
updateFxMaster(settings,context,device){
|
||||||
if (game.user.isGM == false) return;
|
if (game.user.isGM == false) return;
|
||||||
const fxmaster = game.modules.get("fxmaster");
|
const fxmaster = game.modules.get("fxmaster");
|
||||||
if (fxmaster == undefined || fxmaster.active == false) return;
|
if (fxmaster == undefined || fxmaster.active == false) return;
|
||||||
@@ -124,8 +127,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,device,icon,{background:background,ring:ring,ringColor:ringColor});
|
||||||
else streamDeck.setIcon(context, "", background,ring,ringColor);
|
else streamDeck.setIcon(context,device, "", {background:background,ring:ring,ringColor:ringColor});
|
||||||
if (displayName == 0) name = "";
|
if (displayName == 0) name = "";
|
||||||
streamDeck.setTitle(name,context);
|
streamDeck.setTitle(name,context);
|
||||||
}
|
}
|
||||||
@@ -139,7 +142,7 @@ export class ExternalModules{
|
|||||||
} : null;
|
} : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPressFxMaster(settings,context){
|
keyPressFxMaster(settings,context,device){
|
||||||
if (game.user.isGM == false) return;
|
if (game.user.isGM == false) return;
|
||||||
const fxmaster = game.modules.get("fxmaster");
|
const fxmaster = game.modules.get("fxmaster");
|
||||||
if (fxmaster == undefined || fxmaster.active == false) return;
|
if (fxmaster == undefined || fxmaster.active == false) return;
|
||||||
@@ -256,7 +259,7 @@ export class ExternalModules{
|
|||||||
//GM Screen
|
//GM Screen
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
updateGMScreen(settings,context){
|
updateGMScreen(settings,context,device){
|
||||||
if (this.getModuleEnable("gm-screen") == false) return;
|
if (this.getModuleEnable("gm-screen") == false) return;
|
||||||
if (game.user.isGM == false) return;
|
if (game.user.isGM == false) return;
|
||||||
|
|
||||||
@@ -269,12 +272,12 @@ 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,device,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPressGMScreen(settings,context){
|
keyPressGMScreen(settings,context,device){
|
||||||
if (this.getModuleEnable("gm-screen") == false) return;
|
if (this.getModuleEnable("gm-screen") == false) return;
|
||||||
if (game.user.isGM == false) return;
|
if (game.user.isGM == false) return;
|
||||||
window['gm-screen'].toggleGmScreenVisibility();
|
window['gm-screen'].toggleGmScreenVisibility();
|
||||||
@@ -284,7 +287,7 @@ export class ExternalModules{
|
|||||||
//Trigger Happy
|
//Trigger Happy
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
updateTriggerHappy(settings,context) {
|
updateTriggerHappy(settings,context,device) {
|
||||||
if (this.getModuleEnable("trigger-happy") == false) return;
|
if (this.getModuleEnable("trigger-happy") == false) return;
|
||||||
if (game.user.isGM == false) return;
|
if (game.user.isGM == false) return;
|
||||||
|
|
||||||
@@ -295,14 +298,14 @@ 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,device,"fas fa-grin-squint-tears",{background:background,ring:2,ringColor:ringColor});
|
||||||
else streamDeck.setIcon(context,'','#000000');
|
else streamDeck.setIcon(context,device,'',{background:'#000000'});
|
||||||
if (displayName) txt = 'Trigger Happy';
|
if (displayName) txt = 'Trigger Happy';
|
||||||
|
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPressTriggerHappy(settings,context){
|
keyPressTriggerHappy(settings,context,device){
|
||||||
if (this.getModuleEnable("trigger-happy") == false) return;
|
if (this.getModuleEnable("trigger-happy") == false) return;
|
||||||
if (game.user.isGM == false) return;
|
if (game.user.isGM == false) return;
|
||||||
const mode = settings.triggerHappyMode ? settings.triggerHappyMode : 'toggle';
|
const mode = settings.triggerHappyMode ? settings.triggerHappyMode : 'toggle';
|
||||||
@@ -325,7 +328,7 @@ export class ExternalModules{
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//Shared Vision
|
//Shared Vision
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
updateSharedVision(settings,context) {
|
updateSharedVision(settings,context,device) {
|
||||||
if (this.getModuleEnable("SharedVision") == false) return;
|
if (this.getModuleEnable("SharedVision") == false) return;
|
||||||
if (game.user.isGM == false) return;
|
if (game.user.isGM == false) return;
|
||||||
|
|
||||||
@@ -336,13 +339,13 @@ 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,device,"fas fa-eye",{background:background,ring:2,ringColor:ringColor});
|
||||||
else streamDeck.setIcon(context,'','#000000');
|
else streamDeck.setIcon(context,device,'',{background:'#000000'});
|
||||||
if (displayName) txt = 'Shared Vision';
|
if (displayName) txt = 'Shared Vision';
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPressSharedVision(settings,context) {
|
keyPressSharedVision(settings,context,device) {
|
||||||
if (this.getModuleEnable("SharedVision") == false) return;
|
if (this.getModuleEnable("SharedVision") == false) return;
|
||||||
if (game.user.isGM == false) return;
|
if (game.user.isGM == false) return;
|
||||||
|
|
||||||
@@ -356,7 +359,7 @@ export class ExternalModules{
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//Mook AI
|
//Mook AI
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
updateMookAI(settings,context) {
|
updateMookAI(settings,context,device) {
|
||||||
if (this.getModuleEnable("mookAI") == false) return;
|
if (this.getModuleEnable("mookAI") == false) return;
|
||||||
if (game.user.isGM == false) return;
|
if (game.user.isGM == false) return;
|
||||||
|
|
||||||
@@ -366,13 +369,13 @@ 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,device,"fas fa-brain",{background:'#000000'});
|
||||||
else streamDeck.setIcon(context,'','#000000');
|
else streamDeck.setIcon(context,device,'',{background:'#000000'});
|
||||||
if (displayName) txt = 'Mook AI';
|
if (displayName) txt = 'Mook AI';
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
async keyPressMookAI(settings,context) {
|
async keyPressMookAI(settings,context,device) {
|
||||||
if (this.getModuleEnable("mookAI") == false) return;
|
if (this.getModuleEnable("mookAI") == false) return;
|
||||||
if (game.user.isGM == false) return;
|
if (game.user.isGM == false) return;
|
||||||
|
|
||||||
@@ -384,7 +387,7 @@ export class ExternalModules{
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//Not Your Turn!
|
//Not Your Turn!
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
updateNotYourTurn(settings,context) {
|
updateNotYourTurn(settings,context,device) {
|
||||||
|
|
||||||
if (this.getModuleEnable("NotYourTurn") == false) return;
|
if (this.getModuleEnable("NotYourTurn") == false) return;
|
||||||
if (game.user.isGM == false) return;
|
if (game.user.isGM == false) return;
|
||||||
@@ -408,13 +411,13 @@ 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,device,icon,{background:background,ring:2,ringColor:ringColor});
|
||||||
else streamDeck.setIcon(context,'','#000000');
|
else streamDeck.setIcon(context,device,'',{background:'#000000'});
|
||||||
if (displayName == false) txt = '';
|
if (displayName == false) txt = '';
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
async keyPressNotYourTurn(settings,context) {
|
async keyPressNotYourTurn(settings,context,device) {
|
||||||
if (this.getModuleEnable("NotYourTurn") == false) return;
|
if (this.getModuleEnable("NotYourTurn") == false) return;
|
||||||
if (game.user.isGM == false) return;
|
if (game.user.isGM == false) return;
|
||||||
|
|
||||||
@@ -431,7 +434,8 @@ export class ExternalModules{
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//Lock View
|
//Lock View
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
updateLockView(settings,context) {
|
|
||||||
|
updateLockView(settings,context,device) {
|
||||||
|
|
||||||
if (this.getModuleEnable("LockView") == false) return;
|
if (this.getModuleEnable("LockView") == false) return;
|
||||||
if (game.user.isGM == false) return;
|
if (game.user.isGM == false) return;
|
||||||
@@ -461,13 +465,13 @@ 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,device,icon,{background:background,ring:2,ringColor:ringColor});
|
||||||
else streamDeck.setIcon(context,'','#000000');
|
else streamDeck.setIcon(context,device,'',{background:'#000000'});
|
||||||
if (displayName == false) txt = '';
|
if (displayName == false) txt = '';
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
async keyPressLockView(settings,context) {
|
async keyPressLockView(settings,context,device) {
|
||||||
if (this.getModuleEnable("LockView") == false) return;
|
if (this.getModuleEnable("LockView") == false) return;
|
||||||
if (game.user.isGM == false) return;
|
if (game.user.isGM == false) return;
|
||||||
|
|
||||||
@@ -483,6 +487,217 @@ export class ExternalModules{
|
|||||||
|
|
||||||
Hooks.call("setLockView",msg);
|
Hooks.call("setLockView",msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//About Time
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
updateAboutTime(settings,context,device) {
|
||||||
|
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,device,'',{background:background,ring:ring,ringColor:ringColor, clock:clock});
|
||||||
|
}
|
||||||
|
|
||||||
|
keyPressAboutTime(settings,context,device) {
|
||||||
|
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 });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
95
src/macro.js
@@ -1,5 +1,6 @@
|
|||||||
import * as MODULE from "../MaterialDeck.js";
|
import * as MODULE from "../MaterialDeck.js";
|
||||||
import {streamDeck} from "../MaterialDeck.js";
|
import {streamDeck} from "../MaterialDeck.js";
|
||||||
|
import {compatibleCore} from "./misc.js";
|
||||||
|
|
||||||
export class MacroControl{
|
export class MacroControl{
|
||||||
constructor(){
|
constructor(){
|
||||||
@@ -9,14 +10,16 @@ export class MacroControl{
|
|||||||
|
|
||||||
async updateAll(){
|
async updateAll(){
|
||||||
if (this.active == false) return;
|
if (this.active == false) return;
|
||||||
for (let i=0; i<32; i++){
|
for (let device of streamDeck.buttonContext) {
|
||||||
const data = streamDeck.buttonContext[i];
|
for (let i=0; i<device.buttons.length; i++){
|
||||||
|
const data = device.buttons[i];
|
||||||
if (data == undefined || data.action != 'macro') continue;
|
if (data == undefined || data.action != 'macro') continue;
|
||||||
await this.update(data.settings,data.context);
|
await this.update(data.settings,data.context,device.device);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async update(settings,context){
|
async update(settings,context,device){
|
||||||
this.active = true;
|
this.active = true;
|
||||||
const mode = settings.macroMode ? settings.macroMode : 'hotbar';
|
const mode = settings.macroMode ? settings.macroMode : 'hotbar';
|
||||||
const displayName = settings.displayName ? settings.displayName : false;
|
const displayName = settings.displayName ? settings.displayName : false;
|
||||||
@@ -32,10 +35,11 @@ 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 )) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (settings.macroBoardMode == 'offset') { //Offset
|
if (settings.macroBoardMode == 'offset') { //Offset
|
||||||
@@ -57,9 +61,14 @@ export class MacroControl{
|
|||||||
ring = 0;
|
ring = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (mode == 'name') { //macro by name
|
||||||
|
const macroName = settings.macroNumber;
|
||||||
|
const macro = game.macros.getName(macroName);
|
||||||
|
macroId = macro?.id;
|
||||||
|
}
|
||||||
else { //Macro Hotbar
|
else { //Macro Hotbar
|
||||||
if ((MODULE.getPermission('MACRO','HOTBAR') == false )) {
|
if ((MODULE.getPermission('MACRO','HOTBAR') == false )) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mode == 'hotbar') macroId = game.user.data.hotbar[macroNumber];
|
if (mode == 'hotbar') macroId = game.user.data.hotbar[macroNumber];
|
||||||
@@ -70,10 +79,7 @@ export class MacroControl{
|
|||||||
else
|
else
|
||||||
macros = game.macros.apps[0].macros;
|
macros = game.macros.apps[0].macros;
|
||||||
if (macroNumber > 9) macroNumber = 0;
|
if (macroNumber > 9) macroNumber = 0;
|
||||||
for (let j=0; j<10; j++){
|
macroId = game.macros.apps[0].macros.find(m => m.key == macroNumber).macro?.id
|
||||||
if (macros[j].key == macroNumber)
|
|
||||||
macroId = (macros[j].macro == null) ? undefined : macros[j].macro._id;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,19 +89,15 @@ 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 += ')';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if (displayName) name = "";
|
||||||
|
if (displayIcon) src = "modules/MaterialDeck/img/black.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
streamDeck.setIcon(context,device,src,{background:background,ring:ring,ringColor:ringColor,uses:uses});
|
||||||
streamDeck.setIcon(context,src,background,ring,ringColor);
|
|
||||||
streamDeck.setTitle(name,context);
|
streamDeck.setTitle(name,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +123,7 @@ export class MacroControl{
|
|||||||
if(macroNumber == undefined || isNaN(parseInt(macroNumber))) macroNumber = 1;
|
if(macroNumber == undefined || isNaN(parseInt(macroNumber))) macroNumber = 1;
|
||||||
|
|
||||||
if ((MODULE.getPermission('MACRO','HOTBAR') == false )) {
|
if ((MODULE.getPermission('MACRO','HOTBAR') == false )) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,28 +138,17 @@ export class MacroControl{
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (macroNumber > 9) macroNumber = 0;
|
if (macroNumber > 9) macroNumber = 0;
|
||||||
for (let j=0; j<10; j++){
|
macroId = game.macros.apps[0].macros.find(m => m.key == macroNumber).macro?.id
|
||||||
if (macros[j].key == macroNumber){
|
|
||||||
if (macros[j].macro == null) macroId == undefined;
|
|
||||||
else macroId = macros[j].macro._id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
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,device,src,{background:background,uses:uses});
|
||||||
}
|
|
||||||
streamDeck.setIcon(context,src,background);
|
|
||||||
streamDeck.setTitle(name,context);
|
streamDeck.setTitle(name,context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,11 +157,36 @@ export class MacroControl{
|
|||||||
const mode = settings.macroMode ? settings.macroMode : 'hotbar';
|
const mode = settings.macroMode ? settings.macroMode : 'hotbar';
|
||||||
let macroNumber = settings.macroNumber;
|
let macroNumber = settings.macroNumber;
|
||||||
if(macroNumber == undefined || isNaN(parseInt(macroNumber))) macroNumber = 0;
|
if(macroNumber == undefined || isNaN(parseInt(macroNumber))) macroNumber = 0;
|
||||||
|
let target = settings.target ? settings.target : undefined;
|
||||||
|
|
||||||
if (mode == 'hotbar' || mode == 'visibleHotbar' || mode == 'customHotbar'){
|
if (mode == 'hotbar' || mode == 'visibleHotbar' || mode == 'customHotbar'){
|
||||||
if ((MODULE.getPermission('MACRO','HOTBAR') == false )) return;
|
if ((MODULE.getPermission('MACRO','HOTBAR') == false )) return;
|
||||||
this.executeHotbar(macroNumber,mode);
|
this.executeHotbar(macroNumber,mode);
|
||||||
}
|
}
|
||||||
|
else if (mode == 'name') {
|
||||||
|
if ((MODULE.getPermission('MACRO','BY_NAME') == false )) return;
|
||||||
|
const macroName = settings.macroNumber;
|
||||||
|
const macro = game.macros.getName(macroName);
|
||||||
|
|
||||||
|
if (macro == undefined) return;
|
||||||
|
|
||||||
|
const args = settings.macroArgs ? settings.macroArgs : "";
|
||||||
|
|
||||||
|
let furnaceEnabled = false;
|
||||||
|
let furnace = game.modules.get("furnace");
|
||||||
|
if (furnace != undefined && furnace.active && compatibleCore("0.8.1")==false) furnaceEnabled = true;
|
||||||
|
if (args == "" || args == " ") furnaceEnabled = false;
|
||||||
|
if (furnaceEnabled == false) macro.execute({token:target});
|
||||||
|
else {
|
||||||
|
let chatData = {
|
||||||
|
user: game.user._id,
|
||||||
|
speaker: ChatMessage.getSpeaker(),
|
||||||
|
content: "/'" + macro.name + "' " + args
|
||||||
|
};
|
||||||
|
ChatMessage.create(chatData, {});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
if ((MODULE.getPermission('MACRO','MACROBOARD') == false )) return;
|
if ((MODULE.getPermission('MACRO','MACROBOARD') == false )) return;
|
||||||
if (settings.macroBoardMode == 'offset') {
|
if (settings.macroBoardMode == 'offset') {
|
||||||
@@ -194,12 +210,7 @@ export class MacroControl{
|
|||||||
}
|
}
|
||||||
else macros = game.macros.apps[0].macros;
|
else macros = game.macros.apps[0].macros;
|
||||||
if (macroNumber > 9) macroNumber = 0;
|
if (macroNumber > 9) macroNumber = 0;
|
||||||
for (let j=0; j<10; j++){
|
macroId = game.macros.apps[0].macros.find(m => m.key == macroNumber).macro?.id
|
||||||
if (macros[j].key == macroNumber){
|
|
||||||
if (macros[j].macro == null) macroId == undefined;
|
|
||||||
else macroId = macros[j].macro._id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (macroId == undefined) return;
|
if (macroId == undefined) return;
|
||||||
let macro = game.macros.get(macroId);
|
let macro = game.macros.get(macroId);
|
||||||
@@ -218,7 +229,7 @@ export class MacroControl{
|
|||||||
const args = game.settings.get(MODULE.moduleName,'macroSettings').args;
|
const args = game.settings.get(MODULE.moduleName,'macroSettings').args;
|
||||||
let furnaceEnabled = false;
|
let furnaceEnabled = false;
|
||||||
let furnace = game.modules.get("furnace");
|
let furnace = game.modules.get("furnace");
|
||||||
if (furnace != undefined && furnace.active) furnaceEnabled = true;
|
if (furnace != undefined && furnace.active && compatibleCore("0.8.1")==false) furnaceEnabled = true;
|
||||||
if (args == undefined || args[macroNumber] == undefined || args[macroNumber] == "") furnaceEnabled = false;
|
if (args == undefined || args[macroNumber] == undefined || args[macroNumber] == "") furnaceEnabled = false;
|
||||||
if (furnaceEnabled == false) macro.execute();
|
if (furnaceEnabled == false) macro.execute();
|
||||||
else {
|
else {
|
||||||
|
|||||||
64
src/misc.js
@@ -1,6 +1,16 @@
|
|||||||
import * as MODULE from "../MaterialDeck.js";
|
import * as MODULE from "../MaterialDeck.js";
|
||||||
import {macroControl,soundboard,playlistControl} from "../MaterialDeck.js";
|
import {macroControl,soundboard,playlistControl} from "../MaterialDeck.js";
|
||||||
|
|
||||||
|
export function compatibleCore(compatibleVersion){
|
||||||
|
let coreVersion = game.data.version;
|
||||||
|
coreVersion = coreVersion.split(".");
|
||||||
|
compatibleVersion = compatibleVersion.split(".");
|
||||||
|
if (compatibleVersion[0] > coreVersion[0]) return false;
|
||||||
|
if (compatibleVersion[1] > coreVersion[1]) return false;
|
||||||
|
if (compatibleVersion[2] > coreVersion[2]) return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
export class playlistConfigForm extends FormApplication {
|
export class playlistConfigForm extends FormApplication {
|
||||||
constructor(data, options) {
|
constructor(data, options) {
|
||||||
super(data, options);
|
super(data, options);
|
||||||
@@ -17,7 +27,8 @@ export class playlistConfigForm extends FormApplication {
|
|||||||
title: "Material Deck: "+game.i18n.localize("MaterialDeck.Sett.PlaylistConfig"),
|
title: "Material Deck: "+game.i18n.localize("MaterialDeck.Sett.PlaylistConfig"),
|
||||||
template: "./modules/MaterialDeck/templates/playlistConfig.html",
|
template: "./modules/MaterialDeck/templates/playlistConfig.html",
|
||||||
classes: ["sheet"],
|
classes: ["sheet"],
|
||||||
width: 500
|
width: 500,
|
||||||
|
height: "auto"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +76,7 @@ export class playlistConfigForm extends FormApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
playlists: game.playlists.entities,
|
playlists: compatibleCore("0.8.1") ? game.playlists.contents : game.playlists.entities,
|
||||||
numberOfPlaylists: numberOfPlaylists,
|
numberOfPlaylists: numberOfPlaylists,
|
||||||
playlistData: playlistData,
|
playlistData: playlistData,
|
||||||
playMode: playMode
|
playMode: playMode
|
||||||
@@ -171,7 +182,7 @@ export class macroConfigForm extends FormApplication {
|
|||||||
let furnaceEnabled = false;
|
let furnaceEnabled = false;
|
||||||
let height = 95;
|
let height = 95;
|
||||||
let furnace = game.modules.get("furnace");
|
let furnace = game.modules.get("furnace");
|
||||||
if (furnace != undefined && furnace.active) {
|
if (furnace != undefined && furnace.active && compatibleCore("0.8.1")==false) {
|
||||||
furnaceEnabled = true;
|
furnaceEnabled = true;
|
||||||
height += 50;
|
height += 50;
|
||||||
}
|
}
|
||||||
@@ -335,9 +346,11 @@ export class soundboardConfigForm extends FormApplication {
|
|||||||
let playlists = [];
|
let playlists = [];
|
||||||
playlists.push({id:"none",name:game.i18n.localize("MaterialDeck.None")});
|
playlists.push({id:"none",name:game.i18n.localize("MaterialDeck.None")});
|
||||||
playlists.push({id:"FP",name:game.i18n.localize("MaterialDeck.FilePicker")})
|
playlists.push({id:"FP",name:game.i18n.localize("MaterialDeck.FilePicker")})
|
||||||
for (let i=0; i<game.playlists.entities.length; i++){
|
|
||||||
playlists.push({id:game.playlists.entities[i]._id,name:game.playlists.entities[i].name});
|
const playlistArray = compatibleCore("0.8.1") ? game.playlists.contents : game.playlists.entities;
|
||||||
}
|
for (let playlist of playlistArray)
|
||||||
|
playlists.push({id: playlist.id, name: playlist.name})
|
||||||
|
|
||||||
this.playlists = playlists;
|
this.playlists = playlists;
|
||||||
|
|
||||||
//Check what SD model the user is using, and set the number of rows and columns to correspond
|
//Check what SD model the user is using, and set the number of rows and columns to correspond
|
||||||
@@ -376,20 +389,30 @@ export class soundboardConfigForm extends FormApplication {
|
|||||||
else if (this.settings.selectedPlaylists[iteration] == 'FP') selectedPlaylist = 'FP';
|
else if (this.settings.selectedPlaylists[iteration] == 'FP') selectedPlaylist = 'FP';
|
||||||
else {
|
else {
|
||||||
//Get the playlist
|
//Get the playlist
|
||||||
const pl = game.playlists.entities.find(p => p._id == this.settings.selectedPlaylists[iteration]);
|
const playlistArray = compatibleCore("0.8.1") ? game.playlists.contents : game.playlists.entities;
|
||||||
|
let pl = playlistArray.find(p => p.id == this.settings.selectedPlaylists[iteration])
|
||||||
|
|
||||||
if (pl == undefined){
|
if (pl == undefined){
|
||||||
selectedPlaylist = 'none';
|
selectedPlaylist = 'none';
|
||||||
sounds = [];
|
sounds = [];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//Add the sound name and id to the sounds array
|
//Add the sound name and id to the sounds array
|
||||||
for (let i=0; i<pl.sounds.length; i++)
|
if (compatibleCore("0.8.1"))
|
||||||
|
for (let sound of pl.sounds.contents)
|
||||||
sounds.push({
|
sounds.push({
|
||||||
name: pl.sounds[i].name,
|
name: sound.name,
|
||||||
id: pl.sounds[i]._id
|
id: sound.id
|
||||||
});
|
});
|
||||||
|
else {
|
||||||
|
for (let sound of pl.sounds)
|
||||||
|
sounds.push({
|
||||||
|
name: sound.name,
|
||||||
|
id: sound._id
|
||||||
|
});
|
||||||
|
}
|
||||||
//Get the playlist id
|
//Get the playlist id
|
||||||
selectedPlaylist = pl._id;
|
selectedPlaylist = pl.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -489,8 +512,9 @@ export class soundboardConfigForm extends FormApplication {
|
|||||||
//Show the sound selector
|
//Show the sound selector
|
||||||
document.querySelector(`#ss${iteration}`).style='';
|
document.querySelector(`#ss${iteration}`).style='';
|
||||||
|
|
||||||
const pl = game.playlists.entities.find(p => p._id == event.target.value);
|
const playlistArray = compatibleCore("0.8.1") ? game.playlists.contents : game.playlists.entities;
|
||||||
selectedPlaylist = pl._id;
|
const pl = playlistArray.find(p => p.id == event.target.value)
|
||||||
|
selectedPlaylist = pl.id;
|
||||||
|
|
||||||
//Get the sound select element
|
//Get the sound select element
|
||||||
let SSpicker = document.getElementById(`soundSelect${iteration}`);
|
let SSpicker = document.getElementById(`soundSelect${iteration}`);
|
||||||
@@ -504,10 +528,18 @@ export class soundboardConfigForm extends FormApplication {
|
|||||||
optionNone.innerHTML = game.i18n.localize("MaterialDeck.None");
|
optionNone.innerHTML = game.i18n.localize("MaterialDeck.None");
|
||||||
SSpicker.appendChild(optionNone);
|
SSpicker.appendChild(optionNone);
|
||||||
|
|
||||||
for (let i=0; i<pl.sounds.length; i++){
|
if (compatibleCore("0.8.1"))
|
||||||
|
for (let sound of pl.sounds.contents) {
|
||||||
let newOption = document.createElement('option');
|
let newOption = document.createElement('option');
|
||||||
newOption.value = pl.sounds[i]._id;
|
newOption.value = sound.id;
|
||||||
newOption.innerHTML = pl.sounds[i].name;
|
newOption.innerHTML = sound.name;
|
||||||
|
SSpicker.appendChild(newOption);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
for (let sound of pl.sounds) {
|
||||||
|
let newOption = document.createElement('option');
|
||||||
|
newOption.value = sound._id;
|
||||||
|
newOption.innerHTML = sound.name;
|
||||||
SSpicker.appendChild(newOption);
|
SSpicker.appendChild(newOption);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
42
src/move.js
@@ -1,18 +1,19 @@
|
|||||||
import * as MODULE from "../MaterialDeck.js";
|
import * as MODULE from "../MaterialDeck.js";
|
||||||
import {streamDeck} from "../MaterialDeck.js";
|
import {streamDeck} from "../MaterialDeck.js";
|
||||||
|
import {compatibleCore} from "./misc.js";
|
||||||
|
|
||||||
export class Move{
|
export class Move{
|
||||||
constructor(){
|
constructor(){
|
||||||
this.active = false;
|
this.active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
update(settings,context){
|
update(settings,context,device){
|
||||||
const background = settings.background ? settings.background : '#000000';
|
const background = settings.background ? settings.background : '#000000';
|
||||||
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')) {
|
if ((MODULE.getPermission('MOVE','TOKEN') == false && mode == 'selectedToken') || (MODULE.getPermission('MOVE','CANVAS') == false && mode == 'canvas')) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,20 +50,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,device,url,{background:background,overlay:true});
|
||||||
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,device);
|
||||||
|
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 +94,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);
|
||||||
|
|
||||||
@@ -96,13 +107,13 @@ export class Move{
|
|||||||
if (rotType == 'by') rotationVal = token.data.rotation + value;
|
if (rotType == 'by') rotationVal = token.data.rotation + value;
|
||||||
else if (rotType == 'to') rotationVal = value;
|
else if (rotType == 'to') rotationVal = value;
|
||||||
|
|
||||||
token.update({rotation: rotationVal});
|
if (compatibleCore("0.8.1")) token.document.update({rotation: rotationVal});
|
||||||
|
else token.update({rotation: rotationVal});
|
||||||
|
//token.rotate(rotationVal,false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
@@ -132,7 +143,8 @@ export class Move{
|
|||||||
canvas.animatePan(location);
|
canvas.animatePan(location);
|
||||||
}
|
}
|
||||||
if (game.user.isGM == false && (token.can(game.user,"control") == false || token.checkCollision(token.getCenter(x, y)))) return;
|
if (game.user.isGM == false && (token.can(game.user,"control") == false || token.checkCollision(token.getCenter(x, y)))) return;
|
||||||
token.update({x:x,y:y});
|
if (compatibleCore("0.8.1")) token.document.update({x:x,y:y});
|
||||||
|
else token.update({x:x,y:y});
|
||||||
};
|
};
|
||||||
|
|
||||||
moveCanvas(dir){
|
moveCanvas(dir){
|
||||||
|
|||||||
@@ -1,46 +1,59 @@
|
|||||||
import * as MODULE from "../MaterialDeck.js";
|
import * as MODULE from "../MaterialDeck.js";
|
||||||
import {streamDeck} from "../MaterialDeck.js";
|
import {streamDeck} from "../MaterialDeck.js";
|
||||||
|
import {compatibleCore} from "./misc.js";
|
||||||
|
|
||||||
export class OtherControls{
|
export class OtherControls{
|
||||||
constructor(){
|
constructor(){
|
||||||
this.active = false;
|
this.active = false;
|
||||||
this.rollData = {};
|
this.rollData = {};
|
||||||
|
this.rollOption = 'dialog';
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateAll(){
|
setRollOption(option) {
|
||||||
|
this.rollOption = option;
|
||||||
|
this.updateAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
async updateAll(options={}){
|
||||||
if (this.active == false) return;
|
if (this.active == false) return;
|
||||||
for (let i=0; i<32; i++){
|
for (let device of streamDeck.buttonContext) {
|
||||||
const data = streamDeck.buttonContext[i];
|
for (let i=0; i<device.buttons.length; i++){
|
||||||
|
const data = device.buttons[i];
|
||||||
if (data == undefined || data.action != 'other') continue;
|
if (data == undefined || data.action != 'other') continue;
|
||||||
await this.update(data.settings,data.context);
|
await this.update(data.settings,data.context,device.device);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update(settings,context){
|
update(settings,context,device,options={}){
|
||||||
this.active = true;
|
this.active = true;
|
||||||
const mode = settings.otherMode ? settings.otherMode : 'pause';
|
const mode = settings.otherMode ? settings.otherMode : 'pause';
|
||||||
|
|
||||||
if (mode == 'pause') //pause
|
if (mode == 'pause') //pause
|
||||||
this.updatePause(settings,context);
|
this.updatePause(settings,context,device,options);
|
||||||
else if (mode == 'controlButtons') //control buttons
|
else if (mode == 'controlButtons') //control buttons
|
||||||
this.updateControl(settings,context);
|
this.updateControl(settings,context,device,options);
|
||||||
else if (mode == 'darkness') //darkness
|
else if (mode == 'darkness') //darkness
|
||||||
this.updateDarkness(settings,context);
|
this.updateDarkness(settings,context,device,options);
|
||||||
else if (mode == 'rollDice') //roll dice
|
else if (mode == 'rollDice') //roll dice
|
||||||
this.updateRollDice(settings,context);
|
this.updateRollDice(settings,context,device,options);
|
||||||
else if (mode == 'rollTables') //roll tables
|
else if (mode == 'rollTables') //roll tables
|
||||||
this.updateRollTable(settings,context);
|
this.updateRollTable(settings,context,device,options);
|
||||||
else if (mode == 'sidebarTab') //open sidebar tab
|
else if (mode == 'sidebarTab') //open sidebar tab
|
||||||
this.updateSidebar(settings,context);
|
this.updateSidebar(settings,context,device,options);
|
||||||
|
else if (mode == 'compendiumBrowser') //open compendium browser
|
||||||
|
this.updateCompendiumBrowser(settings,context,device,options);
|
||||||
else if (mode == 'compendium') //open compendium
|
else if (mode == 'compendium') //open compendium
|
||||||
this.updateCompendium(settings,context);
|
this.updateCompendium(settings,context,device,options);
|
||||||
else if (mode == 'journal') //open journal
|
else if (mode == 'journal') //open journal
|
||||||
this.updateJournal(settings,context);
|
this.updateJournal(settings,context,device,options);
|
||||||
else if (mode == 'chatMessage')
|
else if (mode == 'chatMessage')
|
||||||
this.updateChatMessage(settings,context);
|
this.updateChatMessage(settings,context,device,options);
|
||||||
|
else if (mode == 'rollOptions')
|
||||||
|
this.updateRollOptions(settings,context,device,options);
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPress(settings,context){
|
keyPress(settings,context,device){
|
||||||
const mode = settings.otherMode ? settings.otherMode : 'pause';
|
const mode = settings.otherMode ? settings.otherMode : 'pause';
|
||||||
|
|
||||||
if (mode == 'pause') //pause
|
if (mode == 'pause') //pause
|
||||||
@@ -50,24 +63,28 @@ export class OtherControls{
|
|||||||
else if (mode == 'darkness') //darkness controll
|
else if (mode == 'darkness') //darkness controll
|
||||||
this.keyPressDarkness(settings);
|
this.keyPressDarkness(settings);
|
||||||
else if (mode == 'rollDice') //roll dice
|
else if (mode == 'rollDice') //roll dice
|
||||||
this.keyPressRollDice(settings,context);
|
this.keyPressRollDice(settings,context,device);
|
||||||
else if (mode == 'rollTables') //roll tables
|
else if (mode == 'rollTables') //roll tables
|
||||||
this.keyPressRollTable(settings);
|
this.keyPressRollTable(settings);
|
||||||
else if (mode == 'sidebarTab') //sidebar
|
else if (mode == 'sidebarTab') //sidebar
|
||||||
this.keyPressSidebar(settings);
|
this.keyPressSidebar(settings);
|
||||||
|
else if (mode == 'compendiumBrowser') //open compendium browser
|
||||||
|
this.keyPressCompendiumBrowser(settings);
|
||||||
else if (mode == 'compendium') //open compendium
|
else if (mode == 'compendium') //open compendium
|
||||||
this.keyPressCompendium(settings);
|
this.keyPressCompendium(settings);
|
||||||
else if (mode == 'journal') //open journal
|
else if (mode == 'journal') //open journal
|
||||||
this.keyPressJournal(settings);
|
this.keyPressJournal(settings);
|
||||||
else if (mode == 'chatMessage')
|
else if (mode == 'chatMessage')
|
||||||
this.keyPressChatMessage(settings);
|
this.keyPressChatMessage(settings);
|
||||||
|
else if (mode == 'rollOptions')
|
||||||
|
this.keyPressRollOptions(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
updatePause(settings,context){
|
updatePause(settings,context,device,options={}){
|
||||||
if (MODULE.getPermission('OTHER','PAUSE') == false ) {
|
if (MODULE.getPermission('OTHER','PAUSE') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +103,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,device,src,{background:background,ring:2,ringColor:ringColor,overlay:true});
|
||||||
streamDeck.setTitle('',context);
|
streamDeck.setTitle('',context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,22 +114,22 @@ export class OtherControls{
|
|||||||
|
|
||||||
if (pauseFunction == 'pause'){ //Pause game
|
if (pauseFunction == 'pause'){ //Pause game
|
||||||
if (game.paused) return;
|
if (game.paused) return;
|
||||||
game.togglePause();
|
game.togglePause(true,true);
|
||||||
}
|
}
|
||||||
else if (pauseFunction == 'resume'){ //Resume game
|
else if (pauseFunction == 'resume'){ //Resume game
|
||||||
if (game.paused == false) return;
|
if (game.paused == false) return;
|
||||||
game.togglePause();
|
game.togglePause(false,true);
|
||||||
}
|
}
|
||||||
else if (pauseFunction == 'toggle') { //toggle
|
else if (pauseFunction == 'toggle') { //toggle
|
||||||
game.togglePause();
|
game.togglePause(!game.paused,true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
updateControl(settings,context){
|
updateControl(settings,context,device,options={}){
|
||||||
if (MODULE.getPermission('OTHER','CONTROL') == false ) {
|
if (MODULE.getPermission('OTHER','CONTROL') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const control = settings.control ? settings.control : 'dispControls';
|
const control = settings.control ? settings.control : 'dispControls';
|
||||||
@@ -130,11 +147,12 @@ export class OtherControls{
|
|||||||
controlNr--;
|
controlNr--;
|
||||||
|
|
||||||
const selectedControl = ui.controls.controls[controlNr];
|
const selectedControl = ui.controls.controls[controlNr];
|
||||||
|
|
||||||
|
if (selectedControl != undefined){
|
||||||
if (selectedControl.visible == false) {
|
if (selectedControl.visible == false) {
|
||||||
streamDeck.noPermission(context,false);
|
streamDeck.noPermission(context,device,false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (selectedControl != undefined){
|
|
||||||
if (tool == 'open'){ //open category
|
if (tool == 'open'){ //open category
|
||||||
txt = game.i18n.localize(selectedControl.title);
|
txt = game.i18n.localize(selectedControl.title);
|
||||||
src = selectedControl.icon;
|
src = selectedControl.icon;
|
||||||
@@ -153,7 +171,7 @@ export class OtherControls{
|
|||||||
const selectedTool = selectedControl.tools[controlNr];
|
const selectedTool = selectedControl.tools[controlNr];
|
||||||
if (selectedTool != undefined){
|
if (selectedTool != undefined){
|
||||||
if (selectedControl.visible == false || selectedTool.visible == false) {
|
if (selectedControl.visible == false || selectedTool.visible == false) {
|
||||||
streamDeck.noPermission(context,false);
|
streamDeck.noPermission(context,device,false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
txt = game.i18n.localize(selectedTool.title);
|
txt = game.i18n.localize(selectedTool.title);
|
||||||
@@ -171,7 +189,7 @@ export class OtherControls{
|
|||||||
const selectedControl = ui.controls.controls.find(c => c.name == control);
|
const selectedControl = ui.controls.controls.find(c => c.name == control);
|
||||||
if (selectedControl != undefined){
|
if (selectedControl != undefined){
|
||||||
if (selectedControl.visible == false) {
|
if (selectedControl.visible == false) {
|
||||||
streamDeck.noPermission(context,false);
|
streamDeck.noPermission(context,device,false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (tool == 'open'){ //open category
|
if (tool == 'open'){ //open category
|
||||||
@@ -184,7 +202,7 @@ export class OtherControls{
|
|||||||
const selectedTool = selectedControl.tools.find(t => t.name == tool);
|
const selectedTool = selectedControl.tools.find(t => t.name == tool);
|
||||||
if (selectedTool != undefined){
|
if (selectedTool != undefined){
|
||||||
if (selectedTool.visible == false) {
|
if (selectedTool.visible == false) {
|
||||||
streamDeck.noPermission(context,false);
|
streamDeck.noPermission(context,device,false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
txt = game.i18n.localize(selectedTool.title);
|
txt = game.i18n.localize(selectedTool.title);
|
||||||
@@ -199,7 +217,7 @@ export class OtherControls{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
streamDeck.setIcon(context,src,background,2,ringColor);
|
streamDeck.setIcon(context,device,src,{background:background,ring:2,ringColor:ringColor});
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,12 +232,13 @@ export class OtherControls{
|
|||||||
if (isNaN(controlNr)) controlNr = 1;
|
if (isNaN(controlNr)) controlNr = 1;
|
||||||
controlNr--;
|
controlNr--;
|
||||||
const selectedControl = ui.controls.controls[controlNr];
|
const selectedControl = ui.controls.controls[controlNr];
|
||||||
|
|
||||||
if (selectedControl != undefined){
|
if (selectedControl != undefined){
|
||||||
if (selectedControl.visible == false) {
|
if (selectedControl.visible == false) {
|
||||||
streamDeck.noPermission(context,false);
|
streamDeck.noPermission(context,device,false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ui.controls.activeControl = 'token';
|
ui.controls.activeControl = selectedControl.name;
|
||||||
selectedControl.activeTool = selectedControl.activeTool;
|
selectedControl.activeTool = selectedControl.activeTool;
|
||||||
canvas.getLayer(selectedControl.layer).activate();
|
canvas.getLayer(selectedControl.layer).activate();
|
||||||
}
|
}
|
||||||
@@ -231,13 +250,13 @@ export class OtherControls{
|
|||||||
const selectedControl = ui.controls.controls.find(c => c.name == ui.controls.activeControl);
|
const selectedControl = ui.controls.controls.find(c => c.name == ui.controls.activeControl);
|
||||||
if (selectedControl != undefined){
|
if (selectedControl != undefined){
|
||||||
if (selectedControl.visible == false) {
|
if (selectedControl.visible == false) {
|
||||||
streamDeck.noPermission(context,false);
|
streamDeck.noPermission(context,device,false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const selectedTool = selectedControl.tools[controlNr];
|
const selectedTool = selectedControl.tools[controlNr];
|
||||||
if (selectedTool != undefined){
|
if (selectedTool != undefined){
|
||||||
if (selectedTool.visible == false) {
|
if (selectedTool.visible == false) {
|
||||||
streamDeck.noPermission(context,false);
|
streamDeck.noPermission(context,device,false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (selectedTool.toggle) {
|
if (selectedTool.toggle) {
|
||||||
@@ -256,11 +275,11 @@ export class OtherControls{
|
|||||||
const selectedControl = ui.controls.controls.find(c => c.name == control);
|
const selectedControl = ui.controls.controls.find(c => c.name == control);
|
||||||
if (selectedControl != undefined){
|
if (selectedControl != undefined){
|
||||||
if (selectedControl.visible == false) {
|
if (selectedControl.visible == false) {
|
||||||
streamDeck.noPermission(context,false);
|
streamDeck.noPermission(context,device,false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (tool == 'open'){ //open category
|
if (tool == 'open'){ //open category
|
||||||
ui.controls.activeControl = 'token';
|
ui.controls.activeControl = control;
|
||||||
selectedControl.activeTool = selectedControl.activeTool;
|
selectedControl.activeTool = selectedControl.activeTool;
|
||||||
canvas.getLayer(selectedControl.layer).activate();
|
canvas.getLayer(selectedControl.layer).activate();
|
||||||
}
|
}
|
||||||
@@ -268,7 +287,7 @@ export class OtherControls{
|
|||||||
const selectedTool = selectedControl.tools.find(t => t.name == tool);
|
const selectedTool = selectedControl.tools.find(t => t.name == tool);
|
||||||
if (selectedTool != undefined){
|
if (selectedTool != undefined){
|
||||||
if (selectedTool.visible == false) {
|
if (selectedTool.visible == false) {
|
||||||
streamDeck.noPermission(context,false);
|
streamDeck.noPermission(context,device,false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ui.controls.activeControl = control;
|
ui.controls.activeControl = control;
|
||||||
@@ -291,9 +310,9 @@ export class OtherControls{
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
updateDarkness(settings,context){
|
updateDarkness(settings,context,device,options={}){
|
||||||
if (MODULE.getPermission('OTHER','DARKNESS') == false ) {
|
if (MODULE.getPermission('OTHER','DARKNESS') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const func = settings.darknessFunction ? settings.darknessFunction : 'value';
|
const func = settings.darknessFunction ? settings.darknessFunction : 'value';
|
||||||
@@ -316,7 +335,7 @@ export class OtherControls{
|
|||||||
txt += darkness;
|
txt += darkness;
|
||||||
}
|
}
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
streamDeck.setIcon(context,src,background);
|
streamDeck.setIcon(context,device,src,{background:background,overlay:true});
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPressDarkness(settings) {
|
keyPressDarkness(settings) {
|
||||||
@@ -337,9 +356,9 @@ export class OtherControls{
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
updateRollDice(settings,context){
|
updateRollDice(settings,context,device,options={}){
|
||||||
if (MODULE.getPermission('OTHER','DICE') == false ) {
|
if (MODULE.getPermission('OTHER','DICE') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const background = settings.background ? settings.background : '#000000';
|
const background = settings.background ? settings.background : '#000000';
|
||||||
@@ -348,10 +367,10 @@ 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,device,'',{background:background});
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPressRollDice(settings,context){
|
keyPressRollDice(settings,context,device){
|
||||||
if (MODULE.getPermission('OTHER','DICE') == false ) return;
|
if (MODULE.getPermission('OTHER','DICE') == false ) return;
|
||||||
if (settings.rollDiceFormula == undefined || settings.rollDiceFormula == '') return;
|
if (settings.rollDiceFormula == undefined || settings.rollDiceFormula == '') return;
|
||||||
const rollFunction = settings.rollDiceFunction ? settings.rollDiceFunction : 'public';
|
const rollFunction = settings.rollDiceFunction ? settings.rollDiceFunction : 'public';
|
||||||
@@ -389,16 +408,16 @@ export class OtherControls{
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
updateRollTable(settings,context){
|
updateRollTable(settings,context,device,options={}){
|
||||||
const name = settings.rollTableName;
|
const name = settings.rollTableName;
|
||||||
if (name == undefined) return;
|
if (name == undefined) return;
|
||||||
if (MODULE.getPermission('OTHER','TABLES') == false ) {
|
if (MODULE.getPermission('OTHER','TABLES') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 : '';
|
||||||
@@ -409,13 +428,13 @@ export class OtherControls{
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (table.permission < 2 && MODULE.getPermission('OTHER','TABLES_ALL') == false ) {
|
if (table.permission < 2 && MODULE.getPermission('OTHER','TABLES_ALL') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
streamDeck.setIcon(context,src,background);
|
streamDeck.setIcon(context,device,src,{background:background});
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPressRollTable(settings){
|
keyPressRollTable(settings){
|
||||||
@@ -424,7 +443,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;
|
||||||
@@ -474,50 +493,93 @@ export class OtherControls{
|
|||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
updateSidebar(settings,context){
|
updateSidebar(settings,context,device,options={}){
|
||||||
if (MODULE.getPermission('OTHER','SIDEBAR') == false ) {
|
if (MODULE.getPermission('OTHER','SIDEBAR') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const popOut = settings.sidebarPopOut ? settings.sidebarPopOut : false;
|
||||||
const sidebarTab = settings.sidebarTab ? settings.sidebarTab : 'chat';
|
const sidebarTab = settings.sidebarTab ? settings.sidebarTab : 'chat';
|
||||||
const background = settings.background ? settings.background : '#000000';
|
const background = settings.background ? settings.background : '#000000';
|
||||||
const collapsed = ui.sidebar._collapsed;
|
const collapsed = ui.sidebar._collapsed;
|
||||||
|
const activeTab = ui.sidebar.activeTab;
|
||||||
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
|
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
|
||||||
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
|
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
|
||||||
const ringColor = (sidebarTab == 'collapse' && collapsed) ? ringOnColor : ringOffColor;
|
let ringColor = ringOffColor;
|
||||||
|
if (popOut && options.sidebarTab == sidebarTab) {
|
||||||
|
ringColor = options.renderPopout ? ringOnColor : ringOffColor;
|
||||||
|
}
|
||||||
|
else ringColor = (sidebarTab == 'collapse' && collapsed || (activeTab == sidebarTab)) ? ringOnColor : ringOffColor;
|
||||||
const name = settings.displaySidebarName ? this.getSidebarName(sidebarTab) : '';
|
const name = settings.displaySidebarName ? this.getSidebarName(sidebarTab) : '';
|
||||||
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,device,icon,{background:background,ring:2,ringColor:ringColor});
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPressSidebar(settings){
|
keyPressSidebar(settings){
|
||||||
if (MODULE.getPermission('OTHER','SIDEBAR') == false ) return;
|
if (MODULE.getPermission('OTHER','SIDEBAR') == false ) return;
|
||||||
const sidebarTab = settings.sidebarTab ? settings.sidebarTab : 'chat';
|
const sidebarTab = settings.sidebarTab ? settings.sidebarTab : 'chat';
|
||||||
|
const popOut = settings.sidebarPopOut ? settings.sidebarPopOut : false;
|
||||||
|
|
||||||
if (sidebarTab == 'collapse'){
|
if (sidebarTab == 'collapse'){
|
||||||
const collapsed = ui.sidebar._collapsed;
|
const collapsed = ui.sidebar._collapsed;
|
||||||
if (collapsed) ui.sidebar.expand();
|
if (collapsed) ui.sidebar.expand();
|
||||||
else if (collapsed == false) ui.sidebar.collapse();
|
else if (collapsed == false) ui.sidebar.collapse();
|
||||||
}
|
}
|
||||||
else ui.sidebar.activateTab(sidebarTab);
|
else if (popOut == false) ui.sidebar.activateTab(sidebarTab);
|
||||||
|
else {
|
||||||
|
const element = document.getElementById(sidebarTab+"-popout");
|
||||||
|
if (element == null) ui?.[sidebarTab].renderPopout();
|
||||||
|
else element.getElementsByClassName("close")[0].click();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
updateCompendium(settings,context){
|
updateCompendiumBrowser(settings,context,device,options={}){
|
||||||
|
let rendered = options.renderCompendiumBrowser;
|
||||||
|
if (rendered == undefined && game.system.id == "pf2e") rendered = (document.getElementById("app-1") != null);
|
||||||
|
else if (rendered == undefined) rendered = (document.getElementById("compendium-popout") != null);
|
||||||
|
const background = settings.background ? settings.background : '#000000';
|
||||||
|
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
|
||||||
|
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
|
||||||
|
const ringColor = rendered ? ringOnColor : ringOffColor;
|
||||||
|
const txt = settings.displayCompendiumName ? name : '';
|
||||||
|
|
||||||
|
streamDeck.setTitle(txt,context);
|
||||||
|
streamDeck.setIcon(context,device,"",{background:background,ring:2,ringColor:ringColor});
|
||||||
|
}
|
||||||
|
|
||||||
|
keyPressCompendiumBrowser(settings){
|
||||||
|
let element = null;
|
||||||
|
if (game.system.id == "pf2e") element = document.getElementById("app-1")
|
||||||
|
else element = document.getElementById("compendium-popout");
|
||||||
|
const rendered = (element != null);
|
||||||
|
|
||||||
|
if (rendered)
|
||||||
|
element.getElementsByClassName("close")[0].click();
|
||||||
|
else if (game.system.id == "pf2e")
|
||||||
|
document.getElementsByClassName("compendium-browser-btn")[0].click()
|
||||||
|
else
|
||||||
|
ui.compendium.renderPopout();
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
updateCompendium(settings,context,device,options={}){
|
||||||
const name = settings.compendiumName;
|
const name = settings.compendiumName;
|
||||||
if (name == undefined) return;
|
if (name == undefined) return;
|
||||||
if (MODULE.getPermission('OTHER','COMPENDIUM') == false ) {
|
if (MODULE.getPermission('OTHER','COMPENDIUM') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let compendium;
|
||||||
const compendium = game.packs.entries.find(p=>p.metadata.label == name);
|
if (compatibleCore("0.8.1")) compendium = game.packs.contents.find(p=>p.metadata.label == name)?.apps[0];
|
||||||
|
else compendium = game.packs.entries.find(p=>p.metadata.label == name);
|
||||||
if (compendium == undefined) return;
|
if (compendium == undefined) return;
|
||||||
if (compendium.private && MODULE.getPermission('OTHER','COMPENDIUM_ALL') == false) {
|
if (compendium.private && MODULE.getPermission('OTHER','COMPENDIUM_ALL') == false) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const background = settings.background ? settings.background : '#000000';
|
const background = settings.background ? settings.background : '#000000';
|
||||||
@@ -527,7 +589,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,device,"",{background:background,ring:2,ringColor:ringColor});
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPressCompendium(settings){
|
keyPressCompendium(settings){
|
||||||
@@ -535,16 +597,18 @@ export class OtherControls{
|
|||||||
if (name == undefined) return;
|
if (name == undefined) return;
|
||||||
if (MODULE.getPermission('OTHER','COMPENDIUM') == false ) return;
|
if (MODULE.getPermission('OTHER','COMPENDIUM') == false ) return;
|
||||||
|
|
||||||
const compendium = game.packs.entries.find(p=>p.metadata.label == name);
|
let compendium;
|
||||||
|
if (compatibleCore("0.8.1")) compendium = game.packs.contents.find(p=>p.metadata.label == name)?.apps[0];
|
||||||
|
else compendium = game.packs.entries.find(p=>p.metadata.label == name);
|
||||||
if (compendium == undefined) return;
|
if (compendium == undefined) return;
|
||||||
if (compendium.private && MODULE.getPermission('OTHER','COMPENDIUM_ALL') == false) return;
|
if (compendium.private && MODULE.getPermission('OTHER','COMPENDIUM_ALL') == false) return;
|
||||||
if (compendium.rendered) compendium.close();
|
else if (compendium.rendered) compendium.close();
|
||||||
else compendium.render(true);
|
else compendium.render(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
updateJournal(settings,context){
|
updateJournal(settings,context,device,options={}){
|
||||||
const name = settings.compendiumName;
|
const name = settings.compendiumName;
|
||||||
if (name == undefined) return;
|
if (name == undefined) return;
|
||||||
|
|
||||||
@@ -552,22 +616,30 @@ export class OtherControls{
|
|||||||
if (journal == undefined) return;
|
if (journal == undefined) return;
|
||||||
|
|
||||||
if (MODULE.getPermission('OTHER','JOURNAL') == false ) {
|
if (MODULE.getPermission('OTHER','JOURNAL') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (journal.permission < 2 && MODULE.getPermission('OTHER','JOURNAL_ALL') == false ) {
|
if (journal.permission < 2 && MODULE.getPermission('OTHER','JOURNAL_ALL') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let rendered = false;
|
||||||
|
|
||||||
|
if (options?.sheet?.title == name) {
|
||||||
|
if (options.hook == 'renderJournalSheet') rendered = true;
|
||||||
|
else if (options.hook == 'closeJournalSheet') rendered = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (document.getElementById("journalentry-sheet-"+journal.id) != null) rendered = true;
|
||||||
|
|
||||||
const background = settings.background ? settings.background : '#000000';
|
const background = settings.background ? settings.background : '#000000';
|
||||||
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
|
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
|
||||||
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
|
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
|
||||||
const ringColor = journal.sheet.rendered ? ringOnColor : ringOffColor;
|
const ringColor = rendered ? ringOnColor : ringOffColor;
|
||||||
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,device,"",{background:background,ring:2,ringColor:ringColor});
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPressJournal(settings){
|
keyPressJournal(settings){
|
||||||
@@ -580,21 +652,20 @@ export class OtherControls{
|
|||||||
if (MODULE.getPermission('OTHER','JOURNAL') == false ) return;
|
if (MODULE.getPermission('OTHER','JOURNAL') == false ) return;
|
||||||
if (journal.permission < 2 && MODULE.getPermission('OTHER','JOURNAL_ALL') == false ) return;
|
if (journal.permission < 2 && MODULE.getPermission('OTHER','JOURNAL_ALL') == false ) return;
|
||||||
|
|
||||||
const element = document.getElementById("journal-"+journal.id);
|
if (journal.sheet.rendered == false) journal.sheet.render(true);
|
||||||
if (element == null) journal.render(true);
|
|
||||||
else journal.sheet.close();
|
else journal.sheet.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
updateChatMessage(settings,context){
|
updateChatMessage(settings,context,device,options={}){
|
||||||
if (MODULE.getPermission('OTHER','CHAT') == false ) {
|
if (MODULE.getPermission('OTHER','CHAT') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
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,device,"",{background:background});
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPressChatMessage(settings){
|
keyPressChatMessage(settings){
|
||||||
@@ -608,4 +679,25 @@ export class OtherControls{
|
|||||||
};
|
};
|
||||||
ChatMessage.create(chatData, {});
|
ChatMessage.create(chatData, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
updateRollOptions(settings,context,device,options={}){
|
||||||
|
const background = settings.background ? settings.background : '#000000';
|
||||||
|
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
|
||||||
|
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
|
||||||
|
const iconSrc = "modules/MaterialDeck/img/other/d20.png";
|
||||||
|
const rollOption = settings.rollOptionFunction ? settings.rollOptionFunction : 'normal';
|
||||||
|
const ringColor = (rollOption == this.rollOption) ? ringOnColor : ringOffColor;
|
||||||
|
streamDeck.setTitle("",context);
|
||||||
|
streamDeck.setIcon(context,device,iconSrc,{background:background,ring:2,ringColor:ringColor,overlay:true});
|
||||||
|
}
|
||||||
|
|
||||||
|
keyPressRollOptions(settings){
|
||||||
|
const rollOption = settings.rollOptionFunction ? settings.rollOptionFunction : 'normal';
|
||||||
|
if (this.rollOption != rollOption) {
|
||||||
|
this.rollOption = rollOption;
|
||||||
|
this.updateAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
143
src/playlist.js
@@ -1,5 +1,6 @@
|
|||||||
import * as MODULE from "../MaterialDeck.js";
|
import * as MODULE from "../MaterialDeck.js";
|
||||||
import {streamDeck} from "../MaterialDeck.js";
|
import {streamDeck} from "../MaterialDeck.js";
|
||||||
|
import {compatibleCore} from "./misc.js";
|
||||||
|
|
||||||
export class PlaylistControl{
|
export class PlaylistControl{
|
||||||
constructor(){
|
constructor(){
|
||||||
@@ -10,51 +11,47 @@ export class PlaylistControl{
|
|||||||
|
|
||||||
async updateAll(){
|
async updateAll(){
|
||||||
if (this.active == false) return;
|
if (this.active == false) return;
|
||||||
for (let i=0; i<32; i++){
|
for (let device of streamDeck.buttonContext) {
|
||||||
const data = streamDeck.buttonContext[i];
|
for (let i=0; i<device.buttons.length; i++){
|
||||||
|
const data = device.buttons[i];
|
||||||
if (data == undefined || data.action != 'playlist') continue;
|
if (data == undefined || data.action != 'playlist') continue;
|
||||||
await this.update(data.settings,data.context);
|
await this.update(data.settings,data.context,device.device);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update(settings,context){
|
update(settings,context,device){
|
||||||
if (MODULE.getPermission('PLAYLIST','PLAY') == false ) {
|
if (MODULE.getPermission('PLAYLIST','PLAY') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
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'){
|
|
||||||
this.updatePlaylist(settings,context);
|
if (mode == 'playlist'){
|
||||||
|
this.updatePlaylist(settings,context,device);
|
||||||
}
|
}
|
||||||
else if (settings.playlistMode == 'track'){
|
else if (mode == 'track'){
|
||||||
this.updateTrack(settings,context);
|
this.updateTrack(settings,context,device);
|
||||||
}
|
}
|
||||||
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,device,src,{background:background,ring:ring,ringColor:ringColor,overlay:true});
|
||||||
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updatePlaylist(settings,context){
|
updatePlaylist(settings,context,device){
|
||||||
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 +76,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,device,"",{background:background,ring:2,ringColor:ringColor});
|
||||||
streamDeck.setTitle(name,context);
|
streamDeck.setTitle(name,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTrack(settings,context){
|
updateTrack(settings,context,device){
|
||||||
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'){
|
||||||
@@ -113,7 +112,10 @@ export class PlaylistControl{
|
|||||||
|
|
||||||
let playlist = this.getPlaylist(playlistNr);
|
let playlist = this.getPlaylist(playlistNr);
|
||||||
if (playlist != undefined){
|
if (playlist != undefined){
|
||||||
let track = playlist.data.sounds[trackNr];
|
let track;
|
||||||
|
if (compatibleCore("0.8.1")) track = playlist.sounds.contents[trackNr];
|
||||||
|
else track = playlist.data.sounds[trackNr];
|
||||||
|
|
||||||
if (track != undefined){
|
if (track != undefined){
|
||||||
if (track.playing)
|
if (track.playing)
|
||||||
ringColor = ringOnColor;
|
ringColor = ringOnColor;
|
||||||
@@ -125,12 +127,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,device,"",{background:background,ring:2,ringColor:ringColor});
|
||||||
streamDeck.setTitle(name,context);
|
streamDeck.setTitle(name,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -168,7 +173,7 @@ export class PlaylistControl{
|
|||||||
else return undefined;
|
else return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPress(settings,context){
|
keyPress(settings,context,device){
|
||||||
if (MODULE.getPermission('PLAYLIST','PLAY') == false ) return;
|
if (MODULE.getPermission('PLAYLIST','PLAY') == false ) return;
|
||||||
let playlistNr = settings.playlistNr;
|
let playlistNr = settings.playlistNr;
|
||||||
if (playlistNr == undefined || playlistNr < 1) playlistNr = 1;
|
if (playlistNr == undefined || playlistNr < 1) playlistNr = 1;
|
||||||
@@ -179,27 +184,30 @@ 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;
|
||||||
|
if (compatibleCore("0.8.1")) track = playlist.sounds.contents[trackNr];
|
||||||
|
else track = playlist.data.sounds[trackNr];
|
||||||
if (track != undefined){
|
if (track != undefined){
|
||||||
this.playTrack(track,playlist,playlistNr);
|
this.playTrack(track,playlist,playlistNr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -209,6 +217,23 @@ export class PlaylistControl{
|
|||||||
}
|
}
|
||||||
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -259,7 +284,11 @@ export class PlaylistControl{
|
|||||||
}
|
}
|
||||||
else if (mode == 2) await playlist.stopAll();
|
else if (mode == 2) await playlist.stopAll();
|
||||||
}
|
}
|
||||||
await playlist.updateEmbeddedEntity("PlaylistSound", {_id: track._id, playing: play});
|
|
||||||
|
if (compatibleCore("0.8.1") && play) await playlist.playSound(track);
|
||||||
|
else if (compatibleCore("0.8.1")) await playlist.stopSound(track);
|
||||||
|
else await playlist.updateEmbeddedEntity("PlaylistSound", {_id: track._id, playing: play});
|
||||||
|
|
||||||
playlist.update({playing: play});
|
playlist.update({playing: play});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
25
src/scene.js
@@ -1,5 +1,6 @@
|
|||||||
import * as MODULE from "../MaterialDeck.js";
|
import * as MODULE from "../MaterialDeck.js";
|
||||||
import {streamDeck} from "../MaterialDeck.js";
|
import {streamDeck} from "../MaterialDeck.js";
|
||||||
|
import {compatibleCore} from "./misc.js";
|
||||||
|
|
||||||
export class SceneControl{
|
export class SceneControl{
|
||||||
constructor(){
|
constructor(){
|
||||||
@@ -10,14 +11,16 @@ export class SceneControl{
|
|||||||
|
|
||||||
async updateAll(){
|
async updateAll(){
|
||||||
if (this.active == false) return;
|
if (this.active == false) return;
|
||||||
for (let i=0; i<32; i++){
|
for (let device of streamDeck.buttonContext) {
|
||||||
const data = streamDeck.buttonContext[i];
|
for (let i=0; i<device.buttons.length; i++){
|
||||||
|
const data = device.buttons[i];
|
||||||
if (data == undefined || data.action != 'scene') continue;
|
if (data == undefined || data.action != 'scene') continue;
|
||||||
await this.update(data.settings,data.context);
|
await this.update(data.settings,data.context,device.device);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update(settings,context){
|
update(settings,context,device){
|
||||||
if (canvas.scene == null) return;
|
if (canvas.scene == null) return;
|
||||||
this.active = true;
|
this.active = true;
|
||||||
const func = settings.sceneFunction ? settings.sceneFunction : 'visible';
|
const func = settings.sceneFunction ? settings.sceneFunction : 'visible';
|
||||||
@@ -31,7 +34,7 @@ export class SceneControl{
|
|||||||
let name = "";
|
let name = "";
|
||||||
if (func == 'visible') { //visible scenes
|
if (func == 'visible') { //visible scenes
|
||||||
if (MODULE.getPermission('SCENE','VISIBLE') == false ) {
|
if (MODULE.getPermission('SCENE','VISIBLE') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let nr = parseInt(settings.sceneNr);
|
let nr = parseInt(settings.sceneNr);
|
||||||
@@ -49,7 +52,7 @@ export class SceneControl{
|
|||||||
}
|
}
|
||||||
else if (func == 'dir') { //from directory
|
else if (func == 'dir') { //from directory
|
||||||
if (MODULE.getPermission('SCENE','DIRECTORY') == false ) {
|
if (MODULE.getPermission('SCENE','DIRECTORY') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let nr = parseInt(settings.sceneNr);
|
let nr = parseInt(settings.sceneNr);
|
||||||
@@ -58,7 +61,7 @@ export class SceneControl{
|
|||||||
|
|
||||||
let sceneList = [];
|
let sceneList = [];
|
||||||
for (let i=0; i<ui.scenes.tree.children.length; i++){
|
for (let i=0; i<ui.scenes.tree.children.length; i++){
|
||||||
const scenesInFolder = ui.scenes.tree.children[i].entities;
|
const scenesInFolder = compatibleCore("0.8.1") ? ui.scenes.tree.children[i].contents : ui.scenes.tree.children[i].entities;
|
||||||
for (let j=0; j<scenesInFolder.length; j++)
|
for (let j=0; j<scenesInFolder.length; j++)
|
||||||
sceneList.push(scenesInFolder[j])
|
sceneList.push(scenesInFolder[j])
|
||||||
}
|
}
|
||||||
@@ -84,7 +87,7 @@ export class SceneControl{
|
|||||||
}
|
}
|
||||||
else if (func == 'any') { //by name
|
else if (func == 'any') { //by name
|
||||||
if (MODULE.getPermission('SCENE','NAME') == false ) {
|
if (MODULE.getPermission('SCENE','NAME') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (settings.sceneName == undefined || settings.sceneName == '') return;
|
if (settings.sceneName == undefined || settings.sceneName == '') return;
|
||||||
@@ -99,7 +102,7 @@ export class SceneControl{
|
|||||||
}
|
}
|
||||||
else if (func == 'active'){
|
else if (func == 'active'){
|
||||||
if (MODULE.getPermission('SCENE','ACTIVE') == false ) {
|
if (MODULE.getPermission('SCENE','ACTIVE') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const scene = game.scenes.active;
|
const scene = game.scenes.active;
|
||||||
@@ -115,7 +118,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,device,src,{background:background,ring:ring,ringColor:ringColor});
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPress(settings){
|
keyPress(settings){
|
||||||
@@ -151,7 +154,7 @@ export class SceneControl{
|
|||||||
|
|
||||||
let sceneList = [];
|
let sceneList = [];
|
||||||
for (let i=0; i<ui.scenes.tree.children.length; i++){
|
for (let i=0; i<ui.scenes.tree.children.length; i++){
|
||||||
const scenesInFolder = ui.scenes.tree.children[i].entities;
|
const scenesInFolder = compatibleCore("0.8.1") ? ui.scenes.tree.children[i].contents : ui.scenes.tree.children[i].entities;
|
||||||
for (let j=0; j<scenesInFolder.length; j++)
|
for (let j=0; j<scenesInFolder.length; j++)
|
||||||
sceneList.push(scenesInFolder[j])
|
sceneList.push(scenesInFolder[j])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ const defaultUserPermissions = {
|
|||||||
},
|
},
|
||||||
MACRO: {
|
MACRO: {
|
||||||
HOTBAR: [true,true,true,true],
|
HOTBAR: [true,true,true,true],
|
||||||
|
BY_NAME: [false,false,true,true],
|
||||||
MACROBOARD: [false,false,true,true],
|
MACROBOARD: [false,false,true,true],
|
||||||
MACROBOARD_CONFIGURE: [false,false,true,true]
|
MACROBOARD_CONFIGURE: [false,false,true,true]
|
||||||
},
|
},
|
||||||
@@ -60,11 +61,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 +78,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()
|
||||||
});
|
});
|
||||||
@@ -114,6 +117,17 @@ export const registerSettings = function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
game.settings.register(MODULE.moduleName, 'imageBrightness', {
|
||||||
|
name: "MaterialDeck.Sett.ImageBrightness",
|
||||||
|
hint: "MaterialDeck.Sett.ImageBrightnessHint",
|
||||||
|
default: 50,
|
||||||
|
type: Number,
|
||||||
|
scope: 'client',
|
||||||
|
range: { min: 0, max: 100, step: 1 },
|
||||||
|
config: true
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
//Create the Help button
|
//Create the Help button
|
||||||
game.settings.registerMenu(MODULE.moduleName, 'helpMenu',{
|
game.settings.registerMenu(MODULE.moduleName, 'helpMenu',{
|
||||||
name: "MaterialDeck.Sett.Help",
|
name: "MaterialDeck.Sett.Help",
|
||||||
@@ -195,6 +209,22 @@ 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];
|
||||||
|
if (permissionSettings.permissions.MACRO.BY_NAME == undefined) permissionSettings.permissions.MACRO.BY_NAME = [false,false,true,true];
|
||||||
|
}
|
||||||
|
game.settings.set(MODULE.moduleName,'userPermission',permissionSettings);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class helpMenu extends FormApplication {
|
export class helpMenu extends FormApplication {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import * as MODULE from "../MaterialDeck.js";
|
import * as MODULE from "../MaterialDeck.js";
|
||||||
import {streamDeck} from "../MaterialDeck.js";
|
import {streamDeck} from "../MaterialDeck.js";
|
||||||
|
import {compatibleCore} from "./misc.js";
|
||||||
|
|
||||||
export class SoundboardControl{
|
export class SoundboardControl{
|
||||||
constructor(){
|
constructor(){
|
||||||
@@ -12,16 +13,18 @@ export class SoundboardControl{
|
|||||||
|
|
||||||
async updateAll(){
|
async updateAll(){
|
||||||
if (this.active == false) return;
|
if (this.active == false) return;
|
||||||
for (let i=0; i<32; i++){
|
for (let device of streamDeck.buttonContext) {
|
||||||
const data = streamDeck.buttonContext[i];
|
for (let i=0; i<device.buttons.length; i++){
|
||||||
|
const data = device.buttons[i];
|
||||||
if (data == undefined || data.action != 'soundboard') continue;
|
if (data == undefined || data.action != 'soundboard') continue;
|
||||||
await this.update(data.settings,data.context);
|
await this.update(data.settings,data.context,device.device);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
update(settings,context){
|
update(settings,context,device){
|
||||||
if (MODULE.getPermission('SOUNDBOARD','PLAY') == false ) {
|
if (MODULE.getPermission('SOUNDBOARD','PLAY') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.active = true;
|
this.active = true;
|
||||||
@@ -45,7 +48,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,device,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 +60,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,device,"",{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,device,src,{background:background,ring:2,ringColor:'#00FF00',overlay:true});
|
||||||
else
|
else
|
||||||
streamDeck.setIcon(context,src,settings.background,1,'#000000',true);
|
streamDeck.setIcon(context,device,src,{background:background,ring:1,ringColor:'#000000',overlay:true});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,7 +90,7 @@ export class SoundboardControl{
|
|||||||
const repeat = (playMode > 0) ? true : false;
|
const repeat = (playMode > 0) ? true : false;
|
||||||
const play = (this.activeSounds[soundNr] == false) ? true : false;
|
const play = (this.activeSounds[soundNr] == false) ? true : false;
|
||||||
|
|
||||||
this.playSound(soundNr,repeat,play);
|
this.prePlaySound(soundNr,repeat,play);
|
||||||
}
|
}
|
||||||
else if (mode == 'offset') { //Offset
|
else if (mode == 'offset') { //Offset
|
||||||
let offset = parseInt(settings.offset);
|
let offset = parseInt(settings.offset);
|
||||||
@@ -97,7 +101,7 @@ export class SoundboardControl{
|
|||||||
else if (mode == 'stopAll') { //Stop All Sounds
|
else if (mode == 'stopAll') { //Stop All Sounds
|
||||||
for (let i=0; i<64; i++) {
|
for (let i=0; i<64; i++) {
|
||||||
if (this.activeSounds[i] != false){
|
if (this.activeSounds[i] != false){
|
||||||
this.playSound(i,false,false);
|
this.prePlaySound(i,false,false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,10 +121,10 @@ export class SoundboardControl{
|
|||||||
const playMode = game.settings.get(MODULE.moduleName,'soundboardSettings').mode[soundNr];
|
const playMode = game.settings.get(MODULE.moduleName,'soundboardSettings').mode[soundNr];
|
||||||
|
|
||||||
if (playMode == 2)
|
if (playMode == 2)
|
||||||
this.playSound(soundNr,false,false);
|
this.prePlaySound(soundNr,false,false);
|
||||||
}
|
}
|
||||||
|
|
||||||
async playSound(soundNr,repeat,play){
|
async prePlaySound(soundNr,repeat,play){
|
||||||
const soundBoardSettings = game.settings.get(MODULE.moduleName,'soundboardSettings');
|
const soundBoardSettings = game.settings.get(MODULE.moduleName,'soundboardSettings');
|
||||||
const playlistId = (soundBoardSettings.selectedPlaylists != undefined) ? soundBoardSettings.selectedPlaylists[soundNr] : undefined;
|
const playlistId = (soundBoardSettings.selectedPlaylists != undefined) ? soundBoardSettings.selectedPlaylists[soundNr] : undefined;
|
||||||
let src;
|
let src;
|
||||||
@@ -141,7 +145,7 @@ export class SoundboardControl{
|
|||||||
const soundId = soundBoardSettings.sounds[soundNr];
|
const soundId = soundBoardSettings.sounds[soundNr];
|
||||||
const sounds = game.playlists.get(playlistId).sounds;
|
const sounds = game.playlists.get(playlistId).sounds;
|
||||||
if (sounds == undefined) return;
|
if (sounds == undefined) return;
|
||||||
const sound = sounds.find(p => p._id == soundId);
|
const sound = compatibleCore("0.8.1") ? sounds.find(p => p.id == soundId) : sounds.find(p => p._id == soundId);
|
||||||
if (sound == undefined) return;
|
if (sound == undefined) return;
|
||||||
src = sound.path;
|
src = sound.path;
|
||||||
}
|
}
|
||||||
@@ -159,26 +163,63 @@ export class SoundboardControl{
|
|||||||
};
|
};
|
||||||
game.socket.emit(`module.MaterialDeck`, payload);
|
game.socket.emit(`module.MaterialDeck`, payload);
|
||||||
|
|
||||||
if (play){
|
this.playSound(soundNr,src,play,repeat,volume)
|
||||||
volume *= game.settings.get("core", "globalInterfaceVolume");
|
}
|
||||||
|
|
||||||
|
async playSound(soundNr,src,play,repeat,volume){
|
||||||
|
if (play){
|
||||||
|
volume *= game.settings.get("core", "globalAmbientVolume");
|
||||||
|
|
||||||
|
if (compatibleCore("0.8.1")) {
|
||||||
|
let newSound = new SoundNode(src);
|
||||||
|
if(newSound.loaded == false) await newSound.load({autoplay:true});
|
||||||
|
newSound.on('end', ()=>{
|
||||||
|
if (repeat == false) {
|
||||||
|
this.activeSounds[soundNr] = false;
|
||||||
|
this.updateAll();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
newSound.play({loop:repeat,volume:volume});
|
||||||
|
this.activeSounds[soundNr] = newSound;
|
||||||
|
}
|
||||||
|
else {
|
||||||
let howl = new Howl({src, volume, loop: repeat, onend: (id)=>{
|
let howl = new Howl({src, volume, loop: repeat, onend: (id)=>{
|
||||||
if (repeat == false){
|
if (repeat == false){
|
||||||
this.activeSounds[soundNr] = false;
|
this.activeSounds[soundNr] = false;
|
||||||
this.updateAll();
|
this.updateAll();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onstop: (id)=>{
|
onstop: ()=>{
|
||||||
this.activeSounds[soundNr] = false;
|
this.activeSounds[soundNr] = false;
|
||||||
this.updateAll();
|
this.updateAll();
|
||||||
}});
|
}});
|
||||||
howl.play();
|
howl.play();
|
||||||
this.activeSounds[soundNr] = howl;
|
this.activeSounds[soundNr] = howl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
this.activeSounds[soundNr].stop();
|
this.activeSounds[soundNr].stop();
|
||||||
this.activeSounds[soundNr] = false;
|
this.activeSounds[soundNr] = false;
|
||||||
}
|
}
|
||||||
this.updateAll();
|
this.updateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
volumeChange(soundNr){
|
||||||
|
|
||||||
|
let volume = game.settings.get("core", "globalAmbientVolume");
|
||||||
|
|
||||||
|
if (soundNr == 'all') {
|
||||||
|
for (let i=0; this.activeSounds.length; i++) {
|
||||||
|
volume * game.settings.get(MODULE.moduleName,'soundboardSettings').volume[i]/100;
|
||||||
|
volume = AudioHelper.inputToVolume(volume);
|
||||||
|
this.activeSounds[i].volume = volume;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
volume * game.settings.get(MODULE.moduleName,'soundboardSettings').volume[soundNr]/100;
|
||||||
|
volume = AudioHelper.inputToVolume(volume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
@@ -7,9 +7,7 @@ export class StreamDeck{
|
|||||||
this.tokenNameContext;
|
this.tokenNameContext;
|
||||||
this.tokenACContext;
|
this.tokenACContext;
|
||||||
this.buttonContext = [];
|
this.buttonContext = [];
|
||||||
for (let i=0; i<23; i++){
|
|
||||||
this.buttonContext[i] = undefined;
|
|
||||||
}
|
|
||||||
this.playlistTrackBuffer = [];
|
this.playlistTrackBuffer = [];
|
||||||
this.playlistSelector = 0;
|
this.playlistSelector = 0;
|
||||||
this.trackSelector = 0;
|
this.trackSelector = 0;
|
||||||
@@ -36,19 +34,39 @@ export class StreamDeck{
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setContext(action,context,coordinates = {column:0,row:0},settings){
|
setContext(device,size,iteration,action,context,coordinates = {column:0,row:0},settings){
|
||||||
|
if (this.buttonContext[iteration] == undefined) {
|
||||||
|
const deckSize = size.columns*size.rows;
|
||||||
|
let buttons = [];
|
||||||
|
for (let i=0; i<deckSize; i++){
|
||||||
|
buttons[i] = undefined;
|
||||||
|
}
|
||||||
|
this.buttonContext[iteration] = {
|
||||||
|
device: device,
|
||||||
|
size: size,
|
||||||
|
buttons: buttons
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
context: context,
|
context: context,
|
||||||
action: action,
|
action: action,
|
||||||
settings: settings
|
settings: settings
|
||||||
}
|
}
|
||||||
let num = coordinates.column + coordinates.row*8;
|
|
||||||
this.buttonContext[num] = data;
|
const num = coordinates.column + coordinates.row*size.columns;
|
||||||
|
this.buttonContext[iteration].buttons[num] = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
clearContext(device,action,coordinates = {column:0,row:0}){
|
||||||
|
for (let d of this.buttonContext) {
|
||||||
|
if (d.device == device) {
|
||||||
|
const num = coordinates.column + coordinates.row*d.size.columns;
|
||||||
|
d.buttons[num] = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clearContext(action,coordinates = {column:0,row:0}){
|
|
||||||
let num = coordinates.column + coordinates.row*8;
|
|
||||||
this.buttonContext[num] = undefined;
|
|
||||||
if (this.getActive(action) == false){
|
if (this.getActive(action) == false){
|
||||||
if (action == 'token') MODULE.tokenControl.active = false;
|
if (action == 'token') MODULE.tokenControl.active = false;
|
||||||
else if (action == 'macro') MODULE.macroControl.active = false;
|
else if (action == 'macro') MODULE.macroControl.active = false;
|
||||||
@@ -127,7 +145,9 @@ export class StreamDeck{
|
|||||||
newTxtArray[counter] = txtNewPart;
|
newTxtArray[counter] = txtNewPart;
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
|
if (counter == 1 && newTxtArray[0] == "") counter = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i=0; i<counter; i++){
|
for (let i=0; i<counter; i++){
|
||||||
if (txtNew.length > 0)
|
if (txtNew.length > 0)
|
||||||
txtNew += "\n";
|
txtNew += "\n";
|
||||||
@@ -177,11 +197,12 @@ export class StreamDeck{
|
|||||||
MODULE.sendWS(JSON.stringify(msg));
|
MODULE.sendWS(JSON.stringify(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
setImage(image,context,nr,id){
|
setImage(image,context,device,nr,id){
|
||||||
var json = {
|
var json = {
|
||||||
target: "SD",
|
target: "SD",
|
||||||
event: "setImage",
|
event: "setImage",
|
||||||
context: context,
|
context: context,
|
||||||
|
device: device,
|
||||||
payload: {
|
payload: {
|
||||||
nr: nr,
|
nr: nr,
|
||||||
id: id,
|
id: id,
|
||||||
@@ -192,11 +213,12 @@ export class StreamDeck{
|
|||||||
MODULE.sendWS(JSON.stringify(json));
|
MODULE.sendWS(JSON.stringify(json));
|
||||||
}
|
}
|
||||||
|
|
||||||
setBufferImage(context,nr,id){
|
setBufferImage(context,device,nr,id){
|
||||||
var json = {
|
var json = {
|
||||||
target: "SD",
|
target: "SD",
|
||||||
event: "setBufferImage",
|
event: "setBufferImage",
|
||||||
context: context,
|
context: context,
|
||||||
|
device: device,
|
||||||
payload: {
|
payload: {
|
||||||
nr: nr,
|
nr: nr,
|
||||||
id: id,
|
id: id,
|
||||||
@@ -206,30 +228,49 @@ 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,device,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';
|
||||||
for (let i=0; i<32; i++){
|
let background = options.background ? options.background : '#000000';
|
||||||
if (this.buttonContext[i] == undefined) continue;
|
let ring = options.ring ? options.ring : 0;
|
||||||
if (this.buttonContext[i].context == context) {
|
let ringColor = options.ringColor ? options.ringColor : '#000000';
|
||||||
if (this.buttonContext[i].icon == src && this.buttonContext[i].ring == ring && this.buttonContext[i].ringColor == ringColor && this.buttonContext[i].background == background)
|
let overlay = options.overlay ? options.overlay : false;
|
||||||
|
let uses = options.uses ? options.uses : undefined;
|
||||||
|
let clock = options.clock ? options.clock : false;
|
||||||
|
|
||||||
|
//if (src != 'modules/MaterialDeck/img/black.png')
|
||||||
|
for (let d of this.buttonContext) {
|
||||||
|
if (d.device == device) {
|
||||||
|
for (let i=0; i<d.buttons.length; i++){
|
||||||
|
if (clock != false) break;
|
||||||
|
if (d.buttons[i] == undefined) continue;
|
||||||
|
if (d.buttons[i].context == context) {
|
||||||
|
if (d.buttons[i].icon == src && d.buttons[i].ring == ring && d.buttons[i].ringColor == ringColor && d.buttons[i].background == background && d.buttons[i].uses == uses)
|
||||||
return;
|
return;
|
||||||
this.buttonContext[i].icon = src;
|
d.buttons[i].icon = src;
|
||||||
this.buttonContext[i].ring = ring;
|
d.buttons[i].ring = ring;
|
||||||
this.buttonContext[i].ringColor = ringColor;
|
d.buttons[i].ringColor = ringColor;
|
||||||
this.buttonContext[i].background = background;
|
d.buttons[i].background = background;
|
||||||
|
d.buttons[i].uses = uses;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
url: src,
|
url: src,
|
||||||
background:background,
|
background:background,
|
||||||
ring:ring,
|
ring:ring,
|
||||||
ringColor:ringColor,
|
ringColor:ringColor,
|
||||||
overlay:overlay
|
overlay:overlay,
|
||||||
|
uses:uses,
|
||||||
|
options:options,
|
||||||
|
devide:device
|
||||||
}
|
}
|
||||||
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,device,imgBuffer,this.getImageBufferId(data))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,12 +283,15 @@ export class StreamDeck{
|
|||||||
target: "SD",
|
target: "SD",
|
||||||
event: 'setIcon',
|
event: 'setIcon',
|
||||||
context: context,
|
context: context,
|
||||||
|
device: device,
|
||||||
url: src,
|
url: src,
|
||||||
format: format,
|
format: format,
|
||||||
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 +343,12 @@ export class StreamDeck{
|
|||||||
getImage(data){
|
getImage(data){
|
||||||
if (data == undefined)
|
if (data == undefined)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const context = data.context;
|
const context = data.context;
|
||||||
|
const device = data.device;
|
||||||
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 +372,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,12 +386,16 @@ export class StreamDeck{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ctx.fillStyle = background;
|
|
||||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
}
|
||||||
|
if (uses != undefined && uses.heart != false && (uses.available > 0 || uses.maximum != undefined)) {
|
||||||
|
const percentage = 102*uses.available/uses.maximum;
|
||||||
|
ctx.fillStyle = uses.heart;
|
||||||
|
ctx.fillRect(0, 121,144,-percentage);
|
||||||
}
|
}
|
||||||
if (format == 'icon' && url != ""){
|
if (format == 'icon' && url != ""){
|
||||||
ctx.font = '600 90px "Font Awesome 5 Free"';
|
ctx.font = '600 90px "Font Awesome 5 Free"';
|
||||||
ctx.fillStyle = "gray";
|
ctx.fillStyle = "#545454";
|
||||||
var elm = document.createElement('i');
|
var elm = document.createElement('i');
|
||||||
elm.className = url;
|
elm.className = url;
|
||||||
elm.style.display = 'none';
|
elm.style.display = 'none';
|
||||||
@@ -368,7 +417,8 @@ export class StreamDeck{
|
|||||||
img.setAttribute('crossorigin', 'anonymous');
|
img.setAttribute('crossorigin', 'anonymous');
|
||||||
img.onload = () => {
|
img.onload = () => {
|
||||||
if (format == 'color') ctx.filter = "opacity(0)";
|
if (format == 'color') ctx.filter = "opacity(0)";
|
||||||
if (data.overlay) ctx.filter = "brightness(60%)";
|
|
||||||
|
if (data.overlay == true) ctx.filter = "brightness(" + game.settings.get(MODULE.moduleName,'imageBrightness') + "%)";
|
||||||
//ctx.filter = "brightness(0) saturate(100%) invert(38%) sepia(62%) saturate(2063%) hue-rotate(209deg) brightness(90%) contrast(95%)";
|
//ctx.filter = "brightness(0) saturate(100%) invert(38%) sepia(62%) saturate(2063%) hue-rotate(209deg) brightness(90%) contrast(95%)";
|
||||||
var imageAspectRatio = img.width / img.height;
|
var imageAspectRatio = img.width / img.height;
|
||||||
var canvasAspectRatio = canvas.width / canvas.height;
|
var canvasAspectRatio = canvas.width / canvas.height;
|
||||||
@@ -400,16 +450,86 @@ 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.heart == false && (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);
|
||||||
this.setImage(dataURL,data.context,nr,this.getImageBufferId(data));
|
this.setImage(dataURL,data.context,device,nr,this.getImageBufferId(data));
|
||||||
};
|
};
|
||||||
img.src = resImageURL;
|
img.src = resImageURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
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){
|
||||||
@@ -445,11 +565,12 @@ export class StreamDeck{
|
|||||||
this.imageBuffer = [];
|
this.imageBuffer = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
noPermission(context,showTxt=true){
|
noPermission(context,device,showTxt=true, origin = ""){
|
||||||
|
console.warn("Material Deck: User lacks permission for function "+origin);
|
||||||
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,device,url,{background:background});
|
||||||
this.setTitle(txt,context);
|
this.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
414
src/token.js
@@ -1,5 +1,6 @@
|
|||||||
import * as MODULE from "../MaterialDeck.js";
|
import * as MODULE from "../MaterialDeck.js";
|
||||||
import {streamDeck} from "../MaterialDeck.js";
|
import {streamDeck, macroControl, otherControls} from "../MaterialDeck.js";
|
||||||
|
import {compatibleCore} from "./misc.js";
|
||||||
|
|
||||||
export class TokenControl{
|
export class TokenControl{
|
||||||
constructor(){
|
constructor(){
|
||||||
@@ -7,31 +8,57 @@ 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 device of streamDeck.buttonContext) {
|
||||||
const data = streamDeck.buttonContext[i];
|
for (let i=0; i<device.buttons.length; i++){
|
||||||
|
const data = device.buttons[i];
|
||||||
if (data == undefined || data.action != 'token') continue;
|
if (data == undefined || data.action != 'token') continue;
|
||||||
await this.pushData(tokenId,data.settings,data.context);
|
await this.pushData(tokenId,data.settings,data.context,device.device);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async pushData(tokenId,settings,context,ring=0,ringColor='#000000'){
|
async pushData(tokenId,settings,context,device,ring=0,ringColor='#000000'){
|
||||||
const name = settings.displayName ? settings.displayName : false;
|
const name = settings.displayName ? settings.displayName : false;
|
||||||
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 : '';
|
||||||
|
const prependTitle = settings.prependTitle ? settings.prependTitle : '';
|
||||||
|
|
||||||
|
let validToken = false;
|
||||||
|
let token;
|
||||||
|
if (tokenId != undefined && tokenId != null) token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
|
||||||
|
else if (selection == 'selected') token = canvas.tokens.controlled[0];
|
||||||
|
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);
|
let hp = undefined;
|
||||||
|
if (validToken) {
|
||||||
|
if (token.owner == false && token.observer == true && MODULE.getPermission('TOKEN','OBSERVER') == false ) {
|
||||||
|
streamDeck.noPermission(context,device);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (token.owner == false && token.observer == false && MODULE.getPermission('TOKEN','NON_OWNED') == false ) {
|
||||||
|
streamDeck.noPermission(context,device);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tokenName = token.data.name;
|
tokenName = token.data.name;
|
||||||
if (name) txt += tokenName;
|
if (name) txt += tokenName;
|
||||||
if (name && stats != 'none') txt += "\n";
|
else txt += prependTitle;
|
||||||
|
|
||||||
const permission = token.actor?.permission;
|
const permission = token.actor?.permission;
|
||||||
if (settings.combat){
|
if (settings.combat){
|
||||||
@@ -49,8 +76,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('[');
|
||||||
@@ -72,12 +99,35 @@ export class TokenControl{
|
|||||||
else if (game.system.id == 'dnd5e'){
|
else if (game.system.id == 'dnd5e'){
|
||||||
let attributes = token.actor.data.data.attributes;
|
let attributes = token.actor.data.data.attributes;
|
||||||
if (stats == 'HP') {
|
if (stats == 'HP') {
|
||||||
|
if (!icon) {
|
||||||
|
uses = {
|
||||||
|
available: attributes.hp.value,
|
||||||
|
maximum: attributes.hp.max,
|
||||||
|
heart: "#FF0000"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
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,
|
||||||
|
heart: false
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (stats == 'TempHP') {
|
else if (stats == 'TempHP') {
|
||||||
txt += attributes.hp.temp;
|
const val = (attributes.hp.temp == null) ? 0 : attributes.hp.temp;
|
||||||
if (attributes.hp.tempmax != null)
|
const max = (attributes.hp.tempmax == null) ? 0 : attributes.hp.tempmax
|
||||||
txt += "/" + attributes.hp.tempmax;
|
if (!icon) {
|
||||||
|
uses = {
|
||||||
|
available: (attributes.hp.temp == null) ? 0 : attributes.hp.temp,
|
||||||
|
maximum: (max == 0) ? 1 : attributes.hp.tempmax,
|
||||||
|
heart: "#00FF00"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
txt += val;
|
||||||
|
if (max != 0) txt += "/" + max;
|
||||||
}
|
}
|
||||||
else if (stats == 'AC') txt += attributes.ac.value;
|
else if (stats == 'AC') txt += attributes.ac.value;
|
||||||
else if (stats == 'Speed'){
|
else if (stats == 'Speed'){
|
||||||
@@ -111,13 +161,60 @@ export class TokenControl{
|
|||||||
}
|
}
|
||||||
txt += speed;
|
txt += speed;
|
||||||
}
|
}
|
||||||
else if (stats == 'Init') txt += attributes.init.total;
|
else if (stats == 'Init') {
|
||||||
|
const value = attributes.init.total;
|
||||||
|
if (value >= 0) txt += '+';
|
||||||
|
txt += value;
|
||||||
|
}
|
||||||
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';
|
||||||
|
const value = token.actor.data.data.abilities?.[ability].mod;
|
||||||
|
if (value >= 0) txt += '+';
|
||||||
|
txt += value;
|
||||||
|
}
|
||||||
|
else if (stats == 'Save') {
|
||||||
|
const ability = settings.save ? settings.save : 'str';
|
||||||
|
const value = token.actor.data.data.abilities?.[ability].save;
|
||||||
|
if (value >= 0) txt += '+';
|
||||||
|
txt += value;
|
||||||
|
}
|
||||||
|
else if (stats == 'Skill') {
|
||||||
|
const skill = settings.skill ? settings.skill : 'acr';
|
||||||
|
const value = token.actor.data.data.skills?.[skill].mod;
|
||||||
|
if (value >= 0) txt += '+';
|
||||||
|
txt += value;
|
||||||
|
}
|
||||||
|
else if (stats == 'Prof') {
|
||||||
|
const value = token.actor.data.data.attributes.prof;
|
||||||
|
if (value >= 0) txt += '+';
|
||||||
|
txt += value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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') {
|
||||||
|
if (!icon) {
|
||||||
|
uses = {
|
||||||
|
available: attributes.hp.value,
|
||||||
|
maximum: attributes.hp.max,
|
||||||
|
heart: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
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;
|
||||||
@@ -144,11 +241,54 @@ export class TokenControl{
|
|||||||
}
|
}
|
||||||
txt += speed;
|
txt += speed;
|
||||||
}
|
}
|
||||||
else if (stats == 'Init') txt += attributes.init.total;
|
else if (stats == 'Init') {
|
||||||
|
const value = attributes.init.total;
|
||||||
|
if (value >= 0) txt += '+';
|
||||||
|
txt += value;
|
||||||
|
}
|
||||||
|
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';
|
||||||
|
const value = token.actor.data.data.abilities?.[ability].mod;
|
||||||
|
if (value >= 0) txt += '+';
|
||||||
|
txt += value;
|
||||||
|
}
|
||||||
|
else if (stats == 'Save') {
|
||||||
|
const ability = settings.save ? settings.save : 'fort';
|
||||||
|
const value = token.actor.data.data.attributes.savingThrows?.[ability].total;
|
||||||
|
if (value >= 0) txt += '+';
|
||||||
|
txt += value;
|
||||||
|
}
|
||||||
|
else if (stats == 'Skill') {
|
||||||
|
const skill = settings.skill ? settings.skill : 'apr';
|
||||||
|
const value = token.actor.data.data.skills?.[skill].mod;
|
||||||
|
if (value >= 0) txt += '+';
|
||||||
|
txt += value;
|
||||||
|
}
|
||||||
|
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') {
|
||||||
|
if (!icon) {
|
||||||
|
uses = {
|
||||||
|
available: attributes.hp.value,
|
||||||
|
maximum: attributes.hp.max,
|
||||||
|
heart: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
@@ -158,7 +298,7 @@ export class TokenControl{
|
|||||||
}
|
}
|
||||||
else if (stats == 'AC') txt += attributes.ac.value;
|
else if (stats == 'AC') txt += attributes.ac.value;
|
||||||
else if (stats == 'Speed'){
|
else if (stats == 'Speed'){
|
||||||
let speed = "Land: " + attributes.speed.value.replace('feet','') + ' feet';
|
let speed = attributes.speed.breakdown;
|
||||||
const otherSpeeds = attributes.speed.otherSpeeds;
|
const otherSpeeds = attributes.speed.otherSpeeds;
|
||||||
if (otherSpeeds.length > 0)
|
if (otherSpeeds.length > 0)
|
||||||
for (let i=0; i<otherSpeeds.length; i++)
|
for (let i=0; i<otherSpeeds.length; i++)
|
||||||
@@ -166,16 +306,72 @@ export class TokenControl{
|
|||||||
txt += speed;
|
txt += speed;
|
||||||
}
|
}
|
||||||
else if (stats == 'Init') {
|
else if (stats == 'Init') {
|
||||||
let init = attributes.initiative.totalModifier;
|
const value = attributes.init.value;
|
||||||
if (init != undefined) txt += init;
|
if (value != undefined) {
|
||||||
|
if (value >= 0) txt += "+";
|
||||||
|
txt += value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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';
|
||||||
|
const value = token.actor.data.data.abilities?.[ability].mod;
|
||||||
|
if (value >= 0) txt += '+';
|
||||||
|
txt += value;
|
||||||
|
}
|
||||||
|
else if (stats == 'Save') {
|
||||||
|
let ability = settings.save ? settings.save : 'fort';
|
||||||
|
if (ability == 'fort') ability = 'fortitude';
|
||||||
|
else if (ability == 'ref') ability = 'reflex';
|
||||||
|
else if (ability == 'will') ability = 'will';
|
||||||
|
const value = token.actor.data.data.saves?.[ability].value;
|
||||||
|
if (value >= 0) txt += "+";
|
||||||
|
txt += value;
|
||||||
|
}
|
||||||
|
else if (stats == 'Skill') {
|
||||||
|
const skill = settings.skill ? settings.skill : 'acr';
|
||||||
|
const value = token.actor.data.data.skills?.[skill].totalModifier;
|
||||||
|
if (value >= 0) txt += '+';
|
||||||
|
txt += value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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') {
|
||||||
|
if (!icon) {
|
||||||
|
uses = {
|
||||||
|
available: attributes.hp.value,
|
||||||
|
maximum: attributes.hp.max,
|
||||||
|
heart: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
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';
|
||||||
|
const value = token.actor.data.data.attributes?.[ability].value;
|
||||||
|
if (value >=0) txt += '+';
|
||||||
|
txt += value;
|
||||||
|
}
|
||||||
|
else if (stats == 'AbilityMod') {
|
||||||
|
const ability = settings.ability ? settings.ability : 'strength';
|
||||||
|
const value = token.actor.data.data.attributes?.[ability].modifier;
|
||||||
|
if (value >=0) txt += '+';
|
||||||
|
txt += value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//Other systems
|
//Other systems
|
||||||
@@ -187,7 +383,7 @@ export class TokenControl{
|
|||||||
|
|
||||||
if (settings.onClick == 'visibility') { //toggle visibility
|
if (settings.onClick == 'visibility') { //toggle visibility
|
||||||
if (MODULE.getPermission('TOKEN','VISIBILITY') == false ) {
|
if (MODULE.getPermission('TOKEN','VISIBILITY') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ring = 1;
|
ring = 1;
|
||||||
@@ -202,7 +398,7 @@ export class TokenControl{
|
|||||||
}
|
}
|
||||||
else if (settings.onClick == 'combatState') { //toggle combat state
|
else if (settings.onClick == 'combatState') { //toggle combat state
|
||||||
if (MODULE.getPermission('TOKEN','COMBAT') == false ) {
|
if (MODULE.getPermission('TOKEN','COMBAT') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ring = 1;
|
ring = 1;
|
||||||
@@ -227,7 +423,7 @@ export class TokenControl{
|
|||||||
}
|
}
|
||||||
else if (settings.onClick == 'condition') { //toggle condition
|
else if (settings.onClick == 'condition') { //toggle condition
|
||||||
if (MODULE.getPermission('TOKEN','CONDITIONS') == false ) {
|
if (MODULE.getPermission('TOKEN','CONDITIONS') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ring = 1;
|
ring = 1;
|
||||||
@@ -238,7 +434,7 @@ export class TokenControl{
|
|||||||
else if (icon == false) {
|
else if (icon == false) {
|
||||||
let effect = CONFIG.statusEffects.find(e => e.id === condition);
|
let effect = CONFIG.statusEffects.find(e => e.id === condition);
|
||||||
iconSrc = effect.icon;
|
iconSrc = effect.icon;
|
||||||
let effects = token.actor.effects.entries;
|
let effects = compatibleCore("0.8.1") ? token.actor.effects.contents : token.actor.effects.entries;
|
||||||
let active = effects.find(e => e.isTemporary === condition);
|
let active = effects.find(e => e.isTemporary === condition);
|
||||||
if (active != undefined){
|
if (active != undefined){
|
||||||
ring = 2;
|
ring = 2;
|
||||||
@@ -282,7 +478,7 @@ export class TokenControl{
|
|||||||
}
|
}
|
||||||
else if (settings.onClick == 'cubCondition') { //Combat Utility Belt conditions
|
else if (settings.onClick == 'cubCondition') { //Combat Utility Belt conditions
|
||||||
if (MODULE.getPermission('TOKEN','CONDITIONS') == false ) {
|
if (MODULE.getPermission('TOKEN','CONDITIONS') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ring = 1;
|
ring = 1;
|
||||||
@@ -292,7 +488,7 @@ export class TokenControl{
|
|||||||
if (icon == false) {
|
if (icon == false) {
|
||||||
let effect = CONFIG.statusEffects.find(e => e.label === condition);
|
let effect = CONFIG.statusEffects.find(e => e.label === condition);
|
||||||
iconSrc = effect.icon;
|
iconSrc = effect.icon;
|
||||||
let effects = token.actor.effects.entries;
|
let effects = compatibleCore("0.8.1") ? token.actor.effects.contents : token.actor.effects.entries;
|
||||||
let active = effects.find(e => e.isTemporary === effect.id);
|
let active = effects.find(e => e.isTemporary === effect.id);
|
||||||
if (active != undefined){
|
if (active != undefined){
|
||||||
ring = 2;
|
ring = 2;
|
||||||
@@ -302,7 +498,7 @@ export class TokenControl{
|
|||||||
}
|
}
|
||||||
else if (settings.onClick == 'wildcard') { //wildcard images
|
else if (settings.onClick == 'wildcard') { //wildcard images
|
||||||
if (MODULE.getPermission('TOKEN','WILDCARD') == false ) {
|
if (MODULE.getPermission('TOKEN','WILDCARD') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (icon == false) return;
|
if (icon == false) return;
|
||||||
@@ -342,7 +538,7 @@ export class TokenControl{
|
|||||||
iconSrc += "";
|
iconSrc += "";
|
||||||
if (settings.onClick == 'visibility') { //toggle visibility
|
if (settings.onClick == 'visibility') { //toggle visibility
|
||||||
if (MODULE.getPermission('TOKEN','VISIBILITY') == false ) {
|
if (MODULE.getPermission('TOKEN','VISIBILITY') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (icon == false) {
|
if (icon == false) {
|
||||||
@@ -353,7 +549,7 @@ export class TokenControl{
|
|||||||
}
|
}
|
||||||
else if (settings.onClick == 'combatState') { //toggle combat state
|
else if (settings.onClick == 'combatState') { //toggle combat state
|
||||||
if (MODULE.getPermission('TOKEN','COMBAT') == false ) {
|
if (MODULE.getPermission('TOKEN','COMBAT') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (icon == false) {
|
if (icon == false) {
|
||||||
@@ -371,7 +567,7 @@ export class TokenControl{
|
|||||||
}
|
}
|
||||||
else if (settings.onClick == 'condition') { //toggle condition
|
else if (settings.onClick == 'condition') { //toggle condition
|
||||||
if (MODULE.getPermission('TOKEN','CONDITIONS') == false ) {
|
if (MODULE.getPermission('TOKEN','CONDITIONS') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (game.system.id == 'dnd5e' || game.system.id == 'D35E' || game.system.id == 'pf1'){
|
if (game.system.id == 'dnd5e' || game.system.id == 'D35E' || game.system.id == 'pf1'){
|
||||||
@@ -400,7 +596,7 @@ export class TokenControl{
|
|||||||
}
|
}
|
||||||
else if (settings.onClick == 'cubCondition') { //Combat Utility Belt conditions
|
else if (settings.onClick == 'cubCondition') { //Combat Utility Belt conditions
|
||||||
if (MODULE.getPermission('TOKEN','CONDITIONS') == false ) {
|
if (MODULE.getPermission('TOKEN','CONDITIONS') == false ) {
|
||||||
streamDeck.noPermission(context);
|
streamDeck.noPermission(context,device);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const condition = settings.cubConditionName;
|
const condition = settings.cubConditionName;
|
||||||
@@ -412,40 +608,86 @@ export class TokenControl{
|
|||||||
overlay = true;
|
overlay = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (icon == false){
|
if (icon == false){
|
||||||
if (MODULE.getPermission('TOKEN','STATS') == false) stats = statsOld;
|
if (MODULE.getPermission('TOKEN','STATS') == false) stats = statsOld;
|
||||||
if (stats == 'HP' || stats == 'TempHP') //HP
|
if (stats == 'HP') //HP
|
||||||
iconSrc = "modules/MaterialDeck/img/token/hp.png";
|
iconSrc = "modules/MaterialDeck/img/token/hp_empty.png";
|
||||||
|
if (stats == 'TempHP') //Temp HP
|
||||||
|
iconSrc = "modules/MaterialDeck/img/token/temp_hp_empty.png";
|
||||||
else if (stats == 'AC' || stats == 'ShieldHP') //AC
|
else if (stats == 'AC' || stats == 'ShieldHP') //AC
|
||||||
iconSrc = "modules/MaterialDeck/img/token/ac.webp";
|
iconSrc = "modules/MaterialDeck/img/token/ac.webp";
|
||||||
else if (stats == 'Speed') //Speed
|
else if (stats == 'Speed') //Speed
|
||||||
iconSrc = "modules/MaterialDeck/img/token/speed.webp";
|
iconSrc = "modules/MaterialDeck/img/token/speed.webp";
|
||||||
else if (stats == 'Init') //Initiative
|
else if (stats == 'Init') //Initiative
|
||||||
iconSrc = "modules/MaterialDeck/img/token/init.png";
|
iconSrc = "modules/MaterialDeck/img/token/init.png";
|
||||||
else if (stats == 'PassivePerception')
|
else if (stats == 'PassivePerception') {
|
||||||
iconSrc = "modules/MaterialDeck/img/black.png";
|
iconSrc = "modules/MaterialDeck/img/token/skills/prc.png";
|
||||||
else if (stats == 'PassiveInvestigation')
|
overlay = true;
|
||||||
iconSrc = "modules/MaterialDeck/img/black.png";
|
ring = 1;
|
||||||
}
|
}
|
||||||
streamDeck.setIcon(context,iconSrc,background,ring,ringColor,overlay);
|
else if (stats == 'PassiveInvestigation') {
|
||||||
|
iconSrc = "modules/MaterialDeck/img/token/skills/inv.png";
|
||||||
|
overlay = true;
|
||||||
|
ring = 1;
|
||||||
|
}
|
||||||
|
else if (stats == 'Ability' || stats == 'AbilityMod' || stats == 'Save') {
|
||||||
|
overlay = true;
|
||||||
|
ring = 1;
|
||||||
|
let ability = (stats == 'Save') ? settings.save : settings.ability;
|
||||||
|
if (ability == undefined) ability = 'str';
|
||||||
|
if (ability == 'con') iconSrc = "modules/MaterialDeck/img/token/abilities/cons.png";
|
||||||
|
else iconSrc = "modules/MaterialDeck/img/token/abilities/" + ability + ".png";
|
||||||
|
}
|
||||||
|
else if (stats == 'Skill') {
|
||||||
|
overlay = true;
|
||||||
|
ring = 1;
|
||||||
|
let skill = settings.skill;
|
||||||
|
if (skill == undefined) skill = 'acr';
|
||||||
|
else iconSrc = "modules/MaterialDeck/img/token/skills/" + skill + ".png";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
streamDeck.setIcon(context,device,iconSrc,{background:background,ring:ring,ringColor:ringColor,overlay:overlay,uses:uses,hp:hp});
|
||||||
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);
|
||||||
@@ -505,7 +747,7 @@ export class TokenControl{
|
|||||||
this.update(tokenId);
|
this.update(tokenId);
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (settings.onClick == 'cubCondition') { //Combat Utility Belt conditions
|
else if (onClick == 'cubCondition') { //Combat Utility Belt conditions
|
||||||
if (MODULE.getPermission('TOKEN','CONDITIONS') == false ) return;
|
if (MODULE.getPermission('TOKEN','CONDITIONS') == false ) return;
|
||||||
const condition = settings.cubConditionName;
|
const condition = settings.cubConditionName;
|
||||||
if (condition == undefined || condition == '') return;
|
if (condition == undefined || condition == '') return;
|
||||||
@@ -595,6 +837,56 @@ export class TokenControl{
|
|||||||
iconSrc = images[imgNr];
|
iconSrc = images[imgNr];
|
||||||
token.update({img: iconSrc})
|
token.update({img: iconSrc})
|
||||||
}
|
}
|
||||||
|
else if (onClick == 'macro') { //call a macro
|
||||||
|
const settingsNew = {
|
||||||
|
target: token,
|
||||||
|
macroMode: settings.macroMode,
|
||||||
|
macroNumber: settings.macroId,
|
||||||
|
macroArgs: settings.macroArgs
|
||||||
|
}
|
||||||
|
macroControl.keyPress(settingsNew);
|
||||||
|
}
|
||||||
|
else if (onClick == 'roll') { //roll skill/save/ability
|
||||||
|
const roll = settings.roll ? settings.roll : 'ability';
|
||||||
|
const ability = settings.rollAbility ? settings.rollAbility : 'str';
|
||||||
|
const skill = settings.rollSkill ? settings.rollSkill : 'acr';
|
||||||
|
const save = settings.rollSave ? settings.rollSave : 'str';
|
||||||
|
const rollOptions = otherControls.rollOption ? otherControls.rollOption : 'dialog';
|
||||||
|
const options = {
|
||||||
|
fastForward: (otherControls.rollOption != 'dialog'),
|
||||||
|
advantage: (otherControls.rollOption == 'advantage'),
|
||||||
|
disadvantage: (otherControls.rollOption == 'disadvantage')
|
||||||
|
}
|
||||||
|
|
||||||
|
if (game.system.id == 'pf2e') {
|
||||||
|
if (roll == 'ability') token.actor.data.data.saves?.[ability].roll(options);
|
||||||
|
else if (roll == 'save') {
|
||||||
|
let ability = save;
|
||||||
|
if (ability == 'fort') ability = 'fortitude';
|
||||||
|
else if (ability == 'ref') ability = 'reflex';
|
||||||
|
else if (ability == 'will') ability = 'will';
|
||||||
|
token.actor.data.data.saves?.[ability].roll(options);
|
||||||
|
}
|
||||||
|
else if (roll == 'skill') token.actor.data.data.skills?.[skill].roll(options);
|
||||||
|
}
|
||||||
|
if (roll == 'ability') token.actor.rollAbilityTest(ability,options);
|
||||||
|
else if (roll == 'save') {
|
||||||
|
if (game.system.id == 'dnd5e') token.actor.rollAbilitySave(save,options);
|
||||||
|
else token.actor.rollSavingThrow(save,options);
|
||||||
|
}
|
||||||
|
else if (roll == 'skill') token.actor.rollSkill(skill,options);
|
||||||
|
else if (roll == 'initiative') token.actor.rollInitiative(options);
|
||||||
|
else if (roll == 'deathSave') token.actor.rollDeathSave(options);
|
||||||
|
else if (roll == 'grapple') token.actor.rollGrapple(options);
|
||||||
|
else if (roll == 'bab') token.actor.rollBAB(options);
|
||||||
|
else if (roll == 'melee') token.actor.rollMelee(options);
|
||||||
|
else if (roll == 'ranged') token.actor.rollRanged(options);
|
||||||
|
else if (roll == 'cmb') token.actor.rollCMB(options);
|
||||||
|
else if (roll == 'attack') token.actor.rollAttack(options);
|
||||||
|
else if (roll == 'defenses') token.actor.rollDefenses(options);
|
||||||
|
|
||||||
|
if (otherControls.rollOption != 'dialog') otherControls.setRollOption('normal');
|
||||||
|
}
|
||||||
else if (onClick == 'custom') {//custom onClick function
|
else if (onClick == 'custom') {//custom onClick function
|
||||||
if (MODULE.getPermission('TOKEN','CUSTOM') == false ) return;
|
if (MODULE.getPermission('TOKEN','CUSTOM') == false ) return;
|
||||||
const formula = settings.customOnClickFormula ? settings.customOnClickFormula : '';
|
const formula = settings.customOnClickFormula ? settings.customOnClickFormula : '';
|
||||||
@@ -604,19 +896,39 @@ export class TokenControl{
|
|||||||
let formulaArrayTemp;
|
let formulaArrayTemp;
|
||||||
let split1 = formula.split(';');
|
let split1 = formula.split(';');
|
||||||
for (let i=0; i<split1.length; i++){
|
for (let i=0; i<split1.length; i++){
|
||||||
|
let macro = false;
|
||||||
|
let furnaceArguments = "";
|
||||||
let split2 = split1[i].split(' = ');
|
let split2 = split1[i].split(' = ');
|
||||||
targetArrayTemp = split2[0];
|
targetArrayTemp = split2[0];
|
||||||
formulaArrayTemp = split2[1];
|
formulaArrayTemp = split2[1];
|
||||||
|
|
||||||
let targetArray = this.splitCustom(targetArrayTemp);
|
let targetArray = this.splitCustom(targetArrayTemp);
|
||||||
|
|
||||||
for (let i=0; i<targetArray.length; i++){
|
for (let i=0; i<targetArray.length; i++){
|
||||||
if (targetArray[i][0] == '@') {
|
if (targetArray[i][0] == '@') {
|
||||||
const dataPath = targetArray[i].split('@')[1].split('.');
|
const dataPath = targetArray[i].split('@')[1].split('.');
|
||||||
targetArray[i] = dataPath;
|
targetArray[i] = dataPath;
|
||||||
|
if (dataPath == 'macro') {
|
||||||
|
macro = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (macro) {
|
||||||
|
const data = targetArray[i].split('[');
|
||||||
|
if (data != undefined && data.length > 1) targetArray[i] = data[1];
|
||||||
|
if (i > 1) {
|
||||||
|
if (furnaceArguments != "") furnaceArguments += " ";
|
||||||
|
furnaceArguments += "\"" + targetArray[i] + "\"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (macro) {
|
||||||
|
const settingsNew = {
|
||||||
|
target: token,
|
||||||
|
macroMode: 'name',
|
||||||
|
macroNumber: targetArray[1],
|
||||||
|
macroArgs: furnaceArguments
|
||||||
|
}
|
||||||
|
macroControl.keyPress(settingsNew);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
let formulaArray = this.splitCustom(formulaArrayTemp);
|
let formulaArray = this.splitCustom(formulaArrayTemp);
|
||||||
|
|
||||||
let value = 0;
|
let value = 0;
|
||||||
@@ -673,7 +985,7 @@ export class TokenControl{
|
|||||||
if (path != '') path += '.';
|
if (path != '') path += '.';
|
||||||
path += targetArray[i][j];
|
path += targetArray[i][j];
|
||||||
}
|
}
|
||||||
actor.update({[path]:value})
|
await actor.update({[path]:value})
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let path = '';
|
let path = '';
|
||||||
@@ -681,9 +993,9 @@ export class TokenControl{
|
|||||||
if (path != '') path += '.';
|
if (path != '') path += '.';
|
||||||
path += targetArray[i][j];
|
path += targetArray[i][j];
|
||||||
}
|
}
|
||||||
actor.update({[path]:value})
|
await actor.update({[path]:value})
|
||||||
}
|
}
|
||||||
|
this.update(token.id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
data = token;
|
data = token;
|
||||||
@@ -692,8 +1004,10 @@ export class TokenControl{
|
|||||||
if (path != '') path += '.';
|
if (path != '') path += '.';
|
||||||
path += targetArray[i][j];
|
path += targetArray[i][j];
|
||||||
}
|
}
|
||||||
token.update({[path]:value})
|
await token.update({[path]:value})
|
||||||
|
this.update(token.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<form autocomplete="off" onsubmit="event.preventDefault()">
|
<form autocomplete="off" onsubmit="event.preventDefault()">
|
||||||
|
|
||||||
<div style="width:1200px">
|
<div style="width:1200px">
|
||||||
|
|
||||||
<h1>Introduction</h1>
|
<h1>Introduction</h1>
|
||||||
Material Deck is a Foundry VTT module that allows you to control certain Foundry functions using an Elgato Stream Deck.
|
Material Deck is a Foundry VTT module that allows you to control certain Foundry functions using an Elgato Stream Deck.
|
||||||
A Stream Deck is a device that has physical buttons with displays behind them. Material Deck uses this to, for example,
|
A Stream Deck is a device that has physical buttons with displays behind them. Material Deck uses this to, for example,
|
||||||
@@ -72,6 +73,8 @@
|
|||||||
you know what you're doing. More info on Material Server can be found <a href="https://github.com/CDeenen/MaterialServer/blob/master/README.md">here</a></li>
|
you know what you're doing. More info on Material Server can be found <a href="https://github.com/CDeenen/MaterialServer/blob/master/README.md">here</a></li>
|
||||||
<li><b>Image Cache Size</b> - Sets the amount of images to store in the image cache. The image cache will locally store all images sent to the Stream Deck.
|
<li><b>Image Cache Size</b> - Sets the amount of images to store in the image cache. The image cache will locally store all images sent to the Stream Deck.
|
||||||
This improves the update speed, but increases memory usage.</li>
|
This improves the update speed, but increases memory usage.</li>
|
||||||
|
<li><b>Image Brightness</b> - Sets the brightness of the default white images for better readibility of the text. If Image Cache Size is large, it'll take a while for
|
||||||
|
the new brightness setting to be applied. A refresh will give instantaneous results.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<BR CLEAR="right" />
|
<BR CLEAR="right" />
|
||||||
|
|||||||
@@ -9,9 +9,9 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
{{#each macroData}}
|
{{#each macroData}}
|
||||||
<div class="form-group">
|
<div class="form-group" style="width:100%">
|
||||||
{{#each this.dataThis}}
|
{{#each this.dataThis}}
|
||||||
<div class="boxed" style="padding: 5px; margin:2px">
|
<div class="boxed" style="padding: 5px; margin:2px; width:10%">
|
||||||
<div style="text-align:center;">
|
<div style="text-align:center;">
|
||||||
{{localize "MaterialDeck.Macro"}} {{this.iteration}}
|
{{localize "MaterialDeck.Macro"}} {{this.iteration}}
|
||||||
</div>
|
</div>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
{{#select this.macro}}
|
{{#select this.macro}}
|
||||||
<option value="">{{localize "MaterialDeck.None"}}</option>
|
<option value="">{{localize "MaterialDeck.None"}}</option>
|
||||||
{{#each ../../macros}}
|
{{#each ../../macros}}
|
||||||
<option value="{{this._id}}">{{this.name}}</option>
|
<option value="{{this.id}}">{{this.name}}</option>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -26,7 +26,7 @@
|
|||||||
{{#select this.playlist}}
|
{{#select this.playlist}}
|
||||||
<option value="">{{localize "MaterialDeck.None"}}</option>
|
<option value="">{{localize "MaterialDeck.None"}}</option>
|
||||||
{{#each ../playlists}}
|
{{#each ../playlists}}
|
||||||
<option value="{{this._id}}">{{this.name}}</option>
|
<option value="{{this.id}}">{{this.name}}</option>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
{{/select}}
|
{{/select}}
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -9,9 +9,9 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
{{#each soundData}}
|
{{#each soundData}}
|
||||||
<div class="form-group">
|
<div class="form-group" style="width:100%">
|
||||||
{{#each this.dataThis}}
|
{{#each this.dataThis}}
|
||||||
<div class="boxed" style="padding: 5px; margin:2px">
|
<div class="boxed" style="padding: 5px; margin:2px; width:10%">
|
||||||
<div style="text-align:center;">
|
<div style="text-align:center;">
|
||||||
{{localize "MaterialDeck.Sound"}} {{this.iteration}}
|
{{localize "MaterialDeck.Sound"}} {{this.iteration}}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||