Exemplo n.º 1
0
        private static void ApplyFlagsToControl(LinedefColorPreset preset, CheckboxArrayControl target, CheckBox useflags)
        {
            if (preset.Flags.Count == 0 && preset.RestrictedFlags.Count == 0)
            {
                useflags.Checked = false;
                target.Enabled   = false;

                foreach (CheckBox box in target.Checkboxes)
                {
                    box.CheckState = CheckState.Indeterminate;
                }
            }
            else
            {
                useflags.Checked = true;
                target.Enabled   = true;

                foreach (CheckBox box in target.Checkboxes)
                {
                    string flag = box.Tag.ToString();
                    if (preset.Flags.Contains(flag))
                    {
                        box.CheckState = CheckState.Checked;
                    }
                    else if (preset.RestrictedFlags.Contains(flag))
                    {
                        box.CheckState = CheckState.Unchecked;
                    }
                    else
                    {
                        box.CheckState = CheckState.Indeterminate;
                    }
                }
            }
        }
Exemplo n.º 2
0
 private static void ApplyFlagsToPreset(CheckboxArrayControl source, LinedefColorPreset preset)
 {
     if (source.Enabled)
     {
         foreach (CheckBox box in source.Checkboxes)
         {
             ApplyFlagToPreset(box.Tag.ToString(), preset, box.CheckState);
         }
     }
     else
     {
         foreach (CheckBox box in source.Checkboxes)
         {
             string flag = box.Tag.ToString();
             if (preset.Flags.Contains(flag))
             {
                 preset.Flags.Remove(flag);
             }
             if (preset.RestrictedFlags.Contains(flag))
             {
                 preset.RestrictedFlags.Remove(flag);
             }
         }
     }
 }
Exemplo n.º 3
0
 //mxd
 internal void PasteColorPresetsFrom(ConfigurationInfo source)
 {
     linedefColorPresets = new LinedefColorPreset[source.linedefColorPresets.Length];
     for (int i = 0; i < source.linedefColorPresets.Length; i++)
     {
         linedefColorPresets[i] = new LinedefColorPreset(source.linedefColorPresets[i]);
     }
     changed = true;
 }
