Skip to content

Commit 6bc77ea

Browse files
author
Matthew Matz
committed
Bug fixes: variables, graphing, add grayscale feature
1 parent 23d6103 commit 6bc77ea

File tree

12 files changed

+125
-111
lines changed

12 files changed

+125
-111
lines changed

src/main/webapp/cdn/blockly/generators/propc.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,21 @@ var colorPalette = {
112112
'protocols': 340,
113113
'system': 320
114114
},
115+
grayscaleColors: {
116+
'input': '#AAAAAA',
117+
'output': '#222222',
118+
'io': '#333333',
119+
'programming': '#444444',
120+
'functions': '#555555',
121+
'variables': '#666666',
122+
'math': '#777777',
123+
'binary': '#777777',
124+
'robot': '#888888',
125+
'heb': '#888888',
126+
'ab': '#999999',
127+
'protocols': '#111111',
128+
'system': '#999999'
129+
},
115130
activePalette: null,
116131
getColor: function (type) {
117132
if (colorPalette.activePalette && colorPalette.activePalette[type] !== undefined) {
@@ -123,7 +138,11 @@ var colorPalette = {
123138

124139
};
125140

126-
colorPalette.activePalette = colorPalette.defaultColors;
141+
if (document.referrer.split('?')[1].indexOf('grayscale=1') === -1 ) {
142+
colorPalette.activePalette = colorPalette.defaultColors;
143+
} else {
144+
colorPalette.activePalette = colorPalette.grayscaleColors;
145+
}
127146

128147

129148

src/main/webapp/cdn/blockly/generators/propc/base.js

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,31 +31,6 @@
3131
if (!Blockly.Blocks)
3232
Blockly.Blocks = {};
3333

34-
/*
35-
Blockly.Blocks.number_range = {
36-
helpUrl: Blockly.MSG_VALUES_HELPURL,
37-
init: function () {
38-
this.setTooltip(Blockly.MSG_MATH_NUMBER_TOOLTIP);
39-
this.setColour(colorPalette.getColor('programming'));
40-
this.appendDummyInput()
41-
.appendField(new Blockly.FieldTextInput('0',
42-
Blockly.FieldTextInput.numberValidator), 'NUM');
43-
this.setOutput(true, 'Number');
44-
}
45-
};
46-
47-
Blockly.propc.number_range = function () {
48-
// Numeric value.
49-
var code = window.parseInt(this.getFieldValue('NUM'));
50-
// -4.abs() returns -4 in Dart due to strange order of operation choices.
51-
// -4 is actually an operator and a number. Reflect this in the order.
52-
var order = code < 0 ?
53-
Blockly.propc.ORDER_UNARY_PREFIX : Blockly.propc.ORDER_ATOMIC;
54-
return [code, order];
55-
};
56-
*/
57-
58-
5934
// Number block that can mutate to show a range or if a value
6035
// is out bounds or not available. Gets values from the block its connected
6136
// to by looking for a hidden field starting with "RANGEVALS".
@@ -1270,7 +1245,7 @@ Blockly.Blocks.combine_strings = {
12701245
},
12711246
renameVar: function (oldName, newName) {
12721247
if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
1273-
this.setTitleValue(newName, 'VALUE');
1248+
this.setFieldValue(newName, 'VALUE');
12741249
}
12751250
}
12761251
};
@@ -1350,7 +1325,7 @@ Blockly.Blocks.get_char_at_position = {
13501325
},
13511326
renameVar: function (oldName, newName) {
13521327
if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
1353-
this.setTitleValue(newName, 'VALUE');
1328+
this.setFieldValue(newName, 'VALUE');
13541329
}
13551330
}
13561331
};
@@ -1392,7 +1367,7 @@ Blockly.Blocks.set_char_at_position = {
13921367
},
13931368
renameVar: function (oldName, newName) {
13941369
if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
1395-
this.setTitleValue(newName, 'VALUE');
1370+
this.setFieldValue(newName, 'VALUE');
13961371
}
13971372
}
13981373
};
@@ -1431,9 +1406,9 @@ Blockly.Blocks.get_substring = {
14311406
},
14321407
renameVar: function (oldName, newName) {
14331408
if (Blockly.Names.equals(oldName, this.getFieldValue('FROM_STR')))
1434-
this.setTitleValue(newName, 'FROM_STR');
1409+
this.setFieldValue(newName, 'FROM_STR');
14351410
if (Blockly.Names.equals(oldName, this.getFieldValue('TO_STR')))
1436-
this.setTitleValue(newName, 'TO_STR');
1411+
this.setFieldValue(newName, 'TO_STR');
14371412
}
14381413
};
14391414

