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 ;
using System.Drawing ;
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
{
// Variables
private string selectedname ;
private Point lastposition ;
private Size lastsize ;
2014-11-25 11:52:01 +00:00
private readonly ListViewGroup usedgroup ;
private readonly ListViewGroup availgroup ;
2013-09-11 09:47:53 +00:00
private TreeNode selectedset ; //mxd
2009-04-19 18:07:22 +00:00
private string selecttextureonfill ;
2014-11-25 11:52:01 +00:00
private readonly bool browseFlats ;
2009-04-19 18:07:22 +00:00
// Properties
public string SelectedName { get { return selectedname ; } }
// Constructor
2012-07-23 21:28:23 +00:00
public TextureBrowserForm ( string selecttexture , bool browseFlats )
2009-04-19 18:07:22 +00:00
{
Cursor . Current = Cursors . WaitCursor ;
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 ? ? "" ) ;
2014-12-03 23:15:26 +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
2013-09-11 09:47:53 +00:00
this . browseFlats = browseFlats ;
2009-04-19 18:07:22 +00:00
// Initialize
InitializeComponent ( ) ;
2012-09-05 10:31:32 +00:00
2013-09-11 09:47:53 +00:00
//mxd. Set title
string imgType = ( browseFlats ? "flats" : "textures" ) ;
this . Text = "Browse " + imgType ;
2012-09-05 10:31:32 +00:00
2014-12-03 23:30:58 +00:00
// Setup texture browser
ImageBrowserControl . ShowTextureSizes = General . Settings . ReadSetting ( "browserwindow.showtexturesizes" , General . Settings . ShowTextureSizes ) ;
ImageBrowserControl . UseLongTextureNames = General . Map . Config . UseLongTextureNames & & General . Settings . ReadSetting ( "browserwindow.uselongtexturenames" , true ) ;
2014-01-24 08:09:57 +00:00
browser . BrowseFlats = browseFlats ;
2009-04-19 18:07:22 +00:00
browser . ApplySettings ( ) ;
// Update the used textures
General . Map . Data . UpdateUsedTextures ( ) ;
2012-07-23 21:28:23 +00:00
2013-09-11 09:47:53 +00:00
tvTextureSets . BeginUpdate ( ) ; //mxd
2012-07-23 21:28:23 +00:00
2013-09-11 09:47:53 +00:00
// Texture to select when list is filled
selecttextureonfill = selecttexture ;
2012-09-05 10:31:32 +00:00
2013-09-11 09:47:53 +00:00
// Make groups
usedgroup = browser . AddGroup ( "Used " + imgType + ":" ) ;
availgroup = browser . AddGroup ( "Available " + imgType + ":" ) ;
2012-07-23 21:28:23 +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
{
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
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 ;
item . Tag = ts ;
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 )
{
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
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 ;
item . Tag = ts ;
item . ImageIndex = 2 + ts . Location . type ;
item . SelectedImageIndex = item . ImageIndex ;
2014-10-07 08:56:21 +00:00
if ( ts . Location . type ! = DataLocation . RESOURCE_WAD )
{
2014-12-03 23:15:26 +00:00
CreateNodes ( item ) ;
2014-09-08 13:09:14 +00:00
item . Expand ( ) ;
}
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. Add All textures set
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
count = ( browseFlats ? General . Map . Data . AllTextureSet . Flats . Count : General . Map . Data . AllTextureSet . Textures . Count ) ;
item = tvTextureSets . Nodes . Add ( General . Map . Data . AllTextureSet . Name + " [" + count + "]" ) ;
2013-09-11 09:47:53 +00:00
item . Name = General . Map . Data . AllTextureSet . Name ;
item . Tag = General . Map . Data . AllTextureSet ;
item . ImageIndex = 1 ;
item . SelectedImageIndex = item . ImageIndex ;
2012-07-23 21:28:23 +00:00
//mxd. Select the last one that was selected
2009-04-19 18:07:22 +00:00
string selectname = General . Settings . ReadSetting ( "browserwindow.textureset" , "" ) ;
2014-01-08 09:46:57 +00:00
TreeNode match ;
2014-12-03 09:06:05 +00:00
if ( string . IsNullOrEmpty ( selectname ) | | selectname = = "-" )
2014-11-25 11:52:01 +00:00
{
2014-12-03 09:06:05 +00:00
// When texture name is empty, select "All" texture set
2014-01-08 09:46:57 +00:00
match = tvTextureSets . Nodes [ tvTextureSets . Nodes . Count - 1 ] ;
2014-11-25 11:52:01 +00:00
}
else
{
2014-12-03 23:15:26 +00:00
match = FindNodeByName ( tvTextureSets . Nodes , selectname ) ;
2014-01-08 09:46:57 +00:00
}
2009-04-19 18:07:22 +00:00
2014-11-25 11:52:01 +00:00
if ( match ! = null )
{
2013-09-11 09:47:53 +00:00
IFilledTextureSet set = ( match . Tag as IFilledTextureSet ) ;
2014-11-25 11:52:01 +00:00
foreach ( ImageData img in set . Textures )
{
if ( img . LongName = = longname )
{
2013-09-11 09:47:53 +00:00
selectedset = match ;
break ;
}
}
}
//mxd. If the selected texture was not found in the last-selected set, try finding it in the other sets
2014-11-25 11:52:01 +00:00
if ( selectedset = = null & & selecttexture ! = "-" )
{
foreach ( TreeNode n in tvTextureSets . Nodes )
{
2014-12-03 23:15:26 +00:00
selectedset = FindTextureByLongName ( n , longname ) ;
2014-09-08 13:09:14 +00:00
if ( selectedset ! = null ) break ;
2013-09-11 09:47:53 +00:00
}
}
//mxd. Texture still now found? Then just select the last used set
if ( selectedset = = null & & match ! = null )
selectedset = match ;
2012-07-23 21:28:23 +00:00
2014-09-08 13:09:14 +00:00
//mxd. Select found node or "All" node, if none were found
2014-10-07 08:56:21 +00:00
if ( tvTextureSets . Nodes . Count > 0 )
{
if ( selectedset = = null ) selectedset = tvTextureSets . Nodes [ tvTextureSets . Nodes . Count - 1 ] ;
tvTextureSets . SelectedNode = selectedset ;
}
2012-07-23 21:28:23 +00:00
2014-09-08 13:09:14 +00:00
tvTextureSets . EndUpdate ( ) ; //mxd
2009-04-19 18:07:22 +00:00
// Keep last position and size
lastposition = this . Location ;
lastsize = this . Size ;
2012-09-05 10:31:32 +00:00
2013-09-11 09:47:53 +00:00
this . SuspendLayout ( ) ;
2012-09-05 10:31:32 +00:00
2009-04-19 18:07:22 +00:00
// Position window from configuration settings
this . Size = new Size ( General . Settings . ReadSetting ( "browserwindow.sizewidth" , this . Size . Width ) ,
General . Settings . ReadSetting ( "browserwindow.sizeheight" , this . Size . Height ) ) ;
this . WindowState = ( FormWindowState ) General . Settings . ReadSetting ( "browserwindow.windowstate" , ( int ) FormWindowState . Normal ) ;
2013-11-08 10:51:35 +00:00
//mxd
2014-11-25 11:52:01 +00:00
if ( this . WindowState = = FormWindowState . Normal )
{
2013-11-08 10:51:35 +00:00
Point location = new Point ( General . Settings . ReadSetting ( "browserwindow.positionx" , int . MaxValue ) , General . Settings . ReadSetting ( "browserwindow.positiony" , int . MaxValue ) ) ;
2014-11-25 11:52:01 +00:00
if ( location . X < int . MaxValue & & location . Y < int . MaxValue )
{
2013-11-08 10:51:35 +00:00
this . Location = location ;
2014-11-25 11:52:01 +00:00
}
else
{
2013-11-08 10:51:35 +00:00
this . StartPosition = FormStartPosition . CenterParent ;
}
}
2009-04-19 18:07:22 +00:00
this . ResumeLayout ( true ) ;
}
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
{
2013-09-11 09:47:53 +00:00
return img1 . FullName . CompareTo ( img2 . FullName ) ;
}
//mxd
2014-12-03 23:15:26 +00:00
private TreeNode FindTextureByLongName ( TreeNode node , long longname )
2014-05-20 09:09:28 +00:00
{
2013-09-11 09:47:53 +00:00
//first search in child nodes
2014-02-21 14:42:12 +00:00
TreeNode match ;
2013-09-11 09:47:53 +00:00
2014-11-25 11:52:01 +00:00
foreach ( TreeNode n in node . Nodes )
{
2014-12-03 23:15:26 +00:00
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
IFilledTextureSet set = ( node . Tag as IFilledTextureSet ) ;
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
if ( browseFlats )
{
foreach ( ImageData img in set . Flats )
if ( img . LongName = = longname ) return node ;
}
else
{
foreach ( ImageData img in 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
{
2014-11-25 11:52:01 +00:00
foreach ( TreeNode n in nodes )
{
2013-11-08 10:51:35 +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
2014-12-03 23:15:26 +00:00
private void CreateNodes ( TreeNode root )
2014-05-20 09:09:28 +00:00
{
2013-09-11 09:47:53 +00:00
ResourceTextureSet set = root . Tag as ResourceTextureSet ;
2014-11-25 11:52:01 +00:00
if ( set = = null )
{
2013-09-11 09:47:53 +00:00
General . ErrorLogger . Add ( ErrorType . Error , "Resource " + root . Name + " doesn't have TextureSet!" ) ;
return ;
}
int imageIndex = set . Location . type + 4 ;
2014-11-25 11:52:01 +00:00
char [ ] separator = new [ ] { Path . AltDirectorySeparatorChar } ;
2013-09-11 09:47:53 +00:00
2014-11-25 11:52:01 +00:00
ImageData [ ] images ;
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
if ( browseFlats )
{
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
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 ;
if ( parts . Length = = 1 ) 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
int localindex = parts [ 0 ] = = "[TEXTURES]" ? 7 : imageIndex ;
2013-09-11 09:47:53 +00:00
2014-11-25 11:52:01 +00:00
for ( int i = 0 ; i < parts . Length - 1 ; i + + )
{
2013-09-11 09:47:53 +00:00
string category = parts [ i ] ;
//already got such category?
2014-11-25 11:52:01 +00:00
if ( curNode . Nodes . Count > 0 & & curNode . Nodes . ContainsKey ( category ) )
{
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
{
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 n = new TreeNode ( category ) { Name = category , ImageIndex = localindex , SelectedImageIndex = localindex } ;
2013-09-11 09:47:53 +00:00
curNode . Nodes . Add ( n ) ;
curNode = n ;
ResourceTextureSet ts = new ResourceTextureSet ( category , set . Location ) ;
curNode . Tag = ts ;
}
//add to current and parent nodes
2014-11-25 11:52:01 +00:00
if ( i = = parts . Length - 2 )
{
2013-09-11 09:47:53 +00:00
TreeNode cn = curNode ;
2014-11-25 11:52:01 +00:00
while ( cn ! = root )
{
2013-09-11 09:47:53 +00:00
ResourceTextureSet curTs = cn . Tag as ResourceTextureSet ;
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
if ( image . IsFlat )
curTs . AddFlat ( image ) ;
else
curTs . AddTexture ( image ) ;
2013-09-11 09:47:53 +00:00
cn = cn . Parent ;
}
}
}
}
2014-11-25 11:52:01 +00:00
if ( root . Nodes . Count = = 1 & & root . Nodes [ 0 ] . Nodes . Count > 0 )
{
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 ) ;
}
2013-11-08 10:51:35 +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
{
2013-09-11 09:47:53 +00:00
ResourceTextureSet ts = node . Tag as ResourceTextureSet ;
if ( ts = = null ) throw new Exception ( "Expected IFilledTextureSet, 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
2013-09-11 09:47:53 +00:00
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
if ( node . Parent ! = null & & General . Map . Config . MixTexturesFlats )
{
2013-09-11 09:47:53 +00:00
ts . MixTexturesAndFlats ( ) ;
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
node . Text + = " [" + ts . Textures . Count + "]" ;
}
else
{
node . Text + = " [" + ( browseFlats ? ts . Flats . Count : ts . Textures . Count ) + "]" ;
}
2013-09-11 09:47:53 +00:00
foreach ( TreeNode child in node . Nodes ) SetItemsCount ( child ) ;
}
2012-07-23 21:28:23 +00:00
2009-04-19 18:07:22 +00:00
// Selection changed
private void browser_SelectedItemChanged ( )
{
apply . Enabled = ( browser . SelectedItem ! = null ) ;
}
// OK clicked
private void apply_Click ( object sender , EventArgs e )
{
// Set selected name and close
if ( browser . SelectedItem ! = null )
{
2014-11-25 11:52:01 +00:00
ImageBrowserItem item = browser . SelectedItem as ImageBrowserItem ;
2014-12-03 09:06:05 +00:00
selectedname = item . 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 ;
}
// Loading
private void TextureBrowserForm_Load ( object sender , EventArgs e )
{
// Normal windowstate?
if ( this . WindowState = = FormWindowState . Normal )
{
// Keep last position and size
lastposition = this . Location ;
lastsize = this . Size ;
}
}
// Resized
private void TextureBrowserForm_ResizeEnd ( object sender , EventArgs e )
{
// Normal windowstate?
if ( this . WindowState = = FormWindowState . Normal )
{
// Keep last position and size
lastposition = this . Location ;
lastsize = this . Size ;
}
}
// Moved
private void TextureBrowserForm_Move ( object sender , EventArgs e )
{
// Normal windowstate?
if ( this . WindowState = = FormWindowState . Normal )
{
// Keep last position and size
lastposition = this . Location ;
lastsize = this . Size ;
}
}
// Closing
private void TextureBrowserForm_FormClosing ( object sender , FormClosingEventArgs e )
{
int windowstate ;
// Determine window state to save
if ( this . WindowState ! = FormWindowState . Minimized )
windowstate = ( int ) this . WindowState ;
else
windowstate = ( int ) FormWindowState . Normal ;
// Save window settings
General . Settings . WriteSetting ( "browserwindow.positionx" , lastposition . X ) ;
General . Settings . WriteSetting ( "browserwindow.positiony" , lastposition . Y ) ;
General . Settings . WriteSetting ( "browserwindow.sizewidth" , lastsize . Width ) ;
General . Settings . WriteSetting ( "browserwindow.sizeheight" , lastsize . Height ) ;
General . Settings . WriteSetting ( "browserwindow.windowstate" , windowstate ) ;
2012-07-23 21:28:23 +00:00
2013-09-11 09:47:53 +00:00
//mxd. Save last selected texture set
2014-09-08 13:09:14 +00:00
if ( this . DialogResult = = DialogResult . OK & & tvTextureSets . SelectedNode ! = null )
2013-09-11 09:47:53 +00:00
General . Settings . WriteSetting ( "browserwindow.textureset" , tvTextureSets . SelectedNode . Name ) ;
2014-12-03 23:30:58 +00:00
//mxd. Save ImageBrowserControl settings
General . Settings . WriteSetting ( "browserwindow.showtexturesizes" , ImageBrowserControl . ShowTextureSizes ) ;
2014-12-04 07:50:01 +00:00
if ( General . Map . Config . UseLongTextureNames ) General . Settings . WriteSetting ( "browserwindow.uselongtexturenames" , ImageBrowserControl . UseLongTextureNames ) ;
2009-04-19 18:07:22 +00:00
// Clean up
browser . CleanUp ( ) ;
}
2012-07-23 21:28:23 +00:00
// Static method to browse for texture or flat
2009-04-19 18:07:22 +00:00
// Returns null when cancelled.
2012-07-23 21:28:23 +00:00
public static string Browse ( IWin32Window parent , string select , bool browseFlats )
2009-04-19 18:07:22 +00:00
{
2013-09-11 09:47:53 +00:00
TextureBrowserForm browser = new TextureBrowserForm ( select , browseFlats ) ;
2014-12-03 23:30:58 +00:00
if ( browser . ShowDialog ( parent ) = = DialogResult . OK ) return browser . SelectedName ; // Return result
2013-11-08 10:51:35 +00:00
// Cancelled
return select ;
2009-04-19 18:07:22 +00:00
}
// Item double clicked
private void browser_SelectedItemDoubleClicked ( )
{
if ( apply . Enabled ) apply_Click ( this , EventArgs . Empty ) ;
}
// This fills the list of textures, depending on the selected texture set
private void FillImagesList ( )
{
// Get the selected texture set
IFilledTextureSet set = ( selectedset . Tag as IFilledTextureSet ) ;
2012-07-23 21:28:23 +00:00
2013-09-11 09:47:53 +00:00
// Start adding
browser . BeginAdding ( false ) ;
2012-07-23 21:28:23 +00:00
2014-11-25 11:52:01 +00:00
if ( browseFlats )
{
2013-08-08 11:04:13 +00:00
// Add all available flats
foreach ( ImageData img in set . Flats )
2014-12-03 09:06:05 +00:00
browser . Add ( img , img , availgroup ) ;
2012-07-23 21:28:23 +00:00
2013-08-08 11:04:13 +00:00
// Add all used flats
foreach ( ImageData img in set . Flats )
2014-12-03 09:06:05 +00:00
if ( img . UsedInMap ) browser . Add ( img , img , usedgroup ) ;
2014-11-25 11:52:01 +00:00
}
else
{
2013-09-11 09:47:53 +00:00
// Add all available textures and mark the images for temporary loading
foreach ( ImageData img in set . Textures )
2014-12-03 09:06:05 +00:00
browser . Add ( img , img , availgroup ) ;
2013-09-11 09:47:53 +00:00
// Add all used textures and mark the images for permanent loading
foreach ( ImageData img in set . Textures )
2014-12-03 09:06:05 +00:00
if ( img . UsedInMap ) browser . Add ( img , img , usedgroup ) ;
2013-09-11 09:47:53 +00:00
}
2009-04-19 18:07:22 +00:00
// Done adding
browser . EndAdding ( ) ;
}
// Help
private void TextureBrowserForm_HelpRequested ( object sender , HelpEventArgs hlpevent )
{
General . ShowHelp ( "w_imagesbrowser.html" ) ;
hlpevent . Handled = true ;
}
private void TextureBrowserForm_Shown ( object sender , EventArgs e )
{
2013-09-11 09:47:53 +00:00
if ( selectedset ! = null ) //mxd. Calling FillImagesList() from constructor leads to TERRIBLE load times. Why? I have no sodding idea...
FillImagesList ( ) ;
// Select texture
2009-04-19 18:07:22 +00:00
if ( ! string . IsNullOrEmpty ( selecttextureonfill ) )
{
browser . SelectItem ( selecttextureonfill , usedgroup ) ;
selecttextureonfill = null ;
}
2013-11-08 10:51:35 +00:00
//mxd. Focus the textbox. Calling this from TextureBrowserForm_Activated (like it's done in DB2) fails when the form is maximized. Again, I've no idea why...
browser . FocusTextbox ( ) ;
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 )
{
if ( tvTextureSets . SelectedNode ! = selectedset )
{
2013-11-21 10:53:11 +00:00
selectedset = tvTextureSets . SelectedNode ;
FillImagesList ( ) ;
}
}
2009-04-19 18:07:22 +00:00
}
}