- disabled atlas system for texture previews (appeared to be slower than separate images)

- small fixes and adjustments
This commit is contained in:
codeimp 2008-10-01 18:19:53 +00:00
parent 6f23292b8c
commit 8702f7c60c
5 changed files with 57 additions and 45 deletions

View file

@ -130,12 +130,9 @@ namespace CodeImp.DoomBuilder.Controls
// Items needs to be redrawn?
if(i.CheckRedrawNeeded())
{
// Bounds within view?
if(i.Bounds.IntersectsWith(list.ClientRectangle))
{
// Refresh item in list
list.RedrawItems(i.Index, i.Index, false);
}
// Refresh item in list
//list.RedrawItems(i.Index, i.Index, false);
list.Invalidate();
}
}
@ -243,25 +240,30 @@ namespace CodeImp.DoomBuilder.Controls
{
// Get selected item
lvi = list.SelectedItems[0];
Rectangle lvirect = list.GetItemRect(lvi.Index, ItemBoundsPortion.Entire);
spos = new Point(lvirect.Location.X + lvirect.Width / 2, lvirect.Y + lvirect.Height / 2);
// Determine point to start searching from
switch(dir)
// Try finding 5 times in the given direction
for(int i = 0; i < 5; i++)
{
case SearchDirectionHint.Left: spos = new Point(lvi.Bounds.Left - 1, lvi.Bounds.Top + 1); break;
case SearchDirectionHint.Right: spos = new Point(lvi.Bounds.Left + 1, lvi.Bounds.Top + 1); break;
case SearchDirectionHint.Up: spos = new Point(lvi.Bounds.Left + 1, lvi.Bounds.Top - 1); break;
case SearchDirectionHint.Down: spos = new Point(lvi.Bounds.Left + 1, lvi.Bounds.Bottom + 1); break;
default: spos = new Point(0, 0); break;
}
// Find next item
//lvi = list.SelectedItems[0].FindNearestItem(dir);
lvi = list.FindNearestItem(dir, spos);
if(lvi != null)
{
// Select next item
list.SelectedItems.Clear();
lvi.Selected = true;
// Move point in given direction
switch(dir)
{
case SearchDirectionHint.Left: spos.X -= list.TileSize.Width / 2; break;
case SearchDirectionHint.Right: spos.X += list.TileSize.Width / 2; break;
case SearchDirectionHint.Up: spos.Y -= list.TileSize.Height / 2; break;
case SearchDirectionHint.Down: spos.Y += list.TileSize.Height / 2; break;
}
// Test position
lvi = list.GetItemAt(spos.X, spos.Y);
if(lvi != null)
{
// Select item
list.SelectedItems.Clear();
lvi.Selected = true;
break;
}
}
// Make selection visible
@ -281,8 +283,7 @@ namespace CodeImp.DoomBuilder.Controls
if(list.Items.Count > 0)
{
list.SelectedItems.Clear();
//lvi = list.FindNearestItem(SearchDirectionHint.Down, new Point(1, -100000));
lvi = list.Items[0];
lvi = list.GetItemAt(list.TileSize.Width / 2, list.TileSize.Height / 2);
if(lvi != null)
{
lvi.Selected = true;

View file

@ -241,7 +241,7 @@ namespace CodeImp.DoomBuilder.Data
matchfound |= ms.AddTexture(img.Value);
// If not matched in any set, add it to the others
othertextures.AddTexture(img.Value);
if(!matchfound) othertextures.AddTexture(img.Value);
}
// Add flat names to texture sets
@ -253,7 +253,7 @@ namespace CodeImp.DoomBuilder.Data
matchfound |= ms.AddFlat(img.Value);
// If not matched in any set, add it to the others
othertextures.AddFlat(img.Value);
if(!matchfound) othertextures.AddFlat(img.Value);
}
// Start background loading

View file

@ -44,8 +44,8 @@ namespace CodeImp.DoomBuilder.Data
internal const int IMAGE_HEIGHT = 64;
// How many previews on a single atlas?
private const int PREVIEWS_X = 16;
private const int PREVIEWS_Y = 16;
private const int PREVIEWS_X = 1;
private const int PREVIEWS_Y = 1;
#endregion
@ -215,12 +215,19 @@ namespace CodeImp.DoomBuilder.Data
// Draw from atlas to target
lock(atlas)
{
RectangleF trect = new RectangleF((float)targetpos.X, (float)targetpos.Y,
(float)IMAGE_WIDTH, (float)IMAGE_HEIGHT);
RectangleF srect = new RectangleF((float)GetLocalXIndex(previewindex) * IMAGE_WIDTH,
(float)GetLocalYIndex(previewindex) * IMAGE_HEIGHT,
(float)IMAGE_WIDTH, (float)IMAGE_HEIGHT);
target.DrawImage(atlas, trect, srect, GraphicsUnit.Pixel);
if((PREVIEWS_X == 1) && (PREVIEWS_Y == 1))
{
target.DrawImageUnscaled(atlas, targetpos.X, targetpos.Y);
}
else
{
RectangleF trect = new RectangleF((float)targetpos.X, (float)targetpos.Y,
(float)IMAGE_WIDTH, (float)IMAGE_HEIGHT);
RectangleF srect = new RectangleF((float)GetLocalXIndex(previewindex) * IMAGE_WIDTH,
(float)GetLocalYIndex(previewindex) * IMAGE_HEIGHT,
(float)IMAGE_WIDTH, (float)IMAGE_HEIGHT);
target.DrawImage(atlas, trect, srect, GraphicsUnit.Pixel);
}
}
}

