private void _readResourceTree(XmlNode root, string resourceType, GmsResourceGroup parent) { foreach (XmlNode node in root) { if (node.Attributes["name"] != null) { //group GmsResourceGroup group = new GmsResourceGroup(node.Attributes["name"].InnerText); _readResourceTree(node, resourceType, group); parent.subitems.Add(group); } else { GmsResource resource; string name = Path.GetFileName(node.InnerText); switch (resourceType) { case "sprites": resource = new GmsSprite(name); GmsResourceSpriteList.Add((GmsSprite)resource); break; case "backgrounds": resource = new GmsBackground(name); GmsResourceBackgroundList.Add((GmsBackground)resource); break; case "objects": resource = new GmsObject(name); GmsResourceObjectList.Add((GmsObject)resource); break; case "rooms": resource = new GmsRoom(name); GmsResourceRoomList.Add((GmsRoom)resource); break; default: resource = new GmsResource(name); break; } resource.name = Path.GetFileName(node.InnerText); parent.subitems.Add(resource); } } }
private void _readRoomsNode(XmlNode root) { foreach (XmlNode node in root) { if (node.Attributes["name"] != null) { _readRoomsNode(node); } else { GmsRoom room = GmsResourceRoomList.Find(n => n.name == node.InnerText.Replace("rooms\\", "").ToString()); if (room == null) { continue; } XmlDocument roomData = new XmlDocument(); roomData.Load(ProjectSource + "/" + node.InnerText + ".room.gmx"); room.width = Int32.Parse(roomData.SelectSingleNode("room/width").InnerText); room.height = Int32.Parse(roomData.SelectSingleNode("room/height").InnerText); string _name; try { _name = roomData.SelectSingleNode("room/backgrounds/background").Attributes["name"].InnerText; if (_name != "") { room.background = GmsResourceBackgroundList.Find(n => n.name == _name); } } catch (Exception) { } XmlNode _instances = roomData.SelectSingleNode("room/instances"); if (_instances.ChildNodes.Count > 0) { foreach (XmlNode inode in _instances) { try { GmsRoomInstance inst = new GmsRoomInstance(); { inst.objName = inode.Attributes["objName"].InnerText; inst.x = Int32.Parse(inode.Attributes["x"].InnerText, CultureInfo.InvariantCulture); inst.y = Int32.Parse(inode.Attributes["y"].InnerText, CultureInfo.InvariantCulture); inst.name = inode.Attributes["name"].InnerText; inst.locked = inode.Attributes["locked"].InnerText == "1" ? true : false; inst.code = inode.Attributes["code"].InnerText; inst.scaleX = float.Parse(inode.Attributes["scaleX"].InnerText, CultureInfo.InvariantCulture); inst.scaleY = float.Parse(inode.Attributes["scaleY"].InnerText, CultureInfo.InvariantCulture); inst.colour = UInt32.Parse(inode.Attributes["colour"].InnerText, CultureInfo.InvariantCulture); inst.rotation = float.Parse(inode.Attributes["rotation"].InnerText, CultureInfo.InvariantCulture); inst.instance_of = GmsResourceObjectList.Find(n => n.name == inode.Attributes["objName"].InnerText); }; //inst.editor_data.Element = PlaceableList.Find(item => item.Name == inst.objName); room.instances.Add(inst); } catch (Exception) { //MessageBox.Show(e.ToString() + " / " + ProjectSource + "/" + node.InnerText + ".room.gmx / " + inode.Attributes["name"].InnerText); } } } //GMRooms.Add(room); } } }