@@ -1515,7 +1490,7 @@ Blockly.Blocks.string_to_number = {
15151490
},
15161491
renameVar: function (oldName, newName) {
15171492
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
1518-
this.setTitleValue(newName, 'VAR');
1493+
this.setFieldValue(newName, 'VAR');
15191494
}
15201495
}
15211496
};
@@ -1556,7 +1531,7 @@ Blockly.Blocks.number_to_string = {
15561531
},
15571532
renameVar: function (oldName, newName) {
15581533
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
1559-
this.setTitleValue(newName, 'VAR');
1534+
this.setFieldValue(newName, 'VAR');
15601535
}
15611536
}
15621537
};
@@ -1670,7 +1645,7 @@ Blockly.Blocks.math_advanced = {
16701645
},
16711646
renameVar: function (oldName, newName) {
16721647
if (Blockly.Names.equals(oldName, this.getFieldValue('STORE'))) {
1673-
this.setTitleValue(newName, 'STORE');
1648+
this.setFieldValue(newName, 'STORE');
16741649
}
16751650
}
16761651
};
@@ -1719,7 +1694,7 @@ Blockly.Blocks.math_inv_trig = {
17191694
},
17201695
renameVar: function (oldName, newName) {
17211696
if (Blockly.Names.equals(oldName, this.getFieldValue('STORE'))) {
1722-
this.setTitleValue(newName, 'STORE');
1697+
this.setFieldValue(newName, 'STORE');
17231698
}
17241699
}
17251700
};

src/main/webapp/cdn/blockly/generators/propc/communicate.js

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ Blockly.Blocks.console_scan_text = {
140140
},
141141
renameVar: function (oldName, newName) {
142142
if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
143-
this.setTitleValue(newName, 'VALUE');
143+
this.setFieldValue(newName, 'VALUE');
144144
}
145145
}
146146

@@ -179,7 +179,7 @@ Blockly.Blocks.console_scan_number = {
179179
},
180180
renameVar: function (oldName, newName) {
181181
if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
182-
this.setTitleValue(newName, 'VALUE');
182+
this.setFieldValue(newName, 'VALUE');
183183
}
184184
}
185185

