kopia lustrzana https://github.com/backface/turtlestitch
update programmatic custom block-type changes in data references
rodzic
225e837aaa
commit
492188f553
|
@ -49,6 +49,9 @@
|
||||||
* **Translation Updates:**
|
* **Translation Updates:**
|
||||||
* German
|
* German
|
||||||
|
|
||||||
|
### 2022-05-25
|
||||||
|
* threads: update programmatic custom block-type changes in data references
|
||||||
|
|
||||||
### 2022-05-23
|
### 2022-05-23
|
||||||
* blocks: fixed block label color when expanding or inserting variadic infix slots
|
* blocks: fixed block label color when expanding or inserting variadic infix slots
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<script src="src/symbols.js?version=2021-03-03"></script>
|
<script src="src/symbols.js?version=2021-03-03"></script>
|
||||||
<script src="src/widgets.js?version=2021-17-09"></script>
|
<script src="src/widgets.js?version=2021-17-09"></script>
|
||||||
<script src="src/blocks.js?version=2022-05-23"></script>
|
<script src="src/blocks.js?version=2022-05-23"></script>
|
||||||
<script src="src/threads.js?version=2022-05-20"></script>
|
<script src="src/threads.js?version=2022-05-25"></script>
|
||||||
<script src="src/objects.js?version=2022-05-20"></script>
|
<script src="src/objects.js?version=2022-05-20"></script>
|
||||||
<script src="src/scenes.js?version=2022-03-03"></script>
|
<script src="src/scenes.js?version=2022-03-03"></script>
|
||||||
<script src="src/gui.js?version=2022-05-19"></script>
|
<script src="src/gui.js?version=2022-05-19"></script>
|
||||||
|
|
|
@ -65,7 +65,7 @@ StagePickerMorph, CustomBlockDefinition*/
|
||||||
|
|
||||||
/*jshint esversion: 11, bitwise: false, evil: true*/
|
/*jshint esversion: 11, bitwise: false, evil: true*/
|
||||||
|
|
||||||
modules.threads = '2022-May-20';
|
modules.threads = '2022-May-25';
|
||||||
|
|
||||||
var ThreadManager;
|
var ThreadManager;
|
||||||
var Process;
|
var Process;
|
||||||
|
@ -5640,6 +5640,7 @@ Process.prototype.doSetBlockAttribute = function (attribute, block, val) {
|
||||||
expr,
|
expr,
|
||||||
def,
|
def,
|
||||||
template,
|
template,
|
||||||
|
oldType,
|
||||||
type;
|
type;
|
||||||
|
|
||||||
this.assertType(block, types);
|
this.assertType(block, types);
|
||||||
|
@ -5666,6 +5667,12 @@ Process.prototype.doSetBlockAttribute = function (attribute, block, val) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isMajorTypeChange() {
|
||||||
|
var rep = ['reporter', 'predicate'];
|
||||||
|
return (type === 'command' && rep.includes(oldType)) ||
|
||||||
|
(oldType == 'command' && rep.includes(type));
|
||||||
|
}
|
||||||
|
|
||||||
switch (choice) {
|
switch (choice) {
|
||||||
case 'label':
|
case 'label':
|
||||||
def.setBlockLabel(val);
|
def.setBlockLabel(val);
|
||||||
|
@ -5698,10 +5705,27 @@ Process.prototype.doSetBlockAttribute = function (attribute, block, val) {
|
||||||
if (rcvr.allBlockInstances(def).every(block =>
|
if (rcvr.allBlockInstances(def).every(block =>
|
||||||
block.isChangeableTo(type))
|
block.isChangeableTo(type))
|
||||||
) {
|
) {
|
||||||
|
oldType = def.type;
|
||||||
def.type = type;
|
def.type = type;
|
||||||
} else {
|
} else {
|
||||||
throw new Error('cannot change this\nfor a block that is in use');
|
throw new Error('cannot change this\nfor a block that is in use');
|
||||||
}
|
}
|
||||||
|
if (isMajorTypeChange()) {
|
||||||
|
// since we've already scanned all contexts we know that those
|
||||||
|
// that contain block instances only contain single, unattached
|
||||||
|
// ones. Therefore we can simply replace them with new ones.
|
||||||
|
if (def.isGlobal) {
|
||||||
|
ide.stage.allContextsUsing(def).forEach(context =>
|
||||||
|
context.expression = def.blockInstance()
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
ide.stage.allContextsInvoking(def.blockSpec(), rcvr).forEach(
|
||||||
|
context => context.expression = def.blockInstance()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'scope':
|
case 'scope':
|
||||||
if (isInUse()) {
|
if (isInUse()) {
|
||||||
|
|
Ładowanie…
Reference in New Issue