some bug fixes and completed the things filter

This commit is contained in:
codeimp 2008-06-03 19:02:06 +00:00
parent c2b5745803
commit 0bc23a5893
13 changed files with 152 additions and 42 deletions

View file

@ -1,5 +1,3 @@
- Complete Things filter with UDMF fields
- Controls to increase/decrease grid size - Controls to increase/decrease grid size
- "Insert Thing" control - "Insert Thing" control

View file

@ -110,9 +110,9 @@ namespace CodeImp.DoomBuilder.Editing
{ {
// Add to the corresponding list // Add to the corresponding list
if((bool)de.Value == true) if((bool)de.Value == true)
requiredfields.Add(de.Value.ToString()); requiredfields.Add(de.Key.ToString());
else else
forbiddenfields.Add(de.Value.ToString()); forbiddenfields.Add(de.Key.ToString());
} }
// We have no destructor // We have no destructor
@ -197,9 +197,18 @@ namespace CodeImp.DoomBuilder.Editing
// Get thing info // Get thing info
ThingTypeInfo ti = General.Map.Config.GetThingInfo(t.Type); ThingTypeInfo ti = General.Map.Config.GetThingInfo(t.Type);
// Check if thing is in unknown category
if(ti.Category == null)
{
// Check if the thing matches id
qualifies = ((t.Type == thingtype) || (thingtype == -1)) && (categoryname.Length == 0);
}
else
{
// Check if the thing matches category and id // Check if the thing matches category and id
qualifies = ((t.Type == thingtype) || (thingtype == -1)) && qualifies = ((t.Type == thingtype) || (thingtype == -1)) &&
((ti.Category.Name == categoryname) || (categoryname.Length == 0)); ((ti.Category.Name == categoryname) || (categoryname.Length == 0));
}
// Still qualifies? // Still qualifies?
if(qualifies) if(qualifies)
@ -207,17 +216,11 @@ namespace CodeImp.DoomBuilder.Editing
// Go for all required fields // Go for all required fields
foreach(string s in requiredfields) foreach(string s in requiredfields)
{ {
if(t.Fields.ContainsKey(s)) if(t.Flags.ContainsKey(s))
{ {
if(t.Fields[s] is bool) qualifies = (t.Flags[s] == true);
{
if((bool)t.Fields[s].Value == false)
{
qualifies = false;
break; break;
} }
}
}
else else
{ {
qualifies = false; qualifies = false;
@ -232,19 +235,13 @@ namespace CodeImp.DoomBuilder.Editing
// Go for all forbidden fields // Go for all forbidden fields
foreach(string s in forbiddenfields) foreach(string s in forbiddenfields)
{ {
if(t.Fields.ContainsKey(s)) if(t.Flags.ContainsKey(s))
{ {
if(t.Fields[s] is bool) qualifies = (t.Flags[s] == false);
{
if((bool)t.Fields[s].Value == true)
{
qualifies = false;
break; break;
} }
} }
} }
}
}
// Put the thing in the correct list // Put the thing in the correct list
if(qualifies) visiblethings.Add(t); else hiddenthings.Add(t); if(qualifies) visiblethings.Add(t); else hiddenthings.Add(t);

View file

@ -497,6 +497,9 @@ namespace CodeImp.DoomBuilder
ReloadResources(); ReloadResources();
} }
// Reset changed status
if(savemode != SAVE_TEST) changed = false;
// Success! // Success!
General.WriteLogLine("Map saving done"); General.WriteLogLine("Map saving done");
return true; return true;

View file

@ -84,6 +84,7 @@ namespace CodeImp.DoomBuilder.Windows
// Hexen map? // Hexen map?
else if(General.Map.IsType(typeof(HexenMapSetIO))) else if(General.Map.IsType(typeof(HexenMapSetIO)))
{ {
tabs.TabPages.Remove(tabcustom);
hexenpanel.Visible = true; hexenpanel.Visible = true;
argspanel.Visible = true; argspanel.Visible = true;
actiongroup.Height = 210; actiongroup.Height = 210;
@ -92,6 +93,7 @@ namespace CodeImp.DoomBuilder.Windows
// Doom map? // Doom map?
else else
{ {
tabs.TabPages.Remove(tabcustom);
actiongroup.Height = 68; actiongroup.Height = 68;
this.Height = 470; this.Height = 470;
} }

View file

@ -110,7 +110,7 @@ namespace CodeImp.DoomBuilder.Windows
groupaction.Size = new System.Drawing.Size(436, 71); groupaction.Size = new System.Drawing.Size(436, 71);
groupaction.TabIndex = 5; groupaction.TabIndex = 5;
groupaction.TabStop = false; groupaction.TabStop = false;
groupaction.Text = " Action "; groupaction.Text = " Identification ";
// //
// tag // tag
// //
@ -395,6 +395,7 @@ namespace CodeImp.DoomBuilder.Windows
| System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.fieldslist.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.fieldslist.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
this.fieldslist.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.fieldslist.Location = new System.Drawing.Point(11, 11); this.fieldslist.Location = new System.Drawing.Point(11, 11);
this.fieldslist.Margin = new System.Windows.Forms.Padding(8); this.fieldslist.Margin = new System.Windows.Forms.Padding(8);
this.fieldslist.Name = "fieldslist"; this.fieldslist.Name = "fieldslist";

View file

@ -55,6 +55,12 @@ namespace CodeImp.DoomBuilder.Windows
floortex.Initialize(); floortex.Initialize();
ceilingtex.Initialize(); ceilingtex.Initialize();
// Not a UDMF map?
if(!General.Map.IsType(typeof(UniversalMapSetIO)))
{
tabs.TabPages.Remove(tabcustom);
}
// Initialize custom fields editor // Initialize custom fields editor
fieldslist.Setup("sector"); fieldslist.Setup("sector");
} }

