Exemplo n.º 1
0
//comment
        private void SetComment(string comment)
        {
            UniFields fields = GetFields();

            if (comment.Length == 0)
            {
                if (fields.ContainsKey("comment"))
                {
                    General.Map.UndoRedo.CreateUndo("Remove comment");
                    fields.BeforeFieldsChange();
                    fields.Remove("comment");
                }
                return;
            }

            //create undo stuff
            General.Map.UndoRedo.CreateUndo("Set comment");
            fields.BeforeFieldsChange();

            if (!fields.ContainsKey("comment"))
            {
                fields.Add("comment", new UniValue((int)UniversalType.String, comment));
            }
            else
            {
                fields["comment"].Value = comment;
            }
        }
Exemplo n.º 2
0
        // Constructor for filter from configuration
        internal ThingsFilter(Configuration cfg, string path)
        {
            // Initialize
            requiredfields  = new List <string>();
            forbiddenfields = new List <string>();
            thingargs       = new int[Thing.NUM_ARGS];
            customfields    = new UniFields();

            // Read settings from config
            name         = cfg.ReadSetting(path + ".name", DEFAULT_NAME);
            categoryname = cfg.ReadSetting(path + ".category", "");
            invert       = cfg.ReadSetting(path + ".invert", false);                           //mxd
            displaymode  = (ThingsFilterDisplayMode)cfg.ReadSetting(path + ".displaymode", 0); //mxd
            thingtype    = cfg.ReadSetting(path + ".type", -1);
            thingangle   = cfg.ReadSetting(path + ".angle", -1);
            thingzheight = cfg.ReadSetting(path + ".zheight", int.MinValue);
            thingaction  = cfg.ReadSetting(path + ".action", -1);
            for (int i = 0; i < Thing.NUM_ARGS; i++)
            {
                thingargs[i] = cfg.ReadSetting(path + ".arg" + i.ToString(CultureInfo.InvariantCulture), -1);
            }
            thingtag = cfg.ReadSetting(path + ".tag", -1);

            // Read flags
            // key is string, value must be boolean which indicates if
            // its a required field (true) or forbidden field (false).
            IDictionary fields = cfg.ReadSetting(path + ".fields", new Hashtable());

            foreach (DictionaryEntry de in fields)
            {
                // Add to the corresponding list
                if ((bool)de.Value)
                {
                    requiredfields.Add(de.Key.ToString());
                }
                else
                {
                    forbiddenfields.Add(de.Key.ToString());
                }
            }

            // Custom fields
            IDictionary fieldvalues = cfg.ReadSetting(path + ".customfieldvalues", new Hashtable());

            foreach (DictionaryEntry fv in fieldvalues)
            {
                int ft = cfg.ReadSetting(path + ".customfieldtypes." + fv.Key, 0);
                customfields.Add(fv.Key.ToString(), new UniValue(ft, fv.Value));
            }

            AdjustForMapFormat();

            // We have no destructor
            GC.SuppressFinalize(this);
        }
Exemplo n.º 3
0
        protected void ApplyCustomFields(UniFields other)
        {
            // Remove custom fields
            string[] keys = new string[other.Keys.Count];
            other.Keys.CopyTo(keys, 0);
            foreach (string key in keys)
            {
                if (!General.Map.FormatInterface.UIFields[elementtype].ContainsKey(key))
                {
                    other.Remove(key);
                }
            }

            // Replace with stored custom fields
            foreach (KeyValuePair <string, UniValue> group in fields)
            {
                other.Add(group.Key, new UniValue(group.Value));
            }
        }
Exemplo n.º 4
0
        public UDMFMapFieldForm()
        {
            InitializeComponent();

            fields = new UniFields();

            if (General.Map.Map.UnidentifiedUDMF != null)
            {
                fieldslist.Setup("map");

                fieldslist.ClearFields();

                foreach (UniversalEntry u in General.Map.Map.UnidentifiedUDMF)
                {
                    if (!(u.Value is UniversalCollection))
                    {
                        int type = (int)UniversalType.Integer;

                        if (u.Value.GetType() == typeof(float))
                        {
                            type = (int)UniversalType.Float;
                        }
                        else if (u.Value.GetType() == typeof(bool))
                        {
                            type = (int)UniversalType.Boolean;
                        }
                        else if (u.Value.GetType() == typeof(string))
                        {
                            type = (int)UniversalType.String;
                        }

                        fields.Add(u.Key, new UniValue(type, u.Value));
                    }
                }
                // Custom fields
                fieldslist.SetValues(fields, true);
            }
        }
Exemplo n.º 5
0
        protected MapElementProperties(UniFields other, MapElementType type)
        {
            // Should we bother?
            if (!General.Map.UDMF)
            {
                return;
            }

            // Copy source fields except the ones controlled by the UI
            fields      = new UniFields();
            uifields    = new UniFields();
            elementtype = type;
            foreach (KeyValuePair <string, UniValue> group in other)
            {
                if (General.Map.FormatInterface.UIFields[elementtype].ContainsKey(group.Key))
                {
                    uifields.Add(group.Key, new UniValue(group.Value));
                }
                else
                {
                    fields.Add(group.Key, new UniValue(group.Value));
                }
            }
        }