Esempio n. 1
0
        public void FromXml(XmlNode node)
        {
            //this.GuiMenuId = node.SelectSingleNode("GuiMenuId").InnerText;
            this.Text       = node.SelectSingleNode("Text").InnerText;
            this.Font       = node.SelectSingleNode("Font").InnerText;
            this.ForeColor  = StructXml.ColorFromXml(node.SelectSingleNode("ForeColor").InnerText);
            this.TextFormat = (DrawTextFormat)DrawTextFormat.Parse(typeof(DrawTextFormat), node.SelectSingleNode("TextFormat").InnerText);
            this.ButtonRect = StructXml.RectangleFromXml(node.SelectSingleNode("ButtonRect"));

            this.Tooltip = node.SelectSingleNode("Tooltip").InnerText;

            this.Params.Clear();
            foreach (XmlNode xPar in node.SelectSingleNode("Params").ChildNodes)
            {
                GuiButtonParam par = GuiButtonParam.InvokeCreate(xPar.Attributes["Type"].Value);
                par.FromXml(xPar);
                this.Params.Add(xPar.Name, par);
            }

            this.Picture         = node.SelectSingleNode("Picture").InnerText;
            this.PictureColor    = StructXml.ColorFromXml(node.SelectSingleNode("PictureColor").InnerText);
            this.Enabled         = bool.Parse(node.SelectSingleNode("Enabled").InnerText);
            this.AnimationFrames = int.Parse(node.SelectSingleNode("AnimationFrames").InnerText);
            this.AnimationTime   = int.Parse(node.SelectSingleNode("AnimationTime").InnerText);
        }
Esempio n. 2
0
        public virtual void FromXml(XmlNode node, bool loadButtons)
        {
            this.id          = node.SelectSingleNode("Id").InnerText;
            this.textureArea = StructXml.RectangleFromXml(node.SelectSingleNode("TextureArea"));
            this.picture     = node.SelectSingleNode("Picture").InnerText;
            this.location    = StructXml.PointFromXml(node.SelectSingleNode("Location"));

            this.buttons.Clear();
            if (loadButtons)
            {
                foreach (XmlNode xBtn in node.SelectSingleNode("Buttons"))
                {
                    string typ = xBtn.Name;

                    if (xBtn.Attributes["Template"] != null)
                    {
                        typ = xBtn.Attributes["Template"].Value;
                    }

                    GuiButtonInfo btn = GameEngine.Instance.GuiButtonTemplates[typ].Clone();

                    btn.GuiMenuId = this.id;

                    this.buttons.Add(xBtn.Name, btn);
                }
            }
        }
Esempio n. 3
0
        public static SolarSystem InvokeCreate(string typ)
        {
            SolarSystem si = StructXml.CreateInstanceFromType(typ) as SolarSystem;

            if (si == null)
            {
                return(new SolarSystem());
            }
            else
            {
                return(si);
            }
        }
Esempio n. 4
0
        public static GuiMenu InvokeCreate(string typ)
        {
            GuiMenu mnu = StructXml.CreateInstanceFromType(typ) as GuiMenu;

            if (mnu == null)
            {
                return(new GuiMenu());
            }
            else
            {
                return(mnu);
            }
        }
Esempio n. 5
0
        public static StationModuleBase InvokeCreate(string typ)
        {
            StationModuleBase si = StructXml.CreateInstanceFromType(typ) as StationModuleBase;

            if (si == null)
            {
                return(new StationModuleBase());
            }
            else
            {
                return(si);
            }
        }
Esempio n. 6
0
        public static WorkTeamBase InvokeCreate(string typ)
        {
            WorkTeamBase si = StructXml.CreateInstanceFromType(typ) as WorkTeamBase;

            if (si == null)
            {
                return(new WorkTeamBase());
            }
            else
            {
                return(si);
            }
        }
