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


pgli.Project gamecore.Base.extend('Project',
{
    
patternRoot//([a-z]+.pmod)/ig,
    
patternPath: /([a-z/]+/)[a-z]+.pmod/ig

},

{
    
appInstancenull,
    
modulesnull,
    
activeFilenull,
    
files:null,
    
keys :[],
    
name"default",
    
path"/files/",
    
root"default.pmod",
    
diagramnull,
    
loadingQueue: [],
    
onLoad: function() { console.log("Project loaded."); },

    

    
init : function(projectFileonLoad)
    {
        
this.onLoad onLoad;        
        
this.modules = new gamecore.Hashtable();
        
this.files = new gamecore.Hashtable();
        
this.path pgli.Project.patternPath.exec(projectFile)[1];
        
this.root pgli.Project.patternRoot.exec(projectFile)[1];

        var 
self this;

        
this.loadFile(projectFile,this.root,true,true);
            
    },

    
loadFile: function(path,name,doDependencies,doDiagram)
    {
        
trace("#Loading ["+name+"].");
        var 
self this;
        var 
request = $.ajax({
                
urlpath,
                
type'get',
                
dataType"text",
            })
            .
success(function(data)
            {
                
self.files.put(namedata);
                
self.keys.push(name);

                var 
object pgli.lang.Parser.parseModule(data);
                
self.modules.put(nameobject);

                if(
doDependencies == true)
                    
self.loadDependencies(object);

                if(
doDiagram == true)
                    
self.getAppInstance().addDiagramNode(nameobject);

                
trace("#["+name+"] loaded");
          
                
self.onLoad();
            })
            .
error(function()
            {
                throw 
"Unable to load file: " path;
            });
    },

    
loadDependencies: function(object)
    {

        if(!(
"layers" in object))
            return;

        var 
layers object.layers;
        var 
self this;

        for (var 
i=0len layers.lengthi<len i++)
        {
            if(!(
"use" in layers[i]) )
                continue;

            var 
layerName layers[i].use;

            
trace("#Found dependency ["+layerName+"]");

            (function(
name,self)
            {
                
self.loadFile(self.path+name,name,true,true);

            })(
layerName,self);
        }

    },

    
getModulesCount: function()
    {
        return 
this.keys.length;
    },

    
getModule: function(key)
    {
        return 
this.modules.get(key);
    },

    
getFile: function(key)
    {
        return 
this.files.get(key);
    },

    
getModuleKey: function(index)
    {
        return 
this.keys[index];
    },

    
getRootModule: function()
    {
        return 
this.modules.get(this.root);
    },

    
isEmpty: function()
    {
        return (
this.keys.length <= 0);
    },

    
setAppInstance: function(app)
    {
        
this.appInstance app;
    },

    
getAppInstance: function()
    {
        return 
this.appInstance;
    },

    
setActiveFile: function(key)
    {
        
this.activeFile key;
    },

    
rememberActiveFile: function()
    {
        if(!
this.activeFile) return;

        
this.files.put(this.activeFilethis.getAppInstance().getEditorContent());
    } 

    
/*updateDiagram: function()
    {

    },

    render: function(canvasRenderer)
    {
        //canvasRenderer.Render(modules, root, new Hashtable());
    }*/

});
?>
Онлайн: 2
Реклама