12 Commits

Author SHA1 Message Date
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
52 changed files with 1708 additions and 705 deletions

View File

@@ -7,6 +7,8 @@ import {CombatTracker} from "./src/combattracker.js";
import {PlaylistControl} from "./src/playlist.js";
import {SoundboardControl} from "./src/soundboard.js";
import {OtherControls} from "./src/othercontrols.js";
import {ExternalModules} from "./src/external.js";
import {SceneControl} from "./src/scene.js";
export var streamDeck;
export var tokenControl;
var move;
@@ -15,6 +17,8 @@ export var combatTracker;
export var playlistControl;
export var soundboard;
export var otherControls;
export var externalModules;
export var sceneControl;
export const moduleName = "MaterialDeck";
export var selectedTokenId;
@@ -36,6 +40,8 @@ let wsOpen = false; //Bool for checking if websocket has ever been o
let wsInterval; //Interval timer to detect disconnections
let WSconnected = false;
//let furnace = game.modules.get("furnace");
/*
* Analyzes the message received
*
@@ -47,7 +53,19 @@ async function analyzeWSmessage(msg){
//console.log("Received",data);
if (data.type == "connected" && data.data == "SD"){
/*
console.log(data);
const minimumSDversion = game.modules.get("MaterialDeck").data.minimumSDversion.replace('v','');
const minimumMSversion = game.modules.get("MaterialDeck").data.minimumMSversion;
console.log('SD',minimumSDversion,minimumMSversion)
if (data.SDversion < minimumSDversion) console.log('SD: nope')
else console.log('SD: yes');
if (data.MSversion < minimumMSversion) console.log('MS: nope')
else console.log('MS: yes');
*/
console.log("streamdeck connected to server");
streamDeck.resetImageBuffer();
}
if (data == undefined || data.payload == undefined) return;
@@ -82,6 +100,10 @@ async function analyzeWSmessage(msg){
soundboard.update(settings,context);
else if (action == 'other')
otherControls.update(settings,context);
else if (action == 'external')
externalModules.update(settings,context);
else if (action == 'scene')
sceneControl.update(settings,context);
}
else if (event == 'willDisappear'){
@@ -102,7 +124,11 @@ async function analyzeWSmessage(msg){
else if (action == 'soundboard')
soundboard.keyPressDown(settings);
else if (action == 'other')
otherControls.keyPress(settings);
otherControls.keyPress(settings,context);
else if (action == 'external')
externalModules.keyPress(settings,context);
else if (action == 'scene')
sceneControl.keyPress(settings);
}
else if (event == 'keyUp'){
@@ -120,7 +146,10 @@ async function analyzeWSmessage(msg){
*/
function startWebsocket() {
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){
//console.log(msg);
@@ -203,7 +232,8 @@ Hooks.once('ready', ()=>{
combatTracker = new CombatTracker();
playlistControl = new PlaylistControl();
otherControls = new OtherControls();
externalModules = new ExternalModules();
sceneControl = new SceneControl();
let soundBoardSettings = game.settings.get(moduleName,'soundboardSettings');
let macroSettings = game.settings.get(moduleName, 'macroSettings');
@@ -287,18 +317,18 @@ Hooks.on('controlToken',(token,controlled)=>{
Hooks.on('renderHotbar', (hotbar)=>{
if (enableModule == false || ready == false) return;
macroControl.hotbar(hotbar.macros);
if (macroControl != undefined) macroControl.hotbar(hotbar.macros);
});
Hooks.on('renderCombatTracker',()=>{
if (enableModule == false || ready == false) return;
combatTracker.updateAll();
tokenControl.update(selectedTokenId);
if (combatTracker != undefined) combatTracker.updateAll();
if (tokenControl != undefined) tokenControl.update(selectedTokenId);
});
Hooks.on('renderPlaylistDirectory', (playlistDirectory)=>{
if (enableModule == false || ready == false) return;
playlistControl.updateAll();
if (playlistControl != undefined) playlistControl.updateAll();
});
Hooks.on('closeplaylistConfigForm', (form)=>{
@@ -314,16 +344,19 @@ Hooks.on('pauseGame',()=>{
Hooks.on('renderSidebarTab',()=>{
if (enableModule == false || ready == false) return;
otherControls.updateAll();
if (otherControls != undefined) otherControls.updateAll();
if (sceneControl != undefined) sceneControl.updateAll();
});
Hooks.on('updateScene',()=>{
if (enableModule == false || ready == false) return;
sceneControl.updateAll();
externalModules.updateAll();
otherControls.updateAll();
});
Hooks.on('renderSceneControls',()=>{
if (enableModule == false || ready == false) return;
if (enableModule == false || ready == false || otherControls == undefined) return;
otherControls.updateAll();
});
@@ -357,6 +390,11 @@ Hooks.on('closeJournalSheet',()=>{
otherControls.updateAll();
});
Hooks.on('gmScreenOpenClose',(html,isOpen)=>{
if (enableModule == false || ready == false) return;
externalModules.updateAll({gmScreen:isOpen});
});
Hooks.once('init', ()=>{
//CONFIG.debug.hooks = true;
registerSettings(); //in ./src/settings.js

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
## 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>
## 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>
<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.
## 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>

View File

@@ -1,18 +1,100 @@
# Changelog Material Deck Module
### 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
Fixes
<ul>
<li>Settings would not show for Combat Tracker action</li>
<li>Macro Action => Macro Board default settings fixed</li>
<li>API has been improved, making integration with other hardware/software easier, and making future changes/additions easier</li>
</ul>
Additions/changes:
Additions:
<ul>
<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>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>API has been improved, making integration with other hardware/software easier, and making future changes/additions easier</li>
<li>Moved default images to Foundry module side instead of Stream Deck plugin</li>
</ul>
<b>Compatible server app and SD plugin:</b><br>

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 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

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

BIN
img/other/cogs.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 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

View File

@@ -9,11 +9,14 @@
"MaterialDeck.Sett.Model_Mini": "Mini",
"MaterialDeck.Sett.Model_Normal": "Normal or Mobile",
"MaterialDeck.Sett.Model_XL": "XL",
"MaterialDeck.Sett.Help": "Help",
"MaterialDeck.Sett.PlaylistConfig": "Playlist Configuration",
"MaterialDeck.Sett.MacroConfig": "Macro Configuration",
"MaterialDeck.Sett.SoundboardConfig": "Soundboard Configuration",
"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 (EXPERIMENTAL)",
"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.PL.Unrestricted": "Unrestricted",
"MaterialDeck.PL.OneTrackPlaylist": "One track per playlist",
@@ -40,6 +43,9 @@
"MaterialDeck.Off": "Off",
"MaterialDeck.Name": "Name",
"MaterialDeck.None": "None",
"MaterialDeck.Save": "Save"
"MaterialDeck.Save": "Save",
"MaterialDeck.FxMaster.Colorize": "Colorize",
"MaterialDeck.FxMaster.Clear": "Clear All"
}

View File

@@ -2,14 +2,16 @@
"name": "MaterialDeck",
"title": "Material Deck",
"description": "Material Deck allows you to control Foundry using an Elgato Stream Deck",
"version": "1.1.0",
"version": "1.2.3",
"minimumSDversion": "1.2.2",
"minimumMSversion": "1.0.2",
"author": "CDeenen",
"esmodules": [
"./MaterialDeck.js"
],
"socket": true,
"minimumCoreVersion": "0.7.5",
"compatibleCoreVersion": "0.7.8",
"compatibleCoreVersion": "0.7.9",
"languages": [
{
"lang": "en",

View File

@@ -10,7 +10,7 @@ export class CombatTracker{
async updateAll(){
if (this.active == false) return;
for (let i=0; i<32; i++){
let data = streamDeck.buttonContext[i];
const data = streamDeck.buttonContext[i];
if (data == undefined || data.action != 'combattracker') continue;
await this.update(data.settings,data.context);
}
@@ -18,28 +18,23 @@ export class CombatTracker{
update(settings,context){
this.active = true;
let ctFunction = settings.combatTrackerFunction;
if (ctFunction == undefined) ctFunction == 'startStop';
let combat = game.combat;
const ctFunction = settings.combatTrackerFunction ? settings.combatTrackerFunction : 'startStop';
const mode = settings.combatTrackerMode ? settings.combatTrackerMode : 'combatants';
const combat = game.combat;
let src = "modules/MaterialDeck/img/black.png";
let txt = "";
let background = "#000000";
let mode = settings.combatTrackerMode;
if (mode == undefined) mode = 'combatants';
if (mode == 'combatants'){
if (combat != null && combat != undefined && combat.turns.length != 0){
let initiativeOrder = combat.turns;
const initiativeOrder = combat.turns;
let nr = settings.combatantNr - 1;
if (nr == undefined || nr < 1) nr = 0;
let combatantState = 1;
if (nr == combat.turn) combatantState = 2;
let combatant = initiativeOrder[nr]
const combatantState = (nr == combat.turn) ? 2 : 1;
const combatant = initiativeOrder[nr]
if (combatant != undefined){
let tokenId = combatant.tokenId;
const tokenId = combatant.tokenId;
tokenControl.pushData(tokenId,settings,context,combatantState,'#cccc00');
return;
}
@@ -55,7 +50,7 @@ export class CombatTracker{
}
else if (mode == 'currentCombatant'){
if (combat != null && combat != undefined && combat.started){
let tokenId = combat.combatant.tokenId;
const tokenId = combat.combatant.tokenId;
tokenControl.pushData(tokenId,settings,context);
}
else {
@@ -64,7 +59,6 @@ export class CombatTracker{
}
}
else if (mode == 'function'){
if (ctFunction == 'startStop') {
if (combat == null || combat == undefined || combat.combatants.length == 0) {
src = "modules/MaterialDeck/img/combattracker/startcombat.png";
@@ -111,15 +105,12 @@ export class CombatTracker{
}
keyPress(settings,context){
let mode = settings.combatTrackerMode;
if (mode == undefined) mode = 'combatants';
if (mode == 'function'){
let combat = game.combat;
if (combat == null || combat == undefined) return;
const mode = settings.combatTrackerMode ? settings.combatTrackerMode : 'combatants';
const combat = game.combat;
let ctFunction = settings.combatTrackerFunction;
if (ctFunction == undefined) ctFunction == 'startStop';
if (mode == 'function'){
if (combat == null || combat == undefined) return;
const ctFunction = settings.combatTrackerFunction ? settings.combatTrackerFunction : 'startStop';
if (ctFunction == 'startStop'){
let src;
let background;
@@ -144,19 +135,14 @@ export class CombatTracker{
else if (ctFunction == 'prevRound') game.combat.previousRound();
}
else {
let onClick = settings.onClick;
if (onClick == undefined) onClick = 'doNothing';
const onClick = settings.onClick ? settings.onClick : 'doNothing';
let tokenId;
let combat = game.combat;
if (mode == 'combatants') {
if (combat != null && combat != undefined && combat.turns.length != 0){
let initiativeOrder = combat.turns;
const initiativeOrder = combat.turns;
let nr = settings.combatantNr - 1;
if (nr == undefined || nr < 1) nr = 0;
let combatantState = 1;
if (nr == combat.turn) combatantState = 2;
let combatant = initiativeOrder[nr]
const combatant = initiativeOrder[nr]
if (combatant == undefined) return;
tokenId = combatant.tokenId;
}
@@ -165,8 +151,7 @@ export class CombatTracker{
if (combat != null && combat != undefined && combat.started)
tokenId = combat.combatant.tokenId;
let token
if (canvas.tokens.children[0] != undefined) token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
let token = (canvas.tokens.children[0] != undefined) ? canvas.tokens.children[0].children.find(p => p.id == tokenId) : undefined;
if (token == undefined) return;
if (onClick == 'doNothing') //Do nothing
return;
@@ -178,7 +163,7 @@ export class CombatTracker{
canvas.animatePan(location);
}
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);
token.control();
}

270
src/external.js Normal file
View File

@@ -0,0 +1,270 @@
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 i=0; i<32; i++){
const data = streamDeck.buttonContext[i];
if (data == undefined || data.action != 'external') continue;
await this.update(data.settings,data.context);
}
}
update(settings,context){
this.active = true;
const module = settings.module ? settings.module : 'fxmaster';
if (module == 'fxmaster') this.updateFxMaster(settings,context);
else if (module == 'gmscreen') this.updateGMScreen(settings,context);
}
keyPress(settings,context){
if (this.active == false) return;
const module = settings.module ? settings.module : 'fxmaster';
if (module == 'fxmaster')
this.keyPressFxMaster(settings,context);
else if (module == 'gmscreen')
this.keyPressGMScreen(settings,context);
}
getModuleEnable(moduleId){
const module = game.modules.get(moduleId);
if (module == undefined || module.active == false) return false;
return true;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//FxMaster
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
updateFxMaster(settings,context){
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,icon,background,ring,ringColor);
else streamDeck.setIcon(context, "", background,ring,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){
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){
if (this.getModuleEnable("gm-screen") == 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,src,background,ring,ringColor);
if (settings.displayGmScreenName) txt = game.i18n.localize(`GMSCR.gmScreen.Open`);
streamDeck.setTitle(txt,context);
}
keyPressGMScreen(settings,context){
if (this.getModuleEnable("gm-screen") == false) return;
window['gm-screen'].toggleGmScreenVisibility();
}
}

View File

@@ -10,7 +10,7 @@ export class MacroControl{
async updateAll(){
if (this.active == false) return;
for (let i=0; i<32; i++){
let data = streamDeck.buttonContext[i];
const data = streamDeck.buttonContext[i];
if (data == undefined || data.action != 'macro') continue;
await this.update(data.settings,data.context);
}
@@ -18,75 +18,61 @@ export class MacroControl{
update(settings,context){
this.active = true;
let mode = settings.macroMode;
let displayName = settings.displayName;
const mode = settings.macroMode ? settings.macroMode : 'hotbar';
const displayName = settings.displayName ? settings.displayName : false;
const displayIcon = settings.displayIcon ? settings.displayIcon : false;
let background = settings.background ? settings.background : '#000000';
let macroNumber = settings.macroNumber;
let background = settings.background;
let icon = false;
if (settings.displayIcon) icon = true;
if (macroNumber == undefined || isNaN(parseInt(macroNumber))) macroNumber = 0;
macroNumber = parseInt(macroNumber);
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);
let name = "";
let src = "";
if (mode == 'macroBoard') { //Macro board
let name = "";
let src = '';
if (settings.macroBoardMode == 'offset') { //Offset
let ringOffColor = settings.offRing;
if (ringOffColor == undefined) ringOffColor = '#000000';
let ringOnColor = settings.onRing;
if (ringOnColor == undefined) ringOnColor = '#00FF00';
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
let macroOffset = parseInt(settings.macroOffset);
if (macroOffset == undefined || isNaN(macroOffset)) macroOffset = 0;
if (macroOffset == parseInt(this.offset)) ringColor = ringOnColor;
else ringColor = ringOffColor;
ringColor = (macroOffset == parseInt(this.offset)) ? ringOnColor : ringOffColor;
ring = 2;
//streamDeck.setIcon(context, "", background,ring,ringColor);
}
else { //Execute macro
macroNumber += this.offset - 1;
if (macroNumber < 0) macroNumber = 0;
var macroId = game.settings.get(MODULE.moduleName,'macroSettings').macros[macroNumber];
background = game.settings.get(MODULE.moduleName,'macroSettings').color[macroNumber];
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;
if (displayName) name += macro.name;
if (displayIcon) src += macro.img;
}
}
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 { //Macro Hotbar
let macroId
if (mode == 'hotbar') macroId = game.user.data.hotbar[macroNumber];
else {
let macros = game.macros.apps[0].macros;
let macros;
if (mode == 'customHotbar' && game.modules.get('custom-hotbar') != undefined)
macros = ui.customHotbar.macros;
else
macros = game.macros.apps[0].macros;
if (macroNumber > 9) macroNumber = 0;
for (let j=0; j<10; j++){
if (macros[j].key == macroNumber){
if (macros[j].macro == null) macroId == undefined;
else macroId = macros[j].macro._id;
}
if (macros[j].key == macroNumber)
macroId = (macros[j].macro == null) ? undefined : macros[j].macro._id;
}
}
let src = "";
@@ -95,42 +81,39 @@ export class MacroControl{
if (macroId != undefined){
let macro = game.macros._source.find(p => p._id == macroId);
if (macro != undefined) {
name += macro.name;
src += macro.img;
if (displayName) name += macro.name;
if (displayIcon) src += macro.img;
}
}
if (icon) streamDeck.setIcon(context,src,background);
else streamDeck.setIcon(context, "", background);
if (displayName == 0) name = "";
streamDeck.setTitle(name,context);
}
streamDeck.setIcon(context,src,background,ring,ringColor);
streamDeck.setTitle(name,context);
}
hotbar(macros){
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;
let context = data.context;
let mode = data.settings.macroMode;
let displayName = data.settings.displayName;
const context = data.context;
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;
let background = data.settings.background ? data.settings.background : '#000000';
let macroNumber = data.settings.macroNumber;
let background = data.settings.background;
if(macroNumber == undefined || isNaN(parseInt(macroNumber))) macroNumber = 1;
let src = "";
let name = "";
if(macroNumber == undefined || isNaN(parseInt(macroNumber))){
macroNumber = 1;
}
if (mode == undefined) mode = 0;
if (mode == 2) continue;
if (displayName == undefined) displayName = false;
if (background == undefined) background = '#000000';
if (mode == 'Macro Board') continue;
let macroId;
if (mode == 0){
if (mode == 'hotbar'){
macroId = game.user.data.hotbar[macroNumber];
}
else {
if (macroNumber > 9) macroNumber = 0;
for (let j=0; j<10; j++){
if (macros[j].key == macroNumber){
if (macros[j].macro == null) macroId == undefined;
@@ -141,25 +124,20 @@ export class MacroControl{
let macro = undefined;
if (macroId != undefined) macro = game.macros._source.find(p => p._id == macroId);
if (macro != undefined && macro != null) {
name += macro.name;
src += macro.img;
if (displayName) name += macro.name;
if (displayIcon) src += macro.img;
}
streamDeck.setIcon(context,src,background);
if (displayName == 0) name = "";
streamDeck.setTitle(name,context);
}
}
keyPress(settings){
let mode = settings.macroMode;
if (mode == undefined) mode = 'hotbar';
const mode = settings.macroMode ? settings.macroMode : 'hotbar';
let macroNumber = settings.macroNumber;
if(macroNumber == undefined || isNaN(parseInt(macroNumber))){
macroNumber = 0;
}
if (mode == 'hotbar' || mode == 'visibleHotbar')
if(macroNumber == undefined || isNaN(parseInt(macroNumber))) macroNumber = 0;
if (mode == 'hotbar' || mode == 'visibleHotbar' || mode == 'customHotbar')
this.executeHotbar(macroNumber,mode);
else {
if (settings.macroBoardMode == 'offset') {
@@ -175,9 +153,14 @@ export class MacroControl{
executeHotbar(macroNumber,mode){
let macroId
if (mode == 0) macroId = game.user.data.hotbar[macroNumber];
if (mode == 'hotbar') macroId = game.user.data.hotbar[macroNumber];
else {
let macros = game.macros.apps[0].macros;
let macros;
if (mode == 'customHotbar' && game.modules.get('custom-hotbar') != undefined) {
macros = ui.customHotbar.macros;
}
else macros = game.macros.apps[0].macros;
if (macroNumber > 9) macroNumber = 0;
for (let j=0; j<10; j++){
if (macros[j].key == macroNumber){
if (macros[j].macro == null) macroId == undefined;

View File

@@ -6,7 +6,6 @@ export class playlistConfigForm extends FormApplication {
super(data, options);
this.data = data;
this.playlistNr;
this.updatePlaylistNr = false;
}
/**
@@ -26,7 +25,10 @@ export class playlistConfigForm extends FormApplication {
* Provide data to the template
*/
getData() {
//Get the playlist settings
let settings = game.settings.get(MODULE.moduleName,'playlists');
//Get values from the settings, and check if they are defined
let selectedPlaylists = settings.selectedPlaylist;
if (selectedPlaylists == undefined) selectedPlaylists = [];
let selectedPlaylistMode = settings.playlistMode;
@@ -36,17 +38,17 @@ export class playlistConfigForm extends FormApplication {
if (numberOfPlaylists == undefined) numberOfPlaylists = 9;
let playMode = settings.playMode;
if (playMode == undefined) playMode = 0;
//Create array to store all the data for each playlist
let playlistData = [];
this.updatePlaylistNr = false;
for (let i=0; i<numberOfPlaylists; i++){
if (selectedPlaylists[i] == undefined) selectedPlaylists[i] = 'none';
if (selectedPlaylistMode[i] == undefined) selectedPlaylistMode[i] = 0;
let dataThis = {
iteration: i+1,
playlist: selectedPlaylists[i],
playlistMode: selectedPlaylistMode[i],
playlists: game.playlists.entities
playlistMode: selectedPlaylistMode[i]
}
playlistData.push(dataThis);
}
@@ -57,7 +59,7 @@ export class playlistConfigForm extends FormApplication {
selectedPlaylist: selectedPlaylists,
playlistMode: selectedPlaylistMode
}
return {
playlists: game.playlists.entities,
numberOfPlaylists: numberOfPlaylists,
@@ -89,9 +91,8 @@ export class playlistConfigForm extends FormApplication {
numberOfPlaylists.on("change", event => {
this.playlistNr = event.target.value;
this.updatePlaylistNr = true;
this.data.playlistNumber=event.target.value;
this.updateSettings(this.data);
this.updateSettings(this.data,true);
});
selectedPlaylist.on("change", event => {
@@ -106,10 +107,11 @@ export class playlistConfigForm extends FormApplication {
this.updateSettings(this.data);
});
}
async updateSettings(settings){
async updateSettings(settings,render){
await game.settings.set(MODULE.moduleName,'playlists', settings);
if (MODULE.enableModule) playlistControl.updateAll();
this.render();
if (render) this.render();
}
}
@@ -125,16 +127,6 @@ export class macroConfigForm extends FormApplication {
* Default Options for this FormApplication
*/
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, {
id: "macro-config",
title: "Material Deck: "+game.i18n.localize("MaterialDeck.Sett.MacroConfig"),
@@ -147,19 +139,26 @@ export class macroConfigForm extends FormApplication {
* Provide data to the template
*/
getData() {
//Get the settings
var selectedMacros = game.settings.get(MODULE.moduleName,'macroSettings').macros;
var color = game.settings.get(MODULE.moduleName,'macroSettings').color;
var args = game.settings.get(MODULE.moduleName,'macroSettings').args;
//Check if the settings are defined
if (selectedMacros == undefined) selectedMacros = [];
if (color == undefined) color = [];
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) {
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 iMax,jMax;
if (streamDeckModel == 0){
@@ -176,45 +175,42 @@ export class macroConfigForm extends FormApplication {
}
let iteration = 0;
let macroData = [];
for (let j=0; j<jMax; j++){
let macroThis = [];
for (let i=0; i<iMax; i++){
let colorThis = color[iteration];
if (colorThis != undefined){
let colorData = color[iteration];
if (colorData != undefined){
let colorCorrect = true;
if (colorThis[0] != '#') colorCorrect = false;
if (colorData[0] != '#') colorCorrect = false;
for (let k=0; k<6; k++){
if (parseInt(colorThis[k+1],16)>15)
if (parseInt(colorData[k+1],16)>15)
colorCorrect = false;
}
if (colorCorrect == false) colorThis = '#000000';
if (colorCorrect == false) colorData = '#000000';
}
else
colorThis = '#000000';
colorData = '#000000';
let dataThis = {
iteration: iteration+1,
macro: selectedMacros[iteration],
color: colorThis,
macros:game.macros,
args: args[iteration],
furnace: furnaceEnabled
color: colorData,
args: args[iteration]
}
macroThis.push(dataThis);
iteration++;
}
let data = {
dataThis: macroThis,
};
macroData.push(data);
macroData.push({dataThis: macroThis});
}
return {
height: height,
macros: game.macros,
selectedMacros: selectedMacros,
macroData: macroData,
furnace: furnaceEnabled
}
}
@@ -258,7 +254,6 @@ export class macroConfigForm extends FormApplication {
async updateSettings(settings){
await game.settings.set(MODULE.moduleName,'macroSettings',settings);
if (MODULE.enableModule) macroControl.updateAll();
this.render();
}
}
@@ -267,10 +262,7 @@ export class macroConfigForm extends FormApplication {
export class soundboardConfigForm extends FormApplication {
constructor(data, options) {
super(data, options);
this.data = data;
this.playlists = [];
this.updatePlaylist = false;
this.update = false;
this.iMax;
this.jMax;
this.settings = {};
@@ -280,16 +272,6 @@ export class soundboardConfigForm extends FormApplication {
* Default Options for this FormApplication
*/
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, {
id: "soundboard-config",
title: "Material Deck: "+game.i18n.localize("MaterialDeck.Sett.SoundboardConfig"),
@@ -298,28 +280,15 @@ export class soundboardConfigForm extends FormApplication {
height: 720
});
}
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
*/
getData() {
if (this.update) {
this.update=false;
return {soundData: this.data};
}
getData() {
//Get the settings
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});
}
//Check if all settings are defined
if (this.settings.sounds == undefined) this.settings.sounds = [];
if (this.settings.colorOn == undefined) this.settings.colorOn = [];
if (this.settings.colorOff == undefined) this.settings.colorOff = [];
@@ -329,8 +298,17 @@ export class soundboardConfigForm extends FormApplication {
if (this.settings.name == undefined) this.settings.name = [];
if (this.settings.selectedPlaylists == undefined) this.settings.selectedPlaylists = [];
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")})
for (let i=0; i<game.playlists.entities.length; i++){
playlists.push({id:game.playlists.entities[i]._id,name:game.playlists.entities[i].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');
if (streamDeckModel == 0){
@@ -346,31 +324,54 @@ export class soundboardConfigForm extends FormApplication {
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++){
let soundsThis = [];
let soundsThis = []; //Stores row data
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 sounds = [];
if (this.settings.volume[iteration] == undefined) this.settings.volume[iteration] = 50;
if (this.settings.selectedPlaylists[iteration]==undefined) selectedPlaylist = 'none';
else if (this.settings.selectedPlaylists[iteration] == 'none') selectedPlaylist = 'none';
else if (this.settings.selectedPlaylists[iteration] == 'FP') selectedPlaylist = 'FP';
else {
//Get the playlist
const pl = game.playlists.entities.find(p => p._id == this.settings.selectedPlaylists[iteration]);
selectedPlaylist = pl._id;
sounds = pl.sounds;
if (pl == undefined){
selectedPlaylist = 'none';
sounds = [];
}
else {
//Add the sound name and id to the sounds array
for (let i=0; i<pl.sounds.length; i++)
sounds.push({
name: pl.sounds[i].name,
id: pl.sounds[i]._id
});
//Get the playlist id
selectedPlaylist = pl._id;
}
}
//Determine whether the sound selector or file picker should be displayed
let styleSS = "";
let styleFP ="display:none";
if (selectedPlaylist == 'FP') {
styleSS = 'display:none';
styleFP = ''
}
//Create and fill the data object for this sound
let dataThis = {
iteration: iteration+1,
playlists: playlists,
selectedPlaylist: selectedPlaylist,
sound: this.settings.sounds[iteration],
sounds: sounds,
@@ -384,18 +385,20 @@ export class soundboardConfigForm extends FormApplication {
styleSS: styleSS,
styleFP: styleFP
}
//Push the data to soundsThis (row array)
soundsThis.push(dataThis);
iteration++;
}
let data = {
dataThis: soundsThis,
};
soundData.push(data);
//Push soundsThis (row array) to soundData (full data array)
soundData.push({dataThis: soundsThis});
}
this.data = soundData;
return {
soundData: this.data
soundData: soundData,
playlists
}
}
@@ -422,122 +425,105 @@ export class soundboardConfigForm extends FormApplication {
nameField.on("change",event => {
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.updateSettings(this.settings);
});
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 sounds = [];
//let sounds = [];
if (event.target.value==undefined) 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 {
//Hide the file picker
document.querySelector(`#fp${iteration}`).style='display:none';
//Show the sound selector
document.querySelector(`#ss${iteration}`).style='';
const pl = game.playlists.entities.find(p => p._id == event.target.value);
selectedPlaylist = pl._id;
sounds = pl.sounds;
}
this.data[j].dataThis[i].sounds=sounds;
let styleSS = "";
let styleFP ="display:none";
if (selectedPlaylist == 'FP') {
styleSS = 'display:none';
styleFP = ''
}
this.data[j].dataThis[i].styleSS=styleSS;
this.data[j].dataThis[i].styleFP=styleFP;
this.update = true;
//Get the sound select element
let SSpicker = document.getElementById(`soundSelect${iteration}`);
this.settings.selectedPlaylists[id]=event.target.value;
//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);
for (let i=0; i<pl.sounds.length; i++){
let newOption = document.createElement('option');
newOption.value = pl.sounds[i]._id;
newOption.innerHTML = pl.sounds[i].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);
});
}
soundSelect.on("change", event => {
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.updateSettings(this.settings);
});
soundFP.on("change",event => {
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.updateSettings(this.settings);
});
imgFP.on("change",event => {
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.updateSettings(this.settings);
});
onCP.on("change",event => {
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.updateSettings(this.settings);
});
offCP.on("change",event => {
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.updateSettings(this.settings);
});
playMode.on("change",event => {
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.updateSettings(this.settings);
});
volume.on("change",event => {
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.updateSettings(this.settings);
});
@@ -546,7 +532,5 @@ export class soundboardConfigForm extends FormApplication {
async updateSettings(settings){
await game.settings.set(MODULE.moduleName,'soundboardSettings',settings);
if (MODULE.enableModule) soundboard.updateAll();
this.render();
}
}

View File

@@ -7,59 +7,84 @@ export class Move{
}
update(settings,context){
let background;
if (settings.background) background = settings.background;
else background = '#000000';
const background = settings.background ? settings.background : '#000000';
const mode = settings.mode ? settings.mode : 'canvas';
const type = settings.type ? settings.type : 'move';
let url = '';
if (settings.dir == 'center') //center
url = "modules/MaterialDeck/img/move/center.png";
else if (settings.dir == 'up') //up
url = "modules/MaterialDeck/img/move/up.png";
else if (settings.dir == 'down') //down
url = "modules/MaterialDeck/img/move/down.png";
else if (settings.dir == 'right') //right
url = "modules/MaterialDeck/img/move/right.png";
else if (settings.dir == 'left') //left
url = "modules/MaterialDeck/img/move/left.png";
else if (settings.dir == 'upRight')
url = "modules/MaterialDeck/img/move/upright.png";
else if (settings.dir == 'upLeft')
url = "modules/MaterialDeck/img/move/upleft.png";
else if (settings.dir == 'downRight')
url = "modules/MaterialDeck/img/move/downright.png";
else if (settings.dir == 'downLeft')
url = "modules/MaterialDeck/img/move/downleft.png";
else if (settings.dir == 'zoomIn')
url = "modules/MaterialDeck/img/move/zoomin.png";
else if (settings.dir == 'zoomOut')
url = "modules/MaterialDeck/img/move/zoomout.png";
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";
else if (dir == 'up') //up
url = "modules/MaterialDeck/img/move/up.png";
else if (dir == 'down') //down
url = "modules/MaterialDeck/img/move/down.png";
else if (dir == 'right') //right
url = "modules/MaterialDeck/img/move/right.png";
else if (dir == 'left') //left
url = "modules/MaterialDeck/img/move/left.png";
else if (dir == 'upRight')
url = "modules/MaterialDeck/img/move/upright.png";
else if (dir == 'upLeft')
url = "modules/MaterialDeck/img/move/upleft.png";
else if (dir == 'downRight')
url = "modules/MaterialDeck/img/move/downright.png";
else if (dir == 'downLeft')
url = "modules/MaterialDeck/img/move/downleft.png";
else if (dir == 'zoomIn')
url = "modules/MaterialDeck/img/move/zoomin.png";
else if (dir == 'zoomOut')
url = "modules/MaterialDeck/img/move/zoomout.png";
}
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,url,background);
}
keyPress(settings){
if (canvas.scene == null) return;
let dir = settings.dir;
let mode = settings.mode;
if (mode == undefined) mode = 'canvas';
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';
if (dir == 'zoomIn') {//zoom in
let viewPosition = canvas.scene._viewPosition;
viewPosition.scale = viewPosition.scale*1.05;
viewPosition.duration = 100;
canvas.animatePan(viewPosition);
if (type == 'move'){
if (dir == 'zoomIn') {//zoom in
let viewPosition = canvas.scene._viewPosition;
viewPosition.scale = viewPosition.scale*1.05;
viewPosition.duration = 100;
canvas.animatePan(viewPosition);
}
else if (dir == 'zoomOut') {//zoom out
let viewPosition = canvas.scene._viewPosition;
viewPosition.scale = viewPosition.scale*0.95;
viewPosition.duration = 100;
canvas.animatePan(viewPosition);
}
else {
if (settings.mode == 'selectedToken')
this.moveToken(MODULE.selectedTokenId,dir);
else
this.moveCanvas(dir);
}
}
else if (dir == 'zoomOut') {//zoom out
let viewPosition = canvas.scene._viewPosition;
viewPosition.scale = viewPosition.scale*0.95;
viewPosition.duration = 100;
canvas.animatePan(viewPosition);
}
else {
if (settings.mode == 'selectedToken')
this.moveToken(MODULE.selectedTokenId,dir);
else
this.moveCanvas(dir);
else if (type == 'rotate' && mode == 'selectedToken'){
const token = canvas.tokens.children[0].children.find(p => p.id == MODULE.selectedTokenId);
if (token == undefined) return;
const rotType = settings.rot ? settings.rot : 'to';
const value = isNaN(parseInt(settings.rotValue)) ? 0 : parseInt(settings.rotValue);
let rotationVal;
if (rotType == 'by') rotationVal = token.data.rotation + value;
else if (rotType == 'to') rotationVal = value;
token.update({rotation: rotationVal});
}
}

View File

@@ -4,13 +4,13 @@ import {streamDeck} from "../MaterialDeck.js";
export class OtherControls{
constructor(){
this.active = false;
this.offset = 0;
this.rollData = {};
}
async updateAll(){
if (this.active == false) return;
for (let i=0; i<32; i++){
let data = streamDeck.buttonContext[i];
const data = streamDeck.buttonContext[i];
if (data == undefined || data.action != 'other') continue;
await this.update(data.settings,data.context);
}
@@ -18,108 +18,75 @@ export class OtherControls{
update(settings,context){
this.active = true;
let mode = settings.otherMode;
if (mode == undefined) mode = 'pause';
const mode = settings.otherMode ? settings.otherMode : 'pause';
if (mode == 'pause') { //pause
this.updatePause(settings.pauseFunction,context);
}
else if (mode == 'sceneSelect') { //scene selection
this.updateScene(settings,context);
}
else if (mode == 'controlButtons'){ //control buttons
if (mode == 'pause') //pause
this.updatePause(settings,context);
else if (mode == 'controlButtons') //control buttons
this.updateControl(settings,context);
}
else if (mode == 'darkness'){ //darkness
else if (mode == 'darkness') //darkness
this.updateDarkness(settings,context);
}
else if (mode == 'rollTables'){ //roll tables
else if (mode == 'rollDice') //roll dice
this.updateRollDice(settings,context);
else if (mode == 'rollTables') //roll tables
this.updateRollTable(settings,context);
}
else if (mode == 'sidebarTab') { //open sidebar tab
else if (mode == 'sidebarTab') //open sidebar tab
this.updateSidebar(settings,context);
}
else if (mode == 'compendium') { //open compendium
else if (mode == 'compendium') //open compendium
this.updateCompendium(settings,context);
}
else if (mode == 'journal') { //open journal
else if (mode == 'journal') //open journal
this.updateJournal(settings,context);
}
else if (mode == 'chatMessage')
this.updateChatMessage(settings,context);
}
keyPress(settings){
let mode = settings.otherMode;
if (mode == undefined) mode = 'pause';
keyPress(settings,context){
const mode = settings.otherMode ? settings.otherMode : 'pause';
if (mode == 'pause') { //pause
this.keyPressPause(settings.pauseFunction);
}
else if (mode == 'sceneSelect') { //scene
this.keyPressScene(settings);
}
else if (mode == 'controlButtons') { //control buttons
if (mode == 'pause') //pause
this.keyPressPause(settings);
else if (mode == 'controlButtons') //control buttons
this.keyPressControl(settings);
}
else if (mode == 'darkness') { //darkness controll
else if (mode == 'darkness') //darkness controll
this.keyPressDarkness(settings);
}
else if (mode == 'rollTables') { //roll tables
else if (mode == 'rollDice') //roll dice
this.keyPressRollDice(settings,context);
else if (mode == 'rollTables') //roll tables
this.keyPressRollTable(settings);
}
else if (mode == 'sidebarTab') { //sidebar
else if (mode == 'sidebarTab') //sidebar
this.keyPressSidebar(settings);
}
else if (mode == 'compendium') { //open compendium
else if (mode == 'compendium') //open compendium
this.keyPressCompendium(settings);
}
else if (mode == 'journal') { //open journal
else if (mode == 'journal') //open journal
this.keyPressJournal(settings);
}
else if (mode == 'chatMessage')
this.keyPressChatMessage(settings);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
updatePause(pauseFunction,context){
updatePause(settings,context){
let src = "";
if (pauseFunction == undefined) pauseFunction = 'pause';
let background = settings.background;
if(background == undefined) background = '#000000';
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 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;
if (pauseFunction == 'pause') //Pause game
src = 'modules/MaterialDeck/img/other/pause/pause.png';
//src = 'action/images/other/pause/pause.png';
}
else if (pauseFunction == 'resume'){ //Resume game
if (game.paused == false) ringColor = ringOnColor;
else ringColor = ringOffColor;
ringColor = game.paused ? ringOffColor : ringOnColor;
src = 'modules/MaterialDeck/img/other/pause/resume.png';
//src = 'action/images/other/pause/resume.png';
}
else if (pauseFunction == 'toggle') { //toggle
if (game.paused == false) ringColor = ringOnColor;
else ringColor = ringOffColor;
else if (pauseFunction == 'toggle') //toggle
src = 'modules/MaterialDeck/img/other/pause/playpause.png';
//src = 'action/images/other/pause/playpause.png';
}
streamDeck.setIcon(context,src,background,2,ringColor,true);
}
keyPressPause(pauseFunction){
if (pauseFunction == undefined) pauseFunction = 'pause';
keyPressPause(settings){
const pauseFunction = settings.pauseFunction ? settings.pauseFunction : 'pause';
if (pauseFunction == 'pause'){ //Pause game
if (game.paused) return;
game.togglePause();
@@ -133,100 +100,13 @@ export class OtherControls{
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
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){
let control = settings.control;
if (control == undefined) control = 'dispControls';
let tool = settings.tool;
if (tool == undefined) tool = 'open';
let background = settings.background;
if (background == undefined) background = '#000000';
const control = settings.control ? settings.control : 'dispControls';
const tool = settings.tool ? settings.tool : 'open';
let background = settings.background ? settings.background : '#000000';
let ringColor = '#000000'
let txt = "";
let src = "";
const activeControl = ui.controls.activeControl;
@@ -260,10 +140,7 @@ export class OtherControls{
src = selectedTool.icon;
if (selectedTool.toggle){
background = "#340057"
if (selectedTool.active)
ringColor = "#A600FF"
else
ringColor = "#340057";
ringColor = selectedTool.active ? "#A600FF" : "#340057";
}
else if (activeTool == selectedTool.name)
ringColor = "#FF7B00";
@@ -285,11 +162,8 @@ export class OtherControls{
txt = game.i18n.localize(selectedTool.title);
src = selectedTool.icon;
if (selectedTool.toggle){
background = "#340057"
if (selectedTool.active)
ringColor = "#A600FF"
else
ringColor = "#340057"
background = "#340057";
ringColor = selectedTool.active ? "#A600FF" : "#340057";
}
else if (activeTool == selectedTool.name && activeControl == selectedControl.name)
ringColor = "#FF7B00";
@@ -303,11 +177,8 @@ export class OtherControls{
keyPressControl(settings){
if (canvas.scene == null) return;
let control = settings.control;
if (control == undefined) control = 'dispControls';
let tool = settings.tool;
if (tool == undefined) tool = 'open';
const control = settings.control ? settings.control : 'dispControls';
const tool = settings.tool ? settings.tool : 'open';
if (control == 'dispControls'){ //displayed controls
let controlNr = parseInt(settings.controlNr);
@@ -372,14 +243,9 @@ export class OtherControls{
//////////////////////////////////////////////////////////////////////////////////////////
updateDarkness(settings,context){
let func = settings.darknessFunction;
if (func == undefined) func = 'value';
let value = settings.darknessValue;
if (value == undefined) value = 0;
let background = settings.background;
if (background == undefined) background = "#000000";
const func = settings.darknessFunction ? settings.darknessFunction : 'value';
const value = parseFloat(settings.darknessValue) ? parseFloat(settings.darknessValue) : 0;
const background = settings.background ? settings.background : '#000000';
let src = "";
let txt = "";
@@ -391,10 +257,9 @@ export class OtherControls{
if (value < 0) src = 'modules/MaterialDeck/img/other/darkness/decreasedarkness.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';
let darkness = '';
if (canvas.scene != null) darkness = Math.floor(canvas.scene.data.darkness*100)/100;
const darkness = canvas.scene != null ? Math.floor(canvas.scene.data.darkness*100)/100 : '';
txt += darkness;
}
streamDeck.setTitle(txt,context);
@@ -403,17 +268,13 @@ export class OtherControls{
keyPressDarkness(settings) {
if (canvas.scene == null) return;
let func = settings.darknessFunction;
if (func == undefined) func = 'value';
let value = parseFloat(settings.darknessValue);
if (value == undefined) value = 0;
const func = settings.darknessFunction ? settings.darknessFunction : 'value';
const value = parseFloat(settings.darknessValue) ? parseFloat(settings.darknessValue) : 0;
if (func == 'value') //value
canvas.scene.update({darkness: value});
else if (func == 'incDec'){ //increase/decrease
let darkness = canvas.scene.data.darkness;
darkness += -1*value;
let darkness = canvas.scene.data.darkness - value;
if (darkness > 1) darkness = 1;
if (darkness < 0) darkness = 0;
canvas.scene.update({darkness: darkness});
@@ -422,37 +283,77 @@ export class OtherControls{
//////////////////////////////////////////////////////////////////////////////////////////
updateRollDice(settings,context){
const background = settings.background ? settings.background : '#000000';
let txt = '';
if (settings.displayDiceName) txt = 'Roll: ' + settings.rollDiceFormula;
streamDeck.setTitle(txt,context);
streamDeck.setIcon(context,'',background);
}
keyPressRollDice(settings,context){
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){
let name = settings.rollTableName;
const name = settings.rollTableName;
if (name == undefined) return;
let background = settings.background;
if (background == undefined) background = "#000000";
const background = settings.background ? settings.background : '#000000';
const table = game.tables.entities.find(p=>p.name == name);
let txt = settings.displayRollName ? table.name : '';
let src = settings.displayRollIcon ? table.data.img : '';
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;
if (table == undefined) {
src = '';
txt = '';
}
streamDeck.setTitle(txt,context);
streamDeck.setIcon(context,src,background);
}
keyPressRollTable(settings){
let func = settings.rolltableFunction;
if (func == undefined) func = 'open';
let name = settings.rollTableName;
const name = settings.rollTableName;
if (name == undefined) return;
let background = settings.background;
if (background == undefined) background = "#000000";
let table = game.tables.entities.find(p=>p.name == name);
const func = settings.rolltableFunction ? settings.rolltableFunction : 'open';
const table = game.tables.entities.find(p=>p.name == name);
if (table != undefined) {
if (func == 'open'){ //open
@@ -502,43 +403,24 @@ export class OtherControls{
}
updateSidebar(settings,context){
let sidebarTab = settings.sidebarTab;
if (sidebarTab == undefined) sidebarTab = 'chat';
const sidebarTab = settings.sidebarTab ? settings.sidebarTab : 'chat';
const background = settings.background ? settings.background : '#000000';
const collapsed = ui.sidebar._collapsed;
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
const ringColor = (sidebarTab == 'collapse' && collapsed) ? 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.setIcon(context,icon,background,2,ringColor);
}
keyPressSidebar(settings){
let sidebarTab = settings.sidebarTab;
if (sidebarTab == undefined) sidebarTab = 'chat';
let collapsed = ui.sidebar._collapsed;
const sidebarTab = settings.sidebarTab ? settings.sidebarTab : 'chat';
if (sidebarTab == 'collapse'){
const collapsed = ui.sidebar._collapsed;
if (collapsed) ui.sidebar.expand();
else if (collapsed == false) ui.sidebar.collapse();
}
@@ -548,27 +430,19 @@ export class OtherControls{
//////////////////////////////////////////////////////////////////////////////////////////
updateCompendium(settings,context){
let background = settings.background;
if(background == undefined) background = '#000000';
let name = settings.compendiumName;
const name = settings.compendiumName;
if (name == undefined) return;
const compendium = game.packs.entries.find(p=>p.metadata.label == name);
if (compendium == undefined) return;
let ringColor = "#000000";
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 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.setTitle(txt,context);
streamDeck.setIcon(context,"",background,2,ringColor);
}
@@ -588,37 +462,50 @@ export class OtherControls{
//game.journal.entries[0].render(true)
updateJournal(settings,context){
let background = settings.background;
if(background == undefined) background = '#000000';
let name = settings.compendiumName;
const name = settings.compendiumName;
if (name == undefined) return;
const journal = game.journal.entries.find(p=>p.name == name);
if (journal == undefined) return;
let ringColor = "#000000";
const background = settings.background ? settings.background : '#000000';
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
const ringColor = journal.sheet.rendered ? ringOnColor : ringOffColor;
const txt = settings.displayCompendiumName ? name : '';
let ringOffColor = settings.offRing;
if (ringOffColor == undefined) ringOffColor = '#000000';
let ringOnColor = settings.onRing;
if (ringOnColor == undefined) ringOnColor = '#00FF00';
if (journal.sheet.rendered) ringColor = ringOnColor;
else ringColor = ringOffColor;
if (settings.displayCompendiumName) streamDeck.setTitle(name,context);
streamDeck.setTitle(txt,context);
streamDeck.setIcon(context,"",background,2,ringColor);
}
keyPressJournal(settings){
let name = settings.compendiumName;
const name = settings.compendiumName;
if (name == undefined) return;
const journal = game.journal.entries.find(p=>p.name == name);
if (journal == undefined) return;
const element = document.getElementById("journal-"+journal.id);
if (element == null) journal.render(true);
else journal.sheet.close();
}
//////////////////////////////////////////////////////////////////////////////////////////
updateChatMessage(settings,context){
const background = settings.background ? settings.background : '#000000';
streamDeck.setTitle("",context);
streamDeck.setIcon(context,"",background);
}
keyPressChatMessage(settings){
const message = settings.chatMessage ? settings.chatMessage : '';
let chatData = {
user: game.user._id,
speaker: ChatMessage.getSpeaker(),
content: message
};
ChatMessage.create(chatData, {});
}
}

View File

@@ -11,7 +11,7 @@ export class PlaylistControl{
async updateAll(){
if (this.active == false) return;
for (let i=0; i<32; i++){
let data = streamDeck.buttonContext[i];
const data = streamDeck.buttonContext[i];
if (data == undefined || data.action != 'playlist') continue;
await this.update(data.settings,data.context);
}

189
src/scene.js Normal file
View File

@@ -0,0 +1,189 @@
import * as MODULE from "../MaterialDeck.js";
import {streamDeck} from "../MaterialDeck.js";
export class SceneControl{
constructor(){
this.active = false;
this.rollData = {};
this.sceneOffset = 0;
}
async updateAll(){
if (this.active == false) return;
for (let i=0; i<32; i++){
const data = streamDeck.buttonContext[i];
if (data == undefined || data.action != 'scene') continue;
await this.update(data.settings,data.context);
}
}
update(settings,context){
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
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
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 = 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 (settings.sceneName == undefined || settings.sceneName == '') return;
let scene = game.scenes.apps[1].entities.find(p=>p.data.name == 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'){
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,src,background,ring,ringColor);
}
keyPress(settings){
const func = settings.sceneFunction ? settings.sceneFunction : 'visible';
if (func == 'visible'){ //visible scenes
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
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 = 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 (settings.sceneName == undefined || settings.sceneName == '') return;
const scenes = game.scenes.entries;
let scene = game.scenes.apps[1].entities.find(p=>p.data.name == 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'){
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

@@ -11,7 +11,7 @@ export const registerSettings = function() {
name: "MaterialDeck.Sett.Enable",
scope: "global",
config: true,
default: false,
default: true,
type: Boolean,
onChange: x => window.location.reload()
});
@@ -39,6 +39,24 @@ export const registerSettings = function() {
onChange: x => window.location.reload()
});
game.settings.register(MODULE.moduleName, 'imageBuffer', {
name: "MaterialDeck.Sett.ImageBuffer",
hint: "MaterialDeck.Sett.ImageBufferHint",
default: 0,
type: Number,
scope: 'world',
range: { min: 0, max: 500, step: 10 },
config: true
});
//Create the Help button
game.settings.registerMenu(MODULE.moduleName, 'helpMenu',{
name: "MaterialDeck.Sett.Help",
label: "MaterialDeck.Sett.Help",
type: helpMenu,
restricted: true
});
/**
* Playlist soundboard
*/
@@ -99,3 +117,45 @@ export const registerSettings = function() {
restricted: true
});
}
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);
}
}

View File

@@ -13,7 +13,7 @@ export class SoundboardControl{
async updateAll(){
if (this.active == false) return;
for (let i=0; i<32; i++){
let data = streamDeck.buttonContext[i];
const data = streamDeck.buttonContext[i];
if (data == undefined || data.action != 'soundboard') continue;
await this.update(data.settings,data.context);
}
@@ -21,17 +21,13 @@ export class SoundboardControl{
update(settings,context){
this.active = true;
let mode = settings.soundboardMode;
if (mode == undefined) mode = 'playSound';
const mode = settings.soundboardMode ? settings.soundboardMode : 'playSound';
const background = settings.background ? settings.background : '#000000';
let ringColor = "#000000"
let txt = "";
let src = "";
let background = settings.background;
if (background == undefined) background = '#000000';
let ringColor = "#000000"
if (mode == 'playSound'){ //play sound
let soundNr = parseInt(settings.soundNr);
if (isNaN(soundNr)) soundNr = 1;
@@ -39,28 +35,23 @@ export class SoundboardControl{
soundNr += this.offset;
let soundboardSettings = game.settings.get(MODULE.moduleName, 'soundboardSettings');
if (this.activeSounds[soundNr]==false)
ringColor = soundboardSettings.colorOff[soundNr];
else
ringColor = soundboardSettings.colorOn[soundNr];
ringColor = (this.activeSounds[soundNr]==false) ? soundboardSettings.colorOff[soundNr] : soundboardSettings.colorOn[soundNr];
if (settings.displayName && soundboardSettings.name != undefined) txt = soundboardSettings.name[soundNr];
if (settings.displayIcon && soundboardSettings.img != undefined) src = soundboardSettings.img[soundNr];
streamDeck.setTitle(txt,context);
streamDeck.setIcon(context,src,background,2,ringColor);
}
else if (mode == 'offset') { //Offset
let ringOffColor = settings.offRing;
if (ringOffColor == undefined) ringOffColor = '#000000';
let ringOnColor = settings.onRing;
if (ringOnColor == undefined) ringOnColor = '#00FF00';
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
let offset = parseInt(settings.offset);
if (isNaN(offset)) offset = 0;
if (offset == this.offset) ringColor = ringOnColor;
else ringColor = ringOffColor;
streamDeck.setTitle(txt,context);
streamDeck.setIcon(context,"",background,2,ringColor);
}
@@ -68,7 +59,8 @@ export class SoundboardControl{
let src = 'modules/MaterialDeck/img/playlist/stop.png';
let soundPlaying = false;
for (let i=0; i<this.activeSounds.length; i++)
if (this.activeSounds[i]) soundPlaying = true;
if (this.activeSounds[i])
soundPlaying = true;
if (soundPlaying)
streamDeck.setIcon(context,src,settings.background,2,'#00FF00',true);
else
@@ -77,8 +69,8 @@ export class SoundboardControl{
}
keyPressDown(settings){
let mode = settings.soundboardMode;
if (mode == undefined) mode = 'playSound';
const mode = settings.soundboardMode ? settings.soundboardMode : 'playSound';
if (mode == 'playSound') { //Play sound
let soundNr = parseInt(settings.soundNr);
if (isNaN(soundNr)) soundNr = 1;
@@ -86,11 +78,9 @@ export class SoundboardControl{
soundNr += this.offset;
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;
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
@@ -109,9 +99,10 @@ export class SoundboardControl{
}
keyPressUp(settings){
let mode = settings.soundboardMode;
if (mode == undefined) mode = 'playSound';
const mode = settings.soundboardMode ? settings.soundboardMode : 'playSound';
if (mode != 'playSound') return;
let soundNr = parseInt(settings.soundNr);
if (isNaN(soundNr)) soundNr = 1;
soundNr--;
@@ -125,8 +116,7 @@ export class SoundboardControl{
async playSound(soundNr,repeat,play){
const soundBoardSettings = game.settings.get(MODULE.moduleName,'soundboardSettings');
let playlistId;
if (soundBoardSettings.selectedPlaylists != undefined) playlistId = soundBoardSettings.selectedPlaylists[soundNr];
const playlistId = (soundBoardSettings.selectedPlaylists != undefined) ? soundBoardSettings.selectedPlaylists[soundNr] : undefined;
let src;
if (playlistId == "" || playlistId == undefined) return;
if (playlistId == 'none') return;
@@ -134,7 +124,8 @@ export class SoundboardControl{
src = soundBoardSettings.src[soundNr];
const ret = await FilePicker.browse("data", src, {wildcard:true});
const files = ret.files;
if (files.length == 1) src = files;
if (files.length == 1)
src = files;
else {
let value = Math.floor(Math.random() * Math.floor(files.length));
src = files[value];

View File

@@ -25,6 +25,11 @@ export class StreamDeck{
document.body.appendChild(canvasBox); // adds the canvas to the body element
this.syllableRegex = /[^aeiouy]*[aeiouy]+(?:[^aeiouy]*$|[^aeiouy](?=[^aeiouy]))?/gi;
this.imageBuffer = [];
this.imageBufferCounter = 0;
}
setScreen(action){
@@ -51,6 +56,8 @@ export class StreamDeck{
else if (action == 'playlist') MODULE.playlistControl.active = false;
else if (action == 'soundboard') MODULE.soundboard.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;
}
}
@@ -170,14 +177,30 @@ export class StreamDeck{
MODULE.sendWS(JSON.stringify(msg));
}
setImage(image,context){
setImage(image,context,nr,id){
var json = {
target: "SD",
event: "setImage",
context: context,
payload: {
image: "" + image,
target: 0
nr: nr,
id: id,
image: "" + image,
target: 0
}
};
MODULE.sendWS(JSON.stringify(json));
}
setBufferImage(context,nr,id){
var json = {
target: "SD",
event: "setBufferImage",
context: context,
payload: {
nr: nr,
id: id,
target: 0
}
};
MODULE.sendWS(JSON.stringify(json));
@@ -197,6 +220,18 @@ export class StreamDeck{
this.buttonContext[i].background = background;
}
}
const data = {
url: src,
background:background,
ring:ring,
ringColor:ringColor,
overlay:overlay
}
const imgBuffer = this.checkImageBuffer(data);
if (imgBuffer != false) {
this.setBufferImage(context,imgBuffer,this.getImageBufferId(data))
return;
}
let split = src.split('.');
//filter out stuff from Tokenizer
@@ -214,7 +249,7 @@ export class StreamDeck{
ringColor: ringColor,
overlay: overlay
};
this.getImage(msg);
this.getImage(msg);
}
setState(state,context,action){
@@ -264,6 +299,7 @@ export class StreamDeck{
getImage(data){
if (data == undefined)
return;
const context = data.context;
var url = data.url;
const format = data.format;
@@ -366,8 +402,46 @@ export class StreamDeck{
ctx.drawImage(img, xStart+margin, yStart+margin, renderableWidth - 2*margin, renderableHeight - 2*margin);
var dataURL = canvas.toDataURL();
canvas.remove();
this.setImage(dataURL,data.context);
const nr = this.addToImageBuffer(dataURL,data);
this.setImage(dataURL,data.context,nr,this.getImageBufferId(data));
};
img.src = resImageURL;
}
getImageBufferId(data){
return data.url+data.background+data.ring+data.ringColor+data.overlay;
}
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 = [];
}
}

View File

@@ -4,44 +4,58 @@ import {streamDeck} from "../MaterialDeck.js";
export class TokenControl{
constructor(){
this.active = false;
this.wildcardOffset = 0;
}
async update(tokenId){
if (this.active == false) return;
for (let i=0; i<32; i++){
let data = streamDeck.buttonContext[i];
const data = streamDeck.buttonContext[i];
if (data == undefined || data.action != 'token') continue;
await this.pushData(tokenId,data.settings,data.context);
}
}
pushData(tokenId,settings,context,ring=0,ringColor='#000000'){
let name = false;
let icon = false;
let stats = settings.stats;
let background = "#000000";
async pushData(tokenId,settings,context,ring=0,ringColor='#000000'){
const name = settings.displayName ? settings.displayName : false;
const icon = settings.displayIcon ? settings.displayIcon : false;
const background = settings.background ? settings.background : "#000000";
const system = settings.system ? settings.system : 'dnd5e';
if (settings.displayIcon) icon = true;
if (settings.displayName) name = true;
let stats = (system == 'demonlord') ? settings.statsDemonlord : settings.stats;
if (stats == undefined) stats = 'none';
if (settings.background) background = settings.background;
let system = settings.system;
if (system == undefined) system = 'dnd5e';
let tokenName = "";
let txt = "";
let iconSrc = "";
let overlay = false;
if (tokenId != undefined) {
let token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
const token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
tokenName = token.data.name;
if (name) txt += tokenName;
if (name && stats != 'none') txt += "\n";
iconSrc = token.data.img;
let actor = canvas.tokens.children[0].children.find(p => p.id == tokenId).actor;
if (system == 'dnd5e' && game.system.id == 'dnd5e'){
let attributes = actor.data.data.attributes;
if (stats == 'custom'){
const custom = settings.custom ? settings.custom : '';
let split = custom.split('[');
for (let i=0; i<split.length; i++) split[i] = split[i].split(']');
for (let i=0; i<split.length; i++)
for (let j=0; j<split[i].length; j++){
if (split[i][j][0] != '@') txt += split[i][j];
else {
const dataPath = split[i][j].split('@')[1].split('.');
let data = token;
for (let i=0; i<dataPath.length; i++)
data = data?.[dataPath[i]];
if (data == undefined) txt += '[undef]';
else txt += data;
}
}
}
else if (system == 'dnd5e' && game.system.id == 'dnd5e'){
let attributes = token.actor.data.data.attributes;
if (stats == 'HP') {
txt += attributes.hp.value + "/" + attributes.hp.max;
}
@@ -53,7 +67,7 @@ export class TokenControl{
else if (stats == 'AC') txt += attributes.ac.value;
else if (stats == 'Speed'){
let speed = "";
if (attributes.speed._deprecated){
if (attributes.movement != undefined){
if (attributes.movement.burrow > 0) speed += game.i18n.localize("DND5E.MovementBurrow") + ': ' + attributes.movement.burrow + attributes.movement.units;
if (attributes.movement.climb > 0) {
if (speed.length > 0) speed += '\n';
@@ -83,11 +97,11 @@ export class TokenControl{
txt += speed;
}
else if (stats == 'Init') txt += attributes.init.total;
else if (stats == 'PassivePerception') txt += actor.data.data.skills.prc.passive;
else if (stats == 'PassiveInvestigation') txt += actor.data.data.skills.inv.passive;
else if (stats == 'PassivePerception') txt += token.actor.data.data.skills.prc.passive;
else if (stats == 'PassiveInvestigation') txt += token.actor.data.data.skills.inv.passive;
}
else if ((system == 'dnd3.5e' && game.system.id == 'D35E') || (system == 'pf1e' && game.system.id == 'pf1')){
let attributes = actor.data.data.attributes;
let attributes = token.actor.data.data.attributes;
if (stats == 'HP') txt += attributes.hp.value + "/" + attributes.hp.max;
else if (stats == 'TempHP') {
if (attributes.hp.temp == null) txt += '0';
@@ -118,7 +132,7 @@ export class TokenControl{
else if (stats == 'Init') txt += attributes.init.total;
}
else if (system == 'pf2e' && game.system.id == 'pf2e'){
let attributes = actor.data.data.attributes;
let attributes = token.actor.data.data.attributes;
if (stats == 'HP') txt += attributes.hp.value + "/" + attributes.hp.max;
else if (stats == 'TempHP') {
if (attributes.hp.temp == null) txt += '0';
@@ -142,11 +156,11 @@ export class TokenControl{
}
}
else if (system == 'demonlord' && game.system.id == 'demonlord'){
let characteristics = actor.data.data.characteristics;
let characteristics = token.actor.data.data.characteristics;
if (stats == 'HP') txt += characteristics.health.value + "/" + characteristics.health.max;
else if (stats == 'AC') txt += characteristics.defense;
else if (stats == 'Speed') txt += characteristics.speed;
else if (stats == 'Init') txt += actor.data.data.fastturn ? "FAST" : "SLOW";
else if (stats == 'Init') txt += token.actor.data.data.fastturn ? "FAST" : "SLOW";
}
else {
//Other systems
@@ -191,8 +205,7 @@ export class TokenControl{
else if (settings.onClick == 'condition') { //toggle condition
ring = 1;
if ((system == 'dnd5e' && game.system.id == 'dnd5e') || (system == 'dnd3.5e' && game.system.id == 'D35E') || (system == 'pf1e' && game.system.id == 'pf1')){
let condition = settings.condition;
if (condition == undefined) condition = 'removeAll';
const condition = settings.condition ? settings.condition : 'removeAll';
if (condition == 'removeAll' && icon == false)
iconSrc = window.CONFIG.controlIcons.effects;
else if (icon == false) {
@@ -207,8 +220,7 @@ export class TokenControl{
}
}
else if (system == 'pf2e' && game.system.id == 'pf2e') {
let condition = settings.conditionPF2E;
if (condition == undefined) condition = 'removeAll';
const condition = settings.conditionPF2E ? settings.conditionPF2E : 'removeAll';
if (condition == 'removeAll' && icon == false)
iconSrc = window.CONFIG.controlIcons.effects;
else if (icon == false) {
@@ -223,8 +235,7 @@ export class TokenControl{
}
}
else if (system == 'demonlord' && game.system.id == 'demonlord'){
let condition = settings.conditionDemonlord;
if (condition == undefined) condition = 'removeAll';
const condition = settings.conditionDemonlord ? settings.conditionDemonlord : 'removeAll';
if (condition == 'removeAll' && icon == false)
iconSrc = window.CONFIG.controlIcons.effects;
else if (icon == false) {
@@ -242,6 +253,40 @@ export class TokenControl{
iconSrc = "";
overlay = true;
}
else if (settings.onClick == 'wildcard') { //wildcard images
if (icon == false) return;
const method = settings.wildcardMethod ? settings.wildcardMethod : 'iterate';
let value = parseInt(settings.wildcardValue);
if (isNaN(value)) value = 1;
const images = await token.actor.getTokenImages();
let currentImgNr = 0
let imgNr;
for (let i=0; i<images.length; i++)
if (images[i] == token.data.img){
currentImgNr = i;
break;
}
if (method == 'iterate'){
imgNr = currentImgNr + value + this.wildcardOffset;
while (imgNr >= images.length) imgNr -= images.length;
while (imgNr < 0) imgNr += images.length;
iconSrc = images[imgNr];
}
else if (method == 'set'){
imgNr = value - 1 + this.wildcardOffset;
if (value >= images.length) iconSrc = "modules/MaterialDeck/img/black.png";
else iconSrc = images[imgNr];
ring = 1;
if (currentImgNr == imgNr) {
ring = 2;
ringColor = "#FF7B00";
}
}
else return;
}
}
else {
iconSrc += "";
@@ -268,27 +313,21 @@ export class TokenControl{
}
else if (settings.onClick == 'condition') { //toggle condition
if ((system == 'dnd5e' && game.system.id == 'dnd5e') || (system == 'dnd3.5e' && game.system.id == 'D35E') || (system == 'pf1e' && game.system.id == 'pf1')){
let condition = settings.condition;
if (condition == undefined) condition = 'removeAll';
const condition = settings.condition ? settings.condition : 'removeAll';
if (condition == 'removeAll' && icon == false)
iconSrc = window.CONFIG.controlIcons.effects;
else if (icon == false)
iconSrc = CONFIG.statusEffects.find(e => e.id === condition).icon;
}
else if (system == 'pf2e' && game.system.id == 'pf2e') {
let condition = settings.conditionPF2E;
if (condition == undefined) condition = 'removeAll';
const condition = settings.conditionPF2E ? settings.conditionPF2E : 'removeAll';
if (condition == 'removeAll' && icon == false)
iconSrc = window.CONFIG.controlIcons.effects;
else if (icon == false)
iconSrc = this.pf2eCondition(condition);
}
else if (system == 'demonlord' && game.system.id == 'demonlord'){
let condition = settings.conditionDemonlord;
if (condition == undefined) condition = 'removeAll';
const condition = settings.conditionDemonlord ? settings.conditionDemonlord : 'removeAll';
if (condition == 'removeAll' && icon == false)
iconSrc = window.CONFIG.controlIcons.effects;
else if (icon == false)
@@ -313,7 +352,6 @@ export class TokenControl{
iconSrc = "modules/MaterialDeck/img/black.png";
}
streamDeck.setIcon(context,iconSrc,background,ring,ringColor,overlay);
streamDeck.setTitle(txt,context);
}
@@ -321,15 +359,14 @@ export class TokenControl{
if (MODULE.selectedTokenId == undefined) return;
const tokenId = MODULE.selectedTokenId;
let onClick = settings.onClick;
if (onClick == undefined) onClick = 'doNothing';
const token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
if (token == undefined) return;
let system = settings.system;
if (system == undefined) system = 'dnd5e';
let system = settings.system ? settings.system : 'dnd5e';
let onClick = (system == 'demonlord') ? settings.onClickDemonlord : settings.onClick;
if (onClick == undefined) onClick = 'doNothing';
if (onClick == 'doNothing') //Do nothing
return;
else if (onClick == 'center'){ //center on token
@@ -357,15 +394,10 @@ export class TokenControl{
}
else if (onClick == 'condition') { //Toggle condition
if ((system == 'dnd5e' && game.system.id == 'dnd5e') || (system == 'dnd3.5e' && game.system.id == 'D35E') || (system == 'pf1e' && game.system.id == 'pf1')){
let condition = settings.condition;
if (condition == undefined) condition = 'removeAll';
const condition = settings.condition ? settings.condition : 'removeAll';
if (condition == 'removeAll'){
const effects = token.actor.effects.entries;
for (let i=0; i<effects.length; i++){
const effect = CONFIG.statusEffects.find(e => e.icon === effects[i].data.icon);
await token.toggleEffect(effect)
}
for( let effect of token.actor.effects)
await effect.delete();
}
else {
const effect = CONFIG.statusEffects.find(e => e.id === condition);
@@ -373,14 +405,10 @@ export class TokenControl{
}
}
else if (system == 'pf2e' && game.system.id == 'pf2e'){
let condition = settings.conditionPF2E;
if (condition == undefined) condition = 'removeAll';
const condition = settings.conditionPF2E ? settings.conditionPF2E : 'removeAll';
if (condition == 'removeAll'){
const effects = token.actor.effects.entries;
for (let i=0; i<effects.length; i++){
const effect = this.pf2eCondition(condition);
await token.toggleEffect(effect)
}
for( let effect of token.actor.effects)
await effect.delete();
}
else {
const effect = this.pf2eCondition(condition);
@@ -388,15 +416,10 @@ export class TokenControl{
}
}
else if (system == 'demonlord' && game.system.id == 'demonlord'){
let condition = settings.conditionDemonlord;
if (condition == undefined) condition = 'removeAll';
const condition = settings.conditionDemonlord ? settings.conditionDemonlord : 'removeAll';
if (condition == 'removeAll'){
const effects = token.actor.effects.entries;
for (let i=0; i<effects.length; i++){
const effect = CONFIG.statusEffects.find(e => e.icon === effects[i].data.icon);
await token.toggleEffect(effect)
}
for( let effect of token.actor.effects)
await effect.delete();
}
else {
const effect = CONFIG.statusEffects.find(e => e.id === condition);
@@ -406,12 +429,217 @@ export class TokenControl{
this.update(tokenId);
}
else if (onClick == 'vision'){
const token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
if (token == undefined) return;
let tokenData = token.data;
const dimVision = parseInt(settings.dimVision);
const brightVision = parseInt(settings.brightVision);
const sightAngle = parseInt(settings.sightAngle);
const dimRadius = parseInt(settings.dimRadius);
const brightRadius = parseInt(settings.brightRadius);
const emissionAngle = parseInt(settings.emissionAngle);
const lightColor = settings.lightColor ? settings.lightColor : '#000000';
const colorIntensity = isNaN(parseInt(settings.colorIntensity)) ? 0 : parseInt(settings.colorIntensity)/100;
const animationType = settings.animationType ? settings.animationType : 'none';
const animationSpeed = isNaN(parseInt(settings.animationSpeed)) ? 1 : parseInt(settings.animationSpeed);
const animationIntensity = isNaN(parseInt(settings.animationIntensity)) ? 1 : parseInt(settings.animationIntensity);
let data = {};
if (isNaN(dimVision)==false) data.dimSight = dimVision;
if (isNaN(brightVision)==false) data.brightSight = brightVision;
if (isNaN(sightAngle)==false) data.sightAngle = sightAngle;
if (isNaN(dimRadius)==false) data.dimLight = dimRadius;
if (isNaN(brightRadius)==false) data.brightLight = brightRadius;
if (isNaN(emissionAngle)==false) data.lightAngle = emissionAngle;
data.lightColor = lightColor;
data.lightAlpha = Math.sqrt(colorIntensity).toNearest(0.05)
let animation = {
type: '',
speed: tokenData.lightAnimation.speed,
intensity: tokenData.lightAnimation.intensity
};
if (animationType != 'none'){
animation.type = animationType;
animation.intensity = animationIntensity;
animation.speed = animationSpeed;
}
data.lightAnimation = animation;
token.update(data);
}
else if (system == 'demonlord' && game.system.id == 'demonlord' && onClick == 'initiative'){
token.actor.update({
'data.fastturn': !token.actor.data?.data?.fastturn
})
}
else if (onClick == 'wildcard') { //wildcard images
const method = settings.wildcardMethod ? settings.wildcardMethod : 'iterate';
let value = parseInt(settings.wildcardValue);
if (isNaN(value)) value = 1;
const images = await token.actor.getTokenImages();
let imgNr;
let iconSrc;
if (method == 'iterate'){
let currentImgNr = 0
for (let i=0; i<images.length; i++)
if (images[i] == token.data.img){
currentImgNr = i;
break;
}
imgNr = currentImgNr + value + this.wildcardOffset;
while (imgNr >= images.length) imgNr -= images.length;
while (imgNr < 0) imgNr += images.length;
}
else if (method == 'set'){
imgNr = value - 1 + this.wildcardOffset;
if (value >= images.length || value < 1) return;
}
else if (method == 'offset'){
this.wildcardOffset = value;
this.update(MODULE.selectedTokenId);
}
else return;
iconSrc = images[imgNr];
token.update({img: iconSrc})
}
else if (onClick == 'custom') {//custom onClick function
const formula = settings.customOnClickFormula ? settings.customOnClickFormula : '';
if (formula == '') return;
let targetArrayTemp;
let formulaArrayTemp;
let split1 = formula.split(';');
for (let i=0; i<split1.length; i++){
let split2 = split1[i].split(' = ');
targetArrayTemp = split2[0];
formulaArrayTemp = split2[1];
let targetArray = this.splitCustom(targetArrayTemp);
for (let i=0; i<targetArray.length; i++){
if (targetArray[i][0] == '@') {
const dataPath = targetArray[i].split('@')[1].split('.');
targetArray[i] = dataPath;
}
}
let formulaArray = this.splitCustom(formulaArrayTemp);
let value = 0;
let previousOperation = '+';
if (formulaArray.length == 1 && formulaArray[0][0] == '[')
value = formulaArray[0].split('[')[1];
else if (formulaArray.length == 1)
value = formulaArray[0];
else {
for (let i=0; i<formulaArray.length; i++){
let val;
if (formulaArray[i][0] == '@') {
let dataPath;
if (formulaArray[i] == '@this') dataPath = targetArray[0];
else dataPath = formulaArray[i].split('@')[1].split('.');
let data = token;
for (let j=0; j<dataPath.length; j++)
data = data?.[dataPath[j]];
if (data == undefined) return;
formulaArray[i] = data;
val = data;
}
else if (isNaN(formulaArray[i])) {
previousOperation = formulaArray[i];
if (previousOperation == '++') value++;
else if (previousOperation == '--') value--;
continue;
}
else
val = parseFloat(formulaArray[i]);
if (previousOperation == '+') value += val;
else if (previousOperation == '-') value -= val;
else if (previousOperation == '*') value *= val;
else if (previousOperation == '/') value /= val;
else if (previousOperation == '**') value **= val;
else if (previousOperation == '%') value %= val;
else if (previousOperation == '<' && value >= val) {value = val-1;}
else if (previousOperation == '>' && value <= val) {value = val+1;}
else if (previousOperation == '<=' && value > val) {value = val;}
else if (previousOperation == '>=' && value < val) {value = val;}
}
}
for (let i=0; i<targetArray.length; i++){
const dataPath = targetArray[i];
let data;
if (dataPath[0] == 'actor') {
let actor = token.actor;
if (dataPath[1] == 'data'){
let path = '';
for (let j=2; j<targetArray[i].length; j++){
if (path != '') path += '.';
path += targetArray[i][j];
}
actor.update({[path]:value})
}
else {
let path = '';
for (let j=1; j<targetArray[i].length; j++){
if (path != '') path += '.';
path += targetArray[i][j];
}
actor.update({[path]:value})
}
}
else {
data = token;
let path = '';
for (let j=1; j<targetArray[i].length; j++){
if (path != '') path += '.';
path += targetArray[i][j];
}
token.update({[path]:value})
}
}
}
}
}
splitCustom(string){
const split = string.split('[');
let array1 = [];
for (let i=0; i<split.length; i++){
if (i>0 && split[i][0] != '@' && split[i] != "" && isNaN(split[i])) split[i] = '['+split[i]
const split2 = split[i].split(']');
for (let j=0; j<split2.length; j++){
array1.push(split2[j]);
}
}
let array2 = [];
for (let i=0; i<array1.length; i++){
if (array1[i][0] == '[') {
array2.push(array1[i]);
continue;
}
const split3 = array1[i].split(' ');
for (let j=0; j<split3.length; j++){
array2.push(split3[j]);
}
}
let array3 = [];
for (let i=0; i<array2.length; i++){
if (array2[i] == "") continue;
array3.push(array2[i]);
}
return array3;
}
pf2eCondition(condition){

193
templates/helpMenu.html Normal file
View File

@@ -0,0 +1,193 @@
<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>
</ul>
<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

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

View File

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

View File

@@ -26,7 +26,7 @@
<div>
<select name="playlist" class="playlist-select" default="" style="width:100%;" id="playlists{{this.iteration}}">
{{#select this.selectedPlaylist}}
{{#each playlists}}
{{#each ../../playlists}}
<option value="{{this.id}}">{{this.name}}</option>
{{/each}}
{{/select}}
@@ -36,17 +36,17 @@
<div style="text-align:center;">
{{localize "MaterialDeck.Sound"}}
</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 this.sound}}
<option value="">{{localize "MaterialDeck.None"}}</option>
{{#each sounds}}
<option value="{{this._id}}">{{this.name}}</option>
<option value="{{this.id}}">{{this.name}}</option>
{{/each}}
{{/select}}
</select>
</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">
<i class="fas fa-file-import fa-fw"></i>
</button>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 17 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: 233 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 609 KiB

After

Width:  |  Height:  |  Size: 598 KiB