Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc5dc9ab63 | ||
|
|
64fd6cb132 | ||
|
|
888b089e7b | ||
|
|
959b9c9e4e | ||
|
|
afaf1c9799 | ||
|
|
2947c54eb8 | ||
|
|
561e3f4bd0 | ||
|
|
33f27047b1 | ||
|
|
7c532f5155 | ||
|
|
e62e82795b |
@@ -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;
|
||||
@@ -48,6 +52,7 @@ async function analyzeWSmessage(msg){
|
||||
|
||||
if (data.type == "connected" && data.data == "SD"){
|
||||
console.log("streamdeck connected to server");
|
||||
streamDeck.resetImageBuffer();
|
||||
}
|
||||
|
||||
if (data == undefined || data.payload == undefined) return;
|
||||
@@ -82,6 +87,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 +111,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'){
|
||||
@@ -203,7 +216,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 +301,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 +328,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();
|
||||
});
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
59
changelog.md
@@ -1,18 +1,71 @@
|
||||
# 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
|
||||
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>
|
||||
|
||||
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 7.1 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 6.3 KiB |
|
Before Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 5.0 KiB |
2
img/external/SOURCES.txt
vendored
Normal 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
|
After Width: | Height: | Size: 6.8 KiB |
BIN
img/external/external@2x.png
vendored
Normal file
|
After Width: | Height: | Size: 6.8 KiB |
BIN
img/external/fxmaster.png
vendored
Normal file
|
After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 7.6 KiB |
@@ -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
|
After Width: | Height: | Size: 7.1 KiB |
BIN
img/move/rotatecw.png
Normal file
|
After Width: | Height: | Size: 7.2 KiB |
|
Before Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 8.1 KiB |
@@ -1 +1,2 @@
|
||||
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
|
After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 6.0 KiB |
|
Before Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 17 KiB |
|
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 5.8 KiB |
|
Before Width: | Height: | Size: 5.5 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 5.7 KiB |
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 6.8 KiB |
|
Before Width: | Height: | Size: 5.0 KiB |
|
Before Width: | Height: | Size: 8.9 KiB |
|
Before Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 9.8 KiB |
@@ -14,6 +14,8 @@
|
||||
"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.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.OneTrackPlaylist": "One track per playlist",
|
||||
@@ -40,6 +42,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"
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
"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.1",
|
||||
"author": "CDeenen",
|
||||
"esmodules": [
|
||||
"./MaterialDeck.js"
|
||||
],
|
||||
"socket": true,
|
||||
"minimumCoreVersion": "0.7.5",
|
||||
"compatibleCoreVersion": "0.7.8",
|
||||
"compatibleCoreVersion": "0.7.9",
|
||||
"languages": [
|
||||
{
|
||||
"lang": "en",
|
||||
|
||||
@@ -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';
|
||||
const mode = settings.combatTrackerMode ? settings.combatTrackerMode : 'combatants';
|
||||
const combat = game.combat;
|
||||
|
||||
if (mode == 'function'){
|
||||
let combat = game.combat;
|
||||
if (combat == null || combat == undefined) return;
|
||||
|
||||
let ctFunction = settings.combatTrackerFunction;
|
||||
if (ctFunction == undefined) ctFunction == 'startStop';
|
||||
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
@@ -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();
|
||||
}
|
||||
}
|
||||
27
src/macro.js
@@ -52,7 +52,6 @@ export class MacroControl{
|
||||
else ringColor = ringOffColor;
|
||||
|
||||
ring = 2;
|
||||
//streamDeck.setIcon(context, "", background,ring,ringColor);
|
||||
}
|
||||
else { //Execute macro
|
||||
macroNumber += this.offset - 1;
|
||||
@@ -76,12 +75,16 @@ export class MacroControl{
|
||||
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;
|
||||
@@ -121,16 +124,17 @@ export class MacroControl{
|
||||
if(macroNumber == undefined || isNaN(parseInt(macroNumber))){
|
||||
macroNumber = 1;
|
||||
}
|
||||
if (mode == undefined) mode = 0;
|
||||
if (mode == 2) continue;
|
||||
if (mode == undefined) mode = 'hotbar';
|
||||
if (mode == 'Macro Board') continue;
|
||||
if (displayName == undefined) displayName = false;
|
||||
if (background == undefined) background = '#000000';
|
||||
|
||||
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;
|
||||
@@ -159,7 +163,7 @@ export class MacroControl{
|
||||
macroNumber = 0;
|
||||
}
|
||||
|
||||
if (mode == 'hotbar' || mode == 'visibleHotbar')
|
||||
if (mode == 'hotbar' || mode == 'visibleHotbar' || mode == 'customHotbar')
|
||||
this.executeHotbar(macroNumber,mode);
|
||||
else {
|
||||
if (settings.macroBoardMode == 'offset') {
|
||||
@@ -175,9 +179,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;
|
||||
|
||||
@@ -359,8 +359,14 @@ export class soundboardConfigForm extends FormApplication {
|
||||
else if (this.settings.selectedPlaylists[iteration] == 'FP') selectedPlaylist = 'FP';
|
||||
else {
|
||||
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;
|
||||
selectedPlaylist = pl._id;
|
||||
}
|
||||
}
|
||||
let styleSS = "";
|
||||
let styleFP ="display:none";
|
||||
|
||||
61
src/move.js
@@ -7,42 +7,53 @@ 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
|
||||
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 (settings.dir == 'up') //up
|
||||
else if (dir == 'up') //up
|
||||
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";
|
||||
else if (settings.dir == 'right') //right
|
||||
else if (dir == 'right') //right
|
||||
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";
|
||||
else if (settings.dir == 'upRight')
|
||||
else if (dir == 'upRight')
|
||||
url = "modules/MaterialDeck/img/move/upright.png";
|
||||
else if (settings.dir == 'upLeft')
|
||||
else if (dir == 'upLeft')
|
||||
url = "modules/MaterialDeck/img/move/upleft.png";
|
||||
else if (settings.dir == 'downRight')
|
||||
else if (dir == 'downRight')
|
||||
url = "modules/MaterialDeck/img/move/downright.png";
|
||||
else if (settings.dir == 'downLeft')
|
||||
else if (dir == 'downLeft')
|
||||
url = "modules/MaterialDeck/img/move/downleft.png";
|
||||
else if (settings.dir == 'zoomIn')
|
||||
else if (dir == 'zoomIn')
|
||||
url = "modules/MaterialDeck/img/move/zoomin.png";
|
||||
else if (settings.dir == 'zoomOut')
|
||||
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 (type == 'move'){
|
||||
if (dir == 'zoomIn') {//zoom in
|
||||
let viewPosition = canvas.scene._viewPosition;
|
||||
viewPosition.scale = viewPosition.scale*1.05;
|
||||
@@ -62,6 +73,20 @@ export class Move{
|
||||
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){
|
||||
if (tokenId == undefined) return;
|
||||
|
||||
@@ -4,7 +4,7 @@ import {streamDeck} from "../MaterialDeck.js";
|
||||
export class OtherControls{
|
||||
constructor(){
|
||||
this.active = false;
|
||||
this.offset = 0;
|
||||
this.rollData = {};
|
||||
}
|
||||
|
||||
async updateAll(){
|
||||
@@ -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';
|
||||
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(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;
|
||||
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, {});
|
||||
}
|
||||
}
|
||||
196
src/scene.js
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,17 @@ 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
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Playlist soundboard
|
||||
*/
|
||||
|
||||
@@ -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,12 +177,14 @@ 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: {
|
||||
nr: nr,
|
||||
id: id,
|
||||
image: "" + image,
|
||||
target: 0
|
||||
}
|
||||
@@ -183,6 +192,20 @@ export class StreamDeck{
|
||||
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){
|
||||
if (src == null || src == undefined) src = '';
|
||||
if (src == '') src = 'modules/MaterialDeck/img/black.png';
|
||||
@@ -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
|
||||
@@ -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 = [];
|
||||
}
|
||||
}
|
||||
76
src/token.js
@@ -23,11 +23,11 @@ export class TokenControl{
|
||||
|
||||
if (settings.displayIcon) icon = true;
|
||||
if (settings.displayName) name = true;
|
||||
if (stats == undefined) stats = 'none';
|
||||
if (settings.background) background = settings.background;
|
||||
|
||||
let system = settings.system;
|
||||
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 txt = "";
|
||||
@@ -40,7 +40,25 @@ export class TokenControl{
|
||||
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'){
|
||||
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;
|
||||
if (stats == 'HP') {
|
||||
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 == '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';
|
||||
@@ -143,10 +161,10 @@ export class TokenControl{
|
||||
}
|
||||
else if (system == 'demonlord' && game.system.id == 'demonlord'){
|
||||
let characteristics = 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";
|
||||
if (statsDemonlord == 'HP') txt += characteristics.health.value + "/" + characteristics.health.max;
|
||||
else if (statsDemonlord == 'AC') txt += characteristics.defense;
|
||||
else if (statsDemonlord == 'Speed') txt += characteristics.speed;
|
||||
else if (statsDemonlord == 'Init') txt += actor.data.data.fastturn ? "FAST" : "SLOW";
|
||||
}
|
||||
else {
|
||||
//Other systems
|
||||
@@ -406,6 +424,46 @@ 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
|
||||
|
||||