diff --git a/src/engine/monitor-record.js b/src/engine/monitor-record.js index daa6f9db1..1259d5252 100644 --- a/src/engine/monitor-record.js +++ b/src/engine/monitor-record.js @@ -12,6 +12,7 @@ const MonitorRecord = Record({ mode: 'default', sliderMin: 0, sliderMax: 100, + isDiscrete: true, x: null, // (x: null, y: null) Indicates that the monitor should be auto-positioned y: null, width: 0, diff --git a/src/serialization/sb2.js b/src/serialization/sb2.js index f8d1b9e65..2e5a556af 100644 --- a/src/serialization/sb2.js +++ b/src/serialization/sb2.js @@ -381,6 +381,7 @@ const parseMonitorObject = (object, runtime, targets, extensions) => { mode: object.mode, sliderMin: object.sliderMin, sliderMax: object.sliderMax, + isDiscrete: object.isDiscrete, x: object.x, y: object.y, width: object.width, diff --git a/src/serialization/sb3.js b/src/serialization/sb3.js index 5b4d5a76e..6aa592c73 100644 --- a/src/serialization/sb3.js +++ b/src/serialization/sb3.js @@ -506,6 +506,7 @@ const serializeMonitors = function (monitors) { if (monitorData.mode !== 'list') { serializedMonitor.sliderMin = monitorData.sliderMin; serializedMonitor.sliderMax = monitorData.sliderMax; + serializedMonitor.isDiscrete = monitorData.isDiscrete; } return serializedMonitor; }); diff --git a/test/fixtures/monitors.sb2 b/test/fixtures/monitors.sb2 index 2b9ede376..587488905 100644 Binary files a/test/fixtures/monitors.sb2 and b/test/fixtures/monitors.sb2 differ diff --git a/test/integration/monitors_sb2.js b/test/integration/monitors_sb2.js index a2c263487..12ab92a83 100644 --- a/test/integration/monitors_sb2.js +++ b/test/integration/monitors_sb2.js @@ -37,6 +37,7 @@ test('importing sb2 project with monitors', t => { t.equal(monitorRecord.mode, 'slider'); t.equal(monitorRecord.sliderMin, -200); // Make sure these are imported for sliders. t.equal(monitorRecord.sliderMax, 30); + t.equal(monitorRecord.isDiscrete, false); t.equal(monitorRecord.x, 5); // These are imported for all monitors, just check once. t.equal(monitorRecord.y, 59); t.equal(monitorRecord.visible, true); @@ -61,8 +62,8 @@ test('importing sb2 project with monitors', t => { t.equal(monitorRecord.opcode, 'data_listcontents'); t.equal(monitorRecord.mode, 'list'); t.equal(monitorRecord.visible, true); - t.equal(monitorRecord.width, 104); // Make sure these are imported from lists. - t.equal(monitorRecord.height, 204); + t.equal(monitorRecord.width, 106); // Make sure these are imported from lists. + t.equal(monitorRecord.height, 206); // Backdrop name monitor is visible, not sprite specific // should get imported with id that references the name parameter diff --git a/test/integration/monitors_sb2_to_sb3.js b/test/integration/monitors_sb2_to_sb3.js index 4fb26bbf8..ec881c2d3 100644 --- a/test/integration/monitors_sb2_to_sb3.js +++ b/test/integration/monitors_sb2_to_sb3.js @@ -54,6 +54,7 @@ test('saving and loading sb2 project with monitors preserves sliderMin and slide t.equal(monitorRecord.mode, 'slider'); t.equal(monitorRecord.sliderMin, -200); // Make sure these are imported for sliders. t.equal(monitorRecord.sliderMax, 30); + t.equal(monitorRecord.isDiscrete, false); t.equal(monitorRecord.x, 5); // These are imported for all monitors, just check once. t.equal(monitorRecord.y, 59); t.equal(monitorRecord.visible, true); @@ -78,8 +79,8 @@ test('saving and loading sb2 project with monitors preserves sliderMin and slide t.equal(monitorRecord.opcode, 'data_listcontents'); t.equal(monitorRecord.mode, 'list'); t.equal(monitorRecord.visible, true); - t.equal(monitorRecord.width, 104); // Make sure these are imported from lists. - t.equal(monitorRecord.height, 204); + t.equal(monitorRecord.width, 106); // Make sure these are imported from lists. + t.equal(monitorRecord.height, 206); // Backdrop name monitor is visible, not sprite specific // should get imported with id that references the name parameter diff --git a/test/integration/monitors_sb3.js b/test/integration/monitors_sb3.js index 3c5c08f9e..f55edb864 100644 --- a/test/integration/monitors_sb3.js +++ b/test/integration/monitors_sb3.js @@ -39,10 +39,9 @@ test('importing sb3 project with monitors', t => { t.equal(monitorRecord.opcode, 'data_variable'); t.equal(monitorRecord.mode, 'default'); // The following few properties are imported for all monitors, just check once. - // sliderMin and sliderMax are currently not implemented, - // but should still get default values serialized and deserialized correctly t.equal(monitorRecord.sliderMin, 0); t.equal(monitorRecord.sliderMax, 100); + t.equal(monitorRecord.isDiscrete, true); // The default if not present t.equal(monitorRecord.x, 10); t.equal(monitorRecord.y, 62); // Height and width are only used for list monitors and should default to 0