コード例 #1
0
        // This loads palette numbers/descriptions
        private void LoadPalettes()
        {
            //TODO: how does that "texture layers" thing from http://infosuite.duke4.net/index.php?page=references_palettes even work?..
            IDictionary   dic       = cfg.ReadSetting("palettes", new Hashtable());
            HashSet <int> processed = new HashSet <int>();

            foreach (DictionaryEntry de in dic)
            {
                // Try paring the palette number
                int index;
                if (int.TryParse(de.Key.ToString(), NumberStyles.Integer, CultureInfo.InvariantCulture, out index))
                {
                    if (processed.Contains(index))
                    {
                        General.ErrorLogger.Add(ErrorType.Warning, "Palette index " + index + " is double-defined in \"palettes\" structure of game configuration \"" + this.Name + "\"");
                        continue;
                    }

                    // Add to collections
                    paletteslist.Add(new EnumItem(index.ToString(), de.Value.ToString()));
                    processed.Add(index);
                }
                else
                {
                    General.ErrorLogger.Add(ErrorType.Warning, "Structure \"palettes\" contains invalid keys in game configuration \"" + this.Name + "\"");
                }
            }
        }
コード例 #2
0
        // Sector effects
        private void LoadSectorEffects()
        {
            // Get sector effects
            IDictionary dic = cfg.ReadSetting("sectoreffects", new Hashtable());

            foreach (DictionaryEntry de in dic)
            {
                // Try paring the sector effect
                int index;
                if (int.TryParse(de.Key.ToString(), NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite, CultureInfo.InvariantCulture, out index))
                {
                    if (sectoreffects.ContainsKey(index))
                    {
                        General.ErrorLogger.Add(ErrorType.Warning, "Sector effect " + index + " is double-defined in \"sectoreffects\" structure of game configuration \"" + this.Name + "\"");
                        continue;
                    }

                    SectorEffectInfo si;
                    if (de.Value is IDictionary)
                    {
                        string        path    = "sectoreffects." + index + ".";
                        string        title   = cfg.ReadSetting(path + "title", "Effect " + index);
                        string        tagsstr = cfg.ReadSetting(path + "setags", string.Empty);
                        HashSet <int> setags  = new HashSet <int>();

                        // Parse setags...
                        if (!string.IsNullOrEmpty(tagsstr) && !General.GetNumbersFromString(tagsstr, setags))
                        {
                            General.ErrorLogger.Add(ErrorType.Warning, "Unable to get Sector Effect tags from string \"" + tagsstr + "\" while parsing Sector Effect " + index + " in game configuration \"" + this.Name + "\"");
                        }

                        // Make effect
                        si = new SectorEffectInfo(index, title, setags);
                    }
                    else
                    {
                        // Make effect
                        si = new SectorEffectInfo(index, de.Value.ToString());
                    }

                    // Add to collections
                    sectoreffects.Add(index, si);
                    sectoreffectslist.Add(new EnumItem(index.ToString(), si.Title));
                }
                else
                {
                    General.ErrorLogger.Add(ErrorType.Warning, "Structure \"sectoreffects\" contains invalid keys in game configuration \"" + this.Name + "\"");
                }
            }

            // Sort the actions list
            //sortedsectoreffects.Sort();
        }