Changed, Textures Browser: frames/names of used textures are now drawn using a different color.

Changed, Textures Browser: the browser now toggles between showing used textures on the top of the list and showing textures in alphabetical order instead of toggling between showing all textures and used textures.
This commit is contained in:
MaxED 2016-12-23 12:39:09 +00:00
parent 447851e457
commit f2db0e1d30
8 changed files with 192 additions and 261 deletions

View file

@ -295,7 +295,7 @@ namespace CodeImp.DoomBuilder.Config
if(Read(cfgfilepathname, defaultfilepathname))
{
// Read the cache variables
blackbrowsers = cfg.ReadSetting("blackbrowsers", false);
blackbrowsers = cfg.ReadSetting("blackbrowsers", true);
visualfov = cfg.ReadSetting("visualfov", 80);
visualmousesensx = cfg.ReadSetting("visualmousesensx", 40f);
visualmousesensy = cfg.ReadSetting("visualmousesensy", 40f);

View file

@ -138,6 +138,7 @@ namespace CodeImp.DoomBuilder.Controls
{
// ensure that the hot state is removed
this.hot = false;
this.Cursor = Cursors.Default; //mxd
this.Invalidate();
}

View file

@ -33,19 +33,19 @@ namespace CodeImp.DoomBuilder.Controls
this.labelMixMode = new System.Windows.Forms.Label();
this.label = new System.Windows.Forms.Label();
this.splitter = new System.Windows.Forms.SplitContainer();
this.list = new CodeImp.DoomBuilder.Controls.ImageSelectorPanel();
this.objectclear = new System.Windows.Forms.Button();
this.sizecombo = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.usedtexturesonly = new System.Windows.Forms.CheckBox();
this.usedtexturesfirst = new System.Windows.Forms.CheckBox();
this.longtexturenames = new System.Windows.Forms.CheckBox();
this.filterheightlabel = new System.Windows.Forms.Label();
this.filterHeight = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
this.filterwidthlabel = new System.Windows.Forms.Label();
this.filterWidth = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
this.texturetypecombo = new System.Windows.Forms.ComboBox();
this.objectname = new System.Windows.Forms.TextBox();
this.refreshtimer = new System.Windows.Forms.Timer(this.components);
this.list = new CodeImp.DoomBuilder.Controls.ImageSelectorPanel();
this.filterHeight = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
this.filterWidth = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
this.splitter.Panel1.SuspendLayout();
this.splitter.Panel2.SuspendLayout();
this.splitter.SuspendLayout();
@ -87,7 +87,7 @@ namespace CodeImp.DoomBuilder.Controls
this.splitter.Panel2.Controls.Add(this.objectclear);
this.splitter.Panel2.Controls.Add(this.sizecombo);
this.splitter.Panel2.Controls.Add(this.label1);
this.splitter.Panel2.Controls.Add(this.usedtexturesonly);
this.splitter.Panel2.Controls.Add(this.usedtexturesfirst);
this.splitter.Panel2.Controls.Add(this.longtexturenames);
this.splitter.Panel2.Controls.Add(this.filterheightlabel);
this.splitter.Panel2.Controls.Add(this.filterHeight);
@ -102,6 +102,23 @@ namespace CodeImp.DoomBuilder.Controls
this.splitter.TabIndex = 0;
this.splitter.TabStop = false;
//
// list
//
this.list.AutoScroll = true;
this.list.BackColor = System.Drawing.Color.White;
this.list.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.list.Dock = System.Windows.Forms.DockStyle.Fill;
this.list.HideSelection = false;
this.list.ImageSize = 128;
this.list.Location = new System.Drawing.Point(0, 0);
this.list.MultiSelect = false;
this.list.Name = "list";
this.list.Size = new System.Drawing.Size(840, 284);
this.list.TabIndex = 1;
this.list.Title = "Default group";
this.list.ItemDoubleClicked += new CodeImp.DoomBuilder.Controls.ImageSelectorPanel.ItemSelectedEventHandler(this.list_ItemDoubleClicked);
this.list.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.list_KeyPress);
//
// objectclear
//
this.objectclear.Image = global::CodeImp.DoomBuilder.Properties.Resources.Close;
@ -141,17 +158,17 @@ namespace CodeImp.DoomBuilder.Controls
this.label1.TabIndex = 1;
this.label1.Text = "Size:";
//
// usedtexturesonly
// usedtexturesfirst
//
this.usedtexturesonly.AutoSize = true;
this.usedtexturesonly.Location = new System.Drawing.Point(365, 8);
this.usedtexturesonly.Name = "usedtexturesonly";
this.usedtexturesonly.Size = new System.Drawing.Size(113, 17);
this.usedtexturesonly.TabIndex = 0;
this.usedtexturesonly.TabStop = false;
this.usedtexturesonly.Text = "Used textures only";
this.usedtexturesonly.UseVisualStyleBackColor = true;
this.usedtexturesonly.CheckedChanged += new System.EventHandler(this.usedtexturesonly_CheckedChanged);
this.usedtexturesfirst.AutoSize = true;
this.usedtexturesfirst.Location = new System.Drawing.Point(365, 8);
this.usedtexturesfirst.Name = "usedtexturesfirst";
this.usedtexturesfirst.Size = new System.Drawing.Size(139, 17);
this.usedtexturesfirst.TabIndex = 0;
this.usedtexturesfirst.TabStop = false;
this.usedtexturesfirst.Text = "Used textures at the top";
this.usedtexturesfirst.UseVisualStyleBackColor = true;
this.usedtexturesfirst.CheckedChanged += new System.EventHandler(this.usedtexturesfirst_CheckedChanged);
//
// longtexturenames
//
@ -174,6 +191,26 @@ namespace CodeImp.DoomBuilder.Controls
this.filterheightlabel.TabIndex = 0;
this.filterheightlabel.Text = "Height:";
//
// filterHeight
//
this.filterHeight.AllowDecimal = false;
this.filterHeight.AllowExpressions = false;
this.filterHeight.AllowNegative = false;
this.filterHeight.AllowRelative = false;
this.filterHeight.ButtonStep = 1;
this.filterHeight.ButtonStepBig = 10F;
this.filterHeight.ButtonStepFloat = 1F;
this.filterHeight.ButtonStepSmall = 0.1F;
this.filterHeight.ButtonStepsUseModifierKeys = false;
this.filterHeight.ButtonStepsWrapAround = false;
this.filterHeight.Location = new System.Drawing.Point(301, 30);
this.filterHeight.Name = "filterHeight";
this.filterHeight.Size = new System.Drawing.Size(54, 24);
this.filterHeight.StepValues = null;
this.filterHeight.TabIndex = 0;
this.filterHeight.TabStop = false;
this.filterHeight.WhenTextChanged += new System.EventHandler(this.filterSize_WhenTextChanged);
//
// filterwidthlabel
//
this.filterwidthlabel.AutoSize = true;
@ -183,6 +220,26 @@ namespace CodeImp.DoomBuilder.Controls
this.filterwidthlabel.TabIndex = 0;
this.filterwidthlabel.Text = "Width:";
//
// filterWidth
//
this.filterWidth.AllowDecimal = false;
this.filterWidth.AllowExpressions = false;
this.filterWidth.AllowNegative = false;
this.filterWidth.AllowRelative = false;
this.filterWidth.ButtonStep = 1;
this.filterWidth.ButtonStepBig = 10F;
this.filterWidth.ButtonStepFloat = 1F;
this.filterWidth.ButtonStepSmall = 0.1F;
this.filterWidth.ButtonStepsUseModifierKeys = false;
this.filterWidth.ButtonStepsWrapAround = false;
this.filterWidth.Location = new System.Drawing.Point(199, 30);
this.filterWidth.Name = "filterWidth";
this.filterWidth.Size = new System.Drawing.Size(54, 24);
this.filterWidth.StepValues = null;
this.filterWidth.TabIndex = 0;
this.filterWidth.TabStop = false;
this.filterWidth.WhenTextChanged += new System.EventHandler(this.filterSize_WhenTextChanged);
//
// texturetypecombo
//
this.texturetypecombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
@ -218,63 +275,6 @@ namespace CodeImp.DoomBuilder.Controls
this.refreshtimer.Interval = 500;
this.refreshtimer.Tick += new System.EventHandler(this.refreshtimer_Tick);
//
// list
//
this.list.AutoScroll = true;
this.list.BackColor = System.Drawing.Color.White;
this.list.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.list.Dock = System.Windows.Forms.DockStyle.Fill;
this.list.HideSelection = false;
this.list.ImageSize = 128;
this.list.Location = new System.Drawing.Point(0, 0);
this.list.MultiSelect = false;
this.list.Name = "list";
this.list.Size = new System.Drawing.Size(840, 284);
this.list.TabIndex = 1;
this.list.Title = "Default group";
this.list.ItemDoubleClicked += new CodeImp.DoomBuilder.Controls.ImageSelectorPanel.ItemSelectedEventHandler(this.list_ItemDoubleClicked);
this.list.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.list_KeyPress);
//
// filterHeight
//
this.filterHeight.AllowDecimal = false;
this.filterHeight.AllowExpressions = false;
this.filterHeight.AllowNegative = false;
this.filterHeight.AllowRelative = false;
this.filterHeight.ButtonStep = 1;
this.filterHeight.ButtonStepBig = 10F;
this.filterHeight.ButtonStepFloat = 1F;
this.filterHeight.ButtonStepSmall = 0.1F;
this.filterHeight.ButtonStepsUseModifierKeys = false;
this.filterHeight.ButtonStepsWrapAround = false;
this.filterHeight.Location = new System.Drawing.Point(301, 30);
this.filterHeight.Name = "filterHeight";
this.filterHeight.Size = new System.Drawing.Size(54, 24);
this.filterHeight.StepValues = null;
this.filterHeight.TabIndex = 0;
this.filterHeight.TabStop = false;
this.filterHeight.WhenTextChanged += new System.EventHandler(this.filterSize_WhenTextChanged);
//
// filterWidth
//
this.filterWidth.AllowDecimal = false;
this.filterWidth.AllowExpressions = false;
this.filterWidth.AllowNegative = false;
this.filterWidth.AllowRelative = false;
this.filterWidth.ButtonStep = 1;
this.filterWidth.ButtonStepBig = 10F;
this.filterWidth.ButtonStepFloat = 1F;
this.filterWidth.ButtonStepSmall = 0.1F;
this.filterWidth.ButtonStepsUseModifierKeys = false;
this.filterWidth.ButtonStepsWrapAround = false;
this.filterWidth.Location = new System.Drawing.Point(199, 30);
this.filterWidth.Name = "filterWidth";
this.filterWidth.Size = new System.Drawing.Size(54, 24);
this.filterWidth.StepValues = null;
this.filterWidth.TabIndex = 0;
this.filterWidth.TabStop = false;
this.filterWidth.WhenTextChanged += new System.EventHandler(this.filterSize_WhenTextChanged);
//
// ImageBrowserControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
@ -304,7 +304,7 @@ namespace CodeImp.DoomBuilder.Controls
private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox filterHeight;
private System.Windows.Forms.Label filterwidthlabel;
private System.Windows.Forms.CheckBox longtexturenames;
private System.Windows.Forms.CheckBox usedtexturesonly;
private System.Windows.Forms.CheckBox usedtexturesfirst;
private System.Windows.Forms.ComboBox sizecombo;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button objectclear;

