Esempio n. 1
0
        private void f(GCore.Sprite parent, XmlNode node)
        {
            //Console.WriteLine("Function f " + node.Name);
            foreach (XmlNode table in node.ChildNodes)
            {
                float x      = rf(table.Attributes["x"]);
                float y      = rf(table.Attributes["y"]);
                float width  = rf(table.Attributes["width"]);
                float height = rf(table.Attributes["height"]);
                switch (table.Name)
                {
                case "img":
                {
                    GCore.Bitmap b = new GCore.Bitmap();
                    b.load(rs(table.Attributes["src"]));
                    b.x     = x;
                    b.y     = y;
                    b.ratio = rb(table.Attributes["ratio"], true);
                    if (width != 0 && height != 0)
                    {
                        b.width  = width;
                        b.height = height;
                    }
                    keeper.add(parent, b);
                } break;

                case "button":
                {
                    UI.Button b = new UI.Button();
                    b.x  = x;
                    b.y  = y;
                    b.id = rs(table.Attributes["id"]);
                    List <string> imgs = new List <string>();
                    foreach (XmlNode img in table.ChildNodes)
                    {
                        imgs.Add(img.Attributes["src"].Value);
                    }
                    b.load(imgs.ToArray());
                    keeper.add(b, GCore.MouseEvent.CLICK, onClick);
                    keeper.add(parent, b);
                } break;

                case "movieclip":
                {
                    GCore.MovieClip m = new GCore.MovieClip();
                    m.x         = x;
                    m.y         = y;
                    m.frameRate = 1;        // ri(table.Attributes["frameRate"], 20);
                    List <string> imgs = new List <string>();
                    foreach (XmlNode img in table.ChildNodes)
                    {
                        imgs.Add(img.Attributes["src"].Value);
                    }
                    m.load(imgs.ToArray());
                    keeper.add(parent, m);
                } break;

                case "textfield":
                {
                    String          value = table.Attributes["value"].Value;
                    GCore.TextField tf    = new GCore.TextField(value);
                    tf.x = x;
                    tf.y = y;
                    if (table.Attributes["size"] != null)
                    {
                        int size = Int32.Parse(table.Attributes["size"].Value);
                        tf.size = size;
                    }
                    keeper.add(parent, tf);
                } break;

                case "plane":
                {
                    GCore.Sprite sp = new GCore.Sprite();
                    sp.x = x;
                    sp.y = y;
                    keeper.add(parent, sp);
                    f(sp, table);
                } break;
                }
            }
        }