2010-11-20 10:37:14 +00:00
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
2011-04-19 08:34:51 +00:00
# ifndef GAME_EDITOR_EDITOR_H
# define GAME_EDITOR_EDITOR_H
2010-05-29 07:25:38 +00:00
2011-07-08 23:09:06 +00:00
# include <math.h>
2010-05-29 07:25:38 +00:00
# include <base/math.h>
2011-07-08 23:09:06 +00:00
# include <base/system.h>
2010-05-29 07:25:38 +00:00
# include <base/tl/algorithm.h>
2011-07-08 23:09:06 +00:00
# include <base/tl/array.h>
2010-09-12 11:15:59 +00:00
# include <base/tl/sorted_array.h>
# include <base/tl/string.h>
2010-05-29 07:25:38 +00:00
2011-07-08 23:09:06 +00:00
# include <game/client/ui.h>
2010-05-29 07:25:38 +00:00
# include <game/mapitems.h>
# include <game/client/render.h>
# include <engine/shared/config.h>
2011-07-08 23:09:06 +00:00
# include <engine/shared/datafile.h>
2010-05-29 07:25:38 +00:00
# include <engine/editor.h>
# include <engine/graphics.h>
2014-10-08 14:53:25 +00:00
# include <engine/sound.h>
2010-05-29 07:25:38 +00:00
2011-07-08 23:09:06 +00:00
# include "auto_map.h"
2010-05-29 07:25:38 +00:00
typedef void ( * INDEX_MODIFY_FUNC ) ( int * pIndex ) ;
//CRenderTools m_RenderTools;
// CEditor SPECIFIC
enum
{
MODE_LAYERS = 0 ,
MODE_IMAGES ,
2014-10-08 12:50:25 +00:00
MODE_SOUNDS ,
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
DIALOG_NONE = 0 ,
DIALOG_FILE ,
} ;
struct CEntity
{
CPoint m_Position ;
int m_Type ;
} ;
class CEnvelope
{
public :
int m_Channels ;
array < CEnvPoint > m_lPoints ;
char m_aName [ 32 ] ;
float m_Bottom , m_Top ;
2011-12-04 13:34:27 +00:00
bool m_Synchronized ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
CEnvelope ( int Chan )
{
m_Channels = Chan ;
m_aName [ 0 ] = 0 ;
m_Bottom = 0 ;
m_Top = 0 ;
2016-05-13 22:42:40 +00:00
m_Synchronized = false ;
2010-05-29 07:25:38 +00:00
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
void Resort ( )
{
sort ( m_lPoints . all ( ) ) ;
FindTopBottom ( 0xf ) ;
}
void FindTopBottom ( int ChannelMask )
{
m_Top = - 1000000000.0f ;
m_Bottom = 1000000000.0f ;
for ( int i = 0 ; i < m_lPoints . size ( ) ; i + + )
{
for ( int c = 0 ; c < m_Channels ; c + + )
{
if ( ChannelMask & ( 1 < < c ) )
{
float v = fx2f ( m_lPoints [ i ] . m_aValues [ c ] ) ;
if ( v > m_Top ) m_Top = v ;
if ( v < m_Bottom ) m_Bottom = v ;
}
}
}
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
int Eval ( float Time , float * pResult )
{
CRenderTools : : RenderEvalEnvelope ( m_lPoints . base_ptr ( ) , m_lPoints . size ( ) , m_Channels , Time , pResult ) ;
return m_Channels ;
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
void AddPoint ( int Time , int v0 , int v1 = 0 , int v2 = 0 , int v3 = 0 )
{
CEnvPoint p ;
p . m_Time = Time ;
p . m_aValues [ 0 ] = v0 ;
p . m_aValues [ 1 ] = v1 ;
p . m_aValues [ 2 ] = v2 ;
p . m_aValues [ 3 ] = v3 ;
p . m_Curvetype = CURVETYPE_LINEAR ;
m_lPoints . add ( p ) ;
Resort ( ) ;
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
float EndTime ( )
{
if ( m_lPoints . size ( ) )
return m_lPoints [ m_lPoints . size ( ) - 1 ] . m_Time * ( 1.0f / 1000.0f ) ;
return 0 ;
}
} ;
class CLayer ;
class CLayerGroup ;
class CEditorMap ;
class CLayer
{
public :
class CEditor * m_pEditor ;
class IGraphics * Graphics ( ) ;
class ITextRender * TextRender ( ) ;
CLayer ( )
{
m_Type = LAYERTYPE_INVALID ;
2011-07-12 01:14:46 +00:00
str_copy ( m_aName , " (invalid) " , sizeof ( m_aName ) ) ;
2010-05-29 07:25:38 +00:00
m_Visible = true ;
m_Readonly = false ;
2010-10-16 16:50:05 +00:00
m_SaveToMap = true ;
2010-05-29 07:25:38 +00:00
m_Flags = 0 ;
m_pEditor = 0 ;
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
virtual ~ CLayer ( )
{
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
virtual void BrushSelecting ( CUIRect Rect ) { }
virtual int BrushGrab ( CLayerGroup * pBrush , CUIRect Rect ) { return 0 ; }
virtual void FillSelection ( bool Empty , CLayer * pBrush , CUIRect Rect ) { }
virtual void BrushDraw ( CLayer * pBrush , float x , float y ) { }
virtual void BrushPlace ( CLayer * pBrush , float x , float y ) { }
virtual void BrushFlipX ( ) { }
virtual void BrushFlipY ( ) { }
virtual void BrushRotate ( float Amount ) { }
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
virtual void Render ( ) { }
virtual int RenderProperties ( CUIRect * pToolbox ) { return 0 ; }
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
virtual void ModifyImageIndex ( INDEX_MODIFY_FUNC pfnFunc ) { }
virtual void ModifyEnvelopeIndex ( INDEX_MODIFY_FUNC pfnFunc ) { }
2014-10-11 11:38:45 +00:00
virtual void ModifySoundIndex ( INDEX_MODIFY_FUNC pfnFunc ) { }
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
virtual void GetSize ( float * w , float * h ) { * w = 0 ; * h = 0 ; }
2011-04-13 18:37:12 +00:00
2011-07-12 01:14:46 +00:00
char m_aName [ 12 ] ;
2010-05-29 07:25:38 +00:00
int m_Type ;
int m_Flags ;
bool m_Readonly ;
bool m_Visible ;
2010-10-16 16:50:05 +00:00
bool m_SaveToMap ;
2010-05-29 07:25:38 +00:00
} ;
class CLayerGroup
{
public :
class CEditorMap * m_pMap ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
array < CLayer * > m_lLayers ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
int m_OffsetX ;
int m_OffsetY ;
int m_ParallaxX ;
int m_ParallaxY ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
int m_UseClipping ;
int m_ClipX ;
int m_ClipY ;
int m_ClipW ;
int m_ClipH ;
2011-04-13 18:37:12 +00:00
2011-07-12 01:14:46 +00:00
char m_aName [ 12 ] ;
2010-05-29 07:25:38 +00:00
bool m_GameGroup ;
bool m_Visible ;
2010-10-16 16:50:05 +00:00
bool m_SaveToMap ;
2011-07-12 15:54:59 +00:00
bool m_Collapse ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
CLayerGroup ( ) ;
~ CLayerGroup ( ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
void Convert ( CUIRect * pRect ) ;
void Render ( ) ;
void MapScreen ( ) ;
void Mapping ( float * pPoints ) ;
void GetSize ( float * w , float * h ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
void DeleteLayer ( int Index ) ;
int SwapLayers ( int Index0 , int Index1 ) ;
2011-04-13 18:37:12 +00:00
bool IsEmpty ( ) const
2010-05-29 07:25:38 +00:00
{
2014-03-12 22:27:03 +00:00
return m_lLayers . size ( ) = = 0 ; // stupid function, since its bad for Fillselection: TODO add a function for Fillselection that returns whether a specific tile is used in the given layer
2010-05-29 07:25:38 +00:00
}
2015-07-09 00:08:14 +00:00
2014-03-12 22:27:03 +00:00
/*bool IsUsedInThisLayer(int Layer, int Index) // <--------- this is what i meant but cause i dont know which Indexes belongs to which layers i cant finish yet
{
switch Layer
{
case LAYERTYPE_GAME : // security
return true ;
case LAYERTYPE_FRONT :
return true ;
case LAYERTYPE_TELE :
{
if ( Index = = ) // you could add an 2D array into mapitems.h which defines which Indexes belong to which layer(s)
}
case LAYERTYPE_SPEEDUP :
{
if ( Index = = TILE_BOOST )
return true ;
else
return false ;
}
case LAYERTYPE_SWITCH :
{
2015-07-09 00:08:14 +00:00
2014-03-12 22:27:03 +00:00
}
case LAYERTYPE_TUNE :
{
if ( Index = = TILE_TUNE1 )
return true ;
else
return false ;
}
default :
return false ;
}
} */
2011-04-13 18:37:12 +00:00
void Clear ( )
{
2010-05-29 07:25:38 +00:00
m_lLayers . delete_all ( ) ;
}
2011-04-13 18:37:12 +00:00
2011-03-21 23:31:42 +00:00
void AddLayer ( CLayer * l ) ;
2010-05-29 07:25:38 +00:00
void ModifyImageIndex ( INDEX_MODIFY_FUNC Func )
{
for ( int i = 0 ; i < m_lLayers . size ( ) ; i + + )
m_lLayers [ i ] - > ModifyImageIndex ( Func ) ;
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
void ModifyEnvelopeIndex ( INDEX_MODIFY_FUNC Func )
{
for ( int i = 0 ; i < m_lLayers . size ( ) ; i + + )
m_lLayers [ i ] - > ModifyEnvelopeIndex ( Func ) ;
}
2014-10-11 11:38:45 +00:00
void ModifySoundIndex ( INDEX_MODIFY_FUNC Func )
{
for ( int i = 0 ; i < m_lLayers . size ( ) ; i + + )
m_lLayers [ i ] - > ModifySoundIndex ( Func ) ;
}
2010-05-29 07:25:38 +00:00
} ;
class CEditorImage : public CImageInfo
{
public :
CEditor * m_pEditor ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
CEditorImage ( CEditor * pEditor )
2011-07-08 23:09:06 +00:00
: m_AutoMapper ( pEditor )
2010-05-29 07:25:38 +00:00
{
m_pEditor = pEditor ;
2011-02-12 10:40:36 +00:00
m_TexID = - 1 ;
2010-05-29 07:25:38 +00:00
m_aName [ 0 ] = 0 ;
m_External = 0 ;
m_Width = 0 ;
m_Height = 0 ;
m_pData = 0 ;
m_Format = 0 ;
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
~ CEditorImage ( ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
void AnalyseTileFlags ( ) ;
2011-04-13 18:37:12 +00:00
2011-02-12 10:40:36 +00:00
int m_TexID ;
2010-05-29 07:25:38 +00:00
int m_External ;
char m_aName [ 128 ] ;
unsigned char m_aTileFlags [ 256 ] ;
2011-07-08 23:09:06 +00:00
class CAutoMapper m_AutoMapper ;
2010-05-29 07:25:38 +00:00
} ;
2014-10-08 12:50:25 +00:00
class CEditorSound
{
public :
2014-10-11 11:38:45 +00:00
CEditor * m_pEditor ;
2015-07-09 00:08:14 +00:00
2014-10-11 11:38:45 +00:00
CEditorSound ( CEditor * pEditor )
2014-10-08 12:50:25 +00:00
{
2014-10-11 11:38:45 +00:00
m_pEditor = pEditor ;
2014-10-08 12:50:25 +00:00
m_aName [ 0 ] = 0 ;
m_External = 0 ;
2014-10-08 14:53:25 +00:00
m_SoundID = 0 ;
2014-10-11 12:50:16 +00:00
m_pData = 0x0 ;
m_DataSize = 0 ;
2014-10-08 12:50:25 +00:00
}
2014-10-11 11:38:45 +00:00
~ CEditorSound ( ) ;
2014-10-08 14:53:25 +00:00
int m_SoundID ;
2014-10-08 12:50:25 +00:00
int m_External ;
char m_aName [ 128 ] ;
2014-10-11 12:50:16 +00:00
void * m_pData ;
unsigned m_DataSize ;
2014-10-08 12:50:25 +00:00
} ;
2010-05-29 07:25:38 +00:00
class CEditorMap
{
void MakeGameGroup ( CLayerGroup * pGroup ) ;
void MakeGameLayer ( CLayer * pLayer ) ;
public :
CEditor * m_pEditor ;
2011-03-21 23:31:42 +00:00
bool m_Modified ;
2014-01-19 03:02:01 +00:00
int m_UndoModified ;
2010-05-29 07:25:38 +00:00
CEditorMap ( )
{
Clean ( ) ;
}
array < CLayerGroup * > m_lGroups ;
array < CEditorImage * > m_lImages ;
array < CEnvelope * > m_lEnvelopes ;
2014-10-08 12:50:25 +00:00
array < CEditorSound * > m_lSounds ;
2011-04-13 18:37:12 +00:00
2011-07-12 21:31:39 +00:00
class CMapInfo
{
public :
char m_aAuthorTmp [ 32 ] ;
char m_aVersionTmp [ 16 ] ;
char m_aCreditsTmp [ 128 ] ;
char m_aLicenseTmp [ 32 ] ;
char m_aAuthor [ 32 ] ;
char m_aVersion [ 16 ] ;
char m_aCredits [ 128 ] ;
char m_aLicense [ 32 ] ;
void Reset ( )
{
m_aAuthorTmp [ 0 ] = 0 ;
m_aVersionTmp [ 0 ] = 0 ;
m_aCreditsTmp [ 0 ] = 0 ;
m_aLicenseTmp [ 0 ] = 0 ;
m_aAuthor [ 0 ] = 0 ;
m_aVersion [ 0 ] = 0 ;
m_aCredits [ 0 ] = 0 ;
m_aLicense [ 0 ] = 0 ;
}
} ;
CMapInfo m_MapInfo ;
2011-07-13 20:38:32 +00:00
struct CSetting
{
char m_aCommand [ 64 ] ;
} ;
array < CSetting > m_lSettings ;
2010-05-29 07:25:38 +00:00
class CLayerGame * m_pGameLayer ;
CLayerGroup * m_pGameGroup ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
CEnvelope * NewEnvelope ( int Channels )
{
2011-03-21 23:31:42 +00:00
m_Modified = true ;
2014-01-19 03:02:01 +00:00
m_UndoModified + + ;
2010-05-29 07:25:38 +00:00
CEnvelope * e = new CEnvelope ( Channels ) ;
m_lEnvelopes . add ( e ) ;
return e ;
}
2010-08-06 18:18:53 +00:00
void DeleteEnvelope ( int Index ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
CLayerGroup * NewGroup ( )
{
2011-03-21 23:31:42 +00:00
m_Modified = true ;
2014-01-19 03:02:01 +00:00
m_UndoModified + + ;
2010-05-29 07:25:38 +00:00
CLayerGroup * g = new CLayerGroup ;
g - > m_pMap = this ;
m_lGroups . add ( g ) ;
return g ;
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
int SwapGroups ( int Index0 , int Index1 )
{
if ( Index0 < 0 | | Index0 > = m_lGroups . size ( ) ) return Index0 ;
if ( Index1 < 0 | | Index1 > = m_lGroups . size ( ) ) return Index0 ;
if ( Index0 = = Index1 ) return Index0 ;
2011-03-21 23:31:42 +00:00
m_Modified = true ;
2014-01-19 03:02:01 +00:00
m_UndoModified + + ;
2010-05-29 07:25:38 +00:00
swap ( m_lGroups [ Index0 ] , m_lGroups [ Index1 ] ) ;
return Index1 ;
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
void DeleteGroup ( int Index )
{
if ( Index < 0 | | Index > = m_lGroups . size ( ) ) return ;
2011-03-21 23:31:42 +00:00
m_Modified = true ;
2014-01-19 03:02:01 +00:00
m_UndoModified + + ;
2010-05-29 07:25:38 +00:00
delete m_lGroups [ Index ] ;
m_lGroups . remove_index ( Index ) ;
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
void ModifyImageIndex ( INDEX_MODIFY_FUNC pfnFunc )
{
2011-03-21 23:31:42 +00:00
m_Modified = true ;
2014-01-19 03:02:01 +00:00
m_UndoModified + + ;
2010-05-29 07:25:38 +00:00
for ( int i = 0 ; i < m_lGroups . size ( ) ; i + + )
m_lGroups [ i ] - > ModifyImageIndex ( pfnFunc ) ;
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
void ModifyEnvelopeIndex ( INDEX_MODIFY_FUNC pfnFunc )
{
2011-03-21 23:31:42 +00:00
m_Modified = true ;
2014-01-19 03:02:01 +00:00
m_UndoModified + + ;
2010-05-29 07:25:38 +00:00
for ( int i = 0 ; i < m_lGroups . size ( ) ; i + + )
m_lGroups [ i ] - > ModifyEnvelopeIndex ( pfnFunc ) ;
}
2011-04-13 18:37:12 +00:00
2014-10-11 11:38:45 +00:00
void ModifySoundIndex ( INDEX_MODIFY_FUNC pfnFunc )
{
m_Modified = true ;
m_UndoModified + + ;
for ( int i = 0 ; i < m_lGroups . size ( ) ; i + + )
m_lGroups [ i ] - > ModifySoundIndex ( pfnFunc ) ;
}
2010-05-29 07:25:38 +00:00
void Clean ( ) ;
void CreateDefault ( int EntitiesTexture ) ;
2011-04-13 18:37:12 +00:00
// io
2010-05-29 07:25:38 +00:00
int Save ( class IStorage * pStorage , const char * pFilename ) ;
2010-10-07 21:51:07 +00:00
int Load ( class IStorage * pStorage , const char * pFilename , int StorageType ) ;
2011-04-09 06:41:31 +00:00
// DDRace
class CLayerTele * m_pTeleLayer ;
class CLayerSpeedup * m_pSpeedupLayer ;
class CLayerFront * m_pFrontLayer ;
class CLayerSwitch * m_pSwitchLayer ;
2014-03-12 22:27:03 +00:00
class CLayerTune * m_pTuneLayer ;
2010-09-30 21:31:19 +00:00
void MakeTeleLayer ( CLayer * pLayer ) ;
void MakeSpeedupLayer ( CLayer * pLayer ) ;
void MakeFrontLayer ( CLayer * pLayer ) ;
void MakeSwitchLayer ( CLayer * pLayer ) ;
2014-03-12 22:27:03 +00:00
void MakeTuneLayer ( CLayer * pLayer ) ;
2010-05-29 07:25:38 +00:00
} ;
struct CProperty
{
const char * m_pName ;
int m_Value ;
int m_Type ;
int m_Min ;
int m_Max ;
} ;
enum
{
PROPTYPE_NULL = 0 ,
PROPTYPE_BOOL ,
PROPTYPE_INT_STEP ,
PROPTYPE_INT_SCROLL ,
2015-07-08 11:55:02 +00:00
PROPTYPE_ANGLE_SCROLL ,
2010-05-29 07:25:38 +00:00
PROPTYPE_COLOR ,
PROPTYPE_IMAGE ,
PROPTYPE_ENVELOPE ,
2010-10-09 16:38:23 +00:00
PROPTYPE_SHIFT ,
2014-10-08 15:33:06 +00:00
PROPTYPE_SOUND ,
2010-05-29 07:25:38 +00:00
} ;
typedef struct
{
int x , y ;
int w , h ;
} RECTi ;
class CLayerTiles : public CLayer
{
public :
CLayerTiles ( int w , int h ) ;
~ CLayerTiles ( ) ;
2016-04-30 23:47:29 +00:00
virtual CTile GetTile ( int x , int y ) ;
virtual void SetTile ( int x , int y , CTile tile ) ;
2015-11-14 23:00:43 +00:00
2010-09-30 21:31:19 +00:00
virtual void Resize ( int NewW , int NewH ) ;
2010-10-20 13:56:29 +00:00
virtual void Shift ( int Direction ) ;
2010-05-29 07:25:38 +00:00
void MakePalette ( ) ;
virtual void Render ( ) ;
2015-07-09 00:08:14 +00:00
2010-05-29 07:25:38 +00:00
int ConvertX ( float x ) const ;
int ConvertY ( float y ) const ;
void Convert ( CUIRect Rect , RECTi * pOut ) ;
void Snap ( CUIRect * pRect ) ;
void Clamp ( RECTi * pRect ) ;
virtual void BrushSelecting ( CUIRect Rect ) ;
virtual int BrushGrab ( CLayerGroup * pBrush , CUIRect Rect ) ;
virtual void FillSelection ( bool Empty , CLayer * pBrush , CUIRect Rect ) ;
virtual void BrushDraw ( CLayer * pBrush , float wx , float wy ) ;
virtual void BrushFlipX ( ) ;
virtual void BrushFlipY ( ) ;
2010-09-05 17:01:01 +00:00
virtual void BrushRotate ( float Amount ) ;
2011-04-13 18:37:12 +00:00
2011-02-18 10:41:27 +00:00
virtual void ShowInfo ( ) ;
2010-05-29 07:25:38 +00:00
virtual int RenderProperties ( CUIRect * pToolbox ) ;
virtual void ModifyImageIndex ( INDEX_MODIFY_FUNC pfnFunc ) ;
virtual void ModifyEnvelopeIndex ( INDEX_MODIFY_FUNC pfnFunc ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
void PrepareForSave ( ) ;
2011-04-13 18:37:12 +00:00
void GetSize ( float * w , float * h ) { * w = m_Width * 32.0f ; * h = m_Height * 32.0f ; }
2011-02-12 10:40:36 +00:00
int m_TexID ;
2010-05-29 07:25:38 +00:00
int m_Game ;
int m_Image ;
int m_Width ;
int m_Height ;
2011-01-04 10:38:14 +00:00
CColor m_Color ;
2011-07-18 10:05:12 +00:00
int m_ColorEnv ;
int m_ColorEnvOffset ;
2010-05-29 07:25:38 +00:00
CTile * m_pTiles ;
2011-04-09 06:41:31 +00:00
// DDRace
int m_Tele ;
int m_Speedup ;
int m_Front ;
int m_Switch ;
2014-03-12 22:27:03 +00:00
int m_Tune ;
2010-12-19 14:10:42 +00:00
char m_aFileName [ 512 ] ;
2010-05-29 07:25:38 +00:00
} ;
class CLayerQuads : public CLayer
{
public :
CLayerQuads ( ) ;
~ CLayerQuads ( ) ;
virtual void Render ( ) ;
CQuad * NewQuad ( ) ;
2010-09-27 19:41:41 +00:00
2010-05-29 07:25:38 +00:00
virtual void BrushSelecting ( CUIRect Rect ) ;
virtual int BrushGrab ( CLayerGroup * pBrush , CUIRect Rect ) ;
virtual void BrushPlace ( CLayer * pBrush , float wx , float wy ) ;
virtual void BrushFlipX ( ) ;
virtual void BrushFlipY ( ) ;
virtual void BrushRotate ( float Amount ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
virtual int RenderProperties ( CUIRect * pToolbox ) ;
virtual void ModifyImageIndex ( INDEX_MODIFY_FUNC pfnFunc ) ;
virtual void ModifyEnvelopeIndex ( INDEX_MODIFY_FUNC pfnFunc ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
void GetSize ( float * w , float * h ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
int m_Image ;
array < CQuad > m_lQuads ;
} ;
class CLayerGame : public CLayerTiles
{
public :
CLayerGame ( int w , int h ) ;
~ CLayerGame ( ) ;
2016-04-30 23:47:29 +00:00
virtual CTile GetTile ( int x , int y ) ;
virtual void SetTile ( int x , int y , CTile tile ) ;
2015-11-14 23:00:43 +00:00
2010-05-29 07:25:38 +00:00
virtual int RenderProperties ( CUIRect * pToolbox ) ;
} ;
class CEditor : public IEditor
{
class IInput * m_pInput ;
class IClient * m_pClient ;
2010-08-17 22:06:00 +00:00
class IConsole * m_pConsole ;
2010-05-29 07:25:38 +00:00
class IGraphics * m_pGraphics ;
class ITextRender * m_pTextRender ;
2014-10-08 14:53:25 +00:00
class ISound * m_pSound ;
2010-09-12 11:15:59 +00:00
class IStorage * m_pStorage ;
2010-05-29 07:25:38 +00:00
CRenderTools m_RenderTools ;
CUI m_UI ;
public :
class IInput * Input ( ) { return m_pInput ; } ;
class IClient * Client ( ) { return m_pClient ; } ;
2010-08-17 22:06:00 +00:00
class IConsole * Console ( ) { return m_pConsole ; } ;
2010-05-29 07:25:38 +00:00
class IGraphics * Graphics ( ) { return m_pGraphics ; } ;
2014-10-08 14:53:25 +00:00
class ISound * Sound ( ) { return m_pSound ; }
2010-05-29 07:25:38 +00:00
class ITextRender * TextRender ( ) { return m_pTextRender ; } ;
2010-09-12 11:15:59 +00:00
class IStorage * Storage ( ) { return m_pStorage ; } ;
2010-05-29 07:25:38 +00:00
CUI * UI ( ) { return & m_UI ; }
CRenderTools * RenderTools ( ) { return & m_RenderTools ; }
CEditor ( ) : m_TilesetPicker ( 16 , 16 )
{
m_pInput = 0 ;
m_pClient = 0 ;
m_pGraphics = 0 ;
m_pTextRender = 0 ;
2014-10-08 14:53:25 +00:00
m_pSound = 0 ;
2010-05-29 07:25:38 +00:00
m_Mode = MODE_LAYERS ;
m_Dialog = 0 ;
2012-01-08 12:36:47 +00:00
m_EditBoxActive = 0 ;
2010-05-29 07:25:38 +00:00
m_pTooltip = 0 ;
2011-07-10 20:16:16 +00:00
m_GridActive = false ;
m_GridFactor = 1 ;
2010-05-29 07:25:38 +00:00
m_aFileName [ 0 ] = 0 ;
2011-03-21 23:31:42 +00:00
m_aFileSaveName [ 0 ] = 0 ;
2010-10-08 20:06:12 +00:00
m_ValidSaveFilename = false ;
2011-03-21 23:31:42 +00:00
m_PopupEventActivated = false ;
2011-08-13 17:22:01 +00:00
m_PopupEventWasActivated = false ;
2011-04-13 18:37:12 +00:00
2010-10-06 21:07:35 +00:00
m_FileDialogStorageType = 0 ;
2010-09-16 10:48:32 +00:00
m_pFileDialogTitle = 0 ;
m_pFileDialogButtonText = 0 ;
m_pFileDialogUser = 0 ;
2010-09-12 11:15:59 +00:00
m_aFileDialogFileName [ 0 ] = 0 ;
2010-10-07 21:51:07 +00:00
m_aFileDialogCurrentFolder [ 0 ] = 0 ;
m_aFileDialogCurrentLink [ 0 ] = 0 ;
m_pFileDialogPath = m_aFileDialogCurrentFolder ;
m_aFileDialogActivate = false ;
m_FileDialogScrollValue = 0.0f ;
m_FilesSelectedIndex = - 1 ;
2010-09-12 11:15:59 +00:00
m_FilesStartAt = 0 ;
m_FilesCur = 0 ;
m_FilesStopAt = 999 ;
2010-05-29 07:25:38 +00:00
m_WorldOffsetX = 0 ;
m_WorldOffsetY = 0 ;
m_EditorOffsetX = 0.0f ;
m_EditorOffsetY = 0.0f ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
m_WorldZoom = 1.0f ;
m_ZoomLevel = 200 ;
m_LockMouse = false ;
m_ShowMousePointer = true ;
m_MouseDeltaX = 0 ;
m_MouseDeltaY = 0 ;
m_MouseDeltaWx = 0 ;
m_MouseDeltaWy = 0 ;
2014-09-29 11:13:56 +00:00
# if defined(__ANDROID__)
m_OldMouseX = 0 ;
m_OldMouseY = 0 ;
# endif
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
m_GuiActive = true ;
m_ProofBorders = false ;
2011-04-13 18:37:12 +00:00
2011-02-18 10:41:27 +00:00
m_ShowTileInfo = false ;
2010-05-29 07:25:38 +00:00
m_ShowDetail = true ;
m_Animate = false ;
m_AnimateStart = 0 ;
m_AnimateTime = 0 ;
m_AnimateSpeed = 1 ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
m_ShowEnvelopeEditor = 0 ;
2014-01-19 03:02:01 +00:00
m_ShowUndo = 0 ;
m_UndoScrollValue = 0.0f ;
2011-07-13 20:38:32 +00:00
m_ShowServerSettingsEditor = false ;
2011-04-13 18:37:12 +00:00
2011-08-15 18:12:31 +00:00
m_ShowEnvelopePreview = 0 ;
m_SelectedQuadEnvelope = - 1 ;
m_SelectedEnvelopePoint = - 1 ;
2011-08-14 14:31:48 +00:00
2011-07-13 20:38:32 +00:00
m_CommandBox = 0.0f ;
m_aSettingsCommand [ 0 ] = 0 ;
2010-05-29 07:25:38 +00:00
ms_CheckerTexture = 0 ;
ms_BackgroundTexture = 0 ;
ms_CursorTexture = 0 ;
ms_EntitiesTexture = 0 ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
ms_pUiGotContext = 0 ;
2011-04-09 06:41:31 +00:00
2011-04-17 15:59:02 +00:00
// DDRace
2010-11-14 01:03:24 +00:00
ms_FrontTexture = 0 ;
ms_TeleTexture = 0 ;
ms_SpeedupTexture = 0 ;
ms_SwitchTexture = 0 ;
2014-03-12 22:27:03 +00:00
ms_TuneTexture = 0 ;
2010-12-07 15:51:59 +00:00
m_TeleNumber = 1 ;
2010-09-30 21:31:19 +00:00
m_SwitchNum = 1 ;
2014-03-12 22:27:03 +00:00
m_TuningNum = 1 ;
2010-11-22 20:43:22 +00:00
m_SwitchDelay = 0 ;
2010-09-30 21:31:19 +00:00
m_SpeedupForce = 50 ;
m_SpeedupMaxSpeed = 0 ;
m_SpeedupAngle = 0 ;
2016-04-27 15:49:14 +00:00
m_LargeLayerWasWarned = false ;
2016-05-01 16:08:07 +00:00
m_PreventUnusedTilesWasWarned = false ;
2016-04-29 14:53:19 +00:00
m_AllowPlaceUnusedTiles = false ;
2010-05-29 07:25:38 +00:00
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
virtual void Init ( ) ;
virtual void UpdateAndRender ( ) ;
2011-03-21 23:31:42 +00:00
virtual bool HasUnsavedData ( ) { return m_Map . m_Modified ; }
2011-04-13 18:37:12 +00:00
2014-01-19 03:02:01 +00:00
int64 m_LastUndoUpdateTime ;
2014-01-19 17:06:56 +00:00
bool m_UndoRunning ;
2014-01-19 03:02:01 +00:00
void CreateUndoStep ( ) ;
static void CreateUndoStepThread ( void * pUser ) ;
int UndoStep ( ) ;
struct CUndo
{
int m_FileNum ;
int m_ButtonId ;
char m_aName [ 128 ] ;
int m_PreviewImage ;
} ;
array < CUndo > m_lUndoSteps ;
bool m_Undo ;
int m_ShowUndo ;
float m_UndoScrollValue ;
2010-10-07 21:51:07 +00:00
void FilelistPopulate ( int StorageType ) ;
void InvokeFileDialog ( int StorageType , int FileType , const char * pTitle , const char * pButtonText ,
2010-05-29 07:25:38 +00:00
const char * pBasepath , const char * pDefaultName ,
2010-10-07 21:51:07 +00:00
void ( * pfnFunc ) ( const char * pFilename , int StorageType , void * pUser ) , void * pUser ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
void Reset ( bool CreateDefault = true ) ;
int Save ( const char * pFilename ) ;
2010-10-07 21:51:07 +00:00
int Load ( const char * pFilename , int StorageType ) ;
int Append ( const char * pFilename , int StorageType ) ;
2010-05-29 07:25:38 +00:00
void Render ( ) ;
CQuad * GetSelectedQuad ( ) ;
CLayer * GetSelectedLayerType ( int Index , int Type ) ;
CLayer * GetSelectedLayer ( int Index ) ;
CLayerGroup * GetSelectedGroup ( ) ;
2014-10-10 17:11:21 +00:00
CSoundSource * GetSelectedSource ( ) ;
2011-04-13 18:37:12 +00:00
2014-05-17 15:19:48 +00:00
int DoProperties ( CUIRect * pToolbox , CProperty * pProps , int * pIDs , int * pNewVal , vec4 color = vec4 ( 1 , 1 , 1 , 0.5f ) ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
int m_Mode ;
int m_Dialog ;
2012-01-08 12:36:47 +00:00
int m_EditBoxActive ;
2010-05-29 07:25:38 +00:00
const char * m_pTooltip ;
2011-07-10 20:16:16 +00:00
bool m_GridActive ;
int m_GridFactor ;
2010-05-29 07:25:38 +00:00
char m_aFileName [ 512 ] ;
2011-03-21 23:31:42 +00:00
char m_aFileSaveName [ 512 ] ;
2010-10-08 20:06:12 +00:00
bool m_ValidSaveFilename ;
2010-10-07 21:51:07 +00:00
2011-03-21 23:31:42 +00:00
enum
{
POPEVENT_EXIT = 0 ,
POPEVENT_LOAD ,
POPEVENT_NEW ,
POPEVENT_SAVE ,
2016-04-27 15:49:14 +00:00
POPEVENT_LARGELAYER ,
2016-05-01 16:08:07 +00:00
POPEVENT_PREVENTUNUSEDTILES
2011-03-21 23:31:42 +00:00
} ;
int m_PopupEventType ;
int m_PopupEventActivated ;
2011-08-13 17:22:01 +00:00
int m_PopupEventWasActivated ;
2016-04-27 15:49:14 +00:00
bool m_LargeLayerWasWarned ;
2016-05-01 16:08:07 +00:00
bool m_PreventUnusedTilesWasWarned ;
2016-04-29 14:53:19 +00:00
bool m_AllowPlaceUnusedTiles ;
2011-03-21 23:31:42 +00:00
2010-10-07 21:51:07 +00:00
enum
{
FILETYPE_MAP ,
FILETYPE_IMG ,
2014-10-08 12:50:25 +00:00
FILETYPE_SOUND ,
2010-10-07 21:51:07 +00:00
MAX_PATH_LENGTH = 512
} ;
2011-04-13 18:37:12 +00:00
2010-10-06 21:07:35 +00:00
int m_FileDialogStorageType ;
2010-09-12 11:15:59 +00:00
const char * m_pFileDialogTitle ;
const char * m_pFileDialogButtonText ;
2010-10-07 21:51:07 +00:00
void ( * m_pfnFileDialogFunc ) ( const char * pFileName , int StorageType , void * pUser ) ;
2010-09-12 11:15:59 +00:00
void * m_pFileDialogUser ;
2010-10-07 21:51:07 +00:00
char m_aFileDialogFileName [ MAX_PATH_LENGTH ] ;
char m_aFileDialogCurrentFolder [ MAX_PATH_LENGTH ] ;
char m_aFileDialogCurrentLink [ MAX_PATH_LENGTH ] ;
char * m_pFileDialogPath ;
bool m_aFileDialogActivate ;
int m_FileDialogFileType ;
float m_FileDialogScrollValue ;
int m_FilesSelectedIndex ;
2011-03-20 21:53:50 +00:00
char m_FileDialogNewFolderName [ 64 ] ;
char m_FileDialogErrString [ 64 ] ;
2014-03-28 21:47:57 +00:00
int m_FilePreviewImage ;
CImageInfo m_FilePreviewImageInfo ;
2010-10-06 21:07:35 +00:00
struct CFilelistItem
{
char m_aFilename [ 128 ] ;
char m_aName [ 128 ] ;
bool m_IsDir ;
2010-10-07 21:51:07 +00:00
bool m_IsLink ;
2010-10-06 21:07:35 +00:00
int m_StorageType ;
2011-04-13 18:37:12 +00:00
2010-10-06 21:07:35 +00:00
bool operator < ( const CFilelistItem & Other ) { return ! str_comp ( m_aFilename , " .. " ) ? true : ! str_comp ( Other . m_aFilename , " .. " ) ? false :
m_IsDir & & ! Other . m_IsDir ? true : ! m_IsDir & & Other . m_IsDir ? false :
str_comp_filenames ( m_aFilename , Other . m_aFilename ) < 0 ; }
} ;
sorted_array < CFilelistItem > m_FileList ;
2010-09-12 11:15:59 +00:00
int m_FilesStartAt ;
int m_FilesCur ;
int m_FilesStopAt ;
2010-05-29 07:25:38 +00:00
float m_WorldOffsetX ;
float m_WorldOffsetY ;
float m_EditorOffsetX ;
float m_EditorOffsetY ;
float m_WorldZoom ;
int m_ZoomLevel ;
bool m_LockMouse ;
bool m_ShowMousePointer ;
bool m_GuiActive ;
bool m_ProofBorders ;
float m_MouseDeltaX ;
float m_MouseDeltaY ;
float m_MouseDeltaWx ;
float m_MouseDeltaWy ;
2014-09-29 11:13:56 +00:00
# if defined(__ANDROID__)
float m_OldMouseX ;
float m_OldMouseY ;
# endif
2011-04-13 18:37:12 +00:00
2011-02-18 10:41:27 +00:00
bool m_ShowTileInfo ;
2010-05-29 07:25:38 +00:00
bool m_ShowDetail ;
bool m_Animate ;
int64 m_AnimateStart ;
float m_AnimateTime ;
float m_AnimateSpeed ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
int m_ShowEnvelopeEditor ;
2011-08-14 14:31:48 +00:00
int m_ShowEnvelopePreview ; //Values: 0-Off|1-Selected Envelope|2-All
2011-07-13 20:38:32 +00:00
bool m_ShowServerSettingsEditor ;
2011-05-04 23:50:23 +00:00
bool m_ShowPicker ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
int m_SelectedLayer ;
int m_SelectedGroup ;
int m_SelectedQuad ;
int m_SelectedPoints ;
int m_SelectedEnvelope ;
2011-08-15 18:12:31 +00:00
int m_SelectedEnvelopePoint ;
2014-08-20 22:56:35 +00:00
int m_SelectedQuadEnvelope ;
2010-05-29 07:25:38 +00:00
int m_SelectedImage ;
2014-10-08 12:50:25 +00:00
int m_SelectedSound ;
2014-10-10 17:11:21 +00:00
int m_SelectedSource ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
static int ms_CheckerTexture ;
static int ms_BackgroundTexture ;
static int ms_CursorTexture ;
static int ms_EntitiesTexture ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
CLayerGroup m_Brush ;
CLayerTiles m_TilesetPicker ;
2014-08-20 22:56:35 +00:00
CLayerQuads m_QuadsetPicker ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
static const void * ms_pUiGotContext ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
CEditorMap m_Map ;
2014-05-31 23:32:54 +00:00
int m_ShiftBy ;
2011-04-13 18:37:12 +00:00
2011-07-18 10:05:12 +00:00
static void EnvelopeEval ( float TimeOffset , int Env , float * pChannels , void * pUser ) ;
2011-07-13 20:38:32 +00:00
float m_CommandBox ;
char m_aSettingsCommand [ 64 ] ;
2011-04-13 18:37:12 +00:00
void DoMapBorder ( ) ;
2010-05-29 07:25:38 +00:00
int DoButton_Editor_Common ( const void * pID , const char * pText , int Checked , const CUIRect * pRect , int Flags , const char * pToolTip ) ;
int DoButton_Editor ( const void * pID , const char * pText , int Checked , const CUIRect * pRect , int Flags , const char * pToolTip ) ;
2015-07-24 22:04:12 +00:00
int DoButton_Env ( const void * pID , const char * pText , int Checked , const CUIRect * pRect , const char * pToolTip , vec3 Color ) ;
2010-05-29 07:25:38 +00:00
int DoButton_Tab ( const void * pID , const char * pText , int Checked , const CUIRect * pRect , int Flags , const char * pToolTip ) ;
2011-07-12 01:14:46 +00:00
int DoButton_Ex ( const void * pID , const char * pText , int Checked , const CUIRect * pRect , int Flags , const char * pToolTip , int Corners , float FontSize = 10.0f ) ;
2010-05-29 07:25:38 +00:00
int DoButton_ButtonDec ( const void * pID , const char * pText , int Checked , const CUIRect * pRect , int Flags , const char * pToolTip ) ;
int DoButton_ButtonInc ( const void * pID , const char * pText , int Checked , const CUIRect * pRect , int Flags , const char * pToolTip ) ;
int DoButton_File ( const void * pID , const char * pText , int Checked , const CUIRect * pRect , int Flags , const char * pToolTip ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
int DoButton_Menu ( const void * pID , const char * pText , int Checked , const CUIRect * pRect , int Flags , const char * pToolTip ) ;
int DoButton_MenuItem ( const void * pID , const char * pText , int Checked , const CUIRect * pRect , int Flags = 0 , const char * pToolTip = 0 ) ;
2011-04-13 18:37:12 +00:00
2015-08-17 12:10:08 +00:00
int DoButton_ColorPicker ( const void * pID , const CUIRect * pRect , vec4 * pColor , const char * pToolTip = 0 ) ;
2011-07-12 01:14:46 +00:00
int DoEditBox ( void * pID , const CUIRect * pRect , char * pStr , unsigned StrSize , float FontSize , float * Offset , bool Hidden = false , int Corners = CUI : : CORNER_ALL ) ;
2010-05-29 07:25:38 +00:00
void RenderBackground ( CUIRect View , int Texture , float Size , float Brightness ) ;
2011-07-10 20:16:16 +00:00
void RenderGrid ( CLayerGroup * pGroup ) ;
2011-02-12 10:40:36 +00:00
void UiInvokePopupMenu ( void * pID , int Flags , float X , float Y , float W , float H , int ( * pfnFunc ) ( CEditor * pEditor , CUIRect Rect ) , void * pExtra = 0 ) ;
2010-05-29 07:25:38 +00:00
void UiDoPopupMenu ( ) ;
2011-04-13 18:37:12 +00:00
2015-08-20 10:51:30 +00:00
int UiDoValueSelector ( void * pID , CUIRect * pRect , const char * pLabel , int Current , int Min , int Max , int Step , float Scale , const char * pToolTip , bool isDegree = false , bool isHex = false ) ;
2010-05-29 07:25:38 +00:00
static int PopupGroup ( CEditor * pEditor , CUIRect View ) ;
static int PopupLayer ( CEditor * pEditor , CUIRect View ) ;
static int PopupQuad ( CEditor * pEditor , CUIRect View ) ;
static int PopupPoint ( CEditor * pEditor , CUIRect View ) ;
2011-03-20 21:53:50 +00:00
static int PopupNewFolder ( CEditor * pEditor , CUIRect View ) ;
2011-07-12 21:31:39 +00:00
static int PopupMapInfo ( CEditor * pEditor , CUIRect View ) ;
2011-03-21 23:31:42 +00:00
static int PopupEvent ( CEditor * pEditor , CUIRect View ) ;
2010-05-29 07:25:38 +00:00
static int PopupSelectImage ( CEditor * pEditor , CUIRect View ) ;
2014-10-08 15:33:06 +00:00
static int PopupSelectSound ( CEditor * pEditor , CUIRect View ) ;
2011-02-12 18:10:45 +00:00
static int PopupSelectGametileOp ( CEditor * pEditor , CUIRect View ) ;
2010-05-29 07:25:38 +00:00
static int PopupImage ( CEditor * pEditor , CUIRect View ) ;
static int PopupMenuFile ( CEditor * pEditor , CUIRect View ) ;
2011-07-08 23:09:06 +00:00
static int PopupSelectConfigAutoMap ( CEditor * pEditor , CUIRect View ) ;
2014-10-08 12:50:25 +00:00
static int PopupSound ( CEditor * pEditor , CUIRect View ) ;
2014-10-10 17:11:21 +00:00
static int PopupSource ( CEditor * pEditor , CUIRect View ) ;
2015-08-17 12:10:08 +00:00
static int PopupColorPicker ( CEditor * pEditor , CUIRect View ) ;
2010-05-29 07:25:38 +00:00
2011-03-21 23:31:42 +00:00
static void CallbackOpenMap ( const char * pFileName , int StorageType , void * pUser ) ;
static void CallbackAppendMap ( const char * pFileName , int StorageType , void * pUser ) ;
static void CallbackSaveMap ( const char * pFileName , int StorageType , void * pUser ) ;
2015-07-26 10:05:14 +00:00
static void CallbackSaveCopyMap ( const char * pFileName , int StorageType , void * pUser ) ;
2010-05-29 07:25:38 +00:00
void PopupSelectImageInvoke ( int Current , float x , float y ) ;
int PopupSelectImageResult ( ) ;
2011-02-12 18:10:45 +00:00
void PopupSelectGametileOpInvoke ( float x , float y ) ;
int PopupSelectGameTileOpResult ( ) ;
2011-08-11 08:59:14 +00:00
2011-07-08 23:09:06 +00:00
void PopupSelectConfigAutoMapInvoke ( float x , float y ) ;
int PopupSelectConfigAutoMapResult ( ) ;
2011-04-13 18:37:12 +00:00
2014-10-08 15:33:06 +00:00
void PopupSelectSoundInvoke ( int Current , float x , float y ) ;
2015-07-09 00:08:14 +00:00
int PopupSelectSoundResult ( ) ;
2014-10-08 15:33:06 +00:00
2011-02-12 10:40:36 +00:00
vec4 ButtonColorMul ( const void * pID ) ;
2010-05-29 07:25:38 +00:00
2012-10-21 12:49:26 +00:00
void DoQuadEnvelopes ( const array < CQuad > & m_lQuads , int TexID = - 1 ) ;
void DoQuadEnvPoint ( const CQuad * pQuad , int QIndex , int pIndex ) ;
2010-05-29 07:25:38 +00:00
void DoQuadPoint ( CQuad * pQuad , int QuadIndex , int v ) ;
2011-08-14 14:31:48 +00:00
2014-10-10 17:11:21 +00:00
void DoSoundSource ( CSoundSource * pSource , int Index ) ;
2010-05-29 07:25:38 +00:00
void DoMapEditor ( CUIRect View , CUIRect Toolbar ) ;
void DoToolbar ( CUIRect Toolbar ) ;
void DoQuad ( CQuad * pQuad , int Index ) ;
2011-02-12 10:40:36 +00:00
float UiDoScrollbarV ( const void * pID , const CUIRect * pRect , float Current ) ;
vec4 GetButtonColor ( const void * pID , int Checked ) ;
2011-04-13 18:37:12 +00:00
2010-10-07 21:51:07 +00:00
static void ReplaceImage ( const char * pFilename , int StorageType , void * pUser ) ;
2014-11-09 13:58:28 +00:00
static void ReplaceSound ( const char * pFileName , int StorageType , void * pUser ) ;
2010-10-07 21:51:07 +00:00
static void AddImage ( const char * pFilename , int StorageType , void * pUser ) ;
2014-10-08 12:50:25 +00:00
static void AddSound ( const char * pFileName , int StorageType , void * pUser ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
void RenderImages ( CUIRect Toolbox , CUIRect Toolbar , CUIRect View ) ;
void RenderLayers ( CUIRect Toolbox , CUIRect Toolbar , CUIRect View ) ;
2014-10-08 12:50:25 +00:00
void RenderSounds ( CUIRect Toolbox , CUIRect Toolbar , CUIRect View ) ;
2010-05-29 07:25:38 +00:00
void RenderModebar ( CUIRect View ) ;
void RenderStatusbar ( CUIRect View ) ;
void RenderEnvelopeEditor ( CUIRect View ) ;
2014-01-19 03:02:01 +00:00
void RenderUndoList ( CUIRect View ) ;
2011-07-13 20:38:32 +00:00
void RenderServerSettingsEditor ( CUIRect View ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
void RenderMenubar ( CUIRect Menubar ) ;
void RenderFileDialog ( ) ;
2010-06-01 20:49:35 +00:00
2010-10-07 21:51:07 +00:00
void AddFileDialogEntry ( int Index , CUIRect * pView ) ;
2010-06-02 16:12:32 +00:00
void SortImages ( ) ;
2010-11-17 12:08:29 +00:00
static void ExtractName ( const char * pFileName , char * pName , int BufferSize )
{
const char * pExtractedName = pFileName ;
const char * pEnd = 0 ;
for ( ; * pFileName ; + + pFileName )
{
if ( * pFileName = = ' / ' | | * pFileName = = ' \\ ' )
pExtractedName = pFileName + 1 ;
else if ( * pFileName = = ' . ' )
pEnd = pFileName ;
}
int Length = pEnd > pExtractedName ? min ( BufferSize , ( int ) ( pEnd - pExtractedName + 1 ) ) : BufferSize ;
str_copy ( pName , pExtractedName , Length ) ;
}
2011-04-09 06:41:31 +00:00
2011-08-13 00:11:06 +00:00
int GetLineDistance ( ) ;
2014-10-07 18:07:46 +00:00
void ZoomMouseTarget ( float ZoomFactor ) ;
2011-08-13 00:11:06 +00:00
2015-08-17 12:10:08 +00:00
static vec3 ms_PickerColor ;
static int ms_SVPicker ;
static int ms_HuePicker ;
2011-04-09 06:41:31 +00:00
// DDRace
static int ms_FrontTexture ;
static int ms_TeleTexture ;
static int ms_SpeedupTexture ;
static int ms_SwitchTexture ;
2014-03-12 22:27:03 +00:00
static int ms_TuneTexture ;
2011-04-09 06:41:31 +00:00
static int PopupTele ( CEditor * pEditor , CUIRect View ) ;
static int PopupSpeedup ( CEditor * pEditor , CUIRect View ) ;
static int PopupSwitch ( CEditor * pEditor , CUIRect View ) ;
2014-03-12 22:27:03 +00:00
static int PopupTune ( CEditor * pEditor , CUIRect View ) ;
2010-12-07 15:51:59 +00:00
unsigned char m_TeleNumber ;
2015-07-09 00:08:14 +00:00
2014-03-12 22:27:03 +00:00
unsigned char m_TuningNum ;
2011-04-09 06:41:31 +00:00
2010-09-30 21:31:19 +00:00
unsigned char m_SpeedupForce ;
unsigned char m_SpeedupMaxSpeed ;
short m_SpeedupAngle ;
unsigned char m_SwitchNum ;
2010-11-22 20:43:22 +00:00
unsigned char m_SwitchDelay ;
2010-05-29 07:25:38 +00:00
} ;
// make sure to inline this function
inline class IGraphics * CLayer : : Graphics ( ) { return m_pEditor - > Graphics ( ) ; }
inline class ITextRender * CLayer : : TextRender ( ) { return m_pEditor - > TextRender ( ) ; }
2011-04-09 06:41:31 +00:00
// DDRace
class CLayerTele : public CLayerTiles
{
public :
CLayerTele ( int w , int h ) ;
~ CLayerTele ( ) ;
CTeleTile * m_pTeleTile ;
unsigned char m_TeleNum ;
virtual void Resize ( int NewW , int NewH ) ;
virtual void Shift ( int Direction ) ;
virtual void BrushDraw ( CLayer * pBrush , float wx , float wy ) ;
2011-04-17 15:59:02 +00:00
virtual void BrushFlipX ( ) ;
virtual void BrushFlipY ( ) ;
virtual void BrushRotate ( float Amount ) ;
2011-04-09 06:41:31 +00:00
virtual void FillSelection ( bool Empty , CLayer * pBrush , CUIRect Rect ) ;
} ;
class CLayerSpeedup : public CLayerTiles
{
public :
CLayerSpeedup ( int w , int h ) ;
~ CLayerSpeedup ( ) ;
CSpeedupTile * m_pSpeedupTile ;
unsigned char m_SpeedupForce ;
unsigned char m_SpeedupMaxSpeed ;
unsigned char m_SpeedupAngle ;
virtual void Resize ( int NewW , int NewH ) ;
virtual void Shift ( int Direction ) ;
virtual void BrushDraw ( CLayer * pBrush , float wx , float wy ) ;
2011-04-17 15:59:02 +00:00
virtual void BrushFlipX ( ) ;
virtual void BrushFlipY ( ) ;
virtual void BrushRotate ( float Amount ) ;
2011-04-09 06:41:31 +00:00
virtual void FillSelection ( bool Empty , CLayer * pBrush , CUIRect Rect ) ;
} ;
class CLayerFront : public CLayerTiles
{
public :
CLayerFront ( int w , int h ) ;
virtual void Resize ( int NewW , int NewH ) ;
virtual void Shift ( int Direction ) ;
2016-04-30 23:47:29 +00:00
virtual void SetTile ( int x , int y , CTile tile ) ;
2011-04-09 06:41:31 +00:00
virtual void BrushDraw ( CLayer * pBrush , float wx , float wy ) ;
} ;
class CLayerSwitch : public CLayerTiles
{
public :
CLayerSwitch ( int w , int h ) ;
~ CLayerSwitch ( ) ;
CSwitchTile * m_pSwitchTile ;
unsigned char m_SwitchNumber ;
unsigned char m_SwitchDelay ;
virtual void Resize ( int NewW , int NewH ) ;
virtual void Shift ( int Direction ) ;
virtual void BrushDraw ( CLayer * pBrush , float wx , float wy ) ;
virtual void FillSelection ( bool Empty , CLayer * pBrush , CUIRect Rect ) ;
} ;
2014-03-12 22:27:03 +00:00
class CLayerTune : public CLayerTiles
{
public :
CLayerTune ( int w , int h ) ;
~ CLayerTune ( ) ;
CTuneTile * m_pTuneTile ;
unsigned char m_TuningNumber ;
virtual void Resize ( int NewW , int NewH ) ;
virtual void Shift ( int Direction ) ;
virtual void BrushDraw ( CLayer * pBrush , float wx , float wy ) ;
virtual void BrushFlipX ( ) ;
virtual void BrushFlipY ( ) ;
virtual void BrushRotate ( float Amount ) ;
virtual void FillSelection ( bool Empty , CLayer * pBrush , CUIRect Rect ) ;
} ;
2014-10-08 15:33:06 +00:00
class CLayerSounds : public CLayer
{
public :
CLayerSounds ( ) ;
~ CLayerSounds ( ) ;
virtual void Render ( ) ;
2014-10-09 10:44:03 +00:00
CSoundSource * NewSource ( ) ;
2014-10-08 15:33:06 +00:00
virtual void BrushSelecting ( CUIRect Rect ) ;
virtual int BrushGrab ( CLayerGroup * pBrush , CUIRect Rect ) ;
virtual void BrushPlace ( CLayer * pBrush , float wx , float wy ) ;
virtual int RenderProperties ( CUIRect * pToolbox ) ;
2014-10-11 14:05:36 +00:00
virtual void ModifyEnvelopeIndex ( INDEX_MODIFY_FUNC pfnFunc ) ;
2014-10-08 15:33:06 +00:00
virtual void ModifySoundIndex ( INDEX_MODIFY_FUNC pfnFunc ) ;
int m_Sound ;
2014-10-09 10:44:03 +00:00
array < CSoundSource > m_lSources ;
2014-10-08 15:33:06 +00:00
} ;
2014-03-12 22:27:03 +00:00
2010-05-29 07:25:38 +00:00
# endif