Esempio n. 7
0
        public static GuiButtonParam InvokeCreate(string typ)
        {
            GuiButtonParam si = StructXml.CreateInstanceFromType(typ) as GuiButtonParam;

            if (si == null)
            {
                return(new GuiButtonParamDoNothing());
            }
            else
            {
                return(si);
            }
        }
Esempio n. 8
0
        public static GuiButtonInfo InvokeCreate(string typ)
        {
            GuiButtonInfo si = StructXml.CreateInstanceFromType(typ) as GuiButtonInfo;

            if (si == null)
            {
                return(new GuiButtonInfo());
            }
            else
            {
                return(si);
            }
        }
Esempio n. 9
0
        public virtual void ToXml(XmlNode node)
        {
            XmlDocument  doc = node.OwnerDocument;
            XmlAttribute at;

            XmlElement el = doc.CreateElement("Id");

            el.InnerText = this.id;
            node.AppendChild(el);

            el = doc.CreateElement("TextureArea");
            node.AppendChild(el);

            StructXml.RectangleToXml(this.textureArea, el);

            el           = doc.CreateElement("Picture");
            el.InnerText = this.picture;
            node.AppendChild(el);

            el = doc.CreateElement("Location");
            node.AppendChild(el);

            StructXml.PointToXml(this.location, el);

            el = doc.CreateElement("Buttons");
            node.AppendChild(el);

            XmlElement el2;

            foreach (KeyValuePair <string, GuiButtonInfo> btn in this.buttons)
            {
                // ALTERNATIVE: use this to save the button info:
                // btn.ToXml(el2);
                // el2 = doc.CreateElement(btn.GetType().ToString());

                el2 = doc.CreateElement(btn.Key);
                el.AppendChild(el2);

                at       = doc.CreateAttribute("Template");
                at.Value = btn.Value.Template;
            }
        }
Esempio n. 10
0
        public virtual void FromXml(XmlNode node)
        {
            this.title        = node.SelectSingleNode("Title").InnerText;
            this.researched   = bool.Parse(node.SelectSingleNode("Researched").InnerText);
            this.canResearch  = bool.Parse(node.SelectSingleNode("CanResearch").InnerText);
            this.type         = (ItemType)ItemType.Parse(typeof(ItemType), node.SelectSingleNode("ItemType").InnerText);
            this.description  = node.SelectSingleNode("Description").InnerText;
            this.buildTime    = int.Parse(node.SelectSingleNode("BuildTime").InnerText);
            this.buildRank    = int.Parse(node.SelectSingleNode("BuildRank").InnerText);
            this.researchRank = int.Parse(node.SelectSingleNode("ResearchRank").InnerText);
            this.orbitalOnly  = bool.Parse(node.SelectSingleNode("OrbitalOnly").InnerText);
            this.picture      = node.SelectSingleNode("Picture").InnerText;

            XmlNode par;

            this.textureArea = StructXml.RectangleFromXml(node.SelectSingleNode("TextureArea"));

            par = node.SelectSingleNode("Resources");

            this.resources.Clear();
            for (int i = 0; i < par.ChildNodes.Count; i++)
            {
                FactoryResource res = new FactoryResource();
                res.FromXml(par.ChildNodes[i]);

                this.resources.Add(res);
            }

            if (node.SelectSingleNode("Mass") != null)
            {
                this.mass = int.Parse(node.SelectSingleNode("Mass").InnerText);
            }
            if (node.SelectSingleNode("ResearchPointsNeeded") != null)
            {
                this.researchPointsNeeded = int.Parse(node.SelectSingleNode("ResearchPointsNeeded").InnerText);
            }
        }
