From f52be84ebbd82c18b84365d295258a9318439cb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sun, 1 Jun 2014 21:34:04 -0300 Subject: [PATCH] Fixed a null deferencing in cUIControl. Removed cIsoMap, since it's not part of the library. Fixed some minor bugs. --- bin/assets/maps/test.eem | Bin 75552 -> 58892 bytes include/eepp/gaming.hpp | 1 - include/eepp/gaming/cisomap.hpp | 120 ------- include/eepp/gaming/cmap.hpp | 4 + projects/linux/ee.creator.user | 4 +- projects/linux/ee.files | 2 - src/eepp/gaming/cisomap.cpp | 361 ---------------------- src/eepp/gaming/cmap.cpp | 3 +- src/eepp/gaming/mapeditor/cmapeditor.cpp | 2 +- src/eepp/gaming/mapeditor/cuimapnew.cpp | 12 +- src/eepp/ui/cuicontrol.cpp | 5 +- src/eepp/ui/tools/ctextureatlaseditor.cpp | 2 +- src/eepp/ui/tools/ctextureatlasnew.cpp | 2 +- src/test/eetest.cpp | 136 +------- src/test/eetest.hpp | 12 +- 15 files changed, 32 insertions(+), 634 deletions(-) delete mode 100755 include/eepp/gaming/cisomap.hpp delete mode 100755 src/eepp/gaming/cisomap.cpp diff --git a/bin/assets/maps/test.eem b/bin/assets/maps/test.eem index b0893caad68789d7826618cf7a060f8f21221d93..8652e9322291ea215306a6cac176f7f02052de94 100644 GIT binary patch delta 2987 zcmYk8&uZLO6vk)l6q+yt+WF5)i?Q4BP*7r1vIz8U0@)PqBV2G?*K}doStLu*ZnF@& zFEAufYL8)dqJzN-$b9{H?x zzP-wPv6cIDyX09$n$q`^)c1#k+)sVB$bG&u_t_}(*+)|?obPt6FJ`!WCG+BaIa&Al z#3B>r!M#e0%pSBQf$U=M-A9*!5g`{ ztBhQkw+BE6lHI1xsk&~5-h9fvyRras-r$g5&UxX6AzQI)DkLI8iYuD2MV*%>1nKC) z{OGAKzx$1ZCFW5JZW;*`*!(~sVnb^hYXqKV+jDr?u;fXGzJZB;M{FcPT*aOZ2|FC* z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^3_3Umd!0$qWwKv$qE z&=u$kbOpKsU4gDZSD-7<73d0d1-b%Vfv!MTpexW7=n8ZNx&mE+EhzA>KY#Q6;oqGa zUO(Tx-rK#tb^Ye;!?(Zp<0nsd;E113;vc_teMI~hb}<8=H?DtpO!)JPuf6)p%g@0P zAEL*H?>jYqe>eJ9MI$DqqQyU!0ETwVQP_x_dL`|$kH?(>&+WPiGQ|KILsi2Tj&^`G7A J-@8|y{T~n}x<>#2 diff --git a/include/eepp/gaming.hpp b/include/eepp/gaming.hpp index 9adddc525..8a3cb44ea 100644 --- a/include/eepp/gaming.hpp +++ b/include/eepp/gaming.hpp @@ -2,7 +2,6 @@ #define EEPP_GAMING_HPP #include -#include #include #include #include diff --git a/include/eepp/gaming/cisomap.hpp b/include/eepp/gaming/cisomap.hpp deleted file mode 100755 index 4eef9c33b..000000000 --- a/include/eepp/gaming/cisomap.hpp +++ /dev/null @@ -1,120 +0,0 @@ -#ifndef EE_GAMINGCISOMAP_H -#define EE_GAMINGCISOMAP_H - -#include - -#include -#include -#include -using namespace EE::Window; - -#include -#include -#include -#include -#include -using namespace EE::Graphics; - -#include - -namespace EE { namespace Gaming { - -class EE_API cIsoTile { - public: - eeColor Color[4]; //! Color of every vertex stored - eeQuad2f Q; //! Vertex Buffer Data - std::vector Layers; - std::string TilePosStr; - eeAABB Box; -}; - -class EE_API cIsoMap { - public: - cIsoMap( Window::cWindow * window = NULL ); - - ~cIsoMap(); - - void Create( const eeUint& MapTilesX, const eeUint& MapTilesY, const eeUint& NumLayers = 1, const eeUint TilesWidth = 64, const eeUint TilesHeight = 32, const eeColor& AmbientCol = eeColor(255,255,255) ); - - cIsoTile& Tile( const eeUint& MapTileX, const eeUint& MapTileY ); - - void Layer( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& LayerNum, cSubTexture * LayerData ); - - void Draw(); - - void Move( const eeFloat& offsetx, const eeFloat& offsety ); - - void SetJointHeight( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& JointNum, const eeUint& Level = 1, const bool& JointUp = true ); - - void SetTileHeight( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& Level = 1, const bool& JointUp = true ); - - eeVector2f TileBaseCoords( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& JointNum); - - eeQuad2f TileQBaseCoords( const eeUint& MapTileX, const eeUint& MapTileY ); - - Uint32 Width() const; - - Uint32 Height() const; - - void AmbientColor( const eeColor& AC ); - - eeColor AmbientColor() const; - - eeVector2i GetMouseTilePos() const; - - eeVector2f GetMouseMapCoords() const; - - eeAABB GetScreenMapCoords() const; - - void Reset(); - - void Font( cFont * font ); - - cFont * Font() const; - - cLight& BaseLight(); - - void DrawFont( bool draw ); - - bool DrawFont() const; - protected: - std::vector Map; - - Window::cWindow * mWindow; - eeColor mMapAmbientColor; - eeUint mMapWidth; - eeUint mMapHeight; - eeUint mMapLayers; - eeUint mTileWidth; - eeUint mTileHeight; - eeUint mTilesRange; - eeFloat mTileHWidth; - eeFloat mTileHHeight; - eeFloat mTileAltitude; - eeVector2i mMouseTilePos; - eeVector2f mMouseMapPos; - eeAABB mScreenAABB; - eeInt Tx; - eeInt Ty; - eeInt Tx2; - eeInt Ty2; - eeFloat mOffsetX; - eeFloat mOffsetY; - - // Fast access to classes - cPrimitives mPR; - - cFont * mFont; - - cLight mLight; - - bool mDrawFont; - - void CreateBaseVertexBuffer(); - - void VertexChangeHeight( const eeInt& MapTileX, const eeInt& MapTileY, const eeUint& JointNum, const eeFloat& Height, const eeFloat& NewJointHeight, const bool& JointUp ); -}; - -}} - -#endif diff --git a/include/eepp/gaming/cmap.hpp b/include/eepp/gaming/cmap.hpp index af3aaf408..e2f2db7c8 100644 --- a/include/eepp/gaming/cmap.hpp +++ b/include/eepp/gaming/cmap.hpp @@ -19,6 +19,8 @@ using namespace EE::Graphics; namespace EE { namespace Gaming { +namespace MapEditor { class cUIMapNew; } + #define EE_MAP_LAYER_UNKNOWN eeINDEX_NOT_FOUND #define EE_MAP_MAGIC ( ( 'E' << 0 ) | ( 'E' << 8 ) | ( 'M' << 16 ) | ( 'P' << 24 ) ) @@ -223,6 +225,8 @@ class EE_API cMap { const eeColorA& GridLinesColor() const; protected: + friend class EE::Gaming::MapEditor::cUIMapNew; + class cForcedHeaders { public: diff --git a/projects/linux/ee.creator.user b/projects/linux/ee.creator.user index 86d908796..6fc399a15 100644 --- a/projects/linux/ee.creator.user +++ b/projects/linux/ee.creator.user @@ -1,6 +1,6 @@ - + ProjectExplorer.Project.ActiveTarget @@ -56,7 +56,7 @@ {388e5431-b31b-42b3-b9ad-9002d279d75d} 0 0 - 11 + 0 ../../make/linux diff --git a/projects/linux/ee.files b/projects/linux/ee.files index d3d83ffef..a421b5bbf 100644 --- a/projects/linux/ee.files +++ b/projects/linux/ee.files @@ -81,7 +81,6 @@ ../../include/eepp/gaming/clightmanager.hpp ../../include/eepp/gaming/clight.hpp ../../include/eepp/gaming/clayer.hpp -../../include/eepp/gaming/cisomap.hpp ../../include/eepp/gaming/cgameobjectvirtual.hpp ../../include/eepp/gaming/cgameobjectsprite.hpp ../../include/eepp/gaming/cgameobjectsubtextureex.hpp @@ -101,7 +100,6 @@ ../../src/eepp/gaming/clightmanager.cpp ../../src/eepp/gaming/clight.cpp ../../src/eepp/gaming/clayer.cpp -../../src/eepp/gaming/cisomap.cpp ../../src/eepp/gaming/cgameobjectvirtual.cpp ../../src/eepp/gaming/cgameobjectsprite.cpp ../../src/eepp/gaming/cgameobjectsubtextureex.cpp diff --git a/src/eepp/gaming/cisomap.cpp b/src/eepp/gaming/cisomap.cpp deleted file mode 100755 index 5f4ca570d..000000000 --- a/src/eepp/gaming/cisomap.cpp +++ /dev/null @@ -1,361 +0,0 @@ -#include -#include -#include - -namespace EE { namespace Gaming { - -cIsoMap::cIsoMap( Window::cWindow * window ) : - mWindow( window ), - mOffsetX(0), - mOffsetY(0), - mFont(NULL) -{ - if ( NULL == mWindow ) { - mWindow = cEngine::instance()->GetCurrentWindow(); - } -} - -cIsoMap::~cIsoMap() { -} - -void cIsoMap::Create( const eeUint& MapTilesX, const eeUint& MapTilesY, const eeUint& NumLayers, const eeUint TilesWidth, const eeUint TilesHeight, const eeColor& AmbientCol ) { - if ( NULL == mWindow ) { - mWindow = cEngine::instance()->GetCurrentWindow(); - } - - mMapWidth = MapTilesX; - mMapHeight = MapTilesY; - mMapLayers = NumLayers; - - mTileWidth = TilesWidth; - mTileHeight = TilesHeight; - - mTileHWidth = mTileWidth * 0.5f; - mTileHHeight = mTileHeight * 0.5f; - mTileAltitude = mTileHeight * 0.25f; - - mMapAmbientColor = AmbientCol; - - Map.resize( mMapWidth * mMapHeight ); - - CreateBaseVertexBuffer(); - - mTilesRange = 10; - - mLight.Create( 250.0f, 0, 0, eeColor(255,255,255), LIGHT_ISOMETRIC ); - - mDrawFont = false; -} - -void cIsoMap::CreateBaseVertexBuffer() { - eeUint i; - - for ( eeUint x = 0; x < mMapWidth; x++ ) { - for ( eeUint y = 0; y < mMapHeight; y++ ) { - cIsoTile * T = &Tile(x, y); - - if ( T->Layers.size() < 1 ) - T->Layers.resize( mMapLayers ); - - T->Q = TileQBaseCoords( x, y ); - T->Box = T->Q.ToAABB(); - T->TilePosStr = String::ToStr( x) + " - " + String::ToStr( y ); - - for ( i = 0; i < 4; i++ ) - T->Color[i] = mMapAmbientColor; - - for ( i = 1; i < mMapLayers; i++ ) - Layer( x, y, i, NULL ); - } - } -} - -cIsoTile& cIsoMap::Tile( const eeUint& MapTileX, const eeUint& MapTileY ) { - eeASSERT ( MapTileX < mMapWidth && MapTileY < mMapHeight ); - return Map[ MapTileX + MapTileY * mMapWidth ]; -} - -void cIsoMap::Layer( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& LayerNum, cSubTexture * LayerData ) { - if( LayerNum < mMapLayers ) - Tile(MapTileX, MapTileY).Layers[LayerNum] = LayerData; -} - -void cIsoMap::Draw() { - eeAABB TileAABB; - cIsoTile * T; - - mScreenAABB = eeAABB( -mOffsetX, -mOffsetY, mWindow->GetWidth() - mOffsetX, mWindow->GetHeight() - mOffsetY ); // Screen AABB to MAP AABB - - mMouseMapPos = eeVector2f( mWindow->GetInput()->MouseX() - mOffsetX, mWindow->GetInput()->MouseY() - mOffsetY ); - - mLight.UpdatePos( mMouseMapPos ); - - if (mOffsetX > 0) - mOffsetX = 0; - - if (mOffsetY > 0) - mOffsetY = 0; - - if ( -mOffsetX > Tile( mMapWidth-1, mMapHeight-1 ).Q.V[1].x - mWindow->GetWidth() ) - mOffsetX = -(Tile( mMapWidth-1, mMapHeight-1 ).Q.V[1].x - mWindow->GetWidth()); - - if ( -mOffsetY > Tile( mMapWidth-1, mMapHeight-1 ).Q.V[1].y - mWindow->GetHeight() ) - mOffsetY = -(Tile( mMapWidth-1, mMapHeight-1 ).Q.V[1].y - mWindow->GetHeight()); - - Tx = (Int32)( -mOffsetX / (eeFloat)mTileHeight ) - mTilesRange; - Ty = (Int32)( -mOffsetY / (eeFloat)mTileHeight ) - mTilesRange; - - if (Tx < 0) Tx = 0; - if (Tx >= (eeInt)mMapWidth) Tx = mMapWidth-1; - - if (Ty < 0) Ty = 0; - if (Ty >= (eeInt)mMapHeight) Ty = mMapHeight-1; - - Tx2 = ( Tx + mTilesRange + (eeInt)( mWindow->GetWidth() / (eeFloat)mTileHeight ) + mTilesRange ); - Ty2 = ( Ty + mTilesRange + (eeInt)( mWindow->GetHeight() / (eeFloat)mTileHeight) + mTilesRange ); - - eeColorA SC(50,50,50,100); - - cGlobalBatchRenderer::instance()->Draw(); - - GLi->LoadIdentity(); - GLi->PushMatrix(); - GLi->Translatef( mOffsetX, mOffsetY, 0.0f ); - - for ( eeUint L = 0; L < mMapLayers; L++ ) { - for ( eeInt y = Ty; y < Ty2; y++ ) { - for ( eeInt x = Tx; x < Tx2; x++ ) { - T = &Tile( (eeUint)x, (eeUint)y ); - - if ( L == 0 ) { - TileAABB = T->Box; - - if ( mScreenAABB.Intersect( TileAABB ) ) { - T->Color[0] = T->Color[1] = T->Color[2] = T->Color[3] = mMapAmbientColor; - - if ( mLight.GetAABB().Intersect( TileAABB ) ) { - T->Color[0] = mLight.ProcessVertex( T->Q.V[0].x, T->Q.V[0].y, T->Color[0], T->Color[0] ); // Left - Top Vertex - T->Color[1] = mLight.ProcessVertex( T->Q.V[1].x, T->Q.V[1].y, T->Color[1], T->Color[1] ); // Left - Bottom Vertex - T->Color[2] = mLight.ProcessVertex( T->Q.V[2].x, T->Q.V[2].y, T->Color[2], T->Color[2] ); // Right - Bottom Vertex - T->Color[3] = mLight.ProcessVertex( T->Q.V[3].x, T->Q.V[3].y, T->Color[3], T->Color[3] ); // Right - Top Vertex - } - - T->Layers[L]->Draw( T->Q, eeVector2f(), 0.f, eeVector2f::One, T->Color[0], T->Color[1], T->Color[2], T->Color[3] ); - - if ( TileAABB.Contains( mMouseMapPos ) ) { - if ( eePolygon2f::IntersectQuad2( T->Q, eeQuad2f( mMouseMapPos, mMouseMapPos, mMouseMapPos, mMouseMapPos ) ) ) { - mMouseTilePos.x = x; - mMouseTilePos.y = y; - } - } - } - } else { - if ( T->Layers[L] != NULL ) { - cSubTexture * SubTexture = T->Layers[L]; - - if ( T != NULL ) { - eeVector2f TileCenter( T->Q.V[1].x + (T->Q.V[3].x - T->Q.V[1].x) * 0.5f, T->Q.V[0].y + (T->Q.V[2].y - T->Q.V[0].y) * 0.5f ); - eeVector2f ObjPos( TileCenter.x - SubTexture->DestSize().x * 0.5f, TileCenter.y - SubTexture->DestSize().y * 0.80f ); - - eeAABB LayerAABB( TileCenter.x - SubTexture->DestSize().x * 0.5f, TileCenter.y - SubTexture->DestSize().y, TileCenter.x + SubTexture->DestSize().x * 0.5f, TileCenter.y ); - eeAABB ShadowAABB( ObjPos.x, TileCenter.y - SubTexture->DestSize().y, TileCenter.x + SubTexture->DestSize().x, TileCenter.y ); - - if ( mScreenAABB.Intersect( ShadowAABB ) ) { - SubTexture->Draw( mOffsetX + ObjPos.x, mOffsetY + ObjPos.y, 0, eeVector2f::One, SC, SC, SC, SC, ALPHA_NORMAL, RN_ISOMETRIC ); - } - - if ( mScreenAABB.Intersect( LayerAABB ) ) { - SubTexture->Draw( mOffsetX + TileCenter.x - (eeFloat)SubTexture->DestSize().x * 0.5f, mOffsetY + TileCenter.y - (eeFloat)SubTexture->DestSize().y, 0, eeVector2f::One, eeColorA(T->Color[0]), eeColorA(T->Color[1]), eeColorA(T->Color[2]), eeColorA(T->Color[3]) ); - } - } - } - } - } - } - - cGlobalBatchRenderer::instance()->Draw(); - - if ( L == 0 ) { - GLi->PopMatrix(); - } - } - - if ( mDrawFont ) { - for ( eeInt y = Ty; y < Ty2; y++ ) { - for ( eeInt x = Tx; x < Tx2; x++ ) { - T = &Tile( (eeUint)x, (eeUint)y ); - mFont->Draw( T->TilePosStr, mOffsetX + T->Q.V[1].x + ( T->Q.V[3].x - T->Q.V[1].x ) * 0.5f - T->TilePosStr.size() * mFont->GetFontHeight() * 0.5f, mOffsetY + T->Q.V[0].y + ( T->Q.V[2].y - T->Q.V[0].y ) * 0.5f - mFont->GetFontHeight() * 0.5f ); - } - } - } - - mPR.FillMode( DRAW_LINE ); - mPR.DrawQuad( Tile( mMouseTilePos.x, mMouseTilePos.y ).Q, mOffsetX, mOffsetY ); -} - -void cIsoMap::Move( const eeFloat& offsetx, const eeFloat& offsety ) { - mOffsetX += offsetx; - mOffsetY += offsety; -} - -void cIsoMap::SetTileHeight( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& Level, const bool& JointUp ) { - SetJointHeight( MapTileX, MapTileY, 0, Level, JointUp ); - SetJointHeight( MapTileX, MapTileY, 1, Level, JointUp ); - SetJointHeight( MapTileX, MapTileY, 2, Level, JointUp ); - SetJointHeight( MapTileX, MapTileY, 3, Level, JointUp ); -} - -void cIsoMap::SetJointHeight( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& JointNum, const eeUint& Level, const bool& JointUp ) { - eeFloat AltitudeModif = ( JointUp ) ? -1.f : 1.f; - eeFloat VertexHeight = (mTileAltitude * AltitudeModif) * (eeFloat)Level; - eeFloat NJHeight; - - if ( MapTileX >= mMapWidth || MapTileY >= mMapHeight ) - return; - - cIsoTile * T = &Tile( MapTileX, MapTileY ); - - T->Q.V[JointNum].y += VertexHeight; - - NJHeight = T->Q.V[JointNum].y; - - switch (JointNum) { - case 0: - if ( (MapTileX % 2) == 0) { - VertexChangeHeight( MapTileX - 1, MapTileY - 1, 3, VertexHeight, NJHeight, JointUp ); - VertexChangeHeight( MapTileX , MapTileY - 1, 2, VertexHeight, NJHeight, JointUp ); - VertexChangeHeight( MapTileX + 1, MapTileY - 1, 1, VertexHeight, NJHeight, JointUp ); - } else { - VertexChangeHeight( MapTileX + 1, MapTileY , 1, VertexHeight, NJHeight, JointUp ); - VertexChangeHeight( MapTileX , MapTileY - 1, 2, VertexHeight, NJHeight, JointUp ); - VertexChangeHeight( MapTileX - 1, MapTileY , 3, VertexHeight, NJHeight, JointUp ); - } - break; - case 1: - if ( (MapTileX % 2) == 0) { - VertexChangeHeight( MapTileX - 1, MapTileY - 1, 2, VertexHeight, NJHeight, JointUp ); - VertexChangeHeight( MapTileX - 2, MapTileY , 3, VertexHeight, NJHeight, JointUp ); - VertexChangeHeight( MapTileX - 1, MapTileY , 0, VertexHeight, NJHeight, JointUp ); - } else { - VertexChangeHeight( MapTileX - 1, MapTileY + 1, 0, VertexHeight, NJHeight, JointUp ); - VertexChangeHeight( MapTileX - 1, MapTileY , 2, VertexHeight, NJHeight, JointUp ); - VertexChangeHeight( MapTileX - 2, MapTileY , 3, VertexHeight, NJHeight, JointUp ); - } - break; - case 2: - if ( (MapTileX % 2) == 0) { - VertexChangeHeight( MapTileX + 1, MapTileY , 1, VertexHeight, NJHeight, JointUp ); - VertexChangeHeight( MapTileX - 1, MapTileY , 3, VertexHeight, NJHeight, JointUp ); - VertexChangeHeight( MapTileX , MapTileY + 1, 0, VertexHeight, NJHeight, JointUp ); - } else { - VertexChangeHeight( MapTileX , MapTileY + 1, 0, VertexHeight, NJHeight, JointUp ); - VertexChangeHeight( MapTileX + 1, MapTileY + 1, 1, VertexHeight, NJHeight, JointUp ); - VertexChangeHeight( MapTileX - 1, MapTileY + 1, 3, VertexHeight, NJHeight, JointUp ); - } - break; - case 3: - if ( (MapTileX % 2) == 0) { - VertexChangeHeight( MapTileX + 1, MapTileY - 1, 2, VertexHeight, NJHeight, JointUp ); - VertexChangeHeight( MapTileX + 1, MapTileY , 0, VertexHeight, NJHeight, JointUp ); - VertexChangeHeight( MapTileX + 2, MapTileY , 1, VertexHeight, NJHeight, JointUp ); - } else { - VertexChangeHeight( MapTileX + 1, MapTileY + 1, 0, VertexHeight, NJHeight, JointUp ); - VertexChangeHeight( MapTileX + 2, MapTileY , 1, VertexHeight, NJHeight, JointUp ); - VertexChangeHeight( MapTileX + 1, MapTileY , 2, VertexHeight, NJHeight, JointUp ); - } - break; - } -} - -void cIsoMap::VertexChangeHeight( const eeInt& MapTileX, const eeInt& MapTileY, const eeUint& JointNum, const eeFloat& Height, const eeFloat& NewJointHeight, const bool& JointUp ) { - if ( ( MapTileX >= 0 && MapTileX < (eeInt)mMapWidth ) && ( MapTileY >= 0 && MapTileY < (eeInt)mMapHeight ) ) { - cIsoTile * T = &Tile( MapTileX, MapTileY ); - - if ( ( JointUp && T->Q.V[JointNum].y >= NewJointHeight ) || ( !JointUp && T->Q.V[JointNum].y <= NewJointHeight ) ) { - T->Q.V[JointNum].y += Height; - T->Box = T->Q.ToAABB(); - } - } -} - -eeVector2f cIsoMap::TileBaseCoords( const eeUint& MapTileX, const eeUint& MapTileY, const eeUint& JointNum) { - eeFloat dX, dY, pX, pY; - - if ( (MapTileX % 2) == 0) { - dX = -mTileHWidth; - dY = -mTileHHeight; - } else { - dX = -mTileHWidth; - dY = 0; - } - - pX = MapTileX * mTileHWidth + dX; - pY = MapTileY * mTileHWidth + dY; - - switch( JointNum ) { - case 0: return eeVector2f( pX + mTileHWidth, pY ); // Left Top Vertex - case 1: return eeVector2f( pX, pY + mTileHHeight ); // Left Bottom Vertex - case 2: return eeVector2f( pX + mTileHWidth, pY + mTileHeight ); // Top Left Vertex - case 3: return eeVector2f( pX + mTileWidth, pY + mTileHHeight ); // Top Bottom Vertex - } - - return eeVector2f(0,0); -} - -eeQuad2f cIsoMap::TileQBaseCoords( const eeUint& MapTileX, const eeUint& MapTileY ) { - return eeQuad2f( TileBaseCoords( MapTileX, MapTileY, 0 ), TileBaseCoords( MapTileX, MapTileY, 1 ), TileBaseCoords( MapTileX, MapTileY, 2 ), TileBaseCoords( MapTileX, MapTileY, 3 ) ); -} - -void cIsoMap::Reset() { - CreateBaseVertexBuffer(); -} - -void cIsoMap::Font( cFont * font ) { - mFont = font; -} - -cFont * cIsoMap::Font() const { - return mFont; -} - -cLight& cIsoMap::BaseLight() { - return mLight; -} - -void cIsoMap::DrawFont( bool draw ) { - mDrawFont = draw; -} - -bool cIsoMap::DrawFont() const { - return mDrawFont; -} - -Uint32 cIsoMap::Width() const { - return mMapWidth; -} - -Uint32 cIsoMap::Height() const { - return mMapHeight; -} - -void cIsoMap::AmbientColor( const eeColor& AC ) { - mMapAmbientColor = AC; -} - -eeColor cIsoMap::AmbientColor() const { - return mMapAmbientColor; -} - -eeVector2i cIsoMap::GetMouseTilePos() const { - return mMouseTilePos; -} - -eeVector2f cIsoMap::GetMouseMapCoords() const { - return mMouseMapPos; -} - -eeAABB cIsoMap::GetScreenMapCoords() const { - return mScreenAABB; -} - -}} diff --git a/src/eepp/gaming/cmap.cpp b/src/eepp/gaming/cmap.cpp index 708cbaf7a..6b738993f 100644 --- a/src/eepp/gaming/cmap.cpp +++ b/src/eepp/gaming/cmap.cpp @@ -118,7 +118,8 @@ void cMap::CreateLightManager() { void cMap::CreateEmptyTile() { //! I create a texture representing an empty tile to render instead of rendering with primitives because is a lot faster, at least with NVIDIA GPUs. cTextureFactory * TF = cTextureFactory::instance(); - std::string tileName( "maptile-" + String::ToStr( mTileSize.Width() ) + "x" + String::ToStr( mTileSize.Height() ) ); + + std::string tileName( String::StrFormated( "maptile-%dx%d-%ul", mTileSize.Width(), mTileSize.Height(), mGridLinesColor.GetValue() ) ); cTexture * Tex = TF->GetByName( tileName ); diff --git a/src/eepp/gaming/mapeditor/cmapeditor.cpp b/src/eepp/gaming/mapeditor/cmapeditor.cpp index 49d13f3f2..79a03cf08 100644 --- a/src/eepp/gaming/mapeditor/cmapeditor.cpp +++ b/src/eepp/gaming/mapeditor/cmapeditor.cpp @@ -378,7 +378,7 @@ void cMapEditor::CreateLightContainer() { Txt = mTheme->CreateTextBox( "Light Radius:", mLightCont, eeSize(), eeVector2i( TAB_CONT_X_DIST, mUIBlueTxt->Pos().y + mUIBlueTxt->Size().Height() + 16 ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW | UI_AUTO_SIZE ); - mLightRadius = mTheme->CreateSpinBox( mLightCont, eeSize( 100, 22 ), eeVector2i( Txt->Pos().x, Txt->Pos().y + Txt->Size().Height() + 8 ), UI_CONTROL_DEFAULT_FLAGS | UI_CLIP_ENABLE | UI_AUTO_SIZE, 100, false ); + mLightRadius = mTheme->CreateSpinBox( mLightCont, eeSize( 100, 22 ), eeVector2i( Txt->Pos().x, Txt->Pos().y + Txt->Size().Height() + 8 ), UI_CONTROL_DEFAULT_FLAGS | UI_CLIP_ENABLE | UI_AUTO_SIZE | UI_TEXT_SELECTION_ENABLED, 100, false ); mLightRadius->MaxValue( 2000 ); mLightRadius->AddEventListener( cUIEvent::EventOnValueChange, cb::Make1( this, &cMapEditor::OnLightRadiusChangeVal ) ); diff --git a/src/eepp/gaming/mapeditor/cuimapnew.cpp b/src/eepp/gaming/mapeditor/cuimapnew.cpp index 749c639b5..26755c3a5 100644 --- a/src/eepp/gaming/mapeditor/cuimapnew.cpp +++ b/src/eepp/gaming/mapeditor/cuimapnew.cpp @@ -33,7 +33,7 @@ cUIMapNew::cUIMapNew( cUIMap * Map, cb::Callback0 NewMapCb, bool ResizeMap Txt = mTheme->CreateTextBox( "Width:", mUIWindow->Container(), eeSize( 46, 24 ), eeVector2i( Txt->Pos().x + DistFromTitle, Txt->Pos().y + DistFromTitle ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW ); - mUIMapWidth = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 53, 24 ), eeVector2i( Txt->Pos().x + Txt->Size().Width(), Txt->Pos().y ), UI_CONTROL_DEFAULT_FLAGS, 100, false ); + mUIMapWidth = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 53, 24 ), eeVector2i( Txt->Pos().x + Txt->Size().Width(), Txt->Pos().y ), UI_CONTROL_DEFAULT_FLAGS | UI_TEXT_SELECTION_ENABLED, 100, false ); mUIMapWidth->MinValue(1); if ( ResizeMap ) { @@ -42,7 +42,7 @@ cUIMapNew::cUIMapNew( cUIMap * Map, cb::Callback0 NewMapCb, bool ResizeMap Txt = mTheme->CreateTextBox( "Height:", mUIWindow->Container(), eeSize( 46, 24 ), eeVector2i( Txt->Pos().x, Txt->Pos().y + Txt->Size().Height() + 8 ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW ); - mUIMapHeight = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 53, 24 ), eeVector2i( Txt->Pos().x + Txt->Size().Width(), Txt->Pos().y ), UI_CONTROL_DEFAULT_FLAGS, 100, false ); + mUIMapHeight = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 53, 24 ), eeVector2i( Txt->Pos().x + Txt->Size().Width(), Txt->Pos().y ), UI_CONTROL_DEFAULT_FLAGS | UI_TEXT_SELECTION_ENABLED, 100, false ); mUIMapHeight->MinValue(1); if ( ResizeMap ) { @@ -53,7 +53,7 @@ cUIMapNew::cUIMapNew( cUIMap * Map, cb::Callback0 NewMapCb, bool ResizeMap Txt = mTheme->CreateTextBox( "Width:", mUIWindow->Container(), eeSize( 46, 24 ), eeVector2i( Txt->Pos().x + DistFromTitle, Txt->Pos().y + DistFromTitle ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW ); - mUIMapTWidth = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 53, 24 ), eeVector2i( Txt->Pos().x + Txt->Size().Width(), Txt->Pos().y ), UI_CONTROL_DEFAULT_FLAGS, 32, false ); + mUIMapTWidth = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 53, 24 ), eeVector2i( Txt->Pos().x + Txt->Size().Width(), Txt->Pos().y ), UI_CONTROL_DEFAULT_FLAGS | UI_TEXT_SELECTION_ENABLED, 32, false ); mUIMapTWidth->MinValue(1); if ( ResizeMap ) { @@ -62,7 +62,7 @@ cUIMapNew::cUIMapNew( cUIMap * Map, cb::Callback0 NewMapCb, bool ResizeMap Txt = mTheme->CreateTextBox( "Height:", mUIWindow->Container(), eeSize( 46, 24 ), eeVector2i( Txt->Pos().x, Txt->Pos().y + Txt->Size().Height() + 8 ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW ); - mUIMapTHeight = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 53, 24 ), eeVector2i( Txt->Pos().x + Txt->Size().Width(), Txt->Pos().y ), UI_CONTROL_DEFAULT_FLAGS, 32, false ); + mUIMapTHeight = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 53, 24 ), eeVector2i( Txt->Pos().x + Txt->Size().Width(), Txt->Pos().y ), UI_CONTROL_DEFAULT_FLAGS | UI_TEXT_SELECTION_ENABLED, 32, false ); mUIMapTHeight->MinValue(1); if ( ResizeMap ) { @@ -71,7 +71,7 @@ cUIMapNew::cUIMapNew( cUIMap * Map, cb::Callback0 NewMapCb, bool ResizeMap Txt = mTheme->CreateTextBox( "Max Layers", mUIWindow->Container(), eeSize(), eeVector2i( 16, mUIMapTHeight->Pos().y + mUIMapTHeight->Size().Height() + 8 ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW | UI_AUTO_SIZE ); - mUIMapMaxLayers = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 53, 24 ), eeVector2i( Txt->Pos().x + DistFromTitle, Txt->Pos().y + DistFromTitle ), UI_CONTROL_DEFAULT_FLAGS, 8, false ); + mUIMapMaxLayers = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 53, 24 ), eeVector2i( Txt->Pos().x + DistFromTitle, Txt->Pos().y + DistFromTitle ), UI_CONTROL_DEFAULT_FLAGS | UI_TEXT_SELECTION_ENABLED, 8, false ); mUIMapMaxLayers->MaxValue( 32 ); Txt = mTheme->CreateTextBox( "Map Flags:", mUIWindow->Container(), eeSize(), eeVector2i( Txt->Pos().x, mUIMapMaxLayers->Pos().y + mUIMapMaxLayers->Size().Height() + 8 ), UI_CONTROL_DEFAULT_FLAGS | UI_DRAW_SHADOW | UI_AUTO_SIZE ); @@ -229,6 +229,7 @@ void cUIMapNew::OKClick( const cUIEvent * Event ) { mUIMap->Map()->Create( eeSize( w, h ), ml, eeSize( tw, th ), Flags, mUIMap->Map()->ViewSize() ); mUIMap->Map()->BaseColor( mUIBaseColor->Background()->Color() ); } else { + std::string oldPath( mUIMap->Map()->Path() ); std::string mapPath( Sys::GetTempPath() + "temp.eepp.map.eem" ); mUIMap->Map()->Save( mapPath ); @@ -238,6 +239,7 @@ void cUIMapNew::OKClick( const cUIEvent * Event ) { Map->ForceHeadersOnLoad( eeSize( w, h ), eeSize( tw, th ), ml, Flags ); Map->Load( mapPath ); Map->DisableForcedHeaders(); + Map->mPath = oldPath; mUIMap->ReplaceMap( Map ); diff --git a/src/eepp/ui/cuicontrol.cpp b/src/eepp/ui/cuicontrol.cpp index 474c72148..161ac990a 100644 --- a/src/eepp/ui/cuicontrol.cpp +++ b/src/eepp/ui/cuicontrol.cpp @@ -658,7 +658,10 @@ void cUIControl::ChildAddAt( cUIControl * ChildCtrl, Uint32 Pos ) { ChildCtrl->mPrev = NULL; } else { if( Pos == 0 ) { - mChild->mPrev = ChildCtrl; + if ( NULL != mChild ) { + mChild->mPrev = ChildCtrl; + } + ChildCtrl->mNext = mChild; ChildCtrl->mPrev = NULL; mChild = ChildCtrl; diff --git a/src/eepp/ui/tools/ctextureatlaseditor.cpp b/src/eepp/ui/tools/ctextureatlaseditor.cpp index ede4559a4..f227a47b2 100644 --- a/src/eepp/ui/tools/ctextureatlaseditor.cpp +++ b/src/eepp/ui/tools/ctextureatlaseditor.cpp @@ -36,7 +36,7 @@ cTextureAtlasEditor::cTextureAtlasEditor( cUIWindow * AttatchTo, const TGEditorC } cUITextBox * TxtBox; - Uint32 Flags = UI_CONTROL_DEFAULT_ALIGN | UI_ANCHOR_TOP | UI_ANCHOR_RIGHT | UI_CLIP_ENABLE | UI_AUTO_SIZE; + Uint32 Flags = UI_CONTROL_DEFAULT_ALIGN | UI_ANCHOR_TOP | UI_ANCHOR_RIGHT | UI_CLIP_ENABLE | UI_AUTO_SIZE | UI_TEXT_SELECTION_ENABLED; Uint32 InitY = 230; CreateTxtBox( eeVector2i( mUIContainer->Size().Width() - 205, 30 ), "SubTexture List:" ); diff --git a/src/eepp/ui/tools/ctextureatlasnew.cpp b/src/eepp/ui/tools/ctextureatlasnew.cpp index a956e1a9f..6e92e5f2f 100644 --- a/src/eepp/ui/tools/ctextureatlasnew.cpp +++ b/src/eepp/ui/tools/ctextureatlasnew.cpp @@ -54,7 +54,7 @@ cTextureAtlasNew::cTextureAtlasNew( TGCreateCb NewTGCb ) : mComboHeight->ListBox()->SetSelected( "512" ); CreateTxtBox( eeVector2i( 10, 110 ), "Space between sub textures (pixels):" ); - mPixelSpace = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 100, 22 ), eeVector2i( PosX, 110 ), UI_CONTROL_DEFAULT_FLAGS | UI_CLIP_ENABLE | UI_AUTO_SIZE, 0, false ); + mPixelSpace = mTheme->CreateSpinBox( mUIWindow->Container(), eeSize( 100, 22 ), eeVector2i( PosX, 110 ), UI_CONTROL_DEFAULT_FLAGS | UI_CLIP_ENABLE | UI_AUTO_SIZE | UI_TEXT_SELECTION_ENABLED, 0, false ); CreateTxtBox( eeVector2i( 10, 140 ), "Texture Atlas Folder Path:" ); mTGPath = mTheme->CreateTextInput( mUIWindow->Container(), eeSize( mUIWindow->Container()->Size().Width() - 60, 22 ), eeVector2i( 10, 160 ), UI_CONTROL_DEFAULT_FLAGS | UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_AUTO_SIZE , false, 512 ); diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index 3fbacbea4..db7fada3c 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -22,8 +22,6 @@ void cEETest::Init() { scale = 1.0f; Ang = ang = alpha = 0; lasttick = 0; - Wireframe = false; - TreeTilingCreated = false; AnimVal = 0.5f; mLastFPSLimit = 0; mWasMinimized = false; @@ -63,6 +61,7 @@ void cEETest::Init() { SetScreen( StartScreen ); mWindow->Caption( "eepp - Test Application" ); + mWindow->PushResizeCallback( cb::Make1( this, &cEETest::OnWindowResize ) ); TF = cTextureFactory::instance(); TF->Allocate(40); @@ -190,8 +189,6 @@ void cEETest::OnFontLoaded( cResourceLoader * ObjLoaded ) { eeASSERT( TTF != NULL ); eeASSERT( TTFB != NULL ); - Map.Font( FF ); - Con.Create( FF, true ); Con.IgnoreCharOnPrompt( 186 ); // 'ยบ' @@ -236,18 +233,6 @@ void cEETest::OnWinMouseUp( const cUIEvent * Event ) { } } -void cEETest::OnTerrainMouse( const cUIEvent * Event ) { - cUIPushButton * PB = static_cast( Event->Ctrl() ); - - if ( PB->Text() == "Terrain Up" ) { - PB->Text( "Terrain Down" ); - mTerrainUp = false; - } else { - PB->Text( "Terrain Up" ); - mTerrainUp = true; - } -} - void cEETest::OnShowMenu( const cUIEvent * Event ) { cUIPushButton * PB = static_cast( Event->Ctrl() ); @@ -258,6 +243,9 @@ void cEETest::OnShowMenu( const cUIEvent * Event ) { } } +void cEETest::OnWindowResize(cWindow * win) { + Map.ViewSize( win->Size() ); +} void cEETest::CreateUI() { cClock TE; @@ -567,28 +555,6 @@ void cEETest::CreateUI() { mGenGrid->CollumnWidth( 1, 24 ); mGenGrid->CollumnWidth( 2, 100 ); -#ifdef EE_PLATFORM_TOUCH - cTextureAtlas * SG = cGlobalTextureAtlas::instance(); - - cTexture * butTex = TF->GetTexture( TF->Load( MyPath + "sprites/button-te_normal.png" ) ); - - SG->Add( butTex->Id(), "button-te_normal" ); - SG->Add( TF->Load( MyPath + "sprites/button-te_mdown.png" ), "button-te_mdown" ); - - cUISkinSimple nSkin( "button-te" ); - - mShowMenu = mTheme->CreatePushButton( NULL, butTex->Size(), eeVector2i( mWindow->GetWidth() - butTex->Width() - 20, mWindow->GetHeight() - butTex->Height() - 10 ), UI_CONTROL_ALIGN_CENTER | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM ); - mShowMenu->SetSkin( nSkin ); - mShowMenu->Text( "Show Menu" ); - mShowMenu->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cEETest::OnShowMenu ) ); - - mTerrainBut = mTheme->CreatePushButton( NULL, butTex->Size(), eeVector2i( mShowMenu->Pos().x - butTex->Width() - 20, mWindow->GetHeight() - butTex->Height() - 10 ), UI_CONTROL_ALIGN_CENTER | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM ); - mTerrainBut->SetSkin( nSkin ); - mTerrainBut->Text( "Terrain Up" ); - mTerrainBut->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cEETest::OnTerrainMouse ) ); - mTerrainBut->Visible( 1 == Screen ); -#endif - C = reinterpret_cast ( C->Parent() ); eePRINTL( "CreateUI time: %4.3f ms.", TE.Elapsed().AsMilliseconds() ); @@ -948,59 +914,12 @@ void cEETest::LoadTextures() { eePRINTL( "Textures loading time: %4.3f ms.", TE.Elapsed().AsMilliseconds() ); - Map.Create( 100, 100, 2, 128, 64, eeColor(175,175,175) ); - RandomizeHeights(); - - TreeTilingCreated = false; - CreateTiling(Wireframe); + Map.Load( MyPath + "maps/test.eem" ); + Map.ViewSize( mWindow->Size() ); eePRINTL( "Map creation time: %4.3f ms.", TE.Elapsed().AsMilliseconds() ); } -void cEETest::RandomizeHeights() { - Map.Reset(); - PerlinNoise.Octaves(7); - PerlinNoise.Persistence(0.25f); - PerlinNoise.Frequency(0.015f); - PerlinNoise.Amplitude(1); - - for ( x = 0; x < static_cast( Map.Width() ); x++ ) { - for ( y = 0; y < static_cast( Map.Height() ); y++ ) { - H = PerlinNoise.PerlinNoise2D((eeFloat)x,(eeFloat)y); - if (H < 0 ) H *= -1; - - eeFloat nh = (eeFloat)( (Int32)( H * 100 ) % 255 ); - eeFloat nf = (4 * nh / 25) / 2; - NH = Int32(nf); - - Map.SetTileHeight( x, y, NH ); - } - } -} - -void cEETest::CreateTiling( const bool& Wire ) { - cMTRand Rand( 0xFF00FF00 ); - - for ( x = 0; x < static_cast( Map.Width() ); x++ ) { - for ( y = 0; y < static_cast( Map.Height() ); y++ ) { - if ( Wire ) - Map.Layer(x, y, 0, Tiles[6] ); - else - Map.Layer(x, y, 0, Tiles[ Rand.RandRange( 0, 5 ) ] ); - - if ( !TreeTilingCreated ) - Map.Layer(x, y, 1, 0); - } - } - - if ( !TreeTilingCreated ) { - for ( x = 0; x < 100; x++ ) - Map.Layer( Rand.RandRange( 0, Map.Width() - 1 ), Rand.RandRange( 0, Map.Height() -1 ), 1, Tiles[7] ); - - TreeTilingCreated = true; - } -} - void cEETest::Run() { ParticlesThread(); } @@ -1022,6 +941,7 @@ void cEETest::UpdateParticles() { } void cEETest::Screen1() { + Map.Update(); Map.Draw(); } @@ -1529,51 +1449,9 @@ void cEETest::Input() { Map.Move( 0, -mWindow->Elapsed().AsMilliseconds() * 0.2f ); } - if ( KM->IsKeyDown(KEY_KP_MINUS) ) - Map.BaseLight().Radius( Map.BaseLight().Radius() - mWindow->Elapsed().AsMilliseconds() * 0.2f ); - - if ( KM->IsKeyDown(KEY_KP_PLUS) ) - Map.BaseLight().Radius( Map.BaseLight().Radius() + mWindow->Elapsed().AsMilliseconds() * 0.2f ); - - if ( KM->IsKeyUp(KEY_F6) ) { - Wireframe = !Wireframe; - Sys::Sleep(1); - CreateTiling(Wireframe); - } - - if ( KM->IsKeyUp(KEY_F7) ) - Map.DrawFont( !Map.DrawFont() ); - if ( KM->IsKeyUp(KEY_F8) ) Map.Reset(); - if ( KM->IsKeyUp(KEY_F9) ) - RandomizeHeights(); - - if ( KM->MouseLeftClick() ) { - eeVector2i P = Map.GetMouseTilePos(); - - if ( NULL != mTerrainBut ) { - if ( !mTerrainBut->GetPolygon().PointInside( KM->GetMousePosf() ) ) { - if ( mTerrainUp ) { - Map.SetTileHeight( P.x, P.y ); - } else { - Map.SetTileHeight( P.x, P.y, 1, false ); - } - } - } else { - if ( mTerrainUp ) { - Map.SetTileHeight( P.x, P.y ); - } else { - Map.SetTileHeight( P.x, P.y, 1, false ); - } - } - } - - if ( KM->MouseRightClick() ) { - eeVector2i P = Map.GetMouseTilePos(); - Map.SetTileHeight( P.x, P.y, 1, false ); - } break; case 2: if ( KM->IsKeyUp(KEY_S) ) diff --git a/src/test/eetest.hpp b/src/test/eetest.hpp index a6a1f5b60..0edb96fbf 100644 --- a/src/test/eetest.hpp +++ b/src/test/eetest.hpp @@ -134,14 +134,7 @@ class cEETest : private cThread { std::string MyPath; bool ShowParticles; - cIsoMap Map; - - bool Wireframe; - - void CreateTiling( const bool& Wire ); - void RandomizeHeights(); - cPerlinNoise PerlinNoise; - bool TreeTilingCreated; + cMap Map; eeFloat H; Int32 NH; @@ -304,8 +297,9 @@ class cEETest : private cThread { void DestroyBody(); - void OnTerrainMouse( const cUIEvent * Event ); void OnShowMenu( const cUIEvent * Event ); + + void OnWindowResize( cWindow * win ); }; }