Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8fa32838d8 | ||
|
|
1552ae6fe8 | ||
|
|
cc9bcf4770 | ||
|
|
7d4fd1e8b1 | ||
|
|
780e06d581 | ||
|
|
64983ca0cb | ||
|
|
dd534488da |
@@ -9,6 +9,7 @@ import {SoundboardControl} from "./src/soundboard.js";
|
||||
import {OtherControls} from "./src/othercontrols.js";
|
||||
import {ExternalModules} from "./src/external.js";
|
||||
import {SceneControl} from "./src/scene.js";
|
||||
import {compatibleCore} from "./src/misc.js";
|
||||
export var streamDeck;
|
||||
export var tokenControl;
|
||||
var move;
|
||||
@@ -28,6 +29,8 @@ let activeSounds = [];
|
||||
|
||||
export let hotbarUses = false;
|
||||
export let calculateHotbarUses;
|
||||
|
||||
|
||||
|
||||
//CONFIG.debug.hooks = true;
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -85,13 +88,13 @@ async function analyzeWSmessage(msg){
|
||||
const event = data.event;
|
||||
const context = data.context;
|
||||
const coordinates = data.payload.coordinates;
|
||||
if (coordinates == undefined) coordinates = 0;
|
||||
const settings = data.payload.settings;
|
||||
|
||||
if (data.data == 'init'){
|
||||
|
||||
}
|
||||
if (event == 'willAppear' || event == 'didReceiveSettings'){
|
||||
if (coordinates == undefined) return;
|
||||
streamDeck.setScreen(action);
|
||||
streamDeck.setContext(action,context,coordinates,settings);
|
||||
|
||||
@@ -118,7 +121,8 @@ async function analyzeWSmessage(msg){
|
||||
}
|
||||
|
||||
else if (event == 'willDisappear'){
|
||||
streamDeck.clearContext(action,coordinates);
|
||||
if (coordinates == undefined) return;
|
||||
streamDeck.clearContext(action,coordinates,context);
|
||||
}
|
||||
|
||||
else if (event == 'keyDown'){
|
||||
@@ -234,9 +238,9 @@ export function getPermission(action,func) {
|
||||
* Attempt to open the websocket
|
||||
*/
|
||||
Hooks.once('ready', async()=>{
|
||||
registerSettings();
|
||||
enableModule = (game.settings.get(moduleName,'Enable')) ? true : false;
|
||||
|
||||
|
||||
soundboard = new SoundboardControl();
|
||||
streamDeck = new StreamDeck();
|
||||
tokenControl = new TokenControl();
|
||||
@@ -250,7 +254,7 @@ Hooks.once('ready', async()=>{
|
||||
|
||||
game.socket.on(`module.MaterialDeck`, async(payload) =>{
|
||||
//console.log(payload);
|
||||
if (payload.msgType == "playSound") playTrack(payload.trackNr,payload.src,payload.play,payload.repeat,payload.volume);
|
||||
if (payload.msgType == "playSound") soundboard.playSound(payload.trackNr,payload.src,payload.play,payload.repeat,payload.volume);
|
||||
else if (game.user.isGM && payload.msgType == "playPlaylist") {
|
||||
const playlist = playlistControl.getPlaylist(payload.playlistNr);
|
||||
playlistControl.playPlaylist(playlist,payload.playlistNr);
|
||||
@@ -339,27 +343,6 @@ Hooks.once('ready', async()=>{
|
||||
|
||||
});
|
||||
|
||||
export function playTrack(soundNr,src,play,repeat,volume){
|
||||
if (play){
|
||||
volume *= game.settings.get("core", "globalInterfaceVolume");
|
||||
|
||||
let howl = new Howl({src, volume, loop: repeat, onend: (id)=>{
|
||||
if (repeat == false){
|
||||
activeSounds[soundNr] = false;
|
||||
}
|
||||
},
|
||||
onstop: (id)=>{
|
||||
activeSounds[soundNr] = false;
|
||||
}});
|
||||
howl.play();
|
||||
activeSounds[soundNr] = howl;
|
||||
}
|
||||
else {
|
||||
activeSounds[soundNr].stop();
|
||||
activeSounds[soundNr] = false;
|
||||
}
|
||||
}
|
||||
|
||||
Hooks.on('updateToken',(scene,token)=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
let tokenId = token._id;
|
||||
@@ -398,10 +381,18 @@ Hooks.on('updateOwnedItem',()=>{
|
||||
})
|
||||
|
||||
Hooks.on('renderHotbar', (hotbar)=>{
|
||||
if (compatibleCore("0.8.1")) return;
|
||||
if (enableModule == false || ready == false) return;
|
||||
if (macroControl != undefined) macroControl.hotbar(hotbar.macros);
|
||||
});
|
||||
|
||||
Hooks.on('render', (app)=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
if (compatibleCore("0.8.1") == false) return;
|
||||
if (app.id == "hotbar" && macroControl != undefined) macroControl.hotbar(app.macros);
|
||||
|
||||
});
|
||||
|
||||
Hooks.on('renderCombatTracker',()=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
if (combatTracker != undefined) combatTracker.updateAll();
|
||||
@@ -424,10 +415,27 @@ Hooks.on('pauseGame',()=>{
|
||||
otherControls.updateAll();
|
||||
});
|
||||
|
||||
Hooks.on('renderSidebarTab',()=>{
|
||||
Hooks.on('renderSidebarTab',(app)=>{
|
||||
const options = {
|
||||
sidebarTab: app.tabName,
|
||||
renderPopout: app.popOut
|
||||
}
|
||||
if (enableModule == false || ready == false) return;
|
||||
if (otherControls != undefined) otherControls.updateAll(options);
|
||||
if (sceneControl != undefined) sceneControl.updateAll();
|
||||
});
|
||||
|
||||
Hooks.on('closeSidebarTab',(app)=>{
|
||||
const options = {
|
||||
sidebarTab: app.tabName,
|
||||
renderPopout: false
|
||||
}
|
||||
if (otherControls != undefined) otherControls.updateAll(options);
|
||||
});
|
||||
|
||||
Hooks.on('changeSidebarTab',()=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
if (otherControls != undefined) otherControls.updateAll();
|
||||
if (sceneControl != undefined) sceneControl.updateAll();
|
||||
});
|
||||
|
||||
Hooks.on('updateScene',()=>{
|
||||
@@ -463,14 +471,30 @@ Hooks.on('closeCompendium',()=>{
|
||||
otherControls.updateAll();
|
||||
});
|
||||
|
||||
Hooks.on('renderJournalSheet',()=>{
|
||||
Hooks.on('renderCompendiumBrowser',()=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
otherControls.updateAll();
|
||||
otherControls.updateAll({renderCompendiumBrowser:true});
|
||||
});
|
||||
|
||||
Hooks.on('closeJournalSheet',()=>{
|
||||
Hooks.on('closeCompendiumBrowser',()=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
otherControls.updateAll();
|
||||
otherControls.updateAll({renderCompendiumBrowser:false});
|
||||
});
|
||||
|
||||
Hooks.on('renderJournalSheet',(sheet)=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
otherControls.updateAll({
|
||||
hook:'renderJournalSheet',
|
||||
sheet:sheet
|
||||
});
|
||||
});
|
||||
|
||||
Hooks.on('closeJournalSheet',(sheet)=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
otherControls.updateAll({
|
||||
hook:'closeJournalSheet',
|
||||
sheet:sheet
|
||||
});
|
||||
});
|
||||
|
||||
Hooks.on('gmScreenOpenClose',(html,isOpen)=>{
|
||||
@@ -488,9 +512,19 @@ Hooks.on('NotYourTurn', ()=>{
|
||||
externalModules.updateAll();
|
||||
})
|
||||
|
||||
Hooks.on('pseudoclockSet', ()=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
externalModules.updateAll();
|
||||
})
|
||||
|
||||
Hooks.on('about-time.clockRunningStatus', ()=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
externalModules.updateAll();
|
||||
})
|
||||
|
||||
Hooks.once('init', ()=>{
|
||||
//CONFIG.debug.hooks = true;
|
||||
registerSettings(); //in ./src/settings.js
|
||||
//registerSettings(); //in ./src/settings.js
|
||||
});
|
||||
|
||||
Hooks.once('canvasReady',()=>{
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
<b>Note:</b><br>
|
||||
At the moment Windows and OSX are supported. Linux has been reported to work, there is no official Linux support for the Stream Deck, but there exist a 3rd party <a href="https://timothycrosley.com/project-7-streamdeck_ui">Stream Deck UI</a> that appears be compatible. To get it working on Linux requires more work, and help I can personally offer is limited.<br>
|
||||
The module works on the native Foundry application, Chrome and Firefox. Safari (you'll need the latest dev version to get Foundry to work on it) doesn't work if your Foundry server is secured, unless you use something like Nginx with which I cannot help you.<br>
|
||||
<b>Note:</b> At the moment Windows and OSX support has been confirmed. Linux support is unknown, there is no official Linux support for the Stream Deck, but there exist a 3rd party <a href="https://timothycrosley.com/project-7-streamdeck_ui">Stream Deck UI</a> that might be compatible.<br>
|
||||
<b>In any case: Proceed at your own risk, I will not take any responsibility if you spent money and the module doesn't work!</b>
|
||||
|
||||
<b>Please read the documentation carefully, especially if you want to modify the default profile!</b>
|
||||
@@ -74,7 +72,7 @@ Module manifest: https://raw.githubusercontent.com/CDeenen/MaterialDeck/Master/m
|
||||
|
||||
## Software Versions & Module Incompatibilities
|
||||
<b>Foundry VTT:</b> Tested on 0.7.9<br>
|
||||
<b>Module Incompatibilities:</b> Combat Utility Belt conditions do not work with the Token Action.<br>
|
||||
<b>Module Incompatibilities:</b> None known.<br>
|
||||
|
||||
## Feedback
|
||||
If you have any suggestions or bugs to report, feel free to create an issue, contact me on Discord (Cris#6864), or send me an email: cdeenen@outlook.com.
|
||||
|
||||
80
changelog.md
80
changelog.md
@@ -1,4 +1,84 @@
|
||||
# Changelog Material Deck Module
|
||||
## v1.3.3
|
||||
Additions:
|
||||
<ul>
|
||||
<li>Other Actions => Open Sidebar Tab: Action now indicates which sidebar tab is open (only works on Foundry 0.8.x)</li>
|
||||
<li>Other Actions => Open Sidebar Tab: Added option to create an pop-out (doesn't work for the chat)</li>
|
||||
<li>Other Actions: Added option to open the pf2e compendium browser</li>
|
||||
<li>Macro Action: Can now call macros by name</li>
|
||||
<li>Token Action => On Click: Added option to call a macro. Currently the macro will be applied to the selected token</li>
|
||||
<li>Token Action => Display Stats: Added saving throws and skill modifiers for most systems</li>
|
||||
<li>Token Action => OnClick: Added 'Dice Roll' option, which allows you to roll ability checks, saving throws and other things (depending on game system)</li>
|
||||
<li>Token Action => Stats => Display HP: Made the heart icon dynamic, so the amount that the heart is filled with red depends on the relative amount of hit points of the token. 25% hp means the lower 25% of the heart is red, 50% hp means the lower 50% of the heart is red, etc</li>
|
||||
<li>Token Action => Stats => Added a '+' before all modifier stats that are bigger than 0</li>
|
||||
<li>Token Action => Custom OnClick: Added support for calling macros. For instructions, please refer to the documentation: https://github.com/CDeenen/MaterialDeck/wiki/Token-Action#custom-on-click-function</li>
|
||||
</ul>
|
||||
|
||||
Fixes:
|
||||
<ul>
|
||||
<li>Other Actions => Pause Game: Pause is now transmitted to all connected clients</li>
|
||||
<li>Token Action => Display Stats: Fixed movement speed for pf2e</li>
|
||||
</ul>
|
||||
|
||||
Other:
|
||||
<ul>
|
||||
<li>Should be compatible with Foundry 0.8.1. Only tested on DnD5e. Please note that any functions that rely on other modules do not work if the other modules are not compatible with 0.8.1</li>
|
||||
</ul>
|
||||
|
||||
<br>
|
||||
<b>Compatible server app and SD plugin:</b><br>
|
||||
Material Server v1.0.2 (unchanged): https://github.com/CDeenen/MaterialServer/releases <br>
|
||||
SD plugin v1.3.4 (<b>must be updated!</b>): https://github.com/CDeenen/MaterialDeck_SD/releases<br>
|
||||
|
||||
## v1.3.2 - 11-03-2021
|
||||
Additions:
|
||||
<ul>
|
||||
<li>Added support for the Multi Action provided by the SD app</li>
|
||||
<li>External Modules Action => Added support for About Time</li>
|
||||
<li>Token Action => Stats: Added 'Ability Scores', 'Ability Score Modifiers', 'Ability Score Saves' (dnd5e only) and 'Proficiency Bonus'</li>
|
||||
<li>Token Action => Stats: Added 'HP (box)' option that displays a box with color that changes depending on the HP</li>
|
||||
<li>Move Action: You can now choose what token should be moved, similar to the Token Action</li>
|
||||
</ul>
|
||||
|
||||
Fixes:
|
||||
<ul>
|
||||
<li>Playlist Action => Relative Offset: Fixed issue with displaying the target playlist name</li>
|
||||
<li>Macro Action: Fixed Hotbar Uses for Shadow of the Demonlord</li>
|
||||
</ul>
|
||||
|
||||
Other:
|
||||
<ul>
|
||||
<li>Macro Action: Improved the way Hotbar Uses are displayed, it is now displayed in a box similar to how the module looks in Foundry</li>
|
||||
<li>Made the way images are generated more flexible to make future additions easier</li>
|
||||
<li></li>
|
||||
</ul>
|
||||
|
||||
<br>
|
||||
<b>Compatible server app and SD plugin:</b><br>
|
||||
Material Server v1.0.2 (unchanged): https://github.com/CDeenen/MaterialServer/releases <br>
|
||||
SD plugin v1.3.2 (<b>must be updated!</b>): https://github.com/CDeenen/MaterialDeck_SD/releases<br>
|
||||
|
||||
### v1.3.1 - 27-02-2021
|
||||
Additions:
|
||||
<ul>
|
||||
<li>Token Action: You can now choose what token should be targeted with the action using: 'Selected Token', 'Token Name', 'Actor Name', 'Token Id' or 'Actor Id'. Added relevant user permissions to the permission configuration</li>
|
||||
<li>Token Action => On Click: Added options 'Select Token' and 'Center on Token and Select Token'</li>
|
||||
<li>Playlist Action: Added relative offset mode, with the option to display the offset target name for playlists</li>
|
||||
<li>Playlist Action => Stop All: Added option to display the name of the playlist at the current offset</li>
|
||||
</ul>
|
||||
|
||||
Fixes:
|
||||
<ul>
|
||||
<li>Default user permissions would not be loaded if no previously saved permissions were present, resulting in MD assuming nobody has any permissions</li>
|
||||
<li>Other Actions => Control Buttons => Lighting Controls: Would create a button for ambient sound instead of lighting</li>
|
||||
<li>Token Action => Display Token Icon: It used to show the icon, even if unchecked, if no stat with default icon was selected</li>
|
||||
</ul>
|
||||
|
||||
<br>
|
||||
<b>Compatible server app and SD plugin:</b><br>
|
||||
Material Server v1.0.2 (unchanged): https://github.com/CDeenen/MaterialServer/releases <br>
|
||||
SD plugin v1.3.1 (<b>must be updated!</b>): https://github.com/CDeenen/MaterialDeck_SD/releases<br>
|
||||
|
||||
### v1.3.0 - 25-02-2021
|
||||
Additions:
|
||||
<ul>
|
||||
|
||||
BIN
img/token/.thumb/hp_empty.png.jpg
Normal file
BIN
img/token/.thumb/hp_empty.png.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
BIN
img/token/hp_empty.png
Normal file
BIN
img/token/hp_empty.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
14
lang/en.json
14
lang/en.json
@@ -91,6 +91,8 @@
|
||||
"MaterialDeck.Perm.MACRO.label": "Macros",
|
||||
"MaterialDeck.Perm.MACRO.HOTBAR.label": "Hotbar Macros",
|
||||
"MaterialDeck.Perm.MACRO.HOTBAR.hint": "Allow users to use hotbar macros",
|
||||
"MaterialDeck.Perm.MACRO.BY_NAME.label": "Macro by Name",
|
||||
"MaterialDeck.Perm.MACRO.BY_NAME.hint": "Allow users to call macros by name",
|
||||
"MaterialDeck.Perm.MACRO.MACROBOARD.label": "Macro Board",
|
||||
"MaterialDeck.Perm.MACRO.MACROBOARD.hint": "Allow users to use the macro board",
|
||||
"MaterialDeck.Perm.MACRO.MACROBOARD_CONFIGURE.label": "Configure the Macro Board",
|
||||
@@ -164,6 +166,16 @@
|
||||
"MaterialDeck.Perm.TOKEN.CONDITIONS.label": "Set Conditions",
|
||||
"MaterialDeck.Perm.TOKEN.CONDITIONS.hint": "Allow the users to set conditions for the controlled token",
|
||||
"MaterialDeck.Perm.TOKEN.CUSTOM.label": "Custom On-Click",
|
||||
"MaterialDeck.Perm.TOKEN.CUSTOM.hint": "Allow the users to set custom on-click functions"
|
||||
"MaterialDeck.Perm.TOKEN.CUSTOM.hint": "Allow the users to set custom on-click functions",
|
||||
"MaterialDeck.Perm.TOKEN.NON_OWNED.label": "Non-Owned and Non-Observer Tokens",
|
||||
"MaterialDeck.Perm.TOKEN.NON_OWNED.hint": "Allow users access to tokens with non-owned or limited permission",
|
||||
"MaterialDeck.Perm.TOKEN.OBSERVER.label": "Observer",
|
||||
"MaterialDeck.Perm.TOKEN.OBSERVER.hint": "Allow users access to tokens with observer permission",
|
||||
|
||||
"MaterialDeck.AboutTime.First": "st",
|
||||
"MaterialDeck.AboutTime.Second": "nd",
|
||||
"MaterialDeck.AboutTime.Third": "rd",
|
||||
"MaterialDeck.AboutTime.Fourth": "th",
|
||||
"MaterialDeck.AboutTime.Of": "of"
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
"name": "MaterialDeck",
|
||||
"title": "Material Deck",
|
||||
"description": "Material Deck allows you to control Foundry using an Elgato Stream Deck",
|
||||
"version": "1.3.0",
|
||||
"minimumSDversion": "1.3.0",
|
||||
"version": "1.3.3",
|
||||
"minimumSDversion": "1.3.4",
|
||||
"minimumMSversion": "1.0.2",
|
||||
"author": "CDeenen",
|
||||
"esmodules": [
|
||||
@@ -11,7 +11,7 @@
|
||||
],
|
||||
"socket": true,
|
||||
"minimumCoreVersion": "0.7.5",
|
||||
"compatibleCoreVersion": "0.7.9",
|
||||
"compatibleCoreVersion": "0.8.1",
|
||||
"languages": [
|
||||
{
|
||||
"lang": "en",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as MODULE from "../MaterialDeck.js";
|
||||
import {streamDeck, tokenControl} from "../MaterialDeck.js";
|
||||
import {compatibleCore} from "./misc.js";
|
||||
|
||||
export class CombatTracker{
|
||||
constructor(){
|
||||
@@ -28,7 +29,7 @@ export class CombatTracker{
|
||||
|
||||
if (mode == 'combatants'){
|
||||
if (MODULE.getPermission('COMBAT','DISPLAY_COMBATANTS') == false) {
|
||||
streamDeck.noPermission(context);
|
||||
streamDeck.noPermission(context,false,"combat tracker");
|
||||
return;
|
||||
}
|
||||
if (combat != null && combat != undefined && combat.turns.length != 0){
|
||||
@@ -39,17 +40,17 @@ export class CombatTracker{
|
||||
const combatant = initiativeOrder[nr]
|
||||
|
||||
if (combatant != undefined){
|
||||
const tokenId = combatant.tokenId;
|
||||
const tokenId = compatibleCore("0.8.1") ? combatant.data.tokenId : combatant.tokenId;
|
||||
tokenControl.pushData(tokenId,settings,context,combatantState,'#cccc00');
|
||||
return;
|
||||
}
|
||||
else {
|
||||
streamDeck.setIcon(context,src,background);
|
||||
streamDeck.setIcon(context,src,{background:background});
|
||||
streamDeck.setTitle(txt,context);
|
||||
}
|
||||
}
|
||||
else {
|
||||
streamDeck.setIcon(context,src,background);
|
||||
streamDeck.setIcon(context,src,{background:background});
|
||||
streamDeck.setTitle(txt,context);
|
||||
}
|
||||
}
|
||||
@@ -59,11 +60,11 @@ export class CombatTracker{
|
||||
return;
|
||||
}
|
||||
if (combat != null && combat != undefined && combat.started){
|
||||
const tokenId = combat.combatant.tokenId;
|
||||
const tokenId = compatibleCore("0.8.1") ? combat.combatant.data.tokenId : combat.combatant.tokenId;
|
||||
tokenControl.pushData(tokenId,settings,context);
|
||||
}
|
||||
else {
|
||||
streamDeck.setIcon(context,src,background);
|
||||
streamDeck.setIcon(context,src,{background:background});
|
||||
streamDeck.setTitle(txt,context);
|
||||
}
|
||||
}
|
||||
@@ -125,7 +126,7 @@ export class CombatTracker{
|
||||
if (txt != "") txt += "\n";
|
||||
if (settings.displayTurn) txt += "Turn\n"+turn;
|
||||
}
|
||||
streamDeck.setIcon(context,src,background);
|
||||
streamDeck.setIcon(context,src,{background:background});
|
||||
streamDeck.setTitle(txt,context);
|
||||
}
|
||||
}
|
||||
@@ -164,11 +165,11 @@ export class CombatTracker{
|
||||
src = "modules/MaterialDeck/img/combattracker/stopcombat.png";
|
||||
background = "#FF0000";
|
||||
}
|
||||
streamDeck.setIcon(context,src,background);
|
||||
streamDeck.setIcon(context,src,{background:background});
|
||||
return;
|
||||
}
|
||||
if (game.combat.started == false) return;
|
||||
|
||||
|
||||
if (ctFunction == 'nextTurn') game.combat.nextTurn();
|
||||
else if (ctFunction == 'prevTurn') game.combat.previousTurn();
|
||||
else if (ctFunction == 'nextRound') game.combat.nextRound();
|
||||
@@ -185,12 +186,12 @@ export class CombatTracker{
|
||||
if (nr == undefined || nr < 1) nr = 0;
|
||||
const combatant = initiativeOrder[nr]
|
||||
if (combatant == undefined) return;
|
||||
tokenId = combatant.tokenId;
|
||||
tokenId = compatibleCore("0.8.1") ? combatant.data.tokenId : combatant.tokenId;
|
||||
}
|
||||
}
|
||||
else if (mode == 'currentCombatant')
|
||||
if (combat != null && combat != undefined && combat.started)
|
||||
tokenId = combat.combatant.tokenId;
|
||||
tokenId = compatibleCore("0.8.1") ? combat.combatant.data.tokenId : combat.combatant.tokenId;
|
||||
|
||||
let token = (canvas.tokens.children[0] != undefined) ? canvas.tokens.children[0].children.find(p => p.id == tokenId) : undefined;
|
||||
if (token == undefined) return;
|
||||
|
||||
241
src/external.js
241
src/external.js
@@ -30,6 +30,7 @@ export class ExternalModules{
|
||||
else if (module == 'mookAI') this.updateMookAI(settings,context);
|
||||
else if (module == 'notYourTurn') this.updateNotYourTurn(settings,context);
|
||||
else if (module == 'lockView') this.updateLockView(settings,context);
|
||||
else if (module == 'aboutTime') this.updateAboutTime(settings,context);
|
||||
}
|
||||
|
||||
keyPress(settings,context){
|
||||
@@ -43,7 +44,7 @@ export class ExternalModules{
|
||||
else if (module == 'mookAI') this.keyPressMookAI(settings,context);
|
||||
else if (module == 'notYourTurn') this.keyPressNotYourTurn(settings,context);
|
||||
else if (module == 'lockView') this.keyPressLockView(settings,context);
|
||||
|
||||
else if (module == 'aboutTime') this.keyPressAboutTime(settings,context);
|
||||
}
|
||||
|
||||
getModuleEnable(moduleId){
|
||||
@@ -124,8 +125,8 @@ export class ExternalModules{
|
||||
name = game.i18n.localize("MaterialDeck.FxMaster.Clear");
|
||||
}
|
||||
|
||||
if (displayIcon) streamDeck.setIcon(context,icon,background,ring,ringColor);
|
||||
else streamDeck.setIcon(context, "", background,ring,ringColor);
|
||||
if (displayIcon) streamDeck.setIcon(context,icon,{background:background,ring:ring,ringColor:ringColor});
|
||||
else streamDeck.setIcon(context, "", {background:background,ring:ring,ringColor:ringColor});
|
||||
if (displayName == 0) name = "";
|
||||
streamDeck.setTitle(name,context);
|
||||
}
|
||||
@@ -269,7 +270,7 @@ export class ExternalModules{
|
||||
if (this.gmScreenOpen) ring = 2;
|
||||
|
||||
if (settings.displayGmScreenIcon) src = "fas fa-book-reader";
|
||||
streamDeck.setIcon(context,src,background,ring,ringColor);
|
||||
streamDeck.setIcon(context,src,{background:background,ring:ring,ringColor:ringColor});
|
||||
if (settings.displayGmScreenName) txt = game.i18n.localize(`GMSCR.gmScreen.Open`);
|
||||
streamDeck.setTitle(txt,context);
|
||||
}
|
||||
@@ -295,8 +296,8 @@ export class ExternalModules{
|
||||
const ringColor = game.settings.get("trigger-happy", "enableTriggers") ? "#A600FF" : "#340057";
|
||||
|
||||
let txt = '';
|
||||
if (displayIcon) streamDeck.setIcon(context,"fas fa-grin-squint-tears",background,2,ringColor);
|
||||
else streamDeck.setIcon(context,'','#000000');
|
||||
if (displayIcon) streamDeck.setIcon(context,"fas fa-grin-squint-tears",{background:background,ring:2,ringColor:ringColor});
|
||||
else streamDeck.setIcon(context,'',{background:'#000000'});
|
||||
if (displayName) txt = 'Trigger Happy';
|
||||
|
||||
streamDeck.setTitle(txt,context);
|
||||
@@ -336,8 +337,8 @@ export class ExternalModules{
|
||||
const ringColor = game.settings.get("SharedVision", "enable") ? "#A600FF" : "#340057";
|
||||
|
||||
let txt = '';
|
||||
if (displayIcon) streamDeck.setIcon(context,"fas fa-eye",background,2,ringColor);
|
||||
else streamDeck.setIcon(context,'','#000000');
|
||||
if (displayIcon) streamDeck.setIcon(context,"fas fa-eye",{background:background,ring:2,ringColor:ringColor});
|
||||
else streamDeck.setIcon(context,'',{background:'#000000'});
|
||||
if (displayName) txt = 'Shared Vision';
|
||||
streamDeck.setTitle(txt,context);
|
||||
}
|
||||
@@ -366,8 +367,8 @@ export class ExternalModules{
|
||||
const background = "#000000";
|
||||
|
||||
let txt = '';
|
||||
if (displayIcon) streamDeck.setIcon(context,"fas fa-brain",'#000000');
|
||||
else streamDeck.setIcon(context,'','#000000');
|
||||
if (displayIcon) streamDeck.setIcon(context,"fas fa-brain",{background:'#000000'});
|
||||
else streamDeck.setIcon(context,'',{background:'#000000'});
|
||||
if (displayName) txt = 'Mook AI';
|
||||
streamDeck.setTitle(txt,context);
|
||||
}
|
||||
@@ -408,8 +409,8 @@ export class ExternalModules{
|
||||
txt = "Block Non-Combat Movement";
|
||||
ringColor = game.settings.get('NotYourTurn','nonCombat') ? "#A600FF": "#340057" ;
|
||||
}
|
||||
if (displayIcon) streamDeck.setIcon(context,icon,background,2,ringColor);
|
||||
else streamDeck.setIcon(context,'','#000000');
|
||||
if (displayIcon) streamDeck.setIcon(context,icon,{background:background,ring:2,ringColor:ringColor});
|
||||
else streamDeck.setIcon(context,'',{background:'#000000'});
|
||||
if (displayName == false) txt = '';
|
||||
streamDeck.setTitle(txt,context);
|
||||
}
|
||||
@@ -431,6 +432,7 @@ export class ExternalModules{
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//Lock View
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
updateLockView(settings,context) {
|
||||
|
||||
if (this.getModuleEnable("LockView") == false) return;
|
||||
@@ -461,8 +463,8 @@ export class ExternalModules{
|
||||
ringColor = canvas.scene.getFlag('LockView', 'boundingBox') ? "#A600FF": "#340057" ;
|
||||
}
|
||||
|
||||
if (displayIcon) streamDeck.setIcon(context,icon,background,2,ringColor);
|
||||
else streamDeck.setIcon(context,'','#000000');
|
||||
if (displayIcon) streamDeck.setIcon(context,icon,{background:background,ring:2,ringColor:ringColor});
|
||||
else streamDeck.setIcon(context,'',{background:'#000000'});
|
||||
if (displayName == false) txt = '';
|
||||
streamDeck.setTitle(txt,context);
|
||||
}
|
||||
@@ -483,6 +485,217 @@ export class ExternalModules{
|
||||
|
||||
Hooks.call("setLockView",msg);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//About Time
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
updateAboutTime(settings,context) {
|
||||
if (this.getModuleEnable("about-time") == false) return;
|
||||
if (game.user.isGM == false) return;
|
||||
|
||||
const displayTime = settings.aboutTimeDisplayTime ? settings.aboutTimeDisplayTime : 'none';
|
||||
const displayDate = settings.aboutTimeDisplayDate ? settings.aboutTimeDisplayDate : 'none';
|
||||
const background = settings.aboutTimeBackground ? settings.aboutTimeBackground : '#000000';
|
||||
const ringOffColor = settings.aboutTimeOffRing ? settings.aboutTimeOffRing : '#000000';
|
||||
const ringOnColor = settings.aboutTimeOnRing ? settings.aboutTimeOnRing : '#00FF00';
|
||||
|
||||
let ring = 0;
|
||||
let ringColor = '#000000';
|
||||
let txt = '';
|
||||
let currentTime = game.Gametime.DTNow().longDateExtended();
|
||||
let clock = 'none';
|
||||
|
||||
if (displayTime == 'clock') {
|
||||
const hours = currentTime.hour > 12 ? currentTime.hour-12 : currentTime.hour;
|
||||
clock = {
|
||||
hours: hours,
|
||||
minutes: currentTime.minute
|
||||
}
|
||||
}
|
||||
else if (displayTime != 'none') {
|
||||
let hours;
|
||||
let AMPM = "";
|
||||
if ((displayTime == 'compact12h' || displayTime == 'full12h' || displayTime == 'hours12h') && currentTime.hour > 12) {
|
||||
hours = currentTime.hour - 12;
|
||||
AMPM = " PM";
|
||||
}
|
||||
else if ((displayTime == 'compact12h' || displayTime == 'full12h' || displayTime == 'hours12h') && currentTime.hour <= 12) {
|
||||
hours = currentTime.hour;
|
||||
AMPM = " AM";
|
||||
}
|
||||
else {
|
||||
hours = currentTime.hour;
|
||||
}
|
||||
if (displayTime == 'hours24h' || displayTime == 'hours12h') txt = hours;
|
||||
else if (displayTime == 'minutes') txt = currentTime.minute;
|
||||
else if (displayTime == 'seconds') txt = currentTime.second;
|
||||
else {
|
||||
if (currentTime.minute < 10) currentTime.minute = '0' + currentTime.minute;
|
||||
if (currentTime.second < 10) currentTime.second = '0' + currentTime.second;
|
||||
txt += hours + ':' + currentTime.minute;
|
||||
if (displayTime == 'full24h' || displayTime == 'full12h') txt += ':' + currentTime.second;
|
||||
}
|
||||
if (displayTime == 'compact12h' || displayTime == 'full12h' || displayTime == 'hours12h') txt += AMPM;
|
||||
}
|
||||
if (displayTime != 'none' && displayTime != 'clock' && displayDate != 'none') txt += '\n';
|
||||
|
||||
if (displayDate == 'day') txt += currentTime.day;
|
||||
else if (displayDate == 'dayName') txt += currentTime.dowString;
|
||||
else if (displayDate == 'month') txt += currentTime.month;
|
||||
else if (displayDate == 'monthName') txt += currentTime.monthString;
|
||||
else if (displayDate == 'year') txt += currentTime.year;
|
||||
else if (displayDate == 'small') txt += currentTime.day + '-' + currentTime.month;
|
||||
else if (displayDate == 'smallInv') txt += currentTime.month + '-' + currentTime.day;
|
||||
else if (displayDate == 'full') txt += currentTime.day + '-' + currentTime.month + '-' + currentTime.year;
|
||||
else if (displayDate == 'fullInv') txt += currentTime.month + '-' + currentTime.day + '-' + currentTime.year;
|
||||
else if (displayDate == 'text' || displayDate == 'textDay') {
|
||||
|
||||
if (displayDate == 'textDay') txt += currentTime.dowString + ' ';
|
||||
txt += currentTime.day;
|
||||
if (currentTime.day % 10 == 1 && currentTime != 11) txt += game.i18n.localize("MaterialDeck.AboutTime.First");
|
||||
else if (currentTime.day % 10 == 2 && currentTime != 12) txt += game.i18n.localize("MaterialDeck.AboutTime.Second");
|
||||
else if (currentTime.day % 10 == 3 && currentTime != 13) txt += game.i18n.localize("MaterialDeck.AboutTime.Third");
|
||||
else txt += game.i18n.localize("MaterialDeck.AboutTime.Fourth");
|
||||
txt += ' ' + game.i18n.localize("MaterialDeck.AboutTime.Of") + ' ' + currentTime.monthString + ', ' + currentTime.year;
|
||||
}
|
||||
|
||||
if (settings.aboutTimeActive) {
|
||||
const clockRunning = game.Gametime.isRunning();
|
||||
ringColor = clockRunning ? ringOnColor : ringOffColor;
|
||||
ring = 2;
|
||||
}
|
||||
|
||||
streamDeck.setTitle(txt,context);
|
||||
streamDeck.setIcon(context,'',{background:background,ring:ring,ringColor:ringColor, clock:clock});
|
||||
}
|
||||
|
||||
keyPressAboutTime(settings,context) {
|
||||
if (this.getModuleEnable("about-time") == false) return;
|
||||
if (game.user.isGM == false) return;
|
||||
|
||||
const onClick = settings.aboutTimeOnClick ? settings.aboutTimeOnClick : 'none';
|
||||
if (onClick == 'none') return;
|
||||
else if (onClick == 'startStop') {
|
||||
const clockRunning = game.Gametime.isRunning();
|
||||
const startMode = settings.aboutTimeStartStopMode ? settings.aboutTimeStartStopMode : 'toggle';
|
||||
if ((startMode == 'toggle' && clockRunning) || startMode == 'stop') game.Gametime.stopRunning();
|
||||
else if ((startMode == 'toggle' && !clockRunning) || startMode == 'start') game.Gametime.startRunning();
|
||||
}
|
||||
else if (onClick == 'advance') {
|
||||
const advanceMode = settings.aboutTimeAdvanceMode ? settings.aboutTimeAdvanceMode : 'dawn';
|
||||
let now = Gametime.DTNow();
|
||||
if (advanceMode == 'dawn') {
|
||||
let newDT = now.add({
|
||||
days: now.hours < 7 ? 0 : 1
|
||||
}).setAbsolute({
|
||||
hours: 7,
|
||||
minutes: 0,
|
||||
seconds: 0
|
||||
});
|
||||
Gametime.setAbsolute(newDT);
|
||||
}
|
||||
else if (advanceMode == 'noon') {
|
||||
let newDT = now.add({
|
||||
days: now.hours < 12 ? 0 : 1
|
||||
}).setAbsolute({
|
||||
hours: 12,
|
||||
minutes: 0,
|
||||
seconds: 0
|
||||
});
|
||||
Gametime.setAbsolute(newDT);
|
||||
}
|
||||
else if (advanceMode == 'dusk') {
|
||||
let newDT = now.add({
|
||||
days: now.hours < 20 ? 0 : 1
|
||||
}).setAbsolute({
|
||||
hours: 20,
|
||||
minutes: 0,
|
||||
seconds: 0
|
||||
});
|
||||
Gametime.setAbsolute(newDT);
|
||||
}
|
||||
else if (advanceMode == 'midnight') {
|
||||
let newDT = Gametime.DTNow().add({
|
||||
days: 1
|
||||
}).setAbsolute({
|
||||
hours: 0,
|
||||
minutes: 0,
|
||||
seconds: 0
|
||||
});
|
||||
Gametime.setAbsolute(newDT);
|
||||
}
|
||||
else if (advanceMode == '1s')
|
||||
game.Gametime.advanceClock(1);
|
||||
else if (advanceMode == '30s')
|
||||
game.Gametime.advanceClock(30);
|
||||
|
||||
else if (advanceMode == '1m')
|
||||
game.Gametime.advanceTime({ minutes: 1 });
|
||||
else if (advanceMode == '5m')
|
||||
game.Gametime.advanceTime({ minutes: 5 });
|
||||
else if (advanceMode == '15m')
|
||||
game.Gametime.advanceTime({ minutes: 15 });
|
||||
else if (advanceMode == '1h')
|
||||
game.Gametime.advanceTime({ hours: 1 });
|
||||
}
|
||||
else if (onClick == 'recede') {
|
||||
const advanceMode = settings.aboutTimeAdvanceMode ? settings.aboutTimeAdvanceMode : 'dawn';
|
||||
let now = Gametime.DTNow();
|
||||
if (advanceMode == 'dawn') {
|
||||
let newDT = now.add({
|
||||
days: now.hours < 7 ? -1 : 0
|
||||
}).setAbsolute({
|
||||
hours: 7,
|
||||
minutes: 0,
|
||||
seconds: 0
|
||||
});
|
||||
Gametime.setAbsolute(newDT);
|
||||
}
|
||||
else if (advanceMode == 'noon') {
|
||||
let newDT = now.add({
|
||||
days: now.hours < 12 ? -1 : 0
|
||||
}).setAbsolute({
|
||||
hours: 12,
|
||||
minutes: 0,
|
||||
seconds: 0
|
||||
});
|
||||
Gametime.setAbsolute(newDT);
|
||||
}
|
||||
else if (advanceMode == 'dusk') {
|
||||
let newDT = now.add({
|
||||
days: now.hours < 20 ? -1 : 0
|
||||
}).setAbsolute({
|
||||
hours: 20,
|
||||
minutes: 0,
|
||||
seconds: 0
|
||||
});
|
||||
Gametime.setAbsolute(newDT);
|
||||
}
|
||||
else if (advanceMode == 'midnight') {
|
||||
let newDT = Gametime.DTNow().add({
|
||||
days: -1
|
||||
}).setAbsolute({
|
||||
hours: 0,
|
||||
minutes: 0,
|
||||
seconds: 0
|
||||
});
|
||||
Gametime.setAbsolute(newDT);
|
||||
}
|
||||
else if (advanceMode == '1s')
|
||||
game.Gametime.advanceClock(-1);
|
||||
else if (advanceMode == '30s')
|
||||
game.Gametime.advanceClock(-30);
|
||||
|
||||
else if (advanceMode == '1m')
|
||||
game.Gametime.advanceTime({ minutes: -1 });
|
||||
else if (advanceMode == '5m')
|
||||
game.Gametime.advanceTime({ minutes: -5 });
|
||||
else if (advanceMode == '15m')
|
||||
game.Gametime.advanceTime({ minutes: -15 });
|
||||
else if (advanceMode == '1h')
|
||||
game.Gametime.advanceTime({ hours: -1 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
89
src/macro.js
89
src/macro.js
@@ -1,5 +1,6 @@
|
||||
import * as MODULE from "../MaterialDeck.js";
|
||||
import {streamDeck} from "../MaterialDeck.js";
|
||||
import {compatibleCore} from "./misc.js";
|
||||
|
||||
export class MacroControl{
|
||||
constructor(){
|
||||
@@ -32,6 +33,7 @@ export class MacroControl{
|
||||
let name = "";
|
||||
let src = "";
|
||||
let macroId = undefined;
|
||||
let uses = undefined;
|
||||
|
||||
if (mode == 'macroBoard') { //Macro board
|
||||
if ((MODULE.getPermission('MACRO','MACROBOARD') == false )) {
|
||||
@@ -57,6 +59,11 @@ export class MacroControl{
|
||||
ring = 0;
|
||||
}
|
||||
}
|
||||
else if (mode == 'name') { //macro by name
|
||||
const macroName = settings.macroNumber;
|
||||
const macro = game.macros.getName(macroName);
|
||||
macroId = macro?.id;
|
||||
}
|
||||
else { //Macro Hotbar
|
||||
if ((MODULE.getPermission('MACRO','HOTBAR') == false )) {
|
||||
streamDeck.noPermission(context);
|
||||
@@ -70,10 +77,7 @@ export class MacroControl{
|
||||
else
|
||||
macros = game.macros.apps[0].macros;
|
||||
if (macroNumber > 9) macroNumber = 0;
|
||||
for (let j=0; j<10; j++){
|
||||
if (macros[j].key == macroNumber)
|
||||
macroId = (macros[j].macro == null) ? undefined : macros[j].macro._id;
|
||||
}
|
||||
macroId = game.macros.apps[0].macros.find(m => m.key == macroNumber).macro?.id
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,19 +87,15 @@ export class MacroControl{
|
||||
if (macro != undefined) {
|
||||
if (displayName) name = macro.name;
|
||||
if (displayIcon) src = macro.img;
|
||||
if (MODULE.hotbarUses && displayUses) {
|
||||
const uses = await this.getUses(macro);
|
||||
if (uses != null){
|
||||
name += '\n(' + uses.available;
|
||||
if (uses.maximum != undefined) name += '/' + uses.maximum;
|
||||
name += ')';
|
||||
}
|
||||
}
|
||||
if (MODULE.hotbarUses && displayUses) uses = await this.getUses(macro);
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
if (displayName) name = "";
|
||||
if (displayIcon) src = "modules/MaterialDeck/img/black.png";
|
||||
}
|
||||
|
||||
streamDeck.setIcon(context,src,background,ring,ringColor);
|
||||
streamDeck.setIcon(context,src,{background:background,ring:ring,ringColor:ringColor,uses:uses});
|
||||
streamDeck.setTitle(name,context);
|
||||
}
|
||||
|
||||
@@ -136,28 +136,17 @@ export class MacroControl{
|
||||
}
|
||||
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;
|
||||
else macroId = macros[j].macro._id;
|
||||
}
|
||||
}
|
||||
macroId = game.macros.apps[0].macros.find(m => m.key == macroNumber).macro?.id
|
||||
}
|
||||
let macro = undefined;
|
||||
let uses = undefined;
|
||||
if (macroId != undefined) macro = game.macros._source.find(p => p._id == macroId);
|
||||
if (macro != undefined && macro != null) {
|
||||
if (displayName) name += macro.name;
|
||||
if (displayIcon) src += macro.img;
|
||||
if (MODULE.hotbarUses && displayUses) {
|
||||
const uses = await this.getUses(macro);
|
||||
if (uses != null){
|
||||
name += '\n(' + uses.available;
|
||||
if (uses.maximum != undefined) name += '/' + uses.maximum;
|
||||
name += ')';
|
||||
}
|
||||
}
|
||||
if (MODULE.hotbarUses && displayUses) uses = await this.getUses(macro);
|
||||
}
|
||||
streamDeck.setIcon(context,src,background);
|
||||
streamDeck.setIcon(context,src,{background:background,uses:uses});
|
||||
streamDeck.setTitle(name,context);
|
||||
}
|
||||
}
|
||||
@@ -166,11 +155,44 @@ export class MacroControl{
|
||||
const mode = settings.macroMode ? settings.macroMode : 'hotbar';
|
||||
let macroNumber = settings.macroNumber;
|
||||
if(macroNumber == undefined || isNaN(parseInt(macroNumber))) macroNumber = 0;
|
||||
let target = settings.target ? settings.target : undefined;
|
||||
//const targetActor = target.actor ? undefined : target;
|
||||
//if (targetActor != undefined) target = undefined;
|
||||
|
||||
//let macroTarget = {
|
||||
// token: target,
|
||||
// actor: targetActor
|
||||
//}
|
||||
//console.log('target',macroTarget,mode);
|
||||
|
||||
if (mode == 'hotbar' || mode == 'visibleHotbar' || mode == 'customHotbar'){
|
||||
if ((MODULE.getPermission('MACRO','HOTBAR') == false )) return;
|
||||
this.executeHotbar(macroNumber,mode);
|
||||
}
|
||||
else if (mode == 'name') {
|
||||
if ((MODULE.getPermission('MACRO','BY_NAME') == false )) return;
|
||||
const macroName = settings.macroNumber;
|
||||
const macro = game.macros.getName(macroName);
|
||||
|
||||
if (macro == undefined) return;
|
||||
|
||||
const args = settings.macroArgs ? settings.macroArgs : "";
|
||||
|
||||
let furnaceEnabled = false;
|
||||
let furnace = game.modules.get("furnace");
|
||||
if (furnace != undefined && furnace.active && compatibleCore("0.8.1")==false) furnaceEnabled = true;
|
||||
if (args == "" || args == " ") furnaceEnabled = false;
|
||||
if (furnaceEnabled == false) macro.execute({token:target});
|
||||
else {
|
||||
let chatData = {
|
||||
user: game.user._id,
|
||||
speaker: ChatMessage.getSpeaker(),
|
||||
content: "/'" + macro.name + "' " + args
|
||||
};
|
||||
ChatMessage.create(chatData, {});
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
if ((MODULE.getPermission('MACRO','MACROBOARD') == false )) return;
|
||||
if (settings.macroBoardMode == 'offset') {
|
||||
@@ -194,12 +216,7 @@ export class MacroControl{
|
||||
}
|
||||
else macros = game.macros.apps[0].macros;
|
||||
if (macroNumber > 9) macroNumber = 0;
|
||||
for (let j=0; j<10; j++){
|
||||
if (macros[j].key == macroNumber){
|
||||
if (macros[j].macro == null) macroId == undefined;
|
||||
else macroId = macros[j].macro._id;
|
||||
}
|
||||
}
|
||||
macroId = game.macros.apps[0].macros.find(m => m.key == macroNumber).macro?.id
|
||||
}
|
||||
if (macroId == undefined) return;
|
||||
let macro = game.macros.get(macroId);
|
||||
@@ -218,7 +235,7 @@ export class MacroControl{
|
||||
const args = game.settings.get(MODULE.moduleName,'macroSettings').args;
|
||||
let furnaceEnabled = false;
|
||||
let furnace = game.modules.get("furnace");
|
||||
if (furnace != undefined && furnace.active) furnaceEnabled = true;
|
||||
if (furnace != undefined && furnace.active && compatibleCore("0.8.1")==false) furnaceEnabled = true;
|
||||
if (args == undefined || args[macroNumber] == undefined || args[macroNumber] == "") furnaceEnabled = false;
|
||||
if (furnaceEnabled == false) macro.execute();
|
||||
else {
|
||||
|
||||
76
src/misc.js
76
src/misc.js
@@ -1,6 +1,16 @@
|
||||
import * as MODULE from "../MaterialDeck.js";
|
||||
import {macroControl,soundboard,playlistControl} from "../MaterialDeck.js";
|
||||
|
||||
export function compatibleCore(compatibleVersion){
|
||||
let coreVersion = game.data.version;
|
||||
coreVersion = coreVersion.split(".");
|
||||
compatibleVersion = compatibleVersion.split(".");
|
||||
if (compatibleVersion[0] > coreVersion[0]) return false;
|
||||
if (compatibleVersion[1] > coreVersion[1]) return false;
|
||||
if (compatibleVersion[2] > coreVersion[2]) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
export class playlistConfigForm extends FormApplication {
|
||||
constructor(data, options) {
|
||||
super(data, options);
|
||||
@@ -17,7 +27,8 @@ export class playlistConfigForm extends FormApplication {
|
||||
title: "Material Deck: "+game.i18n.localize("MaterialDeck.Sett.PlaylistConfig"),
|
||||
template: "./modules/MaterialDeck/templates/playlistConfig.html",
|
||||
classes: ["sheet"],
|
||||
width: 500
|
||||
width: 500,
|
||||
height: "auto"
|
||||
});
|
||||
}
|
||||
|
||||
@@ -65,7 +76,7 @@ export class playlistConfigForm extends FormApplication {
|
||||
}
|
||||
|
||||
return {
|
||||
playlists: game.playlists.entities,
|
||||
playlists: compatibleCore("0.8.1") ? game.playlists.contents : game.playlists.entities,
|
||||
numberOfPlaylists: numberOfPlaylists,
|
||||
playlistData: playlistData,
|
||||
playMode: playMode
|
||||
@@ -171,7 +182,7 @@ export class macroConfigForm extends FormApplication {
|
||||
let furnaceEnabled = false;
|
||||
let height = 95;
|
||||
let furnace = game.modules.get("furnace");
|
||||
if (furnace != undefined && furnace.active) {
|
||||
if (furnace != undefined && furnace.active && compatibleCore("0.8.1")==false) {
|
||||
furnaceEnabled = true;
|
||||
height += 50;
|
||||
}
|
||||
@@ -222,7 +233,7 @@ export class macroConfigForm extends FormApplication {
|
||||
}
|
||||
macroData.push({dataThis: macroThis});
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
height: height,
|
||||
macros: game.macros,
|
||||
@@ -335,9 +346,11 @@ export class soundboardConfigForm extends FormApplication {
|
||||
let playlists = [];
|
||||
playlists.push({id:"none",name:game.i18n.localize("MaterialDeck.None")});
|
||||
playlists.push({id:"FP",name:game.i18n.localize("MaterialDeck.FilePicker")})
|
||||
for (let i=0; i<game.playlists.entities.length; i++){
|
||||
playlists.push({id:game.playlists.entities[i]._id,name:game.playlists.entities[i].name});
|
||||
}
|
||||
|
||||
const playlistArray = compatibleCore("0.8.1") ? game.playlists.contents : game.playlists.entities;
|
||||
for (let playlist of playlistArray)
|
||||
playlists.push({id: playlist.id, name: playlist.name})
|
||||
|
||||
this.playlists = playlists;
|
||||
|
||||
//Check what SD model the user is using, and set the number of rows and columns to correspond
|
||||
@@ -376,20 +389,30 @@ export class soundboardConfigForm extends FormApplication {
|
||||
else if (this.settings.selectedPlaylists[iteration] == 'FP') selectedPlaylist = 'FP';
|
||||
else {
|
||||
//Get the playlist
|
||||
const pl = game.playlists.entities.find(p => p._id == this.settings.selectedPlaylists[iteration]);
|
||||
const playlistArray = compatibleCore("0.8.1") ? game.playlists.contents : game.playlists.entities;
|
||||
let pl = playlistArray.find(p => p.id == this.settings.selectedPlaylists[iteration])
|
||||
|
||||
if (pl == undefined){
|
||||
selectedPlaylist = 'none';
|
||||
sounds = [];
|
||||
}
|
||||
else {
|
||||
//Add the sound name and id to the sounds array
|
||||
for (let i=0; i<pl.sounds.length; i++)
|
||||
sounds.push({
|
||||
name: pl.sounds[i].name,
|
||||
id: pl.sounds[i]._id
|
||||
});
|
||||
if (compatibleCore("0.8.1"))
|
||||
for (let sound of pl.sounds.contents)
|
||||
sounds.push({
|
||||
name: sound.name,
|
||||
id: sound.id
|
||||
});
|
||||
else {
|
||||
for (let sound of pl.sounds)
|
||||
sounds.push({
|
||||
name: sound.name,
|
||||
id: sound._id
|
||||
});
|
||||
}
|
||||
//Get the playlist id
|
||||
selectedPlaylist = pl._id;
|
||||
selectedPlaylist = pl.id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -489,8 +512,9 @@ export class soundboardConfigForm extends FormApplication {
|
||||
//Show the sound selector
|
||||
document.querySelector(`#ss${iteration}`).style='';
|
||||
|
||||
const pl = game.playlists.entities.find(p => p._id == event.target.value);
|
||||
selectedPlaylist = pl._id;
|
||||
const playlistArray = compatibleCore("0.8.1") ? game.playlists.contents : game.playlists.entities;
|
||||
const pl = playlistArray.find(p => p.id == event.target.value)
|
||||
selectedPlaylist = pl.id;
|
||||
|
||||
//Get the sound select element
|
||||
let SSpicker = document.getElementById(`soundSelect${iteration}`);
|
||||
@@ -504,12 +528,20 @@ export class soundboardConfigForm extends FormApplication {
|
||||
optionNone.innerHTML = game.i18n.localize("MaterialDeck.None");
|
||||
SSpicker.appendChild(optionNone);
|
||||
|
||||
for (let i=0; i<pl.sounds.length; i++){
|
||||
let newOption = document.createElement('option');
|
||||
newOption.value = pl.sounds[i]._id;
|
||||
newOption.innerHTML = pl.sounds[i].name;
|
||||
SSpicker.appendChild(newOption);
|
||||
}
|
||||
if (compatibleCore("0.8.1"))
|
||||
for (let sound of pl.sounds.contents) {
|
||||
let newOption = document.createElement('option');
|
||||
newOption.value = sound.id;
|
||||
newOption.innerHTML = sound.name;
|
||||
SSpicker.appendChild(newOption);
|
||||
}
|
||||
else
|
||||
for (let sound of pl.sounds) {
|
||||
let newOption = document.createElement('option');
|
||||
newOption.value = sound._id;
|
||||
newOption.innerHTML = sound.name;
|
||||
SSpicker.appendChild(newOption);
|
||||
}
|
||||
}
|
||||
|
||||
//Save the new playlist to this.settings, and update the settings
|
||||
|
||||
40
src/move.js
40
src/move.js
@@ -1,5 +1,6 @@
|
||||
import * as MODULE from "../MaterialDeck.js";
|
||||
import {streamDeck} from "../MaterialDeck.js";
|
||||
import {compatibleCore} from "./misc.js";
|
||||
|
||||
export class Move{
|
||||
constructor(){
|
||||
@@ -49,20 +50,33 @@ export class Move{
|
||||
else
|
||||
url = "modules/MaterialDeck/img/move/rotateccw.png";
|
||||
}
|
||||
streamDeck.setIcon(context,url,background);
|
||||
streamDeck.setIcon(context,url,{background:background});
|
||||
streamDeck.setTitle('',context);
|
||||
}
|
||||
|
||||
keyPress(settings){
|
||||
if (canvas.scene == null) return;
|
||||
|
||||
if ((MODULE.getPermission('MOVE','TOKEN') == false && mode == 'selectedToken') || (MODULE.getPermission('MOVE','CANVAS') == false && mode == 'canvas')) {
|
||||
streamDeck.noPermission(context);
|
||||
return;
|
||||
}
|
||||
|
||||
const dir = settings.dir ? settings.dir : 'center';
|
||||
const mode = settings.mode ? settings.mode : 'canvas';
|
||||
const type = settings.type ? settings.type : 'move';
|
||||
|
||||
if ((MODULE.getPermission('MOVE','TOKEN') == false && mode == 'selectedToken') || (MODULE.getPermission('MOVE','CANVAS') == false && mode == 'canvas')) {
|
||||
streamDeck.noPermission(context);
|
||||
return;
|
||||
let token;
|
||||
if (mode == 'selectedToken') {
|
||||
const selection = settings.selection ? settings.selection : 'selected';
|
||||
const tokenIdentifier = settings.tokenName ? settings.tokenName : '';
|
||||
|
||||
if (selection == 'selected') token = canvas.tokens.children[0].children.find(p => p.id == MODULE.selectedTokenId);
|
||||
else if (selection != 'selected' && tokenIdentifier == '') {}
|
||||
else if (selection == 'tokenName') token = canvas.tokens.children[0].children.find(p => p.name == tokenIdentifier);
|
||||
else if (selection == 'actorName') token = canvas.tokens.children[0].children.find(p => p.actor.name == tokenIdentifier);
|
||||
else if (selection == 'tokenId') token = canvas.tokens.children[0].children.find(p => p.id == tokenIdentifier);
|
||||
else if (selection == 'actorId') token = canvas.tokens.children[0].children.find(p => p.actor.id == tokenIdentifier);
|
||||
if (token == undefined) return;
|
||||
}
|
||||
|
||||
if (type == 'move'){
|
||||
@@ -80,15 +94,12 @@ export class Move{
|
||||
}
|
||||
else {
|
||||
if (settings.mode == 'selectedToken')
|
||||
this.moveToken(MODULE.selectedTokenId,dir);
|
||||
this.moveToken(token,dir);
|
||||
else
|
||||
this.moveCanvas(dir);
|
||||
}
|
||||
}
|
||||
else if (type == 'rotate' && mode == 'selectedToken'){
|
||||
const token = canvas.tokens.children[0].children.find(p => p.id == MODULE.selectedTokenId);
|
||||
if (token == undefined) return;
|
||||
|
||||
const rotType = settings.rot ? settings.rot : 'to';
|
||||
const value = isNaN(parseInt(settings.rotValue)) ? 0 : parseInt(settings.rotValue);
|
||||
|
||||
@@ -96,13 +107,13 @@ export class Move{
|
||||
if (rotType == 'by') rotationVal = token.data.rotation + value;
|
||||
else if (rotType == 'to') rotationVal = value;
|
||||
|
||||
token.update({rotation: rotationVal});
|
||||
if (compatibleCore("0.8.1")) token.document.update({rotation: rotationVal});
|
||||
else token.update({rotation: rotationVal});
|
||||
//token.rotate(rotationVal,false)
|
||||
}
|
||||
}
|
||||
|
||||
async moveToken(tokenId,dir){
|
||||
if (tokenId == undefined) return;
|
||||
const token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
|
||||
async moveToken(token,dir){
|
||||
const gridSize = canvas.scene.data.grid;
|
||||
let x = token.x;
|
||||
let y = token.y;
|
||||
@@ -132,7 +143,8 @@ export class Move{
|
||||
canvas.animatePan(location);
|
||||
}
|
||||
if (game.user.isGM == false && (token.can(game.user,"control") == false || token.checkCollision(token.getCenter(x, y)))) return;
|
||||
token.update({x:x,y:y});
|
||||
if (compatibleCore("0.8.1")) token.document.update({x:x,y:y});
|
||||
else token.update({x:x,y:y});
|
||||
};
|
||||
|
||||
moveCanvas(dir){
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as MODULE from "../MaterialDeck.js";
|
||||
import {streamDeck} from "../MaterialDeck.js";
|
||||
import {compatibleCore} from "./misc.js";
|
||||
|
||||
export class OtherControls{
|
||||
constructor(){
|
||||
@@ -7,37 +8,39 @@ export class OtherControls{
|
||||
this.rollData = {};
|
||||
}
|
||||
|
||||
async updateAll(){
|
||||
async updateAll(options={}){
|
||||
if (this.active == false) return;
|
||||
for (let i=0; i<32; i++){
|
||||
const data = streamDeck.buttonContext[i];
|
||||
if (data == undefined || data.action != 'other') continue;
|
||||
await this.update(data.settings,data.context);
|
||||
await this.update(data.settings,data.context,options);
|
||||
}
|
||||
}
|
||||
|
||||
update(settings,context){
|
||||
update(settings,context,options={}){
|
||||
this.active = true;
|
||||
const mode = settings.otherMode ? settings.otherMode : 'pause';
|
||||
|
||||
if (mode == 'pause') //pause
|
||||
this.updatePause(settings,context);
|
||||
this.updatePause(settings,context,options);
|
||||
else if (mode == 'controlButtons') //control buttons
|
||||
this.updateControl(settings,context);
|
||||
this.updateControl(settings,context,options);
|
||||
else if (mode == 'darkness') //darkness
|
||||
this.updateDarkness(settings,context);
|
||||
this.updateDarkness(settings,context,options);
|
||||
else if (mode == 'rollDice') //roll dice
|
||||
this.updateRollDice(settings,context);
|
||||
this.updateRollDice(settings,context,options);
|
||||
else if (mode == 'rollTables') //roll tables
|
||||
this.updateRollTable(settings,context);
|
||||
this.updateRollTable(settings,context,options);
|
||||
else if (mode == 'sidebarTab') //open sidebar tab
|
||||
this.updateSidebar(settings,context);
|
||||
this.updateSidebar(settings,context,options);
|
||||
else if (mode == 'compendiumBrowser') //open compendium browser
|
||||
this.updateCompendiumBrowser(settings,context,options);
|
||||
else if (mode == 'compendium') //open compendium
|
||||
this.updateCompendium(settings,context);
|
||||
this.updateCompendium(settings,context,options);
|
||||
else if (mode == 'journal') //open journal
|
||||
this.updateJournal(settings,context);
|
||||
this.updateJournal(settings,context,options);
|
||||
else if (mode == 'chatMessage')
|
||||
this.updateChatMessage(settings,context);
|
||||
this.updateChatMessage(settings,context,options);
|
||||
}
|
||||
|
||||
keyPress(settings,context){
|
||||
@@ -55,6 +58,8 @@ export class OtherControls{
|
||||
this.keyPressRollTable(settings);
|
||||
else if (mode == 'sidebarTab') //sidebar
|
||||
this.keyPressSidebar(settings);
|
||||
else if (mode == 'compendiumBrowser') //open compendium browser
|
||||
this.keyPressCompendiumBrowser(settings);
|
||||
else if (mode == 'compendium') //open compendium
|
||||
this.keyPressCompendium(settings);
|
||||
else if (mode == 'journal') //open journal
|
||||
@@ -65,7 +70,7 @@ export class OtherControls{
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
updatePause(settings,context){
|
||||
updatePause(settings,context,options={}){
|
||||
if (MODULE.getPermission('OTHER','PAUSE') == false ) {
|
||||
streamDeck.noPermission(context);
|
||||
return;
|
||||
@@ -86,7 +91,7 @@ export class OtherControls{
|
||||
}
|
||||
else if (pauseFunction == 'toggle') //toggle
|
||||
src = 'modules/MaterialDeck/img/other/pause/playpause.png';
|
||||
streamDeck.setIcon(context,src,background,2,ringColor,true);
|
||||
streamDeck.setIcon(context,src,{background:background,ring:2,ringColor:ringColor,overlay:true});
|
||||
streamDeck.setTitle('',context);
|
||||
}
|
||||
|
||||
@@ -97,20 +102,20 @@ export class OtherControls{
|
||||
|
||||
if (pauseFunction == 'pause'){ //Pause game
|
||||
if (game.paused) return;
|
||||
game.togglePause();
|
||||
game.togglePause(true,true);
|
||||
}
|
||||
else if (pauseFunction == 'resume'){ //Resume game
|
||||
if (game.paused == false) return;
|
||||
game.togglePause();
|
||||
game.togglePause(false,true);
|
||||
}
|
||||
else if (pauseFunction == 'toggle') { //toggle
|
||||
game.togglePause();
|
||||
game.togglePause(!game.paused,true);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
updateControl(settings,context){
|
||||
updateControl(settings,context,options={}){
|
||||
if (MODULE.getPermission('OTHER','CONTROL') == false ) {
|
||||
streamDeck.noPermission(context);
|
||||
return;
|
||||
@@ -199,7 +204,7 @@ export class OtherControls{
|
||||
}
|
||||
}
|
||||
}
|
||||
streamDeck.setIcon(context,src,background,2,ringColor);
|
||||
streamDeck.setIcon(context,src,{background:background,ring:2,ringColor:ringColor});
|
||||
streamDeck.setTitle(txt,context);
|
||||
}
|
||||
|
||||
@@ -291,7 +296,7 @@ export class OtherControls{
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
updateDarkness(settings,context){
|
||||
updateDarkness(settings,context,options={}){
|
||||
if (MODULE.getPermission('OTHER','DARKNESS') == false ) {
|
||||
streamDeck.noPermission(context);
|
||||
return;
|
||||
@@ -316,7 +321,7 @@ export class OtherControls{
|
||||
txt += darkness;
|
||||
}
|
||||
streamDeck.setTitle(txt,context);
|
||||
streamDeck.setIcon(context,src,background);
|
||||
streamDeck.setIcon(context,src,{background:background});
|
||||
}
|
||||
|
||||
keyPressDarkness(settings) {
|
||||
@@ -337,7 +342,7 @@ export class OtherControls{
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
updateRollDice(settings,context){
|
||||
updateRollDice(settings,context,options={}){
|
||||
if (MODULE.getPermission('OTHER','DICE') == false ) {
|
||||
streamDeck.noPermission(context);
|
||||
return;
|
||||
@@ -348,7 +353,7 @@ export class OtherControls{
|
||||
if (settings.displayDiceName) txt = 'Roll: ' + settings.rollDiceFormula;
|
||||
|
||||
streamDeck.setTitle(txt,context);
|
||||
streamDeck.setIcon(context,'',background);
|
||||
streamDeck.setIcon(context,'',{background:background});
|
||||
}
|
||||
|
||||
keyPressRollDice(settings,context){
|
||||
@@ -389,7 +394,7 @@ export class OtherControls{
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
updateRollTable(settings,context){
|
||||
updateRollTable(settings,context,options={}){
|
||||
const name = settings.rollTableName;
|
||||
if (name == undefined) return;
|
||||
if (MODULE.getPermission('OTHER','TABLES') == false ) {
|
||||
@@ -398,7 +403,7 @@ export class OtherControls{
|
||||
}
|
||||
|
||||
const background = settings.background ? settings.background : '#000000';
|
||||
const table = game.tables.entities.find(p=>p.name == name);
|
||||
const table = game.tables.getName(name);
|
||||
|
||||
let txt = settings.displayRollName ? table.name : '';
|
||||
let src = settings.displayRollIcon ? table.data.img : '';
|
||||
@@ -415,7 +420,7 @@ export class OtherControls{
|
||||
}
|
||||
|
||||
streamDeck.setTitle(txt,context);
|
||||
streamDeck.setIcon(context,src,background);
|
||||
streamDeck.setIcon(context,src,{background:background});
|
||||
}
|
||||
|
||||
keyPressRollTable(settings){
|
||||
@@ -424,7 +429,7 @@ export class OtherControls{
|
||||
if (name == undefined) return;
|
||||
|
||||
const func = settings.rolltableFunction ? settings.rolltableFunction : 'open';
|
||||
const table = game.tables.entities.find(p=>p.name == name);
|
||||
const table = game.tables.getName(name);
|
||||
|
||||
if (table != undefined) {
|
||||
if (table.permission < 2 && MODULE.getPermission('OTHER','TABLES_ALL') == false ) return;
|
||||
@@ -474,47 +479,90 @@ export class OtherControls{
|
||||
return icon;
|
||||
}
|
||||
|
||||
updateSidebar(settings,context){
|
||||
updateSidebar(settings,context,options={}){
|
||||
if (MODULE.getPermission('OTHER','SIDEBAR') == false ) {
|
||||
streamDeck.noPermission(context);
|
||||
return;
|
||||
}
|
||||
const popOut = settings.sidebarPopOut ? settings.sidebarPopOut : false;
|
||||
const sidebarTab = settings.sidebarTab ? settings.sidebarTab : 'chat';
|
||||
const background = settings.background ? settings.background : '#000000';
|
||||
const collapsed = ui.sidebar._collapsed;
|
||||
const activeTab = ui.sidebar.activeTab;
|
||||
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
|
||||
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
|
||||
const ringColor = (sidebarTab == 'collapse' && collapsed) ? ringOnColor : ringOffColor;
|
||||
let ringColor = ringOffColor;
|
||||
if (popOut && options.sidebarTab == sidebarTab) {
|
||||
ringColor = options.renderPopout ? ringOnColor : ringOffColor;
|
||||
}
|
||||
else ringColor = (sidebarTab == 'collapse' && collapsed || (activeTab == sidebarTab)) ? ringOnColor : ringOffColor;
|
||||
const name = settings.displaySidebarName ? this.getSidebarName(sidebarTab) : '';
|
||||
const icon = settings.displaySidebarIcon ? this.getSidebarIcon(sidebarTab) : '';
|
||||
|
||||
streamDeck.setTitle(name,context);
|
||||
streamDeck.setIcon(context,icon,background,2,ringColor);
|
||||
streamDeck.setIcon(context,icon,{background:background,ring:2,ringColor:ringColor});
|
||||
}
|
||||
|
||||
keyPressSidebar(settings){
|
||||
if (MODULE.getPermission('OTHER','SIDEBAR') == false ) return;
|
||||
const sidebarTab = settings.sidebarTab ? settings.sidebarTab : 'chat';
|
||||
const popOut = settings.sidebarPopOut ? settings.sidebarPopOut : false;
|
||||
|
||||
if (sidebarTab == 'collapse'){
|
||||
const collapsed = ui.sidebar._collapsed;
|
||||
if (collapsed) ui.sidebar.expand();
|
||||
else if (collapsed == false) ui.sidebar.collapse();
|
||||
}
|
||||
else ui.sidebar.activateTab(sidebarTab);
|
||||
else if (popOut == false) ui.sidebar.activateTab(sidebarTab);
|
||||
else {
|
||||
const element = document.getElementById(sidebarTab+"-popout");
|
||||
if (element == null) ui?.[sidebarTab].renderPopout();
|
||||
else element.getElementsByClassName("close")[0].click();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
updateCompendium(settings,context){
|
||||
updateCompendiumBrowser(settings,context,options={}){
|
||||
let rendered = options.renderCompendiumBrowser;
|
||||
if (rendered == undefined && game.system.id == "pf2e") rendered = (document.getElementById("app-1") != null);
|
||||
else if (rendered == undefined) rendered = (document.getElementById("compendium-popout") != null);
|
||||
const background = settings.background ? settings.background : '#000000';
|
||||
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
|
||||
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
|
||||
const ringColor = rendered ? ringOnColor : ringOffColor;
|
||||
const txt = settings.displayCompendiumName ? name : '';
|
||||
|
||||
streamDeck.setTitle(txt,context);
|
||||
streamDeck.setIcon(context,"",{background:background,ring:2,ringColor:ringColor});
|
||||
}
|
||||
|
||||
keyPressCompendiumBrowser(settings){
|
||||
let element = null;
|
||||
if (game.system.id == "pf2e") element = document.getElementById("app-1")
|
||||
else element = document.getElementById("compendium-popout");
|
||||
const rendered = (element != null);
|
||||
|
||||
if (rendered)
|
||||
element.getElementsByClassName("close")[0].click();
|
||||
else if (game.system.id == "pf2e")
|
||||
document.getElementsByClassName("compendium-browser-btn")[0].click()
|
||||
else
|
||||
ui.compendium.renderPopout();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
updateCompendium(settings,context,options={}){
|
||||
const name = settings.compendiumName;
|
||||
if (name == undefined) return;
|
||||
if (MODULE.getPermission('OTHER','COMPENDIUM') == false ) {
|
||||
streamDeck.noPermission(context);
|
||||
return;
|
||||
}
|
||||
|
||||
const compendium = game.packs.entries.find(p=>p.metadata.label == name);
|
||||
let compendium;
|
||||
if (compatibleCore("0.8.1")) compendium = game.packs.contents.find(p=>p.metadata.label == name)?.apps[0];
|
||||
else compendium = game.packs.entries.find(p=>p.metadata.label == name);
|
||||
if (compendium == undefined) return;
|
||||
if (compendium.private && MODULE.getPermission('OTHER','COMPENDIUM_ALL') == false) {
|
||||
streamDeck.noPermission(context);
|
||||
@@ -527,7 +575,7 @@ export class OtherControls{
|
||||
const txt = settings.displayCompendiumName ? name : '';
|
||||
|
||||
streamDeck.setTitle(txt,context);
|
||||
streamDeck.setIcon(context,"",background,2,ringColor);
|
||||
streamDeck.setIcon(context,"",{background:background,ring:2,ringColor:ringColor});
|
||||
}
|
||||
|
||||
keyPressCompendium(settings){
|
||||
@@ -535,16 +583,18 @@ export class OtherControls{
|
||||
if (name == undefined) return;
|
||||
if (MODULE.getPermission('OTHER','COMPENDIUM') == false ) return;
|
||||
|
||||
const compendium = game.packs.entries.find(p=>p.metadata.label == name);
|
||||
let compendium;
|
||||
if (compatibleCore("0.8.1")) compendium = game.packs.contents.find(p=>p.metadata.label == name)?.apps[0];
|
||||
else compendium = game.packs.entries.find(p=>p.metadata.label == name);
|
||||
if (compendium == undefined) return;
|
||||
if (compendium.private && MODULE.getPermission('OTHER','COMPENDIUM_ALL') == false) return;
|
||||
if (compendium.rendered) compendium.close();
|
||||
else if (compendium.rendered) compendium.close();
|
||||
else compendium.render(true);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
updateJournal(settings,context){
|
||||
updateJournal(settings,context,options={}){
|
||||
const name = settings.compendiumName;
|
||||
if (name == undefined) return;
|
||||
|
||||
@@ -559,15 +609,23 @@ export class OtherControls{
|
||||
streamDeck.noPermission(context);
|
||||
return;
|
||||
}
|
||||
let rendered = false;
|
||||
|
||||
if (options?.sheet?.title == name) {
|
||||
if (options.hook == 'renderJournalSheet') rendered = true;
|
||||
else if (options.hook == 'closeJournalSheet') rendered = false;
|
||||
}
|
||||
else
|
||||
if (document.getElementById("journalentry-sheet-"+journal.id) != null) rendered = true;
|
||||
|
||||
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 ringColor = rendered ? ringOnColor : ringOffColor;
|
||||
const txt = settings.displayCompendiumName ? name : '';
|
||||
|
||||
streamDeck.setTitle(txt,context);
|
||||
streamDeck.setIcon(context,"",background,2,ringColor);
|
||||
streamDeck.setIcon(context,"",{background:background,ring:2,ringColor:ringColor});
|
||||
}
|
||||
|
||||
keyPressJournal(settings){
|
||||
@@ -580,21 +638,20 @@ export class OtherControls{
|
||||
if (MODULE.getPermission('OTHER','JOURNAL') == false ) return;
|
||||
if (journal.permission < 2 && MODULE.getPermission('OTHER','JOURNAL_ALL') == false ) return;
|
||||
|
||||
const element = document.getElementById("journal-"+journal.id);
|
||||
if (element == null) journal.render(true);
|
||||
if (journal.sheet.rendered == false) journal.sheet.render(true);
|
||||
else journal.sheet.close();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
updateChatMessage(settings,context){
|
||||
updateChatMessage(settings,context,options={}){
|
||||
if (MODULE.getPermission('OTHER','CHAT') == false ) {
|
||||
streamDeck.noPermission(context);
|
||||
return;
|
||||
}
|
||||
const background = settings.background ? settings.background : '#000000';
|
||||
streamDeck.setTitle("",context);
|
||||
streamDeck.setIcon(context,"",background);
|
||||
streamDeck.setIcon(context,"",{background:background});
|
||||
}
|
||||
|
||||
keyPressChatMessage(settings){
|
||||
|
||||
125
src/playlist.js
125
src/playlist.js
@@ -1,5 +1,6 @@
|
||||
import * as MODULE from "../MaterialDeck.js";
|
||||
import {streamDeck} from "../MaterialDeck.js";
|
||||
import {compatibleCore} from "./misc.js";
|
||||
|
||||
export class PlaylistControl{
|
||||
constructor(){
|
||||
@@ -23,38 +24,32 @@ export class PlaylistControl{
|
||||
return;
|
||||
}
|
||||
this.active = true;
|
||||
if (settings.playlistMode == undefined) settings.playlistMode = 'playlist';
|
||||
if (settings.playlistMode == 'playlist'){
|
||||
const mode = settings.playlistMode ? settings.playlistMode : 'playlist';
|
||||
|
||||
if (mode == 'playlist'){
|
||||
this.updatePlaylist(settings,context);
|
||||
}
|
||||
else if (settings.playlistMode == 'track'){
|
||||
else if (mode == 'track'){
|
||||
this.updateTrack(settings,context);
|
||||
}
|
||||
else {
|
||||
let src = 'modules/MaterialDeck/img/playlist/stop.png';
|
||||
if (game.playlists.playing.length > 0)
|
||||
streamDeck.setIcon(context,src,settings.background,2,'#00FF00',true);
|
||||
else
|
||||
streamDeck.setIcon(context,src,settings.background,1,'#000000',true);
|
||||
const src = 'modules/MaterialDeck/img/playlist/stop.png';
|
||||
const background = settings.background ? settings.background : '#000000';
|
||||
const ringColor = (game.playlists.playing.length > 0) ? '#00FF00' : '#000000';
|
||||
const ring = (game.playlists.playing.length > 0) ? 2 : 1;
|
||||
const txt = settings.displayPlaylistName ? this.getPlaylist(this.playlistOffset).name : '';
|
||||
streamDeck.setIcon(context,src,{background:background,ring:ring,ringColor:ringColor,overlay:true});
|
||||
streamDeck.setTitle(txt,context);
|
||||
}
|
||||
}
|
||||
|
||||
updatePlaylist(settings,context){
|
||||
let name = "";
|
||||
|
||||
let background = settings.background;
|
||||
if(background == undefined) background = '#000000';
|
||||
|
||||
let ringColor = "#000000"
|
||||
|
||||
let ringOffColor = settings.offRing;
|
||||
if (ringOffColor == undefined) ringOffColor = '#FF0000';
|
||||
|
||||
let ringOnColor = settings.onRing;
|
||||
if (ringOnColor == undefined) ringOnColor = '#00FF00';
|
||||
|
||||
let playlistType = settings.playlistType;
|
||||
if (playlistType == undefined) playlistType = 'playStop';
|
||||
const background = settings.background ? settings.background : '#000000';
|
||||
const ringOffColor = settings.offRing ? settings.offRing : '#FF0000';
|
||||
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
|
||||
const playlistType = settings.playlistType ? settings.playlistType : 'playStop';
|
||||
|
||||
//Play/Stop
|
||||
if (playlistType == 'playStop'){
|
||||
@@ -79,26 +74,28 @@ export class PlaylistControl{
|
||||
if (isNaN(playlistOffset)) playlistOffset = 0;
|
||||
if (playlistOffset == this.playlistOffset) ringColor = ringOnColor;
|
||||
}
|
||||
streamDeck.setIcon(context,"",background,2,ringColor);
|
||||
//Relative Offset
|
||||
else if (playlistType == 'relativeOffset') {
|
||||
let playlistOffset = parseInt(settings.offset);
|
||||
if (isNaN(playlistOffset)) playlistOffset = 0;
|
||||
let number = parseInt(this.playlistOffset + playlistOffset);
|
||||
const nrOfPlaylists = parseInt(game.settings.get(MODULE.moduleName,'playlists').playlistNumber);
|
||||
if (number < 0) number += nrOfPlaylists;
|
||||
else if (number >= nrOfPlaylists) number -= nrOfPlaylists;
|
||||
const targetPlaylist = this.getPlaylist(number);
|
||||
if (targetPlaylist != undefined) name = targetPlaylist.name;
|
||||
}
|
||||
streamDeck.setIcon(context,"",{background:background,ring:2,ringColor:ringColor});
|
||||
streamDeck.setTitle(name,context);
|
||||
}
|
||||
|
||||
updateTrack(settings,context){
|
||||
let name = "";
|
||||
|
||||
let background = settings.background;
|
||||
if(background == undefined) background = '#000000';
|
||||
|
||||
let ringColor = "#000000"
|
||||
|
||||
let ringOffColor = settings.offRing;
|
||||
if (ringOffColor == undefined) ringOffColor = '#FF0000';
|
||||
|
||||
let ringOnColor = settings.onRing;
|
||||
if (ringOnColor == undefined) ringOnColor = '#00FF00';
|
||||
|
||||
let playlistType = settings.playlistType;
|
||||
if (playlistType == undefined) playlistType = 'playStop';
|
||||
const background = settings.background ? settings.background : '#000000';
|
||||
const ringOffColor = settings.offRing ? settings.offRing : '#FF0000';
|
||||
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
|
||||
const playlistType = settings.playlistType ? settings.playlistType : 'playStop';
|
||||
|
||||
//Play/Stop
|
||||
if (playlistType == 'playStop'){
|
||||
@@ -110,10 +107,13 @@ export class PlaylistControl{
|
||||
if (isNaN(trackNr) || trackNr < 1) trackNr = 1;
|
||||
trackNr--;
|
||||
trackNr += this.trackOffset;
|
||||
|
||||
|
||||
let playlist = this.getPlaylist(playlistNr);
|
||||
if (playlist != undefined){
|
||||
let track = playlist.data.sounds[trackNr];
|
||||
let track;
|
||||
if (compatibleCore("0.8.1")) track = playlist.sounds.contents[trackNr];
|
||||
else track = playlist.data.sounds[trackNr];
|
||||
|
||||
if (track != undefined){
|
||||
if (track.playing)
|
||||
ringColor = ringOnColor;
|
||||
@@ -125,12 +125,15 @@ export class PlaylistControl{
|
||||
}
|
||||
}
|
||||
//Offset
|
||||
else {
|
||||
else if (playlistType == 'offset') {
|
||||
let trackOffset = parseInt(settings.offset);
|
||||
if (isNaN(trackOffset)) trackOffset = 0;
|
||||
if (trackOffset == this.trackOffset) ringColor = ringOnColor;
|
||||
}
|
||||
streamDeck.setIcon(context,"",background,2,ringColor);
|
||||
//Relative Offset
|
||||
else if (playlistType == 'relativeOffset') {
|
||||
}
|
||||
streamDeck.setIcon(context,"",{background:background,ring:2,ringColor:ringColor});
|
||||
streamDeck.setTitle(name,context);
|
||||
}
|
||||
|
||||
@@ -179,36 +182,56 @@ export class PlaylistControl{
|
||||
trackNr--;
|
||||
trackNr += this.trackOffset;
|
||||
|
||||
if (settings.playlistMode == undefined) settings.playlistMode = 'playlist';
|
||||
if (settings.playlistType == undefined) settings.playlistType = 'playStop';
|
||||
if (settings.playlistMode == 'stopAll') {
|
||||
const playlistMode = settings.playlistMode ? settings.playlistMode : 'playlist';
|
||||
const playlistType = settings.playlistType ? settings.playlistType : 'playStop';
|
||||
|
||||
if (playlistMode == 'stopAll') {
|
||||
this.stopAll(true);
|
||||
}
|
||||
else {
|
||||
if (settings.playlistType == 'playStop') {
|
||||
if (playlistType == 'playStop') {
|
||||
let playlist = this.getPlaylist(playlistNr);
|
||||
if (playlist != undefined){
|
||||
if (settings.playlistMode == 'playlist')
|
||||
if (playlistMode == 'playlist')
|
||||
this.playPlaylist(playlist,playlistNr);
|
||||
else {
|
||||
let track = playlist.data.sounds[trackNr];
|
||||
let track;
|
||||
if (compatibleCore("0.8.1")) track = playlist.sounds.contents[trackNr];
|
||||
else track = playlist.data.sounds[trackNr];
|
||||
if (track != undefined){
|
||||
this.playTrack(track,playlist,playlistNr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (settings.playlistMode == 'playlist') {
|
||||
else if (playlistType == 'offset'){
|
||||
if (playlistMode == 'playlist') {
|
||||
this.playlistOffset = parseInt(settings.offset);
|
||||
if (isNaN(this.playlistOffset)) this.playlistOffset = 0;
|
||||
}
|
||||
else {
|
||||
else {
|
||||
this.trackOffset = parseInt(settings.offset);
|
||||
if (isNaN(this.trackOffset)) this.trackOffset = 0;
|
||||
}
|
||||
this.updateAll();
|
||||
}
|
||||
else if (playlistType == 'relativeOffset'){
|
||||
if (playlistMode == 'playlist') {
|
||||
let playlistOffset = parseInt(settings.offset);
|
||||
if (isNaN(playlistOffset)) playlistOffset = 0;
|
||||
let number = parseInt(this.playlistOffset + playlistOffset);
|
||||
const nrOfPlaylists = parseInt(game.settings.get(MODULE.moduleName,'playlists').playlistNumber);
|
||||
if (number < 0) number += nrOfPlaylists;
|
||||
else if (number >= nrOfPlaylists) number -= nrOfPlaylists;
|
||||
this.playlistOffset = number;
|
||||
}
|
||||
else {
|
||||
let value = parseInt(settings.offset);
|
||||
if (isNaN(value)) return;
|
||||
this.trackOffset += value;
|
||||
}
|
||||
this.updateAll();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -259,7 +282,11 @@ export class PlaylistControl{
|
||||
}
|
||||
else if (mode == 2) await playlist.stopAll();
|
||||
}
|
||||
await playlist.updateEmbeddedEntity("PlaylistSound", {_id: track._id, playing: play});
|
||||
|
||||
if (compatibleCore("0.8.1") && play) await playlist.playSound(track);
|
||||
else if (compatibleCore("0.8.1")) await playlist.stopSound(track);
|
||||
else await playlist.updateEmbeddedEntity("PlaylistSound", {_id: track._id, playing: play});
|
||||
|
||||
playlist.update({playing: play});
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as MODULE from "../MaterialDeck.js";
|
||||
import {streamDeck} from "../MaterialDeck.js";
|
||||
import {compatibleCore} from "./misc.js";
|
||||
|
||||
export class SceneControl{
|
||||
constructor(){
|
||||
@@ -58,7 +59,7 @@ export class SceneControl{
|
||||
|
||||
let sceneList = [];
|
||||
for (let i=0; i<ui.scenes.tree.children.length; i++){
|
||||
const scenesInFolder = ui.scenes.tree.children[i].entities;
|
||||
const scenesInFolder = compatibleCore("0.8.1") ? ui.scenes.tree.children[i].contents : ui.scenes.tree.children[i].entities;
|
||||
for (let j=0; j<scenesInFolder.length; j++)
|
||||
sceneList.push(scenesInFolder[j])
|
||||
}
|
||||
@@ -115,7 +116,7 @@ export class SceneControl{
|
||||
else ringColor = ringOffColor;
|
||||
}
|
||||
streamDeck.setTitle(name,context);
|
||||
streamDeck.setIcon(context,src,background,ring,ringColor);
|
||||
streamDeck.setIcon(context,src,{background:background,ring:ring,ringColor:ringColor});
|
||||
}
|
||||
|
||||
keyPress(settings){
|
||||
@@ -151,7 +152,7 @@ export class SceneControl{
|
||||
|
||||
let sceneList = [];
|
||||
for (let i=0; i<ui.scenes.tree.children.length; i++){
|
||||
const scenesInFolder = ui.scenes.tree.children[i].entities;
|
||||
const scenesInFolder = compatibleCore("0.8.1") ? ui.scenes.tree.children[i].contents : ui.scenes.tree.children[i].entities;
|
||||
for (let j=0; j<scenesInFolder.length; j++)
|
||||
sceneList.push(scenesInFolder[j])
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ const defaultUserPermissions = {
|
||||
},
|
||||
MACRO: {
|
||||
HOTBAR: [true,true,true,true],
|
||||
BY_NAME: [false,false,true,true],
|
||||
MACROBOARD: [false,false,true,true],
|
||||
MACROBOARD_CONFIGURE: [false,false,true,true]
|
||||
},
|
||||
@@ -60,11 +61,13 @@ const defaultUserPermissions = {
|
||||
VISION: [false,true,true,true],
|
||||
WILDCARD: [false,true,true,true],
|
||||
CONDITIONS: [false,true,true,true],
|
||||
CUSTOM: [false,false,true,true]
|
||||
CUSTOM: [false,false,true,true],
|
||||
NON_OWNED: [false,false,true,true],
|
||||
OBSERVER: [false,true,true,true]
|
||||
}
|
||||
}
|
||||
|
||||
export const registerSettings = function() {
|
||||
export const registerSettings = async function() {
|
||||
/**
|
||||
* Main settings
|
||||
*/
|
||||
@@ -75,7 +78,7 @@ export const registerSettings = function() {
|
||||
name: "MaterialDeck.Sett.Enable",
|
||||
scope: "client",
|
||||
config: true,
|
||||
default: true,
|
||||
default: false,
|
||||
type: Boolean,
|
||||
onChange: x => window.location.reload()
|
||||
});
|
||||
@@ -195,6 +198,22 @@ export const registerSettings = function() {
|
||||
type: soundboardConfigForm,
|
||||
restricted: false
|
||||
});
|
||||
|
||||
let permissionSettings = game.settings.get(MODULE.moduleName,'userPermission');
|
||||
if (permissionSettings == undefined || permissionSettings == null || MODULE.isEmpty(permissionSettings)) {
|
||||
permissionSettings = {
|
||||
enable: defaultEnable,
|
||||
permissions: defaultUserPermissions
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (permissionSettings.permissions.TOKEN.NON_OWNED == undefined) permissionSettings.permissions.TOKEN.NON_OWNED = [false,false,true,true];
|
||||
if (permissionSettings.permissions.TOKEN.OBSERVER == undefined) permissionSettings.permissions.TOKEN.OBSERVER = [false,true,true,true];
|
||||
if (permissionSettings.permissions.MACRO.BY_NAME == undefined) permissionSettings.permissions.MACRO.BY_NAME = [false,false,true,true];
|
||||
}
|
||||
game.settings.set(MODULE.moduleName,'userPermission',permissionSettings);
|
||||
|
||||
|
||||
}
|
||||
|
||||
export class helpMenu extends FormApplication {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import * as MODULE from "../MaterialDeck.js";
|
||||
import {streamDeck} from "../MaterialDeck.js";
|
||||
import {compatibleCore} from "./misc.js";
|
||||
|
||||
export class SoundboardControl{
|
||||
constructor(){
|
||||
@@ -45,7 +46,7 @@ export class SoundboardControl{
|
||||
if (settings.displayIcon && soundboardSettings.img != undefined) src = soundboardSettings.img[soundNr];
|
||||
|
||||
streamDeck.setTitle(txt,context);
|
||||
streamDeck.setIcon(context,src,background,2,ringColor);
|
||||
streamDeck.setIcon(context,src,{background:background,ring:2,ringColor:ringColor});
|
||||
}
|
||||
else if (mode == 'offset') { //Offset
|
||||
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
|
||||
@@ -57,18 +58,19 @@ export class SoundboardControl{
|
||||
else ringColor = ringOffColor;
|
||||
|
||||
streamDeck.setTitle(txt,context);
|
||||
streamDeck.setIcon(context,"",background,2,ringColor);
|
||||
streamDeck.setIcon(context,"",{background:background,ring:2,ringColor:ringColor});
|
||||
}
|
||||
else if (mode == 'stopAll') { //Stop all sounds
|
||||
let src = 'modules/MaterialDeck/img/playlist/stop.png';
|
||||
let soundPlaying = false;
|
||||
const background = settings.background ? settings.background : '#000000';
|
||||
for (let i=0; i<this.activeSounds.length; i++)
|
||||
if (this.activeSounds[i])
|
||||
soundPlaying = true;
|
||||
if (soundPlaying)
|
||||
streamDeck.setIcon(context,src,settings.background,2,'#00FF00',true);
|
||||
streamDeck.setIcon(context,src,{background:background,ring:2,ringColor:'#00FF00',overlay:true});
|
||||
else
|
||||
streamDeck.setIcon(context,src,settings.background,1,'#000000',true);
|
||||
streamDeck.setIcon(context,src,{background:background,ring:1,ringColor:'#000000',overlay:true});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +88,7 @@ export class SoundboardControl{
|
||||
const repeat = (playMode > 0) ? true : false;
|
||||
const play = (this.activeSounds[soundNr] == false) ? true : false;
|
||||
|
||||
this.playSound(soundNr,repeat,play);
|
||||
this.prePlaySound(soundNr,repeat,play);
|
||||
}
|
||||
else if (mode == 'offset') { //Offset
|
||||
let offset = parseInt(settings.offset);
|
||||
@@ -97,7 +99,7 @@ export class SoundboardControl{
|
||||
else if (mode == 'stopAll') { //Stop All Sounds
|
||||
for (let i=0; i<64; i++) {
|
||||
if (this.activeSounds[i] != false){
|
||||
this.playSound(i,false,false);
|
||||
this.prePlaySound(i,false,false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,10 +119,10 @@ export class SoundboardControl{
|
||||
const playMode = game.settings.get(MODULE.moduleName,'soundboardSettings').mode[soundNr];
|
||||
|
||||
if (playMode == 2)
|
||||
this.playSound(soundNr,false,false);
|
||||
this.prePlaySound(soundNr,false,false);
|
||||
}
|
||||
|
||||
async playSound(soundNr,repeat,play){
|
||||
async prePlaySound(soundNr,repeat,play){
|
||||
const soundBoardSettings = game.settings.get(MODULE.moduleName,'soundboardSettings');
|
||||
const playlistId = (soundBoardSettings.selectedPlaylists != undefined) ? soundBoardSettings.selectedPlaylists[soundNr] : undefined;
|
||||
let src;
|
||||
@@ -141,7 +143,7 @@ export class SoundboardControl{
|
||||
const soundId = soundBoardSettings.sounds[soundNr];
|
||||
const sounds = game.playlists.get(playlistId).sounds;
|
||||
if (sounds == undefined) return;
|
||||
const sound = sounds.find(p => p._id == soundId);
|
||||
const sound = compatibleCore("0.8.1") ? sounds.find(p => p.id == soundId) : sounds.find(p => p._id == soundId);
|
||||
if (sound == undefined) return;
|
||||
src = sound.path;
|
||||
}
|
||||
@@ -159,21 +161,39 @@ export class SoundboardControl{
|
||||
};
|
||||
game.socket.emit(`module.MaterialDeck`, payload);
|
||||
|
||||
if (play){
|
||||
volume *= game.settings.get("core", "globalInterfaceVolume");
|
||||
this.playSound(soundNr,src,play,repeat,volume)
|
||||
}
|
||||
|
||||
let howl = new Howl({src, volume, loop: repeat, onend: (id)=>{
|
||||
if (repeat == false){
|
||||
async playSound(soundNr,src,play,repeat,volume){
|
||||
if (play){
|
||||
volume *= game.settings.get("core", "globalAmbientVolume");
|
||||
|
||||
if (compatibleCore("0.8.1")) {
|
||||
let newSound = new SoundNode(src);
|
||||
if(newSound.loaded == false) await newSound.load({autoplay:true});
|
||||
newSound.on('end', ()=>{
|
||||
if (repeat == false) {
|
||||
this.activeSounds[soundNr] = false;
|
||||
this.updateAll();
|
||||
}
|
||||
});
|
||||
newSound.play({loop:repeat,volume:volume});
|
||||
this.activeSounds[soundNr] = newSound;
|
||||
}
|
||||
else {
|
||||
let howl = new Howl({src, volume, loop: repeat, onend: (id)=>{
|
||||
if (repeat == false){
|
||||
this.activeSounds[soundNr] = false;
|
||||
this.updateAll();
|
||||
}
|
||||
},
|
||||
onstop: ()=>{
|
||||
this.activeSounds[soundNr] = false;
|
||||
this.updateAll();
|
||||
}
|
||||
},
|
||||
onstop: (id)=>{
|
||||
this.activeSounds[soundNr] = false;
|
||||
this.updateAll();
|
||||
}});
|
||||
howl.play();
|
||||
this.activeSounds[soundNr] = howl;
|
||||
}});
|
||||
howl.play();
|
||||
this.activeSounds[soundNr] = howl;
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.activeSounds[soundNr].stop();
|
||||
@@ -181,4 +201,23 @@ export class SoundboardControl{
|
||||
}
|
||||
this.updateAll();
|
||||
}
|
||||
|
||||
/*
|
||||
volumeChange(soundNr){
|
||||
|
||||
let volume = game.settings.get("core", "globalAmbientVolume");
|
||||
|
||||
if (soundNr == 'all') {
|
||||
for (let i=0; this.activeSounds.length; i++) {
|
||||
volume * game.settings.get(MODULE.moduleName,'soundboardSettings').volume[i]/100;
|
||||
volume = AudioHelper.inputToVolume(volume);
|
||||
this.activeSounds[i].volume = volume;
|
||||
}
|
||||
}
|
||||
else {
|
||||
volume * game.settings.get(MODULE.moduleName,'soundboardSettings').volume[soundNr]/100;
|
||||
volume = AudioHelper.inputToVolume(volume);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -7,7 +7,7 @@ export class StreamDeck{
|
||||
this.tokenNameContext;
|
||||
this.tokenACContext;
|
||||
this.buttonContext = [];
|
||||
for (let i=0; i<23; i++){
|
||||
for (let i=0; i<31; i++){
|
||||
this.buttonContext[i] = undefined;
|
||||
}
|
||||
this.playlistTrackBuffer = [];
|
||||
@@ -206,18 +206,26 @@ export class StreamDeck{
|
||||
MODULE.sendWS(JSON.stringify(json));
|
||||
}
|
||||
|
||||
setIcon(context,src='',background = '#000000',ring=0,ringColor = "#000000",overlay=false){
|
||||
setIcon(context,src='',options = {}){
|
||||
if (src == null || src == undefined) src = '';
|
||||
if (src == '') src = 'modules/MaterialDeck/img/black.png';
|
||||
let background = options.background ? options.background : '#000000';
|
||||
let ring = options.ring ? options.ring : 0;
|
||||
let ringColor = options.ringColor ? options.ringColor : '#000000';
|
||||
let overlay = options.overlay ? options.overlay : false;
|
||||
let uses = options.uses ? options.uses : undefined;
|
||||
let clock = options.clock ? options.clock : false;
|
||||
for (let i=0; i<32; i++){
|
||||
if (clock != false) break;
|
||||
if (this.buttonContext[i] == undefined) continue;
|
||||
if (this.buttonContext[i].context == context) {
|
||||
if (this.buttonContext[i].icon == src && this.buttonContext[i].ring == ring && this.buttonContext[i].ringColor == ringColor && this.buttonContext[i].background == background)
|
||||
if (this.buttonContext[i].icon == src && this.buttonContext[i].ring == ring && this.buttonContext[i].ringColor == ringColor && this.buttonContext[i].background == background && this.buttonContext[i].uses == uses)
|
||||
return;
|
||||
this.buttonContext[i].icon = src;
|
||||
this.buttonContext[i].ring = ring;
|
||||
this.buttonContext[i].ringColor = ringColor;
|
||||
this.buttonContext[i].background = background;
|
||||
this.buttonContext[i].uses = uses;
|
||||
}
|
||||
}
|
||||
const data = {
|
||||
@@ -225,9 +233,11 @@ export class StreamDeck{
|
||||
background:background,
|
||||
ring:ring,
|
||||
ringColor:ringColor,
|
||||
overlay:overlay
|
||||
overlay:overlay,
|
||||
uses:uses,
|
||||
options:options
|
||||
}
|
||||
const imgBuffer = this.checkImageBuffer(data);
|
||||
const imgBuffer = (clock == false) ? this.checkImageBuffer(data) : false;
|
||||
if (imgBuffer != false) {
|
||||
this.setBufferImage(context,imgBuffer,this.getImageBufferId(data))
|
||||
return;
|
||||
@@ -247,7 +257,9 @@ export class StreamDeck{
|
||||
background: background,
|
||||
ring: ring,
|
||||
ringColor: ringColor,
|
||||
overlay: overlay
|
||||
overlay: overlay,
|
||||
uses:uses,
|
||||
options:options
|
||||
};
|
||||
this.getImage(msg);
|
||||
}
|
||||
@@ -299,12 +311,11 @@ export class StreamDeck{
|
||||
getImage(data){
|
||||
if (data == undefined)
|
||||
return;
|
||||
|
||||
const context = data.context;
|
||||
var url = data.url;
|
||||
const format = data.format;
|
||||
var background = data.background;
|
||||
|
||||
const uses = data.uses;
|
||||
let BGvalid = true;
|
||||
if (background.length != 7) BGvalid = false;
|
||||
if (background[0] != '#') BGvalid = false;
|
||||
@@ -328,7 +339,8 @@ export class StreamDeck{
|
||||
ctx.filter = "none";
|
||||
|
||||
let margin = 0;
|
||||
|
||||
ctx.fillStyle = background;
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
if (data.ring != undefined && data.ring > 0){
|
||||
ctx.fillStyle = background;
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
@@ -341,8 +353,12 @@ export class StreamDeck{
|
||||
}
|
||||
}
|
||||
else {
|
||||
ctx.fillStyle = background;
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
}
|
||||
if (uses != undefined && uses.heart && (uses.available > 0 || uses.maximum != undefined)) {
|
||||
const percentage = 102*uses.available/uses.maximum;
|
||||
ctx.fillStyle = "#FF0000";
|
||||
ctx.fillRect(0, 121,144,-percentage);
|
||||
}
|
||||
if (format == 'icon' && url != ""){
|
||||
ctx.font = '600 90px "Font Awesome 5 Free"';
|
||||
@@ -400,6 +416,76 @@ export class StreamDeck{
|
||||
yStart = 0;
|
||||
}
|
||||
ctx.drawImage(img, xStart+margin, yStart+margin, renderableWidth - 2*margin, renderableHeight - 2*margin);
|
||||
if (uses != undefined && uses.heart == false && (uses.available > 0 || uses.maximum != undefined)) {
|
||||
let txt = uses.available;
|
||||
if (uses.maximum != undefined) txt = uses.available + '/' + uses.maximum;
|
||||
if (uses.maximum == undefined ) uses.maximum = 1;
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth = 4;
|
||||
let green = Math.ceil(255*(uses.available/uses.maximum));
|
||||
let red = 255-green;
|
||||
green = green.toString(16);
|
||||
if (green.length == 1) green = "0"+green;
|
||||
red = red.toString(16);
|
||||
if (red.length == 1) red = "0"+red;
|
||||
if (uses.available == 0) ctx.strokeStyle = "#c80000";
|
||||
else ctx.strokeStyle = "#"+red.toString(16)+green.toString(16)+"00";
|
||||
const rect = {height:35, paddingSides:20, paddingBottom: 4}
|
||||
ctx.rect(rect.paddingSides, 144-rect.height-rect.paddingBottom,144-2*rect.paddingSides,rect.height);
|
||||
ctx.globalAlpha = 0.5;
|
||||
ctx.fillRect(rect.paddingSides, 144-rect.height-rect.paddingBottom,144-2*rect.paddingSides,rect.height);
|
||||
ctx.globalAlpha = 1;
|
||||
ctx.fillStyle = "white";
|
||||
ctx.font = "24px Arial";
|
||||
ctx.fillText(txt, (canvas.width - ctx.measureText(txt).width) / 2, 144-rect.height-rect.paddingBottom+25);
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
if (data.options.clock != undefined) {
|
||||
if (data.options.clock != false && data.options.clock != 'none') {
|
||||
const hourAngle = (data.options.clock.hours+data.options.clock.minutes/60)*Math.PI/6;
|
||||
const minuteAngle = data.options.clock.minutes*Math.PI/30;
|
||||
|
||||
ctx.translate(72,72);
|
||||
//Draw outer circle
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth = 6;
|
||||
ctx.strokeStyle = "gray";
|
||||
ctx.arc(0,0, 50, 0, 2 * Math.PI);
|
||||
ctx.stroke();
|
||||
|
||||
//Draw hour marks
|
||||
ctx.fillStyle = "gray";
|
||||
ctx.beginPath();
|
||||
for (let i=0; i<12; i++) {
|
||||
ctx.fillRect(-2,40,4,10);
|
||||
const angle = 2*Math.PI/12;
|
||||
ctx.rotate(angle);
|
||||
}
|
||||
|
||||
|
||||
//Draw hour arm
|
||||
|
||||
ctx.rotate(Math.PI + hourAngle);
|
||||
ctx.rotate(0);
|
||||
ctx.fillRect(-4,0,8,30);
|
||||
ctx.stroke();
|
||||
// ctx.rotate 8*Math.PI/12;
|
||||
ctx.beginPath();
|
||||
ctx.rotate(-hourAngle + minuteAngle);
|
||||
ctx.fillStyle = "lightgray";
|
||||
ctx.fillRect(-2,0,4,40);
|
||||
ctx.rotate(2*Math.PI/12);
|
||||
ctx.stroke();
|
||||
|
||||
//Draw inner circle
|
||||
ctx.beginPath();
|
||||
ctx.arc(0,0, 5, 0, 2 * Math.PI);
|
||||
ctx.fill();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var dataURL = canvas.toDataURL();
|
||||
canvas.remove();
|
||||
const nr = this.addToImageBuffer(dataURL,data);
|
||||
@@ -409,7 +495,7 @@ export class StreamDeck{
|
||||
}
|
||||
|
||||
getImageBufferId(data){
|
||||
return data.url+data.background+data.ring+data.ringColor+data.overlay;
|
||||
return data.url+data.background+data.ring+data.ringColor+data.overlay+data.uses?.available+data.uses?.maximum;
|
||||
}
|
||||
|
||||
addToImageBuffer(img,data){
|
||||
@@ -445,11 +531,12 @@ export class StreamDeck{
|
||||
this.imageBuffer = [];
|
||||
}
|
||||
|
||||
noPermission(context,showTxt=true){
|
||||
noPermission(context,showTxt=true, origin = ""){
|
||||
console.warn("Material Deck: User lacks permission for function "+origin);
|
||||
const url = 'modules/MaterialDeck/img/black.png';
|
||||
const background = '#000000';
|
||||
const txt = showTxt ? 'no\npermission' : '';
|
||||
this.setIcon(context,url,background);
|
||||
this.setIcon(context,url,{background:background});
|
||||
this.setTitle(txt,context);
|
||||
}
|
||||
}
|
||||
289
src/token.js
289
src/token.js
@@ -1,5 +1,6 @@
|
||||
import * as MODULE from "../MaterialDeck.js";
|
||||
import {streamDeck} from "../MaterialDeck.js";
|
||||
import {streamDeck, macroControl} from "../MaterialDeck.js";
|
||||
import {compatibleCore} from "./misc.js";
|
||||
|
||||
export class TokenControl{
|
||||
constructor(){
|
||||
@@ -7,7 +8,7 @@ export class TokenControl{
|
||||
this.wildcardOffset = 0;
|
||||
}
|
||||
|
||||
async update(tokenId){
|
||||
async update(tokenId=null){
|
||||
if (this.active == false) return;
|
||||
for (let i=0; i<32; i++){
|
||||
const data = streamDeck.buttonContext[i];
|
||||
@@ -21,17 +22,39 @@ export class TokenControl{
|
||||
const icon = settings.displayIcon ? settings.displayIcon : false;
|
||||
const background = settings.background ? settings.background : "#000000";
|
||||
let stats = settings.stats ? settings.stats : 'none';
|
||||
|
||||
const selection = settings.selection ? settings.selection : 'selected';
|
||||
const tokenIdentifier = settings.tokenName ? settings.tokenName : '';
|
||||
|
||||
let validToken = false;
|
||||
let token;
|
||||
if (selection == 'selected') token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
|
||||
else if (selection != 'selected' && tokenIdentifier == '') {}
|
||||
else if (selection == 'tokenName') token = canvas.tokens.children[0].children.find(p => p.name == tokenIdentifier);
|
||||
else if (selection == 'actorName') token = canvas.tokens.children[0].children.find(p => p.actor.name == tokenIdentifier);
|
||||
else if (selection == 'tokenId') token = canvas.tokens.children[0].children.find(p => p.id == tokenIdentifier);
|
||||
else if (selection == 'actorId') token = canvas.tokens.children[0].children.find(p => p.actor.id == tokenIdentifier);
|
||||
|
||||
if (token != undefined) validToken = true;
|
||||
|
||||
let tokenName = "";
|
||||
let txt = "";
|
||||
let iconSrc = "";
|
||||
let overlay = false;
|
||||
let statsOld;
|
||||
if (tokenId != undefined) {
|
||||
const token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
|
||||
let uses = undefined;
|
||||
let hp = undefined;
|
||||
if (validToken) {
|
||||
if (token.owner == false && token.observer == true && MODULE.getPermission('TOKEN','OBSERVER') == false ) {
|
||||
streamDeck.noPermission(context);
|
||||
return;
|
||||
}
|
||||
if (token.owner == false && token.observer == false && MODULE.getPermission('TOKEN','NON_OWNED') == false ) {
|
||||
streamDeck.noPermission(context);
|
||||
return;
|
||||
}
|
||||
|
||||
tokenName = token.data.name;
|
||||
if (name) txt += tokenName;
|
||||
if (name && stats != 'none') txt += "\n";
|
||||
|
||||
const permission = token.actor?.permission;
|
||||
if (settings.combat){
|
||||
@@ -49,8 +72,8 @@ export class TokenControl{
|
||||
stats = 'none';
|
||||
}
|
||||
|
||||
iconSrc = token.data.img;
|
||||
|
||||
if (icon) iconSrc = token.data.img;
|
||||
if (name && stats != 'none' && stats != 'HPbox') txt += "\n";
|
||||
if (stats == 'custom'){
|
||||
const custom = settings.custom ? settings.custom : '';
|
||||
let split = custom.split('[');
|
||||
@@ -72,8 +95,20 @@ export class TokenControl{
|
||||
else if (game.system.id == 'dnd5e'){
|
||||
let attributes = token.actor.data.data.attributes;
|
||||
if (stats == 'HP') {
|
||||
uses = {
|
||||
available: attributes.hp.value,
|
||||
maximum: attributes.hp.max,
|
||||
heart: true
|
||||
};
|
||||
txt += attributes.hp.value + "/" + attributes.hp.max;
|
||||
}
|
||||
else if (stats == 'HPbox') {
|
||||
uses = {
|
||||
available: attributes.hp.value,
|
||||
maximum: attributes.hp.max,
|
||||
heart: false
|
||||
}
|
||||
}
|
||||
else if (stats == 'TempHP') {
|
||||
txt += attributes.hp.temp;
|
||||
if (attributes.hp.tempmax != null)
|
||||
@@ -111,13 +146,47 @@ export class TokenControl{
|
||||
}
|
||||
txt += speed;
|
||||
}
|
||||
else if (stats == 'Init') txt += attributes.init.total;
|
||||
else if (stats == 'Init') {
|
||||
const value = attributes.init.total;
|
||||
if (value >= 0) txt += '+';
|
||||
txt += value;
|
||||
}
|
||||
else if (stats == 'PassivePerception') txt += token.actor.data.data.skills.prc.passive;
|
||||
else if (stats == 'PassiveInvestigation') txt += token.actor.data.data.skills.inv.passive;
|
||||
else if (stats == 'Ability') {
|
||||
const ability = settings.ability ? settings.ability : 'str';
|
||||
txt += token.actor.data.data.abilities?.[ability].value;
|
||||
}
|
||||
else if (stats == 'AbilityMod') {
|
||||
const ability = settings.ability ? settings.ability : 'str';
|
||||
const value = token.actor.data.data.abilities?.[ability].mod;
|
||||
if (value >= 0) txt += '+';
|
||||
txt += value;
|
||||
}
|
||||
else if (stats == 'Save') {
|
||||
const ability = settings.save ? settings.save : 'str';
|
||||
const value = token.actor.data.data.abilities?.[ability].save;
|
||||
if (value >= 0) txt += '+';
|
||||
txt += value;
|
||||
}
|
||||
else if (stats == 'Skill') {
|
||||
const skill = settings.skill ? settings.skill : 'acr';
|
||||
const value = token.actor.data.data.skills?.[skill].mod;
|
||||
if (value >= 0) txt += '+';
|
||||
txt += value;
|
||||
}
|
||||
else if (stats == 'Prof') txt += token.actor.data.data.attributes.prof;
|
||||
}
|
||||
|
||||
else if (game.system.id == 'D35E' || game.system.id == 'pf1'){
|
||||
let attributes = token.actor.data.data.attributes;
|
||||
if (stats == 'HP') txt += attributes.hp.value + "/" + attributes.hp.max;
|
||||
else if (stats == 'HPbox') {
|
||||
uses = {
|
||||
available: attributes.hp.value,
|
||||
maximum: attributes.hp.max
|
||||
}
|
||||
}
|
||||
else if (stats == 'TempHP') {
|
||||
if (attributes.hp.temp == null) txt += '0';
|
||||
else txt += attributes.hp.temp;
|
||||
@@ -144,11 +213,44 @@ export class TokenControl{
|
||||
}
|
||||
txt += speed;
|
||||
}
|
||||
else if (stats == 'Init') txt += attributes.init.total;
|
||||
else if (stats == 'Init') {
|
||||
const value = attributes.init.total;
|
||||
if (value >= 0) txt += '+';
|
||||
txt += value;
|
||||
}
|
||||
else if (stats == 'Ability') {
|
||||
const ability = settings.ability ? settings.ability : 'str';
|
||||
txt += token.actor.data.data.abilities?.[ability].value;
|
||||
}
|
||||
else if (stats == 'AbilityMod') {
|
||||
const ability = settings.ability ? settings.ability : 'str';
|
||||
const value = token.actor.data.data.abilities?.[ability].mod;
|
||||
if (value >= 0) txt += '+';
|
||||
txt += value;
|
||||
}
|
||||
else if (stats == 'Save') {
|
||||
const ability = settings.save ? settings.save : 'fort';
|
||||
const value = token.actor.data.data.attributes.savingThrows?.[ability].total;
|
||||
if (value >= 0) txt += '+';
|
||||
txt += value;
|
||||
}
|
||||
else if (stats == 'Skill') {
|
||||
const skill = settings.skill ? settings.skill : 'apr';
|
||||
const value = token.actor.data.data.skills?.[skill].mod;
|
||||
if (value >= 0) txt += '+';
|
||||
txt += value;
|
||||
}
|
||||
else if (stats == 'Prof') txt += token.actor.data.data.attributes.prof;
|
||||
}
|
||||
else if (game.system.id == 'pf2e'){
|
||||
let attributes = token.actor.data.data.attributes;
|
||||
if (stats == 'HP') txt += attributes.hp.value + "/" + attributes.hp.max;
|
||||
else if (stats == 'HPbox') {
|
||||
uses = {
|
||||
available: attributes.hp.value,
|
||||
maximum: attributes.hp.max
|
||||
}
|
||||
}
|
||||
else if (stats == 'TempHP') {
|
||||
if (attributes.hp.temp == null) txt += '0';
|
||||
else {
|
||||
@@ -158,7 +260,7 @@ export class TokenControl{
|
||||
}
|
||||
else if (stats == 'AC') txt += attributes.ac.value;
|
||||
else if (stats == 'Speed'){
|
||||
let speed = "Land: " + attributes.speed.value.replace('feet','') + ' feet';
|
||||
let speed = attributes.speed.breakdown;
|
||||
const otherSpeeds = attributes.speed.otherSpeeds;
|
||||
if (otherSpeeds.length > 0)
|
||||
for (let i=0; i<otherSpeeds.length; i++)
|
||||
@@ -166,16 +268,62 @@ export class TokenControl{
|
||||
txt += speed;
|
||||
}
|
||||
else if (stats == 'Init') {
|
||||
let init = attributes.initiative.totalModifier;
|
||||
if (init != undefined) txt += init;
|
||||
const value = attributes.init.value;
|
||||
if (value != undefined) {
|
||||
if (value >= 0) txt += "+";
|
||||
txt += value;
|
||||
}
|
||||
}
|
||||
else if (stats == 'Ability') {
|
||||
const ability = settings.ability ? settings.ability : 'str';
|
||||
txt += token.actor.data.data.abilities?.[ability].value;
|
||||
}
|
||||
else if (stats == 'AbilityMod') {
|
||||
const ability = settings.ability ? settings.ability : 'str';
|
||||
const value = token.actor.data.data.abilities?.[ability].mod;
|
||||
if (value >= 0) txt += '+';
|
||||
txt += value;
|
||||
}
|
||||
else if (stats == 'Save') {
|
||||
let ability = settings.save ? settings.save : 'fort';
|
||||
if (ability == 'fort') ability = 'fortitude';
|
||||
else if (ability == 'ref') ability = 'reflex';
|
||||
else if (ability == 'will') ability = 'will';
|
||||
const value = token.actor.data.data.saves?.[ability].value;
|
||||
if (value >= 0) txt += "+";
|
||||
txt += value;
|
||||
}
|
||||
else if (stats == 'Skill') {
|
||||
const skill = settings.skill ? settings.skill : 'acr';
|
||||
const value = token.actor.data.data.skills?.[skill].totalModifier;
|
||||
if (value >= 0) txt += '+';
|
||||
txt += value;
|
||||
}
|
||||
}
|
||||
else if (game.system.id == 'demonlord'){
|
||||
let characteristics = token.actor.data.data.characteristics;
|
||||
if (stats == 'HP') txt += characteristics.health.value + "/" + characteristics.health.max;
|
||||
else if (stats == 'HPbox') {
|
||||
uses = {
|
||||
available: characteristics.health.value,
|
||||
maximum: characteristics.health.max
|
||||
}
|
||||
}
|
||||
else if (stats == 'AC') txt += characteristics.defense;
|
||||
else if (stats == 'Speed') txt += characteristics.speed;
|
||||
else if (stats == 'Init') txt += token.actor.data.data.fastturn ? "FAST" : "SLOW";
|
||||
else if (stats == 'Ability') {
|
||||
const ability = settings.ability ? settings.ability : 'strength';
|
||||
const value = token.actor.data.data.attributes?.[ability].value;
|
||||
if (value >=0) txt += '+';
|
||||
txt += value;
|
||||
}
|
||||
else if (stats == 'AbilityMod') {
|
||||
const ability = settings.ability ? settings.ability : 'strength';
|
||||
const value = token.actor.data.data.attributes?.[ability].modifier;
|
||||
if (value >=0) txt += '+';
|
||||
txt += value;
|
||||
}
|
||||
}
|
||||
else {
|
||||
//Other systems
|
||||
@@ -238,7 +386,7 @@ export class TokenControl{
|
||||
else if (icon == false) {
|
||||
let effect = CONFIG.statusEffects.find(e => e.id === condition);
|
||||
iconSrc = effect.icon;
|
||||
let effects = token.actor.effects.entries;
|
||||
let effects = compatibleCore("0.8.1") ? token.actor.effects.contents : token.actor.effects.entries;
|
||||
let active = effects.find(e => e.isTemporary === condition);
|
||||
if (active != undefined){
|
||||
ring = 2;
|
||||
@@ -292,7 +440,7 @@ export class TokenControl{
|
||||
if (icon == false) {
|
||||
let effect = CONFIG.statusEffects.find(e => e.label === condition);
|
||||
iconSrc = effect.icon;
|
||||
let effects = token.actor.effects.entries;
|
||||
let effects = compatibleCore("0.8.1") ? token.actor.effects.contents : token.actor.effects.entries;
|
||||
let active = effects.find(e => e.isTemporary === effect.id);
|
||||
if (active != undefined){
|
||||
ring = 2;
|
||||
@@ -415,7 +563,7 @@ export class TokenControl{
|
||||
if (icon == false){
|
||||
if (MODULE.getPermission('TOKEN','STATS') == false) stats = statsOld;
|
||||
if (stats == 'HP' || stats == 'TempHP') //HP
|
||||
iconSrc = "modules/MaterialDeck/img/token/hp.png";
|
||||
iconSrc = "modules/MaterialDeck/img/token/hp_empty.png";
|
||||
else if (stats == 'AC' || stats == 'ShieldHP') //AC
|
||||
iconSrc = "modules/MaterialDeck/img/token/ac.webp";
|
||||
else if (stats == 'Speed') //Speed
|
||||
@@ -427,25 +575,46 @@ export class TokenControl{
|
||||
else if (stats == 'PassiveInvestigation')
|
||||
iconSrc = "modules/MaterialDeck/img/black.png";
|
||||
}
|
||||
streamDeck.setIcon(context,iconSrc,background,ring,ringColor,overlay);
|
||||
streamDeck.setIcon(context,iconSrc,{background:background,ring:ring,ringColor:ringColor,overlay:overlay,uses:uses,hp:hp});
|
||||
streamDeck.setTitle(txt,context);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
async keyPress(settings){
|
||||
if (MODULE.selectedTokenId == undefined) return;
|
||||
const tokenId = MODULE.selectedTokenId;
|
||||
|
||||
const token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
|
||||
const selection = settings.selection ? settings.selection : 'selected';
|
||||
const tokenIdentifier = settings.tokenName ? settings.tokenName : '';
|
||||
|
||||
let token;
|
||||
if (selection == 'selected') token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
|
||||
else if (selection != 'selected' && tokenIdentifier == '') {}
|
||||
else if (selection == 'tokenName') token = canvas.tokens.children[0].children.find(p => p.name == tokenIdentifier);
|
||||
else if (selection == 'actorName') token = canvas.tokens.children[0].children.find(p => p.actor.name == tokenIdentifier);
|
||||
else if (selection == 'tokenId') token = canvas.tokens.children[0].children.find(p => p.id == tokenIdentifier);
|
||||
else if (selection == 'actorId') token = canvas.tokens.children[0].children.find(p => p.actor.id == tokenIdentifier);
|
||||
|
||||
if (token == undefined) return;
|
||||
if (token.owner == false && token.observer == true && MODULE.getPermission('TOKEN','OBSERVER') == false ) return;
|
||||
if (token.owner == false && token.observer == false && MODULE.getPermission('TOKEN','NON_OWNED') == false ) return;
|
||||
|
||||
const onClick = settings.onClick ? settings.onClick : 'doNothing';
|
||||
|
||||
if (onClick == 'doNothing') //Do nothing
|
||||
return;
|
||||
else if (onClick == 'select'){ //select token
|
||||
token.control();
|
||||
}
|
||||
else if (onClick == 'center'){ //center on token
|
||||
let location = token.getCenter(token.x,token.y);
|
||||
canvas.animatePan(location);
|
||||
}
|
||||
else if (onClick == 'centerSelect'){ //center on token and select
|
||||
const location = token.getCenter(token.x,token.y);
|
||||
canvas.animatePan(location);
|
||||
token.control();
|
||||
}
|
||||
else if (onClick == 'charSheet'){ //Open character sheet
|
||||
const element = document.getElementById(token.actor.sheet.id);
|
||||
if (element == null) token.actor.sheet.render(true);
|
||||
@@ -505,7 +674,7 @@ export class TokenControl{
|
||||
this.update(tokenId);
|
||||
|
||||
}
|
||||
else if (settings.onClick == 'cubCondition') { //Combat Utility Belt conditions
|
||||
else if (onClick == 'cubCondition') { //Combat Utility Belt conditions
|
||||
if (MODULE.getPermission('TOKEN','CONDITIONS') == false ) return;
|
||||
const condition = settings.cubConditionName;
|
||||
if (condition == undefined || condition == '') return;
|
||||
@@ -595,6 +764,48 @@ export class TokenControl{
|
||||
iconSrc = images[imgNr];
|
||||
token.update({img: iconSrc})
|
||||
}
|
||||
else if (onClick == 'macro') { //call a macro
|
||||
const settingsNew = {
|
||||
target: token,
|
||||
macroMode: settings.macroMode,
|
||||
macroNumber: settings.macroId,
|
||||
macroArgs: settings.macroArgs
|
||||
}
|
||||
macroControl.keyPress(settingsNew);
|
||||
}
|
||||
else if (onClick == 'roll') { //roll skill/save/ability
|
||||
const roll = settings.roll ? settings.roll : 'abilityCheck';
|
||||
const ability = settings.rollAbility ? settings.rollAbility : 'str';
|
||||
const skill = settings.rollSkill ? settings.rollSkill : 'acr';
|
||||
const save = settings.rollSave ? settings.rollSave : 'str';
|
||||
|
||||
if (game.system.id == 'pf2e') {
|
||||
if (roll == 'abilityCheck') token.actor.data.data.saves?.[ability].roll();
|
||||
else if (roll == 'save') {
|
||||
let ability = save;
|
||||
if (ability == 'fort') ability = 'fortitude';
|
||||
else if (ability == 'ref') ability = 'reflex';
|
||||
else if (ability == 'will') ability = 'will';
|
||||
token.actor.data.data.saves?.[ability].roll();
|
||||
}
|
||||
else if (roll == 'skill') token.actor.data.data.skills?.[skill].roll();
|
||||
}
|
||||
if (roll == 'abilityCheck') token.actor.rollAbilityTest(ability);
|
||||
else if (roll == 'save') {
|
||||
if (game.system.id == 'dnd5e') token.actor.rollAbilitySave(save);
|
||||
else token.actor.rollSavingThrow(save);
|
||||
}
|
||||
else if (roll == 'skill') token.actor.rollSkill(skill);
|
||||
else if (roll == 'initiative') token.actor.rollInitiative();
|
||||
else if (roll == 'deathSave') token.actor.rollDeathSave();
|
||||
else if (roll == 'grapple') token.actor.rollGrapple();
|
||||
else if (roll == 'bab') token.actor.rollBAB();
|
||||
else if (roll == 'melee') token.actor.rollMelee();
|
||||
else if (roll == 'ranged') token.actor.rollRanged();
|
||||
else if (roll == 'cmb') token.actor.rollCMB();
|
||||
else if (roll == 'attack') token.actor.rollAttack();
|
||||
else if (roll == 'defenses') token.actor.rollDefenses();
|
||||
}
|
||||
else if (onClick == 'custom') {//custom onClick function
|
||||
if (MODULE.getPermission('TOKEN','CUSTOM') == false ) return;
|
||||
const formula = settings.customOnClickFormula ? settings.customOnClickFormula : '';
|
||||
@@ -604,19 +815,39 @@ export class TokenControl{
|
||||
let formulaArrayTemp;
|
||||
let split1 = formula.split(';');
|
||||
for (let i=0; i<split1.length; i++){
|
||||
let macro = false;
|
||||
let furnaceArguments = "";
|
||||
let split2 = split1[i].split(' = ');
|
||||
targetArrayTemp = split2[0];
|
||||
formulaArrayTemp = split2[1];
|
||||
|
||||
let targetArray = this.splitCustom(targetArrayTemp);
|
||||
|
||||
for (let i=0; i<targetArray.length; i++){
|
||||
if (targetArray[i][0] == '@') {
|
||||
const dataPath = targetArray[i].split('@')[1].split('.');
|
||||
targetArray[i] = dataPath;
|
||||
if (dataPath == 'macro') {
|
||||
macro = true;
|
||||
}
|
||||
}
|
||||
else if (macro) {
|
||||
const data = targetArray[i].split('[');
|
||||
if (data != undefined && data.length > 1) targetArray[i] = data[1];
|
||||
if (i > 1) {
|
||||
if (furnaceArguments != "") furnaceArguments += " ";
|
||||
furnaceArguments += "\"" + targetArray[i] + "\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (macro) {
|
||||
const settingsNew = {
|
||||
target: token,
|
||||
macroMode: 'name',
|
||||
macroNumber: targetArray[1],
|
||||
macroArgs: furnaceArguments
|
||||
}
|
||||
macroControl.keyPress(settingsNew);
|
||||
continue;
|
||||
}
|
||||
let formulaArray = this.splitCustom(formulaArrayTemp);
|
||||
|
||||
let value = 0;
|
||||
@@ -673,7 +904,7 @@ export class TokenControl{
|
||||
if (path != '') path += '.';
|
||||
path += targetArray[i][j];
|
||||
}
|
||||
actor.update({[path]:value})
|
||||
await actor.update({[path]:value})
|
||||
}
|
||||
else {
|
||||
let path = '';
|
||||
@@ -681,9 +912,9 @@ export class TokenControl{
|
||||
if (path != '') path += '.';
|
||||
path += targetArray[i][j];
|
||||
}
|
||||
actor.update({[path]:value})
|
||||
await actor.update({[path]:value})
|
||||
}
|
||||
|
||||
this.update(token.id);
|
||||
}
|
||||
else {
|
||||
data = token;
|
||||
@@ -692,8 +923,10 @@ export class TokenControl{
|
||||
if (path != '') path += '.';
|
||||
path += targetArray[i][j];
|
||||
}
|
||||
token.update({[path]:value})
|
||||
await token.update({[path]:value})
|
||||
this.update(token.id);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
{{#select this.macro}}
|
||||
<option value="">{{localize "MaterialDeck.None"}}</option>
|
||||
{{#each ../../macros}}
|
||||
<option value="{{this._id}}">{{this.name}}</option>
|
||||
<option value="{{this.id}}">{{this.name}}</option>
|
||||
{{/each}}
|
||||
{{/select}}
|
||||
</select>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
{{#select this.playlist}}
|
||||
<option value="">{{localize "MaterialDeck.None"}}</option>
|
||||
{{#each ../playlists}}
|
||||
<option value="{{this._id}}">{{this.name}}</option>
|
||||
<option value="{{this.id}}">{{this.name}}</option>
|
||||
{{/each}}
|
||||
{{/select}}
|
||||
</select>
|
||||
|
||||
Reference in New Issue
Block a user