kopia lustrzana https://github.com/backface/turtlestitch
				
				
				
			added inheritance support for the wardrobe
also exposed “costumes” as an attributeupd4.1
							rodzic
							
								
									c14e15f7b1
								
							
						
					
					
						commit
						1a872934de
					
				| 
						 | 
				
			
			@ -150,7 +150,7 @@ CustomCommandBlockMorph*/
 | 
			
		|||
 | 
			
		||||
// Global stuff ////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
modules.blocks = '2017-May-09';
 | 
			
		||||
modules.blocks = '2017-May-12';
 | 
			
		||||
 | 
			
		||||
var SyntaxElementMorph;
 | 
			
		||||
var BlockMorph;
 | 
			
		||||
| 
						 | 
				
			
			@ -8133,6 +8133,7 @@ InputSlotMorph.prototype.gettablesMenu = function () {
 | 
			
		|||
        dict.parent = ['parent'];
 | 
			
		||||
    }
 | 
			
		||||
    dict.name = ['name'];
 | 
			
		||||
    dict.costumes = ['costumes'];
 | 
			
		||||
    dict['dangling?'] = ['dangling?'];
 | 
			
		||||
    dict['rotation x'] = ['rotation x'];
 | 
			
		||||
    dict['rotation y'] = ['rotation y'];
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										19
									
								
								gui.js
								
								
								
								
							
							
						
						
									
										19
									
								
								gui.js
								
								
								
								
							| 
						 | 
				
			
			@ -74,7 +74,7 @@ isRetinaSupported, SliderMorph, Animation*/
 | 
			
		|||
 | 
			
		||||
// Global stuff ////////////////////////////////////////////////////////
 | 
			
		||||
 | 
			
		||||
modules.gui = '2017-April-10';
 | 
			
		||||
modules.gui = '2017-May-12';
 | 
			
		||||
 | 
			
		||||
