Exemplo n.º 1
0
        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);
                }
            }
        }
Exemplo n.º 2
0
 public void regenerateBrushList()
 {
     foreach (BrushGroup group in BrushGroups)
     {
         ListView      l  = Manager.MainWindow.brushGroupList;
         ListViewGroup gr = l.Groups.Add(group.GroupName, group.GroupName);
         foreach (string name in group.objects)
         {
             GmsSprite    sprite = Manager.Project.GmsResourceObjectList.Find(item => item.name == name).sprite_index;
             ListViewItem o      = new ListViewItem()
             {
                 Text = name, ImageKey = (sprite == null) ? GmsResource.undefined : sprite.name
             };
             o.Group = gr;
             l.Items.Add(o);
         }
     }
 }
Exemplo n.º 3
0
        public GmsObject(string new_name)
            : base(new_name)
        {
            XmlDocument XMLfile = new XmlDocument();

            XMLfile.Load(Manager.Project.ProjectSource + "\\objects\\" + new_name + ".object.gmx");

            XmlNode node = XMLfile.SelectSingleNode("object/spriteName");

            sprite_index = Manager.Project.GmsResourceSpriteList[0];
            string spriteName = "";

            if (node != null)
            {
                spriteName   = node.InnerText;
                sprite_index = Manager.Project.GmsResourceSpriteList.Find(item => item.name == spriteName);
            }

            node = XMLfile.SelectSingleNode("object/depth");
            if (node != null)
            {
                depth = int.Parse(node.InnerText);
            }
        }
Exemplo n.º 4
0
        public void regenerateTextureList()
        {
            using (LoadingForm form = new LoadingForm())
            {
                form.Show();

                //GraphicsManager.DeleteTextures();

                int i = 0;

                //form.loadingBar.Maximum = this.GMXObjects.Count;
                form.loadingBar.Maximum = this.GmsResourceObjectList.Count;
                form.loadingBar.Value   = 0;

                GraphicsManager.LoadTexture(GmsResource.undefined, new Bitmap(Manager.MainWindow.imageListObjects.Images[GmsResource.undefined]));

                //foreach (string file in RegisteredResources)
                // LOAD ONLY SPRITES ASSIGNED TO OBJECTS, SKIP ELSE
                //List<string> objects = renderItemsList("objects");
                foreach (GmsObject gmobject in this.GmsResourceObjectList)
                {
                    //GMSpriteData itm = this.GMXSprites.Find(item => item.Name == file);
                    //GMSpriteData itm = this.GMXObjects.Find(item => item.Name == gmobject).sprite;
                    GmsSprite itm = gmobject.sprite_index;

                    if (itm != null)
                    {
                        // prevent adding duplicates
                        if (!GraphicsManager.Sprites.ContainsKey(itm.name))
                        {
                            if (File.Exists(itm.image))
                            {
                                GraphicsManager.LoadTexture(itm.name, new Bitmap(itm.image));
                            }
                            else// if (itm.name == null)
                            {
                                GraphicsManager.LoadTexture(itm.name, new Bitmap(Manager.MainWindow.imageListObjects.Images[GmsResource.undefined]));
                            }
                        }

                        if (!Manager.MainWindow.imageListObjects.Images.ContainsKey(itm.name))
                        {
                            if (File.Exists(itm.image))
                            {
                                Manager.MainWindow.imageListObjects.Images.Add(itm.name, new Bitmap(itm.image));
                            }
                        }
                    }
                    //Manager.MainWindow.tsProgress.Value++;
                    form.loadingBar.Value++;
                    if (i % 10 == 0 || i == form.loadingBar.Maximum - 1)
                    {
                        form.Refresh();
                    }
                    i++;
                }

                foreach (GmsRoom r in this.GmsResourceRoomList)
                {
                    if (r.background != null && r.background.image != null)
                    {
                        string imgName = "@bg:" + r.background.name;

                        if (!GraphicsManager.Sprites.ContainsKey(imgName))
                        {
                            if (File.Exists(r.background.image))
                            {
                                GraphicsManager.LoadTexture(imgName, new Bitmap(r.background.image));
                            }
                        }
                    }
                }

                //foreach (PlaceableElement elem in PlaceableList)
                //{
                //    elem.textureId = elem.Sprite;
                //}

                form.Close();
            }

            /*using (LoadingForm form = new LoadingForm())
             * {
             *  form.Show();
             *
             *  List<string> objects = renderItemsList("objects");
             *
             *  foreach (string gmobject in objects)
             *  {
             *      //GMSpriteData itm = this.GMXSprites.Find(item => item.Name == file);
             *      GMSpriteData itm = this.GMXObjects.Find(item => item.Name == gmobject).sprite;
             *
             *      if (itm != null)
             *      {
             *          // prevent adding duplicates
             *          //if (!GraphicsManager.Sprites.ContainsKey(itm.Name))
             *
             *      }
             *  }
             *
             *  form.Close();
             * }*/
        }