From ec964e9db0712da9916decf6ea087ce3ae2725f4 Mon Sep 17 00:00:00 2001 From: MaxED <j.maxed@gmail.com> Date: Sat, 14 Feb 2015 18:15:11 +0000 Subject: [PATCH] Sector Edit form, UDMF: it was impossible to remove a sound sequence if it was set previously. Error Check form: number of selected items is now shown in the window's title. Error Check form: fixed slowdowns when trying to select many (like 1000) results at once. --- .../Windows/SectorEditFormUDMF.Designer.cs | 36 +++++++++++++----- Source/Core/Windows/SectorEditFormUDMF.cs | 34 ++++++++++++++--- .../BuilderModes/Interface/ErrorCheckForm.cs | 37 +++++++++++++++---- 3 files changed, 84 insertions(+), 23 deletions(-) diff --git a/Source/Core/Windows/SectorEditFormUDMF.Designer.cs b/Source/Core/Windows/SectorEditFormUDMF.Designer.cs index 2649c77e4..52da7b866 100644 --- a/Source/Core/Windows/SectorEditFormUDMF.Designer.cs +++ b/Source/Core/Windows/SectorEditFormUDMF.Designer.cs @@ -41,11 +41,12 @@ System.Windows.Forms.Label label6; System.Windows.Forms.Label label5; this.tagSelector = new CodeImp.DoomBuilder.GZBuilder.Controls.TagSelector(); + this.resetsoundsequence = new System.Windows.Forms.Button(); this.fadeColor = new CodeImp.DoomBuilder.GZBuilder.Controls.ColorFieldsControl(); this.lightColor = new CodeImp.DoomBuilder.GZBuilder.Controls.ColorFieldsControl(); this.brightness = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox(); this.desaturation = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox(); - this.soundSequence = new System.Windows.Forms.TextBox(); + this.soundsequence = new System.Windows.Forms.TextBox(); this.gravity = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox(); this.browseeffect = new System.Windows.Forms.Button(); this.effect = new CodeImp.DoomBuilder.Controls.ActionSelectorControl(); @@ -152,6 +153,7 @@ // groupeffect.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); + groupeffect.Controls.Add(this.resetsoundsequence); groupeffect.Controls.Add(this.fadeColor); groupeffect.Controls.Add(this.lightColor); groupeffect.Controls.Add(this.brightness); @@ -159,7 +161,7 @@ groupeffect.Controls.Add(label14); groupeffect.Controls.Add(label9); groupeffect.Controls.Add(label13); - groupeffect.Controls.Add(this.soundSequence); + groupeffect.Controls.Add(this.soundsequence); groupeffect.Controls.Add(this.gravity); groupeffect.Controls.Add(label2); groupeffect.Controls.Add(this.browseeffect); @@ -172,6 +174,17 @@ groupeffect.TabStop = false; groupeffect.Text = " Effects "; // + // resetsoundsequence + // + this.resetsoundsequence.Image = global::CodeImp.DoomBuilder.Properties.Resources.Reset; + this.resetsoundsequence.Location = new System.Drawing.Point(456, 52); + this.resetsoundsequence.Name = "resetsoundsequence"; + this.resetsoundsequence.Size = new System.Drawing.Size(28, 25); + this.resetsoundsequence.TabIndex = 31; + this.resetsoundsequence.Text = " "; + this.resetsoundsequence.UseVisualStyleBackColor = true; + this.resetsoundsequence.Click += new System.EventHandler(this.resetsoundsequence_Click); + // // fadeColor // this.fadeColor.DefaultValue = 0; @@ -250,12 +263,14 @@ label13.Text = "Desaturation:"; label13.TextAlign = System.Drawing.ContentAlignment.TopRight; // - // soundSequence + // soundsequence // - this.soundSequence.Location = new System.Drawing.Point(125, 55); - this.soundSequence.Name = "soundSequence"; - this.soundSequence.Size = new System.Drawing.Size(325, 20); - this.soundSequence.TabIndex = 2; + this.soundsequence.Location = new System.Drawing.Point(125, 55); + this.soundsequence.Name = "soundsequence"; + this.soundsequence.Size = new System.Drawing.Size(325, 20); + this.soundsequence.TabIndex = 2; + this.soundsequence.TextChanged += new System.EventHandler(this.soundsequence_TextChanged); + this.soundsequence.MouseDown += new System.Windows.Forms.MouseEventHandler(this.soundsequence_MouseDown); // // gravity // @@ -551,7 +566,7 @@ // // floorAngleControl // - this.floorAngleControl.Angle = -720; + this.floorAngleControl.Angle = 0; this.floorAngleControl.AngleOffset = 90; this.floorAngleControl.Location = new System.Drawing.Point(6, 132); this.floorAngleControl.Name = "floorAngleControl"; @@ -770,7 +785,7 @@ // // ceilAngleControl // - this.ceilAngleControl.Angle = -720; + this.ceilAngleControl.Angle = 0; this.ceilAngleControl.AngleOffset = 90; this.ceilAngleControl.Location = new System.Drawing.Point(6, 132); this.ceilAngleControl.Name = "ceilAngleControl"; @@ -1137,7 +1152,7 @@ private System.Windows.Forms.GroupBox groupBox3; private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox gravity; private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox desaturation; - private System.Windows.Forms.TextBox soundSequence; + private System.Windows.Forms.TextBox soundsequence; private CodeImp.DoomBuilder.GZBuilder.Controls.ColorFieldsControl fadeColor; private CodeImp.DoomBuilder.GZBuilder.Controls.ColorFieldsControl lightColor; private CodeImp.DoomBuilder.Controls.CheckboxArrayControl flags; @@ -1154,5 +1169,6 @@ private System.Windows.Forms.Label labelFloorScale; private System.Windows.Forms.Label labelCeilOffsets; private System.Windows.Forms.Label labelCeilScale; + private System.Windows.Forms.Button resetsoundsequence; } } \ No newline at end of file diff --git a/Source/Core/Windows/SectorEditFormUDMF.cs b/Source/Core/Windows/SectorEditFormUDMF.cs index cbde492fb..5bcde461a 100644 --- a/Source/Core/Windows/SectorEditFormUDMF.cs +++ b/Source/Core/Windows/SectorEditFormUDMF.cs @@ -22,6 +22,12 @@ namespace CodeImp.DoomBuilder.Windows #endregion + #region ================== Constants + + private const string NO_SOUND_SEQUENCE = "None"; //mxd + + #endregion + #region ================== Variables private ICollection<Sector> sectors; @@ -300,7 +306,7 @@ namespace CodeImp.DoomBuilder.Windows floorRenderStyle.SelectedIndex = Array.IndexOf(renderstyles, sc.Fields.GetValue("renderstylefloor", "translucent")); //Misc - soundSequence.Text = sc.Fields.GetValue("soundsequence", string.Empty); + soundsequence.Text = sc.Fields.GetValue("soundsequence", NO_SOUND_SEQUENCE); gravity.Text = sc.Fields.GetValue("gravity", 1.0f).ToString(); desaturation.Text = General.Clamp(sc.Fields.GetValue("desaturation", 0.0f), 0f, 1f).ToString(); @@ -404,7 +410,7 @@ namespace CodeImp.DoomBuilder.Windows floorRenderStyle.SelectedIndex = -1; //Misc - if(s.Fields.GetValue("soundsequence", string.Empty) != soundSequence.Text) soundSequence.Text = ""; + if(s.Fields.GetValue("soundsequence", NO_SOUND_SEQUENCE) != soundsequence.Text) soundsequence.Text = ""; if(s.Fields.GetValue("gravity", 1.0f).ToString() != gravity.Text) gravity.Text = ""; if(s.Fields.GetValue("desaturation", 0.0f).ToString() != desaturation.Text) desaturation.Text = ""; @@ -667,11 +673,11 @@ namespace CodeImp.DoomBuilder.Windows } // Misc - if(soundSequence.Text != "") - s.Fields["soundsequence"] = new UniValue(UniversalType.String, soundSequence.Text); - if(gravity.Text != "") + if(!string.IsNullOrEmpty(soundsequence.Text)) + UDMFTools.SetString(s.Fields, "soundsequence", soundsequence.Text, NO_SOUND_SEQUENCE); + if(!string.IsNullOrEmpty(gravity.Text)) UDMFTools.SetFloat(s.Fields, "gravity", gravity.GetResultFloat(s.Fields.GetValue("gravity", 1.0f)), 1.0f); - if(desaturation.Text != "") + if(!string.IsNullOrEmpty(desaturation.Text)) { float val = General.Clamp(desaturation.GetResultFloat(s.Fields.GetValue("desaturation", 0f)), 0f, 1f); UDMFTools.SetFloat(s.Fields, "desaturation", val, 0f); @@ -765,6 +771,22 @@ namespace CodeImp.DoomBuilder.Windows floorRotation.StepValues = (cbUseFloorLineAngles.Checked ? anglesteps : null); } + private void resetsoundsequence_Click(object sender, EventArgs e) + { + soundsequence.Text = NO_SOUND_SEQUENCE; + } + + private void soundsequence_TextChanged(object sender, EventArgs e) + { + soundsequence.ForeColor = (soundsequence.Text == NO_SOUND_SEQUENCE ? SystemColors.GrayText : SystemColors.WindowText); + resetsoundsequence.Enabled = (soundsequence.Text != NO_SOUND_SEQUENCE); + } + + private void soundsequence_MouseDown(object sender, MouseEventArgs e) + { + if(soundsequence.Text == NO_SOUND_SEQUENCE) soundsequence.SelectAll(); + } + #endregion #region ================== Sector Realtime events (mxd) diff --git a/Source/Plugins/BuilderModes/Interface/ErrorCheckForm.cs b/Source/Plugins/BuilderModes/Interface/ErrorCheckForm.cs index cbffe1902..0de0aaeeb 100644 --- a/Source/Plugins/BuilderModes/Interface/ErrorCheckForm.cs +++ b/Source/Plugins/BuilderModes/Interface/ErrorCheckForm.cs @@ -54,6 +54,7 @@ namespace CodeImp.DoomBuilder.BuilderModes private Size initialsize; //mxd private List<ErrorResult> resultslist; //mxd private List<Type> hiddentresulttypes; //mxd + private bool bathselectioninprogress; //mxd #endregion @@ -183,8 +184,10 @@ namespace CodeImp.DoomBuilder.BuilderModes private void UpdateTitle() { int hiddencount = resultslist.Count - results.Items.Count; - this.Text = "Map Analysis [" + resultslist.Count + " results" - + (hiddencount > 0 ? ", " + hiddencount + " are hidden]" : "]"); //mxd + string title = "Map Analysis [" + resultslist.Count + " results"; + if(hiddencount > 0) title += hiddencount + " hidden"; + title += ", " + results.SelectedItems.Count + " selected"; + this.Text = title + @"]"; } // This stops checking (only called from the checking management thread) @@ -204,13 +207,13 @@ namespace CodeImp.DoomBuilder.BuilderModes running = false; blockmap.Dispose(); blockmap = null; - UpdateTitle(); //mxd // When no results found, show "no results" and disable the list if(resultslist.Count == 0) { results.Items.Add(new ResultNoErrors()); results.Enabled = false; + UpdateTitle(); //mxd } else { @@ -297,6 +300,8 @@ namespace CodeImp.DoomBuilder.BuilderModes fix1.Visible = false; fix2.Visible = false; fix3.Visible = false; + + UpdateTitle(); //mxd } // This runs in a seperate thread to manage the checking threads @@ -458,6 +463,9 @@ namespace CodeImp.DoomBuilder.BuilderModes // Results selection changed private void results_SelectedIndexChanged(object sender, EventArgs e) { + //mxd + if(bathselectioninprogress) return; + // Anything selected? if(results.SelectedItems.Count > 0) { @@ -519,6 +527,8 @@ namespace CodeImp.DoomBuilder.BuilderModes editmode.CenterOnArea(zoomarea, 0.6f); } } + + UpdateTitle(); //mxd } else { @@ -660,7 +670,6 @@ namespace CodeImp.DoomBuilder.BuilderModes hiddentresulttypes.Clear(); // Do the obvious - UpdateTitle(); ClearSelectedResult(); } @@ -677,10 +686,11 @@ namespace CodeImp.DoomBuilder.BuilderModes } // Remove from the list + results.BeginUpdate(); foreach (ErrorResult r in tohide) results.Items.Remove(r); + results.EndUpdate(); // Do the obvious - UpdateTitle(); ClearSelectedResult(); } @@ -701,7 +711,6 @@ namespace CodeImp.DoomBuilder.BuilderModes results.Items.AddRange(filtered.ToArray()); // Do the obvious - UpdateTitle(); ClearSelectedResult(); } @@ -730,7 +739,6 @@ namespace CodeImp.DoomBuilder.BuilderModes results.Items.AddRange(filtered.ToArray()); // Do the obvious - UpdateTitle(); ClearSelectedResult(); } @@ -758,7 +766,14 @@ namespace CodeImp.DoomBuilder.BuilderModes else if(e.Control && e.KeyCode == Keys.A) { results.SelectedItems.Clear(); + + bathselectioninprogress = true; //mxd + results.BeginUpdate(); //mxd for(int i = 0; i < results.Items.Count; i++) results.SelectedItems.Add(results.Items[i]); + results.EndUpdate(); //mxd + bathselectioninprogress = false; //mxd + + results_SelectedIndexChanged(this, EventArgs.Empty); //trigger update manually } } @@ -767,10 +782,18 @@ namespace CodeImp.DoomBuilder.BuilderModes Dictionary<Type, bool> toselect = GetSelectedTypes(); results.SelectedItems.Clear(); + bathselectioninprogress = true; //mxd + results.BeginUpdate(); //mxd + for(int i = 0; i < results.Items.Count; i++) { if(toselect.ContainsKey(results.Items[i].GetType())) results.SelectedItems.Add(results.Items[i]); } + + results.EndUpdate(); //mxd + bathselectioninprogress = false; //mxd + + results_SelectedIndexChanged(this, EventArgs.Empty); //trigger update manually } #endregion -- GitLab