From bd56f1db223f66f22e0adce0b8dab64b2da3ac16 Mon Sep 17 00:00:00 2001 From: MaxED Date: Sun, 7 Feb 2016 23:04:20 +0000 Subject: [PATCH] Fixed, Sector Edit window, UDMF: sector brightness was applied twice. Fixed, Tags selector, UDMF: tags from sector with the longest array of tags was applied to sectors with shorter arrays of tags. Fixed, Draw Settings panel: sidedef texture overrides were not applied when "Auto-clear sidedef textures" setting was enabled. Added, Thing Edit window, UDMF: added "Show user-added custom fields only" checkbox. --- Source/Core/Controls/FieldsEditorControl.cs | 27 ++++++++++++++++--- .../Core/GZBuilder/Controls/TagsSelector.cs | 19 ++++++++----- Source/Core/Geometry/Tools.cs | 8 +++--- Source/Core/Windows/SectorEditFormUDMF.cs | 1 - .../Windows/ThingEditFormUDMF.Designer.cs | 18 ++++++++++++- Source/Core/Windows/ThingEditFormUDMF.cs | 9 +++++++ 6 files changed, 66 insertions(+), 16 deletions(-) diff --git a/Source/Core/Controls/FieldsEditorControl.cs b/Source/Core/Controls/FieldsEditorControl.cs index dc30a721..bf9f0cc6 100644 --- a/Source/Core/Controls/FieldsEditorControl.cs +++ b/Source/Core/Controls/FieldsEditorControl.cs @@ -61,6 +61,7 @@ namespace CodeImp.DoomBuilder.Controls private string lasteditfieldname; private bool autoinsertuserprefix; private Dictionary uifields;//mxd + private bool showfixedfields = true; //mxd #endregion @@ -73,7 +74,8 @@ namespace CodeImp.DoomBuilder.Controls public bool PropertyColumnVisible { get { return fieldname.Visible; } set { fieldname.Visible = value; UpdateValueColumn(); UpdateBrowseButton(); } } public bool TypeColumnVisible { get { return fieldtype.Visible; } set { fieldtype.Visible = value; UpdateValueColumn(); UpdateBrowseButton(); } } public bool ValueColumnVisible { get { return fieldvalue.Visible; } set { fieldvalue.Visible = value; UpdateValueColumn(); UpdateBrowseButton(); } } - + public bool ShowFixedFields {get { return showfixedfields; } set { showfixedfields = value; UpdateFixedFieldsVisibility(); } } //mxd + #endregion #region ================== Constructor @@ -96,7 +98,7 @@ namespace CodeImp.DoomBuilder.Controls // Keep element name this.elementname = elementname; - //mxd. get proper UIFields + //mxd. Get proper UIFields uifields = General.Map.FormatInterface.UIFields[General.Map.FormatInterface.GetElementType(elementname)]; // Make types list @@ -640,9 +642,16 @@ namespace CodeImp.DoomBuilder.Controls for(int i = fieldslist.Rows.Count - 1; i >= 0; i--) { if(fieldslist.Rows[i].ReadOnly) - try { fieldslist.Rows.RemoveAt(i); } catch(Exception) { } + { + try { fieldslist.Rows.RemoveAt(i); } catch { } + } else - fieldslist.Rows[i].Visible = true; + { + //mxd. Preserve fixed fields visibility setting + FieldsEditorRow frow = (fieldslist.Rows[i] as FieldsEditorRow); + if(frow != null && frow.IsFixed) frow.Visible = showfixedfields; + else fieldslist.Rows[i].Visible = true; + } } // Update new row @@ -831,6 +840,16 @@ namespace CodeImp.DoomBuilder.Controls HideBrowseButton(); } } + + //mxd + private void UpdateFixedFieldsVisibility() + { + foreach(var row in fieldslist.Rows) + { + FieldsEditorRow frow = (row as FieldsEditorRow); + if(frow != null && frow.IsFixed) frow.Visible = showfixedfields; + } + } #endregion } diff --git a/Source/Core/GZBuilder/Controls/TagsSelector.cs b/Source/Core/GZBuilder/Controls/TagsSelector.cs index d3d137b0..407d5b4c 100644 --- a/Source/Core/GZBuilder/Controls/TagsSelector.cs +++ b/Source/Core/GZBuilder/Controls/TagsSelector.cs @@ -126,7 +126,7 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls { if(first) { - foreach(int tag in newtags) tags.Add(tag); + tags.AddRange(newtags); return; } @@ -137,6 +137,13 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls else if(i >= tags.Count) tags.Add(int.MinValue); } + + // If current tags list is shorter than out tags list, mark the rest of our list as mixed + if(newtags.Count < tags.Count) + { + for(int i = newtags.Count; i < tags.Count; i++) + tags[i] = int.MinValue; + } } #endregion @@ -161,13 +168,13 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls private IEnumerable GetResultTags(int[] oldtags, int offset) { - Dictionary newtags = new Dictionary(); + HashSet newtags = new HashSet(); for(int i = 0; i < tags.Count; i++) { if(tags[i] == int.MinValue && oldtags.Length > i) { - if(!newtags.ContainsKey(oldtags[i])) newtags.Add(oldtags[i], false); + if(oldtags[i] != 0 && !newtags.Contains(oldtags[i])) newtags.Add(oldtags[i]); } else if(tags[i] != 0 && tags[i] != int.MinValue) { @@ -179,12 +186,12 @@ namespace CodeImp.DoomBuilder.GZBuilder.Controls else tag = tags[i]; - if(!newtags.ContainsKey(tag)) newtags.Add(tag, false); + if(!newtags.Contains(tag)) newtags.Add(tag); } } - if(newtags.Count == 0) newtags.Add(0, false); - return newtags.Keys; + if(newtags.Count == 0) newtags.Add(0); + return newtags; } #endregion diff --git a/Source/Core/Geometry/Tools.cs b/Source/Core/Geometry/Tools.cs index 7a3f8591..4114ed62 100644 --- a/Source/Core/Geometry/Tools.cs +++ b/Source/Core/Geometry/Tools.cs @@ -743,9 +743,9 @@ namespace CodeImp.DoomBuilder.Geometry //mxd. This applies overrides to a sidedef private static void ApplyOverridesToSidedef(Sidedef sd) { - if(General.Map.Options.OverrideTopTexture) sd.SetTextureHigh(General.Map.Options.DefaultTopTexture); + if(sd.HighRequired() && General.Map.Options.OverrideTopTexture) sd.SetTextureHigh(General.Map.Options.DefaultTopTexture); if(sd.MiddleRequired() && General.Map.Options.OverrideMiddleTexture) sd.SetTextureMid(General.Map.Options.DefaultWallTexture); - if(General.Map.Options.OverrideBottomTexture) sd.SetTextureLow(General.Map.Options.DefaultBottomTexture); + if(sd.LowRequired() && General.Map.Options.OverrideBottomTexture) sd.SetTextureLow(General.Map.Options.DefaultBottomTexture); } #endregion @@ -1467,9 +1467,9 @@ namespace CodeImp.DoomBuilder.Geometry } //mxd. Apply texture overrides - if(useOverrides && !General.Settings.AutoClearSidedefTextures) + if(useOverrides) { - //if new sectors are created, apply overrides to the sides of these sectors, otherwise, apply overrides to all new lines + // If new sectors are created, apply overrides to the sides of these sectors, otherwise, apply overrides to all new lines if(insidesides.Count > 0) { foreach(Sidedef side in insidesides) ApplyOverridesToSidedef(side); diff --git a/Source/Core/Windows/SectorEditFormUDMF.cs b/Source/Core/Windows/SectorEditFormUDMF.cs index 149673ac..01499109 100644 --- a/Source/Core/Windows/SectorEditFormUDMF.cs +++ b/Source/Core/Windows/SectorEditFormUDMF.cs @@ -679,7 +679,6 @@ namespace CodeImp.DoomBuilder.Windows // Effects if(!effect.Empty) s.Effect = effect.Value; - s.Brightness = General.Clamp(brightness.GetResult(s.Brightness), General.Map.FormatInterface.MinBrightness, General.Map.FormatInterface.MaxBrightness); //mxd. Tag tagsselector.ApplyTo(s, tagoffset++); diff --git a/Source/Core/Windows/ThingEditFormUDMF.Designer.cs b/Source/Core/Windows/ThingEditFormUDMF.Designer.cs index 80697dea..7aeef675 100644 --- a/Source/Core/Windows/ThingEditFormUDMF.Designer.cs +++ b/Source/Core/Windows/ThingEditFormUDMF.Designer.cs @@ -91,6 +91,7 @@ this.tabcomment = new System.Windows.Forms.TabPage(); this.commenteditor = new CodeImp.DoomBuilder.Controls.CommentEditor(); this.tabcustom = new System.Windows.Forms.TabPage(); + this.hidefixedfields = new System.Windows.Forms.CheckBox(); this.fieldslist = new CodeImp.DoomBuilder.Controls.FieldsEditorControl(); this.cancel = new System.Windows.Forms.Button(); this.apply = new System.Windows.Forms.Button(); @@ -881,6 +882,7 @@ // // tabcustom // + this.tabcustom.Controls.Add(this.hidefixedfields); this.tabcustom.Controls.Add(this.fieldslist); this.tabcustom.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.tabcustom.Location = new System.Drawing.Point(4, 22); @@ -891,6 +893,17 @@ this.tabcustom.UseVisualStyleBackColor = true; this.tabcustom.MouseEnter += new System.EventHandler(this.tabcustom_MouseEnter); // + // hidefixedfields + // + this.hidefixedfields.AutoSize = true; + this.hidefixedfields.Location = new System.Drawing.Point(10, 381); + this.hidefixedfields.Name = "hidefixedfields"; + this.hidefixedfields.Size = new System.Drawing.Size(195, 17); + this.hidefixedfields.TabIndex = 2; + this.hidefixedfields.Text = "Show user-added custom fields only"; + this.hidefixedfields.UseVisualStyleBackColor = true; + this.hidefixedfields.CheckedChanged += new System.EventHandler(this.hidefixedfields_CheckedChanged); + // // fieldslist // this.fieldslist.AllowInsert = true; @@ -904,7 +917,8 @@ this.fieldslist.Name = "fieldslist"; this.fieldslist.PropertyColumnVisible = true; this.fieldslist.PropertyColumnWidth = 150; - this.fieldslist.Size = new System.Drawing.Size(611, 389); + this.fieldslist.ShowFixedFields = true; + this.fieldslist.Size = new System.Drawing.Size(611, 368); this.fieldslist.TabIndex = 1; this.fieldslist.TypeColumnVisible = true; this.fieldslist.TypeColumnWidth = 100; @@ -1006,6 +1020,7 @@ this.grouptag.ResumeLayout(false); this.tabcomment.ResumeLayout(false); this.tabcustom.ResumeLayout(false); + this.tabcustom.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.hint)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -1082,5 +1097,6 @@ private CodeImp.DoomBuilder.Controls.ArgumentsControl argscontrol; private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox floatbobphase; private System.Windows.Forms.Label label1; + private System.Windows.Forms.CheckBox hidefixedfields; } } \ No newline at end of file diff --git a/Source/Core/Windows/ThingEditFormUDMF.cs b/Source/Core/Windows/ThingEditFormUDMF.cs index 82c8a8a3..d5b710e7 100644 --- a/Source/Core/Windows/ThingEditFormUDMF.cs +++ b/Source/Core/Windows/ThingEditFormUDMF.cs @@ -131,6 +131,9 @@ namespace CodeImp.DoomBuilder.Windows // Fill universal fields list fieldslist.ListFixedFields(General.Map.Config.ThingFields); + //mxd. Show fixed fields? + hidefixedfields.Checked = !General.Settings.ReadSetting("customfieldsshowfixed", true); + // Thing height? posZ.Visible = General.Map.FormatInterface.HasThingHeight; zlabel.Visible = General.Map.FormatInterface.HasThingHeight; @@ -578,6 +581,7 @@ namespace CodeImp.DoomBuilder.Windows { location = this.Location; activetab = tabs.SelectedIndex; + General.Settings.WriteSetting("customfieldsshowfixed", !hidefixedfields.Checked); } // Help @@ -867,6 +871,11 @@ namespace CodeImp.DoomBuilder.Windows if(OnValuesChanged != null) OnValuesChanged(this, EventArgs.Empty); } + private void hidefixedfields_CheckedChanged(object sender, EventArgs e) + { + fieldslist.ShowFixedFields = !hidefixedfields.Checked; + } + #endregion }