Merge pull request #1995 from paulkaplan/is-discrete

Support isDiscrete flag on monitors
This commit is contained in:
Paul Kaplan 2019-02-13 11:19:51 -05:00 committed by GitHub
commit 3b203a2a9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 10 additions and 6 deletions

View file

@ -12,6 +12,7 @@ const MonitorRecord = Record({
mode: 'default', mode: 'default',
sliderMin: 0, sliderMin: 0,
sliderMax: 100, sliderMax: 100,
isDiscrete: true,
x: null, // (x: null, y: null) Indicates that the monitor should be auto-positioned x: null, // (x: null, y: null) Indicates that the monitor should be auto-positioned
y: null, y: null,
width: 0, width: 0,

View file

@ -381,6 +381,7 @@ const parseMonitorObject = (object, runtime, targets, extensions) => {
mode: object.mode, mode: object.mode,
sliderMin: object.sliderMin, sliderMin: object.sliderMin,
sliderMax: object.sliderMax, sliderMax: object.sliderMax,
isDiscrete: object.isDiscrete,
x: object.x, x: object.x,
y: object.y, y: object.y,
width: object.width, width: object.width,

View file

@ -506,6 +506,7 @@ const serializeMonitors = function (monitors) {
if (monitorData.mode !== 'list') { if (monitorData.mode !== 'list') {
serializedMonitor.sliderMin = monitorData.sliderMin; serializedMonitor.sliderMin = monitorData.sliderMin;
serializedMonitor.sliderMax = monitorData.sliderMax; serializedMonitor.sliderMax = monitorData.sliderMax;
serializedMonitor.isDiscrete = monitorData.isDiscrete;
} }
return serializedMonitor; return serializedMonitor;
}); });

Binary file not shown.

View file

@ -37,6 +37,7 @@ test('importing sb2 project with monitors', t => {
t.equal(monitorRecord.mode, 'slider'); t.equal(monitorRecord.mode, 'slider');
t.equal(monitorRecord.sliderMin, -200); // Make sure these are imported for sliders. t.equal(monitorRecord.sliderMin, -200); // Make sure these are imported for sliders.
t.equal(monitorRecord.sliderMax, 30); 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.x, 5); // These are imported for all monitors, just check once.
t.equal(monitorRecord.y, 59); t.equal(monitorRecord.y, 59);
t.equal(monitorRecord.visible, true); 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.opcode, 'data_listcontents');
t.equal(monitorRecord.mode, 'list'); t.equal(monitorRecord.mode, 'list');
t.equal(monitorRecord.visible, true); t.equal(monitorRecord.visible, true);
t.equal(monitorRecord.width, 104); // Make sure these are imported from lists. t.equal(monitorRecord.width, 106); // Make sure these are imported from lists.
t.equal(monitorRecord.height, 204); t.equal(monitorRecord.height, 206);
// Backdrop name monitor is visible, not sprite specific // Backdrop name monitor is visible, not sprite specific
// should get imported with id that references the name parameter // should get imported with id that references the name parameter

View file

@ -54,6 +54,7 @@ test('saving and loading sb2 project with monitors preserves sliderMin and slide
t.equal(monitorRecord.mode, 'slider'); t.equal(monitorRecord.mode, 'slider');
t.equal(monitorRecord.sliderMin, -200); // Make sure these are imported for sliders. t.equal(monitorRecord.sliderMin, -200); // Make sure these are imported for sliders.
t.equal(monitorRecord.sliderMax, 30); 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.x, 5); // These are imported for all monitors, just check once.
t.equal(monitorRecord.y, 59); t.equal(monitorRecord.y, 59);
t.equal(monitorRecord.visible, true); 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.opcode, 'data_listcontents');
t.equal(monitorRecord.mode, 'list'); t.equal(monitorRecord.mode, 'list');
t.equal(monitorRecord.visible, true); t.equal(monitorRecord.visible, true);
t.equal(monitorRecord.width, 104); // Make sure these are imported from lists. t.equal(monitorRecord.width, 106); // Make sure these are imported from lists.
t.equal(monitorRecord.height, 204); t.equal(monitorRecord.height, 206);
// Backdrop name monitor is visible, not sprite specific // Backdrop name monitor is visible, not sprite specific
// should get imported with id that references the name parameter // should get imported with id that references the name parameter

View file

@ -39,10 +39,9 @@ test('importing sb3 project with monitors', t => {
t.equal(monitorRecord.opcode, 'data_variable'); t.equal(monitorRecord.opcode, 'data_variable');
t.equal(monitorRecord.mode, 'default'); t.equal(monitorRecord.mode, 'default');
// The following few properties are imported for all monitors, just check once. // 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.sliderMin, 0);
t.equal(monitorRecord.sliderMax, 100); t.equal(monitorRecord.sliderMax, 100);
t.equal(monitorRecord.isDiscrete, true); // The default if not present
t.equal(monitorRecord.x, 10); t.equal(monitorRecord.x, 10);
t.equal(monitorRecord.y, 62); t.equal(monitorRecord.y, 62);
// Height and width are only used for list monitors and should default to 0 // Height and width are only used for list monitors and should default to 0