// This adds an action to this category
 internal void Add(LinedefActionInfo a)
 {
     // Make it so.
     actions.Add(a);
 }
Example #2
0
        // Linedef actions and action categories
        private void LoadLinedefActions()
        {
            Dictionary <string, LinedefActionCategory> cats = new Dictionary <string, LinedefActionCategory>();
            IDictionary           dic;
            LinedefActionInfo     ai;
            LinedefActionCategory ac;
            int actionnumber;

            // Get linedef categories
            dic = cfg.ReadSetting("linedeftypes", new Hashtable());
            foreach (DictionaryEntry cde in dic)
            {
                if (cde.Value is IDictionary)
                {
                    // Read category title
                    string cattitle = cfg.ReadSetting("linedeftypes." + cde.Key + ".title", "");

                    // Make or get category
                    if (cats.ContainsKey(cde.Key.ToString()))
                    {
                        ac = cats[cde.Key.ToString()];
                    }
                    else
                    {
                        ac = new LinedefActionCategory(cde.Key.ToString(), cattitle);
                        cats.Add(cde.Key.ToString(), ac);
                    }

                    // Go for all line types in category
                    IDictionary catdic = cfg.ReadSetting("linedeftypes." + cde.Key, new Hashtable());
                    foreach (DictionaryEntry de in catdic)
                    {
                        // Check if the item key is numeric
                        if (int.TryParse(de.Key.ToString(),
                                         NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingWhite,
                                         CultureInfo.InvariantCulture, out actionnumber))
                        {
                            // Check if the item value is a structure
                            if (de.Value is IDictionary)
                            {
                                if (!linedefactions.ContainsKey(actionnumber))
                                {
                                    // Make the line type
                                    ai = new LinedefActionInfo(actionnumber, cfg, cde.Key.ToString(), enums);

                                    // Add action to category and sorted list
                                    sortedlinedefactions.Add(ai);
                                    linedefactions.Add(actionnumber, ai);
                                    ac.Add(ai);
                                }
                                else
                                {
                                    General.ErrorLogger.Add(ErrorType.Warning, "Duplicate linedef action " + actionnumber + " in game configuration '" + this.Name + "'. with cde.key '" + cde.Key.ToString() + "'. with title '" + cfg.ReadSetting("linedeftypes." + cde.Key.ToString() + "." + actionnumber.ToString(CultureInfo.InvariantCulture) + ".title", "") + "'");
                                }
                            }
                            else
                            {
                                // Failure
                                if (de.Value != null)
                                {
                                    General.ErrorLogger.Add(ErrorType.Warning, "Structure 'linedeftypes' contains invalid types in game configuration '" + this.Name + "'. All types must be expanded structures.");
                                }
                            }
                        }
                    }
                }
            }

            // Sort the actions list
            sortedlinedefactions.Sort();

            // Copy categories to final list
            actioncategories.Clear();
            actioncategories.AddRange(cats.Values);

            // Sort the categories list
            actioncategories.Sort();
        }