pxt-arcade 2.0.34 → 2.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/built/editor.js +31 -4
- package/built/sim-strings.json +1 -1
- package/built/sim.js +28 -9
- package/built/target.js +1 -1
- package/built/target.json +1 -1
- package/built/targetlight.js +1 -1
- package/built/targetlight.json +1 -1
- package/package.json +3 -3
package/built/editor.js
CHANGED
|
@@ -311,16 +311,20 @@ var pxt;
|
|
|
311
311
|
// same for SpriteKindLegacy
|
|
312
312
|
performOldEnumShimUpgrade("SpriteKindLegacy", "spritetype");
|
|
313
313
|
}
|
|
314
|
-
// Added the "use
|
|
315
|
-
if (pxt.semver.strcmp(pkgTargetVersion || "0.0.0", "2.0.
|
|
314
|
+
// Added the "use on-screen keyboard" options to the ask for number and ask for string blocks
|
|
315
|
+
if (pxt.semver.strcmp(pkgTargetVersion || "0.0.0", "2.0.35") < 0) {
|
|
316
316
|
const allPromptBlocks = pxt.U.toArray(dom.querySelectorAll("block[type=gameaskforstring]"))
|
|
317
317
|
.concat(pxt.U.toArray(dom.querySelectorAll("shadow[type=gameaskforstring]")))
|
|
318
318
|
.concat(pxt.U.toArray(dom.querySelectorAll("block[type=gameaskfornumber]")))
|
|
319
319
|
.concat(pxt.U.toArray(dom.querySelectorAll("shadow[type=gameaskfornumber]")));
|
|
320
320
|
for (const block of allPromptBlocks) {
|
|
321
|
-
if (
|
|
321
|
+
if (getChildNode(block, "value", "name", "useOnScreenKeyboard")) {
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
else {
|
|
325
|
+
// preserve the old behavior by setting the value to true if not present
|
|
322
326
|
const value = document.createElement("value");
|
|
323
|
-
value.setAttribute("name", "
|
|
327
|
+
value.setAttribute("name", "useOnScreenKeyboard");
|
|
324
328
|
const shadow = document.createElement("shadow");
|
|
325
329
|
shadow.setAttribute("type", "logic_boolean");
|
|
326
330
|
const field = document.createElement("field");
|
|
@@ -330,6 +334,29 @@ var pxt;
|
|
|
330
334
|
value.appendChild(shadow);
|
|
331
335
|
block.appendChild(value);
|
|
332
336
|
}
|
|
337
|
+
// since we are going to expand the block, we also need to make sure that
|
|
338
|
+
// the other expandable parameter answerLength is present. the default values
|
|
339
|
+
// and min/max were taken from the source in pxt-common-packages prior to this change
|
|
340
|
+
const isStringBlock = block.getAttribute("type") === "gameaskforstring";
|
|
341
|
+
if (!getChildNode(block, "value", "name", "answerLength")) {
|
|
342
|
+
const value = document.createElement("value");
|
|
343
|
+
value.setAttribute("name", "answerLength");
|
|
344
|
+
const shadow = document.createElement("shadow");
|
|
345
|
+
shadow.setAttribute("type", "math_number_minmax");
|
|
346
|
+
const mutation = document.createElement("mutation");
|
|
347
|
+
mutation.setAttribute("xmlns", "http://www.w3.org/1999/xhtml");
|
|
348
|
+
mutation.setAttribute("min", "1");
|
|
349
|
+
mutation.setAttribute("max", isStringBlock ? "24" : "10");
|
|
350
|
+
mutation.setAttribute("label", "AnswerLength");
|
|
351
|
+
mutation.setAttribute("prevision", "0");
|
|
352
|
+
const field = document.createElement("field");
|
|
353
|
+
field.setAttribute("name", "SLIDER");
|
|
354
|
+
field.textContent = isStringBlock ? "12" : "6";
|
|
355
|
+
shadow.appendChild(field);
|
|
356
|
+
shadow.appendChild(mutation);
|
|
357
|
+
value.appendChild(shadow);
|
|
358
|
+
block.appendChild(value);
|
|
359
|
+
}
|
|
333
360
|
}
|
|
334
361
|
}
|
|
335
362
|
}
|
package/built/sim-strings.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{}
|
|
1
|
+
{"Type your response using your keyboard and hit ENTER":"Type your response using your keyboard and hit ENTER"}
|
package/built/sim.js
CHANGED
|
@@ -270,6 +270,7 @@ var pxsim;
|
|
|
270
270
|
*/
|
|
271
271
|
pxsim.initCurrentRuntime = (msg) => {
|
|
272
272
|
pxsim.runtime.board = new Board();
|
|
273
|
+
pxsim.Keyboard.cancelTextPrompt();
|
|
273
274
|
pxsim.initGamepad();
|
|
274
275
|
const theme = pxsim.theme.parseTheme(msg.theme);
|
|
275
276
|
if (theme && !themeFromQueryParameter) {
|
|
@@ -653,6 +654,8 @@ var pxsim;
|
|
|
653
654
|
}
|
|
654
655
|
kill() {
|
|
655
656
|
super.kill();
|
|
657
|
+
if (this.gameplayer)
|
|
658
|
+
this.gameplayer.dispose();
|
|
656
659
|
pxsim.Keyboard.cancelTextPrompt();
|
|
657
660
|
}
|
|
658
661
|
}
|
|
@@ -775,6 +778,14 @@ var pxsim;
|
|
|
775
778
|
if (input)
|
|
776
779
|
input.remove();
|
|
777
780
|
pxsim.board().disableKeyEvents = true;
|
|
781
|
+
// clear all active button presses
|
|
782
|
+
pxsim.board().setButton(pxsim.Key.A, false);
|
|
783
|
+
pxsim.board().setButton(pxsim.Key.B, false);
|
|
784
|
+
pxsim.board().setButton(pxsim.Key.Up, false);
|
|
785
|
+
pxsim.board().setButton(pxsim.Key.Right, false);
|
|
786
|
+
pxsim.board().setButton(pxsim.Key.Down, false);
|
|
787
|
+
pxsim.board().setButton(pxsim.Key.Left, false);
|
|
788
|
+
pxsim.board().setButton(pxsim.Key.Menu, false);
|
|
778
789
|
input = document.createElement("input");
|
|
779
790
|
input.type = "text";
|
|
780
791
|
input.maxLength = maxLength;
|
|
@@ -787,8 +798,8 @@ var pxsim;
|
|
|
787
798
|
});
|
|
788
799
|
input.addEventListener("keyup", e => {
|
|
789
800
|
if (e.key === "Enter" || e.key === "Escape") {
|
|
790
|
-
pxsim.board().bus.queue(KeyboardEvent.Enter, 0);
|
|
791
801
|
cancelTextPrompt();
|
|
802
|
+
pxsim.board().bus.queue(KeyboardEvent.Enter, 0);
|
|
792
803
|
}
|
|
793
804
|
else if (numberOnly) {
|
|
794
805
|
validateNumberInput();
|
|
@@ -828,6 +839,10 @@ var pxsim;
|
|
|
828
839
|
return "";
|
|
829
840
|
}
|
|
830
841
|
Keyboard.getTextPromptString = getTextPromptString;
|
|
842
|
+
function getLocalizedInstructions() {
|
|
843
|
+
return pxsim.localization.lf("Type your response using your keyboard and hit ENTER");
|
|
844
|
+
}
|
|
845
|
+
Keyboard.getLocalizedInstructions = getLocalizedInstructions;
|
|
831
846
|
function focusTextInput() {
|
|
832
847
|
if (input)
|
|
833
848
|
input.focus();
|
|
@@ -1111,11 +1126,7 @@ var pxsim;
|
|
|
1111
1126
|
this.parent = undefined;
|
|
1112
1127
|
this.dragSurface = undefined;
|
|
1113
1128
|
this.cleanupInterval();
|
|
1114
|
-
this.
|
|
1115
|
-
const [el, ev, cb] = b;
|
|
1116
|
-
el.removeEventListener(ev, cb);
|
|
1117
|
-
});
|
|
1118
|
-
this.bindings = [];
|
|
1129
|
+
this.unBindEvents();
|
|
1119
1130
|
}
|
|
1120
1131
|
pointIsWithinCircle(x, y, circle) {
|
|
1121
1132
|
const bounds = circle.getBoundingClientRect();
|
|
@@ -1155,6 +1166,7 @@ var pxsim;
|
|
|
1155
1166
|
bindEvents(surface) {
|
|
1156
1167
|
if (!surface)
|
|
1157
1168
|
return;
|
|
1169
|
+
this.unBindEvents();
|
|
1158
1170
|
if (visuals.hasPointerEvents()) {
|
|
1159
1171
|
this.bindPointerEvents(surface);
|
|
1160
1172
|
}
|
|
@@ -1175,9 +1187,9 @@ var pxsim;
|
|
|
1175
1187
|
inGesture = false;
|
|
1176
1188
|
});
|
|
1177
1189
|
this.bindEvent(surface, "pointerdown", (ev) => {
|
|
1190
|
+
pxsim.Keyboard.cancelSystemKeyboard();
|
|
1178
1191
|
this.updateButtonGesture(ev.clientX, ev.clientY);
|
|
1179
1192
|
inGesture = true;
|
|
1180
|
-
pxsim.Keyboard.cancelSystemKeyboard();
|
|
1181
1193
|
});
|
|
1182
1194
|
this.bindEvent(surface, "pointermove", (ev) => {
|
|
1183
1195
|
if (inGesture)
|
|
@@ -1256,6 +1268,13 @@ var pxsim;
|
|
|
1256
1268
|
]);
|
|
1257
1269
|
element.addEventListener(event, callback);
|
|
1258
1270
|
}
|
|
1271
|
+
unBindEvents() {
|
|
1272
|
+
this.bindings.forEach(b => {
|
|
1273
|
+
const [el, ev, cb] = b;
|
|
1274
|
+
el.removeEventListener(ev, cb);
|
|
1275
|
+
});
|
|
1276
|
+
this.bindings = [];
|
|
1277
|
+
}
|
|
1259
1278
|
}
|
|
1260
1279
|
visuals.GameButtons = GameButtons;
|
|
1261
1280
|
})(visuals = pxsim.visuals || (pxsim.visuals = {}));
|
|
@@ -1278,10 +1297,10 @@ var pxsim;
|
|
|
1278
1297
|
// TODO: localize; currently can't use lf in this repo
|
|
1279
1298
|
this.menu.setAttribute("aria-label", "Menu");
|
|
1280
1299
|
this.menu.onclick = () => {
|
|
1300
|
+
pxsim.Keyboard.cancelSystemKeyboard();
|
|
1281
1301
|
visuals.pressButton(pxsim.Key.Menu);
|
|
1282
1302
|
visuals.releaseButton(pxsim.Key.Menu);
|
|
1283
1303
|
pxsim.indicateFocus(true);
|
|
1284
|
-
pxsim.Keyboard.cancelSystemKeyboard();
|
|
1285
1304
|
};
|
|
1286
1305
|
}
|
|
1287
1306
|
if (this.reset) {
|
|
@@ -1474,9 +1493,9 @@ var pxsim;
|
|
|
1474
1493
|
inGesture = false;
|
|
1475
1494
|
});
|
|
1476
1495
|
this.bindEvent(surface, "pointerdown", (ev) => {
|
|
1496
|
+
pxsim.Keyboard.cancelSystemKeyboard();
|
|
1477
1497
|
this.updateJoystickDrag(ev.clientX, ev.clientY);
|
|
1478
1498
|
inGesture = true;
|
|
1479
|
-
pxsim.Keyboard.cancelSystemKeyboard();
|
|
1480
1499
|
});
|
|
1481
1500
|
this.bindEvent(surface, "pointermove", (ev) => {
|
|
1482
1501
|
if (inGesture)
|