Ejemplo n.º 1
0
            static Model()
            {
                //load up config and check out the model properties
                try
                {
                    Sluggy.Utility.XmlParser  parser = new Sluggy.Utility.XmlParser(Globals.Files.ConfigFile);
                    List <Sluggy.Utility.Tag> items  = parser.FindAll(null, "baseroom");
                    items.AddRange(parser.FindAll(null, "startroom"));

                    //add default

                    if (items != null)
                    {
                        foreach (Sluggy.Utility.Tag tag in items)
                        {
                            if (tag.Name == "baseroom")
                            {
                                if (tag.Attributes.ContainsKey("name"))
                                {
                                    BaseRoomName = tag.Attributes["name"];
                                }
                            }
                            if (tag.Name == "startroom")
                            {
                                if (tag.Attributes.ContainsKey("name"))
                                {
                                    CustomStartRoomName = tag.Attributes["name"];
                                }
                            }
                        }                //end if
                    }                    //end foreach
                }                        //end try
                catch (Sluggy.Utility.XMLParserException e)
                {
                    MessageBox.Show(e.Message);
                }
                catch (System.IO.FileNotFoundException e)
                {
                    //swallow exception
                }
                catch (System.IO.DirectoryNotFoundException e)
                {
                    //swallow exception
                }
            }
Ejemplo n.º 2
0
        static public Dictionary <string, System.Drawing.Bitmap> LoadIconsFromConfig(string configFile)
        {
            Dictionary <string, Bitmap> roomIcons = new Dictionary <string, Bitmap>();

            try
            {
                Sluggy.Utility.XmlParser  parser = new Sluggy.Utility.XmlParser(configFile);
                List <Sluggy.Utility.Tag> items  = parser.FindAll(null, "icon");


                if (items != null)
                {
                    foreach (Sluggy.Utility.Tag tag in items)
                    {
                        //config global bitmaps
                        if (tag.Attributes.ContainsKey("file") && tag.Attributes.ContainsKey("desc"))
                        {
                            Utility.ConfirmRequiredFile(Globals.Dirs.Bitmaps + tag.Attributes["file"]);
                            try{
                                Bitmap image = new Bitmap(Globals.Dirs.Bitmaps + tag.Attributes["file"]);
                                roomIcons.Add(tag.Attributes["desc"], image);
                            }
                            catch (System.IO.FileNotFoundException e)
                            {
                                //swallow exception
                            }
                            catch (System.IO.DirectoryNotFoundException e)
                            {
                                //swallow exception
                            }
                        }
                    }            //end if
                }                //end foreach
            }                    //end try
            catch (Sluggy.Utility.XMLParserException e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
            }
            catch (System.IO.FileNotFoundException e)
            {
                //swallow exception
            }
            catch (System.IO.DirectoryNotFoundException e)
            {
                //swallow exception
            }

            return(roomIcons);
        }
Ejemplo n.º 3
0
            static NodeProperties()
            {
                Sluggy.Utility.XmlParser  parser = new Sluggy.Utility.XmlParser(Globals.Files.ConfigFile);
                List <Sluggy.Utility.Tag> items  = parser.FindAll(null, "nodeboxes");

                try {
                    //add default
                    if (items != null)
                    {
                        foreach (Sluggy.Utility.Tag tag in items)
                        {
                            //config global image properties
                            if (tag.Name == "nodeboxes")
                            {
                                if (tag.Attributes.ContainsKey("width"))
                                {
                                    Globals.NodeProperties.width = System.Convert.ToInt32(tag.Attributes["width"]);
                                }
                                if (tag.Attributes.ContainsKey("height"))
                                {
                                    Globals.NodeProperties.height = System.Convert.ToInt32(tag.Attributes["height"]);
                                }
                            }
                        }                //end if
                    }                    //end foreach
                }                        //end try
                catch (Sluggy.Utility.XMLParserException e)
                {
                    MessageBox.Show(e.Message);
                }
                catch (System.IO.FileNotFoundException e)
                {
                    //swallow exception
                }
                catch (System.IO.DirectoryNotFoundException e)
                {
                    //swallow exception
                }

                CreateNodeProperties();
            }