mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-01-09 14:32:07 -05:00
Merge pull request #1995 from paulkaplan/is-discrete
Support isDiscrete flag on monitors
This commit is contained in:
commit
3b203a2a9b
7 changed files with 10 additions and 6 deletions
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
});
|
||||
|
|
BIN
test/fixtures/monitors.sb2
vendored
BIN
test/fixtures/monitors.sb2
vendored
Binary file not shown.
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue