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
- "Insert Thing" control

View file

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

View file

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

View file

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

View file

@ -110,7 +110,7 @@ namespace CodeImp.DoomBuilder.Windows
groupaction.Size = new System.Drawing.Size(436, 71);
groupaction.TabIndex = 5;
groupaction.TabStop = false;
groupaction.Text = " Action ";
groupaction.Text = " Identification ";
//
// tag
//
@ -395,6 +395,7 @@ namespace CodeImp.DoomBuilder.Windows
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
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.Margin = new System.Windows.Forms.Padding(8);
this.fieldslist.Name = "fieldslist";

View file

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

View file

@ -41,7 +41,8 @@ namespace CodeImp.DoomBuilder.Windows
this.cancel.Margin = new System.Windows.Forms.Padding(1);
this.cancel.Name = "cancel";
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.UseVisualStyleBackColor = true;
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.Name = "apply";
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.UseVisualStyleBackColor = true;
this.apply.Click += new System.EventHandler(this.apply_Click);
@ -69,7 +71,8 @@ namespace CodeImp.DoomBuilder.Windows
this.textbox.Name = "textbox";
this.textbox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.textbox.Size = new System.Drawing.Size(456, 194);
this.textbox.TabIndex = 22;
this.textbox.TabIndex = 0;
this.textbox.TabStop = false;
//
// TextEditForm
//
@ -90,6 +93,7 @@ namespace CodeImp.DoomBuilder.Windows
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Edit Text";
this.Activated += new System.EventHandler(this.TextEditForm_Activated);
this.ResumeLayout(false);
this.PerformLayout();

View file

@ -71,5 +71,12 @@ namespace CodeImp.DoomBuilder.Windows
this.DialogResult = DialogResult.Cancel;
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">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</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>

View file

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

View file

@ -117,7 +117,7 @@ namespace CodeImp.DoomBuilder.Windows
this.filterfields.Columns = 2;
this.filterfields.Location = new System.Drawing.Point(18, 125);
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;
//
// label3

View file

@ -37,20 +37,33 @@ namespace CodeImp.DoomBuilder.Windows
{
public partial class ThingsFiltersForm : DelayedForm
{
#region ================== Variables
private bool settingup;
#endregion
#region ================== Constructor
// Constructor
public ThingsFiltersForm()
{
settingup = true;
// Initialize
InitializeComponent();
// Fill the categories combobox
filtercategory.Items.Add("(any category)");
filtercategory.Items.AddRange(General.Map.Config.ThingCategories.ToArray());
// Fill checkboxes list
// TODO: When UDMF is implemented
filterfields.Add("TODO: When UDMF is implemented!", null);
foreach(KeyValuePair<string, string> flag in General.Map.Config.ThingFlags)
{
CheckBox box = filterfields.Add(flag.Value, flag.Key);
box.ThreeState = true;
box.CheckStateChanged += new EventHandler(filterfield_Check);
}
// Fill list of filters
foreach(ThingsFilter f in General.Map.ConfigSettings.ThingsFilters)
@ -69,6 +82,9 @@ namespace CodeImp.DoomBuilder.Windows
// Sort the list
listfilters.Sort();
// Done
settingup = false;
}
#endregion
@ -137,13 +153,38 @@ namespace CodeImp.DoomBuilder.Windows
ThingsFilter f = listfilters.SelectedItems[0].Tag as ThingsFilter;
// Enable settings
settingup = true;
deletefilter.Enabled = true;
filtergroup.Enabled = true;
// Show settings
// Show name
filtername.Text = f.Name;
// Show category
foreach(ThingCategory c in filtercategory.Items)
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
{
@ -169,9 +210,12 @@ namespace CodeImp.DoomBuilder.Windows
// Get selected filter
ThingsFilter f = listfilters.SelectedItems[0].Tag as ThingsFilter;
// Set new category name
if(filtercategory.SelectedIndex > -1)
// Category selected
if((filtercategory.SelectedIndex > -1) && (filtercategory.SelectedItem is ThingCategory))
{
// Set new category name
f.CategoryName = (filtercategory.SelectedItem as ThingCategory).Name;
}
}
}
@ -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
}
}

View file

@ -153,12 +153,6 @@
<metadata name="apply.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</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">
<value>True</value>
</metadata>