mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-23 04:12:12 +00:00
Changed the way filtering in the Edit Things, Browse Action and Browse Effect windows work: items, which names start with filter text are now displayed first.
Cosmetic tweaks to the way thing bounding boxes are rendered in Things mode when "Fixed Things Scale" option is enabled (bounding boxes of highlighted/selected things are now more opaque than the ones of unselected things). Changed, Preferences form: action selected in the actions list is now stays selected when applying the filtering (unless it's no longer valid).
This commit is contained in:
parent
b29004880b
commit
b5577ed423
5 changed files with 113 additions and 53 deletions
|
@ -455,14 +455,25 @@ namespace CodeImp.DoomBuilder.Controls
|
||||||
validnodes.Clear();
|
validnodes.Clear();
|
||||||
|
|
||||||
string match = tbFilter.Text.ToUpperInvariant();
|
string match = tbFilter.Text.ToUpperInvariant();
|
||||||
|
HashSet<string> added = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
// First add nodes, which titles start with given text
|
||||||
foreach(TreeNode node in nodes)
|
foreach(TreeNode node in nodes)
|
||||||
{
|
{
|
||||||
if(node.Text.ToUpperInvariant().Contains(match))
|
if(node.Text.ToUpperInvariant().StartsWith(match))
|
||||||
{
|
{
|
||||||
typelist.Nodes.Add(node);
|
typelist.Nodes.Add(node);
|
||||||
|
added.Add(node.Text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Then add nodes, which titles contain given text
|
||||||
|
foreach(TreeNode node in nodes)
|
||||||
|
{
|
||||||
|
if(!added.Contains(node.Text) && node.Text.ToUpperInvariant().Contains(match))
|
||||||
|
typelist.Nodes.Add(node);
|
||||||
|
}
|
||||||
|
|
||||||
doupdatenode = true;
|
doupdatenode = true;
|
||||||
doupdatetextbox = true;
|
doupdatetextbox = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1111,7 +1111,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
|
|
||||||
// Make alpha color
|
// Make alpha color
|
||||||
Color4 alphacolor = new Color4(alpha, 1.0f, 1.0f, 1.0f);
|
Color4 alphacolor = new Color4(alpha, 1.0f, 1.0f, 1.0f);
|
||||||
byte bboxalpha = (byte)(alpha * (General.Editing.Mode.GetType().Name == "ThingsMode" ? 128 : 255));
|
bool isthingsmode = (General.Editing.Mode.GetType().Name == "ThingsMode");
|
||||||
|
|
||||||
// Set renderstates for things rendering
|
// Set renderstates for things rendering
|
||||||
graphics.Device.SetRenderState(RenderState.CullMode, Cull.None);
|
graphics.Device.SetRenderState(RenderState.CullMode, Cull.None);
|
||||||
|
@ -1160,6 +1160,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
||||||
|
|
||||||
// Create vertices
|
// Create vertices
|
||||||
PixelColor tc = fixedcolor ? c : DetermineThingColor(t);
|
PixelColor tc = fixedcolor ? c : DetermineThingColor(t);
|
||||||
|
byte bboxalpha = (byte)(alpha * ((!fixedcolor && !t.Selected && isthingsmode) ? 128 : 255));
|
||||||
if(CreateThingBoxVerts(t, ref verts, ref bboxes, thingsByPosition, buffercount * 6, tc, bboxalpha))
|
if(CreateThingBoxVerts(t, ref verts, ref bboxes, thingsByPosition, buffercount * 6, tc, bboxalpha))
|
||||||
{
|
{
|
||||||
buffercount++;
|
buffercount++;
|
||||||
|
|
|
@ -192,24 +192,40 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
}
|
}
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
private void FilterActions(string p)
|
private void FilterActions(string text)
|
||||||
{
|
{
|
||||||
List<TreeNode> filteredNodes = new List<TreeNode>();
|
List<TreeNode> filterednodes = new List<TreeNode>();
|
||||||
|
HashSet<string> added = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
// First add nodes, which titles start with given text
|
||||||
foreach(TreeNode n in allNodes)
|
foreach(TreeNode n in allNodes)
|
||||||
{
|
{
|
||||||
foreach(TreeNode cn in n.Nodes)
|
foreach(TreeNode cn in n.Nodes)
|
||||||
{
|
{
|
||||||
LinedefActionInfo ai = cn.Tag as LinedefActionInfo;
|
LinedefActionInfo ai = cn.Tag as LinedefActionInfo;
|
||||||
if(ai.Title.ToLowerInvariant().IndexOf(p) != -1)
|
if(ai != null && ai.Title.ToUpperInvariant().StartsWith(text))
|
||||||
filteredNodes.Add(cn);
|
{
|
||||||
|
filterednodes.Add(cn);
|
||||||
|
added.Add(ai.Title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Then add nodes, which titles contain given text
|
||||||
|
foreach(TreeNode n in allNodes)
|
||||||
|
{
|
||||||
|
foreach(TreeNode cn in n.Nodes)
|
||||||
|
{
|
||||||
|
LinedefActionInfo ai = cn.Tag as LinedefActionInfo;
|
||||||
|
if(ai != null && !added.Contains(ai.Title) && ai.Title.ToUpperInvariant().Contains(text))
|
||||||
|
filterednodes.Add(cn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
actions.BeginUpdate();
|
actions.BeginUpdate();
|
||||||
actions.Nodes.Clear();
|
actions.Nodes.Clear();
|
||||||
actions.ShowLines = false;
|
actions.ShowLines = false;
|
||||||
actions.Nodes.AddRange(filteredNodes.ToArray());
|
actions.Nodes.AddRange(filterednodes.ToArray());
|
||||||
actions.EndUpdate();
|
actions.EndUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,7 +338,7 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
{
|
{
|
||||||
if(!string.IsNullOrEmpty(tbFilter.Text.Trim()))
|
if(!string.IsNullOrEmpty(tbFilter.Text.Trim()))
|
||||||
{
|
{
|
||||||
FilterActions(tbFilter.Text);
|
FilterActions(tbFilter.Text.ToUpperInvariant());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -155,20 +155,36 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
}
|
}
|
||||||
|
|
||||||
//mxd
|
//mxd
|
||||||
private void FilterEffects(string p)
|
private void FilterEffects(string text)
|
||||||
{
|
{
|
||||||
List<ListViewItem> filteredItems = new List<ListViewItem>();
|
List<ListViewItem> filtereditems = new List<ListViewItem>();
|
||||||
|
HashSet<string> added = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
// First add nodes, which titles start with given text
|
||||||
foreach(ListViewItem i in allitems)
|
foreach(ListViewItem i in allitems)
|
||||||
{
|
{
|
||||||
SectorEffectInfo si = i.Tag as SectorEffectInfo;
|
SectorEffectInfo si = i.Tag as SectorEffectInfo;
|
||||||
if(si.Title.ToLowerInvariant().IndexOf(p) != -1)
|
if(si != null && si.Title.ToUpperInvariant().StartsWith(text))
|
||||||
filteredItems.Add(i);
|
{
|
||||||
|
filtereditems.Add(i);
|
||||||
|
added.Add(si.Title);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Then add nodes, which titles contain given text
|
||||||
|
foreach(ListViewItem i in allitems)
|
||||||
|
{
|
||||||
|
SectorEffectInfo si = i.Tag as SectorEffectInfo;
|
||||||
|
if(si != null && !added.Contains(si.Title) && si.Title.ToUpperInvariant().Contains(text))
|
||||||
|
{
|
||||||
|
filtereditems.Add(i);
|
||||||
|
added.Add(si.Title);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
effects.BeginUpdate();
|
effects.BeginUpdate();
|
||||||
effects.Items.Clear();
|
effects.Items.Clear();
|
||||||
effects.Items.AddRange(filteredItems.ToArray());
|
effects.Items.AddRange(filtereditems.ToArray());
|
||||||
effects.EndUpdate();
|
effects.EndUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -236,7 +252,7 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
{
|
{
|
||||||
if(!string.IsNullOrEmpty(tbFilter.Text.Trim()))
|
if(!string.IsNullOrEmpty(tbFilter.Text.Trim()))
|
||||||
{
|
{
|
||||||
FilterEffects(tbFilter.Text);
|
FilterEffects(tbFilter.Text.ToUpperInvariant());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,8 +39,8 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
private bool allowapplycontrol;
|
private bool allowapplycontrol;
|
||||||
private bool disregardshift;
|
private bool disregardshift;
|
||||||
private bool disregardcontrol;
|
private bool disregardcontrol;
|
||||||
private readonly List<ListViewItem> actionListItems; //mxd
|
private readonly List<ListViewItem> allactionitems; //mxd
|
||||||
private readonly List<int> actionListItemsGroupIndices; //mxd
|
private readonly List<int> allactionitemsgroups; //mxd
|
||||||
|
|
||||||
private bool reloadresources;
|
private bool reloadresources;
|
||||||
|
|
||||||
|
@ -148,8 +148,10 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
|
|
||||||
// Fill list of actions
|
// Fill list of actions
|
||||||
Action[] actions = General.Actions.GetAllActions();
|
Action[] actions = General.Actions.GetAllActions();
|
||||||
actionListItems = new List<ListViewItem>(); //mxd
|
allactionitems = new List<ListViewItem>(); //mxd
|
||||||
actionListItemsGroupIndices = new List<int>(); //mxd
|
allactionitemsgroups = new List<int>(); //mxd
|
||||||
|
|
||||||
|
listactions.BeginUpdate(); //mxd
|
||||||
foreach(Action a in actions)
|
foreach(Action a in actions)
|
||||||
{
|
{
|
||||||
// Create item
|
// Create item
|
||||||
|
@ -161,15 +163,16 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
if(General.Actions.Categories.ContainsKey(a.Category))
|
if(General.Actions.Categories.ContainsKey(a.Category))
|
||||||
{
|
{
|
||||||
item.Group = listactions.Groups[a.Category];
|
item.Group = listactions.Groups[a.Category];
|
||||||
actionListItemsGroupIndices.Add(listactions.Groups.IndexOf(item.Group));
|
allactionitemsgroups.Add(listactions.Groups.IndexOf(item.Group)); //mxd
|
||||||
}
|
}
|
||||||
else //mxd
|
else //mxd
|
||||||
{
|
{
|
||||||
actionListItemsGroupIndices.Add(-1);
|
allactionitemsgroups.Add(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
actionListItems.Add(item); //mxd
|
allactionitems.Add(item); //mxd
|
||||||
}
|
}
|
||||||
|
listactions.EndUpdate(); //mxd
|
||||||
|
|
||||||
// Set the colors
|
// Set the colors
|
||||||
// TODO: Make this automated by using the collection
|
// TODO: Make this automated by using the collection
|
||||||
|
@ -304,7 +307,7 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
General.Settings.ScriptFontSize = fontsize;
|
General.Settings.ScriptFontSize = fontsize;
|
||||||
|
|
||||||
// Apply control keys to actions
|
// Apply control keys to actions
|
||||||
foreach(ListViewItem item in actionListItems) //mxd
|
foreach(ListViewItem item in allactionitems) //mxd
|
||||||
General.Actions[item.Name].SetShortcutKey((int)item.SubItems[1].Tag);
|
General.Actions[item.Name].SetShortcutKey((int)item.SubItems[1].Tag);
|
||||||
|
|
||||||
// Apply the colors
|
// Apply the colors
|
||||||
|
@ -503,7 +506,7 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
if(thiskey != 0)
|
if(thiskey != 0)
|
||||||
{
|
{
|
||||||
// Find actions with same key
|
// Find actions with same key
|
||||||
foreach(ListViewItem item in actionListItems)
|
foreach(ListViewItem item in allactionitems)
|
||||||
{
|
{
|
||||||
// Don't count the selected action
|
// Don't count the selected action
|
||||||
if(item != listactions.SelectedItems[0])
|
if(item != listactions.SelectedItems[0])
|
||||||
|
@ -665,6 +668,9 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
// Item selected
|
// Item selected
|
||||||
private void listactions_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
|
private void listactions_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
|
||||||
{
|
{
|
||||||
|
//mxd. Leave when not allowed to update
|
||||||
|
if(!allowapplycontrol) return;
|
||||||
|
|
||||||
string disregardkeys = "";
|
string disregardkeys = "";
|
||||||
|
|
||||||
// Anything selected?
|
// Anything selected?
|
||||||
|
@ -851,49 +857,59 @@ namespace CodeImp.DoomBuilder.Windows
|
||||||
//mxd
|
//mxd
|
||||||
private void tbFilterActions_TextChanged(object sender, EventArgs e)
|
private void tbFilterActions_TextChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
listactions.BeginUpdate();
|
ListViewItem curselection = (listactions.SelectedItems.Count > 0 ? listactions.SelectedItems[0] : null);
|
||||||
|
ListViewItem toselect = null;
|
||||||
|
|
||||||
//restore everything
|
allowapplycontrol = false;
|
||||||
|
listactions.BeginUpdate();
|
||||||
|
listactions.Items.Clear();
|
||||||
|
|
||||||
|
// Restore everything
|
||||||
if(string.IsNullOrEmpty(tbFilterActions.Text))
|
if(string.IsNullOrEmpty(tbFilterActions.Text))
|
||||||
{
|
{
|
||||||
//restore items
|
// Restore items and groups
|
||||||
listactions.Items.Clear();
|
for(int i = 0; i < allactionitems.Count; i++)
|
||||||
listactions.Items.AddRange(actionListItems.ToArray());
|
|
||||||
|
|
||||||
//restore groups
|
|
||||||
for(int i = 0; i < actionListItems.Count; i++)
|
|
||||||
{
|
{
|
||||||
if(actionListItemsGroupIndices[i] != -1)
|
if(allactionitemsgroups[i] != -1)
|
||||||
actionListItems[i].Group = listactions.Groups[actionListItemsGroupIndices[i]];
|
allactionitems[i].Group = listactions.Groups[allactionitemsgroups[i]];
|
||||||
|
|
||||||
|
// Item sould be added AFTER restoring it's group, otherwise item sorting will be screwed!
|
||||||
|
listactions.Items.Add(allactionitems[i]);
|
||||||
|
|
||||||
|
// Restore selection?
|
||||||
|
if(allactionitems[i] == curselection) toselect = curselection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else //apply filtering
|
// Apply filtering
|
||||||
|
else
|
||||||
{
|
{
|
||||||
string match = tbFilterActions.Text.ToUpperInvariant();
|
string match = tbFilterActions.Text.ToUpperInvariant();
|
||||||
for(int i = 0; i < actionListItems.Count; i++)
|
for(int i = 0; i < allactionitems.Count; i++)
|
||||||
{
|
{
|
||||||
if(actionListItems[i].Text.ToUpperInvariant().Contains(match))
|
if(allactionitems[i].Text.ToUpperInvariant().Contains(match))
|
||||||
{
|
{
|
||||||
//ensure visible
|
// Restore group
|
||||||
if(!listactions.Items.Contains(actionListItems[i]))
|
if(allactionitemsgroups[i] != -1)
|
||||||
{
|
allactionitems[i].Group = listactions.Groups[allactionitemsgroups[i]];
|
||||||
listactions.Items.Add(actionListItems[i]);
|
|
||||||
|
|
||||||
//restore group
|
// Add item
|
||||||
if(actionListItemsGroupIndices[i] != -1)
|
listactions.Items.Add(allactionitems[i]);
|
||||||
actionListItems[i].Group = listactions.Groups[actionListItemsGroupIndices[i]];
|
|
||||||
}
|
// Restore selection?
|
||||||
}
|
if(allactionitems[i] == curselection) toselect = curselection;
|
||||||
else if(listactions.Items.Contains(actionListItems[i]))
|
|
||||||
{
|
|
||||||
//ensure invisible
|
|
||||||
listactions.Items.Remove(actionListItems[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
listactions.Sort();
|
// Restore selection?
|
||||||
|
if(toselect != null)
|
||||||
|
{
|
||||||
|
toselect.Selected = true;
|
||||||
|
listactions.EnsureVisible(toselect.Index);
|
||||||
|
}
|
||||||
|
|
||||||
listactions.EndUpdate();
|
listactions.EndUpdate();
|
||||||
|
allowapplycontrol = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
Loading…
Reference in a new issue