Skip to content

Commit 0a69ed9

Browse files
authored
Merge branch 'TurboWarp:master' into master
2 parents d8a323b + cb1df04 commit 0a69ed9

File tree

5 files changed

+350
-21
lines changed

5 files changed

+350
-21
lines changed

extensions/SharkPool/Camera.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// By: SharkPool
55
// License: MIT
66

7-
// Version V.1.0.09
7+
// Version V.1.0.1
88

99
(function (Scratch) {
1010
"use strict";
@@ -274,6 +274,23 @@
274274
}
275275
};
276276

277+
const ogUpdateVisible = render.exports.Drawable.prototype.updateVisible;
278+
render.exports.Drawable.prototype.updateVisible = function (isVisible) {
279+
if (!this[cameraSymbol]) setupState(this);
280+
if (isVisible) {
281+
// save some renderer calls, packing this all into one
282+
// while running only when isVisible is true combines this
283+
// into a single renderer call
284+
this[cameraSymbol].needsRefresh = true;
285+
this.updateProperties({
286+
position: this._position,
287+
direction: this._direction,
288+
scale: this.scale,
289+
});
290+
}
291+
ogUpdateVisible.call(this, isVisible);
292+
};
293+
277294
// Clones should inherit the parents camera
278295
const ogInitDrawable = vm.exports.RenderedTarget.prototype.initDrawable;
279296
vm.exports.RenderedTarget.prototype.initDrawable = function (layerGroup) {

extensions/cursor.js

Lines changed: 279 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@
154154
{ size }
155155
);
156156