View file

@ -57,9 +57,9 @@ namespace CodeImp.DoomBuilder.Controls
private bool blockupdate; //mxd
//mxd. All items
private Dictionary<string, List<ImageBrowserItem>> items; // <group, <items>>
private List<string> groups;
private string selectedgroup;
private List<ImageBrowserItem> items;
private string usedfirstgroup;
private string availgroup;
// Filtered items
private List<ImageBrowserItem> visibleitems;
@ -75,7 +75,14 @@ namespace CodeImp.DoomBuilder.Controls
public bool HideInputBox { get { return splitter.Panel2Collapsed; } set { splitter.Panel2Collapsed = value; } }
public List<ImageBrowserItem> SelectedItems { get { return list.SelectedItems; } } //mxd
public ImageBrowserItem SelectedItem { get { return (list.SelectedItems.Count > 0 ? list.SelectedItems[0] : null); } }
public string SelectedGroup { get { return selectedgroup; } } //mxd
public string ElementName //mxd
{
set
{
usedfirstgroup = "Available " + value + " (used first):";
availgroup = "Available " + value + ":";
}
}
#endregion
@ -86,8 +93,7 @@ namespace CodeImp.DoomBuilder.Controls
{
// Initialize
InitializeComponent();
items = new Dictionary<string, List<ImageBrowserItem>>();
groups = new List<string>();
items = new List<ImageBrowserItem>();
//mxd
StepsList sizes = new StepsList { 4, 8, 16, 32, 48, 64, 96, 128, 196, 256, 512, 1024 };
@ -109,18 +115,10 @@ namespace CodeImp.DoomBuilder.Controls
{
blockupdate = true;
//TODO: group handling doesn't couple well with usedtexturesonly checkbox...
this.browseflats = browseflats;
uselongtexturenames = General.Map.Options.UseLongTextureNames;
selectedgroup = General.Settings.ReadSetting(settingpath + ".selectedgroup", string.Empty);
if(string.IsNullOrEmpty(selectedgroup) || (groups.Count > 0 && !groups.Contains(selectedgroup)))
{
selectedgroup = groups[0];
}
texturetype = General.Settings.ReadSetting(settingpath + ".texturetype", 0);
usedtexturesonly.Checked = (groups.IndexOf(selectedgroup) == 1);
usedtexturesfirst.Checked = General.Settings.ReadSetting(settingpath + ".showusedtexturesfirst", false);
int imagesize = General.Settings.ReadSetting(settingpath + ".imagesize", 128);
sizecombo.Text = (imagesize == 0 ? sizecombo.Items[0].ToString() : imagesize.ToString());
@ -173,7 +171,7 @@ namespace CodeImp.DoomBuilder.Controls
//mxd. Save settings
public virtual void OnClose(string settingpath)
{
General.Settings.WriteSetting(settingpath + ".selectedgroup", selectedgroup);
General.Settings.WriteSetting(settingpath + ".showusedtexturesfirst", usedtexturesfirst.Checked);
General.Settings.WriteSetting(settingpath + ".imagesize", list.ImageSize);
if(General.Map.Config.UseLongTextureNames) General.Map.Options.UseLongTextureNames = uselongtexturenames;
@ -240,10 +238,10 @@ namespace CodeImp.DoomBuilder.Controls
{
e.SuppressKeyPress = true;
}
// Toggle groups
// Toggle used items sorting
else if(e.KeyData == Keys.Tab)
{
ShowNextGroup();
usedtexturesfirst.Checked = !usedtexturesfirst.Checked;
e.SuppressKeyPress = true;
}
}
@ -264,7 +262,7 @@ namespace CodeImp.DoomBuilder.Controls
//mxd
protected override bool ProcessTabKey(bool forward)
{
usedtexturesonly.Checked = !usedtexturesonly.Checked;
usedtexturesfirst.Checked = !usedtexturesfirst.Checked;
return false;
}
@ -348,17 +346,25 @@ namespace CodeImp.DoomBuilder.Controls
//mxd
private void longtexturenames_CheckedChanged(object sender, EventArgs e)
{
if(blockupdate) return;
uselongtexturenames = longtexturenames.Checked;
objectname.CharacterCasing = (uselongtexturenames ? CharacterCasing.Normal : CharacterCasing.Upper);
RefillList(false);
if(!blockupdate)
{
uselongtexturenames = longtexturenames.Checked;
objectname.CharacterCasing = (uselongtexturenames ? CharacterCasing.Normal : CharacterCasing.Upper);
foreach(var item in items) item.ShowFullName = uselongtexturenames;
list.Refresh();
list.Focus();
}
}
//mxd
private void usedtexturesonly_CheckedChanged(object sender, EventArgs e)
private void usedtexturesfirst_CheckedChanged(object sender, EventArgs e)
{
if(blockupdate) return;
ShowNextGroup();
if(!blockupdate)
{
RefillList(false);
list.Focus();
}
}
#endregion
@ -366,46 +372,24 @@ namespace CodeImp.DoomBuilder.Controls
#region ================== Methods
// This selects an item by longname (mxd - changed from name to longname)
public void SelectItem(long longname, string preferredgroup)
public void SelectItem(long longname)
{
// Not when selecting is prevented
if(preventselection) return;
// Assemble group order
List<string> searchorder;
if(string.IsNullOrEmpty(preferredgroup) || !groups.Contains(preferredgroup))
{
searchorder = new List<string>(groups);
}
else
{
searchorder = new List<string> { preferredgroup };
List<string> othergroups = new List<string>(groups);
othergroups.Remove(preferredgroup);
searchorder.AddRange(othergroups);
}
// Search for item
ImageBrowserItem target = null; //mxd
string targetgroup = string.Empty;
foreach(string group in searchorder)
foreach(ImageBrowserItem item in items)
{
foreach(ImageBrowserItem item in items[group])
if(item.Icon.LongName == longname) //mxd
{
if(item.Icon.LongName == longname) //mxd
{
target = item;
targetgroup = group;
break;
}
target = item;
break;
}
}
if(target != null)
{
// Group switching required?
SelectGroup(targetgroup);
// Select the item
list.SetSelectedItem(target);
}
@ -421,37 +405,6 @@ namespace CodeImp.DoomBuilder.Controls
if(list.Items.Count > 0) list.SetSelectedItem(list.Items[0]);
}
// This adds a group
public void AddGroup(string name)
{
if(groups.Contains(name)) return;
groups.Add(name);
items.Add(name, new List<ImageBrowserItem>());
}
// This selects a group
public void SelectGroup(string groupname)
{
if(string.IsNullOrEmpty(groupname) || groupname == selectedgroup || !groups.Contains(groupname)) return;
selectedgroup = groupname;
list.SetItems(items[groupname]);
blockupdate = true;
usedtexturesonly.Checked = (groups.IndexOf(selectedgroup) == 1);
blockupdate = false;
RefillList(false);
}
// This toggles between groups
private void ShowNextGroup()
{
if(groups.Count < 2) return;
int nextgroupindex = groups.IndexOf(selectedgroup) + 1;
if(nextgroupindex >= items.Count) nextgroupindex = 0;
SelectGroup(groups[nextgroupindex]);
}
// This begins adding items
public void BeginAdding(bool keepselectedindex)
{
@ -463,10 +416,6 @@ namespace CodeImp.DoomBuilder.Controls
// Clean list
items.Clear();
// Re-add groups...
foreach(string s in groups)
items.Add(s, new List<ImageBrowserItem>());
// Stop updating
refreshtimer.Enabled = false;
}
@ -482,19 +431,12 @@ namespace CodeImp.DoomBuilder.Controls
}
//mxd. This adds a category item
public void AddFolder(ImageBrowserItemType itemtype, string group, string categoryname)
public void AddFolder(ImageBrowserItemType itemtype, string categoryname)
{
if(string.IsNullOrEmpty(group)) group = ImageSelectorPanel.DEFAULT_GROUP;
if(!items.ContainsKey(group))
{
items.Add(group, new List<ImageBrowserItem>());
groups.Add(group);
}
switch(itemtype)
{
case ImageBrowserItemType.FOLDER: case ImageBrowserItemType.FOLDER_UP:
items[group].Add(new ImageBrowserCategoryItem(itemtype, categoryname));
items.Add(new ImageBrowserCategoryItem(itemtype, categoryname));
break;
default: throw new Exception("Unsupported ImageBrowserItemType");
@ -502,35 +444,21 @@ namespace CodeImp.DoomBuilder.Controls
}
// This adds an item
public void AddItem(ImageData image, string group, string tooltip)
public void AddItem(ImageData image, string tooltip)
{
if(string.IsNullOrEmpty(group)) group = ImageSelectorPanel.DEFAULT_GROUP;
if(!items.ContainsKey(group))
{
items.Add(group, new List<ImageBrowserItem>());
groups.Add(group);
}
items[group].Add(new ImageBrowserItem(image, tooltip, uselongtexturenames));
items.Add(new ImageBrowserItem(image, tooltip, uselongtexturenames));
}
public void AddItem(ImageData image, string group)
public void AddItem(ImageData image)
{
AddItem(image, group, string.Empty);
items.Add(new ImageBrowserItem(image, string.Empty, uselongtexturenames));
}
// This fills the list based on the objectname filter
private void RefillList(bool selectfirst)
{
if(groups.Count == 0) return;
visibleitems = new List<ImageBrowserItem>();
//mxd. Check group name...
if(string.IsNullOrEmpty(selectedgroup))
{
if(groups.Count == 0) throw new Exception("No groups defined...");
selectedgroup = groups[0];
}
//mxd. Store info about currently selected item
string selectedname = string.Empty;
if(!selectfirst && keepselected == -1 && list.SelectedItems.Count > 0)
@ -540,7 +468,10 @@ namespace CodeImp.DoomBuilder.Controls
// Clear list first
list.Clear();
list.Title = selectedgroup;
list.Title = (usedtexturesfirst.Checked ? usedfirstgroup : availgroup);
//mxd. Anything to do?
if(items.Count == 0) return;
//mxd. Filtering by texture size?
int w = filterWidth.GetResult(-1);
@ -548,19 +479,19 @@ namespace CodeImp.DoomBuilder.Controls
// Go for all items
ImageBrowserItem previtem = null; //mxd
for(int i = items[selectedgroup].Count - 1; i > -1; i--)
for(int i = items.Count - 1; i > -1; i--)
{
// Add item if valid
items[selectedgroup][i].ShowFullName = uselongtexturenames; //mxd
if(ValidateItem(items[selectedgroup][i], previtem) && ValidateItemSize(items[selectedgroup][i], w, h))
items[i].ShowFullName = uselongtexturenames; //mxd
if(ValidateItem(items[i], previtem) && ValidateItemSize(items[i], w, h))
{
visibleitems.Add(items[selectedgroup][i]);
previtem = items[selectedgroup][i];
visibleitems.Add(items[i]);
previtem = items[i];
}
}
// Fill list
visibleitems.Sort();
visibleitems.Sort(SortItems);
list.SetItems(visibleitems);
// Make selection?
@ -649,6 +580,21 @@ namespace CodeImp.DoomBuilder.Controls
return true;
}
//mxd
private int SortItems(ImageBrowserItem item1, ImageBrowserItem item2)
{
if(usedtexturesfirst.Checked
&& item1.ItemType == ImageBrowserItemType.IMAGE
&& item2.ItemType == ImageBrowserItemType.IMAGE
&& item1.Icon.UsedInMap != item2.Icon.UsedInMap)
{
// Push used items to the top
return (item1.Icon.UsedInMap ? -1 : 1);
}
return item1.CompareTo(item2);
}
//mxd. This sends the focus to the textures list
public void FocusList()
{

View file

@ -36,7 +36,7 @@ namespace CodeImp.DoomBuilder.Controls
public ImageData Icon { get { return icon; } }
public ImageBrowserItemType ItemType { get { return itemtype; } }
public virtual bool IsPreviewLoaded { get { return imageloaded; } }
public virtual bool IsPreviewLoaded { get { return icon.IsPreviewLoaded; } }
public bool ShowFullName { set { showfullname = value; } }
public virtual string TextureName { get { return (showfullname ? icon.Name : icon.ShortName); } }
public string ToolTip { get { return tooltip; } }
@ -71,7 +71,7 @@ namespace CodeImp.DoomBuilder.Controls
return false;
}
internal void Draw(Graphics g, Image bmp, int x, int y, int w, int h, bool selected)
internal void Draw(Graphics g, Image bmp, int x, int y, int w, int h, bool selected, bool used)
{
if(bmp == null) return;
@ -89,37 +89,41 @@ namespace CodeImp.DoomBuilder.Controls
ih = h;
}
int ix = (iw < w ? x + (w - iw) / 2 : x + 1);
int iy = (ih < h ? y + (h - ih) / 2 : y + 1);
int ix = (iw < w ? x + (w - iw) / 2 : x);
int iy = (ih < h ? y + (h - ih) / 2 : y);
// Pick colors and brushes
Brush bgbrush, fgbrush, selectedbgbrush, selectionbrush;
Brush bgbrush, fgbrush, selectedbgbrush, selectionbrush, selectiontextbrush;
Color bgcolor;
Pen selection;
Pen selection, frame;
if(General.Settings.BlackBrowsers)
{
bgcolor = Color.Black;
bgbrush = Brushes.Black;
fgbrush = Brushes.White;
fgbrush = (used ? Brushes.Orange : Brushes.White);
selectedbgbrush = Brushes.Gray;
frame = (used ? Pens.Orange : Pens.Gray);
selection = Pens.Red;
selectionbrush = Brushes.Red;
selectiontextbrush = Brushes.White;
}
else
{
bgcolor = SystemColors.Window;
bgbrush = SystemBrushes.Window;
fgbrush = SystemBrushes.ControlText;
selectedbgbrush = SystemBrushes.ActiveCaption;
fgbrush = (used ? SystemBrushes.HotTrack : SystemBrushes.ControlText);
selectedbgbrush = SystemBrushes.Highlight;
frame = (used ? SystemPens.HotTrack : SystemPens.ActiveBorder);
selection = SystemPens.HotTrack;
selectionbrush = SystemBrushes.HotTrack;
selectiontextbrush = SystemBrushes.Window;
}
// Item bg
g.FillRectangle(bgbrush, x - 3, y - 3, w + 6, h + 10 + SystemFonts.MessageBoxFont.Height);
g.FillRectangle(bgbrush, x - 2, y - 2, w + 3, h + 8 + SystemFonts.MessageBoxFont.Height);
// Selected image bg
if(selected) g.FillRectangle(selectedbgbrush, x - 1, y - 1, w + 2, h + 2);
if(selected) g.FillRectangle(selectedbgbrush, x - 2, y - 2, w + 4, h + 2 + SystemFonts.MessageBoxFont.Height);
// Image
g.DrawImage(bmp, ix, iy, iw, ih);
@ -129,14 +133,17 @@ namespace CodeImp.DoomBuilder.Controls
{
g.DrawRectangle(selection, x - 1, y - 1, w + 1, h + 1);
g.DrawRectangle(selection, x - 2, y - 2, w + 3, h + 3);
// Image name bg
g.FillRectangle(selectionbrush, x - 2, y + h + 2, w + 4, SystemFonts.MessageBoxFont.Height);
}
else
{
g.DrawRectangle(Pens.Gray, x - 2, y - 2, w + 3, h + 3);
g.DrawRectangle(frame, x - 1, y - 1, w + 1, h + 1);
}
// Image name
g.DrawString(TextureName, SystemFonts.MessageBoxFont, (selected ? selectionbrush : fgbrush), x - 2, y + h + 3);
g.DrawString(TextureName, SystemFonts.MessageBoxFont, (selected ? selectiontextbrush : fgbrush), x - 2, y + h + 1);
// Image size
if(General.Settings.ShowTextureSizes && icon.IsPreviewLoaded && itemtype == ImageBrowserItemType.IMAGE)
@ -144,16 +151,23 @@ namespace CodeImp.DoomBuilder.Controls
string imagesize = Math.Abs(icon.ScaledWidth) + "x" + Math.Abs(icon.ScaledHeight);
SizeF textsize = g.MeasureString(imagesize, SystemFonts.MessageBoxFont);
textsize.Width += 2;
textsize.Height -= 2;
textsize.Height -= 3;
// Draw bg
using(Brush bg = new SolidBrush(Color.FromArgb(192, bgcolor)))
if(selected)
{
g.FillRectangle(bg, x, y, textsize.Width, textsize.Height);
g.FillRectangle(selectionbrush, x, y, textsize.Width, textsize.Height);
}
else
{
using(Brush bg = new SolidBrush(Color.FromArgb(192, bgcolor)))
{
g.FillRectangle(bg, x, y, textsize.Width, textsize.Height);
}
}
// Draw text
g.DrawString(imagesize, SystemFonts.MessageBoxFont, (selected ? selectionbrush : fgbrush), x, y - 1);
g.DrawString(imagesize, SystemFonts.MessageBoxFont, (selected ? selectiontextbrush : fgbrush), x, y - 1);
}
}

View file

@ -2,7 +2,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
@ -18,8 +17,6 @@ namespace CodeImp.DoomBuilder.Controls
{
#region ================== Constants
internal const string DEFAULT_GROUP = "[DEFAULT_GROUP]";
#endregion
#region ================== Variables
@ -136,7 +133,7 @@ namespace CodeImp.DoomBuilder.Controls
selection = new List<ImageBrowserItem>();
imagesize = 128;
rectangles = new List<Rectangle>();
title = "Default group";
title = "All images:";
Controls.Add(scrollbar);
}
@ -151,16 +148,13 @@ namespace CodeImp.DoomBuilder.Controls
#region ================== Add/Remove/Get Textures
//mxd
//mxd. Clears the list without redrawing it
public void Clear()
{
selection.Clear();
items.Clear();
lastselecteditem = null;
rectangles.Clear();
OnSelectionChanged(selection);
Refresh();
}
//mxd
@ -470,12 +464,6 @@ namespace CodeImp.DoomBuilder.Controls
return false;
}
/*protected override void OnMouseEnter(EventArgs e)
{
Focus();
base.OnMouseEnter(e);
}*/
#endregion
#region ================== Updating Rectangles & Dimensions
@ -492,7 +480,7 @@ namespace CodeImp.DoomBuilder.Controls
private void UpdateRectangles()
{
int w = ClientRectangle.Width - scrollbar.Width;
const int pad = 3;
const int pad = 2;
int font = 4 + SystemFonts.MessageBoxFont.Height;
int cx = 0;
int cy = titleheight;
@ -566,12 +554,12 @@ namespace CodeImp.DoomBuilder.Controls
if(rec.Top > y + height) break;
Image bmp = GetPreview(items[i], imagesize);
items[i].Draw(g, bmp, rec.X, rec.Y - y, rec.Width, rec.Height, selection.Contains(items[i]));
items[i].Draw(g, bmp, rec.X, rec.Y - y, rec.Width, rec.Height, selection.Contains(items[i]), items[i].Icon.UsedInMap);
}
}
// Draw title on top of items
if(title != DEFAULT_GROUP)
if(!string.IsNullOrEmpty(title))
{
// Draw group name bg
bool blackbrowsers = (General.Settings != null && General.Settings.BlackBrowsers);
@ -628,7 +616,7 @@ namespace CodeImp.DoomBuilder.Controls
{
g.PageUnit = GraphicsUnit.Pixel;
g.InterpolationMode = InterpolationMode.NearestNeighbor;
g.PixelOffsetMode = PixelOffsetMode.None;
g.PixelOffsetMode = PixelOffsetMode.Half;
g.DrawImage(img, new Rectangle(0, 0, previewwidth, previewheight));
}

View file

@ -40,8 +40,6 @@ namespace CodeImp.DoomBuilder.Windows
// Variables
private string selectedname;
private readonly string usedgroup;
private readonly string availgroup;
private TreeNode selectedset; //mxd
private long selecttextureonfill; //mxd. Was string, which wasn't reliable whem dealing with long texture names
private readonly bool browseflats; //mxd
@ -65,15 +63,10 @@ namespace CodeImp.DoomBuilder.Windows
// Initialize
InitializeComponent();
//mxd. Set title
//mxd. Set titles
string imagetype = (browseflats ? "flats" : "textures");
this.Text = "Browse " + imagetype;
// Make groups
usedgroup = "Used " + imagetype + ":";
availgroup = "Available " + imagetype + ":";
browser.AddGroup(availgroup);
browser.AddGroup(usedgroup);
browser.ElementName = imagetype;
// Setup texture browser
browser.ApplySettings("windows." + configname, browseflats);
@ -506,40 +499,30 @@ namespace CodeImp.DoomBuilder.Windows
if(selectedset.Parent != null)
{
TreeNodeData data = (TreeNodeData)selectedset.Parent.Tag;
browser.AddFolder(ImageBrowserItemType.FOLDER_UP, availgroup, data.FolderName);
browser.AddFolder(ImageBrowserItemType.FOLDER_UP, data.FolderName);
}
else
{
browser.AddFolder(ImageBrowserItemType.FOLDER_UP, availgroup, "All Texture Sets");
browser.AddFolder(ImageBrowserItemType.FOLDER_UP, "All Texture Sets");
}
//mxd. Add folders
foreach(TreeNode child in selectedset.Nodes)
{
TreeNodeData data = (TreeNodeData)child.Tag;
browser.AddFolder(ImageBrowserItemType.FOLDER, availgroup, data.FolderName);
browser.AddFolder(ImageBrowserItemType.FOLDER, data.FolderName);
}
// Add textures
if(browseflats)
{
// Add all available flats
foreach(ImageData img in set.Flats)
browser.AddItem(img, availgroup);
// Add all used flats
foreach(ImageData img in set.Flats)
if(img.UsedInMap) browser.AddItem(img, usedgroup);
foreach(ImageData img in set.Flats) browser.AddItem(img);
}
else
{
// Add all available textures and mark the images for temporary loading
foreach(ImageData img in set.Textures)
browser.AddItem(img, availgroup);
// Add all used textures and mark the images for permanent loading
foreach(ImageData img in set.Textures)
if(img.UsedInMap) browser.AddItem(img, usedgroup);
// Add all available textures
foreach(ImageData img in set.Textures) browser.AddItem(img);
}
// Done adding
@ -554,8 +537,7 @@ namespace CodeImp.DoomBuilder.Windows
foreach(TreeNode node in tvTextureSets.Nodes)
{
TreeNodeData data = (TreeNodeData)node.Tag;
browser.AddFolder(ImageBrowserItemType.FOLDER, availgroup, data.FolderName);
browser.AddFolder(ImageBrowserItemType.FOLDER, usedgroup, data.FolderName);
browser.AddFolder(ImageBrowserItemType.FOLDER, data.FolderName);
}
// Done adding
@ -577,7 +559,7 @@ namespace CodeImp.DoomBuilder.Windows
// Select texture
if(selecttextureonfill != 0)
{
browser.SelectItem(selecttextureonfill, browser.SelectedGroup);
browser.SelectItem(selecttextureonfill);
selecttextureonfill = 0;
}

View file

@ -171,7 +171,7 @@ namespace CodeImp.DoomBuilder.Windows
{
bool ismatch = set.IsMatch(img);
if((ismatch && matchesbutton.Checked) || (!ismatch && nomatchesbutton.Checked))
matcheslist.AddItem(img, null, tooltiptext);
matcheslist.AddItem(img, tooltiptext);
}
// If not already mixed, add flats as well
@ -182,7 +182,7 @@ namespace CodeImp.DoomBuilder.Windows
{
bool ismatch = set.IsMatch(img);
if((ismatch && matchesbutton.Checked) || (!ismatch && nomatchesbutton.Checked))
matcheslist.AddItem(img, null, tooltiptext);
matcheslist.AddItem(img, tooltiptext);
}
}