Compare commits
52 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8cf974455a | ||
|
|
e7e9b84227 | ||
|
|
108c955ac2 | ||
|
|
4d320a5f6c | ||
|
|
ccacd3e26e | ||
|
|
d3c2c6465d | ||
|
|
bc0804bc08 | ||
|
|
49bc188dde | ||
|
|
dce419d7c3 | ||
|
|
4566b8ef53 | ||
|
|
1f55b324c5 | ||
|
|
a6a6cd170e | ||
|
|
cc8588bf4d | ||
|
|
117a1fb59d | ||
|
|
888a2971fb | ||
|
|
c74d27610a | ||
|
|
f4d02cf296 | ||
|
|
874d9c8fb6 | ||
|
|
66b8406615 | ||
|
|
e6c54a2b13 | ||
|
|
c01f9ec566 | ||
|
|
7bd06d7797 | ||
|
|
2fd5f81891 | ||
|
|
e8df118ce1 | ||
|
|
6e22fef160 | ||
|
|
3a52ed28b4 | ||
|
|
6c840cbf59 | ||
|
|
e58d9ca757 | ||
|
|
ce28b2da97 | ||
|
|
9c1f549791 | ||
|
|
28212f03e2 | ||
|
|
22debde812 | ||
|
|
26afbae66b | ||
|
|
a5655f46dd | ||
|
|
b4fe337824 | ||
|
|
69442aec39 | ||
|
|
9e12b7cd84 | ||
|
|
5c6a4a4223 | ||
|
|
57812d0863 | ||
|
|
560c3a573f | ||
|
|
cffa2318f7 | ||
|
|
ec207fa658 | ||
|
|
9ffa796eeb | ||
|
|
2dcbfbe096 | ||
|
|
87a031ae44 | ||
|
|
63bda666b5 | ||
|
|
6b8ca86fe2 | ||
|
|
efbbdf7760 | ||
|
|
3b30f7d439 | ||
|
|
318c16d013 | ||
|
|
1dcdcd9c0b | ||
|
|
cf95255a47 |
12
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: MaterialFoundry
|
||||
open_collective: # Replace with a single Open Collective username
|
||||
ko_fi: materialfoundry
|
||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
||||
liberapay: # Replace with a single Liberapay username
|
||||
issuehunt: # Replace with a single IssueHunt username
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
||||
28
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: "[BUG]"
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Setup**
|
||||
- OS: [e.g. windows]
|
||||
- Browser: [e.g. chrome, safari, Foundry app]
|
||||
- Module version: [e.g. 1.2.5]
|
||||
- Foundry version: [e.g. 0.8.6]
|
||||
- Gaming system & version: [e.g. dnd5e 1.3.3]
|
||||
- Any other modules enabled: [yes/no]
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Console Log**
|
||||
Please check the console (F12) to see if there are any errors and also include them.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: "[FEATURE]"
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
10
.github/ISSUE_TEMPLATE/other-issues.md
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
name: Other issues
|
||||
about: For any other issues
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
|
||||
40
DEVGUIDE.md
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
# Dev Guide
|
||||
|
||||
In addition to this repo, you will also need to check out the [MaterialDeck_SD github repo](https://github.com/CDeenen/MaterialDeck_SD).
|
||||
|
||||
## Module Development
|
||||
|
||||
### Make a new system.js file
|
||||
|
||||
In the [src/systems](src/systems) directory, create a new system file by copying and pasting a similar system to it; for example, `cp demonlord.js wfrp4.js`
|
||||
You then need to go through all the functions in there and make sure that the correct data is set.
|
||||
|
||||
### Update TokenHelper
|
||||
In [src/systems/TokenHelper.js](src/systems/TokenHelper.js), you need to add an `import {}` for your new system.
|
||||
|
||||
In the same file, in the setSystem() function, you need to wire in your system to the if/else block.
|
||||
|
||||
## Debugging
|
||||
|
||||
It's possible to debug on the Stream Deck, so you can do `console.log`. Just follow the instructions [from elgato here](https://developer.elgato.com/documentation/stream-deck/sdk/create-your-own-plugin/). After editing the code for the plugin, you need to either refresh by refreshing the debug window, or by deselecting the current button, and selecting it again.
|
||||
|
||||
When you go to the debugging page, there should be multiple options. With the property inspector open, you should connect to the one with property inspector in its name. If you go to to propertyinspector/js/common.js, near the top there's the debugEn variable. Set it to true, and you should get tons of messages, especially if you change any settings.
|
||||
In the module, in MaterialDeck.js, at line 60, there's //console.log("Received",data);. If you uncomment that, it'll log everything that's send from the SD to the module. Might be helpful for debugging.
|
||||
|
||||
|
||||
## Streamdeck
|
||||
|
||||
To enable logging on the streamdeck, [follow these instructions](https://developer.elgato.com/documentation/stream-deck/sdk/create-your-own-plugin/) from Elgato.
|
||||
|
||||
The plugin in Windows is located at (Windows) `AppData/Roaming/Elgato/StreamDeck/Plugins/com.cdeenen.materialdeck.sdPlugin`
|
||||
In `propertyinspector/js/common.js::getStats()` there are various functions that are used to get the relevant options to show up in the SD plugin. Each array element has a value and a name, you should keep the value the same, but the name can be whatever you like. I think you'll be able to figure out how to add stuff for wfrp by looking at the others.
|
||||
|
||||
|
||||
## Property discovery
|
||||
In a Foundry client browser instance, if you go to the dev console, you can browser your tokens via the `canvas.tokens` path, for example `canvas.tokens.children[0].children[0].actor.data`.
|
||||
|
||||
## Module Deployment
|
||||
If you make changes to files in this project, you'll need to copy the changed files to your Foundry install folder, probably found here: `C:\Users\$USER\AppData\Local\FoundryVTT\Data\modules\MaterialDeck`.
|
||||
|
||||
If you change the `MaterialDeck_SD` code (for example, `propertyinspector\js\common.js`), you will need to copy that file to the Elgato streamdeck plugins directory, probably found here: `C:\Users\$USER\AppData\Roaming\Elgato\StreamDeck\Plugins\com.cdeenen.materialdeck.sdPlugin`.
|
||||
118
MaterialDeck.js
@@ -23,6 +23,8 @@ export var tokenHelper;
|
||||
|
||||
export const moduleName = "MaterialDeck";
|
||||
|
||||
export let gamingSystem = "dnd5e";
|
||||
|
||||
let ready = false;
|
||||
|
||||
export let hotbarUses = false;
|
||||
@@ -32,6 +34,8 @@ let controlTokenTimer;
|
||||
|
||||
export let sdVersion;
|
||||
export let msVersion;
|
||||
|
||||
let updateDialog;
|
||||
|
||||
//CONFIG.debug.hooks = true;
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -63,7 +67,7 @@ async function analyzeWSmessage(msg){
|
||||
const msg = {
|
||||
target: "SD",
|
||||
type: "init",
|
||||
system: game.system.id
|
||||
system: gamingSystem
|
||||
}
|
||||
ws.send(JSON.stringify(msg));
|
||||
|
||||
@@ -86,8 +90,8 @@ async function analyzeWSmessage(msg){
|
||||
|
||||
sdVersion = data.version;
|
||||
|
||||
if (data.version < minimumSDversion) {
|
||||
let d = new Dialog({
|
||||
if (data.version < minimumSDversion && updateDialog == undefined) {
|
||||
updateDialog = new Dialog({
|
||||
title: "Material Deck: Update Needed",
|
||||
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: {
|
||||
@@ -103,19 +107,24 @@ async function analyzeWSmessage(msg){
|
||||
},
|
||||
default: "download"
|
||||
});
|
||||
d.render(true);
|
||||
updateDialog.render(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.type == 'newDevice') {
|
||||
streamDeck.newDevice(data.iteration,data.device);
|
||||
return;
|
||||
}
|
||||
|
||||
if (data == undefined || data.payload == undefined) return;
|
||||
//console.log("Received",data);
|
||||
const action = data.action;
|
||||
const event = data.event;
|
||||
const context = data.context;
|
||||
const coordinates = data.payload.coordinates;
|
||||
const settings = data.payload.settings;
|
||||
const device = data.device;
|
||||
|
||||
const name = data.deviceName;
|
||||
const type = data.deviceType;
|
||||
|
||||
if (data.data == 'init'){
|
||||
|
||||
@@ -123,7 +132,9 @@ async function analyzeWSmessage(msg){
|
||||
if (event == 'willAppear' || event == 'didReceiveSettings'){
|
||||
if (coordinates == undefined) return;
|
||||
streamDeck.setScreen(action);
|
||||
await streamDeck.setContext(device,data.size,data.deviceIteration,action,context,coordinates,settings);
|
||||
await streamDeck.setContext(device,data.size,data.deviceIteration,action,context,coordinates,settings,name,type);
|
||||
|
||||
if (game.settings.get(moduleName, 'devices')?.[device]?.enable == false) return;
|
||||
|
||||
if (action == 'token'){
|
||||
tokenControl.active = true;
|
||||
@@ -151,6 +162,8 @@ async function analyzeWSmessage(msg){
|
||||
}
|
||||
|
||||
else if (event == 'keyDown'){
|
||||
if (game.settings.get(moduleName, 'devices')?.[device]?.enable == false) return;
|
||||
|
||||
if (action == 'token')
|
||||
tokenControl.keyPress(settings);
|
||||
else if (action == 'macro')
|
||||
@@ -170,6 +183,8 @@ async function analyzeWSmessage(msg){
|
||||
}
|
||||
|
||||
else if (event == 'keyUp'){
|
||||
if (game.settings.get(moduleName, 'devices')?.[device]?.enable == false) return;
|
||||
|
||||
if (action == 'soundboard'){
|
||||
soundboard.keyPressUp(settings);
|
||||
}
|
||||
@@ -209,7 +224,7 @@ function startWebsocket() {
|
||||
const msg2 = {
|
||||
target: "SD",
|
||||
type: "init",
|
||||
system: game.system.id
|
||||
system: gamingSystem
|
||||
}
|
||||
ws.send(JSON.stringify(msg2));
|
||||
clearInterval(wsInterval);
|
||||
@@ -225,19 +240,22 @@ let messageCount = 0;
|
||||
*/
|
||||
function resetWS(){
|
||||
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);
|
||||
if (wsOpen) {
|
||||
ui.notifications.warn("Material Deck: "+game.i18n.localize("MaterialDeck.Notifications.Disconnected"));
|
||||
wsOpen = false;
|
||||
messageCount = 0;
|
||||
WSconnected = false;
|
||||
startWebsocket();
|
||||
}
|
||||
else if (ws.readyState == 3){
|
||||
if (maxMessages == 0 || maxMessages > messageCount) {
|
||||
messageCount++;
|
||||
const countString = maxMessages == 0 ? "" : " (" + messageCount + "/" + maxMessages + ")";
|
||||
ui.notifications.warn("Material Deck: "+game.i18n.localize("MaterialDeck.Notifications.ConnectFail") + countString);
|
||||
}
|
||||
WSconnected = false;
|
||||
startWebsocket();
|
||||
}
|
||||
|
||||
WSconnected = false;
|
||||
startWebsocket();
|
||||
}
|
||||
|
||||
export function sendWS(txt){
|
||||
@@ -275,8 +293,9 @@ Hooks.once('ready', async()=>{
|
||||
registerSettings();
|
||||
enableModule = (game.settings.get(moduleName,'Enable')) ? true : false;
|
||||
|
||||
|
||||
|
||||
const systemOverride = game.settings.get(moduleName,'systemOverride');
|
||||
gamingSystem = systemOverride != '' ? systemOverride : game.system.id;
|
||||
|
||||
soundboard = new SoundboardControl();
|
||||
streamDeck = new StreamDeck();
|
||||
tokenControl = new TokenControl();
|
||||
@@ -365,12 +384,6 @@ Hooks.once('ready', async()=>{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (enableModule == false) return;
|
||||
if (getPermission('ENABLE') == false) {
|
||||
ready = true;
|
||||
@@ -383,6 +396,11 @@ Hooks.once('ready', async()=>{
|
||||
if (hotbarUsesTemp != undefined) hotbarUses = true;
|
||||
});
|
||||
|
||||
function updateActor(id) {
|
||||
const token = tokenHelper.getTokenFromActorId(id)
|
||||
tokenControl.update(token.id);
|
||||
}
|
||||
|
||||
Hooks.on('updateToken',(scene,token)=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
let tokenId = token._id;
|
||||
@@ -390,21 +408,30 @@ Hooks.on('updateToken',(scene,token)=>{
|
||||
if (macroControl != undefined) macroControl.updateAll();
|
||||
});
|
||||
|
||||
Hooks.on('updateActor',(scene,actor)=>{
|
||||
Hooks.on('updateActor',(actor)=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
let children = canvas.tokens.children[0].children;
|
||||
for (let i=0; i<children.length; i++){
|
||||
if (children[i].actor.id == actor._id){
|
||||
let tokenId = children[i].id;
|
||||
if (tokenId == canvas.tokens.controlled[0]?.id) {
|
||||
tokenControl.update(canvas.tokens.controlled[0]?.id);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
updateActor(actor.id);
|
||||
if (macroControl != undefined) macroControl.updateAll();
|
||||
});
|
||||
|
||||
Hooks.on('createActiveEffect',(data)=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
updateActor(data.parent.id);
|
||||
return;
|
||||
});
|
||||
|
||||
Hooks.on('deleteActiveEffect',(data)=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
updateActor(data.parent.id);
|
||||
return;
|
||||
});
|
||||
|
||||
Hooks.on('onActorSetCondition',(data)=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
updateActor(data.actor.id);
|
||||
return;
|
||||
});
|
||||
|
||||
Hooks.on('controlToken',(token,controlled)=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
if (controlled) {
|
||||
@@ -472,6 +499,10 @@ Hooks.on('renderSidebarTab',(app)=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
if (otherControls != undefined) otherControls.updateAll(options);
|
||||
if (sceneControl != undefined) sceneControl.updateAll();
|
||||
if (document.getElementsByClassName("roll-type-select")[0] != undefined)
|
||||
document.getElementsByClassName("roll-type-select")[0].addEventListener('change',function(){
|
||||
if (otherControls != undefined) otherControls.updateAll(options);
|
||||
})
|
||||
});
|
||||
|
||||
Hooks.on('closeSidebarTab',(app)=>{
|
||||
@@ -571,6 +602,11 @@ Hooks.on('about-time.clockRunningStatus', ()=>{
|
||||
externalModules.updateAll();
|
||||
})
|
||||
|
||||
Hooks.on('updateTile',()=>{
|
||||
if (enableModule == false || ready == false) return;
|
||||
externalModules.updateAll();
|
||||
});
|
||||
|
||||
Hooks.once('init', ()=>{
|
||||
//CONFIG.debug.hooks = true;
|
||||
//registerSettings(); //in ./src/settings.js
|
||||
@@ -578,4 +614,8 @@ Hooks.once('init', ()=>{
|
||||
|
||||
Hooks.once('canvasReady',()=>{
|
||||
ready = true;
|
||||
});
|
||||
|
||||
Hooks.on("soundscape", (data) => {
|
||||
externalModules.newSoundscapeData(data);
|
||||
});
|
||||
@@ -69,6 +69,9 @@ Module manifest: https://raw.githubusercontent.com/CDeenen/MaterialDeck/Master/m
|
||||
<b>Foundry VTT:</b> Tested on 0.7.9 - 0.8.5<br>
|
||||
<b>Module Incompatibilities:</b> None known.<br>
|
||||
|
||||
## Developer Guide
|
||||
See the [developer guide](./DEVGUIDE.md) for a guide on how to add new systems to `MaterialDeck`.
|
||||
|
||||
## Feedback
|
||||
If you have any suggestions or bugs to report, feel free to create an issue, contact me on Discord (Cris#6864), or send me an email: cdeenen@outlook.com.
|
||||
|
||||
@@ -79,6 +82,7 @@ Special thanks to Asmodeus#7588 who made this module possible by generously dona
|
||||
<br>
|
||||
Please consider supporting me on <a href="https://www.patreon.com/materialfoundry">Patreon</a>, and feel free to join the Material Foundry <a href="https://discord.gg/3hd4G6TkmA">Discord</a> server.
|
||||
|
||||
|
||||
## Abandonment
|
||||
Abandoned modules are a (potential) problem for Foundry, because users and/or other modules might rely on abandoned modules, which might break in future Foundry updates.<br>
|
||||
I consider this module abandoned if all of the below cases apply:
|
||||
|
||||
81
changelog.md
@@ -1,4 +1,85 @@
|
||||
# Changelog Material Deck Module
|
||||
### v1.4.9 - 16-04-2022
|
||||
Fixes:
|
||||
<ul>
|
||||
<li>PF2e: Fixed rolls and conditions for compatibility with latest pf2e version. Thanks to Kyamsil</li>
|
||||
<li>Token Action => Set Vison: Setting light is working again</li>
|
||||
<li>Other Actions => Roll Dice: Roll result would show as 'NaN' in Foundry v9, this is fixed</li>
|
||||
</ul>
|
||||
|
||||
Additions:
|
||||
<ul>
|
||||
<li>Added support for the Starfinder system</li>
|
||||
<li>External Modules => Added support for 'Monks Active Tile Triggers'</li>
|
||||
<li>Added 'System Override' module setting. If your system is not supported, MD defaults to 5e. Here you can choose a supported system that is most similar to yours and have Material Deck use that system instead.</li>
|
||||
<li>Token Action => Displayed Stats: A colored border is drawn around certain skills, saves, etc to indicate proficiency (compatible systems: dnd5e, pf2e). Thanks to Kyamsil</li>
|
||||
</ul>
|
||||
|
||||
### v1.4.8 - 22-12-2021
|
||||
Fixes:
|
||||
<ul>
|
||||
<li>'Device Configuration' would not save its settings properly</li>
|
||||
</ul>
|
||||
|
||||
|
||||
### v1.4.7 - 20-12-2021
|
||||
Fixes:
|
||||
<ul>
|
||||
<li>External Modules => GM Screen: Changed to new api (thanks to akrigline)</li>
|
||||
<li>Fixed an issue where SDs would not iterate properly, causing errors (thanks to InnerGI)</li>
|
||||
<li>Fixed support for FXMaster. Requires FXMaster v2.0.0 or later (not officially released yet)</li>
|
||||
</ul>
|
||||
|
||||
Additions:
|
||||
<ul>
|
||||
<li>Added compatibility for Foundry V0.9</li>
|
||||
<li>Added Forbidden Lands system (thanks to JackDCondon)</li>
|
||||
<li>Other Controls => Control Buttons: Added offset for 'Displayed Controls' and 'Displayed Tools'</li>
|
||||
<li>Added 'Device Configuration' to the module settings. You can use this to configure specific SD devices to not connect to a client</li>
|
||||
<li>Playlist Action => Added option to play next or previous track</li>
|
||||
</ul>
|
||||
|
||||
### v1.4.6 - 07-09-2021
|
||||
Fixes:
|
||||
<ul>
|
||||
<li>Token Action => Move token: If the user is not the GM, tokens can no longer move if game is paused, and they can no longer move through walls</li>
|
||||
<li>Modifications made in the Property Inspector now immediately get saved, instead of when user deselects the setting (changed 'onchange' to 'oninput' event)</li>
|
||||
</ul>
|
||||
|
||||
Additions:
|
||||
<ul>
|
||||
<li>Playlist Action: Added a 'Pause All' option</li>
|
||||
</ul>
|
||||
|
||||
Other:
|
||||
<ul>
|
||||
<li>PF2E compatibility updated (thanks @kyamsil)</li>
|
||||
</ul>
|
||||
|
||||
### v1.4.5 - 27-07-2021
|
||||
Fixes:
|
||||
<ul>
|
||||
<li>Combat Tracker Action => Turn Display: If only 'Display Round' was enabled, the vertical alignment would be off. This has been fixed.</li>
|
||||
<li>WebSocket client no longer creates duplicate connections</li>
|
||||
<li>Token Action => If 'Display Uses/Quantity' is enabled for an item that has no maximum uses/quantity, the uses/quantity border is now consistently black.</li>
|
||||
<li>Update dialog that appears if the SD plugin needs to be updated now only appears once</li>
|
||||
</ul>
|
||||
|
||||
Additions:
|
||||
<ul>
|
||||
<li>External Modules: Added support for the Soundscape module. Requires Soundscape v1.0.3</li>
|
||||
<li>Macro Action => Advanced Macros is now supported for calling macros with arguments</li>
|
||||
<li>Combat Tracker Action => Function: Added option to select the combatant after changing the turn</li>
|
||||
<li>Other Actions => Added 'Set Roll Mode' which sets the roll mode for all rolls to public, private gm, blind gm or self roll</li>
|
||||
<li>Added support for wfrp4e (thanks to sozin#8622 & eccobold#3541)</li>
|
||||
<li>Added DEVGUIDE.md to help developers add support for new systems (thanks to sozin#8622 & eccobold#3541)</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.5 (<b>must be updated!</b>): https://github.com/CDeenen/MaterialDeck_SD/releases<br>
|
||||
|
||||
### v1.4.4 - 26-05-2021
|
||||
Fixes:
|
||||
<ul>
|
||||
|
||||
BIN
img/playlist/.thumb/pause.png.jpg
Normal file
|
After Width: | Height: | Size: 2.9 KiB |
@@ -1,2 +1,3 @@
|
||||
play.png: Edited from https://fontawesome.com/icons/play?style=solid
|
||||
stop.png: Edited from https://fontawesome.com/icons/stop?style=solid
|
||||
stop.png: Edited from https://fontawesome.com/icons/stop?style=solid
|
||||
pause.png: Edited from https://fontawesome.com/v5.15/icons/pause?style=solid
|
||||
BIN
img/playlist/pause.png
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
img/token/abilities/.thumb/fort.png.jpg
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
img/token/abilities/.thumb/ref.png.jpg
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
img/token/abilities/.thumb/will.png.jpg
Normal file
|
After Width: | Height: | Size: 8.9 KiB |
@@ -4,4 +4,7 @@ dex.png: https://game-icons.net/1x1/darkzaitzev/acrobatic.html
|
||||
cons.png: https://game-icons.net/1x1/zeromancer/heart-plus.html
|
||||
int.png: https://game-icons.net/1x1/lorc/bookmarklet.html
|
||||
wis.png: https://game-icons.net/1x1/delapouite/wisdom.html
|
||||
cha.png: https://game-icons.net/1x1/lorc/icicles-aura.html
|
||||
cha.png: https://game-icons.net/1x1/lorc/icicles-aura.html
|
||||
fort.png: https://game-icons.net/1x1/delapouite/rock-golem.html
|
||||
ref.png: https://game-icons.net/1x1/lorc/dodging.html
|
||||
will.png: https://game-icons.net/1x1/lorc/meditation.html
|
||||
BIN
img/token/abilities/fort.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
img/token/abilities/ref.png
Normal file
|
After Width: | Height: | Size: 25 KiB |
BIN
img/token/abilities/will.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
img/token/skills/.thumb/cra.png.jpg
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
BIN
img/token/skills/.thumb/dip.png.jpg
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
img/token/skills/.thumb/lor.png.jpg
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
img/token/skills/.thumb/occ.png.jpg
Normal file
|
After Width: | Height: | Size: 11 KiB |
BIN
img/token/skills/.thumb/soc.png.jpg
Normal file
|
After Width: | Height: | Size: 8.5 KiB |
BIN
img/token/skills/.thumb/thi.png.jpg
Normal file
|
After Width: | Height: | Size: 12 KiB |
@@ -3,17 +3,23 @@ acr.png: https://game-icons.net/1x1/delapouite/contortionist.html
|
||||
ani.png: https://game-icons.net/1x1/delapouite/cavalry.html
|
||||
arc.png: https://game-icons.net/1x1/delapouite/spell-book.html
|
||||
ath.png: https://game-icons.net/1x1/lorc/muscle-up.html
|
||||
cra.png: https://game-icons.net/1x1/lorc/sword-smithing.html
|
||||
dec.png: https://game-icons.net/1x1/delapouite/convince.html
|
||||
dip.png: https://game-icons.net/1x1/delapouite/shaking-hands.html
|
||||
his.png: https://game-icons.net/1x1/delapouite/backward-time.html
|
||||
ins.png: https://game-icons.net/1x1/lorc/light-bulb.html
|
||||
itm.png: https://game-icons.net/1x1/lorc/one-eyed.html
|
||||
inv.png: https://game-icons.net/1x1/lorc/magnifying-glass.html
|
||||
lor.png: https://game-icons.net/1x1/lorc/bookmarklet.html
|
||||
med.png: https://game-icons.net/1x1/delapouite/first-aid-kit.html
|
||||
nat.png: https://game-icons.net/1x1/delapouite/forest.html
|
||||
occ.png: https://game-icons.net/1x1/skoll/pentacle.html
|
||||
prc.png: https://game-icons.net/1x1/lorc/semi-closed-eye.html
|
||||
prf.png: https://game-icons.net/1x1/lorc/sing.html
|
||||
per.png: https://game-icons.net/1x1/delapouite/public-speaker.html
|
||||
rel.png: https://game-icons.net/1x1/lorc/holy-grail.html
|
||||
soc.png: https://game-icons.net/1x1/delapouite/trumpet-flag.html
|
||||
slt.png: https://game-icons.net/1x1/lorc/snatch.html
|
||||
ste.png: https://game-icons.net/1x1/lorc/cloak-dagger.html
|
||||
sur.png: https://game-icons.net/1x1/delapouite/pyre.html
|
||||
sur.png: https://game-icons.net/1x1/delapouite/pyre.html
|
||||
thi.png: https://game-icons.net/1x1/delapouite/lock-picking.html
|
||||
BIN
img/token/skills/cra.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
img/token/skills/dip.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
img/token/skills/lor.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
img/token/skills/occ.png
Normal file
|
After Width: | Height: | Size: 31 KiB |
BIN
img/token/skills/soc.png
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
img/token/skills/thi.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
@@ -9,6 +9,7 @@
|
||||
"MaterialDeck.Sett.Enable": "Enable module",
|
||||
"MaterialDeck.Sett.Help": "Help",
|
||||
"MaterialDeck.Sett.Permission": "User Permission Configuration",
|
||||
"MaterialDeck.DeviceConfig.Title": "Device Configuration",
|
||||
"MaterialDeck.Sett.PlaylistConfig": "Playlist Configuration",
|
||||
"MaterialDeck.Sett.MacroConfig": "Macro Configuration",
|
||||
"MaterialDeck.Sett.SoundboardConfig": "Soundboard Configuration",
|
||||
@@ -20,6 +21,8 @@
|
||||
"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.Sett.SystemOverride": "System Override",
|
||||
"MaterialDeck.Sett.SystemOverrideHint": "Overrides the automatic gaming system detection. Unsupported systems default to dnd5e, but if an unsupported system is similar to a different system you can specify that system here. Leave empty for system autodetection.",
|
||||
|
||||
"MaterialDeck.PL.Unrestricted": "Unrestricted",
|
||||
"MaterialDeck.PL.OneTrackPlaylist": "One track per playlist",
|
||||
@@ -32,7 +35,7 @@
|
||||
"MaterialDeck.Playlists": "Playlists",
|
||||
"MaterialDeck.Playlist": "Playlist",
|
||||
"MaterialDeck.FilePicker": "File Picker",
|
||||
"MaterialDeck.FurnaceArgs": "Furnace arguments",
|
||||
"MaterialDeck.FurnaceArgs": "Macro arguments",
|
||||
"MaterialDeck.Background": "Background",
|
||||
"MaterialDeck.Macro": "Macro",
|
||||
"MaterialDeck.Sound": "Sound",
|
||||
@@ -58,6 +61,8 @@
|
||||
"MaterialDeck.Import": "Import",
|
||||
"MaterialDeck.Export": "Export",
|
||||
"MaterialDeck.Filename": "Filename",
|
||||
"MaterialDeck.Id": "Id",
|
||||
"MaterialDeck.Type": "Type",
|
||||
|
||||
"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.",
|
||||
|
||||
60
lang/ja.json
@@ -13,13 +13,13 @@
|
||||
"MaterialDeck.Sett.MacroConfig": "マクロ設定",
|
||||
"MaterialDeck.Sett.SoundboardConfig": "サウンド設定",
|
||||
"MaterialDeck.Sett.ServerAddr": "Material Server アドレス",
|
||||
"MaterialDeck.Sett.ServerAddrHint": "MaterialServerのIPアドレスとポート。デフォルト値は99%の人に有効ですが、何をしているのかがわかっている場合にのみ変更してください。[ip_address]:[port]の形式に従う必要があります。例:「localhost:3001」または「192.168.1.1:4000」。",
|
||||
"MaterialDeck.Sett.ServerAddrHint": "Material ServerのIPアドレスとポート。デフォルト値は99%の人に有効ですが、何をしているのかがわかっている場合にのみ変更してください。[ip_address]:[port]の形式に従う必要があります。例:「localhost:3001」または「192.168.1.1:4000」。",
|
||||
"MaterialDeck.Sett.ImageBuffer": "画像キャッシュサイズ",
|
||||
"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.Sett.NrOfConnMessages": "接続警告回数",
|
||||
"MaterialDeck.Sett.NrOfConnMessagesHint": "Material DeckがMaterial Serverに接続できない場合に表示される接続警告回数を設定します。0に設定すると、無制限となります。",
|
||||
|
||||
"MaterialDeck.PL.Unrestricted": "無制限",
|
||||
"MaterialDeck.PL.OneTrackPlaylist": "プレイリストごとに1つのトラック",
|
||||
@@ -49,24 +49,24 @@
|
||||
"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.ClearAll": "すべて クリア",
|
||||
"MaterialDeck.ClearAll_Content": "すべてのデータがクリアされます。この操作は取り消すことができません、続行しますか?",
|
||||
"MaterialDeck.ClearPage": "ページ クリア",
|
||||
"MaterialDeck.ClearPage_Content": "このページのすべてのデータがクリアされます。この操作は取り消すことができません、続行しますか?",
|
||||
"MaterialDeck.Continue": "継続",
|
||||
"MaterialDeck.Cancel": "キャンセル",
|
||||
"MaterialDeck.Import": "インポート",
|
||||
"MaterialDeck.Export": "エクスポート",
|
||||
"MaterialDeck.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.ExportDialog.Title": "エクスポート",
|
||||
"MaterialDeck.ExportDialog.SoundboardContent": "SouseBoardデータをエクスポートします。メタデータのみがエクスポートされるので、インポートするときにオーディオファイルが相対的に同じ場所にあることを確認する必要があります。",
|
||||
"MaterialDeck.ExportDialog.MacroboardContent": "MacroBoardデータをエクスポートします。メタデータのみがエクスポートされるため、インポートしたときに同じマクロが使用可能であることを確認する必要があります。",
|
||||
|
||||
"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.ImportDialog.Title": "インポート",
|
||||
"MaterialDeck.ImportDialog.SoundboardContent": "インポートするファイルを選択してください。メタデータのみがインポートされるので、オーディオファイルがそれらをエクスポートしたときと同じ相対的な場所にあることを確認する必要があります。",
|
||||
"MaterialDeck.ImportDialog.MacroboardContent": "MacroBoardデータをインポートします。 ",
|
||||
"MaterialDeck.ImportDialog.Warning": "現在の設定が上書きされ、元に戻すことはできません。",
|
||||
|
||||
"MaterialDeck.FxMaster.Colorize": "色付け",
|
||||
"MaterialDeck.FxMaster.Clear": "すべてクリア",
|
||||
@@ -190,20 +190,20 @@
|
||||
"MaterialDeck.AboutTime.Fourth": "4",
|
||||
"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.Title": "ダウンロード・ユーティリティ",
|
||||
"MaterialDeck.DownloadUtility.Plugin": "プラグイン&Material Server",
|
||||
"MaterialDeck.DownloadUtility.Minimum": "最小",
|
||||
"MaterialDeck.DownloadUtility.Current": "現在",
|
||||
"MaterialDeck.DownloadUtility.Latest": "最新",
|
||||
"MaterialDeck.DownloadUtility.OS": "OS",
|
||||
"MaterialDeck.DownloadUtility.Download": "Download",
|
||||
"MaterialDeck.DownloadUtility.SDplugin": "SD Plugin",
|
||||
"MaterialDeck.DownloadUtility.Download": "ダウンロード",
|
||||
"MaterialDeck.DownloadUtility.SDplugin": "SDプラグイン",
|
||||
"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"
|
||||
"MaterialDeck.DownloadUtility.Source": "ソース",
|
||||
"MaterialDeck.DownloadUtility.Profiles": "プロファイル",
|
||||
"MaterialDeck.DownloadUtility.Name": "名前",
|
||||
"MaterialDeck.DownloadUtility.Refresh": "更新"
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "MaterialDeck",
|
||||
"title": "Material Deck",
|
||||
"description": "Material Deck allows you to control Foundry using an Elgato Stream Deck",
|
||||
"version": "1.4.4",
|
||||
"version": "1.4.9",
|
||||
"author": "CDeenen",
|
||||
"authors": {
|
||||
"name": "CDeenen",
|
||||
@@ -12,17 +12,17 @@
|
||||
"reddit": "CDeenen123"
|
||||
},
|
||||
"flags": {
|
||||
"minimumSDversion": "1.4.4",
|
||||
"minimumSDversion": "1.4.7",
|
||||
"minimumMSversion": "1.0.2"
|
||||
},
|
||||
"minimumSDversion": "1.4.4",
|
||||
"minimumSDversion": "1.4.7",
|
||||
"minimumMSversion": "1.0.2",
|
||||
"esmodules": [
|
||||
"./MaterialDeck.js"
|
||||
],
|
||||
"socket": true,
|
||||
"minimumCoreVersion": "0.7.5",
|
||||
"compatibleCoreVersion": "0.8.5",
|
||||
"compatibleCoreVersion": "9",
|
||||
"languages": [
|
||||
{
|
||||
"lang": "en",
|
||||
|
||||
@@ -127,16 +127,18 @@ export class CombatTracker{
|
||||
turn = combat.turn+1;
|
||||
}
|
||||
if (settings.displayRound) txt += "Round\n"+round;
|
||||
if (txt != "") txt += "\n";
|
||||
if (settings.displayRound && settings.displayTurn) txt += "\n";
|
||||
if (settings.displayTurn) txt += "Turn\n"+turn;
|
||||
}
|
||||
|
||||
streamDeck.setIcon(context,device,src,{background:background});
|
||||
streamDeck.setTitle(txt,context);
|
||||
}
|
||||
}
|
||||
|
||||
keyPress(settings,context,device){
|
||||
async keyPress(settings,context,device){
|
||||
const mode = settings.combatTrackerMode ? settings.combatTrackerMode : 'combatants';
|
||||
const selectCombatant = settings.selectCombatant ? settings.selectCombatant : false;
|
||||
const combat = game.combat;
|
||||
|
||||
if (mode == 'function'){
|
||||
@@ -169,11 +171,17 @@ export class CombatTracker{
|
||||
}
|
||||
if (game.combat.started == false) return;
|
||||
|
||||
if (ctFunction == 'nextTurn') game.combat.nextTurn();
|
||||
else if (ctFunction == 'prevTurn') game.combat.previousTurn();
|
||||
else if (ctFunction == 'nextRound') game.combat.nextRound();
|
||||
else if (ctFunction == 'prevRound') game.combat.previousRound();
|
||||
else if (ctFunction == 'endTurn' && game.combat.combatant.owner) game.combat.nextTurn();
|
||||
if (ctFunction == 'nextTurn') await game.combat.nextTurn();
|
||||
else if (ctFunction == 'prevTurn') await game.combat.previousTurn();
|
||||
else if (ctFunction == 'nextRound') await game.combat.nextRound();
|
||||
else if (ctFunction == 'prevRound') await game.combat.previousRound();
|
||||
else if (ctFunction == 'endTurn' && game.combat.combatant.owner) await game.combat.nextTurn();
|
||||
|
||||
if (selectCombatant) {
|
||||
const token = canvas.tokens.placeables.filter(token => token.id == game.combat.combatant.token.id)[0];
|
||||
if (token.can(game.userId,"control")) token.control();
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
const onClick = settings.onClick ? settings.onClick : 'doNothing';
|
||||
|
||||
576
src/external.js
@@ -1,9 +1,44 @@
|
||||
import {streamDeck} from "../MaterialDeck.js";
|
||||
|
||||
export class ExternalModules{
|
||||
soundscapeSettings = {
|
||||
channels: [],
|
||||
master: {
|
||||
mute: false,
|
||||
volume: 1,
|
||||
playing: false,
|
||||
name: 'Master'
|
||||
},
|
||||
soundboard: [],
|
||||
soundboardVolume: 1,
|
||||
playing: false
|
||||
}
|
||||
constructor(){
|
||||
this.active = false;
|
||||
this.gmScreenOpen = false;
|
||||
|
||||
let channelData = [];
|
||||
let soundboardData = [];
|
||||
for (let i=0; i<8; i++) {
|
||||
channelData.push({
|
||||
volume: 1,
|
||||
mute: false,
|
||||
solo: false,
|
||||
link: false,
|
||||
playing: false,
|
||||
pan: 1,
|
||||
name: ''
|
||||
})
|
||||
}
|
||||
for (let i=0; i<25; i++) {
|
||||
soundboardData.push({
|
||||
active: false,
|
||||
name: '',
|
||||
icon: ''
|
||||
})
|
||||
}
|
||||
this.soundscapeSettings.channels = channelData;
|
||||
this.soundscapeSettings.soundboard = soundboardData;
|
||||
}
|
||||
|
||||
async updateAll(data={}){
|
||||
@@ -33,6 +68,8 @@ export class ExternalModules{
|
||||
else if (module == 'notYourTurn') this.updateNotYourTurn(settings,context,device);
|
||||
else if (module == 'lockView') this.updateLockView(settings,context,device);
|
||||
else if (module == 'aboutTime') this.updateAboutTime(settings,context,device);
|
||||
else if (module == 'soundscape') this.updateSoundscape(settings,context,device);
|
||||
else if (module == 'monksActiveTiles') this.updateMonksActiveTiles(settings,context,device);
|
||||
}
|
||||
|
||||
keyPress(settings,context,device){
|
||||
@@ -47,6 +84,8 @@ export class ExternalModules{
|
||||
else if (module == 'notYourTurn') this.keyPressNotYourTurn(settings,context,device);
|
||||
else if (module == 'lockView') this.keyPressLockView(settings,context,device);
|
||||
else if (module == 'aboutTime') this.keyPressAboutTime(settings,context,device);
|
||||
else if (module == 'soundscape') this.keyPressSoundscape(settings,context,device);
|
||||
else if (module == 'monksActiveTiles') this.keyPressMonksActiveTiles(settings,context,device);
|
||||
}
|
||||
|
||||
getModuleEnable(moduleId){
|
||||
@@ -74,38 +113,20 @@ export class ExternalModules{
|
||||
let name = '';
|
||||
if (type == 'weatherControls') {
|
||||
const effect = (settings.weatherEffect == undefined) ? 'leaves' : settings.weatherEffect;
|
||||
name = CONFIG.weatherEffects[effect].label;
|
||||
icon = CONFIG.weatherEffects[effect].icon;
|
||||
ring = this.findWeatherEffect(effect) != undefined ? 2 : 1;
|
||||
name = CONFIG.fxmaster.weather[effect].label;
|
||||
icon = CONFIG.fxmaster.weather[effect].icon;
|
||||
ring = canvas.scene.getFlag("fxmaster", "effects")?.[`core_${effect}`] ? 2 : 1;
|
||||
ringColor = ring < 2 ? '#000000' : "#00ff00";
|
||||
}
|
||||
else if (type == 'colorize') {
|
||||
background = (settings.fxMasterColorizeColor == undefined) ? '#000000' : settings.fxMasterColorizeColor;
|
||||
icon = "fas fa-palette";
|
||||
name = game.i18n.localize("MaterialDeck.FxMaster.Colorize");
|
||||
const filters = canvas.scene.getFlag("fxmaster", "filters");
|
||||
ring = 2;
|
||||
if (filters == undefined || filters['core_color'] == undefined) {
|
||||
ringColor = "#000000";
|
||||
}
|
||||
else {
|
||||
const colors = filters['core_color'].options;
|
||||
let red = Math.ceil(colors.red*255).toString(16);
|
||||
if (red.length == 1) red = '0' + red;
|
||||
let green = Math.ceil(colors.green*255).toString(16);
|
||||
if (green.length == 1) green = '0' + green;
|
||||
let blue = Math.ceil(colors.blue*255).toString(16);
|
||||
if (blue.length == 1) blue = '0' + blue;
|
||||
ringColor = "#" + red + green + blue;
|
||||
}
|
||||
}
|
||||
else if (type == 'filters') {
|
||||
const filter = (settings.fxMasterFilter == undefined) ? 'underwater' : settings.fxMasterFilter;
|
||||
name = CONFIG.fxmaster.filters[filter].label;
|
||||
background = "#340057";
|
||||
if (displayIcon){
|
||||
if (filter == 'underwater') icon = "fas fa-water";
|
||||
if (filter == 'lightning') icon = "fas fa-bolt";
|
||||
else if (filter == 'underwater') icon = "fas fa-water";
|
||||
else if (filter == 'predator') icon = "fas fa-wave-square";
|
||||
else if (filter == 'color') icon = "fas fa-palette";
|
||||
else if (filter == 'oldfilm') icon = "fas fa-film";
|
||||
else if (filter == 'bloom') icon = "fas fa-ghost";
|
||||
}
|
||||
@@ -121,6 +142,7 @@ export class ExternalModules{
|
||||
}
|
||||
}
|
||||
}
|
||||
if (filter == 'color') background = settings.fxMasterFilterColor ? settings.fxMasterFilterColor : '#ffffff';
|
||||
}
|
||||
else if (type == 'clear'){
|
||||
icon = "fas fa-trash";
|
||||
@@ -133,15 +155,6 @@ export class ExternalModules{
|
||||
streamDeck.setTitle(name,context);
|
||||
}
|
||||
|
||||
hexToRgb(hex) {
|
||||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
||||
return result ? {
|
||||
red: parseInt(result[1], 16)/256,
|
||||
green: parseInt(result[2], 16)/256,
|
||||
blue: parseInt(result[3], 16)/256
|
||||
} : null;
|
||||
}
|
||||
|
||||
keyPressFxMaster(settings,context,device){
|
||||
if (game.user.isGM == false) return;
|
||||
const fxmaster = game.modules.get("fxmaster");
|
||||
@@ -151,91 +164,63 @@ export class ExternalModules{
|
||||
|
||||
if (type == 'weatherControls') {
|
||||
const effect = (settings.weatherEffect == undefined) ? 'leaves' : settings.weatherEffect;
|
||||
let exists = false;
|
||||
let newEffects = {};
|
||||
let effects = canvas.scene.getFlag("fxmaster", "effects");
|
||||
if (effects != undefined){
|
||||
const weatherIds = Object.keys(effects);
|
||||
for (let i=0; i<weatherIds.length; i++){
|
||||
const weather = effects[weatherIds[i]].type;
|
||||
if (weather === effect) {
|
||||
exists = true;
|
||||
continue;
|
||||
}
|
||||
newEffects[weatherIds[i]] = effects[weatherIds[i]];
|
||||
}
|
||||
|
||||
const options = {
|
||||
density: (settings.densitySlider == undefined) ? 0.25 : settings.densitySlider,
|
||||
speed: (settings.speedSlider == undefined) ? 1 : settings.speedSlider,
|
||||
direction: (settings.directionSlider == undefined) ? 15 : settings.directionSlider,
|
||||
scale: (settings.scaleSlider == undefined) ? 1 : settings.scaleSlider,
|
||||
color: (settings.fxMasterWeatherColor == undefined) ? "#000000" : settings.fxMasterWeatherColor,
|
||||
applyColor: (settings.fxWeatherEnColor == undefined) ? false : settings.fxWeatherEnColor
|
||||
}
|
||||
|
||||
const density = (settings.densitySlider == undefined) ? 50 : settings.densitySlider;
|
||||
const speed = (settings.speedSlider == undefined) ? 50 : settings.speedSlider;
|
||||
const direction = (settings.directionSlider == undefined) ? 50 : settings.directionSlider;
|
||||
const scale = (settings.scaleSlider == undefined) ? 50 : settings.scaleSlider;
|
||||
const color = (settings.fxMasterWeatherColor == undefined) ? "#000000" : settings.fxMasterWeatherColor;
|
||||
const applyColor = (settings.fxWeatherEnColor == undefined) ? false : settings.fxWeatherEnColor;
|
||||
|
||||
if (exists == false) {
|
||||
newEffects[randomID()] = {
|
||||
type: effect,
|
||||
options: {
|
||||
density: density,
|
||||
speed: speed,
|
||||
scale: scale,
|
||||
tint: color,
|
||||
direction: direction,
|
||||
apply_tint: applyColor
|
||||
}
|
||||
};
|
||||
}
|
||||
canvas.scene.unsetFlag("fxmaster", "effects").then(() => {
|
||||
canvas.scene.setFlag("fxmaster", "effects", newEffects);
|
||||
});
|
||||
|
||||
}
|
||||
else if (type == 'colorize') {
|
||||
const color = (settings.fxMasterColorizeColor == undefined) ? '#000000' : settings.fxMasterColorizeColor;
|
||||
const filters = canvas.scene.getFlag("fxmaster", "filters");
|
||||
let newFilters = {};
|
||||
if (filters != undefined){
|
||||
const filterObjects = Object.keys(filters);
|
||||
for (let i=0; i<filterObjects.length; i++){
|
||||
if (filterObjects[i] == 'core_color'){
|
||||
//continue;
|
||||
}
|
||||
newFilters[filterObjects[i]] = filters[filterObjects[i]];
|
||||
}
|
||||
}
|
||||
newFilters['core_color'] = {
|
||||
type : 'color',
|
||||
options: this.hexToRgb(color)
|
||||
};
|
||||
|
||||
canvas.scene.unsetFlag("fxmaster", "filters").then(() => {
|
||||
canvas.scene.setFlag("fxmaster", "filters", newFilters);
|
||||
});
|
||||
Hooks.call("fxmaster.switchWeather", {
|
||||
name: `core_${effect}`,
|
||||
type: effect,
|
||||
options,
|
||||
});
|
||||
|
||||
}
|
||||
else if (type == 'filters') {
|
||||
const filter = (settings.fxMasterFilter == undefined) ? 'underwater' : settings.fxMasterFilter;
|
||||
const filters = canvas.scene.getFlag("fxmaster", "filters");
|
||||
let newFilters = {};
|
||||
let exists = false;
|
||||
if (filters != undefined){
|
||||
const filterObjects = Object.keys(filters);
|
||||
for (let i=0; i<filterObjects.length; i++){
|
||||
if (filterObjects[i] == 'core_'+filter){
|
||||
exists = true;
|
||||
continue;
|
||||
}
|
||||
newFilters[filterObjects[i]] = filters[filterObjects[i]];
|
||||
|
||||
let options = {color: {value:"#000000", apply:false}};
|
||||
if (filter == 'lightning') {
|
||||
options.period = settings.fxMasterFilterPeriod ? parseFloat(settings.fxMasterFilterPeriod) : 500;
|
||||
options.duration = settings.fxMasterFilterDuration ? parseFloat(settings.fxMasterFilterDuration) : 300;
|
||||
options.brightness = settings.fxMasterFilterBrightness ? parseFloat(settings.fxMasterFilterBrightness) : 1.3;
|
||||
}
|
||||
else if (filter == 'underwater') {
|
||||
options.speed = settings.fxMasterFilterSpeed ? parseFloat(settings.fxMasterFilterSpeed) : 0.3;
|
||||
options.scale = settings.fxMasterFilterScale ? parseFloat(settings.fxMasterFilterScale) : 4;
|
||||
}
|
||||
else if (filter == 'predator') {
|
||||
options.noise = settings.fxMasterFilterNoise ? parseFloat(settings.fxMasterFilterNoise) : 4;
|
||||
options.speed = settings.fxMasterFilterSpeed ? parseFloat(settings.fxMasterFilterSpeed)*0.1 : 0.03;
|
||||
}
|
||||
|
||||
else if (filter == 'bloom') {
|
||||
options.blur = settings.fxMasterFilterBlur ? parseFloat(settings.fxMasterFilterBlur) : 1;
|
||||
options.bloom = settings.fxMasterFilterBloom ? parseFloat(settings.fxMasterFilterBloom) : 0.1;
|
||||
options.threshold = settings.fxMasterFilterThreshold ? parseFloat(settings.fxMasterFilterThreshold) : 0.5;
|
||||
}
|
||||
else if (filter == 'oldfilm') {
|
||||
options.sepia = settings.fxMasterFilterSepia ? parseFloat(settings.fxMasterFilterSepia) : 0.3;
|
||||
options.noise = settings.fxMasterFilterNoise ? parseFloat(settings.fxMasterFilterNoise) : 4;
|
||||
}
|
||||
|
||||
if (filter == 'color') {
|
||||
options.color = {
|
||||
apply: settings.fxMasterFilterTint ? settings.fxMasterFilterTint : false,
|
||||
value: settings.fxMasterFilterColor ? settings.fxMasterFilterColor : '#ffffff'
|
||||
}
|
||||
|
||||
options.saturation = settings.fxMasterFilterSaturation ? parseFloat(settings.fxMasterFilterSaturation) : 1;
|
||||
options.contrast = settings.fxMasterFilterContrast ? parseFloat(settings.fxMasterFilterContrast) : 1;
|
||||
options.brightness = settings.fxMasterFilterBrightness ? parseFloat(settings.fxMasterFilterBrightness) : 1;
|
||||
options.Gamma = settings.fxMasterFilterGamma ? parseFloat(settings.fxMasterFilterGamma) : 1;
|
||||
}
|
||||
if (exists == false) {
|
||||
newFilters['core_'+filter] = {type : filter};
|
||||
}
|
||||
canvas.scene.unsetFlag("fxmaster", "filters").then(() => {
|
||||
canvas.scene.setFlag("fxmaster", "filters", newFilters);
|
||||
});
|
||||
|
||||
FXMASTER.filters.switch(`core_${filter}`, filter, options);
|
||||
}
|
||||
else if (type == 'clear'){
|
||||
canvas.scene.unsetFlag("fxmaster", "filters");
|
||||
@@ -243,18 +228,6 @@ export class ExternalModules{
|
||||
}
|
||||
}
|
||||
|
||||
findWeatherEffect(effect){
|
||||
const effects = canvas.scene.getFlag("fxmaster", "effects");
|
||||
if (effects == undefined) return undefined;
|
||||
|
||||
const weatherIds = Object.keys(effects);
|
||||
for (let i = 0; i < weatherIds.length; ++i) {
|
||||
const weather = effects[weatherIds[i]].type;
|
||||
if (weather === effect) return weatherIds[i];
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//GM Screen
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -280,7 +253,7 @@ export class ExternalModules{
|
||||
keyPressGMScreen(settings,context,device){
|
||||
if (this.getModuleEnable("gm-screen") == false) return;
|
||||
if (game.user.isGM == false) return;
|
||||
window['gm-screen'].toggleGmScreenVisibility();
|
||||
game.modules.get('gm-screen')?.api?.toggleGmScreenVisibility?.();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -698,6 +671,363 @@ export class ExternalModules{
|
||||
game.Gametime.advanceTime({ hours: -1 });
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//Soundscape
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
updateSoundscape(settings,context,device) {
|
||||
|
||||
if (this.getModuleEnable("soundscape") == false) return;
|
||||
if (game.user.isGM == false) return;
|
||||
|
||||
const target = settings.soundscapeTarget ? settings.soundscapeTarget : 'mixer';
|
||||
let channel = settings.soundscapeChannel ? settings.soundscapeChannel : 1;
|
||||
|
||||
let background = '#000000';
|
||||
let ring = 0;
|
||||
let ringColor = '#000000';
|
||||
|
||||
let txt = '';
|
||||
let src = 'modules/MaterialDeck/img/transparant.png';
|
||||
let name = '';
|
||||
|
||||
if (target == 'mixer') {
|
||||
let mode = settings.soundscapeMixerMode ? settings.soundscapeMixerMode : 'startStopAll';
|
||||
const displayName = settings.soundscapeMixerName;
|
||||
const displayChannel = settings.soundscapeDisplayMixerChannel;
|
||||
|
||||
if (mode == 'startStopAll') {
|
||||
channel = 'master';
|
||||
mode = 'startStop';
|
||||
}
|
||||
|
||||
if (channel == 'Master') channel = 'master';
|
||||
|
||||
let channelSettings;
|
||||
if (channel == 'master') {
|
||||
channelSettings = this.soundscapeSettings.master;
|
||||
channelSettings.playing = this.soundscapeSettings.playing;
|
||||
channelSettings.name = 'Master';
|
||||
}
|
||||
else channelSettings = this.soundscapeSettings.channels[channel-1];
|
||||
if (displayChannel && channel == 'master') txt += 'Master';
|
||||
else if (displayChannel) txt += channel;
|
||||
|
||||
if (mode == 'startStop') {
|
||||
if (displayChannel) txt += '\n';
|
||||
if (channelSettings.playing) {
|
||||
src = "fas fa-stop";
|
||||
ringColor = '#00ff00';
|
||||
}
|
||||
else {
|
||||
src = "fas fa-play";
|
||||
ringColor = '#006600';
|
||||
}
|
||||
ring=2;
|
||||
|
||||
}
|
||||
else if (mode == 'mute') {
|
||||
if (displayChannel) txt += '\n';
|
||||
txt += 'M';
|
||||
if (displayName) txt += '\n';
|
||||
ring=2;
|
||||
ringColor = '#ff0000';
|
||||
background = channelSettings.mute ? '#ff0000' : '#660000'
|
||||
}
|
||||
else if (mode == 'solo') {
|
||||
if (channel == 'master') return;
|
||||
if (displayChannel) txt += '\n';
|
||||
txt += 'S';
|
||||
if (displayName) txt += '\n';
|
||||
ring=2;
|
||||
ringColor = '#ffff00';
|
||||
background = channelSettings.solo ? '#ffff00' : '#666600'
|
||||
}
|
||||
else if (mode == 'link') {
|
||||
if (channel == 'master') return;
|
||||
if (displayChannel) txt += '\n';
|
||||
txt += 'L';
|
||||
if (displayName) txt += '\n';
|
||||
ring=2;
|
||||
ringColor = '#00ffff';
|
||||
background = channelSettings.link ? '#00ffff' : '#000066'
|
||||
}
|
||||
else if (displayName && displayChannel) txt += '\n';
|
||||
|
||||
if (displayName) txt += channelSettings.name;
|
||||
|
||||
if (mode == 'volume') {
|
||||
const displayValue = settings.soundscapeDisplayMixerValue;
|
||||
const volume = Math.floor(channelSettings.volume*100);
|
||||
if (displayValue && (displayName || displayChannel)) txt += '\n';
|
||||
if (displayValue) txt += volume;
|
||||
}
|
||||
|
||||
}
|
||||
else if (target == 'soundboard') {
|
||||
const displayName = settings.soundscapeSoundboardName;
|
||||
const displayIcon = settings.soundscapeSoundboardIcon;
|
||||
const displayChannel = settings.soundscapeDisplayChannel;
|
||||
const displayValue = settings.soundscapeSoundboardValue;
|
||||
const mode = settings.soundscapeSoundboardMode ? settings.soundscapeSoundboardMode : 'play';
|
||||
|
||||
if (mode == 'play') {
|
||||
channel -= 1;
|
||||
let sound = this.soundscapeSettings.soundboard[channel];
|
||||
|
||||
if (displayChannel) txt += channel+1;
|
||||
if (displayChannel && displayName) txt += '\n';
|
||||
if (displayName) txt += sound.name;
|
||||
if (displayIcon) src = sound.icon;
|
||||
}
|
||||
else if (mode == 'volume') {
|
||||
const volume = Math.floor(this.soundscapeSettings.soundboardVolume*100);
|
||||
if (displayValue) txt += volume;
|
||||
}
|
||||
else if (mode == 'stop') {
|
||||
src = 'modules/MaterialDeck/img/playlist/stop.png';
|
||||
}
|
||||
}
|
||||
|
||||
streamDeck.setTitle(txt,context);
|
||||
streamDeck.setIcon(context,device,src,{background:background,ring:ring,ringColor:ringColor});
|
||||
}
|
||||
|
||||
async keyPressSoundscape(settings,context,device) {
|
||||
if (this.getModuleEnable("soundscape") == false) return;
|
||||
if (game.user.isGM == false) return;
|
||||
|
||||
const target = settings.soundscapeTarget ? settings.soundscapeTarget : 'mixer';
|
||||
let channel = settings.soundscapeChannel ? settings.soundscapeChannel : 1;
|
||||
|
||||
if (target == 'mixer') {
|
||||
const mode = settings.soundscapeMixerMode ? settings.soundscapeMixerMode : 'startStopAll';
|
||||
|
||||
if (mode == 'startStopAll') {
|
||||
const playing = !this.soundscapeSettings.playing;
|
||||
if (playing) {
|
||||
Hooks.call('setSoundscape',{"msgType":"start","channelNr":undefined});
|
||||
return;
|
||||
}
|
||||
else {
|
||||
Hooks.call('setSoundscape',{"msgType":"stop","channelNr":undefined});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (channel == 'Master') channel = 'master';
|
||||
|
||||
let channelSettings;
|
||||
if (channel == 'master') {
|
||||
channelSettings = this.soundscapeSettings.master;
|
||||
channelSettings.playing = this.soundscapeSettings.playing;
|
||||
}
|
||||
else channelSettings = this.soundscapeSettings.channels[channel-1];
|
||||
|
||||
let mute, solo, link, playing;
|
||||
let setChannel = false;
|
||||
|
||||
if (mode == 'startStop') {
|
||||
setChannel = true;
|
||||
playing = !channelSettings.playing;
|
||||
if (channel == 'master' && playing) {
|
||||
Hooks.call('setSoundscape',{"msgType":"stop"});
|
||||
return;
|
||||
}
|
||||
else if (channel == 'master') {
|
||||
Hooks.call('setSoundscape',{"msgType":"start"});
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (mode == 'mute') {
|
||||
setChannel = true;
|
||||
mute = !channelSettings.mute;
|
||||
}
|
||||
else if (mode == 'solo') {
|
||||
if (channel == 'master') return;
|
||||
setChannel = true;
|
||||
solo = !channelSettings.solo;
|
||||
}
|
||||
else if (mode == 'link') {
|
||||
if (channel == 'master') return;
|
||||
setChannel = true;
|
||||
link = !channelSettings.link;
|
||||
}
|
||||
if (setChannel) {
|
||||
const channelNr = channel == 'master' ? 'master' : channel-1;
|
||||
const payload = {
|
||||
"msgType": "setChannel",
|
||||
"channelNr": channelNr,
|
||||
mute,
|
||||
solo,
|
||||
link,
|
||||
playing
|
||||
};
|
||||
Hooks.call('setSoundscape',payload);
|
||||
return;
|
||||
}
|
||||
|
||||
if (mode == 'volume') {
|
||||
const volumeMode = settings.soundscapeMixerValueMode ? settings.soundscapeMixerValueMode : 'incrementDecrement';
|
||||
const value = parseInt(settings.soundscapeMixerValue);
|
||||
if (isNaN(value) == false) {
|
||||
let volume = channelSettings.volume*100;
|
||||
|
||||
if (volumeMode == 'set')
|
||||
volume = value;
|
||||
else
|
||||
volume += value;
|
||||
|
||||
volume = Math.floor(volume*100)/10000;
|
||||
const channelNr = channel == 'master' ? 'master' : channel-1;
|
||||
const payload = {
|
||||
"msgType": "setVolume",
|
||||
"channelNr": channelNr,
|
||||
volume
|
||||
};
|
||||
Hooks.call('setSoundscape',payload);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (target == 'soundboard') {
|
||||
const mode = settings.soundscapeSoundboardMode ? settings.soundscapeSoundboardMode : 'play';
|
||||
|
||||
if (mode == 'play') {
|
||||
channel -= 1;
|
||||
const payload = {
|
||||
"msgType": "playSoundboard",
|
||||
channelNr: channel
|
||||
};
|
||||
Hooks.call('setSoundscape',payload);
|
||||
}
|
||||
else if (mode == 'volume') {
|
||||
const volumeMode = settings.soundscapeSoundboardValueMode ? settings.soundscapeSoundboardValueMode : 'incrementDecrement';
|
||||
const value = parseInt(settings.soundscapeSoundboardValue);
|
||||
if (isNaN(value) == false) {
|
||||
let volume = this.soundscapeSettings.soundboardVolume*100;
|
||||
|
||||
if (volumeMode == 'set')
|
||||
volume = value;
|
||||
else
|
||||
volume += value;
|
||||
|
||||
volume = Math.floor(volume*100)/10000;
|
||||
const payload = {
|
||||
"msgType": "setSoundboardVolume",
|
||||
volume
|
||||
};
|
||||
Hooks.call('setSoundscape',payload);
|
||||
}
|
||||
}
|
||||
else if (mode == 'stop') {
|
||||
const payload = {
|
||||
"msgType": "stopSoundboard"
|
||||
};
|
||||
Hooks.call('setSoundscape',payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newSoundscapeData(data) {
|
||||
let channel;
|
||||
if (data.channel != undefined) channel = data.channel;
|
||||
else if (data.channelNr != undefined) channel = data.channelNr;
|
||||
|
||||
let channelSettings = channel == 'master' ? this.soundscapeSettings.master : this.soundscapeSettings.channels[channel]
|
||||
if (data.msgType == 'soundConfig') {
|
||||
|
||||
let newChannelSettings = {
|
||||
volume: data.data.settings.volume,
|
||||
mute: data.data.settings.mute,
|
||||
solo: data.data.settings.solo,
|
||||
link: data.data.settings.link,
|
||||
playing: false,
|
||||
pan: data.data.settings.pan,
|
||||
name: data.data.settings.name
|
||||
};
|
||||
this.soundscapeSettings.channels[channel] = newChannelSettings;
|
||||
}
|
||||
else if (data.msgType == 'setMute') channelSettings.mute = data.mute;
|
||||
else if (data.msgType == 'setSolo') channelSettings.solo = data.solo;
|
||||
else if (data.msgType == 'setLink') channelSettings.link = data.link;
|
||||
else if (data.msgType == 'setVolume') {
|
||||
if (channel >= 100) return;
|
||||
channelSettings.volume = data.volume;
|
||||
}
|
||||
else if (data.msgType == 'start') {
|
||||
this.soundscapeSettings.playing = true;
|
||||
this.soundscapeSettings.master.playing = true;
|
||||
if (data.channel == undefined) for (let i=0; i<8; i++) this.soundscapeSettings.channels[i].playing = true;
|
||||
else this.soundscapeSettings.channels[data.channel].playing = true;
|
||||
}
|
||||
else if (data.msgType == 'stop') {
|
||||
|
||||
if (data.channel == undefined) {
|
||||
for (let i=0; i<8; i++) this.soundscapeSettings.channels[i].playing = false;
|
||||
this.soundscapeSettings.playing = false;
|
||||
}
|
||||
else {
|
||||
this.soundscapeSettings.channels[data.channel].playing = false;
|
||||
let check = 0;
|
||||
for (let i=0; i<8; i++) if (this.soundscapeSettings.channels[data.channel].playing) check++;
|
||||
if (check == 0) this.soundscapeSettings.playing = false;
|
||||
}
|
||||
}
|
||||
else if (data.msgType == 'sbSoundConfig') {
|
||||
|
||||
const channel = data.channel - 100;
|
||||
let active = true;
|
||||
if (data.data.soundArray == undefined) active = false;
|
||||
this.soundscapeSettings.soundboard[channel] = {
|
||||
active,
|
||||
name: data.data.name,
|
||||
icon: data.data.imageSrc
|
||||
};
|
||||
}
|
||||
else if (data.msgType == 'setSoundboardVolume')
|
||||
this.soundscapeSettings.soundboardVolume = data.volume;
|
||||
|
||||
this.updateAll();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//Monks Active Tile Triggers
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
updateMonksActiveTiles(settings,context,device) {
|
||||
const id = settings.monksActiveTilesId;
|
||||
if (id == undefined || id == '') return;
|
||||
let tile = canvas.background.placeables.find(t => t.id == id);
|
||||
if (tile == undefined) return;
|
||||
const tileData = tile.data.flags?.['monks-active-tiles'];
|
||||
if (tileData == undefined) return;
|
||||
|
||||
let ring = 1;
|
||||
let ringColor = '#000000';
|
||||
let background = '#000000';
|
||||
if (tileData.active) {
|
||||
ring = 2;
|
||||
ringColor = '#00ff00'
|
||||
}
|
||||
let src = tile.data.img;
|
||||
|
||||
streamDeck.setTitle('',context);
|
||||
streamDeck.setIcon(context,device,src,{background:background,ring:ring,ringColor:ringColor});
|
||||
}
|
||||
|
||||
keyPressMonksActiveTiles(settings,context,device) {
|
||||
const mode = settings.monksActiveTilesMode ? settings.monksActiveTilesMode : 'toggle';
|
||||
const id = settings.monksActiveTilesId;
|
||||
if (id == undefined || id == '') return;
|
||||
let tile = canvas.background.placeables.find(t => t.id == id);
|
||||
if (tile == undefined) return;
|
||||
const tileData = tile.data.flags?.['monks-active-tiles'];
|
||||
if (tileData == undefined) return;
|
||||
|
||||
if (mode == 'toggle') tile.document.setFlag('monks-active-tiles','active',!tileData.active);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
10
src/macro.js
@@ -180,7 +180,12 @@ export class MacroControl{
|
||||
let furnaceEnabled = false;
|
||||
let furnace = game.modules.get("furnace");
|
||||
if (furnace != undefined && furnace.active && compatibleCore("0.8.1")==false) furnaceEnabled = true;
|
||||
|
||||
let advancedMacros = game.modules.get("advanced-macros");
|
||||
if (advancedMacros != undefined && advancedMacros.active) furnaceEnabled = true;
|
||||
|
||||
if (args == "" || args == " ") furnaceEnabled = false;
|
||||
|
||||
if (furnaceEnabled == false) macro.execute({token:target});
|
||||
else {
|
||||
let chatData = {
|
||||
@@ -235,7 +240,12 @@ export class MacroControl{
|
||||
let furnaceEnabled = false;
|
||||
let furnace = game.modules.get("furnace");
|
||||
if (furnace != undefined && furnace.active && compatibleCore("0.8.1")==false) furnaceEnabled = true;
|
||||
|
||||
let advancedMacros = game.modules.get("advanced-macros");
|
||||
if (advancedMacros != undefined && advancedMacros.active) furnaceEnabled = true;
|
||||
|
||||
if (args == undefined || args[macroNumber] == undefined || args[macroNumber] == "") furnaceEnabled = false;
|
||||
|
||||
if (furnaceEnabled == false) macro.execute();
|
||||
else {
|
||||
let chatData = {
|
||||
|
||||
113
src/misc.js
@@ -1,15 +1,17 @@
|
||||
import {sdVersion, msVersion, moduleName, getPermission, enableModule} from "../MaterialDeck.js";
|
||||
import {sdVersion, msVersion, moduleName, getPermission, enableModule, streamDeck} from "../MaterialDeck.js";
|
||||
import {macroControl,soundboard,playlistControl} from "../MaterialDeck.js";
|
||||
|
||||
export function compatibleCore(compatibleVersion){
|
||||
let coreVersion = game.data.version;
|
||||
let coreVersion = game.version == undefined ? game.data.version : `0.${game.version}`;
|
||||
coreVersion = coreVersion.split(".");
|
||||
compatibleVersion = compatibleVersion.split(".");
|
||||
if (compatibleVersion[0] > coreVersion[0]) return false;
|
||||
if (compatibleVersion[0] < coreVersion[0]) return true;
|
||||
if (compatibleVersion[1] > coreVersion[1]) return false;
|
||||
if (compatibleVersion[1] < coreVersion[1]) return true;
|
||||
if (compatibleVersion[2] > coreVersion[2]) return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export class playlistConfigForm extends FormApplication {
|
||||
constructor(data, options) {
|
||||
@@ -183,7 +185,8 @@ export class macroConfigForm extends FormApplication {
|
||||
let furnaceEnabled = false;
|
||||
let height = 95;
|
||||
let furnace = game.modules.get("furnace");
|
||||
if (furnace != undefined && furnace.active && compatibleCore("0.8.1")==false) {
|
||||
let advancedMacros = game.modules.get("advanced-macros");
|
||||
if ((furnace != undefined && furnace.active && compatibleCore("0.8.1")==false) || (advancedMacros != undefined && advancedMacros.active)) {
|
||||
furnaceEnabled = true;
|
||||
height += 50;
|
||||
}
|
||||
@@ -1056,12 +1059,23 @@ export class downloadUtility extends FormApplication {
|
||||
}
|
||||
if (this.localMSversion == undefined) this.localMSversion = 'unknown';
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return {
|
||||
minimumSdVersion: game.modules.get("MaterialDeck").data.minimumSDversion.replace('v',''),
|
||||
minimumSdVersion,
|
||||
localSdVersion: this.localSDversion,
|
||||
masterSdVersion: this.masterSDversion,
|
||||
sdDlDisable: this.masterSDversion == undefined,
|
||||
minimumMsVersion: game.modules.get("MaterialDeck").data.minimumMSversion.replace('v',''),
|
||||
minimumMsVersion,
|
||||
localMsVersion: this.localMSversion,
|
||||
masterMsVersion: this.masterMSversion,
|
||||
msDlDisable: this.masterMSversion == undefined,
|
||||
@@ -1173,4 +1187,91 @@ export class downloadUtility extends FormApplication {
|
||||
document.getElementById(elementId).innerHTML = 'Error';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class deviceConfig extends FormApplication {
|
||||
constructor(data, options) {
|
||||
super(data, options);
|
||||
|
||||
this.devices = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Default Options for this FormApplication
|
||||
*/
|
||||
static get defaultOptions() {
|
||||
return mergeObject(super.defaultOptions, {
|
||||
id: "MD_DeviceConfig",
|
||||
title: "Material Deck: " + game.i18n.localize("MaterialDeck.DeviceConfig.Title"),
|
||||
template: "./modules/MaterialDeck/templates/deviceConfig.html",
|
||||
width: 500,
|
||||
height: "auto"
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide data to the template
|
||||
*/
|
||||
getData() {
|
||||
this.devices = [];
|
||||
let dConfig = game.settings.get(moduleName, 'devices');
|
||||
if (Object.prototype.toString.call(game.settings.get('MaterialDeck', 'devices')) === "[object String]") {
|
||||
dConfig = {};
|
||||
game.settings.set(moduleName, 'devices', dConfig);
|
||||
}
|
||||
|
||||
for (let d of streamDeck.buttonContext) {
|
||||
let type;
|
||||
if (d.type == 0) type = 'Stream Deck';
|
||||
else if (d.type == 1) type = 'Stream Deck Mini';
|
||||
else if (d.type == 2) type = 'Stream Deck XL';
|
||||
else if (d.type == 3) type = 'Stream Deck Mobile';
|
||||
else if (d.type == 4) type = 'Corsair G Keys';
|
||||
|
||||
const name = d.name;
|
||||
const id = d.device;
|
||||
let enable;
|
||||
if (dConfig?.[id] == undefined) enable = true;
|
||||
else enable = dConfig?.[id].enable;
|
||||
|
||||
const device = {
|
||||
id,
|
||||
name,
|
||||
type,
|
||||
en: enable
|
||||
}
|
||||
this.devices.push(device);
|
||||
}
|
||||
|
||||
return {
|
||||
devices: this.devices
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update on form submit
|
||||
* @param {*} event
|
||||
* @param {*} formData
|
||||
*/
|
||||
async _updateObject(event, formData) {
|
||||
|
||||
}
|
||||
|
||||
activateListeners(html) {
|
||||
super.activateListeners(html);
|
||||
|
||||
html.find("input[name='enable']").on('change', (event) => {
|
||||
const id = event.currentTarget.id;
|
||||
for (let d of this.devices) {
|
||||
if (d.id == id) {
|
||||
let dConfig = game.settings.get(moduleName, 'devices');
|
||||
delete dConfig[id];
|
||||
dConfig[id] = {enable: event.currentTarget.checked}
|
||||
game.settings.set(moduleName, 'devices', dConfig);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as MODULE from "../MaterialDeck.js";
|
||||
import {streamDeck} from "../MaterialDeck.js";
|
||||
import {streamDeck, gamingSystem} from "../MaterialDeck.js";
|
||||
import {compatibleCore} from "./misc.js";
|
||||
|
||||
export class OtherControls{
|
||||
@@ -7,6 +7,8 @@ export class OtherControls{
|
||||
this.active = false;
|
||||
this.rollData = {};
|
||||
this.rollOption = 'dialog';
|
||||
this.controlsOffset = 0;
|
||||
this.toolsOffset = 0;
|
||||
}
|
||||
|
||||
setRollOption(option) {
|
||||
@@ -54,6 +56,8 @@ export class OtherControls{
|
||||
this.updateChatMessage(settings,context,device,options);
|
||||
else if (mode == 'rollOptions')
|
||||
this.updateRollOptions(settings,context,device,options);
|
||||
else if (mode == 'rollMode')
|
||||
this.updateRollMode(settings,context,device,options);
|
||||
}
|
||||
|
||||
keyPress(settings,context,device){
|
||||
@@ -83,6 +87,8 @@ export class OtherControls{
|
||||
this.keyPressChatMessage(settings);
|
||||
else if (mode == 'rollOptions')
|
||||
this.keyPressRollOptions(settings);
|
||||
else if (mode == 'rollMode')
|
||||
this.keyPressRollMode(settings);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -221,7 +227,9 @@ export class OtherControls{
|
||||
const control = settings.control ? settings.control : 'dispControls';
|
||||
const tool = settings.tool ? settings.tool : 'open';
|
||||
let background = settings.background ? settings.background : '#000000';
|
||||
let ringColor = '#000000'
|
||||
let ringColor = '#000000';
|
||||
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
|
||||
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
|
||||
let txt = "";
|
||||
let src = "";
|
||||
const activeControl = ui.controls.activeControl;
|
||||
@@ -231,6 +239,7 @@ export class OtherControls{
|
||||
let controlNr = parseInt(settings.controlNr);
|
||||
if (isNaN(controlNr)) controlNr = 1;
|
||||
controlNr--;
|
||||
controlNr += this.controlsOffset;
|
||||
|
||||
const selectedControl = ui.controls.controls[controlNr];
|
||||
|
||||
@@ -251,6 +260,7 @@ export class OtherControls{
|
||||
let controlNr = parseInt(settings.controlNr);
|
||||
if (isNaN(controlNr)) controlNr = 1;
|
||||
controlNr--;
|
||||
controlNr += this.toolsOffset;
|
||||
|
||||
const selectedControl = ui.controls.controls.find(c => c.name == ui.controls.activeControl);
|
||||
if (selectedControl != undefined){
|
||||
@@ -271,6 +281,18 @@ export class OtherControls{
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (control == 'controlsOffset') {
|
||||
const display = settings.controlsOffsetDisplay ? settings.controlsOffsetDisplay : false;
|
||||
const offsetType = settings.controlsOffsetType ? settings.controlsOffsetType : 'absoluteOffset';
|
||||
if (display) txt = `${this.controlsOffset}`;
|
||||
if (offsetType == 'absoluteOffset') ringColor = (this.controlsOffset == settings.controlsOffset) ? ringOnColor : ringOffColor;
|
||||
}
|
||||
else if (control == 'toolsOffset') {
|
||||
const display = settings.controlsOffsetDisplay ? settings.controlsOffsetDisplay : false;
|
||||
const offsetType = settings.controlsOffsetType ? settings.controlsOffsetType : 'absoluteOffset';
|
||||
if (display) txt = `${this.toolsOffset}`;
|
||||
if (offsetType == 'absoluteOffset') ringColor = (this.toolsOffset == settings.controlsOffset) ? ringOnColor : ringOffColor;
|
||||
}
|
||||
else { // specific control/tool
|
||||
const selectedControl = ui.controls.controls.find(c => c.name == control);
|
||||
if (selectedControl != undefined){
|
||||
@@ -366,6 +388,16 @@ export class OtherControls{
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (control == 'controlsOffset') {
|
||||
const offsetType = settings.controlsOffsetType ? settings.controlsOffsetType : 'absoluteOffset';
|
||||
if (offsetType == 'absoluteOffset') this.controlsOffset = parseInt(settings.controlsOffset);
|
||||
else if (offsetType == 'relativeOffset') this.controlsOffset += parseInt(settings.controlsOffset);
|
||||
}
|
||||
else if (control == 'toolsOffset') {
|
||||
const offsetType = settings.controlsOffsetType ? settings.controlsOffsetType : 'absoluteOffset';
|
||||
if (offsetType == 'absoluteOffset') this.toolsOffset = parseInt(settings.controlsOffset);
|
||||
else if (offsetType == 'relativeOffset') this.toolsOffset += parseInt(settings.controlsOffset);
|
||||
}
|
||||
else { //select control
|
||||
const selectedControl = ui.controls.controls.find(c => c.name == control);
|
||||
if (selectedControl != undefined){
|
||||
@@ -498,7 +530,7 @@ export class OtherControls{
|
||||
if (tokenControlled) r = new Roll(settings.rollDiceFormula,actor.getRollData());
|
||||
else r = new Roll(settings.rollDiceFormula);
|
||||
|
||||
r.evaluate();
|
||||
r.evaluate({async:false});
|
||||
|
||||
if (rollFunction == 'public') {
|
||||
r.toMessage(r,{rollMode:"roll"})
|
||||
@@ -584,6 +616,7 @@ export class OtherControls{
|
||||
else if (nr == 'items') name = game.i18n.localize("SIDEBAR.TabItems");
|
||||
else if (nr == 'journal') name = game.i18n.localize("SIDEBAR.TabJournal");
|
||||
else if (nr == 'tables') name = game.i18n.localize("SIDEBAR.TabTables");
|
||||
else if (nr == 'cards') name = game.i18n.localize("SIDEBAR.TabCards");
|
||||
else if (nr == 'playlists') name = game.i18n.localize("SIDEBAR.TabPlaylists");
|
||||
else if (nr == 'compendium') name = game.i18n.localize("SIDEBAR.TabCompendium");
|
||||
else if (nr == 'settings') name = game.i18n.localize("SIDEBAR.TabSettings");
|
||||
@@ -596,10 +629,11 @@ export class OtherControls{
|
||||
if (nr == 'chat') icon = window.CONFIG.ChatMessage.sidebarIcon;
|
||||
else if (nr == 'combat') icon = window.CONFIG.Combat.sidebarIcon;
|
||||
else if (nr == 'scenes') icon = window.CONFIG.Scene.sidebarIcon;
|
||||
else if (nr == 'actors') icon = window.CONFIG.Actor.sidebarIcon;
|
||||
else if (nr == 'actors') icon = "fas fa-users";
|
||||
else if (nr == 'items') icon = window.CONFIG.Item.sidebarIcon;
|
||||
else if (nr == 'journal') icon = window.CONFIG.JournalEntry.sidebarIcon;
|
||||
else if (nr == 'tables') icon = window.CONFIG.RollTable.sidebarIcon;
|
||||
else if (nr == 'cards') icon = "fas fa-id-badge";
|
||||
else if (nr == 'playlists') icon = window.CONFIG.Playlist.sidebarIcon;
|
||||
else if (nr == 'compendium') icon = "fas fa-atlas";
|
||||
else if (nr == 'settings') icon = "fas fa-cogs";
|
||||
@@ -653,7 +687,7 @@ export class OtherControls{
|
||||
|
||||
updateCompendiumBrowser(settings,context,device,options={}){
|
||||
let rendered = options.renderCompendiumBrowser;
|
||||
if (rendered == undefined && game.system.id == "pf2e") rendered = (document.getElementById("app-1") != null);
|
||||
if (rendered == undefined && gamingSystem == "pf2e") rendered = (document.getElementById("app-1") != null);
|
||||
else if (rendered == undefined) rendered = (document.getElementById("compendium-popout") != null);
|
||||
const background = settings.background ? settings.background : '#000000';
|
||||
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
|
||||
@@ -667,13 +701,13 @@ export class OtherControls{
|
||||
|
||||
keyPressCompendiumBrowser(settings){
|
||||
let element = null;
|
||||
if (game.system.id == "pf2e") element = document.getElementById("app-1")
|
||||
if (gamingSystem == "pf2e") element = document.getElementById("app-1")
|
||||
else element = document.getElementById("compendium-popout");
|
||||
const rendered = (element != null);
|
||||
|
||||
if (rendered)
|
||||
element.getElementsByClassName("close")[0].click();
|
||||
else if (game.system.id == "pf2e")
|
||||
else if (gamingSystem == "pf2e")
|
||||
document.getElementsByClassName("compendium-browser-btn")[0].click()
|
||||
else
|
||||
ui.compendium.renderPopout();
|
||||
@@ -812,4 +846,23 @@ export class OtherControls{
|
||||
this.updateAll();
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
updateRollMode(settings,context,device,options={}){
|
||||
const background = settings.background ? settings.background : '#000000';
|
||||
const ringOffColor = settings.offRing ? settings.offRing : '#000000';
|
||||
const ringOnColor = settings.onRing ? settings.onRing : '#00FF00';
|
||||
const iconSrc = "modules/MaterialDeck/img/other/d20.png";
|
||||
const rollMode = settings.rollMode ? settings.rollMode : 'roll';
|
||||
const ringColor = (rollMode == game.settings.get('core','rollMode')) ? ringOnColor : ringOffColor;
|
||||
streamDeck.setTitle("",context);
|
||||
streamDeck.setIcon(context,device,iconSrc,{background:background,ring:2,ringColor:ringColor,overlay:true});
|
||||
}
|
||||
|
||||
async keyPressRollMode(settings){
|
||||
const rollMode = settings.rollMode ? settings.rollMode : 'roll';
|
||||
await game.settings.set('core','rollMode',rollMode);
|
||||
this.updateAll();
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ export class PlaylistControl{
|
||||
this.updateTrack(settings,context,device);
|
||||
}
|
||||
else {
|
||||
const src = 'modules/MaterialDeck/img/playlist/stop.png';
|
||||
const src = mode == 'stopAll' ? 'modules/MaterialDeck/img/playlist/stop.png' : 'modules/MaterialDeck/img/playlist/pause.png';
|
||||
const background = settings.background ? settings.background : '#000000';
|
||||
const ringColor = (game.playlists.playing.length > 0) ? '#00FF00' : '#000000';
|
||||
const ring = (game.playlists.playing.length > 0) ? 2 : 1;
|
||||
@@ -167,6 +167,27 @@ export class PlaylistControl{
|
||||
}
|
||||
}
|
||||
|
||||
pauseAll(){
|
||||
if (game.user.isGM == false) {
|
||||
const payload = {
|
||||
"msgType": "pauseAllPlaylists"
|
||||
};
|
||||
game.socket.emit(`module.MaterialDeck`, payload);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
let playing = game.playlists.playing;
|
||||
for (let i=0; i<playing.length; i++){
|
||||
for (let sound of playing[i].sounds.contents) {
|
||||
if (sound.playing) sound.sound.pause();
|
||||
}
|
||||
}
|
||||
*/
|
||||
for (let elmnt of document.getElementsByClassName('sound-control pause'))
|
||||
elmnt.click();
|
||||
}
|
||||
|
||||
getPlaylist(num){
|
||||
let selectedPlaylists = game.settings.get(MODULE.moduleName,'playlists').selectedPlaylist;
|
||||
if (selectedPlaylists != undefined)
|
||||
@@ -191,6 +212,9 @@ export class PlaylistControl{
|
||||
if (playlistMode == 'stopAll') {
|
||||
this.stopAll(true);
|
||||
}
|
||||
else if (playlistMode == 'pauseAll') {
|
||||
this.pauseAll();
|
||||
}
|
||||
else {
|
||||
if (playlistType == 'playStop') {
|
||||
let playlist = this.getPlaylist(playlistNr);
|
||||
@@ -205,6 +229,12 @@ export class PlaylistControl{
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (playlistType == 'playNext') {
|
||||
this.getPlaylist(playlistNr).playNext();
|
||||
}
|
||||
else if (playlistType == 'playPrev') {
|
||||
this.getPlaylist(playlistNr).playNext(null,{direction:-1});
|
||||
}
|
||||
else if (playlistType == 'offset'){
|
||||
if (playlistMode == 'playlist') {
|
||||
this.playlistOffset = parseInt(settings.offset);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import * as MODULE from "../MaterialDeck.js";
|
||||
import { playlistConfigForm, macroConfigForm, soundboardConfigForm, downloadUtility } from "./misc.js";
|
||||
import { playlistConfigForm, macroConfigForm, soundboardConfigForm, downloadUtility, deviceConfig } from "./misc.js";
|
||||
|
||||
let userPermissions = {};
|
||||
const defaultEnable = [true,true,true,true];
|
||||
@@ -79,6 +79,19 @@ export const registerSettings = async function() {
|
||||
onChange: x => window.location.reload()
|
||||
});
|
||||
|
||||
/**
|
||||
* System override
|
||||
*/
|
||||
game.settings.register(MODULE.moduleName,'systemOverride', {
|
||||
name: "MaterialDeck.Sett.SystemOverride",
|
||||
hint: "MaterialDeck.Sett.SystemOverrideHint",
|
||||
scope: "client",
|
||||
config: true,
|
||||
default: "",
|
||||
type: String,
|
||||
onChange: x => window.location.reload()
|
||||
});
|
||||
|
||||
/**
|
||||
* Sets the ip address of the server
|
||||
*/
|
||||
@@ -133,6 +146,27 @@ export const registerSettings = async function() {
|
||||
restricted: false
|
||||
});
|
||||
|
||||
game.settings.registerMenu(MODULE.moduleName, 'downloadUtility',{
|
||||
name: "MaterialDeck.DownloadUtility.Title",
|
||||
label: "MaterialDeck.DownloadUtility.Title",
|
||||
type: downloadUtility,
|
||||
restricted: false
|
||||
});
|
||||
|
||||
game.settings.registerMenu(MODULE.moduleName, 'deviceConfig',{
|
||||
name: "MaterialDeck.DeviceConfig.Title",
|
||||
label: "MaterialDeck.DeviceConfig.Title",
|
||||
type: deviceConfig,
|
||||
restricted: false
|
||||
});
|
||||
|
||||
game.settings.register(MODULE.moduleName, 'devices', {
|
||||
name: "devices",
|
||||
scope: "client",
|
||||
type: Object,
|
||||
config: false
|
||||
});
|
||||
|
||||
game.settings.registerMenu(MODULE.moduleName, 'permissionConfig',{
|
||||
name: "MaterialDeck.Sett.Permission",
|
||||
label: "MaterialDeck.Sett.Permission",
|
||||
@@ -147,13 +181,6 @@ 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
|
||||
*/
|
||||
|
||||
@@ -34,7 +34,26 @@ export class StreamDeck{
|
||||
|
||||
}
|
||||
|
||||
setContext(device,size,iteration,action,context,coordinates = {column:0,row:0},settings){
|
||||
//getButtonContext
|
||||
|
||||
newDevice(iteration,device) {
|
||||
if (this.buttonContext[iteration] == undefined) {
|
||||
const deckSize = device.size.columns*device.size.rows;
|
||||
let buttons = [];
|
||||
for (let i=0; i<deckSize; i++){
|
||||
buttons[i] = undefined;
|
||||
}
|
||||
this.buttonContext[iteration] = {
|
||||
device: device.id,
|
||||
name: device.name,
|
||||
type: device.type,
|
||||
size: size,
|
||||
buttons: buttons
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setContext(device,size,iteration,action,context,coordinates = {column:0,row:0},settings, name, type){
|
||||
if (device == undefined) return;
|
||||
if (this.buttonContext[iteration] == undefined) {
|
||||
const deckSize = size.columns*size.rows;
|
||||
@@ -44,6 +63,8 @@ export class StreamDeck{
|
||||
}
|
||||
this.buttonContext[iteration] = {
|
||||
device: device,
|
||||
name: name,
|
||||
type: type,
|
||||
size: size,
|
||||
buttons: buttons
|
||||
}
|
||||
@@ -61,7 +82,7 @@ export class StreamDeck{
|
||||
|
||||
clearContext(device,action,coordinates = {column:0,row:0}){
|
||||
for (let d of this.buttonContext) {
|
||||
if (d.device == device) {
|
||||
if (d?.device == device) {
|
||||
const num = coordinates.column + coordinates.row*d.size.columns;
|
||||
d.buttons[num] = undefined;
|
||||
return;
|
||||
@@ -241,7 +262,7 @@ export class StreamDeck{
|
||||
|
||||
//if (src != 'modules/MaterialDeck/img/black.png')
|
||||
for (let d of this.buttonContext) {
|
||||
if (d.device == device) {
|
||||
if (d?.device == device) {
|
||||
for (let i=0; i<d.buttons.length; i++){
|
||||
if (clock != false) break;
|
||||
if (d.buttons[i] == undefined) continue;
|
||||
@@ -357,15 +378,13 @@ export class StreamDeck{
|
||||
if(isNaN(parseInt(background[i],16)))
|
||||
BGvalid = false;
|
||||
if (BGvalid == false) background = '#000000';
|
||||
|
||||
let canvas;
|
||||
if (canvas == null || canvas == undefined){
|
||||
canvas = document.createElement('canvas');
|
||||
canvas.width="144";
|
||||
canvas.height="144";
|
||||
canvas.style="background-color:transparent;visibility:hidden";
|
||||
document.getElementById('sdCanvasBox').appendChild(canvas); // adds the canvas to #someBox
|
||||
}
|
||||
|
||||
let canvas = document.createElement('canvas');
|
||||
canvas.width="144";
|
||||
canvas.height="144";
|
||||
canvas.style="background-color:transparent;visibility:hidden;display:none";
|
||||
document.getElementById('sdCanvasBox').appendChild(canvas); // adds the canvas to #someBox
|
||||
|
||||
this.counter++;
|
||||
if (this.counter > 31) this.counter = 0;
|
||||
|
||||
@@ -413,6 +432,7 @@ export class StreamDeck{
|
||||
|
||||
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();
|
||||
img.setAttribute('crossorigin', 'anonymous');
|
||||
@@ -452,11 +472,16 @@ export class StreamDeck{
|
||||
}
|
||||
ctx.drawImage(img, xStart+margin, yStart+margin, renderableWidth - 2*margin, renderableHeight - 2*margin);
|
||||
if (uses != undefined && uses.heart == undefined) {
|
||||
|
||||
let txt = '';
|
||||
let noMaxUses = false;
|
||||
if (uses.available != undefined) {
|
||||
txt = uses.available;
|
||||
if (uses.maximum != undefined) txt = uses.available + '/' + uses.maximum;
|
||||
if (uses.maximum == undefined ) uses.maximum = 1;
|
||||
if (uses.maximum == undefined ) {
|
||||
uses.maximum = 1;
|
||||
noMaxUses = true;
|
||||
}
|
||||
}
|
||||
ctx.beginPath();
|
||||
ctx.lineWidth = 4;
|
||||
@@ -466,7 +491,8 @@ export class StreamDeck{
|
||||
if (green.length == 1) green = "0"+green;
|
||||
red = red.toString(16);
|
||||
if (red.length == 1) red = "0"+red;
|
||||
if (uses.available == 0) ctx.strokeStyle = "#c80000";
|
||||
if (noMaxUses) ctx.strokeStyle = "#c000000";
|
||||
else if (uses.available == 0) ctx.strokeStyle = "#c80000";
|
||||
else ctx.strokeStyle = "#"+red.toString(16)+green.toString(16)+"00";
|
||||
const rect = {height:35, paddingSides:20, paddingBottom: 4}
|
||||
ctx.rect(rect.paddingSides, 144-rect.height-rect.paddingBottom,144-2*rect.paddingSides,rect.height);
|
||||
@@ -577,4 +603,4 @@ export class StreamDeck{
|
||||
this.setIcon(context,device,url,{background:background});
|
||||
this.setTitle(txt,context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,4 +130,19 @@ export class demonlord{
|
||||
getSpellUses(token,level,item) {
|
||||
return;
|
||||
}
|
||||
|
||||
rollItem(item) {
|
||||
return item.roll()
|
||||
}
|
||||
|
||||
/**
|
||||
* Ring Colors
|
||||
*/
|
||||
getSkillRingColor(token, skill) {
|
||||
return;
|
||||
}
|
||||
|
||||
getSaveRingColor(token, save) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -195,4 +195,19 @@ export class dnd35e{
|
||||
maximum: item.maxCharges
|
||||
}
|
||||
}
|
||||
|
||||
rollItem(item) {
|
||||
return item.roll()
|
||||
}
|
||||
|
||||
/**
|
||||
* Ring Colors
|
||||
*/
|
||||
getSkillRingColor(token, skill) {
|
||||
return;
|
||||
}
|
||||
|
||||
getSaveRingColor(token, save) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,12 @@
|
||||
import {compatibleCore} from "../misc.js";
|
||||
|
||||
const proficiencyColors = {
|
||||
0: "#000000",
|
||||
0.5: "#804A00",
|
||||
1: "#C0C0C0",
|
||||
2: "#FFD700"
|
||||
}
|
||||
|
||||
export class dnd5e{
|
||||
constructor(){
|
||||
|
||||
@@ -198,4 +205,23 @@ export class dnd5e{
|
||||
maximum: token.actor.data.data.spells?.[`spell${level}`].max
|
||||
}
|
||||
}
|
||||
|
||||
rollItem(item) {
|
||||
return item.roll()
|
||||
}
|
||||
|
||||
/**
|
||||
* Ring Colors
|
||||
*/
|
||||
getSkillRingColor(token, skill) {
|
||||
const profLevel = token.actor.data.data?.skills[skill]?.proficient;
|
||||
if (profLevel == undefined) return;
|
||||
return proficiencyColors?.[profLevel];
|
||||
}
|
||||
|
||||
getSaveRingColor(token, save) {
|
||||
const profLevel = token.actor.data.data?.abilities[save]?.proficient;
|
||||
if (profLevel == undefined) return;
|
||||
return proficiencyColors?.[profLevel];
|
||||
}
|
||||
}
|
||||
249
src/systems/forbidden-lands.js
Normal file
@@ -0,0 +1,249 @@
|
||||
import {compatibleCore} from "../misc.js";
|
||||
|
||||
export class forbiddenlands{
|
||||
constructor(){
|
||||
|
||||
}
|
||||
|
||||
getHP(token) {
|
||||
const hp = token.actor.data.data.attribute.strength;
|
||||
return {
|
||||
value: hp.value,
|
||||
max: hp.max
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getAgility(token) {
|
||||
const agility = token.actor.data.data.attribute.agility;
|
||||
return {
|
||||
value: agility.value,
|
||||
max: agility.max
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getWits(token) {
|
||||
const wits = token.actor.data.data.attribute.wits;
|
||||
return {
|
||||
value: wits.value,
|
||||
max: wits.max
|
||||
}
|
||||
}
|
||||
|
||||
getEmpathy(token) {
|
||||
const empathy = token.actor.data.data.attribute.empathy;
|
||||
return {
|
||||
value: empathy.value,
|
||||
max: empathy.max
|
||||
}
|
||||
}
|
||||
|
||||
getWillPower(token) {
|
||||
const wp = token.actor.data.data.bio.willpower;
|
||||
return {
|
||||
value: wp.value,
|
||||
max: wp.max
|
||||
}
|
||||
}
|
||||
|
||||
getTempHP(token) {
|
||||
return 0;
|
||||
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) {
|
||||
|
||||
const totalArmor = token.actor.itemTypes.armor.reduce((sum, armor) => {
|
||||
if (armor.itemProperties.part === "shield") return sum;
|
||||
const value = armor.itemProperties.bonus.value;
|
||||
return (sum += value);
|
||||
}, 0);
|
||||
return totalArmor;
|
||||
}
|
||||
|
||||
getShieldHP(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getSpeed(token) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
getInitiative(token) {
|
||||
return 0;
|
||||
let initiative = token.actor.data.data.attributes.init.total;
|
||||
return (initiative >= 0) ? `+${initiative}` : initiative;
|
||||
}
|
||||
|
||||
toggleInitiative(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getPassivePerception(token) {
|
||||
return 0;
|
||||
return token.actor.data.data.skills.prc.passive;
|
||||
}
|
||||
|
||||
getPassiveInvestigation(token) {
|
||||
return;
|
||||
return token.actor.data.data.skills.inv.passive;
|
||||
}
|
||||
|
||||
getAbility(token, ability) {
|
||||
if (ability == undefined) ability = 'strength';
|
||||
return token.actor.data.data.attribute?.[ability].value;
|
||||
}
|
||||
|
||||
getAbilityModifier(token, ability) {
|
||||
return;
|
||||
}
|
||||
|
||||
getAbilitySave(token, ability) {
|
||||
return this.getAbility(token, ability);
|
||||
}
|
||||
|
||||
getSkill(token, skill) {
|
||||
if (skill == undefined) skill = 'might';
|
||||
let skillComp = token.actor.sheet.getSkill(skill);
|
||||
const val = skillComp.skill.value + skillComp.attribute.value;
|
||||
return game.i18n.localize(skillComp.skill.label)+`-${val}`;
|
||||
}
|
||||
|
||||
getProficiency(token) {
|
||||
return;
|
||||
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 = 'strength';
|
||||
if (skill == undefined) skill = 'might';
|
||||
if (save == undefined) save = 'strength';
|
||||
|
||||
if (roll == 'ability') token.actor.sheet.rollAttribute(ability);
|
||||
else if (roll == 'save') token.actor.sheet.rollAttribute(save);
|
||||
else if (roll == 'skill') token.actor.sheet.rollSkill(skill);
|
||||
else if (roll == 'rollFood') token.actor.sheet.rollConsumable('food');
|
||||
else if (roll == 'rollWater') token.actor.sheet.rollConsumable('water');
|
||||
else if (roll == 'rollArrows') token.actor.sheet.rollConsumable('arrows');
|
||||
else if (roll == 'rollTorches') token.actor.sheet.rollConsumable('torches');
|
||||
else if (roll == 'rollArmor') token.actor.sheet.rollArmor();
|
||||
else if (roll == 'monsterAttack') token.actor.sheet.rollAttack();
|
||||
//else if (roll == 'initiative') token.actor.rollInitiative(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 == 'armor' || i.type == 'gear' || i.type == 'rawMaterial');
|
||||
else if (token.actor.type == 'monster' && itemType == 'weapon')
|
||||
{
|
||||
return allItems.filter(i => i.type == 'monsterAttack');
|
||||
}
|
||||
return allItems.filter(i => i.type == itemType);
|
||||
}
|
||||
|
||||
getItemUses(item) {
|
||||
if (item.type == 'monsterAttack') return;
|
||||
if (item.type == 'rawMaterial') return {available: item.data.data.quantity};
|
||||
return {available: item.data.data.bonus.value,
|
||||
maximum: item.data.data.bonus.max};
|
||||
}
|
||||
|
||||
/**
|
||||
* Features
|
||||
*/
|
||||
getFeatures(token,featureType) {
|
||||
if (featureType == undefined) featureType = 'any';
|
||||
const allItems = token.actor.items;
|
||||
if (featureType == 'any') return allItems.filter(i => i.type == 'talent')
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
rollItem(item) {
|
||||
const sheet = item.actor.sheet;
|
||||
if (item.type === "armor")
|
||||
return sheet.rollSpecificArmor(item.id);
|
||||
else if (item.type === "weapon")
|
||||
return sheet.rollGear(item.id);
|
||||
else if (item.type === "spell")
|
||||
return sheet.rollSpell(item.id);
|
||||
else if (item.type === "monsterAttack")
|
||||
sheet.rollSpecificAttack(item.id);
|
||||
return item.sendToChat();
|
||||
}
|
||||
|
||||
/**
|
||||
* Ring Colors
|
||||
*/
|
||||
getSkillRingColor(token, skill) {
|
||||
return;
|
||||
}
|
||||
|
||||
getSaveRingColor(token, save) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +1,79 @@
|
||||
import {compatibleCore} from "../misc.js";
|
||||
import {otherControls} from "../../MaterialDeck.js";
|
||||
|
||||
const limitedSheets = ['loot', 'vehicle'];
|
||||
const proficiencyColors =
|
||||
{
|
||||
untrained: "#424242",
|
||||
trained: "#171F69",
|
||||
expert: "#3C005E",
|
||||
master: "#664400",
|
||||
legendary: "#5E0000"
|
||||
};
|
||||
|
||||
export class pf2e{
|
||||
|
||||
constructor(){
|
||||
|
||||
}
|
||||
|
||||
tokenSpellData = new Map();
|
||||
|
||||
getHP(token) {
|
||||
const hp = token.actor.data.data.attributes.hp;
|
||||
const hp = token.actor.attributes?.hp;
|
||||
return {
|
||||
value: hp.value,
|
||||
max: hp.max
|
||||
value: (hp?.value == null) ? 0 : hp.value,
|
||||
max: (hp?.max == null) ? 0 : hp.max
|
||||
}
|
||||
}
|
||||
|
||||
getTempHP(token) {
|
||||
const hp = token.actor.data.data.attributes.hp;
|
||||
const hp = token.actor.attributes?.hp;
|
||||
return {
|
||||
value: (hp.temp == null) ? 0 : hp.temp,
|
||||
max: (hp.tempmax == null) ? 0 : hp.tempmax
|
||||
value: (hp?.temp == null) ? 0 : hp.temp,
|
||||
max: (hp?.tempmax == null) ? 0 : hp.tempmax
|
||||
}
|
||||
}
|
||||
|
||||
getAC(token) {
|
||||
return token.actor.data.data.attributes.ac.value;
|
||||
const ac = token.actor.attributes?.ac;
|
||||
return (ac?.value == null) ? 10 : ac?.value;
|
||||
}
|
||||
|
||||
getShieldHP(token) {
|
||||
return token.actor.data.data.attributes.shield.value;
|
||||
const shieldhp = token.actor.attributes.shield
|
||||
return (shieldhp?.value == null) ? 0 : shieldhp?.value;
|
||||
}
|
||||
|
||||
getSpeed(token) {
|
||||
let speed = token.actor.data.data.attributes.speed.breakdown;
|
||||
const otherSpeeds = token.actor.data.data.attributes.speed.otherSpeeds;
|
||||
if (this.isLimitedSheet(token.actor) || token.actor.type == 'hazard') {
|
||||
if (token.actor.type == 'vehicle') {
|
||||
return token.actor.data.data.details.speed;
|
||||
} else return '';
|
||||
}
|
||||
let speed = `${token.actor.attributes.speed?.total}'`;
|
||||
const otherSpeeds = token.actor.attributes.speed?.otherSpeeds;
|
||||
if (otherSpeeds.length > 0)
|
||||
for (let i=0; i<otherSpeeds.length; i++)
|
||||
speed += `\n${otherSpeeds[i].type}: ${otherSpeeds[i].value}`;
|
||||
for (let os of otherSpeeds)
|
||||
speed += `\n${os.type} ${os.total}'`;
|
||||
return speed;
|
||||
}
|
||||
|
||||
getInitiative(token) {
|
||||
let initiative = token.actor.data.data.attributes.init.value;
|
||||
return (initiative >= 0) ? `+${initiative}` : initiative;
|
||||
if (this.isLimitedSheet(token.actor) || token.actor.type == 'familiar') return '';
|
||||
if (token.actor.type == 'hazard') {
|
||||
let initiative = token.actor.attributes?.stealth?.value;
|
||||
return `Init: Stealth (${initiative})`;
|
||||
}
|
||||
let initiative = token.actor.attributes.initiative;
|
||||
let initiativeModifier = initiative?.totalModifier;
|
||||
let initiativeLabel = initiative?.label.replace('iative',''); //Initiative is too long for the button
|
||||
if (initiativeModifier > 0) {
|
||||
initiativeModifier = `+${initiativeModifier}`;
|
||||
} else {
|
||||
initiativeModifier = this.getPerception(token); //NPCs won't have a valid Initiative value, so default to use Perception
|
||||
}
|
||||
return `${initiativeLabel} (${initiativeModifier})`;
|
||||
}
|
||||
|
||||
toggleInitiative(token) {
|
||||
@@ -55,39 +88,85 @@ export class pf2e{
|
||||
return;
|
||||
}
|
||||
|
||||
getPerception(token) {
|
||||
if (this.isLimitedSheet(token.actor) || token.actor.type == 'hazard') return '';
|
||||
let perception = token.actor.attributes.perception?.totalModifier;
|
||||
return (perception >= 0) ? `+${perception}` : perception;
|
||||
}
|
||||
|
||||
getAbility(token, ability) {
|
||||
if (this.isLimitedSheet(token.actor) || token.actor.type == 'familiar') return '';
|
||||
if (ability == undefined) ability = 'str';
|
||||
return token.actor.data.data.abilities?.[ability].value;
|
||||
return token.actor.abilities?.[ability]?.value;
|
||||
}
|
||||
|
||||
getAbilityModifier(token, ability) {
|
||||
if (this.isLimitedSheet(token.actor) || token.actor.type == 'hazard' || token.actor.type == 'familiar') return '';
|
||||
if (ability == undefined) ability = 'str';
|
||||
let val = token.actor.data.data.abilities?.[ability].mod;
|
||||
let val = token.actor.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;
|
||||
ability = this.fixSave(ability);
|
||||
const save = this.findSave(token, ability);
|
||||
if (save == undefined) return '';
|
||||
let val = save?.value;
|
||||
return (val >= 0) ? `+${val}` : val;
|
||||
}
|
||||
|
||||
findSave(token, ability) {
|
||||
if (this.isLimitedSheet(token.actor)) return;
|
||||
return token.actor.data.data.saves?.[ability];
|
||||
}
|
||||
|
||||
fixSave(ability) {
|
||||
if (ability == undefined) return 'fortitude';
|
||||
else if (ability == 'fort') return 'fortitude';
|
||||
else if (ability == 'ref') return 'reflex';
|
||||
else if (ability == 'will') return 'will';
|
||||
}
|
||||
|
||||
getSkill(token, skill) {
|
||||
if (skill == undefined) skill = 'acr';
|
||||
const val = token.actor.data.data.skills?.[skill].totalModifier;
|
||||
const tokenSkill = this.findSkill(token, skill);
|
||||
if (tokenSkill == undefined) return '';
|
||||
|
||||
if (skill.startsWith('lor')) {
|
||||
return `${tokenSkill.name}: +${tokenSkill.totalModifier}`;
|
||||
}
|
||||
|
||||
const val = tokenSkill.totalModifier;
|
||||
return (val >= 0) ? `+${val}` : val;
|
||||
}
|
||||
|
||||
findSkill(token, skill) {
|
||||
if (this.isLimitedSheet(token.actor)) return;
|
||||
if (skill == undefined) skill = 'acr';
|
||||
if (skill.startsWith('lor')) {
|
||||
const index = parseInt(skill.split('_')[1])-1;
|
||||
const loreSkills = this.getLoreSkills(token);
|
||||
if (loreSkills.length > index) {
|
||||
return loreSkills[index];
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
return token.actor.data.data.skills?.[skill];
|
||||
}
|
||||
|
||||
getLoreSkills(token) {
|
||||
if (this.isLimitedSheet(token.actor)) return [];
|
||||
const skills = token.actor.data.data.skills;
|
||||
return Object.keys(skills).map(key => skills[key]).filter(s => s.lore == true);
|
||||
}
|
||||
|
||||
getProficiency(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getCondition(token,condition) {
|
||||
if (condition == undefined || condition == 'removeAll') return undefined;
|
||||
const Condition = condition.charAt(0).toUpperCase() + condition.slice(1);
|
||||
const Condition = this.getConditionName(condition);
|
||||
const effects = token.actor.items.filter(i => i.type == 'condition');
|
||||
return effects.find(e => e.name === Condition);
|
||||
}
|
||||
@@ -102,22 +181,52 @@ export class pf2e{
|
||||
return this.getCondition(token,condition) != undefined;
|
||||
}
|
||||
|
||||
async toggleCondition(token,condition) {
|
||||
getConditionValue(token,condition) {
|
||||
const effect = this.getCondition(token, condition);
|
||||
if (effect != undefined && effect?.value != null) return effect;
|
||||
}
|
||||
|
||||
async modifyConditionValue(token,condition,delta) {
|
||||
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.getConditionValue(token,condition);
|
||||
if (effect == undefined) {
|
||||
if (delta > 0) {
|
||||
await game.pf2e.ConditionManager.addConditionToToken(condition, token);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
await game.pf2e.ConditionManager.updateConditionValue(effect.id, token, effect.value+delta);
|
||||
} catch (error) {
|
||||
//Do nothing. updateConditionValue will have an error about 'documentData is not iterable' when called from an NPC token.
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
getConditionName(condition) {
|
||||
if ("flatFooted" == condition) {
|
||||
return 'Flat-Footed'; //An inconsistency has been introduced on the PF2E system. The icon is still using 'flatFooted' as the name, but the condition in the manager has been renamed to 'Flat-Footed'
|
||||
} else return condition.charAt(0).toUpperCase() + condition.slice(1);
|
||||
}
|
||||
|
||||
async toggleCondition(token,condition) {
|
||||
if (condition == undefined) condition = 'removeAll';
|
||||
if (condition == 'removeAll'){
|
||||
for( let existing of token.actor.items.filter(i => i.type == 'condition'))
|
||||
await game.pf2e.ConditionManager.removeConditionFromToken(existing.data._id, token);
|
||||
}
|
||||
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);
|
||||
await game.pf2e.ConditionManager.addConditionToToken(condition, token);
|
||||
}
|
||||
else {
|
||||
effect.delete();
|
||||
await game.pf2e.ConditionManager.removeConditionFromToken(effect.data._id, token);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -127,69 +236,278 @@ export class pf2e{
|
||||
* Roll
|
||||
*/
|
||||
roll(token,roll,options,ability,skill,save) {
|
||||
if (roll == undefined) roll = 'ability';
|
||||
if (this.isLimitedSheet(token.actor)) return;
|
||||
options.skipDialog = true;
|
||||
if (roll == undefined) roll = 'skill';
|
||||
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);
|
||||
if (roll == 'perception') {
|
||||
this.checkRoll(`Perception Check`, token.actor.perception, 'perception-check', token.actor);
|
||||
}
|
||||
if (roll == 'initiative') {
|
||||
token.actor.rollInitiative({createCombatants:true, initiativeOptions: {skipDialog: true}});
|
||||
}
|
||||
|
||||
if (roll == 'ability') return; //Ability Checks are not supported in pf2e
|
||||
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);
|
||||
if (token.actor.type == 'hazard' && ability == 'will') return; //Hazards don't have Will saves
|
||||
let abilityName = ability.charAt(0).toUpperCase() + ability.slice(1);
|
||||
this.checkRoll(`${abilityName} Saving Throw`, token.actor.saves?.[ability], 'saving-throw', token.actor);
|
||||
}
|
||||
else if (roll == 'skill') token.actor.data.data.skills?.[skill].roll(options);
|
||||
else if (roll == 'skill') {
|
||||
if (skill.startsWith('lor')) {
|
||||
const index = parseInt(skill.split('_')[1])-1;
|
||||
const loreSkills = this.getLoreSkills(token);
|
||||
if (loreSkills.length > index) {
|
||||
let loreSkill = loreSkills[index];
|
||||
skill = loreSkill.shortform == undefined? loreSkills[index].expanded : loreSkills[index].shortform;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
let skillName = token.actor.data.data.skills?.[skill].name;
|
||||
skillName = skillName.charAt(0).toUpperCase() + skillName.slice(1);
|
||||
this.checkRoll(`Skill Check: ${skillName}`, token.actor.skills?.[skill], 'skill-check', token.actor);
|
||||
}
|
||||
}
|
||||
|
||||
checkRoll(checkLabel,stat,type,actor) {
|
||||
let checkModifier = new game.pf2e.CheckModifier(checkLabel, stat);
|
||||
game.pf2e.Check.roll(checkModifier, {type:type, actor: actor, skipDialog: true}, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Items
|
||||
*/
|
||||
getItems(token,itemType) {
|
||||
if (this.isLimitedSheet(token.actor)) return [];
|
||||
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');
|
||||
if (itemType == 'weapon') return allItems.filter(i => i.type == 'weapon' || i.type == 'melee') //Include melee actions for NPCs without equipment
|
||||
else return allItems.filter(i => i.type == itemType);
|
||||
}
|
||||
|
||||
getItemUses(item) {
|
||||
return {available: item.data.data.quantity.value};
|
||||
return {available: item.quantity.value};
|
||||
}
|
||||
|
||||
/**
|
||||
* Features
|
||||
*/
|
||||
getFeatures(token,featureType) {
|
||||
if (this.isLimitedSheet(token.actor)) return [];
|
||||
if (featureType == undefined) featureType = 'any';
|
||||
const allItems = token.actor.items;
|
||||
if (featureType == 'any') return allItems.filter(i => i.type == 'class' || i.type == 'feat')
|
||||
if (featureType == 'any') return allItems.filter(i => i.type == 'ancestry' || i.type == 'background' || i.type == 'class' || i.type == 'feat' || i.type == 'action');
|
||||
if (featureType == 'action-any') return allItems.filter(i => i.type == 'action');
|
||||
if (featureType == 'action-def') return allItems.filter(i => i.type == 'action' && i.data.data.actionCategory?.value == 'defensive');
|
||||
if (featureType == 'action-int') return allItems.filter(i => i.type == 'action' && i.data.data.actionCategory?.value == 'interaction');
|
||||
if (featureType == 'action-off') return allItems.filter(i => i.type == 'action' && i.data.data.actionCategory?.value == 'offensive');
|
||||
if (featureType == 'strike') { //Strikes are not in the actor.items collection
|
||||
if (token.actor.type == 'hazard' || token.actor.type == 'familiar') {
|
||||
return allItems.filter(i => i.type == 'melee' || i.type == 'ranged');
|
||||
}
|
||||
let actions = token.actor.data.data.actions?.filter(a=>a.type == 'strike');
|
||||
for (let a of actions) {
|
||||
a.img = a.imageUrl;
|
||||
a.data = {
|
||||
sort: 1
|
||||
};
|
||||
}
|
||||
return actions;
|
||||
}
|
||||
else return allItems.filter(i => i.type == featureType)
|
||||
}
|
||||
|
||||
getFeatureUses(item) {
|
||||
if (item.data.type == 'class') return {available: item.actor.data.data.details.level.value};
|
||||
if (item.data.type == 'class') return {available: item.actor.details.level.value};
|
||||
else return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Spells
|
||||
*/
|
||||
buildSpellData(token) {
|
||||
let spellData = [[],[],[],[],[],[],[],[],[],[],[],[]];
|
||||
let spellcastingEntries = token.actor.spellcasting;
|
||||
const actorLevel = token.actor.data.data.details.level.value;
|
||||
spellcastingEntries.forEach(spellCastingEntry => {
|
||||
let highestSpellSlot = Math.ceil(actorLevel/2);
|
||||
while (spellCastingEntry.data.data.slots?.[`slot${highestSpellSlot}`]?.max <= 0) highestSpellSlot--;
|
||||
//Prepared (not flexible)
|
||||
if (spellCastingEntry.data.data.prepared?.value == 'prepared' && !spellCastingEntry?.data.data?.prepared?.flexible == true) {
|
||||
for (let slotLevel = 0; slotLevel < 11; slotLevel++) {
|
||||
for (let slot = 0; slot < spellCastingEntry.data.data.slots?.[`slot${slotLevel}`].max; slot++) {
|
||||
let spellId = spellCastingEntry.data.data.slots?.[`slot${slotLevel}`].prepared?.[slot].id;
|
||||
let spell = spellCastingEntry.spells.get(spellId);
|
||||
if (spellId != null) {
|
||||
spellData[slotLevel].push(spell);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
spellCastingEntry.spells.forEach( ses => {
|
||||
if ((spellCastingEntry.data.data.prepared.value == 'spontaneous' || spellCastingEntry.data.data.prepared?.flexible == true) && ses.data.data.location.signature == true) {
|
||||
let baseLevel = this.getSpellLevel(ses);
|
||||
for (let level = baseLevel; level <= highestSpellSlot; level++) {
|
||||
spellData[level].push(ses);
|
||||
}
|
||||
} else {
|
||||
spellData[this.getSpellLevel(ses)].push(ses);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
this.tokenSpellData.set(token.id, {spellData: spellData, timeStamp: Date.now()});
|
||||
return spellData;
|
||||
}
|
||||
|
||||
getSpellData(token) {
|
||||
let existingSpellData = this.tokenSpellData.get(token.id);
|
||||
if (existingSpellData == undefined) return this.buildSpellData(token);
|
||||
let milisSinceCreation = Date.now() - existingSpellData.timeStamp;
|
||||
if (milisSinceCreation > 10000) {
|
||||
this.tokenSpellData.delete(token.id);
|
||||
return this.buildSpellData(token);
|
||||
}
|
||||
return existingSpellData.spellData;
|
||||
}
|
||||
|
||||
getSpellLevel(spell) {
|
||||
if (spell.isFocusSpell == true) return 11;
|
||||
if (spell.isCantrip == true) return 0;
|
||||
return spell.level;
|
||||
}
|
||||
|
||||
getSpells(token,level) {
|
||||
if (this.isLimitedSheet(token.actor)) return '';
|
||||
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)
|
||||
let spellData = this.getSpellData(token);
|
||||
|
||||
if (level == 'f') return this.getUniqueSpells(spellData[11]);
|
||||
if (level == 'any') return this.getUniqueSpells(spellData.flat());
|
||||
return this.getUniqueSpells(spellData[level]);
|
||||
}
|
||||
|
||||
getUniqueSpells(spells) {
|
||||
return Array.from(new Set(spells));
|
||||
}
|
||||
|
||||
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 (this.isLimitedSheet(token.actor)) return '';
|
||||
if (level == undefined || level == 'any') level = item.level;
|
||||
if (item.isCantrip == true) return;
|
||||
if (item.isFocusSpell == true) return {
|
||||
available: token.actor.data.data.resources.focus.value,
|
||||
maximum: token.actor.data.data.resources.focus.max
|
||||
}
|
||||
const spellbook = this.findSpellcastingEntry(token.actor, item);
|
||||
if (spellbook == undefined) return;
|
||||
if (spellbook.data.data.prepared.value == 'innate') {
|
||||
return {
|
||||
available: item.data.data.location.uses.value,
|
||||
maximum: item.data.data.location.uses.max
|
||||
}
|
||||
}
|
||||
if (spellbook.data.data.prepared.value == 'prepared') {
|
||||
if (!spellbook.data.data.prepared?.flexible == true) {
|
||||
let slotsExpended = 0;
|
||||
let slotsPrepared = 0;
|
||||
for (let slot = 0; slot < spellbook.data.data.slots?.[`slot${level}`].max; slot++) {
|
||||
let slotEntry = spellbook.data.data.slots?.[`slot${level}`].prepared?.[slot];
|
||||
if (slotEntry.id == item.id) {
|
||||
slotsPrepared++;
|
||||
if (slotEntry?.expended == true) {
|
||||
slotsExpended++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
available: slotsPrepared - slotsExpended,
|
||||
maximum: slotsPrepared
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
available: spellbook.data.data.slots?.[`slot${level}`].value,
|
||||
maximum: spellbook.data.data.slots?.[`slot${level}`].max
|
||||
}
|
||||
}
|
||||
|
||||
findSpellcastingEntry(actor, spell) {
|
||||
let spellcastingEntries = actor.spellcasting;
|
||||
let result;
|
||||
spellcastingEntries.forEach(spellCastingEntry => {
|
||||
if (spellCastingEntry.spells.get(spell.id) != undefined) {
|
||||
result = spellCastingEntry;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
rollItem(item, settings) {
|
||||
let variant = 0;
|
||||
if (otherControls.rollOption == 'map1') variant = 1;
|
||||
if (otherControls.rollOption == 'map2') variant = 2;
|
||||
if (item?.parent?.type == 'hazard' && item.type==='melee') return item.rollNPCAttack({}, variant+1);
|
||||
if (item.type==='strike') return item.variants[variant].roll({event});
|
||||
if (item?.parent?.type !== 'hazard' && (item.type==='weapon' || item.type==='melee')) return item.parent.actions.find(a=>a.name===item.name).variants[variant].roll({event});
|
||||
if (item.type === 'spell') {
|
||||
const spellbook = this.findSpellcastingEntry(item.parent, item);
|
||||
if (spellbook != undefined) {
|
||||
let spellLvl = item.level;
|
||||
if (settings.spellType == 'f' || settings.spellType == '0') {
|
||||
const actorLevel = item.parent.data.data.details.level.value;
|
||||
spellLvl = Math.ceil(actorLevel/2);
|
||||
} else if (settings.spellType != 'any') {
|
||||
spellLvl = settings.spellType;
|
||||
}
|
||||
if (spellbook.data.data.prepared.value == 'prepared' && !spellbook.data.data.prepared?.flexible == true) {
|
||||
for (let slotId = 0; slotId < spellbook.data.data.slots?.[`slot${spellLvl}`].max; slotId++) {
|
||||
let slotEntry = spellbook.data.data.slots?.[`slot${spellLvl}`].prepared?.[slotId];
|
||||
if (slotEntry.id == item.id) {
|
||||
if (!slotEntry?.expended == true) {
|
||||
return spellbook.cast(item, {slot: slotId, level: spellLvl});
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return spellbook.cast(item, { level: spellLvl});
|
||||
}
|
||||
}
|
||||
}
|
||||
return game.pf2e.rollItemMacro(item.id);
|
||||
}
|
||||
|
||||
isLimitedSheet(actor) {
|
||||
return limitedSheets.includes(actor.type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ring Colors
|
||||
*/
|
||||
getSkillRingColor(token, skill) {
|
||||
return this.getRingColor(this.findSkill(token, skill));
|
||||
}
|
||||
|
||||
getSaveRingColor(token, save) {
|
||||
save = this.fixSave(save);
|
||||
return this.getRingColor(this.findSave(token, save));
|
||||
}
|
||||
|
||||
getRingColor(stat) {
|
||||
if (stat == undefined) return;
|
||||
let statModifiers = stat?.modifiers || stat?._modifiers;
|
||||
const profLevel = statModifiers?.find(m => m.type == 'proficiency')?.slug;
|
||||
if (profLevel != undefined) {
|
||||
return proficiencyColors?.[profLevel];
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
242
src/systems/starfinder.js
Normal file
@@ -0,0 +1,242 @@
|
||||
import {compatibleCore} from "../misc.js";
|
||||
|
||||
const proficiencyColors = {
|
||||
0: "#000000",
|
||||
0.5: "#804A00",
|
||||
1: "#C0C0C0",
|
||||
2: "#FFD700"
|
||||
}
|
||||
|
||||
export class starfinder{
|
||||
constructor(){
|
||||
|
||||
}
|
||||
|
||||
getHP(token) {
|
||||
const hp = token.actor.data.data.attributes.hp;
|
||||
return {
|
||||
value: hp.value,
|
||||
max: hp.max
|
||||
}
|
||||
}
|
||||
|
||||
getTempHP(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getStamina(token) {
|
||||
const stamina = token.actor.data.data.attributes.sp;
|
||||
return {
|
||||
value: stamina.value,
|
||||
max: stamina.max
|
||||
}
|
||||
}
|
||||
|
||||
getAC(token) {
|
||||
return token.actor.data.data.attributes.eac.value;
|
||||
}
|
||||
|
||||
getKinAC(token) {
|
||||
return token.actor.data.data.attributes.kac.value;
|
||||
}
|
||||
|
||||
getShieldHP(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getSpeed(token) {
|
||||
const movement = token.actor.data.data.attributes.speed;
|
||||
let speed = "";
|
||||
if (movement.burrowing.value > 0) speed += `Burrow: ${movement.burrowing.value}Ft`;
|
||||
if (movement.climbing.value > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += `Climb: ${movement.climbing.value}Ft`;
|
||||
}
|
||||
if (movement.flying.value > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += `Fly: ${movement.flying.value}Ft`;
|
||||
}
|
||||
if (movement.land.value > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += `Land: ${movement.land.value}Ft`;
|
||||
}
|
||||
if (movement.swimming.value > 0) {
|
||||
if (speed.length > 0) speed += '\n';
|
||||
speed += `Swim: ${movement.swimming.value}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';
|
||||
else if (ability == 'ref') ability = 'reflex';
|
||||
let val = token.actor.data.data.attributes?.[ability].bonus;
|
||||
return (val >= 0) ? `+${val}` : val;
|
||||
}
|
||||
|
||||
getSkill(token, skill) {
|
||||
if (skill == undefined) skill = 'acr';
|
||||
const val = token.actor.data.data.skills?.[skill].mod;
|
||||
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) {
|
||||
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 == 'shield' || i.type == 'equipment' || i.type == 'consumable' || i.type == 'goods' || i.type == 'container' || i.type == 'technological' || i.type == 'fusion' || i.type == 'upgrade' || i.type == 'weaponAccessory' || i.type == 'augmentation');
|
||||
else if (itemType == 'enhancers') return allItems.filter(i => i.type == 'fusion' || i.type == 'upgrade' || i.type == 'weaponAccessory');
|
||||
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 == 'race' || i.type == 'theme'|| i.type == 'asi' || i.type == 'archetype' || i.type == 'feat' || i.type == 'actorResource')
|
||||
else if (featureType == 'activeFeat' || featureType == 'passiveFeat') {
|
||||
const features = allItems.filter(i => i.type == 'feat');
|
||||
if (featureType == 'activeFeat') return features.filter(i => i.labels.featType == 'Action');
|
||||
else return features.filter(i => i.labels.featType == 'Passive');
|
||||
}
|
||||
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 if (level == 'innate') return allItems.filter(i => i.type == 'spell' && i.data.data.preparation.mode == 'innate');
|
||||
else return allItems.filter(i => i.type == 'spell' && i.data.data.preparation.mode == '' && i.data.data.level == level)
|
||||
}
|
||||
|
||||
getSpellUses(token,level,item) {
|
||||
if (level == undefined) level = 'any';
|
||||
if (item.data.data.level == 0) return;
|
||||
|
||||
const spellSlots = token.actor.data.data.spells;
|
||||
const allowedClasses = item.data.data.allowedClasses;
|
||||
|
||||
let uses = {available: 0, maximum: 0};
|
||||
if (allowedClasses.myst && spellSlots?.[`spell${level}`].perClass?.mystic?.max > uses.maximum)
|
||||
uses = {available: spellSlots?.[`spell${level}`].perClass?.mystic.value, maximum: spellSlots?.[`spell${level}`].perClass?.mystic.max}
|
||||
if (allowedClasses.precog && spellSlots?.[`spell${level}`].perClass?.precog?.max > uses.maximum)
|
||||
uses = {available: spellSlots?.[`spell${level}`].perClass?.precog.value, maximum: spellSlots?.[`spell${level}`].perClass?.precog.max}
|
||||
if (allowedClasses.tech && spellSlots?.[`spell${level}`].perClass?.technomancer?.max > uses.maximum)
|
||||
uses = {available: spellSlots?.[`spell${level}`].perClass?.technomancer.value, maximum: spellSlots?.[`spell${level}`].perClass?.technomancer.max}
|
||||
if (allowedClasses.wysh && spellSlots?.[`spell${level}`].perClass?.witchwarper?.max > uses.maximum)
|
||||
uses = {available: spellSlots?.[`spell${level}`].perClass?.witchwarper.value, maximum: spellSlots?.[`spell${level}`].perClass?.witchwarper.max}
|
||||
|
||||
return uses;
|
||||
}
|
||||
|
||||
rollItem(item) {
|
||||
return item.roll()
|
||||
}
|
||||
|
||||
/**
|
||||
* Ring Colors
|
||||
*/
|
||||
getSkillRingColor(token, skill) {
|
||||
const profLevel = token.actor.data.data?.skills[skill]?.proficient;
|
||||
if (profLevel == undefined) return;
|
||||
return proficiencyColors?.[profLevel];
|
||||
}
|
||||
|
||||
getSaveRingColor(token, save) {
|
||||
const profLevel = token.actor.data.data?.abilities[save]?.proficient;
|
||||
if (profLevel == undefined) return;
|
||||
return proficiencyColors?.[profLevel];
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,13 @@
|
||||
import {dnd5e} from "./dnd5e.js"
|
||||
import {dnd35e} from "./dnd35e.js"
|
||||
import {pf2e} from "./pf2e.js"
|
||||
import {dnd5e} from "./dnd5e.js";
|
||||
import {dnd35e} from "./dnd35e.js";
|
||||
import {pf2e} from "./pf2e.js";
|
||||
import {demonlord} from "./demonlord.js";
|
||||
import {wfrp4e} from "./wfrp4e.js";
|
||||
import {forbiddenlands} from "./forbidden-lands.js";
|
||||
import {starfinder} from "./starfinder.js";
|
||||
import {compatibleCore} from "../misc.js";
|
||||
import {gamingSystem} from "../../MaterialDeck.js";
|
||||
|
||||
|
||||
export class TokenHelper{
|
||||
constructor(){
|
||||
@@ -11,9 +16,12 @@ export class TokenHelper{
|
||||
}
|
||||
|
||||
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();
|
||||
if (gamingSystem == 'D35E' || gamingSystem == 'pf1') this.system = new dnd35e();
|
||||
else if (gamingSystem == 'pf2e') this.system = new pf2e();
|
||||
else if (gamingSystem == 'demonlord') this.system = new demonlord();
|
||||
else if (gamingSystem == 'wfrp4e') this.system = new wfrp4e();
|
||||
else if (gamingSystem == 'forbidden-lands') this.system = new forbiddenlands();
|
||||
else if (gamingSystem == 'sfrpg') this.system = new starfinder();
|
||||
else this.system = new dnd5e(); //default to dnd5e
|
||||
}
|
||||
|
||||
@@ -29,7 +37,7 @@ export class TokenHelper{
|
||||
else if (type == 'actorId') return this.getTokenFromActorId(identifier);
|
||||
}
|
||||
getTokenFromTokenId(id) {
|
||||
return canvas.tokens.children[0].children.find(p => p.id == id);
|
||||
return canvas.tokens.get(id);
|
||||
}
|
||||
|
||||
getTokenFromTokenName(name) {
|
||||
@@ -78,7 +86,8 @@ export class TokenHelper{
|
||||
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 (game.user.isGM == false && game.paused) return;
|
||||
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});
|
||||
};
|
||||
@@ -126,7 +135,7 @@ export class TokenHelper{
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* System agnostic functions
|
||||
* System specific functions
|
||||
***********************************************************************/
|
||||
getHP(token) {
|
||||
return this.system.getHP(token);
|
||||
@@ -184,6 +193,76 @@ export class TokenHelper{
|
||||
return this.system.getProficiency(token);
|
||||
}
|
||||
|
||||
/* WFRP 4E */
|
||||
getFate(token) {
|
||||
return this.system.getFate(token)
|
||||
}
|
||||
|
||||
/* WFRP 4E */
|
||||
getFortune(token) {
|
||||
return this.system.getFortune(token)
|
||||
}
|
||||
|
||||
/* WFRP 4E */
|
||||
getCriticalWounds(token) {
|
||||
return this.system.getCriticalWounds(token)
|
||||
}
|
||||
|
||||
/* WFRP 4E */
|
||||
getCorruption(token) {
|
||||
return this.system.getCorruption(token)
|
||||
}
|
||||
|
||||
/* WFRP 4E */
|
||||
getAdvantage(token) {
|
||||
return this.system.getAdvantage(token)
|
||||
}
|
||||
|
||||
/* WFRP 4E */
|
||||
getResolve(token) {
|
||||
return this.system.getResolve(token)
|
||||
}
|
||||
|
||||
/* WFRP 4E */
|
||||
getResilience(token) {
|
||||
return this.system.getResilience(token)
|
||||
}
|
||||
|
||||
/* PF2E */
|
||||
getPerception(token) {
|
||||
return this.system.getPerception(token)
|
||||
}
|
||||
|
||||
/* forbidden-lands */
|
||||
getAgility(token) {
|
||||
return this.system.getAgility(token)
|
||||
}
|
||||
|
||||
/* forbidden-lands */
|
||||
getWits(token) {
|
||||
return this.system.getWits(token)
|
||||
}
|
||||
|
||||
/* forbidden-lands */
|
||||
getEmpathy(token) {
|
||||
return this.system.getEmpathy(token)
|
||||
}
|
||||
/* forbidden-lands */
|
||||
getWillPower(token) {
|
||||
return this.system.getWillPower(token)
|
||||
}
|
||||
|
||||
/* starfinder */
|
||||
getStamina(token) {
|
||||
return this.system.getStamina(token);
|
||||
}
|
||||
|
||||
/* starfinder */
|
||||
getKinAC(token) {
|
||||
return this.system.getKinAC(token);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Conditions
|
||||
*/
|
||||
@@ -199,6 +278,16 @@ export class TokenHelper{
|
||||
return this.system.toggleCondition(token,condition);
|
||||
}
|
||||
|
||||
/* PF2E */
|
||||
getConditionValue(token,condition) {
|
||||
return this.system.getConditionValue(token,condition);
|
||||
}
|
||||
|
||||
/* PF2E */
|
||||
modifyConditionValue(token,condition,delta) {
|
||||
return this.system.modifyConditionValue(token,condition,delta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Roll
|
||||
*/
|
||||
@@ -238,4 +327,18 @@ export class TokenHelper{
|
||||
getSpellUses(token,level,item) {
|
||||
return this.system.getSpellUses(token,level,item);
|
||||
}
|
||||
|
||||
rollItem(item, settings) {
|
||||
return this.system.rollItem(item, settings);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ring Colors
|
||||
*/
|
||||
getSkillRingColor(token,skill) {
|
||||
return this.system.getSkillRingColor(token,skill);
|
||||
}
|
||||
getSaveRingColor(token,save) {
|
||||
return this.system.getSaveRingColor(token,save);
|
||||
}
|
||||
}
|
||||
179
src/systems/wfrp4e.js
Normal file
@@ -0,0 +1,179 @@
|
||||
import {compatibleCore} from "../misc.js";
|
||||
|
||||
export class wfrp4e {
|
||||
constructor(){
|
||||
|
||||
}
|
||||
|
||||
getFate(token) {
|
||||
return token.actor.data.data.status.fate.value
|
||||
}
|
||||
|
||||
getFortune(token) {
|
||||
return token.actor.data.data.status.fortune.value
|
||||
}
|
||||
|
||||
|
||||
getWounds(token) {
|
||||
const wounds = token.actor.data.data.status.wounds
|
||||
return {
|
||||
value: wounds.value,
|
||||
max: wounds.max
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
getCriticalWounds(token) {
|
||||
const criticalWounds = token.actor.data.data.status.criticalWounds
|
||||
return {
|
||||
value: criticalWounds.value,
|
||||
max: criticalWounds.max
|
||||
}
|
||||
}
|
||||
|
||||
getCorruption(token) {
|
||||
return token.actor.data.data.status.corruption.value
|
||||
}
|
||||
|
||||
getAdvantage(token) {
|
||||
return token.actor.data.data.status.advantage.value
|
||||
}
|
||||
|
||||
getResolve(token) {
|
||||
return token.actor.data.data.status.resolve.value
|
||||
}
|
||||
|
||||
getResilience(token) {
|
||||
return token.actor.data.data.status.resilience.value
|
||||
}
|
||||
|
||||
getAbility(token, abilityName) {
|
||||
return this.getCharacteristics(token, abilityName);
|
||||
}
|
||||
|
||||
getCharacteristics(token, characteristicName) {
|
||||
if (characteristicName == undefined ) characteristicName = `AG`;
|
||||
const characteristic = token.actor.data.data.characteristics[characteristicName.toLowerCase()]
|
||||
const val = characteristic.value;
|
||||
return (val >= 0) ? `+${val}` : val;
|
||||
}
|
||||
|
||||
getFeatures(token,featureType) {
|
||||
if (featureType == undefined) featureType = 'any';
|
||||
const allItems = token.actor.items;
|
||||
if (featureType == 'any') return allItems.filter(i => i.type == 'skill' || i.type == 'talent' || i.type == "career" || i.type == 'trait');
|
||||
return allItems.filter(i => i.type == featureType);
|
||||
}
|
||||
getSpells(token,spellType) {
|
||||
const allItems = token.actor.items;
|
||||
return allItems.filter(i => i.type == 'spell')
|
||||
}
|
||||
|
||||
getSpellUses(token,level,item) {
|
||||
return;
|
||||
}
|
||||
|
||||
getFeatureUses(item) {
|
||||
return {available: `+${item.data.data.total.value}`};
|
||||
}
|
||||
|
||||
getHP(token) {
|
||||
return this.getWounds(token);
|
||||
}
|
||||
|
||||
rollItem(item) {
|
||||
return game.wfrp4e.utility.rollItemMacro(item.name, item.type, false);
|
||||
}
|
||||
|
||||
getSpeed(token) {
|
||||
return token.actor.data.data.details.move.value;
|
||||
}
|
||||
|
||||
|
||||
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(token,roll,options,ability,skill,save) {
|
||||
if (ability == undefined) ability = 'ag';
|
||||
return game.wfrp4e.utility.rollItemMacro(ability, "characteristic", false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
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 == 'ammunition' ||
|
||||
i.type == 'armour' ||
|
||||
i.type == 'trapping');
|
||||
else {
|
||||
return allItems.filter(i => i.type == itemType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
getItemUses(item) {
|
||||
if ( item.type == 'ammunition') {
|
||||
return {available: item.data.data.quantity.value};
|
||||
}
|
||||
else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* this is all cargo-culted in and some of it could be deleted once the interface is resolved
|
||||
to not be the superset of all possible systems
|
||||
*/
|
||||
|
||||
getAC(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getShieldHP(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
getInitiative(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
toggleInitiative(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
getConditionIcon(condition) {
|
||||
return;
|
||||
}
|
||||
|
||||
getConditionActive(token,condition) {
|
||||
return;
|
||||
}
|
||||
|
||||
getTempHP(token) {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ring Colors
|
||||
*/
|
||||
getSkillRingColor(token, skill) {
|
||||
return;
|
||||
}
|
||||
|
||||
getSaveRingColor(token, save) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
162
src/token.js
@@ -1,5 +1,6 @@
|
||||
import * as MODULE from "../MaterialDeck.js";
|
||||
import {streamDeck, macroControl, otherControls, tokenHelper} from "../MaterialDeck.js";
|
||||
import { compatibleCore } from "./misc.js";
|
||||
|
||||
export class TokenControl{
|
||||
constructor(){
|
||||
@@ -94,7 +95,7 @@ export class TokenControl{
|
||||
}
|
||||
}
|
||||
|
||||
if (stats == 'HP') {
|
||||
if (stats == 'HP' || stats == 'Wounds') {
|
||||
const hp = tokenHelper.getHP(token);
|
||||
txt += hp.value + "/" + hp.max;
|
||||
|
||||
@@ -105,6 +106,71 @@ export class TokenControl{
|
||||
heart: "#FF0000"
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
if (stats == 'Agility') { /* forbidden-lands */
|
||||
const wits = tokenHelper.getAgility(token);
|
||||
txt += wits.value + "/" + wits.max;
|
||||
|
||||
if (icon == 'stats')
|
||||
uses = {
|
||||
available: wits.value,
|
||||
maximum: wits.max,
|
||||
heart: "#FF0000"
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
if (stats == 'Wits') { /* forbidden-lands */
|
||||
const wits = tokenHelper.getWits(token);
|
||||
txt += wits.value + "/" + wits.max;
|
||||
|
||||
if (icon == 'stats')
|
||||
uses = {
|
||||
available: wits.value,
|
||||
maximum: wits.max,
|
||||
heart: "#FF0000"
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
if (stats == 'Empathy') { /* forbidden-lands */
|
||||
const wits = tokenHelper.getEmpathy(token);
|
||||
txt += wits.value + "/" + wits.max;
|
||||
|
||||
if (icon == 'stats')
|
||||
uses = {
|
||||
available: wits.value,
|
||||
maximum: wits.max,
|
||||
heart: "#FF0000"
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
if (stats == 'WillPower') { /* forbidden-lands */
|
||||
const wits = tokenHelper.getWillPower(token);
|
||||
txt += wits.value + "/" + wits.max;
|
||||
|
||||
if (icon == 'stats')
|
||||
uses = {
|
||||
available: wits.value,
|
||||
maximum: wits.max,
|
||||
heart: "#FF0000"
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
if (stats == 'CriticalWounds') { /* WFRP4e */
|
||||
const criticalWounds = tokenHelper.getCriticalWounds(token);
|
||||
txt += criticalWounds.value + "/" + criticalWounds.max;
|
||||
|
||||
if (icon == 'stats')
|
||||
uses = {
|
||||
available: criticalWounds.value,
|
||||
maximum: criticalWounds.max,
|
||||
heart: "#FF0000"
|
||||
};
|
||||
|
||||
}
|
||||
else if (stats == 'HPbox') {
|
||||
const hp = tokenHelper.getHP(token);
|
||||
@@ -124,6 +190,13 @@ export class TokenControl{
|
||||
heart: "#00FF00"
|
||||
};
|
||||
}
|
||||
else if (stats == 'Stamina') { //starfinder
|
||||
const stamina = tokenHelper.getStamina(token);
|
||||
txt += `${stamina.value}/${stamina.max}`;
|
||||
}
|
||||
else if (stats == 'KinAC') { //starfinder
|
||||
txt += tokenHelper.getKinAC(token);
|
||||
}
|
||||
else if (stats == 'AC') txt += tokenHelper.getAC(token);
|
||||
else if (stats == 'ShieldHP') txt += tokenHelper.getShieldHP(token);
|
||||
else if (stats == 'Speed') txt += tokenHelper.getSpeed(token);
|
||||
@@ -132,9 +205,30 @@ export class TokenControl{
|
||||
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 == 'Save') {
|
||||
txt += tokenHelper.getAbilitySave(token, settings.save);
|
||||
ringColor = tokenHelper.getSaveRingColor(token, settings.save);
|
||||
if (ringColor != undefined) ring = 2;
|
||||
}
|
||||
else if (stats == 'Skill') {
|
||||
txt += tokenHelper.getSkill(token, settings.skill);
|
||||
ringColor = tokenHelper.getSkillRingColor(token, settings.skill);
|
||||
if (ringColor != undefined) ring = 2;
|
||||
}
|
||||
else if (stats == 'Prof') txt += tokenHelper.getProficiency(token);
|
||||
else if (stats == 'Fate') txt += tokenHelper.getFate(token) /* WFRP4e */
|
||||
else if (stats == 'Fortune') txt += tokenHelper.getFortune(token) /* WFRP4e */
|
||||
else if (stats == 'Corruption') txt += tokenHelper.getCorruption(token) /* WFRP4e */
|
||||
else if (stats == 'Advantage') txt += tokenHelper.getAdvantage(token) /* WFRP4e */
|
||||
else if (stats == 'Resolve') txt += tokenHelper.getResolve(token) /* WFRP4e */
|
||||
else if (stats == 'Resilience') txt += tokenHelper.getResilience(token) /* WFRP4e */
|
||||
else if (stats == 'Perception') txt += tokenHelper.getPerception(token) /* PF2E */
|
||||
else if (stats == 'Condition') { /* PF2E */
|
||||
const valuedCondition = tokenHelper.getConditionValue(token, settings.condition);
|
||||
if (valuedCondition != undefined) {
|
||||
txt += valuedCondition?.value;
|
||||
}
|
||||
}
|
||||
|
||||
if (settings.onClick == 'visibility') { //toggle visibility
|
||||
if (MODULE.getPermission('TOKEN','VISIBILITY') == false ) {
|
||||
@@ -176,7 +270,7 @@ export class TokenControl{
|
||||
iconSrc = "fas fa-bullseye";
|
||||
}
|
||||
}
|
||||
else if (settings.onClick == 'condition') { //toggle condition
|
||||
else if (settings.onClick == 'condition') { //handle condition
|
||||
if (MODULE.getPermission('TOKEN','CONDITIONS') == false ) {
|
||||
streamDeck.noPermission(context,device);
|
||||
return;
|
||||
@@ -347,7 +441,7 @@ export class TokenControl{
|
||||
iconSrc = "modules/MaterialDeck/img/token/hp_empty.png";
|
||||
if (stats == 'TempHP') //Temp HP
|
||||
iconSrc = "modules/MaterialDeck/img/token/temp_hp_empty.png";
|
||||
else if (stats == 'AC' || stats == 'ShieldHP') //AC
|
||||
else if (stats == 'AC' || stats == 'ShieldHP' || stats == 'KinAC') //AC
|
||||
iconSrc = "modules/MaterialDeck/img/token/ac.webp";
|
||||
else if (stats == 'Speed') //Speed
|
||||
iconSrc = "modules/MaterialDeck/img/token/speed.webp";
|
||||
@@ -365,7 +459,6 @@ export class TokenControl{
|
||||
}
|
||||
else if (stats == 'Ability' || stats == 'AbilityMod' || stats == 'Save') {
|
||||
overlay = true;
|
||||
ring = 1;
|
||||
let ability = (stats == 'Save') ? settings.save : settings.ability;
|
||||
if (ability == undefined) ability = 'str';
|
||||
if (ability == 'con') iconSrc = "modules/MaterialDeck/img/token/abilities/cons.png";
|
||||
@@ -373,10 +466,9 @@ export class TokenControl{
|
||||
}
|
||||
else if (stats == 'Skill') {
|
||||
overlay = true;
|
||||
ring = 1;
|
||||
let skill = settings.skill;
|
||||
if (skill == undefined) skill = 'acr';
|
||||
else iconSrc = "modules/MaterialDeck/img/token/skills/" + skill + ".png";
|
||||
else iconSrc = "modules/MaterialDeck/img/token/skills/" + (skill.startsWith('lor')? 'lor' : skill) + ".png";
|
||||
}
|
||||
else if (settings.onClick == 'center' || settings.onClick == 'centerSelect') {
|
||||
overlay = true;
|
||||
@@ -483,10 +575,23 @@ export class TokenControl{
|
||||
else if (onClick == 'target') { //Target token
|
||||
token.setTarget(!token.isTargeted,{releaseOthers:false});
|
||||
}
|
||||
else if (onClick == 'condition') { //Toggle condition
|
||||
else if (onClick == 'condition') { //Handle condition
|
||||
if (MODULE.getPermission('TOKEN','CONDITIONS') == false ) return;
|
||||
await tokenHelper.toggleCondition(token,settings.condition);
|
||||
this.update(tokenId);
|
||||
const func = settings.conditionFunction ? settings.conditionFunction : 'toggle';
|
||||
|
||||
if (func == 'toggle'){ //toggle
|
||||
await tokenHelper.toggleCondition(token,settings.condition);
|
||||
this.update(tokenId);
|
||||
}
|
||||
else if (func == 'increase'){ //increase
|
||||
await tokenHelper.modifyConditionValue(token, settings.condition, +1)
|
||||
this.update(tokenId);
|
||||
}
|
||||
else if (func == 'decrease'){ //decrease
|
||||
await tokenHelper.modifyConditionValue(token, settings.condition, -1)
|
||||
this.update(tokenId);
|
||||
}
|
||||
|
||||
}
|
||||
else if (onClick == 'cubCondition') { //Combat Utility Belt conditions
|
||||
if (MODULE.getPermission('TOKEN','CONDITIONS') == false ) return;
|
||||
@@ -518,23 +623,30 @@ export class TokenControl{
|
||||
if (isNaN(dimVision)==false) data.dimSight = dimVision;
|
||||
if (isNaN(brightVision)==false) data.brightSight = brightVision;
|
||||
if (isNaN(sightAngle)==false) data.sightAngle = sightAngle;
|
||||
if (isNaN(dimRadius)==false) data.dimLight = dimRadius;
|
||||
if (isNaN(brightRadius)==false) data.brightLight = brightRadius;
|
||||
if (isNaN(emissionAngle)==false) data.lightAngle = emissionAngle;
|
||||
data.lightColor = lightColor;
|
||||
data.lightAlpha = Math.sqrt(colorIntensity).toNearest(0.05)
|
||||
|
||||
let light = {};
|
||||
|
||||
|
||||
if (isNaN(dimRadius)==false) light.dim = dimRadius;
|
||||
if (isNaN(brightRadius)==false) light.bright = brightRadius;
|
||||
if (isNaN(emissionAngle)==false) light.angle = emissionAngle;
|
||||
light.color = lightColor;
|
||||
light.alpha = Math.sqrt(colorIntensity).toNearest(0.05)
|
||||
|
||||
let animation = {
|
||||
type: '',
|
||||
speed: tokenData.lightAnimation.speed,
|
||||
intensity: tokenData.lightAnimation.intensity
|
||||
speed: tokenData.light.animation.speed,
|
||||
intensity: tokenData.light.animation.intensity
|
||||
};
|
||||
if (animationType != 'none'){
|
||||
animation.type = animationType;
|
||||
animation.intensity = animationIntensity;
|
||||
animation.speed = animationSpeed;
|
||||
}
|
||||
data.lightAnimation = animation;
|
||||
token.update(data);
|
||||
light.animation = animation;
|
||||
data.light = light;
|
||||
if (compatibleCore('0.8.1')) token.document.update(data);
|
||||
else token.update(data);
|
||||
}
|
||||
else if (onClick == 'initiative'){
|
||||
tokenHelper.toggleInitiative(token);
|
||||
@@ -572,7 +684,8 @@ export class TokenControl{
|
||||
else return;
|
||||
|
||||
iconSrc = images[imgNr];
|
||||
token.update({img: iconSrc})
|
||||
if (compatibleCore('0.8.1')) token.document.update({img: iconSrc});
|
||||
else token.update({img: iconSrc})
|
||||
}
|
||||
else if (onClick == 'macro') { //call a macro
|
||||
const settingsNew = {
|
||||
@@ -715,7 +828,8 @@ export class TokenControl{
|
||||
if (path != '') path += '.';
|
||||
path += targetArray[i][j];
|
||||
}
|
||||
await token.update({[path]:value})
|
||||
if (compatibleCore('0.8.1')) await token.document.update({[path]:value});
|
||||
else await token.update({[path]:value})
|
||||
this.update(token.id);
|
||||
}
|
||||
|
||||
@@ -739,7 +853,9 @@ export class TokenControl{
|
||||
items = this.sortItems(items);
|
||||
|
||||
const item = items[itemNr];
|
||||
if (item != undefined) item.roll();
|
||||
if (item != undefined) {
|
||||
tokenHelper.rollItem(item, settings);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
41
templates/deviceConfig.html
Normal file
@@ -0,0 +1,41 @@
|
||||
<form autocomplete="off" onsubmit="event.preventDefault()">
|
||||
|
||||
<style>
|
||||
.columnLabel {
|
||||
max-width:30%;
|
||||
min-width:30%;
|
||||
text-align: left;
|
||||
}
|
||||
.columnId {
|
||||
max-width:25%;
|
||||
min-width:25%;
|
||||
text-align: left;
|
||||
text-overflow: hidden;
|
||||
}
|
||||
.columnCB {
|
||||
width:10%;
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
|
||||
<table style="width:100%; min-width:400px">
|
||||
<tr>
|
||||
<th class='columnLabel'>{{localize "MaterialDeck.Name"}}</th>
|
||||
<th class='columnLabel'>{{localize "MaterialDeck.Type"}}</th>
|
||||
<th class='columnId'>{{localize "MaterialDeck.Id"}}</th>
|
||||
<th class='columnCB'>{{localize "MaterialDeck.Perm.ENABLE.ENABLE.label"}}</th>
|
||||
</tr>
|
||||
{{#each devices as |d|}}
|
||||
<tr>
|
||||
<td class='columnLabel'>{{d.name}}</td>
|
||||
<td class='columnLabel'>{{d.type}}</td>
|
||||
<td class='columnId'><input type="text" value={{d.id}} disabled></td>
|
||||
<td class='columnCB'><input type="checkbox" name="enable" id={{d.id}} {{checked d.en}}></td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
BIN
wiki/img/.thumb/DownloadUtility.png.jpg
Normal file
|
After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 14 KiB |
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |