2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
* This program is released under GNU General Public License
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
using System.Drawing;
|
|
|
|
using CodeImp.DoomBuilder.Windows;
|
2013-06-17 13:17:53 +00:00
|
|
|
using CodeImp.DoomBuilder.Data;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.Controls
|
|
|
|
{
|
|
|
|
public class FlatSelectorControl : ImageSelectorControl
|
|
|
|
{
|
|
|
|
// Setup
|
2009-07-09 22:43:39 +00:00
|
|
|
public override void Initialize()
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2009-07-09 22:43:39 +00:00
|
|
|
base.Initialize();
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Fill autocomplete list
|
|
|
|
name.AutoCompleteCustomSource.AddRange(General.Map.Data.FlatNames.ToArray());
|
|
|
|
}
|
|
|
|
|
|
|
|
// This finds the image we need for the given flat name
|
|
|
|
protected override Image FindImage(string imagename)
|
|
|
|
{
|
2013-11-21 10:53:11 +00:00
|
|
|
timer.Stop(); //mxd
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Check if name is a "none" texture
|
2013-07-31 12:38:47 +00:00
|
|
|
if((imagename.Length < 1) || (imagename == "-"))
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2013-07-08 13:13:28 +00:00
|
|
|
DisplayImageSize(0, 0); //mxd
|
2013-06-17 13:17:53 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Flat required!
|
|
|
|
return CodeImp.DoomBuilder.Properties.Resources.MissingTexture;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-08 13:13:28 +00:00
|
|
|
ImageData texture = General.Map.Data.GetFlatImage(imagename); //mxd
|
|
|
|
|
2013-07-29 08:50:50 +00:00
|
|
|
if(string.IsNullOrEmpty(texture.FullName) || texture is UnknownImage) DisplayImageSize(0, 0); //mxd
|
2013-07-08 13:13:28 +00:00
|
|
|
else DisplayImageSize(texture.ScaledWidth, texture.ScaledHeight); //mxd
|
2013-11-21 10:53:11 +00:00
|
|
|
if(!texture.IsPreviewLoaded) timer.Start(); //mxd
|
2013-06-17 13:17:53 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Set the image
|
2013-06-17 13:17:53 +00:00
|
|
|
return texture.GetPreview();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This browses for a flat
|
|
|
|
protected override string BrowseImage(string imagename)
|
|
|
|
{
|
|
|
|
string result;
|
|
|
|
|
|
|
|
// Browse for texture
|
2013-09-11 09:47:53 +00:00
|
|
|
result = TextureBrowserForm.Browse(this.ParentForm, imagename, true); //mxd
|
2009-04-19 18:07:22 +00:00
|
|
|
if(result != null) return result; else return imagename;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|