@@ -410,7 +410,7 @@ Blockly.Blocks.serial_rx = {
410410
},
411411
renameVar: function (oldName, newName) {
412412
if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
413-
this.setTitleValue(newName, 'VALUE');
413+
this.setFieldValue(newName, 'VALUE');
414414
}
415415
}
416416
};
@@ -452,7 +452,7 @@ Blockly.Blocks.serial_receive_text = {
452452
},
453453
renameVar: function (oldName, newName) {
454454
if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
455-
this.setTitleValue(newName, 'VALUE');
455+
this.setFieldValue(newName, 'VALUE');
456456
}
457457
}
458458
};
@@ -903,7 +903,7 @@ Blockly.Blocks.xbee_receive = {
903903
},
904904
renameVar: function (oldName, newName) {
905905
if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
906-
this.setTitleValue(newName, 'VALUE');
906+
this.setFieldValue(newName, 'VALUE');
907907
}
908908
}
909909
};
@@ -2259,10 +2259,10 @@ Blockly.Blocks.wx_scan_multiple = {
22592259
},
22602260
renameVar: function (oldName, newName) {
22612261
if (Blockly.Names.equals(oldName, this.getFieldValue('HANDLE')))
2262-
this.setTitleValue(newName, 'VALUE');
2262+
this.setFieldValue(newName, 'VALUE');
22632263
for (var i = 0; i < this.optionList_.length; i++) {
22642264
if (Blockly.Names.equals(oldName, this.getFieldValue('CPU' + i)))
2265-
this.setTitleValue(newName, 'CPU' + i);
2265+
this.setFieldValue(newName, 'CPU' + i);
22662266

22672267
}
22682268
}
@@ -2470,7 +2470,7 @@ Blockly.Blocks.wx_print_multiple = {
24702470
},
24712471
renameVar: function (oldName, newName) {
24722472
if (Blockly.Names.equals(oldName, this.getFieldValue('HANDLE'))) {
2473-
this.setTitleValue(newName, 'HANDLE');
2473+
this.setFieldValue(newName, 'HANDLE');
24742474
}
24752475
}
24762476
};
@@ -2588,9 +2588,9 @@ Blockly.Blocks.wx_scan_string = {
25882588
},
25892589
renameVar: function (oldName, newName) {
25902590
if (Blockly.Names.equals(oldName, this.getFieldValue('HANDLE')))
2591-
this.setTitleValue(newName, 'HANDLE');
2591+
this.setFieldValue(newName, 'HANDLE');
25922592
if (Blockly.Names.equals(oldName, this.getFieldValue('VARNAME')))
2593-
this.setTitleValue(newName, 'VARNAME');
2593+
this.setFieldValue(newName, 'VARNAME');
25942594
}
25952595
};
25962596

@@ -2636,7 +2636,7 @@ Blockly.Blocks.wx_send_string = {
26362636
},
26372637
renameVar: function (oldName, newName) {
26382638
if (Blockly.Names.equals(oldName, this.getFieldValue('HANDLE'))) {
2639-
this.setTitleValue(newName, 'HANDLE');
2639+
this.setFieldValue(newName, 'HANDLE');
26402640
}
26412641
}
26422642
};
@@ -2680,11 +2680,11 @@ Blockly.Blocks.wx_receive_string = {
26802680
},
26812681
renameVar: function (oldName, newName) {
26822682
if (Blockly.Names.equals(oldName, this.getFieldValue('DATA')))
2683-
this.setTitleValue(newName, 'DATA');
2683+
this.setFieldValue(newName, 'DATA');
26842684
if (Blockly.Names.equals(oldName, this.getFieldValue('BYTES')))
2685-
this.setTitleValue(newName, 'BYTES');
2685+
this.setFieldValue(newName, 'BYTES');
26862686
if (Blockly.Names.equals(oldName, this.getFieldValue('HANDLE')))
2687-
this.setTitleValue(newName, 'HANDLE');
2687+
this.setFieldValue(newName, 'HANDLE');
26882688
}
26892689
};
26902690

@@ -2725,11 +2725,11 @@ Blockly.Blocks.wx_poll = {
27252725
},
27262726
renameVar: function (oldName, newName) {
27272727
if (Blockly.Names.equals(oldName, this.getFieldValue('ID')))
2728-
this.setTitleValue(newName, 'ID');
2728+
this.setFieldValue(newName, 'ID');
27292729
if (Blockly.Names.equals(oldName, this.getFieldValue('EVENT')))
2730-
this.setTitleValue(newName, 'EVENT');
2730+
this.setFieldValue(newName, 'EVENT');
27312731
if (Blockly.Names.equals(oldName, this.getFieldValue('HANDLE')))
2732-
this.setTitleValue(newName, 'HANDLE');
2732+
this.setFieldValue(newName, 'HANDLE');
27332733
}
27342734
};
27352735

