mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-11 17:17:42 +03:00
Keep it working on the map editor, maps can now be saved, i'll implement the loading next.
Changed a little bit how to load from memory packs. Fixed some minor bugs on the UI. And many things that i can't remember, i forgot to make a commit yesterday.
This commit is contained in:
@@ -59,12 +59,15 @@ bool cSoundBuffer::LoadFromFile(const std::string& Filename) {
|
||||
}
|
||||
|
||||
bool cSoundBuffer::LoadFromPack( cPack* Pack, const std::string& FilePackPath ) {
|
||||
std::vector<Uint8> TmpData;
|
||||
bool Ret = false;
|
||||
cPack::PointerData PData;
|
||||
|
||||
if ( Pack->IsOpen() && Pack->ExtractFileToMemory( FilePackPath, TmpData ) )
|
||||
return LoadFromMemory( reinterpret_cast<const char*> ( &TmpData[0] ), TmpData.size() );
|
||||
if ( Pack->IsOpen() && Pack->ExtractFileToMemory( FilePackPath, PData ) )
|
||||
Ret = LoadFromMemory( reinterpret_cast<const char*> ( PData.Data ), PData.DataSize );
|
||||
|
||||
return false;
|
||||
eeSAFE_DELETE( PData.Data );
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
bool cSoundBuffer::LoadFromMemory( const char* Data, std::size_t SizeInBytes ) {
|
||||
|
||||
@@ -60,8 +60,33 @@ eeVector2f cGameObject::Pos() const {
|
||||
void cGameObject::Pos( eeVector2f pos ) {
|
||||
}
|
||||
|
||||
eeSize cGameObject::Size() {
|
||||
return eeSize();
|
||||
}
|
||||
|
||||
Uint32 cGameObject::Type() const {
|
||||
return GAMEOBJECT_TYPE_BASE;
|
||||
}
|
||||
|
||||
Uint32 cGameObject::DataId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cGameObject::DataId( Uint32 Id ){
|
||||
}
|
||||
|
||||
EE_RENDERTYPE cGameObject::RenderTypeFromFlags() {
|
||||
EE_RENDERTYPE Render = RN_NORMAL;
|
||||
|
||||
if ( ( mFlags & GObjFlags::GAMEOBJECT_MIRRORED ) && ( mFlags & GObjFlags::GAMEOBJECT_FLIPED ) ) {
|
||||
Render = RN_FLIPMIRROR;
|
||||
} else if ( mFlags & GObjFlags::GAMEOBJECT_MIRRORED ) {
|
||||
Render = RN_MIRROR;
|
||||
} else if ( mFlags & GObjFlags::GAMEOBJECT_FLIPED ) {
|
||||
Render = RN_FLIP;
|
||||
}
|
||||
|
||||
return Render;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
#include "base.hpp"
|
||||
#include "maphelper.hpp"
|
||||
#include "../graphics/renders.hpp"
|
||||
|
||||
using namespace EE::Graphics;
|
||||
|
||||
namespace EE { namespace Gaming {
|
||||
|
||||
@@ -20,6 +23,8 @@ class cGameObject {
|
||||
|
||||
virtual void Pos( eeVector2f pos );
|
||||
|
||||
virtual eeSize Size();
|
||||
|
||||
virtual Uint32 Type() const;
|
||||
|
||||
bool IsType( const Uint32& type );
|
||||
@@ -32,13 +37,19 @@ class cGameObject {
|
||||
|
||||
Uint32 FlagGet( const Uint32& Flag );
|
||||
|
||||
void FlagSet( const Uint32& Flag );
|
||||
virtual void FlagSet( const Uint32& Flag );
|
||||
|
||||
void FlagClear( const Uint32& Flag );
|
||||
|
||||
Uint32 IsBlocked() const;
|
||||
|
||||
virtual Uint32 DataId();
|
||||
|
||||
virtual void DataId( Uint32 Id );
|
||||
protected:
|
||||
Uint32 mFlags;
|
||||
|
||||
virtual EE_RENDERTYPE RenderTypeFromFlags();
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "cgameobjectshape.hpp"
|
||||
#include "../graphics/cshapegroupmanager.hpp"
|
||||
|
||||
namespace EE { namespace Gaming {
|
||||
|
||||
@@ -18,23 +19,7 @@ Uint32 cGameObjectShape::Type() const {
|
||||
|
||||
void cGameObjectShape::Draw() {
|
||||
if ( NULL != mShape ) {
|
||||
Uint8 Both = 0;
|
||||
EE_RENDERTYPE Render = RN_NORMAL;
|
||||
|
||||
if ( mFlags & GObjFlags::GAMEOBJECT_MIRRORED ) {
|
||||
Render = RN_MIRROR;
|
||||
Both |= 1 << RN_MIRROR;
|
||||
}
|
||||
|
||||
if ( mFlags & GObjFlags::GAMEOBJECT_FLIPED ) {
|
||||
Render = RN_FLIP;
|
||||
Both |= 1 << RN_FLIP;
|
||||
}
|
||||
|
||||
if ( ( Both & RN_MIRROR ) && ( Both & RN_FLIP ) )
|
||||
Render = RN_FLIPMIRROR;
|
||||
|
||||
mShape->Draw( mPos.x, mPos.y, eeColorA(), 0.f, 1.f, ALPHA_NORMAL, Render );
|
||||
mShape->Draw( mPos.x, mPos.y, eeColorA(), 0.f, 1.f, ALPHA_NORMAL, RenderTypeFromFlags() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,6 +30,13 @@ eeVector2f cGameObjectShape::Pos() const {
|
||||
return mPos;
|
||||
}
|
||||
|
||||
eeSize cGameObjectShape::Size() {
|
||||
if ( NULL != mShape )
|
||||
return mShape->RealSize();
|
||||
|
||||
return eeSize();
|
||||
}
|
||||
|
||||
void cGameObjectShape::Pos( eeVector2f pos ) {
|
||||
mPos = pos;
|
||||
}
|
||||
@@ -57,4 +49,12 @@ void cGameObjectShape::Shape( cShape * shape ) {
|
||||
mShape = shape;
|
||||
}
|
||||
|
||||
Uint32 cGameObjectShape::DataId() {
|
||||
return mShape->Id();
|
||||
}
|
||||
|
||||
void cGameObjectShape::DataId( Uint32 Id ) {
|
||||
Shape( cShapeGroupManager::instance()->GetShapeById( Id ) );
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -21,6 +21,8 @@ class cGameObjectShape : public cGameObject {
|
||||
|
||||
virtual eeVector2f Pos() const;
|
||||
|
||||
virtual eeSize Size();
|
||||
|
||||
virtual void Pos( eeVector2f pos );
|
||||
|
||||
cShape * Shape() const;
|
||||
@@ -28,6 +30,10 @@ class cGameObjectShape : public cGameObject {
|
||||
void Shape( cShape * shape );
|
||||
|
||||
virtual Uint32 Type() const;
|
||||
|
||||
virtual Uint32 DataId();
|
||||
|
||||
virtual void DataId( Uint32 Id );
|
||||
protected:
|
||||
cShape * mShape;
|
||||
eeVector2f mPos;
|
||||
|
||||
@@ -11,6 +11,7 @@ cGameObjectShapeEx::cGameObjectShapeEx( const Uint32& Flags, cShape * Shape, con
|
||||
mColor( Color ),
|
||||
mVertexColors( NULL )
|
||||
{
|
||||
mRender = RenderTypeFromFlags();
|
||||
}
|
||||
|
||||
cGameObjectShapeEx::~cGameObjectShapeEx()
|
||||
@@ -30,4 +31,10 @@ void cGameObjectShapeEx::Draw() {
|
||||
}
|
||||
}
|
||||
|
||||
void cGameObjectShapeEx::FlagSet( const Uint32& Flag ) {
|
||||
mRender = RenderTypeFromFlags();
|
||||
|
||||
cGameObject::FlagSet( Flag );
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -15,6 +15,8 @@ class cGameObjectShapeEx : public cGameObjectShape {
|
||||
virtual void Draw();
|
||||
|
||||
virtual Uint32 Type() const;
|
||||
|
||||
virtual void FlagSet( const Uint32& Flag );
|
||||
protected:
|
||||
EE_PRE_BLEND_FUNC mBlend;
|
||||
EE_RENDERTYPE mRender;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "cgameobjectsprite.hpp"
|
||||
#include "../graphics/cshapegroupmanager.hpp"
|
||||
|
||||
namespace EE { namespace Gaming {
|
||||
|
||||
@@ -6,6 +7,8 @@ cGameObjectSprite::cGameObjectSprite( const Uint32& Flags, cSprite * Sprite ) :
|
||||
cGameObject( Flags ),
|
||||
mSprite( Sprite )
|
||||
{
|
||||
if ( NULL != mSprite )
|
||||
mSprite->SetRenderType( RenderTypeFromFlags() );
|
||||
}
|
||||
|
||||
cGameObjectSprite::~cGameObjectSprite() {
|
||||
@@ -26,15 +29,22 @@ void cGameObjectSprite::Update() {
|
||||
}
|
||||
|
||||
eeVector2f cGameObjectSprite::Pos() const {
|
||||
eeASSERT( NULL != mSprite )
|
||||
if ( NULL != mSprite )
|
||||
return mSprite->Position();
|
||||
|
||||
return mSprite->Position();
|
||||
return eeVector2f();
|
||||
}
|
||||
|
||||
void cGameObjectSprite::Pos( eeVector2f pos ) {
|
||||
eeASSERT( NULL != mSprite );
|
||||
if ( NULL != mSprite )
|
||||
mSprite->Position( pos );
|
||||
}
|
||||
|
||||
mSprite->Position( pos );
|
||||
eeSize cGameObjectSprite::Size() {
|
||||
if ( NULL != mSprite )
|
||||
return mSprite->GetShape(0)->RealSize();
|
||||
|
||||
return eeSize();
|
||||
}
|
||||
|
||||
cSprite * cGameObjectSprite::Sprite() const {
|
||||
@@ -42,7 +52,29 @@ cSprite * cGameObjectSprite::Sprite() const {
|
||||
}
|
||||
|
||||
void cGameObjectSprite::Sprite( cSprite * sprite ) {
|
||||
eeSAFE_DELETE( mSprite );
|
||||
mSprite = sprite;
|
||||
}
|
||||
|
||||
void cGameObjectSprite::FlagSet( const Uint32& Flag ) {
|
||||
if ( NULL != mSprite )
|
||||
mSprite->SetRenderType( RenderTypeFromFlags() );
|
||||
|
||||
cGameObject::FlagSet( Flag );
|
||||
}
|
||||
|
||||
Uint32 cGameObjectSprite::DataId() {
|
||||
return mSprite->GetShape(0)->Id();
|
||||
}
|
||||
|
||||
void cGameObjectSprite::DataId( Uint32 Id ) {
|
||||
std::vector<cShape*> tShapeVec = cShapeGroupManager::instance()->GetShapesByPatternId( Id );
|
||||
|
||||
if ( tShapeVec.size() ) {
|
||||
cSprite * tSprite = eeNew( cSprite, () );
|
||||
tSprite->CreateAnimation();
|
||||
tSprite->AddFrames( tShapeVec );
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -23,11 +23,19 @@ class cGameObjectSprite : public cGameObject {
|
||||
|
||||
virtual void Pos( eeVector2f pos );
|
||||
|
||||
virtual eeSize Size();
|
||||
|
||||
cSprite * Sprite() const;
|
||||
|
||||
void Sprite( cSprite * sprite );
|
||||
|
||||
virtual Uint32 Type() const;
|
||||
|
||||
virtual void FlagSet( const Uint32& Flag );
|
||||
|
||||
virtual Uint32 DataId();
|
||||
|
||||
virtual void DataId( Uint32 Id );
|
||||
private:
|
||||
cSprite * mSprite;
|
||||
};
|
||||
|
||||
96
src/gaming/cgameobjectvirtual.cpp
Normal file
96
src/gaming/cgameobjectvirtual.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
#include "cgameobjectvirtual.hpp"
|
||||
|
||||
#include "cmap.hpp"
|
||||
#include "clayer.hpp"
|
||||
#include "../graphics/cprimitives.hpp"
|
||||
using namespace EE::Graphics;
|
||||
|
||||
namespace EE { namespace Gaming {
|
||||
|
||||
cGameObjectVirtual::cGameObjectVirtual( Uint32 DataId, const Uint32& Flags, Uint32 Type, const eeVector2f& Pos ) :
|
||||
cGameObject( Flags ),
|
||||
mType( Type ),
|
||||
mDataId( DataId ),
|
||||
mPos( Pos ),
|
||||
mLayer( NULL ),
|
||||
mShape( NULL )
|
||||
{
|
||||
}
|
||||
|
||||
cGameObjectVirtual::cGameObjectVirtual( cShape * Shape, const Uint32& Flags, Uint32 Type, const eeVector2f& Pos ) :
|
||||
cGameObject( Flags ),
|
||||
mType( Type ),
|
||||
mDataId( 0 ),
|
||||
mPos( Pos ),
|
||||
mLayer( NULL ),
|
||||
mShape( Shape )
|
||||
{
|
||||
if ( NULL != Shape )
|
||||
mDataId = Shape->Id();
|
||||
}
|
||||
|
||||
cGameObjectVirtual::~cGameObjectVirtual() {
|
||||
}
|
||||
|
||||
Uint32 cGameObjectVirtual::Type() const {
|
||||
return GAMEOBJECT_TYPE_VIRTUAL;
|
||||
}
|
||||
|
||||
Uint32 cGameObjectVirtual::RealType() const {
|
||||
return mType;
|
||||
}
|
||||
|
||||
eeSize cGameObjectVirtual::Size() {
|
||||
if ( NULL != mShape )
|
||||
return mShape->RealSize();
|
||||
|
||||
if ( NULL != mLayer )
|
||||
return mLayer->Map()->TileSize();
|
||||
|
||||
return eeSize( 32, 32 );
|
||||
}
|
||||
|
||||
void cGameObjectVirtual::Draw() {
|
||||
if ( NULL != mShape ) {
|
||||
mShape->Draw( mPos.x, mPos.y, eeColorA(), 0.f, 1.f, ALPHA_NORMAL, RenderTypeFromFlags() );
|
||||
} else {
|
||||
cPrimitives P;
|
||||
|
||||
eeColorA C( mDataId );
|
||||
C.Alpha = 255;
|
||||
|
||||
P.SetColor( C );
|
||||
|
||||
if ( NULL != mLayer ) {
|
||||
eeSize ts = mLayer->Map()->TileSize();
|
||||
P.DrawRectangle( mPos.x, mPos.y, ts.x ,ts.y, 0, 1 );
|
||||
} else {
|
||||
P.DrawRectangle( mPos.x, mPos.y, 32 ,32, 0, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cGameObjectVirtual::Update() {
|
||||
}
|
||||
|
||||
eeVector2f cGameObjectVirtual::Pos() const {
|
||||
return mPos;
|
||||
}
|
||||
|
||||
void cGameObjectVirtual::Pos( eeVector2f pos ) {
|
||||
mPos = pos;
|
||||
}
|
||||
|
||||
Uint32 cGameObjectVirtual::DataId() {
|
||||
return mDataId;
|
||||
}
|
||||
|
||||
void cGameObjectVirtual::DataId( Uint32 Id ) {
|
||||
mDataId = Id;
|
||||
}
|
||||
|
||||
void cGameObjectVirtual::SetLayer( cLayer * Layer ) {
|
||||
mLayer = Layer;
|
||||
}
|
||||
|
||||
}}
|
||||
50
src/gaming/cgameobjectvirtual.hpp
Normal file
50
src/gaming/cgameobjectvirtual.hpp
Normal file
@@ -0,0 +1,50 @@
|
||||
#ifndef EE_GAMINGCGAMEOBJECTVIRTUAL_HPP
|
||||
#define EE_GAMINGCGAMEOBJECTVIRTUAL_HPP
|
||||
|
||||
#include "base.hpp"
|
||||
#include "cgameobject.hpp"
|
||||
#include "../graphics/cshape.hpp"
|
||||
using namespace EE::Graphics;
|
||||
|
||||
namespace EE { namespace Gaming {
|
||||
|
||||
class cLayer;
|
||||
|
||||
class cGameObjectVirtual : public cGameObject {
|
||||
public:
|
||||
cGameObjectVirtual( Uint32 DataId, const Uint32& Flags = GObjFlags::GAMEOBJECT_STATIC, Uint32 RealType = GAMEOBJECT_TYPE_VIRTUAL, const eeVector2f& Pos = eeVector2f() );
|
||||
|
||||
cGameObjectVirtual( cShape * Shape, const Uint32& Flags = GObjFlags::GAMEOBJECT_STATIC, Uint32 RealType = GAMEOBJECT_TYPE_VIRTUAL, const eeVector2f& Pos = eeVector2f() );
|
||||
|
||||
virtual ~cGameObjectVirtual();
|
||||
|
||||
virtual void Draw();
|
||||
|
||||
virtual void Update();
|
||||
|
||||
virtual eeVector2f Pos() const;
|
||||
|
||||
virtual eeSize Size();
|
||||
|
||||
virtual void Pos( eeVector2f pos );
|
||||
|
||||
virtual Uint32 Type() const;
|
||||
|
||||
virtual Uint32 RealType() const;
|
||||
|
||||
virtual Uint32 DataId();
|
||||
|
||||
virtual void DataId( Uint32 Id );
|
||||
|
||||
void SetLayer( cLayer * Layer );
|
||||
protected:
|
||||
Uint32 mType;
|
||||
Uint32 mDataId;
|
||||
eeVector2f mPos;
|
||||
cLayer * mLayer;
|
||||
cShape * mShape;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -61,5 +61,25 @@ const Uint32& cLayer::Id() const {
|
||||
return mNameHash;
|
||||
}
|
||||
|
||||
void cLayer::ClearProperties() {
|
||||
mProperties.clear();
|
||||
}
|
||||
|
||||
void cLayer::AddProperty( std::string Text, std::string Value ) {
|
||||
mProperties[ Text ] = Value;
|
||||
}
|
||||
|
||||
void cLayer::EditProperty( std::string Text, std::string Value ) {
|
||||
mProperties[ Text ] = Value;
|
||||
}
|
||||
|
||||
void cLayer::RemoveProperty( std::string Text ) {
|
||||
mProperties.erase( Text );
|
||||
}
|
||||
|
||||
cLayer::PropertiesMap& cLayer::GetProperties() {
|
||||
return mProperties;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ class cMap;
|
||||
|
||||
class cLayer {
|
||||
public:
|
||||
typedef std::map<std::string, std::string> PropertiesMap;
|
||||
|
||||
virtual ~cLayer();
|
||||
|
||||
virtual void Draw( const eeVector2f& Offset = eeVector2f(0,0) ) = 0;
|
||||
@@ -34,6 +36,16 @@ class cLayer {
|
||||
const std::string& Name() const;
|
||||
|
||||
const Uint32& Id() const;
|
||||
|
||||
void AddProperty( std::string Text, std::string Value );
|
||||
|
||||
void EditProperty( std::string Text, std::string Value );
|
||||
|
||||
void RemoveProperty( std::string Text );
|
||||
|
||||
void ClearProperties();
|
||||
|
||||
PropertiesMap& GetProperties();
|
||||
protected:
|
||||
friend class cMap;
|
||||
|
||||
@@ -43,6 +55,7 @@ class cLayer {
|
||||
eeVector2f mOffset;
|
||||
Uint32 mNameHash;
|
||||
std::string mName;
|
||||
PropertiesMap mProperties;
|
||||
|
||||
cLayer( cMap * map, Uint32 type, Uint32 flags, std::string name = "", eeVector2f offset = eeVector2f(0,0) );
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "cmap.hpp"
|
||||
#include "cgameobjectvirtual.hpp"
|
||||
#include "cgameobjectshape.hpp"
|
||||
#include "cgameobjectshapeex.hpp"
|
||||
#include "cgameobjectsprite.hpp"
|
||||
@@ -6,6 +7,8 @@
|
||||
#include "cobjectlayer.hpp"
|
||||
|
||||
#include "../graphics/cprimitives.hpp"
|
||||
#include "../graphics/cshapegroupmanager.hpp"
|
||||
#include "../ui/cuithememanager.hpp"
|
||||
using namespace EE::Graphics;
|
||||
|
||||
namespace EE { namespace Gaming {
|
||||
@@ -56,6 +59,7 @@ void cMap::Create( eeSize Size, Uint32 MaxLayers, eeSize TileSize, Uint32 Flags,
|
||||
mMaxLayers = MaxLayers;
|
||||
mSize = Size;
|
||||
mTileSize = TileSize;
|
||||
mPixelSize = Size * TileSize;
|
||||
mLayers = eeNewArray( cLayer*, mMaxLayers );
|
||||
|
||||
for ( Uint32 i = 0; i < mMaxLayers; i++ )
|
||||
@@ -100,6 +104,17 @@ cLayer* cMap::GetLayerByHash( Uint32 hash ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Uint32 cMap::GetLayerIndex( cLayer * Layer ) {
|
||||
if ( NULL != Layer ) {
|
||||
for ( Uint32 i = 0; i < mLayerCount; i++ ) {
|
||||
if ( mLayers[i] == Layer )
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return MAP_LAYER_UNKNOWN;
|
||||
}
|
||||
|
||||
cLayer* cMap::GetLayer( const std::string& name ) {
|
||||
return GetLayerByHash( MakeHash( name ) );
|
||||
}
|
||||
@@ -111,40 +126,51 @@ void cMap::Draw() {
|
||||
mWindow->ClipEnable( mScreenPos.x, mScreenPos.y, mViewSize.x, mViewSize.y );
|
||||
}
|
||||
|
||||
eeVector2f offsetFixed = eeVector2f( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y ) + FixOffset();
|
||||
mOffsetFixed = eeVector2f( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y ) + FixOffset();
|
||||
|
||||
GetMouseOverTile();
|
||||
|
||||
GridDraw();
|
||||
|
||||
for ( Uint32 i = 0; i < mLayerCount; i++ ) {
|
||||
mLayers[i]->Draw( offsetFixed );
|
||||
mLayers[i]->Draw( mOffsetFixed );
|
||||
}
|
||||
|
||||
MouseOverDraw();
|
||||
|
||||
if ( ClipedArea() ) {
|
||||
mWindow->ClipDisable();
|
||||
}
|
||||
}
|
||||
|
||||
void cMap::GridDraw() {
|
||||
if ( !DrawGrid() )
|
||||
void cMap::MouseOverDraw() {
|
||||
if ( !DrawTileOver() )
|
||||
return;
|
||||
|
||||
cPrimitives P;
|
||||
P.SetColor( eeColorA( 255, 0, 0, 255 ) );
|
||||
|
||||
P.DrawRectangle( mOffsetFixed.x + mMouseOverTileFinal.x * mTileSize.x, mOffsetFixed.y + mMouseOverTileFinal.y * mTileSize.y, mTileSize.x, mTileSize.y, 0.f, 1.f, EE_DRAW_LINE );
|
||||
}
|
||||
|
||||
void cMap::GridDraw() {
|
||||
cPrimitives P;
|
||||
|
||||
P.SetColor( eeColorA( 0, 0, 0, 50 ) );
|
||||
P.DrawRectangle( mScreenPos.x, mScreenPos.y, mViewSize.x, mViewSize.y, 0.f, 1.f );
|
||||
P.SetColor( eeColorA( 255, 255, 255, 255 ) );
|
||||
|
||||
if ( !DrawGrid() )
|
||||
return;
|
||||
|
||||
if ( 0 == mSize.x || 0 == mSize.y )
|
||||
return;
|
||||
|
||||
cGlobalBatchRenderer::instance()->Draw();
|
||||
eeVector2f offsetFixed = eeVector2f( (eeFloat)mScreenPos.x, (eeFloat)mScreenPos.y ) + FixOffset();
|
||||
|
||||
GLi->LoadIdentity();
|
||||
GLi->PushMatrix();
|
||||
GLi->Translatef( offsetFixed.x, offsetFixed.y, 0.0f );
|
||||
GLi->Translatef( mOffsetFixed.x, mOffsetFixed.y, 0.0f );
|
||||
|
||||
eeVector2i start = StartTile();
|
||||
eeVector2i end = EndTile();
|
||||
@@ -155,14 +181,30 @@ void cMap::GridDraw() {
|
||||
}
|
||||
}
|
||||
|
||||
P.DrawBatch();
|
||||
|
||||
GLi->PopMatrix();
|
||||
}
|
||||
|
||||
void cMap::GetMouseOverTile() {
|
||||
eeVector2i mouse = mWindow->GetInput()->GetMousePos();
|
||||
|
||||
mMouseOverTile.x = ( mouse.x - mScreenPos.x - mOffset.x ) / mTileSize.Width();
|
||||
mMouseOverTile.y = ( mouse.y - mScreenPos.y - mOffset.y ) / mTileSize.Height();
|
||||
eeVector2i MapPos( mouse.x - mScreenPos.x - mOffset.x, mouse.y - mScreenPos.y - mOffset.y );
|
||||
|
||||
if ( MapPos.x < 0 )
|
||||
MapPos.x = 0;
|
||||
|
||||
if ( MapPos.y < 0 )
|
||||
MapPos.y = 0;
|
||||
|
||||
if ( MapPos.x > mPixelSize.x )
|
||||
MapPos.x = mPixelSize.x;
|
||||
|
||||
if ( MapPos.y > mPixelSize.y )
|
||||
MapPos.y = mPixelSize.y;
|
||||
|
||||
mMouseOverTile.x = MapPos.x / mTileSize.Width();
|
||||
mMouseOverTile.y = MapPos.y / mTileSize.Height();
|
||||
|
||||
if ( mMouseOverTile.x < 0 )
|
||||
mMouseOverTile.x = 0;
|
||||
@@ -177,7 +219,8 @@ void cMap::GetMouseOverTile() {
|
||||
mMouseOverTile.y = mSize.Height() - 1;
|
||||
|
||||
// Clamped pos
|
||||
mMouseOverTileFinal = eeVector2u( mMouseOverTile.x, mMouseOverTile.y );
|
||||
mMouseOverTileFinal = eeVector2i( mMouseOverTile.x, mMouseOverTile.y );
|
||||
mMouseMapPos = eeVector2i( MapPos.x, MapPos.y );
|
||||
}
|
||||
|
||||
void cMap::Update() {
|
||||
@@ -189,10 +232,14 @@ const eeSize& cMap::ViewSize() const {
|
||||
return mViewSize;
|
||||
}
|
||||
|
||||
const eeVector2u& cMap::GetMouseTilePos() const {
|
||||
const eeVector2i& cMap::GetMouseTilePos() const {
|
||||
return mMouseOverTileFinal;
|
||||
}
|
||||
|
||||
const eeVector2i& cMap::GetMouseMapPos() const {
|
||||
return mMouseMapPos;
|
||||
}
|
||||
|
||||
void cMap::ViewSize( const eeSize& viewSize ) {
|
||||
mViewSize = viewSize;
|
||||
|
||||
@@ -294,6 +341,14 @@ Uint32 cMap::ClampBorders() const {
|
||||
return mFlags & MAP_FLAG_CLAMP_BODERS;
|
||||
}
|
||||
|
||||
Uint32 cMap::DrawTileOver() const {
|
||||
return mFlags & MAP_FLAG_DRAW_TILE_OVER;
|
||||
}
|
||||
|
||||
void cMap::DrawTileOver( const bool& draw ) {
|
||||
SetFlagValue( &mFlags, MAP_FLAG_DRAW_TILE_OVER, draw ? 1 : 0 );
|
||||
}
|
||||
|
||||
eeVector2f cMap::FixOffset() {
|
||||
return eeVector2f( (eeFloat)static_cast<Int32>( mOffset.x ), (eeFloat)static_cast<Int32>( mOffset.y ) );
|
||||
}
|
||||
@@ -319,6 +374,10 @@ cGameObject * cMap::CreateGameObject( const Uint32& Type, const Uint32& Flags )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const eeSize& cMap::TotalSize() const {
|
||||
return mPixelSize;
|
||||
}
|
||||
|
||||
const eeSize& cMap::TileSize() const {
|
||||
return mTileSize;
|
||||
}
|
||||
@@ -335,12 +394,395 @@ const Uint32& cMap::MaxLayers() const {
|
||||
return mMaxLayers;
|
||||
}
|
||||
|
||||
bool cMap::MoveLayerUp( cLayer * Layer ) {
|
||||
Uint32 Lindex = GetLayerIndex( Layer );
|
||||
|
||||
if ( Lindex != MAP_LAYER_UNKNOWN && mLayerCount > 1 && ( Lindex < mLayerCount - 1 ) && ( Lindex + 1 < mLayerCount ) ) {
|
||||
cLayer * tLayer = mLayers[ Lindex + 1 ];
|
||||
|
||||
mLayers[ Lindex ] = tLayer;
|
||||
mLayers[ Lindex + 1 ] = Layer;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cMap::MoveLayerDown( cLayer * Layer ) {
|
||||
Uint32 Lindex = GetLayerIndex( Layer );
|
||||
|
||||
if ( Lindex != MAP_LAYER_UNKNOWN && mLayerCount > 1 && Lindex >= 1 ) {
|
||||
cLayer * tLayer = mLayers[ Lindex - 1 ];
|
||||
|
||||
mLayers[ Lindex ] = tLayer;
|
||||
mLayers[ Lindex - 1 ] = Layer;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cMap::RemoveLayer( cLayer * Layer ) {
|
||||
Uint32 Lindex = GetLayerIndex( Layer );
|
||||
|
||||
if ( Lindex != MAP_LAYER_UNKNOWN ) {
|
||||
eeSAFE_DELETE( mLayers[ Lindex ] );
|
||||
|
||||
cLayer * LastLayer = NULL;
|
||||
|
||||
// Reorder layers, to clean empty layers in between layers.
|
||||
for ( Uint32 i = 0; i < mLayerCount; i++ ) {
|
||||
if ( i > 0 && NULL != mLayers[i] && NULL == LastLayer ) {
|
||||
mLayers[ i - 1 ] = mLayers[ i ];
|
||||
mLayers[ i ] = NULL;
|
||||
}
|
||||
|
||||
LastLayer = mLayers[i];
|
||||
}
|
||||
|
||||
mLayerCount--;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void cMap::ClearProperties() {
|
||||
mProperties.clear();
|
||||
}
|
||||
|
||||
void cMap::AddProperty( std::string Text, std::string Value ) {
|
||||
mProperties[ Text ] = Value;
|
||||
}
|
||||
|
||||
void cMap::EditProperty( std::string Text, std::string Value ) {
|
||||
mProperties[ Text ] = Value;
|
||||
}
|
||||
|
||||
void cMap::RemoveProperty( std::string Text ) {
|
||||
mProperties.erase( Text );
|
||||
}
|
||||
|
||||
cMap::PropertiesMap& cMap::GetProperties() {
|
||||
return mProperties;
|
||||
}
|
||||
|
||||
void cMap::AddVirtualObjectType( const std::string& name ) {
|
||||
mObjTypes.push_back( name );
|
||||
mObjTypes.unique();
|
||||
}
|
||||
|
||||
void cMap::RemoveVirtualObjectType( const std::string& name ) {
|
||||
mObjTypes.remove( name );
|
||||
}
|
||||
|
||||
void cMap::ClearVirtualObjectTypes() {
|
||||
mObjTypes.clear();
|
||||
}
|
||||
|
||||
cMap::GOTypesList& cMap::GetVirtualObjectTypes() {
|
||||
return mObjTypes;
|
||||
}
|
||||
|
||||
#define MAP_PROPERTY_SIZE (64)
|
||||
#define LAYER_NAME_SIZE (64)
|
||||
#define MAP_SHAPEGROUP_PATH_SIZE (128)
|
||||
|
||||
typedef struct sPropertyHdrS {
|
||||
char Name[ MAP_PROPERTY_SIZE ];
|
||||
char Value[ MAP_PROPERTY_SIZE ];
|
||||
} sPropertyHdr;
|
||||
|
||||
typedef struct sMapShapeGroupS {
|
||||
char Path[ MAP_SHAPEGROUP_PATH_SIZE ];
|
||||
} sMapShapeGroup;
|
||||
|
||||
typedef struct sVirtualObjS {
|
||||
char Name[ MAP_PROPERTY_SIZE ];
|
||||
} sVirtualObj;
|
||||
|
||||
typedef struct sMapHdrS {
|
||||
Uint32 Magic;
|
||||
Uint32 SizeX;
|
||||
Uint32 SizeY;
|
||||
Uint32 MaxLayers;
|
||||
Uint32 LayerCount;
|
||||
Uint32 Flags;
|
||||
Uint32 PropertyCount;
|
||||
Uint32 ShapeGroupCount;
|
||||
Uint32 VirtualObjectTypesCount;
|
||||
} sMapHdr;
|
||||
|
||||
typedef struct sLayerHdrS {
|
||||
char Name[ LAYER_NAME_SIZE ];
|
||||
Uint32 Type;
|
||||
Uint32 Flags;
|
||||
Int32 OffsetX;
|
||||
Int32 OffsetY;
|
||||
Uint32 PropertyCount;
|
||||
Uint32 ObjectCount; //! Only used by the Object Layer
|
||||
} sLayerHdr;
|
||||
|
||||
typedef struct sMapTileGOHdrS {
|
||||
Uint32 Type;
|
||||
Uint32 Id;
|
||||
Uint32 Flags;
|
||||
} sMapTileGOHdr;
|
||||
|
||||
typedef struct sMapObjGOHdrS {
|
||||
Uint32 Type;
|
||||
Uint32 Id;
|
||||
Uint32 Flags;
|
||||
Int32 PosX;
|
||||
Int32 PosY;
|
||||
} sMapObjGOHdr;
|
||||
|
||||
void cMap::Load( const std::string& path ) {
|
||||
|
||||
}
|
||||
|
||||
void cMap::Save( const std::string& path ) {
|
||||
std::vector<std::string> cMap::GetShapeGroups() {
|
||||
cShapeGroupManager * SGM = cShapeGroupManager::instance();
|
||||
std::list<cShapeGroup*>& Res = SGM->GetResources();
|
||||
|
||||
std::vector<std::string> items;
|
||||
|
||||
//! Ugly ugly ugly, but i don't see another way
|
||||
Uint32 Restricted1 = MakeHash( std::string( "global" ) );
|
||||
Uint32 Restricted2 = MakeHash( UI::cUIThemeManager::instance()->DefaultTheme()->ShapeGroup()->Name() );
|
||||
|
||||
for ( std::list<cShapeGroup*>::iterator it = Res.begin(); it != Res.end(); it++ ) {
|
||||
if ( (*it)->Id() != Restricted1 && (*it)->Id() != Restricted2 )
|
||||
items.push_back( (*it)->Path() );
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
void cMap::Save( const std::string& path ) {
|
||||
Uint32 i;
|
||||
sMapHdr MapHdr;
|
||||
cLayer * tLayer;
|
||||
|
||||
std::vector<std::string> ShapeGroups = GetShapeGroups();
|
||||
|
||||
MapHdr.Magic = ( ( 'E' << 0 ) | ( 'E' << 8 ) | ( 'M' << 16 ) | ( 'P' << 24 ) );
|
||||
MapHdr.Flags = mFlags;
|
||||
MapHdr.MaxLayers = mMaxLayers;
|
||||
MapHdr.SizeX = mSize.Width();
|
||||
MapHdr.SizeY = mSize.Height();
|
||||
MapHdr.LayerCount = mLayerCount;
|
||||
MapHdr.PropertyCount = mProperties.size();
|
||||
MapHdr.ShapeGroupCount = ShapeGroups.size();
|
||||
MapHdr.VirtualObjectTypesCount = mObjTypes.size(); //! This is only usefull for the Map Editor, to auto add on the load the virtual object types that where used to create the map.
|
||||
|
||||
std::fstream fs ( path.c_str() , std::ios::out | std::ios::binary );
|
||||
|
||||
if ( fs.is_open() ) {
|
||||
//! Writes the map header
|
||||
fs.write( reinterpret_cast<const char*> ( &MapHdr ), sizeof(sMapHdr) );
|
||||
|
||||
//! Writes the layers type order ( because the object layers will be saved separately
|
||||
for ( i = 0; i < mLayerCount; i++ ) {
|
||||
if ( NULL != mLayers[i] ) {
|
||||
fs.write( reinterpret_cast<const char*> ( &mLayers[i]->Type() ), sizeof(Uint32) );
|
||||
}
|
||||
}
|
||||
|
||||
//! Writes the properties of the map
|
||||
for ( cMap::PropertiesMap::iterator it = mProperties.begin(); it != mProperties.end(); it++ ) {
|
||||
sPropertyHdr tProp;
|
||||
|
||||
memset( tProp.Name, 0, MAP_PROPERTY_SIZE );
|
||||
memset( tProp.Value, 0, MAP_PROPERTY_SIZE );
|
||||
|
||||
StrCopy( tProp.Name, (*it).first.c_str(), MAP_PROPERTY_SIZE );
|
||||
StrCopy( tProp.Value, (*it).second.c_str(), MAP_PROPERTY_SIZE );
|
||||
|
||||
fs.write( reinterpret_cast<const char*> ( &tProp ), sizeof(sPropertyHdr) );
|
||||
}
|
||||
|
||||
//! Writes the shape groups that the map will need and load
|
||||
for ( i = 0; i < ShapeGroups.size(); i++ ) {
|
||||
sMapShapeGroup tSG;
|
||||
|
||||
memset( tSG.Path, 0, MAP_SHAPEGROUP_PATH_SIZE );
|
||||
|
||||
StrCopy( tSG.Path, ShapeGroups[i].c_str(), MAP_SHAPEGROUP_PATH_SIZE );
|
||||
|
||||
fs.write( reinterpret_cast<const char*> ( &tSG ), sizeof(sMapShapeGroup) );
|
||||
}
|
||||
|
||||
//! Writes the names of the virtual object types created in the map editor
|
||||
for ( GOTypesList::iterator votit = mObjTypes.begin(); votit != mObjTypes.end(); votit++ ) {
|
||||
sVirtualObj tVObjH;
|
||||
|
||||
memset( tVObjH.Name, 0, MAP_PROPERTY_SIZE );
|
||||
|
||||
StrCopy( tVObjH.Name, (*votit).c_str(), MAP_PROPERTY_SIZE );
|
||||
|
||||
fs.write( reinterpret_cast<const char*> ( &tVObjH ), sizeof(sVirtualObj) );
|
||||
}
|
||||
|
||||
//! Writes every layer header
|
||||
for ( i = 0; i < mLayerCount; i++ ) {
|
||||
tLayer = mLayers[i];
|
||||
sLayerHdr tLayerH;
|
||||
|
||||
memset( tLayerH.Name, 0, LAYER_NAME_SIZE );
|
||||
|
||||
StrCopy( tLayerH.Name, tLayer->Name().c_str(), LAYER_NAME_SIZE );
|
||||
|
||||
tLayerH.Type = tLayer->Type();
|
||||
tLayerH.Flags = tLayer->Flags();
|
||||
tLayerH.OffsetX = tLayer->Offset().x;
|
||||
tLayerH.OffsetY = tLayer->Offset().y;
|
||||
tLayerH.ObjectCount = 0;
|
||||
|
||||
cLayer::PropertiesMap& tLayerProp = tLayer->GetProperties();
|
||||
|
||||
tLayerH.PropertyCount = tLayerProp.size();
|
||||
|
||||
//! Writes the layer header
|
||||
fs.write( reinterpret_cast<const char*> ( &tLayerH ), sizeof(sLayerHdr) );
|
||||
|
||||
//! Writes the properties of the current layer
|
||||
for ( cLayer::PropertiesMap::iterator lit = tLayerProp.begin(); lit != tLayerProp.end(); lit++ ) {
|
||||
sPropertyHdr tProp;
|
||||
|
||||
memset( tProp.Name, 0, MAP_PROPERTY_SIZE );
|
||||
memset( tProp.Value, 0, MAP_PROPERTY_SIZE );
|
||||
|
||||
StrCopy( tProp.Name, (*lit).first.c_str(), MAP_PROPERTY_SIZE );
|
||||
StrCopy( tProp.Value, (*lit).second.c_str(), MAP_PROPERTY_SIZE );
|
||||
}
|
||||
}
|
||||
|
||||
//! This method is slow, but allows to save big maps with little space needed, i'll add an alternative save method ( just plain layer -> tile object saving )
|
||||
Int32 x, y;
|
||||
Uint32 tReadFlag = 0, z;
|
||||
cTileLayer * tTLayer;
|
||||
cGameObject * tObj;
|
||||
|
||||
cGameObject * tObjects[ mLayerCount ];
|
||||
|
||||
//! First we save the tiled layers.
|
||||
for ( y = 0; y < mSize.y; y++ ) {
|
||||
for ( x = 0; x < mSize.x; x++ ) {
|
||||
//! Reset Layer Read Flags and temporal objects
|
||||
tReadFlag = 0;
|
||||
|
||||
for ( z = 0; z < mLayerCount; z++ )
|
||||
tObjects[z] = NULL;
|
||||
|
||||
//! Look at every layer if it's some data on the current tile, in that case it will write a bit flag to
|
||||
//! inform that it's an object on the current tile layer, and it will store a temporal reference to the
|
||||
//! object to write layer the object header information
|
||||
for ( i = 0; i < mLayerCount; i++ ) {
|
||||
tLayer = mLayers[i];
|
||||
|
||||
if ( NULL != tLayer && tLayer->Type() == MAP_LAYER_TILED ) {
|
||||
tTLayer = reinterpret_cast<cTileLayer*> ( tLayer );
|
||||
|
||||
tObj = tTLayer->GetGameObject( eeVector2i( x, y ) );
|
||||
|
||||
if ( NULL != tObj ) {
|
||||
tReadFlag |= 1 << i;
|
||||
|
||||
tObjects[i] = tObj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! Writes the current tile flags
|
||||
fs.write( reinterpret_cast<const char*> ( &tReadFlag ), sizeof(Uint32) );
|
||||
|
||||
//! Writes every game object header corresponding to this tile
|
||||
for ( i = 0; i < mLayerCount; i++ ) {
|
||||
if ( tReadFlag & ( 1 << i ) ) {
|
||||
tObj = tObjects[i];
|
||||
|
||||
sMapTileGOHdr tTGOHdr;
|
||||
|
||||
//! The DataId should be the Shape hash name ( at least in the cases of type Shape, ShapeEx and Sprite.
|
||||
tTGOHdr.Id = tObj->DataId();
|
||||
|
||||
//! If the object type is virtual, means that the real type is stored elsewhere.
|
||||
if ( tObj->Type() != GAMEOBJECT_TYPE_VIRTUAL ) {
|
||||
tTGOHdr.Type = tObj->Type();
|
||||
} else {
|
||||
cGameObjectVirtual * tObjV = reinterpret_cast<cGameObjectVirtual*> ( tObj );
|
||||
|
||||
tTGOHdr.Type = tObjV->RealType();
|
||||
}
|
||||
|
||||
tTGOHdr.Flags = tObj->Flags();
|
||||
|
||||
fs.write( reinterpret_cast<const char*> ( &tTGOHdr ), sizeof(sMapTileGOHdr) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//! Then we save the Object layers.
|
||||
std::list<cObjectLayer*> mObjLayers;
|
||||
cObjectLayer * tOLayer;
|
||||
|
||||
for ( i = 0; i < mLayerCount; i++ ) {
|
||||
tLayer = mLayers[i];
|
||||
|
||||
if ( NULL != tLayer && tLayer->Type() == MAP_LAYER_OBJECT ) {
|
||||
mObjLayers.push_back( reinterpret_cast<cObjectLayer*> ( tLayer ) );
|
||||
}
|
||||
}
|
||||
|
||||
for ( std::list<cObjectLayer*>::iterator oit = mObjLayers.begin(); oit != mObjLayers.end(); oit++ ) {
|
||||
tOLayer = (*oit);
|
||||
|
||||
sLayerHdr tLayerH;
|
||||
|
||||
memset( tLayerH.Name, 0, LAYER_NAME_SIZE );
|
||||
|
||||
StrCopy( tLayerH.Name, tOLayer->Name().c_str(), LAYER_NAME_SIZE );
|
||||
|
||||
tLayerH.Type = tOLayer->Type();
|
||||
tLayerH.Flags = tOLayer->Flags();
|
||||
tLayerH.OffsetX = tOLayer->Offset().x;
|
||||
tLayerH.OffsetY = tOLayer->Offset().y;
|
||||
tLayerH.ObjectCount = tOLayer->GetObjectCount();
|
||||
|
||||
fs.write( reinterpret_cast<const char*> ( &tLayerH ), sizeof(sLayerHdr) );
|
||||
|
||||
cObjectLayer::ObjList ObjList = tOLayer->GetObjectList();
|
||||
|
||||
for ( cObjectLayer::ObjList::iterator MapObjIt = ObjList.begin(); MapObjIt != ObjList.end(); MapObjIt++ ) {
|
||||
tObj = (*MapObjIt);
|
||||
|
||||
sMapTileGOHdr tTGOHdr;
|
||||
|
||||
//! The DataId should be the Shape hash name ( at least in the cases of type Shape, ShapeEx and Sprite.
|
||||
tTGOHdr.Id = tObj->DataId();
|
||||
|
||||
//! If the object type is virtual, means that the real type is stored elsewhere.
|
||||
if ( tObj->Type() != GAMEOBJECT_TYPE_VIRTUAL ) {
|
||||
tTGOHdr.Type = tObj->Type();
|
||||
} else {
|
||||
cGameObjectVirtual * tObjV = reinterpret_cast<cGameObjectVirtual*> ( tObj );
|
||||
|
||||
tTGOHdr.Type = tObjV->RealType();
|
||||
}
|
||||
|
||||
tTGOHdr.Flags = tObj->Flags();
|
||||
|
||||
fs.write( reinterpret_cast<const char*> ( &tTGOHdr ), sizeof(sMapTileGOHdr) );
|
||||
}
|
||||
}
|
||||
|
||||
fs.close();
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -14,8 +14,13 @@ using namespace EE::Window;
|
||||
|
||||
namespace EE { namespace Gaming {
|
||||
|
||||
#define MAP_LAYER_UNKNOWN 0xFFFFFFFF
|
||||
|
||||
class cMap {
|
||||
public:
|
||||
typedef std::map<std::string, std::string> PropertiesMap;
|
||||
typedef std::list<std::string> GOTypesList; //! Special object types used in this map
|
||||
|
||||
cMap();
|
||||
|
||||
virtual ~cMap();
|
||||
@@ -26,6 +31,8 @@ class cMap {
|
||||
|
||||
virtual cLayer * GetLayer( Uint32 index );
|
||||
|
||||
virtual Uint32 GetLayerIndex( cLayer * Layer );
|
||||
|
||||
virtual cLayer * GetLayerByHash( Uint32 hash );
|
||||
|
||||
virtual cLayer * GetLayer( const std::string& name );
|
||||
@@ -76,9 +83,41 @@ class cMap {
|
||||
|
||||
Uint32 DrawGrid() const;
|
||||
|
||||
Uint32 DrawTileOver() const;
|
||||
|
||||
void DrawTileOver( const bool& draw );
|
||||
|
||||
void Reset();
|
||||
|
||||
const eeVector2u& GetMouseTilePos() const;
|
||||
bool MoveLayerUp( cLayer * Layer );
|
||||
|
||||
bool MoveLayerDown( cLayer * Layer );
|
||||
|
||||
bool RemoveLayer( cLayer * Layer );
|
||||
|
||||
const eeVector2i& GetMouseTilePos() const;
|
||||
|
||||
const eeVector2i& GetMouseMapPos() const;
|
||||
|
||||
const eeSize& TotalSize() const;
|
||||
|
||||
void AddProperty( std::string Text, std::string Value );
|
||||
|
||||
void EditProperty( std::string Text, std::string Value );
|
||||
|
||||
void RemoveProperty( std::string Text );
|
||||
|
||||
void ClearProperties();
|
||||
|
||||
PropertiesMap& GetProperties();
|
||||
|
||||
void AddVirtualObjectType( const std::string& name );
|
||||
|
||||
void RemoveVirtualObjectType( const std::string& name );
|
||||
|
||||
void ClearVirtualObjectTypes();
|
||||
|
||||
GOTypesList& GetVirtualObjectTypes();
|
||||
protected:
|
||||
cWindow * mWindow;
|
||||
cLayer** mLayers;
|
||||
@@ -86,6 +125,7 @@ class cMap {
|
||||
Uint32 mMaxLayers;
|
||||
Uint32 mLayerCount;
|
||||
eeSize mSize;
|
||||
eeSize mPixelSize;
|
||||
eeSize mTileSize;
|
||||
eeSize mViewSize;
|
||||
eeVector2f mOffset;
|
||||
@@ -93,7 +133,11 @@ class cMap {
|
||||
eeVector2i mStartTile;
|
||||
eeVector2i mEndTile;
|
||||
eeVector2i mMouseOverTile;
|
||||
eeVector2u mMouseOverTileFinal;
|
||||
eeVector2i mMouseOverTileFinal;
|
||||
eeVector2i mMouseMapPos;
|
||||
eeVector2f mOffsetFixed;
|
||||
PropertiesMap mProperties;
|
||||
GOTypesList mObjTypes;
|
||||
|
||||
cGameObject * CreateGameObject( const Uint32& Type, const Uint32& Flags );
|
||||
|
||||
@@ -107,7 +151,11 @@ class cMap {
|
||||
|
||||
void GridDraw();
|
||||
|
||||
void MouseOverDraw();
|
||||
|
||||
void DeleteLayers();
|
||||
|
||||
std::vector<std::string> GetShapeGroups();
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -13,6 +13,7 @@ cObjectLayer::cObjectLayer( cMap * map, Uint32 flags, std::string name, eeVector
|
||||
}
|
||||
|
||||
cObjectLayer::~cObjectLayer() {
|
||||
DeallocateLayer();
|
||||
}
|
||||
|
||||
void cObjectLayer::AllocateLayer() {
|
||||
@@ -47,12 +48,48 @@ void cObjectLayer::Update() {
|
||||
}
|
||||
}
|
||||
|
||||
Uint32 cObjectLayer::GetObjectCount() const {
|
||||
return mObjects.size();
|
||||
}
|
||||
|
||||
void cObjectLayer::AddGameObject( cGameObject * obj ) {
|
||||
mObjects.push_back( obj );
|
||||
}
|
||||
|
||||
void cObjectLayer::RemoveGameObject( cGameObject * obj ) {
|
||||
mObjects.remove( obj );
|
||||
|
||||
eeSAFE_DELETE( obj );
|
||||
}
|
||||
|
||||
void cObjectLayer::RemoveGameObject( const eeVector2i& pos ) {
|
||||
cGameObject * tObj = GetObjectOver( pos );
|
||||
|
||||
if ( NULL != tObj ) {
|
||||
RemoveGameObject( tObj );
|
||||
}
|
||||
}
|
||||
|
||||
cGameObject * cObjectLayer::GetObjectOver( const eeVector2i& pos ) {
|
||||
cGameObject * tObj;
|
||||
register eeVector2f tPos;
|
||||
register eeSize tSize;
|
||||
|
||||
for ( ObjList::reverse_iterator it = mObjects.rbegin(); it != mObjects.rend(); it++ ) {
|
||||
tObj = (*it);
|
||||
|
||||
tPos = tObj->Pos();
|
||||
tSize = tObj->Size();
|
||||
|
||||
if ( Contains( eeRecti( tPos.x, tPos.y, tPos.x + tSize.x, tPos.y + tSize.y ), pos ) )
|
||||
return tObj;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cObjectLayer::ObjList& cObjectLayer::GetObjectList() {
|
||||
return mObjects;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -10,6 +10,8 @@ class cMap;
|
||||
|
||||
class cObjectLayer : public cLayer {
|
||||
public:
|
||||
typedef std::list<cGameObject*> ObjList;
|
||||
|
||||
virtual ~cObjectLayer();
|
||||
|
||||
virtual void Draw( const eeVector2f &Offset = eeVector2f(0,0) );
|
||||
@@ -19,11 +21,15 @@ class cObjectLayer : public cLayer {
|
||||
virtual void AddGameObject( cGameObject * obj );
|
||||
|
||||
virtual void RemoveGameObject( cGameObject * obj );
|
||||
|
||||
virtual void RemoveGameObject( const eeVector2i& pos );
|
||||
|
||||
virtual cGameObject * GetObjectOver( const eeVector2i& pos );
|
||||
|
||||
virtual Uint32 GetObjectCount() const;
|
||||
protected:
|
||||
friend class cMap;
|
||||
|
||||
typedef std::list<cGameObject*> ObjList;
|
||||
|
||||
ObjList mObjects;
|
||||
|
||||
cObjectLayer( cMap * map, Uint32 flags, std::string name = "", eeVector2f offset = eeVector2f(0,0) );
|
||||
@@ -31,6 +37,8 @@ class cObjectLayer : public cLayer {
|
||||
void AllocateLayer();
|
||||
|
||||
void DeallocateLayer();
|
||||
|
||||
ObjList& GetObjectList();
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -76,7 +76,9 @@ void cTileLayer::DeallocateLayer() {
|
||||
eeSAFE_DELETE_ARRAY( mTiles );
|
||||
}
|
||||
|
||||
void cTileLayer::AddGameObject( cGameObject * obj, const eeVector2u& TilePos ) {
|
||||
void cTileLayer::AddGameObject( cGameObject * obj, const eeVector2i& TilePos ) {
|
||||
eeASSERT( TilePos.x >= 0 && TilePos.y >= 0 );
|
||||
|
||||
RemoveGameObject( TilePos );
|
||||
|
||||
mTiles[ TilePos.x ][ TilePos.y ] = obj;
|
||||
@@ -84,13 +86,15 @@ void cTileLayer::AddGameObject( cGameObject * obj, const eeVector2u& TilePos ) {
|
||||
obj->Pos( eeVector2f( TilePos.x * mMap->TileSize().x, TilePos.y * mMap->TileSize().y ) );
|
||||
}
|
||||
|
||||
void cTileLayer::RemoveGameObject( const eeVector2u& TilePos ) {
|
||||
void cTileLayer::RemoveGameObject( const eeVector2i& TilePos ) {
|
||||
eeASSERT( TilePos.x >= 0 && TilePos.y >= 0 );
|
||||
|
||||
if ( NULL != mTiles[ TilePos.x ][ TilePos.y ] ) {
|
||||
eeSAFE_DELETE( mTiles[ TilePos.x ][ TilePos.y ] );
|
||||
}
|
||||
}
|
||||
|
||||
cGameObject * cTileLayer::GetGameObject( const eeVector2u& TilePos ) {
|
||||
cGameObject * cTileLayer::GetGameObject( const eeVector2i& TilePos ) {
|
||||
return mTiles[ TilePos.x ][ TilePos.y ];
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +14,11 @@ class cTileLayer : public cLayer {
|
||||
|
||||
virtual void Update();
|
||||
|
||||
virtual void AddGameObject( cGameObject * obj, const eeVector2u& TilePos );
|
||||
virtual void AddGameObject( cGameObject * obj, const eeVector2i& TilePos );
|
||||
|
||||
virtual void RemoveGameObject( const eeVector2u& TilePos );
|
||||
virtual void RemoveGameObject( const eeVector2i& TilePos );
|
||||
|
||||
virtual cGameObject * GetGameObject( const eeVector2u& TilePos );
|
||||
virtual cGameObject * GetGameObject( const eeVector2i& TilePos );
|
||||
protected:
|
||||
friend class cMap;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "cuigotypenew.hpp"
|
||||
#include "../ctilelayer.hpp"
|
||||
#include "../cobjectlayer.hpp"
|
||||
#include "../cgameobjectvirtual.hpp"
|
||||
#include "../cgameobjectshape.hpp"
|
||||
#include "../cgameobjectshapeex.hpp"
|
||||
#include "../cgameobjectsprite.hpp"
|
||||
@@ -92,11 +93,13 @@ void cMapEditor::CreateWinMenu() {
|
||||
|
||||
reinterpret_cast<cUIMenuCheckBox*> ( PU3->GetItem( "Show Grid" ) )->Active( true );
|
||||
|
||||
PU3->AddCheckBox( "Mark Tile Over" );
|
||||
|
||||
PU3->AddEventListener( cUIEvent::EventOnItemClicked, cb::Make1( this, &cMapEditor::ViewMenuClick ) );
|
||||
WinMenu->AddMenuButton( "View", PU3 );
|
||||
|
||||
cUIPopUpMenu * PU4 = mTheme->CreatePopUpMenu();
|
||||
PU4->Add( "Create New Texture Group..." );
|
||||
PU4->Add( "New Texture Group..." );
|
||||
PU4->Add( "Add External Texture Group..." );
|
||||
PU4->AddSeparator();
|
||||
PU4->Add( "Map Properties..." );
|
||||
@@ -108,6 +111,11 @@ void cMapEditor::CreateWinMenu() {
|
||||
PU5->Add( "Add Tile Layer..." );
|
||||
PU5->Add( "Add Object Layer..." );
|
||||
PU5->AddSeparator();
|
||||
PU5->Add( "Remove Layer" );
|
||||
PU5->AddSeparator();
|
||||
PU5->Add( "Move Layer Up" );
|
||||
PU5->Add( "Move Layer Down" );
|
||||
PU5->AddSeparator();
|
||||
PU5->Add( "Layer Properties..." );
|
||||
|
||||
PU5->AddEventListener( cUIEvent::EventOnItemClicked, cb::Make1( this, &cMapEditor::LayerMenuClick ) );
|
||||
@@ -124,27 +132,25 @@ void cMapEditor::CreateWinMenu() {
|
||||
}
|
||||
|
||||
void cMapEditor::CreateETGMenu() {
|
||||
cUITextBox * Txt;
|
||||
Uint32 TxtFlags = UI_CONTROL_DEFAULT_ALIGN | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP | UI_DRAW_SHADOW;
|
||||
|
||||
Int32 Width = 200;
|
||||
Int32 DistToBorder = 5;
|
||||
|
||||
Uint32 TxtFlags = UI_CONTROL_DEFAULT_ALIGN | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP | UI_DRAW_SHADOW;
|
||||
cUIComplexControl::CreateParams CParams;
|
||||
CParams.Parent( mWinContainer );
|
||||
CParams.PosSet( eeVector2i( mWinContainer->Size().Width() - Width - DistToBorder, 0 ) );
|
||||
CParams.SizeSet( eeSize( Width + DistToBorder, mWinContainer->Size().Height() ) );
|
||||
CParams.Flags = UI_CONTROL_DEFAULT_ALIGN | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP;
|
||||
mRPCont = eeNew( cUIComplexControl, ( CParams ) );
|
||||
mRPCont->Enabled( true );
|
||||
mRPCont->Visible( true );
|
||||
|
||||
cUITextBox * Txt = mTheme->CreateTextBox( mWinContainer, eeSize( Width, 16 ), eeVector2i( mWinContainer->Size().Width() - Width - DistToBorder, 4 ), TxtFlags );
|
||||
Txt->Text( "Shape Groups:" );
|
||||
|
||||
mShapeGroupsList = mTheme->CreateDropDownList( mWinContainer, eeSize( Width, 21 ), eeVector2i( mWinContainer->Size().Width() - Width - DistToBorder, Txt->Pos().y +Txt->Size().Height() + 4 ), UI_CONTROL_DEFAULT_ALIGN | UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
mShapeGroupsList->AddEventListener( cUIEvent::EventOnItemSelected, cb::Make1( this, &cMapEditor::OnShapeGroupChange ) );
|
||||
|
||||
mShapeList = mTheme->CreateListBox( mWinContainer, eeSize( Width, 156 ), eeVector2i( mWinContainer->Size().Width() - Width - DistToBorder, mShapeGroupsList->Pos().y + mShapeGroupsList->Size().Height() + 4 ), UI_CONTROL_DEFAULT_ALIGN | UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
mShapeList->AddEventListener( cUIEvent::EventOnItemSelected, cb::Make1( this, &cMapEditor::OnShapeChange ) );
|
||||
|
||||
mGfxPreview = mTheme->CreateGfx( NULL, mWinContainer, eeSize( Width, Width ), eeVector2i( mWinContainer->Size().Width() - Width - DistToBorder, mShapeList->Pos().y + mShapeList->Size().Height() + 4 ), UI_VALIGN_CENTER | UI_HALIGN_CENTER | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP | UI_AUTO_FIT );
|
||||
mGfxPreview->Border( true );
|
||||
|
||||
Txt = mTheme->CreateTextBox( mWinContainer, eeSize( Width, 16 ), eeVector2i( mWinContainer->Size().Width() - Width - DistToBorder, mGfxPreview->Pos().y + mGfxPreview->Size().Height() + 4 ), TxtFlags );
|
||||
Txt = mTheme->CreateTextBox( mRPCont, eeSize( Width, 16 ), eeVector2i( 0, 4 ), TxtFlags );
|
||||
Txt->Text( "Add Game Object as..." );
|
||||
|
||||
mGOTypeList = mTheme->CreateDropDownList( mWinContainer, eeSize( Width - 26, 21 ), eeVector2i( mWinContainer->Size().Width() - Width - DistToBorder, Txt->Pos().y + Txt->Size().Height() + 4 ), UI_CONTROL_DEFAULT_ALIGN | UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
mGOTypeList = mTheme->CreateDropDownList( mRPCont, eeSize( Width - 26, 21 ), eeVector2i( 0, Txt->Pos().y + Txt->Size().Height() + 4 ), UI_CONTROL_DEFAULT_ALIGN | UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
std::vector<String> items;
|
||||
items.push_back( "Shape" );
|
||||
items.push_back( "ShapeEx" );
|
||||
@@ -153,42 +159,99 @@ void cMapEditor::CreateETGMenu() {
|
||||
mGOTypeList->AddEventListener( cUIEvent::EventOnItemSelected, cb::Make1( this, &cMapEditor::OnTypeChange ) );
|
||||
mGOTypeList->ListBox()->SetSelected(0);
|
||||
|
||||
mBtnGOTypeAdd = mTheme->CreatePushButton( mWinContainer, eeSize( 24, 21 ), eeVector2i( mGOTypeList->Pos().x + mGOTypeList->Size().Width() + 2, mGOTypeList->Pos().y ), UI_CONTROL_DEFAULT_FLAGS_CENTERED | UI_AUTO_SIZE, mTheme->GetIconByName( "add" ) );
|
||||
mBtnGOTypeAdd = mTheme->CreatePushButton( mRPCont, eeSize( 24, 21 ), eeVector2i( mGOTypeList->Pos().x + mGOTypeList->Size().Width() + 2, mGOTypeList->Pos().y ), UI_CONTROL_ALIGN_CENTER | UI_AUTO_SIZE | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP, mTheme->GetIconByName( "add" ) );
|
||||
mBtnGOTypeAdd->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cMapEditor::AddNewGOType ) );
|
||||
|
||||
if ( NULL == mBtnGOTypeAdd->Icon()->Shape() )
|
||||
mBtnGOTypeAdd->Text( "..." );
|
||||
|
||||
Txt = mTheme->CreateTextBox( mWinContainer, eeSize( Width, 16 ), eeVector2i( mWinContainer->Size().Width() - Width - DistToBorder, mGOTypeList->Pos().y + mGOTypeList->Size().Height() + 4 ), TxtFlags );
|
||||
Txt = mTheme->CreateTextBox( mRPCont, eeSize( Width, 16 ), eeVector2i( 0, mGOTypeList->Pos().y + mGOTypeList->Size().Height() + 4 ), TxtFlags );
|
||||
Txt->Text( "Layers:" );
|
||||
|
||||
mLayerList = mTheme->CreateDropDownList( mWinContainer, eeSize( Width, 21 ), eeVector2i( mWinContainer->Size().Width() - Width - DistToBorder, Txt->Pos().y + Txt->Size().Height() + 4 ), UI_CONTROL_DEFAULT_ALIGN | UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
mLayerList = mTheme->CreateDropDownList( mRPCont, eeSize( Width, 21 ), eeVector2i( 0, Txt->Pos().y + Txt->Size().Height() + 4 ), UI_CONTROL_DEFAULT_ALIGN | UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
mLayerList->AddEventListener( cUIEvent::EventOnItemSelected, cb::Make1( this, &cMapEditor::OnLayerSelect ) );
|
||||
|
||||
Txt = mTheme->CreateTextBox( mWinContainer, eeSize( Width, 16 ), eeVector2i( mWinContainer->Size().Width() - Width - DistToBorder, mLayerList->Pos().y + mLayerList->Size().Height() + 4 ), TxtFlags );
|
||||
Txt = mTheme->CreateTextBox( mRPCont, eeSize( Width, 16 ), eeVector2i( 0, mLayerList->Pos().y + mLayerList->Size().Height() + 4 ), TxtFlags );
|
||||
Txt->Text( "Game Object Flags:" );
|
||||
|
||||
Uint32 ChkFlags = UI_CONTROL_DEFAULT_ALIGN | UI_AUTO_SIZE | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP;
|
||||
|
||||
mChkMirrored = mTheme->CreateCheckBox( mWinContainer, eeSize(), eeVector2i( mWinContainer->Size().Width() - Width - DistToBorder, Txt->Pos().y + Txt->Size().Height() + 4 ), ChkFlags );
|
||||
mChkMirrored = mTheme->CreateCheckBox( mRPCont, eeSize(), eeVector2i( 0, Txt->Pos().y + Txt->Size().Height() + 4 ), ChkFlags );
|
||||
mChkMirrored->Text( "Mirrored" );
|
||||
mChkMirrored->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cMapEditor::ChkClickMirrored ) );
|
||||
|
||||
mChkFliped = mTheme->CreateCheckBox( mWinContainer, eeSize(), eeVector2i( mChkMirrored->Pos().x + mChkMirrored->Size().Width() + 32, mChkMirrored->Pos().y ), ChkFlags );
|
||||
mChkFliped = mTheme->CreateCheckBox( mRPCont, eeSize(), eeVector2i( mChkMirrored->Pos().x + mChkMirrored->Size().Width() + 32, mChkMirrored->Pos().y ), ChkFlags );
|
||||
mChkFliped->Text( "Fliped" );
|
||||
mChkFliped->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cMapEditor::ChkClickFliped ) );
|
||||
|
||||
mChkBlocked = mTheme->CreateCheckBox( mWinContainer, eeSize(), eeVector2i( mChkMirrored->Pos().x, mChkMirrored->Pos().y + mChkMirrored->Size().Height() + 4 ), ChkFlags );
|
||||
mChkBlocked = mTheme->CreateCheckBox( mRPCont, eeSize(), eeVector2i( mChkMirrored->Pos().x, mChkMirrored->Pos().y + mChkMirrored->Size().Height() + 4 ), ChkFlags );
|
||||
mChkBlocked->Text( "Blocked" );
|
||||
mChkBlocked->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cMapEditor::ChkClickBlocked ) );
|
||||
|
||||
mChkAnim = mTheme->CreateCheckBox( mWinContainer, eeSize(), eeVector2i( mChkFliped->Pos().x, mChkFliped->Pos().y + mChkFliped->Size().Height() + 4 ), ChkFlags );
|
||||
mChkAnim = mTheme->CreateCheckBox( mRPCont, eeSize(), eeVector2i( mChkFliped->Pos().x, mChkFliped->Pos().y + mChkFliped->Size().Height() + 4 ), ChkFlags );
|
||||
mChkAnim->Text( "Animated" );
|
||||
mChkAnim->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cMapEditor::ChkClickAnimated ) );
|
||||
|
||||
Txt = mTheme->CreateTextBox( mRPCont, eeSize( Width, 16 ), eeVector2i( 0, mChkBlocked->Pos().y + mChkBlocked->Size().Height() + 8 ), TxtFlags );
|
||||
Txt->Text( "Game Object Data:" );
|
||||
|
||||
mChkDI = mTheme->CreateCheckBox( mRPCont, eeSize(), eeVector2i( 0, Txt->Pos().y + Txt->Size().Height() + 4 ), ChkFlags );
|
||||
mChkDI->Text( "Add as DataId" );
|
||||
mChkDI->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cMapEditor::ChkClickDI ) );
|
||||
|
||||
cUIComplexControl::CreateParams SGParams;
|
||||
SGParams.Parent( mRPCont );
|
||||
SGParams.PosSet( eeVector2i( 0, mChkDI->Pos().y + mChkDI->Size().Height() + 8 ) );
|
||||
SGParams.SizeSet( eeSize( Width, 400 ) );
|
||||
SGParams.Flags = UI_CONTROL_DEFAULT_ALIGN | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP;
|
||||
mSGCont = eeNew( cUIComplexControl, ( SGParams ) );
|
||||
mSGCont->Enabled( true );
|
||||
mSGCont->Visible( true );
|
||||
|
||||
Txt = mTheme->CreateTextBox( mSGCont, eeSize( Width, 16 ), eeVector2i( 0, 0 ), TxtFlags );
|
||||
Txt->Text( "Shape Groups:" );
|
||||
|
||||
mShapeGroupsList = mTheme->CreateDropDownList( mSGCont, eeSize( Width, 21 ), eeVector2i( 0, Txt->Pos().y +Txt->Size().Height() + 4 ), UI_CONTROL_DEFAULT_ALIGN | UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
mShapeGroupsList->AddEventListener( cUIEvent::EventOnItemSelected, cb::Make1( this, &cMapEditor::OnShapeGroupChange ) );
|
||||
|
||||
mShapeList = mTheme->CreateListBox( mSGCont, eeSize( Width, 156 ), eeVector2i( 0, mShapeGroupsList->Pos().y + mShapeGroupsList->Size().Height() + 4 ), UI_CONTROL_DEFAULT_ALIGN | UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
mShapeList->Size( mShapeList->Size().Width(), mShapeList->RowHeight() * 9 + mShapeList->PaddingContainer().Top + mShapeList->PaddingContainer().Bottom );
|
||||
mShapeList->AddEventListener( cUIEvent::EventOnItemSelected, cb::Make1( this, &cMapEditor::OnShapeChange ) );
|
||||
|
||||
mGfxPreview = mTheme->CreateGfx( NULL, mSGCont, eeSize( Width, Width ), eeVector2i( 0, mShapeList->Pos().y + mShapeList->Size().Height() + 4 ), UI_VALIGN_CENTER | UI_HALIGN_CENTER | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP | UI_AUTO_FIT );
|
||||
mGfxPreview->Border( true );
|
||||
|
||||
cUIComplexControl::CreateParams DIParams;
|
||||
DIParams.Parent( mRPCont );
|
||||
DIParams.PosSet( SGParams.Pos );
|
||||
DIParams.SizeSet( eeSize( Width, 400 ) );
|
||||
DIParams.Flags = UI_CONTROL_DEFAULT_ALIGN | UI_ANCHOR_RIGHT | UI_ANCHOR_TOP;
|
||||
mDICont = eeNew( cUIComplexControl, ( DIParams ) );
|
||||
mDICont->Enabled( false );
|
||||
mDICont->Visible( false );
|
||||
|
||||
Txt = mTheme->CreateTextBox( mDICont, eeSize( Width, 16 ), eeVector2i( 0, 0 ), TxtFlags );
|
||||
Txt->Text( "DataId String:" );
|
||||
|
||||
mDataIdInput = mTheme->CreateTextInput( mDICont, eeSize( Width / 4 * 3, 21 ), eeVector2i( 8, Txt->Pos().y + Txt->Size().Height() + 8 ), UI_CONTROL_DEFAULT_ALIGN | UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_AUTO_SIZE );
|
||||
|
||||
FillSGCombo();
|
||||
}
|
||||
|
||||
void cMapEditor::ChkClickDI( const cUIEvent * Event ) {
|
||||
if ( mChkDI->Active() ) {
|
||||
mSGCont->Enabled( false );
|
||||
mSGCont->Visible( false );
|
||||
mDICont->Enabled( true );
|
||||
mDICont->Visible( true );
|
||||
} else {
|
||||
mSGCont->Enabled( true );
|
||||
mSGCont->Visible( true );
|
||||
mDICont->Enabled( false );
|
||||
mDICont->Visible( false );
|
||||
}
|
||||
}
|
||||
|
||||
void cMapEditor::UpdateGfx() {
|
||||
if ( mChkMirrored->Active() && mChkFliped->Active() )
|
||||
mGfxPreview->RenderType( RN_FLIPMIRROR );
|
||||
@@ -224,10 +287,13 @@ void cMapEditor::OnTypeChange( const cUIEvent * Event ) {
|
||||
else if ( mGOTypeList->Text() == "Sprite" )
|
||||
mCurGOType = GAMEOBJECT_TYPE_SPRITE;
|
||||
else
|
||||
mCurGOType = MakeHash( mGOTypeList->Text() );
|
||||
mCurGOType = MakeHash( mGOTypeList->Text().ToUtf8() );
|
||||
|
||||
if ( NULL != mChkAnim && NULL != mGOTypeList && mChkAnim->Active() && mGOTypeList->Text() != "Sprite" )
|
||||
mChkAnim->Active( false );
|
||||
if ( NULL != mChkAnim && NULL != mGOTypeList && mChkAnim->Active() && mGOTypeList->Text() != "Sprite" ) {
|
||||
if ( mGOTypeList->Text() == "Shape" || mGOTypeList->Text() == "ShapeEx" ) {
|
||||
mChkAnim->Active( false );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cMapEditor::ChkClickMirrored( const cUIEvent * Event ) {
|
||||
@@ -247,7 +313,7 @@ void cMapEditor::ChkClickBlocked( const cUIEvent * Event ) {
|
||||
void cMapEditor::ChkClickAnimated( const cUIEvent * Event ) {
|
||||
UpdateFlags();
|
||||
|
||||
if ( mChkAnim->Active() ) {
|
||||
if ( mChkAnim->Active() && ( mGOTypeList->Text() == "Shape" || mGOTypeList->Text() == "ShapeEx" ) ) {
|
||||
mGOTypeList->ListBox()->SetSelected( "Sprite" );
|
||||
}
|
||||
}
|
||||
@@ -257,8 +323,17 @@ void cMapEditor::AddNewGOType( const cUIEvent * Event ) {
|
||||
}
|
||||
|
||||
void cMapEditor::OnNewGOTypeAdded( std::string name, Uint32 hash ) {
|
||||
if ( "" != name )
|
||||
if ( "" != name ) {
|
||||
for ( Uint32 i = 0; i < mGOTypeList->ListBox()->Count(); i++ ) {
|
||||
cUIListBoxItem * Item = mGOTypeList->ListBox()->GetItem(i);
|
||||
|
||||
if ( Item->Text() == name )
|
||||
return;
|
||||
}
|
||||
|
||||
mGOTypeList->ListBox()->AddListBoxItem( name );
|
||||
mUIMap->Map()->AddVirtualObjectType( name );
|
||||
}
|
||||
}
|
||||
|
||||
void cMapEditor::FillSGCombo() {
|
||||
@@ -301,10 +376,14 @@ void cMapEditor::FillShapeList() {
|
||||
}
|
||||
|
||||
if ( items.size() ) {
|
||||
std::sort( items.begin(), items.end() );
|
||||
|
||||
mShapeList->AddListBoxItems( items );
|
||||
mShapeList->SetSelected( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
mShapeList->VerticalScrollBar()->ClickStep( 8.f / (eeFloat)mShapeList->Count() );
|
||||
}
|
||||
|
||||
void cMapEditor::OnShapeChange( const cUIEvent * Event ) {
|
||||
@@ -346,6 +425,7 @@ void cMapEditor::CreateUIMap() {
|
||||
mUIMap->Map()->Create( eeSize( 100, 100 ), 16, eeSize( 32, 32 ), MAP_FLAG_DRAW_GRID | MAP_FLAG_CLAMP_BODERS | MAP_FLAG_CLIP_AREA, Params.Size );
|
||||
mUIMap->AddEventListener( cUIEvent::EventOnSizeChange, cb::Make1( this, &cMapEditor::OnMapSizeChange ) );
|
||||
mUIMap->AddEventListener( cUIEvent::EventMouseDown, cb::Make1( this, &cMapEditor::OnMapMouseDown ) );
|
||||
mUIMap->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cMapEditor::OnMapMouseClick ) );
|
||||
|
||||
mMapHScroll = mTheme->CreateScrollBar( mWinContainer, eeSize( Params.Size.Width(), 15 ), eeVector2i( 0, Params.Size.Height() ), UI_ANCHOR_LEFT | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM );
|
||||
mMapHScroll->AddEventListener( cUIEvent::EventOnValueChange, cb::Make1( this, &cMapEditor::OnScrollMapH ) );
|
||||
@@ -358,10 +438,10 @@ void cMapEditor::CreateUIMap() {
|
||||
|
||||
void cMapEditor::OnMapSizeChange( const cUIEvent *Event ) {
|
||||
mMapHScroll->MinValue( 0 );
|
||||
mMapHScroll->MaxValue( mUIMap->Map()->Size().Width() * mUIMap->Map()->TileSize().Width() - mUIMap->Size().Width() );
|
||||
mMapHScroll->MaxValue( mUIMap->Map()->TotalSize().Width() - mUIMap->Size().Width() );
|
||||
mMapHScroll->ClickStep( mUIMap->Map()->TileSize().Width() );
|
||||
mMapVScroll->MinValue( 0 );
|
||||
mMapVScroll->MaxValue( mUIMap->Map()->Size().Height() * mUIMap->Map()->TileSize().Height() - mUIMap->Size().Height() );
|
||||
mMapVScroll->MaxValue( mUIMap->Map()->TotalSize().Height() - mUIMap->Size().Height() );
|
||||
mMapVScroll->ClickStep( mUIMap->Map()->TileSize().Height() );
|
||||
}
|
||||
|
||||
@@ -408,6 +488,9 @@ void cMapEditor::FileMenuClick( const cUIEvent * Event ) {
|
||||
TGDialog->AddEventListener( cUIEvent::EventOpenFile, cb::Make1( this, &cMapEditor::MapOpen ) );
|
||||
TGDialog->Center();
|
||||
TGDialog->Show();
|
||||
} else if ( "Save" == txt ) {
|
||||
//! Testing, temporal!
|
||||
mUIMap->Map()->Save( GetProcessPath() + "data/test.eem" );
|
||||
} else if ( "Quit" == txt ) {
|
||||
if ( mUIWindow == cUIManager::instance()->MainControl() ) {
|
||||
cUIManager::instance()->GetWindow()->Close();
|
||||
@@ -429,6 +512,8 @@ void cMapEditor::ViewMenuClick( const cUIEvent * Event ) {
|
||||
|
||||
if ( "Show Grid" == txt ) {
|
||||
mUIMap->Map()->DrawGrid( reinterpret_cast<cUIMenuCheckBox*> ( Event->Ctrl() )->Active() );
|
||||
} else if ( "Mark Tile Over" == txt ) {
|
||||
mUIMap->Map()->DrawTileOver( reinterpret_cast<cUIMenuCheckBox*> ( Event->Ctrl() )->Active() );
|
||||
}
|
||||
}
|
||||
void cMapEditor::MapMenuClick( const cUIEvent * Event ) {
|
||||
@@ -457,6 +542,54 @@ void cMapEditor::LayerMenuClick( const cUIEvent * Event ) {
|
||||
eeNew( cUILayerNew, ( mUIMap, MAP_LAYER_TILED, cb::Make1( this, &cMapEditor::OnLayerAdd ) ) );
|
||||
} else if ( "Add Object Layer..." == txt ) {
|
||||
eeNew( cUILayerNew, ( mUIMap, MAP_LAYER_OBJECT, cb::Make1( this, &cMapEditor::OnLayerAdd ) ) );
|
||||
} else if ( "Remove Layer" == txt ) {
|
||||
RemoveLayer();
|
||||
} else if ( "Move Layer Up" == txt ) {
|
||||
MoveLayerUp();
|
||||
} else if ( "Move Layer Down" == txt ) {
|
||||
MoveLayerDown();
|
||||
}
|
||||
}
|
||||
|
||||
void cMapEditor::MoveLayerUp() {
|
||||
if ( mUIMap->Map()->MoveLayerUp( mCurLayer ) ) {
|
||||
RefreshLayersList();
|
||||
}
|
||||
}
|
||||
|
||||
void cMapEditor::MoveLayerDown() {
|
||||
if ( mUIMap->Map()->MoveLayerDown( mCurLayer ) ) {
|
||||
RefreshLayersList();
|
||||
}
|
||||
}
|
||||
|
||||
void cMapEditor::RemoveLayer() {
|
||||
if ( mUIMap->Map()->RemoveLayer( mCurLayer ) ) {
|
||||
mCurLayer = NULL;
|
||||
|
||||
RefreshLayersList();
|
||||
}
|
||||
}
|
||||
|
||||
void cMapEditor::RefreshLayersList() {
|
||||
mLayerList->ListBox()->Clear();
|
||||
|
||||
if ( mUIMap->Map()->LayerCount() ) {
|
||||
std::vector<String> layers;
|
||||
|
||||
for ( Uint32 i = 0; i < mUIMap->Map()->LayerCount(); i++ ) {
|
||||
layers.push_back( mUIMap->Map()->GetLayer(i)->Name() );
|
||||
}
|
||||
|
||||
mLayerList->ListBox()->AddListBoxItems( layers );
|
||||
}
|
||||
|
||||
if ( NULL != mCurLayer ) {
|
||||
mLayerList->ListBox()->SetSelected( mCurLayer->Name() );
|
||||
} else {
|
||||
if ( mUIMap->Map()->LayerCount() ) {
|
||||
mLayerList->ListBox()->SetSelected(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -525,7 +658,11 @@ cGameObject * cMapEditor::CreateGameObject() {
|
||||
}
|
||||
} else {
|
||||
//! Creates an empty game object. The client will interpret the GameObject Type, and instanciate the corresponding class.
|
||||
tObj = eeNew( cGameObject, ( mCurGOFlags ) );
|
||||
|
||||
if ( mChkDI->Active() )
|
||||
tObj = eeNew( cGameObjectVirtual, ( MakeHash( mDataIdInput->Text().ToUtf8() ), mCurGOFlags, mCurGOType ) );
|
||||
else
|
||||
tObj = eeNew( cGameObjectVirtual, ( mGfxPreview->Shape(), mCurGOFlags, mCurGOType ) );
|
||||
}
|
||||
|
||||
return tObj;
|
||||
@@ -536,8 +673,12 @@ void cMapEditor::AddGameObjectToTile() {
|
||||
cMap * tMap = mUIMap->Map();
|
||||
cGameObject * tObj = CreateGameObject();
|
||||
|
||||
if ( NULL != tObj )
|
||||
if ( NULL != tObj ) {
|
||||
if ( tObj->Type() == GAMEOBJECT_TYPE_VIRTUAL )
|
||||
reinterpret_cast<cGameObjectVirtual*> ( tObj )->SetLayer( tLayer );
|
||||
|
||||
tLayer->AddGameObject( tObj, tMap->GetMouseTilePos() );
|
||||
}
|
||||
}
|
||||
|
||||
void cMapEditor::RemoveGameObjectFromTile() {
|
||||
@@ -547,6 +688,44 @@ void cMapEditor::RemoveGameObjectFromTile() {
|
||||
tLayer->RemoveGameObject( tMap->GetMouseTilePos() );
|
||||
}
|
||||
|
||||
void cMapEditor::AddGameObject() {
|
||||
cObjectLayer * tLayer = reinterpret_cast<cObjectLayer*> ( mCurLayer );
|
||||
cMap * tMap = mUIMap->Map();
|
||||
cGameObject * tObj = CreateGameObject();
|
||||
|
||||
if ( NULL != tObj ) {
|
||||
if ( tObj->Type() == GAMEOBJECT_TYPE_VIRTUAL )
|
||||
reinterpret_cast<cGameObjectVirtual*> ( tObj )->SetLayer( tLayer );
|
||||
|
||||
eeVector2i p( tMap->GetMouseMapPos() );
|
||||
|
||||
tObj->Pos( eeVector2f( p.x, p.y ) );
|
||||
tLayer->AddGameObject( tObj );
|
||||
}
|
||||
}
|
||||
|
||||
void cMapEditor::RemoveGameObject() {
|
||||
cObjectLayer * tLayer = reinterpret_cast<cObjectLayer*> ( mCurLayer );
|
||||
cMap * tMap = mUIMap->Map();
|
||||
|
||||
tLayer->RemoveGameObject( tMap->GetMouseMapPos() );
|
||||
}
|
||||
|
||||
void cMapEditor::OnMapMouseClick( const cUIEvent * Event ) {
|
||||
const cUIEventMouse * MEvent = reinterpret_cast<const cUIEventMouse*> ( Event );
|
||||
|
||||
if ( NULL == mCurLayer || NULL == mGfxPreview->Shape() || cUIManager::instance()->DownControl() != mUIMap )
|
||||
return;
|
||||
|
||||
if ( MEvent->Flags() & EE_BUTTON_LMASK ) {
|
||||
if ( mCurLayer->Type() == MAP_LAYER_OBJECT )
|
||||
AddGameObject();
|
||||
} else if ( MEvent->Flags() & EE_BUTTON_RMASK ) {
|
||||
if ( mCurLayer->Type() == MAP_LAYER_OBJECT )
|
||||
RemoveGameObject();
|
||||
}
|
||||
}
|
||||
|
||||
void cMapEditor::OnMapMouseDown( const cUIEvent * Event ) {
|
||||
const cUIEventMouse * MEvent = reinterpret_cast<const cUIEventMouse*> ( Event );
|
||||
|
||||
|
||||
@@ -43,6 +43,11 @@ class cMapEditor {
|
||||
cUIPushButton * mBtnGOTypeAdd;
|
||||
Uint32 mCurGOType;
|
||||
Uint32 mCurGOFlags;
|
||||
cUIComplexControl * mRPCont;
|
||||
cUIComplexControl * mSGCont;
|
||||
cUIComplexControl * mDICont;
|
||||
cUICheckBox * mChkDI;
|
||||
cUITextInput * mDataIdInput;
|
||||
|
||||
void WindowClose( const cUIEvent * Event );
|
||||
|
||||
@@ -98,8 +103,12 @@ class cMapEditor {
|
||||
|
||||
void ChkClickAnimated( const cUIEvent * Event );
|
||||
|
||||
void ChkClickDI( const cUIEvent * Event );
|
||||
|
||||
void OnMapMouseDown( const cUIEvent * Event );
|
||||
|
||||
void OnMapMouseClick( const cUIEvent * Event );
|
||||
|
||||
void OnLayerAdd( cUILayerNew * UILayer );
|
||||
|
||||
void AddNewGOType( const cUIEvent * Event );
|
||||
@@ -114,7 +123,19 @@ class cMapEditor {
|
||||
|
||||
void RemoveGameObjectFromTile();
|
||||
|
||||
void AddGameObject();
|
||||
|
||||
void RemoveGameObject();
|
||||
|
||||
cGameObject * CreateGameObject();
|
||||
|
||||
void MoveLayerUp();
|
||||
|
||||
void MoveLayerDown();
|
||||
|
||||
void RemoveLayer();
|
||||
|
||||
void RefreshLayersList();
|
||||
};
|
||||
|
||||
}}}
|
||||
|
||||
@@ -15,11 +15,11 @@ class GObjFlags {
|
||||
};
|
||||
|
||||
enum EE_GAMEOBJECT_TYPE {
|
||||
GAMEOBJECT_TYPE_BASE,
|
||||
GAMEOBJECT_TYPE_SHAPE,
|
||||
GAMEOBJECT_TYPE_SHAPEEX,
|
||||
GAMEOBJECT_TYPE_SPRITE,
|
||||
GAMEOBJECT_TYPE_USER = 10
|
||||
GAMEOBJECT_TYPE_BASE = 236430550u, //MakeHash( "Base" ),
|
||||
GAMEOBJECT_TYPE_VIRTUAL = 4069800883u, //MakeHash( "Virtual" ),
|
||||
GAMEOBJECT_TYPE_SHAPE = 3517332124u, //MakeHash( "Shape" ),
|
||||
GAMEOBJECT_TYPE_SHAPEEX = 3708695628u, //MakeHash( "ShapeEx" ),
|
||||
GAMEOBJECT_TYPE_SPRITE = 2088954976u //MakeHash( "Sprite" )
|
||||
};
|
||||
|
||||
enum EE_LAYER_TYPE {
|
||||
@@ -30,7 +30,8 @@ enum EE_LAYER_TYPE {
|
||||
enum EE_MAP_FLAGS {
|
||||
MAP_FLAG_CLAMP_BODERS = ( 1 << 0 ),
|
||||
MAP_FLAG_CLIP_AREA = ( 1 << 1 ),
|
||||
MAP_FLAG_DRAW_GRID = ( 1 << 2 )
|
||||
MAP_FLAG_DRAW_GRID = ( 1 << 2 ),
|
||||
MAP_FLAG_DRAW_TILE_OVER = ( 1 << 3 )
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -41,17 +41,19 @@ cShader::cShader( const Uint32& Type, const char * Data, const Uint32& DataSize
|
||||
}
|
||||
|
||||
cShader::cShader( const Uint32& Type, cPack * Pack, const std::string& Filename ) {
|
||||
cPack::PointerData PData;
|
||||
|
||||
Init( Type );
|
||||
|
||||
if ( NULL != Pack && Pack->IsOpen() && -1 != Pack->Exists( Filename ) ) {
|
||||
std::vector<Uint8> TempData;
|
||||
Pack->ExtractFileToMemory( Filename, PData );
|
||||
|
||||
Pack->ExtractFileToMemory( Filename, TempData );
|
||||
|
||||
SetSource( reinterpret_cast<char*> ( &TempData[0] ), (Uint32)TempData.size() );
|
||||
SetSource( reinterpret_cast<char*> ( PData.Data ), PData.DataSize );
|
||||
}
|
||||
|
||||
Compile();
|
||||
|
||||
eeSAFE_DELETE( PData.Data );
|
||||
}
|
||||
|
||||
cShader::cShader( const Uint32& Type, const char ** Data, const Uint32& NumLines ) {
|
||||
|
||||
@@ -66,7 +66,7 @@ cShape::cShape( const Uint32& TexId, const eeRecti& SrcRect, const eeFloat& Dest
|
||||
CreateUnnamed();
|
||||
}
|
||||
|
||||
cShape::cShape( const Uint32& TexId, const eeRecti& SrcRect, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeFloat& OffsetX, const eeFloat& OffsetY, const std::string& Name ) :
|
||||
cShape::cShape( const Uint32& TexId, const eeRecti& SrcRect, const eeFloat& DestWidth, const eeFloat& DestHeight, const Int32& OffsetX, const Int32& OffsetY, const std::string& Name ) :
|
||||
mPixels(NULL),
|
||||
mAlpha(NULL),
|
||||
mName( Name ),
|
||||
@@ -143,19 +143,19 @@ void cShape::DestHeight( const eeFloat& height ) {
|
||||
mDestHeight = height;
|
||||
}
|
||||
|
||||
const eeFloat& cShape::OffsetX() const {
|
||||
const Int32& cShape::OffsetX() const {
|
||||
return mOffSetX;
|
||||
}
|
||||
|
||||
void cShape::OffsetX( const eeFloat& offsetx ) {
|
||||
void cShape::OffsetX( const Int32& offsetx ) {
|
||||
mOffSetX = offsetx;
|
||||
}
|
||||
|
||||
const eeFloat& cShape::OffsetY() const {
|
||||
const Int32& cShape::OffsetY() const {
|
||||
return mOffSetY;
|
||||
}
|
||||
|
||||
void cShape::OffsetY( const eeFloat& offsety ) {
|
||||
void cShape::OffsetY( const Int32& offsety ) {
|
||||
mOffSetY = offsety;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class EE_API cShape {
|
||||
|
||||
cShape( const Uint32& TexId, const eeRecti& SrcRect, const eeFloat& DestWidth, const eeFloat& DestHeight, const std::string& Name = "" );
|
||||
|
||||
cShape( const Uint32& TexId, const eeRecti& SrcRect, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeFloat& OffsetX, const eeFloat& OffsetY, const std::string& Name = "" );
|
||||
cShape( const Uint32& TexId, const eeRecti& SrcRect, const eeFloat& DestWidth, const eeFloat& DestHeight, const Int32& OffsetX, const Int32& OffsetY, const std::string& Name = "" );
|
||||
|
||||
~cShape();
|
||||
|
||||
@@ -43,13 +43,13 @@ class EE_API cShape {
|
||||
|
||||
void DestHeight( const eeFloat& height );
|
||||
|
||||
const eeFloat& OffsetX() const;
|
||||
const Int32& OffsetX() const;
|
||||
|
||||
void OffsetX( const eeFloat& offsetx );
|
||||
void OffsetX( const Int32& offsetx );
|
||||
|
||||
const eeFloat& OffsetY() const;
|
||||
const Int32& OffsetY() const;
|
||||
|
||||
void OffsetY( const eeFloat& offsety );
|
||||
void OffsetY( const Int32& offsety );
|
||||
|
||||
void Draw( const eeFloat& X, const eeFloat& Y, const eeColorA& Color = eeColorA(), const eeFloat& Angle = 0.f, const eeFloat& Scale = 1.f, const EE_PRE_BLEND_FUNC& Blend = ALPHA_NORMAL, const EE_RENDERTYPE& Effect = RN_NORMAL, const bool& ScaleRendered = true );
|
||||
|
||||
@@ -100,8 +100,8 @@ class EE_API cShape {
|
||||
eeRecti mSrcRect;
|
||||
eeFloat mDestWidth;
|
||||
eeFloat mDestHeight;
|
||||
eeFloat mOffSetX;
|
||||
eeFloat mOffSetY;
|
||||
Int32 mOffSetX;
|
||||
Int32 mOffSetY;
|
||||
|
||||
void CreateUnnamed();
|
||||
};
|
||||
|
||||
@@ -20,6 +20,14 @@ void cShapeGroup::Name( const std::string& name ) {
|
||||
mId = MakeHash( mName );
|
||||
}
|
||||
|
||||
const std::string& cShapeGroup::Path() const {
|
||||
return mPath;
|
||||
}
|
||||
|
||||
void cShapeGroup::Path( const std::string& path ) {
|
||||
mPath = path;
|
||||
}
|
||||
|
||||
const Uint32& cShapeGroup::Id() const {
|
||||
return mId;
|
||||
}
|
||||
|
||||
@@ -28,12 +28,17 @@ class EE_API cShapeGroup : public tResourceManager<cShape> {
|
||||
|
||||
void Name( const std::string& name );
|
||||
|
||||
const std::string& Path() const;
|
||||
|
||||
void Path( const std::string& path );
|
||||
|
||||
const Uint32& Id() const;
|
||||
|
||||
Uint32 Count();
|
||||
protected:
|
||||
std::string mName;
|
||||
Uint32 mId;
|
||||
std::string mPath;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -45,6 +45,27 @@ void cShapeGroupManager::PrintResources() {
|
||||
(*it)->PrintNames();
|
||||
}
|
||||
|
||||
std::vector<cShape*> cShapeGroupManager::GetShapesByPatternId( const Uint32& ShapeId, const std::string& extension, cShapeGroup * SearchInShapeGroup ) {
|
||||
cShape * tShape = NULL;
|
||||
std::string tName;
|
||||
|
||||
if ( NULL == SearchInShapeGroup )
|
||||
tShape = GetShapeById( ShapeId );
|
||||
else
|
||||
tShape = SearchInShapeGroup->GetById( ShapeId );
|
||||
|
||||
if ( NULL != tShape ) {
|
||||
if ( extension.size() )
|
||||
tName = RemoveNumbersAtEnd( FileRemoveExtension( tShape->Name() ) ) + extension;
|
||||
else
|
||||
tName = tShape->Name();
|
||||
|
||||
return GetShapesByPattern( RemoveNumbersAtEnd( tShape->Name() ), "", SearchInShapeGroup );
|
||||
}
|
||||
|
||||
return std::vector<cShape*>();
|
||||
}
|
||||
|
||||
std::vector<cShape*> cShapeGroupManager::GetShapesByPattern( const std::string& name, const std::string& extension, cShapeGroup * SearchInShapeGroup ) {
|
||||
std::vector<cShape*> Shapes;
|
||||
std::string search;
|
||||
|
||||
@@ -26,6 +26,8 @@ class EE_API cShapeGroupManager : public tResourceManager<cShapeGroup>, public t
|
||||
*/
|
||||
std::vector<cShape*> GetShapesByPattern( const std::string& name, const std::string& extension = "", cShapeGroup * SearchInShapeGroup = NULL );
|
||||
|
||||
std::vector<cShape*> GetShapesByPatternId( const Uint32& ShapeId, const std::string& extension = "", cShapeGroup * SearchInShapeGroup = NULL );
|
||||
|
||||
void PrintResources();
|
||||
};
|
||||
|
||||
|
||||
@@ -355,6 +355,18 @@ bool cSprite::AddFrames( const std::vector<cShape*> Shapes ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cSprite::AddFramesByPatternId( const Uint32& ShapeId, const std::string& extension, cShapeGroup * SearchInShapeGroup ) {
|
||||
std::vector<cShape*> Shapes = cShapeGroupManager::instance()->GetShapesByPatternId( ShapeId, extension, SearchInShapeGroup );
|
||||
|
||||
if ( Shapes.size() ) {
|
||||
AddFrames( Shapes );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cSprite::AddFramesByPattern( const std::string& name, const std::string& extension, cShapeGroup * SearchInShapeGroup ) {
|
||||
std::vector<cShape*> Shapes = cShapeGroupManager::instance()->GetShapesByPattern( name, extension, SearchInShapeGroup );
|
||||
|
||||
@@ -405,7 +417,7 @@ eeUint cSprite::AddFrame(const Uint32& TexId, const eeFloat& DestWidth, const ee
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool cSprite::AddSubFrame(const Uint32& TexId, const eeUint& NumFrame, const eeUint& NumSubFrame, const eeFloat& DestWidth, const eeFloat& DestHeight, const eeFloat& offSetX, const eeFloat& offSetY, const eeRecti& TexSector) {
|
||||
bool cSprite::AddSubFrame(const Uint32& TexId, const eeUint& NumFrame, const eeUint& NumSubFrame, const eeFloat& DestWidth, const eeFloat& DestHeight, const Int32& offSetX, const Int32& offSetY, const eeRecti& TexSector) {
|
||||
if ( !cTextureFactory::instance()->TextureIdExists( TexId ) )
|
||||
return false;
|
||||
|
||||
@@ -580,39 +592,39 @@ eeUint cSprite::GetSubFrame( const eeUint& SubFrame ) {
|
||||
return SFN;
|
||||
}
|
||||
|
||||
eeFloat cSprite::OffSetX() {
|
||||
Int32 cSprite::OffSetX() {
|
||||
cShape* S = GetCurrentShape();
|
||||
|
||||
if ( S != NULL )
|
||||
return S->OffsetX();
|
||||
|
||||
return 0.0f;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cSprite::OffSetX( const eeFloat& offsetx ) {
|
||||
void cSprite::OffSetX( const Int32& offsetx ) {
|
||||
cShape* S = GetCurrentShape();
|
||||
|
||||
if ( S != NULL )
|
||||
S->OffsetX( offsetx );
|
||||
}
|
||||
|
||||
eeFloat cSprite::OffSetY() {
|
||||
Int32 cSprite::OffSetY() {
|
||||
cShape* S = GetCurrentShape();
|
||||
|
||||
if ( S != NULL )
|
||||
return S->OffsetY();
|
||||
|
||||
return 0.0f;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cSprite::OffSetY( const eeFloat& offsety ) {
|
||||
void cSprite::OffSetY( const Int32& offsety ) {
|
||||
cShape* S = GetCurrentShape();
|
||||
|
||||
if ( S != NULL )
|
||||
S->OffsetY( offsety );
|
||||
}
|
||||
|
||||
void cSprite::OffSet( const eeVector2f& offset ) {
|
||||
void cSprite::OffSet( const eeVector2i& offset ) {
|
||||
cShape* S = GetCurrentShape();
|
||||
|
||||
if ( S != NULL ) {
|
||||
|
||||
@@ -222,6 +222,8 @@ class EE_API cSprite {
|
||||
/** @see cShapeGroupManager::GetShapesByPattern */
|
||||
bool AddFramesByPattern( const std::string& name, const std::string& extension = "", cShapeGroup * SearchInShapeGroup = NULL );
|
||||
|
||||
bool AddFramesByPatternId( const Uint32& ShapeId, const std::string& extension, cShapeGroup * SearchInShapeGroup );
|
||||
|
||||
/** Add a frame on an specific subframe to the sprite
|
||||
* @param TexId The internal Texture Id
|
||||
* @param NumFrame The Frame Number
|
||||
@@ -233,7 +235,7 @@ class EE_API cSprite {
|
||||
* @param TexSector The texture sector to be rendered ( default all the texture )
|
||||
* @return True if success
|
||||
*/
|
||||
bool AddSubFrame( const Uint32& TexId, const eeUint& NumFrame, const eeUint& NumSubFrame, const eeFloat& DestWidth = 0, const eeFloat& DestHeight = 0, const eeFloat& offSetX = 0, const eeFloat& offSetY = 0, const eeRecti& TexSector = eeRecti(0,0,0,0) );
|
||||
bool AddSubFrame( const Uint32& TexId, const eeUint& NumFrame, const eeUint& NumSubFrame, const eeFloat& DestWidth = 0, const eeFloat& DestHeight = 0, const Int32& offSetX = 0, const Int32& offSetY = 0, const eeRecti& TexSector = eeRecti(0,0,0,0) );
|
||||
|
||||
/** Add a frame on an specific subframe to the sprite
|
||||
* @param Shape The Shape used in the frame
|
||||
@@ -280,19 +282,19 @@ class EE_API cSprite {
|
||||
eeQuad2f GetQuad();
|
||||
|
||||
/** @return The OffSetX of the current frame */
|
||||
eeFloat OffSetX();
|
||||
Int32 OffSetX();
|
||||
|
||||
/** Set the OffSetX of the current frame */
|
||||
void OffSetX( const eeFloat& offsetx );
|
||||
void OffSetX( const Int32& offsetx );
|
||||
|
||||
/** @return The OffSetY of the current frame */
|
||||
eeFloat OffSetY();
|
||||
Int32 OffSetY();
|
||||
|
||||
/** Set the OffSetY of the current frame */
|
||||
void OffSetY( const eeFloat& offsety );
|
||||
void OffSetY( const Int32& offsety );
|
||||
|
||||
/** Set the OffSet of the current frame */
|
||||
void OffSet( const eeVector2f& offset );
|
||||
void OffSet( const eeVector2i& offset );
|
||||
|
||||
/** Reverse the animation from last frame to first mFrames. */
|
||||
void ReverseAnim( const bool& Reverse );
|
||||
|
||||
@@ -137,12 +137,15 @@ bool cTextureFont::Load( const Uint32& TexId, const std::string& CoordinatesDatP
|
||||
}
|
||||
|
||||
bool cTextureFont::LoadFromPack( const Uint32& TexId, cPack* Pack, const std::string& FilePackPath, const bool& VerticalDraw ) {
|
||||
std::vector<Uint8> TmpData;
|
||||
bool Ret = false;
|
||||
cPack::PointerData PData;
|
||||
|
||||
if ( Pack->IsOpen() && Pack->ExtractFileToMemory( FilePackPath, TmpData ) )
|
||||
return LoadFromMemory( TexId, reinterpret_cast<const Uint8*> (&TmpData[0]), (Uint32)TmpData.size(), VerticalDraw );
|
||||
if ( Pack->IsOpen() && Pack->ExtractFileToMemory( FilePackPath, PData ) )
|
||||
Ret = LoadFromMemory( TexId, reinterpret_cast<const Uint8*> ( PData.Data ), PData.DataSize, VerticalDraw );
|
||||
|
||||
return false;
|
||||
eeSAFE_DELETE( PData.Data );
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
bool cTextureFont::LoadFromMemory( const Uint32& TexId, const Uint8* CoordData, const Uint32& CoordDataSize, const bool& VerticalDraw ) {
|
||||
|
||||
@@ -113,11 +113,13 @@ void cTextureGroupLoader::LoadFromPack( cPack * Pack, const std::string& FilePac
|
||||
if ( NULL != Pack && Pack->IsOpen() && -1 != Pack->Exists( FilePackPath ) ) {
|
||||
mPack = Pack;
|
||||
|
||||
std::vector<Uint8> TempData;
|
||||
cPack::PointerData PData;
|
||||
|
||||
Pack->ExtractFileToMemory( FilePackPath, TempData );
|
||||
Pack->ExtractFileToMemory( FilePackPath, PData );
|
||||
|
||||
LoadFromMemory( reinterpret_cast<const Uint8*> ( &TempData[0] ), (Uint32)TempData.size(), FilePackPath );
|
||||
LoadFromMemory( reinterpret_cast<const Uint8*> ( PData.Data ), PData.DataSize, FilePackPath );
|
||||
|
||||
eeSAFE_DELETE( PData.Data );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,6 +199,11 @@ void cTextureGroupLoader::CreateShapes() {
|
||||
name = FileRemoveExtension( name );
|
||||
|
||||
mShapeGroup = eeNew( cShapeGroup, ( name ) );
|
||||
|
||||
std::string etgpath = FileRemoveExtension( path ) + ".etg";
|
||||
|
||||
mShapeGroup->Path( etgpath );
|
||||
|
||||
cShapeGroupManager::instance()->Add( mShapeGroup );
|
||||
}
|
||||
|
||||
@@ -211,7 +218,7 @@ void cTextureGroupLoader::CreateShapes() {
|
||||
|
||||
eeRecti tRect( tSh->X, tSh->Y, tSh->X + tSh->Width, tSh->Y + tSh->Height );
|
||||
|
||||
cShape * tShape = eeNew( cShape, ( tTex->Id(), tRect, (eeFloat)tSh->DestWidth, (eeFloat)tSh->DestHeight, (eeFloat)tSh->OffsetX, (eeFloat)tSh->OffsetY, ShapeName ) );
|
||||
cShape * tShape = eeNew( cShape, ( tTex->Id(), tRect, (eeFloat)tSh->DestWidth, (eeFloat)tSh->DestHeight, tSh->OffsetX, tSh->OffsetY, ShapeName ) );
|
||||
|
||||
//if ( tSh->Flags & HDR_SHAPE_FLAG_FLIPED )
|
||||
// Should rotate the shape, but.. shape rotation is not stored.
|
||||
|
||||
@@ -172,14 +172,16 @@ void cTextureLoader::LoadFromPath() {
|
||||
}
|
||||
|
||||
void cTextureLoader::LoadFromPack() {
|
||||
std::vector<Uint8> TmpData;
|
||||
cPack::PointerData PData;
|
||||
|
||||
if ( NULL != mPack && mPack->IsOpen() && mPack->ExtractFileToMemory( mFilepath, TmpData ) ) {
|
||||
mImagePtr = reinterpret_cast<const Uint8*> (&TmpData[0]);
|
||||
mSize = (Uint32)TmpData.size();
|
||||
if ( NULL != mPack && mPack->IsOpen() && mPack->ExtractFileToMemory( mFilepath, PData ) ) {
|
||||
mImagePtr = PData.Data;
|
||||
mSize = PData.DataSize;
|
||||
|
||||
LoadFromMemory();
|
||||
}
|
||||
|
||||
eeSAFE_DELETE( PData.Data );
|
||||
}
|
||||
|
||||
void cTextureLoader::LoadFromMemory() {
|
||||
|
||||
@@ -11,39 +11,55 @@ class cTexturePackerTex {
|
||||
|
||||
void Place( Int32 x, Int32 y, bool flipped );
|
||||
|
||||
inline const std::string& Name() const { return mName; }
|
||||
inline const std::string& Name() const { return mName; }
|
||||
|
||||
inline const Int32& X() const { return mX; }
|
||||
inline const Int32& X() const { return mX; }
|
||||
|
||||
inline const Int32& Y() const { return mY; }
|
||||
inline const Int32& Y() const { return mY; }
|
||||
|
||||
inline const Int32& Channels() { return mChannels; }
|
||||
inline const Int32& Channels() { return mChannels; }
|
||||
|
||||
inline void X( const Int32& x ) { mX = x; }
|
||||
inline void X( const Int32& x ) { mX = x; }
|
||||
|
||||
inline void Y( const Int32& y ) { mY = y; }
|
||||
inline void Y( const Int32& y ) { mY = y; }
|
||||
|
||||
inline const Int32& Width() const { return mWidth; }
|
||||
inline const Int32& Width() const { return mWidth; }
|
||||
|
||||
inline const Int32& Height() const { return mHeight; }
|
||||
inline const Int32& Height() const { return mHeight; }
|
||||
|
||||
inline void Width( const Int32& W ) { mWidth = W; }
|
||||
inline void Width( const Int32& W ) { mWidth = W; }
|
||||
|
||||
inline void Height( const Int32& H ) { mHeight = H; }
|
||||
inline void Height( const Int32& H ) { mHeight = H; }
|
||||
|
||||
inline const bool& LoadedInfo() const { return mLoadedInfo; }
|
||||
inline const bool& LoadedInfo() const { return mLoadedInfo; }
|
||||
|
||||
inline const Int32& Area() const { return mArea; }
|
||||
inline const Int32& Area() const { return mArea; }
|
||||
|
||||
inline const bool& Placed() const { return mPlaced; }
|
||||
inline const bool& Placed() const { return mPlaced; }
|
||||
|
||||
inline const bool& Flipped() const { return mFlipped; }
|
||||
inline const bool& Flipped() const { return mFlipped; }
|
||||
|
||||
inline const Int32& LongestEdge() const { return mLongestEdge; }
|
||||
inline const Int32& LongestEdge() const { return mLongestEdge; }
|
||||
|
||||
inline const bool& Disabled() const { return mDisabled; }
|
||||
inline const bool& Disabled() const { return mDisabled; }
|
||||
|
||||
inline void Disabled( const bool& d ) { mDisabled = d; }
|
||||
inline void Disabled( const bool& d ) { mDisabled = d; }
|
||||
|
||||
inline const Int32& DestWidth() const { return mDestWidth; }
|
||||
|
||||
inline const Int32& DestHeight() const { return mDestHeight; }
|
||||
|
||||
inline void DestWidth( const Int32& W ) { mDestWidth = W; }
|
||||
|
||||
inline void DestHeight( const Int32& H ){ mDestHeight = H; }
|
||||
|
||||
inline const Int32& OffsetX() const { return mOffsetX; }
|
||||
|
||||
inline const Int32& OffsetY() const { return mOffsetY; }
|
||||
|
||||
inline void OffsetX( const Int32& offx ){ mOffsetX = offx; }
|
||||
|
||||
inline void OffsetY( const Int32& offy ){ mDestHeight = offy; }
|
||||
protected:
|
||||
std::string mName;
|
||||
Int32 mWidth;
|
||||
@@ -53,6 +69,10 @@ class cTexturePackerTex {
|
||||
Int32 mY;
|
||||
Int32 mLongestEdge;
|
||||
Int32 mArea;
|
||||
Int32 mDestWidth;
|
||||
Int32 mDestHeight;
|
||||
Int32 mOffsetX;
|
||||
Int32 mOffsetY;
|
||||
bool mFlipped;
|
||||
bool mPlaced;
|
||||
bool mLoadedInfo;
|
||||
|
||||
@@ -16,17 +16,18 @@ cTTFFont::~cTTFFont() {
|
||||
}
|
||||
|
||||
bool cTTFFont::LoadFromPack( cPack* Pack, const std::string& FilePackPath, const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& VerticalDraw, const Uint16& NumCharsToGen, const eeColor& FontColor, const Uint8& OutlineSize, const eeColor& OutlineColor, const bool& AddPixelSeparator ) {
|
||||
std::vector<Uint8> TmpData;
|
||||
bool Ret = false;
|
||||
cPack::PointerData PData;
|
||||
|
||||
if ( Pack->IsOpen() && Pack->ExtractFileToMemory( FilePackPath, TmpData ) ) {
|
||||
if ( Pack->IsOpen() && Pack->ExtractFileToMemory( FilePackPath, PData ) ) {
|
||||
mFilepath = FilePackPath;
|
||||
|
||||
return LoadFromMemory( reinterpret_cast<Uint8*> (&TmpData[0]), (eeUint)TmpData.size(), Size, Style, VerticalDraw, NumCharsToGen, FontColor, OutlineSize, OutlineColor, AddPixelSeparator );
|
||||
Ret = LoadFromMemory( PData.Data, PData.DataSize, Size, Style, VerticalDraw, NumCharsToGen, FontColor, OutlineSize, OutlineColor, AddPixelSeparator );
|
||||
}
|
||||
|
||||
TmpData.clear();
|
||||
eeSAFE_DELETE( PData.Data );
|
||||
|
||||
return false;
|
||||
return Ret;
|
||||
}
|
||||
|
||||
bool cTTFFont::LoadFromMemory( Uint8* TTFData, const eeUint& TTFDataSize, const eeUint& Size, EE_TTF_FONTSTYLE Style, const bool& VerticalDraw, const Uint16& NumCharsToGen, const eeColor& FontColor, const Uint8& OutlineSize, const eeColor& OutlineColor, const bool& AddPixelSeparator ) {
|
||||
|
||||
@@ -9,6 +9,13 @@ namespace EE { namespace System {
|
||||
/** @brief Base class for al packing classes */
|
||||
class EE_API cPack : protected cMutex {
|
||||
public:
|
||||
class PointerData {
|
||||
public:
|
||||
PointerData() : Data( NULL ), DataSize( 0 ) {}
|
||||
Uint8 * Data;
|
||||
Uint32 DataSize;
|
||||
};
|
||||
|
||||
cPack();
|
||||
|
||||
virtual ~cPack();
|
||||
@@ -51,7 +58,7 @@ class EE_API cPack : protected cMutex {
|
||||
virtual bool ExtractFileToMemory( const std::string& path, std::vector<Uint8>& data ) = 0;
|
||||
|
||||
/** Extract a file to memory from the pack file */
|
||||
virtual bool ExtractFileToMemory( const std::string& path, Uint8** data, Uint32* dataSize ) = 0;
|
||||
virtual bool ExtractFileToMemory( const std::string& path, PointerData& data ) = 0;
|
||||
|
||||
/** Check if a file exists in the pack file and return the number of the file, otherwise return -1. */
|
||||
virtual Int32 Exists( const std::string& path ) = 0;
|
||||
|
||||
@@ -141,7 +141,7 @@ bool cPak::ExtractFileToMemory( const std::string& path, std::vector<Uint8>& dat
|
||||
return Ret;
|
||||
}
|
||||
|
||||
bool cPak::ExtractFileToMemory( const std::string& path, Uint8** data, Uint32* dataSize ) {
|
||||
bool cPak::ExtractFileToMemory( const std::string& path, PointerData& data ) {
|
||||
Lock();
|
||||
|
||||
bool Ret = false;
|
||||
@@ -149,11 +149,11 @@ bool cPak::ExtractFileToMemory( const std::string& path, Uint8** data, Uint32* d
|
||||
Int32 Pos = Exists( path );
|
||||
|
||||
if ( Pos != -1 ) {
|
||||
*dataSize = pakFiles[Pos].file_length;
|
||||
*data = eeNew( Uint8, (*dataSize) );
|
||||
data.DataSize = pakFiles[Pos].file_length;
|
||||
data.Data = eeNewArray( Uint8, ( data.DataSize ) );
|
||||
|
||||
myPak.fs.seekg( pakFiles[Pos].file_position, std::ios::beg );
|
||||
myPak.fs.read( reinterpret_cast<char*> ( *data ), pakFiles[Pos].file_length );
|
||||
myPak.fs.read( reinterpret_cast<char*> ( data.Data ), pakFiles[Pos].file_length );
|
||||
|
||||
Ret = true;
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ class EE_API cPak : public cPack {
|
||||
bool ExtractFileToMemory( const std::string& path, std::vector<Uint8>& data );
|
||||
|
||||
/** Extract a file to memory from the pakFile */
|
||||
bool ExtractFileToMemory( const std::string& path, Uint8** data, Uint32* dataSize );
|
||||
bool ExtractFileToMemory( const std::string& path, PointerData& data );
|
||||
|
||||
/** Check if a file exists in the pakFile and return the number of the file, otherwise return -1. */
|
||||
Int32 Exists( const std::string& path );
|
||||
|
||||
@@ -180,7 +180,7 @@ bool cZip::ExtractFileToMemory( const std::string& path, std::vector<Uint8>& dat
|
||||
return Ret;
|
||||
}
|
||||
|
||||
bool cZip::ExtractFileToMemory( const std::string& path, Uint8** data, Uint32* dataSize ) {
|
||||
bool cZip::ExtractFileToMemory( const std::string& path, PointerData& data ) {
|
||||
Lock();
|
||||
|
||||
bool Ret = false;
|
||||
@@ -196,10 +196,10 @@ bool cZip::ExtractFileToMemory( const std::string& path, Uint8** data, Uint32* d
|
||||
struct zip_file * zf = zip_fopen_index( mZip, zs.index, 0 );
|
||||
|
||||
if ( NULL != zf ) {
|
||||
*dataSize = (Uint32)zs.size;
|
||||
*data = eeNew( Uint8, (*dataSize) );
|
||||
data.DataSize = (Uint32)zs.size;
|
||||
data.Data = eeNewArray( Uint8, ( data.DataSize ) );
|
||||
|
||||
Result = (Int32)zip_fread( zf, reinterpret_cast<void*> (&data[0]), (*dataSize) );
|
||||
Result = (Int32)zip_fread( zf, (void*)data.Data, data.DataSize );
|
||||
|
||||
zip_fclose(zf);
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ class EE_API cZip : public cPack {
|
||||
bool ExtractFileToMemory( const std::string& path, std::vector<Uint8>& data );
|
||||
|
||||
/** Extract a file to memory from the pakFile */
|
||||
bool ExtractFileToMemory( const std::string& path, Uint8** data, Uint32* dataSize );
|
||||
bool ExtractFileToMemory( const std::string& path, PointerData& data );
|
||||
|
||||
/** Check if a file exists in the pack file and return the number of the file, otherwise return -1. */
|
||||
Int32 Exists( const std::string& path );
|
||||
|
||||
@@ -66,20 +66,6 @@ void cEETest::Init() {
|
||||
run = ( mWindow->Created() && PAK.IsOpen() );
|
||||
|
||||
if ( run ) {
|
||||
#ifdef EE_DEBUG
|
||||
std::cout << "Size of Callback0: " << sizeof( cb::Callback0<void> ) << std::endl;
|
||||
std::cout << "Size of cWaypoints: " << sizeof( cWaypoints ) << std::endl;
|
||||
std::cout << "Size of UIEventsMap: " << sizeof( std::map< Uint32, std::map<Uint32, cUIControl::UIEventCallback> > ) << std::endl;
|
||||
std::cout << "Size of eePolygon2f: " << sizeof(eePolygon2f) << std::endl;
|
||||
std::cout << "Size of cTexture: " << sizeof(cTexture) << std::endl;
|
||||
std::cout << "Size of cShape: " << sizeof(Graphics::cShape) << std::endl;
|
||||
std::cout << "Size of cSprite: " << sizeof(cSprite) << std::endl;
|
||||
std::cout << "Size of cUIControl: " << sizeof(cUIControl) << std::endl;
|
||||
std::cout << "Size of cUIControlAnim: " << sizeof(cUIControlAnim) << std::endl;
|
||||
std::cout << "Size of cUITextBox: " << sizeof(cUITextBox) << std::endl;
|
||||
std::cout << "Size of cUIComplexControl: " << sizeof(cUIComplexControl) << std::endl;
|
||||
#endif
|
||||
|
||||
SetScreen( 0 );
|
||||
|
||||
mWindow->Caption( "EE++ Test Application" );
|
||||
@@ -880,7 +866,7 @@ void cEETest::LoadTextures() {
|
||||
TLayer->AddGameObject(
|
||||
eeNew(
|
||||
cGameObjectShape, ( GObjFlags::GAMEOBJECT_STATIC, Tiles[ Rand.RandRange( 0, 5 ) ] )
|
||||
), eeVector2u( x, y )
|
||||
), eeVector2i( x, y )
|
||||
);
|
||||
}
|
||||
}*/
|
||||
|
||||
@@ -86,16 +86,19 @@ void cUIDropDownList::ShowListBox() {
|
||||
mListBox->Parent()->ScreenToControl( Pos );
|
||||
mListBox->Pos( Pos );
|
||||
|
||||
eeRecti tPadding = mListBox->PaddingContainer();
|
||||
if ( mListBox->Count() ) {
|
||||
eeRecti tPadding = mListBox->PaddingContainer();
|
||||
|
||||
if ( mMinNumVisibleItems < mListBox->Count() )
|
||||
mListBox->Size( mSize.Width(), (Int32)( mMinNumVisibleItems * mSize.Height() ) + tPadding.Top );
|
||||
else
|
||||
mListBox->Size( mSize.Width(), (Int32)( mListBox->Count() * mSize.Height() ) + tPadding.Top );
|
||||
if ( mMinNumVisibleItems < mListBox->Count() )
|
||||
mListBox->Size( mSize.Width(), (Int32)( mMinNumVisibleItems * mListBox->RowHeight() ) + tPadding.Top + tPadding.Bottom );
|
||||
else {
|
||||
mListBox->Size( mSize.Width(), (Int32)( mListBox->Count() * mListBox->RowHeight() ) + tPadding.Top + tPadding.Bottom );
|
||||
}
|
||||
|
||||
Show();
|
||||
Show();
|
||||
|
||||
mListBox->SetFocus();
|
||||
mListBox->SetFocus();
|
||||
}
|
||||
} else {
|
||||
Hide();
|
||||
}
|
||||
|
||||
@@ -584,6 +584,7 @@ void cUIWindow::Draw() {
|
||||
|
||||
P.DrawTriangle( eeTriangle2f( eeVector2f( ShadowPos.x, ShadowPos.y + mSize.Height() ), eeVector2f( ShadowPos.x - SSize, ShadowPos.y + mSize.Height() ), eeVector2f( ShadowPos.x, ShadowPos.y + mSize.Height() + SSize ) ), BeginC, EndC, EndC );
|
||||
|
||||
P.ForceDraw( true );
|
||||
P.DrawBatch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -630,10 +630,6 @@ Uint32 MakeHash( const std::string& str ) {
|
||||
return MakeHash( reinterpret_cast<const Uint8*>( &str[0] ) );
|
||||
}
|
||||
|
||||
Uint32 MakeHash( const EE::String& str ) {
|
||||
return MakeHash( reinterpret_cast<const Uint8*>( str.data() ) );
|
||||
}
|
||||
|
||||
Uint32 MakeHash( const Uint8 * str ) {
|
||||
//! This is djb2 + sdbm mixed. This hash doesn't exists, but worked.
|
||||
//! Since i found this pretty funny because i used this hash in a lot of projects and never found a collision, i'll let it stay here.
|
||||
@@ -820,7 +816,7 @@ std::string RemoveLastFolderFromPath( std::string path ) {
|
||||
|
||||
std::size_t pos = path.find_last_of( GetOSlash() );
|
||||
|
||||
if ( std::string::npos != pos ) {
|
||||
if ( std::string::npos != pos ) {
|
||||
std::string sstr;
|
||||
std::size_t pos2 = path.find_first_of( GetOSlash() );
|
||||
|
||||
@@ -830,15 +826,15 @@ std::string RemoveLastFolderFromPath( std::string path ) {
|
||||
if ( pos == pos2 ) {
|
||||
sstr = path.substr(0,pos2+1);
|
||||
}
|
||||
}
|
||||
|
||||
if ( sstr.size() ) {
|
||||
DirPathAddSlashAtEnd( sstr );
|
||||
|
||||
return sstr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( sstr.size() ) {
|
||||
DirPathAddSlashAtEnd( sstr );
|
||||
|
||||
return sstr;
|
||||
}
|
||||
}
|
||||
|
||||
DirPathAddSlashAtEnd( path );
|
||||
|
||||
return path;
|
||||
|
||||
@@ -43,9 +43,6 @@ namespace EE { namespace Utils {
|
||||
/** @return string hash */
|
||||
Uint32 EE_API MakeHash( const Uint8 * str );
|
||||
|
||||
/** @return string hash */
|
||||
Uint32 EE_API MakeHash( const EE::String& str );
|
||||
|
||||
/** Copy a file to memory
|
||||
* @param path The file path
|
||||
* @param data The vector to allocate the file in memory
|
||||
|
||||
Reference in New Issue
Block a user