v1.4.4
@@ -1,7 +1,6 @@
|
||||
import {registerSettings} from "./src/settings.js";
|
||||
import {StreamDeck} from "./src/streamDeck.js";
|
||||
import {TokenControl} from "./src/token.js";
|
||||
import {Move} from "./src/move.js";
|
||||
import {MacroControl} from "./src/macro.js";
|
||||
import {CombatTracker} from "./src/combattracker.js";
|
||||
import {PlaylistControl} from "./src/playlist.js";
|
||||
@@ -9,10 +8,10 @@ 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";
|
||||
import {downloadUtility, compatibleCore} from "./src/misc.js";
|
||||
import {TokenHelper} from "./src/systems/tokenHelper.js";
|
||||
export var streamDeck;
|
||||
export var tokenControl;
|
||||
var move;
|
||||
export var macroControl;
|
||||
export var combatTracker;
|
||||
export var playlistControl;
|
||||
@@ -20,17 +19,20 @@ export var soundboard;
|
||||
export var otherControls;
|
||||
export var externalModules;
|
||||
export var sceneControl;
|
||||
export var tokenHelper;
|
||||
|
||||
export const moduleName = "MaterialDeck";
|
||||
|
||||
let ready = false;
|
||||
let activeSounds = [];
|
||||
|
||||
export let hotbarUses = false;
|
||||
export let calculateHotbarUses;
|
||||
|
||||
let controlTokenTimer;
|
||||
|
||||
export let sdVersion;
|
||||
export let msVersion;
|
||||
|
||||
//CONFIG.debug.hooks = true;
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -71,18 +73,28 @@ async function analyzeWSmessage(msg){
|
||||
}
|
||||
|
||||
if (data.type == "version" && data.source == "SD") {
|
||||
const minimumSDversion = game.modules.get("MaterialDeck").data.minimumSDversion.replace('v','');
|
||||
const minimumMSversion = game.modules.get("MaterialDeck").data.minimumMSversion;
|
||||
let minimumSDversion;
|
||||
let minimumMSversion;
|
||||
if (compatibleCore("0.8.5")) {
|
||||
minimumSDversion = game.modules.get("MaterialDeck").data.flags.minimumSDversion.replace('v','');
|
||||
minimumMSversion = game.modules.get("MaterialDeck").data.flags.minimumMSversion;
|
||||
}
|
||||
else {
|
||||
minimumSDversion = game.modules.get("MaterialDeck").data.minimumSDversion.replace('v','');
|
||||
minimumMSversion = game.modules.get("MaterialDeck").data.minimumMSversion;
|
||||
}
|
||||
|
||||
sdVersion = data.version;
|
||||
|
||||
if (data.version < minimumSDversion) {
|
||||
let d = new Dialog({
|
||||
title: "Material Deck: Update Needed",
|
||||
content: "<p>The Stream Deck plugin version you're using is v" + data.version + ", which is outdated.<br>Update to v" + minimumSDversion + " or newer.</p>",
|
||||
content: "<p>The Stream Deck plugin version you're using is v" + data.version + ", which is incompatible with this verion of the module.<br>Update to v" + minimumSDversion + " or newer.</p>",
|
||||
buttons: {
|
||||
download: {
|
||||
icon: '<i class="fas fa-download"></i>',
|
||||
label: "Update",
|
||||
callback: () => window.open("https://github.com/CDeenen/MaterialDeck_SD/releases")
|
||||
label: "Download Utility",
|
||||
callback: () => new downloadUtility()
|
||||
},
|
||||
ignore: {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
@@ -117,8 +129,6 @@ async function analyzeWSmessage(msg){
|
||||
tokenControl.active = true;
|
||||
tokenControl.pushData(canvas.tokens.controlled[0]?.id,settings,context,device);
|
||||
}
|
||||
else if (action == 'move')
|
||||
move.update(settings,context,device);
|
||||
else if (action == 'macro')
|
||||
macroControl.update(settings,context,device);
|
||||
else if (action == 'combattracker')
|
||||
@@ -143,8 +153,6 @@ async function analyzeWSmessage(msg){
|
||||
else if (event == 'keyDown'){
|
||||
if (action == 'token')
|
||||
tokenControl.keyPress(settings);
|
||||
else if (action == 'move')
|
||||
move.keyPress(settings);
|
||||
else if (action == 'macro')
|
||||
macroControl.keyPress(settings);
|
||||
else if (action == 'combattracker')
|
||||
@@ -189,6 +197,7 @@ function startWebsocket() {
|
||||
}
|
||||
|
||||
ws.onopen = function() {
|
||||
messageCount = 0;
|
||||
WSconnected = true;
|
||||
ui.notifications.info("Material Deck "+game.i18n.localize("MaterialDeck.Notifications.Connected") +": "+address);
|
||||
wsOpen = true;
|
||||
@@ -210,13 +219,23 @@ function startWebsocket() {
|
||||
clearInterval(wsInterval);
|
||||
wsInterval = setInterval(resetWS, 10000);
|
||||
}
|
||||
|
||||
let messageCount = 0;
|
||||
/**
|
||||
* Try to reset the websocket if a connection is lost
|
||||
*/
|
||||
function resetWS(){
|
||||
if (wsOpen) ui.notifications.warn("Material Deck: "+game.i18n.localize("MaterialDeck.Notifications.Disconnected"));
|
||||
else ui.notifications.warn("Material Deck: "+game.i18n.localize("MaterialDeck.Notifications.ConnectFail"));
|
||||
const maxMessages = game.settings.get(moduleName, 'nrOfConnMessages');
|
||||
if (maxMessages == 0 || maxMessages > messageCount) {
|
||||
messageCount++;
|
||||
const countString = maxMessages == 0 ? "" : " (" + messageCount + "/" + maxMessages + ")";
|
||||
if (wsOpen) {
|
||||
ui.notifications.warn("Material Deck: "+game.i18n.localize("MaterialDeck.Notifications.Disconnected"));
|
||||
wsOpen = false;
|
||||
messageCount = 0;
|
||||
}
|
||||
else ui.notifications.warn("Material Deck: "+game.i18n.localize("MaterialDeck.Notifications.ConnectFail") + countString);
|
||||
}
|
||||
|
||||
WSconnected = false;
|
||||
startWebsocket();
|
||||
}
|
||||
@@ -256,16 +275,18 @@ Hooks.once('ready', async()=>{
|
||||
registerSettings();
|
||||
enableModule = (game.settings.get(moduleName,'Enable')) ? true : false;
|
||||
|
||||
|
||||
|
||||
soundboard = new SoundboardControl();
|
||||
streamDeck = new StreamDeck();
|
||||
tokenControl = new TokenControl();
|
||||
move = new Move();
|
||||
macroControl = new MacroControl();
|
||||
combatTracker = new CombatTracker();
|
||||
playlistControl = new PlaylistControl();
|
||||
otherControls = new OtherControls();
|
||||
externalModules = new ExternalModules();
|
||||
sceneControl = new SceneControl();
|
||||
tokenHelper = new TokenHelper();
|
||||
|
||||
game.socket.on(`module.MaterialDeck`, async(payload) =>{
|
||||
//console.log(payload);
|
||||
@@ -313,9 +334,6 @@ Hooks.once('ready', async()=>{
|
||||
|
||||
});
|
||||
|
||||
for (let i=0; i<64; i++)
|
||||
activeSounds[i] = false;
|
||||
|
||||
if (game.user.isGM) {
|
||||
let soundBoardSettings = game.settings.get(moduleName,'soundboardSettings');
|
||||
let macroSettings = game.settings.get(moduleName, 'macroSettings');
|
||||
@@ -425,6 +443,11 @@ Hooks.on('renderCombatTracker',()=>{
|
||||
if (tokenControl != undefined) tokenControl.update(canvas.tokens.controlled[0]?.id);
|
||||
});
|
||||
|
||||
Hooks.on('renderActorSheet',()=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
if (tokenControl != undefined) tokenControl.update();
|
||||
});
|
||||
|
||||
Hooks.on('renderPlaylistDirectory', (playlistDirectory)=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
if (playlistControl != undefined) playlistControl.updateAll();
|
||||
|
||||
@@ -31,11 +31,6 @@ The functions are categorized into actions. Here is a list of the available acti
|
||||
<li>Toggle token visibility, combat state, conditions</li>
|
||||
</ul>
|
||||
<li>Move Action: Move selected token or the canvas</li>
|
||||
<ul>
|
||||
<li>Move token (in a specified direction)</li>
|
||||
<li>Move canvas (in a specified direction)</li>
|
||||
<li>Zoom canvas in/out</li>
|
||||
</ul>
|
||||
<li>Macro Actions: Execute macros</li>
|
||||
<ul>
|
||||
<li>Execute macro from hotbar</li>
|
||||
@@ -71,7 +66,7 @@ Instructions and more info can be found in the <a href="https://github.com/CDeen
|
||||
Module manifest: https://raw.githubusercontent.com/CDeenen/MaterialDeck/Master/module.json
|
||||
|
||||
## Software Versions & Module Incompatibilities
|
||||
<b>Foundry VTT:</b> Tested on 0.7.9<br>
|
||||
<b>Foundry VTT:</b> Tested on 0.7.9 - 0.8.5<br>
|
||||
<b>Module Incompatibilities:</b> None known.<br>
|
||||
|
||||
## Feedback
|
||||
|
||||
32
changelog.md
@@ -1,4 +1,36 @@
|
||||
# Changelog Material Deck Module
|
||||
### v1.4.4 - 26-05-2021
|
||||
Fixes:
|
||||
<ul>
|
||||
<li>Some small fixes to make the module compatible with Foundry 0.8.5</li>
|
||||
</ul>
|
||||
|
||||
Additions:
|
||||
<ul>
|
||||
<li>Token Action => Added 'Page-Wide Token' option. All buttons on the current page (where the page is the collection of buttons that are shown) that have this enabled will use the same token</li>
|
||||
<li>Token Action => On Click: Added 'Set Page-Wide Token' option, so you can configure buttons to set the page-wide token by pressing a button</li>
|
||||
<li>Token Action: Added a 'Mode' select box. Setting it to 'Token' is the same as pre v1.4.4. New are the inventory, features and spellbook options that can be used to auto-populate buttons with items, features and spells.</li>
|
||||
<li>Added a 'Clear Page' and 'Clear All' button to the soundboard and macroboard configuration</li>
|
||||
<li>Added import and export buttons to the soundboard and macroboard configuration (only imports/exports metadata, not the actual audio files or the macros)</li>
|
||||
<li>The number of connection error messages you will get is now configurable in the module settings</li>
|
||||
<li>Added a download utility to the module settings, so you can easily version-check with the SD plugin and Material Server, download them and download profiles</li>
|
||||
<li>Added Japanese localization (thanks BrotherSharper and Asami). All of the new features have not yet been translated</li>
|
||||
</ul>
|
||||
|
||||
Other:
|
||||
<ul>
|
||||
<li><b>(Breaking)</b> The Move Action has been removed. Moving tokens is not in the Token Action (it's an on click setting) and moving the canvas is in the Other Actions.</li>
|
||||
<li>Major change to the soundboard and macroboard configuration. It is now displayed as pages of 16 sounds or 32 macros each, you can browse through the pages using the arrow keys at the top.</li>
|
||||
<li>There is no longer a limit to the amount of sounds/macros you can assign to the soundboard/macroboard, but please note that at some point you might experience performance issues if there's too many sounds/macros.</li>
|
||||
<li>Removed the 'Stream Deck Model' module setting, since it's not that useful</li>
|
||||
<li>Token Action has been revamped to make it clearer and easier to implement new game systems</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.4.4 (<b>must be updated!</b>): https://github.com/CDeenen/MaterialDeck_SD/releases<br>
|
||||
|
||||
### v1.4.3 - 05-05-2021
|
||||
Fixes:
|
||||
<ul>
|
||||
|
||||
60
lang/en.json
@@ -3,15 +3,10 @@
|
||||
"MaterialDeck.Notifications.ConnectFail": "Can't connect to Material Server, retrying",
|
||||
"MaterialDeck.Notifications.Connected": "Connected",
|
||||
"MaterialDeck.Notifications.Soundboard.NoPermission": "You do not have permission to configure the soundboard",
|
||||
"MaterialDeck.Notifications.Macroboard.NoPermission": "You do not have permission to configure the macro board",
|
||||
"MaterialDeck.Notifications.Macroboard.NoPermission": "You do not have permission to configure the macroboard",
|
||||
"MaterialDeck.Notifications.Playlist.NoPermission": "You do not have permission to configure the playlists",
|
||||
|
||||
"MaterialDeck.Sett.Enable": "Enable module",
|
||||
"MaterialDeck.Sett.Model": "Stream Deck Model",
|
||||
"MaterialDeck.Sett.Model_Hint": "Reduces the amount of macros and sounds in the macro and soundboard configuration screens. Gives a better overview, but if desired it can be set to XL to get the maximum number. This doesn't influence the operation of the module.",
|
||||
"MaterialDeck.Sett.Model_Mini": "Mini",
|
||||
"MaterialDeck.Sett.Model_Normal": "Normal or Mobile",
|
||||
"MaterialDeck.Sett.Model_XL": "XL",
|
||||
"MaterialDeck.Sett.Help": "Help",
|
||||
"MaterialDeck.Sett.Permission": "User Permission Configuration",
|
||||
"MaterialDeck.Sett.PlaylistConfig": "Playlist Configuration",
|
||||
@@ -23,6 +18,8 @@
|
||||
"MaterialDeck.Sett.ImageBufferHint": "Sets the amount of images to store in the image cache. The image cache will locally store all images sent to the Stream Deck. This improves the update speed, but increases memory usage.",
|
||||
"MaterialDeck.Sett.ImageBrightness": "Image Brightness",
|
||||
"MaterialDeck.Sett.ImageBrightnessHint": "Sets the brightness of the default white images. If the Image Cache Size is bigger than 0, perform a refresh for instant results.",
|
||||
"MaterialDeck.Sett.NrOfConnMessages": "Number of Connection Warnings",
|
||||
"MaterialDeck.Sett.NrOfConnMessagesHint": "Sets the number of times a connection warning is displayed if Material Deck cannot connect to Material Server. If set to 0, it will give not be limited.",
|
||||
|
||||
"MaterialDeck.PL.Unrestricted": "Unrestricted",
|
||||
"MaterialDeck.PL.OneTrackPlaylist": "One track per playlist",
|
||||
@@ -39,6 +36,8 @@
|
||||
"MaterialDeck.Background": "Background",
|
||||
"MaterialDeck.Macro": "Macro",
|
||||
"MaterialDeck.Sound": "Sound",
|
||||
"MaterialDeck.Sounds": "Sounds",
|
||||
"MaterialDeck.Of": "of",
|
||||
"MaterialDeck.Icon": "Icon",
|
||||
"MaterialDeck.Once": "Once",
|
||||
"MaterialDeck.Repeat": "Repeat",
|
||||
@@ -50,11 +49,28 @@
|
||||
"MaterialDeck.Name": "Name",
|
||||
"MaterialDeck.None": "None",
|
||||
"MaterialDeck.Save": "Save",
|
||||
"MaterialDeck.ClearAll": "Clear All",
|
||||
"MaterialDeck.ClearAll_Content": "This will clear all the data. This cannot be undone, are you sure you want to proceed?",
|
||||
"MaterialDeck.ClearPage": "Clear Page",
|
||||
"MaterialDeck.ClearPage_Content": "This will clear all the data on this page. This cannot be undone, are you sure you want to proceed?",
|
||||
"MaterialDeck.Continue": "Continue",
|
||||
"MaterialDeck.Cancel": "Cancel",
|
||||
"MaterialDeck.Import": "Import",
|
||||
"MaterialDeck.Export": "Export",
|
||||
"MaterialDeck.Filename": "Filename",
|
||||
|
||||
"MaterialDeck.ExportDialog.Title": "Export",
|
||||
"MaterialDeck.ExportDialog.SoundboardContent": "Export the soundboard data. Please note that only the metadata is exported, so you will have to make sure the audio files are in the same relative location when you import them.",
|
||||
"MaterialDeck.ExportDialog.MacroboardContent": "Export the macroboard data. Please note that only the metadata is exported, so you will have to make sure the same macros are available when you import them.",
|
||||
|
||||
"MaterialDeck.ImportDialog.Title": "Import",
|
||||
"MaterialDeck.ImportDialog.SoundboardContent": "Select a file to import. Please note that only the metadata is imported, so you will have to make sure the audio files are in the same relative location as when you exported them.",
|
||||
"MaterialDeck.ImportDialog.MacroboardContent": "Import the macroboard data. ",
|
||||
"MaterialDeck.ImportDialog.Warning": "This will overwrite your current settings, and cannot be undone.",
|
||||
|
||||
"MaterialDeck.FxMaster.Colorize": "Colorize",
|
||||
"MaterialDeck.FxMaster.Clear": "Clear All",
|
||||
|
||||
|
||||
"MaterialDeck.Perm.Instructions": "Configure the permission for each Material Deck action.",
|
||||
"MaterialDeck.Perm.DefaultNotification": "Material Deck user permissions have been configured to the default values.",
|
||||
|
||||
@@ -96,15 +112,9 @@
|
||||
"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.hint": "Allow users to use the macroboard",
|
||||
"MaterialDeck.Perm.MACRO.MACROBOARD_CONFIGURE.label": "Configure the Macro Board",
|
||||
"MaterialDeck.Perm.MACRO.MACROBOARD_CONFIGURE.hint": "Allow users to configure the macro board. To allow users to pick icons using the filepicker, enable 'Browse File Explorer' for that user in the core Permission Configuration",
|
||||
|
||||
"MaterialDeck.Perm.MOVE.label": "Move",
|
||||
"MaterialDeck.Perm.MOVE.TOKEN.label": "Token",
|
||||
"MaterialDeck.Perm.MOVE.TOKEN.hint": "Allow users to move a controlled token",
|
||||
"MaterialDeck.Perm.MOVE.CANVAS.label": "Canvas",
|
||||
"MaterialDeck.Perm.MOVE.CANVAS.hint": "Allow users to move their canvas",
|
||||
"MaterialDeck.Perm.MACRO.MACROBOARD_CONFIGURE.hint": "Allow users to configure the macroboard. To allow users to pick icons using the filepicker, enable 'Browse File Explorer' for that user in the core Permission Configuration",
|
||||
|
||||
"MaterialDeck.Perm.OTHER.label": "Other",
|
||||
"MaterialDeck.Perm.OTHER.PAUSE.label": "Pause/Resume",
|
||||
@@ -178,6 +188,22 @@
|
||||
"MaterialDeck.AboutTime.Second": "nd",
|
||||
"MaterialDeck.AboutTime.Third": "rd",
|
||||
"MaterialDeck.AboutTime.Fourth": "th",
|
||||
"MaterialDeck.AboutTime.Of": "of"
|
||||
}
|
||||
"MaterialDeck.AboutTime.Of": "of",
|
||||
|
||||
"MaterialDeck.DownloadUtility.Title": "Download Utility",
|
||||
"MaterialDeck.DownloadUtility.Plugin": "Plugin & Material Server",
|
||||
"MaterialDeck.DownloadUtility.Minimum": "Minimum",
|
||||
"MaterialDeck.DownloadUtility.Current": "Current",
|
||||
"MaterialDeck.DownloadUtility.Latest": "Latest",
|
||||
"MaterialDeck.DownloadUtility.OS": "OS",
|
||||
"MaterialDeck.DownloadUtility.Download": "Download",
|
||||
"MaterialDeck.DownloadUtility.SDplugin": "SD Plugin",
|
||||
"MaterialDeck.DownloadUtility.MSserver": "Material Server",
|
||||
"MaterialDeck.DownloadUtility.Windows": "Windows",
|
||||
"MaterialDeck.DownloadUtility.Macos": "MacOS",
|
||||
"MaterialDeck.DownloadUtility.Linux": "Linux",
|
||||
"MaterialDeck.DownloadUtility.Source": "Source",
|
||||
"MaterialDeck.DownloadUtility.Profiles": "Profiles",
|
||||
"MaterialDeck.DownloadUtility.Name": "Name",
|
||||
"MaterialDeck.DownloadUtility.Refresh": "Refresh"
|
||||
}
|
||||
54
lang/ja.json
@@ -7,11 +7,6 @@
|
||||
"MaterialDeck.Notifications.Playlist.NoPermission": "プレイリストを設定する権限がありません",
|
||||
|
||||
"MaterialDeck.Sett.Enable": "モジュールの有効化",
|
||||
"MaterialDeck.Sett.Model": "Stream Deck モデル",
|
||||
"MaterialDeck.Sett.Model_Hint": "マクロとサウンドボードの設定画面でのマクロとサウンドの量を減らします。概要がわかりやすくなりますが、必要に応じてXLに設定して最大数を取得できます。これはモジュールの動作には影響しません。",
|
||||
"MaterialDeck.Sett.Model_Mini": "Mini",
|
||||
"MaterialDeck.Sett.Model_Normal": "Normal / Mobile",
|
||||
"MaterialDeck.Sett.Model_XL": "XL",
|
||||
"MaterialDeck.Sett.Help": "ヘルプ",
|
||||
"MaterialDeck.Sett.Permission": "ユーザー権限の設定",
|
||||
"MaterialDeck.Sett.PlaylistConfig": "プレイリスト設定",
|
||||
@@ -23,6 +18,8 @@
|
||||
"MaterialDeck.Sett.ImageBufferHint": "画像キャッシュに保存する画像のデータ量を設定します。画像キャッシュは、ストリームデッキに送信されたすべての画像をローカルに保存します。これにより更新速度は向上しますが、メモリ使用量は増加します。",
|
||||
"MaterialDeck.Sett.ImageBrightness": "画像の明るさ",
|
||||
"MaterialDeck.Sett.ImageBrightnessHint": "デフォルトの画像の明るさを設定します。画像キャッシュサイズが0より大きい場合、更新を実行してください。",
|
||||
"MaterialDeck.Sett.NrOfConnMessages": "Number of Connection Warnings",
|
||||
"MaterialDeck.Sett.NrOfConnMessagesHint": "Sets the number of times a connection warning is displayed if Material Deck cannot connect to Material Server. If set to 0, it will give not be limited.",
|
||||
|
||||
"MaterialDeck.PL.Unrestricted": "無制限",
|
||||
"MaterialDeck.PL.OneTrackPlaylist": "プレイリストごとに1つのトラック",
|
||||
@@ -39,6 +36,8 @@
|
||||
"MaterialDeck.Background": "背景",
|
||||
"MaterialDeck.Macro": "マクロ",
|
||||
"MaterialDeck.Sound": "サウンド",
|
||||
"MaterialDeck.Sounds": "Sounds",
|
||||
"MaterialDeck.Of": "of",
|
||||
"MaterialDeck.Icon": "アイコン",
|
||||
"MaterialDeck.Once": "一度だけ再生",
|
||||
"MaterialDeck.Repeat": "リピート再生",
|
||||
@@ -50,11 +49,28 @@
|
||||
"MaterialDeck.Name": "名前",
|
||||
"MaterialDeck.None": "無し",
|
||||
"MaterialDeck.Save": "セーブ",
|
||||
"MaterialDeck.ClearAll": "Clear All",
|
||||
"MaterialDeck.ClearAll_Content": "This will clear all the data. This cannot be undone, are you sure you want to proceed?",
|
||||
"MaterialDeck.ClearPage": "Clear Page",
|
||||
"MaterialDeck.ClearPage_Content": "This will clear all the data on this page. This cannot be undone, are you sure you want to proceed?",
|
||||
"MaterialDeck.Continue": "Continue",
|
||||
"MaterialDeck.Cancel": "Cancel",
|
||||
"MaterialDeck.Import": "Import",
|
||||
"MaterialDeck.Export": "Export",
|
||||
"MaterialDeck.Filename": "Filename",
|
||||
|
||||
"MaterialDeck.ExportDialog.Title": "Export",
|
||||
"MaterialDeck.ExportDialog.SoundboardContent": "Export the soundboard data. Please note that only the metadata is exported, so you will have to make sure the audio files are in the same relative location when you import them.",
|
||||
"MaterialDeck.ExportDialog.MacroboardContent": "Export the macro board data. Please note that only the metadata is exported, so you will have to make sure the same macros are available when you import them.",
|
||||
|
||||
"MaterialDeck.ImportDialog.Title": "Import",
|
||||
"MaterialDeck.ImportDialog.SoundboardContent": "Select a file to import. Please note that only the metadata is imported, so you will have to make sure the audio files are in the same relative location as when you exported them.",
|
||||
"MaterialDeck.ImportDialog.MacroboardContent": "Import the macro board data. ",
|
||||
"MaterialDeck.ImportDialog.Warning": "This will overwrite your current settings, and cannot be undone.",
|
||||
|
||||
"MaterialDeck.FxMaster.Colorize": "色付け",
|
||||
"MaterialDeck.FxMaster.Clear": "すべてクリア",
|
||||
|
||||
|
||||
"MaterialDeck.Perm.Instructions": "各Material Deckアクションの権限を設定します。",
|
||||
"MaterialDeck.Perm.DefaultNotification": "Material Deckのユーザー権限がデフォルト値に設定されています。",
|
||||
|
||||
@@ -100,12 +116,6 @@
|
||||
"MaterialDeck.Perm.MACRO.MACROBOARD_CONFIGURE.label": "マクロボードの設定",
|
||||
"MaterialDeck.Perm.MACRO.MACROBOARD_CONFIGURE.hint": "ユーザーがマクロボードを設定できるようにする。ユーザーがファイルエクスプローラを使用してアイコンを選択できるようにするには、コア設定の「権限の設定」でそのユーザーに対して「ファイルエクスプローラの使用」を有効にすること。",
|
||||
|
||||
"MaterialDeck.Perm.MOVE.label": "移動",
|
||||
"MaterialDeck.Perm.MOVE.TOKEN.label": "トークン",
|
||||
"MaterialDeck.Perm.MOVE.TOKEN.hint": "ユーザーが制御するトークンを移動できるようにする",
|
||||
"MaterialDeck.Perm.MOVE.CANVAS.label": "キャンバス",
|
||||
"MaterialDeck.Perm.MOVE.CANVAS.hint": "ユーザーがキャンバスを移動できるようにする",
|
||||
|
||||
"MaterialDeck.Perm.OTHER.label": "その他",
|
||||
"MaterialDeck.Perm.OTHER.PAUSE.label": "一時停止/再開",
|
||||
"MaterialDeck.Perm.OTHER.PAUSE.hint": "ユーザーがゲームを一時停止または再開できるようにする",
|
||||
@@ -178,6 +188,22 @@
|
||||
"MaterialDeck.AboutTime.Second": "2",
|
||||
"MaterialDeck.AboutTime.Third": "3",
|
||||
"MaterialDeck.AboutTime.Fourth": "4",
|
||||
"MaterialDeck.AboutTime.Of": "/"
|
||||
}
|
||||
"MaterialDeck.AboutTime.Of": "/",
|
||||
|
||||
"MaterialDeck.DownloadUtility.Title": "Download Utility",
|
||||
"MaterialDeck.DownloadUtility.Plugin": "Plugin & Material Server",
|
||||
"MaterialDeck.DownloadUtility.Minimum": "Minimum",
|
||||
"MaterialDeck.DownloadUtility.Current": "Current",
|
||||
"MaterialDeck.DownloadUtility.Latest": "Latest",
|
||||
"MaterialDeck.DownloadUtility.OS": "OS",
|
||||
"MaterialDeck.DownloadUtility.Download": "Download",
|
||||
"MaterialDeck.DownloadUtility.SDplugin": "SD Plugin",
|
||||
"MaterialDeck.DownloadUtility.MSserver": "Material Server",
|
||||
"MaterialDeck.DownloadUtility.Windows": "Windows",
|
||||
"MaterialDeck.DownloadUtility.Macos": "MacOS",
|
||||
"MaterialDeck.DownloadUtility.Linux": "Linux",
|
||||
"MaterialDeck.DownloadUtility.Source": "Source",
|
||||
"MaterialDeck.DownloadUtility.Profiles": "Profiles",
|
||||
"MaterialDeck.DownloadUtility.Name": "Name",
|
||||
"MaterialDeck.DownloadUtility.Refresh": "Refresh"
|
||||
}
|
||||
13
module.json
@@ -2,9 +2,7 @@
|
||||
"name": "MaterialDeck",
|
||||
"title": "Material Deck",
|
||||
"description": "Material Deck allows you to control Foundry using an Elgato Stream Deck",
|
||||
"version": "1.4.3",
|
||||
"minimumSDversion": "1.4.2",
|
||||
"minimumMSversion": "1.0.2",
|
||||
"version": "1.4.4",
|
||||
"author": "CDeenen",
|
||||
"authors": {
|
||||
"name": "CDeenen",
|
||||
@@ -13,13 +11,18 @@
|
||||
"patreon": "MaterialFoundry",
|
||||
"reddit": "CDeenen123"
|
||||
},
|
||||
|
||||
"flags": {
|
||||
"minimumSDversion": "1.4.4",
|
||||
"minimumMSversion": "1.0.2"
|
||||
},
|
||||
"minimumSDversion": "1.4.4",
|
||||
"minimumMSversion": "1.0.2",
|
||||
"esmodules": [
|
||||
"./MaterialDeck.js"
|
||||
],
|
||||
"socket": true,
|
||||
"minimumCoreVersion": "0.7.5",
|
||||
"compatibleCoreVersion": "0.8.2",
|
||||
"compatibleCoreVersion": "0.8.5",
|
||||
"languages": [
|
||||
{
|
||||
"lang": "en",
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import * as MODULE from "../MaterialDeck.js";
|
||||
import {streamDeck} from "../MaterialDeck.js";
|
||||
|
||||
export class ExternalModules{
|
||||
|
||||
693
src/misc.js
@@ -1,4 +1,4 @@
|
||||
import * as MODULE from "../MaterialDeck.js";
|
||||
import {sdVersion, msVersion, moduleName, getPermission, enableModule} from "../MaterialDeck.js";
|
||||
import {macroControl,soundboard,playlistControl} from "../MaterialDeck.js";
|
||||
|
||||
export function compatibleCore(compatibleVersion){
|
||||
@@ -36,12 +36,12 @@ export class playlistConfigForm extends FormApplication {
|
||||
* Provide data to the template
|
||||
*/
|
||||
getData() {
|
||||
if (MODULE.getPermission('PLAYLIST','CONFIGURE') == false ) {
|
||||
if (getPermission('PLAYLIST','CONFIGURE') == false ) {
|
||||
ui.notifications.warn(game.i18n.localize("MaterialDeck.Notifications.Playlist.NoPermission"));
|
||||
return;
|
||||
}
|
||||
//Get the playlist settings
|
||||
let settings = game.settings.get(MODULE.moduleName,'playlists');
|
||||
let settings = game.settings.get(moduleName,'playlists');
|
||||
|
||||
//Get values from the settings, and check if they are defined
|
||||
let selectedPlaylists = settings.selectedPlaylist;
|
||||
@@ -125,8 +125,8 @@ export class playlistConfigForm extends FormApplication {
|
||||
|
||||
async updateSettings(settings,render){
|
||||
if (game.user.isGM) {
|
||||
await game.settings.set(MODULE.moduleName,'playlists', settings);
|
||||
if (MODULE.enableModule) playlistControl.updateAll();
|
||||
await game.settings.set(moduleName,'playlists', settings);
|
||||
if (enableModule) playlistControl.updateAll();
|
||||
if (render) this.render();
|
||||
}
|
||||
else {
|
||||
@@ -146,6 +146,7 @@ export class macroConfigForm extends FormApplication {
|
||||
constructor(data, options) {
|
||||
super(data, options);
|
||||
this.data = data;
|
||||
this.page = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -164,14 +165,14 @@ export class macroConfigForm extends FormApplication {
|
||||
* Provide data to the template
|
||||
*/
|
||||
getData() {
|
||||
if (MODULE.getPermission('MACRO','MACROBOARD_CONFIGURE') == false ) {
|
||||
if (getPermission('MACRO','MACROBOARD_CONFIGURE') == false ) {
|
||||
ui.notifications.warn(game.i18n.localize("MaterialDeck.Notifications.Macroboard.NoPermission"));
|
||||
return;
|
||||
}
|
||||
//Get the settings
|
||||
var selectedMacros = game.settings.get(MODULE.moduleName,'macroSettings').macros;
|
||||
var color = game.settings.get(MODULE.moduleName,'macroSettings').color;
|
||||
var args = game.settings.get(MODULE.moduleName,'macroSettings').args;
|
||||
var selectedMacros = game.settings.get(moduleName,'macroSettings').macros;
|
||||
var color = game.settings.get(moduleName,'macroSettings').color;
|
||||
var args = game.settings.get(moduleName,'macroSettings').args;
|
||||
|
||||
//Check if the settings are defined
|
||||
if (selectedMacros == undefined) selectedMacros = [];
|
||||
@@ -187,28 +188,12 @@ export class macroConfigForm extends FormApplication {
|
||||
height += 50;
|
||||
}
|
||||
|
||||
//Check what SD model the user is using, and set the number of rows and columns to correspond
|
||||
let streamDeckModel = game.settings.get(MODULE.moduleName,'streamDeckModel');
|
||||
let iMax,jMax;
|
||||
if (streamDeckModel == 0){
|
||||
jMax = 6;
|
||||
iMax = 3;
|
||||
}
|
||||
else if (streamDeckModel == 1){
|
||||
jMax = 6;
|
||||
iMax = 5;
|
||||
}
|
||||
else {
|
||||
jMax = 8;
|
||||
iMax = 8;
|
||||
}
|
||||
|
||||
let iteration = 0;
|
||||
let iteration = this.page*32;
|
||||
let macroData = [];
|
||||
for (let j=0; j<jMax; j++){
|
||||
for (let j=0; j<4; j++){
|
||||
let macroThis = [];
|
||||
|
||||
for (let i=0; i<iMax; i++){
|
||||
for (let i=0; i<8; i++){
|
||||
let colorData = color[iteration];
|
||||
if (colorData != undefined){
|
||||
let colorCorrect = true;
|
||||
@@ -233,13 +218,15 @@ export class macroConfigForm extends FormApplication {
|
||||
}
|
||||
macroData.push({dataThis: macroThis});
|
||||
}
|
||||
|
||||
return {
|
||||
height: height,
|
||||
macros: game.macros,
|
||||
selectedMacros: selectedMacros,
|
||||
macroData: macroData,
|
||||
furnace: furnaceEnabled
|
||||
furnace: furnaceEnabled,
|
||||
macroRange: `${this.page*32 + 1} - ${this.page*32 + 32}`,
|
||||
prevDisabled: this.page == 0 ? 'disabled' : '',
|
||||
totalMacros: Math.max(Math.ceil(selectedMacros.length/32)*32, this.page*32 + 32)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,27 +241,118 @@ export class macroConfigForm extends FormApplication {
|
||||
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
const navNext = html.find("button[id='navNext']");
|
||||
const navPrev = html.find("button[id='navPrev']");
|
||||
const clearAll = html.find("button[id='clearAll']");
|
||||
const clearPage = html.find("button[id='clearPage']");
|
||||
const importBtn = html.find("button[id='import']");
|
||||
const exportBtn = html.find("button[id='export']");
|
||||
const macro = html.find("select[name='macros']");
|
||||
const args = html.find("input[name='args']");
|
||||
const color = html.find("input[name='colorPicker']");
|
||||
|
||||
importBtn.on('click', async(event) => {
|
||||
let importDialog = new importConfigForm();
|
||||
importDialog.setData('macroboard',this)
|
||||
importDialog.render(true);
|
||||
});
|
||||
|
||||
exportBtn.on('click', async(event) => {
|
||||
const settings = game.settings.get(moduleName,'macroSettings');
|
||||
let exportDialog = new exportConfigForm();
|
||||
exportDialog.setData(settings,'macroboard')
|
||||
exportDialog.render(true);
|
||||
});
|
||||
|
||||
navNext.on('click',async (event) => {
|
||||
this.page++;
|
||||
this.render(true);
|
||||
});
|
||||
|
||||
navPrev.on('click',async (event) => {
|
||||
const settings = game.settings.get(moduleName,'macroSettings');
|
||||
this.page--;
|
||||
if (this.page < 0) this.page = 0;
|
||||
else {
|
||||
const totalMacros = Math.ceil(settings.macros.length/32)*32;
|
||||
if ((this.page + 2)*32 == totalMacros) {
|
||||
let pageEmpty = this.getPageEmpty(totalMacros-32);
|
||||
if (pageEmpty) {
|
||||
await this.clearPage(totalMacros-32,true)
|
||||
}
|
||||
}
|
||||
}
|
||||
this.render(true);
|
||||
});
|
||||
|
||||
clearAll.on('click',async (event) => {
|
||||
const parent = this;
|
||||
|
||||
let d = new Dialog({
|
||||
title: game.i18n.localize("MaterialDeck.ClearAll"),
|
||||
content: game.i18n.localize("MaterialDeck.ClearAll_Content"),
|
||||
buttons: {
|
||||
continue: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: game.i18n.localize("MaterialDeck.Continue"),
|
||||
callback: async () => {
|
||||
this.page = 0;
|
||||
await parent.clearAllSettings();
|
||||
parent.render(true);
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
label: game.i18n.localize("MaterialDeck.Cancel")
|
||||
}
|
||||
},
|
||||
default: "cancel"
|
||||
});
|
||||
d.render(true);
|
||||
})
|
||||
|
||||
clearPage.on('click',(event) => {
|
||||
const parent = this;
|
||||
|
||||
let d = new Dialog({
|
||||
title: game.i18n.localize("MaterialDeck.ClearPage"),
|
||||
content: game.i18n.localize("MaterialDeck.ClearPage_Content"),
|
||||
buttons: {
|
||||
continue: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: game.i18n.localize("MaterialDeck.Continue"),
|
||||
callback: async () => {
|
||||
await parent.clearPage(parent.page*32)
|
||||
parent.render(true);
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
label: game.i18n.localize("MaterialDeck.Cancel")
|
||||
}
|
||||
},
|
||||
default: "cancel"
|
||||
});
|
||||
d.render(true);
|
||||
})
|
||||
|
||||
macro.on("change", event => {
|
||||
let id = event.target.id.replace('macros','');
|
||||
let settings = game.settings.get(MODULE.moduleName,'macroSettings');
|
||||
let settings = game.settings.get(moduleName,'macroSettings');
|
||||
settings.macros[id-1]=event.target.value;
|
||||
this.updateSettings(settings);
|
||||
});
|
||||
|
||||
args.on("change", event => {
|
||||
let id = event.target.id.replace('args','');
|
||||
let settings = game.settings.get(MODULE.moduleName,'macroSettings');
|
||||
let settings = game.settings.get(moduleName,'macroSettings');
|
||||
settings.args[id-1]=event.target.value;
|
||||
this.updateSettings(settings);
|
||||
});
|
||||
|
||||
color.on("change", event => {
|
||||
let id = event.target.id.replace('colorpicker','');
|
||||
let settings = game.settings.get(MODULE.moduleName,'macroSettings');
|
||||
let settings = game.settings.get(moduleName,'macroSettings');
|
||||
settings.color[id-1]=event.target.value;
|
||||
this.updateSettings(settings);
|
||||
});
|
||||
@@ -282,8 +360,8 @@ export class macroConfigForm extends FormApplication {
|
||||
|
||||
async updateSettings(settings){
|
||||
if (game.user.isGM) {
|
||||
await game.settings.set(MODULE.moduleName,'macroSettings',settings);
|
||||
if (MODULE.enableModule) macroControl.updateAll();
|
||||
await game.settings.set(moduleName,'macroSettings',settings);
|
||||
if (enableModule) macroControl.updateAll();
|
||||
}
|
||||
else {
|
||||
const payload = {
|
||||
@@ -293,6 +371,49 @@ export class macroConfigForm extends FormApplication {
|
||||
game.socket.emit(`module.MaterialDeck`, payload);
|
||||
}
|
||||
}
|
||||
|
||||
getPageEmpty(pageStart) {
|
||||
const settings = game.settings.get(moduleName,'macroSettings');
|
||||
let pageEmpty = true;
|
||||
for (let i=pageStart; i<pageStart+32; i++) {
|
||||
if (settings.macros[i] != undefined && settings.macros[i] != null && settings.macros[i] != "") {
|
||||
pageEmpty = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return pageEmpty;
|
||||
}
|
||||
|
||||
async clearPage(pageStart,remove=false) {
|
||||
const settings = game.settings.get(moduleName,'macroSettings');
|
||||
if (remove) {
|
||||
await settings.macros.splice(pageStart,32);
|
||||
await settings.color.splice(pageStart,32);
|
||||
if (settings.args != undefined) await settings.args.splice(pageStart,32);
|
||||
}
|
||||
else {
|
||||
for (let i=pageStart; i<pageStart+32; i++) {
|
||||
settings.macros[i] = null;
|
||||
settings.color[i] = "0";
|
||||
if (settings.args != undefined) settings.args[i] = null;
|
||||
}
|
||||
}
|
||||
await this.updateSettings(settings);
|
||||
}
|
||||
|
||||
async clearAllSettings() {
|
||||
let settings = {
|
||||
macros: [],
|
||||
color: [],
|
||||
args: []
|
||||
};
|
||||
for (let i=0; i<32; i++) {
|
||||
settings.macros[i] = null;
|
||||
settings.color[i] = "0";
|
||||
settings.args[i] = null;
|
||||
}
|
||||
await this.updateSettings(settings);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -301,9 +422,8 @@ export class soundboardConfigForm extends FormApplication {
|
||||
constructor(data, options) {
|
||||
super(data, options);
|
||||
this.playlists = [];
|
||||
this.iMax;
|
||||
this.jMax;
|
||||
this.settings = {};
|
||||
this.page = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -315,7 +435,7 @@ export class soundboardConfigForm extends FormApplication {
|
||||
title: "Material Deck: "+game.i18n.localize("MaterialDeck.Sett.SoundboardConfig"),
|
||||
template: "./modules/MaterialDeck/templates/soundboardConfig.html",
|
||||
classes: ["sheet"],
|
||||
height: 720
|
||||
height: "auto"
|
||||
});
|
||||
}
|
||||
|
||||
@@ -323,13 +443,13 @@ export class soundboardConfigForm extends FormApplication {
|
||||
* Provide data to the template
|
||||
*/
|
||||
getData() {
|
||||
if (MODULE.getPermission('SOUNDBOARD','CONFIGURE') == false ) {
|
||||
if (getPermission('SOUNDBOARD','CONFIGURE') == false ) {
|
||||
ui.notifications.warn(game.i18n.localize("MaterialDeck.Notifications.Soundboard.NoPermission"));
|
||||
return;
|
||||
}
|
||||
|
||||
//Get the settings
|
||||
this.settings = game.settings.get(MODULE.moduleName,'soundboardSettings');
|
||||
this.settings = game.settings.get(moduleName,'soundboardSettings');
|
||||
|
||||
//Check if all settings are defined
|
||||
if (this.settings.sounds == undefined) this.settings.sounds = [];
|
||||
@@ -353,29 +473,13 @@ export class soundboardConfigForm extends FormApplication {
|
||||
|
||||
this.playlists = playlists;
|
||||
|
||||
//Check what SD model the user is using, and set the number of rows and columns to correspond
|
||||
let streamDeckModel = game.settings.get(MODULE.moduleName,'streamDeckModel');
|
||||
|
||||
if (streamDeckModel == 0){
|
||||
this.jMax = 6;
|
||||
this.iMax = 3;
|
||||
}
|
||||
else if (streamDeckModel == 1){
|
||||
this.jMax = 6;
|
||||
this.iMax = 5;
|
||||
}
|
||||
else {
|
||||
this.jMax = 8;
|
||||
this.iMax = 8;
|
||||
}
|
||||
|
||||
let iteration = 0; //Sound number
|
||||
let iteration = this.page*16; //Sound number
|
||||
let soundData = []; //Stores all the data for each sound
|
||||
|
||||
//Fill soundData. soundData is an array the size of jMax (nr of rows), with each array element containing an array the size of iMax (nr of columns)
|
||||
for (let j=0; j<this.jMax; j++){
|
||||
//Fill soundData
|
||||
for (let j=0; j<2; j++){
|
||||
let soundsThis = []; //Stores row data
|
||||
for (let i=0; i<this.iMax; i++){
|
||||
for (let i=0; i<8; i++){
|
||||
//Each iteration gets the data for each sound
|
||||
|
||||
//If the volume is undefined for this sound, define it and set it to its default value
|
||||
@@ -453,7 +557,10 @@ export class soundboardConfigForm extends FormApplication {
|
||||
|
||||
return {
|
||||
soundData: soundData,
|
||||
playlists
|
||||
playlists,
|
||||
soundRange: `${this.page*16 + 1} - ${this.page*16 + 16}`,
|
||||
prevDisabled: this.page == 0 ? 'disabled' : '',
|
||||
totalSounds: this.settings.volume.length
|
||||
}
|
||||
}
|
||||
|
||||
@@ -468,6 +575,12 @@ export class soundboardConfigForm extends FormApplication {
|
||||
|
||||
async activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
const navNext = html.find("button[id='navNext']");
|
||||
const navPrev = html.find("button[id='navPrev']");
|
||||
const clearAll = html.find("button[id='clearAll']");
|
||||
const clearPage = html.find("button[id='clearPage']");
|
||||
const importBtn = html.find("button[id='import']");
|
||||
const exportBtn = html.find("button[id='export']");
|
||||
const nameField = html.find("input[name='namebox']");
|
||||
const playlistSelect = html.find("select[name='playlist']");
|
||||
const soundSelect = html.find("select[name='sounds']");
|
||||
@@ -478,6 +591,89 @@ export class soundboardConfigForm extends FormApplication {
|
||||
const playMode = html.find("select[name='mode']");
|
||||
const volume = html.find("input[name='volume']");
|
||||
|
||||
importBtn.on('click', async(event) => {
|
||||
let importDialog = new importConfigForm();
|
||||
importDialog.setData('soundboard',this)
|
||||
importDialog.render(true);
|
||||
});
|
||||
|
||||
exportBtn.on('click', async(event) => {
|
||||
const settings = game.settings.get(moduleName,'soundboardSettings');
|
||||
let exportDialog = new exportConfigForm();
|
||||
exportDialog.setData(settings,'soundboard')
|
||||
exportDialog.render(true);
|
||||
});
|
||||
|
||||
navNext.on('click',async (event) => {
|
||||
this.page++;
|
||||
this.render(true);
|
||||
});
|
||||
navPrev.on('click',async (event) => {
|
||||
this.page--;
|
||||
if (this.page < 0) this.page = 0;
|
||||
else {
|
||||
const totalSounds = this.settings.volume.length;
|
||||
if ((this.page + 2)*16 == totalSounds) {
|
||||
let pageEmpty = this.getPageEmpty(totalSounds-16);
|
||||
if (pageEmpty) {
|
||||
await this.clearPage(totalSounds-16,true)
|
||||
}
|
||||
}
|
||||
}
|
||||
this.render(true);
|
||||
});
|
||||
|
||||
clearAll.on('click',async (event) => {
|
||||
const parent = this;
|
||||
|
||||
let d = new Dialog({
|
||||
title: game.i18n.localize("MaterialDeck.ClearAll"),
|
||||
content: game.i18n.localize("MaterialDeck.ClearAll_Content"),
|
||||
buttons: {
|
||||
continue: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: game.i18n.localize("MaterialDeck.Continue"),
|
||||
callback: async () => {
|
||||
this.page = 0;
|
||||
await parent.clearAllSettings();
|
||||
parent.render(true);
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
label: game.i18n.localize("MaterialDeck.Cancel")
|
||||
}
|
||||
},
|
||||
default: "cancel"
|
||||
});
|
||||
d.render(true);
|
||||
})
|
||||
|
||||
clearPage.on('click',(event) => {
|
||||
const parent = this;
|
||||
|
||||
let d = new Dialog({
|
||||
title: game.i18n.localize("MaterialDeck.ClearPage"),
|
||||
content: game.i18n.localize("MaterialDeck.ClearPage_Content"),
|
||||
buttons: {
|
||||
continue: {
|
||||
icon: '<i class="fas fa-check"></i>',
|
||||
label: game.i18n.localize("MaterialDeck.Continue"),
|
||||
callback: async () => {
|
||||
await parent.clearPage(parent.page*16)
|
||||
parent.render(true);
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
icon: '<i class="fas fa-times"></i>',
|
||||
label: game.i18n.localize("MaterialDeck.Cancel")
|
||||
}
|
||||
},
|
||||
default: "cancel"
|
||||
});
|
||||
d.render(true);
|
||||
})
|
||||
|
||||
nameField.on("change",event => {
|
||||
let id = event.target.id.replace('name','')-1;
|
||||
this.settings.name[id]=event.target.value;
|
||||
@@ -595,8 +791,8 @@ export class soundboardConfigForm extends FormApplication {
|
||||
|
||||
async updateSettings(settings){
|
||||
if (game.user.isGM) {
|
||||
await game.settings.set(MODULE.moduleName,'soundboardSettings',settings);
|
||||
if (MODULE.enableModule) soundboard.updateAll();
|
||||
await game.settings.set(moduleName,'soundboardSettings',settings);
|
||||
if (enableModule) soundboard.updateAll();
|
||||
}
|
||||
else {
|
||||
const payload = {
|
||||
@@ -606,4 +802,375 @@ export class soundboardConfigForm extends FormApplication {
|
||||
game.socket.emit(`module.MaterialDeck`, payload);
|
||||
}
|
||||
}
|
||||
|
||||
getPageEmpty(pageStart) {
|
||||
let pageEmpty = true;
|
||||
for (let i=pageStart; i<pageStart+16; i++) {
|
||||
const name = this.settings.name[i];
|
||||
const playlist = this.settings.selectedPlaylists[i];
|
||||
const sound = this.settings.sounds[i];
|
||||
if ((name != "" && name != null) || playlist != undefined || sound != undefined) {
|
||||
pageEmpty = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return pageEmpty;
|
||||
}
|
||||
|
||||
async clearPage(pageStart,remove=false) {
|
||||
if (remove) {
|
||||
await this.settings.sounds.splice(pageStart,16);
|
||||
await this.settings.colorOn.splice(pageStart,16);
|
||||
await this.settings.colorOff.splice(pageStart,16);
|
||||
await this.settings.mode.splice(pageStart,16);
|
||||
await this.settings.img.splice(pageStart,16);
|
||||
await this.settings.volume.splice(pageStart,16);
|
||||
await this.settings.name.splice(pageStart,16);
|
||||
await this.settings.selectedPlaylists.splice(pageStart,16);
|
||||
await this.settings.src.splice(pageStart,16);
|
||||
await this.settings.sounds.splice(pageStart,16);
|
||||
}
|
||||
else {
|
||||
for (let i=pageStart; i<pageStart+16; i++) {
|
||||
this.settings.sounds[i] = null;
|
||||
this.settings.colorOn[i] = null;
|
||||
this.settings.colorOff[i] = null;
|
||||
this.settings.mode[i] = null;
|
||||
this.settings.img[i] = null;
|
||||
this.settings.volume[i] = null;
|
||||
this.settings.name[i] = null;
|
||||
this.settings.selectedPlaylists[i] = null;
|
||||
this.settings.src[i] = null;
|
||||
this.settings.sounds[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
await this.updateSettings(this.settings);
|
||||
}
|
||||
|
||||
async clearAllSettings() {
|
||||
let array = [];
|
||||
for (let i=0; i<16; i++) array[i] = "";
|
||||
let arrayVolume = [];
|
||||
for (let i=0; i<16; i++) arrayVolume[i] = "50";
|
||||
let arrayZero = [];
|
||||
for (let i=0; i<16; i++) arrayZero[i] = "0";
|
||||
|
||||
const settings = {
|
||||
playlist: "",
|
||||
sounds: array,
|
||||
colorOn: arrayZero,
|
||||
colorOff: arrayZero,
|
||||
mode: arrayZero,
|
||||
toggle: arrayZero,
|
||||
volume: arrayVolume
|
||||
};
|
||||
await this.updateSettings(settings);
|
||||
}
|
||||
}
|
||||
|
||||
export class exportConfigForm extends FormApplication {
|
||||
constructor(data, options) {
|
||||
super(data, options);
|
||||
this.data = {};
|
||||
this.name = "";
|
||||
this.source = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Default Options for this FormApplication
|
||||
*/
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
id: "MD_Export",
|
||||
title: "Material Deck: " + game.i18n.localize("MaterialDeck.ExportDialog.Title"),
|
||||
template: "./modules/MaterialDeck/templates/exportDialog.html",
|
||||
width: 500,
|
||||
height: "auto"
|
||||
});
|
||||
}
|
||||
|
||||
setData(data,source) {
|
||||
this.data = data;
|
||||
this.source = source;
|
||||
this.name = source;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide data to the template
|
||||
*/
|
||||
getData() {
|
||||
return {
|
||||
source: this.source,
|
||||
name: this.name,
|
||||
content: this.source == "soundboard" ? game.i18n.localize("MaterialDeck.ExportDialog.SoundboardContent") : game.i18n.localize("MaterialDeck.ExportDialog.MacroboardContent")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update on form submit
|
||||
* @param {*} event
|
||||
* @param {*} formData
|
||||
*/
|
||||
async _updateObject(event, formData) {
|
||||
this.download(this.data,formData.name)
|
||||
}
|
||||
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
}
|
||||
|
||||
download(data,name) {
|
||||
let dataStr = JSON.stringify(data);
|
||||
let dataUri = 'data:application/json;charset=utf-8,'+ encodeURIComponent(dataStr);
|
||||
let exportFileDefaultName = `${name}.json`;
|
||||
let linkElement = document.createElement('a');
|
||||
linkElement.setAttribute('href', dataUri);
|
||||
linkElement.setAttribute('download', exportFileDefaultName);
|
||||
linkElement.click();
|
||||
}
|
||||
}
|
||||
|
||||
export class importConfigForm extends FormApplication {
|
||||
constructor(data, options) {
|
||||
super(data, options);
|
||||
this.data = {};
|
||||
this.name = "";
|
||||
this.source = "";
|
||||
this.parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default Options for this FormApplication
|
||||
*/
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
id: "MD_Import",
|
||||
title: "Material Deck: " + game.i18n.localize("MaterialDeck.ImportDialog.Title"),
|
||||
template: "./modules/MaterialDeck/templates/importDialog.html",
|
||||
width: 500,
|
||||
height: "auto"
|
||||
});
|
||||
}
|
||||
|
||||
setData(source,parent) {
|
||||
this.source = source;
|
||||
this.name = source;
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide data to the template
|
||||
*/
|
||||
getData() {
|
||||
return {
|
||||
source: this.source,
|
||||
name: this.name,
|
||||
content: this.source == "soundboard" ? game.i18n.localize("MaterialDeck.ImportDialog.SoundboardContent") : game.i18n.localize("MaterialDeck.ImportDialog.MacroboardContent")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update on form submit
|
||||
* @param {*} event
|
||||
* @param {*} formData
|
||||
*/
|
||||
async _updateObject(event, formData) {
|
||||
await this.parent.updateSettings(this.data);
|
||||
this.parent.render(true);
|
||||
}
|
||||
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
const upload = html.find("input[id='uploadJson']");
|
||||
|
||||
upload.on('change',(event) => {
|
||||
event.preventDefault();
|
||||
this.readJsonFile(event.target.files[0]);
|
||||
})
|
||||
}
|
||||
|
||||
readJsonFile(jsonFile) {
|
||||
var reader = new FileReader();
|
||||
reader.addEventListener('load', (loadEvent) => {
|
||||
try {
|
||||
let json = JSON.parse(loadEvent.target.result);
|
||||
this.data = json;
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
reader.readAsText(jsonFile);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
export class downloadUtility extends FormApplication {
|
||||
constructor(data, options) {
|
||||
super(data, options);
|
||||
this.localSDversion = sdVersion;
|
||||
this.masterSDversion;
|
||||
this.localMSversion = msVersion;
|
||||
this.masterMSversion;
|
||||
this.releaseAssets = [];
|
||||
this.profiles = [];
|
||||
|
||||
let parent = this;
|
||||
setTimeout(function(){
|
||||
parent.checkForUpdate('SD');
|
||||
parent.checkForUpdate('MS');
|
||||
parent.getReleaseData();
|
||||
},100)
|
||||
}
|
||||
|
||||
/**
|
||||
* Default Options for this FormApplication
|
||||
*/
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
id: "MD_DownloadUtility",
|
||||
title: "Material Deck: " + game.i18n.localize("MaterialDeck.DownloadUtility.Title"),
|
||||
template: "./modules/MaterialDeck/templates/downloadUtility.html",
|
||||
width: 500,
|
||||
height: "auto"
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide data to the template
|
||||
*/
|
||||
getData() {
|
||||
let dlDisabled = true;
|
||||
|
||||
this.profiles = [];
|
||||
let iteration = 0;
|
||||
for (let asset of this.releaseAssets) {
|
||||
let split = asset.name.split('.');
|
||||
if (split[split.length-1] == 'streamDeckProfile') {
|
||||
this.profiles.push({id: iteration, label:split[0], url:asset.browser_download_url});
|
||||
iteration++;
|
||||
dlDisabled = false;
|
||||
}
|
||||
}
|
||||
if (this.localMSversion == undefined) this.localMSversion = 'unknown';
|
||||
|
||||
return {
|
||||
minimumSdVersion: game.modules.get("MaterialDeck").data.minimumSDversion.replace('v',''),
|
||||
localSdVersion: this.localSDversion,
|
||||
masterSdVersion: this.masterSDversion,
|
||||
sdDlDisable: this.masterSDversion == undefined,
|
||||
minimumMsVersion: game.modules.get("MaterialDeck").data.minimumMSversion.replace('v',''),
|
||||
localMsVersion: this.localMSversion,
|
||||
masterMsVersion: this.masterMSversion,
|
||||
msDlDisable: this.masterMSversion == undefined,
|
||||
profiles: this.profiles,
|
||||
profileDlDisable: dlDisabled
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update on form submit
|
||||
* @param {*} event
|
||||
* @param {*} formData
|
||||
*/
|
||||
async _updateObject(event, formData) {
|
||||
|
||||
}
|
||||
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
const downloadSd = html.find("button[id='downloadSd']");
|
||||
const downloadMs = html.find("button[id='downloadMs']");
|
||||
const downloadProfile = html.find("button[name='downloadProfile']")
|
||||
const refresh = html.find("button[id='refresh']");
|
||||
|
||||
downloadSd.on('click', () => {
|
||||
const version = document.getElementById('masterSdVersion').innerHTML;
|
||||
if (version == '' || version == undefined || version == 'Error') return;
|
||||
const url = `https://github.com/CDeenen/MaterialDeck_SD/releases/download/v${version}/com.cdeenen.materialdeck.streamDeckPlugin`;
|
||||
this.downloadURI(url,'com.cdeenen.materialdeck.streamDeckPlugin')
|
||||
})
|
||||
downloadMs.on('click', () => {
|
||||
const version = document.getElementById('masterMsVersion').innerHTML;
|
||||
const os = document.getElementById('os').value;
|
||||
if (version == '' || version == undefined || version == 'Error') return;
|
||||
let name = `MaterialServer-${os}.zip`;
|
||||
let url;
|
||||
if (os == 'source') url = `https://github.com/CDeenen/MaterialServer/archive/refs/tags/v${version}.zip`;
|
||||
else url = `https://github.com/CDeenen/MaterialServer/releases/download/v${version}/${name}`;
|
||||
this.downloadURI(url,name)
|
||||
})
|
||||
downloadProfile.on('click',(event) => {
|
||||
let id = event.currentTarget.id.replace('dlProfile-','');
|
||||
this.downloadURI(this.profiles[id].url,`${this.profiles[id].label}.streamDeckProfile`);
|
||||
})
|
||||
refresh.on('click', () => {
|
||||
document.getElementById('masterSdVersion').value = 'Getting data';
|
||||
this.checkForUpdate('SD');
|
||||
document.getElementById('masterMsVersion').value = 'Getting data';
|
||||
this.checkForUpdate('MS');
|
||||
this.getReleaseData();
|
||||
})
|
||||
}
|
||||
|
||||
downloadURI(uri, name) {
|
||||
var link = document.createElement("a");
|
||||
link.download = name;
|
||||
link.href = uri;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}
|
||||
|
||||
getReleaseData() {
|
||||
let parent = this;
|
||||
const url = 'https://api.github.com/repos/CDeenen/MaterialDeck_SD/releases/latest';
|
||||
var request = new XMLHttpRequest();
|
||||
request.open('GET', url, true);
|
||||
request.send(null);
|
||||
request.onreadystatechange = function () {
|
||||
if (request.readyState === 4 && request.status === 200) {
|
||||
var type = request.getResponseHeader('Content-Type');
|
||||
const data = JSON.parse(request.responseText);
|
||||
parent.releaseAssets = data.assets;
|
||||
parent.render(true);
|
||||
if (type.indexOf("text") !== 1) {
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
request.onerror = function () {
|
||||
}
|
||||
}
|
||||
|
||||
checkForUpdate(reqType) {
|
||||
let parent = this;
|
||||
let url;
|
||||
if (reqType == 'SD') url = 'https://raw.githubusercontent.com/CDeenen/MaterialDeck_SD/master/Plugin/com.cdeenen.materialdeck.sdPlugin/manifest.json';
|
||||
else if (reqType == 'MS') url = 'https://raw.githubusercontent.com/CDeenen/MaterialServer/master/src/Windows/package.json';
|
||||
const elementId = reqType == 'SD' ? 'masterSdVersion' : 'masterMsVersion';
|
||||
|
||||
var request = new XMLHttpRequest();
|
||||
request.open('GET', url, true);
|
||||
request.send(null);
|
||||
request.onreadystatechange = function () {
|
||||
if (request.readyState === 4 && request.status === 200) {
|
||||
var type = request.getResponseHeader('Content-Type');
|
||||
if (type.indexOf("text") !== 1) {
|
||||
if (reqType == 'SD') parent.masterSDversion = JSON.parse(request.responseText).Version;
|
||||
else if (reqType == 'MS') parent.masterMSversion = JSON.parse(request.responseText).version;
|
||||
parent.render(true);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
request.onerror = function () {
|
||||
document.getElementById(elementId).innerHTML = 'Error';
|
||||
}
|
||||
}
|
||||
}
|
||||
181
src/move.js
@@ -1,181 +0,0 @@
|
||||
import * as MODULE from "../MaterialDeck.js";
|
||||
import {streamDeck} from "../MaterialDeck.js";
|
||||
import {compatibleCore} from "./misc.js";
|
||||
|
||||
export class Move{
|
||||
constructor(){
|
||||
this.active = false;
|
||||
}
|
||||
|
||||
update(settings,context,device){
|
||||
const background = settings.background ? settings.background : '#000000';
|
||||
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,device);
|
||||
return;
|
||||
}
|
||||
|
||||
let url = '';
|
||||
if (mode == 'canvas' || (mode == 'selectedToken' && type == 'move')){
|
||||
const dir = settings.dir ? settings.dir : 'center';
|
||||
if (dir == 'center') //center
|
||||
url = "modules/MaterialDeck/img/move/center.png";
|
||||
else if (dir == 'up') //up
|
||||
url = "modules/MaterialDeck/img/move/up.png";
|
||||
else if (dir == 'down') //down
|
||||
url = "modules/MaterialDeck/img/move/down.png";
|
||||
else if (dir == 'right') //right
|
||||
url = "modules/MaterialDeck/img/move/right.png";
|
||||
else if (dir == 'left') //left
|
||||
url = "modules/MaterialDeck/img/move/left.png";
|
||||
else if (dir == 'upRight')
|
||||
url = "modules/MaterialDeck/img/move/upright.png";
|
||||
else if (dir == 'upLeft')
|
||||
url = "modules/MaterialDeck/img/move/upleft.png";
|
||||
else if (dir == 'downRight')
|
||||
url = "modules/MaterialDeck/img/move/downright.png";
|
||||
else if (dir == 'downLeft')
|
||||
url = "modules/MaterialDeck/img/move/downleft.png";
|
||||
else if (dir == 'zoomIn')
|
||||
url = "modules/MaterialDeck/img/move/zoomin.png";
|
||||
else if (dir == 'zoomOut')
|
||||
url = "modules/MaterialDeck/img/move/zoomout.png";
|
||||
}
|
||||
else if (mode == 'selectedToken' && type == 'rotate'){
|
||||
const value = isNaN(parseInt(settings.rotValue)) ? 0 : parseInt(settings.rotValue);
|
||||
if (value >= 0)
|
||||
url = "modules/MaterialDeck/img/move/rotatecw.png";
|
||||
else
|
||||
url = "modules/MaterialDeck/img/move/rotateccw.png";
|
||||
}
|
||||
streamDeck.setIcon(context,device,url,{background:background,overlay:true});
|
||||
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,device);
|
||||
return;
|
||||
}
|
||||
|
||||
const dir = settings.dir ? settings.dir : 'center';
|
||||
const mode = settings.mode ? settings.mode : 'canvas';
|
||||
const type = settings.type ? settings.type : 'move';
|
||||
|
||||
let token;
|
||||
if (mode == 'selectedToken') {
|
||||
const selection = settings.selection ? settings.selection : 'selected';
|
||||
const tokenIdentifier = settings.tokenName ? settings.tokenName : '';
|
||||
|
||||
if (selection == 'selected') token = canvas.tokens.controlled[0];
|
||||
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'){
|
||||
if (dir == 'zoomIn') {//zoom in
|
||||
let viewPosition = canvas.scene._viewPosition;
|
||||
viewPosition.scale = viewPosition.scale*1.05;
|
||||
viewPosition.duration = 100;
|
||||
canvas.animatePan(viewPosition);
|
||||
}
|
||||
else if (dir == 'zoomOut') {//zoom out
|
||||
let viewPosition = canvas.scene._viewPosition;
|
||||
viewPosition.scale = viewPosition.scale*0.95;
|
||||
viewPosition.duration = 100;
|
||||
canvas.animatePan(viewPosition);
|
||||
}
|
||||
else {
|
||||
if (settings.mode == 'selectedToken')
|
||||
this.moveToken(token,dir);
|
||||
else
|
||||
this.moveCanvas(dir);
|
||||
}
|
||||
}
|
||||
else if (type == 'rotate' && mode == 'selectedToken'){
|
||||
const rotType = settings.rot ? settings.rot : 'to';
|
||||
const value = isNaN(parseInt(settings.rotValue)) ? 0 : parseInt(settings.rotValue);
|
||||
|
||||
let rotationVal;
|
||||
if (rotType == 'by') rotationVal = token.data.rotation + value;
|
||||
else if (rotType == 'to') rotationVal = value;
|
||||
|
||||
if (compatibleCore("0.8.1")) token.document.update({rotation: rotationVal});
|
||||
else token.update({rotation: rotationVal});
|
||||
//token.rotate(rotationVal,false)
|
||||
}
|
||||
}
|
||||
|
||||
async moveToken(token,dir){
|
||||
const gridSize = canvas.scene.data.grid;
|
||||
let x = token.x;
|
||||
let y = token.y;
|
||||
|
||||
if (dir == 'up') y -= gridSize;
|
||||
else if (dir == 'down') y += gridSize;
|
||||
else if (dir == 'right') x += gridSize;
|
||||
else if (dir == 'left') x -= gridSize;
|
||||
else if (dir == 'upRight') {
|
||||
x += gridSize;
|
||||
y -= gridSize;
|
||||
}
|
||||
else if (dir == 'upLeft') {
|
||||
x -= gridSize;
|
||||
y -= gridSize;
|
||||
}
|
||||
else if (dir == 'downRight') {
|
||||
x += gridSize;
|
||||
y += gridSize;
|
||||
}
|
||||
else if (dir == 'downLeft') {
|
||||
x -= gridSize;
|
||||
y += gridSize;
|
||||
}
|
||||
else if (dir == 'center') {
|
||||
let location = token.getCenter(x,y);
|
||||
canvas.animatePan(location);
|
||||
}
|
||||
if (game.user.isGM == false && (token.can(game.user,"control") == false || token.checkCollision(token.getCenter(x, y)))) return;
|
||||
if (compatibleCore("0.8.1")) token.document.update({x:x,y:y});
|
||||
else token.update({x:x,y:y});
|
||||
};
|
||||
|
||||
moveCanvas(dir){
|
||||
let viewPosition = canvas.scene._viewPosition;
|
||||
const gridSize = canvas.scene.data.grid;
|
||||
viewPosition.duration = 100;
|
||||
|
||||
if (dir == 'up') viewPosition.y -= gridSize;
|
||||
else if (dir == 'down') viewPosition.y += gridSize;
|
||||
else if (dir == 'right') viewPosition.x += gridSize;
|
||||
else if (dir == 'left') viewPosition.x -= gridSize;
|
||||
else if (dir == 'upRight') {
|
||||
viewPosition.x += gridSize;
|
||||
viewPosition.y -= gridSize;
|
||||
}
|
||||
else if (dir == 'upLeft') {
|
||||
viewPosition.x -= gridSize;
|
||||
viewPosition.y -= gridSize;
|
||||
}
|
||||
else if (dir == 'downRight') {
|
||||
viewPosition.x += gridSize;
|
||||
viewPosition.y += gridSize;
|
||||
}
|
||||
else if (dir == 'downLeft') {
|
||||
viewPosition.x -= gridSize;
|
||||
viewPosition.y += gridSize;
|
||||
}
|
||||
else if (dir == 'center') {
|
||||
viewPosition.x = (canvas.dimensions.sceneWidth+window.innerWidth)/2;
|
||||
viewPosition.y = (canvas.dimensions.sceneHeight+window.innerHeight)/2;
|
||||
}
|
||||
canvas.animatePan(viewPosition);
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,8 @@ export class OtherControls{
|
||||
|
||||
if (mode == 'pause') //pause
|
||||
this.updatePause(settings,context,device,options);
|
||||
else if (mode == 'move') //move canvas
|
||||
this.updateMove(settings,context,device,options);
|
||||
else if (mode == 'controlButtons') //control buttons
|
||||
this.updateControl(settings,context,device,options);
|
||||
else if (mode == 'darkness') //darkness
|
||||
@@ -59,6 +61,8 @@ export class OtherControls{
|
||||
|
||||
if (mode == 'pause') //pause
|
||||
this.keyPressPause(settings);
|
||||
else if (mode == 'move') //move canvas
|
||||
this.keyPressMove(settings);
|
||||
else if (mode == 'controlButtons') //control buttons
|
||||
this.keyPressControl(settings);
|
||||
else if (mode == 'darkness') //darkness controll
|
||||
@@ -126,6 +130,87 @@ export class OtherControls{
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
updateMove(settings,context,device,options={}){
|
||||
let url = '';
|
||||
const dir = settings.dir ? settings.dir : 'center';
|
||||
const background = settings.background ? settings.background : '#000000';
|
||||
if (dir == 'center') //center
|
||||
url = "modules/MaterialDeck/img/move/center.png";
|
||||
else if (dir == 'up') //up
|
||||
url = "modules/MaterialDeck/img/move/up.png";
|
||||
else if (dir == 'down') //down
|
||||
url = "modules/MaterialDeck/img/move/down.png";
|
||||
else if (dir == 'right') //right
|
||||
url = "modules/MaterialDeck/img/move/right.png";
|
||||
else if (dir == 'left') //left
|
||||
url = "modules/MaterialDeck/img/move/left.png";
|
||||
else if (dir == 'upRight')
|
||||
url = "modules/MaterialDeck/img/move/upright.png";
|
||||
else if (dir == 'upLeft')
|
||||
url = "modules/MaterialDeck/img/move/upleft.png";
|
||||
else if (dir == 'downRight')
|
||||
url = "modules/MaterialDeck/img/move/downright.png";
|
||||
else if (dir == 'downLeft')
|
||||
url = "modules/MaterialDeck/img/move/downleft.png";
|
||||
else if (dir == 'zoomIn')
|
||||
url = "modules/MaterialDeck/img/move/zoomin.png";
|
||||
else if (dir == 'zoomOut')
|
||||
url = "modules/MaterialDeck/img/move/zoomout.png";
|
||||
|
||||
streamDeck.setIcon(context,device,url,{background:background,overlay:true});
|
||||
streamDeck.setTitle('',context);
|
||||
}
|
||||
|
||||
keyPressMove(settings){
|
||||
if (canvas.scene == null) return;
|
||||
const dir = settings.dir ? settings.dir : 'center';
|
||||
if (dir == 'zoomIn') {//zoom in
|
||||
let viewPosition = canvas.scene._viewPosition;
|
||||
viewPosition.scale = viewPosition.scale*1.05;
|
||||
viewPosition.duration = 100;
|
||||
canvas.animatePan(viewPosition);
|
||||
}
|
||||
else if (dir == 'zoomOut') {//zoom out
|
||||
let viewPosition = canvas.scene._viewPosition;
|
||||
viewPosition.scale = viewPosition.scale*0.95;
|
||||
viewPosition.duration = 100;
|
||||
canvas.animatePan(viewPosition);
|
||||
}
|
||||
else {
|
||||
let viewPosition = canvas.scene._viewPosition;
|
||||
const gridSize = canvas.scene.data.grid;
|
||||
viewPosition.duration = 100;
|
||||
|
||||
if (dir == 'up') viewPosition.y -= gridSize;
|
||||
else if (dir == 'down') viewPosition.y += gridSize;
|
||||
else if (dir == 'right') viewPosition.x += gridSize;
|
||||
else if (dir == 'left') viewPosition.x -= gridSize;
|
||||
else if (dir == 'upRight') {
|
||||
viewPosition.x += gridSize;
|
||||
viewPosition.y -= gridSize;
|
||||
}
|
||||
else if (dir == 'upLeft') {
|
||||
viewPosition.x -= gridSize;
|
||||
viewPosition.y -= gridSize;
|
||||
}
|
||||
else if (dir == 'downRight') {
|
||||
viewPosition.x += gridSize;
|
||||
viewPosition.y += gridSize;
|
||||
}
|
||||
else if (dir == 'downLeft') {
|
||||
viewPosition.x -= gridSize;
|
||||
viewPosition.y += gridSize;
|
||||
}
|
||||
else if (dir == 'center') {
|
||||
viewPosition.x = (canvas.dimensions.sceneWidth+window.innerWidth)/2;
|
||||
viewPosition.y = (canvas.dimensions.sceneHeight+window.innerHeight)/2;
|
||||
}
|
||||
canvas.animatePan(viewPosition);
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
updateControl(settings,context,device,options={}){
|
||||
@@ -603,18 +688,17 @@ export class OtherControls{
|
||||
streamDeck.noPermission(context,device);
|
||||
return;
|
||||
}
|
||||
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);
|
||||
const compendium = game.packs.find(p=>p.metadata.label == name);
|
||||
if (compendium == undefined) return;
|
||||
if (compendium.private && MODULE.getPermission('OTHER','COMPENDIUM_ALL') == false) {
|
||||
streamDeck.noPermission(context,device);
|
||||
return;
|
||||
}
|
||||
const rendered = compatibleCore("0.8.5") ? compendium.apps[0].rendered : compendium.rendered;
|
||||
const background = settings.background ? settings.background : '#000000';
|
||||
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
|
||||
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
|
||||
const ringColor = compendium.rendered ? ringOnColor : ringOffColor;
|
||||
const ringColor = rendered ? ringOnColor : ringOffColor;
|
||||
const txt = settings.displayCompendiumName ? name : '';
|
||||
|
||||
streamDeck.setTitle(txt,context);
|
||||
@@ -626,12 +710,11 @@ export class OtherControls{
|
||||
if (name == undefined) return;
|
||||
if (MODULE.getPermission('OTHER','COMPENDIUM') == false ) return;
|
||||
|
||||
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);
|
||||
const compendium = game.packs.find(p=>p.metadata.label == name);
|
||||
const rendered = compatibleCore("0.8.5") ? compendium.apps[0].rendered : compendium.rendered;
|
||||
if (compendium == undefined) return;
|
||||
if (compendium.private && MODULE.getPermission('OTHER','COMPENDIUM_ALL') == false) return;
|
||||
else if (compendium.rendered) compendium.close();
|
||||
else if (rendered) compatibleCore("0.8.5") ? compendium.apps[0].close() : compendium.close();
|
||||
else compendium.render(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ export class PlaylistControl{
|
||||
playlistNr += this.playlistOffset;
|
||||
|
||||
let playlist = this.getPlaylist(playlistNr);
|
||||
|
||||
if (playlist != undefined){
|
||||
if (playlist.playing)
|
||||
ringColor = ringOnColor;
|
||||
@@ -115,10 +116,7 @@ export class PlaylistControl{
|
||||
|
||||
let playlist = this.getPlaylist(playlistNr);
|
||||
if (playlist != undefined){
|
||||
let track;
|
||||
if (compatibleCore("0.8.1")) track = playlist.sounds.contents[trackNr];
|
||||
else track = playlist.data.sounds[trackNr];
|
||||
|
||||
const track = compatibleCore("0.8.1") ? playlist.sounds.contents[trackNr] : playlist.sounds[trackNr];
|
||||
if (track != undefined){
|
||||
if (track.playing)
|
||||
ringColor = ringOnColor;
|
||||
@@ -200,9 +198,7 @@ export class PlaylistControl{
|
||||
if (playlistMode == 'playlist')
|
||||
this.playPlaylist(playlist,playlistNr);
|
||||
else {
|
||||
let track;
|
||||
if (compatibleCore("0.8.1")) track = playlist.sounds.contents[trackNr];
|
||||
else track = playlist.data.sounds[trackNr];
|
||||
const track = compatibleCore("0.8.1") ? playlist.sounds.contents[trackNr] : playlist.sounds[trackNr];
|
||||
if (track != undefined){
|
||||
this.playTrack(track,playlist,playlistNr);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as MODULE from "../MaterialDeck.js";
|
||||
import { playlistConfigForm, macroConfigForm, soundboardConfigForm } from "./misc.js";
|
||||
import { playlistConfigForm, macroConfigForm, soundboardConfigForm, downloadUtility } from "./misc.js";
|
||||
|
||||
let userPermissions = {};
|
||||
const defaultEnable = [true,true,true,true];
|
||||
@@ -22,10 +22,6 @@ const defaultUserPermissions = {
|
||||
MACROBOARD: [false,false,true,true],
|
||||
MACROBOARD_CONFIGURE: [false,false,true,true]
|
||||
},
|
||||
MOVE: {
|
||||
TOKEN: [true,true,true,true],
|
||||
CANVAS: [true,true,true,true]
|
||||
},
|
||||
OTHER: {
|
||||
PAUSE: [false,false,true,true],
|
||||
CONTROL: [true,true,true,true],
|
||||
@@ -83,16 +79,6 @@ export const registerSettings = async function() {
|
||||
onChange: x => window.location.reload()
|
||||
});
|
||||
|
||||
game.settings.register(MODULE.moduleName,'streamDeckModel', {
|
||||
name: "MaterialDeck.Sett.Model",
|
||||
hint: "MaterialDeck.Sett.Model_Hint",
|
||||
scope: "client",
|
||||
config: true,
|
||||
type:Number,
|
||||
default:1,
|
||||
choices:["MaterialDeck.Sett.Model_Mini","MaterialDeck.Sett.Model_Normal","MaterialDeck.Sett.Model_XL"],
|
||||
});
|
||||
|
||||
/**
|
||||
* Sets the ip address of the server
|
||||
*/
|
||||
@@ -128,6 +114,17 @@ export const registerSettings = async function() {
|
||||
|
||||
});
|
||||
|
||||
game.settings.register(MODULE.moduleName, 'nrOfConnMessages', {
|
||||
name: "MaterialDeck.Sett.NrOfConnMessages",
|
||||
hint: "MaterialDeck.Sett.NrOfConnMessagesHint",
|
||||
default: 5,
|
||||
type: Number,
|
||||
scope: 'client',
|
||||
range: { min: 0, max: 100, step: 1 },
|
||||
config: true
|
||||
|
||||
});
|
||||
|
||||
//Create the Help button
|
||||
game.settings.registerMenu(MODULE.moduleName, 'helpMenu',{
|
||||
name: "MaterialDeck.Sett.Help",
|
||||
@@ -150,6 +147,13 @@ export const registerSettings = async function() {
|
||||
config: false
|
||||
});
|
||||
|
||||
game.settings.registerMenu(MODULE.moduleName, 'downloadUtility',{
|
||||
name: "MaterialDeck.DownloadUtility.Title",
|
||||
label: "MaterialDeck.DownloadUtility.Title",
|
||||
type: downloadUtility,
|
||||
restricted: false
|
||||
});
|
||||
|
||||
/**
|
||||
* Playlist soundboard
|
||||
*/
|
||||
@@ -224,10 +228,10 @@ export const registerSettings = async function() {
|
||||
}
|
||||
if (game.user.isGM)
|
||||
game.settings.set(MODULE.moduleName,'userPermission',permissionSettings);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
export class helpMenu extends FormApplication {
|
||||
constructor(data, options) {
|
||||
super(data, options);
|
||||
@@ -302,11 +306,7 @@ export class helpMenu extends FormApplication {
|
||||
}
|
||||
|
||||
const actions = Object.entries(duplicate(settings.permissions)).reduce((arr, e) => {
|
||||
//const perm = e[1];
|
||||
|
||||
const perms = Object.entries(duplicate(e[1])).reduce((arr, p) => {
|
||||
//const perm = e[1];
|
||||
|
||||
let perm = {};
|
||||
perm.roles = [p[1][0],p[1][1],p[1][2],p[1][3]]
|
||||
perm.id = p[0];
|
||||
@@ -324,8 +324,10 @@ export class helpMenu extends FormApplication {
|
||||
arr.push(cat);
|
||||
return arr;
|
||||
}, []);
|
||||
|
||||
const current = await game.settings.get("core", "permissions");
|
||||
for (let i=0; i<actions.length; i++) {
|
||||
if (actions[i].id == 'MOVE')
|
||||
actions.splice(i,1);
|
||||
}
|
||||
return {
|
||||
roles: Object.keys(CONST.USER_ROLES).reduce((obj, r) => {
|
||||
if ( r === "NONE" ) return obj;
|
||||
@@ -348,7 +350,7 @@ export class helpMenu extends FormApplication {
|
||||
settings.enable = permissions.ENABLE;
|
||||
delete permissions.ENABLE;
|
||||
settings.permissions = permissions;
|
||||
game.settings.set(MODULE.moduleName,'userPermission',settings);
|
||||
// game.settings.set(MODULE.moduleName,'userPermission',settings);
|
||||
}
|
||||
|
||||
async activateListeners(html) {
|
||||
|
||||
@@ -7,8 +7,6 @@ export class SoundboardControl{
|
||||
this.active = false;
|
||||
this.offset = 0;
|
||||
this.activeSounds = [];
|
||||
for (let i=0; i<64; i++)
|
||||
this.activeSounds[i] = false;
|
||||
}
|
||||
|
||||
async updateAll(){
|
||||
@@ -43,7 +41,7 @@ export class SoundboardControl{
|
||||
soundNr += this.offset;
|
||||
|
||||
let soundboardSettings = game.settings.get(MODULE.moduleName, 'soundboardSettings');
|
||||
ringColor = (this.activeSounds[soundNr]==false) ? soundboardSettings.colorOff[soundNr] : soundboardSettings.colorOn[soundNr];
|
||||
ringColor = (this.activeSounds[soundNr]==undefined) ? soundboardSettings.colorOff[soundNr] : soundboardSettings.colorOn[soundNr];
|
||||
|
||||
if (settings.displayName && soundboardSettings.name != undefined) txt = soundboardSettings.name[soundNr];
|
||||
if (settings.displayIcon && soundboardSettings.img != undefined) src = soundboardSettings.img[soundNr];
|
||||
@@ -89,7 +87,7 @@ export class SoundboardControl{
|
||||
|
||||
const playMode = game.settings.get(MODULE.moduleName,'soundboardSettings').mode[soundNr];
|
||||
const repeat = (playMode > 0) ? true : false;
|
||||
const play = (this.activeSounds[soundNr] == false) ? true : false;
|
||||
const play = (this.activeSounds[soundNr] == undefined) ? true : false;
|
||||
|
||||
this.prePlaySound(soundNr,repeat,play);
|
||||
}
|
||||
@@ -100,8 +98,8 @@ export class SoundboardControl{
|
||||
this.updateAll();
|
||||
}
|
||||
else if (mode == 'stopAll') { //Stop All Sounds
|
||||
for (let i=0; i<64; i++) {
|
||||
if (this.activeSounds[i] != false){
|
||||
for (let i=0; i<this.activeSounds.length; i++) {
|
||||
if (this.activeSounds[i] != undefined){
|
||||
this.prePlaySound(i,false,false);
|
||||
}
|
||||
}
|
||||
@@ -176,7 +174,7 @@ export class SoundboardControl{
|
||||
if(newSound.loaded == false) await newSound.load({autoplay:true});
|
||||
newSound.on('end', ()=>{
|
||||
if (repeat == false) {
|
||||
this.activeSounds[soundNr] = false;
|
||||
this.activeSounds[soundNr] = undefined;
|
||||
this.updateAll();
|
||||
}
|
||||
});
|
||||
@@ -186,12 +184,12 @@ export class SoundboardControl{
|
||||
else {
|
||||
let howl = new Howl({src, volume, loop: repeat, onend: (id)=>{
|
||||
if (repeat == false){
|
||||
this.activeSounds[soundNr] = false;
|
||||
this.activeSounds[soundNr] = undefined;
|
||||
this.updateAll();
|
||||
}
|
||||
},
|
||||
onstop: ()=>{
|
||||
this.activeSounds[soundNr] = false;
|
||||
this.activeSounds[soundNr] = undefined;
|
||||
this.updateAll();
|
||||
}});
|
||||
howl.play();
|
||||
@@ -199,28 +197,9 @@ export class SoundboardControl{
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.activeSounds[soundNr].stop();
|
||||
this.activeSounds[soundNr] = false;
|
||||
if (this.activeSounds[soundNr] != undefined) this.activeSounds[soundNr].stop();
|
||||
this.activeSounds[soundNr] = undefined;
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -389,7 +389,7 @@ export class StreamDeck{
|
||||
else {
|
||||
|
||||
}
|
||||
if (uses != undefined && uses.heart != false && (uses.available > 0 || uses.maximum != undefined)) {
|
||||
if (uses != undefined && uses.heart != undefined && (uses.available > 0 || uses.maximum != undefined)) {
|
||||
const percentage = 102*uses.available/uses.maximum;
|
||||
ctx.fillStyle = uses.heart;
|
||||
ctx.fillRect(0, 121,144,-percentage);
|
||||
@@ -411,7 +411,7 @@ export class StreamDeck{
|
||||
ctx.fillText(content[1], horOffset, vertOffset);
|
||||
}
|
||||
|
||||
if (format != 'jpg' && format != 'jpeg' && format != 'png' && format != 'webm' && format != 'webp' && format != 'gif' && format != 'svg') url = "modules/MaterialDeck/img/transparant.png";
|
||||
if (format != 'jpg' && format != 'jpeg' && format != 'png' && format != 'PNG' && format != 'webm' && format != 'webp' && format != 'gif' && format != 'svg') url = "modules/MaterialDeck/img/transparant.png";
|
||||
//if (url == "") url = "modules/MaterialDeck/img/transparant.png"
|
||||
let resImageURL = url;
|
||||
let img = new Image();
|
||||
@@ -451,10 +451,13 @@ 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 != undefined && uses.heart == undefined) {
|
||||
let txt = '';
|
||||
if (uses.available != undefined) {
|
||||
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));
|
||||
|
||||
133
src/systems/demonlord.js
Normal file
@@ -0,0 +1,133 @@
|
||||
import {compatibleCore} from "../misc.js";
|
||||
|
||||
export class demonlord{
|
||||
constructor(){
|
||||
|
||||
}
|
||||
|
||||
getHP(token) {
|
||||
const hp = token.actor.data.data.characteristics.health;
|
||||
return {
|
||||
value: hp.value,
|
||||
max: hp.max
|
||||
}
|
||||
}
|
||||
|
||||
getTempHP(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getAC(token) {
|
||||
return token.actor.data.data.characteristics.defense;
|
||||
}
|
||||
|
||||
getShieldHP(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getSpeed(token) {
|
||||
return token.actor.data.data.characteristics.speed;
|
||||
}
|
||||
|
||||
getInitiative(token) {
|
||||
return token.actor.data.data.fastturn ? "FAST" : "SLOW";
|
||||
}
|
||||
|
||||
toggleInitiative(token) {
|
||||
token.actor.update({
|
||||
'data.fastturn': !token.actor.data?.data?.fastturn
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
getPassivePerception(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getPassiveInvestigation(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getAbility(token, ability) {
|
||||
if (ability == undefined) ability = 'strength';
|
||||
return token.actor.data.data.attributes?.[ability].value;
|
||||
}
|
||||
|
||||
getAbilityModifier(token, ability) {
|
||||
if (ability == undefined) ability = 'str';
|
||||
let val = token.actor.data.data.attributes?.[ability].modifier;
|
||||
return (val >= 0) ? `+${val}` : val;
|
||||
}
|
||||
|
||||
getAbilitySave(token, ability) {
|
||||
return;
|
||||
}
|
||||
|
||||
getSkill(token, skill) {
|
||||
if (skill == undefined) skill = 'acr';
|
||||
const val = token.actor.data.data.skills?.[skill].total;
|
||||
return (val >= 0) ? `+${val}` : val;
|
||||
}
|
||||
|
||||
getProficiency(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getConditionIcon(condition) {
|
||||
if (condition == undefined) condition = 'removeAll';
|
||||
if (condition == 'removeAll') return window.CONFIG.controlIcons.effects;
|
||||
else return CONFIG.statusEffects.find(e => e.id === condition).icon;
|
||||
}
|
||||
|
||||
getConditionActive(token,condition) {
|
||||
if (condition == undefined) condition = 'removeAll';
|
||||
return token.actor.effects.find(e => e.isTemporary === condition) != undefined;
|
||||
}
|
||||
|
||||
async toggleCondition(token,condition) {
|
||||
if (condition == undefined) condition = 'removeAll';
|
||||
if (condition == 'removeAll'){
|
||||
for( let effect of token.actor.effects)
|
||||
await effect.delete();
|
||||
}
|
||||
else {
|
||||
const effect = CONFIG.statusEffects.find(e => e.id === condition);
|
||||
await token.toggleEffect(effect);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Roll
|
||||
*/
|
||||
roll(token,roll,options,ability,skill,save) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Items
|
||||
*/
|
||||
getItems(token,itemType) {
|
||||
if (itemType == undefined) itemType = 'any';
|
||||
const allItems = token.actor.items;
|
||||
if (itemType == 'any') return allItems.filter(i => i.type == 'item');
|
||||
}
|
||||
|
||||
getItemUses(item) {
|
||||
return {available: item.data.data.quantity};
|
||||
}
|
||||
|
||||
/**
|
||||
* Spells
|
||||
*/
|
||||
getSpells(token,level) {
|
||||
if (level == undefined) level = 'any';
|
||||
const allItems = token.actor.items;
|
||||
if (level == 'any') return allItems.filter(i => i.type == 'spell')
|
||||
else return allItems.filter(i => i.type == 'spell' && i.data.data.rank == level)
|
||||
}
|
||||
|
||||
getSpellUses(token,level,item) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
198
src/systems/dnd35e.js
Normal file
@@ -0,0 +1,198 @@
|
||||
import {compatibleCore} from "../misc.js";
|
||||
|
||||
export class dnd35e{
|
||||
constructor(){
|
||||
|
||||
}
|
||||
|
||||
getHP(token) {
|
||||
const hp = token.actor.data.data.attributes.hp;
|
||||
return {
|
||||
value: hp.value,
|
||||
max: hp.max
|
||||
}
|
||||
}
|
||||
|
||||
getTempHP(token) {
|
||||
const hp = token.actor.data.data.attributes.hp;
|
||||
return {
|
||||
value: (hp.temp == null) ? 0 : hp.temp,
|
||||
max: (hp.tempmax == null) ? 0 : hp.tempmax
|
||||
}
|
||||
}
|
||||
|
||||
getAC(token) {
|
||||
return token.actor.data.data.attributes.ac.normal.total;
|
||||
}
|
||||
|
||||
getShieldHP(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getSpeed(token) {
|
||||
const movement = token.actor.data.data.attributes.speed;
|
||||
let speed = "";
|
||||
if (movement.burrow.total > 0) speed += `Burrow: ${movement.burrow.total}Ft`;
|
||||
if (movement.climb.total > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += `Climb: ${movement.climb.total}Ft`;
|
||||
}
|
||||
if (movement.fly.total > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += `Fly: ${movement.fly.total}Ft`;
|
||||
}
|
||||
if (movement.land.total > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += `Land: ${movement.land.total}Ft`;
|
||||
}
|
||||
if (movement.swim.total > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += `Swim: ${movement.swim.total}Ft`;
|
||||
}
|
||||
return speed;
|
||||
}
|
||||
|
||||
getInitiative(token) {
|
||||
let initiative = token.actor.data.data.attributes.init.total;
|
||||
return (initiative >= 0) ? `+${initiative}` : initiative;
|
||||
}
|
||||
|
||||
toggleInitiative(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getPassivePerception(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getPassiveInvestigation(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getAbility(token, ability) {
|
||||
if (ability == undefined) ability = 'str';
|
||||
return token.actor.data.data.abilities?.[ability].value;
|
||||
}
|
||||
|
||||
getAbilityModifier(token, ability) {
|
||||
if (ability == undefined) ability = 'str';
|
||||
let val = token.actor.data.data.abilities?.[ability].mod;
|
||||
return (val >= 0) ? `+${val}` : val;
|
||||
}
|
||||
|
||||
getAbilitySave(token, ability) {
|
||||
if (ability == undefined) ability = 'fort';
|
||||
let val = token.actor.data.data.attributes.savingThrows?.[ability].total;
|
||||
return (val >= 0) ? `+${val}` : val;
|
||||
}
|
||||
|
||||
getSkill(token, skill) {
|
||||
if (skill == undefined) skill = 'apr';
|
||||
const val = token.actor.data.data.skills?.[skill].mod;
|
||||
return (val >= 0) ? `+${val}` : val;
|
||||
}
|
||||
|
||||
getProficiency(token) {
|
||||
const val = token.actor.data.data.attributes.prof;
|
||||
return (val >= 0) ? `+${val}` : val;
|
||||
}
|
||||
|
||||
getConditionIcon(condition) {
|
||||
if (condition == undefined) condition = 'removeAll';
|
||||
if (condition == 'removeAll') return window.CONFIG.controlIcons.effects;
|
||||
else return CONFIG.statusEffects.find(e => e.id === condition).icon;
|
||||
}
|
||||
|
||||
getConditionActive(token,condition) {
|
||||
if (condition == undefined) condition = 'removeAll';
|
||||
return token.actor.effects.find(e => e.isTemporary === condition) != undefined;
|
||||
}
|
||||
|
||||
async toggleCondition(token,condition) {
|
||||
if (condition == undefined) condition = 'removeAll';
|
||||
if (condition == 'removeAll'){
|
||||
for( let effect of token.actor.effects)
|
||||
await effect.delete();
|
||||
}
|
||||
else {
|
||||
const effect = CONFIG.statusEffects.find(e => e.id === condition);
|
||||
await token.toggleEffect(effect);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Roll
|
||||
*/
|
||||
roll(token,roll,options,ability,skill,save) {
|
||||
if (roll == undefined) roll = 'ability';
|
||||
if (ability == undefined) ability = 'str';
|
||||
if (skill == undefined) skill = 'apr';
|
||||
if (save == undefined) save = 'fort';
|
||||
|
||||
if (roll == 'ability') token.actor.rollAbilityTest(ability,options);
|
||||
else if (roll == 'save') token.actor.rollSavingThrow(save, null, null,options);
|
||||
else if (roll == 'skill') token.actor.rollSkill(skill,options);
|
||||
else if (roll == 'initiative') token.actor.rollInitiative(options);
|
||||
else if (roll == 'grapple') token.actor.rollGrapple(options);
|
||||
else if (roll == 'bab') token.actor.rollBAB(options);
|
||||
else if (roll == 'melee') token.actor.rollMelee(options);
|
||||
else if (roll == 'ranged') token.actor.rollRanged(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Items
|
||||
*/
|
||||
getItems(token,itemType) {
|
||||
if (itemType == undefined) itemType = 'any';
|
||||
const allItems = token.actor.items;
|
||||
if (itemType == 'any') return allItems.filter(i => i.type == 'weapon' || i.type == 'equipment' || i.type == 'consumable' || i.type == 'loot' || i.type == 'container');
|
||||
else if (game.system.id == 'D35E' && itemType == 'container') return allItems.filter(i => i.type == 'loot' && i.data.data.subType == itemType);
|
||||
else {
|
||||
if (itemType == 'gear' || itemType == 'ammo' || itemType == 'misc' || itemType == 'tradeGoods')
|
||||
return allItems.filter(i => i.type == 'loot' && i.data.data.subType == itemType);
|
||||
else return allItems.filter(i => i.type == itemType);
|
||||
}
|
||||
}
|
||||
|
||||
getItemUses(item) {
|
||||
return {available: item.data.data.quantity};
|
||||
}
|
||||
|
||||
/**
|
||||
* Features
|
||||
*/
|
||||
getFeatures(token,featureType) {
|
||||
if (featureType == undefined) featureType = 'any';
|
||||
const allItems = token.actor.items;
|
||||
if (featureType == 'any') return allItems.filter(i => i.type == 'class' || i.type == 'feat')
|
||||
else return allItems.filter(i => i.type == featureType)
|
||||
}
|
||||
|
||||
getFeatureUses(item) {
|
||||
if (item.data.type == 'class') return {available: item.data.data.levels};
|
||||
else return {
|
||||
available: item.data.data.uses.value,
|
||||
maximum: item.data.data.uses.max
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Spells
|
||||
*/
|
||||
getSpells(token,level) {
|
||||
if (level == undefined) level = 'any';
|
||||
const allItems = token.actor.items;
|
||||
if (level == 'any') return allItems.filter(i => i.type == 'spell')
|
||||
else return allItems.filter(i => i.type == 'spell' && i.data.data.level == level)
|
||||
}
|
||||
|
||||
getSpellUses(token,level,item) {
|
||||
if (level == undefined) level = 'any';
|
||||
if (item.data.data.level == 0) return;
|
||||
return {
|
||||
available: item.charges,
|
||||
maximum: item.maxCharges
|
||||
}
|
||||
}
|
||||
}
|
||||
201
src/systems/dnd5e.js
Normal file
@@ -0,0 +1,201 @@
|
||||
import {compatibleCore} from "../misc.js";
|
||||
|
||||
export class dnd5e{
|
||||
constructor(){
|
||||
|
||||
}
|
||||
|
||||
getHP(token) {
|
||||
const hp = token.actor.data.data.attributes.hp;
|
||||
return {
|
||||
value: hp.value,
|
||||
max: hp.max
|
||||
}
|
||||
}
|
||||
|
||||
getTempHP(token) {
|
||||
const hp = token.actor.data.data.attributes.hp;
|
||||
return {
|
||||
value: (hp.temp == null) ? 0 : hp.temp,
|
||||
max: (hp.tempmax == null) ? 0 : hp.tempmax
|
||||
}
|
||||
}
|
||||
|
||||
getAC(token) {
|
||||
return token.actor.data.data.attributes.ac.value;
|
||||
}
|
||||
|
||||
getShieldHP(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getSpeed(token) {
|
||||
const movement = token.actor.data.data.attributes.movement;
|
||||
let speed = "";
|
||||
if (movement != undefined){
|
||||
if (movement.burrow > 0) speed += `${game.i18n.localize("DND5E.MovementBurrow")}: ${movement.burrow + movement.units}`;
|
||||
if (movement.climb > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += `${game.i18n.localize("DND5E.MovementClimb")}: ${movement.climb + movement.units}`;
|
||||
}
|
||||
if (movement.fly > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += `${game.i18n.localize("DND5E.MovementFly")}: ${movement.fly + movement.units}`;
|
||||
}
|
||||
if (movement.hover > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += `${game.i18n.localize("DND5E.MovementHover")}: ${movement.hover + movement.units}`;
|
||||
}
|
||||
if (movement.swim > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += `${game.i18n.localize("DND5E.MovementSwim")}: ${movement.swim + movement.units}`;
|
||||
}
|
||||
if (movement.walk > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += `${game.i18n.localize("DND5E.MovementWalk")}: ${movement.walk + movement.units}`;
|
||||
}
|
||||
}
|
||||
else {
|
||||
const spd = token.actor.data.data.attributes.speed;
|
||||
speed = spd.value;
|
||||
if (spd.special.length > 0) speed + "\n" + spd.special;
|
||||
}
|
||||
return speed;
|
||||
}
|
||||
|
||||
getInitiative(token) {
|
||||
let initiative = token.actor.data.data.attributes.init.total;
|
||||
return (initiative >= 0) ? `+${initiative}` : initiative;
|
||||
}
|
||||
|
||||
toggleInitiative(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getPassivePerception(token) {
|
||||
return token.actor.data.data.skills.prc.passive;
|
||||
}
|
||||
|
||||
getPassiveInvestigation(token) {
|
||||
return token.actor.data.data.skills.inv.passive;
|
||||
}
|
||||
|
||||
getAbility(token, ability) {
|
||||
if (ability == undefined) ability = 'str';
|
||||
return token.actor.data.data.abilities?.[ability].value;
|
||||
}
|
||||
|
||||
getAbilityModifier(token, ability) {
|
||||
if (ability == undefined) ability = 'str';
|
||||
let val = token.actor.data.data.abilities?.[ability].mod;
|
||||
return (val >= 0) ? `+${val}` : val;
|
||||
}
|
||||
|
||||
getAbilitySave(token, ability) {
|
||||
if (ability == undefined) ability = 'str';
|
||||
let val = token.actor.data.data.abilities?.[ability].save;
|
||||
return (val >= 0) ? `+${val}` : val;
|
||||
}
|
||||
|
||||
getSkill(token, skill) {
|
||||
if (skill == undefined) skill = 'acr';
|
||||
const val = token.actor.data.data.skills?.[skill].total;
|
||||
return (val >= 0) ? `+${val}` : val;
|
||||
}
|
||||
|
||||
getProficiency(token) {
|
||||
const val = token.actor.data.data.attributes.prof;
|
||||
return (val >= 0) ? `+${val}` : val;
|
||||
}
|
||||
|
||||
getConditionIcon(condition) {
|
||||
if (condition == undefined) condition = 'removeAll';
|
||||
if (condition == 'removeAll') return window.CONFIG.controlIcons.effects;
|
||||
else return CONFIG.statusEffects.find(e => e.id === condition).icon;
|
||||
}
|
||||
|
||||
getConditionActive(token,condition) {
|
||||
if (condition == undefined) condition = 'removeAll';
|
||||
return token.actor.effects.find(e => e.isTemporary === condition) != undefined;
|
||||
}
|
||||
|
||||
async toggleCondition(token,condition) {
|
||||
if (condition == undefined) condition = 'removeAll';
|
||||
if (condition == 'removeAll'){
|
||||
for( let effect of token.actor.effects)
|
||||
await effect.delete();
|
||||
}
|
||||
else {
|
||||
const effect = CONFIG.statusEffects.find(e => e.id === condition);
|
||||
await token.toggleEffect(effect);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Roll
|
||||
*/
|
||||
roll(token,roll,options,ability,skill,save) {
|
||||
if (roll == undefined) roll = 'ability';
|
||||
if (ability == undefined) ability = 'str';
|
||||
if (skill == undefined) skill = 'acr';
|
||||
if (save == undefined) save = 'str';
|
||||
|
||||
if (roll == 'ability') token.actor.rollAbilityTest(ability,options);
|
||||
else if (roll == 'save') token.actor.rollAbilitySave(save,options);
|
||||
else if (roll == 'skill') token.actor.rollSkill(skill,options);
|
||||
else if (roll == 'initiative') token.actor.rollInitiative(options);
|
||||
else if (roll == 'deathSave') token.actor.rollDeathSave(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Items
|
||||
*/
|
||||
getItems(token,itemType) {
|
||||
if (itemType == undefined) itemType = 'any';
|
||||
const allItems = token.actor.items;
|
||||
if (itemType == 'any') return allItems.filter(i => i.type == 'weapon' || i.type == 'equipment' || i.type == 'consumable' || i.type == 'loot' || i.type == 'container');
|
||||
else return allItems.filter(i => i.type == itemType);
|
||||
}
|
||||
|
||||
getItemUses(item) {
|
||||
return {available: item.data.data.quantity};
|
||||
}
|
||||
|
||||
/**
|
||||
* Features
|
||||
*/
|
||||
getFeatures(token,featureType) {
|
||||
if (featureType == undefined) featureType = 'any';
|
||||
const allItems = token.actor.items;
|
||||
if (featureType == 'any') return allItems.filter(i => i.type == 'class' || i.type == 'feat')
|
||||
else return allItems.filter(i => i.type == featureType)
|
||||
}
|
||||
|
||||
getFeatureUses(item) {
|
||||
if (item.data.type == 'class') return {available: item.data.data.levels};
|
||||
else return {
|
||||
available: item.data.data.uses.value,
|
||||
maximum: item.data.data.uses.max
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Spells
|
||||
*/
|
||||
getSpells(token,level) {
|
||||
if (level == undefined) level = 'any';
|
||||
const allItems = token.actor.items;
|
||||
if (level == 'any') return allItems.filter(i => i.type == 'spell')
|
||||
else return allItems.filter(i => i.type == 'spell' && i.data.data.level == level)
|
||||
}
|
||||
|
||||
getSpellUses(token,level,item) {
|
||||
if (level == undefined) level = 'any';
|
||||
if (item.data.data.level == 0) return;
|
||||
return {
|
||||
available: token.actor.data.data.spells?.[`spell${level}`].value,
|
||||
maximum: token.actor.data.data.spells?.[`spell${level}`].max
|
||||
}
|
||||
}
|
||||
}
|
||||
195
src/systems/pf2e.js
Normal file
@@ -0,0 +1,195 @@
|
||||
import {compatibleCore} from "../misc.js";
|
||||
|
||||
export class pf2e{
|
||||
constructor(){
|
||||
|
||||
}
|
||||
|
||||
getHP(token) {
|
||||
const hp = token.actor.data.data.attributes.hp;
|
||||
return {
|
||||
value: hp.value,
|
||||
max: hp.max
|
||||
}
|
||||
}
|
||||
|
||||
getTempHP(token) {
|
||||
const hp = token.actor.data.data.attributes.hp;
|
||||
return {
|
||||
value: (hp.temp == null) ? 0 : hp.temp,
|
||||
max: (hp.tempmax == null) ? 0 : hp.tempmax
|
||||
}
|
||||
}
|
||||
|
||||
getAC(token) {
|
||||
return token.actor.data.data.attributes.ac.value;
|
||||
}
|
||||
|
||||
getShieldHP(token) {
|
||||
return token.actor.data.data.attributes.shield.value;
|
||||
}
|
||||
|
||||
getSpeed(token) {
|
||||
let speed = token.actor.data.data.attributes.speed.breakdown;
|
||||
const otherSpeeds = token.actor.data.data.attributes.speed.otherSpeeds;
|
||||
if (otherSpeeds.length > 0)
|
||||
for (let i=0; i<otherSpeeds.length; i++)
|
||||
speed += `\n${otherSpeeds[i].type}: ${otherSpeeds[i].value}`;
|
||||
return speed;
|
||||
}
|
||||
|
||||
getInitiative(token) {
|
||||
let initiative = token.actor.data.data.attributes.init.value;
|
||||
return (initiative >= 0) ? `+${initiative}` : initiative;
|
||||
}
|
||||
|
||||
toggleInitiative(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getPassivePerception(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getPassiveInvestigation(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getAbility(token, ability) {
|
||||
if (ability == undefined) ability = 'str';
|
||||
return token.actor.data.data.abilities?.[ability].value;
|
||||
}
|
||||
|
||||
getAbilityModifier(token, ability) {
|
||||
if (ability == undefined) ability = 'str';
|
||||
let val = token.actor.data.data.abilities?.[ability].mod;
|
||||
return (val >= 0) ? `+${val}` : val;
|
||||
}
|
||||
|
||||
getAbilitySave(token, ability) {
|
||||
if (ability == undefined) ability = 'fortitude';
|
||||
else if (ability == 'fort') ability = 'fortitude';
|
||||
else if (ability == 'ref') ability = 'reflex';
|
||||
else if (ability == 'will') ability = 'will';
|
||||
let val = token.actor.data.data.saves?.[ability].value;
|
||||
return (val >= 0) ? `+${val}` : val;
|
||||
}
|
||||
|
||||
getSkill(token, skill) {
|
||||
if (skill == undefined) skill = 'acr';
|
||||
const val = token.actor.data.data.skills?.[skill].totalModifier;
|
||||
return (val >= 0) ? `+${val}` : val;
|
||||
}
|
||||
|
||||
getProficiency(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getCondition(token,condition) {
|
||||
if (condition == undefined || condition == 'removeAll') return undefined;
|
||||
const Condition = condition.charAt(0).toUpperCase() + condition.slice(1);
|
||||
const effects = token.actor.items.filter(i => i.type == 'condition');
|
||||
return effects.find(e => e.name === Condition);
|
||||
}
|
||||
|
||||
getConditionIcon(condition) {
|
||||
if (condition == undefined) condition = 'removeAll';
|
||||
if (condition == 'removeAll') return window.CONFIG.controlIcons.effects;
|
||||
else return `${CONFIG.PF2E.statusEffects.effectsIconFolder}${condition}.webp`;
|
||||
}
|
||||
|
||||
getConditionActive(token,condition) {
|
||||
return this.getCondition(token,condition) != undefined;
|
||||
}
|
||||
|
||||
async toggleCondition(token,condition) {
|
||||
if (condition == undefined) condition = 'removeAll';
|
||||
if (condition == 'removeAll'){
|
||||
for( let effect of token.actor.items.filter(i => i.type == 'condition'))
|
||||
await effect.delete();
|
||||
}
|
||||
else {
|
||||
const effect = this.getCondition(token,condition);
|
||||
if (effect == undefined) {
|
||||
const Condition = condition.charAt(0).toUpperCase() + condition.slice(1);
|
||||
const newCondition = game.pf2e.ConditionManager.getCondition(Condition);
|
||||
newCondition.data.sources.hud = !0,
|
||||
await game.pf2e.ConditionManager.addConditionToToken(newCondition, token);
|
||||
}
|
||||
else {
|
||||
effect.delete();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Roll
|
||||
*/
|
||||
roll(token,roll,options,ability,skill,save) {
|
||||
if (roll == undefined) roll = 'ability';
|
||||
if (ability == undefined) ability = 'str';
|
||||
if (skill == undefined) skill = 'acr';
|
||||
if (save == undefined) save = 'fort';
|
||||
|
||||
if (roll == 'ability') token.actor.data.data.abilities?.[ability].roll(options);
|
||||
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(options);
|
||||
}
|
||||
else if (roll == 'skill') token.actor.data.data.skills?.[skill].roll(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Items
|
||||
*/
|
||||
getItems(token,itemType) {
|
||||
if (itemType == undefined) itemType = 'any';
|
||||
const allItems = token.actor.items;
|
||||
if (itemType == 'any') return allItems.filter(i => i.type == 'weapon' || i.type == 'equipment' || i.type == 'consumable' || i.type == 'loot' || i.type == 'container');
|
||||
else return allItems.filter(i => i.type == itemType);
|
||||
}
|
||||
|
||||
getItemUses(item) {
|
||||
return {available: item.data.data.quantity.value};
|
||||
}
|
||||
|
||||
/**
|
||||
* Features
|
||||
*/
|
||||
getFeatures(token,featureType) {
|
||||
if (featureType == undefined) featureType = 'any';
|
||||
const allItems = token.actor.items;
|
||||
if (featureType == 'any') return allItems.filter(i => i.type == 'class' || i.type == 'feat')
|
||||
else return allItems.filter(i => i.type == featureType)
|
||||
}
|
||||
|
||||
getFeatureUses(item) {
|
||||
if (item.data.type == 'class') return {available: item.actor.data.data.details.level.value};
|
||||
else return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spells
|
||||
*/
|
||||
getSpells(token,level) {
|
||||
if (level == undefined) level = 'any';
|
||||
const allItems = token.actor.items;
|
||||
if (level == 'any') return allItems.filter(i => i.type == 'spell')
|
||||
else return allItems.filter(i => i.type == 'spell' && i.data.data.level.value == level)
|
||||
}
|
||||
|
||||
getSpellUses(token,level,item) {
|
||||
if (level == undefined) level = 'any';
|
||||
if (item.data.data.level.value == 0) return;
|
||||
const spellbook = token.actor.items.filter(i => i.data.type === 'spellcastingEntry')[0];
|
||||
if (spellbook == undefined) return;
|
||||
return {
|
||||
available: spellbook.data.data.slots?.[`slot${level}`].value,
|
||||
maximum: spellbook.data.data.slots?.[`slot${level}`].max
|
||||
}
|
||||
}
|
||||
}
|
||||
241
src/systems/tokenHelper.js
Normal file
@@ -0,0 +1,241 @@
|
||||
import {dnd5e} from "./dnd5e.js"
|
||||
import {dnd35e} from "./dnd35e.js"
|
||||
import {pf2e} from "./pf2e.js"
|
||||
import {demonlord} from "./demonlord.js";
|
||||
import {compatibleCore} from "../misc.js";
|
||||
|
||||
export class TokenHelper{
|
||||
constructor(){
|
||||
this.system;
|
||||
this.setSystem();
|
||||
}
|
||||
|
||||
setSystem() {
|
||||
if (game.system.id == 'D35E' || game.system.id == 'pf1') this.system = new dnd35e();
|
||||
else if (game.system.id == 'pf2e') this.system = new pf2e();
|
||||
else if (game.system.id == 'demonlord') this.system = new demonlord();
|
||||
else this.system = new dnd5e(); //default to dnd5e
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* System agnostic functions
|
||||
***********************************************************************/
|
||||
getToken(type,identifier) {
|
||||
if (type == 'selected') return this.getSelectedToken();
|
||||
else if (type != 'selected' && identifier == '') return;
|
||||
else if (type == 'tokenName') return this.getTokenFromTokenName(identifier);
|
||||
else if (type == 'actorName') return this.getTokenFromActorName(identifier);
|
||||
else if (type == 'tokenId') return this.getTokenFromTokenId(identifier);
|
||||
else if (type == 'actorId') return this.getTokenFromActorId(identifier);
|
||||
}
|
||||
getTokenFromTokenId(id) {
|
||||
return canvas.tokens.children[0].children.find(p => p.id == id);
|
||||
}
|
||||
|
||||
getTokenFromTokenName(name) {
|
||||
return canvas.tokens.children[0].children.find(p => p.name == name);
|
||||
}
|
||||
|
||||
getTokenFromActorId(id) {
|
||||
return canvas.tokens.children[0].children.find(p => p.actor.id == id);
|
||||
}
|
||||
|
||||
getTokenFromActorName(name) {
|
||||
return canvas.tokens.children[0].children.find(p => p.actor.name == name);
|
||||
}
|
||||
|
||||
getSelectedToken() {
|
||||
return canvas.tokens.controlled[0];
|
||||
}
|
||||
|
||||
moveToken(token,dir){
|
||||
if (dir == undefined) dir = 'up';
|
||||
const gridSize = canvas.scene.data.grid;
|
||||
let x = token.x;
|
||||
let y = token.y;
|
||||
|
||||
if (dir == 'up') y -= gridSize;
|
||||
else if (dir == 'down') y += gridSize;
|
||||
else if (dir == 'right') x += gridSize;
|
||||
else if (dir == 'left') x -= gridSize;
|
||||
else if (dir == 'upRight') {
|
||||
x += gridSize;
|
||||
y -= gridSize;
|
||||
}
|
||||
else if (dir == 'upLeft') {
|
||||
x -= gridSize;
|
||||
y -= gridSize;
|
||||
}
|
||||
else if (dir == 'downRight') {
|
||||
x += gridSize;
|
||||
y += gridSize;
|
||||
}
|
||||
else if (dir == 'downLeft') {
|
||||
x -= gridSize;
|
||||
y += gridSize;
|
||||
}
|
||||
else if (dir == 'center') {
|
||||
let location = token.getCenter(x,y);
|
||||
canvas.animatePan(location);
|
||||
}
|
||||
if (game.user.isGM == false && game.paused == true && (token.can(game.user,"control") == false || token.checkCollision(token.getCenter(x, y)))) return;
|
||||
if (compatibleCore("0.8.1")) token.document.update({x:x,y:y});
|
||||
else token.update({x:x,y:y});
|
||||
};
|
||||
|
||||
rotateToken(token,move,value) {
|
||||
if (move == undefined) move = 'to';
|
||||
value = isNaN(parseInt(value)) ? 0 : parseInt(value);
|
||||
|
||||
let rotationVal;
|
||||
if (move == 'by') rotationVal = token.data.rotation + value;
|
||||
else rotationVal = value;
|
||||
|
||||
if (compatibleCore("0.8.1")) token.document.update({rotation: rotationVal});
|
||||
else token.update({rotation: rotationVal});
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Get name/id
|
||||
*/
|
||||
getTokenName(token) {
|
||||
return token.name;
|
||||
}
|
||||
|
||||
getTokenId(token) {
|
||||
return token.id;
|
||||
}
|
||||
|
||||
getActorName(token) {
|
||||
return token.actor.name;
|
||||
}
|
||||
|
||||
getActorId(token) {
|
||||
return token.actor.id;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
getTokenIcon(token) {
|
||||
return token.data.img;
|
||||
}
|
||||
|
||||
getActorIcon(token) {
|
||||
return token.actor.data.img;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* System agnostic functions
|
||||
***********************************************************************/
|
||||
getHP(token) {
|
||||
return this.system.getHP(token);
|
||||
}
|
||||
|
||||
getTempHP(token) {
|
||||
return this.system.getTempHP(token);
|
||||
}
|
||||
|
||||
getAC(token) {
|
||||
return this.system.getAC(token);
|
||||
}
|
||||
|
||||
getShieldHP(token) {
|
||||
return this.system.getShieldHP(token);
|
||||
}
|
||||
|
||||
getSpeed(token) {
|
||||
return this.system.getSpeed(token);
|
||||
}
|
||||
|
||||
getInitiative(token) {
|
||||
return this.system.getInitiative(token);
|
||||
}
|
||||
|
||||
toggleInitiative(token) {
|
||||
return this.system.toggleInitiative(token);
|
||||
}
|
||||
|
||||
getPassivePerception(token) {
|
||||
return this.system.getPassivePerception(token);
|
||||
}
|
||||
|
||||
getPassiveInvestigation(token) {
|
||||
return this.system.getPassiveInvestigation(token);
|
||||
}
|
||||
|
||||
getAbility(token, ability) {
|
||||
return this.system.getAbility(token, ability);
|
||||
}
|
||||
|
||||
getAbilityModifier(token, ability) {
|
||||
return this.system.getAbilityModifier(token, ability);
|
||||
}
|
||||
|
||||
getAbilitySave(token, ability) {
|
||||
return this.system.getAbilitySave(token, ability);
|
||||
}
|
||||
|
||||
getSkill(token, skill) {
|
||||
return this.system.getSkill(token, skill);
|
||||
}
|
||||
|
||||
getProficiency(token) {
|
||||
return this.system.getProficiency(token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Conditions
|
||||
*/
|
||||
getConditionIcon(condition) {
|
||||
return this.system.getConditionIcon(condition);
|
||||
}
|
||||
|
||||
getConditionActive(token,condition) {
|
||||
return this.system.getConditionActive(token,condition);
|
||||
}
|
||||
|
||||
toggleCondition(token,condition) {
|
||||
return this.system.toggleCondition(token,condition);
|
||||
}
|
||||
|
||||
/**
|
||||
* Roll
|
||||
*/
|
||||
roll(token,roll,options,ability,skill,save) {
|
||||
return this.system.roll(token,roll,options,ability,skill,save);
|
||||
}
|
||||
|
||||
/**
|
||||
* Items
|
||||
*/
|
||||
getItems(token,itemType) {
|
||||
return this.system.getItems(token,itemType);
|
||||
}
|
||||
|
||||
getItemUses(item) {
|
||||
return this.system.getItemUses(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Features
|
||||
*/
|
||||
getFeatures(token,featureType) {
|
||||
return this.system.getFeatures(token,featureType);
|
||||
}
|
||||
|
||||
getFeatureUses(item) {
|
||||
return this.system.getFeatureUses(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Spells
|
||||
*/
|
||||
getSpells(token,level) {
|
||||
return this.system.getSpells(token,level);
|
||||
}
|
||||
|
||||
getSpellUses(token,level,item) {
|
||||
return this.system.getSpellUses(token,level,item);
|
||||
}
|
||||
}
|
||||
598
src/token.js
@@ -1,6 +1,5 @@
|
||||
import * as MODULE from "../MaterialDeck.js";
|
||||
import {streamDeck, macroControl, otherControls} from "../MaterialDeck.js";
|
||||
import {compatibleCore} from "./misc.js";
|
||||
import {streamDeck, macroControl, otherControls, tokenHelper} from "../MaterialDeck.js";
|
||||
|
||||
export class TokenControl{
|
||||
constructor(){
|
||||
@@ -28,22 +27,14 @@ export class TokenControl{
|
||||
const selection = settings.selection ? settings.selection : 'selected';
|
||||
const tokenIdentifier = settings.tokenName ? settings.tokenName : '';
|
||||
const prependTitle = settings.prependTitle ? settings.prependTitle : '';
|
||||
const mode = settings.tokenMode ? settings.tokenMode : 'token';
|
||||
|
||||
let validToken = false;
|
||||
let token;
|
||||
if (settings.combatTrackerMode) {
|
||||
const mode = settings.combatTrackerMode;
|
||||
token = canvas.tokens.children[0].children.find(p => p.id == tokenId);
|
||||
}
|
||||
else if (selection == 'selected') token = canvas.tokens.controlled[0];
|
||||
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 (settings.combatTrackerMode) token = tokenHelper.getTokenFromTokenId(tokenId);
|
||||
else token = tokenHelper.getToken(selection,tokenIdentifier);
|
||||
|
||||
if (token != undefined) validToken = true;
|
||||
let tokenName = "";
|
||||
let txt = "";
|
||||
let iconSrc = "";
|
||||
let overlay = false;
|
||||
@@ -60,9 +51,9 @@ export class TokenControl{
|
||||
return;
|
||||
}
|
||||
|
||||
tokenName = token.data.name;
|
||||
if (name) txt += tokenName;
|
||||
else txt += prependTitle;
|
||||
if (mode == 'token') {
|
||||
if (name) txt += tokenHelper.getTokenName(token);
|
||||
txt += prependTitle;
|
||||
|
||||
const permission = token.actor?.permission;
|
||||
if (settings.combat){
|
||||
@@ -80,9 +71,10 @@ export class TokenControl{
|
||||
stats = 'none';
|
||||
}
|
||||
|
||||
if (icon == 'tokenIcon') iconSrc = token.data.img;
|
||||
else if (icon == 'actorIcon') iconSrc = token.actor.data.img;
|
||||
if (icon == 'tokenIcon') iconSrc = tokenHelper.getTokenIcon(token);
|
||||
else if (icon == 'actorIcon') iconSrc = tokenHelper.getActorIcon(token);
|
||||
if (name && stats != 'none' && stats != 'HPbox') txt += "\n";
|
||||
|
||||
if (stats == 'custom'){
|
||||
const custom = settings.custom ? settings.custom : '';
|
||||
let split = custom.split('[');
|
||||
@@ -101,290 +93,48 @@ export class TokenControl{
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (game.system.id == 'dnd5e'){
|
||||
let attributes = token.actor.data.data.attributes;
|
||||
|
||||
if (stats == 'HP') {
|
||||
if (icon == 'stats') {
|
||||
const hp = tokenHelper.getHP(token);
|
||||
txt += hp.value + "/" + hp.max;
|
||||
|
||||
if (icon == 'stats')
|
||||
uses = {
|
||||
available: attributes.hp.value,
|
||||
maximum: attributes.hp.max,
|
||||
available: hp.value,
|
||||
maximum: hp.max,
|
||||
heart: "#FF0000"
|
||||
};
|
||||
}
|
||||
|
||||
txt += attributes.hp.value + "/" + attributes.hp.max;
|
||||
}
|
||||
else if (stats == 'HPbox') {
|
||||
const hp = tokenHelper.getHP(token);
|
||||
uses = {
|
||||
available: attributes.hp.value,
|
||||
maximum: attributes.hp.max,
|
||||
heart: false
|
||||
available: hp.value,
|
||||
maximum: hp.max
|
||||
}
|
||||
}
|
||||
else if (stats == 'TempHP') {
|
||||
const val = (attributes.hp.temp == null) ? 0 : attributes.hp.temp;
|
||||
const max = (attributes.hp.tempmax == null) ? 0 : attributes.hp.tempmax
|
||||
if (icon == 'stats') {
|
||||
const tempHP = tokenHelper.getTempHP(token);
|
||||
txt += (tempHP.max == 0) ? tempHP.value : `${tempHP.value}/${tempHP.max}`;
|
||||
|
||||
if (icon == 'stats')
|
||||
uses = {
|
||||
available: (attributes.hp.temp == null) ? 0 : attributes.hp.temp,
|
||||
maximum: (max == 0) ? 1 : attributes.hp.tempmax,
|
||||
available: tempHP.value,
|
||||
maximum: tempHP.max,
|
||||
heart: "#00FF00"
|
||||
};
|
||||
}
|
||||
txt += val;
|
||||
if (max != 0) txt += "/" + max;
|
||||
}
|
||||
else if (stats == 'AC') txt += attributes.ac.value;
|
||||
else if (stats == 'Speed'){
|
||||
let speed = "";
|
||||
if (attributes.movement != undefined){
|
||||
if (attributes.movement.burrow > 0) speed += game.i18n.localize("DND5E.MovementBurrow") + ': ' + attributes.movement.burrow + attributes.movement.units;
|
||||
if (attributes.movement.climb > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += game.i18n.localize("DND5E.MovementClimb") + ': ' + attributes.movement.climb + attributes.movement.units;
|
||||
}
|
||||
if (attributes.movement.fly > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += game.i18n.localize("DND5E.MovementFly") + ': ' + attributes.movement.fly + attributes.movement.units;
|
||||
}
|
||||
if (attributes.movement.hover > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += game.i18n.localize("DND5E.MovementHover") + ': ' + attributes.movement.hover + attributes.movement.units;
|
||||
}
|
||||
if (attributes.movement.swim > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += game.i18n.localize("DND5E.MovementSwim") + ': ' + attributes.movement.swim + attributes.movement.units;
|
||||
}
|
||||
if (attributes.movement.walk > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += game.i18n.localize("DND5E.MovementWalk") + ': ' + attributes.movement.walk + attributes.movement.units;
|
||||
}
|
||||
}
|
||||
else {
|
||||
speed = attributes.speed.value;
|
||||
if (attributes.speed.special.length > 0) speed + "\n" + attributes.speed.special;
|
||||
}
|
||||
txt += speed;
|
||||
}
|
||||
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].total;
|
||||
if (value >= 0) txt += '+';
|
||||
txt += value;
|
||||
}
|
||||
else if (stats == 'Prof') {
|
||||
const value = token.actor.data.data.attributes.prof;
|
||||
if (value >= 0) txt += '+';
|
||||
txt += value;
|
||||
}
|
||||
}
|
||||
|
||||
else if (game.system.id == 'D35E' || game.system.id == 'pf1'){
|
||||
let attributes = token.actor.data.data.attributes;
|
||||
if (stats == 'HP') {
|
||||
if (icon == 'stats') {
|
||||
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
|
||||
}
|
||||
}
|
||||
else if (stats == 'TempHP') {
|
||||
if (attributes.hp.temp == null) txt += '0';
|
||||
else txt += attributes.hp.temp;
|
||||
}
|
||||
else if (stats == 'AC') txt += attributes.ac.normal.total;
|
||||
else if (stats == 'Speed'){
|
||||
let speed = "";
|
||||
if (attributes.speed.burrow.total > 0) speed += 'Burrow: ' + attributes.speed.burrow.total + 'Ft';
|
||||
if (attributes.speed.climb.total > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += 'Climb: ' + attributes.speed.climb.total + 'Ft';
|
||||
}
|
||||
if (attributes.speed.fly.total > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += 'Fly: ' + attributes.speed.fly.total + 'Ft';
|
||||
}
|
||||
if (attributes.speed.land.total > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += 'Land: ' + attributes.speed.land.total + 'Ft';
|
||||
}
|
||||
if (attributes.speed.swim.total > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += 'Swim: ' + attributes.speed.swim.total + 'Ft';
|
||||
}
|
||||
txt += speed;
|
||||
}
|
||||
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') {
|
||||
if (icon == 'stats') {
|
||||
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
|
||||
}
|
||||
}
|
||||
else if (stats == 'TempHP') {
|
||||
if (attributes.hp.temp == null) txt += '0';
|
||||
else {
|
||||
txt += attributes.hp.temp;
|
||||
if (attributes.hp.tempmax > 0) txt += '/' + attributes.hp.tempmax;
|
||||
}
|
||||
}
|
||||
else if (stats == 'AC') txt += attributes.ac.value;
|
||||
else if (stats == 'Speed'){
|
||||
let speed = attributes.speed.breakdown;
|
||||
const otherSpeeds = attributes.speed.otherSpeeds;
|
||||
if (otherSpeeds.length > 0)
|
||||
for (let i=0; i<otherSpeeds.length; i++)
|
||||
speed += '\n' + otherSpeeds[i].type + ": " + otherSpeeds[i].value;
|
||||
txt += speed;
|
||||
}
|
||||
else if (stats == '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') {
|
||||
if (icon == 'stats') {
|
||||
uses = {
|
||||
available: attributes.hp.value,
|
||||
maximum: attributes.hp.max,
|
||||
heart: true
|
||||
};
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
else if (stats == 'AC') txt += tokenHelper.getAC(token);
|
||||
else if (stats == 'ShieldHP') txt += tokenHelper.getShieldHP(token);
|
||||
else if (stats == 'Speed') txt += tokenHelper.getSpeed(token);
|
||||
else if (stats == 'Init') txt += tokenHelper.getInitiative(token);
|
||||
else if (stats == 'PassivePerception') txt += tokenHelper.getPassivePerception(token);
|
||||
else if (stats == 'PassiveInvestigation') txt += tokenHelper.getPassiveInvestigation(token);
|
||||
else if (stats == 'Ability') txt += tokenHelper.getAbility(token, settings.ability);
|
||||
else if (stats == 'AbilityMod') txt += tokenHelper.getAbilityModifier(token, settings.ability);
|
||||
else if (stats == 'Save') txt += tokenHelper.getAbilitySave(token, settings.save);
|
||||
else if (stats == 'Skill') txt += tokenHelper.getSkill(token, settings.skill);
|
||||
else if (stats == 'Prof') txt += tokenHelper.getProficiency(token);
|
||||
|
||||
if (settings.onClick == 'visibility') { //toggle visibility
|
||||
if (MODULE.getPermission('TOKEN','VISIBILITY') == false ) {
|
||||
@@ -432,54 +182,14 @@ export class TokenControl{
|
||||
return;
|
||||
}
|
||||
ring = 1;
|
||||
if (game.system.id == 'dnd5e' || game.system.id == 'D35E' || game.system.id == 'pf1'){
|
||||
const condition = settings.condition ? settings.condition : 'removeAll';
|
||||
if (condition == 'removeAll' && icon == 'stats')
|
||||
iconSrc = window.CONFIG.controlIcons.effects;
|
||||
else if (icon == 'stats') {
|
||||
let effect = CONFIG.statusEffects.find(e => e.id === condition);
|
||||
iconSrc = effect.icon;
|
||||
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;
|
||||
ringColor = "#FF7B00";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (game.system.id == 'pf2e') {
|
||||
const condition = settings.condition ? settings.condition : 'removeAll';
|
||||
if (condition == 'removeAll' && icon == 'stats')
|
||||
iconSrc = window.CONFIG.controlIcons.effects;
|
||||
else if (icon == 'stats') {
|
||||
let effects = token.data.effects;
|
||||
for (let i=0; i<effects.length; i++){
|
||||
if (this.pf2eCondition(condition) == effects[i]){
|
||||
ring = 2;
|
||||
ringColor = "#FF7B00";
|
||||
}
|
||||
}
|
||||
iconSrc = this.pf2eCondition(condition);
|
||||
}
|
||||
}
|
||||
else if (game.system.id == 'demonlord'){
|
||||
const condition = settings.condition ? settings.condition : 'removeAll';
|
||||
if (condition == 'removeAll' && icon == 'stats')
|
||||
iconSrc = window.CONFIG.controlIcons.effects;
|
||||
else if (icon == 'stats') {
|
||||
let effect = CONFIG.statusEffects.find(e => e.id === condition);
|
||||
iconSrc = effect.icon;
|
||||
let effects = token.actor.effects.entries;
|
||||
let active = effects.find(e => e.isTemporary === condition);
|
||||
if (active != undefined){
|
||||
ring = 2;
|
||||
ringColor = "#FF7B00";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
iconSrc = "";
|
||||
overlay = true;
|
||||
if (icon == 'stats') {
|
||||
iconSrc = tokenHelper.getConditionIcon(settings.condition);
|
||||
if (tokenHelper.getConditionActive(token,settings.condition)) {
|
||||
ring = 2;
|
||||
ringColor = "#FF7B00";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (settings.onClick == 'cubCondition') { //Combat Utility Belt conditions
|
||||
if (MODULE.getPermission('TOKEN','CONDITIONS') == false ) {
|
||||
@@ -491,11 +201,8 @@ export class TokenControl{
|
||||
const condition = settings.cubConditionName;
|
||||
if (condition == undefined || condition == '') return;
|
||||
if (icon == 'stats') {
|
||||
let effect = CONFIG.statusEffects.find(e => e.label === condition);
|
||||
iconSrc = effect.icon;
|
||||
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){
|
||||
iconSrc = CONFIG.statusEffects.find(e => e.label === condition).icon;
|
||||
if (tokenHelper.getConditionActive(token,condition)){
|
||||
ring = 2;
|
||||
ringColor = "#FF7B00";
|
||||
}
|
||||
@@ -538,8 +245,47 @@ export class TokenControl{
|
||||
}
|
||||
else return;
|
||||
}
|
||||
else if (settings.onClick == 'initiative') //Initiative
|
||||
iconSrc = "modules/MaterialDeck/img/token/init.png";
|
||||
}
|
||||
//Items
|
||||
else {
|
||||
txt += prependTitle;
|
||||
const allItems = token.actor.items;
|
||||
const itemNr = settings.itemNr ? settings.itemNr - 1 : 0;
|
||||
const displayUses = settings.displayUses ? settings.displayUses : false;
|
||||
const displayName = settings.displayInventoryName ? settings.displayInventoryName : false;
|
||||
const displayIcon = settings.displayInventoryIcon ? settings.displayInventoryIcon : false;
|
||||
let items = allItems;
|
||||
let item;
|
||||
if (mode == 'inventory') {
|
||||
items = tokenHelper.getItems(token,settings.inventoryType);
|
||||
items = this.sortItems(items);
|
||||
item = items[itemNr];
|
||||
if (item != undefined && displayUses) uses = tokenHelper.getItemUses(item);
|
||||
}
|
||||
else if (mode == 'features') {
|
||||
items = tokenHelper.getFeatures(token,settings.featureType);
|
||||
items = this.sortItems(items);
|
||||
item = items[itemNr];
|
||||
if (item != undefined && displayUses) uses = tokenHelper.getFeatureUses(item);
|
||||
}
|
||||
else if (mode == 'spellbook') {
|
||||
items = tokenHelper.getSpells(token,settings.spellType);
|
||||
items = this.sortItems(items);
|
||||
item = items[itemNr];
|
||||
if (displayUses && item != undefined) uses = tokenHelper.getSpellUses(token,settings.spellType,item);
|
||||
}
|
||||
if (item != undefined) {
|
||||
if (displayIcon) iconSrc = item.img;
|
||||
if (displayName) txt = item.name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//No valid token found:
|
||||
else {
|
||||
if (mode == 'token') {
|
||||
iconSrc += "";
|
||||
if (settings.onClick == 'visibility') { //toggle visibility
|
||||
if (MODULE.getPermission('TOKEN','VISIBILITY') == false ) {
|
||||
@@ -575,29 +321,9 @@ export class TokenControl{
|
||||
streamDeck.noPermission(context,device);
|
||||
return;
|
||||
}
|
||||
if (game.system.id == 'dnd5e' || game.system.id == 'D35E' || game.system.id == 'pf1'){
|
||||
const condition = settings.condition ? settings.condition : 'removeAll';
|
||||
if (condition == 'removeAll' && icon == false)
|
||||
iconSrc = window.CONFIG.controlIcons.effects;
|
||||
else if (icon == 'stats')
|
||||
iconSrc = CONFIG.statusEffects.find(e => e.id === condition).icon;
|
||||
}
|
||||
else if (game.system.id == 'pf2e') {
|
||||
const condition = settings.condition ? settings.condition : 'removeAll';
|
||||
if (condition == 'removeAll' && icon == 'stats')
|
||||
iconSrc = window.CONFIG.controlIcons.effects;
|
||||
else if (icon == 'stats')
|
||||
iconSrc = this.pf2eCondition(condition);
|
||||
}
|
||||
else if (game.system.id == 'demonlord'){
|
||||
const condition = settings.condition ? settings.condition : 'removeAll';
|
||||
if (condition == 'removeAll' && icon == 'stats')
|
||||
iconSrc = window.CONFIG.controlIcons.effects;
|
||||
else if (icon == 'stats')
|
||||
iconSrc = CONFIG.statusEffects.find(e => e.id === condition).icon;
|
||||
}
|
||||
ring = 1;
|
||||
overlay = true;
|
||||
if (icon == 'stats') iconSrc = tokenHelper.getConditionIcon(settings.condition);
|
||||
}
|
||||
else if (settings.onClick == 'cubCondition') { //Combat Utility Belt conditions
|
||||
if (MODULE.getPermission('TOKEN','CONDITIONS') == false ) {
|
||||
@@ -613,6 +339,7 @@ export class TokenControl{
|
||||
overlay = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (icon == 'stats'){
|
||||
if (MODULE.getPermission('TOKEN','STATS') == false) stats = statsOld;
|
||||
@@ -624,7 +351,7 @@ export class TokenControl{
|
||||
iconSrc = "modules/MaterialDeck/img/token/ac.webp";
|
||||
else if (stats == 'Speed') //Speed
|
||||
iconSrc = "modules/MaterialDeck/img/token/speed.webp";
|
||||
else if (stats == 'Init') //Initiative
|
||||
else if (stats == 'Init' || settings.onClick == 'initiative') //Initiative
|
||||
iconSrc = "modules/MaterialDeck/img/token/init.png";
|
||||
else if (stats == 'PassivePerception') {
|
||||
iconSrc = "modules/MaterialDeck/img/token/skills/prc.png";
|
||||
@@ -651,11 +378,49 @@ export class TokenControl{
|
||||
if (skill == undefined) skill = 'acr';
|
||||
else iconSrc = "modules/MaterialDeck/img/token/skills/" + skill + ".png";
|
||||
}
|
||||
else if (settings.onClick == 'center' || settings.onClick == 'centerSelect') {
|
||||
overlay = true;
|
||||
iconSrc = "modules/MaterialDeck/img/move/center.png";
|
||||
}
|
||||
else if (settings.onClick == 'move') {
|
||||
overlay = true;
|
||||
const dir = settings.dir ? settings.dir : 'center';
|
||||
if (dir == 'up') //up
|
||||
iconSrc = "modules/MaterialDeck/img/move/up.png";
|
||||
else if (dir == 'down') //down
|
||||
iconSrc = "modules/MaterialDeck/img/move/down.png";
|
||||
else if (dir == 'right') //right
|
||||
iconSrc = "modules/MaterialDeck/img/move/right.png";
|
||||
else if (dir == 'left') //left
|
||||
iconSrc = "modules/MaterialDeck/img/move/left.png";
|
||||
else if (dir == 'upRight')
|
||||
iconSrc = "modules/MaterialDeck/img/move/upright.png";
|
||||
else if (dir == 'upLeft')
|
||||
iconSrc = "modules/MaterialDeck/img/move/upleft.png";
|
||||
else if (dir == 'downRight')
|
||||
iconSrc = "modules/MaterialDeck/img/move/downright.png";
|
||||
else if (dir == 'downLeft')
|
||||
iconSrc = "modules/MaterialDeck/img/move/downleft.png";
|
||||
}
|
||||
else if (settings.onClick == 'rotate') {
|
||||
overlay = true;
|
||||
const value = isNaN(parseInt(settings.rotValue)) ? 0 : parseInt(settings.rotValue);
|
||||
if (value >= 0)
|
||||
iconSrc = "modules/MaterialDeck/img/move/rotatecw.png";
|
||||
else
|
||||
iconSrc = "modules/MaterialDeck/img/move/rotateccw.png";
|
||||
}
|
||||
}
|
||||
streamDeck.setIcon(context,device,iconSrc,{background:background,ring:ring,ringColor:ringColor,overlay:overlay,uses:uses,hp:hp});
|
||||
streamDeck.setTitle(txt,context);
|
||||
}
|
||||
|
||||
sortItems(items) {
|
||||
let sorted = Object.values(items);
|
||||
sorted.sort((a,b) => a.data.sort - b.data.sort);
|
||||
return sorted;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
async keyPress(settings){
|
||||
@@ -663,19 +428,18 @@ export class TokenControl{
|
||||
|
||||
const selection = settings.selection ? settings.selection : 'selected';
|
||||
const tokenIdentifier = settings.tokenName ? settings.tokenName : '';
|
||||
const mode = settings.tokenMode ? settings.tokenMode : 'token';
|
||||
|
||||
let token;
|
||||
if (selection == 'selected') token = canvas.tokens.controlled[0];
|
||||
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);
|
||||
else token = tokenHelper.getToken(selection,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;
|
||||
|
||||
if (mode == 'token') {
|
||||
|
||||
const onClick = settings.onClick ? settings.onClick : 'doNothing';
|
||||
|
||||
if (onClick == 'doNothing') //Do nothing
|
||||
@@ -692,6 +456,12 @@ export class TokenControl{
|
||||
canvas.animatePan(location);
|
||||
token.control();
|
||||
}
|
||||
else if (onClick == 'move') { //move token
|
||||
tokenHelper.moveToken(token,settings.dir);
|
||||
}
|
||||
else if (onClick == 'rotate') { //rotate token
|
||||
tokenHelper.rotateToken(token,settings.rot,settings.rotValue);
|
||||
}
|
||||
else if (onClick == 'charSheet'){ //Open character sheet
|
||||
const element = document.getElementById(token.actor.sheet.id);
|
||||
if (element == null) token.actor.sheet.render(true);
|
||||
@@ -715,47 +485,13 @@ export class TokenControl{
|
||||
}
|
||||
else if (onClick == 'condition') { //Toggle condition
|
||||
if (MODULE.getPermission('TOKEN','CONDITIONS') == false ) return;
|
||||
if (game.system.id == 'dnd5e' || game.system.id == 'D35E' || game.system.id == 'pf1'){
|
||||
const condition = settings.condition ? settings.condition : 'removeAll';
|
||||
if (condition == 'removeAll'){
|
||||
for( let effect of token.actor.effects)
|
||||
await effect.delete();
|
||||
}
|
||||
else {
|
||||
const effect = CONFIG.statusEffects.find(e => e.id === condition);
|
||||
await token.toggleEffect(effect);
|
||||
}
|
||||
}
|
||||
else if (game.system.id == 'pf2e'){
|
||||
const condition = settings.condition ? settings.condition : 'removeAll';
|
||||
if (condition == 'removeAll'){
|
||||
for( let effect of token.actor.effects)
|
||||
await effect.delete();
|
||||
}
|
||||
else {
|
||||
const effect = this.pf2eCondition(condition);
|
||||
await token.toggleEffect(effect);
|
||||
}
|
||||
}
|
||||
else if (game.system.id == 'demonlord'){
|
||||
const condition = settings.condition ? settings.condition : 'removeAll';
|
||||
if (condition == 'removeAll'){
|
||||
for( let effect of token.actor.effects)
|
||||
await effect.delete();
|
||||
}
|
||||
else {
|
||||
const effect = CONFIG.statusEffects.find(e => e.id === condition);
|
||||
await token.toggleEffect(effect);
|
||||
}
|
||||
}
|
||||
await tokenHelper.toggleCondition(token,settings.condition);
|
||||
this.update(tokenId);
|
||||
|
||||
}
|
||||
else if (onClick == 'cubCondition') { //Combat Utility Belt conditions
|
||||
if (MODULE.getPermission('TOKEN','CONDITIONS') == false ) return;
|
||||
const condition = settings.cubConditionName;
|
||||
if (condition == undefined || condition == '') return;
|
||||
|
||||
const effect = CONFIG.statusEffects.find(e => e.label === condition);
|
||||
await token.toggleEffect(effect);
|
||||
this.update(tokenId);
|
||||
@@ -800,11 +536,8 @@ export class TokenControl{
|
||||
data.lightAnimation = animation;
|
||||
token.update(data);
|
||||
}
|
||||
else if (game.system.id == 'demonlord' && onClick == 'initiative'){
|
||||
token.actor.update({
|
||||
'data.fastturn': !token.actor.data?.data?.fastturn
|
||||
})
|
||||
|
||||
else if (onClick == 'initiative'){
|
||||
tokenHelper.toggleInitiative(token);
|
||||
}
|
||||
else if (onClick == 'wildcard') { //wildcard images
|
||||
if (MODULE.getPermission('TOKEN','WILDCARD') == false ) return;
|
||||
@@ -851,10 +584,6 @@ export class TokenControl{
|
||||
macroControl.keyPress(settingsNew);
|
||||
}
|
||||
else if (onClick == 'roll') { //roll skill/save/ability
|
||||
const roll = settings.roll ? settings.roll : 'ability';
|
||||
const ability = settings.rollAbility ? settings.rollAbility : 'str';
|
||||
const skill = settings.rollSkill ? settings.rollSkill : 'acr';
|
||||
const save = settings.rollSave ? settings.rollSave : 'str';
|
||||
const rollMode = settings.rollMode ? settings.rollMode : 'default';
|
||||
let options;
|
||||
if (rollMode == 'default')
|
||||
@@ -866,34 +595,7 @@ export class TokenControl{
|
||||
else if (rollMode == 'normal') options = {fastForward:true}
|
||||
else if (rollMode == 'advantage') options = {fastForward:true,advantage:true}
|
||||
else if (rollMode == 'disadvantage') options = {fastForward:true,disadvantage:true}
|
||||
|
||||
if (game.system.id == 'pf2e') {
|
||||
if (roll == 'ability') token.actor.data.data.saves?.[ability].roll(options);
|
||||
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(options);
|
||||
}
|
||||
else if (roll == 'skill') token.actor.data.data.skills?.[skill].roll(options);
|
||||
}
|
||||
if (roll == 'ability') token.actor.rollAbilityTest(ability,options);
|
||||
else if (roll == 'save') {
|
||||
if (game.system.id == 'dnd5e') token.actor.rollAbilitySave(save,options);
|
||||
else token.actor.rollSavingThrow(save,options);
|
||||
}
|
||||
else if (roll == 'skill') token.actor.rollSkill(skill,options);
|
||||
else if (roll == 'initiative') token.actor.rollInitiative(options);
|
||||
else if (roll == 'deathSave') token.actor.rollDeathSave(options);
|
||||
else if (roll == 'grapple') token.actor.rollGrapple(options);
|
||||
else if (roll == 'bab') token.actor.rollBAB(options);
|
||||
else if (roll == 'melee') token.actor.rollMelee(options);
|
||||
else if (roll == 'ranged') token.actor.rollRanged(options);
|
||||
else if (roll == 'cmb') token.actor.rollCMB(options);
|
||||
else if (roll == 'attack') token.actor.rollAttack(options);
|
||||
else if (roll == 'defenses') token.actor.rollDefenses(options);
|
||||
|
||||
tokenHelper.roll(token,settings.roll,options,settings.rollAbility,settings.rollSkill,settings.rollSave)
|
||||
if (otherControls.rollOption != 'dialog') otherControls.setRollOption('normal');
|
||||
}
|
||||
else if (onClick == 'custom') {//custom onClick function
|
||||
@@ -1021,6 +723,26 @@ export class TokenControl{
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
const allItems = token.actor.items;
|
||||
const itemNr = settings.itemNr ? settings.itemNr - 1 : 0;
|
||||
let items = allItems;
|
||||
if (mode == 'inventory') {
|
||||
items = tokenHelper.getItems(token,settings.inventoryType);
|
||||
}
|
||||
else if (mode == 'features') {
|
||||
items = tokenHelper.getFeatures(token,settings.featureType);
|
||||
}
|
||||
else if (mode == 'spellbook') {
|
||||
items = tokenHelper.getSpells(token,settings.spellType);
|
||||
}
|
||||
items = this.sortItems(items);
|
||||
|
||||
const item = items[itemNr];
|
||||
if (item != undefined) item.roll();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
splitCustom(string){
|
||||
const split = string.split('[');
|
||||
|
||||
94
templates/downloadUtility.html
Normal file
@@ -0,0 +1,94 @@
|
||||
<form autocomplete="off" onsubmit="event.preventDefault()">
|
||||
<style>
|
||||
.columnLabel {
|
||||
width:25%;
|
||||
text-align: left;
|
||||
}
|
||||
.columnVersion {
|
||||
width:15%;
|
||||
text-align: left;
|
||||
}
|
||||
.columnOS {
|
||||
width:15%;
|
||||
}
|
||||
.columnButton {
|
||||
width:15%;
|
||||
}
|
||||
.btn {
|
||||
width:100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
<h2>{{localize "MaterialDeck.DownloadUtility.Plugin"}}</h2>
|
||||
|
||||
<table style="width:100%; min-width:400px">
|
||||
<tr>
|
||||
<th class='columnLabel'></th>
|
||||
<th class='columnVersion'>{{localize "MaterialDeck.DownloadUtility.Current"}}</th>
|
||||
<th class='columnVersion'>{{localize "MaterialDeck.DownloadUtility.Minimum"}}</th>
|
||||
<th class='columnVersion'>{{localize "MaterialDeck.DownloadUtility.Latest"}}</th>
|
||||
<th class='columnOS'>{{localize "MaterialDeck.DownloadUtility.OS"}}</th>
|
||||
<th class='columnButton'>{{localize "MaterialDeck.DownloadUtility.Download"}}</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class='columnLabel'>{{localize "MaterialDeck.DownloadUtility.SDplugin"}}</td>
|
||||
<td class='columnVersion'>{{localSdVersion}}</td>
|
||||
<td class='columnVersion'>{{minimumSdVersion}}</td>
|
||||
<td class='columnVersion' id='masterSdVersion'>{{masterSdVersion}}</td>
|
||||
<td class='columnOS'></td>
|
||||
<td class='columnButton'>
|
||||
<button type="button" class='btn' id='downloadSd' {{#if sdDlDisable}}disabled{{/if}}>
|
||||
<i class="fas fa-download"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class='columnLabel'>{{localize "MaterialDeck.DownloadUtility.MSserver"}}</td>
|
||||
<td class='columnVersion'>{{localMsVersion}}</td>
|
||||
<td class='columnVersion'>{{minimumMsVersion}}</td>
|
||||
<td class='columnVersion' id='masterMsVersion'>{{masterMsVersion}}</td>
|
||||
<td class='columnOS'>
|
||||
<select id="os" default="" {{#if msDlDisable}}disabled{{/if}}>
|
||||
<option value="win">{{localize "MaterialDeck.DownloadUtility.Windows"}}</option>
|
||||
<option value="macos">{{localize "MaterialDeck.DownloadUtility.Macos"}}</option>
|
||||
<option value="linux">{{localize "MaterialDeck.DownloadUtility.Linux"}}</option>
|
||||
<option value="source">{{localize "MaterialDeck.DownloadUtility.Source"}}</option>
|
||||
</select>
|
||||
</td>
|
||||
<td class='columnButton'>
|
||||
<button type="button" class='btn' id='downloadMs' {{#if msDlDisable}}disabled{{/if}}>
|
||||
<i class="fas fa-download"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
<h2>{{localize "MaterialDeck.DownloadUtility.Profiles"}}</h2>
|
||||
|
||||
<table style="width:100%; min-width:400px">
|
||||
<tr>
|
||||
<th style='text-align: left;'>{{localize "MaterialDeck.DownloadUtility.Name"}}</th>
|
||||
<th class='columnButton'>{{localize "MaterialDeck.DownloadUtility.Download"}}</th>
|
||||
</tr>
|
||||
<div id='profileContents'>
|
||||
{{#each profiles as |p|}}
|
||||
<tr>
|
||||
<td>{{p.label}}</td>
|
||||
<td class='columnButton'>
|
||||
<button type="button" class='btn' id='dlProfile-{{p.id}}' name='downloadProfile' {{#if ../profileDlDisable}}disabled{{/if}}>
|
||||
<i class="fas fa-download"></i>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</div>
|
||||
</table>
|
||||
|
||||
<button type="button" id='refresh'>
|
||||
<i class="fas fa-redo"></i>
|
||||
{{localize "MaterialDeck.DownloadUtility.Refresh"}}
|
||||
</button>
|
||||
|
||||
</form>
|
||||
12
templates/exportDialog.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<form autocomplete="off" onsubmit="event.preventDefault()">
|
||||
<p>{{content}}</p>
|
||||
|
||||
<div class="form-group">
|
||||
<label>{{localize "MaterialDeck.Filename"}}: </label>
|
||||
<input type="text" name="name" value="{{name}}" id="name" style="width:100%;" >
|
||||
</div>
|
||||
|
||||
<button type="submit" name="submit">
|
||||
<i></i>{{localize "MaterialDeck.Export"}}
|
||||
</button>
|
||||
</form>
|
||||
@@ -17,22 +17,35 @@
|
||||
<a href="https://github.com/CDeenen/MaterialDeck/releases">Module</a><br>
|
||||
<a href="https://github.com/CDeenen/MaterialDeck_SD/releases">Stream Deck</a><br>
|
||||
<a href="https://github.com/CDeenen/MaterialServer/releases">Server</a><br>
|
||||
You can use the download utility in the module settings to download the Stream Deck plugin, Stream Deck profiles and Material Server.
|
||||
|
||||
<h1>Getting Started</h1>
|
||||
Besides installing this module, you also need to install and run some other things.
|
||||
|
||||
<h2>Installing the Stream Deck Software and Plugin</h2>
|
||||
YOu have to download and install the <a href="https://www.elgato.com/en/gaming/downloads">Stream Deck software</a>.
|
||||
You then need to install the plugin. There is a delay between when the plugin get's updated and the update being pushed in the store.
|
||||
If you try to install the plugin right after an update, you might not have the latest version. Manual installation is better in that case.
|
||||
<br>
|
||||
<h3>Stream Deck Store</h3>
|
||||
<ol>
|
||||
<li>Download and install the <a href="https://www.elgato.com/en/gaming/downloads">Stream Deck software</a></li>
|
||||
<li>Download the latest plugin file (com.cdeenen.materialdeck.streamDeckPlugin) from <a href="https://github.com/CDeenen/MaterialDeck_SD/releases">here</a></li>
|
||||
<li>Open the Stream Deck application</li>
|
||||
<li>Press 'More Actions' in the lower right</li>
|
||||
<li>Search (top right) or scroll to find Material Deck</li>
|
||||
<li>Press the 'Install' button</li>
|
||||
</ol>
|
||||
|
||||
<h3>Manually</h3>
|
||||
<ol>
|
||||
<li>Download the latest plugin file using the download utility in the module settings, or download it (com.cdeenen.materialdeck.streamDeckPlugin) from <a href="https://github.com/CDeenen/MaterialDeck_SD/releases">here</a></li>
|
||||
<li>Double-click the file, this should open the Stream Deck software</li>
|
||||
<li>Press 'Install' in the pop-up</li>
|
||||
</ol>
|
||||
|
||||
<h2>Installing the Stream Deck Profile (optional)</h2>
|
||||
<h2>Installing a Stream Deck Profile (optional)</h2>
|
||||
You can create your own profile, but it is recommended to start with one of the pre-made profiles. Currently, there is a profile for the normal and XL Stream Deck variants.
|
||||
<ol>
|
||||
<li>Download the latest profile (ending with .streamDeckProfile) from <a href="https://github.com/CDeenen/MaterialDeck_SD/releases">here</a></li>
|
||||
<li>Download the latest plugin file using the download utility in the module settings, or download one (ending with .streamDeckProfile) from <a href="https://github.com/CDeenen/MaterialDeck_SD/releases">here</a></li>
|
||||
<li>Double-click the file, this should load the profile into the Stream Deck software</li>
|
||||
</ol>
|
||||
|
||||
@@ -55,6 +68,8 @@
|
||||
There are four buttons at the top:
|
||||
<ul>
|
||||
<li>Help</li>
|
||||
<li>User Permission Configuration</li>
|
||||
<li>Download Utility</li>
|
||||
<li>Playlist Configuration</li>
|
||||
<li>Macro Configuration</li>
|
||||
<li>Soundboard Configuration</li>
|
||||
@@ -63,10 +78,7 @@
|
||||
<br>
|
||||
Below the buttons you will find the following settings:
|
||||
<ul>
|
||||
<li><b>Enable Module</b> - Ticking this box enabled the module</li>
|
||||
<li><b>Stream Deck Model</b> - Select the model of your Stream Deck. This is optional, as it only changes the amount of macros and sounds that
|
||||
you can assign in the macro and soundboard configuration screens. If you have a smaller Stream Deck, you might not want to
|
||||
have a screen filled with 64 macros, since you probably won't use that many (you can, if you want to, though)</li>
|
||||
<li><b>Enable Module</b> - Ticking this box enabled the module for the client</li>
|
||||
<li><b>Material Server Address</b> - Fill in the address of Material Server (usually if you run it on the same computer as
|
||||
you're using for Foundry, this can be localhost:3001). This is not necessarily the IP address of Foundry! It is the IP
|
||||
address of the computer that's running Material Server. The default value will work for 99% of people, only change it if
|
||||
@@ -75,6 +87,7 @@
|
||||
This improves the update speed, but increases memory usage.</li>
|
||||
<li><b>Image Brightness</b> - Sets the brightness of the default white images for better readibility of the text. If Image Cache Size is large, it'll take a while for
|
||||
the new brightness setting to be applied. A refresh will give instantaneous results.</li>
|
||||
<li><b>Number of Connection Warnings</b> - Sets the number of times you will get a warning when Material Deck cannot connect to Material Server. Will be unlimited if set to 0.</li>
|
||||
</ul>
|
||||
|
||||
<BR CLEAR="right" />
|
||||
@@ -89,6 +102,17 @@
|
||||
|
||||
<BR CLEAR="right" />
|
||||
|
||||
<h2>Download Utility</h2>
|
||||
<img src="modules/MaterialDeck/wiki/img/DownloadUtility.png" align="right" HSPACE="5" width="350">
|
||||
The download utility allows you to easily check the current version of the Stream Deck plugin and Material Server, and gives you the option to download the latest version.<br>
|
||||
Please note that the current version of Material Server is at the moment not supported.<br>
|
||||
<br>
|
||||
At the bottom you can also download the default profiles from <a href="https://github.com/CDeenen/MaterialDeck_SD/releases">Github</a><div class=""></div><br>
|
||||
<br>
|
||||
The refresh button at the bottom refreshes the page in case there was a connection issue.
|
||||
|
||||
<BR CLEAR="right" />
|
||||
|
||||
<h2>Playlist Configuration</h2>
|
||||
<img src="modules/MaterialDeck/wiki/img/PlaylistConfig.png" align="right" HSPACE="5" width="350">
|
||||
The playlist configuration screen configures the playlists that you control using the <a href="https://github.com/CDeenen/MaterialDeck/wiki/Playlist-Action">Playlist action</a>.<br>
|
||||
@@ -119,10 +143,11 @@
|
||||
<b>Note:</b> While you can assign the same playlist to multiple playlists in this configuration screen, only the play method of the first instance will be applied.
|
||||
|
||||
<h2>Macro Configuration</h2>
|
||||
The Macro Configuration screen is to configure the macro board for the <a href="https://github.com/CDeenen/MaterialDeck/wiki/Macro-Action">Macro action</a>.<br>
|
||||
The Macro Configuration screen is to configure the macroboard for the <a href="https://github.com/CDeenen/MaterialDeck/wiki/Macro-Action">Macro action</a>.<br>
|
||||
<br>
|
||||
The screen is divided into a number of boxes, each labeled 'Macro #', where each represents a single macro and its settings. The number of macros you can see
|
||||
depends on what Stream Deck model you've set up in the module configuration.<br>
|
||||
The screen is divided into 32 boxes, each labeled 'Macro #', where each represents a single macro and its settings. This screen will be refered to as a page.
|
||||
By pressing the arrows at the top right and top left, you can go to the next or previous page. There is no limit to the amount of pages you can add, but if you
|
||||
have a lot of pages, at some point you might notice some performance issues.<br>
|
||||
<br>
|
||||
For each macro there are 3 options:
|
||||
<ul>
|
||||
@@ -134,13 +159,25 @@
|
||||
<li><b>Background</b> - Color picker to set the background color of the Stream Deck button</li>
|
||||
</ul>
|
||||
|
||||
<br>
|
||||
At the bottom you have the following buttons:
|
||||
<ul>
|
||||
<li><b>Clear Page</b> - Clears all the macros on the current page. Please note that this is irreversible.</li>
|
||||
<li><b>Clear All</b> - Clears all the macros. Please note that this is irreversible.</li>
|
||||
<li><b>Import</b> - Import the macroboard from a file. This will override your current macroboard, and is irreversible.</li>
|
||||
<li><b>Export</b> - Export your macroboard to a file.</li>
|
||||
</ul>
|
||||
When importing and exporting, you only import/export the metadata, not the actual macros. This means that you need to have the same macros in both the source and target Foundry client,
|
||||
or you might run into issues.
|
||||
|
||||
<img src="modules/MaterialDeck/wiki/img/MacroConfig.png" align="center" HSPACE="5" width="100%">
|
||||
|
||||
<h2>Soundboard Configuration</h2>
|
||||
The Soundboard Configuration screen is used to configure the soundboard for the <a href="https://github.com/CDeenen/MaterialDeck/wiki/Soundboard-Action">Soundboard action</a>.<br>
|
||||
<br>
|
||||
Similar to the Macro Configuration screen, the screen is divided into a number of boxes, each labeled 'Sound #', where each represents a single sound and its settings.
|
||||
The number of sounds you can see depends on what Stream Deck model you've set up in the module configuration.<br>
|
||||
Similar to the Macro Configuration screen, the screen is divided into boxes, each labeled 'Sound #', where each represents a single sound and its settings. This screen will be refered to as a page.
|
||||
By pressing the arrows at the top right and top left, you can go to the next or previous page. There is no limit to the amount of pages you can add, but if you
|
||||
have a lot of pages, at some point you might notice some performance issues.<br>
|
||||
<br>
|
||||
For each sound there are multiple options:
|
||||
<ul>
|
||||
@@ -166,6 +203,17 @@
|
||||
<li><b>Volume</b> - The playback volume of the sound. The final playback volume is also determined by the Interface Volume slider in Foundry's 'Audio Playlists' tab.</li>
|
||||
</ul>
|
||||
|
||||
<br>
|
||||
At the bottom you have the following buttons:
|
||||
<ul>
|
||||
<li><b>Clear Page</b> - Clears all the sounds on the current page. Please note that this is irreversible.</li>
|
||||
<li><b>Clear All</b> - Clears all the sounds. Please note that this is irreversible.</li>
|
||||
<li><b>Import</b> - Import the soundboard from a file. This will override your current soundboard, and is irreversible.</li>
|
||||
<li><b>Export</b> - Export your soundboard to a file.</li>
|
||||
</ul>
|
||||
When importing and exporting, you only import/export the metadata, not the actual audio files. This means that you need to have the same audio files in the same relative location in both the source and target Foundry client,
|
||||
or you might run into issues.
|
||||
|
||||
<img src="modules/MaterialDeck/wiki/img/SoundboardConfig.png" align="center" HSPACE="5" width="100%">
|
||||
|
||||
<h1>Customization</h1>
|
||||
@@ -183,7 +231,6 @@
|
||||
<li><a href="https://github.com/CDeenen/MaterialDeck/wiki/Combat-Tracker-Action">Combat Tracker Action</a></li>
|
||||
<li><a href="https://github.com/CDeenen/MaterialDeck/wiki/External-Modules">External Modules</a></li>
|
||||
<li><a href="https://github.com/CDeenen/MaterialDeck/wiki/Macro-Action">Macro Action</a></li>
|
||||
<li><a href="https://github.com/CDeenen/MaterialDeck/wiki/Move-Action">Move Action</a></li>
|
||||
<li><a href="https://github.com/CDeenen/MaterialDeck/wiki/Other-Actions">Other Actions</a></li>
|
||||
<li><a href="https://github.com/CDeenen/MaterialDeck/wiki/Playlist-Action">Playlist Action</a></li>
|
||||
<li><a href="https://github.com/CDeenen/MaterialDeck/wiki/Scene-Action">Scene Action</a></li>
|
||||
@@ -191,10 +238,6 @@
|
||||
<li><a href="https://github.com/CDeenen/MaterialDeck/wiki/Token-Action">Token Action</a></li>
|
||||
</ul>
|
||||
|
||||
<h1>Software Versions & Module Incompatibilities</h1>
|
||||
<b>Foundry VTT:</b> Tested on 0.7.9<br>
|
||||
<b>Module Incompatibilities:</b> None known.<br>
|
||||
|
||||
<h1>Feedback</h1>
|
||||
If you have any suggestions or bugs to report, feel free to create an issue, contact me on Discord (Cris#6864), or send me an email: cdeenen@outlook.com.
|
||||
|
||||
|
||||
13
templates/importDialog.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<form autocomplete="off" onsubmit="event.preventDefault()">
|
||||
<p>{{content}}</p>
|
||||
<p><b>{{ localize "MaterialDeck.ImportDialog.Warning" }}</b></p>
|
||||
|
||||
<div class="form-group upload-file">
|
||||
<label><i class="fas fa-upload fa-fw"></i> {{ localize "FILES.Upload" }}</label>
|
||||
<input type="file" name="upload" id="uploadJson">
|
||||
</div>
|
||||
|
||||
<button type="submit" name="submit">
|
||||
<i></i>{{localize "MaterialDeck.Import"}}
|
||||
</button>
|
||||
</form>
|
||||
@@ -6,8 +6,25 @@
|
||||
max-width: 166px;
|
||||
height: {{height}}px;
|
||||
}
|
||||
.navigation {
|
||||
flex:1;
|
||||
max-width: 8%;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="navigationDiv" style="width:100%; display:flex; flex-direction:row;">
|
||||
<button type="button" class="navigation" id="navPrev" {{prevDisabled}}>
|
||||
<i class="fas fa-arrow-left"></i>
|
||||
</button>
|
||||
<p style="width:84%; text-align:center; padding: 0px 0; font-size: 20px"><b>
|
||||
{{localize "MaterialDeck.Perm.MACRO.label"}}: {{macroRange}} {{localize "MaterialDeck.Of"}} {{totalMacros}}
|
||||
</b></p>
|
||||
<button type="button" class="navigation" id="navNext">
|
||||
<i class="fas fa-arrow-right"></i>
|
||||
</button>
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
{{#each macroData}}
|
||||
<div class="form-group" style="width:100%">
|
||||
{{#each this.dataThis}}
|
||||
@@ -16,7 +33,7 @@
|
||||
{{localize "MaterialDeck.Macro"}} {{this.iteration}}
|
||||
</div>
|
||||
<div>
|
||||
<select name="macros" class="macros-select" id="macros{{this.iteration}}" default="" style="max-width:140px;">
|
||||
<select name="macros" class="macros-select" id="macros{{this.iteration}}" default="" style="width:100%;">
|
||||
{{#select this.macro}}
|
||||
<option value="">{{localize "MaterialDeck.None"}}</option>
|
||||
{{#each ../../macros}}
|
||||
@@ -38,4 +55,20 @@
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/each}}
|
||||
<hr>
|
||||
<div class="navigationDiv" style="width:100%; display:flex; flex-direction:row;">
|
||||
<button type="button" class="navigation" id="clearPage">
|
||||
<i></i>{{localize "MaterialDeck.ClearPage"}}
|
||||
</button>
|
||||
<button type="button" class="navigation" id="clearAll">
|
||||
<i></i>{{localize "MaterialDeck.ClearAll"}}
|
||||
</button>
|
||||
<p style="width:68%;"></p>
|
||||
<button type="button" class="navigation" id="import">
|
||||
<i></i>{{localize "MaterialDeck.Import"}}
|
||||
</button>
|
||||
<button type="button" class="navigation" id="export">
|
||||
<i></i>{{localize "MaterialDeck.Export"}}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -6,8 +6,25 @@
|
||||
max-width: 166px;
|
||||
height: 300px;
|
||||
}
|
||||
|
||||
.navigation {
|
||||
flex:1;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="navigation" style="width:100%; display:flex; flex-direction:row;">
|
||||
<button type="button" class="navigation" id="navPrev" {{prevDisabled}}>
|
||||
<i class="fas fa-arrow-left"></i>
|
||||
</button>
|
||||
<p style="flex:15; text-align:center; padding: 0px 0; font-size: 20px"><b>
|
||||
{{localize "MaterialDeck.Sounds"}}: {{soundRange}} {{localize "MaterialDeck.Of"}} {{totalSounds}}
|
||||
</b></p>
|
||||
<button type="button" class="navigation" id="navNext">
|
||||
<i class="fas fa-arrow-right"></i>
|
||||
</button>
|
||||
</div>
|
||||
<hr>
|
||||
|
||||
{{#each soundData}}
|
||||
<div class="form-group" style="width:100%">
|
||||
{{#each this.dataThis}}
|
||||
@@ -87,4 +104,20 @@
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/each}}
|
||||
<hr>
|
||||
<div class="navigation" style="width:100%; display:flex; flex-direction:row;">
|
||||
<button type="button" class="navigation" id="clearPage">
|
||||
<i></i>{{localize "MaterialDeck.ClearPage"}}
|
||||
</button>
|
||||
<button type="button" class="navigation" id="clearAll">
|
||||
<i></i>{{localize "MaterialDeck.ClearAll"}}
|
||||
</button>
|
||||
<p style="flex:15;"></p>
|
||||
<button type="button" class="navigation" id="import">
|
||||
<i></i>{{localize "MaterialDeck.Import"}}
|
||||
</button>
|
||||
<button type="button" class="navigation" id="export">
|
||||
<i></i>{{localize "MaterialDeck.Export"}}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
BIN
wiki/img/DownloadUtility.png
Normal file
|
After Width: | Height: | Size: 230 KiB |
|
Before Width: | Height: | Size: 481 KiB After Width: | Height: | Size: 584 KiB |
|
Before Width: | Height: | Size: 321 KiB After Width: | Height: | Size: 363 KiB |
|
Before Width: | Height: | Size: 598 KiB After Width: | Height: | Size: 622 KiB |