This commit is contained in:
CDeenen
2021-05-05 01:00:18 +02:00
parent bf8c5c0076
commit 484b7a0b7f
39 changed files with 197 additions and 117 deletions

View File

@@ -22,7 +22,6 @@ export var externalModules;
export var sceneControl; export var sceneControl;
export const moduleName = "MaterialDeck"; export const moduleName = "MaterialDeck";
export var selectedTokenId;
let ready = false; let ready = false;
let activeSounds = []; let activeSounds = [];
@@ -116,7 +115,7 @@ async function analyzeWSmessage(msg){
if (action == 'token'){ if (action == 'token'){
tokenControl.active = true; tokenControl.active = true;
tokenControl.pushData(selectedTokenId,settings,context,device); tokenControl.pushData(canvas.tokens.controlled[0]?.id,settings,context,device);
} }
else if (action == 'move') else if (action == 'move')
move.update(settings,context,device); move.update(settings,context,device);
@@ -317,14 +316,7 @@ Hooks.once('ready', async()=>{
for (let i=0; i<64; i++) for (let i=0; i<64; i++)
activeSounds[i] = false; activeSounds[i] = false;
if (enableModule == false) return; if (game.user.isGM) {
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');
let array = []; let array = [];
@@ -340,8 +332,8 @@ Hooks.once('ready', async()=>{
color: arrayZero color: arrayZero
}); });
} }
if (soundBoardSettings.colorOff == undefined){
game.settings.set(moduleName,'soundboardSettings',{ const settings = {
playlist: "", playlist: "",
sounds: array, sounds: array,
colorOn: arrayZero, colorOn: arrayZero,
@@ -349,8 +341,25 @@ Hooks.once('ready', async()=>{
mode: arrayZero, mode: arrayZero,
toggle: arrayZero, toggle: arrayZero,
volume: arrayVolume volume: arrayVolume
}); };
if (soundBoardSettings.colorOff == undefined){
game.settings.set(moduleName,'soundboardSettings',settings);
} }
}
if (enableModule == false) return;
if (getPermission('ENABLE') == false) {
ready = true;
return;
}
startWebsocket();
const hotbarUsesTemp = game.modules.get("illandril-hotbar-uses"); const hotbarUsesTemp = game.modules.get("illandril-hotbar-uses");
if (hotbarUsesTemp != undefined) hotbarUses = true; if (hotbarUsesTemp != undefined) hotbarUses = true;
@@ -359,7 +368,7 @@ Hooks.once('ready', async()=>{
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) tokenControl.update(selectedTokenId); if (tokenId == canvas.tokens.controlled[0]?.id) tokenControl.update(canvas.tokens.controlled[0]?.id);
if (macroControl != undefined) macroControl.updateAll(); if (macroControl != undefined) macroControl.updateAll();
}); });
@@ -369,8 +378,8 @@ Hooks.on('updateActor',(scene,actor)=>{
for (let i=0; i<children.length; i++){ for (let i=0; i<children.length; i++){
if (children[i].actor.id == actor._id){ if (children[i].actor.id == actor._id){
let tokenId = children[i].id; let tokenId = children[i].id;
if (tokenId == selectedTokenId) { if (tokenId == canvas.tokens.controlled[0]?.id) {
tokenControl.update(selectedTokenId); tokenControl.update(canvas.tokens.controlled[0]?.id);
} }
} }
@@ -381,16 +390,14 @@ Hooks.on('updateActor',(scene,actor)=>{
Hooks.on('controlToken',(token,controlled)=>{ Hooks.on('controlToken',(token,controlled)=>{
if (enableModule == false || ready == false) return; if (enableModule == false || ready == false) return;
if (controlled) { if (controlled) {
selectedTokenId = token.data._id; tokenControl.update(token.data._id);
tokenControl.update(selectedTokenId);
if (controlTokenTimer != undefined) { if (controlTokenTimer != undefined) {
clearTimeout(controlTokenTimer); clearTimeout(controlTokenTimer);
controlTokenTimer = undefined; controlTokenTimer = undefined;
} }
} }
else { else {
controlTokenTimer = setTimeout(function(){tokenControl.update(selectedTokenId);},10) controlTokenTimer = setTimeout(function(){tokenControl.update(canvas.tokens.controlled[0]?.id);},10)
selectedTokenId = undefined;
} }
if (macroControl != undefined) macroControl.updateAll(); if (macroControl != undefined) macroControl.updateAll();
@@ -401,7 +408,6 @@ Hooks.on('updateOwnedItem',()=>{
}) })
Hooks.on('renderHotbar', (hotbar)=>{ Hooks.on('renderHotbar', (hotbar)=>{
if (compatibleCore("0.8.1")) return;
if (enableModule == false || ready == false) return; if (enableModule == false || ready == false) return;
if (macroControl != undefined) macroControl.hotbar(hotbar.macros); if (macroControl != undefined) macroControl.hotbar(hotbar.macros);
}); });
@@ -416,7 +422,7 @@ Hooks.on('render', (app)=>{
Hooks.on('renderCombatTracker',()=>{ Hooks.on('renderCombatTracker',()=>{
if (enableModule == false || ready == false) return; if (enableModule == false || ready == false) return;
if (combatTracker != undefined) combatTracker.updateAll(); if (combatTracker != undefined) combatTracker.updateAll();
if (tokenControl != undefined) tokenControl.update(selectedTokenId); if (tokenControl != undefined) tokenControl.update(canvas.tokens.controlled[0]?.id);
}); });
Hooks.on('renderPlaylistDirectory', (playlistDirectory)=>{ Hooks.on('renderPlaylistDirectory', (playlistDirectory)=>{
@@ -473,7 +479,7 @@ Hooks.on('renderSceneControls',()=>{
Hooks.on('targetToken',(user,token,targeted)=>{ Hooks.on('targetToken',(user,token,targeted)=>{
if (enableModule == false || ready == false) return; if (enableModule == false || ready == false) return;
if (token.id == selectedTokenId) tokenControl.update(selectedTokenId); if (token.id == canvas.tokens.controlled[0]?.id) tokenControl.update(canvas.tokens.controlled[0]?.id);
}); });
Hooks.on('sidebarCollapse',()=>{ Hooks.on('sidebarCollapse',()=>{

View File

@@ -1,4 +1,23 @@
# Changelog Material Deck Module # Changelog Material Deck Module
### v1.4.3 - 05-05-2021
Fixes:
<ul>
<li>Fixed issue where the module would break if multiple Stream Decks were configured in the Stream Deck application, but not all of them had MD actions assigned to them</li>
<li>In the User Permission Configuration, the Scene Directory hint wasn't displayed properly</li>
<li>Got rid of warnings that popped up on initialization when using MD as a player</li>
<li>Fixed issue where the soundboard and macro board could not be configured by players, if it hadn't first been configured by a GM</li>
</ul>
Other
<ul>
<li>Added compatibility for Foundry 0.8.2. Some functions no longer work in 0.8.1 (they still do in 0.7.9)</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.2 (unchanged): https://github.com/CDeenen/MaterialDeck_SD/releases<br>
### v1.4.2 - 23-04-2021 ### v1.4.2 - 23-04-2021
Fixes: Fixes:
<ul> <ul>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -98,7 +98,7 @@
"MaterialDeck.Perm.MACRO.MACROBOARD.label": "Macro Board", "MaterialDeck.Perm.MACRO.MACROBOARD.label": "Macro Board",
"MaterialDeck.Perm.MACRO.MACROBOARD.hint": "Allow users to use the macro board", "MaterialDeck.Perm.MACRO.MACROBOARD.hint": "Allow users to use the macro board",
"MaterialDeck.Perm.MACRO.MACROBOARD_CONFIGURE.label": "Configure the Macro Board", "MaterialDeck.Perm.MACRO.MACROBOARD_CONFIGURE.label": "Configure the Macro Board",
"MaterialDeck.Perm.MACRO.MACROBOARD_CONFIGURE.hint": "Allow users to configure the macro board", "MaterialDeck.Perm.MACRO.MACROBOARD_CONFIGURE.hint": "Allow users to configure the macro board. To allow users to pick icons using the filepicker, enable 'Browse File Explorer' for that user in the core Permission Configuration",
"MaterialDeck.Perm.MOVE.label": "Move", "MaterialDeck.Perm.MOVE.label": "Move",
"MaterialDeck.Perm.MOVE.TOKEN.label": "Token", "MaterialDeck.Perm.MOVE.TOKEN.label": "Token",
@@ -144,7 +144,7 @@
"MaterialDeck.Perm.SCENE.ACTIVE.label": "Active Scene", "MaterialDeck.Perm.SCENE.ACTIVE.label": "Active Scene",
"MaterialDeck.Perm.SCENE.ACTIVE.hint": "Allow users to view the active scene", "MaterialDeck.Perm.SCENE.ACTIVE.hint": "Allow users to view the active scene",
"MaterialDeck.Perm.SCENE.DIRECTORY.label": "Scene Directory", "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.DIRECTORY.hint": "Allow users to view and control scenes from the scene directory",
"MaterialDeck.Perm.SCENE.NAME.label": "Scene by Name", "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.SCENE.NAME.hint": "Allow users to view and control any scene by name",
@@ -152,7 +152,7 @@
"MaterialDeck.Perm.SOUNDBOARD.PLAY.label": "Enable", "MaterialDeck.Perm.SOUNDBOARD.PLAY.label": "Enable",
"MaterialDeck.Perm.SOUNDBOARD.PLAY.hint": "Allow users to play sounds from the soundboard", "MaterialDeck.Perm.SOUNDBOARD.PLAY.hint": "Allow users to play sounds from the soundboard",
"MaterialDeck.Perm.SOUNDBOARD.CONFIGURE.label": "Configure", "MaterialDeck.Perm.SOUNDBOARD.CONFIGURE.label": "Configure",
"MaterialDeck.Perm.SOUNDBOARD.CONFIGURE.hint": "Allow users to configure the soundboard", "MaterialDeck.Perm.SOUNDBOARD.CONFIGURE.hint": "Allow users to configure the soundboard. To allow users to pick files and icons using the filepicker, enable 'Browse File Explorer' for that user in the core Permission Configuration",
"MaterialDeck.Perm.TOKEN.label": "Token", "MaterialDeck.Perm.TOKEN.label": "Token",
"MaterialDeck.Perm.TOKEN.STATS.label": "Display Stats", "MaterialDeck.Perm.TOKEN.STATS.label": "Display Stats",

View File

@@ -2,16 +2,24 @@
"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.4.2", "version": "1.4.3",
"minimumSDversion": "1.4.2", "minimumSDversion": "1.4.2",
"minimumMSversion": "1.0.2", "minimumMSversion": "1.0.2",
"author": "CDeenen", "author": "CDeenen",
"authors": {
"name": "CDeenen",
"email": "cdeenen@outlook.com",
"discord": "Cris#6864",
"patreon": "MaterialFoundry",
"reddit": "CDeenen123"
},
"esmodules": [ "esmodules": [
"./MaterialDeck.js" "./MaterialDeck.js"
], ],
"socket": true, "socket": true,
"minimumCoreVersion": "0.7.5", "minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.8.1", "compatibleCoreVersion": "0.8.2",
"languages": [ "languages": [
{ {
"lang": "en", "lang": "en",
@@ -19,6 +27,13 @@
"path": "lang/en.json" "path": "lang/en.json"
} }
], ],
"media": [
{
"type": "icon",
"url": "https://raw.githubusercontent.com/CDeenen/MaterialDeck/Master/img/MaterialFoundry512x512.png"
}
],
"manifestPlusVersion": "1.1.0",
"url": "https://github.com/CDeenen/MaterialDeck", "url": "https://github.com/CDeenen/MaterialDeck",
"manifest": "https://raw.githubusercontent.com/CDeenen/MaterialDeck/Master/module.json", "manifest": "https://raw.githubusercontent.com/CDeenen/MaterialDeck/Master/module.json",
"download": "https://github.com/CDeenen/MaterialDeck/archive/Master.zip" "download": "https://github.com/CDeenen/MaterialDeck/archive/Master.zip"

View File

@@ -11,6 +11,7 @@ export class CombatTracker{
async updateAll(){ async updateAll(){
if (this.active == false) return; if (this.active == false) return;
for (let device of streamDeck.buttonContext) { for (let device of streamDeck.buttonContext) {
if (device?.buttons == undefined) continue;
for (let i=0; i<device.buttons.length; i++){ for (let i=0; i<device.buttons.length; i++){
const data = device.buttons[i]; const data = device.buttons[i];
if (data == undefined || data.action != 'combattracker') continue; if (data == undefined || data.action != 'combattracker') continue;

View File

@@ -13,6 +13,7 @@ export class ExternalModules{
} }
if (this.active == false) return; if (this.active == false) return;
for (let device of streamDeck.buttonContext) { for (let device of streamDeck.buttonContext) {
if (device?.buttons == undefined) continue;
for (let i=0; i<device.buttons.length; i++){ for (let i=0; i<device.buttons.length; i++){
const data = device.buttons[i]; const data = device.buttons[i];
if (data == undefined || data.action != 'external') continue; if (data == undefined || data.action != 'external') continue;

View File

@@ -11,6 +11,7 @@ export class MacroControl{
async updateAll(){ async updateAll(){
if (this.active == false) return; if (this.active == false) return;
for (let device of streamDeck.buttonContext) { for (let device of streamDeck.buttonContext) {
if (device?.buttons == undefined) continue;
for (let i=0; i<device.buttons.length; i++){ for (let i=0; i<device.buttons.length; i++){
const data = device.buttons[i]; const data = device.buttons[i];
if (data == undefined || data.action != 'macro') continue; if (data == undefined || data.action != 'macro') continue;
@@ -109,9 +110,11 @@ export class MacroControl{
return uses; return uses;
} }
async hotbar(macros){ async hotbar(){
for (let i=0; i<32; i++){ for (let device of streamDeck.buttonContext) {
const data = streamDeck.buttonContext[i]; if (device?.buttons == undefined) continue;
for (let i=0; i<device.buttons.length; i++){
const data = device.buttons[i];
if (data == undefined || data.action != 'macro' || data.settings.macroMode == 'macroBoard') continue; if (data == undefined || data.action != 'macro' || data.settings.macroMode == 'macroBoard') continue;
const context = data.context; const context = data.context;
@@ -153,6 +156,7 @@ export class MacroControl{
streamDeck.setTitle(name,context); streamDeck.setTitle(name,context);
} }
} }
}
keyPress(settings){ keyPress(settings){
const mode = settings.macroMode ? settings.macroMode : 'hotbar'; const mode = settings.macroMode ? settings.macroMode : 'hotbar';

View File

@@ -70,7 +70,7 @@ export class Move{
const selection = settings.selection ? settings.selection : 'selected'; const selection = settings.selection ? settings.selection : 'selected';
const tokenIdentifier = settings.tokenName ? settings.tokenName : ''; const tokenIdentifier = settings.tokenName ? settings.tokenName : '';
if (selection == 'selected') token = canvas.tokens.children[0].children.find(p => p.id == MODULE.selectedTokenId); if (selection == 'selected') token = canvas.tokens.controlled[0];
else if (selection != 'selected' && tokenIdentifier == '') {} else if (selection != 'selected' && tokenIdentifier == '') {}
else if (selection == 'tokenName') token = canvas.tokens.children[0].children.find(p => p.name == 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 == 'actorName') token = canvas.tokens.children[0].children.find(p => p.actor.name == tokenIdentifier);

View File

@@ -17,10 +17,11 @@ export class OtherControls{
async updateAll(options={}){ async updateAll(options={}){
if (this.active == false) return; if (this.active == false) return;
for (let device of streamDeck.buttonContext) { for (let device of streamDeck.buttonContext) {
if (device?.buttons == undefined) continue;
for (let i=0; i<device.buttons.length; i++){ for (let i=0; i<device.buttons.length; i++){
const data = device.buttons[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,device.device); await this.update(data.settings,data.context,device.device,options);
} }
} }
} }
@@ -240,7 +241,16 @@ export class OtherControls{
} }
ui.controls.activeControl = selectedControl.name; ui.controls.activeControl = selectedControl.name;
selectedControl.activeTool = selectedControl.activeTool; selectedControl.activeTool = selectedControl.activeTool;
canvas.getLayer(selectedControl.layer).activate(); if (compatibleCore("0.8.2")) {
for (let layer of canvas.layers) {
if (layer.options == undefined) continue;
if (layer.options.name == selectedControl.layer) {
layer.activate();
break;
}
}
}
else canvas.getLayer(selectedControl.layer).activate();
} }
} }
else if (control == 'dispTools'){ //displayed tools else if (control == 'dispTools'){ //displayed tools
@@ -281,7 +291,16 @@ export class OtherControls{
if (tool == 'open'){ //open category if (tool == 'open'){ //open category
ui.controls.activeControl = control; ui.controls.activeControl = control;
selectedControl.activeTool = selectedControl.activeTool; selectedControl.activeTool = selectedControl.activeTool;
canvas.getLayer(selectedControl.layer).activate(); if (compatibleCore("0.8.2")) {
for (let layer of canvas.layers) {
if (layer.options == undefined) continue;
if (layer.options.name == selectedControl.layer) {
layer.activate();
break;
}
}
}
else 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);
@@ -291,7 +310,16 @@ export class OtherControls{
return; return;
} }
ui.controls.activeControl = control; ui.controls.activeControl = control;
canvas.getLayer(selectedControl.layer).activate(); if (compatibleCore("0.8.2")) {
for (let layer of canvas.layers) {
if (layer.options == undefined) continue;
if (layer.options.name == selectedControl.layer) {
layer.activate();
break;
}
}
}
else canvas.getLayer(selectedControl.layer).activate();
if (selectedTool.toggle) { if (selectedTool.toggle) {
selectedTool.active = !selectedTool.active; selectedTool.active = !selectedTool.active;
selectedTool.onClick(selectedTool.active); selectedTool.onClick(selectedTool.active);
@@ -378,7 +406,7 @@ export class OtherControls{
let actor; let actor;
let tokenControlled = false; let tokenControlled = false;
if (MODULE.selectedTokenId != undefined) actor = canvas.tokens.children[0].children.find(p => p.id == MODULE.selectedTokenId).actor; if (canvas.tokens.controlled[0] != undefined) actor = canvas.tokens.controlled[0].actor;
if (actor != undefined) tokenControlled = true; if (actor != undefined) tokenControlled = true;
let r; let r;
@@ -418,6 +446,7 @@ export class OtherControls{
const background = settings.background ? settings.background : '#000000'; const background = settings.background ? settings.background : '#000000';
const table = game.tables.getName(name); const table = game.tables.getName(name);
if (table == undefined) return;
let txt = settings.displayRollName ? table.name : ''; let txt = settings.displayRollName ? table.name : '';
let src = settings.displayRollIcon ? table.data.img : ''; let src = settings.displayRollIcon ? table.data.img : '';
@@ -509,7 +538,7 @@ export class OtherControls{
if (popOut && options.sidebarTab == sidebarTab) { if (popOut && options.sidebarTab == sidebarTab) {
ringColor = options.renderPopout ? ringOnColor : ringOffColor; ringColor = options.renderPopout ? ringOnColor : ringOffColor;
} }
else ringColor = (sidebarTab == 'collapse' && collapsed || (activeTab == sidebarTab)) ? ringOnColor : ringOffColor; else if (popOut == false) ringColor = (sidebarTab == 'collapse' && collapsed || (activeTab == sidebarTab)) ? ringOnColor : ringOffColor;
const name = settings.displaySidebarName ? this.getSidebarName(sidebarTab) : ''; const name = settings.displaySidebarName ? this.getSidebarName(sidebarTab) : '';
const icon = settings.displaySidebarIcon ? this.getSidebarIcon(sidebarTab) : ''; const icon = settings.displaySidebarIcon ? this.getSidebarIcon(sidebarTab) : '';

View File

@@ -12,6 +12,7 @@ export class PlaylistControl{
async updateAll(){ async updateAll(){
if (this.active == false) return; if (this.active == false) return;
for (let device of streamDeck.buttonContext) { for (let device of streamDeck.buttonContext) {
if (device?.buttons == undefined) continue;
for (let i=0; i<device.buttons.length; i++){ for (let i=0; i<device.buttons.length; i++){
const data = device.buttons[i]; const data = device.buttons[i];
if (data == undefined || data.action != 'playlist') continue; if (data == undefined || data.action != 'playlist') continue;

View File

@@ -12,6 +12,7 @@ export class SceneControl{
async updateAll(){ async updateAll(){
if (this.active == false) return; if (this.active == false) return;
for (let device of streamDeck.buttonContext) { for (let device of streamDeck.buttonContext) {
if (device?.buttons == undefined) continue;
for (let i=0; i<device.buttons.length; i++){ for (let i=0; i<device.buttons.length; i++){
const data = device.buttons[i]; const data = device.buttons[i];
if (data == undefined || data.action != 'scene') continue; if (data == undefined || data.action != 'scene') continue;

View File

@@ -222,6 +222,7 @@ export const registerSettings = async function() {
if (permissionSettings.permissions.TOKEN.OBSERVER == undefined) permissionSettings.permissions.TOKEN.OBSERVER = [false,true,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]; if (permissionSettings.permissions.MACRO.BY_NAME == undefined) permissionSettings.permissions.MACRO.BY_NAME = [false,false,true,true];
} }
if (game.user.isGM)
game.settings.set(MODULE.moduleName,'userPermission',permissionSettings); game.settings.set(MODULE.moduleName,'userPermission',permissionSettings);

View File

@@ -14,6 +14,7 @@ export class SoundboardControl{
async updateAll(){ async updateAll(){
if (this.active == false) return; if (this.active == false) return;
for (let device of streamDeck.buttonContext) { for (let device of streamDeck.buttonContext) {
if (device?.buttons == undefined) continue;
for (let i=0; i<device.buttons.length; i++){ for (let i=0; i<device.buttons.length; i++){
const data = device.buttons[i]; const data = device.buttons[i];
if (data == undefined || data.action != 'soundboard') continue; if (data == undefined || data.action != 'soundboard') continue;
@@ -171,7 +172,7 @@ export class SoundboardControl{
volume *= game.settings.get("core", "globalAmbientVolume"); volume *= game.settings.get("core", "globalAmbientVolume");
if (compatibleCore("0.8.1")) { if (compatibleCore("0.8.1")) {
let newSound = new SoundNode(src); let newSound = new Sound(src);
if(newSound.loaded == false) await newSound.load({autoplay:true}); if(newSound.loaded == false) await newSound.load({autoplay:true});
newSound.on('end', ()=>{ newSound.on('end', ()=>{
if (repeat == false) { if (repeat == false) {

View File

@@ -35,6 +35,7 @@ export class StreamDeck{
} }
setContext(device,size,iteration,action,context,coordinates = {column:0,row:0},settings){ setContext(device,size,iteration,action,context,coordinates = {column:0,row:0},settings){
if (device == undefined) return;
if (this.buttonContext[iteration] == undefined) { if (this.buttonContext[iteration] == undefined) {
const deckSize = size.columns*size.rows; const deckSize = size.columns*size.rows;
let buttons = []; let buttons = [];

View File

@@ -11,6 +11,7 @@ export class TokenControl{
async update(tokenId=null){ async update(tokenId=null){
if (this.active == false) return; if (this.active == false) return;
for (let device of streamDeck.buttonContext) { for (let device of streamDeck.buttonContext) {
if (device?.buttons == undefined) continue;
for (let i=0; i<device.buttons.length; i++){ for (let i=0; i<device.buttons.length; i++){
const data = device.buttons[i]; const data = device.buttons[i];
if (data == undefined || data.action != 'token') continue; if (data == undefined || data.action != 'token') continue;
@@ -650,7 +651,6 @@ export class TokenControl{
if (skill == undefined) skill = 'acr'; if (skill == undefined) skill = 'acr';
else iconSrc = "modules/MaterialDeck/img/token/skills/" + skill + ".png"; else iconSrc = "modules/MaterialDeck/img/token/skills/" + skill + ".png";
} }
} }
streamDeck.setIcon(context,device,iconSrc,{background:background,ring:ring,ringColor:ringColor,overlay:overlay,uses:uses,hp:hp}); streamDeck.setIcon(context,device,iconSrc,{background:background,ring:ring,ringColor:ringColor,overlay:overlay,uses:uses,hp:hp});
streamDeck.setTitle(txt,context); streamDeck.setTitle(txt,context);
@@ -659,13 +659,13 @@ export class TokenControl{
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
async keyPress(settings){ async keyPress(settings){
const tokenId = MODULE.selectedTokenId; const tokenId = canvas.tokens.controlled[0]?.id;
const selection = settings.selection ? settings.selection : 'selected'; const selection = settings.selection ? settings.selection : 'selected';
const tokenIdentifier = settings.tokenName ? settings.tokenName : ''; const tokenIdentifier = settings.tokenName ? settings.tokenName : '';
let token; let token;
if (selection == 'selected') token = canvas.tokens.children[0].children.find(p => p.id == tokenId); if (selection == 'selected') token = canvas.tokens.controlled[0];
else if (selection != 'selected' && tokenIdentifier == '') {} else if (selection != 'selected' && tokenIdentifier == '') {}
else if (selection == 'tokenName') token = canvas.tokens.children[0].children.find(p => p.name == 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 == 'actorName') token = canvas.tokens.children[0].children.find(p => p.actor.name == tokenIdentifier);
@@ -834,7 +834,7 @@ export class TokenControl{
} }
else if (method == 'offset'){ else if (method == 'offset'){
this.wildcardOffset = value; this.wildcardOffset = value;
this.update(MODULE.selectedTokenId); this.update(canvas.tokens.controlled[0]?.id);
} }
else return; else return;