// This loads the enumerations
        private void LoadEnums()
        {
            // Get enums list
            IDictionary dic = cfg.ReadSetting("enums", new Hashtable());

            foreach (DictionaryEntry de in dic)
            {
                // Make new enum
                EnumList list = new EnumList(de.Key.ToString(), cfg);
                enums.Add(de.Key.ToString(), list);
            }
        }
예제 #2
0
        // Constructor for property info from configuration
        internal PropertyInfo(Configuration cfg, string propertypath, PropertyType defaultpropertytype, IDictionary <string, EnumList> enums)
        {
            // Read
            this.used = cfg.SettingExists(propertypath);
            if (!this.used)
            {
                this.title          = DEFAULT_TITLE;
                this.type           = defaultpropertytype;
                this.enumlist       = new EnumList();
                this.channeltargets = new HashSet <int>();
                return;
            }

            this.title   = cfg.ReadSetting(propertypath + "title", DEFAULT_TITLE);
            this.tooltip = cfg.ReadSetting(propertypath + "tooltip", string.Empty);

            string typestr = cfg.ReadSetting(propertypath + "type", "Integer");

            this.type = General.Types.PropertyTypeFromName(typestr);
            if (this.type == PropertyType.Unknown)
            {
                General.ErrorLogger.Add(ErrorType.Warning, "\"" + propertypath + ".type\" references unknown property type \"" + typestr + "\"");
                this.type = PropertyType.Integer;
            }

            // Determine enum type
            IDictionary argdic = cfg.ReadSetting(propertypath, new Hashtable());

            if (argdic.Contains("enum"))
            {
                // Enum fully specified?
                if (argdic["enum"] is IDictionary)
                {
                    // Create anonymous enum
                    this.enumlist = new EnumList(argdic["enum"] as IDictionary);
                }
                else
                {
                    // Check if referenced enum exists
                    string enumname = argdic["enum"].ToString();
                    if ((enumname.Length > 0) && enums.ContainsKey(enumname))
                    {
                        // Get the enum list
                        this.enumlist = enums[enumname];
                    }
                    else
                    {
                        General.ErrorLogger.Add(ErrorType.Warning, "\"" + propertypath + ".enum\" references unknown enumeration \"" + enumname + "\"");
                    }
                }
            }

            // Read channeltargets
            string targetsstr = cfg.ReadSetting(propertypath + "channeltargets", string.Empty);

            if (!string.IsNullOrEmpty(targetsstr) && !General.GetNumbersFromString(targetsstr, channeltargets))
            {
                General.ErrorLogger.Add(ErrorType.Warning, "Unable to get Channel target from string \"" + targetsstr + "\" while parsing \"" + propertypath + ".channeltargets\"");
            }

            //mxd
            if (this.enumlist == null)
            {
                this.enumlist = new EnumList();
            }
        }
        // Constructor
        internal GameConfiguration(Configuration cfg)
        {
            // Initialize
            this.cfg                = cfg;
            this.spriteflags        = new Dictionary <string, string>();
            this.sortedspriteflags  = new List <int>();
            this.defaultspriteflags = new List <string>();
            this.thingcategories    = new List <SpriteCategory>();
            this.things             = new Dictionary <int, SpriteInfo>();
            this.wallflags          = new Dictionary <string, string>();
            this.sortedwallflags    = new List <int>();
            this.sectorflags        = new Dictionary <string, string>();
            this.sortedsectorflags  = new List <int>();
            this.sectoreffects      = new Dictionary <int, SectorEffectInfo>();
            this.sectoreffectslist  = new EnumList();
            this.paletteslist       = new EnumList();
            this.skills             = new List <SkillInfo>();
            this.imagesets          = new List <DefinedImageSet>();
            this.thingfilters       = new List <ThingsFilter>();
            this.enums              = new Dictionary <string, EnumList>(StringComparer.Ordinal);

            // Read general settings
            configname           = cfg.ReadSetting("name", "<unnamed game>");
            enginename           = cfg.ReadSetting("engine", string.Empty);
            iconfilename         = cfg.ReadSetting("icon", string.Empty);
            formatinterface      = cfg.ReadSetting("formatinterface", string.Empty);
            testparameters       = cfg.ReadSetting("testparameters", string.Empty);
            playerstarttileindex = cfg.ReadSetting("playerstarttileindex", 0);
            nomonstersparam      = cfg.ReadSetting("nomonstersparameter", string.Empty);

            // Default tiles
            defaultwalltile    = cfg.ReadSetting("defaultwalltile", -1);
            defaultceilingtile = cfg.ReadSetting("defaultceilingtile", -1);
            defaultfloortile   = cfg.ReadSetting("defaultfloortile", -1);
            defaultspritetile  = cfg.ReadSetting("defaultspritetile", 1);

            // Default drawing settings
            defaultshade         = cfg.ReadSetting("defaultshade", 0);
            defaultvisibility    = cfg.ReadSetting("defaultvisibility", 0);
            defaultfloorheight   = cfg.ReadSetting("defaultfloorheight", 0);
            defaultceilingheight = cfg.ReadSetting("defaultceilingheight", -16384);
            defaultspriteangle   = Angle2D.DegToRad(cfg.ReadSetting("defaultspriteangle", 0));

            // Skills
            LoadSkills();

            // Enums
            LoadEnums();

            // Palettes
            LoadPalettes();

            // Things
            LoadFlags(spriteflags, sortedspriteflags, "spriteflags");
            LoadSpriteCategories();

            // Walls
            LoadFlags(wallflags, sortedwallflags, "wallflags");

            // Sectors
            LoadFlags(sectorflags, sortedsectorflags, "sectorflags");
            LoadSectorEffects();

            // Defaults
            LoadImageSets();
            LoadSpriteFilters();
        }