private unsafe void Load(int index, int program) { if (TKContext.CurrentContext == null) { return; } Source = null; if (Texture != null) { Texture.Delete(); } Texture = new GLTexture(); Texture.Bind(index, program); Bitmap bmp = null; if (_folderWatcher.EnableRaisingEvents && !String.IsNullOrEmpty(_folderWatcher.Path)) { bmp = SearchDirectory(_folderWatcher.Path + Name); } if (bmp == null && TKContext.CurrentContext._states.ContainsKey("_Node_Refs")) { List <ResourceNode> nodes = TKContext.CurrentContext._states["_Node_Refs"] as List <ResourceNode>; List <ResourceNode> searched = new List <ResourceNode>(nodes.Count); TEX0Node tNode = null; foreach (ResourceNode n in nodes) { ResourceNode node = n.RootNode; if (searched.Contains(node)) { continue; } searched.Add(node); //Search node itself first if ((tNode = node.FindChild("Textures(NW4R)/" + Name, true) as TEX0Node) != null) { Source = tNode; Texture.Attach(tNode, _palette); return; } else //Then search the directory { bmp = SearchDirectory(node._origPath); } if (bmp != null) { break; } } searched.Clear(); } if (bmp != null) { Texture.Attach(bmp); } else { Texture.Default(); } }
private unsafe void Load(int index, int program) { if (TKContext.CurrentContext == null) { return; } bool isStage = false; Source = null; if (Texture != null) { Texture.Delete(); } Texture = new GLTexture(); Texture.Bind(index, program); Bitmap bmp = null; if (RootNode is ARCNode) { isStage = ((ARCNode)RootNode).IsStage; } if (_folderWatcher.EnableRaisingEvents && !String.IsNullOrEmpty(_folderWatcher.Path)) { bmp = SearchDirectory(_folderWatcher.Path + Name); } BRRESNode parentBRRES = null; ARCNode parentARC = null; // Safely search for whether this is part of a BRRES if (_parent != null) { if (_parent._parent != null) { if (_parent._parent._parent != null) { if (_parent._parent._parent._parent != null) { if (_parent._parent._parent._parent is BRRESNode) { parentBRRES = (BRRESNode)_parent._parent._parent._parent; if (parentBRRES._parent != null) { if (parentBRRES._parent is ARCNode) { parentARC = (ARCNode)parentBRRES._parent; } } } } } } } List <ResourceNode> nodes = TKContext.CurrentContext._states["_Node_Refs"] as List <ResourceNode>; TEX0Node tNode = null; if (bmp == null && TKContext.CurrentContext._states.ContainsKey("_Node_Refs") && parentBRRES != null) { ResourceNode node = parentBRRES; //Search node itself first if ((tNode = node.SearchForTextures("Textures(NW4R)/" + Name, true, false) as TEX0Node) != null) { Source = tNode; Texture.Attach(tNode, _palette); return; } } if (bmp == null && TKContext.CurrentContext._states.ContainsKey("_Node_Refs") && parentARC != null) { ResourceNode node = parentARC; //Search node itself first if ((tNode = node.SearchForTextures("Textures(NW4R)/" + Name, true, isStage) as TEX0Node) != null) { Source = tNode; Texture.Attach(tNode, _palette); return; } else //Then search the directory { bmp = SearchDirectory(node._origPath); } } if (bmp != null) { Texture.Attach(bmp); } else { Texture.Default(); } }