Exemplo n.º 4
0
        private void apply_Click(object sender, EventArgs e)
        {
            // Replace all presets
            LinedefColorPreset[] newpresets = new LinedefColorPreset[colorpresets.Items.Count];
            for (int i = 0; i < colorpresets.Items.Count; i++)
            {
                newpresets[i] = ((PresetItem)colorpresets.Items[i]).Preset;
            }
            General.Map.ConfigSettings.LinedefColorPresets = newpresets;

            // Update stuff
            General.Map.Map.UpdateCustomLinedefColors();
            General.MainWindow.UpdateLinedefColorPresets();
            General.Map.ConfigSettings.Changed = true;

            // Close
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Exemplo n.º 5
0
        private static void ApplyFlagToPreset(string flag, LinedefColorPreset preset, CheckState state)
        {
            switch (state)
            {
            case CheckState.Checked:
                if (!preset.Flags.Contains(flag))
                {
                    preset.Flags.Add(flag);
                }
                if (preset.RestrictedFlags.Contains(flag))
                {
                    preset.RestrictedFlags.Remove(flag);
                }
                break;

            case CheckState.Unchecked:
                if (preset.Flags.Contains(flag))
                {
                    preset.Flags.Remove(flag);
                }
                if (!preset.RestrictedFlags.Contains(flag))
                {
                    preset.RestrictedFlags.Add(flag);
                }
                break;

            default:
                if (preset.Flags.Contains(flag))
                {
                    preset.Flags.Remove(flag);
                }
                if (preset.RestrictedFlags.Contains(flag))
                {
                    preset.RestrictedFlags.Remove(flag);
                }
                break;
            }
        }
Exemplo n.º 6
0
        //mxd. Not all properties should be pasted
        internal void PasteFrom(ConfigurationInfo source)
        {
            nodebuildersave    = source.nodebuildersave;
            nodebuildertest    = source.nodebuildertest;
            currentEngineIndex = source.currentEngineIndex;
            resources          = new DataLocationList(source.resources);

            testEngines = new List <EngineInfo>();
            foreach (EngineInfo info in source.testEngines)
            {
                testEngines.Add(new EngineInfo(info));
            }
            if (currentEngineIndex >= testEngines.Count)
            {
                currentEngineIndex = Math.Max(0, testEngines.Count - 1);
            }
            linedefColorPresets = new LinedefColorPreset[source.linedefColorPresets.Length];
            for (int i = 0; i < source.linedefColorPresets.Length; i++)
            {
                linedefColorPresets[i] = new LinedefColorPreset(source.linedefColorPresets[i]);
            }

            startmode   = source.startmode;
            changed     = true;
            texturesets = new List <DefinedTextureSet>();
            foreach (DefinedTextureSet s in source.texturesets)
            {
                texturesets.Add(s.Copy());
            }
            thingsfilters = new List <ThingsFilter>();
            foreach (ThingsFilter f in source.thingsfilters)
            {
                thingsfilters.Add(new ThingsFilter(f));
            }
            editmodes = new Dictionary <string, bool>(source.editmodes);
        }
Exemplo n.º 7
0
        // Constructor
        internal ConfigurationInfo(Configuration cfg, string filename)
        {
            // Initialize
            this.filename    = filename;
            this.config      = cfg;        //mxd
            this.settingskey = Path.GetFileNameWithoutExtension(filename).ToLower();

            // Load settings from game configuration
            this.name            = config.ReadSetting("game", "<unnamed game>");
            this.defaultlumpname = config.ReadSetting("defaultlumpname", "");

            // Load settings from program configuration
            this.nodebuildersave       = General.Settings.ReadSetting("configurations." + settingskey + ".nodebuildersave", MISSING_NODEBUILDER);
            this.nodebuildertest       = General.Settings.ReadSetting("configurations." + settingskey + ".nodebuildertest", MISSING_NODEBUILDER);
            this.formatinterface       = config.ReadSetting("formatinterface", "").ToLowerInvariant(); //mxd
            this.defaultscriptcompiler = cfg.ReadSetting("defaultscriptcompiler", "");                 //mxd
            this.resources             = new DataLocationList(General.Settings.Config, "configurations." + settingskey + ".resources");
            this.startmode             = General.Settings.ReadSetting("configurations." + settingskey + ".startmode", "VerticesMode");
            this.enabled = General.Settings.ReadSetting("configurations." + settingskey + ".enabled", config.ReadSetting("enabledbydefault", false));             //mxd

            //mxd. Read test engines
            testEngines = new List <EngineInfo>();
            IDictionary list = General.Settings.ReadSetting("configurations." + settingskey + ".engines", new ListDictionary());

            currentEngineIndex = Math.Max(0, General.Settings.ReadSetting("configurations." + settingskey + ".currentengineindex", 0));

            // No engine list found? Use old engine properties
            if (list.Count == 0)
            {
                EngineInfo info = new EngineInfo();
                info.TestProgram      = General.Settings.ReadSetting("configurations." + settingskey + ".testprogram", "");
                info.TestProgramName  = General.Settings.ReadSetting("configurations." + settingskey + ".testprogramname", EngineInfo.DEFAULT_ENGINE_NAME);
                info.TestParameters   = General.Settings.ReadSetting("configurations." + settingskey + ".testparameters", "");
                info.TestShortPaths   = General.Settings.ReadSetting("configurations." + settingskey + ".testshortpaths", false);
                info.CustomParameters = General.Settings.ReadSetting("configurations." + settingskey + ".customparameters", false);
                info.TestSkill        = General.Settings.ReadSetting("configurations." + settingskey + ".testskill", 3);
                testEngines.Add(info);
                currentEngineIndex = 0;
            }
            else
            {
                //read engines settings from config
                foreach (DictionaryEntry de in list)
                {
                    string     path = "configurations." + settingskey + ".engines." + de.Key;
                    EngineInfo info = new EngineInfo();
                    info.TestProgram      = General.Settings.ReadSetting(path + ".testprogram", "");
                    info.TestProgramName  = General.Settings.ReadSetting(path + ".testprogramname", EngineInfo.DEFAULT_ENGINE_NAME);
                    info.TestParameters   = General.Settings.ReadSetting(path + ".testparameters", "");
                    info.TestShortPaths   = General.Settings.ReadSetting(path + ".testshortpaths", false);
                    info.CustomParameters = General.Settings.ReadSetting(path + ".customparameters", false);
                    info.TestSkill        = General.Settings.ReadSetting(path + ".testskill", 3);
                    testEngines.Add(info);
                }

                if (currentEngineIndex >= testEngines.Count)
                {
                    currentEngineIndex = 0;
                }
            }

            //mxd. read custom linedef colors
            List <LinedefColorPreset> colorPresets = new List <LinedefColorPreset>();

            list = General.Settings.ReadSetting("configurations." + settingskey + ".linedefcolorpresets", new ListDictionary());

            //no presets? add "classic" ones then.
            if (list.Count == 0)
            {
                colorPresets.Add(new LinedefColorPreset("Any action", PixelColor.FromColor(System.Drawing.Color.PaleGreen), -1, 0, new List <string>(), new List <string>(), true));
            }
            else
            {
                //read custom linedef colors from config
                foreach (DictionaryEntry de in list)
                {
                    string        path          = "configurations." + settingskey + ".linedefcolorpresets." + de.Key;
                    string        presetname    = General.Settings.ReadSetting(path + ".name", "Unnamed");
                    bool          presetenabled = General.Settings.ReadSetting(path + ".enabled", true);
                    PixelColor    color         = PixelColor.FromInt(General.Settings.ReadSetting(path + ".color", -1));
                    int           action        = General.Settings.ReadSetting(path + ".action", 0);
                    int           activation    = General.Settings.ReadSetting(path + ".activation", 0);
                    List <string> flags         = new List <string>();
                    flags.AddRange(General.Settings.ReadSetting(path + ".flags", "").Split(LINEDEF_COLOR_PRESET_FLAGS_SEPARATOR, StringSplitOptions.RemoveEmptyEntries));
                    List <string> restrictedFlags = new List <string>();
                    restrictedFlags.AddRange(General.Settings.ReadSetting(path + ".restrictedflags", "").Split(LINEDEF_COLOR_PRESET_FLAGS_SEPARATOR, StringSplitOptions.RemoveEmptyEntries));
                    LinedefColorPreset preset = new LinedefColorPreset(presetname, color, action, activation, flags, restrictedFlags, presetenabled);
                    colorPresets.Add(preset);
                }
            }
            linedefColorPresets = colorPresets.ToArray();

            // Make list of things filters
            thingsfilters = new List <ThingsFilter>();
            IDictionary cfgfilters = General.Settings.ReadSetting("configurations." + settingskey + ".thingsfilters", new Hashtable());

            foreach (DictionaryEntry de in cfgfilters)
            {
                thingsfilters.Add(new ThingsFilter(General.Settings.Config, "configurations." + settingskey + ".thingsfilters." + de.Key));
            }

            // Make list of texture sets
            texturesets = new List <DefinedTextureSet>();
            IDictionary sets = General.Settings.ReadSetting("configurations." + settingskey + ".texturesets", new Hashtable());

            foreach (DictionaryEntry de in sets)
            {
                texturesets.Add(new DefinedTextureSet(General.Settings.Config, "configurations." + settingskey + ".texturesets." + de.Key));
            }

            // Make list of edit modes
            this.editmodes = new Dictionary <string, bool>(StringComparer.Ordinal);
            IDictionary modes = General.Settings.ReadSetting("configurations." + settingskey + ".editmodes", new Hashtable());

            foreach (DictionaryEntry de in modes)
            {
                if (de.Key.ToString().StartsWith(MODE_ENABLED_KEY))
                {
                    editmodes.Add(de.Value.ToString(), true);
                }
                else if (de.Key.ToString().StartsWith(MODE_DISABLED_KEY))
                {
                    editmodes.Add(de.Value.ToString(), false);
                }
            }
        }
Exemplo n.º 8
0
 // Constructor for existing preset
 public PresetItem(LinedefColorPreset preset)
 {
     Preset = new LinedefColorPreset(preset);
     color  = Preset.Color.ToColor();
 }
Exemplo n.º 9
0
 // Constructor for a new preset
 public PresetItem()
 {
     Preset = new LinedefColorPreset(DEFAULT_NAME, General.Colors.BrightColors[General.Random(0, General.Colors.BrightColors.Length - 1)]);
     color  = Preset.Color.ToColor();
 }