28 Commits

Author SHA1 Message Date
CDeenen
e229abc3ee v1.4.1 2021-04-21 23:32:05 +02:00
CDeenen
51119f42ea v1.4.0 2021-04-21 18:27:03 +02:00
CDeenen
42e4f8f0d8 merge fix 2021-04-21 18:26:10 +02:00
CDeenen
c3ee0a76aa v1.4.0 2021-04-21 18:23:02 +02:00
Material Foundry
2264d018c2 Update changelog.md 2021-04-18 21:55:15 +02:00
CDeenen
8fa32838d8 v1.3.3 2021-04-13 02:30:25 +02:00
CDeenen
1552ae6fe8 v1.3.3 2021-04-13 02:30:10 +02:00
CDeenen
cc9bcf4770 v1.3.2 2021-03-11 02:28:26 +01:00
CDeenen
7d4fd1e8b1 readme fix 2021-02-27 05:14:56 +01:00
CDeenen
780e06d581 Merge branch 'Master' of https://github.com/CDeenen/MaterialDeck into Master 2021-02-27 05:09:23 +01:00
CDeenen
64983ca0cb v1.3.1 2021-02-27 05:07:47 +01:00
CDeenen
dd534488da Update settings.js 2021-02-25 07:54:20 +01:00
CDeenen
7e2796316e Merge branch 'Master' of https://github.com/CDeenen/MaterialDeck into Master 2021-02-25 06:49:29 +01:00
CDeenen
7fa5352459 v1.3.0 2021-02-25 06:48:27 +01:00
CDeenen
c31cea4c64 Update README.md 2021-02-08 16:46:52 +01:00
CDeenen
f994e64fc7 v1.2.3 2021-02-04 05:03:34 +01:00
CDeenen
f0c1b0e1e0 v1.2.2 2021-02-02 05:32:08 +01:00
CDeenen
cc5dc9ab63 v1.2.1 2021-01-07 05:40:07 +01:00
CDeenen
64fd6cb132 Merge branch 'Master' of https://github.com/CDeenen/MaterialDeck into Master 2021-01-07 05:39:02 +01:00
CDeenen
888b089e7b v1.2.1 2021-01-07 05:38:16 +01:00
CDeenen
959b9c9e4e Add files via upload 2021-01-02 05:19:06 +01:00
CDeenen
afaf1c9799 Delete Black.png 2021-01-02 05:18:50 +01:00
CDeenen
2947c54eb8 v1.2.0 2020-12-28 05:31:59 +01:00
CDeenen
561e3f4bd0 Update README.md 2020-12-19 08:01:28 +01:00
CDeenen
33f27047b1 changelog fix 2020-12-12 19:32:07 +01:00
CDeenen
7c532f5155 v1.1.1 2020-12-12 19:17:34 +01:00
CDeenen
e62e82795b v1.1.1 2020-12-12 19:16:07 +01:00
CDeenen
91e07e79c5 changelog fix 2020-12-09 03:32:32 +01:00
88 changed files with 4303 additions and 1058 deletions

View File

