Skip to content

Commit

Permalink
v3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
CDeenen committed Oct 3, 2023
1 parent 0987ace commit 6fed658
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 54 deletions.
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Changelog Material Plane Foundry Module
### v3.0.1 - 04-10-2023
Fixes:
<ul>
<li>Calibration overlay is now properly displayed</li>
<li>Calibration 'Next' and 'Close' buttons are now properly communicated to the sensor</li>
</ul>

### v3.0.0 - 30-09-2023
This release is only meant for the production hardware (requiring firmware v3.0.0+). DIY hardware is currently not supported.<br>
The communication between the sensor and module has been overhauled, which is why it only works with the latest firmware. Besides that, a lot of minor changes and fixes have been made.<br>
Expand Down
58 changes: 29 additions & 29 deletions module.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
{
"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.0",
"esmodules": [
"MaterialPlane.js"
],
"socket": true,
"flags": {
"minimumSensorVersion": "3.0.0",
"minimumSensorWsVersion": "2.0.0",
"minimumBaseVersion": "2.0.0",
"minimumPenVersion": "2.0.0",
"minimumMSversion": "1.0.0"
},
"languages": [
{
"lang": "en",
"name": "English",
"path": "lang/en.json",
"flags": {}
"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.1",
"esmodules": [
"MaterialPlane.js"
],
"socket": true,
"flags": {
"minimumSensorVersion": "3.0.0",
"minimumSensorWsVersion": "2.0.0",
"minimumBaseVersion": "2.0.0",
"minimumPenVersion": "2.0.0",
"minimumMSversion": "1.0.0"
},
"languages": [
{
"lang": "en",
"name": "English",
"path": "lang/en.json",
"flags": {}
}
],
"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",
"id": "MaterialPlane",
"compatibility": {
"minimum": "10",
"verified": "11"
}
],
"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/v2.1.7/module.zip",
"id": "MaterialPlane",
"compatibility": {
"minimum": "10",
"verified": "11"
}
}
46 changes: 25 additions & 21 deletions src/calibration.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,9 @@ export class calibrationProgressScreen extends FormApplication {
const calNextBtn = html.find("button[name='calNext']");

calNextBtn.on("click", event => {
console.log('test')
const msg = JSON.stringify({event:"calibration", state:"next"});
let user = game.users.contents.filter(u => u.active == true && u.isGM == true)[0];
if (game.userId == user.id) sendWS(msg);
else if (user == undefined && game.settings.get(moduleName,'TargetName') == game.user.name) sendWS(msg);
sendWS(msg);
});

}
Expand All @@ -74,7 +73,7 @@ export class calibrationProgressScreen extends FormApplication {
countdownCount = 5;
this.render(true);

if (this.calibrationMode != 'multi' && overlay == undefined && game.settings.get(moduleName,'TargetName') == game.user.name) {
if (this.calibrationMode != 'multi' && overlay == undefined && game.settings.get(moduleName,'ActiveUser') == game.userId) {
overlay = new calibrationOverlay();
canvas.stage.addChild(overlay);
overlay.init();
Expand Down Expand Up @@ -104,11 +103,11 @@ export class calibrationProgressScreen extends FormApplication {
if (this.calibrationMode != 'MultiPoint') return;
let points = 0;
for (let i=0; i<4; i++) {
if (data[i]?.x != undefined && data[i]?.y != undefined) {
if (data.points[i]?.x != undefined && data.points[i]?.y != undefined) {
points++;
if (data[i].x != 0 && data[i].y != 0) {
document.getElementById("mpCalPoint_x"+i).innerHTML=data[i].x;
document.getElementById("mpCalPoint_y"+i).innerHTML=data[i].y;
if (data.points[i].x != 0 && data.points[i].y != 0) {
document.getElementById("mpCalPoint_x"+i).innerHTML=Math.round(data.points[i].x);
document.getElementById("mpCalPoint_y"+i).innerHTML=Math.round(data.points[i].y);
}
document.getElementById("iterationPoint"+i).style.color='black';
document.getElementById("mpCalPoint_x"+i).style.color='black';
Expand All @@ -131,19 +130,24 @@ export class calibrationProgressScreen extends FormApplication {
}

setPoint(data) {
if (this.calibrationMode == 'multi') return;
if (data.point < 0 || data.point > 3) return;
this.pointCount = data.point+1;

document.getElementById("mpCalPoint_x"+data.point).value = data.x;
document.getElementById("mpCalPoint_y"+data.point).value = data.y;
document.getElementById("iterationPoint"+data.point).style.color='black';
document.getElementById("mpCalPoint_x"+data.point).style.color='black';
document.getElementById("mpCalPoint_y"+data.point).style.color='black';
if (data.mode == 'MultiPoint') {
this.setMultiPoint(data);
}
else {
if (data.point < 0 || data.point > 3) return;
this.pointCount = data.point+1;

document.getElementById("mpCalPoint_x"+data.point).value = data.x;
document.getElementById("mpCalPoint_y"+data.point).value = data.y;
document.getElementById("iterationPoint"+data.point).style.color='black';
document.getElementById("mpCalPoint_x"+data.point).style.color='black';
document.getElementById("mpCalPoint_y"+data.point).style.color='black';
}

}

updatePoint(data) {
if (this.calibrationMode == 'multi') return;
if (this.calibrationMode == 'MultiPoint') return;
document.getElementById("noMovement").style="display:none";
document.getElementById("waiting").style="";
countdownCount = 5;
Expand Down Expand Up @@ -174,7 +178,7 @@ export class calibrationProgressScreen extends FormApplication {
const msg = JSON.stringify({event:"calibration", state:"next"});
let user = game.users.contents.filter(u => u.active == true && u.isGM == true)[0];
if (game.userId == user.id) sendWS(msg);
else if (user == undefined && game.settings.get(moduleName,'TargetName') == game.user.name) sendWS(msg);
else if (user == undefined && game.settings.get(moduleName,'ActiveUser') == game.userId) sendWS(msg);
}
}

Expand Down Expand Up @@ -202,7 +206,7 @@ export class calibrationProgressScreen extends FormApplication {
}

export function removeOverlay(){
if (game.settings.get(moduleName,'TargetName') != game.user.name) return;
if (game.settings.get(moduleName,'ActiveUser') != game.userId) return;
if (overlay == undefined) return;
canvas.stage.removeChild(overlay);
overlay.remove();
Expand All @@ -223,7 +227,7 @@ export class calibrationOverlay extends ControlsLayer {
this.addChild(this.container);

var drawing = new PIXI.Graphics();
drawing.beginFill("0x0");
drawing.beginFill("0x000000");
drawing.drawRect(0,0,canvas.scene.dimensions.width,canvas.scene.dimensions.height);
drawing.endFill();
drawing.alpha = 0.5;
Expand Down
14 changes: 10 additions & 4 deletions src/websocket.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async function analyzeWSmessage(msg,passthrough = false){
//console.log('data',data);
}
catch (error) {
console.warn('could not parse JSON',error);
console.warn('could not parse JSON',error, msg);
//console.log(msg);
return;
}
Expand Down Expand Up @@ -111,9 +111,14 @@ export async function startWebsocket() {
wsOpen = true;
if (game.settings.get(moduleName,'EnMaterialServer')) {
const msg = {
target: "server",
module: "MP",
ip: game.settings.get(moduleName,'IP')
target: "MaterialCompanion",
source: "MaterialPlane_Foundry",
sourceTarget: "MaterialPlane_Device",
type: "connected",
userId: game.userId,
userName: game.user.name,
version: game.modules.get(moduleName).version,
sensorIp: game.settings.get(moduleName,'IP')
}
ws.send(JSON.stringify(msg));
}
Expand Down Expand Up @@ -151,6 +156,7 @@ function resetWS(){


export function sendWS(txt){
console.log('SendWS',wsOpen,txt)
if (wsOpen) {
if (game.settings.get(moduleName,'EnMaterialServer')) {
const msg = {
Expand Down

0 comments on commit 6fed658

Please sign in to comment.