Skip to content

Commit

Permalink
v3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
CDeenen committed Apr 16, 2024
1 parent dbac521 commit bfd3de1
Show file tree
Hide file tree
Showing 33 changed files with 3,936 additions and 2,025 deletions.
103 changes: 81 additions & 22 deletions MaterialPlane.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

import { registerSettings, mpConfig, onHwVariantChange } from "./src/Misc/settings.js";
import { sendWS,startWebsocket } from "./src/websocket.js";
import { calibrationProgressScreen, removeOverlay } from "./src/calibration.js";
import { registerLayer, configureDebug, compareVersions, compatibleCore } from "./src/Misc/misc.js";
import { initializeIRtokens, initializeCursors, setLastBaseAddress } from "./src/analyzeIR.js";
import { registerSettings, onHwVariantChange } from "./src/Misc/settings.js";
import { mpConfig } from "./src/Misc/config.js";
import { sendWS, startWebsocket } from "./src/Communication/websocket.js";
import { calibrationProgressScreen, removeOverlay, calOverlay } from "./src/calibration.js";
import { registerLayer, configureDebug, compatibleCore } from "./src/Misc/misc.js";
import { initializeIRtokens, initializeCursors, setLastBaseAddress, pen } from "./src/analyzeIR.js";
import { IRremote } from "./src/IRremote/IRremote.js";
import { analyzeTouch } from "./src/analyzeTouch.js";

Expand All @@ -23,14 +24,16 @@ let enableModule = false;
export let configDialog;
export let calibrationProgress;

export let hwVariant = 'Beta';
export let hwVariant = 'Production';
export let hwFirmware;
export let hwWebserver;
export let msVersion;
export let latestReleases = {};

export let irRemote = new IRremote();

export let routingLibEnabled = false;

