Skip to content

Commit

Permalink
v3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
CDeenen committed Oct 19, 2023
1 parent fb52cbe commit dbac521
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 109 deletions.
66 changes: 3 additions & 63 deletions MaterialPlane.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ Hooks.on('ready', ()=>{

enableModule = game.user.id == game.settings.get(moduleName,'ActiveUser');
hideElements = game.settings.get(moduleName,'HideElements') && game.user.isGM == false;
if (game.settings.get(moduleName,'device') == 'sensor' && game.settings.get(moduleName,'Enable') && window.location.protocol == "https:" && game.settings.get(moduleName,'EnMaterialServer') == false){
if (game.settings.get(moduleName,'device') == 'sensor' && game.settings.get(moduleName,'ConnectionMode') != "noConnect" && window.location.protocol == "https:" && game.settings.get(moduleName,'ConnectionMode') != 'materialCompanion'){
ui.notifications.warn("Material Plane: "+game.i18n.localize("MaterialPlane.Notifications.SSL"));
enableModule = false;
return;
}
if ((enableModule || game.user.isGM) && game.settings.get(moduleName,'Enable')){
if ((enableModule || game.user.isGM) && game.settings.get(moduleName,'ConnectionMode') != "noConnect"){
if (game.settings.get(moduleName,'device') == 'sensor')
startWebsocket();
else {
Expand Down Expand Up @@ -294,10 +294,9 @@ Hooks.on('closecalibrationProgressScreen',() => {
* Initialize settings
*/
Hooks.once('init', function(){
registerSettings(); //in ./src/settings.js
registerSettings();
registerLayer();
configDialog = new mpConfig();
//calibrationDialog = new calibrationForm();
calibrationProgress = new calibrationProgressScreen();
});

Expand Down Expand Up @@ -334,11 +333,6 @@ Hooks.on('renderPlayerList', (app, html) => {
}
});

Hooks.on('canvasReady', (canvas) => {
// canvas.stage.addChild(circle);
//circle.init();
})

Hooks.on('controlToken', (token,controlled) => {
if (!controlled) return;
enableModule = game.user.id == game.settings.get(moduleName,'ActiveUser');
Expand Down Expand Up @@ -401,58 +395,4 @@ export async function checkForUpdate(reqType) {
latestReleases.materialCompanion = version;
}
});

return;

var request = new XMLHttpRequest();
request.open('GET', url, true);
request.send(null);
request.onreadystatechange = function () {
if (request.readyState === 4 && request.status === 200) {
var type = request.getResponseHeader('Content-Type');
if (type.indexOf("text") !== 1) {
let version;
if (reqType == 'module') {
version = JSON.parse(request.responseText).version;
latestReleases.module = version;
}
else if (reqType == 'MS') {
version = JSON.parse(request.responseText).version;
latestReleases.ms = version;
}
else if (reqType == 'SWs') {
const start = request.responseText.search('"', request.responseText.search('const webserverVersion = "v')) + 2;
let v = "";
for (let i=start; i<start+10; i++) {
if (request.responseText[i] == '"') break;
else v += request.responseText[i];
}
latestReleases.sensorWs = v;
version = v;
}
else {
const start = request.responseText.search('"', request.responseText.search('#define FIRMWARE_VERSION')) + 1;
let v = "";
for (let i=start; i<start+10; i++) {
if (request.responseText[i] == '"') break;
else v += request.responseText[i];
}

if (reqType == 'hwFw') latestReleases.sensorFW = v;
else if (reqType == 'base') latestReleases.baseFW = v;
else if (reqType == 'pen') latestReleases.penFW = v;
version = v;
}

if (document.getElementById('MaterialPlane_Config') != null) {
document.getElementById(`mpConfigMaster${id}Version`).innerHTML = version;
}
return;
}

}
}
request.onerror = function () {

}
}
13 changes: 12 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
# Changelog Material Plane Foundry Module
### v3.0.2 -
### v3.0.2 - 20-10-2023
Fixes:
<ul>
<li>Decreased the size of the battery indicator to it doesn't overflow</li>
<li>Data is now correctly formatted before being sent to Material Companion</li>
<li>In the base setup, rules with base IDs of the current base display a green ID again</li>
</ul>

Additions:
<ul>
<li>Added a configurable maximum connection attempts to connect to either the sensor or Material Companion</li>
</ul>

Other:
<ul>
<li>Added a 'Connection Mode' setting that replaces the 'Connect to the Sensor' and 'Use Material Server' settings</li>
<li>When connecting to the sensor through Material Companion, the IP address now has to be configured in Material Companion instead of in the module.</li>
</ul>

### v3.0.1 - 04-10-2023
Fixes:
<ul>
Expand Down
Binary file added img/.thumb/MaterialFoundry2560x1440.jpg.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/MaterialFoundry2560x1440.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 10 additions & 6 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"MaterialPlane.Config.General_Hint": "General configuration for Material Plane.",
"MaterialPlane.Config.Refresh_Hint": "will refresh the browser after closing this configuration screen",
"MaterialPlane.Config.Connection": "Connection",
"MaterialPlane.Config.Connection_Hint": "Connection configuration for the Material Plane sensor. These settings are client settings, so they will need to be configured for bot the GM and the active user.",
"MaterialPlane.Config.Connection_Hint": "Connection configuration for the Material Plane sensor. These settings are client settings, so they will need to be configured for both the GM and the active user.",
"MaterialPlane.Config.Sensor": "Sensor",
"MaterialPlane.Config.Sensor_Hint": "Material Plane sensor configuration.",
"MaterialPlane.Config.Touch": "Touch",
Expand Down Expand Up @@ -42,15 +42,18 @@
"MaterialPlane.Config.BlockInteraction": "Block Interactions",
"MaterialPlane.Config.BlockInteraction_Hint": "Block interactions with the canvas while this screen is open.",

"MaterialPlane.Config.Connect": "Connect to the Sensor",
"MaterialPlane.Config.Connect_Hint": "Let the current client connect to the sensor. Is only applicable for GM accounts and the active user",
"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'.",
"MaterialPlane.Config.EnMaterialServer": "Use Material Companion",
"MaterialPlane.Config.EnMaterialServer_Hint": "Redirects communication to the sensor through Material Companion. Required if the Foundry server is secured using SSL, or if you want to connect to the sensor through the USB port.",
"MaterialPlane.Config.MaterialServerIP": "Material Companion IP Address",
"MaterialPlane.Config.MaterialServerIP_Hint": "Fill in the IP address of Material Companion, include the port. Default: 'localhost:3001'.",

"MaterialPlane.Config.ConnectionModeLabel": "Connection Mode",
"MaterialPlane.Config.ConnectionModeLabel_Hint": "Configure how to connect to the sensor. Either directly, through Material Companion, or not at all.",
"MaterialPlane.Config.ConnectionModeDirect": "Connect Directly to the Sensor",
"MaterialPlane.Config.ConnectionModeMC": "Connect Through Material Companion",
"MaterialPlane.Config.ConnectionModeNoConnect": "Don't Connect",
"MaterialPlane.Config.MaxAttempts": "Maximum Connection Attempts",
"MaterialPlane.Config.MaxAttempts_Hint": "The maximum amount of times Material Plane will attempt to connect to the sensor or Material Companion.",

"MaterialPlane.Config.TapMode": "Tap Mode",
"MaterialPlane.Config.TapMode_Hint": "Sets the tap mode. This can be used to distinguish between touches caused by minis and taps that are meant to interact with the canvas (such as opening doors).",
"MaterialPlane.Config.TapMode_Timeout_Hint": "'Tap Timeout': When a new touch is detected, a timer will start. If the touch is removed before the timer is bigger than 'Tap Timeout', MP will assume it was a tap. Otherwise it'll assume a mini was placed. Token movement will start after 'Tap Timeout' has elapsed.",
Expand Down Expand Up @@ -188,6 +191,7 @@
"MaterialPlane.Notifications.ConnectedMSS": "Connected to Material Sensor through Material Companion",
"MaterialPlane.Notifications.Disconnected": "Disconnected, attempting to reconnect",
"MaterialPlane.Notifications.ConnectFail": "Can't connect, retrying",
"MaterialPlane.Notifications.MaxAttemptsReached": "The maximum number of connection attempts has been reached",
"MaterialPlane.Notifications.SSL": "Your Foundry server is secured, you will need to use Material Companion to connect to the sensor",
"MaterialPlane.Notifications.AutoExposureDone": "Auto exposure done",
"MaterialPlane.Notifications.SpaceOccupied": "Space already occupied. Moving token to nearest empty space along its travel path.",
Expand Down
18 changes: 16 additions & 2 deletions 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_pre2",
"version": "3.0.2",
"esmodules": [
"MaterialPlane.js"
],
Expand All @@ -11,7 +11,7 @@
"minimumSensorWsVersion": "2.0.0",
"minimumBaseVersion": "2.0.0",
"minimumPenVersion": "2.0.0",
"minimumMSversion": "1.0.0"
"minimumMSversion": "1.0.2"
},
"languages": [
{
Expand All @@ -21,6 +21,20 @@
"flags": {}
}
],
"media": [
{
"type": "icon",
"url": "modules/MaterialPlane/img/MaterialFoundry512x512.png"
},
{
"type": "setup",
"url": "modules/MaterialPlane/img/MaterialFoundry2560x1440.jpg"
},
{
"type": "cover",
"url": "modules/MaterialPlane/img/MaterialFoundry2560x1440.jpg"
}
],
"url": "https://github.com/MaterialFoundry/MaterialPlane_Foundry",
"manifest": "https://github.com/MaterialFoundry/MaterialPlane_Foundry/releases/latest/download/module.json",
"download": "https://github.com/MaterialFoundry/MaterialPlane_Foundry/releases/download/v3.0.0/module.zip",
Expand Down
4 changes: 1 addition & 3 deletions src/IRtoken/IRtoken.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,13 @@ export class IRtoken {
rotation: this.token.document.rotation
}



if (game.settings.get(moduleName,'collisionPrevention')) {
newCoords = this.findNearestEmptySpace(newCoords);
}

this.previousPosition = this.currentPosition;

// this.moveToken(this.currentPosition);
this.moveToken(this.currentPosition);

//Get the coordinates of the center of the grid closest to the coords
if (game.settings.get(moduleName,'movementMethod') != 'stepByStep') {
Expand Down
63 changes: 59 additions & 4 deletions src/Misc/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,25 @@ export const registerSettings = function() {
type: String
});

/**
* Connection mode
*/
game.settings.register(moduleName,'ConnectionMode', {
scope: "client",
config: false,
default: "",
type: String
});

game.settings.register(moduleName, 'nrOfConnAttempts', {
default: 5,
type: Number,
scope: 'client',
range: { min: 0, max: 100, step: 1 },
config: false

});

/**
* Use Material Server
*/
Expand Down Expand Up @@ -211,6 +230,16 @@ export const registerSettings = function() {
default: false,
type: Boolean
});


//Settings migration
if (game.settings.get(moduleName, 'ConnectionMode') == "") {
console.log("Migrating Material Plane setting: 'Connection Mode'");
if (!game.settings.get(moduleName, 'Enable')) game.settings.set(moduleName, 'ConnectionMode', 'noConnect')
else if (game.settings.get(moduleName, 'EnMaterialServer')) game.settings.set(moduleName, 'ConnectionMode', 'materialCompanion')
else game.settings.set(moduleName, 'ConnectionMode', 'direct')
}

}

export function onHwVariantChange(variant) {
Expand Down Expand Up @@ -283,10 +312,10 @@ export class mpConfig extends FormApplication {
hideElements: game.settings.get(moduleName,'HideElements'),
penMenu: game.settings.get(moduleName,'MenuSize'),

connectToSensor: game.settings.get(moduleName,'Enable'),
connectionMode: game.settings.get(moduleName,'ConnectionMode'),
sensorIP: game.settings.get(moduleName,'IP'),
connectThroughMS: game.settings.get(moduleName,'EnMaterialServer'),
materialServerIP: game.settings.get(moduleName,'MaterialServerIP'),
nrOfConnAttempts: game.settings.get(moduleName,'nrOfConnAttempts'),

tapMode: game.settings.get(moduleName,'tapMode'),
touchTimeout: game.settings.get(moduleName,'touchTimeout'),
Expand Down Expand Up @@ -377,10 +406,36 @@ export class mpConfig extends FormApplication {
html.find("input[id=mpBlockInteraction]").on('change', event => { parent.blockInteraction = event.target.checked; });

// --- Connection settings ---
html.find("input[id=mpConnect]").on('change', event => { this.setSettings('Enable',event.target.checked); this.restart = true; });
html.find("select[id=mpConnectionMethod]").on('change', event =>{
const target = event.target.value;
if (target == 'direct') {
document.getElementById("mpSensorIpWrapper").style.display = "";
document.getElementById("mpMCIpWrapper").style.display = "none";
}
else if (target == 'materialCompanion') {
document.getElementById("mpSensorIpWrapper").style.display = "none";
document.getElementById("mpMCIpWrapper").style.display = "";
}
else {
document.getElementById("mpSensorIpWrapper").style.display = "none";
document.getElementById("mpMCIpWrapper").style.display = "none";
}
this.setSettings('ConnectionMode',target); this.restart = true;
});
html.find("input[id=mpSensorIP]").on('change', event => { this.setSettings('IP',event.target.value); this.restart = true; });
html.find("input[id=mpEnMaterialServer]").on('change', event => { this.setSettings('EnMaterialServer',event.target.checked); this.restart = true; });
html.find("input[id=mpMaterialServerIP]").on('change', event => { this.setSettings('MaterialServerIP',event.target.value); this.restart = true; });
html.find("input[id=mpConnAttempts]").on('change', event =>{
const val = this.constrain(event.target.value, game.settings.settings.get("MaterialPlane.nrOfConnAttempts").range);
document.getElementById("mpConnAttempts").value = val;
document.getElementById("mpConnAttemptsNumber").value = val;
this.setSettings('nrOfConnAttempts',val);
});
html.find("input[id=mpConnAttemptsNumber]").on('change', event =>{
const val = this.constrain(event.target.value, game.settings.settings.get("MaterialPlane.nrOfConnAttempts").range);
document.getElementById("mpConnAttempts").value = val;
document.getElementById("mpConnAttemptsNumber").value = val;
this.setSettings('nrOfConnAttempts',val);
});

// --- Touch settings ---
html.find("select[id=mpTapMode]").on('change', event => { this.setSettings('tapMode',event.target.value); });
Expand Down
1 change: 1 addition & 0 deletions src/analyzeIR.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export async function analyzeIR(data) {
// if (game.user.id != activeUser) return;
// for (let token of IRtokens) token.dropIRtoken();
// foundBases = 0;
debug('baseData',`No base detected`)
return;
}

Expand Down
Loading

0 comments on commit dbac521

Please sign in to comment.