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 ;
2016-12-22 15:04:40 +00:00
using System.Collections.Generic ;
2009-04-19 18:07:22 +00:00
using System.Windows.Forms ;
2014-11-25 11:52:01 +00:00
using CodeImp.DoomBuilder.Controls ;
2009-04-19 18:07:22 +00:00
using CodeImp.DoomBuilder.IO ;
using CodeImp.DoomBuilder.Data ;
using CodeImp.DoomBuilder.Config ;
2012-07-23 21:28:23 +00:00
using System.IO ;
2009-04-19 18:07:22 +00:00
#endregion
namespace CodeImp.DoomBuilder.Windows
{
2014-10-22 13:07:17 +00:00
internal partial class TextureBrowserForm : DelayedForm
2009-04-19 18:07:22 +00:00
{
2016-12-24 21:52:42 +00:00
//mxd. Constants
private const string ALL_IMAGES = "[All]" ;
2016-12-22 15:04:40 +00:00
//mxd. Structs
private struct TreeNodeData
{
public IFilledTextureSet Set ;
public string FolderName ;
}
2009-04-19 18:07:22 +00:00
// Variables
private string selectedname ;
2013-09-11 09:47:53 +00:00
private TreeNode selectedset ; //mxd
2015-07-07 18:37:54 +00:00
private long selecttextureonfill ; //mxd. Was string, which wasn't reliable whem dealing with long texture names
2015-01-16 21:38:42 +00:00
private readonly bool browseflats ; //mxd
2009-04-19 18:07:22 +00:00
// Properties
public string SelectedName { get { return selectedname ; } }
// Constructor
2015-01-16 21:38:42 +00:00
public TextureBrowserForm ( string selecttexture , bool browseflats )
2009-04-19 18:07:22 +00:00
{
Cursor . Current = Cursors . WaitCursor ;
Fixed(?), Texture Browser: possibly fixed Texture Browser not showing up / locking edit forms when current map has a ton of textures (like 2000 or more) in a single texture group.
Changed, cosmetic, Sector Info panel, Visual mode: info about currently highlighted surface is now shown using different color.
Changed, cosmetic, Linedef Info panel, Visual mode, non-UDMF: texture offset labels for currently highlighted sidedef are now shown using different color.
Changed, cosmetic, Vertex Info panel, UDMF: floor and ceiling offset labels are now grayed out when they have default values.
2015-03-23 22:39:31 +00:00
General . Interface . DisableProcessing ( ) ; //mxd
Textures Browser form: empty texture sets are no longer shown when mixed textures & flats is disabled in the current game configuration.
Textures Browser form: PK3/Directory TEXTURES images are now shown in a separate folder in the resources tree.
Fixed, Textures Browser form: fixed a logic error when trying to select initial flat when mix textures & flats was disabled in the current game configuration (this resulted in the blank textures list after opening the form).
Fixed, Textures Browser form: resources tree showed textures count even when browsing flats.
Fixed, Textures Browser form: PK3/Directory textures took precedence even when browsing flats (this means when there were a flat and a texture with the same name, a texture was displayed when browsing flats).
Fixed, Classic modes: actor's scale set in DECORATE was ignored when rendering models.
Fixed, MODELDEF parser: in some cases, several model definitions were skipped when trying to skip the current one.
Fixed, resource management: flat and sprite TEXTURES definitions were loaded only from TEXTURES files named "TEXTURES".
Fixed/added, PK3/folder resource management: patch locations for sprites defined in TEXTURES are now checked the same way as in ZDoom (previously only the "sprites" folder was checked).
Fixed/added, PK3/folder resource management: patch locations for textures defined in TEXTURES are now checked the same way as in ZDoom (previously only the "textures" folder was checked).
Fixed, PK3/folder resource management: flats defined in TEXTURES were not added to the global Flats image list.
Fixed, PK3/folder resource management: in some cases, the image search algorithm could find flats, textures, patches or sprites in incorrect folders (for example, it could find a flat in "flats_backup" folder).
2014-10-07 00:23:02 +00:00
TreeNode item ; //mxd
2009-05-17 15:02:03 +00:00
long longname = Lump . MakeLongName ( selecttexture ? ? "" ) ;
2017-04-03 17:40:51 +00:00
// [ZZ] check if this name is even ok.
2017-04-11 01:48:01 +00:00
if ( browseflats & & General . Map . Data . GetFlatImage ( longname ) = = General . Map . Data . UnknownImage )
2017-04-03 17:40:51 +00:00
longname = Lump . MakeLongName ( "" ) ;
2015-01-16 21:38:42 +00:00
longname = ( browseflats ? General . Map . Data . GetFullLongFlatName ( longname ) : General . Map . Data . GetFullLongTextureName ( longname ) ) ; //mxd
Textures Browser form: empty texture sets are no longer shown when mixed textures & flats is disabled in the current game configuration.
Textures Browser form: PK3/Directory TEXTURES images are now shown in a separate folder in the resources tree.
Fixed, Textures Browser form: fixed a logic error when trying to select initial flat when mix textures & flats was disabled in the current game configuration (this resulted in the blank textures list after opening the form).
Fixed, Textures Browser form: resources tree showed textures count even when browsing flats.
Fixed, Textures Browser form: PK3/Directory textures took precedence even when browsing flats (this means when there were a flat and a texture with the same name, a texture was displayed when browsing flats).
Fixed, Classic modes: actor's scale set in DECORATE was ignored when rendering models.
Fixed, MODELDEF parser: in some cases, several model definitions were skipped when trying to skip the current one.
Fixed, resource management: flat and sprite TEXTURES definitions were loaded only from TEXTURES files named "TEXTURES".
Fixed/added, PK3/folder resource management: patch locations for sprites defined in TEXTURES are now checked the same way as in ZDoom (previously only the "sprites" folder was checked).
Fixed/added, PK3/folder resource management: patch locations for textures defined in TEXTURES are now checked the same way as in ZDoom (previously only the "textures" folder was checked).
Fixed, PK3/folder resource management: flats defined in TEXTURES were not added to the global Flats image list.
Fixed, PK3/folder resource management: in some cases, the image search algorithm could find flats, textures, patches or sprites in incorrect folders (for example, it could find a flat in "flats_backup" folder).
2014-10-07 00:23:02 +00:00
int count ; //mxd
selectedset = null ; //mxd
2015-01-16 21:38:42 +00:00
this . browseflats = browseflats ; //mxd
2009-04-19 18:07:22 +00:00
// Initialize
InitializeComponent ( ) ;
2012-09-05 10:31:32 +00:00
2016-12-23 12:39:09 +00:00
//mxd. Set titles
2015-01-16 21:38:42 +00:00
string imagetype = ( browseflats ? "flats" : "textures" ) ;
this . Text = "Browse " + imagetype ;
2016-12-23 12:39:09 +00:00
browser . ElementName = imagetype ;
2016-12-22 15:04:40 +00:00
2014-12-03 23:30:58 +00:00
// Setup texture browser
2016-12-22 15:04:40 +00:00
browser . ApplySettings ( "windows." + configname , browseflats ) ;
2009-04-19 18:07:22 +00:00
// Update the used textures
General . Map . Data . UpdateUsedTextures ( ) ;
2012-07-23 21:28:23 +00:00
2015-01-16 21:38:42 +00:00
tvTextureSets . BeginUpdate ( ) ; //mxd
2012-07-23 21:28:23 +00:00
2015-07-07 18:37:54 +00:00
//mxd. Texture longname to select when list is filled
selecttextureonfill = longname ;
2012-09-05 10:31:32 +00:00
2013-09-11 09:47:53 +00:00
//mxd. Fill texture sets list with normal texture sets
Textures Browser form: empty texture sets are no longer shown when mixed textures & flats is disabled in the current game configuration.
Textures Browser form: PK3/Directory TEXTURES images are now shown in a separate folder in the resources tree.
Fixed, Textures Browser form: fixed a logic error when trying to select initial flat when mix textures & flats was disabled in the current game configuration (this resulted in the blank textures list after opening the form).
Fixed, Textures Browser form: resources tree showed textures count even when browsing flats.
Fixed, Textures Browser form: PK3/Directory textures took precedence even when browsing flats (this means when there were a flat and a texture with the same name, a texture was displayed when browsing flats).
Fixed, Classic modes: actor's scale set in DECORATE was ignored when rendering models.
Fixed, MODELDEF parser: in some cases, several model definitions were skipped when trying to skip the current one.
Fixed, resource management: flat and sprite TEXTURES definitions were loaded only from TEXTURES files named "TEXTURES".
Fixed/added, PK3/folder resource management: patch locations for sprites defined in TEXTURES are now checked the same way as in ZDoom (previously only the "sprites" folder was checked).
Fixed/added, PK3/folder resource management: patch locations for textures defined in TEXTURES are now checked the same way as in ZDoom (previously only the "textures" folder was checked).
Fixed, PK3/folder resource management: flats defined in TEXTURES were not added to the global Flats image list.
Fixed, PK3/folder resource management: in some cases, the image search algorithm could find flats, textures, patches or sprites in incorrect folders (for example, it could find a flat in "flats_backup" folder).
2014-10-07 00:23:02 +00:00
foreach ( IFilledTextureSet ts in General . Map . Data . TextureSets )
2009-04-19 18:07:22 +00:00
{
2015-01-16 21:38:42 +00:00
count = ( browseflats ? ts . Flats . Count : ts . Textures . Count ) ;
2014-10-07 08:56:21 +00:00
if ( ( count = = 0 & & ! General . Map . Config . MixTexturesFlats ) | | ( ts . Flats . Count = = 0 & & ts . Textures . Count = = 0 ) )
continue ;
Textures Browser form: empty texture sets are no longer shown when mixed textures & flats is disabled in the current game configuration.
Textures Browser form: PK3/Directory TEXTURES images are now shown in a separate folder in the resources tree.
Fixed, Textures Browser form: fixed a logic error when trying to select initial flat when mix textures & flats was disabled in the current game configuration (this resulted in the blank textures list after opening the form).
Fixed, Textures Browser form: resources tree showed textures count even when browsing flats.
Fixed, Textures Browser form: PK3/Directory textures took precedence even when browsing flats (this means when there were a flat and a texture with the same name, a texture was displayed when browsing flats).
Fixed, Classic modes: actor's scale set in DECORATE was ignored when rendering models.
Fixed, MODELDEF parser: in some cases, several model definitions were skipped when trying to skip the current one.
Fixed, resource management: flat and sprite TEXTURES definitions were loaded only from TEXTURES files named "TEXTURES".
Fixed/added, PK3/folder resource management: patch locations for sprites defined in TEXTURES are now checked the same way as in ZDoom (previously only the "sprites" folder was checked).
Fixed/added, PK3/folder resource management: patch locations for textures defined in TEXTURES are now checked the same way as in ZDoom (previously only the "textures" folder was checked).
Fixed, PK3/folder resource management: flats defined in TEXTURES were not added to the global Flats image list.
Fixed, PK3/folder resource management: in some cases, the image search algorithm could find flats, textures, patches or sprites in incorrect folders (for example, it could find a flat in "flats_backup" folder).
2014-10-07 00:23:02 +00:00
item = tvTextureSets . Nodes . Add ( ts . Name + " [" + count + "]" ) ;
2013-09-11 09:47:53 +00:00
item . Name = ts . Name ;
2016-12-22 15:04:40 +00:00
item . Tag = new TreeNodeData { Set = ts , FolderName = ts . Name } ;
2013-09-11 09:47:53 +00:00
item . ImageIndex = 0 ;
2009-04-19 18:07:22 +00:00
}
2013-09-11 09:47:53 +00:00
//mxd. Add container-specific texture sets
2009-04-19 18:07:22 +00:00
foreach ( ResourceTextureSet ts in General . Map . Data . ResourceTextureSets )
{
2015-01-16 21:38:42 +00:00
count = ( browseflats ? ts . Flats . Count : ts . Textures . Count ) ;
2014-10-07 08:56:21 +00:00
if ( ( count = = 0 & & ! General . Map . Config . MixTexturesFlats ) | | ( ts . Flats . Count = = 0 & & ts . Textures . Count = = 0 ) )
continue ;
Textures Browser form: empty texture sets are no longer shown when mixed textures & flats is disabled in the current game configuration.
Textures Browser form: PK3/Directory TEXTURES images are now shown in a separate folder in the resources tree.
Fixed, Textures Browser form: fixed a logic error when trying to select initial flat when mix textures & flats was disabled in the current game configuration (this resulted in the blank textures list after opening the form).
Fixed, Textures Browser form: resources tree showed textures count even when browsing flats.
Fixed, Textures Browser form: PK3/Directory textures took precedence even when browsing flats (this means when there were a flat and a texture with the same name, a texture was displayed when browsing flats).
Fixed, Classic modes: actor's scale set in DECORATE was ignored when rendering models.
Fixed, MODELDEF parser: in some cases, several model definitions were skipped when trying to skip the current one.
Fixed, resource management: flat and sprite TEXTURES definitions were loaded only from TEXTURES files named "TEXTURES".
Fixed/added, PK3/folder resource management: patch locations for sprites defined in TEXTURES are now checked the same way as in ZDoom (previously only the "sprites" folder was checked).
Fixed/added, PK3/folder resource management: patch locations for textures defined in TEXTURES are now checked the same way as in ZDoom (previously only the "textures" folder was checked).
Fixed, PK3/folder resource management: flats defined in TEXTURES were not added to the global Flats image list.
Fixed, PK3/folder resource management: in some cases, the image search algorithm could find flats, textures, patches or sprites in incorrect folders (for example, it could find a flat in "flats_backup" folder).
2014-10-07 00:23:02 +00:00
2016-12-22 15:04:40 +00:00
item = tvTextureSets . Nodes . Add ( ts . Name ) ;
2013-09-11 09:47:53 +00:00
item . Name = ts . Name ;
2016-12-22 15:04:40 +00:00
item . Tag = new TreeNodeData { Set = ts , FolderName = ts . Name } ;
2013-09-11 09:47:53 +00:00
item . ImageIndex = 2 + ts . Location . type ;
item . SelectedImageIndex = item . ImageIndex ;
2015-03-21 20:08:47 +00:00
CreateNodes ( item ) ;
item . Expand ( ) ;
2009-04-19 18:07:22 +00:00
}
2012-07-23 21:28:23 +00:00
2015-01-16 21:38:42 +00:00
//mxd. Add "All" texture set
2022-03-05 15:57:23 +00:00
AllTextureSet alltextureset = browseflats ? General . Map . Data . FlatTextureSet : General . Map . Data . WallTextureSet ;
count = ( browseflats ? alltextureset . Flats . Count : alltextureset . Textures . Count ) ;
item = tvTextureSets . Nodes . Add ( alltextureset . Name + " [" + count + "]" ) ;
item . Name = alltextureset . Name ;
item . Tag = new TreeNodeData { Set = alltextureset , FolderName = alltextureset . Name } ;
2013-09-11 09:47:53 +00:00
item . ImageIndex = 1 ;
item . SelectedImageIndex = item . ImageIndex ;
2012-07-23 21:28:23 +00:00
2015-03-06 19:12:12 +00:00
//mxd. Should we bother finding the correct texture set?
if ( General . Settings . LocateTextureGroup )
2014-11-25 11:52:01 +00:00
{
2015-03-06 19:12:12 +00:00
//mxd. Get the previously selected texture set
2016-09-10 11:24:03 +00:00
string prevtextureset = General . Settings . ReadSetting ( "windows." + configname + ".textureset" , "" ) ;
2015-03-06 19:12:12 +00:00
TreeNode match ;
2009-04-19 18:07:22 +00:00
2016-04-01 10:49:19 +00:00
// When texture set name is empty, select "All" texture set
if ( string . IsNullOrEmpty ( prevtextureset ) )
2015-03-06 19:12:12 +00:00
{
match = tvTextureSets . Nodes [ tvTextureSets . Nodes . Count - 1 ] ;
}
else
{
2016-04-01 10:49:19 +00:00
match = FindNodeByName ( tvTextureSets . Nodes , prevtextureset ) ;
2015-03-06 19:12:12 +00:00
}
if ( match ! = null )
2014-11-25 11:52:01 +00:00
{
2016-12-22 15:04:40 +00:00
IFilledTextureSet set = ( ( TreeNodeData ) match . Tag ) . Set ;
2015-07-07 18:37:54 +00:00
foreach ( ImageData img in ( browseflats ? set . Flats : set . Textures ) )
2014-11-25 11:52:01 +00:00
{
2015-03-06 19:12:12 +00:00
if ( img . LongName = = longname )
{
selectedset = match ;
break ;
}
2013-09-11 09:47:53 +00:00
}
}
2015-03-06 19:12:12 +00:00
//mxd. If the selected texture was not found in the last-selected set, try finding it in the other sets
if ( selectedset = = null & & selecttexture ! = "-" )
2014-11-25 11:52:01 +00:00
{
2015-03-06 19:12:12 +00:00
foreach ( TreeNode n in tvTextureSets . Nodes )
{
selectedset = FindTextureByLongName ( n , longname ) ;
if ( selectedset ! = null ) break ;
}
2013-09-11 09:47:53 +00:00
}
2015-03-06 19:12:12 +00:00
//mxd. Texture still not found? Then just select the last used set
if ( selectedset = = null & & match ! = null ) selectedset = match ;
}
2012-07-23 21:28:23 +00:00
2015-01-16 21:38:42 +00:00
//mxd. Select the found set or "All", if none were found
2015-12-28 15:01:53 +00:00
if ( tvTextureSets . Nodes . Count > 0 )
2014-10-07 08:56:21 +00:00
{
2015-12-28 15:01:53 +00:00
if ( selectedset = = null ) selectedset = tvTextureSets . Nodes [ tvTextureSets . Nodes . Count - 1 ] ;
2015-03-07 21:38:58 +00:00
tvTextureSets . SelectedNodes . Clear ( ) ;
tvTextureSets . SelectedNodes . Add ( selectedset ) ;
selectedset . EnsureVisible ( ) ;
2014-10-07 08:56:21 +00:00
}
2012-07-23 21:28:23 +00:00
2016-12-22 15:04:40 +00:00
tvTextureSets . EndUpdate ( ) ; //mxd
2009-04-19 18:07:22 +00:00
2015-03-13 11:06:00 +00:00
//mxd. Set splitter position and state (doesn't work when layout is suspended)
2016-09-10 11:24:03 +00:00
if ( General . Settings . ReadSetting ( "windows." + configname + ".splittercollapsed" , false ) )
splitter . IsCollapsed = true ;
2015-04-03 12:05:37 +00:00
//mxd. Looks like SplitterDistance is unaffected by DPI scaling. Let's fix that...
2016-09-10 11:24:03 +00:00
int splitterdistance = General . Settings . ReadSetting ( "windows." + configname + ".splitterdistance" , int . MinValue ) ;
2015-04-03 12:05:37 +00:00
if ( splitterdistance = = int . MinValue )
{
splitterdistance = 210 ;
if ( MainForm . DPIScaler . Width ! = 1.0f )
{
splitterdistance = ( int ) Math . Round ( splitterdistance * MainForm . DPIScaler . Width ) ;
}
}
splitter . SplitPosition = splitterdistance ;
2009-04-19 18:07:22 +00:00
}
2013-09-11 09:47:53 +00:00
//mxd
2014-12-03 23:15:26 +00:00
private static int SortImageData ( ImageData img1 , ImageData img2 )
2014-05-20 09:09:28 +00:00
{
2016-12-22 15:04:40 +00:00
return String . Compare ( img1 . Name , img2 . Name , StringComparison . OrdinalIgnoreCase ) ;
}
//mxd
private static int SortTreeNodes ( TreeNode n1 , TreeNode n2 )
{
2016-12-24 21:52:42 +00:00
return String . Compare ( n1 . Text , n2 . Text , StringComparison . InvariantCultureIgnoreCase ) ;
2013-09-11 09:47:53 +00:00
}
//mxd
2014-12-03 23:15:26 +00:00
private TreeNode FindTextureByLongName ( TreeNode node , long longname )
2014-05-20 09:09:28 +00:00
{
2016-12-24 21:52:42 +00:00
if ( node . Name = = ALL_IMAGES ) return null ; // Skip "All images" set
2013-09-11 09:47:53 +00:00
//first search in child nodes
2015-12-28 15:01:53 +00:00
foreach ( TreeNode n in node . Nodes )
2014-11-25 11:52:01 +00:00
{
2015-12-28 15:01:53 +00:00
TreeNode match = FindTextureByLongName ( n , longname ) ;
2013-11-08 10:51:35 +00:00
if ( match ! = null ) return match ;
2013-09-11 09:47:53 +00:00
}
//then - in current node
2016-12-22 15:04:40 +00:00
IFilledTextureSet set = ( ( TreeNodeData ) node . Tag ) . Set ;
2013-09-11 09:47:53 +00:00
2015-09-16 12:10:43 +00:00
foreach ( ImageData img in ( browseflats ? set . Flats : set . Textures ) )
if ( img . LongName = = longname ) return node ;
2013-09-11 09:47:53 +00:00
return null ;
}
//mxd
2014-12-03 23:15:26 +00:00
private static TreeNode FindNodeByName ( TreeNodeCollection nodes , string selectname )
2014-05-20 09:09:28 +00:00
{
2015-12-28 15:01:53 +00:00
foreach ( TreeNode n in nodes )
2014-11-25 11:52:01 +00:00
{
2015-12-28 15:01:53 +00:00
if ( n . Name = = selectname ) return n ;
2013-09-11 09:47:53 +00:00
2014-12-03 23:15:26 +00:00
TreeNode match = FindNodeByName ( n . Nodes , selectname ) ;
2013-11-08 10:51:35 +00:00
if ( match ! = null ) return match ;
2013-09-11 09:47:53 +00:00
}
return null ;
}
//mxd
2016-12-22 15:04:40 +00:00
private void CreateNodes ( TreeNode root )
2014-05-20 09:09:28 +00:00
{
2016-12-22 15:04:40 +00:00
TreeNodeData rootdata = ( TreeNodeData ) root . Tag ;
ResourceTextureSet set = rootdata . Set as ResourceTextureSet ;
2015-12-28 15:01:53 +00:00
if ( set = = null )
2014-11-25 11:52:01 +00:00
{
2013-09-11 09:47:53 +00:00
General . ErrorLogger . Add ( ErrorType . Error , "Resource " + root . Name + " doesn't have TextureSet!" ) ;
return ;
}
2015-03-22 20:43:05 +00:00
int imageIndex = set . Location . type + 5 ;
2016-09-10 11:24:03 +00:00
char [ ] separator = { Path . AltDirectorySeparatorChar } ;
2013-09-11 09:47:53 +00:00
2014-11-25 11:52:01 +00:00
ImageData [ ] images ;
2015-12-28 15:01:53 +00:00
if ( browseflats )
Textures Browser form: empty texture sets are no longer shown when mixed textures & flats is disabled in the current game configuration.
Textures Browser form: PK3/Directory TEXTURES images are now shown in a separate folder in the resources tree.
Fixed, Textures Browser form: fixed a logic error when trying to select initial flat when mix textures & flats was disabled in the current game configuration (this resulted in the blank textures list after opening the form).
Fixed, Textures Browser form: resources tree showed textures count even when browsing flats.
Fixed, Textures Browser form: PK3/Directory textures took precedence even when browsing flats (this means when there were a flat and a texture with the same name, a texture was displayed when browsing flats).
Fixed, Classic modes: actor's scale set in DECORATE was ignored when rendering models.
Fixed, MODELDEF parser: in some cases, several model definitions were skipped when trying to skip the current one.
Fixed, resource management: flat and sprite TEXTURES definitions were loaded only from TEXTURES files named "TEXTURES".
Fixed/added, PK3/folder resource management: patch locations for sprites defined in TEXTURES are now checked the same way as in ZDoom (previously only the "sprites" folder was checked).
Fixed/added, PK3/folder resource management: patch locations for textures defined in TEXTURES are now checked the same way as in ZDoom (previously only the "textures" folder was checked).
Fixed, PK3/folder resource management: flats defined in TEXTURES were not added to the global Flats image list.
Fixed, PK3/folder resource management: in some cases, the image search algorithm could find flats, textures, patches or sprites in incorrect folders (for example, it could find a flat in "flats_backup" folder).
2014-10-07 00:23:02 +00:00
{
2014-11-25 11:52:01 +00:00
images = new ImageData [ set . Flats . Count ] ;
set . Flats . CopyTo ( images , 0 ) ;
Textures Browser form: empty texture sets are no longer shown when mixed textures & flats is disabled in the current game configuration.
Textures Browser form: PK3/Directory TEXTURES images are now shown in a separate folder in the resources tree.
Fixed, Textures Browser form: fixed a logic error when trying to select initial flat when mix textures & flats was disabled in the current game configuration (this resulted in the blank textures list after opening the form).
Fixed, Textures Browser form: resources tree showed textures count even when browsing flats.
Fixed, Textures Browser form: PK3/Directory textures took precedence even when browsing flats (this means when there were a flat and a texture with the same name, a texture was displayed when browsing flats).
Fixed, Classic modes: actor's scale set in DECORATE was ignored when rendering models.
Fixed, MODELDEF parser: in some cases, several model definitions were skipped when trying to skip the current one.
Fixed, resource management: flat and sprite TEXTURES definitions were loaded only from TEXTURES files named "TEXTURES".
Fixed/added, PK3/folder resource management: patch locations for sprites defined in TEXTURES are now checked the same way as in ZDoom (previously only the "sprites" folder was checked).
Fixed/added, PK3/folder resource management: patch locations for textures defined in TEXTURES are now checked the same way as in ZDoom (previously only the "textures" folder was checked).
Fixed, PK3/folder resource management: flats defined in TEXTURES were not added to the global Flats image list.
Fixed, PK3/folder resource management: in some cases, the image search algorithm could find flats, textures, patches or sprites in incorrect folders (for example, it could find a flat in "flats_backup" folder).
2014-10-07 00:23:02 +00:00
}
else
{
2014-11-25 11:52:01 +00:00
images = new ImageData [ set . Textures . Count ] ;
set . Textures . CopyTo ( images , 0 ) ;
Textures Browser form: empty texture sets are no longer shown when mixed textures & flats is disabled in the current game configuration.
Textures Browser form: PK3/Directory TEXTURES images are now shown in a separate folder in the resources tree.
Fixed, Textures Browser form: fixed a logic error when trying to select initial flat when mix textures & flats was disabled in the current game configuration (this resulted in the blank textures list after opening the form).
Fixed, Textures Browser form: resources tree showed textures count even when browsing flats.
Fixed, Textures Browser form: PK3/Directory textures took precedence even when browsing flats (this means when there were a flat and a texture with the same name, a texture was displayed when browsing flats).
Fixed, Classic modes: actor's scale set in DECORATE was ignored when rendering models.
Fixed, MODELDEF parser: in some cases, several model definitions were skipped when trying to skip the current one.
Fixed, resource management: flat and sprite TEXTURES definitions were loaded only from TEXTURES files named "TEXTURES".
Fixed/added, PK3/folder resource management: patch locations for sprites defined in TEXTURES are now checked the same way as in ZDoom (previously only the "sprites" folder was checked).
Fixed/added, PK3/folder resource management: patch locations for textures defined in TEXTURES are now checked the same way as in ZDoom (previously only the "textures" folder was checked).
Fixed, PK3/folder resource management: flats defined in TEXTURES were not added to the global Flats image list.
Fixed, PK3/folder resource management: in some cases, the image search algorithm could find flats, textures, patches or sprites in incorrect folders (for example, it could find a flat in "flats_backup" folder).
2014-10-07 00:23:02 +00:00
}
2014-12-03 23:15:26 +00:00
Array . Sort ( images , SortImageData ) ;
2013-09-11 09:47:53 +00:00
2016-12-22 15:04:40 +00:00
List < ImageData > rootimages = new List < ImageData > ( ) ;
2014-11-25 11:52:01 +00:00
foreach ( ImageData image in images )
{
string [ ] parts = image . VirtualName . Split ( separator , StringSplitOptions . RemoveEmptyEntries ) ;
2013-09-11 09:47:53 +00:00
TreeNode curNode = root ;
2016-12-22 15:04:40 +00:00
if ( parts . Length = = 1 )
{
rootimages . Add ( image ) ;
continue ;
}
2013-09-11 09:47:53 +00:00
2016-12-22 15:04:40 +00:00
int localindex = ( ( parts [ 0 ] = = "[TEXTURES]" | | image is TEXTURESImage ) ? 8 : imageIndex ) ;
2015-09-16 12:10:43 +00:00
string category = set . Name ;
for ( int i = 0 ; i < parts . Length - 1 ; i + + )
2014-11-25 11:52:01 +00:00
{
2015-09-16 12:10:43 +00:00
category + = ( Path . DirectorySeparatorChar + parts [ i ] ) ;
2013-09-11 09:47:53 +00:00
//already got such category?
2015-12-28 15:01:53 +00:00
if ( curNode . Nodes . Count > 0 & & curNode . Nodes . ContainsKey ( category ) )
2014-11-25 11:52:01 +00:00
{
2013-09-11 09:47:53 +00:00
curNode = curNode . Nodes [ category ] ;
2014-11-25 11:52:01 +00:00
}
else //create a new one
2015-09-16 12:10:43 +00:00
{
TreeNode n = new TreeNode ( parts [ i ] ) { Name = category , ImageIndex = localindex , SelectedImageIndex = localindex } ;
2013-09-11 09:47:53 +00:00
curNode . Nodes . Add ( n ) ;
curNode = n ;
2016-12-22 15:04:40 +00:00
curNode . Tag = new TreeNodeData { Set = new ResourceTextureSet ( category , set . Location ) , FolderName = parts [ i ] } ;
2013-09-11 09:47:53 +00:00
}
2016-12-22 15:04:40 +00:00
// Add to current node
2015-09-16 12:10:43 +00:00
if ( i = = parts . Length - 2 )
2014-11-25 11:52:01 +00:00
{
2016-12-22 15:04:40 +00:00
ResourceTextureSet curTs = ( ( TreeNodeData ) curNode . Tag ) . Set as ResourceTextureSet ;
2022-03-05 15:57:23 +00:00
if ( image . TextureNamespace = = TextureNamespace . FLAT )
2016-12-22 15:04:40 +00:00
curTs . AddFlat ( image ) ;
else
curTs . AddTexture ( image ) ;
2013-09-11 09:47:53 +00:00
}
}
}
2016-12-22 15:04:40 +00:00
// Shift the tree up when only single child node was added
2015-09-16 12:10:43 +00:00
if ( root . Nodes . Count = = 1 & & root . Nodes [ 0 ] . Nodes . Count > 0 )
2014-11-25 11:52:01 +00:00
{
2013-09-11 09:47:53 +00:00
TreeNode [ ] children = new TreeNode [ root . Nodes [ 0 ] . Nodes . Count ] ;
root . Nodes [ 0 ] . Nodes . CopyTo ( children , 0 ) ;
root . Nodes . Clear ( ) ;
root . Nodes . AddRange ( children ) ;
}
2016-12-24 21:52:42 +00:00
// Add "All set textures" node
if ( General . Map . Config . MixTexturesFlats & & root . Nodes . Count > 1 )
{
TreeNode allnode = new TreeNode ( ALL_IMAGES )
{
Name = ALL_IMAGES ,
ImageIndex = imageIndex ,
SelectedImageIndex = imageIndex ,
Tag = new TreeNodeData { Set = set , FolderName = ALL_IMAGES }
} ;
root . Nodes . Add ( allnode ) ;
}
2016-12-22 15:04:40 +00:00
// Sort immediate child nodes...
TreeNode [ ] rootnodes = new TreeNode [ root . Nodes . Count ] ;
root . Nodes . CopyTo ( rootnodes , 0 ) ;
Array . Sort ( rootnodes , SortTreeNodes ) ;
root . Nodes . Clear ( ) ;
root . Nodes . AddRange ( rootnodes ) ;
// Re-add root images
ResourceTextureSet rootset = new ResourceTextureSet ( set . Name , set . Location ) ;
if ( browseflats )
{
foreach ( ImageData data in rootimages ) rootset . AddFlat ( data ) ;
}
else
{
foreach ( ImageData data in rootimages ) rootset . AddTexture ( data ) ;
}
2016-12-24 21:52:42 +00:00
if ( General . Map . Config . MixTexturesFlats ) rootset . MixTexturesAndFlats ( ) ;
2016-12-22 15:04:40 +00:00
// Store root data
rootdata . Set = rootset ;
root . Tag = rootdata ;
// Set root images count
2016-12-24 21:52:42 +00:00
var rootsetimages = ( browseflats ? rootset . Flats : rootset . Textures ) ;
if ( rootsetimages . Count > 0 ) root . Text + = " [" + rootsetimages . Count + "]" ;
2016-12-22 15:04:40 +00:00
// Add image count to node titles
2015-12-28 15:01:53 +00:00
foreach ( TreeNode n in root . Nodes ) SetItemsCount ( n ) ;
2013-09-11 09:47:53 +00:00
}
//mxd
Textures Browser form: empty texture sets are no longer shown when mixed textures & flats is disabled in the current game configuration.
Textures Browser form: PK3/Directory TEXTURES images are now shown in a separate folder in the resources tree.
Fixed, Textures Browser form: fixed a logic error when trying to select initial flat when mix textures & flats was disabled in the current game configuration (this resulted in the blank textures list after opening the form).
Fixed, Textures Browser form: resources tree showed textures count even when browsing flats.
Fixed, Textures Browser form: PK3/Directory textures took precedence even when browsing flats (this means when there were a flat and a texture with the same name, a texture was displayed when browsing flats).
Fixed, Classic modes: actor's scale set in DECORATE was ignored when rendering models.
Fixed, MODELDEF parser: in some cases, several model definitions were skipped when trying to skip the current one.
Fixed, resource management: flat and sprite TEXTURES definitions were loaded only from TEXTURES files named "TEXTURES".
Fixed/added, PK3/folder resource management: patch locations for sprites defined in TEXTURES are now checked the same way as in ZDoom (previously only the "sprites" folder was checked).
Fixed/added, PK3/folder resource management: patch locations for textures defined in TEXTURES are now checked the same way as in ZDoom (previously only the "textures" folder was checked).
Fixed, PK3/folder resource management: flats defined in TEXTURES were not added to the global Flats image list.
Fixed, PK3/folder resource management: in some cases, the image search algorithm could find flats, textures, patches or sprites in incorrect folders (for example, it could find a flat in "flats_backup" folder).
2014-10-07 00:23:02 +00:00
private void SetItemsCount ( TreeNode node )
2014-05-20 09:09:28 +00:00
{
2016-12-22 15:04:40 +00:00
ResourceTextureSet ts = ( ( TreeNodeData ) node . Tag ) . Set as ResourceTextureSet ;
if ( ts = = null ) throw new Exception ( "Expected ResourceTextureSet, but got null..." ) ;
Textures Browser form: empty texture sets are no longer shown when mixed textures & flats is disabled in the current game configuration.
Textures Browser form: PK3/Directory TEXTURES images are now shown in a separate folder in the resources tree.
Fixed, Textures Browser form: fixed a logic error when trying to select initial flat when mix textures & flats was disabled in the current game configuration (this resulted in the blank textures list after opening the form).
Fixed, Textures Browser form: resources tree showed textures count even when browsing flats.
Fixed, Textures Browser form: PK3/Directory textures took precedence even when browsing flats (this means when there were a flat and a texture with the same name, a texture was displayed when browsing flats).
Fixed, Classic modes: actor's scale set in DECORATE was ignored when rendering models.
Fixed, MODELDEF parser: in some cases, several model definitions were skipped when trying to skip the current one.
Fixed, resource management: flat and sprite TEXTURES definitions were loaded only from TEXTURES files named "TEXTURES".
Fixed/added, PK3/folder resource management: patch locations for sprites defined in TEXTURES are now checked the same way as in ZDoom (previously only the "sprites" folder was checked).
Fixed/added, PK3/folder resource management: patch locations for textures defined in TEXTURES are now checked the same way as in ZDoom (previously only the "textures" folder was checked).
Fixed, PK3/folder resource management: flats defined in TEXTURES were not added to the global Flats image list.
Fixed, PK3/folder resource management: in some cases, the image search algorithm could find flats, textures, patches or sprites in incorrect folders (for example, it could find a flat in "flats_backup" folder).
2014-10-07 00:23:02 +00:00
2015-12-28 15:01:53 +00:00
if ( node . Parent ! = null & & General . Map . Config . MixTexturesFlats )
Textures Browser form: empty texture sets are no longer shown when mixed textures & flats is disabled in the current game configuration.
Textures Browser form: PK3/Directory TEXTURES images are now shown in a separate folder in the resources tree.
Fixed, Textures Browser form: fixed a logic error when trying to select initial flat when mix textures & flats was disabled in the current game configuration (this resulted in the blank textures list after opening the form).
Fixed, Textures Browser form: resources tree showed textures count even when browsing flats.
Fixed, Textures Browser form: PK3/Directory textures took precedence even when browsing flats (this means when there were a flat and a texture with the same name, a texture was displayed when browsing flats).
Fixed, Classic modes: actor's scale set in DECORATE was ignored when rendering models.
Fixed, MODELDEF parser: in some cases, several model definitions were skipped when trying to skip the current one.
Fixed, resource management: flat and sprite TEXTURES definitions were loaded only from TEXTURES files named "TEXTURES".
Fixed/added, PK3/folder resource management: patch locations for sprites defined in TEXTURES are now checked the same way as in ZDoom (previously only the "sprites" folder was checked).
Fixed/added, PK3/folder resource management: patch locations for textures defined in TEXTURES are now checked the same way as in ZDoom (previously only the "textures" folder was checked).
Fixed, PK3/folder resource management: flats defined in TEXTURES were not added to the global Flats image list.
Fixed, PK3/folder resource management: in some cases, the image search algorithm could find flats, textures, patches or sprites in incorrect folders (for example, it could find a flat in "flats_backup" folder).
2014-10-07 00:23:02 +00:00
{
2013-09-11 09:47:53 +00:00
ts . MixTexturesAndFlats ( ) ;
2016-12-22 15:04:40 +00:00
if ( ts . Textures . Count > 0 ) node . Text + = " [" + ts . Textures . Count + "]" ;
Textures Browser form: empty texture sets are no longer shown when mixed textures & flats is disabled in the current game configuration.
Textures Browser form: PK3/Directory TEXTURES images are now shown in a separate folder in the resources tree.
Fixed, Textures Browser form: fixed a logic error when trying to select initial flat when mix textures & flats was disabled in the current game configuration (this resulted in the blank textures list after opening the form).
Fixed, Textures Browser form: resources tree showed textures count even when browsing flats.
Fixed, Textures Browser form: PK3/Directory textures took precedence even when browsing flats (this means when there were a flat and a texture with the same name, a texture was displayed when browsing flats).
Fixed, Classic modes: actor's scale set in DECORATE was ignored when rendering models.
Fixed, MODELDEF parser: in some cases, several model definitions were skipped when trying to skip the current one.
Fixed, resource management: flat and sprite TEXTURES definitions were loaded only from TEXTURES files named "TEXTURES".
Fixed/added, PK3/folder resource management: patch locations for sprites defined in TEXTURES are now checked the same way as in ZDoom (previously only the "sprites" folder was checked).
Fixed/added, PK3/folder resource management: patch locations for textures defined in TEXTURES are now checked the same way as in ZDoom (previously only the "textures" folder was checked).
Fixed, PK3/folder resource management: flats defined in TEXTURES were not added to the global Flats image list.
Fixed, PK3/folder resource management: in some cases, the image search algorithm could find flats, textures, patches or sprites in incorrect folders (for example, it could find a flat in "flats_backup" folder).
2014-10-07 00:23:02 +00:00
}
else
{
2016-12-22 15:04:40 +00:00
int texcount = ( browseflats ? ts . Flats . Count : ts . Textures . Count ) ;
if ( texcount > 0 ) node . Text + = " [" + texcount + "]" ;
Textures Browser form: empty texture sets are no longer shown when mixed textures & flats is disabled in the current game configuration.
Textures Browser form: PK3/Directory TEXTURES images are now shown in a separate folder in the resources tree.
Fixed, Textures Browser form: fixed a logic error when trying to select initial flat when mix textures & flats was disabled in the current game configuration (this resulted in the blank textures list after opening the form).
Fixed, Textures Browser form: resources tree showed textures count even when browsing flats.
Fixed, Textures Browser form: PK3/Directory textures took precedence even when browsing flats (this means when there were a flat and a texture with the same name, a texture was displayed when browsing flats).
Fixed, Classic modes: actor's scale set in DECORATE was ignored when rendering models.
Fixed, MODELDEF parser: in some cases, several model definitions were skipped when trying to skip the current one.
Fixed, resource management: flat and sprite TEXTURES definitions were loaded only from TEXTURES files named "TEXTURES".
Fixed/added, PK3/folder resource management: patch locations for sprites defined in TEXTURES are now checked the same way as in ZDoom (previously only the "sprites" folder was checked).
Fixed/added, PK3/folder resource management: patch locations for textures defined in TEXTURES are now checked the same way as in ZDoom (previously only the "textures" folder was checked).
Fixed, PK3/folder resource management: flats defined in TEXTURES were not added to the global Flats image list.
Fixed, PK3/folder resource management: in some cases, the image search algorithm could find flats, textures, patches or sprites in incorrect folders (for example, it could find a flat in "flats_backup" folder).
2014-10-07 00:23:02 +00:00
}
2013-09-11 09:47:53 +00:00
2015-12-28 15:01:53 +00:00
foreach ( TreeNode child in node . Nodes ) SetItemsCount ( child ) ;
2013-09-11 09:47:53 +00:00
}
2012-07-23 21:28:23 +00:00
2009-04-19 18:07:22 +00:00
// Selection changed
2016-12-22 15:04:40 +00:00
private void browser_SelectedItemChanged ( ImageBrowserItem item )
2009-04-19 18:07:22 +00:00
{
2016-12-22 15:04:40 +00:00
apply . Enabled = ( item ! = null & & item . ItemType = = ImageBrowserItemType . IMAGE ) ;
2009-04-19 18:07:22 +00:00
}
// OK clicked
private void apply_Click ( object sender , EventArgs e )
{
// Set selected name and close
2016-12-22 15:04:40 +00:00
if ( browser . SelectedItem ! = null & & browser . SelectedItem . ItemType = = ImageBrowserItemType . IMAGE )
2009-04-19 18:07:22 +00:00
{
2016-12-22 15:04:40 +00:00
selectedname = browser . SelectedItem . TextureName ;
2009-04-19 18:07:22 +00:00
DialogResult = DialogResult . OK ;
}
else
{
selectedname = "" ;
DialogResult = DialogResult . Cancel ;
}
this . Close ( ) ;
}
// Cancel clicked
private void cancel_Click ( object sender , EventArgs e )
{
// No selection, close
selectedname = "" ;
DialogResult = DialogResult . Cancel ;
this . Close ( ) ;
}
// Activated
private void TextureBrowserForm_Activated ( object sender , EventArgs e )
{
Cursor . Current = Cursors . Default ;
Fixed(?), Texture Browser: possibly fixed Texture Browser not showing up / locking edit forms when current map has a ton of textures (like 2000 or more) in a single texture group.
Changed, cosmetic, Sector Info panel, Visual mode: info about currently highlighted surface is now shown using different color.
Changed, cosmetic, Linedef Info panel, Visual mode, non-UDMF: texture offset labels for currently highlighted sidedef are now shown using different color.
Changed, cosmetic, Vertex Info panel, UDMF: floor and ceiling offset labels are now grayed out when they have default values.
2015-03-23 22:39:31 +00:00
General . Interface . EnableProcessing ( ) ; //mxd
2009-04-19 18:07:22 +00:00
}
// Closing
private void TextureBrowserForm_FormClosing ( object sender , FormClosingEventArgs e )
{
// Save window settings
2016-09-10 11:24:03 +00:00
General . Settings . WriteSetting ( "windows." + configname + ".splitterdistance" , splitter . SplitPosition ) ; //mxd
General . Settings . WriteSetting ( "windows." + configname + ".splittercollapsed" , splitter . IsCollapsed ) ; //mxd
2012-07-23 21:28:23 +00:00
2016-04-01 10:49:19 +00:00
//mxd. Save last selected texture set
if ( this . DialogResult = = DialogResult . OK & & tvTextureSets . SelectedNodes . Count > 0 )
2016-09-10 11:24:03 +00:00
General . Settings . WriteSetting ( "windows." + configname + ".textureset" , tvTextureSets . SelectedNodes [ 0 ] . Name ) ;
2009-04-19 18:07:22 +00:00
// Clean up
2016-12-22 15:04:40 +00:00
browser . OnClose ( "windows." + configname ) ;
2009-04-19 18:07:22 +00:00
}
2016-12-22 15:04:40 +00:00
// Static method to browse for texture or flat.
public static string Browse ( IWin32Window parent , string select , bool browseflats )
2009-04-19 18:07:22 +00:00
{
2016-12-22 15:04:40 +00:00
TextureBrowserForm browser = new TextureBrowserForm ( select , browseflats ) ;
return ( browser . ShowDialog ( parent ) = = DialogResult . OK ? browser . SelectedName : select ) ;
2009-04-19 18:07:22 +00:00
}
// Item double clicked
2016-12-22 15:04:40 +00:00
private void browser_SelectedItemDoubleClicked ( ImageBrowserItem item )
2009-04-19 18:07:22 +00:00
{
2016-12-22 15:04:40 +00:00
if ( item = = null ) return ;
switch ( item . ItemType )
{
case ImageBrowserItemType . IMAGE :
if ( selectedset = = null ) throw new NotSupportedException ( "selectedset required!" ) ;
if ( apply . Enabled ) apply_Click ( this , EventArgs . Empty ) ;
break ;
case ImageBrowserItemType . FOLDER_UP :
if ( selectedset = = null ) throw new NotSupportedException ( "selectedset required!" ) ;
if ( selectedset . Parent ! = null )
{
// Select the node
tvTextureSets . SelectedNodes . Clear ( ) ;
tvTextureSets . SelectedNodes . Add ( selectedset . Parent ) ;
selectedset . Parent . EnsureVisible ( ) ;
// Update textures list
selectedset = selectedset . Parent ;
}
else
{
tvTextureSets . SelectedNodes . Clear ( ) ;
selectedset = null ;
}
FillImagesList ( ) ;
break ;
case ImageBrowserItemType . FOLDER :
// selectedset is null when at root level
TreeNodeCollection nodes = ( selectedset = = null ? tvTextureSets . Nodes : selectedset . Nodes ) ;
foreach ( TreeNode child in nodes )
{
TreeNodeData data = ( TreeNodeData ) child . Tag ;
if ( data . FolderName = = item . TextureName )
{
// Select the node
tvTextureSets . SelectedNodes . Clear ( ) ;
tvTextureSets . SelectedNodes . Add ( child ) ;
child . EnsureVisible ( ) ;
// Update textures list
selectedset = child ;
FillImagesList ( ) ;
break ;
}
}
break ;
default : throw new NotImplementedException ( "Unsupported ImageBrowserItemType" ) ;
}
2009-04-19 18:07:22 +00:00
}
// This fills the list of textures, depending on the selected texture set
private void FillImagesList ( )
{
2016-12-22 15:04:40 +00:00
//mxd. Show root items
if ( selectedset = = null )
{
FillCategoriesList ( ) ;
return ;
}
2009-04-19 18:07:22 +00:00
// Get the selected texture set
2016-12-22 15:04:40 +00:00
IFilledTextureSet set = ( ( TreeNodeData ) selectedset . Tag ) . Set ;
2012-07-23 21:28:23 +00:00
2013-09-11 09:47:53 +00:00
// Start adding
2016-12-22 15:04:40 +00:00
browser . BeginAdding ( false ) ;
2012-07-23 21:28:23 +00:00
2016-12-22 15:04:40 +00:00
//mxd. Add "Browse up" item
if ( selectedset . Parent ! = null )
{
TreeNodeData data = ( TreeNodeData ) selectedset . Parent . Tag ;
2016-12-23 12:39:09 +00:00
browser . AddFolder ( ImageBrowserItemType . FOLDER_UP , data . FolderName ) ;
2016-12-22 15:04:40 +00:00
}
else
{
2016-12-23 12:39:09 +00:00
browser . AddFolder ( ImageBrowserItemType . FOLDER_UP , "All Texture Sets" ) ;
2016-12-22 15:04:40 +00:00
}
//mxd. Add folders
foreach ( TreeNode child in selectedset . Nodes )
{
TreeNodeData data = ( TreeNodeData ) child . Tag ;
2016-12-23 12:39:09 +00:00
browser . AddFolder ( ImageBrowserItemType . FOLDER , data . FolderName ) ;
2016-12-22 15:04:40 +00:00
}
// Add textures
2015-12-28 15:01:53 +00:00
if ( browseflats )
2014-11-25 11:52:01 +00:00
{
2013-08-08 11:04:13 +00:00
// Add all available flats
2016-12-23 12:39:09 +00:00
foreach ( ImageData img in set . Flats ) browser . AddItem ( img ) ;
2014-11-25 11:52:01 +00:00
}
else
{
2016-12-23 12:39:09 +00:00
// Add all available textures
2022-03-05 15:57:23 +00:00
foreach ( ImageData img in set . Textures ) browser . AddItem ( img ) ;
2013-09-11 09:47:53 +00:00
}
2019-05-31 21:11:17 +00:00
browser . MakeTexturesUnique ( ) ; // biwa
2009-04-19 18:07:22 +00:00
// Done adding
browser . EndAdding ( ) ;
}
2016-12-22 15:04:40 +00:00
private void FillCategoriesList ( )
{
// Start adding
browser . BeginAdding ( false ) ;
foreach ( TreeNode node in tvTextureSets . Nodes )
{
TreeNodeData data = ( TreeNodeData ) node . Tag ;
2016-12-23 12:39:09 +00:00
browser . AddFolder ( ImageBrowserItemType . FOLDER , data . FolderName ) ;
2016-12-22 15:04:40 +00:00
}
// Done adding
browser . EndAdding ( ) ;
}
2009-04-19 18:07:22 +00:00
// Help
2016-12-22 15:04:40 +00:00
private void TextureBrowserForm_HelpRequested ( object sender , HelpEventArgs e )
2009-04-19 18:07:22 +00:00
{
General . ShowHelp ( "w_imagesbrowser.html" ) ;
2016-12-22 15:04:40 +00:00
e . Handled = true ;
2009-04-19 18:07:22 +00:00
}
private void TextureBrowserForm_Shown ( object sender , EventArgs e )
{
2016-12-22 15:04:40 +00:00
//mxd. Calling FillImagesList() from constructor results in TERRIBLE load times. Why? I have no sodding idea...
if ( selectedset ! = null ) FillImagesList ( ) ;
2013-09-11 09:47:53 +00:00
// Select texture
2015-07-07 18:37:54 +00:00
if ( selecttextureonfill ! = 0 )
2009-04-19 18:07:22 +00:00
{
2016-12-23 12:39:09 +00:00
browser . SelectItem ( selecttextureonfill ) ;
2015-07-07 18:37:54 +00:00
selecttextureonfill = 0 ;
2009-04-19 18:07:22 +00:00
}
2013-11-08 10:51:35 +00:00
2016-12-22 15:04:40 +00:00
//mxd. Focus the textures list. Calling this from TextureBrowserForm_Activated (like it's done in DB2) fails when the form is maximized. Again, I've no idea why...
browser . FocusList ( ) ;
2009-04-19 18:07:22 +00:00
}
2012-07-23 21:28:23 +00:00
2013-09-11 09:47:53 +00:00
//mxd
2014-11-25 11:52:01 +00:00
private void tvTextureSets_NodeMouseClick ( object sender , TreeNodeMouseClickEventArgs e )
{
2013-09-11 09:47:53 +00:00
selectedset = e . Node ;
FillImagesList ( ) ;
}
2013-11-21 10:53:11 +00:00
//mxd
2014-11-25 11:52:01 +00:00
private void tvTextureSets_KeyUp ( object sender , KeyEventArgs e )
{
2015-03-07 21:38:58 +00:00
if ( tvTextureSets . SelectedNodes . Count > 0 & & tvTextureSets . SelectedNodes [ 0 ] ! = selectedset )
2014-11-25 11:52:01 +00:00
{
2015-03-07 21:38:58 +00:00
selectedset = tvTextureSets . SelectedNodes [ 0 ] ;
2013-11-21 10:53:11 +00:00
FillImagesList ( ) ;
}
}
2009-04-19 18:07:22 +00:00
}
}