157-
const cursors = [
157+
const ALL_ALLOWED_CURSORS = [
158+
// This list includes "none" while the dropdown's list does not
159+
"none",
160+
158161
"default",
159162
"pointer",
160163
"move",
@@ -249,7 +252,280 @@
249252
menus: {
250253
cursors: {
251254
acceptReporters: true,
252-
items: cursors,
255+
items: [
256+
{
257+
text: Scratch.translate({
258+
default: "default",
259+
description:
260+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
261+
}),
262+
value: "default",
263+
},
264+
{
265+
text: Scratch.translate({
266+
default: "pointer",
267+
description:
268+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
269+
}),
270+
value: "pointer",
271+
},
272+
{
273+
text: Scratch.translate({
274+
default: "move",
275+
description:
276+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
277+
}),
278+
value: "move",
279+
},
280+
{
281+
text: Scratch.translate({
282+
default: "grab",
283+
description:
284+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
285+
}),
286+
value: "grab",
287+
},
288+
{
289+
text: Scratch.translate({
290+
default: "grabbing",
291+
description:
292+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
293+
}),
294+
value: "grabbing",
295+
},
296+
{
297+
text: Scratch.translate({
298+
default: "text",
299+
description:
300+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
301+
}),
302+
value: "text",
303+
},
304+
{
305+
text: Scratch.translate({
306+
default: "vertical-text",
307+
description:
308+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
309+
}),
310+
value: "vertical-text",
311+
},
312+
{
313+
text: Scratch.translate({
314+
default: "wait",
315+
description:
316+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
317+
}),
318+
value: "wait",
319+
},
320+
{
321+
text: Scratch.translate({
322+
default: "progress",
323+
description:
324+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
325+
}),
326+
value: "progress",
327+
},
328+
{
329+
text: Scratch.translate({
330+
default: "help",
331+
description:
332+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
333+
}),
334+
value: "help",
335+
},
336+
{
337+
text: Scratch.translate({
338+
default: "context-menu",
339+
description:
340+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
341+
}),
342+
value: "context-menu",
343+
},
344+
{
345+
text: Scratch.translate({
346+
default: "zoom-in",
347+
description:
348+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
349+
}),
350+
value: "zoom-in",
351+
},
352+
{
353+
text: Scratch.translate({
354+
default: "zoom-out",
355+
description:
356+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
357+
}),
358+
value: "zoom-out",
359+
},
360+
{
361+
text: Scratch.translate({
362+
default: "crosshair",
363+
description:
364+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
365+
}),
366+
value: "crosshair",
367+
},
368+
{
369+
text: Scratch.translate({
370+
default: "cell",
371+
description:
372+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
373+
}),
374+
value: "cell",
375+
},
376+
{
377+
text: Scratch.translate({
378+
default: "not allowed",
379+
description:
380+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
381+
}),
382+
value: "not-allowed",
383+
},
384+
{
385+
text: Scratch.translate({
386+
default: "copy",
387+
description:
388+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
389+
}),
390+
value: "copy",
391+
},
392+
{
393+
text: Scratch.translate({
394+
default: "alias",
395+
description:
396+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
397+
}),
398+
value: "alias",
399+
},
400+
{
401+
text: Scratch.translate({
402+
default: "no drop",
403+
description:
404+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
405+
}),
406+
value: "no-drop",
407+
},
408+
{
409+
text: Scratch.translate({
410+
default: "all-scroll",
411+
description:
412+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
413+
}),
414+
value: "all-scroll",
415+
},
416+
{
417+
text: Scratch.translate({
418+
default: "col-resize",
419+
description:
420+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
421+
}),
422+
value: "col-resize",
423+
},
424+
{
425+
text: Scratch.translate({
426+
default: "row-resize",
427+
description:
428+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
429+
}),
430+
value: "row-resize",
431+
},
432+
{
433+
text: Scratch.translate({
434+
default: "n-resize",
435+
description:
436+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
437+
}),
438+
value: "n-resize",
439+
},
440+
{
441+
text: Scratch.translate({
442+
default: "e-resize",
443+
description:
444+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
445+
}),
446+
value: "e-resize",
447+
},
448+
{
449+
text: Scratch.translate({
450+
default: "s-resize",
451+
description:
452+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
453+
}),
454+
value: "s-resize",
455+
},
456+
{
457+
text: Scratch.translate({
458+
default: "w-resize",
459+
description:
460+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
461+
}),
462+
value: "w-resize",
463+
},
464+
{
465+
text: Scratch.translate({
466+
default: "ne-resize",
467+
description:
468+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
469+
}),
470+
value: "ne-resize",
471+
},
472+
{
473+
text: Scratch.translate({
474+
default: "nw-resize",
475+
description:
476+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
477+
}),
478+
value: "nw-resize",
479+
},
480+
{
481+
text: Scratch.translate({
482+
default: "se-resize",
483+
description:
484+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
485+
}),
486+
value: "se-resize",
487+
},
488+
{
489+
text: Scratch.translate({
490+
default: "sw-resize",
491+
description:
492+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
493+
}),
494+
value: "sw-resize",
495+
},
496+
{
497+
text: Scratch.translate({
498+
default: "ew-resize",
499+
description:
500+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
501+
}),
502+
value: "ew-resize",
503+
},
504+
{
505+
text: Scratch.translate({
506+
default: "ns-resize",
507+
description:
508+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
509+
}),
510+
value: "ns-resize",
511+
},
512+
{
513+
text: Scratch.translate({
514+
default: "nesw-resize",
515+
description:
516+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
517+
}),
518+
value: "nesw-resize",
519+
},
520+
{
521+
text: Scratch.translate({
522+
default: "nwse-resize",
523+
description:
524+
"Part of cursor dropdown. See https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/cursor#keyword",
525+
}),
526+
value: "nwse-resize",
527+
},
528+
],
253529
},
254530
imagePositions: {
255531
acceptReporters: true,
@@ -285,7 +561,7 @@
285561
setCur(args) {
286562
const newCursor = Scratch.Cast.toString(args.cur);
287563
// Prevent setting cursor to "url(...), default" from causing fetch.
288-
if (cursors.includes(newCursor) || newCursor === "none") {
564+
if (ALL_ALLOWED_CURSORS.includes(newCursor)) {
289565
nativeCursor = newCursor;
290566
customCursorImageName = null;
291567
currentCanvasCursor = newCursor;

extensions/local-storage.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@
2020
Scratch.vm.runtime.extensionStorage["localstorage"] = {
2121
namespace: newNamespace,
2222
};
23-
Scratch.vm.extensionManager.refreshBlocks("localstorage");
2423
readFromStorage();
24+
25+
// We can generate namespace before we have fully loaded
26+
if (Scratch.vm.extensionManager.isExtensionLoaded("localstorage")) {
27+
Scratch.vm.extensionManager.refreshBlocks("localstorage");
28+
}
2529
};
2630

2731
const STORAGE_PREFIX = "extensions.turbowarp.org/local-storage:";
@@ -103,21 +107,24 @@
103107
return id;
104108
};
105109

106-
const generateRandomNamespaceIfMissing = () => {
107-
if (!getNamespace()) {
110+
const prepareInitialNamespace = () => {
111+
if (getNamespace()) {
112+
readFromStorage();
113+
} else {
108114
setNamespace(generateRandomNamespace());
109115
}
110116
};
111117

112118
Scratch.vm.runtime.on("PROJECT_LOADED", () => {
113-
generateRandomNamespaceIfMissing();
119+
prepareInitialNamespace();
114120
});
115121

116122
Scratch.vm.runtime.on("RUNTIME_DISPOSED", () => {
117-
generateRandomNamespace();
123+
// Will always be followed by a PROJECT_LOADED event later
124+
namespaceValues = Object.create(null);
118125
});
119126

120-
generateRandomNamespaceIfMissing();
127+
prepareInitialNamespace();
121128

122129
let lastNamespaceWarning = 0;
123130
const validNamespace = () => {

0 commit comments

Comments
 (0)