Вход Регистрация
Файл: Space race/libs/Editor_files/Node.js
Строк: 76
<?php
var pgli pgli || {};
pgli.diagram pgli.diagram || {};

pgli.diagram.Node gamecore.Base.extend('Node',
// static
    
layersWidth20,
    
layersMargin20,
    
layersHeight16,
    
headerHeight40,
    
slotX10,
    
slotY14,
    
slotRadius6
},
// instance
    
modulenull,

    
keynull,

    
shapenull,
    
backgroundnull,
    
namenull,
    
layersnull,
    
slotnull,
    
    
sockets: [],
    
    
width150,
    
height200,

    
init: function(keymodulexy)
    {
        var static = 
pgli.diagram.Node;

        
this.key key;
        
this.module module;

        
this.shape = new Kinetic.Group({
            
x== undefined x,
            
y== undefined y,
            
draggabletrue
        
});

        var 
layerCount = (module.layers != undefined module.layers.length 0) + 1;

        
this.height = static.headerHeight layerCount * static.layersHeight;

        
this.background = new Kinetic.Rect({
            
x0,
            
y0,
            
widththis.width,
            
heightthis.height,
            
fill"#222",
            
stroke"#000",
            
strokeWidth0.5,
            
shadow: {
                
color"black",
                
blur6,
                
offset: [00],
                
opacity0.5
            
}
        });

        
this.layers = new Kinetic.Shape({
            
drawFunc: function(ctx){
                
ctx.beginPath();
                for(var 
i=0len this.attrs.countlen; ++i)
                    
ctx.arc(1010+i*static.layersHeight, static.slotRadius0Math.PI*2true); 
                
ctx.closePath();
                
this.fill(ctx);
            },
            
xthis.width-static.layersWidth,
            
y: static.layersMargin,
            
countlayerCount,
            
fill"#111"
        
});

        
this.slot = new Kinetic.Circle({
            
x: static.slotX,
            
y: static.slotY,
            
radius: static.slotRadius,
            
fill"#111"
        
});

        
this.name = new Kinetic.Text({
            
x20,
            
y6,
            
textmodule.name,
            
fontSize13,
            
fontFamily"Ubuntu Mono",
            
textFill"#aaa"
        
});

        
this.shape.on('mousedown', function(){
            
this.moveToTop();
        });

        
this.shape.add(this.background);
        
this.shape.add(this.name);
        
this.shape.add(this.layers);
        
this.shape.add(this.slot);
    },

    
updateLayers: function()
    {
        var 
layerCount = (module.layers != undefined module.layers.length 0) + 1;
        
this.layers.attrs.count layerCount;
    },

    
getSlot: function()
    {
        var static = 
pgli.diagram.Node;
        return [
this.shape.getX()+static.slotX
                
this.shape.getY()+static.slotY];
    },

    
getLayerSlot: function(index)
    {
        var static = 
pgli.diagram.Node;
        return [
this.shape.getX()+this.width-static.layersWidth/2
                
this.shape.getY()+10+index*static.layersHeight+static.layersMargin];
    }
});
?>
Онлайн: 4
Реклама