export const urls = [
{
target: 'Module',
Expand Down Expand Up @@ -67,14 +70,15 @@ Handlebars.registerHelper('ifNCond', function(v1, v2, options) {
return options.fn(this);
});

//CONFIG.debug.hooks = true;

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Functions
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

export function setHwVariant(v) {
return;
if (hwVariant != v) {
onHwVariantChange(v);
}
Expand Down Expand Up @@ -142,9 +146,11 @@ function checkKeys() {
* Ready hook
* Attempt to open the websocket
*/
Hooks.on('ready', ()=>{
Hooks.on('ready', async ()=>{
// configDialog.setConfigOpen(true);
// configDialog.render(true);

if (game.version.split('.')[0] >= 11 && game.settings.get(moduleName,'device') == 'touch') {
console.warn("")
let d = new Dialog({
title: "Material Plane: Incompatibility",
content: "<p>The touch functionality of Material Plane is incompatible with Foundry V11.<br>You should downgrade to Foundry V10 if you want to use the touch functionality. If you ignore this message, expect weird behavior.</p>",
Expand All @@ -171,8 +177,9 @@ Hooks.on('ready', ()=>{
return;
}
if ((enableModule || game.user.isGM) && game.settings.get(moduleName,'ConnectionMode') != "noConnect"){
if (game.settings.get(moduleName,'device') == 'sensor')
if (game.settings.get(moduleName,'device') == 'sensor') {
startWebsocket();
}
else {
document.addEventListener('touchstart',function(e) {e.preventDefault(); analyzeTouch('start',e);});
document.addEventListener('touchmove',function(e) {e.preventDefault(); analyzeTouch('move',e);});
Expand All @@ -191,15 +198,6 @@ Hooks.on('ready', ()=>{
}
}

if (!enableModule && !game.user.isGM) return;

checkForUpdate('Module');
checkForUpdate('SensorFirmware');
checkForUpdate('SensorWebserver');
checkForUpdate('MaterialCompanion');
checkForUpdate('Base');
checkForUpdate('Pen');

game.socket.on(`module.MaterialPlane`, (payload) =>{
//console.log(payload);

Expand Down Expand Up @@ -233,7 +231,6 @@ Hooks.on('ready', ()=>{
if (lastBaseAddress == base.value) base.style.color="green";
else base.style.color="";
}

}
}
}
Expand All @@ -242,11 +239,49 @@ Hooks.on('ready', ()=>{
}
}
});

if (!enableModule && !game.user.isGM) return;

checkForUpdate('Module');
checkForUpdate('SensorFirmware');
checkForUpdate('SensorWebserver');
checkForUpdate('MaterialCompanion');
checkForUpdate('Base');
checkForUpdate('Pen');

if (game.user.isGM) game.settings.set(moduleName,'menuOpen',false);

let rulerSettings = await game.settings.get(moduleName,'tokenRuler');
if (rulerSettings.mode == undefined) rulerSettings.mode = 'disabled';
if (rulerSettings.stop == undefined) rulerSettings.stop = 'tokenDrop';
if (rulerSettings.distance == undefined) rulerSettings.distance = 2;
game.settings.set(moduleName,'tokenRuler',rulerSettings);

const routingLib = game.modules.get('routinglib');
if (routingLib && routingLib.active) routingLibEnabled = true;

initializeIRtokens();
initializeCursors();

Hooks.on('activateDrawingsLayer', layer => {
const drawings = layer.placeables;

for (let drawing of drawings) {
pen.drawingTarget.addTarget(drawing);
}
})

Hooks.on('refreshDrawing', drawing => {
pen.drawingTarget.updateTarget(drawing);
});

Hooks.on('drawDrawing', drawing => {
pen.drawingTarget.addTarget(drawing);
})

Hooks.on('deleteDrawing', drawing => {
pen.drawingTarget.removeTarget(drawing);
})
});

Hooks.on("renderSidebarTab", (app, html) => {
Expand Down Expand Up @@ -363,7 +398,31 @@ Hooks.on('renderPlayerList', (a,b, playerlist) => {
const pl = playerlist.users.find(p => p._id == game.settings.get(moduleName,'ActiveUser'));
if (pl == undefined) return;
const html = `<span style="font-size:0.6rem; border:2px solid; border-radius:25%; padding: 0px 3px 0px 3px">MP</span>`;
document.querySelectorAll(`[data-tooltip="${pl.displayName}"]`)[0].innerHTML+=html;
if (compatibleCore('11.0'))
document.querySelectorAll(`[data-tooltip="${pl.displayName}"]`)[0].innerHTML+=html;
//else
// document.querySelectorAll(`[data-user-id="${pl._id}"]`)[0].innerHTML+=html;
});

//let scaleOld;
let viewPositionOld;

Hooks.on('canvasPan', (canvas, viewPosition) => {
if (pen == undefined) return;
if (viewPositionOld == undefined) {
viewPositionOld = viewPosition;
return;
}

if (viewPosition.scale-viewPositionOld.scale == 0) {
pen.menu.moveMenu({x:viewPosition.x-viewPositionOld.x, y:viewPosition.y-viewPositionOld.y}, true)
}
else {
pen.menu.drawMenu(undefined);
}
viewPositionOld = viewPosition;

if (calOverlay != undefined) calOverlay.update();
});

export async function checkForUpdate(reqType) {
Expand Down Expand Up @@ -395,4 +454,4 @@ export async function checkForUpdate(reqType) {
latestReleases.materialCompanion = version;
}
});
}
}
31 changes: 31 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,35 @@
# Changelog Material Plane Foundry Module
### v3.1.0 - 16-04-2024
Fixes:
<ul>
<li>Battery icon now properly displays charging state</li>
<li>Reduced the amount of situations where a token can 'teleport' through a wall when the wall intersects a gridspace</li>
<li>Token targeting with the pen now works on non-owned tokens and it correctly accounts for token size</li>
<li>Fixed issue where 'Token Collision Prevention' would not move some UI elements of a token (such as its health bar) to the correct location</li>
<li>When a new template was drawn using the pen, the preview would not be properly removed and would stay visible until a refresh</li>
</ul>

Additions:
<ul>
<li>Added the functionality to draw a ruler when a token is moved (similar to Drag Ruler)</li>
<li>Added a 'Pen Setup' tab in the config for all pen related settings</li>
<li>Added the ability to run macros using the pen</li>
<li>Added a 'Control' tab in the config that handles all settings related to token controls</li>
<li>Added a cursor size slider for the pen cursor</li>
<li>Added the ability to use on-screen calibration points instead of the corner of the display</li>
<li>Added low battery notifications</li>
<li>Added 'Base Orientation' selector so offsets are calculated correctly when using base adapters at different orientations</li>
<li>Added a targeting icon for drawings when using the pen. This makes it easier to select the correct drawing</li>
</ul>

Other:
<ul>
<li>Changed the calibration procedure. It now opens a dialog to select how you want to calibrate</li>
<li>The pen menu will now have the same size and position on the screen regardless of canvas zoom or pan</li>
<li>Changed the label for sensor 'brightness' to 'sensitivity' to better reflect what it does and to better distinguish it from 'minimum brightness'</li>
<li>Did some code cleanup & organization</li>
</ul>

### v3.0.2 - 20-10-2023
Fixes:
<ul>
Expand Down
Binary file added img/.thumb/calPos.png.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/.thumb/macro.png.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions img/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
MaterialFoundry512x512.png is owned by Material Foundry
macro.png: Foundry's icon folder, converted from .svg, original name: dice-target.svg
All other images are from fontawesome
Binary file added img/calPos.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/macro.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 48 additions & 4 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@
"MaterialPlane.Config.Touch_Hint": "Touch configuration for IR Touch Frames or other touch screens.",
"MaterialPlane.Config.BaseSetup": "Base Setup",
"MaterialPlane.Config.BaseSetup_Hint": "Configure bases to be linked to specific tokens or actors.",
"MaterialPlane.Config.PenSetup": "Pen Setup",
"MaterialPlane.Config.PenSetup_Hint": "Configure the pen.",
"MaterialPlane.Config.RC": "Remote Control",
"MaterialPlane.Config.RC_Hint": "Configure macros to be triggered by specific IR remote signals sent by normal remote controls.",
"MaterialPlane.Config.Downloads": "Downloads",
"MaterialPlane.Config.Downloads_Hint": "Download firmware updates or Material Companion.",
"MaterialPlane.Config.Control": "Control",
"MaterialPlane.Config.Control_Hint": "Control Hint",

"MaterialPlane.Config.ActiveUser": "Active User",
"MaterialPlane.Config.ActiveUser_Hint": "Active user for MP, usually the user that is displayed on the TV.",
Expand All @@ -37,10 +41,12 @@
"MaterialPlane.Config.CollisionPrevention_Hint": "When enabled, Material Plane will try to prevent two tokens from occupying the same space by placing the moving token onto the nearest empty grid space along its movement path.",
"MaterialPlane.Config.HideDisplay": "Hide Display Elements",
"MaterialPlane.Config.HideDisplay_Hint": "Hides all display elements for the active user (if not GM). Client can press the 'Ctrl' button to toggle the elements.",
"MaterialPlane.Config.MenuSize": "Pen Menu Size",
"MaterialPlane.Config.MenuSize_Hint": "Set the size of the pen menu relative to the grid size.",
"MaterialPlane.Config.BlockInteraction": "Block Interactions",
"MaterialPlane.Config.BlockInteraction_Hint": "Block interactions with the canvas while this screen is open.",
"MaterialPlane.Config.BatteryNotifications_Label": "Low Battery Notifications",
"MaterialPlane.Config.BatteryNotifications_Hint": "Will display a notification if there is a low battery",
"MaterialPlane.Config.BaseOrientation_Label": "Base Orientation",
"MaterialPlane.Config.BaseOrientation_Hint": "(For base adapters only) Set the orientation of the bases relative to the display. 0 degrees means that the infrared LED is on the top-right side of the display.",

"MaterialPlane.Config.SensorIP": "Sensor Module IP Address",
"MaterialPlane.Config.SensorIP_Hint": "Fill in the IP address of the sensor module, include the port. Default: 'masterialsensor.local:3000'.",
Expand Down Expand Up @@ -91,6 +97,20 @@
"MaterialPlane.Config.PlusBtn": "+ button",
"MaterialPlane.Config.PlusBtn_Hint": "Add a new configuration.",

"MaterialPlane.Config.CursorSize": "Cursor Size",
"MaterialPlane.Config.CursorSize_Hint": "Set the size of the pen cursor.",
"MaterialPlane.Config.MenuSize": "Pen Menu Size",
"MaterialPlane.Config.MenuSize_Hint": "Set the size of the pen menu.",
"MaterialPlane.Config.PenId": "Pen ID",
"MaterialPlane.Config.PenButton": "Btn",
"MaterialPlane.Config.PenMode": "Mode",
"MaterialPlane.Config.PenMode_Press": "Press",
"MaterialPlane.Config.PenMode_Hold": "Hold",
"MaterialPlane.Config.PenMode_Release": "Release",
"MaterialPlane.Config.PenMacro": "Macro",
"MaterialPlane.Config.PenArgs": "Arguments",
"MaterialPlane.Config.Any": "Any",

"MaterialPlane.Config.Protocol": "Protocol",
"MaterialPlane.Config.Protocol_Hint": "IR Protocol.",
"MaterialPlane.Config.Code": "Code",
Expand Down Expand Up @@ -119,8 +139,8 @@

"MaterialPlane.Config.AutoExpose": "Auto Exposure",
"MaterialPlane.Config.AutoExpose_Hint": "Attempts to automatically configure the exposure settings. Place a base or the pen in a corner of the screen, and make sure the IR led is on (tilt the base, if necessary). The procedure can take a few seconds, the settings will automatically be updated after the procedure.",
"MaterialPlane.Config.Brightness": "Brightness",
"MaterialPlane.Config.Brightness_Hint": "Sets the brightness. Higher values will increase the brightness of points.",
"MaterialPlane.Config.Brightness": "Sensitivity",
"MaterialPlane.Config.Brightness_Hint": "Sets the sensor sensitivity. Higher values will increase the brightness of detected infrared points.",
"MaterialPlane.Config.UpdateRate": "Update Rate",
"MaterialPlane.Config.UpdateRate_Hint": "The update rate of the sensor. Higher increases responsiveness but can decrease performance on slower machines.",
"MaterialPlane.Config.MinBrightness": "Minimum Brightness",
Expand All @@ -144,12 +164,15 @@
"MaterialPlane.Config.ScaleX_Hint": "Scales all coordinates on the X-axis by a set value to fix alignment issues.",
"MaterialPlane.Config.ScaleY": "Scale Y",
"MaterialPlane.Config.ScaleY_Hint": "Scales all coordinates on the Y-axis by a set value to fix alignment issues.",

"MaterialPlane.Config.CalibrationEnabled": "Calibration Enabled",
"MaterialPlane.Config.CalibrationEnabled_Hint": "Enables the calibration.",
"MaterialPlane.Config.OffsetEnabled": "Calibration Offset Enabled",
"MaterialPlane.Config.OffsetEnabled_Hint": "Enables the calibration offset.",
"MaterialPlane.Config.Calibrate": "Calibrate",
"MaterialPlane.Config.Calibrate_Hint": "Start the calibration procedure.",
"MaterialPlane.Config.Normal": "Normal",
"MaterialPlane.Config.Select": "Select",
"MaterialPlane.Config.SinglePoint": "Single-Point",
"MaterialPlane.Config.MultiPoint": "Multi-Point",
"MaterialPlane.Config.Offset": "Offset",
Expand Down Expand Up @@ -180,6 +203,21 @@
"MaterialPlane.Config.NA": "N/A",
"MaterialPlane.Config.Refresh": "Refresh",

"MaterialPlane.Config.Ruler": "Ruler",
"MaterialPlane.Config.Ruler_Hint": "The ruler will draw a ruler whenever a token is moved. This is currently an experimental feature, so expect some weird behavior.",
"MaterialPlane.Config.RulerMode_Label": "Ruler Mode",
"MaterialPlane.Config.RulerMode_Hint": "Select how the ruler should be drawn. 'Disabled' disables the ruler, 'Straight Line' draws a straight line from the movement's start to the current position. 'Follow Movement' will draw a ruler that (approximately) follows the token's path. 'Pathfinding' finds the shortest route between the movement's start and current position.",
"MaterialPlane.Config.RulerModeDisabled": "Disabled",
"MaterialPlane.Config.RulerModeStraight": "Straight Line",
"MaterialPlane.Config.RulerModeFollow": "Follow Movement",
"MaterialPlane.Config.RulerModePathfinding": "Pathfinding",
"MaterialPlane.Config.RulerStop_Label": "Clear Ruler",
"MaterialPlane.Config.RulerStop_Hint": "Sets when to clear the ruler. 'On Token Drop' will clear the ruler when the token is dropped (released). 'On New Movement' will clear the ruler when new movement is detected.",
"MaterialPlane.Config.RulerStopTokenDrop": "On Token Drop",
"MaterialPlane.Config.RulerStopNewMovement": "On New Movement",
"MaterialPlane.Config.RulerDistance_Label": "Pathfinding Distance",
"MaterialPlane.Config.RulerDistance_Hint": "Pathfinding is enabled for the last ruler segments to distances up to this value (in grid spaces). Segments at further distances will be locked. Set to 0 to disable.",

"MaterialPlane.Sett.Config": "Configuration",

"MaterialPlane.Sett.DIY_SIMPLE": "Simple DIY",
Expand All @@ -197,6 +235,12 @@
"MaterialPlane.Notifications.SpaceOccupied": "Space already occupied. Moving token to nearest empty space along its travel path.",
"MaterialPlane.Notifications.FileNotFound": "Could not find the requested file",
"MaterialPlane.Notifications.GamePaused": "The game is paused",
"MaterialPlane.Notifications.RoutingLib": "Please install and enable RoutingLib to use the pathfinding ruler mode",
"MaterialPlane.Notifications.BatteryLowBase": "Base battery low.",
"MaterialPlane.Notifications.BatteryLowPen": "Pen battery low.",
"MaterialPlane.Notifications.BatteryLowSensor": "Sensor battery low.",
"MaterialPlane.Notifications.NoDrawingPermission": "User lacks permission to create drawings.",
"MaterialPlane.Notifications.NoTemplatePermission": "User lacks permission to create templates.",

"MaterialPlane.CalDialog.Singlepoint1": "Single-point calibration",
"MaterialPlane.CalDialog.Singlepoint2": "Please calibrate each corner of you screen.",
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title": "Material Plane",
"description": "Module for tracking physical minis. By using an IR tracking camera and mini bases with IR LED's this module can be used to move tokens in Foundry by moving physical tokens on top of a horizontally mounted TV",
"version": "3.0.2",
"version": "3.1.0",
"esmodules": [
"MaterialPlane.js"
],
Expand Down
Loading

0 comments on commit bfd3de1

Please sign in to comment.