示例#1
0
        private void HelpForm_Load(object sender, EventArgs e)
        {
            string sHelpContent = String.Empty;

            try
            {
                sHelpContent = TokenUtilities.GetEmbeddedText("MassiveDarknessRandomDungeonGenerator.MDRandomDungeonGeneratorHelpContents.rtf");
            }
            catch (Exception exHelp)
            {
                // use default help content
                sHelpContent = @"{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Courier New;}{\f1\fnil\fcharset2 Symbol;}}" +
                               @" {\*\generator Msftedit 5.41.21.2510;}\viewkind4\uc1\pard\fs22 Unable to load About contents: " + exHelp.Message + @" \par}";
            }

            rtxtHelpContent.Rtf = sHelpContent;
        }
示例#2
0
        private void ParseConfigFile(string filename)
        {
            try
            {
                string      sConfigContents = TokenUtilities.GetEmbeddedText("MassiveDarknessRandomDungeonGenerator.MassiveDarknessInfo.cfg");
                XmlDocument xmlDoc          = new XmlDocument();
                xmlDoc.LoadXml(sConfigContents);

                // Extract the Tile sets
                XmlNodeList xmlTileSets = xmlDoc.GetElementsByTagName("TileSet");
                foreach (XmlNode xmlTileSet in xmlTileSets)
                {
                    TileSet newTileSet = new TileSet(xmlTileSet);
                    lstTilesets.Items.Add(newTileSet);
                }

                // Extract the Chips
                XmlNodeList xmlChips = xmlDoc.GetElementsByTagName("Chip");
                foreach (XmlNode xmlChip in xmlChips)
                {
                    Chip newChip = new Chip(xmlChip);
                    lstChips.Add(newChip);

                    switch (newChip.Name.ToLower())
                    {
                    case "start":
                        chpStart = newChip;
                        break;

                    case "exit":
                        chpExit = newChip;
                        break;

                    case "door":
                        chpDoor = newChip;
                        break;

                    case "bridge":
                        chpBridge = newChip;
                        break;

                    case "lvl1":
                        chpLevel1 = newChip;
                        break;

                    case "lvl2":
                        chpLevel2 = newChip;
                        break;

                    case "lvl3":
                        chpLevel3 = newChip;
                        break;

                    case "lvl4":
                        chpLevel4 = newChip;
                        break;

                    case "lvl5":
                        chpLevel5 = newChip;
                        break;

                    default:
                        break;
                    }
                }

                // Extract the Dice
                XmlNodeList xmlDice = xmlDoc.GetElementsByTagName("Die");
                foreach (XmlNode xmlDie in xmlDice)
                {
                    Die newDie = new Die(xmlDie);
                    lstDice.Add(newDie);
                    switch (newDie.Name.ToLower())
                    {
                    case "red":
                        dieRed = newDie;
                        break;

                    case "green":
                        dieGreen = newDie;
                        break;

                    default:
                        break;
                    }
                }

                // Validate the extraction of the Chips and Dice
                if ((null == chpStart) || (null == chpExit) || (null == chpDoor) || (null == chpBridge))
                {
                    sLoadErrors += Environment.NewLine + "Error parsing configuration file: Chip extraction failed.";
                }
                if ((null == chpLevel1) || (null == chpLevel2) || (null == chpLevel3) || (null == chpLevel4) || (null == chpLevel5))
                {
                    sLoadErrors += Environment.NewLine + "Error parsing configuration file: Chip Level extraction failed.";
                }
                if ((null == dieRed) || (null == dieGreen))
                {
                    sLoadErrors += Environment.NewLine + "Error parsing configuration file: Die extraction failed.";
                }
            }
            catch (Exception exXMLParse)
            {
                sLoadErrors = "Error parsing configuration file:" + Environment.NewLine + Environment.NewLine + exXMLParse.Message;
            }
        }