Skip to content

Commit 4869111

Browse files
committed
fix up reverse tooltips
1 parent cb10f94 commit 4869111

File tree

4 files changed

+84
-90
lines changed

4 files changed

+84
-90
lines changed

editor.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,15 @@ namespace microcode {
297297
// to string
298298
const progAsString = this.progdef.toString()
299299
const progFromString = parse(progAsString)
300-
const progAsBuf = progFromString.toBuffer()
301-
// compare buffers
302-
if (buf.length == progAsBuf.length) {
303-
} else {
304-
control.assert(
305-
false,
306-
`buf.length = ${buf.length} progAsBuf.length = ${progAsBuf.length}`
307-
)
308-
}
300+
// const progAsBuf = progFromString.toBuffer()
301+
// // compare buffers
302+
// if (buf.length == progAsBuf.length) {
303+
// } else {
304+
// control.assert(
305+
// false,
306+
// `buf.length = ${buf.length} progAsBuf.length = ${progAsBuf.length}`
307+
// )
308+
// }
309309
}
310310
this.configureP1Keys()
311311
}

mcparser.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,22 @@ namespace microcode {
2626
let currTile: Tile = undefined
2727
for (let i = 0; i < lines.length; i++) {
2828
if (currTile instanceof IconEditor) {
29-
// grab the next 4 lines as well
3029
const all5 = lines.slice(i, i + 4).join("\n")
3130
currTile.field = currTile.fieldEditor.fromString(all5)
3231
currTile = undefined
33-
i = i + 4
32+
i = i + 4 // loop count adds one more
3433
continue
3534
}
3635
const tokens = lines[i].split(" ")
36+
if (tokens.length == 0) continue
37+
console.log(`tok = ${tokens[0]}`)
3738
if (tokens[0] == "Page") {
3839
currPage = new PageDefn()
3940
} else if (tokens[0] == "EOP") {
4041
prog.pages.push(currPage)
4142
currPage = undefined
4243
} else if (tokens[0] == "EOR") {
44+
console.log("EOR")
4345
currPage.rules.push(currRule)
4446
currRule = undefined
4547
} else {
@@ -50,10 +52,12 @@ namespace microcode {
5052
}
5153
let tok = tokens.shift()
5254
while (tok) {
55+
console.log(`tok = ${tok}`)
5356
if (!currTile) {
5457
currTile = token2tile(tok)
5558
placeTile(currTile, currRule)
5659
} else if (currTile instanceof IconEditor) {
60+
console.log(`got IconEditor`)
5761
break
5862
} else if (currTile instanceof DigitEditor) {
5963
currTile.field = currTile.fieldEditor.fromString(tok)

scripts/lochex.mjs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,6 @@ for (const lang of languages.filter(l => l !== "pxt")) {
8484

8585
const entries = {}
8686

87-
/*
88-
ERROR: already have entry for red
89-
ERROR: already have entry for purple
90-
91-
ERROR: already have entry for turn-left
92-
ERROR: already have entry for turn-right
93-
ERROR: already have entry for on
94-
ERROR: already have entry for off
95-
*/
96-
9787
const tooltip2tid = `
9888
export function tooltip2tid(id: string): number {
9989
let tid: number = undefined
@@ -105,7 +95,7 @@ for (const lang of languages.filter(l => l !== "pxt")) {
10595
.filter(k => /T\d+/.test(k))
10696
.map(k => {
10797
const tid = parseInt(k.slice(1))
108-
const trans = translations[k].replace(/ /g, "-")
98+
const trans = translations[k]
10999
if (entries[trans]) {
110100
console.log(`ERROR: already have entry for ${trans}`)
111101
} else {

tooltips.ts

Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,18 @@ namespace microcode {
173173
export function tooltip2tid(id: string): number {
174174
let tid: number = undefined
175175
if (!id) return tid
176-
else if (id === "page-start") tid = 10;
176+
else if (id === "page start") tid = 10;
177177
else if (id === "press") tid = 11;
178178
else if (id === "release") tid = 12;
179179
else if (id === "move") tid = 13;
180180
else if (id === "timer") tid = 14;
181-
else if (id === "light-(external)") tid = 15;
181+
else if (id === "light (external)") tid = 15;
182182
else if (id === "temperature") tid = 16;
183-
else if (id === "radio-receive") tid = 17;
183+
else if (id === "radio receive") tid = 17;
184184
else if (id === "sound") tid = 18;
185-
else if (id === "variable-X-set") tid = 19;
186-
else if (id === "variable-Y-set") tid = 20;
187-
else if (id === "variable-Z-set") tid = 21;
185+
else if (id === "variable X set") tid = 19;
186+
else if (id === "variable Y set") tid = 20;
187+
else if (id === "variable Z set") tid = 21;
188188
else if (id === "magnet") tid = 22;
189189
else if (id === "slider") tid = 23;
190190
else if (id === "dial") tid = 24;
@@ -193,69 +193,69 @@ namespace microcode {
193193
else if (id === "light") tid = 27;
194194
else if (id === "moisture") tid = 28;
195195
else if (id === "distance") tid = 29;
196-
else if (id === "reflected-light") tid = 30;
197-
else if (id === "switch-page") tid = 40;
198-
else if (id === "play-sound") tid = 41;
196+
else if (id === "reflected light") tid = 30;
197+
else if (id === "switch page") tid = 40;
198+
else if (id === "play sound") tid = 41;
199199
else if (id === "music") tid = 43;
200-
else if (id === "show-image") tid = 44;
201-
else if (id === "radio-send") tid = 45;
202-
else if (id === "radio-set-group") tid = 46;
200+
else if (id === "show image") tid = 44;
201+
else if (id === "radio send") tid = 45;
202+
else if (id === "radio set group") tid = 46;
203203
else if (id === "LED") tid = 47;
204-
else if (id === "set-variable-X") tid = 48;
205-
else if (id === "set-variable-Y") tid = 49;
206-
else if (id === "set-variable-Z") tid = 50;
207-
else if (id === "show-number") tid = 51;
204+
else if (id === "set variable X") tid = 48;
205+
else if (id === "set variable Y") tid = 49;
206+
else if (id === "set variable Z") tid = 50;
207+
else if (id === "show number") tid = 51;
208208
else if (id === "robot") tid = 52;
209-
else if (id === "servo-set-angle") tid = 53;
209+
else if (id === "servo set angle") tid = 53;
210210
else if (id === "relay") tid = 54;
211-
else if (id === "servo-power") tid = 55;
212-
else if (id === "touch-pin-0") tid = 70;
213-
else if (id === "touch-pin-1") tid = 71;
214-
else if (id === "touch-pin-2") tid = 72;
215-
else if (id === "button-A") tid = 73;
216-
else if (id === "button-B") tid = 74;
217-
else if (id === "key-1") tid = 75;
218-
else if (id === "key-2") tid = 76;
211+
else if (id === "servo power") tid = 55;
212+
else if (id === "touch pin 0") tid = 70;
213+
else if (id === "touch pin 1") tid = 71;
214+
else if (id === "touch pin 2") tid = 72;
215+
else if (id === "button A") tid = 73;
216+
else if (id === "button B") tid = 74;
217+
else if (id === "key 1") tid = 75;
218+
else if (id === "key 2") tid = 76;
219219
else if (id === "logo") tid = 77;
220220
else if (id === "1") tid = 78;
221221
else if (id === "2") tid = 79;
222222
else if (id === "3") tid = 80;
223223
else if (id === "4") tid = 81;
224224
else if (id === "5") tid = 82;
225-
else if (id === "1/4-second") tid = 83;
226-
else if (id === "1-second") tid = 84;
227-
else if (id === "1-random-second") tid = 85;
228-
else if (id === "5-seconds") tid = 86;
225+
else if (id === "1/4 second") tid = 83;
226+
else if (id === "1 second") tid = 84;
227+
else if (id === "1 random second") tid = 85;
228+
else if (id === "5 seconds") tid = 86;
229229
else if (id === "loud") tid = 87;
230230
else if (id === "quiet") tid = 88;
231231
else if (id === "NA1") tid = 89;
232232
else if (id === "shake") tid = 90;
233-
else if (id === "tilt-up") tid = 91;
234-
else if (id === "tilt-down") tid = 92;
235-
else if (id === "tilt-left") tid = 93;
236-
else if (id === "tilt-right") tid = 94;
237-
else if (id === "variable-X") tid = 95;
238-
else if (id === "variable-Y") tid = 96;
239-
else if (id === "variable-Z") tid = 97;
240-
else if (id === "turn-left") tid = 98;
241-
else if (id === "turn-right") tid = 99;
233+
else if (id === "tilt up") tid = 91;
234+
else if (id === "tilt down") tid = 92;
235+
else if (id === "tilt left") tid = 93;
236+
else if (id === "tilt right") tid = 94;
237+
else if (id === "variable X") tid = 95;
238+
else if (id === "variable Y") tid = 96;
239+
else if (id === "variable Z") tid = 97;
240+
else if (id === "turn left") tid = 98;
241+
else if (id === "turn right") tid = 99;
242242
else if (id === "up") tid = 100;
243243
else if (id === "down") tid = 101;
244244
else if (id === "right") tid = 103;
245245
else if (id === "both") tid = 104;
246246
else if (id === "none") tid = 105;
247-
else if (id === "lost-left") tid = 106;
248-
else if (id === "lost-right") tid = 107;
249-
else if (id === "face-up") tid = 108;
250-
else if (id === "face-down") tid = 109;
247+
else if (id === "lost left") tid = 106;
248+
else if (id === "lost right") tid = 107;
249+
else if (id === "face up") tid = 108;
250+
else if (id === "face down") tid = 109;
251251
else if (id === "active") tid = 110;
252252
else if (id === "unactive") tid = 111;
253-
else if (id === "page-1") tid = 150;
254-
else if (id === "page-2") tid = 151;
255-
else if (id === "page-3") tid = 152;
256-
else if (id === "page-4") tid = 153;
257-
else if (id === "page-5") tid = 154;
258-
else if (id === "LED-image") tid = 160;
253+
else if (id === "page 1") tid = 150;
254+
else if (id === "page 2") tid = 151;
255+
else if (id === "page 3") tid = 152;
256+
else if (id === "page 4") tid = 153;
257+
else if (id === "page 5") tid = 154;
258+
else if (id === "LED image") tid = 160;
259259
else if (id === "NA5") tid = 161;
260260
else if (id === "NA6") tid = 162;
261261
else if (id === "giggle") tid = 163;
@@ -268,8 +268,8 @@ namespace microcode {
268268
else if (id === "spring") tid = 170;
269269
else if (id === "twinkle") tid = 171;
270270
else if (id === "yawn") tid = 172;
271-
else if (id === "radio-value") tid = 176;
272-
else if (id === "random-number") tid = 177;
271+
else if (id === "radio value") tid = 176;
272+
else if (id === "random number") tid = 177;
273273
else if (id === "repeat") tid = 178;
274274
else if (id === "melody") tid = 179;
275275
else if (id === "temp.") tid = 180;
@@ -287,31 +287,31 @@ namespace microcode {
287287
else if (id === "NA3") tid = 192;
288288
else if (id === "NA4") tid = 193;
289289
else if (id === "stop") tid = 194;
290-
else if (id === "fast-forward") tid = 195;
291-
else if (id === "spin-left") tid = 196;
292-
else if (id === "spin-right") tid = 197;
293-
else if (id === "LED-red") tid = 198;
294-
else if (id === "LED-green") tid = 199;
295-
else if (id === "LED-blue") tid = 200;
296-
else if (id === "LED-OFF") tid = 201;
297-
else if (id === "arm-open") tid = 202;
298-
else if (id === "arm-close") tid = 203;
290+
else if (id === "fast forward") tid = 195;
291+
else if (id === "spin left") tid = 196;
292+
else if (id === "spin right") tid = 197;
293+
else if (id === "LED red") tid = 198;
294+
else if (id === "LED green") tid = 199;
295+
else if (id === "LED blue") tid = 200;
296+
else if (id === "LED OFF") tid = 201;
297+
else if (id === "arm open") tid = 202;
298+
else if (id === "arm close") tid = 203;
299299
else if (id === "on") tid = 204;
300300
else if (id === "off") tid = 205;
301-
else if (id === "light-value") tid = 206;
302-
else if (id === "magnet-value") tid = 207;
303-
else if (id === "sound-value") tid = 208;
301+
else if (id === "light value") tid = 206;
302+
else if (id === "magnet value") tid = 207;
303+
else if (id === "sound value") tid = 208;
304304
else if (id === "add") tid = 210;
305305
else if (id === "subtract") tid = 211;
306306
else if (id === "multiply") tid = 212;
307307
else if (id === "divide") tid = 213;
308308
else if (id === "equals") tid = 220;
309-
else if (id === "not-equals") tid = 221;
310-
else if (id === "less-than") tid = 222;
311-
else if (id === "less-than-or-equals") tid = 223;
312-
else if (id === "greater-than") tid = 224;
313-
else if (id === "greater-than-or-equals") tid = 225;
314-
else if (id === "enter-number") tid = 255;
309+
else if (id === "not equals") tid = 221;
310+
else if (id === "less than") tid = 222;
311+
else if (id === "less than or equals") tid = 223;
312+
else if (id === "greater than") tid = 224;
313+
else if (id === "greater than or equals") tid = 225;
314+
else if (id === "enter number") tid = 255;
315315
return tid
316316
}
317317

0 commit comments

Comments
 (0)