v0.8.4
This commit is contained in:
@@ -45,7 +45,7 @@ async function analyzeWSmessage(msg,passthrough = false){
|
|||||||
if (enableModule == false) return;
|
if (enableModule == false) return;
|
||||||
const data = JSON.parse(msg);
|
const data = JSON.parse(msg);
|
||||||
if (data == undefined || data.payload == undefined) return;
|
if (data == undefined || data.payload == undefined) return;
|
||||||
console.log(data);
|
//console.log(data);
|
||||||
const action = data.action;
|
const action = data.action;
|
||||||
const event = data.event;
|
const event = data.event;
|
||||||
const context = data.context;
|
const context = data.context;
|
||||||
|
|||||||
10
changelog.md
10
changelog.md
@@ -1,4 +1,14 @@
|
|||||||
# Changelog Material Deck Module
|
# Changelog Material Deck Module
|
||||||
|
### v0.8.4 - 11-11-2020
|
||||||
|
<ul>
|
||||||
|
<li>In 'Other' action, 'Control Button' mode, add 'Displayed Controls' option</li>
|
||||||
|
<li>Change 'Other', 'Playlist' and 'Soundboard' actions from background color change to ring color</li>
|
||||||
|
<li>Macro board fixed</li>
|
||||||
|
<li>Added proper background color options for 'Other' action</li>
|
||||||
|
<li>In 'Other' action, control button icons are now properly centered</li>
|
||||||
|
<li>Newly created actions now show the correct options at the start</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
### v0.8.3 - 10-11-2020
|
### v0.8.3 - 10-11-2020
|
||||||
Fixed compatibility with tokenizer
|
Fixed compatibility with tokenizer
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
"name": "MaterialDeck",
|
"name": "MaterialDeck",
|
||||||
"title": "Material Deck",
|
"title": "Material Deck",
|
||||||
"description": "",
|
"description": "",
|
||||||
"version": "0.8.3",
|
"version": "0.8.4",
|
||||||
"author": "CDeenen",
|
"author": "CDeenen",
|
||||||
"esmodules": [
|
"esmodules": [
|
||||||
"./MaterialDeck.js"
|
"./MaterialDeck.js"
|
||||||
|
|||||||
33
src/macro.js
33
src/macro.js
@@ -19,6 +19,8 @@ export class MacroControl{
|
|||||||
let displayName = settings.displayName;
|
let displayName = settings.displayName;
|
||||||
let macroNumber = settings.macroNumber;
|
let macroNumber = settings.macroNumber;
|
||||||
let background = settings.background;
|
let background = settings.background;
|
||||||
|
let ringColor = "#000000";
|
||||||
|
let ring = 0;
|
||||||
if(macroNumber == undefined || isNaN(parseInt(macroNumber))){
|
if(macroNumber == undefined || isNaN(parseInt(macroNumber))){
|
||||||
macroNumber = 0;
|
macroNumber = 0;
|
||||||
}
|
}
|
||||||
@@ -76,18 +78,21 @@ export class MacroControl{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
src = "";
|
let ringOffColor = settings.offRing;
|
||||||
let onBackground = settings.onBackground;
|
if (ringOffColor == undefined) ringOffColor = '#000000';
|
||||||
if (onBackground == undefined) onBackground = '#00FF00';
|
|
||||||
let offBackground = settings.offBackground;
|
let ringOnColor = settings.onRing;
|
||||||
if (offBackground == undefined) offBackground = '#000000';
|
if (ringOnColor == undefined) ringOnColor = '#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)) background = onBackground;
|
if (macroOffset == parseInt(this.offset)) ringColor = ringOnColor;
|
||||||
else background = offBackground;
|
else ringColor = ringOffColor;
|
||||||
|
|
||||||
|
ring = 2;
|
||||||
}
|
}
|
||||||
streamDeck.setIcon(1,context,src,background);
|
streamDeck.setIcon(1, context,src,background,ring,ringColor);
|
||||||
if (displayName == 0) name = "";
|
if (displayName == 0) name = "";
|
||||||
streamDeck.setTitle(name,context);
|
streamDeck.setTitle(name,context);
|
||||||
}
|
}
|
||||||
@@ -140,13 +145,13 @@ export class MacroControl{
|
|||||||
let mode = settings.macroMode;
|
let mode = settings.macroMode;
|
||||||
if (mode == undefined) mode = 0;
|
if (mode == undefined) mode = 0;
|
||||||
|
|
||||||
if (mode == 0 || mode == 1){
|
let macroNumber = settings.macroNumber;
|
||||||
let macroNumber = settings.macroNumber;
|
if(macroNumber == undefined || isNaN(parseInt(macroNumber))){
|
||||||
if(macroNumber == undefined || isNaN(parseInt(macroNumber))){
|
macroNumber = 0;
|
||||||
macroNumber = 0;
|
|
||||||
}
|
|
||||||
this.executeHotbar(macroNumber,mode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mode == 0 || mode == 1)
|
||||||
|
this.executeHotbar(macroNumber,mode);
|
||||||
else {
|
else {
|
||||||
if (settings.macroBoardMode == 0)
|
if (settings.macroBoardMode == 0)
|
||||||
this.executeBoard(macroNumber);
|
this.executeBoard(macroNumber);
|
||||||
|
|||||||
@@ -59,25 +59,39 @@ export class OtherControls{
|
|||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
updatePause(pauseFunction,context){
|
updatePause(pauseFunction,context){
|
||||||
|
|
||||||
if (pauseFunction == undefined) pauseFunction = 0;
|
|
||||||
let src = "";
|
let src = "";
|
||||||
let name = "";
|
if (pauseFunction == undefined) pauseFunction = 0;
|
||||||
let background = "#000000";
|
|
||||||
|
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 playlistType = settings.playlistType;
|
||||||
|
if (playlistType == undefined) playlistType = 0;
|
||||||
|
|
||||||
if (pauseFunction == 0){ //Pause game
|
if (pauseFunction == 0){ //Pause game
|
||||||
if (game.paused) background = "#00FF00"
|
if (game.paused) ringColor = ringOnColor;
|
||||||
|
else ringColor = ringOffColor;
|
||||||
src = 'action/images/other/pause/pause.png';
|
src = 'action/images/other/pause/pause.png';
|
||||||
}
|
}
|
||||||
else if (pauseFunction == 1){ //Resume game
|
else if (pauseFunction == 1){ //Resume game
|
||||||
if (game.paused == false) background = "#00FF00"
|
if (game.paused == false) ringColor = ringOnColor;
|
||||||
|
else ringColor = ringOffColor;
|
||||||
src = 'action/images/other/pause/resume.png';
|
src = 'action/images/other/pause/resume.png';
|
||||||
}
|
}
|
||||||
else if (pauseFunction == 2) { //toggle
|
else if (pauseFunction == 2) { //toggle
|
||||||
if (game.paused == false) background = "#00FF00"
|
if (game.paused == false) ringColor = ringOnColor;
|
||||||
|
else ringColor = ringOffColor;
|
||||||
src = 'action/images/other/pause/playpause.png';
|
src = 'action/images/other/pause/playpause.png';
|
||||||
}
|
}
|
||||||
streamDeck.setIcon(0,context,src,background);
|
streamDeck.setIcon(0,context,src,background,2,ringColor);
|
||||||
streamDeck.setTitle(name,context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPressPause(pauseFunction){
|
keyPressPause(pauseFunction){
|
||||||
@@ -101,56 +115,54 @@ export class OtherControls{
|
|||||||
let func = settings.sceneFunction;
|
let func = settings.sceneFunction;
|
||||||
if (func == undefined) func = 0;
|
if (func == undefined) func = 0;
|
||||||
|
|
||||||
|
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 playlistType = settings.playlistType;
|
||||||
|
if (playlistType == undefined) playlistType = 0;
|
||||||
|
|
||||||
|
let src = "";
|
||||||
|
let name = "";
|
||||||
if (func == 0){ //visible scenes
|
if (func == 0){ //visible scenes
|
||||||
let nr = parseInt(settings.sceneNr);
|
let nr = parseInt(settings.sceneNr);
|
||||||
if (isNaN(nr)) nr = 1;
|
if (isNaN(nr)) nr = 1;
|
||||||
nr--;
|
nr--;
|
||||||
|
|
||||||
let background = settings.background;
|
|
||||||
if (background == undefined) background = "#000000";
|
|
||||||
|
|
||||||
let scene = game.scenes.apps[0].scenes[nr];
|
let scene = game.scenes.apps[0].scenes[nr];
|
||||||
let name = "";
|
|
||||||
let src = "";
|
|
||||||
let ringColor = "#000000";
|
|
||||||
let ring = 1;
|
|
||||||
|
|
||||||
if (scene != undefined){
|
if (scene != undefined){
|
||||||
if (scene.isView) {
|
if (scene.isView)
|
||||||
ringColor = "#00FF00";
|
ringColor = ringOnColor;
|
||||||
ring = 2;
|
else
|
||||||
}
|
ringColor = ringOffColor;
|
||||||
if (settings.displaySceneName) name = scene.name;
|
if (settings.displaySceneName) name = scene.name;
|
||||||
if (settings.displaySceneIcon) src = scene.img;
|
if (settings.displaySceneIcon) src = scene.img;
|
||||||
if (scene.active) name += "\n(Active)";
|
if (scene.active) name += "\n(Active)";
|
||||||
}
|
}
|
||||||
streamDeck.setTitle(name,context);
|
|
||||||
streamDeck.setIcon(1, context,src,background,ring,ringColor);
|
|
||||||
}
|
}
|
||||||
else if (func == 1) { //all scenes
|
else if (func == 1) { //all scenes
|
||||||
let name = settings.sceneName;
|
|
||||||
if (name == undefined) return;
|
|
||||||
|
|
||||||
let background = settings.background;
|
|
||||||
if (background == undefined) background = "#000000";
|
|
||||||
|
|
||||||
let src = "";
|
|
||||||
let ringColor = "#000000";
|
|
||||||
let ring = 1;
|
|
||||||
let scene = game.scenes.apps[1].entities.find(p=>p.data.name == name);
|
let scene = game.scenes.apps[1].entities.find(p=>p.data.name == name);
|
||||||
name = "";
|
|
||||||
if (scene != undefined){
|
if (scene != undefined){
|
||||||
if (scene.isView) {
|
if (scene.isView)
|
||||||
ringColor = "#00FF00";
|
ringColor = ringOnColor;
|
||||||
ring = 2;
|
else
|
||||||
}
|
ringColor = ringOffColor;
|
||||||
if (settings.displaySceneName) name = scene.name;
|
if (settings.displaySceneName) name = scene.name;
|
||||||
if (settings.displaySceneIcon) src = scene.img;
|
if (settings.displaySceneIcon) src = scene.img;
|
||||||
if (scene.active) name += "\n(Active)";
|
if (scene.active) name += "\n(Active)";
|
||||||
}
|
}
|
||||||
streamDeck.setTitle(name,context);
|
|
||||||
streamDeck.setIcon(1, context,src,background,ring,ringColor);
|
|
||||||
}
|
}
|
||||||
|
streamDeck.setTitle(name,context);
|
||||||
|
streamDeck.setIcon(1, context,src,background,2,ringColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
keyPressScene(settings){
|
keyPressScene(settings){
|
||||||
@@ -176,10 +188,10 @@ export class OtherControls{
|
|||||||
if (scene.isView) scene.activate();
|
if (scene.isView) scene.activate();
|
||||||
scene.view();
|
scene.view();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
updateControl(settings,context){
|
updateControl(settings,context){
|
||||||
@@ -189,27 +201,42 @@ export class OtherControls{
|
|||||||
let tool = settings.tool;
|
let tool = settings.tool;
|
||||||
if (tool == undefined) tool = 0;
|
if (tool == undefined) tool = 0;
|
||||||
|
|
||||||
|
let background = settings.background;
|
||||||
|
if (background == undefined) background = '#000000';
|
||||||
|
|
||||||
|
let ringColor = '#000000'
|
||||||
|
|
||||||
const controlName = this.getControlName(control);
|
const controlName = this.getControlName(control);
|
||||||
const toolName = this.getToolName(control,tool);
|
const toolName = this.getToolName(control,tool);
|
||||||
|
|
||||||
let txt = "";
|
let txt = "";
|
||||||
let src = "";
|
let src = "";
|
||||||
let background = "#000000";
|
const activeControl = ui.controls.activeControl;
|
||||||
let ringColor = "#FF7B00"
|
const activeTool = ui.controls.activeTool;
|
||||||
let selectedControl;
|
|
||||||
let selectedTool;
|
|
||||||
let ring = 1;
|
|
||||||
let activeControl = ui.controls.activeControl;
|
|
||||||
let activeTool = ui.controls.activeTool;
|
|
||||||
|
|
||||||
if (control == 0){
|
if (control == 0) { //displayed controls
|
||||||
let controlNr = parseInt(settings.controlNr);
|
let controlNr = parseInt(settings.controlNr);
|
||||||
if (isNaN(controlNr)) controlNr = 1;
|
if (isNaN(controlNr)) controlNr = 1;
|
||||||
controlNr--;
|
controlNr--;
|
||||||
|
|
||||||
selectedControl = ui.controls.controls.find(c => c.name == ui.controls.activeControl);
|
const selectedControl = ui.controls.controls[controlNr];
|
||||||
if (selectedControl != undefined){
|
if (selectedControl != undefined){
|
||||||
selectedTool = selectedControl.tools[controlNr];
|
if (tool == 0){ //open category
|
||||||
|
txt = game.i18n.localize(selectedControl.title);
|
||||||
|
src = selectedControl.icon;
|
||||||
|
if (activeControl == selectedControl.name)
|
||||||
|
ringColor = "#FF7B00";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (control == 1){ //displayed tools
|
||||||
|
let controlNr = parseInt(settings.controlNr);
|
||||||
|
if (isNaN(controlNr)) controlNr = 1;
|
||||||
|
controlNr--;
|
||||||
|
|
||||||
|
const selectedControl = ui.controls.controls.find(c => c.name == ui.controls.activeControl);
|
||||||
|
if (selectedControl != undefined){
|
||||||
|
const selectedTool = selectedControl.tools[controlNr];
|
||||||
if (selectedTool != undefined){
|
if (selectedTool != undefined){
|
||||||
txt = game.i18n.localize(selectedTool.title);
|
txt = game.i18n.localize(selectedTool.title);
|
||||||
src = selectedTool.icon;
|
src = selectedTool.icon;
|
||||||
@@ -218,25 +245,24 @@ export class OtherControls{
|
|||||||
if (selectedTool.active)
|
if (selectedTool.active)
|
||||||
ringColor = "#A600FF"
|
ringColor = "#A600FF"
|
||||||
else
|
else
|
||||||
ringColor = "#340057"
|
ringColor = "#340057";
|
||||||
ring = 2;
|
|
||||||
}
|
}
|
||||||
else if (activeTool == selectedTool.name)
|
else if (activeTool == selectedTool.name)
|
||||||
ring = 2;
|
ringColor = "#FF7B00";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else { // specific control/tool
|
||||||
selectedControl = ui.controls.controls.find(c => c.name == controlName);
|
const selectedControl = ui.controls.controls.find(c => c.name == controlName);
|
||||||
if (selectedControl != undefined){
|
if (selectedControl != undefined){
|
||||||
if (tool == 0){ //open category
|
if (tool == 0){ //open category
|
||||||
txt = game.i18n.localize(selectedControl.title);
|
txt = game.i18n.localize(selectedControl.title);
|
||||||
src = selectedControl.icon;
|
src = selectedControl.icon;
|
||||||
if (activeControl == selectedControl.name)
|
if (activeControl == selectedControl.name)
|
||||||
ring = 2;
|
ringColor = "#FF7B00";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
selectedTool = selectedControl.tools.find(t => t.name == toolName);
|
const selectedTool = selectedControl.tools.find(t => t.name == toolName);
|
||||||
if (selectedTool != undefined){
|
if (selectedTool != undefined){
|
||||||
txt = game.i18n.localize(selectedTool.title);
|
txt = game.i18n.localize(selectedTool.title);
|
||||||
src = selectedTool.icon;
|
src = selectedTool.icon;
|
||||||
@@ -246,15 +272,14 @@ export class OtherControls{
|
|||||||
ringColor = "#A600FF"
|
ringColor = "#A600FF"
|
||||||
else
|
else
|
||||||
ringColor = "#340057"
|
ringColor = "#340057"
|
||||||
ring = 2;
|
|
||||||
}
|
}
|
||||||
else if (activeTool == selectedTool.name && activeControl == selectedControl.name)
|
else if (activeTool == selectedTool.name && activeControl == selectedControl.name)
|
||||||
ring = 2;
|
ringColor = "#FF7B00";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
streamDeck.setIcon(1,context,src,background,ring,ringColor);
|
streamDeck.setIcon(1,context,src,background,2,ringColor);
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,29 +293,37 @@ export class OtherControls{
|
|||||||
const controlName = this.getControlName(control);
|
const controlName = this.getControlName(control);
|
||||||
const toolName = this.getToolName(control,tool);
|
const toolName = this.getToolName(control,tool);
|
||||||
|
|
||||||
if (control == 0){ //displayed tools
|
if (control == 0){ //displayed controls
|
||||||
let controlNr = parseInt(settings.controlNr);
|
let controlNr = parseInt(settings.controlNr);
|
||||||
if (isNaN(controlNr)) controlNr = 1;
|
if (isNaN(controlNr)) controlNr = 1;
|
||||||
controlNr--;
|
controlNr--;
|
||||||
let selectedControl = ui.controls.controls.find(c => c.name == ui.controls.activeControl);
|
const selectedControl = ui.controls.controls[controlNr];
|
||||||
if (selectedControl != undefined){
|
if (selectedControl != undefined){
|
||||||
let selectedTool = selectedControl.tools[controlNr];
|
ui.controls.activeControl = controlName;
|
||||||
|
selectedControl.activeTool = selectedControl.activeTool;
|
||||||
|
canvas.getLayer(selectedControl.layer).activate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (control == 1){ //displayed tools
|
||||||
|
let controlNr = parseInt(settings.controlNr);
|
||||||
|
if (isNaN(controlNr)) controlNr = 1;
|
||||||
|
controlNr--;
|
||||||
|
const selectedControl = ui.controls.controls.find(c => c.name == ui.controls.activeControl);
|
||||||
|
if (selectedControl != undefined){
|
||||||
|
const selectedTool = selectedControl.tools[controlNr];
|
||||||
if (selectedTool != undefined){
|
if (selectedTool != undefined){
|
||||||
if (selectedTool.toggle){
|
if (selectedTool.toggle)
|
||||||
let newValue = !selectedTool.active;
|
selectedTool.active = !selectedTool.active;
|
||||||
selectedTool.active = newValue;
|
|
||||||
}
|
|
||||||
else if (selectedTool.button){
|
else if (selectedTool.button){
|
||||||
selectedTool.onClick();
|
selectedTool.onClick();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
selectedControl.activeTool = selectedTool.name;
|
selectedControl.activeTool = selectedTool.name;
|
||||||
ui.controls.render();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { //select control
|
else { //select control
|
||||||
let selectedControl = ui.controls.controls.find(c => c.name == controlName);
|
const selectedControl = ui.controls.controls.find(c => c.name == controlName);
|
||||||
if (selectedControl != undefined){
|
if (selectedControl != undefined){
|
||||||
if (tool == 0){ //open category
|
if (tool == 0){ //open category
|
||||||
ui.controls.activeControl = controlName;
|
ui.controls.activeControl = controlName;
|
||||||
@@ -298,14 +331,12 @@ export class OtherControls{
|
|||||||
canvas.getLayer(selectedControl.layer).activate();
|
canvas.getLayer(selectedControl.layer).activate();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let selectedTool = selectedControl.tools.find(t => t.name == toolName);
|
const selectedTool = selectedControl.tools.find(t => t.name == toolName);
|
||||||
if (selectedTool != undefined){
|
if (selectedTool != undefined){
|
||||||
ui.controls.activeControl = controlName;
|
ui.controls.activeControl = controlName;
|
||||||
canvas.getLayer(selectedControl.layer).activate();
|
canvas.getLayer(selectedControl.layer).activate();
|
||||||
if (selectedTool.toggle){
|
if (selectedTool.toggle)
|
||||||
let newValue = !selectedTool.active;
|
selectedTool.active = !selectedTool.active;
|
||||||
selectedTool.active = newValue;
|
|
||||||
}
|
|
||||||
else if (selectedTool.button){
|
else if (selectedTool.button){
|
||||||
selectedTool.onClick();
|
selectedTool.onClick();
|
||||||
}
|
}
|
||||||
@@ -313,21 +344,13 @@ export class OtherControls{
|
|||||||
selectedControl.activeTool = toolName;
|
selectedControl.activeTool = toolName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ui.controls.render();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ui.controls.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//ui.controls.controls.find(c => c.name == 'token')
|
|
||||||
//ui.controls.controls.find(c => c.name == 'walls').tools.find(t => t.name == 'snap').active=false
|
|
||||||
//ui.controls.render()
|
|
||||||
|
|
||||||
getControlName(control){
|
getControlName(control){
|
||||||
control--;
|
control -= 2;
|
||||||
let name;
|
let name;
|
||||||
if (control == 0) name = 'token';
|
if (control == 0) name = 'token';
|
||||||
else if (control == 1) name = 'measure';
|
else if (control == 1) name = 'measure';
|
||||||
@@ -341,7 +364,7 @@ export class OtherControls{
|
|||||||
}
|
}
|
||||||
|
|
||||||
getToolName(control,tool){
|
getToolName(control,tool){
|
||||||
control--;
|
control -= 2;
|
||||||
tool--;
|
tool--;
|
||||||
let name;
|
let name;
|
||||||
if (control == 0){ //basic controls
|
if (control == 0){ //basic controls
|
||||||
|
|||||||
@@ -31,8 +31,17 @@ export class PlaylistControl{
|
|||||||
|
|
||||||
updatePlaylist(settings,context){
|
updatePlaylist(settings,context){
|
||||||
let name = "";
|
let name = "";
|
||||||
let src = 'action/images/Black.png';
|
|
||||||
let background = '#000000';
|
let background = settings.background;
|
||||||
|
if(background == undefined) background = '#000000';
|
||||||
|
|
||||||
|
let ringColor = "#000000"
|
||||||
|
|
||||||
|
let ringOffColor = settings.offRing;
|
||||||
|
if (ringOffColor == undefined) ringOffColor = '#FF0000';
|
||||||
|
|
||||||
|
let ringOnColor = settings.onRing;
|
||||||
|
if (ringOnColor == undefined) ringOnColor = '#00FF00';
|
||||||
|
|
||||||
let playlistType = settings.playlistType;
|
let playlistType = settings.playlistType;
|
||||||
if (playlistType == undefined) playlistType = 0;
|
if (playlistType == undefined) playlistType = 0;
|
||||||
@@ -44,47 +53,39 @@ export class PlaylistControl{
|
|||||||
playlistNr--;
|
playlistNr--;
|
||||||
playlistNr += this.playlistOffset;
|
playlistNr += this.playlistOffset;
|
||||||
|
|
||||||
let playBackground = settings.playBackground;
|
|
||||||
if (playBackground == undefined) playBackground == '#00FF00';
|
|
||||||
let stopBackground = settings.stopBackground;
|
|
||||||
if (stopBackground == undefined) stopBackground == '#FF0000';
|
|
||||||
|
|
||||||
let playlist = this.getPlaylist(playlistNr);
|
let playlist = this.getPlaylist(playlistNr);
|
||||||
if (playlist != undefined){
|
if (playlist != undefined){
|
||||||
if (playlist.playing) {
|
if (playlist.playing)
|
||||||
background = playBackground;
|
ringColor = ringOnColor;
|
||||||
src = 'action/images/playlist/stop.png';
|
else
|
||||||
}
|
ringColor = ringOffColor;
|
||||||
else {
|
|
||||||
background = stopBackground;
|
|
||||||
src = 'action/images/playlist/play.png';
|
|
||||||
}
|
|
||||||
if (settings.displayName)
|
if (settings.displayName)
|
||||||
name = playlist.name;
|
name = playlist.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//Offset
|
//Offset
|
||||||
else {
|
else {
|
||||||
src = "";
|
|
||||||
let onBackground = settings.onBackground;
|
|
||||||
if (onBackground == undefined) onBackground = '#00FF00';
|
|
||||||
let offBackground = settings.offBackground;
|
|
||||||
if (offBackground == undefined) offBackground = '#000000';
|
|
||||||
|
|
||||||
let playlistOffset = parseInt(settings.offset);
|
let playlistOffset = parseInt(settings.offset);
|
||||||
if (isNaN(playlistOffset)) playlistOffset = 0;
|
if (isNaN(playlistOffset)) playlistOffset = 0;
|
||||||
if (playlistOffset == this.playlistOffset) background = onBackground;
|
if (playlistOffset == this.playlistOffset) ringColor = ringOnColor;
|
||||||
else background = offBackground;
|
|
||||||
}
|
}
|
||||||
streamDeck.setIcon(0,context,src,background);
|
streamDeck.setIcon(0,context,"",background,2,ringColor);
|
||||||
streamDeck.setTitle(name,context);
|
streamDeck.setTitle(name,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTrack(settings,context){
|
updateTrack(settings,context){
|
||||||
let name = "";
|
let name = "";
|
||||||
let src = 'action/images/Black.png';
|
|
||||||
let background = '#000000';
|
let background = settings.background;
|
||||||
|
if(background == undefined) background = '#000000';
|
||||||
|
|
||||||
|
let ringColor = "#000000"
|
||||||
|
|
||||||
|
let ringOffColor = settings.offRing;
|
||||||
|
if (ringOffColor == undefined) ringOffColor = '#FF0000';
|
||||||
|
|
||||||
|
let ringOnColor = settings.onRing;
|
||||||
|
if (ringOnColor == undefined) ringOnColor = '#00FF00';
|
||||||
|
|
||||||
let playlistType = settings.playlistType;
|
let playlistType = settings.playlistType;
|
||||||
if (playlistType == undefined) playlistType = 0;
|
if (playlistType == undefined) playlistType = 0;
|
||||||
@@ -100,43 +101,26 @@ export class PlaylistControl{
|
|||||||
trackNr--;
|
trackNr--;
|
||||||
trackNr += this.trackOffset;
|
trackNr += this.trackOffset;
|
||||||
|
|
||||||
let playBackground = settings.playBackground;
|
|
||||||
if (playBackground == undefined) playBackground == '#00FF00';
|
|
||||||
let stopBackground = settings.stopBackground;
|
|
||||||
if (stopBackground == undefined) stopBackground == '#FF0000';
|
|
||||||
|
|
||||||
let playlist = this.getPlaylist(playlistNr);
|
let playlist = this.getPlaylist(playlistNr);
|
||||||
if (playlist != undefined){
|
if (playlist != undefined){
|
||||||
let track = playlist.data.sounds[trackNr];
|
let track = playlist.data.sounds[trackNr];
|
||||||
if (track != undefined){
|
if (track != undefined){
|
||||||
if (track.playing) {
|
if (track.playing)
|
||||||
background = playBackground;
|
ringColor = ringOnColor;
|
||||||
src = 'action/images/playlist/stop.png';
|
else
|
||||||
}
|
ringColor = ringOffColor;
|
||||||
else {
|
|
||||||
background = stopBackground;
|
|
||||||
src = 'action/images/playlist/play.png';
|
|
||||||
}
|
|
||||||
if (settings.displayName)
|
if (settings.displayName)
|
||||||
name = track.name;
|
name = track.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//Offset
|
//Offset
|
||||||
else {
|
else {
|
||||||
src = "";
|
|
||||||
let onBackground = settings.onBackground;
|
|
||||||
if (onBackground == undefined) onBackground = '#00FF00';
|
|
||||||
let offBackground = settings.offBackground;
|
|
||||||
if (offBackground == undefined) offBackground = '#000000';
|
|
||||||
|
|
||||||
let trackOffset = parseInt(settings.offset);
|
let trackOffset = parseInt(settings.offset);
|
||||||
if (isNaN(trackOffset)) trackOffset = 0;
|
if (isNaN(trackOffset)) trackOffset = 0;
|
||||||
if (trackOffset == this.trackOffset) background = onBackground;
|
if (trackOffset == this.trackOffset) ringColor = ringOnColor;
|
||||||
else background = offBackground;
|
|
||||||
}
|
}
|
||||||
streamDeck.setIcon(0,context,src,background);
|
streamDeck.setIcon(0,context,"",background,2,ringColor);
|
||||||
streamDeck.setTitle(name,context);
|
streamDeck.setTitle(name,context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,11 @@ export class SoundboardControl{
|
|||||||
|
|
||||||
let txt = "";
|
let txt = "";
|
||||||
let src = "";
|
let src = "";
|
||||||
let background = "#000000";
|
|
||||||
|
let background = settings.background;
|
||||||
|
if (background == undefined) background = '#000000';
|
||||||
|
|
||||||
|
let ringColor = "#000000"
|
||||||
|
|
||||||
if (mode == 0){ //play sound
|
if (mode == 0){ //play sound
|
||||||
let soundNr = parseInt(settings.soundNr);
|
let soundNr = parseInt(settings.soundNr);
|
||||||
@@ -33,37 +37,33 @@ export class SoundboardControl{
|
|||||||
|
|
||||||
let soundboardSettings = game.settings.get(MODULE.moduleName, 'soundboardSettings');
|
let soundboardSettings = game.settings.get(MODULE.moduleName, 'soundboardSettings');
|
||||||
|
|
||||||
let onColor = soundboardSettings.colorOn[soundNr];
|
if (this.activeSounds[soundNr]==false)
|
||||||
let offColor = soundboardSettings.colorOff[soundNr];
|
ringColor = soundboardSettings.colorOff[soundNr];
|
||||||
|
else
|
||||||
|
ringColor = soundboardSettings.colorOn[soundNr];
|
||||||
|
|
||||||
background = onColor;
|
|
||||||
let ring = 2;
|
|
||||||
if (this.activeSounds[soundNr]==false) {
|
|
||||||
background = offColor;
|
|
||||||
ring = 1;
|
|
||||||
}
|
|
||||||
if (settings.displayName) txt = soundboardSettings.name[soundNr];
|
if (settings.displayName) txt = soundboardSettings.name[soundNr];
|
||||||
if (settings.displayIcon) src = soundboardSettings.img[soundNr];
|
if (settings.displayIcon) src = soundboardSettings.img[soundNr];
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
streamDeck.setIcon(1,context,src,background,ring,background);
|
streamDeck.setIcon(1,context,src,background,2,ringColor);
|
||||||
}
|
}
|
||||||
else if (mode == 1) { //Offset
|
else if (mode == 1) { //Offset
|
||||||
src = "";
|
let ringOffColor = settings.offRing;
|
||||||
let onBackground = settings.onBackground;
|
if (ringOffColor == undefined) ringOffColor = '#000000';
|
||||||
if (onBackground == undefined) onBackground = '#00FF00';
|
|
||||||
let offBackground = settings.offBackground;
|
let ringOnColor = settings.onRing;
|
||||||
if (offBackground == undefined) offBackground = '#000000';
|
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) background = onBackground;
|
if (offset == this.offset) ringColor = ringOnColor;
|
||||||
else background = offBackground;
|
else ringColor = ringOffColor;
|
||||||
streamDeck.setTitle(txt,context);
|
streamDeck.setTitle(txt,context);
|
||||||
streamDeck.setIcon(1,context,src,background);
|
streamDeck.setIcon(1,context,"",background,2,ringColor);
|
||||||
}
|
}
|
||||||
else if (mode == 2) { //Stop all sounds
|
else if (mode == 2) { //Stop all sounds
|
||||||
let src = 'action/images/soundboard/stop.png';
|
let src = 'action/images/soundboard/stop.png';
|
||||||
streamDeck.setIcon(0,context,src,settings.background);
|
streamDeck.setIcon(0,context,src,background);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -180,7 +180,6 @@ export class StreamDeck{
|
|||||||
var content = window.getComputedStyle(
|
var content = window.getComputedStyle(
|
||||||
elm, ':before'
|
elm, ':before'
|
||||||
).getPropertyValue('content')
|
).getPropertyValue('content')
|
||||||
//console.log(elm);
|
|
||||||
document.body.removeChild(elm);
|
document.body.removeChild(elm);
|
||||||
return content;
|
return content;
|
||||||
};
|
};
|
||||||
@@ -188,7 +187,7 @@ export class StreamDeck{
|
|||||||
getImage(data){
|
getImage(data){
|
||||||
if (data == undefined)
|
if (data == undefined)
|
||||||
return;
|
return;
|
||||||
console.log('image',data)
|
//console.log('image',data)
|
||||||
const context = data.context;
|
const context = data.context;
|
||||||
var url = data.url;
|
var url = data.url;
|
||||||
const format = data.format;
|
const format = data.format;
|
||||||
@@ -246,14 +245,15 @@ export class StreamDeck{
|
|||||||
var content = window.getComputedStyle(
|
var content = window.getComputedStyle(
|
||||||
elm, ':before'
|
elm, ':before'
|
||||||
).getPropertyValue('content')
|
).getPropertyValue('content')
|
||||||
//console.log(content[1]);
|
|
||||||
canvas.removeChild(elm);
|
canvas.removeChild(elm);
|
||||||
ctx.fillText(content[1], 35, 105);
|
const iconMeasurement = ctx.measureText(content[1]);
|
||||||
|
const horOffset = (144-iconMeasurement.width)/2;
|
||||||
|
const vertOffset = 144-(iconMeasurement.actualBoundingBoxAscent-iconMeasurement.actualBoundingBoxDescent)/2;
|
||||||
|
ctx.fillText(content[1], horOffset, vertOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (format != 'jpg' && format != 'jpeg' && format != 'png' && format != 'webm' && format != 'webp' && format != 'gif' && format != 'svg') url = "modules/MaterialDeck/img/transparant.png";
|
if (format != 'jpg' && format != 'jpeg' && format != 'png' && format != 'webm' && format != 'webp' && format != 'gif' && format != 'svg') url = "modules/MaterialDeck/img/transparant.png";
|
||||||
if (url == "") url = "modules/MaterialDeck/img/transparant.png"
|
if (url == "") url = "modules/MaterialDeck/img/transparant.png"
|
||||||
//console.log(url);
|
|
||||||
let resImageURL = url;
|
let resImageURL = url;
|
||||||
|
|
||||||
let img = new Image();
|
let img = new Image();
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ export class TokenControl{
|
|||||||
}
|
}
|
||||||
|
|
||||||
async update(tokenId){
|
async update(tokenId){
|
||||||
console.log('tokenId',tokenId)
|
|
||||||
for (let i=0; i<32; i++){
|
for (let i=0; i<32; i++){
|
||||||
let data = streamDeck.buttonContext[i];
|
let data = streamDeck.buttonContext[i];
|
||||||
if (data == undefined || data.action != 'token') continue;
|
if (data == undefined || data.action != 'token') continue;
|
||||||
@@ -15,7 +14,6 @@ export class TokenControl{
|
|||||||
}
|
}
|
||||||
|
|
||||||
pushData(tokenId,settings,context,ring=0,ringColor='#000000'){
|
pushData(tokenId,settings,context,ring=0,ringColor='#000000'){
|
||||||
console.log('tk',tokenId,settings)
|
|
||||||
let name = false;
|
let name = false;
|
||||||
let icon = false;
|
let icon = false;
|
||||||
let type = 0;
|
let type = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user