@@ -2812,15 +2812,15 @@ Blockly.Blocks.wx_listen = {
28122812
},
28132813
renameVar: function (oldName, newName) {
28142814
if (Blockly.Names.equals(oldName, this.getFieldValue('ID')))
2815-
this.setTitleValue(newName, 'ID');
2815+
this.setFieldValue(newName, 'ID');
28162816
if (Blockly.Names.equals(oldName, this.getFieldValue('ID1')))
2817-
this.setTitleValue(newName, 'ID1');
2817+
this.setFieldValue(newName, 'ID1');
28182818
if (Blockly.Names.equals(oldName, this.getFieldValue('ID2')))
2819-
this.setTitleValue(newName, 'ID2');
2819+
this.setFieldValue(newName, 'ID2');
28202820
if (Blockly.Names.equals(oldName, this.getFieldValue('ID3')))
2821-
this.setTitleValue(newName, 'ID3');
2821+
this.setFieldValue(newName, 'ID3');
28222822
if (Blockly.Names.equals(oldName, this.getFieldValue('ID4')))
2823-
this.setTitleValue(newName, 'ID4');
2823+
this.setFieldValue(newName, 'ID4');
28242824
}
28252825
};
28262826

@@ -3048,7 +3048,7 @@ Blockly.Blocks.wx_buffer = {
30483048
},
30493049
renameVar: function (oldName, newName) {
30503050
if (Blockly.Names.equals(oldName, this.getFieldValue('BUFFER'))) {
3051-
this.setTitleValue(newName, 'BUFFER');
3051+
this.setFieldValue(newName, 'BUFFER');
30523052
}
30533053
}
30543054
};
@@ -3115,7 +3115,7 @@ Blockly.Blocks.wx_disconnect = {
31153115
},
31163116
renameVar: function (oldName, newName) {
31173117
if (Blockly.Names.equals(oldName, this.getFieldValue('ID'))) {
3118-
this.setTitleValue(newName, 'ID');
3118+
this.setFieldValue(newName, 'ID');
31193119
}
31203120
}
31213121
};
@@ -3268,14 +3268,6 @@ Blockly.Blocks.graph_output = {
32683268
this.removeInput('PRINTa');
32693269
this.removeInput('PRINTb');
32703270
}
3271-
},
3272-
getVars: function () {
3273-
return [this.getFieldValue('HANDLE')];
3274-
},
3275-
renameVar: function (oldName, newName) {
3276-
if (Blockly.Names.equals(oldName, this.getFieldValue('HANDLE'))) {
3277-
this.setTitleValue(newName, 'HANDLE');
3278-
}
32793271
}
32803272
};
32813273

src/main/webapp/cdn/blockly/generators/propc/control.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ Blockly.Blocks.control_repeat_for_loop = {
392392
},
393393
renameVar: function (oldName, newName) {
394394
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
395-
this.setTitleValue(newName, 'VAR');
395+
this.setFieldValue(newName, 'VAR');
396396
}
397397
}
398398
};

src/main/webapp/cdn/blockly/generators/propc/gpio.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ Blockly.Blocks.eeprom_read = {
556556
},
557557
renameVar: function (oldName, newName) {
558558
if (Blockly.Names.equals(oldName, this.getFieldValue('VALUE'))) {
559-
this.setTitleValue(newName, 'VALUE');
559+
this.setFieldValue(newName, 'VALUE');
560560
}
561561
}
562562
};

src/main/webapp/cdn/blockly/generators/propc/heb.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,9 @@ Blockly.Blocks.heb_ir_read_signal = {
545545
},
546546
renameVar: function (oldName, newName) {
547547
if (Blockly.Names.equals(oldName, this.getFieldValue('BUFFER')))
548-
this.setTitleValue(newName, 'BUFFER');
548+
this.setFieldValue(newName, 'BUFFER');
549549
if (Blockly.Names.equals(oldName, this.getFieldValue('LENGTH')))
550-
this.setTitleValue(newName, 'LENGTH');
550+
this.setFieldValue(newName, 'LENGTH');
551551
}
552552
};
553553

@@ -644,7 +644,7 @@ Blockly.Blocks.heb_badge_eeprom_retrieve = {
644644
},
645645
renameVar: function (oldName, newName) {
646646
if (Blockly.Names.equals(oldName, this.getFieldValue('BUFFER'))) {
647-
this.setTitleValue(newName, 'BUFFER');
647+
this.setFieldValue(newName, 'BUFFER');
648648
}
649649
}
650650
};

0 commit comments

Comments
 (0)