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-07-08 23:09:06 +00:00
2015-08-17 12:10:08 +00:00
# include <base/color.h>
2011-07-08 23:09:06 +00:00
# include <base/tl/array.h>
2010-08-17 22:06:00 +00:00
# include <engine/console.h>
2010-05-29 07:25:38 +00:00
# include <engine/graphics.h>
# include <engine/input.h>
# include <engine/keys.h>
2011-03-20 21:53:50 +00:00
# include <engine/storage.h>
2011-07-08 23:09:06 +00:00
2011-04-19 08:34:51 +00:00
# include "editor.h"
2008-01-17 23:09:49 +00:00
// popup menu handling
static struct
{
2010-05-29 07:25:38 +00:00
CUIRect m_Rect ;
void * m_pId ;
int ( * m_pfnFunc ) ( CEditor * pEditor , CUIRect Rect ) ;
int m_IsMenu ;
void * m_pExtra ;
} s_UiPopups [ 8 ] ;
2008-01-17 23:09:49 +00:00
2010-05-29 07:25:38 +00:00
static int g_UiNumPopups = 0 ;
2008-01-17 23:09:49 +00:00
2011-02-13 06:47:51 +00:00
void CEditor : : UiInvokePopupMenu ( void * pID , int Flags , float x , float y , float Width , float Height , int ( * pfnFunc ) ( CEditor * pEditor , CUIRect Rect ) , void * pExtra )
2008-01-17 23:09:49 +00:00
{
2015-05-31 15:34:01 +00:00
if ( g_UiNumPopups > 7 )
return ;
2010-08-17 22:06:00 +00:00
Console ( ) - > Print ( IConsole : : OUTPUT_LEVEL_DEBUG , " editor " , " invoked " ) ;
2011-02-13 06:47:51 +00:00
if ( x + Width > UI ( ) - > Screen ( ) - > w )
x - = Width ;
if ( y + Height > UI ( ) - > Screen ( ) - > h )
y - = Height ;
2011-02-12 10:40:36 +00:00
s_UiPopups [ g_UiNumPopups ] . m_pId = pID ;
2010-05-29 07:25:38 +00:00
s_UiPopups [ g_UiNumPopups ] . m_IsMenu = Flags ;
2011-02-13 06:47:51 +00:00
s_UiPopups [ g_UiNumPopups ] . m_Rect . x = x ;
s_UiPopups [ g_UiNumPopups ] . m_Rect . y = y ;
s_UiPopups [ g_UiNumPopups ] . m_Rect . w = Width ;
s_UiPopups [ g_UiNumPopups ] . m_Rect . h = Height ;
2010-05-29 07:25:38 +00:00
s_UiPopups [ g_UiNumPopups ] . m_pfnFunc = pfnFunc ;
s_UiPopups [ g_UiNumPopups ] . m_pExtra = pExtra ;
g_UiNumPopups + + ;
2008-01-17 23:09:49 +00:00
}
2010-05-29 07:25:38 +00:00
void CEditor : : UiDoPopupMenu ( )
2008-01-17 23:09:49 +00:00
{
2010-05-29 07:25:38 +00:00
for ( int i = 0 ; i < g_UiNumPopups ; i + + )
2008-01-17 23:09:49 +00:00
{
2010-05-29 07:25:38 +00:00
bool Inside = UI ( ) - > MouseInside ( & s_UiPopups [ i ] . m_Rect ) ;
UI ( ) - > SetHotItem ( & s_UiPopups [ i ] . m_pId ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
if ( UI ( ) - > ActiveItem ( ) = = & s_UiPopups [ i ] . m_pId )
2008-01-17 23:09:49 +00:00
{
2009-10-27 14:38:53 +00:00
if ( ! UI ( ) - > MouseButton ( 0 ) )
2008-01-17 23:09:49 +00:00
{
2010-05-29 07:25:38 +00:00
if ( ! Inside )
2016-04-27 15:49:14 +00:00
{
2010-05-29 07:25:38 +00:00
g_UiNumPopups - - ;
2016-04-27 15:49:14 +00:00
m_PopupEventWasActivated = false ;
}
2009-10-27 14:38:53 +00:00
UI ( ) - > SetActiveItem ( 0 ) ;
2008-01-17 23:09:49 +00:00
}
}
2010-05-29 07:25:38 +00:00
else if ( UI ( ) - > HotItem ( ) = = & s_UiPopups [ i ] . m_pId )
2008-01-17 23:09:49 +00:00
{
2009-10-27 14:38:53 +00:00
if ( UI ( ) - > MouseButton ( 0 ) )
2010-05-29 07:25:38 +00:00
UI ( ) - > SetActiveItem ( & s_UiPopups [ i ] . m_pId ) ;
2008-01-17 23:09:49 +00:00
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
int Corners = CUI : : CORNER_ALL ;
if ( s_UiPopups [ i ] . m_IsMenu )
Corners = CUI : : CORNER_R | CUI : : CORNER_B ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
CUIRect r = s_UiPopups [ i ] . m_Rect ;
RenderTools ( ) - > DrawUIRect ( & r , vec4 ( 0.5f , 0.5f , 0.5f , 0.75f ) , Corners , 3.0f ) ;
2009-10-27 14:38:53 +00:00
r . Margin ( 1.0f , & r ) ;
2010-05-29 07:25:38 +00:00
RenderTools ( ) - > DrawUIRect ( & r , vec4 ( 0 , 0 , 0 , 0.75f ) , Corners , 3.0f ) ;
2009-10-27 14:38:53 +00:00
r . Margin ( 4.0f , & r ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
if ( s_UiPopups [ i ] . m_pfnFunc ( this , r ) )
2015-08-22 18:22:23 +00:00
{
m_LockMouse = false ;
UI ( ) - > SetActiveItem ( 0 ) ;
2010-05-29 07:25:38 +00:00
g_UiNumPopups - - ;
2016-04-27 15:49:14 +00:00
m_PopupEventWasActivated = false ;
2015-08-22 18:22:23 +00:00
}
2011-04-13 18:37:12 +00:00
2016-04-30 18:11:26 +00:00
if ( Input ( ) - > KeyPress ( KEY_ESCAPE ) )
2015-08-22 18:22:23 +00:00
{
m_LockMouse = false ;
UI ( ) - > SetActiveItem ( 0 ) ;
2010-05-29 07:25:38 +00:00
g_UiNumPopups - - ;
2016-04-27 15:49:14 +00:00
m_PopupEventWasActivated = false ;
2015-08-22 18:22:23 +00:00
}
2008-01-17 23:09:49 +00:00
}
}
2010-05-29 07:25:38 +00:00
int CEditor : : PopupGroup ( CEditor * pEditor , CUIRect View )
2008-01-17 23:09:49 +00:00
{
// remove group button
2010-05-29 07:25:38 +00:00
CUIRect Button ;
View . HSplitBottom ( 12.0f , & View , & Button ) ;
static int s_DeleteButton = 0 ;
2011-04-13 18:37:12 +00:00
2008-03-02 15:53:53 +00:00
// don't allow deletion of game group
2011-02-18 09:49:54 +00:00
if ( pEditor - > m_Map . m_pGameGroup ! = pEditor - > GetSelectedGroup ( ) )
2008-01-17 23:09:49 +00:00
{
2011-03-20 16:04:03 +00:00
if ( pEditor - > DoButton_Editor ( & s_DeleteButton , " Delete group " , 0 , & Button , 0 , " Delete group " ) )
2011-02-18 09:49:54 +00:00
{
pEditor - > m_Map . DeleteGroup ( pEditor - > m_SelectedGroup ) ;
pEditor - > m_SelectedGroup = max ( 0 , pEditor - > m_SelectedGroup - 1 ) ;
return 1 ;
}
}
else
{
2014-12-01 19:35:30 +00:00
if ( pEditor - > DoButton_Editor ( & s_DeleteButton , " Clean up game tiles " , 0 , & Button , 0 , " Removes game tiles that aren't based on a layer " ) )
2011-02-18 09:49:54 +00:00
{
// gather all tile layers
array < CLayerTiles * > Layers ;
for ( int i = 0 ; i < pEditor - > m_Map . m_pGameGroup - > m_lLayers . size ( ) ; + + i )
{
if ( pEditor - > m_Map . m_pGameGroup - > m_lLayers [ i ] ! = pEditor - > m_Map . m_pGameLayer & & pEditor - > m_Map . m_pGameGroup - > m_lLayers [ i ] - > m_Type = = LAYERTYPE_TILES )
Layers . add ( static_cast < CLayerTiles * > ( pEditor - > m_Map . m_pGameGroup - > m_lLayers [ i ] ) ) ;
}
// search for unneeded game tiles
CLayerTiles * gl = pEditor - > m_Map . m_pGameLayer ;
for ( int y = 0 ; y < gl - > m_Height ; + + y )
for ( int x = 0 ; x < gl - > m_Width ; + + x )
{
if ( gl - > m_pTiles [ y * gl - > m_Width + x ] . m_Index > static_cast < unsigned char > ( TILE_NOHOOK ) )
continue ;
bool Found = false ;
for ( int i = 0 ; i < Layers . size ( ) ; + + i )
{
if ( x < Layers [ i ] - > m_Width & & y < Layers [ i ] - > m_Height & & Layers [ i ] - > m_pTiles [ y * Layers [ i ] - > m_Width + x ] . m_Index )
{
Found = true ;
break ;
}
}
if ( ! Found )
2011-03-21 23:31:42 +00:00
{
2011-02-18 09:49:54 +00:00
gl - > m_pTiles [ y * gl - > m_Width + x ] . m_Index = TILE_AIR ;
2011-03-21 23:31:42 +00:00
pEditor - > m_Map . m_Modified = true ;
}
2011-02-18 09:49:54 +00:00
}
return 1 ;
}
2008-01-17 23:09:49 +00:00
}
2010-09-30 21:31:19 +00:00
if ( pEditor - > GetSelectedGroup ( ) - > m_GameGroup & & ! pEditor - > m_Map . m_pTeleLayer )
{
// new tele layer
2014-12-01 19:35:30 +00:00
View . HSplitBottom ( 5.0f , & View , & Button ) ;
2010-09-30 21:31:19 +00:00
View . HSplitBottom ( 12.0f , & View , & Button ) ;
static int s_NewSwitchLayerButton = 0 ;
2014-12-01 19:35:30 +00:00
if ( pEditor - > DoButton_Editor ( & s_NewSwitchLayerButton , " Add tele layer " , 0 , & Button , 0 , " Creates a new tele layer " ) )
2010-09-30 21:31:19 +00:00
{
CLayer * l = new CLayerTele ( pEditor - > m_Map . m_pGameLayer - > m_Width , pEditor - > m_Map . m_pGameLayer - > m_Height ) ;
pEditor - > m_Map . MakeTeleLayer ( l ) ;
pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > AddLayer ( l ) ;
2018-07-25 20:57:58 +00:00
pEditor - > SelectLayer ( pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_lLayers . size ( ) - 1 ) ;
2010-09-30 21:31:19 +00:00
pEditor - > m_Brush . Clear ( ) ;
return 1 ;
}
}
if ( pEditor - > GetSelectedGroup ( ) - > m_GameGroup & & ! pEditor - > m_Map . m_pSpeedupLayer )
{
// new speedup layer
2014-12-01 19:35:30 +00:00
View . HSplitBottom ( 5.0f , & View , & Button ) ;
2010-09-30 21:31:19 +00:00
View . HSplitBottom ( 12.0f , & View , & Button ) ;
static int s_NewSwitchLayerButton = 0 ;
2014-12-01 19:35:30 +00:00
if ( pEditor - > DoButton_Editor ( & s_NewSwitchLayerButton , " Add speedup layer " , 0 , & Button , 0 , " Creates a new speedup layer " ) )
2010-09-30 21:31:19 +00:00
{
CLayer * l = new CLayerSpeedup ( pEditor - > m_Map . m_pGameLayer - > m_Width , pEditor - > m_Map . m_pGameLayer - > m_Height ) ;
pEditor - > m_Map . MakeSpeedupLayer ( l ) ;
pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > AddLayer ( l ) ;
2018-07-25 20:57:58 +00:00
pEditor - > SelectLayer ( pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_lLayers . size ( ) - 1 ) ;
2010-09-30 21:31:19 +00:00
pEditor - > m_Brush . Clear ( ) ;
return 1 ;
}
}
2015-07-09 00:08:14 +00:00
2014-03-12 23:01:15 +00:00
if ( pEditor - > GetSelectedGroup ( ) - > m_GameGroup & & ! pEditor - > m_Map . m_pTuneLayer )
{
// new tune layer
2014-12-01 19:35:30 +00:00
View . HSplitBottom ( 5.0f , & View , & Button ) ;
2014-03-12 23:01:15 +00:00
View . HSplitBottom ( 12.0f , & View , & Button ) ;
static int s_NewSwitchLayerButton = 0 ;
2014-12-01 19:35:30 +00:00
if ( pEditor - > DoButton_Editor ( & s_NewSwitchLayerButton , " Add tune layer " , 0 , & Button , 0 , " Creates a new tuning layer " ) )
2014-03-12 23:01:15 +00:00
{
CLayer * l = new CLayerTune ( pEditor - > m_Map . m_pGameLayer - > m_Width , pEditor - > m_Map . m_pGameLayer - > m_Height ) ;
pEditor - > m_Map . MakeTuneLayer ( l ) ;
pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > AddLayer ( l ) ;
2018-07-25 20:57:58 +00:00
pEditor - > SelectLayer ( pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_lLayers . size ( ) - 1 ) ;
2014-03-12 23:01:15 +00:00
pEditor - > m_Brush . Clear ( ) ;
return 1 ;
}
}
2011-04-09 06:41:31 +00:00
2010-09-30 21:31:19 +00:00
if ( pEditor - > GetSelectedGroup ( ) - > m_GameGroup & & ! pEditor - > m_Map . m_pFrontLayer )
{
// new force layer
2014-12-01 19:35:30 +00:00
View . HSplitBottom ( 5.0f , & View , & Button ) ;
2010-09-30 21:31:19 +00:00
View . HSplitBottom ( 12.0f , & View , & Button ) ;
static int s_NewFrontLayerButton = 0 ;
2014-12-01 19:35:30 +00:00
if ( pEditor - > DoButton_Editor ( & s_NewFrontLayerButton , " Add front layer " , 0 , & Button , 0 , " Creates a new item layer " ) )
2010-09-30 21:31:19 +00:00
{
CLayer * l = new CLayerFront ( pEditor - > m_Map . m_pGameLayer - > m_Width , pEditor - > m_Map . m_pGameLayer - > m_Height ) ;
pEditor - > m_Map . MakeFrontLayer ( l ) ;
pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > AddLayer ( l ) ;
2018-07-25 20:57:58 +00:00
pEditor - > SelectLayer ( pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_lLayers . size ( ) - 1 ) ;
2010-09-30 21:31:19 +00:00
pEditor - > m_Brush . Clear ( ) ;
return 1 ;
}
}
if ( pEditor - > GetSelectedGroup ( ) - > m_GameGroup & & ! pEditor - > m_Map . m_pSwitchLayer )
{
// new Switch layer
2014-12-01 19:35:30 +00:00
View . HSplitBottom ( 5.0f , & View , & Button ) ;
2010-09-30 21:31:19 +00:00
View . HSplitBottom ( 12.0f , & View , & Button ) ;
static int s_NewSwitchLayerButton = 0 ;
2014-12-01 19:35:30 +00:00
if ( pEditor - > DoButton_Editor ( & s_NewSwitchLayerButton , " Add switch layer " , 0 , & Button , 0 , " Creates a new switch layer " ) )
2010-09-30 21:31:19 +00:00
{
CLayer * l = new CLayerSwitch ( pEditor - > m_Map . m_pGameLayer - > m_Width , pEditor - > m_Map . m_pGameLayer - > m_Height ) ;
pEditor - > m_Map . MakeSwitchLayer ( l ) ;
pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > AddLayer ( l ) ;
2018-07-25 20:57:58 +00:00
pEditor - > SelectLayer ( pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_lLayers . size ( ) - 1 ) ;
2010-09-30 21:31:19 +00:00
pEditor - > m_Brush . Clear ( ) ;
return 1 ;
}
}
2014-10-08 15:33:06 +00:00
// new quad layer
2014-12-01 19:35:30 +00:00
View . HSplitBottom ( 5.0f , & View , & Button ) ;
2010-05-29 07:25:38 +00:00
View . HSplitBottom ( 12.0f , & View , & Button ) ;
static int s_NewQuadLayerButton = 0 ;
2011-03-20 16:04:03 +00:00
if ( pEditor - > DoButton_Editor ( & s_NewQuadLayerButton , " Add quads layer " , 0 , & Button , 0 , " Creates a new quad layer " ) )
2008-01-17 23:09:49 +00:00
{
2010-05-29 07:25:38 +00:00
CLayer * l = new CLayerQuads ;
l - > m_pEditor = pEditor ;
pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > AddLayer ( l ) ;
2018-07-25 20:57:58 +00:00
pEditor - > SelectLayer ( pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_lLayers . size ( ) - 1 ) ;
2011-07-12 15:54:59 +00:00
pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_Collapse = false ;
2008-01-17 23:09:49 +00:00
return 1 ;
}
2014-10-08 15:33:06 +00:00
// new tile layer
2010-05-29 07:25:38 +00:00
View . HSplitBottom ( 5.0f , & View , & Button ) ;
View . HSplitBottom ( 12.0f , & View , & Button ) ;
static int s_NewTileLayerButton = 0 ;
2011-03-20 16:04:03 +00:00
if ( pEditor - > DoButton_Editor ( & s_NewTileLayerButton , " Add tile layer " , 0 , & Button , 0 , " Creates a new tile layer " ) )
2008-01-17 23:09:49 +00:00
{
2010-09-30 21:31:19 +00:00
CLayer * l = new CLayerTiles ( pEditor - > m_Map . m_pGameLayer - > m_Width , pEditor - > m_Map . m_pGameLayer - > m_Height ) ;
2010-05-29 07:25:38 +00:00
l - > m_pEditor = pEditor ;
pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > AddLayer ( l ) ;
2018-07-25 20:57:58 +00:00
pEditor - > SelectLayer ( pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_lLayers . size ( ) - 1 ) ;
2011-07-12 15:54:59 +00:00
pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_Collapse = false ;
2008-01-17 23:09:49 +00:00
return 1 ;
}
2011-04-13 18:37:12 +00:00
2014-10-08 15:33:06 +00:00
// new sound layer
View . HSplitBottom ( 5.0f , & View , & Button ) ;
View . HSplitBottom ( 12.0f , & View , & Button ) ;
static int s_NewSoundLayerButton = 0 ;
if ( pEditor - > DoButton_Editor ( & s_NewSoundLayerButton , " Add sound layer " , 0 , & Button , 0 , " Creates a new sound layer " ) )
{
CLayer * l = new CLayerSounds ;
l - > m_pEditor = pEditor ;
pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > AddLayer ( l ) ;
2018-07-25 20:57:58 +00:00
pEditor - > SelectLayer ( pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_lLayers . size ( ) - 1 ) ;
2014-10-08 15:33:06 +00:00
pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_Collapse = false ;
return 1 ;
}
2011-07-12 01:14:46 +00:00
// group name
if ( ! pEditor - > GetSelectedGroup ( ) - > m_GameGroup )
{
View . HSplitBottom ( 5.0f , & View , & Button ) ;
View . HSplitBottom ( 12.0f , & View , & Button ) ;
static float s_Name = 0 ;
pEditor - > UI ( ) - > DoLabel ( & Button , " Name: " , 10.0f , - 1 , - 1 ) ;
Button . VSplitLeft ( 40.0f , 0 , & Button ) ;
2011-07-20 20:18:31 +00:00
if ( pEditor - > DoEditBox ( & s_Name , & Button , pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_aName , sizeof ( pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_aName ) , 10.0f , & s_Name ) )
pEditor - > m_Map . m_Modified = true ;
2011-07-12 01:14:46 +00:00
}
2008-01-17 23:09:49 +00:00
enum
{
PROP_ORDER = 0 ,
PROP_POS_X ,
PROP_POS_Y ,
PROP_PARA_X ,
PROP_PARA_Y ,
2008-03-29 11:44:03 +00:00
PROP_USE_CLIPPING ,
PROP_CLIP_X ,
PROP_CLIP_Y ,
PROP_CLIP_W ,
PROP_CLIP_H ,
2008-01-17 23:09:49 +00:00
NUM_PROPS ,
} ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
CProperty aProps [ ] = {
2011-03-20 16:04:03 +00:00
{ " Order " , pEditor - > m_SelectedGroup , PROPTYPE_INT_STEP , 0 , pEditor - > m_Map . m_lGroups . size ( ) - 1 } ,
{ " Pos X " , - pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_OffsetX , PROPTYPE_INT_SCROLL , - 1000000 , 1000000 } ,
{ " Pos Y " , - pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_OffsetY , PROPTYPE_INT_SCROLL , - 1000000 , 1000000 } ,
{ " Para X " , pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_ParallaxX , PROPTYPE_INT_SCROLL , - 1000000 , 1000000 } ,
{ " Para Y " , pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_ParallaxY , PROPTYPE_INT_SCROLL , - 1000000 , 1000000 } ,
{ " Use Clipping " , pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_UseClipping , PROPTYPE_BOOL , 0 , 1 } ,
{ " Clip X " , pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_ClipX , PROPTYPE_INT_SCROLL , - 1000000 , 1000000 } ,
{ " Clip Y " , pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_ClipY , PROPTYPE_INT_SCROLL , - 1000000 , 1000000 } ,
2014-08-31 13:24:19 +00:00
{ " Clip W " , pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_ClipW , PROPTYPE_INT_SCROLL , 0 , 1000000 } ,
{ " Clip H " , pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_ClipH , PROPTYPE_INT_SCROLL , 0 , 1000000 } ,
2008-01-17 23:09:49 +00:00
{ 0 } ,
} ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
static int s_aIds [ NUM_PROPS ] = { 0 } ;
int NewVal = 0 ;
2011-04-13 18:37:12 +00:00
2008-01-17 23:09:49 +00:00
// cut the properties that isn't needed
2010-05-29 07:25:38 +00:00
if ( pEditor - > GetSelectedGroup ( ) - > m_GameGroup )
aProps [ PROP_POS_X ] . m_pName = 0 ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
int Prop = pEditor - > DoProperties ( & View , aProps , s_aIds , & NewVal ) ;
2011-03-21 23:31:42 +00:00
if ( Prop ! = - 1 )
pEditor - > m_Map . m_Modified = true ;
2010-05-29 07:25:38 +00:00
if ( Prop = = PROP_ORDER )
pEditor - > m_SelectedGroup = pEditor - > m_Map . SwapGroups ( pEditor - > m_SelectedGroup , NewVal ) ;
2011-04-13 18:37:12 +00:00
2008-01-17 23:09:49 +00:00
// these can not be changed on the game group
2010-05-29 07:25:38 +00:00
if ( ! pEditor - > GetSelectedGroup ( ) - > m_GameGroup )
2008-01-17 23:09:49 +00:00
{
2010-05-29 07:25:38 +00:00
if ( Prop = = PROP_PARA_X ) pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_ParallaxX = NewVal ;
else if ( Prop = = PROP_PARA_Y ) pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_ParallaxY = NewVal ;
else if ( Prop = = PROP_POS_X ) pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_OffsetX = - NewVal ;
else if ( Prop = = PROP_POS_Y ) pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_OffsetY = - NewVal ;
else if ( Prop = = PROP_USE_CLIPPING ) pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_UseClipping = NewVal ;
else if ( Prop = = PROP_CLIP_X ) pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_ClipX = NewVal ;
else if ( Prop = = PROP_CLIP_Y ) pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_ClipY = NewVal ;
else if ( Prop = = PROP_CLIP_W ) pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_ClipW = NewVal ;
else if ( Prop = = PROP_CLIP_H ) pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > m_ClipH = NewVal ;
2008-01-17 23:09:49 +00:00
}
2011-04-13 18:37:12 +00:00
2008-01-17 23:09:49 +00:00
return 0 ;
}
2010-05-29 07:25:38 +00:00
int CEditor : : PopupLayer ( CEditor * pEditor , CUIRect View )
2008-01-17 23:09:49 +00:00
{
// remove layer button
2010-05-29 07:25:38 +00:00
CUIRect Button ;
View . HSplitBottom ( 12.0f , & View , & Button ) ;
static int s_DeleteButton = 0 ;
2011-04-13 18:37:12 +00:00
2008-03-02 15:53:53 +00:00
// don't allow deletion of game layer
2011-02-16 10:01:51 +00:00
if ( pEditor - > m_Map . m_pGameLayer ! = pEditor - > GetSelectedLayer ( 0 ) & &
2011-03-20 16:04:03 +00:00
pEditor - > DoButton_Editor ( & s_DeleteButton , " Delete layer " , 0 , & Button , 0 , " Deletes the layer " ) )
2008-01-17 23:09:49 +00:00
{
2011-02-16 10:01:51 +00:00
if ( pEditor - > GetSelectedLayer ( 0 ) = = pEditor - > m_Map . m_pFrontLayer )
pEditor - > m_Map . m_pFrontLayer = 0x0 ;
2010-09-30 21:31:19 +00:00
if ( pEditor - > GetSelectedLayer ( 0 ) = = pEditor - > m_Map . m_pTeleLayer )
pEditor - > m_Map . m_pTeleLayer = 0x0 ;
if ( pEditor - > GetSelectedLayer ( 0 ) = = pEditor - > m_Map . m_pSpeedupLayer )
pEditor - > m_Map . m_pSpeedupLayer = 0x0 ;
if ( pEditor - > GetSelectedLayer ( 0 ) = = pEditor - > m_Map . m_pSwitchLayer )
pEditor - > m_Map . m_pSwitchLayer = 0x0 ;
2014-03-12 23:01:15 +00:00
if ( pEditor - > GetSelectedLayer ( 0 ) = = pEditor - > m_Map . m_pTuneLayer )
pEditor - > m_Map . m_pTuneLayer = 0x0 ;
2018-07-25 20:57:58 +00:00
pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] - > DeleteLayer ( pEditor - > m_lSelectedLayers [ 0 ] ) ;
2008-01-17 23:09:49 +00:00
return 1 ;
}
2011-07-12 01:14:46 +00:00
// layer name
2011-08-13 00:12:40 +00:00
// if(pEditor->m_Map.m_pGameLayer != pEditor->GetSelectedLayer(0))
2014-03-12 23:01:15 +00:00
if ( pEditor - > m_Map . m_pGameLayer ! = pEditor - > GetSelectedLayer ( 0 ) & & pEditor - > m_Map . m_pTeleLayer ! = pEditor - > GetSelectedLayer ( 0 ) & & pEditor - > m_Map . m_pSpeedupLayer ! = pEditor - > GetSelectedLayer ( 0 ) & & pEditor - > m_Map . m_pFrontLayer ! = pEditor - > GetSelectedLayer ( 0 ) & & pEditor - > m_Map . m_pSwitchLayer ! = pEditor - > GetSelectedLayer ( 0 ) & & pEditor - > m_Map . m_pTuneLayer ! = pEditor - > GetSelectedLayer ( 0 ) )
2011-07-12 01:14:46 +00:00
{
View . HSplitBottom ( 5.0f , & View , & Button ) ;
View . HSplitBottom ( 12.0f , & View , & Button ) ;
static float s_Name = 0 ;
pEditor - > UI ( ) - > DoLabel ( & Button , " Name: " , 10.0f , - 1 , - 1 ) ;
Button . VSplitLeft ( 40.0f , 0 , & Button ) ;
2011-07-20 20:18:31 +00:00
if ( pEditor - > DoEditBox ( & s_Name , & Button , pEditor - > GetSelectedLayer ( 0 ) - > m_aName , sizeof ( pEditor - > GetSelectedLayer ( 0 ) - > m_aName ) , 10.0f , & s_Name ) )
pEditor - > m_Map . m_Modified = true ;
2011-07-12 01:14:46 +00:00
}
2010-05-29 07:25:38 +00:00
View . HSplitBottom ( 10.0f , & View , 0 ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
CLayerGroup * pCurrentGroup = pEditor - > m_Map . m_lGroups [ pEditor - > m_SelectedGroup ] ;
CLayer * pCurrentLayer = pEditor - > GetSelectedLayer ( 0 ) ;
2011-04-13 18:37:12 +00:00
2008-01-17 23:09:49 +00:00
enum
{
PROP_GROUP = 0 ,
PROP_ORDER ,
2008-03-21 17:39:09 +00:00
PROP_HQ ,
2008-01-17 23:09:49 +00:00
NUM_PROPS ,
} ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
CProperty aProps [ ] = {
2011-03-20 16:04:03 +00:00
{ " Group " , pEditor - > m_SelectedGroup , PROPTYPE_INT_STEP , 0 , pEditor - > m_Map . m_lGroups . size ( ) - 1 } ,
2018-07-25 20:57:58 +00:00
{ " Order " , pEditor - > m_lSelectedLayers [ 0 ] , PROPTYPE_INT_STEP , 0 , pCurrentGroup - > m_lLayers . size ( ) } ,
2019-01-09 07:38:49 +00:00
{ " Detail " , pCurrentLayer & & pCurrentLayer - > m_Flags & LAYERFLAG_DETAIL , PROPTYPE_BOOL , 0 , 1 } ,
2008-01-17 23:09:49 +00:00
{ 0 } ,
} ;
2010-05-29 07:25:38 +00:00
2018-02-04 15:00:47 +00:00
// if(pEditor->m_Map.m_pGameLayer == pEditor->GetSelectedLayer(0)) // don't use Group and Detail from the selection if this is the game layer
if ( pEditor - > m_Map . m_pGameLayer = = pEditor - > GetSelectedLayer ( 0 ) | | pEditor - > m_Map . m_pTeleLayer = = pEditor - > GetSelectedLayer ( 0 ) | | pEditor - > m_Map . m_pSpeedupLayer = = pEditor - > GetSelectedLayer ( 0 ) | | pEditor - > m_Map . m_pFrontLayer = = pEditor - > GetSelectedLayer ( 0 ) | | pEditor - > m_Map . m_pSwitchLayer = = pEditor - > GetSelectedLayer ( 0 ) | | pEditor - > m_Map . m_pTuneLayer = = pEditor - > GetSelectedLayer ( 0 ) ) // don't use Group and Detail from the selection if this is the game layer
2010-05-29 07:25:38 +00:00
{
aProps [ 0 ] . m_Type = PROPTYPE_NULL ;
2010-09-27 19:41:41 +00:00
aProps [ 2 ] . m_Type = PROPTYPE_NULL ;
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
static int s_aIds [ NUM_PROPS ] = { 0 } ;
int NewVal = 0 ;
2011-03-21 23:31:42 +00:00
int Prop = pEditor - > DoProperties ( & View , aProps , s_aIds , & NewVal ) ;
if ( Prop ! = - 1 )
pEditor - > m_Map . m_Modified = true ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
if ( Prop = = PROP_ORDER )
2018-07-25 20:57:58 +00:00
pEditor - > SelectLayer ( pCurrentGroup - > SwapLayers ( pEditor - > m_lSelectedLayers [ 0 ] , NewVal ) ) ;
2019-01-09 07:38:49 +00:00
else if ( Prop = = PROP_GROUP & & pCurrentLayer & & pCurrentLayer - > m_Type ! = LAYERTYPE_GAME )
2008-01-17 23:09:49 +00:00
{
2010-05-29 07:25:38 +00:00
if ( NewVal > = 0 & & NewVal < pEditor - > m_Map . m_lGroups . size ( ) )
2008-01-17 23:09:49 +00:00
{
2010-05-29 07:25:38 +00:00
pCurrentGroup - > m_lLayers . remove ( pCurrentLayer ) ;
pEditor - > m_Map . m_lGroups [ NewVal ] - > m_lLayers . add ( pCurrentLayer ) ;
pEditor - > m_SelectedGroup = NewVal ;
2018-07-25 20:57:58 +00:00
pEditor - > SelectLayer ( pEditor - > m_Map . m_lGroups [ NewVal ] - > m_lLayers . size ( ) - 1 ) ;
2008-01-17 23:09:49 +00:00
}
}
2019-01-09 07:38:49 +00:00
else if ( Prop = = PROP_HQ & & pCurrentLayer )
2008-03-21 17:39:09 +00:00
{
2010-05-29 07:25:38 +00:00
pCurrentLayer - > m_Flags & = ~ LAYERFLAG_DETAIL ;
if ( NewVal )
pCurrentLayer - > m_Flags | = LAYERFLAG_DETAIL ;
2008-03-21 17:39:09 +00:00
}
2011-04-13 18:37:12 +00:00
2019-01-09 07:38:49 +00:00
if ( ! pCurrentLayer )
return true ;
2010-05-29 07:25:38 +00:00
return pCurrentLayer - > RenderProperties ( & View ) ;
2008-01-17 23:09:49 +00:00
}
2010-05-29 07:25:38 +00:00
int CEditor : : PopupQuad ( CEditor * pEditor , CUIRect View )
2008-01-17 23:09:49 +00:00
{
2018-08-13 09:11:56 +00:00
array < CQuad * > lQuads = pEditor - > GetSelectedQuads ( ) ;
CQuad * pCurrentQuad = lQuads [ pEditor - > m_SelectedQuadIndex ] ;
2008-01-17 23:09:49 +00:00
2010-05-29 07:25:38 +00:00
CUIRect Button ;
2011-04-13 18:37:12 +00:00
2008-03-02 15:59:52 +00:00
// delete button
2010-05-29 07:25:38 +00:00
View . HSplitBottom ( 12.0f , & View , & Button ) ;
static int s_DeleteButton = 0 ;
2011-03-20 16:04:03 +00:00
if ( pEditor - > DoButton_Editor ( & s_DeleteButton , " Delete " , 0 , & Button , 0 , " Deletes the current quad " ) )
2008-03-02 15:59:52 +00:00
{
2010-05-29 07:25:38 +00:00
CLayerQuads * pLayer = ( CLayerQuads * ) pEditor - > GetSelectedLayerType ( 0 , LAYERTYPE_QUADS ) ;
if ( pLayer )
2008-03-02 15:59:52 +00:00
{
2011-03-21 23:31:42 +00:00
pEditor - > m_Map . m_Modified = true ;
2018-08-13 09:11:56 +00:00
pEditor - > DeleteSelectedQuads ( ) ;
2008-03-02 15:59:52 +00:00
}
return 1 ;
}
2010-09-19 15:12:09 +00:00
// aspect ratio button
2011-03-29 10:08:46 +00:00
View . HSplitBottom ( 10.0f , & View , & Button ) ;
View . HSplitBottom ( 12.0f , & View , & Button ) ;
2010-09-19 15:12:09 +00:00
CLayerQuads * pLayer = ( CLayerQuads * ) pEditor - > GetSelectedLayerType ( 0 , LAYERTYPE_QUADS ) ;
if ( pLayer & & pLayer - > m_Image > = 0 & & pLayer - > m_Image < pEditor - > m_Map . m_lImages . size ( ) )
{
static int s_AspectRatioButton = 0 ;
2011-03-20 16:04:03 +00:00
if ( pEditor - > DoButton_Editor ( & s_AspectRatioButton , " Aspect ratio " , 0 , & Button , 0 , " Resizes the current Quad based on the aspect ratio of the image " ) )
2010-09-19 15:12:09 +00:00
{
2018-08-13 09:11:56 +00:00
for ( int i = 0 ; i < lQuads . size ( ) ; + + i )
2010-09-19 15:12:09 +00:00
{
2018-08-13 09:11:56 +00:00
int Top = lQuads [ i ] - > m_aPoints [ 0 ] . y ;
int Left = lQuads [ i ] - > m_aPoints [ 0 ] . x ;
int Right = lQuads [ i ] - > m_aPoints [ 0 ] . x ;
2010-09-19 15:12:09 +00:00
2018-08-13 09:11:56 +00:00
for ( int k = 1 ; k < 4 ; k + + )
{
if ( lQuads [ i ] - > m_aPoints [ k ] . y < Top ) Top = lQuads [ i ] - > m_aPoints [ k ] . y ;
if ( lQuads [ i ] - > m_aPoints [ k ] . x < Left ) Left = lQuads [ i ] - > m_aPoints [ k ] . x ;
if ( lQuads [ i ] - > m_aPoints [ k ] . x > Right ) Right = lQuads [ i ] - > m_aPoints [ k ] . x ;
}
2011-04-13 18:37:12 +00:00
2018-08-13 09:11:56 +00:00
int Height = ( Right - Left ) * pEditor - > m_Map . m_lImages [ pLayer - > m_Image ] - > m_Height / pEditor - > m_Map . m_lImages [ pLayer - > m_Image ] - > m_Width ;
lQuads [ i ] - > m_aPoints [ 0 ] . x = Left ; lQuads [ i ] - > m_aPoints [ 0 ] . y = Top ;
lQuads [ i ] - > m_aPoints [ 1 ] . x = Right ; lQuads [ i ] - > m_aPoints [ 1 ] . y = Top ;
lQuads [ i ] - > m_aPoints [ 2 ] . x = Left ; lQuads [ i ] - > m_aPoints [ 2 ] . y = Top + Height ;
lQuads [ i ] - > m_aPoints [ 3 ] . x = Right ; lQuads [ i ] - > m_aPoints [ 3 ] . y = Top + Height ;
pEditor - > m_Map . m_Modified = true ;
}
2010-09-19 15:12:09 +00:00
return 1 ;
}
2011-03-29 10:08:46 +00:00
}
// align button
View . HSplitBottom ( 6.0f , & View , & Button ) ;
View . HSplitBottom ( 12.0f , & View , & Button ) ;
static int s_AlignButton = 0 ;
if ( pEditor - > DoButton_Editor ( & s_AlignButton , " Align " , 0 , & Button , 0 , " Aligns coordinates of the quad points " ) )
{
2018-08-13 09:11:56 +00:00
for ( int i = 0 ; i < lQuads . size ( ) ; + + i )
2011-03-29 10:08:46 +00:00
{
2018-08-13 09:11:56 +00:00
for ( int k = 1 ; k < 4 ; k + + )
{
2019-04-11 10:21:42 +00:00
lQuads [ i ] - > m_aPoints [ k ] . x = 1000.0f * ( lQuads [ i ] - > m_aPoints [ k ] . x / 1000 ) ;
lQuads [ i ] - > m_aPoints [ k ] . y = 1000.0f * ( lQuads [ i ] - > m_aPoints [ k ] . y / 1000 ) ;
2018-08-13 09:11:56 +00:00
}
pEditor - > m_Map . m_Modified = true ;
2011-03-29 10:08:46 +00:00
}
return 1 ;
2010-09-19 15:12:09 +00:00
}
// square button
2011-03-29 10:08:46 +00:00
View . HSplitBottom ( 6.0f , & View , & Button ) ;
2010-05-29 07:25:38 +00:00
View . HSplitBottom ( 12.0f , & View , & Button ) ;
static int s_Button = 0 ;
2011-03-20 16:04:03 +00:00
if ( pEditor - > DoButton_Editor ( & s_Button , " Square " , 0 , & Button , 0 , " Squares the current quad " ) )
2008-01-17 23:09:49 +00:00
{
2018-08-13 09:11:56 +00:00
for ( int i = 0 ; i < lQuads . size ( ) ; + + i )
2008-01-17 23:09:49 +00:00
{
2018-08-13 09:11:56 +00:00
int Top = lQuads [ i ] - > m_aPoints [ 0 ] . y ;
int Left = lQuads [ i ] - > m_aPoints [ 0 ] . x ;
int Bottom = lQuads [ i ] - > m_aPoints [ 0 ] . y ;
int Right = lQuads [ i ] - > m_aPoints [ 0 ] . x ;
2011-04-13 18:37:12 +00:00
2018-08-13 09:11:56 +00:00
for ( int k = 1 ; k < 4 ; k + + )
{
if ( lQuads [ i ] - > m_aPoints [ k ] . y < Top ) Top = lQuads [ i ] - > m_aPoints [ k ] . y ;
if ( lQuads [ i ] - > m_aPoints [ k ] . x < Left ) Left = lQuads [ i ] - > m_aPoints [ k ] . x ;
if ( lQuads [ i ] - > m_aPoints [ k ] . y > Bottom ) Bottom = lQuads [ i ] - > m_aPoints [ k ] . y ;
if ( lQuads [ i ] - > m_aPoints [ k ] . x > Right ) Right = lQuads [ i ] - > m_aPoints [ k ] . x ;
}
lQuads [ i ] - > m_aPoints [ 0 ] . x = Left ; lQuads [ i ] - > m_aPoints [ 0 ] . y = Top ;
lQuads [ i ] - > m_aPoints [ 1 ] . x = Right ; lQuads [ i ] - > m_aPoints [ 1 ] . y = Top ;
lQuads [ i ] - > m_aPoints [ 2 ] . x = Left ; lQuads [ i ] - > m_aPoints [ 2 ] . y = Bottom ;
lQuads [ i ] - > m_aPoints [ 3 ] . x = Right ; lQuads [ i ] - > m_aPoints [ 3 ] . y = Bottom ;
pEditor - > m_Map . m_Modified = true ;
}
2008-01-17 23:09:49 +00:00
return 1 ;
}
enum
{
2011-03-29 10:08:46 +00:00
PROP_POS_X = 0 ,
PROP_POS_Y ,
PROP_POS_ENV ,
2008-01-17 23:09:49 +00:00
PROP_POS_ENV_OFFSET ,
PROP_COLOR_ENV ,
PROP_COLOR_ENV_OFFSET ,
NUM_PROPS ,
} ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
CProperty aProps [ ] = {
2018-08-13 09:11:56 +00:00
{ " Pos X " , pCurrentQuad - > m_aPoints [ 4 ] . x / 1000 , PROPTYPE_INT_SCROLL , - 1000000 , 1000000 } ,
{ " Pos Y " , pCurrentQuad - > m_aPoints [ 4 ] . y / 1000 , PROPTYPE_INT_SCROLL , - 1000000 , 1000000 } ,
{ " Pos. Env " , pCurrentQuad - > m_PosEnv + 1 , PROPTYPE_INT_STEP , 0 , pEditor - > m_Map . m_lEnvelopes . size ( ) + 1 } ,
{ " Pos. TO " , pCurrentQuad - > m_PosEnvOffset , PROPTYPE_INT_SCROLL , - 1000000 , 1000000 } ,
{ " Color Env " , pCurrentQuad - > m_ColorEnv + 1 , PROPTYPE_INT_STEP , 0 , pEditor - > m_Map . m_lEnvelopes . size ( ) + 1 } ,
{ " Color TO " , pCurrentQuad - > m_ColorEnvOffset , PROPTYPE_INT_SCROLL , - 1000000 , 1000000 } ,
2011-04-13 18:37:12 +00:00
2008-01-17 23:09:49 +00:00
{ 0 } ,
} ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
static int s_aIds [ NUM_PROPS ] = { 0 } ;
int NewVal = 0 ;
2011-03-21 23:31:42 +00:00
int Prop = pEditor - > DoProperties ( & View , aProps , s_aIds , & NewVal ) ;
if ( Prop ! = - 1 )
pEditor - > m_Map . m_Modified = true ;
2011-04-13 18:37:12 +00:00
2018-08-13 09:11:56 +00:00
float OffsetX = NewVal * 1000 - pCurrentQuad - > m_aPoints [ 4 ] . x ;
float OffsetY = NewVal * 1000 - pCurrentQuad - > m_aPoints [ 4 ] . y ;
for ( int i = 0 ; i < lQuads . size ( ) ; + + i )
2011-08-06 20:30:18 +00:00
{
2018-08-13 09:11:56 +00:00
if ( Prop = = PROP_POS_X )
2011-08-06 20:30:18 +00:00
{
2018-08-13 09:11:56 +00:00
for ( int k = 0 ; k < 5 ; + + k )
lQuads [ i ] - > m_aPoints [ k ] . x + = OffsetX ;
2011-08-06 20:30:18 +00:00
}
2018-08-13 09:11:56 +00:00
if ( Prop = = PROP_POS_Y )
2011-08-06 20:30:18 +00:00
{
2018-08-13 09:11:56 +00:00
for ( int k = 0 ; k < 5 ; + + k )
lQuads [ i ] - > m_aPoints [ k ] . y + = OffsetY ;
}
if ( Prop = = PROP_POS_ENV )
{
int Index = clamp ( NewVal - 1 , - 1 , pEditor - > m_Map . m_lEnvelopes . size ( ) - 1 ) ;
int Step = ( Index - lQuads [ i ] - > m_PosEnv ) % 2 ;
if ( Step ! = 0 )
{
for ( ; Index > = - 1 & & Index < pEditor - > m_Map . m_lEnvelopes . size ( ) ; Index + = Step )
if ( Index = = - 1 | | pEditor - > m_Map . m_lEnvelopes [ Index ] - > m_Channels = = 3 )
{
lQuads [ i ] - > m_PosEnv = Index ;
break ;
}
}
}
if ( Prop = = PROP_POS_ENV_OFFSET ) lQuads [ i ] - > m_PosEnvOffset = NewVal ;
if ( Prop = = PROP_COLOR_ENV )
{
int Index = clamp ( NewVal - 1 , - 1 , pEditor - > m_Map . m_lEnvelopes . size ( ) - 1 ) ;
int Step = ( Index - lQuads [ i ] - > m_ColorEnv ) % 2 ;
if ( Step ! = 0 )
{
for ( ; Index > = - 1 & & Index < pEditor - > m_Map . m_lEnvelopes . size ( ) ; Index + = Step )
if ( Index = = - 1 | | pEditor - > m_Map . m_lEnvelopes [ Index ] - > m_Channels = = 4 )
{
lQuads [ i ] - > m_ColorEnv = Index ;
break ;
}
}
2011-08-06 20:30:18 +00:00
}
2018-08-13 09:11:56 +00:00
if ( Prop = = PROP_COLOR_ENV_OFFSET ) lQuads [ i ] - > m_ColorEnvOffset = NewVal ;
2011-08-06 20:30:18 +00:00
}
2011-04-13 18:37:12 +00:00
2008-01-17 23:09:49 +00:00
return 0 ;
}
2014-10-10 17:11:21 +00:00
int CEditor : : PopupSource ( CEditor * pEditor , CUIRect View )
{
CSoundSource * pSource = pEditor - > GetSelectedSource ( ) ;
CUIRect Button ;
// delete button
View . HSplitBottom ( 12.0f , & View , & Button ) ;
static int s_DeleteButton = 0 ;
if ( pEditor - > DoButton_Editor ( & s_DeleteButton , " Delete " , 0 , & Button , 0 , " Deletes the current source " ) )
{
CLayerSounds * pLayer = ( CLayerSounds * ) pEditor - > GetSelectedLayerType ( 0 , LAYERTYPE_SOUNDS ) ;
if ( pLayer )
{
pEditor - > m_Map . m_Modified = true ;
pLayer - > m_lSources . remove_index ( pEditor - > m_SelectedSource ) ;
pEditor - > m_SelectedSource - - ;
}
return 1 ;
}
2014-11-28 19:25:43 +00:00
// Sound shape button
CUIRect ShapeButton ;
2014-11-29 12:20:04 +00:00
View . HSplitBottom ( 3.0f , & View , 0x0 ) ;
2014-11-28 19:25:43 +00:00
View . HSplitBottom ( 12.0f , & View , & ShapeButton ) ;
static int s_ShapeTypeButton = 0 ;
static const char * s_aShapeNames [ ] = {
" Rectangle " ,
" Circle "
} ;
2014-11-30 10:33:44 +00:00
pSource - > m_Shape . m_Type = pSource - > m_Shape . m_Type % CSoundShape : : NUM_SHAPES ; // prevent out of array errors
2014-11-28 19:25:43 +00:00
if ( pEditor - > DoButton_Editor ( & s_ShapeTypeButton , s_aShapeNames [ pSource - > m_Shape . m_Type ] , 0 , & ShapeButton , 0 , " Change shape " ) )
{
pSource - > m_Shape . m_Type = ( pSource - > m_Shape . m_Type + 1 ) % CSoundShape : : NUM_SHAPES ;
// set default values
switch ( pSource - > m_Shape . m_Type )
{
case CSoundShape : : SHAPE_CIRCLE :
{
pSource - > m_Shape . m_Circle . m_Radius = 1000.0f ;
break ;
}
case CSoundShape : : SHAPE_RECTANGLE :
{
pSource - > m_Shape . m_Rectangle . m_Width = f2fx ( 1000.0f ) ;
pSource - > m_Shape . m_Rectangle . m_Height = f2fx ( 800.0f ) ;
break ;
}
}
}
2015-07-09 00:08:14 +00:00
2014-11-28 19:25:43 +00:00
2014-10-10 17:11:21 +00:00
enum
{
PROP_POS_X = 0 ,
PROP_POS_Y ,
PROP_LOOP ,
2014-11-30 11:23:05 +00:00
PROP_PAN ,
2014-10-10 17:11:21 +00:00
PROP_TIME_DELAY ,
2014-11-28 19:25:43 +00:00
PROP_FALLOFF ,
2014-10-12 13:10:33 +00:00
PROP_POS_ENV ,
PROP_POS_ENV_OFFSET ,
2014-10-11 14:05:36 +00:00
PROP_SOUND_ENV ,
2014-10-12 13:10:33 +00:00
PROP_SOUND_ENV_OFFSET ,
2014-10-10 17:11:21 +00:00
NUM_PROPS ,
} ;
CProperty aProps [ ] = {
{ " Pos X " , pSource - > m_Position . x / 1000 , PROPTYPE_INT_SCROLL , - 1000000 , 1000000 } ,
{ " Pos Y " , pSource - > m_Position . y / 1000 , PROPTYPE_INT_SCROLL , - 1000000 , 1000000 } ,
{ " Loop " , pSource - > m_Loop , PROPTYPE_BOOL , 0 , 1 } ,
2014-11-30 11:23:05 +00:00
{ " Pan " , pSource - > m_Pan , PROPTYPE_BOOL , 0 , 1 } ,
2014-10-10 17:11:21 +00:00
{ " Delay " , pSource - > m_TimeDelay , PROPTYPE_INT_SCROLL , 0 , 1000000 } ,
2014-11-28 19:25:43 +00:00
{ " Falloff " , pSource - > m_Falloff , PROPTYPE_INT_SCROLL , 0 , 255 } ,
2014-10-12 13:10:33 +00:00
{ " Pos. Env " , pSource - > m_PosEnv + 1 , PROPTYPE_INT_STEP , 0 , pEditor - > m_Map . m_lEnvelopes . size ( ) + 1 } ,
{ " Pos. TO " , pSource - > m_PosEnvOffset , PROPTYPE_INT_SCROLL , - 1000000 , 1000000 } ,
2014-10-11 14:05:36 +00:00
{ " Sound Env " , pSource - > m_SoundEnv + 1 , PROPTYPE_INT_STEP , 0 , pEditor - > m_Map . m_lEnvelopes . size ( ) + 1 } ,
2014-10-12 13:10:33 +00:00
{ " Sound. TO " , pSource - > m_PosEnvOffset , PROPTYPE_INT_SCROLL , - 1000000 , 1000000 } ,
2014-10-10 17:11:21 +00:00
{ 0 } ,
} ;
2014-11-28 19:25:43 +00:00
2014-10-10 17:11:21 +00:00
static int s_aIds [ NUM_PROPS ] = { 0 } ;
int NewVal = 0 ;
int Prop = pEditor - > DoProperties ( & View , aProps , s_aIds , & NewVal ) ;
if ( Prop ! = - 1 )
pEditor - > m_Map . m_Modified = true ;
if ( Prop = = PROP_POS_X ) pSource - > m_Position . x = NewVal * 1000 ;
if ( Prop = = PROP_POS_Y ) pSource - > m_Position . y = NewVal * 1000 ;
if ( Prop = = PROP_LOOP ) pSource - > m_Loop = NewVal ;
2014-11-30 11:23:05 +00:00
if ( Prop = = PROP_PAN ) pSource - > m_Pan = NewVal ;
2014-10-10 17:11:21 +00:00
if ( Prop = = PROP_TIME_DELAY ) pSource - > m_TimeDelay = NewVal ;
2014-11-28 19:25:43 +00:00
if ( Prop = = PROP_FALLOFF ) pSource - > m_Falloff = NewVal ;
2014-10-12 13:10:33 +00:00
if ( Prop = = PROP_POS_ENV )
{
int Index = clamp ( NewVal - 1 , - 1 , pEditor - > m_Map . m_lEnvelopes . size ( ) - 1 ) ;
int Step = ( Index - pSource - > m_PosEnv ) % 2 ;
if ( Step ! = 0 )
{
for ( ; Index > = - 1 & & Index < pEditor - > m_Map . m_lEnvelopes . size ( ) ; Index + = Step )
if ( Index = = - 1 | | pEditor - > m_Map . m_lEnvelopes [ Index ] - > m_Channels = = 3 )
{
pSource - > m_PosEnv = Index ;
break ;
}
}
}
if ( Prop = = PROP_POS_ENV_OFFSET ) pSource - > m_PosEnvOffset = NewVal ;
2014-10-11 14:05:36 +00:00
if ( Prop = = PROP_SOUND_ENV )
{
int Index = clamp ( NewVal - 1 , - 1 , pEditor - > m_Map . m_lEnvelopes . size ( ) - 1 ) ;
int Step = ( Index - pSource - > m_SoundEnv ) % 2 ;
if ( Step ! = 0 )
{
for ( ; Index > = - 1 & & Index < pEditor - > m_Map . m_lEnvelopes . size ( ) ; Index + = Step )
2014-10-12 13:10:33 +00:00
if ( Index = = - 1 | | pEditor - > m_Map . m_lEnvelopes [ Index ] - > m_Channels = = 1 )
2014-10-11 14:05:36 +00:00
{
pSource - > m_SoundEnv = Index ;
break ;
}
}
}
2014-10-12 13:10:33 +00:00
if ( Prop = = PROP_SOUND_ENV_OFFSET ) pSource - > m_SoundEnvOffset = NewVal ;
2014-10-10 17:11:21 +00:00
2014-11-28 19:25:43 +00:00
// source shape properties
switch ( pSource - > m_Shape . m_Type )
{
case CSoundShape : : SHAPE_CIRCLE :
{
enum
{
PROP_CIRCLE_RADIUS = 0 ,
NUM_CIRCLE_PROPS ,
} ;
2015-07-09 00:08:14 +00:00
2014-11-28 19:25:43 +00:00
CProperty aCircleProps [ ] = {
{ " Radius " , pSource - > m_Shape . m_Circle . m_Radius , PROPTYPE_INT_SCROLL , 0 , 1000000 } ,
{ 0 } ,
} ;
static int s_aCircleIds [ NUM_CIRCLE_PROPS ] = { 0 } ;
2015-07-09 00:08:14 +00:00
2014-11-28 19:25:43 +00:00
NewVal = 0 ;
Prop = pEditor - > DoProperties ( & View , aCircleProps , s_aCircleIds , & NewVal ) ;
if ( Prop ! = - 1 )
pEditor - > m_Map . m_Modified = true ;
if ( Prop = = PROP_CIRCLE_RADIUS ) pSource - > m_Shape . m_Circle . m_Radius = NewVal ;
break ;
}
2015-07-09 00:08:14 +00:00
2014-11-28 19:25:43 +00:00
case CSoundShape : : SHAPE_RECTANGLE :
{
2014-11-29 12:20:04 +00:00
enum
{
PROP_RECTANGLE_WIDTH = 0 ,
PROP_RECTANGLE_HEIGHT ,
NUM_RECTANGLE_PROPS ,
} ;
2015-07-09 00:08:14 +00:00
2014-11-29 12:20:04 +00:00
CProperty aRectangleProps [ ] = {
{ " Width " , pSource - > m_Shape . m_Rectangle . m_Width / 1024 , PROPTYPE_INT_SCROLL , 0 , 1000000 } ,
{ " Height " , pSource - > m_Shape . m_Rectangle . m_Height / 1024 , PROPTYPE_INT_SCROLL , 0 , 1000000 } ,
{ 0 } ,
} ;
static int s_aRectangleIds [ NUM_RECTANGLE_PROPS ] = { 0 } ;
2015-07-09 00:08:14 +00:00
2014-11-29 12:20:04 +00:00
NewVal = 0 ;
Prop = pEditor - > DoProperties ( & View , aRectangleProps , s_aRectangleIds , & NewVal ) ;
if ( Prop ! = - 1 )
pEditor - > m_Map . m_Modified = true ;
if ( Prop = = PROP_RECTANGLE_WIDTH ) pSource - > m_Shape . m_Rectangle . m_Width = NewVal * 1024 ;
2014-11-29 13:29:40 +00:00
if ( Prop = = PROP_RECTANGLE_HEIGHT ) pSource - > m_Shape . m_Rectangle . m_Height = NewVal * 1024 ;
2014-11-29 12:20:04 +00:00
2014-11-28 19:25:43 +00:00
break ;
}
}
2015-07-09 00:08:14 +00:00
2014-11-28 19:25:43 +00:00
2014-10-10 17:11:21 +00:00
return 0 ;
}
2010-05-29 07:25:38 +00:00
int CEditor : : PopupPoint ( CEditor * pEditor , CUIRect View )
2008-01-17 23:09:49 +00:00
{
2018-08-13 09:11:56 +00:00
array < CQuad * > lQuads = pEditor - > GetSelectedQuads ( ) ;
CQuad * pCurrentQuad = lQuads [ pEditor - > m_SelectedQuadIndex ] ;
2011-04-13 18:37:12 +00:00
2008-01-17 23:09:49 +00:00
enum
{
2011-03-29 10:08:46 +00:00
PROP_POS_X = 0 ,
PROP_POS_Y ,
PROP_COLOR ,
2019-03-29 11:38:21 +00:00
PROP_TEX_U ,
PROP_TEX_V ,
2008-01-17 23:09:49 +00:00
NUM_PROPS ,
} ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
int Color = 0 ;
2018-08-13 09:11:56 +00:00
Color | = pCurrentQuad - > m_aColors [ pEditor - > m_SelectedQuadPoint ] . r < < 24 ;
Color | = pCurrentQuad - > m_aColors [ pEditor - > m_SelectedQuadPoint ] . g < < 16 ;
Color | = pCurrentQuad - > m_aColors [ pEditor - > m_SelectedQuadPoint ] . b < < 8 ;
Color | = pCurrentQuad - > m_aColors [ pEditor - > m_SelectedQuadPoint ] . a ;
2011-04-13 18:37:12 +00:00
2018-08-13 09:11:56 +00:00
int x = pCurrentQuad - > m_aPoints [ pEditor - > m_SelectedQuadPoint ] . x / 1000 ;
int y = pCurrentQuad - > m_aPoints [ pEditor - > m_SelectedQuadPoint ] . y / 1000 ;
2019-03-29 11:38:21 +00:00
int tu = pCurrentQuad - > m_aTexcoords [ pEditor - > m_SelectedQuadPoint ] . x / 1000 * 1024 ;
int tv = pCurrentQuad - > m_aTexcoords [ pEditor - > m_SelectedQuadPoint ] . y / 1000 * 1024 ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
CProperty aProps [ ] = {
2011-03-29 10:08:46 +00:00
{ " Pos X " , x , PROPTYPE_INT_SCROLL , - 1000000 , 1000000 } ,
{ " Pos Y " , y , PROPTYPE_INT_SCROLL , - 1000000 , 1000000 } ,
2011-03-20 16:04:03 +00:00
{ " Color " , Color , PROPTYPE_COLOR , - 1 , pEditor - > m_Map . m_lEnvelopes . size ( ) } ,
2019-03-29 11:38:21 +00:00
{ " Tex U " , tu , PROPTYPE_INT_SCROLL , - 1000000 , 1000000 } ,
{ " Tex V " , tv , PROPTYPE_INT_SCROLL , - 1000000 , 1000000 } ,
2008-01-17 23:09:49 +00:00
{ 0 } ,
} ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
static int s_aIds [ NUM_PROPS ] = { 0 } ;
int NewVal = 0 ;
2011-03-29 10:08:46 +00:00
int Prop = pEditor - > DoProperties ( & View , aProps , s_aIds , & NewVal ) ;
if ( Prop ! = - 1 )
pEditor - > m_Map . m_Modified = true ;
2018-08-13 09:11:56 +00:00
float OffsetX = NewVal * 1000 - x * 1000 ;
float OffsetY = NewVal * 1000 - y * 1000 ;
2019-03-29 11:38:21 +00:00
float OffsetU = NewVal * 1000 / 1024 - tu * 1000 / 1024 ;
float OffsetV = NewVal * 1000 / 1024 - tv * 1000 / 1024 ;
2018-08-13 09:11:56 +00:00
for ( int i = 0 ; i < lQuads . size ( ) ; + + i )
2008-01-17 23:09:49 +00:00
{
2018-08-13 09:11:56 +00:00
if ( Prop = = PROP_POS_X )
{
for ( int v = 0 ; v < 4 ; v + + )
if ( pEditor - > m_SelectedPoints & ( 1 < < v ) )
lQuads [ i ] - > m_aPoints [ v ] . x + = OffsetX ;
}
if ( Prop = = PROP_POS_Y )
2008-01-17 23:09:49 +00:00
{
2018-08-13 09:11:56 +00:00
for ( int v = 0 ; v < 4 ; v + + )
if ( pEditor - > m_SelectedPoints & ( 1 < < v ) )
lQuads [ i ] - > m_aPoints [ v ] . y + = OffsetY ;
}
if ( Prop = = PROP_COLOR )
{
for ( int v = 0 ; v < 4 ; v + + )
2008-01-17 23:09:49 +00:00
{
2018-08-13 09:11:56 +00:00
if ( pEditor - > m_SelectedPoints & ( 1 < < v ) )
{
lQuads [ i ] - > m_aColors [ v ] . r = ( NewVal > > 24 ) & 0xff ;
lQuads [ i ] - > m_aColors [ v ] . g = ( NewVal > > 16 ) & 0xff ;
lQuads [ i ] - > m_aColors [ v ] . b = ( NewVal > > 8 ) & 0xff ;
lQuads [ i ] - > m_aColors [ v ] . a = NewVal & 0xff ;
}
2008-01-17 23:09:49 +00:00
}
}
2019-03-29 11:38:21 +00:00
if ( Prop = = PROP_TEX_U )
{
for ( int v = 0 ; v < 4 ; v + + )
if ( pEditor - > m_SelectedPoints & ( 1 < < v ) )
lQuads [ i ] - > m_aTexcoords [ v ] . x + = OffsetU ;
}
if ( Prop = = PROP_TEX_V )
{
for ( int v = 0 ; v < 4 ; v + + )
if ( pEditor - > m_SelectedPoints & ( 1 < < v ) )
lQuads [ i ] - > m_aTexcoords [ v ] . y + = OffsetV ;
}
2008-01-17 23:09:49 +00:00
}
2011-04-13 18:37:12 +00:00
return 0 ;
2008-01-17 23:09:49 +00:00
}
2011-03-20 21:53:50 +00:00
int CEditor : : PopupNewFolder ( CEditor * pEditor , CUIRect View )
{
2011-03-21 23:31:42 +00:00
CUIRect Label , ButtonBar ;
2011-03-20 21:53:50 +00:00
// title
View . HSplitTop ( 10.0f , 0 , & View ) ;
View . HSplitTop ( 30.0f , & Label , & View ) ;
pEditor - > UI ( ) - > DoLabel ( & Label , " Create new folder " , 20.0f , 0 ) ;
View . HSplitBottom ( 10.0f , & View , 0 ) ;
2011-04-13 18:37:12 +00:00
View . HSplitBottom ( 20.0f , & View , & ButtonBar ) ;
2011-03-20 21:53:50 +00:00
if ( pEditor - > m_FileDialogErrString [ 0 ] = = 0 )
{
// interaction box
View . HSplitBottom ( 40.0f , & View , 0 ) ;
View . VMargin ( 40.0f , & View ) ;
View . HSplitBottom ( 20.0f , & View , & Label ) ;
2011-07-12 01:14:46 +00:00
static float s_FolderBox = 0 ;
pEditor - > DoEditBox ( & s_FolderBox , & Label , pEditor - > m_FileDialogNewFolderName , sizeof ( pEditor - > m_FileDialogNewFolderName ) , 15.0f , & s_FolderBox ) ;
2011-03-20 21:53:50 +00:00
View . HSplitBottom ( 20.0f , & View , & Label ) ;
pEditor - > UI ( ) - > DoLabel ( & Label , " Name: " , 10.0f , - 1 ) ;
// button bar
ButtonBar . VSplitLeft ( 30.0f , 0 , & ButtonBar ) ;
ButtonBar . VSplitLeft ( 110.0f , & Label , & ButtonBar ) ;
static int s_CreateButton = 0 ;
if ( pEditor - > DoButton_Editor ( & s_CreateButton , " Create " , 0 , & Label , 0 , 0 ) )
{
// create the folder
if ( * pEditor - > m_FileDialogNewFolderName )
{
char aBuf [ 512 ] ;
str_format ( aBuf , sizeof ( aBuf ) , " %s/%s " , pEditor - > m_pFileDialogPath , pEditor - > m_FileDialogNewFolderName ) ;
if ( pEditor - > Storage ( ) - > CreateFolder ( aBuf , IStorage : : TYPE_SAVE ) )
{
pEditor - > FilelistPopulate ( IStorage : : TYPE_SAVE ) ;
return 1 ;
}
else
str_copy ( pEditor - > m_FileDialogErrString , " Unable to create the folder " , sizeof ( pEditor - > m_FileDialogErrString ) ) ;
2011-04-13 18:37:12 +00:00
}
2011-03-20 21:53:50 +00:00
}
ButtonBar . VSplitRight ( 30.0f , & ButtonBar , 0 ) ;
ButtonBar . VSplitRight ( 110.0f , & ButtonBar , & Label ) ;
static int s_AbortButton = 0 ;
if ( pEditor - > DoButton_Editor ( & s_AbortButton , " Abort " , 0 , & Label , 0 , 0 ) )
return 1 ;
}
else
{
// error text
View . HSplitTop ( 30.0f , 0 , & View ) ;
View . VMargin ( 40.0f , & View ) ;
View . HSplitTop ( 20.0f , & Label , & View ) ;
pEditor - > UI ( ) - > DoLabel ( & Label , " Error: " , 10.0f , - 1 ) ;
View . HSplitTop ( 20.0f , & Label , & View ) ;
pEditor - > UI ( ) - > DoLabel ( & Label , " Unable to create the folder " , 10.0f , - 1 , View . w ) ;
// button
ButtonBar . VMargin ( ButtonBar . w / 2.0f - 55.0f , & ButtonBar ) ;
static int s_CreateButton = 0 ;
if ( pEditor - > DoButton_Editor ( & s_CreateButton , " Ok " , 0 , & ButtonBar , 0 , 0 ) )
return 1 ;
}
2011-04-13 18:37:12 +00:00
return 0 ;
2011-03-20 21:53:50 +00:00
}
2008-01-17 23:09:49 +00:00
2011-07-12 21:31:39 +00:00
int CEditor : : PopupMapInfo ( CEditor * pEditor , CUIRect View )
{
CUIRect Label , ButtonBar , Button ;
// title
View . HSplitTop ( 10.0f , 0 , & View ) ;
View . HSplitTop ( 30.0f , & Label , & View ) ;
pEditor - > UI ( ) - > DoLabel ( & Label , " Map details " , 20.0f , 0 ) ;
View . HSplitBottom ( 10.0f , & View , 0 ) ;
View . HSplitBottom ( 20.0f , & View , & ButtonBar ) ;
View . VMargin ( 40.0f , & View ) ;
// author box
View . HSplitTop ( 20.0f , & Label , & View ) ;
pEditor - > UI ( ) - > DoLabel ( & Label , " Author: " , 10.0f , - 1 ) ;
Label . VSplitLeft ( 40.0f , 0 , & Button ) ;
Button . HSplitTop ( 12.0f , & Button , 0 ) ;
static float s_AuthorBox = 0 ;
pEditor - > DoEditBox ( & s_AuthorBox , & Button , pEditor - > m_Map . m_MapInfo . m_aAuthorTmp , sizeof ( pEditor - > m_Map . m_MapInfo . m_aAuthorTmp ) , 10.0f , & s_AuthorBox ) ;
// version box
View . HSplitTop ( 20.0f , & Label , & View ) ;
pEditor - > UI ( ) - > DoLabel ( & Label , " Version: " , 10.0f , - 1 ) ;
Label . VSplitLeft ( 40.0f , 0 , & Button ) ;
Button . HSplitTop ( 12.0f , & Button , 0 ) ;
static float s_VersionBox = 0 ;
pEditor - > DoEditBox ( & s_VersionBox , & Button , pEditor - > m_Map . m_MapInfo . m_aVersionTmp , sizeof ( pEditor - > m_Map . m_MapInfo . m_aVersionTmp ) , 10.0f , & s_VersionBox ) ;
// credits box
View . HSplitTop ( 20.0f , & Label , & View ) ;
pEditor - > UI ( ) - > DoLabel ( & Label , " Credits: " , 10.0f , - 1 ) ;
Label . VSplitLeft ( 40.0f , 0 , & Button ) ;
Button . HSplitTop ( 12.0f , & Button , 0 ) ;
static float s_CreditsBox = 0 ;
pEditor - > DoEditBox ( & s_CreditsBox , & Button , pEditor - > m_Map . m_MapInfo . m_aCreditsTmp , sizeof ( pEditor - > m_Map . m_MapInfo . m_aCreditsTmp ) , 10.0f , & s_CreditsBox ) ;
// license box
View . HSplitTop ( 20.0f , & Label , & View ) ;
pEditor - > UI ( ) - > DoLabel ( & Label , " License: " , 10.0f , - 1 ) ;
Label . VSplitLeft ( 40.0f , 0 , & Button ) ;
Button . HSplitTop ( 12.0f , & Button , 0 ) ;
static float s_LicenseBox = 0 ;
pEditor - > DoEditBox ( & s_LicenseBox , & Button , pEditor - > m_Map . m_MapInfo . m_aLicenseTmp , sizeof ( pEditor - > m_Map . m_MapInfo . m_aLicenseTmp ) , 10.0f , & s_LicenseBox ) ;
// button bar
ButtonBar . VSplitLeft ( 30.0f , 0 , & ButtonBar ) ;
ButtonBar . VSplitLeft ( 110.0f , & Label , & ButtonBar ) ;
static int s_CreateButton = 0 ;
2016-11-27 18:50:20 +00:00
if ( pEditor - > DoButton_Editor ( & s_CreateButton , " Ok " , 0 , & Label , 0 , 0 ) )
2011-07-12 21:31:39 +00:00
{
str_copy ( pEditor - > m_Map . m_MapInfo . m_aAuthor , pEditor - > m_Map . m_MapInfo . m_aAuthorTmp , sizeof ( pEditor - > m_Map . m_MapInfo . m_aAuthor ) ) ;
str_copy ( pEditor - > m_Map . m_MapInfo . m_aVersion , pEditor - > m_Map . m_MapInfo . m_aVersionTmp , sizeof ( pEditor - > m_Map . m_MapInfo . m_aVersion ) ) ;
str_copy ( pEditor - > m_Map . m_MapInfo . m_aCredits , pEditor - > m_Map . m_MapInfo . m_aCreditsTmp , sizeof ( pEditor - > m_Map . m_MapInfo . m_aCredits ) ) ;
str_copy ( pEditor - > m_Map . m_MapInfo . m_aLicense , pEditor - > m_Map . m_MapInfo . m_aLicenseTmp , sizeof ( pEditor - > m_Map . m_MapInfo . m_aLicense ) ) ;
return 1 ;
}
ButtonBar . VSplitRight ( 30.0f , & ButtonBar , 0 ) ;
ButtonBar . VSplitRight ( 110.0f , & ButtonBar , & Label ) ;
static int s_AbortButton = 0 ;
if ( pEditor - > DoButton_Editor ( & s_AbortButton , " Abort " , 0 , & Label , 0 , 0 ) )
return 1 ;
2011-04-13 18:37:12 +00:00
return 0 ;
2011-03-20 21:53:50 +00:00
}
2008-01-17 23:09:49 +00:00
2011-03-21 23:31:42 +00:00
int CEditor : : PopupEvent ( CEditor * pEditor , CUIRect View )
{
CUIRect Label , ButtonBar ;
// title
View . HSplitTop ( 10.0f , 0 , & View ) ;
View . HSplitTop ( 30.0f , & Label , & View ) ;
if ( pEditor - > m_PopupEventType = = POPEVENT_EXIT )
pEditor - > UI ( ) - > DoLabel ( & Label , " Exit the editor " , 20.0f , 0 ) ;
else if ( pEditor - > m_PopupEventType = = POPEVENT_LOAD )
pEditor - > UI ( ) - > DoLabel ( & Label , " Load map " , 20.0f , 0 ) ;
else if ( pEditor - > m_PopupEventType = = POPEVENT_NEW )
pEditor - > UI ( ) - > DoLabel ( & Label , " New map " , 20.0f , 0 ) ;
else if ( pEditor - > m_PopupEventType = = POPEVENT_SAVE )
pEditor - > UI ( ) - > DoLabel ( & Label , " Save map " , 20.0f , 0 ) ;
2016-04-27 15:49:14 +00:00
else if ( pEditor - > m_PopupEventType = = POPEVENT_LARGELAYER )
pEditor - > UI ( ) - > DoLabel ( & Label , " Large layer " , 20.0f , 0 ) ;
2016-05-01 16:08:07 +00:00
else if ( pEditor - > m_PopupEventType = = POPEVENT_PREVENTUNUSEDTILES )
pEditor - > UI ( ) - > DoLabel ( & Label , " Unused tiles disabled " , 20.0f , 0 ) ;
2011-03-21 23:31:42 +00:00
View . HSplitBottom ( 10.0f , & View , 0 ) ;
2011-04-13 18:37:12 +00:00
View . HSplitBottom ( 20.0f , & View , & ButtonBar ) ;
2011-03-21 23:31:42 +00:00
// notification text
View . HSplitTop ( 30.0f , 0 , & View ) ;
View . VMargin ( 40.0f , & View ) ;
View . HSplitTop ( 20.0f , & Label , & View ) ;
if ( pEditor - > m_PopupEventType = = POPEVENT_EXIT )
pEditor - > UI ( ) - > DoLabel ( & Label , " The map contains unsaved data, you might want to save it before you exit the editor. \n Continue anyway? " , 10.0f , - 1 , Label . w - 10.0f ) ;
2016-08-23 01:08:36 +00:00
else if ( ( pEditor - > m_PopupEventType = = POPEVENT_LOAD )
| | ( pEditor - > m_PopupEventType = = POPEVENT_LOADCURRENT ) )
2011-03-21 23:31:42 +00:00
pEditor - > UI ( ) - > DoLabel ( & Label , " The map contains unsaved data, you might want to save it before you load a new map. \n Continue anyway? " , 10.0f , - 1 , Label . w - 10.0f ) ;
else if ( pEditor - > m_PopupEventType = = POPEVENT_NEW )
pEditor - > UI ( ) - > DoLabel ( & Label , " The map contains unsaved data, you might want to save it before you create a new map. \n Continue anyway? " , 10.0f , - 1 , Label . w - 10.0f ) ;
else if ( pEditor - > m_PopupEventType = = POPEVENT_SAVE )
pEditor - > UI ( ) - > DoLabel ( & Label , " The file already exists. \n Do you want to overwrite the map? " , 10.0f , - 1 ) ;
2016-04-27 15:49:14 +00:00
else if ( pEditor - > m_PopupEventType = = POPEVENT_LARGELAYER )
pEditor - > UI ( ) - > DoLabel ( & Label , " You are trying to set the height or width of a layer to more than 1000 tiles. This is actually possible, but only rarely necessary. It may cause the editor to work slower, larger file size as well as higher memory usage for client and server. " , 10.0f , - 1 , Label . w - 10.0f ) ;
2016-05-01 16:08:07 +00:00
else if ( pEditor - > m_PopupEventType = = POPEVENT_PREVENTUNUSEDTILES )
2019-02-08 02:10:12 +00:00
pEditor - > UI ( ) - > DoLabel ( & Label , " Unused tiles can't be placed by default because they could get a use later and then destroy your map. \n Activate the 'Unused' switch to be able to place every tile. " , 10.0f , - 1 , Label . w - 10.0f ) ;
2011-03-21 23:31:42 +00:00
// button bar
ButtonBar . VSplitLeft ( 30.0f , 0 , & ButtonBar ) ;
ButtonBar . VSplitLeft ( 110.0f , & Label , & ButtonBar ) ;
static int s_OkButton = 0 ;
if ( pEditor - > DoButton_Editor ( & s_OkButton , " Ok " , 0 , & Label , 0 , 0 ) )
{
if ( pEditor - > m_PopupEventType = = POPEVENT_EXIT )
g_Config . m_ClEditor = 0 ;
else if ( pEditor - > m_PopupEventType = = POPEVENT_LOAD )
pEditor - > InvokeFileDialog ( IStorage : : TYPE_ALL , FILETYPE_MAP , " Load map " , " Load " , " maps " , " " , pEditor - > CallbackOpenMap , pEditor ) ;
2016-08-23 01:08:36 +00:00
else if ( pEditor - > m_PopupEventType = = POPEVENT_LOADCURRENT )
pEditor - > LoadCurrentMap ( ) ;
2011-03-21 23:31:42 +00:00
else if ( pEditor - > m_PopupEventType = = POPEVENT_NEW )
{
pEditor - > Reset ( ) ;
pEditor - > m_aFileName [ 0 ] = 0 ;
}
else if ( pEditor - > m_PopupEventType = = POPEVENT_SAVE )
pEditor - > CallbackSaveMap ( pEditor - > m_aFileSaveName , IStorage : : TYPE_SAVE , pEditor ) ;
2011-08-13 17:22:01 +00:00
pEditor - > m_PopupEventWasActivated = false ;
2011-03-21 23:31:42 +00:00
return 1 ;
}
ButtonBar . VSplitRight ( 30.0f , & ButtonBar , 0 ) ;
ButtonBar . VSplitRight ( 110.0f , & ButtonBar , & Label ) ;
2016-05-01 16:08:07 +00:00
if ( pEditor - > m_PopupEventType ! = POPEVENT_LARGELAYER & & pEditor - > m_PopupEventType ! = POPEVENT_PREVENTUNUSEDTILES )
2011-08-13 17:22:01 +00:00
{
2016-04-27 15:49:14 +00:00
static int s_AbortButton = 0 ;
if ( pEditor - > DoButton_Editor ( & s_AbortButton , " Abort " , 0 , & Label , 0 , 0 ) )
{
pEditor - > m_PopupEventWasActivated = false ;
return 1 ;
}
2011-08-13 17:22:01 +00:00
}
2011-03-21 23:31:42 +00:00
return 0 ;
}
2008-01-17 23:09:49 +00:00
2010-05-29 07:25:38 +00:00
static int g_SelectImageSelected = - 100 ;
static int g_SelectImageCurrent = - 100 ;
2008-01-17 23:09:49 +00:00
2010-05-29 07:25:38 +00:00
int CEditor : : PopupSelectImage ( CEditor * pEditor , CUIRect View )
2008-01-17 23:09:49 +00:00
{
2010-05-29 07:25:38 +00:00
CUIRect ButtonBar , ImageView ;
View . VSplitLeft ( 80.0f , & ButtonBar , & View ) ;
View . Margin ( 10.0f , & ImageView ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
int ShowImage = g_SelectImageCurrent ;
2011-04-13 18:37:12 +00:00
2014-06-11 23:09:02 +00:00
static int s_ScrollBar = 0 ;
static float s_ScrollValue = 0 ;
float ImagesHeight = pEditor - > m_Map . m_lImages . size ( ) * 14 ;
float ScrollDifference = ImagesHeight - ButtonBar . h ;
if ( pEditor - > m_Map . m_lImages . size ( ) > 20 ) // Do we need a scrollbar?
{
CUIRect Scroll ;
ButtonBar . VSplitRight ( 15.0f , & ButtonBar , & Scroll ) ;
ButtonBar . VSplitRight ( 3.0f , & ButtonBar , 0 ) ; // extra spacing
Scroll . HMargin ( 5.0f , & Scroll ) ;
s_ScrollValue = pEditor - > UiDoScrollbarV ( & s_ScrollBar , & Scroll , s_ScrollValue ) ;
if ( pEditor - > UI ( ) - > MouseInside ( & Scroll ) | | pEditor - > UI ( ) - > MouseInside ( & ButtonBar ) )
{
int ScrollNum = ( int ) ( ( ImagesHeight - ButtonBar . h ) / 14.0f ) + 1 ;
if ( ScrollNum > 0 )
{
2016-04-30 18:11:26 +00:00
if ( pEditor - > Input ( ) - > KeyPress ( KEY_MOUSE_WHEEL_UP ) )
2014-06-11 23:09:02 +00:00
s_ScrollValue = clamp ( s_ScrollValue - 1.0f / ScrollNum , 0.0f , 1.0f ) ;
2016-04-30 18:11:26 +00:00
if ( pEditor - > Input ( ) - > KeyPress ( KEY_MOUSE_WHEEL_DOWN ) )
2014-06-11 23:09:02 +00:00
s_ScrollValue = clamp ( s_ScrollValue + 1.0f / ScrollNum , 0.0f , 1.0f ) ;
}
}
}
float ImageStartAt = ScrollDifference * s_ScrollValue ;
if ( ImageStartAt < 0.0f )
ImageStartAt = 0.0f ;
float ImageStopAt = ImagesHeight - ScrollDifference * ( 1 - s_ScrollValue ) ;
float ImageCur = 0.0f ;
2010-05-29 07:25:38 +00:00
for ( int i = - 1 ; i < pEditor - > m_Map . m_lImages . size ( ) ; i + + )
2008-01-17 23:09:49 +00:00
{
2014-06-11 23:09:02 +00:00
if ( ImageCur > ImageStopAt )
break ;
if ( ImageCur < ImageStartAt )
{
ImageCur + = 14.0f ;
continue ;
}
ImageCur + = 14.0f ;
2010-05-29 07:25:38 +00:00
CUIRect Button ;
2014-06-11 23:09:02 +00:00
ButtonBar . HSplitTop ( 14.0f , & Button , & ButtonBar ) ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
if ( pEditor - > UI ( ) - > MouseInside ( & Button ) )
ShowImage = i ;
2011-04-13 18:37:12 +00:00
2008-01-17 23:09:49 +00:00
if ( i = = - 1 )
{
2011-03-20 16:04:03 +00:00
if ( pEditor - > DoButton_MenuItem ( & pEditor - > m_Map . m_lImages [ i ] , " None " , i = = g_SelectImageCurrent , & Button ) )
2010-05-29 07:25:38 +00:00
g_SelectImageSelected = - 1 ;
2008-01-17 23:09:49 +00:00
}
else
{
2010-05-29 07:25:38 +00:00
if ( pEditor - > DoButton_MenuItem ( & pEditor - > m_Map . m_lImages [ i ] , pEditor - > m_Map . m_lImages [ i ] - > m_aName , i = = g_SelectImageCurrent , & Button ) )
g_SelectImageSelected = i ;
2008-01-17 23:09:49 +00:00
}
}
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
if ( ShowImage > = 0 & & ShowImage < pEditor - > m_Map . m_lImages . size ( ) )
2011-08-06 11:08:29 +00:00
{
if ( ImageView . h < ImageView . w )
ImageView . w = ImageView . h ;
else
ImageView . h = ImageView . w ;
float Max = ( float ) ( max ( pEditor - > m_Map . m_lImages [ ShowImage ] - > m_Width , pEditor - > m_Map . m_lImages [ ShowImage ] - > m_Height ) ) ;
ImageView . w * = pEditor - > m_Map . m_lImages [ ShowImage ] - > m_Width / Max ;
ImageView . h * = pEditor - > m_Map . m_lImages [ ShowImage ] - > m_Height / Max ;
2011-02-12 10:40:36 +00:00
pEditor - > Graphics ( ) - > TextureSet ( pEditor - > m_Map . m_lImages [ ShowImage ] - > m_TexID ) ;
2012-01-08 00:47:53 +00:00
pEditor - > Graphics ( ) - > BlendNormal ( ) ;
pEditor - > Graphics ( ) - > WrapClamp ( ) ;
pEditor - > Graphics ( ) - > QuadsBegin ( ) ;
IGraphics : : CQuadItem QuadItem ( ImageView . x , ImageView . y , ImageView . w , ImageView . h ) ;
pEditor - > Graphics ( ) - > QuadsDrawTL ( & QuadItem , 1 ) ;
pEditor - > Graphics ( ) - > QuadsEnd ( ) ;
pEditor - > Graphics ( ) - > WrapNormal ( ) ;
2011-08-06 11:08:29 +00:00
}
2008-01-17 23:09:49 +00:00
return 0 ;
}
2010-05-29 07:25:38 +00:00
void CEditor : : PopupSelectImageInvoke ( int Current , float x , float y )
2008-01-17 23:09:49 +00:00
{
2010-05-29 07:25:38 +00:00
static int s_SelectImagePopupId = 0 ;
g_SelectImageSelected = - 100 ;
g_SelectImageCurrent = Current ;
2014-06-11 23:09:02 +00:00
UiInvokePopupMenu ( & s_SelectImagePopupId , 0 , x , y , 400 , 300 , PopupSelectImage ) ;
2008-01-17 23:09:49 +00:00
}
2010-05-29 07:25:38 +00:00
int CEditor : : PopupSelectImageResult ( )
2008-01-17 23:09:49 +00:00
{
2010-05-29 07:25:38 +00:00
if ( g_SelectImageSelected = = - 100 )
2008-01-17 23:09:49 +00:00
return - 100 ;
2011-04-13 18:37:12 +00:00
2010-05-29 07:25:38 +00:00
g_SelectImageCurrent = g_SelectImageSelected ;
g_SelectImageSelected = - 100 ;
return g_SelectImageCurrent ;
2008-01-17 23:09:49 +00:00
}
2014-10-08 15:33:06 +00:00
static int g_SelectSoundSelected = - 100 ;
static int g_SelectSoundCurrent = - 100 ;
int CEditor : : PopupSelectSound ( CEditor * pEditor , CUIRect View )
{
CUIRect ButtonBar , SoundView ;
View . VSplitLeft ( 80.0f , & ButtonBar , & View ) ;
View . Margin ( 10.0f , & SoundView ) ;
static int s_ScrollBar = 0 ;
static float s_ScrollValue = 0 ;
float SoundsHeight = pEditor - > m_Map . m_lSounds . size ( ) * 14 ;
float ScrollDifference = SoundsHeight - ButtonBar . h ;
if ( pEditor - > m_Map . m_lSounds . size ( ) > 20 ) // Do we need a scrollbar?
{
CUIRect Scroll ;
ButtonBar . VSplitRight ( 15.0f , & ButtonBar , & Scroll ) ;
ButtonBar . VSplitRight ( 3.0f , & ButtonBar , 0 ) ; // extra spacing
Scroll . HMargin ( 5.0f , & Scroll ) ;
s_ScrollValue = pEditor - > UiDoScrollbarV ( & s_ScrollBar , & Scroll , s_ScrollValue ) ;
if ( pEditor - > UI ( ) - > MouseInside ( & Scroll ) | | pEditor - > UI ( ) - > MouseInside ( & ButtonBar ) )
{
int ScrollNum = ( int ) ( ( SoundsHeight - ButtonBar . h ) / 14.0f ) + 1 ;
if ( ScrollNum > 0 )
{
2016-04-30 18:11:26 +00:00
if ( pEditor - > Input ( ) - > KeyPress ( KEY_MOUSE_WHEEL_UP ) )
2014-10-08 15:33:06 +00:00
s_ScrollValue = clamp ( s_ScrollValue - 1.0f / ScrollNum , 0.0f , 1.0f ) ;
2016-04-30 18:11:26 +00:00
if ( pEditor - > Input ( ) - > KeyPress ( KEY_MOUSE_WHEEL_DOWN ) )
2014-10-08 15:33:06 +00:00
s_ScrollValue = clamp ( s_ScrollValue + 1.0f / ScrollNum , 0.0f , 1.0f ) ;
}
}
}
float SoundStartAt = ScrollDifference * s_ScrollValue ;
if ( SoundStartAt < 0.0f )
SoundStartAt = 0.0f ;
float SoundStopAt = SoundsHeight - ScrollDifference * ( 1 - s_ScrollValue ) ;
float SoundCur = 0.0f ;
for ( int i = - 1 ; i < pEditor - > m_Map . m_lSounds . size ( ) ; i + + )
{
if ( SoundCur > SoundStopAt )
break ;
if ( SoundCur < SoundStartAt )
{
SoundCur + = 14.0f ;
continue ;
}
SoundCur + = 14.0f ;
CUIRect Button ;
ButtonBar . HSplitTop ( 14.0f , & Button , & ButtonBar ) ;
2014-10-19 11:19:36 +00:00
//if(pEditor->UI()->MouseInside(&Button))
// ShowSound = i;
2014-10-08 15:33:06 +00:00
if ( i = = - 1 )
{
if ( pEditor - > DoButton_MenuItem ( & pEditor - > m_Map . m_lSounds [ i ] , " None " , i = = g_SelectSoundCurrent , & Button ) )
g_SelectSoundSelected = - 1 ;
}
else
{
if ( pEditor - > DoButton_MenuItem ( & pEditor - > m_Map . m_lSounds [ i ] , pEditor - > m_Map . m_lSounds [ i ] - > m_aName , i = = g_SelectSoundCurrent , & Button ) )
g_SelectSoundSelected = i ;
}
}
return 0 ;
}
void CEditor : : PopupSelectSoundInvoke ( int Current , float x , float y )
{
static int s_SelectSoundPopupId = 0 ;
g_SelectSoundSelected = - 100 ;
g_SelectSoundCurrent = Current ;
UiInvokePopupMenu ( & s_SelectSoundPopupId , 0 , x , y , 400 , 300 , PopupSelectSound ) ;
}
int CEditor : : PopupSelectSoundResult ( )
{
if ( g_SelectSoundSelected = = - 100 )
return - 100 ;
g_SelectSoundCurrent = g_SelectSoundSelected ;
g_SelectSoundSelected = - 100 ;
return g_SelectSoundCurrent ;
2015-07-09 00:08:14 +00:00
}
2014-10-08 15:33:06 +00:00
2011-02-12 18:10:45 +00:00
static int s_GametileOpSelected = - 1 ;
2008-01-17 23:09:49 +00:00
2011-02-12 18:10:45 +00:00
int CEditor : : PopupSelectGametileOp ( CEditor * pEditor , CUIRect View )
{
2016-05-05 16:23:04 +00:00
static const char * s_pButtonNames [ ] = { " Air " , " Hookable " , " Death " , " Unhookable " , " Hookthrough " , " Freeze " , " Unfreeze " , " Deep Freeze " , " Deep Unfreeze " , " Blue Check-Tele " , " Red Check-Tele " } ;
2011-02-12 18:10:45 +00:00
static unsigned s_NumButtons = sizeof ( s_pButtonNames ) / sizeof ( char * ) ;
CUIRect Button ;
for ( unsigned i = 0 ; i < s_NumButtons ; + + i )
{
View . HSplitTop ( 2.0f , 0 , & View ) ;
View . HSplitTop ( 12.0f , & Button , & View ) ;
2011-03-20 16:04:03 +00:00
if ( pEditor - > DoButton_Editor ( & s_pButtonNames [ i ] , s_pButtonNames [ i ] , 0 , & Button , 0 , 0 ) )
2011-02-12 18:10:45 +00:00
s_GametileOpSelected = i ;
}
2008-01-17 23:09:49 +00:00
2011-02-12 18:10:45 +00:00
return 0 ;
}
2008-01-17 23:09:49 +00:00
2011-02-12 18:10:45 +00:00
void CEditor : : PopupSelectGametileOpInvoke ( float x , float y )
{
static int s_SelectGametileOpPopupId = 0 ;
s_GametileOpSelected = - 1 ;
2016-05-01 15:44:02 +00:00
UiInvokePopupMenu ( & s_SelectGametileOpPopupId , 0 , x , y , 120.0f , 165.0f , PopupSelectGametileOp ) ;
2011-02-12 18:10:45 +00:00
}
2008-01-17 23:09:49 +00:00
2011-02-12 18:10:45 +00:00
int CEditor : : PopupSelectGameTileOpResult ( )
{
if ( s_GametileOpSelected < 0 )
return - 1 ;
2011-04-13 18:37:12 +00:00
2011-02-12 18:10:45 +00:00
int Result = s_GametileOpSelected ;
s_GametileOpSelected = - 1 ;
return Result ;
}
2008-01-17 23:09:49 +00:00
2018-10-08 20:44:49 +00:00
static int s_AutoMapConfigSelected = - 100 ;
static int s_AutoMapConfigCurrent = - 100 ;
2011-08-13 00:12:40 +00:00
int CEditor : : PopupSelectConfigAutoMap ( CEditor * pEditor , CUIRect View )
{
CLayerTiles * pLayer = static_cast < CLayerTiles * > ( pEditor - > GetSelectedLayer ( 0 ) ) ;
CUIRect Button ;
static int s_AutoMapperConfigButtons [ 256 ] ;
CAutoMapper * pAutoMapper = & pEditor - > m_Map . m_lImages [ pLayer - > m_Image ] - > m_AutoMapper ;
2011-08-11 08:59:14 +00:00
2018-10-03 16:16:58 +00:00
for ( int i = - 1 ; i < pAutoMapper - > ConfigNamesNum ( ) ; + + i )
2011-08-13 00:12:40 +00:00
{
View . HSplitTop ( 2.0f , 0 , & View ) ;
View . HSplitTop ( 12.0f , & Button , & View ) ;
2018-10-03 16:16:58 +00:00
if ( pEditor - > DoButton_MenuItem ( & s_AutoMapperConfigButtons [ i ] , i = = - 1 ? " None " : pAutoMapper - > GetConfigName ( i ) , i = = s_AutoMapConfigCurrent , & Button , 0 , 0 ) )
2011-08-13 00:12:40 +00:00
s_AutoMapConfigSelected = i ;
}
return 0 ;
}
2018-10-03 16:16:58 +00:00
void CEditor : : PopupSelectConfigAutoMapInvoke ( int Current , float x , float y )
2011-08-13 00:12:40 +00:00
{
static int s_AutoMapConfigSelectID = 0 ;
2018-10-03 16:16:58 +00:00
s_AutoMapConfigSelected = - 100 ;
s_AutoMapConfigCurrent = Current ;
2011-08-13 00:12:40 +00:00
CLayerTiles * pLayer = static_cast < CLayerTiles * > ( GetSelectedLayer ( 0 ) ) ;
2018-10-03 16:16:58 +00:00
UiInvokePopupMenu ( & s_AutoMapConfigSelectID , 0 , x , y , 120.0f , 26.0f + 14.0f * m_Map . m_lImages [ pLayer - > m_Image ] - > m_AutoMapper . ConfigNamesNum ( ) , PopupSelectConfigAutoMap ) ;
2011-08-13 00:12:40 +00:00
}
int CEditor : : PopupSelectConfigAutoMapResult ( )
{
2018-10-03 16:16:58 +00:00
if ( s_AutoMapConfigSelected = = - 100 )
return - 100 ;
2011-08-11 08:59:14 +00:00
2018-10-03 16:16:58 +00:00
s_AutoMapConfigCurrent = s_AutoMapConfigSelected ;
s_AutoMapConfigSelected = - 100 ;
return s_AutoMapConfigCurrent ;
2011-08-13 00:12:40 +00:00
}
2011-04-09 06:41:31 +00:00
// DDRace
2010-09-30 21:31:19 +00:00
int CEditor : : PopupTele ( CEditor * pEditor , CUIRect View )
{
CUIRect Button ;
View . HSplitBottom ( 12.0f , & View , & Button ) ;
2011-04-09 06:41:31 +00:00
2010-09-30 21:31:19 +00:00
enum
{
PROP_TELE = 0 ,
NUM_PROPS ,
} ;
2011-04-09 06:41:31 +00:00
2010-09-30 21:31:19 +00:00
CProperty aProps [ ] = {
2010-12-07 15:51:59 +00:00
{ " Number " , pEditor - > m_TeleNumber , PROPTYPE_INT_STEP , 0 , 255 } ,
2010-09-30 21:31:19 +00:00
{ 0 } ,
} ;
2008-01-17 23:09:49 +00:00
2010-09-30 21:31:19 +00:00
static int s_aIds [ NUM_PROPS ] = { 0 } ;
int NewVal = 0 ;
2014-05-17 15:19:48 +00:00
static vec4 s_color = vec4 ( 1 , 1 , 1 , 0.5f ) ;
int Prop = pEditor - > DoProperties ( & View , aProps , s_aIds , & NewVal , s_color ) ;
2011-04-09 06:41:31 +00:00
2010-09-30 21:31:19 +00:00
if ( Prop = = PROP_TELE )
2014-05-17 15:19:48 +00:00
{
2015-06-28 14:17:23 +00:00
NewVal = ( NewVal + 256 ) % 256 ;
2014-05-17 15:19:48 +00:00
CLayerTele * gl = pEditor - > m_Map . m_pTeleLayer ;
for ( int y = 0 ; y < gl - > m_Height ; + + y )
{
for ( int x = 0 ; x < gl - > m_Width ; + + x )
{
if ( gl - > m_pTeleTile [ y * gl - > m_Width + x ] . m_Number = = NewVal )
{
s_color = vec4 ( 1 , 0.5f , 0.5f , 0.5f ) ;
goto done ;
}
}
}
s_color = vec4 ( 0.5f , 1 , 0.5f , 0.5f ) ;
done :
pEditor - > m_TeleNumber = NewVal ;
}
2011-04-09 06:41:31 +00:00
2010-09-30 21:31:19 +00:00
return 0 ;
}
int CEditor : : PopupSpeedup ( CEditor * pEditor , CUIRect View )
{
CUIRect Button ;
View . HSplitBottom ( 12.0f , & View , & Button ) ;
2011-04-09 06:41:31 +00:00
2010-09-30 21:31:19 +00:00
enum
{
PROP_FORCE = 0 ,
PROP_MAXSPEED ,
PROP_ANGLE ,
NUM_PROPS
} ;
2011-04-09 06:41:31 +00:00
2010-09-30 21:31:19 +00:00
CProperty aProps [ ] = {
2016-06-02 13:31:12 +00:00
{ " Force " , pEditor - > m_SpeedupForce , PROPTYPE_INT_STEP , 0 , 255 } ,
{ " Max Speed " , pEditor - > m_SpeedupMaxSpeed , PROPTYPE_INT_STEP , 0 , 255 } ,
2015-07-08 11:55:02 +00:00
{ " Angle " , pEditor - > m_SpeedupAngle , PROPTYPE_ANGLE_SCROLL , 0 , 359 } ,
2010-09-30 21:31:19 +00:00
{ 0 } ,
} ;
static int s_aIds [ NUM_PROPS ] = { 0 } ;
int NewVal = 0 ;
int Prop = pEditor - > DoProperties ( & View , aProps , s_aIds , & NewVal ) ;
if ( Prop = = PROP_FORCE )
pEditor - > m_SpeedupForce = clamp ( NewVal , 0 , 255 ) ;
if ( Prop = = PROP_MAXSPEED )
pEditor - > m_SpeedupMaxSpeed = clamp ( NewVal , 0 , 255 ) ;
if ( Prop = = PROP_ANGLE )
pEditor - > m_SpeedupAngle = clamp ( NewVal , 0 , 359 ) ;
2011-04-09 06:41:31 +00:00
2010-09-30 21:31:19 +00:00
return 0 ;
}
2008-01-17 23:09:49 +00:00
2010-09-30 21:31:19 +00:00
int CEditor : : PopupSwitch ( CEditor * pEditor , CUIRect View )
{
CUIRect Button ;
View . HSplitBottom ( 12.0f , & View , & Button ) ;
2008-01-17 23:09:49 +00:00
2010-09-30 21:31:19 +00:00
enum
{
2016-05-14 13:16:52 +00:00
PROP_SwitchDelay = 0 ,
PROP_SwitchNumber ,
2010-09-30 21:31:19 +00:00
NUM_PROPS ,
} ;
2010-09-22 17:43:23 +00:00
2010-09-30 21:31:19 +00:00
CProperty aProps [ ] = {
2010-11-22 20:43:22 +00:00
{ " Delay " , pEditor - > m_SwitchDelay , PROPTYPE_INT_STEP , 0 , 255 } ,
2016-05-14 13:16:52 +00:00
{ " Number " , pEditor - > m_SwitchNum , PROPTYPE_INT_STEP , 0 , 255 } ,
2010-09-30 21:31:19 +00:00
{ 0 } ,
} ;
static int s_aIds [ NUM_PROPS ] = { 0 } ;
int NewVal = 0 ;
2014-05-17 15:19:48 +00:00
static vec4 s_color = vec4 ( 1 , 1 , 1 , 0.5f ) ;
int Prop = pEditor - > DoProperties ( & View , aProps , s_aIds , & NewVal , s_color ) ;
2010-09-30 21:31:19 +00:00
2010-11-22 20:43:22 +00:00
if ( Prop = = PROP_SwitchNumber )
2014-05-17 15:19:48 +00:00
{
2015-06-28 14:17:23 +00:00
NewVal = ( NewVal + 256 ) % 256 ;
2014-05-17 15:19:48 +00:00
CLayerSwitch * gl = pEditor - > m_Map . m_pSwitchLayer ;
for ( int y = 0 ; y < gl - > m_Height ; + + y )
{
for ( int x = 0 ; x < gl - > m_Width ; + + x )
{
if ( gl - > m_pSwitchTile [ y * gl - > m_Width + x ] . m_Number = = NewVal )
{
s_color = vec4 ( 1 , 0.5f , 0.5f , 0.5f ) ;
goto done ;
}
}
}
s_color = vec4 ( 0.5f , 1 , 0.5f , 0.5f ) ;
done :
pEditor - > m_SwitchNum = NewVal ;
}
2010-11-22 20:43:22 +00:00
if ( Prop = = PROP_SwitchDelay )
2015-06-28 14:17:23 +00:00
pEditor - > m_SwitchDelay = ( NewVal + 256 ) % 256 ;
2010-09-30 21:31:19 +00:00
return 0 ;
2011-02-13 05:35:13 +00:00
}
2014-03-12 23:01:15 +00:00
int CEditor : : PopupTune ( CEditor * pEditor , CUIRect View )
{
CUIRect Button ;
View . HSplitBottom ( 12.0f , & View , & Button ) ;
enum
{
PROP_TUNE = 0 ,
NUM_PROPS ,
} ;
CProperty aProps [ ] = {
{ " Zone " , pEditor - > m_TuningNum , PROPTYPE_INT_STEP , 1 , 255 } ,
{ 0 } ,
} ;
static int s_aIds [ NUM_PROPS ] = { 0 } ;
int NewVal = 0 ;
int Prop = pEditor - > DoProperties ( & View , aProps , s_aIds , & NewVal ) ;
if ( Prop = = PROP_TUNE )
2015-06-28 14:17:23 +00:00
pEditor - > m_TuningNum = ( NewVal - 1 + 255 ) % 255 + 1 ;
2014-03-12 23:01:15 +00:00
return 0 ;
}
2015-08-17 12:10:08 +00:00
int CEditor : : PopupColorPicker ( CEditor * pEditor , CUIRect View )
{
CUIRect SVPicker , HuePicker ;
View . VSplitRight ( 20.0f , & SVPicker , & HuePicker ) ;
HuePicker . VSplitLeft ( 4.0f , 0x0 , & HuePicker ) ;
pEditor - > Graphics ( ) - > TextureSet ( - 1 ) ;
pEditor - > Graphics ( ) - > QuadsBegin ( ) ;
// base: white - hue
vec3 hsv = pEditor - > ms_PickerColor ;
IGraphics : : CColorVertex ColorArray [ 4 ] ;
vec3 c = HsvToRgb ( vec3 ( hsv . x , 0.0f , 1.0f ) ) ;
ColorArray [ 0 ] = IGraphics : : CColorVertex ( 0 , c . r , c . g , c . b , 1.0f ) ;
c = HsvToRgb ( vec3 ( hsv . x , 1.0f , 1.0f ) ) ;
ColorArray [ 1 ] = IGraphics : : CColorVertex ( 1 , c . r , c . g , c . b , 1.0f ) ;
c = HsvToRgb ( vec3 ( hsv . x , 1.0f , 1.0f ) ) ;
ColorArray [ 2 ] = IGraphics : : CColorVertex ( 2 , c . r , c . g , c . b , 1.0f ) ;
c = HsvToRgb ( vec3 ( hsv . x , 0.0f , 1.0f ) ) ;
ColorArray [ 3 ] = IGraphics : : CColorVertex ( 3 , c . r , c . g , c . b , 1.0f ) ;
pEditor - > Graphics ( ) - > SetColorVertex ( ColorArray , 4 ) ;
IGraphics : : CQuadItem QuadItem ( SVPicker . x , SVPicker . y , SVPicker . w , SVPicker . h ) ;
pEditor - > Graphics ( ) - > QuadsDrawTL ( & QuadItem , 1 ) ;
// base: transparent - black
ColorArray [ 0 ] = IGraphics : : CColorVertex ( 0 , 0.0f , 0.0f , 0.0f , 0.0f ) ;
ColorArray [ 1 ] = IGraphics : : CColorVertex ( 1 , 0.0f , 0.0f , 0.0f , 0.0f ) ;
ColorArray [ 2 ] = IGraphics : : CColorVertex ( 2 , 0.0f , 0.0f , 0.0f , 1.0f ) ;
ColorArray [ 3 ] = IGraphics : : CColorVertex ( 3 , 0.0f , 0.0f , 0.0f , 1.0f ) ;
pEditor - > Graphics ( ) - > SetColorVertex ( ColorArray , 4 ) ;
pEditor - > Graphics ( ) - > QuadsDrawTL ( & QuadItem , 1 ) ;
pEditor - > Graphics ( ) - > QuadsEnd ( ) ;
// marker
vec2 Marker = vec2 ( hsv . y * pEditor - > UI ( ) - > Scale ( ) , ( 1.0f - hsv . z ) * pEditor - > UI ( ) - > Scale ( ) ) * vec2 ( SVPicker . w , SVPicker . h ) ;
pEditor - > Graphics ( ) - > QuadsBegin ( ) ;
pEditor - > Graphics ( ) - > SetColor ( 0.5f , 0.5f , 0.5f , 1.0f ) ;
IGraphics : : CQuadItem aMarker [ 2 ] ;
aMarker [ 0 ] = IGraphics : : CQuadItem ( SVPicker . x + Marker . x , SVPicker . y + Marker . y - 5.0f * pEditor - > UI ( ) - > PixelSize ( ) , pEditor - > UI ( ) - > PixelSize ( ) , 11.0f * pEditor - > UI ( ) - > PixelSize ( ) ) ;
aMarker [ 1 ] = IGraphics : : CQuadItem ( SVPicker . x + Marker . x - 5.0f * pEditor - > UI ( ) - > PixelSize ( ) , SVPicker . y + Marker . y , 11.0f * pEditor - > UI ( ) - > PixelSize ( ) , pEditor - > UI ( ) - > PixelSize ( ) ) ;
pEditor - > Graphics ( ) - > QuadsDrawTL ( aMarker , 2 ) ;
pEditor - > Graphics ( ) - > QuadsEnd ( ) ;
// logic
float X , Y ;
if ( pEditor - > UI ( ) - > DoPickerLogic ( & pEditor - > ms_SVPicker , & SVPicker , & X , & Y ) )
{
hsv . y = X / SVPicker . w ;
2017-02-21 16:10:08 +00:00
hsv . z = 1.0f - Y / SVPicker . h ;
2015-08-17 12:10:08 +00:00
}
// hue slider
static const float s_aColorIndices [ 7 ] [ 3 ] = {
{ 1.0f , 0.0f , 0.0f } , // red
{ 1.0f , 0.0f , 1.0f } , // magenta
{ 0.0f , 0.0f , 1.0f } , // blue
{ 0.0f , 1.0f , 1.0f } , // cyan
{ 0.0f , 1.0f , 0.0f } , // green
{ 1.0f , 1.0f , 0.0f } , // yellow
{ 1.0f , 0.0f , 0.0f } // red
} ;
pEditor - > Graphics ( ) - > QuadsBegin ( ) ;
vec4 ColorTop , ColorBottom ;
2015-08-17 18:19:27 +00:00
float Offset = HuePicker . h / 6.0f ;
for ( int j = 0 ; j < 6 ; j + + )
2015-08-17 12:10:08 +00:00
{
ColorTop = vec4 ( s_aColorIndices [ j ] [ 0 ] , s_aColorIndices [ j ] [ 1 ] , s_aColorIndices [ j ] [ 2 ] , 1.0f ) ;
ColorBottom = vec4 ( s_aColorIndices [ j + 1 ] [ 0 ] , s_aColorIndices [ j + 1 ] [ 1 ] , s_aColorIndices [ j + 1 ] [ 2 ] , 1.0f ) ;
ColorArray [ 0 ] = IGraphics : : CColorVertex ( 0 , ColorTop . r , ColorTop . g , ColorTop . b , ColorTop . a ) ;
ColorArray [ 1 ] = IGraphics : : CColorVertex ( 1 , ColorTop . r , ColorTop . g , ColorTop . b , ColorTop . a ) ;
ColorArray [ 2 ] = IGraphics : : CColorVertex ( 2 , ColorBottom . r , ColorBottom . g , ColorBottom . b , ColorBottom . a ) ;
ColorArray [ 3 ] = IGraphics : : CColorVertex ( 3 , ColorBottom . r , ColorBottom . g , ColorBottom . b , ColorBottom . a ) ;
pEditor - > Graphics ( ) - > SetColorVertex ( ColorArray , 4 ) ;
IGraphics : : CQuadItem QuadItem ( HuePicker . x , HuePicker . y + Offset * j , HuePicker . w , Offset ) ;
pEditor - > Graphics ( ) - > QuadsDrawTL ( & QuadItem , 1 ) ;
}
// marker
pEditor - > Graphics ( ) - > SetColor ( 0.5f , 0.5f , 0.5f , 1.0f ) ;
IGraphics : : CQuadItem QuadItemMarker ( HuePicker . x , HuePicker . y + ( 1.0f - hsv . x ) * HuePicker . h * pEditor - > UI ( ) - > Scale ( ) , HuePicker . w , pEditor - > UI ( ) - > PixelSize ( ) ) ;
pEditor - > Graphics ( ) - > QuadsDrawTL ( & QuadItemMarker , 1 ) ;
pEditor - > Graphics ( ) - > QuadsEnd ( ) ;
if ( pEditor - > UI ( ) - > DoPickerLogic ( & pEditor - > ms_HuePicker , & HuePicker , & X , & Y ) )
{
2017-02-21 16:10:08 +00:00
hsv . x = 1.0f - Y / HuePicker . h ;
2015-08-17 12:10:08 +00:00
}
pEditor - > ms_PickerColor = hsv ;
return 0 ;
2015-08-22 13:27:41 +00:00
}
2018-10-01 21:04:43 +00:00
int CEditor : : PopupEntities ( CEditor * pEditor , CUIRect View )
{
2018-10-02 21:08:17 +00:00
for ( int i = 0 ; i < ( int ) pEditor - > m_SelectEntitiesFiles . size ( ) ; i + + )
2018-10-01 21:04:43 +00:00
{
CUIRect Button ;
View . HSplitTop ( 14.0f , & Button , & View ) ;
2018-10-02 21:08:17 +00:00
const char * Name = pEditor - > m_SelectEntitiesFiles [ i ] . c_str ( ) ;
2018-10-02 21:39:22 +00:00
if ( pEditor - > DoButton_MenuItem ( Name , Name , pEditor - > m_SelectEntitiesFiles [ i ] = = pEditor - > m_SelectEntitiesImage , & Button ) ) {
if ( pEditor - > m_SelectEntitiesFiles [ i ] ! = pEditor - > m_SelectEntitiesImage ) {
pEditor - > m_SelectEntitiesImage = pEditor - > m_SelectEntitiesFiles [ i ] ;
2019-02-08 02:10:12 +00:00
pEditor - > m_AllowPlaceUnusedTiles = pEditor - > m_SelectEntitiesImage = = " DDNet " ? 0 : - 1 ;
pEditor - > m_PreventUnusedTilesWasWarned = false ;
2018-10-02 21:08:17 +00:00
char aBuf [ 512 ] ;
str_format ( aBuf , sizeof ( aBuf ) , " editor/entities/%s.png " , Name ) ;
2018-10-01 21:04:43 +00:00
pEditor - > Graphics ( ) - > UnloadTexture ( ms_EntitiesTexture ) ;
2018-10-02 21:08:17 +00:00
ms_EntitiesTexture = pEditor - > Graphics ( ) - > LoadTexture ( aBuf , IStorage : : TYPE_ALL , CImageInfo : : FORMAT_AUTO , 0 ) ;
2018-10-01 21:04:43 +00:00
}
}
}
return 0 ;
}