@@ -7,6 +7,9 @@ import {CombatTracker} from "./src/combattracker.js";
import {PlaylistControl} from "./src/playlist.js"; import {PlaylistControl} from "./src/playlist.js";
import {SoundboardControl} from "./src/soundboard.js"; 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 {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;
@@ -15,6 +18,8 @@ export var combatTracker;
export var playlistControl; export var playlistControl;
export var soundboard; export var soundboard;
export var otherControls; export var otherControls;
export var externalModules;
export var sceneControl;
export const moduleName = "MaterialDeck"; export const moduleName = "MaterialDeck";
export var selectedTokenId; export var selectedTokenId;
@@ -22,6 +27,11 @@ export var selectedTokenId;
let ready = false; let ready = false;
let activeSounds = []; let activeSounds = [];
export let hotbarUses = false;
export let calculateHotbarUses;
//CONFIG.debug.hooks = true; //CONFIG.debug.hooks = true;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
@@ -36,6 +46,8 @@ let wsOpen = false; //Bool for checking if websocket has ever been o
let wsInterval; //Interval timer to detect disconnections let wsInterval; //Interval timer to detect disconnections
let WSconnected = false; let WSconnected = false;
//let furnace = game.modules.get("furnace");
/* /*
* Analyzes the message received * Analyzes the message received
* *
@@ -47,7 +59,41 @@ async function analyzeWSmessage(msg){
//console.log("Received",data); //console.log("Received",data);
if (data.type == "connected" && data.data == "SD"){ if (data.type == "connected" && data.data == "SD"){
const msg = {
target: "SD",
type: "init",
system: game.system.id
}
ws.send(JSON.stringify(msg));
console.log("streamdeck connected to server"); console.log("streamdeck connected to server");
streamDeck.resetImageBuffer();
}
if (data.type == "version" && data.source == "SD") {
const minimumSDversion = game.modules.get("MaterialDeck").data.minimumSDversion.replace('v','');
const minimumMSversion = game.modules.get("MaterialDeck").data.minimumMSversion;
if (data.version < minimumSDversion) {
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;
@@ -56,36 +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')
externalModules.update(settings,context,device);
else if (action == 'scene')
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'){
@@ -96,13 +149,17 @@ 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); otherControls.keyPress(settings,context,device);
else if (action == 'external')
externalModules.keyPress(settings,context,device);
else if (action == 'scene')
sceneControl.keyPress(settings);
} }
else if (event == 'keyUp'){ else if (event == 'keyUp'){
@@ -120,7 +177,10 @@ async function analyzeWSmessage(msg){
*/ */
function startWebsocket() { function startWebsocket() {
const address = game.settings.get(moduleName,'address'); const address = game.settings.get(moduleName,'address');
ws = new WebSocket('ws://'+address+'/');
const url = address.startsWith('wss://') ? address : ('ws://'+address+'/');
ws = new WebSocket(url);
ws.onmessage = function(msg){ ws.onmessage = function(msg){
//console.log(msg); //console.log(msg);
@@ -140,7 +200,8 @@ function startWebsocket() {
ws.send(JSON.stringify(msg)); ws.send(JSON.stringify(msg));
const msg2 = { const msg2 = {
target: "SD", target: "SD",
type: "init" type: "init",
system: game.system.id
} }
ws.send(JSON.stringify(msg2)); ws.send(JSON.stringify(msg2));
clearInterval(wsInterval); clearInterval(wsInterval);
@@ -166,6 +227,22 @@ export function sendWS(txt){
ws.send(txt); ws.send(txt);
} }
export function isEmpty(obj) {
for(var key in obj) {
if(obj.hasOwnProperty(key))
return false;
}
return true;
}
export function getPermission(action,func) {
const role = game.user.role-1;
const settings = game.settings.get(moduleName,'userPermission');
if (action == 'ENABLE') return settings.enable[role];
else return settings.permissions?.[action]?.[func]?.[role];
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Hooks // Hooks
@@ -176,25 +253,10 @@ export function sendWS(txt){
* Ready hook * Ready hook
* Attempt to open the websocket * Attempt to open the websocket
*/ */
Hooks.once('ready', ()=>{ Hooks.once('ready', async()=>{
registerSettings();
enableModule = (game.settings.get(moduleName,'Enable')) ? true : false; enableModule = (game.settings.get(moduleName,'Enable')) ? true : false;
game.socket.on(`module.MaterialDeck`, (payload) =>{
//console.log(payload);
if (payload.msgType != "playSound") return;
playTrack(payload.trackNr,payload.src,payload.play,payload.repeat,payload.volume);
});
for (let i=0; i<64; i++)
activeSounds[i] = false;
if (enableModule == false) return;
if (game.user.isGM == false) {
ready = true;
return;
}
startWebsocket();
soundboard = new SoundboardControl(); soundboard = new SoundboardControl();
streamDeck = new StreamDeck(); streamDeck = new StreamDeck();
tokenControl = new TokenControl(); tokenControl = new TokenControl();
@@ -203,7 +265,65 @@ Hooks.once('ready', ()=>{
combatTracker = new CombatTracker(); combatTracker = new CombatTracker();
playlistControl = new PlaylistControl(); playlistControl = new PlaylistControl();
otherControls = new OtherControls(); otherControls = new OtherControls();
externalModules = new ExternalModules();
sceneControl = new SceneControl();
game.socket.on(`module.MaterialDeck`, async(payload) =>{
//console.log(payload);
if (payload.msgType == "playSound") soundboard.playSound(payload.trackNr,payload.src,payload.play,payload.repeat,payload.volume);
else if (game.user.isGM && payload.msgType == "playPlaylist") {
const playlist = playlistControl.getPlaylist(payload.playlistNr);
playlistControl.playPlaylist(playlist,payload.playlistNr);
}
else if (game.user.isGM && payload.msgType == "playTrack") {
const playlist = playlistControl.getPlaylist(payload.playlistNr);
const sounds = playlist.data.sounds;
for (let track of sounds)
if (track._id == payload.trackId)
playlistControl.playTrack(track,playlist,payload.playlistNr)
}
else if (game.user.isGM && payload.msgType == "stopAllPlaylists")
playlistControl.stopAll(payload.force);
else if (game.user.isGM && payload.msgType == "soundboardUpdate") {
await game.settings.set(moduleName,'soundboardSettings',payload.settings);
const payloadNew = {
"msgType": "soundboardRefresh"
};
game.socket.emit(`module.MaterialDeck`, payloadNew);
}
else if (game.user.isGM == false && payload.msgType == "soundboardRefresh" && enableModule)
soundboard.updateAll();
else if (game.user.isGM && payload.msgType == "macroboardUpdate") {
await game.settings.set(moduleName,'macroSettings',payload.settings);
const payloadNew = {
"msgType": "macroboardRefresh"
};
game.socket.emit(`module.MaterialDeck`, payloadNew);
}
else if (game.user.isGM == false && payload.msgType == "macroboardRefresh" && enableModule)
macroControl.updateAll();
else if (game.user.isGM && payload.msgType == "playlistUpdate") {
await game.settings.set(moduleName,'playlists',payload.settings);
const payloadNew = {
"msgType": "playlistRefresh"
};
game.socket.emit(`module.MaterialDeck`, payloadNew);
}
else if (game.user.isGM == false && payload.msgType == "playlistRefresh" && enableModule)
playlistControl.updateAll();
});
for (let i=0; i<64; i++)
activeSounds[i] = false;
if (enableModule == false) return;
if (getPermission('ENABLE') == false) {
ready = true;
return;
}
startWebsocket();
let soundBoardSettings = game.settings.get(moduleName,'soundboardSettings'); let soundBoardSettings = game.settings.get(moduleName,'soundboardSettings');
let macroSettings = game.settings.get(moduleName, 'macroSettings'); let macroSettings = game.settings.get(moduleName, 'macroSettings');
@@ -232,34 +352,19 @@ Hooks.once('ready', ()=>{
}); });
} }
const hotbarUsesTemp = game.modules.get("illandril-hotbar-uses");
if (hotbarUsesTemp != undefined) {
hotbarUses = true;
}
}); });
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;
if (tokenId == selectedTokenId) if (tokenId == selectedTokenId)
tokenControl.update(selectedTokenId); tokenControl.update(selectedTokenId);
if (macroControl != undefined) macroControl.updateAll();
}); });
Hooks.on('updateActor',(scene,actor)=>{ Hooks.on('updateActor',(scene,actor)=>{
@@ -272,6 +377,7 @@ Hooks.on('updateActor',(scene,actor)=>{
tokenControl.update(selectedTokenId); tokenControl.update(selectedTokenId);
} }
} }
if (macroControl != undefined) macroControl.updateAll();
}); });
Hooks.on('controlToken',(token,controlled)=>{ Hooks.on('controlToken',(token,controlled)=>{
@@ -283,22 +389,35 @@ Hooks.on('controlToken',(token,controlled)=>{
selectedTokenId = undefined; selectedTokenId = undefined;
} }
tokenControl.update(selectedTokenId); tokenControl.update(selectedTokenId);
if (macroControl != undefined) macroControl.updateAll();
}); });
Hooks.on('updateOwnedItem',()=>{
if (macroControl != undefined) macroControl.updateAll();
})
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;
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;
combatTracker.updateAll(); if (combatTracker != undefined) combatTracker.updateAll();
tokenControl.update(selectedTokenId); if (tokenControl != undefined) tokenControl.update(selectedTokenId);
}); });
Hooks.on('renderPlaylistDirectory', (playlistDirectory)=>{ Hooks.on('renderPlaylistDirectory', (playlistDirectory)=>{
if (enableModule == false || ready == false) return; if (enableModule == false || ready == false) return;
playlistControl.updateAll(); if (playlistControl != undefined) playlistControl.updateAll();
}); });
Hooks.on('closeplaylistConfigForm', (form)=>{ Hooks.on('closeplaylistConfigForm', (form)=>{
@@ -312,19 +431,40 @@ 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 (enableModule == false || ready == false) return;
otherControls.updateAll(); 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 (otherControls != undefined) otherControls.updateAll();
}); });
Hooks.on('updateScene',()=>{ Hooks.on('updateScene',()=>{
if (enableModule == false || ready == false) return; if (enableModule == false || ready == false) return;
sceneControl.updateAll();
externalModules.updateAll();
otherControls.updateAll(); otherControls.updateAll();
}); });
Hooks.on('renderSceneControls',()=>{ Hooks.on('renderSceneControls',()=>{
if (enableModule == false || ready == false) return; if (enableModule == false || ready == false || otherControls == undefined) return;
otherControls.updateAll(); otherControls.updateAll();
externalModules.updateAll();
}); });
Hooks.on('targetToken',(user,token,targeted)=>{ Hooks.on('targetToken',(user,token,targeted)=>{
@@ -347,19 +487,60 @@ 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)=>{
if (enableModule == false || ready == false) return;
externalModules.updateAll({gmScreen:isOpen});
});
Hooks.on('ShareVision', ()=>{
if (enableModule == false || ready == false) return;
externalModules.updateAll();
})
Hooks.on('NotYourTurn', ()=>{
if (enableModule == false || ready == false) return;
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',()=>{

View File

@@ -71,7 +71,7 @@ Instructions and more info can be found in the <a href="https://github.com/CDeen
Module manifest: https://raw.githubusercontent.com/CDeenen/MaterialDeck/Master/module.json Module manifest: https://raw.githubusercontent.com/CDeenen/MaterialDeck/Master/module.json
## Software Versions & Module Incompatibilities ## Software Versions & Module Incompatibilities
<b>Foundry VTT:</b> Tested on 0.7.7<br> <b>Foundry VTT:</b> Tested on 0.7.9<br>
<b>Module Incompatibilities:</b> None known.<br> <b>Module Incompatibilities:</b> None known.<br>
## Feedback ## Feedback
@@ -81,6 +81,8 @@ If you have any suggestions or bugs to report, feel free to create an issue, con
<b>Author:</b> Cristian Deenen (Cris#6864 on Discord)<br> <b>Author:</b> Cristian Deenen (Cris#6864 on Discord)<br>
<br> <br>
Special thanks to Asmodeus#7588 who made this module possible by generously donating a Stream Deck XL Special thanks to Asmodeus#7588 who made this module possible by generously donating a Stream Deck XL
<br>
Please consider supporting me on <a href="https://www.patreon.com/materialfoundry">Patreon</a>, and feel free to join the Material Foundry <a href="https://discord.gg/3hd4G6TkmA">Discord</a> server.
## Abandonment ## Abandonment
Abandoned modules are a (potential) problem for Foundry, because users and/or other modules might rely on abandoned modules, which might break in future Foundry updates.<br> Abandoned modules are a (potential) problem for Foundry, because users and/or other modules might rely on abandoned modules, which might break in future Foundry updates.<br>

View File

@@ -1,19 +1,241 @@
# 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
Additions:
<ul>
<li>Material Deck can now be used by players. A 'User Permission Configuration' screen has been added to the module settings where the GM can deside what Material Deck functions are available to users</li>
<li>Macro Action: Added support for Illandril's Hotbar Uses (only requires the module to be installed, does not have to be active)</li>
<li>Token Action => OnClick: Added support for CUB conditions</li>
<li>External Modules => Added support for the 'Trigger Happy' module</li>
<li>External Modules => Added support for the 'MookAI' 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 'Not Your Turn' module</li>
</ul>
Fixes:
<ul>
<li>Token Action => OnClick: Fixed conditions for pf1e and dnd3.5e</li>
</ul>
Other Changes:
<ul>
<li>Token and Combat Tracker Actions now autodetect the game system</li>
<li>Game-system related settings in the SD app unified and improved</li>
<li>Image Cache setting is no longer considered experimental</li>
</ul>
<b>Note 1: </b>Because the module can now be used by players, some settings have been moved from 'world' settings to 'client' settings. This means that previous settings have been deleted, and they have to be set up again in the module settings.<br>
<b>Note 2: </b>You can give users access to the playlists, macro board and soundboard. Currently, everyone has to share the same configuration, so be careful with giving players permission to configure one of them.<br>
<b>Note 3: </b>Because of the new game system autodetection, some settings for non dnd5e systems might be deleted. You'll have to reconfigure them.<br>
<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.0 (<b>must be updated!</b>): https://github.com/CDeenen/MaterialDeck_SD/releases<br>
### v1.2.3 - 03-02-2021
Fixes:
<ul>
<li>Fixed some issues for the Shadow of the Demon Lord system</li>
</ul>
Other Changes:
<ul>
<li>Improved performance of the 'Playlist Configuration', 'Macro Configuration' and 'Soundboard Configuration' screens</li>
<li>Minor code clean-up</li>
</ul>
<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.2.2 (unchanged): https://github.com/CDeenen/MaterialDeck_SD/releases<br>
### v1.2.2 - 02-02-2021
Additions:
<ul>
<li>Added a help button in the module configuration</li>
<li>Token Action: Added support for easy token wildcard image changes</li>
<li>Token Action: Added a comprehensive custom onClick function that can modify token and actor data, with support for basic mathematical expressions</li>
</ul>
Other Changes:
<ul>
<li>Improved GM screen compatibility</li>
</ul>
<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.2.2: https://github.com/CDeenen/MaterialDeck_SD/releases<br>
### v1.2.1 - 07-01-2021
<b>Note:</b> Due to a change in how scene control is handled (moved from 'Other Controls' to its own 'Scene Action'), any actions related to scenes no longer work. You will have to set them up again using the new Scene Action.<br>
<br>
Additions:
<ul>
<li>EXPERIMENTAL: Added an image buffer to prevent resending of images that have already been sent, giving a slight performance boost. Buffer size can be set in the module settings</li>
<li>Token Action => Display Stats: Added option to select a data path for an attribute</li>
<li>External Modules => GM Screen: Open and close the GM screen. Link to module: https://foundryvtt.com/packages/gm-screen/</li>
<li>Other Actions => Roll dice: Roll dice in foundry and select between public roll, private roll, or displaying result on the SD</li>
<li>Scene Action: Added way to create scene selection screen similar to soundboard/macro board. New functions to do this: 'Scene Directory' and 'Scene Offset'</li>
<li>Scene Action: Added 'Active Scene' function</li>
<li>Move Action => Selected Token: Added rotate to and rotate by functions</li>
<li>Token Action => On Click: Added 'Set Vision' option to set the token's vision and light emission</li>
<li>Other Actions => Send Chat Message: Send a message to the Foundry chat</li>
</ul>
Other Changes:
<ul>
<li>Plugin: Scene Action created that replaces Other Actions => Scene Selection</li>
<li>Plugin: Scene Action: Changed 'Any Scene' to 'Scene by Name'</li>
<li>Plugin: Actions are now ordered alphabetically</li>
<li>Plugin: Replaced color strings with color pickers</li>
<li>Various minor bug fixes</li>
</ul>
<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.2.1: https://github.com/CDeenen/MaterialDeck_SD/releases<br>
### v1.2.0 - 28-12-2020
Fixes
<ul>
<li>Incorrect link to some black backgrounds fixed</li>
<li>Token Action: Movement speed wouldn't be displayed for DnD5e 1.2.0</li>
<li>Macro Action => Hotbar: 10th macro would not trigger and display correctly</li>
<li>Combat Tracker Action => Function: Default value would not properly initialize</li>
<li>Other Actions => Darkness Control => Display would not function correctly</li>
<li>Fixed some issues in the SD plugin where correct settings would not be displayed</li>
</ul>
Additions:
<ul>
<li>Added new 'External Modules Action', which will contain all module integrations that don't fit anywhere else</li>
<li>Added support for the Custom Hotbar module in 'Macro Action' => Mode: 'Custom Hotbar'. Link to module: https://foundryvtt.com/packages/custom-hotbar/</li>
<li>Added support for the FxMaster module in 'External Modules Action' => Mode: 'Fx Master'. Link to module: https://foundryvtt.com/packages/fxmaster/</li>
</ul>
### v1.1.1 - 12-12-2020
Fixes
<ul>
<li>Fixed issue where deleting a playlist would cause an error preventing the Soundboard Configuration to show up</li>
</ul>
<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.1.0 (unchanged): https://github.com/CDeenen/MaterialDeck_SD/releases<br>
### v1.1.0 - 09-12-2020 ### v1.1.0 - 09-12-2020
Fixes Fixes
<ul> <ul>
<li>Settings would not show for Combat Tracker action</li> <li>Settings would not show for Combat Tracker action</li>
<li>Macro Action => Macro Board default settings fixed</li> <li>Macro Action => Macro Board default settings fixed</li>
</li> <li>API has been improved, making integration with other hardware/software easier, and making future changes/additions easier</li>
Additions/changes: </ul>
Additions:
<ul> <ul>
<li>Added support for Pathfinder 1e and Shadow of the Demon Lord</li> <li>Added support for Pathfinder 1e and Shadow of the Demon Lord</li>
<li>All dialogs that are openable using the SD can now be closed by pressing the button while the dialog is open</li> <li>All dialogs that are openable using the SD can now be closed by pressing the button while the dialog is open</li>
<li>Playlist Action & Soundboard Action => Stop All now indicates if there are tracks/playlists/sounds playing</li> <li>Playlist Action & Soundboard Action => Stop All now indicates if there are tracks/playlists/sounds playing</li>
<li>Confirmed Foundry 0.7.8 compatibility</li> <li>Confirmed Foundry 0.7.8 compatibility</li>
<li>API has been improved, making integration with other hardware/software easier, and making future changes/additions easier</li> </ul>
<li>Moved default images to Foundry module side instead of Stream Deck plugin</li>
</li>
<b>Compatible server app and SD plugin:</b><br> <b>Compatible server app and SD plugin:</b><br>
Material Server v1.0.2 (unchanged): https://github.com/CDeenen/MaterialServer/releases <br> Material Server v1.0.2 (unchanged): https://github.com/CDeenen/MaterialServer/releases <br>

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
img/external/.thumb/external.png.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

BIN
img/external/.thumb/external@2x.png.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

BIN
img/external/.thumb/fxmaster.png.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

2
img/external/SOURCES.txt vendored Normal file
View File

@@ -0,0 +1,2 @@
external.png: Edited from https://fontawesome.com/icons/external-link-alt?style=solid
fxmaster.png: Edited from https://fontawesome.com/icons/magic?style=solid

BIN
img/external/external.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

BIN
img/external/external@2x.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

BIN
img/external/fxmaster.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.2 KiB

View File

@@ -1,2 +1,3 @@
center.png: made by me center.png: made by me.
rotatecw.png & rotateccw.png Edited from https://fontawesome.com/icons/sync-alt?style=solid.
All other images taken from freepngimg.com, iverted color and rotated. Source: https://freepngimg.com/png/24691-right-arrow-hd All other images taken from freepngimg.com, iverted color and rotated. Source: https://freepngimg.com/png/24691-right-arrow-hd

BIN
img/move/rotateccw.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

BIN
img/move/rotatecw.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

@@ -1 +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
d20.png: Edited from https://game-icons.net/1x1/delapouite/dice-twenty-faces-twenty.html

BIN
img/other/cogs.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
img/other/d20.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.5 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -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

View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

BIN
img/token/abilities/dex.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
img/token/abilities/int.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
img/token/abilities/str.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
img/token/abilities/wis.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
img/token/hp_empty.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View 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

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

BIN
img/token/skills/ani.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
img/token/skills/arc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
img/token/skills/ath.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
img/token/skills/dec.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
img/token/skills/his.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 KiB

BIN
img/token/skills/ins.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

BIN
img/token/skills/inv.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
img/token/skills/itm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
img/token/skills/med.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

BIN
img/token/skills/nat.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
img/token/skills/per.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

BIN
img/token/skills/prc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
img/token/skills/prf.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
img/token/skills/rel.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
img/token/skills/slt.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
img/token/skills/ste.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
img/token/skills/sur.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
img/token/temp_hp_empty.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -2,6 +2,9 @@
"MaterialDeck.Notifications.Disconnected": "Disconnected from Material Server, attempting to reconnect", "MaterialDeck.Notifications.Disconnected": "Disconnected from Material Server, attempting to reconnect",
"MaterialDeck.Notifications.ConnectFail": "Can't connect to Material Server, retrying", "MaterialDeck.Notifications.ConnectFail": "Can't connect to Material Server, retrying",
"MaterialDeck.Notifications.Connected": "Connected", "MaterialDeck.Notifications.Connected": "Connected",
"MaterialDeck.Notifications.Soundboard.NoPermission": "You do not have permission to configure the soundboard",
"MaterialDeck.Notifications.Macroboard.NoPermission": "You do not have permission to configure the macro board",
"MaterialDeck.Notifications.Playlist.NoPermission": "You do not have permission to configure the playlists",
"MaterialDeck.Sett.Enable": "Enable module", "MaterialDeck.Sett.Enable": "Enable module",
"MaterialDeck.Sett.Model": "Stream Deck Model", "MaterialDeck.Sett.Model": "Stream Deck Model",
@@ -9,11 +12,17 @@
"MaterialDeck.Sett.Model_Mini": "Mini", "MaterialDeck.Sett.Model_Mini": "Mini",
"MaterialDeck.Sett.Model_Normal": "Normal or Mobile", "MaterialDeck.Sett.Model_Normal": "Normal or Mobile",
"MaterialDeck.Sett.Model_XL": "XL", "MaterialDeck.Sett.Model_XL": "XL",
"MaterialDeck.Sett.Help": "Help",
"MaterialDeck.Sett.Permission": "User Permission Configuration",
"MaterialDeck.Sett.PlaylistConfig": "Playlist Configuration", "MaterialDeck.Sett.PlaylistConfig": "Playlist Configuration",
"MaterialDeck.Sett.MacroConfig": "Macro Configuration", "MaterialDeck.Sett.MacroConfig": "Macro Configuration",
"MaterialDeck.Sett.SoundboardConfig": "Soundboard Configuration", "MaterialDeck.Sett.SoundboardConfig": "Soundboard Configuration",
"MaterialDeck.Sett.ServerAddr": "Material Server Address", "MaterialDeck.Sett.ServerAddr": "Material Server Address",
"MaterialDeck.Sett.ServerAddrHint": "Fill in the IP address and port of the Material Server. 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.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",
@@ -40,6 +49,135 @@
"MaterialDeck.Off": "Off", "MaterialDeck.Off": "Off",
"MaterialDeck.Name": "Name", "MaterialDeck.Name": "Name",
"MaterialDeck.None": "None", "MaterialDeck.None": "None",
"MaterialDeck.Save": "Save" "MaterialDeck.Save": "Save",
"MaterialDeck.FxMaster.Colorize": "Colorize",
"MaterialDeck.FxMaster.Clear": "Clear All",
"MaterialDeck.Perm.Instructions": "Configure the permission for each Material Deck action.",
"MaterialDeck.Perm.DefaultNotification": "Material Deck user permissions have been configured to the default values.",
"MaterialDeck.Perm.ENABLE.label": "Enable Module",
"MaterialDeck.Perm.ENABLE.ENABLE.label": "Enable",
"MaterialDeck.Perm.ENABLE.ENABLE.hint": "Allow users to use Material Deck",
"MaterialDeck.Perm.COMBAT.label": "Combat Tracker",
"MaterialDeck.Perm.COMBAT.END_TURN.label": "End Turn",
"MaterialDeck.Perm.COMBAT.END_TURN.hint": "Allow users to end their turn",
"MaterialDeck.Perm.COMBAT.TURN_DISPLAY.label": "Turn Display",
"MaterialDeck.Perm.COMBAT.TURN_DISPLAY.hint": "Allow users to display the turn display",
"MaterialDeck.Perm.COMBAT.OTHER_FUNCTIONS.label": "Other Functions",
"MaterialDeck.Perm.COMBAT.OTHER_FUNCTIONS.hint": "Allow users to use other functions in the 'Function Mode', such as starting/stopping combat, increasing/decreasing the turn, etc",
"MaterialDeck.Perm.COMBAT.DISPLAY_COMBATANTS.label": "Display Combatants",
"MaterialDeck.Perm.COMBAT.DISPLAY_COMBATANTS.hint": "Allow users to display the combatants",
"MaterialDeck.Perm.COMBAT.DISPLAY_NON_OWNED_STATS.label": "Display Non-Owned and Non-Observer Stats",
"MaterialDeck.Perm.COMBAT.DISPLAY_NON_OWNED_STATS.hint": "Allow users to display stats for tokens they do not own or have observer permission for",
"MaterialDeck.Perm.COMBAT.DISPLAY_LIMITED_HP.label": "Display Limited HP",
"MaterialDeck.Perm.COMBAT.DISPLAY_LIMITED_HP.hint": "Allow users to display the HP of tokens they have Limited permission for",
"MaterialDeck.Perm.COMBAT.DISPLAY_OBSERVER_HP.label": "Display Observer HP",
"MaterialDeck.Perm.COMBAT.DISPLAY_OBSERVER_HP.hint": "Allow users to display the HP of tokens they have Observer permission for",
"MaterialDeck.Perm.COMBAT.DISPLAY_ALL_NAMES.label": "Display All Names",
"MaterialDeck.Perm.COMBAT.DISPLAY_ALL_NAMES.hint": "Allow users to display the name of all tokens",
"MaterialDeck.Perm.COMBAT.DISPLAY_LIMITED_NAME.label": "Display Limited Name",
"MaterialDeck.Perm.COMBAT.DISPLAY_LIMITED_NAME.hint": "Allow users to display the name of tokens they have Limited permission for",
"MaterialDeck.Perm.COMBAT.DISPLAY_OBSERVER_NAME.label": "Display Observer Name",
"MaterialDeck.Perm.COMBAT.DISPLAY_OBSERVER_NAME.hint": "Allow users to display the name of tokens they have Observer permission for",
"MaterialDeck.Perm.EXTERNAL.label": "External Modules",
"MaterialDeck.Perm.EXTERNAL.FXMASTER.label": "Fx Master",
"MaterialDeck.Perm.EXTERNAL.FXMASTER.hint": "Allow users to control the Fx Master module",
"MaterialDeck.Perm.EXTERNAL.GM_SCREEN.label": "GM Screen",
"MaterialDeck.Perm.EXTERNAL.GM_SCREEN.hint": "Allow users to display a GM screen using the GM Screen module",
"MaterialDeck.Perm.MACRO.label": "Macros",
"MaterialDeck.Perm.MACRO.HOTBAR.label": "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.hint": "Allow users to use the macro board",
"MaterialDeck.Perm.MACRO.MACROBOARD_CONFIGURE.label": "Configure the Macro Board",
"MaterialDeck.Perm.MACRO.MACROBOARD_CONFIGURE.hint": "Allow users to configure the macro board",
"MaterialDeck.Perm.MOVE.label": "Move",
"MaterialDeck.Perm.MOVE.TOKEN.label": "Token",
"MaterialDeck.Perm.MOVE.TOKEN.hint": "Allow users to move a controlled token",
"MaterialDeck.Perm.MOVE.CANVAS.label": "Canvas",
"MaterialDeck.Perm.MOVE.CANVAS.hint": "Allow users to move their canvas",
"MaterialDeck.Perm.OTHER.label": "Other",
"MaterialDeck.Perm.OTHER.PAUSE.label": "Pause/Resume",
"MaterialDeck.Perm.OTHER.PAUSE.hint": "Allow users to pause or resume the game",
"MaterialDeck.Perm.OTHER.CONTROL.label": "Control Buttons",
"MaterialDeck.Perm.OTHER.CONTROL.hint": "Allow users to control the control buttons",
"MaterialDeck.Perm.OTHER.DARKNESS.label": "Scene Darkness",
"MaterialDeck.Perm.OTHER.DARKNESS.hint": "Allow users to set the scene darkness",
"MaterialDeck.Perm.OTHER.DICE.label": "Dice Rolling",
"MaterialDeck.Perm.OTHER.DICE.hint": "Allow users to roll dice",
"MaterialDeck.Perm.OTHER.TABLES_ALL.label": "Roll Tables (all)",
"MaterialDeck.Perm.OTHER.TABLES_ALL.hint": "Allow users to view and roll from all roll tables",
"MaterialDeck.Perm.OTHER.TABLES.label": "Roll Tables (observer/owner)",
"MaterialDeck.Perm.OTHER.TABLES.hint": "Allow users to view and roll from roll tables that they have observer or owner permission for",
"MaterialDeck.Perm.OTHER.SIDEBAR.label": "Sidebar",
"MaterialDeck.Perm.OTHER.SIDEBAR.hint": "Allow users to control the sidebar",
"MaterialDeck.Perm.OTHER.COMPENDIUM_ALL.label": "Compendium Packs (all)",
"MaterialDeck.Perm.OTHER.COMPENDIUM_ALL.hint": "Allow users to open all compendium packs",
"MaterialDeck.Perm.OTHER.COMPENDIUM.label": "Compendium Packs (observer/owner)",
"MaterialDeck.Perm.OTHER.COMPENDIUM.hint": "Allow users to open compendium packs that they have observer or owner permission for",
"MaterialDeck.Perm.OTHER.JOURNAL_ALL.label": "Journals (all)",
"MaterialDeck.Perm.OTHER.JOURNAL_ALL.hint": "Allow users to open all journals",
"MaterialDeck.Perm.OTHER.JOURNAL.label": "Journals (observer/owner)",
"MaterialDeck.Perm.OTHER.JOURNAL.hint": "Allow users to open journals they have observer or owner permission for",
"MaterialDeck.Perm.OTHER.CHAT.label": "Chat Messages",
"MaterialDeck.Perm.OTHER.CHAT.hint": "Allow users to send chat messages",
"MaterialDeck.Perm.PLAYLIST.label": "Playlists",
"MaterialDeck.Perm.PLAYLIST.PLAY.label": "Control",
"MaterialDeck.Perm.PLAYLIST.PLAY.hint": "Allow users to play and pause playlists and tracks",
"MaterialDeck.Perm.PLAYLIST.CONFIGURE.label": "Configure",
"MaterialDeck.Perm.PLAYLIST.CONFIGURE.hint": "Allow users to configure the playlists",
"MaterialDeck.Perm.SCENE.label": "Scenes",
"MaterialDeck.Perm.SCENE.VISIBLE.label": "Visible Scenes",
"MaterialDeck.Perm.SCENE.VISIBLE.hint": "Allow users to view and control the visible scenes",
"MaterialDeck.Perm.SCENE.ACTIVE.label": "Active Scene",
"MaterialDeck.Perm.SCENE.ACTIVE.hint": "Allow users to view the active scene",
"MaterialDeck.Perm.SCENE.DIRECTORY.label": "Scene Directory",
"MaterialDeck.Perm.SCENE.DIRECTOR.hint": "Allow users to view and control scenes from the scene directory",
"MaterialDeck.Perm.SCENE.NAME.label": "Scene by Name",
"MaterialDeck.Perm.SCENE.NAME.hint": "Allow users to view and control any scene by name",
"MaterialDeck.Perm.SOUNDBOARD.label": "Soundboard",
"MaterialDeck.Perm.SOUNDBOARD.PLAY.label": "Enable",
"MaterialDeck.Perm.SOUNDBOARD.PLAY.hint": "Allow users to play sounds from the soundboard",
"MaterialDeck.Perm.SOUNDBOARD.CONFIGURE.label": "Configure",
"MaterialDeck.Perm.SOUNDBOARD.CONFIGURE.hint": "Allow users to configure the soundboard",
"MaterialDeck.Perm.TOKEN.label": "Token",
"MaterialDeck.Perm.TOKEN.STATS.label": "Display Stats",
"MaterialDeck.Perm.TOKEN.STATS.hint": "Allow the user to display the stats of the controlled token",
"MaterialDeck.Perm.TOKEN.VISIBILITY.label": "Toggle Visibility",
"MaterialDeck.Perm.TOKEN.VISIBILITY.hint": "Allow the user to toggle the visibility of the controlled token",
"MaterialDeck.Perm.TOKEN.COMBAT.label": "Toggle Combat State",
"MaterialDeck.Perm.TOKEN.COMBAT.hint": "Allow the user to toggle the combat state of the controlled token",
"MaterialDeck.Perm.TOKEN.VISION.label": "Set Vision",
"MaterialDeck.Perm.TOKEN.VISION.hint": "Allow the user to set the vision of the controlled token",
"MaterialDeck.Perm.TOKEN.WILDCARD.label": "Wildcard Images",
"MaterialDeck.Perm.TOKEN.WILDCARD.hint": "Allow the user to set the controlled token's image using the wildcard image functionality",
"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.CUSTOM.label": "Custom On-Click",
"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"
} }

View File

@@ -2,14 +2,16 @@
"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.1.0", "version": "1.4.1",
"minimumSDversion": "1.4.0",
"minimumMSversion": "1.0.2",
"author": "CDeenen", "author": "CDeenen",
"esmodules": [ "esmodules": [
"./MaterialDeck.js" "./MaterialDeck.js"
], ],
"socket": true, "socket": true,
"minimumCoreVersion": "0.7.5", "minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.8", "compatibleCoreVersion": "0.8.1",
"languages": [ "languages": [
{ {
"lang": "en", "lang": "en",

View File

@@ -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,62 +10,81 @@ 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) {
let 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;
let ctFunction = settings.combatTrackerFunction; const ctFunction = settings.combatTrackerFunction ? settings.combatTrackerFunction : 'startStop';
if (ctFunction == undefined) ctFunction == 'startStop'; const mode = settings.combatTrackerMode ? settings.combatTrackerMode : 'combatants';
const combat = game.combat;
let combat = game.combat;
let src = "modules/MaterialDeck/img/black.png"; let src = "modules/MaterialDeck/img/black.png";
let txt = ""; let txt = "";
let background = "#000000"; let background = "#000000";
let mode = settings.combatTrackerMode; settings.combat = true;
if (mode == undefined) mode = 'combatants';
if (mode == 'combatants'){ if (mode == 'combatants'){
if (MODULE.getPermission('COMBAT','DISPLAY_COMBATANTS') == false) {
streamDeck.noPermission(context,device,device,false,"combat tracker");
return;
}
if (combat != null && combat != undefined && combat.turns.length != 0){ if (combat != null && combat != undefined && combat.turns.length != 0){
let initiativeOrder = combat.turns; const initiativeOrder = combat.turns;
let nr = settings.combatantNr - 1; let nr = settings.combatantNr - 1;
if (nr == undefined || nr < 1) nr = 0; if (nr == undefined || nr < 1) nr = 0;
let combatantState = 1; const combatantState = (nr == combat.turn) ? 2 : 1;
if (nr == combat.turn) combatantState = 2; const combatant = initiativeOrder[nr]
let combatant = initiativeOrder[nr]
if (combatant != undefined){ if (combatant != undefined){
let 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) {
streamDeck.noPermission(context,device,device);
return;
}
if (combat != null && combat != undefined && combat.started){ if (combat != null && combat != undefined && combat.started){
let 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) {
streamDeck.noPermission(context,device);
return;
}
else if (ctFunction == 'endTurn' && MODULE.getPermission('COMBAT','END_TURN') == false) {
streamDeck.noPermission(context,device);
return;
}
else if (ctFunction != 'turnDisplay' && ctFunction != 'endTurn' && MODULE.getPermission('COMBAT','OTHER_FUNCTIONS') == false) {
streamDeck.noPermission(context,device);
return;
}
if (ctFunction == 'startStop') { if (ctFunction == 'startStop') {
if (combat == null || combat == undefined || combat.combatants.length == 0) { if (combat == null || combat == undefined || combat.combatants.length == 0) {
src = "modules/MaterialDeck/img/combattracker/startcombat.png"; src = "modules/MaterialDeck/img/combattracker/startcombat.png";
@@ -81,6 +101,9 @@ export class CombatTracker{
} }
} }
} }
else if (ctFunction == 'endTurn') {
src = "modules/MaterialDeck/img/combattracker/nextturn.png";
}
else if (ctFunction == 'nextTurn') { else if (ctFunction == 'nextTurn') {
src = "modules/MaterialDeck/img/combattracker/nextturn.png"; src = "modules/MaterialDeck/img/combattracker/nextturn.png";
} }
@@ -105,35 +128,41 @@ 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){
let mode = settings.combatTrackerMode; const mode = settings.combatTrackerMode ? settings.combatTrackerMode : 'combatants';
if (mode == undefined) mode = 'combatants'; const combat = game.combat;
if (mode == 'function'){ if (mode == 'function'){
let combat = game.combat;
if (combat == null || combat == undefined) return; if (combat == null || combat == undefined) return;
const ctFunction = settings.combatTrackerFunction ? settings.combatTrackerFunction : 'startStop';
if (ctFunction == 'turnDisplay' && MODULE.getPermission('COMBAT','TURN_DISPLAY') == false) {
streamDeck.noPermission(context,device);
return;
}
else if (ctFunction == 'endTurn' && MODULE.getPermission('COMBAT','END_TURN') == false) {
streamDeck.noPermission(context,device);
return;
}
else if (ctFunction != 'turnDisplay' && ctFunction != 'endTurn' && MODULE.getPermission('COMBAT','OTHER_FUNCTIONS') == false) {
streamDeck.noPermission(context,device);
return;
}
let ctFunction = settings.combatTrackerFunction;
if (ctFunction == undefined) ctFunction == 'startStop';
if (ctFunction == 'startStop'){ if (ctFunction == 'startStop'){
let src; let src;
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;
@@ -142,31 +171,26 @@ export class CombatTracker{
else if (ctFunction == 'prevTurn') game.combat.previousTurn(); else if (ctFunction == 'prevTurn') game.combat.previousTurn();
else if (ctFunction == 'nextRound') game.combat.nextRound(); else if (ctFunction == 'nextRound') game.combat.nextRound();
else if (ctFunction == 'prevRound') game.combat.previousRound(); else if (ctFunction == 'prevRound') game.combat.previousRound();
else if (ctFunction == 'endTurn' && game.combat.combatant.owner) game.combat.nextTurn();
} }
else { else {
let onClick = settings.onClick; const onClick = settings.onClick ? settings.onClick : 'doNothing';
if (onClick == undefined) onClick = 'doNothing';
let tokenId; let tokenId;
let combat = game.combat;
if (mode == 'combatants') { if (mode == 'combatants') {
if (combat != null && combat != undefined && combat.turns.length != 0){ if (combat != null && combat != undefined && combat.turns.length != 0){
let initiativeOrder = combat.turns; const initiativeOrder = combat.turns;
let nr = settings.combatantNr - 1; let nr = settings.combatantNr - 1;
if (nr == undefined || nr < 1) nr = 0; if (nr == undefined || nr < 1) nr = 0;
let combatantState = 1; const combatant = initiativeOrder[nr]
if (nr == combat.turn) combatantState = 2;
let 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 let token = (canvas.tokens.children[0] != undefined) ? canvas.tokens.children[0].children.find(p => p.id == tokenId) : undefined;
if (canvas.tokens.children[0] != undefined) token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
if (token == undefined) return; if (token == undefined) return;
if (onClick == 'doNothing') //Do nothing if (onClick == 'doNothing') //Do nothing
return; return;
@@ -178,7 +202,7 @@ export class CombatTracker{
canvas.animatePan(location); canvas.animatePan(location);
} }
else if (onClick == 'centerSelect'){ //center on token and select else if (onClick == 'centerSelect'){ //center on token and select
let location = token.getCenter(token.x,token.y); const location = token.getCenter(token.x,token.y);
canvas.animatePan(location); canvas.animatePan(location);
token.control(); token.control();
} }

703
src/external.js Normal file
View File

@@ -0,0 +1,703 @@
import * as MODULE from "../MaterialDeck.js";
import {streamDeck} from "../MaterialDeck.js";
export class ExternalModules{
constructor(){
this.active = false;
this.gmScreenOpen = false;
}
async updateAll(data={}){
if (data.gmScreen != undefined){
this.gmScreenOpen = data.gmScreen.isOpen;
}
if (this.active == false) return;
for (let device of streamDeck.buttonContext) {
for (let i=0; i<device.buttons.length; i++){
const data = device.buttons[i];
if (data == undefined || data.action != 'external') continue;
await this.update(data.settings,data.context,device.device);
}
}
}
update(settings,context,device){
this.active = true;
const module = settings.module ? settings.module : 'fxmaster';
if (module == 'fxmaster') this.updateFxMaster(settings,context,device);
else if (module == 'gmscreen') this.updateGMScreen(settings,context,device);
else if (module == 'triggerHappy') this.updateTriggerHappy(settings,context,device);
else if (module == 'sharedVision') this.updateSharedVision(settings,context,device);
else if (module == 'mookAI') this.updateMookAI(settings,context,device);
else if (module == 'notYourTurn') this.updateNotYourTurn(settings,context,device);
else if (module == 'lockView') this.updateLockView(settings,context,device);
else if (module == 'aboutTime') this.updateAboutTime(settings,context,device);
}
keyPress(settings,context,device){
if (this.active == false) return;
const module = settings.module ? settings.module : 'fxmaster';
if (module == 'fxmaster') this.keyPressFxMaster(settings,context,device);
else if (module == 'gmscreen') this.keyPressGMScreen(settings,context,device);
else if (module == 'triggerHappy') this.keyPressTriggerHappy(settings,context,device);
else if (module == 'sharedVision') this.keyPressSharedVision(settings,context,device);
else if (module == 'mookAI') this.keyPressMookAI(settings,context,device);
else if (module == 'notYourTurn') this.keyPressNotYourTurn(settings,context,device);
else if (module == 'lockView') this.keyPressLockView(settings,context,device);
else if (module == 'aboutTime') this.keyPressAboutTime(settings,context,device);
}
getModuleEnable(moduleId){
const module = game.modules.get(moduleId);
if (module == undefined || module.active == false) return false;
return true;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//FxMaster
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
updateFxMaster(settings,context,device){
if (game.user.isGM == false) return;
const fxmaster = game.modules.get("fxmaster");
if (fxmaster == undefined || fxmaster.active == false) return;
const type = (settings.fxMasterType == undefined) ? 'weatherControls' : settings.fxMasterType;
const displayIcon = settings.displayFxMasterIcon;
const displayName = settings.displayFxMasterName;
let ring = 0;
let ringColor = "#000000";
let background = "#000000"
let icon = '';
let name = '';
if (type == 'weatherControls') {
const effect = (settings.weatherEffect == undefined) ? 'leaves' : settings.weatherEffect;
name = CONFIG.weatherEffects[effect].label;
icon = CONFIG.weatherEffects[effect].icon;
ring = this.findWeatherEffect(effect) != undefined ? 2 : 1;
ringColor = ring < 2 ? '#000000' : "#00ff00";
}
else if (type == 'colorize') {
background = (settings.fxMasterColorizeColor == undefined) ? '#000000' : settings.fxMasterColorizeColor;
icon = "fas fa-palette";
name = game.i18n.localize("MaterialDeck.FxMaster.Colorize");
const filters = canvas.scene.getFlag("fxmaster", "filters");
ring = 2;
if (filters == undefined || filters['core_color'] == undefined) {
ringColor = "#000000";
}
else {
const colors = filters['core_color'].options;
let red = Math.ceil(colors.red*255).toString(16);
if (red.length == 1) red = '0' + red;
let green = Math.ceil(colors.green*255).toString(16);
if (green.length == 1) green = '0' + green;
let blue = Math.ceil(colors.blue*255).toString(16);
if (blue.length == 1) blue = '0' + blue;
ringColor = "#" + red + green + blue;
}
}
else if (type == 'filters') {
const filter = (settings.fxMasterFilter == undefined) ? 'underwater' : settings.fxMasterFilter;
name = CONFIG.fxmaster.filters[filter].label;
background = "#340057";
if (displayIcon){
if (filter == 'underwater') icon = "fas fa-water";
else if (filter == 'predator') icon = "fas fa-wave-square";
else if (filter == 'oldfilm') icon = "fas fa-film";
else if (filter == 'bloom') icon = "fas fa-ghost";
}
const fxmaster = canvas.scene.getFlag("fxmaster", "filters");
ring = 1;
if (fxmaster != undefined) {
const objKeys = Object.keys(fxmaster);
for (let i=0; i<objKeys.length; i++){
if (objKeys[i] == "core_"+filter) {
ring = 2;
ringColor = "#A600FF";
break;
}
}
}
}
else if (type == 'clear'){
icon = "fas fa-trash";
name = game.i18n.localize("MaterialDeck.FxMaster.Clear");
}
if (displayIcon) streamDeck.setIcon(context,device,icon,{background:background,ring:ring,ringColor:ringColor});
else streamDeck.setIcon(context,device, "", {background:background,ring:ring,ringColor:ringColor});
if (displayName == 0) name = "";
streamDeck.setTitle(name,context);
}
hexToRgb(hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
red: parseInt(result[1], 16)/256,
green: parseInt(result[2], 16)/256,
blue: parseInt(result[3], 16)/256
} : null;
}
keyPressFxMaster(settings,context,device){
if (game.user.isGM == false) return;
const fxmaster = game.modules.get("fxmaster");
if (fxmaster == undefined || fxmaster.active == false) return;
const type = (settings.fxMasterType == undefined) ? 'weatherControls' : settings.fxMasterType;
if (type == 'weatherControls') {
const effect = (settings.weatherEffect == undefined) ? 'leaves' : settings.weatherEffect;
let exists = false;
let newEffects = {};
let effects = canvas.scene.getFlag("fxmaster", "effects");
if (effects != undefined){
const weatherIds = Object.keys(effects);
for (let i=0; i<weatherIds.length; i++){
const weather = effects[weatherIds[i]].type;
if (weather === effect) {
exists = true;
continue;
}
newEffects[weatherIds[i]] = effects[weatherIds[i]];
}
}
const density = (settings.densitySlider == undefined) ? 50 : settings.densitySlider;
const speed = (settings.speedSlider == undefined) ? 50 : settings.speedSlider;
const direction = (settings.directionSlider == undefined) ? 50 : settings.directionSlider;
const scale = (settings.scaleSlider == undefined) ? 50 : settings.scaleSlider;
const color = (settings.fxMasterWeatherColor == undefined) ? "#000000" : settings.fxMasterWeatherColor;
const applyColor = (settings.fxWeatherEnColor == undefined) ? false : settings.fxWeatherEnColor;
if (exists == false) {
newEffects[randomID()] = {
type: effect,
options: {
density: density,
speed: speed,
scale: scale,
tint: color,
direction: direction,
apply_tint: applyColor
}
};
}
canvas.scene.unsetFlag("fxmaster", "effects").then(() => {
canvas.scene.setFlag("fxmaster", "effects", newEffects);
});
}
else if (type == 'colorize') {
const color = (settings.fxMasterColorizeColor == undefined) ? '#000000' : settings.fxMasterColorizeColor;
const filters = canvas.scene.getFlag("fxmaster", "filters");
let newFilters = {};
if (filters != undefined){
const filterObjects = Object.keys(filters);
for (let i=0; i<filterObjects.length; i++){
if (filterObjects[i] == 'core_color'){
//continue;
}
newFilters[filterObjects[i]] = filters[filterObjects[i]];
}
}
newFilters['core_color'] = {
type : 'color',
options: this.hexToRgb(color)
};
canvas.scene.unsetFlag("fxmaster", "filters").then(() => {
canvas.scene.setFlag("fxmaster", "filters", newFilters);
});
}
else if (type == 'filters') {
const filter = (settings.fxMasterFilter == undefined) ? 'underwater' : settings.fxMasterFilter;
const filters = canvas.scene.getFlag("fxmaster", "filters");
let newFilters = {};
let exists = false;
if (filters != undefined){
const filterObjects = Object.keys(filters);
for (let i=0; i<filterObjects.length; i++){
if (filterObjects[i] == 'core_'+filter){
exists = true;
continue;
}
newFilters[filterObjects[i]] = filters[filterObjects[i]];
}
}
if (exists == false) {
newFilters['core_'+filter] = {type : filter};
}
canvas.scene.unsetFlag("fxmaster", "filters").then(() => {
canvas.scene.setFlag("fxmaster", "filters", newFilters);
});
}
else if (type == 'clear'){
canvas.scene.unsetFlag("fxmaster", "filters");
canvas.scene.unsetFlag("fxmaster", "effects");
}
}
findWeatherEffect(effect){
const effects = canvas.scene.getFlag("fxmaster", "effects");
if (effects == undefined) return undefined;
const weatherIds = Object.keys(effects);
for (let i = 0; i < weatherIds.length; ++i) {
const weather = effects[weatherIds[i]].type;
if (weather === effect) return weatherIds[i];
}
return undefined;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//GM Screen
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
updateGMScreen(settings,context,device){
if (this.getModuleEnable("gm-screen") == false) return;
if (game.user.isGM == false) return;
const background = settings.gmScreenBackground ? settings.gmScreenBackground : '#000000';
let ring = 1;
const ringColor = '#00FF00'
let src = '';
let txt = '';
if (this.gmScreenOpen) ring = 2;
if (settings.displayGmScreenIcon) src = "fas fa-book-reader";
streamDeck.setIcon(context,device,src,{background:background,ring:ring,ringColor:ringColor});
if (settings.displayGmScreenName) txt = game.i18n.localize(`GMSCR.gmScreen.Open`);
streamDeck.setTitle(txt,context);
}
keyPressGMScreen(settings,context,device){
if (this.getModuleEnable("gm-screen") == false) return;
if (game.user.isGM == false) return;
window['gm-screen'].toggleGmScreenVisibility();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Trigger Happy
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
updateTriggerHappy(settings,context,device) {
if (this.getModuleEnable("trigger-happy") == false) return;
if (game.user.isGM == false) return;
const displayName = settings.displayTriggerHappyName ? settings.displayTriggerHappyName : false;
const displayIcon = settings.displayTriggerHappyIcon ? settings.displayTriggerHappyIcon : false;
const background = "#340057";
const ringColor = game.settings.get("trigger-happy", "enableTriggers") ? "#A600FF" : "#340057";
let txt = '';
if (displayIcon) streamDeck.setIcon(context,device,"fas fa-grin-squint-tears",{background:background,ring:2,ringColor:ringColor});
else streamDeck.setIcon(context,device,'',{background:'#000000'});
if (displayName) txt = 'Trigger Happy';
streamDeck.setTitle(txt,context);
}
keyPressTriggerHappy(settings,context,device){
if (this.getModuleEnable("trigger-happy") == false) return;
if (game.user.isGM == false) return;
const mode = settings.triggerHappyMode ? settings.triggerHappyMode : 'toggle';
let val = game.settings.get("trigger-happy", "enableTriggers");
if (mode == 'toggle') val = !val;
else if (mode == 'enable') val = true;
else if (mode == 'disable') val = false;
game.settings.set("trigger-happy", "enableTriggers", val);
const control = ui.controls.controls.find(c => c.name == 'token');
if (control == undefined) return;
let tool = control.tools.find(t => t.name == 'triggers');
if (tool == undefined) return;
tool.active = val;
ui.controls.render();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Shared Vision
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
updateSharedVision(settings,context,device) {
if (this.getModuleEnable("SharedVision") == false) return;
if (game.user.isGM == false) return;
const displayName = settings.sharedVisionName ? settings.sharedVisionName : false;
const displayIcon = settings.sharedVisionIcon ? settings.sharedVisionIcon : false;
const background = "#340057";
const ringColor = game.settings.get("SharedVision", "enable") ? "#A600FF" : "#340057";
let txt = '';
if (displayIcon) streamDeck.setIcon(context,device,"fas fa-eye",{background:background,ring:2,ringColor:ringColor});
else streamDeck.setIcon(context,device,'',{background:'#000000'});
if (displayName) txt = 'Shared Vision';
streamDeck.setTitle(txt,context);
}
keyPressSharedVision(settings,context,device) {
if (this.getModuleEnable("SharedVision") == false) return;
if (game.user.isGM == false) return;
const mode = settings.sharedVisionMode ? settings.sharedVisionMode : 'toggle';
if (mode == 'toggle') Hooks.call("setShareVision",{enable:'toggle'});
else if (mode == 'enable') Hooks.call("setShareVision",{enable:true});
else if (mode == 'disable') Hooks.call("setShareVision",{enable:false});
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Mook AI
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
updateMookAI(settings,context,device) {
if (this.getModuleEnable("mookAI") == false) return;
if (game.user.isGM == false) return;
const displayName = settings.mookName ? settings.mookName : false;
const displayIcon = settings.mookIcon ? settings.mookIcon : false;
const background = "#000000";
let txt = '';
if (displayIcon) streamDeck.setIcon(context,device,"fas fa-brain",{background:'#000000'});
else streamDeck.setIcon(context,device,'',{background:'#000000'});
if (displayName) txt = 'Mook AI';
streamDeck.setTitle(txt,context);
}
async keyPressMookAI(settings,context,device) {
if (this.getModuleEnable("mookAI") == false) return;
if (game.user.isGM == false) return;
let mook = await import('../../mookAI/scripts/mookAI.js');
let mookAI = new mook.MookAI ();
mookAI.takeNextTurn();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Not Your Turn!
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
updateNotYourTurn(settings,context,device) {
if (this.getModuleEnable("NotYourTurn") == false) return;
if (game.user.isGM == false) return;
const mode = settings.notYourTurnMode ? settings.notYourTurnMode : 'toggle';
const displayName = settings.notYourTurnName ? settings.notYourTurnName : false;
const displayIcon = settings.notYourTurnIcon ? settings.notYourTurnIcon : false;
const background = "#340057";
let ringColor = "#340057" ;
let txt = '';
let icon = '';
if (mode == 'toggle' || mode == 'enable' || mode == 'disable') {
icon = "fas fa-fist-raised";
txt = "Block Combat Movement";
ringColor = game.settings.get('NotYourTurn','enable') ? "#A600FF": "#340057" ;
}
else {
icon = "fas fa-lock";
txt = "Block Non-Combat Movement";
ringColor = game.settings.get('NotYourTurn','nonCombat') ? "#A600FF": "#340057" ;
}
if (displayIcon) streamDeck.setIcon(context,device,icon,{background:background,ring:2,ringColor:ringColor});
else streamDeck.setIcon(context,device,'',{background:'#000000'});
if (displayName == false) txt = '';
streamDeck.setTitle(txt,context);
}
async keyPressNotYourTurn(settings,context,device) {
if (this.getModuleEnable("NotYourTurn") == false) return;
if (game.user.isGM == false) return;
const mode = settings.notYourTurnMode ? settings.notYourTurnMode : 'toggle';
if (mode == 'toggle') Hooks.call("setNotYourTurn",{combat:'toggle'});
else if (mode == 'enable') Hooks.call("setNotYourTurn",{combat:true});
else if (mode == 'disable') Hooks.call("setNotYourTurn",{combat:false});
else if (mode == 'toggleNonCombat') Hooks.call("setNotYourTurn",{nonCombat:'toggle'});
else if (mode == 'enableNonCombat') Hooks.call("setNotYourTurn",{nonCombat:true});
else if (mode == 'disableNonCombat') Hooks.call("setNotYourTurn",{nonCombat:false});
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Lock View
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
updateLockView(settings,context,device) {
if (this.getModuleEnable("LockView") == false) return;
if (game.user.isGM == false) return;
const mode = settings.lockViewMode ? settings.lockViewMode : 'panLock';
const displayName = settings.lockViewName ? settings.lockViewName : false;
const displayIcon = settings.lockViewIcon ? settings.lockViewIcon : false;
const background = "#340057";
let ringColor = "#340057" ;
let txt = '';
let icon = '';
if (mode == 'panLock') {
icon = "fas fa-arrows-alt";
txt = "Pan Lock";
ringColor = canvas.scene.getFlag('LockView', 'lockPan') ? "#A600FF": "#340057" ;
}
else if (mode == 'zoomLock') {
icon = "fas fa-search-plus";
txt = "Zoom Lock";
ringColor = canvas.scene.getFlag('LockView', 'lockZoom') ? "#A600FF": "#340057" ;
}
else if (mode == 'boundingBox') {
icon = "fas fa-box";
txt = "Bounding Box";
ringColor = canvas.scene.getFlag('LockView', 'boundingBox') ? "#A600FF": "#340057" ;
}
if (displayIcon) streamDeck.setIcon(context,device,icon,{background:background,ring:2,ringColor:ringColor});
else streamDeck.setIcon(context,device,'',{background:'#000000'});
if (displayName == false) txt = '';
streamDeck.setTitle(txt,context);
}
async keyPressLockView(settings,context,device) {
if (this.getModuleEnable("LockView") == false) return;
if (game.user.isGM == false) return;
const mode = settings.lockViewMode ? settings.lockViewMode : 'panLock';
let toggle = settings.lockViewToggle ? settings.lockViewToggle : 'toggle';
if (toggle == 'enable') toggle = true;
else if (toggle == 'disable') toggle = false;
let msg = {};
if (mode == 'panLock') msg = {panLock:toggle};
else if (mode == 'zoomLock') msg = {zoomLock:toggle};
else if (mode == 'boundingBox') msg = {boundingBox:toggle};
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 });
}
}
}

View File

@@ -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,159 +10,185 @@ 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) {
let 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);
}
} }
} }
update(settings,context){ async update(settings,context,device){
this.active = true; this.active = true;
let mode = settings.macroMode; const mode = settings.macroMode ? settings.macroMode : 'hotbar';
let displayName = settings.displayName; const displayName = settings.displayName ? settings.displayName : false;
const displayIcon = settings.displayIcon ? settings.displayIcon : false;
const displayUses = settings.displayUses ? settings.displayUses : false;
let background = settings.background ? settings.background : '#000000';
let macroNumber = settings.macroNumber; let macroNumber = settings.macroNumber;
let background = settings.background; if (macroNumber == undefined || isNaN(parseInt(macroNumber))) macroNumber = 0;
let icon = false;
if (settings.displayIcon) icon = true;
let ringColor = "#000000";
let ring = 0;
if(macroNumber == undefined || isNaN(parseInt(macroNumber))){
macroNumber = 0;
}
if (mode == undefined) mode = 'hotbar';
if (displayName == undefined) displayName = false;
if (background == undefined) background = '#000000';
macroNumber = parseInt(macroNumber); macroNumber = parseInt(macroNumber);
if (mode == 'macroBoard') { //Macro board let ringColor = "#000000";
let ring = 0;
let name = ""; let name = "";
let src = ''; let src = "";
if (settings.macroBoardMode == 'offset') { //Offset let macroId = undefined;
let ringOffColor = settings.offRing; let uses = undefined;
if (ringOffColor == undefined) ringOffColor = '#000000';
let ringOnColor = settings.onRing; if (mode == 'macroBoard') { //Macro board
if (ringOnColor == undefined) ringOnColor = '#00FF00'; if ((MODULE.getPermission('MACRO','MACROBOARD') == false )) {
streamDeck.noPermission(context,device);
return;
}
if (settings.macroBoardMode == 'offset') { //Offset
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
let macroOffset = parseInt(settings.macroOffset); let macroOffset = parseInt(settings.macroOffset);
if (macroOffset == undefined || isNaN(macroOffset)) macroOffset = 0; if (macroOffset == undefined || isNaN(macroOffset)) macroOffset = 0;
if (macroOffset == parseInt(this.offset)) ringColor = ringOnColor; ringColor = (macroOffset == parseInt(this.offset)) ? ringOnColor : ringOffColor;
else ringColor = ringOffColor;
ring = 2; ring = 2;
//streamDeck.setIcon(context, "", background,ring,ringColor);
} }
else { //Execute macro else { //Execute macro
macroNumber += this.offset - 1; macroNumber += this.offset - 1;
if (macroNumber < 0) macroNumber = 0; if (macroNumber < 0) macroNumber = 0;
var macroId = game.settings.get(MODULE.moduleName,'macroSettings').macros[macroNumber]; macroId = game.settings.get(MODULE.moduleName,'macroSettings').macros[macroNumber];
background = game.settings.get(MODULE.moduleName,'macroSettings').color[macroNumber]; background = game.settings.get(MODULE.moduleName,'macroSettings').color[macroNumber];
if (background == undefined) background = '#000000'; if (background == undefined) background = '#000000';
src = "";
if (macroId != undefined){
let macro = game.macros._source.find(p => p._id == macroId);
if (macro != undefined) {
name += macro.name;
src += macro.img;
}
}
ring = 0; ring = 0;
} }
if (icon) streamDeck.setIcon(context,src,background,ring,ringColor);
else streamDeck.setIcon(context, "", background,ring,ringColor);
if (displayName == 0) name = "";
streamDeck.setTitle(name,context);
} }
else 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
let macroId if ((MODULE.getPermission('MACRO','HOTBAR') == false )) {
streamDeck.noPermission(context,device);
return;
}
if (mode == 'hotbar') macroId = game.user.data.hotbar[macroNumber]; if (mode == 'hotbar') macroId = game.user.data.hotbar[macroNumber];
else { else {
let macros = game.macros.apps[0].macros; let macros;
for (let j=0; j<10; j++){ if (mode == 'customHotbar' && game.modules.get('custom-hotbar') != undefined)
if (macros[j].key == macroNumber){ macros = ui.customHotbar.macros;
if (macros[j].macro == null) macroId == undefined; else
else macroId = macros[j].macro._id; macros = game.macros.apps[0].macros;
if (macroNumber > 9) macroNumber = 0;
macroId = game.macros.apps[0].macros.find(m => m.key == macroNumber).macro?.id
} }
} }
}
let src = "";
let name = "";
if (macroId != undefined){ if (macroId != undefined){
let macro = game.macros._source.find(p => p._id == macroId); let macro = game.macros._source.find(p => p._id == macroId);
if (macro != undefined) { if (macro != undefined) {
name += macro.name; if (displayName) name = macro.name;
src += macro.img; if (displayIcon) src = macro.img;
if (MODULE.hotbarUses && displayUses) uses = await this.getUses(macro);
} }
} }
if (icon) streamDeck.setIcon(context,src,background); else {
else streamDeck.setIcon(context, "", background); if (displayName) name = "";
if (displayName == 0) name = ""; if (displayIcon) src = "modules/MaterialDeck/img/black.png";
}
streamDeck.setIcon(context,device,src,{background:background,ring:ring,ringColor:ringColor,uses:uses});
streamDeck.setTitle(name,context); streamDeck.setTitle(name,context);
} }
async getUses(macro) {
let hbUses = await import('../../illandril-hotbar-uses/scripts/item-system.js');
const command = macro.command;
const uses = await hbUses.calculateUses(command);
return uses;
} }
hotbar(macros){ async hotbar(macros){
for (let i=0; i<32; i++){ for (let i=0; i<32; i++){
let data = streamDeck.buttonContext[i]; const data = streamDeck.buttonContext[i];
if (data == undefined || data.action != 'macro' || data.settings.macroMode == 'macroBoard') continue; if (data == undefined || data.action != 'macro' || data.settings.macroMode == 'macroBoard') continue;
let context = data.context;
let mode = data.settings.macroMode; const context = data.context;
let displayName = data.settings.displayName; const mode = data.settings.macroMode ? data.settings.macroMode : 'hotbar';
const displayName = data.settings.displayName ? data.settings.displayName : false;
const displayIcon = data.settings.displayIcon ? data.settings.displayIcon : false;
const displayUses = data.settings.displayUses ? data.settings.displayUses : false;
let background = data.settings.background ? data.settings.background : '#000000';
let macroNumber = data.settings.macroNumber; let macroNumber = data.settings.macroNumber;
let background = data.settings.background; if(macroNumber == undefined || isNaN(parseInt(macroNumber))) macroNumber = 1;
if ((MODULE.getPermission('MACRO','HOTBAR') == false )) {
streamDeck.noPermission(context,device);
return;
}
let src = ""; let src = "";
let name = ""; let name = "";
if(macroNumber == undefined || isNaN(parseInt(macroNumber))){
macroNumber = 1; if (mode == 'Macro Board') continue;
}
if (mode == undefined) mode = 0;
if (mode == 2) continue;
if (displayName == undefined) displayName = false;
if (background == undefined) background = '#000000';
let macroId; let macroId;
if (mode == 0){ if (mode == 'hotbar'){
macroId = game.user.data.hotbar[macroNumber]; macroId = game.user.data.hotbar[macroNumber];
} }
else { else {
for (let j=0; j<10; j++){ if (macroNumber > 9) macroNumber = 0;
if (macros[j].key == macroNumber){ macroId = game.macros.apps[0].macros.find(m => m.key == macroNumber).macro?.id
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) {
name += macro.name; if (displayName) name += macro.name;
src += macro.img; if (displayIcon) src += macro.img;
if (MODULE.hotbarUses && displayUses) uses = await this.getUses(macro);
} }
streamDeck.setIcon(context,src,background); streamDeck.setIcon(context,device,src,{background:background,uses:uses});
if (displayName == 0) name = "";
streamDeck.setTitle(name,context); streamDeck.setTitle(name,context);
} }
} }
keyPress(settings){ keyPress(settings){
let mode = settings.macroMode; const mode = settings.macroMode ? settings.macroMode : 'hotbar';
if (mode == undefined) mode = 'hotbar';
let macroNumber = settings.macroNumber; let macroNumber = settings.macroNumber;
if(macroNumber == undefined || isNaN(parseInt(macroNumber))){ if(macroNumber == undefined || isNaN(parseInt(macroNumber))) macroNumber = 0;
macroNumber = 0; let target = settings.target ? settings.target : undefined;
if (mode == 'hotbar' || mode == 'visibleHotbar' || mode == 'customHotbar'){
if ((MODULE.getPermission('MACRO','HOTBAR') == false )) return;
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, {});
} }
if (mode == 'hotbar' || mode == 'visibleHotbar') }
this.executeHotbar(macroNumber,mode);
else { else {
if ((MODULE.getPermission('MACRO','MACROBOARD') == false )) return;
if (settings.macroBoardMode == 'offset') { if (settings.macroBoardMode == 'offset') {
let macroOffset = settings.macroOffset; let macroOffset = settings.macroOffset;
if (macroOffset == undefined) macroOffset = 0; if (macroOffset == undefined) macroOffset = 0;
@@ -175,15 +202,15 @@ export class MacroControl{
executeHotbar(macroNumber,mode){ executeHotbar(macroNumber,mode){
let macroId let macroId
if (mode == 0) macroId = game.user.data.hotbar[macroNumber]; if (mode == 'hotbar') macroId = game.user.data.hotbar[macroNumber];
else { else {
let macros = game.macros.apps[0].macros; let macros;
for (let j=0; j<10; j++){ if (mode == 'customHotbar' && game.modules.get('custom-hotbar') != undefined) {
if (macros[j].key == macroNumber){ macros = ui.customHotbar.macros;
if (macros[j].macro == null) macroId == undefined;
else macroId = macros[j].macro._id;
}
} }
else macros = game.macros.apps[0].macros;
if (macroNumber > 9) macroNumber = 0;
macroId = game.macros.apps[0].macros.find(m => m.key == macroNumber).macro?.id
} }
if (macroId == undefined) return; if (macroId == undefined) return;
let macro = game.macros.get(macroId); let macro = game.macros.get(macroId);
@@ -202,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 {
@@ -217,13 +244,3 @@ export class MacroControl{
} }
} }
} }

View File

@@ -1,12 +1,21 @@
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);
this.data = data; this.data = data;
this.playlistNr; this.playlistNr;
this.updatePlaylistNr = false;
} }
/** /**
@@ -18,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"
}); });
} }
@@ -26,7 +36,14 @@ export class playlistConfigForm extends FormApplication {
* Provide data to the template * Provide data to the template
*/ */
getData() { getData() {
if (MODULE.getPermission('PLAYLIST','CONFIGURE') == false ) {
ui.notifications.warn(game.i18n.localize("MaterialDeck.Notifications.Playlist.NoPermission"));
return;
}
//Get the playlist settings
let settings = game.settings.get(MODULE.moduleName,'playlists'); let settings = game.settings.get(MODULE.moduleName,'playlists');
//Get values from the settings, and check if they are defined
let selectedPlaylists = settings.selectedPlaylist; let selectedPlaylists = settings.selectedPlaylist;
if (selectedPlaylists == undefined) selectedPlaylists = []; if (selectedPlaylists == undefined) selectedPlaylists = [];
let selectedPlaylistMode = settings.playlistMode; let selectedPlaylistMode = settings.playlistMode;
@@ -36,17 +53,17 @@ export class playlistConfigForm extends FormApplication {
if (numberOfPlaylists == undefined) numberOfPlaylists = 9; if (numberOfPlaylists == undefined) numberOfPlaylists = 9;
let playMode = settings.playMode; let playMode = settings.playMode;
if (playMode == undefined) playMode = 0; if (playMode == undefined) playMode = 0;
let playlistData = [];
this.updatePlaylistNr = false;
//Create array to store all the data for each playlist
let playlistData = [];
for (let i=0; i<numberOfPlaylists; i++){ for (let i=0; i<numberOfPlaylists; i++){
if (selectedPlaylists[i] == undefined) selectedPlaylists[i] = 'none'; if (selectedPlaylists[i] == undefined) selectedPlaylists[i] = 'none';
if (selectedPlaylistMode[i] == undefined) selectedPlaylistMode[i] = 0; if (selectedPlaylistMode[i] == undefined) selectedPlaylistMode[i] = 0;
let dataThis = { let dataThis = {
iteration: i+1, iteration: i+1,
playlist: selectedPlaylists[i], playlist: selectedPlaylists[i],
playlistMode: selectedPlaylistMode[i], playlistMode: selectedPlaylistMode[i]
playlists: game.playlists.entities
} }
playlistData.push(dataThis); playlistData.push(dataThis);
} }
@@ -59,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
@@ -89,9 +106,8 @@ export class playlistConfigForm extends FormApplication {
numberOfPlaylists.on("change", event => { numberOfPlaylists.on("change", event => {
this.playlistNr = event.target.value; this.playlistNr = event.target.value;
this.updatePlaylistNr = true;
this.data.playlistNumber=event.target.value; this.data.playlistNumber=event.target.value;
this.updateSettings(this.data); this.updateSettings(this.data,true);
}); });
selectedPlaylist.on("change", event => { selectedPlaylist.on("change", event => {
@@ -106,10 +122,21 @@ export class playlistConfigForm extends FormApplication {
this.updateSettings(this.data); this.updateSettings(this.data);
}); });
} }
async updateSettings(settings){
async updateSettings(settings,render){
if (game.user.isGM) {
await game.settings.set(MODULE.moduleName,'playlists', settings); await game.settings.set(MODULE.moduleName,'playlists', settings);
if (MODULE.enableModule) playlistControl.updateAll(); if (MODULE.enableModule) playlistControl.updateAll();
this.render(); if (render) this.render();
}
else {
const payload = {
"msgType": "playlistUpdate",
"settings": settings,
"render": render
};
game.socket.emit(`module.MaterialDeck`, payload);
}
} }
} }
@@ -125,16 +152,6 @@ export class macroConfigForm extends FormApplication {
* Default Options for this FormApplication * Default Options for this FormApplication
*/ */
static get defaultOptions() { static get defaultOptions() {
/*
let streamDeckModel = game.settings.get(MODULE.moduleName,'streamDeckModel');
let width;
if (streamDeckModel == 0)
width = 550;
else if (streamDeckModel == 1)
width= 1500;
else
width = 1400;
*/
return mergeObject(super.defaultOptions, { return mergeObject(super.defaultOptions, {
id: "macro-config", id: "macro-config",
title: "Material Deck: "+game.i18n.localize("MaterialDeck.Sett.MacroConfig"), title: "Material Deck: "+game.i18n.localize("MaterialDeck.Sett.MacroConfig"),
@@ -147,19 +164,30 @@ export class macroConfigForm extends FormApplication {
* Provide data to the template * Provide data to the template
*/ */
getData() { getData() {
if (MODULE.getPermission('MACRO','MACROBOARD_CONFIGURE') == false ) {
ui.notifications.warn(game.i18n.localize("MaterialDeck.Notifications.Macroboard.NoPermission"));
return;
}
//Get the settings
var selectedMacros = game.settings.get(MODULE.moduleName,'macroSettings').macros; var selectedMacros = game.settings.get(MODULE.moduleName,'macroSettings').macros;
var color = game.settings.get(MODULE.moduleName,'macroSettings').color; var color = game.settings.get(MODULE.moduleName,'macroSettings').color;
var args = game.settings.get(MODULE.moduleName,'macroSettings').args; var args = game.settings.get(MODULE.moduleName,'macroSettings').args;
//Check if the settings are defined
if (selectedMacros == undefined) selectedMacros = []; if (selectedMacros == undefined) selectedMacros = [];
if (color == undefined) color = []; if (color == undefined) color = [];
if (args == undefined) args = []; if (args == undefined) args = [];
let macroData = [];
let furnaceEnabled = false;
let furnace = game.modules.get("furnace");
if (furnace != undefined && furnace.active) furnaceEnabled = true;
let height = 95;
if (furnaceEnabled) height += 50;
//Check if the Furnace is installed and enabled
let furnaceEnabled = false;
let height = 95;
let furnace = game.modules.get("furnace");
if (furnace != undefined && furnace.active && compatibleCore("0.8.1")==false) {
furnaceEnabled = true;
height += 50;
}
//Check what SD model the user is using, and set the number of rows and columns to correspond
let streamDeckModel = game.settings.get(MODULE.moduleName,'streamDeckModel'); let streamDeckModel = game.settings.get(MODULE.moduleName,'streamDeckModel');
let iMax,jMax; let iMax,jMax;
if (streamDeckModel == 0){ if (streamDeckModel == 0){
@@ -176,38 +204,34 @@ export class macroConfigForm extends FormApplication {
} }
let iteration = 0; let iteration = 0;
let macroData = [];
for (let j=0; j<jMax; j++){ for (let j=0; j<jMax; j++){
let macroThis = []; let macroThis = [];
for (let i=0; i<iMax; i++){ for (let i=0; i<iMax; i++){
let colorThis = color[iteration]; let colorData = color[iteration];
if (colorThis != undefined){ if (colorData != undefined){
let colorCorrect = true; let colorCorrect = true;
if (colorThis[0] != '#') colorCorrect = false; if (colorData[0] != '#') colorCorrect = false;
for (let k=0; k<6; k++){ for (let k=0; k<6; k++){
if (parseInt(colorThis[k+1],16)>15) if (parseInt(colorData[k+1],16)>15)
colorCorrect = false; colorCorrect = false;
} }
if (colorCorrect == false) colorThis = '#000000'; if (colorCorrect == false) colorData = '#000000';
} }
else else
colorThis = '#000000'; colorData = '#000000';
let dataThis = { let dataThis = {
iteration: iteration+1, iteration: iteration+1,
macro: selectedMacros[iteration], macro: selectedMacros[iteration],
color: colorThis, color: colorData,
macros:game.macros, args: args[iteration]
args: args[iteration],
furnace: furnaceEnabled
} }
macroThis.push(dataThis); macroThis.push(dataThis);
iteration++; iteration++;
} }
let data = { macroData.push({dataThis: macroThis});
dataThis: macroThis,
};
macroData.push(data);
} }
return { return {
@@ -215,6 +239,7 @@ export class macroConfigForm extends FormApplication {
macros: game.macros, macros: game.macros,
selectedMacros: selectedMacros, selectedMacros: selectedMacros,
macroData: macroData, macroData: macroData,
furnace: furnaceEnabled
} }
} }
@@ -256,9 +281,17 @@ export class macroConfigForm extends FormApplication {
} }
async updateSettings(settings){ async updateSettings(settings){
if (game.user.isGM) {
await game.settings.set(MODULE.moduleName,'macroSettings',settings); await game.settings.set(MODULE.moduleName,'macroSettings',settings);
if (MODULE.enableModule) macroControl.updateAll(); if (MODULE.enableModule) macroControl.updateAll();
this.render(); }
else {
const payload = {
"msgType": "macroboardUpdate",
"settings": settings
};
game.socket.emit(`module.MaterialDeck`, payload);
}
} }
} }
@@ -267,10 +300,7 @@ export class macroConfigForm extends FormApplication {
export class soundboardConfigForm extends FormApplication { export class soundboardConfigForm extends FormApplication {
constructor(data, options) { constructor(data, options) {
super(data, options); super(data, options);
this.data = data;
this.playlists = []; this.playlists = [];
this.updatePlaylist = false;
this.update = false;
this.iMax; this.iMax;
this.jMax; this.jMax;
this.settings = {}; this.settings = {};
@@ -280,16 +310,6 @@ export class soundboardConfigForm extends FormApplication {
* Default Options for this FormApplication * Default Options for this FormApplication
*/ */
static get defaultOptions() { static get defaultOptions() {
/*
let streamDeckModel = game.settings.get(MODULE.moduleName,'streamDeckModel');
let width;
if (streamDeckModel == 0)
width = 550;
else if (streamDeckModel == 1)
width= 885;
else
width = 1400;
*/
return mergeObject(super.defaultOptions, { return mergeObject(super.defaultOptions, {
id: "soundboard-config", id: "soundboard-config",
title: "Material Deck: "+game.i18n.localize("MaterialDeck.Sett.SoundboardConfig"), title: "Material Deck: "+game.i18n.localize("MaterialDeck.Sett.SoundboardConfig"),
@@ -299,27 +319,19 @@ export class soundboardConfigForm extends FormApplication {
}); });
} }
getArray(data){
let array = [data.a,data.b,data.c,data.d,data.e,data.f,data.g,data.h];
return array;
}
/** /**
* Provide data to the template * Provide data to the template
*/ */
getData() { getData() {
if (this.update) { if (MODULE.getPermission('SOUNDBOARD','CONFIGURE') == false ) {
this.update=false; ui.notifications.warn(game.i18n.localize("MaterialDeck.Notifications.Soundboard.NoPermission"));
return {soundData: this.data}; return;
}
this.settings = game.settings.get(MODULE.moduleName,'soundboardSettings');
let playlists = [];
playlists.push({id:"none",name:game.i18n.localize("MaterialDeck.None")});
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});
} }
//Get the settings
this.settings = game.settings.get(MODULE.moduleName,'soundboardSettings');
//Check if all settings are defined
if (this.settings.sounds == undefined) this.settings.sounds = []; if (this.settings.sounds == undefined) this.settings.sounds = [];
if (this.settings.colorOn == undefined) this.settings.colorOn = []; if (this.settings.colorOn == undefined) this.settings.colorOn = [];
if (this.settings.colorOff == undefined) this.settings.colorOff = []; if (this.settings.colorOff == undefined) this.settings.colorOff = [];
@@ -329,8 +341,19 @@ export class soundboardConfigForm extends FormApplication {
if (this.settings.name == undefined) this.settings.name = []; if (this.settings.name == undefined) this.settings.name = [];
if (this.settings.selectedPlaylists == undefined) this.settings.selectedPlaylists = []; if (this.settings.selectedPlaylists == undefined) this.settings.selectedPlaylists = [];
if (this.settings.src == undefined) this.settings.src = []; if (this.settings.src == undefined) this.settings.src = [];
let soundData = [];
//Create the playlist array
let playlists = [];
playlists.push({id:"none",name:game.i18n.localize("MaterialDeck.None")});
playlists.push({id:"FP",name:game.i18n.localize("MaterialDeck.FilePicker")})
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;
//Check what SD model the user is using, and set the number of rows and columns to correspond
let streamDeckModel = game.settings.get(MODULE.moduleName,'streamDeckModel'); let streamDeckModel = game.settings.get(MODULE.moduleName,'streamDeckModel');
if (streamDeckModel == 0){ if (streamDeckModel == 0){
@@ -346,31 +369,64 @@ export class soundboardConfigForm extends FormApplication {
this.iMax = 8; this.iMax = 8;
} }
let iteration = 0; let iteration = 0; //Sound number
let soundData = []; //Stores all the data for each sound
//Fill soundData. soundData is an array the size of jMax (nr of rows), with each array element containing an array the size of iMax (nr of columns)
for (let j=0; j<this.jMax; j++){ for (let j=0; j<this.jMax; j++){
let soundsThis = []; let soundsThis = []; //Stores row data
for (let i=0; i<this.iMax; i++){ for (let i=0; i<this.iMax; i++){
//Each iteration gets the data for each sound
//If the volume is undefined for this sound, define it and set it to its default value
if (this.settings.volume[iteration] == undefined) this.settings.volume[iteration] = 50;
//Get the selected playlist and the sounds of that playlist
let selectedPlaylist; let selectedPlaylist;
let sounds = []; let sounds = [];
if (this.settings.volume[iteration] == undefined) this.settings.volume[iteration] = 50;
if (this.settings.selectedPlaylists[iteration]==undefined) selectedPlaylist = 'none'; if (this.settings.selectedPlaylists[iteration]==undefined) selectedPlaylist = 'none';
else if (this.settings.selectedPlaylists[iteration] == 'none') selectedPlaylist = 'none'; else if (this.settings.selectedPlaylists[iteration] == 'none') selectedPlaylist = 'none';
else if (this.settings.selectedPlaylists[iteration] == 'FP') selectedPlaylist = 'FP'; else if (this.settings.selectedPlaylists[iteration] == 'FP') selectedPlaylist = 'FP';
else { else {
const pl = game.playlists.entities.find(p => p._id == this.settings.selectedPlaylists[iteration]); //Get the playlist
selectedPlaylist = pl._id; const playlistArray = compatibleCore("0.8.1") ? game.playlists.contents : game.playlists.entities;
sounds = pl.sounds; let pl = playlistArray.find(p => p.id == this.settings.selectedPlaylists[iteration])
if (pl == undefined){
selectedPlaylist = 'none';
sounds = [];
} }
else {
//Add the sound name and id to the sounds array
if (compatibleCore("0.8.1"))
for (let sound of pl.sounds.contents)
sounds.push({
name: sound.name,
id: sound.id
});
else {
for (let sound of pl.sounds)
sounds.push({
name: sound.name,
id: sound._id
});
}
//Get the playlist id
selectedPlaylist = pl.id;
}
}
//Determine whether the sound selector or file picker should be displayed
let styleSS = ""; let styleSS = "";
let styleFP ="display:none"; let styleFP ="display:none";
if (selectedPlaylist == 'FP') { if (selectedPlaylist == 'FP') {
styleSS = 'display:none'; styleSS = 'display:none';
styleFP = '' styleFP = ''
} }
//Create and fill the data object for this sound
let dataThis = { let dataThis = {
iteration: iteration+1, iteration: iteration+1,
playlists: playlists,
selectedPlaylist: selectedPlaylist, selectedPlaylist: selectedPlaylist,
sound: this.settings.sounds[iteration], sound: this.settings.sounds[iteration],
sounds: sounds, sounds: sounds,
@@ -384,18 +440,20 @@ export class soundboardConfigForm extends FormApplication {
styleSS: styleSS, styleSS: styleSS,
styleFP: styleFP styleFP: styleFP
} }
//Push the data to soundsThis (row array)
soundsThis.push(dataThis); soundsThis.push(dataThis);
iteration++; iteration++;
} }
let data = {
dataThis: soundsThis, //Push soundsThis (row array) to soundData (full data array)
}; soundData.push({dataThis: soundsThis});
soundData.push(data);
} }
this.data = soundData;
return { return {
soundData: this.data soundData: soundData,
playlists
} }
} }
@@ -422,131 +480,130 @@ export class soundboardConfigForm extends FormApplication {
nameField.on("change",event => { nameField.on("change",event => {
let id = event.target.id.replace('name','')-1; let id = event.target.id.replace('name','')-1;
let j = Math.floor(id/this.jMax);
let i = id % this.jMax;
this.data[j].dataThis[i].name=event.target.value;
this.update = true;
this.settings.name[id]=event.target.value; this.settings.name[id]=event.target.value;
this.updateSettings(this.settings); this.updateSettings(this.settings);
}); });
if (playlistSelect.length > 0) { if (playlistSelect.length > 0) {
playlistSelect.on("change", event => {
let id = event.target.id.replace('playlists','')-1;
let j = Math.floor(id/this.jMax);
let i = id % this.jMax;
this.data[j].dataThis[i].selectedPlaylist=event.target.value;
//Listener for when the playlist is changed
playlistSelect.on("change", event => {
//Get the sound number
const iteration = event.target.id.replace('playlists','');
//Get the selected playlist and the sounds of that playlist
let selectedPlaylist; let selectedPlaylist;
let sounds = []; //let sounds = [];
if (event.target.value==undefined) selectedPlaylist = 'none'; if (event.target.value==undefined) selectedPlaylist = 'none';
else if (event.target.value == 'none') selectedPlaylist = 'none'; else if (event.target.value == 'none') selectedPlaylist = 'none';
else if (event.target.value == 'FP') selectedPlaylist = 'FP'; else if (event.target.value == 'FP') {
selectedPlaylist = 'FP';
//Show the file picker
document.querySelector(`#fp${iteration}`).style='';
//Hide the sound selector
document.querySelector(`#ss${iteration}`).style='display:none';
}
else { else {
const pl = game.playlists.entities.find(p => p._id == event.target.value); //Hide the file picker
selectedPlaylist = pl._id; document.querySelector(`#fp${iteration}`).style='display:none';
sounds = pl.sounds;
}
this.data[j].dataThis[i].sounds=sounds;
let styleSS = ""; //Show the sound selector
let styleFP ="display:none"; document.querySelector(`#ss${iteration}`).style='';
if (selectedPlaylist == 'FP') {
styleSS = 'display:none';
styleFP = ''
}
this.data[j].dataThis[i].styleSS=styleSS;
this.data[j].dataThis[i].styleFP=styleFP;
this.update = true;
this.settings.selectedPlaylists[id]=event.target.value; const playlistArray = compatibleCore("0.8.1") ? game.playlists.contents : game.playlists.entities;
const pl = playlistArray.find(p => p.id == event.target.value)
selectedPlaylist = pl.id;
//Get the sound select element
let SSpicker = document.getElementById(`soundSelect${iteration}`);
//Empty ss element
SSpicker.options.length=0;
//Create new options and append them
let optionNone = document.createElement('option');
optionNone.value = "";
optionNone.innerHTML = game.i18n.localize("MaterialDeck.None");
SSpicker.appendChild(optionNone);
if (compatibleCore("0.8.1"))
for (let sound of pl.sounds.contents) {
let newOption = document.createElement('option');
newOption.value = sound.id;
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);
}
}
//Save the new playlist to this.settings, and update the settings
this.settings.selectedPlaylists[iteration-1]=event.target.value;
this.updateSettings(this.settings); this.updateSettings(this.settings);
}); });
} }
soundSelect.on("change", event => { soundSelect.on("change", event => {
let id = event.target.id.replace('soundSelect','')-1; let id = event.target.id.replace('soundSelect','')-1;
let j = Math.floor(id/this.jMax);
let i = id % this.jMax;
this.data[j].dataThis[i].sound=event.target.value;
this.update = true;
this.settings.sounds[id]=event.target.value; this.settings.sounds[id]=event.target.value;
this.updateSettings(this.settings); this.updateSettings(this.settings);
}); });
soundFP.on("change",event => { soundFP.on("change",event => {
let id = event.target.id.replace('srcPath','')-1; let id = event.target.id.replace('srcPath','')-1;
let j = Math.floor(id/this.jMax);
let i = id % this.jMax;
this.data[j].dataThis[i].srcPath=event.target.value;
this.update = true;
this.settings.src[id]=event.target.value; this.settings.src[id]=event.target.value;
this.updateSettings(this.settings); this.updateSettings(this.settings);
}); });
imgFP.on("change",event => { imgFP.on("change",event => {
let id = event.target.id.replace('imgPath','')-1; let id = event.target.id.replace('imgPath','')-1;
let j = Math.floor(id/this.jMax);
let i = id % this.jMax;
this.data[j].dataThis[i].imgPath=event.target.value;
this.update = true;
this.settings.img[id]=event.target.value; this.settings.img[id]=event.target.value;
this.updateSettings(this.settings); this.updateSettings(this.settings);
}); });
onCP.on("change",event => { onCP.on("change",event => {
let id = event.target.id.replace('colorOn','')-1; let id = event.target.id.replace('colorOn','')-1;
let j = Math.floor(id/this.jMax);
let i = id % this.jMax;
this.data[j].dataThis[i].colorOn=event.target.value;
this.update = true;
this.settings.colorOn[id]=event.target.value; this.settings.colorOn[id]=event.target.value;
this.updateSettings(this.settings); this.updateSettings(this.settings);
}); });
offCP.on("change",event => { offCP.on("change",event => {
let id = event.target.id.replace('colorOff','')-1; let id = event.target.id.replace('colorOff','')-1;
let j = Math.floor(id/this.jMax);
let i = id % this.jMax;
this.data[j].dataThis[i].colorOff=event.target.value;
this.update = true;
this.settings.colorOff[id]=event.target.value; this.settings.colorOff[id]=event.target.value;
this.updateSettings(this.settings); this.updateSettings(this.settings);
}); });
playMode.on("change",event => { playMode.on("change",event => {
let id = event.target.id.replace('playmode','')-1; let id = event.target.id.replace('playmode','')-1;
let j = Math.floor(id/this.jMax);
let i = id % this.jMax;
this.data[j].dataThis[i].mode=event.target.value;
this.update = true;
this.settings.mode[id]=event.target.value; this.settings.mode[id]=event.target.value;
this.updateSettings(this.settings); this.updateSettings(this.settings);
}); });
volume.on("change",event => { volume.on("change",event => {
let id = event.target.id.replace('volume','')-1; let id = event.target.id.replace('volume','')-1;
let j = Math.floor(id/this.jMax);
let i = id % this.jMax;
this.data[j].dataThis[i].volume=event.target.value;
this.update = true;
this.settings.volume[id]=event.target.value; this.settings.volume[id]=event.target.value;
this.updateSettings(this.settings); this.updateSettings(this.settings);
}); });
} }
async updateSettings(settings){ async updateSettings(settings){
if (game.user.isGM) {
await game.settings.set(MODULE.moduleName,'soundboardSettings',settings); await game.settings.set(MODULE.moduleName,'soundboardSettings',settings);
if (MODULE.enableModule) soundboard.updateAll(); if (MODULE.enableModule) soundboard.updateAll();
this.render();
} }
else {
const payload = {
"msgType": "soundboardUpdate",
"settings": settings
};
game.socket.emit(`module.MaterialDeck`, payload);
}
}
} }

View File

@@ -1,48 +1,85 @@
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){
let background; const background = settings.background ? settings.background : '#000000';
if (settings.background) background = settings.background; const mode = settings.mode ? settings.mode : 'canvas';
else background = '#000000'; const type = settings.type ? settings.type : 'move';
if ((MODULE.getPermission('MOVE','TOKEN') == false && mode == 'selectedToken') || (MODULE.getPermission('MOVE','CANVAS') == false && mode == 'canvas')) {
streamDeck.noPermission(context,device);
return;
}
let url = ''; let url = '';
if (settings.dir == 'center') //center if (mode == 'canvas' || (mode == 'selectedToken' && type == 'move')){
const dir = settings.dir ? settings.dir : 'center';
if (dir == 'center') //center
url = "modules/MaterialDeck/img/move/center.png"; url = "modules/MaterialDeck/img/move/center.png";
else if (settings.dir == 'up') //up else if (dir == 'up') //up
url = "modules/MaterialDeck/img/move/up.png"; url = "modules/MaterialDeck/img/move/up.png";
else if (settings.dir == 'down') //down else if (dir == 'down') //down
url = "modules/MaterialDeck/img/move/down.png"; url = "modules/MaterialDeck/img/move/down.png";
else if (settings.dir == 'right') //right else if (dir == 'right') //right
url = "modules/MaterialDeck/img/move/right.png"; url = "modules/MaterialDeck/img/move/right.png";
else if (settings.dir == 'left') //left else if (dir == 'left') //left
url = "modules/MaterialDeck/img/move/left.png"; url = "modules/MaterialDeck/img/move/left.png";
else if (settings.dir == 'upRight') else if (dir == 'upRight')
url = "modules/MaterialDeck/img/move/upright.png"; url = "modules/MaterialDeck/img/move/upright.png";
else if (settings.dir == 'upLeft') else if (dir == 'upLeft')
url = "modules/MaterialDeck/img/move/upleft.png"; url = "modules/MaterialDeck/img/move/upleft.png";
else if (settings.dir == 'downRight') else if (dir == 'downRight')
url = "modules/MaterialDeck/img/move/downright.png"; url = "modules/MaterialDeck/img/move/downright.png";
else if (settings.dir == 'downLeft') else if (dir == 'downLeft')
url = "modules/MaterialDeck/img/move/downleft.png"; url = "modules/MaterialDeck/img/move/downleft.png";
else if (settings.dir == 'zoomIn') else if (dir == 'zoomIn')
url = "modules/MaterialDeck/img/move/zoomin.png"; url = "modules/MaterialDeck/img/move/zoomin.png";
else if (settings.dir == 'zoomOut') else if (dir == 'zoomOut')
url = "modules/MaterialDeck/img/move/zoomout.png"; url = "modules/MaterialDeck/img/move/zoomout.png";
streamDeck.setIcon(context,url,background);
} }
else if (mode == 'selectedToken' && type == 'rotate'){
const value = isNaN(parseInt(settings.rotValue)) ? 0 : parseInt(settings.rotValue);
if (value >= 0)
url = "modules/MaterialDeck/img/move/rotatecw.png";
else
url = "modules/MaterialDeck/img/move/rotateccw.png";
}
streamDeck.setIcon(context,device,url,{background:background,overlay:true});
streamDeck.setTitle('',context);
}
keyPress(settings){ keyPress(settings){
if (canvas.scene == null) return; if (canvas.scene == null) return;
let dir = settings.dir; if ((MODULE.getPermission('MOVE','TOKEN') == false && mode == 'selectedToken') || (MODULE.getPermission('MOVE','CANVAS') == false && mode == 'canvas')) {
let mode = settings.mode; streamDeck.noPermission(context,device);
if (mode == undefined) mode = 'canvas'; return;
if (dir == undefined) dir = 'center'; }
const dir = settings.dir ? settings.dir : 'center';
const mode = settings.mode ? settings.mode : 'canvas';
const type = settings.type ? settings.type : 'move';
let token;
if (mode == 'selectedToken') {
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 (dir == 'zoomIn') {//zoom in if (dir == 'zoomIn') {//zoom in
let viewPosition = canvas.scene._viewPosition; let viewPosition = canvas.scene._viewPosition;
viewPosition.scale = viewPosition.scale*1.05; viewPosition.scale = viewPosition.scale*1.05;
@@ -57,15 +94,26 @@ 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'){
const rotType = settings.rot ? settings.rot : 'to';
const value = isNaN(parseInt(settings.rotValue)) ? 0 : parseInt(settings.rotValue);
async moveToken(tokenId,dir){ let rotationVal;
if (tokenId == undefined) return; if (rotType == 'by') rotationVal = token.data.rotation + value;
const token = canvas.tokens.children[0].children.find(p => p.id == tokenId); else if (rotType == 'to') rotationVal = value;
if (compatibleCore("0.8.1")) token.document.update({rotation: rotationVal});
else token.update({rotation: rotationVal});
//token.rotate(rotationVal,false)
}
}
async moveToken(token,dir){
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;
@@ -95,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){

View File

@@ -1,232 +1,141 @@
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.offset = 0; 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) {
let 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;
let mode = settings.otherMode; const mode = settings.otherMode ? settings.otherMode : 'pause';
if (mode == undefined) mode = 'pause';
if (mode == 'pause') { //pause if (mode == 'pause') //pause
this.updatePause(settings.pauseFunction,context); this.updatePause(settings,context,device,options);
} else if (mode == 'controlButtons') //control buttons
else if (mode == 'sceneSelect') { //scene selection this.updateControl(settings,context,device,options);
this.updateScene(settings,context); else if (mode == 'darkness') //darkness
} this.updateDarkness(settings,context,device,options);
else if (mode == 'controlButtons'){ //control buttons else if (mode == 'rollDice') //roll dice
this.updateControl(settings,context); this.updateRollDice(settings,context,device,options);
} else if (mode == 'rollTables') //roll tables
else if (mode == 'darkness'){ //darkness this.updateRollTable(settings,context,device,options);
this.updateDarkness(settings,context); else if (mode == 'sidebarTab') //open sidebar tab
} this.updateSidebar(settings,context,device,options);
else if (mode == 'rollTables'){ //roll tables else if (mode == 'compendiumBrowser') //open compendium browser
this.updateRollTable(settings,context); this.updateCompendiumBrowser(settings,context,device,options);
} else if (mode == 'compendium') //open compendium
else if (mode == 'sidebarTab') { //open sidebar tab this.updateCompendium(settings,context,device,options);
this.updateSidebar(settings,context); else if (mode == 'journal') //open journal
} this.updateJournal(settings,context,device,options);
else if (mode == 'compendium') { //open compendium else if (mode == 'chatMessage')
this.updateCompendium(settings,context); this.updateChatMessage(settings,context,device,options);
} else if (mode == 'rollOptions')
else if (mode == 'journal') { //open journal this.updateRollOptions(settings,context,device,options);
this.updateJournal(settings,context);
}
} }
keyPress(settings){ keyPress(settings,context,device){
let mode = settings.otherMode; const mode = settings.otherMode ? settings.otherMode : 'pause';
if (mode == undefined) mode = 'pause';
if (mode == 'pause') { //pause if (mode == 'pause') //pause
this.keyPressPause(settings.pauseFunction); this.keyPressPause(settings);
} else if (mode == 'controlButtons') //control buttons
else if (mode == 'sceneSelect') { //scene
this.keyPressScene(settings);
}
else if (mode == 'controlButtons') { //control buttons
this.keyPressControl(settings); this.keyPressControl(settings);
} 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 == 'rollTables') { //roll tables this.keyPressRollDice(settings,context,device);
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
else if (mode == 'compendium') { //open compendium this.keyPressCompendiumBrowser(settings);
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')
this.keyPressChatMessage(settings);
else if (mode == 'rollOptions')
this.keyPressRollOptions(settings);
} }
////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////
updatePause(pauseFunction,context){ updatePause(settings,context,device,options={}){
if (MODULE.getPermission('OTHER','PAUSE') == false ) {
streamDeck.noPermission(context,device);
return;
}
let src = ""; let src = "";
if (pauseFunction == undefined) pauseFunction = 'pause'; const pauseFunction = settings.pauseFunction ? settings.pauseFunction : 'pause';
const background = settings.background ? settings.background : '#000000';
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
let ringColor = game.paused ? ringOnColor : ringOffColor;
let background = settings.background; if (pauseFunction == 'pause') //Pause game
if(background == undefined) background = '#000000';
let ringColor = "#000000";
let ringOffColor = settings.offRing;
if (ringOffColor == undefined) ringOffColor = '#000000';
let ringOnColor = settings.onRing;
if (ringOnColor == undefined) ringOnColor = '#00FF00';
let playlistType = settings.playlistType;
if (playlistType == undefined) playlistType = 0;
if (pauseFunction == 'pause'){ //Pause game
if (game.paused) ringColor = ringOnColor;
else ringColor = ringOffColor;
src = 'modules/MaterialDeck/img/other/pause/pause.png'; src = 'modules/MaterialDeck/img/other/pause/pause.png';
//src = 'action/images/other/pause/pause.png';
}
else if (pauseFunction == 'resume'){ //Resume game else if (pauseFunction == 'resume'){ //Resume game
if (game.paused == false) ringColor = ringOnColor; ringColor = game.paused ? ringOffColor : ringOnColor;
else ringColor = ringOffColor;
src = 'modules/MaterialDeck/img/other/pause/resume.png'; src = 'modules/MaterialDeck/img/other/pause/resume.png';
//src = 'action/images/other/pause/resume.png';
} }
else if (pauseFunction == 'toggle') { //toggle else if (pauseFunction == 'toggle') //toggle
if (game.paused == false) ringColor = ringOnColor;
else ringColor = ringOffColor;
src = 'modules/MaterialDeck/img/other/pause/playpause.png'; src = 'modules/MaterialDeck/img/other/pause/playpause.png';
//src = 'action/images/other/pause/playpause.png'; streamDeck.setIcon(context,device,src,{background:background,ring:2,ringColor:ringColor,overlay:true});
} streamDeck.setTitle('',context);
streamDeck.setIcon(context,src,background,2,ringColor,true);
} }
keyPressPause(pauseFunction){ keyPressPause(settings){
if (pauseFunction == undefined) pauseFunction = 'pause'; if (MODULE.getPermission('OTHER','PAUSE') == false ) return;
const pauseFunction = settings.pauseFunction ? settings.pauseFunction : 'pause';
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);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
updateScene(settings,context){
if (canvas.scene == null) return;
let func = settings.sceneFunction;
if (func == undefined) func = 'visible';
let background = settings.background;
if(background == undefined) background = '#000000';
let ringColor = "#000000";
let ringOffColor = settings.offRing;
if (ringOffColor == undefined) ringOffColor = '#000000';
let ringOnColor = settings.onRing;
if (ringOnColor == undefined) ringOnColor = '#00FF00';
let src = "";
let name = "";
if (func == 'visible'){ //visible scenes
let nr = parseInt(settings.sceneNr);
if (isNaN(nr)) nr = 1;
nr--;
let scene = game.scenes.apps[0].scenes[nr];
if (scene != undefined){
if (scene.isView)
ringColor = ringOnColor;
else
ringColor = ringOffColor;
if (settings.displaySceneName) name = scene.name;
if (settings.displaySceneIcon) src = scene.img;
if (scene.active) name += "\n(Active)";
}
}
else if (func == 'any') { //all scenes
let scene = game.scenes.apps[1].entities.find(p=>p.data.name == name);
if (scene != undefined){
if (scene.isView)
ringColor = ringOnColor;
else
ringColor = ringOffColor;
if (settings.displaySceneName) name = scene.name;
if (settings.displaySceneIcon) src = scene.img;
if (scene.active) name += "\n(Active)";
}
}
streamDeck.setTitle(name,context);
streamDeck.setIcon(context,src,background,2,ringColor);
}
keyPressScene(settings){
let func = settings.sceneFunction;
if (func == undefined) func = 'visible';
if (func == 'visible'){ //visible scenes
let viewFunc = settings.sceneViewFunction;
if (viewFunc == undefined) viewFunc = 'view';
let nr = parseInt(settings.sceneNr);
if (isNaN(nr)) nr = 1;
nr--;
let scene = game.scenes.apps[0].scenes[nr];
if (scene != undefined){
if (viewFunc == 'view'){
scene.view();
}
else if (viewFunc == 'activate'){
scene.activate();
}
else {
if (scene.isView) scene.activate();
scene.view();
}
}
} }
} }
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
updateControl(settings,context){ updateControl(settings,context,device,options={}){
let control = settings.control; if (MODULE.getPermission('OTHER','CONTROL') == false ) {
if (control == undefined) control = 'dispControls'; streamDeck.noPermission(context,device);
return;
let tool = settings.tool; }
if (tool == undefined) tool = 'open'; const control = settings.control ? settings.control : 'dispControls';
const tool = settings.tool ? settings.tool : 'open';
let background = settings.background; let background = settings.background ? settings.background : '#000000';
if (background == undefined) background = '#000000';
let ringColor = '#000000' let ringColor = '#000000'
let txt = ""; let txt = "";
let src = ""; let src = "";
const activeControl = ui.controls.activeControl; const activeControl = ui.controls.activeControl;
@@ -238,7 +147,12 @@ export class OtherControls{
controlNr--; controlNr--;
const selectedControl = ui.controls.controls[controlNr]; const selectedControl = ui.controls.controls[controlNr];
if (selectedControl != undefined){ if (selectedControl != undefined){
if (selectedControl.visible == false) {
streamDeck.noPermission(context,device,false);
return;
}
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;
@@ -256,14 +170,15 @@ export class OtherControls{
if (selectedControl != undefined){ if (selectedControl != undefined){
const selectedTool = selectedControl.tools[controlNr]; const selectedTool = selectedControl.tools[controlNr];
if (selectedTool != undefined){ if (selectedTool != undefined){
if (selectedControl.visible == false || selectedTool.visible == false) {
streamDeck.noPermission(context,device,false);
return;
}
txt = game.i18n.localize(selectedTool.title); txt = game.i18n.localize(selectedTool.title);
src = selectedTool.icon; src = selectedTool.icon;
if (selectedTool.toggle){ if (selectedTool.toggle){
background = "#340057" background = "#340057"
if (selectedTool.active) ringColor = selectedTool.active ? "#A600FF" : "#340057";
ringColor = "#A600FF"
else
ringColor = "#340057";
} }
else if (activeTool == selectedTool.name) else if (activeTool == selectedTool.name)
ringColor = "#FF7B00"; ringColor = "#FF7B00";
@@ -273,6 +188,10 @@ export class OtherControls{
else { // specific control/tool else { // specific control/tool
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) {
streamDeck.noPermission(context,device,false);
return;
}
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;
@@ -282,14 +201,15 @@ export class OtherControls{
else { else {
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) {
streamDeck.noPermission(context,device,false);
return;
}
txt = game.i18n.localize(selectedTool.title); txt = game.i18n.localize(selectedTool.title);
src = selectedTool.icon; src = selectedTool.icon;
if (selectedTool.toggle){ if (selectedTool.toggle){
background = "#340057" background = "#340057";
if (selectedTool.active) ringColor = selectedTool.active ? "#A600FF" : "#340057";
ringColor = "#A600FF"
else
ringColor = "#340057"
} }
else if (activeTool == selectedTool.name && activeControl == selectedControl.name) else if (activeTool == selectedTool.name && activeControl == selectedControl.name)
ringColor = "#FF7B00"; ringColor = "#FF7B00";
@@ -297,25 +217,28 @@ 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);
} }
keyPressControl(settings){ keyPressControl(settings){
if (MODULE.getPermission('OTHER','CONTROL') == false ) return;
if (canvas.scene == null) return; if (canvas.scene == null) return;
let control = settings.control; const control = settings.control ? settings.control : 'dispControls';
if (control == undefined) control = 'dispControls'; const tool = settings.tool ? settings.tool : 'open';
let tool = settings.tool;
if (tool == undefined) tool = 'open';
if (control == 'dispControls'){ //displayed controls if (control == 'dispControls'){ //displayed controls
let controlNr = parseInt(settings.controlNr); let controlNr = parseInt(settings.controlNr);
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){
ui.controls.activeControl = 'token'; if (selectedControl.visible == false) {
streamDeck.noPermission(context,device,false);
return;
}
ui.controls.activeControl = selectedControl.name;
selectedControl.activeTool = selectedControl.activeTool; selectedControl.activeTool = selectedControl.activeTool;
canvas.getLayer(selectedControl.layer).activate(); canvas.getLayer(selectedControl.layer).activate();
} }
@@ -326,8 +249,16 @@ export class OtherControls{
controlNr--; controlNr--;
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) {
streamDeck.noPermission(context,device,false);
return;
}
const selectedTool = selectedControl.tools[controlNr]; const selectedTool = selectedControl.tools[controlNr];
if (selectedTool != undefined){ if (selectedTool != undefined){
if (selectedTool.visible == false) {
streamDeck.noPermission(context,device,false);
return;
}
if (selectedTool.toggle) { if (selectedTool.toggle) {
selectedTool.active = !selectedTool.active; selectedTool.active = !selectedTool.active;
selectedTool.onClick(selectedTool.active); selectedTool.onClick(selectedTool.active);
@@ -343,14 +274,22 @@ export class OtherControls{
else { //select control else { //select control
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) {
streamDeck.noPermission(context,device,false);
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();
} }
else { else {
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) {
streamDeck.noPermission(context,device,false);
return;
}
ui.controls.activeControl = control; ui.controls.activeControl = control;
canvas.getLayer(selectedControl.layer).activate(); canvas.getLayer(selectedControl.layer).activate();
if (selectedTool.toggle) { if (selectedTool.toggle) {
@@ -371,15 +310,14 @@ export class OtherControls{
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
updateDarkness(settings,context){ updateDarkness(settings,context,device,options={}){
let func = settings.darknessFunction; if (MODULE.getPermission('OTHER','DARKNESS') == false ) {
if (func == undefined) func = 'value'; streamDeck.noPermission(context,device);
return;
let value = settings.darknessValue; }
if (value == undefined) value = 0; const func = settings.darknessFunction ? settings.darknessFunction : 'value';
const value = parseFloat(settings.darknessValue) ? parseFloat(settings.darknessValue) : 0;
let background = settings.background; const background = settings.background ? settings.background : '#000000';
if (background == undefined) background = "#000000";
let src = ""; let src = "";
let txt = ""; let txt = "";
@@ -391,29 +329,25 @@ export class OtherControls{
if (value < 0) src = 'modules/MaterialDeck/img/other/darkness/decreasedarkness.png'; if (value < 0) src = 'modules/MaterialDeck/img/other/darkness/decreasedarkness.png';
else src = 'modules/MaterialDeck/img/other/darkness/increasedarkness.png'; else src = 'modules/MaterialDeck/img/other/darkness/increasedarkness.png';
} }
else if (func == 'display'){ //display darkness else if (func == 'disp'){ //display darkness
src = 'modules/MaterialDeck/img/other/darkness/darkness.png'; src = 'modules/MaterialDeck/img/other/darkness/darkness.png';
let darkness = ''; const darkness = canvas.scene != null ? Math.floor(canvas.scene.data.darkness*100)/100 : '';
if (canvas.scene != null) darkness = Math.floor(canvas.scene.data.darkness*100)/100;
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) {
if (canvas.scene == null) return; if (canvas.scene == null) return;
let func = settings.darknessFunction; if (MODULE.getPermission('OTHER','DARKNESS') == false ) return;
if (func == undefined) func = 'value'; const func = settings.darknessFunction ? settings.darknessFunction : 'value';
const value = parseFloat(settings.darknessValue) ? parseFloat(settings.darknessValue) : 0;
let value = parseFloat(settings.darknessValue);
if (value == undefined) value = 0;
if (func == 'value') //value if (func == 'value') //value
canvas.scene.update({darkness: value}); canvas.scene.update({darkness: value});
else if (func == 'incDec'){ //increase/decrease else if (func == 'incDec'){ //increase/decrease
let darkness = canvas.scene.data.darkness; let darkness = canvas.scene.data.darkness - value;
darkness += -1*value;
if (darkness > 1) darkness = 1; if (darkness > 1) darkness = 1;
if (darkness < 0) darkness = 0; if (darkness < 0) darkness = 0;
canvas.scene.update({darkness: darkness}); canvas.scene.update({darkness: darkness});
@@ -422,39 +356,97 @@ export class OtherControls{
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
updateRollTable(settings,context){ updateRollDice(settings,context,device,options={}){
let name = settings.rollTableName; if (MODULE.getPermission('OTHER','DICE') == false ) {
if (name == undefined) return; streamDeck.noPermission(context,device);
return;
let background = settings.background;
if (background == undefined) background = "#000000";
let table = game.tables.entities.find(p=>p.name == name);
let txt = "";
let src = "";
if (table != undefined) {
if (settings.displayRollIcon) src = table.data.img;
if (settings.displayRollName) txt = table.name;
} }
const background = settings.background ? settings.background : '#000000';
let txt = '';
if (settings.displayDiceName) txt = 'Roll: ' + settings.rollDiceFormula;
streamDeck.setTitle(txt,context); streamDeck.setTitle(txt,context);
streamDeck.setIcon(context,src,background); streamDeck.setIcon(context,device,'',{background:background});
}
keyPressRollDice(settings,context,device){
if (MODULE.getPermission('OTHER','DICE') == false ) return;
if (settings.rollDiceFormula == undefined || settings.rollDiceFormula == '') return;
const rollFunction = settings.rollDiceFunction ? settings.rollDiceFunction : 'public';
let actor;
let tokenControlled = false;
if (MODULE.selectedTokenId != undefined) actor = canvas.tokens.children[0].children.find(p => p.id == MODULE.selectedTokenId).actor;
if (actor != undefined) tokenControlled = true;
let r;
if (tokenControlled) r = new Roll(settings.rollDiceFormula,actor.getRollData());
else r = new Roll(settings.rollDiceFormula);
r.evaluate();
if (rollFunction == 'public') {
r.toMessage(r,{rollMode:"roll"})
}
else if (rollFunction == 'private') {
r.toMessage(r,{rollMode:"selfroll"})
}
else if (rollFunction == 'sd'){
let txt = settings.displayDiceName ? 'Roll: '+settings.rollDiceFormula + '\nResult: ' : '';
txt += r.total;
streamDeck.setTitle(txt,context);
let data = this.rollData
data[context] = {
formula: settings.rollDiceFormula,
result: txt
}
this.rollData = data;
}
}
//////////////////////////////////////////////////////////////////////////////////////////
updateRollTable(settings,context,device,options={}){
const name = settings.rollTableName;
if (name == undefined) return;
if (MODULE.getPermission('OTHER','TABLES') == false ) {
streamDeck.noPermission(context,device);
return;
}
const background = settings.background ? settings.background : '#000000';
const table = game.tables.getName(name);
let txt = settings.displayRollName ? table.name : '';
let src = settings.displayRollIcon ? table.data.img : '';
if (table == undefined) {
src = '';
txt = '';
}
else {
if (table.permission < 2 && MODULE.getPermission('OTHER','TABLES_ALL') == false ) {
streamDeck.noPermission(context,device);
return;
}
}
streamDeck.setTitle(txt,context);
streamDeck.setIcon(context,device,src,{background:background});
} }
keyPressRollTable(settings){ keyPressRollTable(settings){
let func = settings.rolltableFunction; if (MODULE.getPermission('OTHER','TABLES') == false ) return;
if (func == undefined) func = 'open'; const name = settings.rollTableName;
let name = settings.rollTableName;
if (name == undefined) return; if (name == undefined) return;
let background = settings.background; const func = settings.rolltableFunction ? settings.rolltableFunction : 'open';
if (background == undefined) background = "#000000"; const table = game.tables.getName(name);
let table = game.tables.entities.find(p=>p.name == name);
if (table != undefined) { if (table != undefined) {
if (table.permission < 2 && MODULE.getPermission('OTHER','TABLES_ALL') == false ) return;
if (func == 'open'){ //open if (func == 'open'){ //open
const element = document.getElementById(table.sheet.id); const element = document.getElementById(table.sheet.id);
if (element == null) table.sheet.render(true); if (element == null) table.sheet.render(true);
@@ -501,124 +493,211 @@ export class OtherControls{
return icon; return icon;
} }
updateSidebar(settings,context){ updateSidebar(settings,context,device,options={}){
let sidebarTab = settings.sidebarTab; if (MODULE.getPermission('OTHER','SIDEBAR') == false ) {
if (sidebarTab == undefined) sidebarTab = 'chat'; streamDeck.noPermission(context,device);
return;
}
const popOut = settings.sidebarPopOut ? settings.sidebarPopOut : false;
const sidebarTab = settings.sidebarTab ? settings.sidebarTab : 'chat';
const background = settings.background ? settings.background : '#000000';
const collapsed = ui.sidebar._collapsed;
const activeTab = ui.sidebar.activeTab;
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
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 icon = settings.displaySidebarIcon ? this.getSidebarIcon(sidebarTab) : '';
let activeTab = ui.sidebar.activeTab;
let collapsed = ui.sidebar._collapsed;
let name = "";
let icon = "";
let background = settings.background;
if(background == undefined) background = '#000000';
let ringColor = "#000000";
let ringOffColor = settings.offRing;
if (ringOffColor == undefined) ringOffColor = '#000000';
let ringOnColor = settings.onRing;
if (ringOnColor == undefined) ringOnColor = '#00FF00';
if (settings.displaySidebarName) name = this.getSidebarName(sidebarTab);
if (settings.displaySidebarIcon) icon = this.getSidebarIcon(sidebarTab);
if ((sidebarTab == 'collapse' && collapsed))
ringColor = ringOnColor;
else
ringColor = ringOffColor;
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){
let sidebarTab = settings.sidebarTab; if (MODULE.getPermission('OTHER','SIDEBAR') == false ) return;
if (sidebarTab == undefined) sidebarTab = 'chat'; const sidebarTab = settings.sidebarTab ? settings.sidebarTab : 'chat';
let collapsed = ui.sidebar._collapsed; const popOut = settings.sidebarPopOut ? settings.sidebarPopOut : false;
if (sidebarTab == 'collapse'){ if (sidebarTab == 'collapse'){
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 background = settings.background; let rendered = options.renderCompendiumBrowser;
if(background == undefined) background = '#000000'; 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 : '';
let name = settings.compendiumName; 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;
if (name == undefined) return; if (name == undefined) return;
if (MODULE.getPermission('OTHER','COMPENDIUM') == false ) {
const compendium = game.packs.entries.find(p=>p.metadata.label == name); streamDeck.noPermission(context,device);
return;
}
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) {
streamDeck.noPermission(context,device);
return;
}
const background = settings.background ? settings.background : '#000000';
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
const ringColor = compendium.rendered ? ringOnColor : ringOffColor;
const txt = settings.displayCompendiumName ? name : '';
let ringColor = "#000000"; streamDeck.setTitle(txt,context);
streamDeck.setIcon(context,device,"",{background:background,ring:2,ringColor:ringColor});
let ringOffColor = settings.offRing;
if (ringOffColor == undefined) ringOffColor = '#000000';
let ringOnColor = settings.onRing;
if (ringOnColor == undefined) ringOnColor = '#00FF00';
if (compendium.rendered) ringColor = ringOnColor;
else ringColor = ringOffColor;
if (settings.displayCompendiumName) streamDeck.setTitle(name,context);
streamDeck.setIcon(context,"",background,2,ringColor);
} }
keyPressCompendium(settings){ keyPressCompendium(settings){
let name = settings.compendiumName; let name = settings.compendiumName;
if (name == undefined) return; if (name == undefined) 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.rendered) compendium.close(); if (compendium.private && MODULE.getPermission('OTHER','COMPENDIUM_ALL') == false) return;
else if (compendium.rendered) compendium.close();
else compendium.render(true); else compendium.render(true);
} }
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
//Journals updateJournal(settings,context,device,options={}){
//game.journal.entries[0].render(true) const name = settings.compendiumName;
updateJournal(settings,context){
let background = settings.background;
if(background == undefined) background = '#000000';
let name = settings.compendiumName;
if (name == undefined) return; if (name == undefined) return;
const journal = game.journal.entries.find(p=>p.name == name);
const journal = game.journal.getName(name);
if (journal == undefined) return; if (journal == undefined) return;
let ringColor = "#000000"; if (MODULE.getPermission('OTHER','JOURNAL') == false ) {
streamDeck.noPermission(context,device);
return;
}
if (journal.permission < 2 && MODULE.getPermission('OTHER','JOURNAL_ALL') == false ) {
streamDeck.noPermission(context,device);
return;
}
let rendered = false;
let ringOffColor = settings.offRing; if (options?.sheet?.title == name) {
if (ringOffColor == undefined) ringOffColor = '#000000'; if (options.hook == 'renderJournalSheet') rendered = true;
else if (options.hook == 'closeJournalSheet') rendered = false;
}
else
if (document.getElementById("journalentry-sheet-"+journal.id) != null) rendered = true;
let ringOnColor = settings.onRing; const background = settings.background ? settings.background : '#000000';
if (ringOnColor == undefined) ringOnColor = '#00FF00'; const ringOffColor = settings.offRing ? settings.offRing : '#000000';
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
const ringColor = rendered ? ringOnColor : ringOffColor;
const txt = settings.displayCompendiumName ? name : '';
if (journal.sheet.rendered) ringColor = ringOnColor; streamDeck.setTitle(txt,context);
else ringColor = ringOffColor; streamDeck.setIcon(context,device,"",{background:background,ring:2,ringColor:ringColor});
if (settings.displayCompendiumName) streamDeck.setTitle(name,context);
streamDeck.setIcon(context,"",background,2,ringColor);
} }
keyPressJournal(settings){ keyPressJournal(settings){
let name = settings.compendiumName; const name = settings.compendiumName;
if (name == undefined) return; if (name == undefined) return;
const journal = game.journal.entries.find(p=>p.name == name); const journal = game.journal.getName(name);
if (journal == undefined) return; if (journal == undefined) return;
const element = document.getElementById("journal-"+journal.id);
if (element == null) journal.render(true); if (MODULE.getPermission('OTHER','JOURNAL') == false ) return;
if (journal.permission < 2 && MODULE.getPermission('OTHER','JOURNAL_ALL') == false ) return;
if (journal.sheet.rendered == false) journal.sheet.render(true);
else journal.sheet.close(); else journal.sheet.close();
} }
//////////////////////////////////////////////////////////////////////////////////////////
updateChatMessage(settings,context,device,options={}){
if (MODULE.getPermission('OTHER','CHAT') == false ) {
streamDeck.noPermission(context,device);
return;
}
const background = settings.background ? settings.background : '#000000';
streamDeck.setTitle("",context);
streamDeck.setIcon(context,device,"",{background:background});
}
keyPressChatMessage(settings){
if (MODULE.getPermission('OTHER','CHAT') == false ) return;
const message = settings.chatMessage ? settings.chatMessage : '';
let chatData = {
user: game.user._id,
speaker: ChatMessage.getSpeaker(),
content: message
};
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();
}
}
} }

View File

@@ -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,47 +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) {
let 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){
this.active = true; if (MODULE.getPermission('PLAYLIST','PLAY') == false ) {
if (settings.playlistMode == undefined) settings.playlistMode = 'playlist'; streamDeck.noPermission(context,device);
if (settings.playlistMode == 'playlist'){ return;
this.updatePlaylist(settings,context);
} }
else if (settings.playlistMode == 'track'){ this.active = true;
this.updateTrack(settings,context); const mode = settings.playlistMode ? settings.playlistMode : 'playlist';
if (mode == 'playlist'){
this.updatePlaylist(settings,context,device);
}
else if (mode == 'track'){
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'){
@@ -75,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'){
@@ -109,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;
@@ -121,16 +127,27 @@ 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);
} }
stopAll(force=false){ stopAll(force=false){
if (game.user.isGM == false) {
const payload = {
"msgType": "stopAllPlaylists",
"force": force
};
game.socket.emit(`module.MaterialDeck`, payload);
return;
}
if (force){ if (force){
let playing = game.playlists.playing; let playing = game.playlists.playing;
for (let i=0; i<playing.length; i++){ for (let i=0; i<playing.length; i++){
@@ -152,11 +169,12 @@ export class PlaylistControl{
getPlaylist(num){ getPlaylist(num){
let selectedPlaylists = game.settings.get(MODULE.moduleName,'playlists').selectedPlaylist; let selectedPlaylists = game.settings.get(MODULE.moduleName,'playlists').selectedPlaylist;
if (selectedPlaylists != undefined) if (selectedPlaylists != undefined)
return game.playlists.entities.find(p => p._id == selectedPlaylists[num]); return game.playlists.get(selectedPlaylists[num]);
else return undefined; else return undefined;
} }
keyPress(settings,context){ keyPress(settings,context,device){
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;
playlistNr--; playlistNr--;
@@ -166,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;
} }
@@ -196,11 +217,37 @@ 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();
}
} }
} }
async playPlaylist(playlist,playlistNr){ async playPlaylist(playlist,playlistNr){
if (game.user.isGM == false) {
const payload = {
"msgType": "playPlaylist",
"playlistId": playlist.id,
"playlistNr": playlistNr
};
game.socket.emit(`module.MaterialDeck`, payload);
return;
}
if (playlist.playing) { if (playlist.playing) {
playlist.stopAll(); playlist.stopAll();
return; return;
@@ -214,6 +261,16 @@ export class PlaylistControl{
} }
async playTrack(track,playlist,playlistNr){ async playTrack(track,playlist,playlistNr){
if (game.user.isGM == false) {
const payload = {
"msgType": "playTrack",
"playlistId": playlist.id,
"playlistNr": playlistNr,
"trackId": track._id
};
game.socket.emit(`module.MaterialDeck`, payload);
return;
}
let play; let play;
if (track.playing) if (track.playing)
play = false; play = false;
@@ -227,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});
} }
} }

213
src/scene.js Normal file
View File

@@ -0,0 +1,213 @@
import * as MODULE from "../MaterialDeck.js";
import {streamDeck} from "../MaterialDeck.js";
import {compatibleCore} from "./misc.js";
export class SceneControl{
constructor(){
this.active = false;
this.rollData = {};
this.sceneOffset = 0;
}
async updateAll(){
if (this.active == false) return;
for (let device of streamDeck.buttonContext) {
for (let i=0; i<device.buttons.length; i++){
const data = device.buttons[i];
if (data == undefined || data.action != 'scene') continue;
await this.update(data.settings,data.context,device.device);
}
}
}
update(settings,context,device){
if (canvas.scene == null) return;
this.active = true;
const func = settings.sceneFunction ? settings.sceneFunction : 'visible';
const background = settings.background ? settings.background : '#000000';
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
let ringColor = "#000000";
let ring = 2;
let src = "";
let name = "";
if (func == 'visible') { //visible scenes
if (MODULE.getPermission('SCENE','VISIBLE') == false ) {
streamDeck.noPermission(context,device);
return;
}
let nr = parseInt(settings.sceneNr);
if (isNaN(nr) || nr < 1) nr = 1;
nr--;
let scene = game.scenes.apps[0].scenes[nr];
if (scene != undefined){
ringColor = scene.isView ? ringOnColor : ringOffColor;
if (settings.displaySceneName) name = scene.name;
if (settings.displaySceneIcon) src = scene.img;
if (scene.active) name += "\n(Active)";
}
}
else if (func == 'dir') { //from directory
if (MODULE.getPermission('SCENE','DIRECTORY') == false ) {
streamDeck.noPermission(context,device);
return;
}
let nr = parseInt(settings.sceneNr);
if (isNaN(nr) || nr < 1) nr = 1;
nr--;
let sceneList = [];
for (let i=0; i<ui.scenes.tree.children.length; i++){
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++)
sceneList.push(scenesInFolder[j])
}
for (let i=0; i<ui.scenes.tree.content.length; i++)
sceneList.push(ui.scenes.tree.content[i])
const scene = sceneList[nr+this.sceneOffset];
if (scene != undefined){
if (scene.isView)
ringColor = ringOnColor;
else if (scene.data.navigation && scene.data.permission.default == 0)
ringColor = '#000791';
else if (scene.data.navigation)
ringColor = '#2d2d2d';
else
ringColor = ringOffColor;
if (settings.displaySceneName) name = scene.name;
if (settings.displaySceneIcon) src = scene.img;
if (scene.active) name += "\n(Active)";
}
}
else if (func == 'any') { //by name
if (MODULE.getPermission('SCENE','NAME') == false ) {
streamDeck.noPermission(context,device);
return;
}
if (settings.sceneName == undefined || settings.sceneName == '') return;
let scene = game.scenes.getName(settings.sceneName);
if (scene != undefined){
ringColor = scene.isView ? ringOnColor : ringOffColor;
if (settings.displaySceneName) name = scene.name;
if (settings.displaySceneIcon) src = scene.img;
if (scene.active) name += "\n(Active)";
}
}
else if (func == 'active'){
if (MODULE.getPermission('SCENE','ACTIVE') == false ) {
streamDeck.noPermission(context,device);
return;
}
const scene = game.scenes.active;
if (scene == undefined) return;
if (settings.displaySceneName) name = scene.name;
if (settings.displaySceneIcon) src = scene.img;
ring = 0;
}
else if (func == 'offset'){
let offset = parseInt(settings.sceneOffset);
if (isNaN(offset)) offset = 0;
if (offset == this.sceneOffset) ringColor = ringOnColor;
else ringColor = ringOffColor;
}
streamDeck.setTitle(name,context);
streamDeck.setIcon(context,device,src,{background:background,ring:ring,ringColor:ringColor});
}
keyPress(settings){
const func = settings.sceneFunction ? settings.sceneFunction : 'visible';
if (func == 'visible'){ //visible scenes
if (MODULE.getPermission('SCENE','VISIBLE') == false ) return;
const viewFunc = settings.sceneViewFunction ? settings.sceneViewFunction : 'view';
let nr = parseInt(settings.sceneNr);
if (isNaN(nr) || nr < 1) nr = 1;
nr--;
let scene = game.scenes.apps[0].scenes[nr];
if (scene != undefined){
if (viewFunc == 'view'){
scene.view();
}
else if (viewFunc == 'activate'){
scene.activate();
}
else {
if (scene.isView) scene.activate();
scene.view();
}
}
}
else if (func == 'dir') { //from directory
if (MODULE.getPermission('SCENE','DIRECTORY') == false ) return;
const viewFunc = settings.sceneViewFunction ? settings.sceneViewFunction : 'view';
let nr = parseInt(settings.sceneNr);
if (isNaN(nr) || nr < 1) nr = 1;
nr--;
let sceneList = [];
for (let i=0; i<ui.scenes.tree.children.length; i++){
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++)
sceneList.push(scenesInFolder[j])
}
for (let i=0; i<ui.scenes.tree.content.length; i++)
sceneList.push(ui.scenes.tree.content[i])
const scene = sceneList[nr+this.sceneOffset];
if (scene != undefined){
if (viewFunc == 'view'){
scene.view();
}
else if (viewFunc == 'activate'){
scene.activate();
}
else {
if (scene.isView) scene.activate();
scene.view();
}
}
}
else if (func == 'any'){ //by name
if (MODULE.getPermission('SCENE','NAME') == false ) return;
if (settings.sceneName == undefined || settings.sceneName == '') return;
const scenes = game.scenes.entries;
let scene = game.scenes.getName(settings.sceneName);
if (scene == undefined) return;
const viewFunc = settings.sceneViewFunction ? settings.sceneViewFunction : 'view';
if (viewFunc == 'view'){
scene.view();
}
else if (viewFunc == 'activate'){
scene.activate();
}
else {
if (scene.isView) scene.activate();
scene.view();
}
}
else if (func == 'active'){
if (MODULE.getPermission('SCENE','ACTIVE') == false ) return;
const scene = game.scenes.active;
if (scene == undefined) return;
scene.view();
}
else if (func == 'offset'){
let offset = parseInt(settings.sceneOffset);
if (isNaN(offset)) offset = 0;
this.sceneOffset = offset;
this.updateAll();
}
}
}

View File

@@ -1,15 +1,82 @@
import * as MODULE from "../MaterialDeck.js"; import * as MODULE from "../MaterialDeck.js";
import { playlistConfigForm, macroConfigForm, soundboardConfigForm } from "./misc.js"; import { playlistConfigForm, macroConfigForm, soundboardConfigForm } from "./misc.js";
export const registerSettings = function() { let userPermissions = {};
const defaultEnable = [true,true,true,true];
const defaultUserPermissions = {
COMBAT: {
END_TURN: [true,true,true,true],
TURN_DISPLAY: [true,true,true,true],
OTHER_FUNCTIONS: [false,false,true,true],
DISPLAY_COMBATANTS: [false,false,true,true],
DISPLAY_NON_OWNED_STATS: [false,false,true,true],
DISPLAY_LIMITED_HP: [false,true,true,true],
DISPLAY_OBSERVER_HP: [true,true,true,true],
DISPLAY_ALL_NAMES: [false,false,true,true],
DISPLAY_LIMITED_NAME: [false,true,true,true],
DISPLAY_OBSERVER_NAME: [true,true,true,true]
},
MACRO: {
HOTBAR: [true,true,true,true],
BY_NAME: [false,false,true,true],
MACROBOARD: [false,false,true,true],
MACROBOARD_CONFIGURE: [false,false,true,true]
},
MOVE: {
TOKEN: [true,true,true,true],
CANVAS: [true,true,true,true]
},
OTHER: {
PAUSE: [false,false,true,true],
CONTROL: [true,true,true,true],
DARKNESS: [false,false,true,true],
DICE: [true,true,true,true],
TABLES_ALL: [false,false,true,true],
TABLES: [false,true,true,true],
SIDEBAR: [true,true,true,true],
COMPENDIUM_ALL: [false,false,true,true],
COMPENDIUM: [false,true,true,true],
JOURNAL_ALL: [false,false,true,true],
JOURNAL: [false,true,true,true],
CHAT: [false,true,true,true]
},
PLAYLIST: {
PLAY: [false,false,true,true],
CONFIGURE: [false,false,true,true]
},
SCENE: {
VISIBLE: [false,false,true,true],
ACTIVE: [true,true,true,true],
DIRECTORY: [false,false,true,true],
NAME: [false,false,true,true]
},
SOUNDBOARD: {
PLAY: [false,false,true,true],
CONFIGURE: [false,false,true,true]
},
TOKEN: {
STATS: [true,true,true,true],
VISIBILITY: [false,false,true,true],
COMBAT: [false,true,true,true],
VISION: [false,true,true,true],
WILDCARD: [false,true,true,true],
CONDITIONS: [false,true,true,true],
CUSTOM: [false,false,true,true],
NON_OWNED: [false,false,true,true],
OBSERVER: [false,true,true,true]
}
}
export const registerSettings = async function() {
/** /**
* Main settings * Main settings
*/ */
//world,global,client
//Enabled the module //Enabled the module
game.settings.register(MODULE.moduleName,'Enable', { game.settings.register(MODULE.moduleName,'Enable', {
name: "MaterialDeck.Sett.Enable", name: "MaterialDeck.Sett.Enable",
scope: "global", scope: "client",
config: true, config: true,
default: false, default: false,
type: Boolean, type: Boolean,
@@ -19,7 +86,7 @@ export const registerSettings = function() {
game.settings.register(MODULE.moduleName,'streamDeckModel', { game.settings.register(MODULE.moduleName,'streamDeckModel', {
name: "MaterialDeck.Sett.Model", name: "MaterialDeck.Sett.Model",
hint: "MaterialDeck.Sett.Model_Hint", hint: "MaterialDeck.Sett.Model_Hint",
scope: "world", scope: "client",
config: true, config: true,
type:Number, type:Number,
default:1, default:1,
@@ -32,13 +99,57 @@ export const registerSettings = function() {
game.settings.register(MODULE.moduleName,'address', { game.settings.register(MODULE.moduleName,'address', {
name: "MaterialDeck.Sett.ServerAddr", name: "MaterialDeck.Sett.ServerAddr",
hint: "MaterialDeck.Sett.ServerAddrHint", hint: "MaterialDeck.Sett.ServerAddrHint",
scope: "world", scope: "client",
config: true, config: true,
default: "localhost:3001", default: "localhost:3001",
type: String, type: String,
onChange: x => window.location.reload() onChange: x => window.location.reload()
}); });
game.settings.register(MODULE.moduleName, 'imageBuffer', {
name: "MaterialDeck.Sett.ImageBuffer",
hint: "MaterialDeck.Sett.ImageBufferHint",
default: 100,
type: Number,
scope: 'client',
range: { min: 0, max: 500, step: 10 },
config: true
});
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
game.settings.registerMenu(MODULE.moduleName, 'helpMenu',{
name: "MaterialDeck.Sett.Help",
label: "MaterialDeck.Sett.Help",
type: helpMenu,
restricted: false
});
game.settings.registerMenu(MODULE.moduleName, 'permissionConfig',{
name: "MaterialDeck.Sett.Permission",
label: "MaterialDeck.Sett.Permission",
type: userPermission,
restricted: true
});
game.settings.register(MODULE.moduleName, 'userPermission', {
name: "userPermission",
scope: "world",
type: Object,
config: false
});
/** /**
* Playlist soundboard * Playlist soundboard
*/ */
@@ -46,7 +157,7 @@ export const registerSettings = function() {
name: "MaterialDeck.Sett.PlaylistConfig", name: "MaterialDeck.Sett.PlaylistConfig",
label: "MaterialDeck.Sett.PlaylistConfig", label: "MaterialDeck.Sett.PlaylistConfig",
type: playlistConfigForm, type: playlistConfigForm,
restricted: true restricted: false
}); });
game.settings.register(MODULE.moduleName, 'playlists', { game.settings.register(MODULE.moduleName, 'playlists', {
@@ -64,7 +175,7 @@ export const registerSettings = function() {
name: "MaterialDeck.Sett.MacroConfig", name: "MaterialDeck.Sett.MacroConfig",
label: "MaterialDeck.Sett.MacroConfig", label: "MaterialDeck.Sett.MacroConfig",
type: macroConfigForm, type: macroConfigForm,
restricted: true restricted: false
}); });
game.settings.register(MODULE.moduleName, 'macroSettings', { game.settings.register(MODULE.moduleName, 'macroSettings', {
@@ -96,6 +207,169 @@ export const registerSettings = function() {
name: "MaterialDeck.Sett.SoundboardConfig", name: "MaterialDeck.Sett.SoundboardConfig",
label: "MaterialDeck.Sett.SoundboardConfig", label: "MaterialDeck.Sett.SoundboardConfig",
type: soundboardConfigForm, type: soundboardConfigForm,
restricted: true 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 {
constructor(data, options) {
super(data, options);
}
/**
* Default Options for this FormApplication
*/
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
id: "helpMenu",
title: "Material Deck: "+game.i18n.localize("MaterialDeck.Sett.Help"),
template: "./modules/MaterialDeck/templates/helpMenu.html",
width: "500px"
});
}
/**
* Provide data to the template
*/
getData() {
return {
}
}
/**
* Update on form submit
* @param {*} event
* @param {*} formData
*/
async _updateObject(event, formData) {
}
activateListeners(html) {
super.activateListeners(html);
}
}
class userPermission extends FormApplication {
constructor(data, options) {
super(data, options);
}
/**
* Default Options for this FormApplication
*/
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
id: "userPermissionConfig",
title: "Material Deck: "+game.i18n.localize("MaterialDeck.Sett.Permission"),
template: "./modules/MaterialDeck/templates/userPermissionConfig.html",
width: 660,
height: "auto",
scrollY: [".permissions-list"],
});
}
/**
* Provide data to the template
*/
async getData() {
let settings = game.settings.get(MODULE.moduleName,'userPermission');
if (settings == undefined || settings == null || MODULE.isEmpty(settings)) {
settings = {
enable: defaultEnable,
permissions: defaultUserPermissions
}
}
const actions = Object.entries(duplicate(settings.permissions)).reduce((arr, e) => {
//const perm = e[1];
const perms = Object.entries(duplicate(e[1])).reduce((arr, p) => {
//const perm = e[1];
let perm = {};
perm.roles = [p[1][0],p[1][1],p[1][2],p[1][3]]
perm.id = p[0];
perm.label = game.i18n.localize("MaterialDeck.Perm."+e[0]+"."+p[0]+".label");
perm.hint = game.i18n.localize("MaterialDeck.Perm."+e[0]+"."+p[0]+".hint");
arr.push(perm);
return arr;
}, []);
let cat = {};
cat.permissions = perms;
cat.id = e[0];
cat.label = game.i18n.localize("MaterialDeck.Perm."+e[0]+".label");
cat.hint = game.i18n.localize("MaterialDeck.Perm."+e[0]+".hint");
arr.push(cat);
return arr;
}, []);
const current = await game.settings.get("core", "permissions");
return {
roles: Object.keys(CONST.USER_ROLES).reduce((obj, r) => {
if ( r === "NONE" ) return obj;
obj[r] = `USER.Role${r.titleCase()}`;
return obj;
}, {}),
actions: actions,
enable: settings.enable
}
}
/**
* Update on form submit
* @param {*} event
* @param {*} formData
*/
async _updateObject(event, formData) {
let permissions = expandObject(formData);
let settings = {};
settings.enable = permissions.ENABLE;
delete permissions.ENABLE;
settings.permissions = permissions;
game.settings.set(MODULE.moduleName,'userPermission',settings);
}
async activateListeners(html) {
super.activateListeners(html);
const defaultBtn = html.find('button[name="reset"]');
defaultBtn.on("click", event => {
this.resetToDefault();
})
}
async resetToDefault(){
const settings = {
enable: defaultEnable,
permissions: defaultUserPermissions
}
await game.settings.set(MODULE.moduleName,'userPermission',settings);
this.render();
ui.notifications.info(game.i18n.localize("MaterialDeck.Perm.DefaultNotification"));
}
}

View File

@@ -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,26 +13,28 @@ 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) {
let 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 ) {
streamDeck.noPermission(context,device);
return;
}
this.active = true; this.active = true;
let mode = settings.soundboardMode; const mode = settings.soundboardMode ? settings.soundboardMode : 'playSound';
if (mode == undefined) mode = 'playSound'; const background = settings.background ? settings.background : '#000000';
let ringColor = "#000000"
let txt = ""; let txt = "";
let src = ""; let src = "";
let background = settings.background;
if (background == undefined) background = '#000000';
let ringColor = "#000000"
if (mode == 'playSound'){ //play sound if (mode == 'playSound'){ //play sound
let soundNr = parseInt(settings.soundNr); let soundNr = parseInt(settings.soundNr);
if (isNaN(soundNr)) soundNr = 1; if (isNaN(soundNr)) soundNr = 1;
@@ -39,46 +42,44 @@ export class SoundboardControl{
soundNr += this.offset; soundNr += this.offset;
let soundboardSettings = game.settings.get(MODULE.moduleName, 'soundboardSettings'); let soundboardSettings = game.settings.get(MODULE.moduleName, 'soundboardSettings');
ringColor = (this.activeSounds[soundNr]==false) ? soundboardSettings.colorOff[soundNr] : soundboardSettings.colorOn[soundNr];
if (this.activeSounds[soundNr]==false)
ringColor = soundboardSettings.colorOff[soundNr];
else
ringColor = soundboardSettings.colorOn[soundNr];
if (settings.displayName && soundboardSettings.name != undefined) txt = soundboardSettings.name[soundNr]; if (settings.displayName && soundboardSettings.name != undefined) txt = soundboardSettings.name[soundNr];
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
let ringOffColor = settings.offRing; const ringOffColor = settings.offRing ? settings.offRing : '#000000';
if (ringOffColor == undefined) ringOffColor = '#000000'; const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
let ringOnColor = settings.onRing;
if (ringOnColor == undefined) ringOnColor = '#00FF00';
let offset = parseInt(settings.offset); let offset = parseInt(settings.offset);
if (isNaN(offset)) offset = 0; if (isNaN(offset)) offset = 0;
if (offset == this.offset) ringColor = ringOnColor; if (offset == this.offset) ringColor = ringOnColor;
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]) soundPlaying = true; if (this.activeSounds[i])
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});
} }
} }
keyPressDown(settings){ keyPressDown(settings){
let mode = settings.soundboardMode; if (MODULE.getPermission('SOUNDBOARD','PLAY') == false ) return;
if (mode == undefined) mode = 'playSound'; const mode = settings.soundboardMode ? settings.soundboardMode : 'playSound';
if (mode == 'playSound') { //Play sound if (mode == 'playSound') { //Play sound
let soundNr = parseInt(settings.soundNr); let soundNr = parseInt(settings.soundNr);
if (isNaN(soundNr)) soundNr = 1; if (isNaN(soundNr)) soundNr = 1;
@@ -86,12 +87,10 @@ export class SoundboardControl{
soundNr += this.offset; soundNr += this.offset;
const playMode = game.settings.get(MODULE.moduleName,'soundboardSettings').mode[soundNr]; const playMode = game.settings.get(MODULE.moduleName,'soundboardSettings').mode[soundNr];
const repeat = (playMode > 0) ? true : false;
const play = (this.activeSounds[soundNr] == false) ? true : false;
let repeat = false; this.prePlaySound(soundNr,repeat,play);
if (playMode > 0) repeat = true;
let play = false;
if (this.activeSounds[soundNr] == false) play = true;
this.playSound(soundNr,repeat,play);
} }
else if (mode == 'offset') { //Offset else if (mode == 'offset') { //Offset
let offset = parseInt(settings.offset); let offset = parseInt(settings.offset);
@@ -102,16 +101,18 @@ 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);
} }
} }
} }
} }
keyPressUp(settings){ keyPressUp(settings){
let mode = settings.soundboardMode; if (MODULE.getPermission('SOUNDBOARD','PLAY') == false ) return;
if (mode == undefined) mode = 'playSound'; const mode = settings.soundboardMode ? settings.soundboardMode : 'playSound';
if (mode != 'playSound') return; if (mode != 'playSound') return;
let soundNr = parseInt(settings.soundNr); let soundNr = parseInt(settings.soundNr);
if (isNaN(soundNr)) soundNr = 1; if (isNaN(soundNr)) soundNr = 1;
soundNr--; soundNr--;
@@ -120,13 +121,12 @@ 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');
let playlistId; const playlistId = (soundBoardSettings.selectedPlaylists != undefined) ? soundBoardSettings.selectedPlaylists[soundNr] : undefined;
if (soundBoardSettings.selectedPlaylists != undefined) playlistId = soundBoardSettings.selectedPlaylists[soundNr];
let src; let src;
if (playlistId == "" || playlistId == undefined) return; if (playlistId == "" || playlistId == undefined) return;
if (playlistId == 'none') return; if (playlistId == 'none') return;
@@ -134,7 +134,8 @@ export class SoundboardControl{
src = soundBoardSettings.src[soundNr]; src = soundBoardSettings.src[soundNr];
const ret = await FilePicker.browse("data", src, {wildcard:true}); const ret = await FilePicker.browse("data", src, {wildcard:true});
const files = ret.files; const files = ret.files;
if (files.length == 1) src = files; if (files.length == 1)
src = files;
else { else {
let value = Math.floor(Math.random() * Math.floor(files.length)); let value = Math.floor(Math.random() * Math.floor(files.length));
src = files[value]; src = files[value];
@@ -142,9 +143,9 @@ export class SoundboardControl{
} }
else { else {
const soundId = soundBoardSettings.sounds[soundNr]; const soundId = soundBoardSettings.sounds[soundNr];
const sounds = game.playlists.entities.find(p => p._id == playlistId).data.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;
} }
@@ -162,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);
}
}
*/
} }

View File

@@ -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;
@@ -25,25 +23,50 @@ export class StreamDeck{
document.body.appendChild(canvasBox); // adds the canvas to the body element document.body.appendChild(canvasBox); // adds the canvas to the body element
this.syllableRegex = /[^aeiouy]*[aeiouy]+(?:[^aeiouy]*$|[^aeiouy](?=[^aeiouy]))?/gi; this.syllableRegex = /[^aeiouy]*[aeiouy]+(?:[^aeiouy]*$|[^aeiouy](?=[^aeiouy]))?/gi;
this.imageBuffer = [];
this.imageBufferCounter = 0;
} }
setScreen(action){ setScreen(action){
} }
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;
@@ -51,6 +74,8 @@ export class StreamDeck{
else if (action == 'playlist') MODULE.playlistControl.active = false; else if (action == 'playlist') MODULE.playlistControl.active = false;
else if (action == 'soundboard') MODULE.soundboard.active = false; else if (action == 'soundboard') MODULE.soundboard.active = false;
else if (action == 'other') MODULE.otherControls.active = false; else if (action == 'other') MODULE.otherControls.active = false;
else if (action == 'external') MODULE.externalModules.active = false;
else if (action == 'scene') MODULE.sceneControl.active = false;
} }
} }
@@ -120,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";
@@ -170,12 +197,15 @@ export class StreamDeck{
MODULE.sendWS(JSON.stringify(msg)); MODULE.sendWS(JSON.stringify(msg));
} }
setImage(image,context){ 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,
id: id,
image: "" + image, image: "" + image,
target: 0 target: 0
} }
@@ -183,20 +213,66 @@ export class StreamDeck{
MODULE.sendWS(JSON.stringify(json)); MODULE.sendWS(JSON.stringify(json));
} }
setIcon(context,src='',background = '#000000',ring=0,ringColor = "#000000",overlay=false){ setBufferImage(context,device,nr,id){
var json = {
target: "SD",
event: "setBufferImage",
context: context,
device: device,
payload: {
nr: nr,
id: id,
target: 0
}
};
MODULE.sendWS(JSON.stringify(json));
}
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 = {
url: src,
background:background,
ring:ring,
ringColor:ringColor,
overlay:overlay,
uses:uses,
options:options,
devide:device
}
const imgBuffer = (clock == false) ? this.checkImageBuffer(data) : false;
if (imgBuffer != false) {
this.setBufferImage(context,device,imgBuffer,this.getImageBufferId(data))
return;
}
let split = src.split('.'); let split = src.split('.');
//filter out stuff from Tokenizer //filter out stuff from Tokenizer
@@ -207,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);
} }
@@ -265,10 +344,11 @@ export class StreamDeck{
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;
@@ -292,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);
@@ -305,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';
@@ -332,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;
@@ -364,10 +450,127 @@ 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();
this.setImage(dataURL,data.context); const nr = this.addToImageBuffer(dataURL,data);
this.setImage(dataURL,data.context,device,nr,this.getImageBufferId(data));
}; };
img.src = resImageURL; img.src = resImageURL;
} }
getImageBufferId(data){
return data.url+data.background+data.ring+data.ringColor+data.overlay+data.uses?.available+data.uses?.maximum;
}
addToImageBuffer(img,data){
const id = this.getImageBufferId(data);
const maxBufferSize = game.settings.get(MODULE.moduleName,'imageBuffer');
if (maxBufferSize == 0) return false;
if (this.imageBufferCounter > maxBufferSize) this.imageBufferCounter = 0;
const newData = {
id: id,
img: img
}
if (this.imageBuffer[this.imageBufferCounter] == undefined) this.imageBuffer.push(newData);
else this.imageBuffer[this.imageBufferCounter] = newData;
this.imageBufferCounter++;
return this.imageBufferCounter - 1;
}
checkImageBuffer(data){
if (game.settings.get(MODULE.moduleName,'imageBuffer') == 0) return false;
const id = this.getImageBufferId(data);
for (let i=0; i<this.imageBuffer.length; i++){
if (this.imageBuffer[i].id == id) return i;
}
return false;
}
resetImageBuffer(){
this.imageBufferCounter = 0;
this.imageBuffer = [];
}
noPermission(context,device,showTxt=true, origin = ""){
console.warn("Material Deck: User lacks permission for function "+origin);
const url = 'modules/MaterialDeck/img/black.png';
const background = '#000000';
const txt = showTxt ? 'no\npermission' : '';
this.setIcon(context,device,url,{background:background});
this.setTitle(txt,context);
}
} }

File diff suppressed because it is too large Load Diff

208
templates/helpMenu.html Normal file
View File

@@ -0,0 +1,208 @@
<form autocomplete="off" onsubmit="event.preventDefault()">
<div style="width:1200px">
<h1>Introduction</h1>
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,
control playlists, execute macros, display and control the combat tracker.<br><br>
The module allows a high degree of customization, where each button on the Stream Deck can be assigned any desired function.
Furthermore, it supports folder structures, allowing easy switching between various button configurations so you can easily switch
between the combat tracker, soundboard, or any other (custom) configuration.<br>
<br>
Material Deck is a very large module with tons of features and ways of customizing your experience. This menu will only cover the basics to get you started,
the full documentation can be found on <a href="https://github.com/CDeenen/MaterialDeck/wiki">Github</a>. Please also check the <a href="https://github.com/CDeenen/MaterialDeck/wiki/FAQ">FAQ</a> which answers some common questions, including some basic troubleshooting.<br>
<h1>Latest Releases</h1>
<a href="https://github.com/CDeenen/MaterialDeck/releases">Module</a><br>
<a href="https://github.com/CDeenen/MaterialDeck_SD/releases">Stream Deck</a><br>
<a href="https://github.com/CDeenen/MaterialServer/releases">Server</a><br>
<h1>Getting Started</h1>
Besides installing this module, you also need to install and run some other things.
<h2>Installing the Stream Deck Software and Plugin</h2>
<ol>
<li>Download and install the <a href="https://www.elgato.com/en/gaming/downloads">Stream Deck software</a></li>
<li>Download the latest plugin file (com.cdeenen.materialdeck.streamDeckPlugin) from <a href="https://github.com/CDeenen/MaterialDeck_SD/releases">here</a></li>
<li>Double-click the file, this should open the Stream Deck software</li>
<li>Press 'Install' in the pop-up</li>
</ol>
<h2>Installing the Stream Deck Profile (optional)</h2>
You can create your own profile, but it is recommended to start with one of the pre-made profiles. Currently, there is a profile for the normal and XL Stream Deck variants.
<ol>
<li>Download the latest profile (ending with .streamDeckProfile) from <a href="https://github.com/CDeenen/MaterialDeck_SD/releases">here</a></li>
<li>Double-click the file, this should load the profile into the Stream Deck software</li>
</ol>
<h2>Downloading and Starting Material Server</h2>
Material Server acts as a bridge application, bridging the communication between the Stream Deck and Material Deck.
<ol>
<li>Download the latest version for your operating system <a href="https://github.com/CDeenen/MaterialServer/releases">here</a></li>
<li>Download and install the <a href="https://github.com/CDeenen/MaterialServer/blob/master/README.md#prerequisites">prerequisites</a></li>
<li>Extract the archive</li>
<li>Double-click the file to start the server</li>
</ol>
<b>You need to always have Material Server running when you want to use Material Deck</b>
<br>
<br>
After setting up the module settings I suggest you just play around with one of the profiles to see that happens when you press buttons and do things in Foundry.
Most things should be pretty self explanatory. After that you could look into customizing your experience, as you can read about below.
<h1>Module Setup</h1>
<img src="modules/MaterialDeck/wiki/img/ModuleSettings.png" align="right" HSPACE="5" width="450">
There are four buttons at the top:
<ul>
<li>Help</li>
<li>Playlist Configuration</li>
<li>Macro Configuration</li>
<li>Soundboard Configuration</li>
</ul>
The help button leads you to the page you are currently reading, the other buttons will be explained below.<br>
<br>
Below the buttons you will find the following settings:
<ul>
<li><b>Enable Module</b> - Ticking this box enabled the module</li>
<li><b>Stream Deck Model</b> - Select the model of your Stream Deck. This is optional, as it only changes the amount of macros and sounds that
you can assign in the macro and soundboard configuration screens. If you have a smaller Stream Deck, you might not want to
have a screen filled with 64 macros, since you probably won't use that many (you can, if you want to, though)</li>
<li><b>Material Server Address</b> - Fill in the address of Material Server (usually if you run it on the same computer as
you're using for Foundry, this can be localhost:3001). This is not necessarily the IP address of Foundry! It is the IP
address of the computer that's running Material Server. The default value will work for 99% of people, only change it if
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.
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>
<BR CLEAR="right" />
<h2>User Permission Configuration</h2>
<img src="modules/MaterialDeck/wiki/img/PermissionConfig.png" align="right" HSPACE="5" width="450">
Using the 'User Permission Configuration' screen, the GM can configure what Material Deck functions users have access to.<br>
Each action has various settings, and these settings can be set for each user role.<br>
<br>
To save the settings, press the 'Save Configuration' button at the lower left, or to set the settings back to the default values, press 'Reset Defaults' in the lower right.<br>
<br>
<BR CLEAR="right" />
<h2>Playlist Configuration</h2>
<img src="modules/MaterialDeck/wiki/img/PlaylistConfig.png" align="right" HSPACE="5" width="350">
The playlist configuration screen configures the playlists that you control using the <a href="https://github.com/CDeenen/MaterialDeck/wiki/Playlist-Action">Playlist action</a>.<br>
There are 2 sections: 'Settings', and 'Playlists'.
<h3><b>Settings</b></h3>
<h4><b>Default Play Mode</b></h4>
The play mode determines what to do when a track is playing, while another track is requested. By setting it to 'Unrestricted', you can play as many tracks at the same time as you want. Setting it to 'One track per playlist' will automatically stop all playing tracks in the playlist, ensuring that only one track is playing at a time. Setting 'Play Method' to 'One track in total' will limit playback to only one track in total.<br>
This setting sets the default play mode, which can be overridden for each separate playlist, which will be discussed below.<br>
<br>
Options:
<ul>
<li><b>Unrestricted</b> - Play as many tracks at the same time as you want</li>
<li><b>One track per playlist</b> - Play only one track per playlist. Trying to start a second track will stop the other tracks in the playlist</li>
<li><b>One track in total</b> - Play only one track in total. Trying to start a second track will stop all other tracks that are playing</li>
</ul>
<b>Note:</b> This play method only applies if tracks are started using the Stream Deck, you can still play more tracks using Foundry's internal audio player.
<h4><b>Number of Playlists</b></h4>
This sets the number of playlists that will be displayed. You can make this number as high or low as you want. This only changes the amount of playlists
that are displayed, not the amount of playlists that can be controlled (there is no upper limit, as long as Foundry doesn't crash).
<h3><b>Playlists</b></h3>
Here you can select which playlists can be controlled with the module. You can manage as many playlists as you've set at 'Number of playlists',
where the playlist number corresponds with the number you have to fill in in the property inspector (see below).<br>
For each playlist you can set the play mode, which overrides the default play mode for that specific playlist.<br>
<br>
<b>Note:</b> While you can assign the same playlist to multiple playlists in this configuration screen, only the play method of the first instance will be applied.
<h2>Macro Configuration</h2>
The Macro Configuration screen is to configure the macro board for the <a href="https://github.com/CDeenen/MaterialDeck/wiki/Macro-Action">Macro action</a>.<br>
<br>
The screen is divided into a number of boxes, each labeled 'Macro #', where each represents a single macro and its settings. The number of macros you can see
depends on what Stream Deck model you've set up in the module configuration.<br>
<br>
For each macro there are 3 options:
<ul>
<li><b>Macro Selection</b> - Drop down menu from where you can select a macro from your macro directory</li>
<li><b>Furnace Arguments</b> - Allows you to use arguments if <a href="https://foundryvtt.com/packages/furnace/">the Furnace</a> is installed. Please read the
documentation regarding advanced macros in the <a href="https://github.com/League-of-Foundry-Developers/fvtt-module-furnace#advanced-macros">README</a> of the Furnace.
If, for example, you wanted to execute a macro named 'My Macro' with the arguments 'argument1 argument2 argument3', you would use for example /"My Macro" 100 50 "test"
in the chat. In the macro configuration screen you would only fill in the arguments, so: 100 50 "test"</li>
<li><b>Background</b> - Color picker to set the background color of the Stream Deck button</li>
</ul>
<img src="modules/MaterialDeck/wiki/img/MacroConfig.png" align="center" HSPACE="5" width="100%">
<h2>Soundboard Configuration</h2>
The Soundboard Configuration screen is used to configure the soundboard for the <a href="https://github.com/CDeenen/MaterialDeck/wiki/Soundboard-Action">Soundboard action</a>.<br>
<br>
Similar to the Macro Configuration screen, the screen is divided into a number of boxes, each labeled 'Sound #', where each represents a single sound and its settings.
The number of sounds you can see depends on what Stream Deck model you've set up in the module configuration.<br>
<br>
For each sound there are multiple options:
<ul>
<li><b>Name</b> - The name of the sound, this is the name that will be displayed on the SD button if 'Display Name' is selected in the property inspector.
This name doesn't have to correspond with the file name of the sound, or the name that can be seen in the Foundry playlist.</li>
<li><b>Playlist</b> - Sets the playlist from which you want to select a sound. If you select 'File Picker', a file picker will appear instead of the sound selection drop-down menu.</li>
<li><b>Sound</b> - This is either a drop-down menu where you can select a sound from the selected playlist, or a file picker.
When using the file picker, it is possible to use wildcard names, this means that you can randomly play a sound from a selection. To do this, navigate to the folder that
contains the sounds, in the textbox append the folder name with the common part of the name of the sounds you want to play, followed by an asterisk.
For example, if you have the sounds 'Thunder.wav', 'Thunder2.wav' and 'Thunder3.wav' in the folder 'Assets', you could fill in the following: 'Assets/Thunder*', which
will play one of the three sounds randomly when you press the button on the Stream Deck.</li>
<li><b>Icon</b> - Here you can select an icon that will be displayed on the SD button if 'Display Icon' is selected in the property inspector.
Please read <a href="https://github.com/CDeenen/MaterialDeck/wiki/Getting-Started#important-notes-on-foundry-assigned-text-and-icons">these</a> notes on rules regarding icon selection.</li>
<li><b>On</b> - Clicking the colored box you'll be presented with a color picker. This sets the color of the ring that's shown on the button when the sound is playing.</li>
<li><b>Off</b> - Clicking the colored box you'll be presented with a color picker. This sets the color of the ring that's shown on the button when the sound is not playing.</li>
<li><b>Playback</b> - This sets the playback mode, you can select from:
<ul>
<li>Once - Play the sound once</li>
<li>Repeat - Play the sound on repeat</li>
<li>Hold - Play the sound as long as the button is held down</li>
</ul>
</li>
<li><b>Volume</b> - The playback volume of the sound. The final playback volume is also determined by the Interface Volume slider in Foundry's 'Audio Playlists' tab.</li>
</ul>
<img src="modules/MaterialDeck/wiki/img/SoundboardConfig.png" align="center" HSPACE="5" width="100%">
<h1>Customization</h1>
Material Deck is extremely flexible, but most of this flexibility must be performed in the Stream Deck software.<br>
Some basic instructions on using the software can be found <a href="https://github.com/CDeenen/MaterialDeck/wiki/Getting-Started#basic-stream-deck-setup-instructions">here</a>.<br>
<br>
Some of the things you can change are:
<ul>
<li><b>Button location</b> - You can drag buttons around into any order you want</li>
<li><b>Changing button text and icon</b> - All the text and icons on the Stream Deck can be customized, see <a href="https://github.com/CDeenen/MaterialDeck/wiki/Getting-Started#changing-the-button-text-and-icon">here</a></li>
<li><b>Customize the behavior of buttons</b> - See below</li>
</ul>
All the buttons have many settings to fine-tune your experience. Due to the large amount of things you can change, they will not be discussed here, instead you can read about it at the following links:
<ul>
<li><a href="https://github.com/CDeenen/MaterialDeck/wiki/Combat-Tracker-Action">Combat Tracker Action</a></li>
<li><a href="https://github.com/CDeenen/MaterialDeck/wiki/External-Modules">External Modules</a></li>
<li><a href="https://github.com/CDeenen/MaterialDeck/wiki/Macro-Action">Macro Action</a></li>
<li><a href="https://github.com/CDeenen/MaterialDeck/wiki/Move-Action">Move Action</a></li>
<li><a href="https://github.com/CDeenen/MaterialDeck/wiki/Other-Actions">Other Actions</a></li>
<li><a href="https://github.com/CDeenen/MaterialDeck/wiki/Playlist-Action">Playlist Action</a></li>
<li><a href="https://github.com/CDeenen/MaterialDeck/wiki/Scene-Action">Scene Action</a></li>
<li><a href="https://github.com/CDeenen/MaterialDeck/wiki/Soundboard-Action">Soundboard Action</a></li>
<li><a href="https://github.com/CDeenen/MaterialDeck/wiki/Token-Action">Token Action</a></li>
</ul>
<h1>Software Versions & Module Incompatibilities</h1>
<b>Foundry VTT:</b> Tested on 0.7.9<br>
<b>Module Incompatibilities:</b> None known.<br>
<h1>Feedback</h1>
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.
<h1>Credits</h1>
<b>Author:</b> Cristian Deenen (Cris#6864 on Discord)<br>
<br>
Special thanks to Asmodeus#7588 who made this module possible by generously donating a Stream Deck XL
<br>
Please consider supporting me on <a href="https://www.patreon.com/materialfoundry">Patreon</a>, and feel free to join the Material Foundry <a href="https://discord.gg/3hd4G6TkmA">Discord</a> server.
</div>
</form>

View File

@@ -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>
@@ -19,13 +19,13 @@
<select name="macros" class="macros-select" id="macros{{this.iteration}}" default="" style="max-width:140px;"> <select name="macros" class="macros-select" id="macros{{this.iteration}}" default="" style="max-width:140px;">
{{#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>
</div> </div>
{{#if this.furnace}} {{#if ../../furnace}}
<label>{{localize "MaterialDeck.FurnaceArgs"}}</label> <label>{{localize "MaterialDeck.FurnaceArgs"}}</label>
<input type="text" name="args" id="args{{this.iteration}}" value="{{this.args}}"> <input type="text" name="args" id="args{{this.iteration}}" value="{{this.args}}">
{{/if}} {{/if}}

View File

@@ -25,8 +25,8 @@
<select name="selectedPlaylist" class="playlist-select" id="playlist{{this.iteration}}" default=""> <select name="selectedPlaylist" class="playlist-select" id="playlist{{this.iteration}}" default="">
{{#select this.playlist}} {{#select this.playlist}}
<option value="">{{localize "MaterialDeck.None"}}</option> <option value="">{{localize "MaterialDeck.None"}}</option>
{{#each this.playlists}} {{#each ../playlists}}
<option value="{{this._id}}">{{this.name}}</option> <option value="{{this.id}}">{{this.name}}</option>
{{/each}} {{/each}}
{{/select}} {{/select}}
</select> </select>

View File

@@ -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>
@@ -26,7 +26,7 @@
<div> <div>
<select name="playlist" class="playlist-select" default="" style="width:100%;" id="playlists{{this.iteration}}"> <select name="playlist" class="playlist-select" default="" style="width:100%;" id="playlists{{this.iteration}}">
{{#select this.selectedPlaylist}} {{#select this.selectedPlaylist}}
{{#each playlists}} {{#each ../../playlists}}
<option value="{{this.id}}">{{this.name}}</option> <option value="{{this.id}}">{{this.name}}</option>
{{/each}} {{/each}}
{{/select}} {{/select}}
@@ -36,17 +36,17 @@
<div style="text-align:center;"> <div style="text-align:center;">
{{localize "MaterialDeck.Sound"}} {{localize "MaterialDeck.Sound"}}
</div> </div>
<div class="form-fields" style={{this.styleSS}}> <div class="form-fields" id="ss{{this.iteration}}" style="{{this.styleSS}}">
<select name="sounds" class="sounds-select" default="" style="width:100%;" id="soundSelect{{this.iteration}}"> <select name="sounds" class="sounds-select" default="" style="width:100%;" id="soundSelect{{this.iteration}}">
{{#select this.sound}} {{#select this.sound}}
<option value="">{{localize "MaterialDeck.None"}}</option> <option value="">{{localize "MaterialDeck.None"}}</option>
{{#each sounds}} {{#each sounds}}
<option value="{{this._id}}">{{this.name}}</option> <option value="{{this.id}}">{{this.name}}</option>
{{/each}} {{/each}}
{{/select}} {{/select}}
</select> </select>
</div> </div>
<div class="form-fields" style={{this.styleFP}}> <div class="form-fields" id="fp{{this.iteration}}" style="{{this.styleFP}}">
<button type="button" class="file-picker" data-type="audio" data-target="src{{this.iteration}}" title="Browse Files" tabindex="-1"> <button type="button" class="file-picker" data-type="audio" data-target="src{{this.iteration}}" title="Browse Files" tabindex="-1">
<i class="fas fa-file-import fa-fw"></i> <i class="fas fa-file-import fa-fw"></i>
</button> </button>

View File

@@ -0,0 +1,113 @@
<form autocomplete="off" onsubmit="event.preventDefault();">
<style>
header.table-header {
background: rgba(0, 0, 0, 0.5);
padding: 5px;
border: 1px solid #191813;
text-align: center;
color: #f0f0e0;
font-weight: bold;
text-shadow: 1px 1px #000;
}
ul.permissions-list {
list-style: none;
margin: 0;
padding: 0;
overflow: hidden auto;
scrollbar-width: thin;
}
li.permission {
padding: 5px;
border-bottom: 1px solid #7a7971;
}
li.permission .form-fields {
justify-content: space-around;
}
li.permission input[type="checkbox"] {
margin: 0;
}
.index {
flex: 0 0 200px;
text-align: left;
font-weight: bold;
}
.hint {
flex: 0 0 100%;
color: #4b4a44;
font-size: 13px;
margin: 5px 0 0;
}
.form-fields {
justify-content: space-around;
}
</style>
<p class="notes">{{localize "MaterialDeck.Perm.Instructions"}}</p>
<hr>
<div class="form-group">
<h2>{{ localize "MaterialDeck.Perm.ENABLE.label" }}</h2>
</div>
<header class="table-header flexrow">
<label class="index">{{ localize "PERMISSION.Permission" }}</label>
{{#each roles as |rl r|}}
<label>{{ localize rl}}</label>
{{/each}}
</header>
<li class="permission form-group">
<label class="index">{{ localize "MaterialDeck.Perm.ENABLE.ENABLE.label" }}</label>
<div class="form-fields">
{{#each enable as |r|}}
<input type="checkbox" name="ENABLE" {{checked r}}>
{{/each}}
</div>
<p class="hint">{{ localize "MaterialDeck.Perm.ENABLE.ENABLE.hint" }}</p>
</li>
{{#each actions as |a|}}
<div class="form-group">
<h2>{{ localize a.label }}</h2>
</div>
<header class="table-header flexrow">
<label class="index">{{ localize "PERMISSION.Permission" }}</label>
{{#each ../roles as |rl r|}}
<label>{{ localize rl}}</label>
{{/each}}
</header>
<ul class="permissions-list">
{{#each a.permissions as |p|}}
<li class="permission form-group">
<label class="index">{{ localize p.label }}</label>
<div class="form-fields">
{{#each p.roles as |r|}}
<input type="checkbox" id="{{p.id}}" name="{{a.id}}.{{p.id}}" {{checked r}}>
{{/each}}
</div>
<p class="hint">{{ localize p.hint }}</p>
</li>
{{/each}}
</ul>
{{/each}}
<div class="form-group">
<button type="submit" name="submit">
<i class="fas fa-save"></i> {{localize 'PERMISSION.Submit'}}
</button>
<button type="button" name="reset">
<i class="fas fa-sync"></i> {{localize 'PERMISSION.Reset'}}
</button>
</div>
</form>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 175 KiB

After

Width:  |  Height:  |  Size: 321 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 609 KiB

After

Width:  |  Height:  |  Size: 598 KiB