View file

@ -41,7 +41,8 @@ namespace CodeImp.DoomBuilder.Windows
this.cancel.Margin = new System.Windows.Forms.Padding(1); this.cancel.Margin = new System.Windows.Forms.Padding(1);
this.cancel.Name = "cancel"; this.cancel.Name = "cancel";
this.cancel.Size = new System.Drawing.Size(112, 25); this.cancel.Size = new System.Drawing.Size(112, 25);
this.cancel.TabIndex = 21; this.cancel.TabIndex = 2;
this.cancel.TabStop = false;
this.cancel.Text = "Cancel"; this.cancel.Text = "Cancel";
this.cancel.UseVisualStyleBackColor = true; this.cancel.UseVisualStyleBackColor = true;
this.cancel.Click += new System.EventHandler(this.cancel_Click); this.cancel.Click += new System.EventHandler(this.cancel_Click);
@ -53,7 +54,8 @@ namespace CodeImp.DoomBuilder.Windows
this.apply.Margin = new System.Windows.Forms.Padding(1); this.apply.Margin = new System.Windows.Forms.Padding(1);
this.apply.Name = "apply"; this.apply.Name = "apply";
this.apply.Size = new System.Drawing.Size(112, 25); this.apply.Size = new System.Drawing.Size(112, 25);
this.apply.TabIndex = 20; this.apply.TabIndex = 1;
this.apply.TabStop = false;
this.apply.Text = "OK"; this.apply.Text = "OK";
this.apply.UseVisualStyleBackColor = true; this.apply.UseVisualStyleBackColor = true;
this.apply.Click += new System.EventHandler(this.apply_Click); this.apply.Click += new System.EventHandler(this.apply_Click);
@ -69,7 +71,8 @@ namespace CodeImp.DoomBuilder.Windows
this.textbox.Name = "textbox"; this.textbox.Name = "textbox";
this.textbox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.textbox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.textbox.Size = new System.Drawing.Size(456, 194); this.textbox.Size = new System.Drawing.Size(456, 194);
this.textbox.TabIndex = 22; this.textbox.TabIndex = 0;
this.textbox.TabStop = false;
// //
// TextEditForm // TextEditForm
// //
@ -90,6 +93,7 @@ namespace CodeImp.DoomBuilder.Windows
this.ShowInTaskbar = false; this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Edit Text"; this.Text = "Edit Text";
this.Activated += new System.EventHandler(this.TextEditForm_Activated);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();

View file

@ -71,5 +71,12 @@ namespace CodeImp.DoomBuilder.Windows
this.DialogResult = DialogResult.Cancel; this.DialogResult = DialogResult.Cancel;
this.Close(); this.Close();
} }
// Window activated
private void TextEditForm_Activated(object sender, EventArgs e)
{
// Focus to textbox
textbox.Focus();
}
} }
} }

View file

@ -117,4 +117,16 @@
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="cancel.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="apply.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="textbox.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root> </root>

View file

@ -70,6 +70,12 @@ namespace CodeImp.DoomBuilder.Windows
// Initialize custom fields editor // Initialize custom fields editor
fieldslist.Setup("thing"); fieldslist.Setup("thing");
// Not a UDMF map?
if(!General.Map.IsType(typeof(UniversalMapSetIO)))
{
tabs.TabPages.Remove(tabcustom);
}
// Go for all predefined categories // Go for all predefined categories
typelist.Nodes.Clear(); typelist.Nodes.Clear();
nodes = new List<TreeNode>(); nodes = new List<TreeNode>();

View file

@ -117,7 +117,7 @@ namespace CodeImp.DoomBuilder.Windows
this.filterfields.Columns = 2; this.filterfields.Columns = 2;
this.filterfields.Location = new System.Drawing.Point(18, 125); this.filterfields.Location = new System.Drawing.Point(18, 125);
this.filterfields.Name = "filterfields"; this.filterfields.Name = "filterfields";
this.filterfields.Size = new System.Drawing.Size(350, 198); this.filterfields.Size = new System.Drawing.Size(329, 198);
this.filterfields.TabIndex = 5; this.filterfields.TabIndex = 5;
// //
// label3 // label3

View file

