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 TextureSelectorControl : ImageSelectorControl
|
|
|
|
{
|
|
|
|
// Variables
|
|
|
|
private bool required;
|
|
|
|
|
|
|
|
// Properties
|
|
|
|
public bool Required { get { return required; } set { required = value; } }
|
|
|
|
|
|
|
|
// 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.TextureNames.ToArray());
|
|
|
|
allowclear = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This finds the image we need for the given texture name
|
|
|
|
protected override Image FindImage(string imagename)
|
|
|
|
{
|
|
|
|
// Check if name is a "none" texture
|
|
|
|
if((imagename.Length < 1) || (imagename[0] == '-'))
|
|
|
|
{
|
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
|
|
|
// Determine image to show
|
|
|
|
if(required)
|
|
|
|
return CodeImp.DoomBuilder.Properties.Resources.MissingTexture;
|
|
|
|
else
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-08 13:13:28 +00:00
|
|
|
ImageData texture = General.Map.Data.GetTextureImage(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-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 texture
|
|
|
|
protected override string BrowseImage(string imagename)
|
|
|
|
{
|
|
|
|
string result;
|
|
|
|
|
|
|
|
// Browse for texture
|
2012-07-23 21:28:23 +00:00
|
|
|
result = TextureBrowserForm.Browse(this.ParentForm, imagename, false);
|
2009-04-19 18:07:22 +00:00
|
|
|
if(result != null) return result; else return imagename;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|