Esempio n. 11
0
        public virtual void ToXml(XmlNode node)
        {
            XmlDocument doc = node.OwnerDocument;

            XmlAttribute at = doc.CreateAttribute("Type");

            at.Value = this.GetType().ToString();
            node.Attributes.Append(at);

            XmlElement el = doc.CreateElement("Title");

            el.InnerText = title;
            node.AppendChild(el);

            el           = doc.CreateElement("Researched");
            el.InnerText = researched.ToString();
            node.AppendChild(el);

            el           = doc.CreateElement("CanResearch");
            el.InnerText = canResearch.ToString();
            node.AppendChild(el);

            el           = doc.CreateElement("ItemType");
            el.InnerText = type.ToString();
            node.AppendChild(el);

            el           = doc.CreateElement("Description");
            el.InnerText = this.description;
            node.AppendChild(el);

            el           = doc.CreateElement("BuildTime");
            el.InnerText = this.buildTime.ToString();
            node.AppendChild(el);

            el           = doc.CreateElement("BuildRank");
            el.InnerText = this.buildRank.ToString();
            node.AppendChild(el);

            el           = doc.CreateElement("ResearchRank");
            el.InnerText = this.researchRank.ToString();
            node.AppendChild(el);

            el           = doc.CreateElement("OrbitalOnly");
            el.InnerText = this.orbitalOnly.ToString();
            node.AppendChild(el);

            el           = doc.CreateElement("Picture");
            el.InnerText = this.picture;
            node.AppendChild(el);

            el = doc.CreateElement("TextureArea");
            node.AppendChild(el);

            StructXml.RectangleToXml(this.textureArea, el);

            XmlElement el2;

            el = doc.CreateElement("Resources");
            node.AppendChild(el);

            for (int i = 0; i < this.resources.Count; i++)
            {
                el2 = doc.CreateElement("Resource");
                el.AppendChild(el2);

                this.resources[i].ToXml(el2);
            }

            el           = doc.CreateElement("Mass");
            el.InnerText = this.mass.ToString();
            node.AppendChild(el);

            el           = doc.CreateElement("ResearchPointsNeeded");
            el.InnerText = this.researchPointsNeeded.ToString();
            node.AppendChild(el);
        }
Esempio n. 12
0
        public void ToXml(XmlNode node)
        {
            XmlDocument doc = node.OwnerDocument;

            XmlElement   el;
            XmlAttribute at;

//			el = doc.CreateElement("GuiMenuId");
//			el.InnerText = GuiMenuId;
//			node.AppendChild(el);

            el           = doc.CreateElement("Text");
            el.InnerText = Text;
            node.AppendChild(el);

            el           = doc.CreateElement("Font");
            el.InnerText = Font;
            node.AppendChild(el);

            el           = doc.CreateElement("ForeColor");
            el.InnerText = StructXml.ColorToXml(ForeColor);
            node.AppendChild(el);

            el           = doc.CreateElement("TextFormat");
            el.InnerText = TextFormat.ToString();
            node.AppendChild(el);

            el = doc.CreateElement("ButtonRect");
            node.AppendChild(el);

            StructXml.RectangleToXml(this.ButtonRect, el);

            el           = doc.CreateElement("Tooltip");
            el.InnerText = Tooltip;
            node.AppendChild(el);

            el = doc.CreateElement("Params");
            node.AppendChild(el);

            XmlElement el2;

            foreach (KeyValuePair <string, GuiButtonParam> par in Params)
            {
                if (par.Value != null)
                {
                    el2      = doc.CreateElement(par.Key);
                    at       = doc.CreateAttribute("Type");
                    at.Value = par.Value.GetType().ToString();
                    el2.Attributes.Append(at);
                    el.AppendChild(el2);

                    par.Value.ToXml(el2);
                }
            }

            el           = doc.CreateElement("Picture");
            el.InnerText = Picture;
            node.AppendChild(el);

            el           = doc.CreateElement("PictureColor");
            el.InnerText = StructXml.ColorToXml(PictureColor);
            node.AppendChild(el);

            el           = doc.CreateElement("Enabled");
            el.InnerText = Enabled.ToString();
            node.AppendChild(el);

            el           = doc.CreateElement("AnimationFrames");
            el.InnerText = AnimationFrames.ToString();
            node.AppendChild(el);

            el           = doc.CreateElement("AnimationTime");
            el.InnerText = AnimationTime.ToString();
            node.AppendChild(el);
        }