@ -37,20 +37,33 @@ namespace CodeImp.DoomBuilder.Windows
{ {
public partial class ThingsFiltersForm : DelayedForm public partial class ThingsFiltersForm : DelayedForm
{ {
#region ================== Variables
private bool settingup;
#endregion
#region ================== Constructor #region ================== Constructor
// Constructor // Constructor
public ThingsFiltersForm() public ThingsFiltersForm()
{ {
settingup = true;
// Initialize // Initialize
InitializeComponent(); InitializeComponent();
// Fill the categories combobox // Fill the categories combobox
filtercategory.Items.Add("(any category)");
filtercategory.Items.AddRange(General.Map.Config.ThingCategories.ToArray()); filtercategory.Items.AddRange(General.Map.Config.ThingCategories.ToArray());
// Fill checkboxes list // Fill checkboxes list
// TODO: When UDMF is implemented foreach(KeyValuePair<string, string> flag in General.Map.Config.ThingFlags)
filterfields.Add("TODO: When UDMF is implemented!", null); {
CheckBox box = filterfields.Add(flag.Value, flag.Key);
box.ThreeState = true;
box.CheckStateChanged += new EventHandler(filterfield_Check);
}
// Fill list of filters // Fill list of filters
foreach(ThingsFilter f in General.Map.ConfigSettings.ThingsFilters) foreach(ThingsFilter f in General.Map.ConfigSettings.ThingsFilters)
@ -69,6 +82,9 @@ namespace CodeImp.DoomBuilder.Windows
// Sort the list // Sort the list
listfilters.Sort(); listfilters.Sort();
// Done
settingup = false;
} }
#endregion #endregion
@ -137,13 +153,38 @@ namespace CodeImp.DoomBuilder.Windows
ThingsFilter f = listfilters.SelectedItems[0].Tag as ThingsFilter; ThingsFilter f = listfilters.SelectedItems[0].Tag as ThingsFilter;
// Enable settings // Enable settings
settingup = true;
deletefilter.Enabled = true; deletefilter.Enabled = true;
filtergroup.Enabled = true; filtergroup.Enabled = true;
// Show settings // Show name
filtername.Text = f.Name; filtername.Text = f.Name;
// Show category
foreach(ThingCategory c in filtercategory.Items) foreach(ThingCategory c in filtercategory.Items)
if(c.Name == f.CategoryName) filtercategory.SelectedItem = c; if(c.Name == f.CategoryName) filtercategory.SelectedItem = c;
// Show fields
foreach(CheckBox b in filterfields.Checkboxes)
{
// Field name forbidden?
if(f.ForbiddenFields.Contains(b.Tag.ToString()))
{
b.CheckState = CheckState.Unchecked;
}
// Field name required?
else if(f.RequiredFields.Contains(b.Tag.ToString()))
{
b.CheckState = CheckState.Checked;
}
else
{
b.CheckState = CheckState.Indeterminate;
}
}
// Done
settingup = false;
} }
else else
{ {
@ -169,11 +210,14 @@ namespace CodeImp.DoomBuilder.Windows
// Get selected filter // Get selected filter
ThingsFilter f = listfilters.SelectedItems[0].Tag as ThingsFilter; ThingsFilter f = listfilters.SelectedItems[0].Tag as ThingsFilter;
// Category selected
if((filtercategory.SelectedIndex > -1) && (filtercategory.SelectedItem is ThingCategory))
{
// Set new category name // Set new category name
if(filtercategory.SelectedIndex > -1)
f.CategoryName = (filtercategory.SelectedItem as ThingCategory).Name; f.CategoryName = (filtercategory.SelectedItem as ThingCategory).Name;
} }
} }
}
// Rename filter // Rename filter
private void filtername_Validating(object sender, CancelEventArgs e) private void filtername_Validating(object sender, CancelEventArgs e)
@ -195,6 +239,42 @@ namespace CodeImp.DoomBuilder.Windows
} }
} }
// Field clicked
private void filterfield_Check(object sender, EventArgs e)
{
// Get the checkbox
CheckBox box = (sender as CheckBox);
// Not setting up?
if(!settingup)
{
// Anything selected?
if(listfilters.SelectedItems.Count > 0)
{
// Get selected filter
ThingsFilter f = listfilters.SelectedItems[0].Tag as ThingsFilter;
// New state is required?
if(box.CheckState == CheckState.Checked)
{
f.ForbiddenFields.Remove(box.Tag.ToString());
if(!f.RequiredFields.Contains(box.Tag.ToString())) f.RequiredFields.Add(box.Tag.ToString());
}
// New state is forbidden?
else if(box.CheckState == CheckState.Unchecked)
{
f.RequiredFields.Remove(box.Tag.ToString());
if(!f.ForbiddenFields.Contains(box.Tag.ToString())) f.ForbiddenFields.Add(box.Tag.ToString());
}
else
{
f.ForbiddenFields.Remove(box.Tag.ToString());
f.RequiredFields.Remove(box.Tag.ToString());
}
}
}
}
#endregion #endregion
} }
} }

View file

@ -153,12 +153,6 @@
<metadata name="apply.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="apply.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>
<metadata name="checkBox1.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="checkBox2.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value> <value>True</value>
</metadata> </metadata>