Added, Textures Browser: "[All]" folder is now added to each map resource. It holds all textures found in that resource.

Fixed, Textures Browser: only name filtering is now applied to folder-type image items, filtering is never applied to "go to parent folder" image items.
Fixed, Textures Browser: in some cases "Backspace" key was ignored by the Filter textbox.
Fixed, Textures Browser: "Ctrl-Backspace" key combo now clears Filter textbox instead of adding an unknown char to it.
This commit is contained in:
MaxED 2016-12-24 21:52:42 +00:00
parent f2db0e1d30
commit 26687a2ee3
5 changed files with 73 additions and 52 deletions

View file

@ -233,17 +233,18 @@ namespace CodeImp.DoomBuilder.Controls
// Key pressed in textbox
private void objectname_KeyDown(object sender, KeyEventArgs e)
{
// Let the list handle arrow keys and such
if(list.ProcessKeyDown(e))
{
e.SuppressKeyPress = true;
}
// Toggle used items sorting
else if(e.KeyData == Keys.Tab)
if(e.KeyData == Keys.Tab)
{
usedtexturesfirst.Checked = !usedtexturesfirst.Checked;
e.SuppressKeyPress = true;
}
//mxd. Clear text field instead of typing strange chars...
else if(e.KeyData == (Keys.Back | Keys.Control))
{
if(objectname.Text.Length > 0) objectname.Clear();
e.SuppressKeyPress = true;
}
}
//mxd
@ -292,26 +293,24 @@ namespace CodeImp.DoomBuilder.Controls
//mxd. Transfer input to Filter textbox
private void list_KeyPress(object sender, KeyPressEventArgs e)
{
if(e.KeyChar == '\b') // Any better way to check for Backspace?..
if(e.KeyChar == 8) // Backspace
{
if(!string.IsNullOrEmpty(objectname.Text) && objectname.SelectionStart > 0 && objectname.SelectionLength == 0)
if(objectname.Text.Length > 0)
{
int s = objectname.SelectionStart - 1;
objectname.Text = objectname.Text.Remove(s, 1);
objectname.SelectionStart = s;
if(objectname.SelectionLength > 0)
{
objectname.Text = objectname.Text.Substring(0, objectname.SelectionStart) +
objectname.Text.Substring(objectname.SelectionStart + objectname.SelectionLength);
}
else
{
objectname.Text = objectname.Text.Substring(0, objectname.Text.Length - 1);
}
}
}
if(e.KeyChar == 8 && objectname.Text.Length > 0)
else if(e.KeyChar == 127) // Ctrl-Backspace
{
if(objectname.SelectionLength > 0)
{
objectname.Text = objectname.Text.Substring(0, objectname.SelectionStart) +
objectname.Text.Substring(objectname.SelectionStart + objectname.SelectionLength);
}
else
{
objectname.Text = objectname.Text.Substring(0, objectname.Text.Length - 1);
}
if(objectname.Text.Length > 0) objectname.Clear();
}
else if((e.KeyChar >= 'a' && e.KeyChar <= 'z') || (e.KeyChar >= '0' && e.KeyChar <= '9') || AllowedSpecialChars.Contains(e.KeyChar))
{
@ -483,10 +482,26 @@ namespace CodeImp.DoomBuilder.Controls
{
// Add item if valid
items[i].ShowFullName = uselongtexturenames; //mxd
if(ValidateItem(items[i], previtem) && ValidateItemSize(items[i], w, h))
switch(items[i].ItemType)
{
visibleitems.Add(items[i]);
previtem = items[i];
case ImageBrowserItemType.IMAGE:
if(ValidateItem(items[i], previtem) && ValidateItemSize(items[i], w, h))
{
visibleitems.Add(items[i]);
previtem = items[i];
}
break;
case ImageBrowserItemType.FOLDER_UP: //mxd. "Browse Up" items are always valid
visibleitems.Add(items[i]);
break;
case ImageBrowserItemType.FOLDER: //mxd. Only apply name filtering to "Folder" items
if(items[i].TextureName.ToUpperInvariant().Contains(objectname.Text.ToUpperInvariant()))
visibleitems.Add(items[i]);
break;
default: throw new NotImplementedException("Unknown ImageBrowserItemType");
}
}

View file

@ -431,37 +431,24 @@ namespace CodeImp.DoomBuilder.Controls
}
protected override void OnKeyDown(KeyEventArgs e)
{
ProcessKeyDown(e);
base.OnKeyDown(e);
}
internal bool ProcessKeyDown(KeyEventArgs e)
{
switch(e.KeyCode)
{
//mxd. Cursor keys
case Keys.Left: SelectNextItem(SearchDirectionHint.Left); return true;
case Keys.Right: SelectNextItem(SearchDirectionHint.Right); return true;
case Keys.Up: SelectNextItem(SearchDirectionHint.Up); return true;
case Keys.Down: SelectNextItem(SearchDirectionHint.Down); return true;
case Keys.Left: SelectNextItem(SearchDirectionHint.Left); break;
case Keys.Right: SelectNextItem(SearchDirectionHint.Right); break;
case Keys.Up: SelectNextItem(SearchDirectionHint.Up); break;
case Keys.Down: SelectNextItem(SearchDirectionHint.Down); break;
case Keys.PageDown: ScrollByAmount(scrollbar.LargeChange); return true;
case Keys.PageUp: ScrollByAmount(-scrollbar.LargeChange); return true;
case Keys.End: ScrollByAmount(int.MaxValue); return true;
case Keys.Home: ScrollByAmount(-int.MaxValue); return true;
case Keys.Enter:
if(selection.Count > 0)
{
OnItemDoubleClicked(selection[0]);
return true;
}
break;
case Keys.PageDown: ScrollByAmount(scrollbar.LargeChange); break;
case Keys.PageUp: ScrollByAmount(-scrollbar.LargeChange); break;
case Keys.End: ScrollByAmount(int.MaxValue); break;
case Keys.Home: ScrollByAmount(-int.MaxValue); break;
case Keys.Enter: if(selection.Count > 0) OnItemDoubleClicked(selection[0]); break;
}
return false;
base.OnKeyDown(e);
}
#endregion

View file

@ -128,7 +128,7 @@ namespace CodeImp.DoomBuilder.Data
private void Initialize()
{
is_iwad = file.IsIWAD;
isreadonly |= is_iwad; // Just in case...
isreadonly |= file.IsReadOnly; // Just in case...
// Initialize
patchranges = new List<LumpRange>();

View file

@ -130,7 +130,6 @@ namespace CodeImp.DoomBuilder.Windows
//
// splitter
//
this.splitter.Cursor = System.Windows.Forms.Cursors.Hand;
this.splitter.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitter.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
this.splitter.Location = new System.Drawing.Point(0, 0);

View file

@ -31,6 +31,9 @@ namespace CodeImp.DoomBuilder.Windows
{
internal partial class TextureBrowserForm : DelayedForm
{
//mxd. Constants
private const string ALL_IMAGES = "[All]";
//mxd. Structs
private struct TreeNodeData
{
@ -199,12 +202,14 @@ namespace CodeImp.DoomBuilder.Windows
//mxd
private static int SortTreeNodes(TreeNode n1, TreeNode n2)
{
return String.Compare(n1.Text, n2.Text, StringComparison.OrdinalIgnoreCase);
return String.Compare(n1.Text, n2.Text, StringComparison.InvariantCultureIgnoreCase);
}
//mxd
private TreeNode FindTextureByLongName(TreeNode node, long longname)
{
if(node.Name == ALL_IMAGES) return null; // Skip "All images" set
//first search in child nodes
foreach(TreeNode n in node.Nodes)
{
@ -313,6 +318,19 @@ namespace CodeImp.DoomBuilder.Windows
root.Nodes.AddRange(children);
}
// Add "All set textures" node
if(General.Map.Config.MixTexturesFlats && root.Nodes.Count > 1)
{
TreeNode allnode = new TreeNode(ALL_IMAGES)
{
Name = ALL_IMAGES,
ImageIndex = imageIndex,
SelectedImageIndex = imageIndex,
Tag = new TreeNodeData { Set = set, FolderName = ALL_IMAGES }
};
root.Nodes.Add(allnode);
}
// Sort immediate child nodes...
TreeNode[] rootnodes = new TreeNode[root.Nodes.Count];
root.Nodes.CopyTo(rootnodes, 0);
@ -330,13 +348,15 @@ namespace CodeImp.DoomBuilder.Windows
{
foreach(ImageData data in rootimages) rootset.AddTexture(data);
}
if(General.Map.Config.MixTexturesFlats) rootset.MixTexturesAndFlats();
// Store root data
rootdata.Set = rootset;
root.Tag = rootdata;
// Set root images count
if(rootimages.Count > 0) root.Text += " [" + rootimages.Count + "]";
var rootsetimages = (browseflats ? rootset.Flats : rootset.Textures);
if(rootsetimages.Count > 0) root.Text += " [" + rootsetimages.Count + "]";
// Add image count to node titles
foreach(TreeNode n in root.Nodes) SetItemsCount(n);