View file

@ -46,7 +46,7 @@ namespace CodeImp.DoomBuilder.Windows
this.browser.Location = new System.Drawing.Point(187, 9);
this.browser.Name = "browser";
this.browser.PreventSelection = false;
this.browser.Size = new System.Drawing.Size(589, 457);
this.browser.Size = new System.Drawing.Size(589, 510);
this.browser.TabIndex = 0;
this.browser.SelectedItemChanged += new CodeImp.DoomBuilder.Controls.ImageBrowserControl.SelectedItemChangedDelegate(this.browser_SelectedItemChanged);
//
@ -54,7 +54,7 @@ namespace CodeImp.DoomBuilder.Windows
//
this.cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancel.Location = new System.Drawing.Point(676, 443);
this.cancel.Location = new System.Drawing.Point(676, 496);
this.cancel.Name = "cancel";
this.cancel.Size = new System.Drawing.Size(100, 25);
this.cancel.TabIndex = 22;
@ -65,7 +65,7 @@ namespace CodeImp.DoomBuilder.Windows
// apply
//
this.apply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.apply.Location = new System.Drawing.Point(570, 443);
this.apply.Location = new System.Drawing.Point(570, 496);
this.apply.Name = "apply";
this.apply.Size = new System.Drawing.Size(100, 25);
this.apply.TabIndex = 21;
@ -75,6 +75,8 @@ namespace CodeImp.DoomBuilder.Windows
//
// texturesets
//
this.texturesets.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.texturesets.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1});
this.texturesets.FullRowSelect = true;
@ -83,7 +85,7 @@ namespace CodeImp.DoomBuilder.Windows
this.texturesets.Location = new System.Drawing.Point(12, 9);
this.texturesets.MultiSelect = false;
this.texturesets.Name = "texturesets";
this.texturesets.Size = new System.Drawing.Size(166, 423);
this.texturesets.Size = new System.Drawing.Size(166, 476);
this.texturesets.TabIndex = 24;
this.texturesets.UseCompatibleStateImageBehavior = false;
this.texturesets.View = System.Windows.Forms.View.Details;
@ -99,7 +101,7 @@ namespace CodeImp.DoomBuilder.Windows
this.AcceptButton = this.apply;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.CancelButton = this.cancel;
this.ClientSize = new System.Drawing.Size(788, 478);
this.ClientSize = new System.Drawing.Size(788, 531);
this.Controls.Add(this.texturesets);
this.Controls.Add(this.cancel);
this.Controls.Add(this.apply);

View file

@ -46,7 +46,7 @@ namespace CodeImp.DoomBuilder.Windows
this.browser.Location = new System.Drawing.Point(187, 9);
this.browser.Name = "browser";
this.browser.PreventSelection = false;
this.browser.Size = new System.Drawing.Size(589, 457);
this.browser.Size = new System.Drawing.Size(589, 510);
this.browser.TabIndex = 0;
this.browser.SelectedItemChanged += new CodeImp.DoomBuilder.Controls.ImageBrowserControl.SelectedItemChangedDelegate(this.browser_SelectedItemChanged);
//
@ -54,7 +54,7 @@ namespace CodeImp.DoomBuilder.Windows
//
this.cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.cancel.Location = new System.Drawing.Point(676, 443);
this.cancel.Location = new System.Drawing.Point(676, 496);
this.cancel.Name = "cancel";
this.cancel.Size = new System.Drawing.Size(100, 25);
this.cancel.TabIndex = 22;
@ -65,7 +65,7 @@ namespace CodeImp.DoomBuilder.Windows
// apply
//
this.apply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.apply.Location = new System.Drawing.Point(570, 443);
this.apply.Location = new System.Drawing.Point(570, 496);
this.apply.Name = "apply";
this.apply.Size = new System.Drawing.Size(100, 25);
this.apply.TabIndex = 21;
@ -75,6 +75,8 @@ namespace CodeImp.DoomBuilder.Windows
//
// texturesets
//
this.texturesets.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.texturesets.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1});
this.texturesets.FullRowSelect = true;
@ -83,7 +85,7 @@ namespace CodeImp.DoomBuilder.Windows
this.texturesets.Location = new System.Drawing.Point(12, 9);
this.texturesets.MultiSelect = false;
this.texturesets.Name = "texturesets";
this.texturesets.Size = new System.Drawing.Size(166, 423);
this.texturesets.Size = new System.Drawing.Size(166, 476);
this.texturesets.TabIndex = 23;
this.texturesets.UseCompatibleStateImageBehavior = false;
this.texturesets.View = System.Windows.Forms.View.Details;
@ -99,7 +101,7 @@ namespace CodeImp.DoomBuilder.Windows
this.AcceptButton = this.apply;
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.CancelButton = this.cancel;
this.ClientSize = new System.Drawing.Size(788, 478);
this.ClientSize = new System.Drawing.Size(788, 531);
this.Controls.Add(this.texturesets);
this.Controls.Add(this.cancel);
this.Controls.Add(this.apply);