10 Commits

Author SHA1 Message Date
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
69 changed files with 997 additions and 395 deletions

View File

@@ -7,6 +7,8 @@ import {CombatTracker} from "./src/combattracker.js";
import {PlaylistControl} from "./src/playlist.js"; import {PlaylistControl} from "./src/playlist.js";
import {SoundboardControl} from "./src/soundboard.js"; import {SoundboardControl} from "./src/soundboard.js";
import {OtherControls} from "./src/othercontrols.js"; import {OtherControls} from "./src/othercontrols.js";
import {ExternalModules} from "./src/external.js";
import {SceneControl} from "./src/scene.js";
export var streamDeck; export var streamDeck;
export var tokenControl; export var tokenControl;
var move; var move;
@@ -15,6 +17,8 @@ export var combatTracker;
export var playlistControl; export var playlistControl;
export var soundboard; export var soundboard;
export var otherControls; export var otherControls;
export var externalModules;
export var sceneControl;
export const moduleName = "MaterialDeck"; export const moduleName = "MaterialDeck";
export var selectedTokenId; export var selectedTokenId;
@@ -48,6 +52,7 @@ async function analyzeWSmessage(msg){
if (data.type == "connected" && data.data == "SD"){ if (data.type == "connected" && data.data == "SD"){
console.log("streamdeck connected to server"); console.log("streamdeck connected to server");
streamDeck.resetImageBuffer();
} }
if (data == undefined || data.payload == undefined) return; if (data == undefined || data.payload == undefined) return;
@@ -82,6 +87,10 @@ async function analyzeWSmessage(msg){
soundboard.update(settings,context); soundboard.update(settings,context);
else if (action == 'other') else if (action == 'other')
otherControls.update(settings,context); otherControls.update(settings,context);
else if (action == 'external')
externalModules.update(settings,context);
else if (action == 'scene')
sceneControl.update(settings,context);
} }
else if (event == 'willDisappear'){ else if (event == 'willDisappear'){
@@ -102,7 +111,11 @@ async function analyzeWSmessage(msg){
else if (action == 'soundboard') else if (action == 'soundboard')
soundboard.keyPressDown(settings); soundboard.keyPressDown(settings);
else if (action == 'other') else if (action == 'other')
otherControls.keyPress(settings); otherControls.keyPress(settings,context);
else if (action == 'external')
externalModules.keyPress(settings,context);
else if (action == 'scene')
sceneControl.keyPress(settings);
} }
else if (event == 'keyUp'){ else if (event == 'keyUp'){
@@ -203,7 +216,8 @@ Hooks.once('ready', ()=>{
combatTracker = new CombatTracker(); combatTracker = new CombatTracker();
playlistControl = new PlaylistControl(); playlistControl = new PlaylistControl();
otherControls = new OtherControls(); otherControls = new OtherControls();
externalModules = new ExternalModules();
sceneControl = new SceneControl();
let soundBoardSettings = game.settings.get(moduleName,'soundboardSettings'); let soundBoardSettings = game.settings.get(moduleName,'soundboardSettings');
let macroSettings = game.settings.get(moduleName, 'macroSettings'); let macroSettings = game.settings.get(moduleName, 'macroSettings');
@@ -287,18 +301,18 @@ Hooks.on('controlToken',(token,controlled)=>{
Hooks.on('renderHotbar', (hotbar)=>{ Hooks.on('renderHotbar', (hotbar)=>{
if (enableModule == false || ready == false) return; if (enableModule == false || ready == false) return;
macroControl.hotbar(hotbar.macros); if (macroControl != undefined) macroControl.hotbar(hotbar.macros);
}); });
Hooks.on('renderCombatTracker',()=>{ Hooks.on('renderCombatTracker',()=>{
if (enableModule == false || ready == false) return; if (enableModule == false || ready == false) return;
combatTracker.updateAll(); if (combatTracker != undefined) combatTracker.updateAll();
tokenControl.update(selectedTokenId); if (tokenControl != undefined) tokenControl.update(selectedTokenId);
}); });
Hooks.on('renderPlaylistDirectory', (playlistDirectory)=>{ Hooks.on('renderPlaylistDirectory', (playlistDirectory)=>{
if (enableModule == false || ready == false) return; if (enableModule == false || ready == false) return;
playlistControl.updateAll(); if (playlistControl != undefined) playlistControl.updateAll();
}); });
Hooks.on('closeplaylistConfigForm', (form)=>{ Hooks.on('closeplaylistConfigForm', (form)=>{
@@ -314,16 +328,19 @@ Hooks.on('pauseGame',()=>{
Hooks.on('renderSidebarTab',()=>{ Hooks.on('renderSidebarTab',()=>{
if (enableModule == false || ready == false) return; if (enableModule == false || ready == false) return;
otherControls.updateAll(); if (otherControls != undefined) otherControls.updateAll();
if (sceneControl != undefined) sceneControl.updateAll();
}); });
Hooks.on('updateScene',()=>{ Hooks.on('updateScene',()=>{
if (enableModule == false || ready == false) return; if (enableModule == false || ready == false) return;
sceneControl.updateAll();
externalModules.updateAll();
otherControls.updateAll(); otherControls.updateAll();
}); });
Hooks.on('renderSceneControls',()=>{ Hooks.on('renderSceneControls',()=>{
if (enableModule == false || ready == false) return; if (enableModule == false || ready == false || otherControls == undefined) return;
otherControls.updateAll(); otherControls.updateAll();
}); });

View File

@@ -81,6 +81,8 @@ If you have any suggestions or bugs to report, feel free to create an issue, con
<b>Author:</b> Cristian Deenen (Cris#6864 on Discord)<br> <b>Author:</b> Cristian Deenen (Cris#6864 on Discord)<br>
<br> <br>
Special thanks to Asmodeus#7588 who made this module possible by generously donating a Stream Deck XL Special thanks to Asmodeus#7588 who made this module possible by generously donating a Stream Deck XL
<br>
Please consider supporting me on <a href="https://www.patreon.com/materialfoundry">Patreon</a>, and feel free to join the Material Foundry <a href="https://discord.gg/3hd4G6TkmA">Discord</a> server.
## Abandonment ## Abandonment
Abandoned modules are a (potential) problem for Foundry, because users and/or other modules might rely on abandoned modules, which might break in future Foundry updates.<br> Abandoned modules are a (potential) problem for Foundry, because users and/or other modules might rely on abandoned modules, which might break in future Foundry updates.<br>

View File

@@ -1,18 +1,71 @@
# Changelog Material Deck Module # Changelog Material Deck Module
### v1.2.1 - 07-01-2021
<b>Note:</b> Due to a change in how scene control is handled (moved from 'Other Controls' to its own 'Scene Action'), any actions related to scenes no longer work. You will have to set them up again using the new Scene Action.<br>
<br>
Additions:
<ul>
<li>EXPERIMENTAL: Added an image buffer to prevent resending of images that have already been sent, giving a slight performance boost. Buffer size can be set in the module settings</li>
<li>Token Action => Display Stats: Added option to select a data path for an attribute</li>
<li>External Modules => GM Screen: Open and close the GM screen. Link to module: https://foundryvtt.com/packages/gm-screen/</li>
<li>Other Actions => Roll dice: Roll dice in foundry and select between public roll, private roll, or displaying result on the SD</li>
<li>Scene Action: Added way to create scene selection screen similar to soundboard/macro board. New functions to do this: 'Scene Directory' and 'Scene Offset'</li>
<li>Scene Action: Added 'Active Scene' function</li>
<li>Move Action => Selected Token: Added rotate to and rotate by functions</li>
<li>Token Action => On Click: Added 'Set Vision' option to set the token's vision and light emission</li>
<li>Other Actions => Send Chat Message: Send a message to the Foundry chat</li>
</ul>
Other Changes:
<ul>
<li>Plugin: Scene Action created that replaces Other Actions => Scene Selection</li>
<li>Plugin: Scene Action: Changed 'Any Scene' to 'Scene by Name'</li>
<li>Plugin: Actions are now ordered alphabetically</li>
<li>Plugin: Replaced color strings with color pickers</li>
<li>Various minor bug fixes</li>
</ul>
<b>Compatible server app and SD plugin:</b><br>
Material Server v1.0.2 (unchanged): https://github.com/CDeenen/MaterialServer/releases <br>
SD plugin v1.2.1: https://github.com/CDeenen/MaterialDeck_SD/releases<br>
### v1.2.0 - 28-12-2020
Fixes
<ul>
<li>Incorrect link to some black backgrounds fixed</li>
<li>Token Action: Movement speed wouldn't be displayed for DnD5e 1.2.0</li>
<li>Macro Action => Hotbar: 10th macro would not trigger and display correctly</li>
<li>Combat Tracker Action => Function: Default value would not properly initialize</li>
<li>Other Actions => Darkness Control => Display would not function correctly</li>
<li>Fixed some issues in the SD plugin where correct settings would not be displayed</li>
</ul>
Additions:
<ul>
<li>Added new 'External Modules Action', which will contain all module integrations that don't fit anywhere else</li>
<li>Added support for the Custom Hotbar module in 'Macro Action' => Mode: 'Custom Hotbar'. Link to module: https://foundryvtt.com/packages/custom-hotbar/</li>
<li>Added support for the FxMaster module in 'External Modules Action' => Mode: 'Fx Master'. Link to module: https://foundryvtt.com/packages/fxmaster/</li>
</ul>
### v1.1.1 - 12-12-2020
Fixes
<ul>
<li>Fixed issue where deleting a playlist would cause an error preventing the Soundboard Configuration to show up</li>
</ul>
<b>Compatible server app and SD plugin:</b><br>
Material Server v1.0.2 (unchanged): https://github.com/CDeenen/MaterialServer/releases <br>
SD plugin v1.1.0 (unchanged): https://github.com/CDeenen/MaterialDeck_SD/releases<br>
### v1.1.0 - 09-12-2020 ### v1.1.0 - 09-12-2020
Fixes Fixes
<ul> <ul>
<li>Settings would not show for Combat Tracker action</li> <li>Settings would not show for Combat Tracker action</li>
<li>Macro Action => Macro Board default settings fixed</li> <li>Macro Action => Macro Board default settings fixed</li>
<li>API has been improved, making integration with other hardware/software easier, and making future changes/additions easier</li>
</ul> </ul>
Additions/changes: Additions:
<ul> <ul>
<li>Added support for Pathfinder 1e and Shadow of the Demon Lord</li> <li>Added support for Pathfinder 1e and Shadow of the Demon Lord</li>
<li>All dialogs that are openable using the SD can now be closed by pressing the button while the dialog is open</li> <li>All dialogs that are openable using the SD can now be closed by pressing the button while the dialog is open</li>
<li>Playlist Action & Soundboard Action => Stop All now indicates if there are tracks/playlists/sounds playing</li> <li>Playlist Action & Soundboard Action => Stop All now indicates if there are tracks/playlists/sounds playing</li>
<li>Confirmed Foundry 0.7.8 compatibility</li> <li>Confirmed Foundry 0.7.8 compatibility</li>
<li>API has been improved, making integration with other hardware/software easier, and making future changes/additions easier</li>
<li>Moved default images to Foundry module side instead of Stream Deck plugin</li>
</ul> </ul>
<b>Compatible server app and SD plugin:</b><br> <b>Compatible server app and SD plugin:</b><br>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

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

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

View File

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

BIN
img/move/rotateccw.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

BIN
img/move/rotatecw.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.8 KiB

View File

@@ -14,6 +14,8 @@
"MaterialDeck.Sett.SoundboardConfig": "Soundboard Configuration", "MaterialDeck.Sett.SoundboardConfig": "Soundboard Configuration",
"MaterialDeck.Sett.ServerAddr": "Material Server Address", "MaterialDeck.Sett.ServerAddr": "Material Server Address",
"MaterialDeck.Sett.ServerAddrHint": "Fill in the IP address and port of the Material Server. Must follow the format [ip_address]:[port], for example: 'localhost:3001' or '192.168.1.1:4000'.", "MaterialDeck.Sett.ServerAddrHint": "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.ImageBuffer": "Image Buffer Size (EXPERIMENTAL)",
"MaterialDeck.Sett.ImageBufferHint": "Sets the amount of images to store in the image buffer. The image buffer will store all images sent to the Steram Deck in a buffer. This greatly improves the update speed, but can use big amounts of memory if set too high.",
"MaterialDeck.PL.Unrestricted": "Unrestricted", "MaterialDeck.PL.Unrestricted": "Unrestricted",
"MaterialDeck.PL.OneTrackPlaylist": "One track per playlist", "MaterialDeck.PL.OneTrackPlaylist": "One track per playlist",
@@ -40,6 +42,9 @@
"MaterialDeck.Off": "Off", "MaterialDeck.Off": "Off",
"MaterialDeck.Name": "Name", "MaterialDeck.Name": "Name",
"MaterialDeck.None": "None", "MaterialDeck.None": "None",
"MaterialDeck.Save": "Save" "MaterialDeck.Save": "Save",
"MaterialDeck.FxMaster.Colorize": "Colorize",
"MaterialDeck.FxMaster.Clear": "Clear All"
} }

View File

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

View File

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

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;
}
async updateAll(){
if (this.active == false) return;
for (let i=0; i<32; i++){
let data = streamDeck.buttonContext[i];
if (data == undefined || data.action != 'external') continue;
await this.update(data.settings,data.context);
}
}
update(settings,context){
this.active = true;
let module = settings.module;
if (module == undefined) 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;
let module = settings.module;
if (module == undefined) 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;
let ringColor = '#00FF00'
let src = '';
let txt = '';
//if (document.getElementsByClassName("gm-screen-app gm-screen-drawer expanded")[0] != undefined) 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;
document.getElementsByClassName("gm-screen-button")[0].click();
}
}

View File

@@ -52,7 +52,6 @@ export class MacroControl{
else ringColor = ringOffColor; else ringColor = ringOffColor;
ring = 2; ring = 2;
//streamDeck.setIcon(context, "", background,ring,ringColor);
} }
else { //Execute macro else { //Execute macro
macroNumber += this.offset - 1; macroNumber += this.offset - 1;
@@ -76,12 +75,16 @@ export class MacroControl{
if (displayName == 0) name = ""; if (displayName == 0) name = "";
streamDeck.setTitle(name,context); streamDeck.setTitle(name,context);
} }
else { //Macro Hotbar else { //Macro Hotbar
let macroId let macroId
if (mode == 'hotbar') macroId = game.user.data.hotbar[macroNumber]; if (mode == 'hotbar') macroId = game.user.data.hotbar[macroNumber];
else { else {
let macros = game.macros.apps[0].macros; let macros;
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++){ for (let j=0; j<10; j++){
if (macros[j].key == macroNumber){ if (macros[j].key == macroNumber){
if (macros[j].macro == null) macroId == undefined; if (macros[j].macro == null) macroId == undefined;
@@ -121,16 +124,17 @@ export class MacroControl{
if(macroNumber == undefined || isNaN(parseInt(macroNumber))){ if(macroNumber == undefined || isNaN(parseInt(macroNumber))){
macroNumber = 1; macroNumber = 1;
} }
if (mode == undefined) mode = 0; if (mode == undefined) mode = 'hotbar';
if (mode == 2) continue; if (mode == 'Macro Board') continue;
if (displayName == undefined) displayName = false; if (displayName == undefined) displayName = false;
if (background == undefined) background = '#000000'; if (background == undefined) background = '#000000';
let macroId; let macroId;
if (mode == 0){ if (mode == 'hotbar'){
macroId = game.user.data.hotbar[macroNumber]; macroId = game.user.data.hotbar[macroNumber];
} }
else { else {
if (macroNumber > 9) macroNumber = 0;
for (let j=0; j<10; j++){ for (let j=0; j<10; j++){
if (macros[j].key == macroNumber){ if (macros[j].key == macroNumber){
if (macros[j].macro == null) macroId == undefined; if (macros[j].macro == null) macroId == undefined;
@@ -159,7 +163,7 @@ export class MacroControl{
macroNumber = 0; macroNumber = 0;
} }
if (mode == 'hotbar' || mode == 'visibleHotbar') if (mode == 'hotbar' || mode == 'visibleHotbar' || mode == 'customHotbar')
this.executeHotbar(macroNumber,mode); this.executeHotbar(macroNumber,mode);
else { else {
if (settings.macroBoardMode == 'offset') { if (settings.macroBoardMode == 'offset') {
@@ -175,9 +179,14 @@ export class MacroControl{
executeHotbar(macroNumber,mode){ executeHotbar(macroNumber,mode){
let macroId let macroId
if (mode == 0) macroId = game.user.data.hotbar[macroNumber]; if (mode == 'hotbar') macroId = game.user.data.hotbar[macroNumber];
else { else {
let macros = game.macros.apps[0].macros; let macros;
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++){ for (let j=0; j<10; j++){
if (macros[j].key == macroNumber){ if (macros[j].key == macroNumber){
if (macros[j].macro == null) macroId == undefined; if (macros[j].macro == null) macroId == undefined;

View File

@@ -359,8 +359,14 @@ export class soundboardConfigForm extends FormApplication {
else if (this.settings.selectedPlaylists[iteration] == 'FP') selectedPlaylist = 'FP'; else if (this.settings.selectedPlaylists[iteration] == 'FP') selectedPlaylist = 'FP';
else { else {
const pl = game.playlists.entities.find(p => p._id == this.settings.selectedPlaylists[iteration]); const pl = game.playlists.entities.find(p => p._id == this.settings.selectedPlaylists[iteration]);
selectedPlaylist = pl._id; if (pl == undefined){
selectedPlaylist = 'none';
sounds = [];
}
else {
sounds = pl.sounds; sounds = pl.sounds;
selectedPlaylist = pl._id;
}
} }
let styleSS = ""; let styleSS = "";
let styleFP ="display:none"; let styleFP ="display:none";

View File

@@ -7,42 +7,53 @@ export class Move{
} }
update(settings,context){ update(settings,context){
let background; const background = settings.background ? settings.background : '#000000';
if (settings.background) background = settings.background; const mode = settings.mode ? settings.mode : 'canvas';
else background = '#000000'; const type = settings.type ? settings.type : 'move';
let url = ''; let url = '';
if (settings.dir == 'center') //center if (mode == 'canvas' || (mode == 'selectedToken' && type == 'move')){
const dir = settings.dir ? settings.dir : 'center';
if (dir == 'center') //center
url = "modules/MaterialDeck/img/move/center.png"; url = "modules/MaterialDeck/img/move/center.png";
else if (settings.dir == 'up') //up else if (dir == 'up') //up
url = "modules/MaterialDeck/img/move/up.png"; url = "modules/MaterialDeck/img/move/up.png";
else if (settings.dir == 'down') //down else if (dir == 'down') //down
url = "modules/MaterialDeck/img/move/down.png"; url = "modules/MaterialDeck/img/move/down.png";
else if (settings.dir == 'right') //right else if (dir == 'right') //right
url = "modules/MaterialDeck/img/move/right.png"; url = "modules/MaterialDeck/img/move/right.png";
else if (settings.dir == 'left') //left else if (dir == 'left') //left
url = "modules/MaterialDeck/img/move/left.png"; url = "modules/MaterialDeck/img/move/left.png";
else if (settings.dir == 'upRight') else if (dir == 'upRight')
url = "modules/MaterialDeck/img/move/upright.png"; url = "modules/MaterialDeck/img/move/upright.png";
else if (settings.dir == 'upLeft') else if (dir == 'upLeft')
url = "modules/MaterialDeck/img/move/upleft.png"; url = "modules/MaterialDeck/img/move/upleft.png";
else if (settings.dir == 'downRight') else if (dir == 'downRight')
url = "modules/MaterialDeck/img/move/downright.png"; url = "modules/MaterialDeck/img/move/downright.png";
else if (settings.dir == 'downLeft') else if (dir == 'downLeft')
url = "modules/MaterialDeck/img/move/downleft.png"; url = "modules/MaterialDeck/img/move/downleft.png";
else if (settings.dir == 'zoomIn') else if (dir == 'zoomIn')
url = "modules/MaterialDeck/img/move/zoomin.png"; url = "modules/MaterialDeck/img/move/zoomin.png";
else if (settings.dir == 'zoomOut') else if (dir == 'zoomOut')
url = "modules/MaterialDeck/img/move/zoomout.png"; url = "modules/MaterialDeck/img/move/zoomout.png";
}
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); streamDeck.setIcon(context,url,background);
} }
keyPress(settings){ keyPress(settings){
if (canvas.scene == null) return; if (canvas.scene == null) return;
let dir = settings.dir; const dir = settings.dir ? settings.dir : 'center';
let mode = settings.mode; const mode = settings.mode ? settings.mode : 'canvas';
if (mode == undefined) mode = 'canvas'; const type = settings.type ? settings.type : 'move';
if (dir == undefined) dir = 'center';
if (type == 'move'){
if (dir == 'zoomIn') {//zoom in if (dir == 'zoomIn') {//zoom in
let viewPosition = canvas.scene._viewPosition; let viewPosition = canvas.scene._viewPosition;
viewPosition.scale = viewPosition.scale*1.05; viewPosition.scale = viewPosition.scale*1.05;
@@ -62,6 +73,20 @@ export class Move{
this.moveCanvas(dir); 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});
}
}
async moveToken(tokenId,dir){ async moveToken(tokenId,dir){
if (tokenId == undefined) return; if (tokenId == undefined) return;

View File

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

196
src/scene.js Normal file
View File

@@ -0,0 +1,196 @@
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++){
let 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){
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 == '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){
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 == '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;
let viewFunc = settings.sceneViewFunction;
if (viewFunc == undefined) viewFunc = '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

@@ -39,6 +39,17 @@ export const registerSettings = function() {
onChange: x => window.location.reload() onChange: x => window.location.reload()
}); });
game.settings.register(MODULE.moduleName, 'imageBuffer', {
name: "MaterialDeck.Sett.ImageBuffer",
hint: "MaterialDeck.Sett.ImageBufferHint",
default: 0,
type: Number,
scope: 'world',
range: { min: 0, max: 500, step: 10 },
config: true
});
/** /**
* Playlist soundboard * Playlist soundboard
*/ */

View File

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

@@ -23,11 +23,11 @@ export class TokenControl{
if (settings.displayIcon) icon = true; if (settings.displayIcon) icon = true;
if (settings.displayName) name = true; if (settings.displayName) name = true;
if (stats == undefined) stats = 'none';
if (settings.background) background = settings.background;
let system = settings.system; let system = settings.system;
if (system == undefined) system = 'dnd5e'; if (system == undefined) system = 'dnd5e';
if (system == 'demonlord') stats = settings.statsDemonlord;
if (stats == undefined) stats = 'none';
if (settings.background) background = settings.background;
let tokenName = ""; let tokenName = "";
let txt = ""; let txt = "";
@@ -40,7 +40,25 @@ export class TokenControl{
if (name && stats != 'none') txt += "\n"; if (name && stats != 'none') txt += "\n";
iconSrc = token.data.img; iconSrc = token.data.img;
let actor = canvas.tokens.children[0].children.find(p => p.id == tokenId).actor; let actor = canvas.tokens.children[0].children.find(p => p.id == tokenId).actor;
if (system == 'dnd5e' && game.system.id == 'dnd5e'){ 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 = actor.data.data.attributes; let attributes = actor.data.data.attributes;
if (stats == 'HP') { if (stats == 'HP') {
txt += attributes.hp.value + "/" + attributes.hp.max; txt += attributes.hp.value + "/" + attributes.hp.max;
@@ -53,7 +71,7 @@ export class TokenControl{
else if (stats == 'AC') txt += attributes.ac.value; else if (stats == 'AC') txt += attributes.ac.value;
else if (stats == 'Speed'){ else if (stats == 'Speed'){
let speed = ""; 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.burrow > 0) speed += game.i18n.localize("DND5E.MovementBurrow") + ': ' + attributes.movement.burrow + attributes.movement.units;
if (attributes.movement.climb > 0) { if (attributes.movement.climb > 0) {
if (speed.length > 0) speed += '\n'; if (speed.length > 0) speed += '\n';
@@ -143,10 +161,10 @@ export class TokenControl{
} }
else if (system == 'demonlord' && game.system.id == 'demonlord'){ else if (system == 'demonlord' && game.system.id == 'demonlord'){
let characteristics = actor.data.data.characteristics; let characteristics = actor.data.data.characteristics;
if (stats == 'HP') txt += characteristics.health.value + "/" + characteristics.health.max; if (statsDemonlord == 'HP') txt += characteristics.health.value + "/" + characteristics.health.max;
else if (stats == 'AC') txt += characteristics.defense; else if (statsDemonlord == 'AC') txt += characteristics.defense;
else if (stats == 'Speed') txt += characteristics.speed; else if (statsDemonlord == 'Speed') txt += characteristics.speed;
else if (stats == 'Init') txt += actor.data.data.fastturn ? "FAST" : "SLOW"; else if (statsDemonlord == 'Init') txt += actor.data.data.fastturn ? "FAST" : "SLOW";
} }
else { else {
//Other systems //Other systems
@@ -406,6 +424,46 @@ export class TokenControl{
this.update(tokenId); 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'){ else if (system == 'demonlord' && game.system.id == 'demonlord' && onClick == 'initiative'){
token.actor.update({ token.actor.update({
'data.fastturn': !token.actor.data?.data?.fastturn 'data.fastturn': !token.actor.data?.data?.fastturn