home *** CD-ROM | disk | FTP | other *** search
- class com.neodelight.std.Blueprint
- {
- static var lib = new Array();
- static var cfgLoader = new LoadVars();
- function Blueprint()
- {
- }
- static function addBlueprint(id, o)
- {
- com.neodelight.std.Blueprint.lib[id] = o;
- }
- static function readConfigFile(path)
- {
- com.neodelight.std.Blueprint.cfgLoader.onData = function(src)
- {
- var _loc4_ = src.split("\n");
- var _loc3_ = 0;
- while(_loc3_ < _loc4_.length)
- {
- var _loc2_ = _loc4_[_loc3_];
- if(_loc2_.charAt(0) != "#")
- {
- if(com.neodelight.std.XString.trim(_loc2_) != "")
- {
- if(_loc2_.indexOf("=") != -1)
- {
- var _loc1_ = _loc2_.split("=");
- _loc1_[0] = com.neodelight.std.XString.trim(_loc1_[0]);
- _loc1_[1] = com.neodelight.std.XString.trim(_loc1_[1]);
- com.neodelight.std.Blueprint.addBlueprint(_loc1_[0],_loc1_[1]);
- }
- }
- }
- _loc3_ = _loc3_ + 1;
- }
- com.neodelight.std.Blueprint.onReadConfigFile(src != undefined);
- };
- com.neodelight.std.Blueprint.cfgLoader.load(path);
- }
- static function onReadConfigFile(success)
- {
- }
- static function isBlueprint(id)
- {
- return com.neodelight.std.Blueprint.lib[id] != undefined;
- }
- static function getBlueprint(id)
- {
- if(typeof id == "object")
- {
- return id;
- }
- var _loc1_ = com.neodelight.std.Blueprint.lib[id];
- if(_loc1_.blueprint)
- {
- com.neodelight.std.Blueprint.apply(_loc1_,_loc1_.blueprint);
- }
- return _loc1_;
- }
- static function getBlueprints(filter)
- {
- if(!filter)
- {
- return undefined;
- }
- var _loc1_ = new Array();
- for(var _loc3_ in com.neodelight.std.Blueprint.lib)
- {
- if(filter.test(_loc3_))
- {
- _loc1_.push(com.neodelight.std.Blueprint.getBlueprint(_loc3_));
- }
- }
- return _loc1_;
- }
- static function apply(target, id)
- {
- if(!id)
- {
- id = String(target.blueprint);
- }
- var _loc3_ = com.neodelight.std.Blueprint.lib[id];
- if(!_loc3_)
- {
- trace("!!!blueprint not found:" + id);
- }
- var _loc6_ = 0;
- for(var _loc1_ in _loc3_)
- {
- if(_loc1_ != "blueprint")
- {
- if(target[_loc1_] == undefined)
- {
- target[_loc1_] = _loc3_[_loc1_];
- }
- }
- }
- if(_loc3_.blueprint)
- {
- var _loc4_ = _loc3_.blueprint.split(",");
- _loc1_ = 0;
- while(_loc1_ < _loc4_.length)
- {
- com.neodelight.std.Blueprint.apply(target,_loc4_[_loc1_]);
- _loc1_ = _loc1_ + 1;
- }
- }
- return target;
- }
- }
-