// Declarations
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -7111,6 +7111,7 @@ CostumeIconMorph.prototype.userMenu = function () {
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
CostumeIconMorph.prototype.editCostume = function () {
 | 
			
		||||
    this.disinherit();
 | 
			
		||||
    if (this.object instanceof SVG_Costume) {
 | 
			
		||||
        this.object.editRotationPointOnly(this.world());
 | 
			
		||||
    } else {
 | 
			
		||||
| 
						 | 
				
			
			@ -7129,6 +7130,7 @@ CostumeIconMorph.prototype.editRotationPointOnly = function () {
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
CostumeIconMorph.prototype.renameCostume = function () {
 | 
			
		||||
    this.disinherit();
 | 
			
		||||
    var costume = this.object,
 | 
			
		||||
        wardrobe = this.parentThatIsA(WardrobeMorph),
 | 
			
		||||
        ide = this.parentThatIsA(IDE_Morph);
 | 
			
		||||
| 
						 | 
				
			
			@ -7189,9 +7191,21 @@ CostumeIconMorph.prototype.exportCostume = function () {
 | 
			
		|||
CostumeIconMorph.prototype.createBackgrounds
 | 
			
		||||
    = SpriteIconMorph.prototype.createBackgrounds;
 | 
			
		||||
 | 
			
		||||
// CostumeIconMorph inheritance
 | 
			
		||||
 | 
			
		||||
CostumeIconMorph.prototype.disinherit = function () {
 | 
			
		||||
    var wardrobe = this.parentThatIsA(WardrobeMorph),
 | 
			
		||||
        idx = this.parent.children.indexOf(this);
 | 
			
		||||
    if (wardrobe.sprite.inheritsAttribute('costumes')) {
 | 
			
		||||
        wardrobe.sprite.shadowAttribute('costumes');
 | 
			
		||||
        this.object = wardrobe.sprite.costumes.at(idx - 2);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
// CostumeIconMorph drag & drop
 | 
			
		||||
 | 
			
		||||
CostumeIconMorph.prototype.prepareToBeGrabbed = function () {
 | 
			
		||||
    this.disinherit();
 | 
			
		||||
    this.mouseClickLeft(); // select me
 | 
			
		||||
    this.removeCostume();
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -7521,6 +7535,7 @@ WardrobeMorph.prototype.step = function () {
 | 
			
		|||
// Wardrobe ops
 | 
			
		||||
 | 
			
		||||
WardrobeMorph.prototype.removeCostumeAt = function (idx) {
 | 
			
		||||
    this.sprite.shadowAttribute('costumes');
 | 
			
		||||
    this.sprite.costumes.remove(idx);
 | 
			
		||||
    this.updateList();
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -7533,6 +7548,7 @@ WardrobeMorph.prototype.paintNew = function () {
 | 
			
		|||
        ide = this.parentThatIsA(IDE_Morph),
 | 
			
		||||
        myself = this;
 | 
			
		||||
    cos.edit(this.world(), ide, true, null, function () {
 | 
			
		||||
        myself.sprite.shadowAttribute('costumes');
 | 
			
		||||
        myself.sprite.addCostume(cos);
 | 
			
		||||
        myself.updateList();
 | 
			
		||||
        if (ide) {
 | 
			
		||||
| 
						 | 
				
			
			@ -7558,6 +7574,7 @@ WardrobeMorph.prototype.reactToDropOf = function (icon) {
 | 
			
		|||
            idx += 1;
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
    this.sprite.shadowAttribute('costumes');
 | 
			
		||||
    this.sprite.costumes.add(costume, idx + 1);
 | 
			
		||||
    this.updateList();
 | 
			
		||||
    icon.mouseClickLeft(); // select
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3422,6 +3422,11 @@ Fixes:
 | 
			
		|||
* added tools to the library browser
 | 
			
		||||
* added attributes to the “delete” block’s drop-down menu
 | 
			
		||||
 | 
			
		||||
170512
 | 
			
		||||
------
 | 
			
		||||
* added inheritance support for the wardrobe
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Features:
 | 
			
		||||
* polymorphic sprite-local custom blocks
 | 
			
		||||
* inheritance of sprite-local custom blocks
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										33
									
								
								objects.js
								
								
								
								
							
							
						
						
									
										33
									
								
								objects.js
								
								
								
								
							| 
						 | 
				
			
			@ -82,7 +82,7 @@ SpeechBubbleMorph, RingMorph, isNil, FileReader, TableDialogMorph,
 | 
			
		|||
BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, localize,
 | 
			
		||||
TableMorph, TableFrameMorph, normalizeCanvas, BooleanSlotMorph, HandleMorph*/
 | 
			
		||||
 | 
			
		||||
modules.objects = '2017-May-09';
 | 
			
		||||
modules.objects = '2017-May-12';
 | 
			
		||||
 | 
			
		||||
var SpriteMorph;
 | 
			
		||||
var StageMorph;
 | 
			
		||||
| 
						 | 
				
			
			@ -119,7 +119,8 @@ SpriteMorph.prototype.attributes =
 | 
			
		|||
        'x position',
 | 
			
		||||
        'y position',
 | 
			
		||||
        'direction',
 | 
			
		||||
        'size'
 | 
			
		||||
        'size',
 | 
			
		||||
        'costumes'
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
SpriteMorph.prototype.categories =
 | 
			
		||||
| 
						 | 
				
			
			@ -2901,6 +2902,7 @@ SpriteMorph.prototype.addCostume = function (costume) {
 | 
			
		|||
    if (!costume.name) {
 | 
			
		||||
        costume.name = 'costume' + (this.costumes.length() + 1);
 | 
			
		||||
    }
 | 
			
		||||
    this.shadowAttribute('costumes');
 | 
			
		||||
    this.costumes.add(costume);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -5149,7 +5151,8 @@ SpriteMorph.prototype.shadowedAttributes = function () {
 | 
			
		|||
};
 | 
			
		||||
 | 
			
		||||
SpriteMorph.prototype.shadowAttribute = function (aName) {
 | 
			
		||||
    var ide;
 | 
			
		||||
    var ide, wardrobe,
 | 
			
		||||
        myself = this;
 | 
			
		||||
    if (!this.inheritsAttribute(aName)) {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -5157,7 +5160,17 @@ SpriteMorph.prototype.shadowAttribute = function (aName) {
 | 
			
		|||
    this.inheritedAttributes = this.inheritedAttributes.filter(
 | 
			
		||||
        function (each) {return each !== aName; }
 | 
			
		||||
    );
 | 
			
		||||
    if (ide) {
 | 
			
		||||
    if (aName === 'costumes') {
 | 
			
		||||
        wardrobe = new List();
 | 
			
		||||
        this.costumes.asArray().forEach(function (costume) {
 | 
			
		||||
            var cst = costume.copy();
 | 
			
		||||
            wardrobe.add(cst);
 | 
			
		||||
            if (costume === myself.costume) {
 | 
			
		||||
                myself.wearCostume(cst);
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
        this.costumes = wardrobe;
 | 
			
		||||
    } else if (ide) {
 | 
			
		||||
        ide.flushBlocksCache(); // optimization: specify category if known
 | 
			
		||||
        ide.refreshPalette();
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			@ -5170,10 +5183,14 @@ SpriteMorph.prototype.inheritAttribute = function (aName) {
 | 
			
		|||
    }
 | 
			
		||||
    if (!this.inheritsAttribute(aName)) {
 | 
			
		||||
        this.inheritedAttributes.push(aName);
 | 
			
		||||
        this.refreshInheritedAttribute(aName);
 | 
			
		||||
        if (ide) {
 | 
			
		||||
            ide.flushBlocksCache(); // optimization: specify category if known
 | 
			
		||||
            ide.refreshPalette();
 | 
			
		||||
        if (aName === 'costumes') {
 | 
			
		||||
            this.costumes = this.exemplar.costumes;
 | 
			
		||||
        } else {
 | 
			
		||||
            this.refreshInheritedAttribute(aName);
 | 
			
		||||
            if (ide) {
 | 
			
		||||
                ide.flushBlocksCache(); // optimization: specify category
 | 
			
		||||
                ide.refreshPalette();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -61,7 +61,7 @@ StageMorph, SpriteMorph, StagePrompterMorph, Note, modules, isString, copy,
 | 
			
		|||
isNil, WatcherMorph, List, ListWatcherMorph, alert, console, TableMorph,
 | 
			
		||||
TableFrameMorph, ColorSlotMorph, isSnapObject*/
 | 
			
		||||
 | 
			
		||||
modules.threads = '2017-May-09';
 | 
			
		||||
modules.threads = '2017-May-12';
 | 
			
		||||
 | 
			
		||||
var ThreadManager;
 | 
			
		||||
var Process;
 | 
			
		||||
| 
						 | 
				
			
			@ -3010,6 +3010,8 @@ Process.prototype.reportGet = function (query) {
 | 
			
		|||
            return thisObj.name;
 | 
			
		||||
        case 'stage':
 | 
			
		||||
            return thisObj.parentThatIsA(StageMorph);
 | 
			
		||||
        case 'costumes':
 | 
			
		||||
            return thisObj.reportCostumes();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    return '';
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Ładowanie…
	
		Reference in New Issue