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
|
2014-03-05 09:21:28 +00:00
|
|
|
if(string.IsNullOrEmpty(imagename))
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
2013-07-08 13:13:28 +00:00
|
|
|
DisplayImageSize(0, 0); //mxd
|
2014-12-03 09:06:05 +00:00
|
|
|
UpdateToggleImageNameButton(null); //mxd
|
2013-06-17 13:17:53 +00:00
|
|
|
|
2014-03-05 09:21:28 +00:00
|
|
|
//mxd. Flat required?
|
|
|
|
return multipletextures ? Properties.Resources.ImageStack : Properties.Resources.MissingTexture;
|
|
|
|
}
|
|
|
|
else if(imagename == "-") //mxd
|
|
|
|
{
|
|
|
|
DisplayImageSize(0, 0);
|
2014-12-03 09:06:05 +00:00
|
|
|
UpdateToggleImageNameButton(null); //mxd
|
2014-03-05 09:21:28 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Flat required!
|
2014-02-21 14:42:12 +00:00
|
|
|
return Properties.Resources.MissingTexture;
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-08 13:13:28 +00:00
|
|
|
ImageData texture = General.Map.Data.GetFlatImage(imagename); //mxd
|
2014-12-03 09:06:05 +00:00
|
|
|
UpdateToggleImageNameButton(texture); //mxd
|
2013-07-08 13:13:28 +00:00
|
|
|
|
2015-11-17 17:50:56 +00:00
|
|
|
if(string.IsNullOrEmpty(texture.FilePathName) || texture is UnknownImage) DisplayImageSize(0, 0); //mxd
|
2013-07-08 13:13:28 +00:00
|
|
|
else DisplayImageSize(texture.ScaledWidth, texture.ScaledHeight); //mxd
|
2014-11-25 11:52:01 +00:00
|
|
|
if(usepreviews ? !texture.IsPreviewLoaded : !texture.IsImageLoaded) timer.Start(); //mxd
|
2013-06-17 13:17:53 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Set the image
|
2016-03-04 08:10:56 +00:00
|
|
|
// mxd. GetPreview() returns a copy of preview, GetBitmap() returns actual bitmap
|
|
|
|
return (usepreviews ? texture.GetPreview() : new Bitmap(texture.GetBitmap()));
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This browses for a flat
|
|
|
|
protected override string BrowseImage(string imagename)
|
|
|
|
{
|
|
|
|
// Browse for texture
|
2014-05-19 13:33:38 +00:00
|
|
|
string result = TextureBrowserForm.Browse(this.ParentForm, imagename, true);
|
2009-04-19 18:07:22 +00:00
|
|
|
if(result != null) return result; else return imagename;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|