EE::Maps is now a module and not part of the main library.

This commit is contained in:
Martín Lucas Golini
2022-12-03 18:54:13 -03:00
parent 1bb6749e54
commit 6a56b21868
61 changed files with 338 additions and 217 deletions

View File

@@ -48,10 +48,6 @@ using namespace EE::Scene;
using namespace EE::UI;
using namespace EE::UI::Tools;
// Maps
#include <eepp/maps.hpp>
using namespace EE::Maps;
// Physics
#include <eepp/physics.hpp>
using namespace EE::Physics;

View File

@@ -1,15 +0,0 @@
#ifndef EEPP_MAPS_HPP
#define EEPP_MAPS_HPP
#include <eepp/maps/gameobject.hpp>
#include <eepp/maps/gameobjectsprite.hpp>
#include <eepp/maps/gameobjecttextureregion.hpp>
#include <eepp/maps/gameobjecttextureregionex.hpp>
#include <eepp/maps/mapeditor/mapeditor.hpp>
#include <eepp/maps/maplayer.hpp>
#include <eepp/maps/maplight.hpp>
#include <eepp/maps/mapobjectlayer.hpp>
#include <eepp/maps/tilemap.hpp>
#include <eepp/maps/tilemaplayer.hpp>
#endif

View File

@@ -1,21 +0,0 @@
#ifndef EE_MAPS__BASE
#define EE_MAPS__BASE
#include <eepp/core.hpp>
#include <eepp/math/math.hpp>
#include <eepp/math/rect.hpp>
#include <eepp/math/vector2.hpp>
using namespace EE::Math;
#include <eepp/system/bitop.hpp>
#include <eepp/system/color.hpp>
#include <eepp/system/filesystem.hpp>
#include <eepp/system/iostream.hpp>
#include <eepp/system/iostreamfile.hpp>
#include <eepp/system/iostreammemory.hpp>
#include <eepp/system/pack.hpp>
#include <eepp/system/time.hpp>
using namespace EE::System;
#endif

View File

@@ -1,89 +0,0 @@
#ifndef EE_MAPS_CGAMEOBJECT_HPP
#define EE_MAPS_CGAMEOBJECT_HPP
#include <eepp/maps/base.hpp>
#include <eepp/maps/maphelper.hpp>
#include <eepp/maps/maplayer.hpp>
#include <eepp/graphics/blendmode.hpp>
#include <eepp/graphics/rendermode.hpp>
using namespace EE::Graphics;
namespace EE { namespace Maps {
class EE_API GameObject {
public:
GameObject( const Uint32& Flags, MapLayer* Layer );
virtual ~GameObject();
virtual void draw();
virtual void update( const Time& dt );
virtual Vector2f getPosition() const;
virtual void setPosition( Vector2f pos );
virtual Vector2i getTilePosition() const;
virtual void setTilePosition( Vector2i pos );
virtual Sizei getSize();
virtual Uint32 getType() const;
virtual bool isType( const Uint32& type );
const Uint32& getFlags() const;
Uint32 getFlag( const Uint32& Flag );
virtual void setFlag( const Uint32& Flag );
void clearFlag( const Uint32& Flag );
bool isBlocked() const;
void setBlocked( bool blocked );
bool isRotated() const;
void setRotated( bool rotated );
bool isMirrored() const;
void setMirrored( bool mirrored );
bool isFliped() const;
void setFliped( bool fliped );
bool isBlendAdd() const;
void setBlendAdd( bool blendAdd );
virtual Uint32 getDataId();
virtual void setDataId( Uint32 Id );
MapLayer* getLayer() const;
protected:
Uint32 mFlags;
MapLayer* mLayer;
virtual RenderMode getRenderModeFromFlags();
virtual BlendMode getBlendModeFromFlags();
void autoFixTilePos();
void assignTilePos();
Float getRotation();
};
}} // namespace EE::Maps
#endif

View File

@@ -1,93 +0,0 @@
#ifndef EE_MAPS_CGAMEOBJECTOBJECT_HPP
#define EE_MAPS_CGAMEOBJECTOBJECT_HPP
#include <eepp/graphics/textureregion.hpp>
#include <eepp/maps/base.hpp>
#include <eepp/maps/gameobject.hpp>
using namespace EE::Graphics;
namespace EE { namespace Maps {
class MapLayer;
class EE_API GameObjectObject : public GameObject {
public:
typedef std::map<std::string, std::string> PropertiesMap;
GameObjectObject( Uint32 DataId, const Rectf& rect, MapLayer* Layer,
const Uint32& Flags = GObjFlags::GAMEOBJECT_STATIC );
virtual ~GameObjectObject();
virtual void draw();
virtual Vector2f getPosition() const;
virtual Sizei getSize();
virtual void setPosition( Vector2f pos );
virtual Uint32 getType() const;
virtual bool isType( const Uint32& type );
virtual Uint32 getDataId();
virtual void setDataId( Uint32 Id );
void addProperty( std::string Text, std::string Value );
void editProperty( std::string Text, std::string Value );
void removeProperty( std::string Text );
void setProperties( const PropertiesMap& prop );
void clearProperties();
PropertiesMap& getProperties();
Uint32 getPropertyCount();
const std::string& getName() const;
void setName( const std::string& name );
const std::string& getTypeName() const;
void setTypeName( const std::string& type );
virtual bool pointInside( const Vector2f& p );
Polygon2f& getPolygon();
const bool& isSelected() const;
void setSelected( const bool& sel );
virtual void setPolygonPoint( Uint32 index, Vector2f p );
virtual GameObjectObject* clone();
protected:
Rectf mRect;
Polygon2f mPoly;
Vector2f mPos;
Uint32 mDataId;
bool mSelected;
std::string mName;
std::string mType;
PropertiesMap mProperties;
};
class GameObjectPolyData {
public:
std::string Name;
std::string Type;
GameObjectObject::PropertiesMap Properties;
Polygon2f Poly;
};
}} // namespace EE::Maps
#endif

View File

@@ -1,32 +0,0 @@
#ifndef EE_MAPS_CGAMEOBJECTPOLYGON_HPP
#define EE_MAPS_CGAMEOBJECTPOLYGON_HPP
#include <eepp/maps/gameobjectobject.hpp>
namespace EE { namespace Maps {
class EE_API GameObjectPolygon : public GameObjectObject {
public:
GameObjectPolygon( Uint32 DataId, Polygon2f poly, MapLayer* Layer,
const Uint32& Flags = GObjFlags::GAMEOBJECT_STATIC );
virtual ~GameObjectPolygon();
virtual void draw();
virtual Sizei getSize();
virtual Uint32 getType() const;
virtual bool isType( const Uint32& type );
virtual bool pointInside( const Vector2f& p );
virtual void setPolygonPoint( Uint32 index, Vector2f p );
virtual GameObjectObject* clone();
};
}} // namespace EE::Maps
#endif

View File

@@ -1,26 +0,0 @@
#ifndef EE_MAPS_CGAMEOBJECTPOLYLINE_HPP
#define EE_MAPS_CGAMEOBJECTPOLYLINE_HPP
#include <eepp/maps/gameobjectpolygon.hpp>
namespace EE { namespace Maps {
class EE_API GameObjectPolyline : public GameObjectPolygon {
public:
GameObjectPolyline( Uint32 DataId, Polygon2f poly, MapLayer* Layer,
const Uint32& Flags = GObjFlags::GAMEOBJECT_STATIC );
virtual ~GameObjectPolyline();
virtual Uint32 getType() const;
virtual bool isType( const Uint32& type );
virtual void draw();
virtual GameObjectObject* clone();
};
}} // namespace EE::Maps
#endif

View File

@@ -1,54 +0,0 @@
#ifndef EE_MAPS_CGAMEOBJECTSPRITE_HPP
#define EE_MAPS_CGAMEOBJECTSPRITE_HPP
#include <eepp/maps/base.hpp>
#include <eepp/maps/gameobject.hpp>
namespace EE { namespace Graphics {
class Sprite;
}} // namespace EE::Graphics
namespace EE { namespace Maps {
class EE_API GameObjectSprite : public GameObject {
public:
GameObjectSprite( const Uint32& Flags, MapLayer* Layer, Graphics::Sprite* Sprite = NULL );
virtual ~GameObjectSprite();
virtual void draw();
virtual void update( const Time& dt );
Vector2f getPosition() const;
virtual void setPosition( Vector2f pos );
virtual Vector2i getTilePosition() const;
virtual void setTilePosition( Vector2i pos );
virtual Sizei getSize();
Graphics::Sprite* getSprite() const;
void setSprite( Graphics::Sprite* sprite );
virtual Uint32 getType() const;
virtual bool isType( const Uint32& type );
virtual void setFlag( const Uint32& Flag );
virtual Uint32 getDataId();
virtual void setDataId( Uint32 Id );
protected:
Graphics::Sprite* mSprite;
Vector2i mTilePos;
};
}} // namespace EE::Maps
#endif

View File

@@ -1,52 +0,0 @@
#ifndef EE_MAPS_CGAMEOBJECTTEXTUREREGION_HPP
#define EE_MAPS_CGAMEOBJECTTEXTUREREGION_HPP
#include <eepp/maps/base.hpp>
#include <eepp/maps/gameobject.hpp>
#include <eepp/graphics/textureregion.hpp>
using namespace EE::Graphics;
namespace EE { namespace Maps {
class EE_API GameObjectTextureRegion : public GameObject {
public:
GameObjectTextureRegion( const Uint32& Flags, MapLayer* Layer,
Graphics::TextureRegion* TextureRegion = NULL,
const Vector2f& Pos = Vector2f() );
virtual ~GameObjectTextureRegion();
virtual void draw();
virtual Vector2f getPosition() const;
virtual void setPosition( Vector2f pos );
virtual Vector2i getTilePosition() const;
virtual void setTilePosition( Vector2i pos );
virtual Sizei getSize();
Graphics::TextureRegion* getTextureRegion() const;
void setTextureRegion( Graphics::TextureRegion* TextureRegion );
virtual Uint32 getType() const;
virtual bool isType( const Uint32& type );
virtual Uint32 getDataId();
virtual void setDataId( Uint32 Id );
protected:
Graphics::TextureRegion* mTextureRegion;
Vector2f mPos;
Vector2i mTilePos;
};
}} // namespace EE::Maps
#endif

View File

@@ -1,38 +0,0 @@
#ifndef EE_GAMEOBJECTTEXTUREREGIONEX_HPP
#define EE_GAMEOBJECTTEXTUREREGIONEX_HPP
#include <eepp/maps/base.hpp>
#include <eepp/maps/gameobjecttextureregion.hpp>
namespace EE { namespace Maps {
class EE_API GameObjectTextureRegionEx : public GameObjectTextureRegion {
public:
GameObjectTextureRegionEx( const Uint32& Flags, MapLayer* Layer,
Graphics::TextureRegion* TextureRegion = NULL,
const Vector2f& Pos = Vector2f(), BlendMode Blend = BlendMode::Alpha(),
RenderMode Render = RENDER_NORMAL, Float Angle = 0.f,
Vector2f Scale = Vector2f::One, Color color = Color::White );
virtual ~GameObjectTextureRegionEx();
virtual void draw();
virtual Uint32 getType() const;
virtual bool isType( const Uint32& type );
virtual void setFlag( const Uint32& Flag );
protected:
BlendMode mBlend;
RenderMode mRender;
Float mAngle;
Vector2f mScale;
Color mColor;
Color* mVertexColors;
};
}} // namespace EE::Maps
#endif

View File

@@ -1,57 +0,0 @@
#ifndef EE_MAPS_CGAMEOBJECTVIRTUAL_HPP
#define EE_MAPS_CGAMEOBJECTVIRTUAL_HPP
#include <eepp/graphics/textureregion.hpp>
#include <eepp/maps/base.hpp>
#include <eepp/maps/gameobject.hpp>
using namespace EE::Graphics;
namespace EE { namespace Maps {
class MapLayer;
class EE_API GameObjectVirtual : public GameObject {
public:
GameObjectVirtual( Uint32 getDataId, MapLayer* Layer,
const Uint32& Flags = GObjFlags::GAMEOBJECT_STATIC,
Uint32 RealType = GAMEOBJECT_TYPE_VIRTUAL,
const Vector2f& Pos = Vector2f() );
GameObjectVirtual( TextureRegion* TextureRegion, MapLayer* Layer,
const Uint32& Flags = GObjFlags::GAMEOBJECT_STATIC,
Uint32 RealType = GAMEOBJECT_TYPE_VIRTUAL,
const Vector2f& Pos = Vector2f() );
virtual ~GameObjectVirtual();
virtual void draw();
virtual Vector2f getPosition() const;
virtual Sizei getSize();
virtual void setPosition( Vector2f pos );
virtual Uint32 getType() const;
virtual bool isType( const Uint32& type );
virtual Uint32 getRealType() const;
virtual Uint32 getDataId();
virtual void setDataId( Uint32 Id );
void setLayer( MapLayer* Layer );
protected:
Uint32 mType;
Uint32 mDataId;
Vector2f mPos;
MapLayer* mLayer;
TextureRegion* mTextureRegion;
};
}} // namespace EE::Maps
#endif

View File

@@ -1,260 +0,0 @@
#ifndef EE_MAPS_CMAPEDITOR_HPP
#define EE_MAPS_CMAPEDITOR_HPP
#include <eepp/maps/base.hpp>
#include <eepp/maps/gameobject.hpp>
#include <eepp/maps/maplayer.hpp>
#include <eepp/maps/maplight.hpp>
#include <eepp/ui/tools/textureatlaseditor.hpp>
#include <eepp/ui/uicheckbox.hpp>
#include <eepp/ui/uifiledialog.hpp>
#include <eepp/ui/uimenubar.hpp>
#include <eepp/ui/uimenucheckbox.hpp>
#include <eepp/ui/uimessagebox.hpp>
#include <eepp/ui/uipopupmenu.hpp>
#include <eepp/ui/uiselectbutton.hpp>
#include <eepp/ui/uispinbox.hpp>
#include <eepp/ui/uitabwidget.hpp>
#include <eepp/ui/uitextureregion.hpp>
#include <eepp/ui/uithememanager.hpp>
#include <eepp/ui/uiwindow.hpp>
namespace EE { namespace UI {
class UIMessageBox;
class UITextView;
}} // namespace EE::UI
using namespace EE::UI;
namespace EE { namespace Maps {
namespace Private {
class UIMapLayerNew;
class UIMap;
} // namespace Private
class EE_API MapEditor {
public:
typedef std::function<void()> MapEditorCloseCb;
static MapEditor* New( UIWindow* AttatchTo = NULL,
const MapEditorCloseCb& callback = MapEditorCloseCb() );
MapEditor( UIWindow* AttatchTo = NULL, const MapEditorCloseCb& callback = MapEditorCloseCb() );
~MapEditor();
protected:
UIWindow* mUIWindow;
Node* mUIContainer;
UITheme* mTheme;
Private::UIMap* mUIMap;
MapEditorCloseCb mCloseCb;
UIDropDownList* mTextureAtlasesList;
UIWidget* mWinContainer;
UIListBox* mTextureRegionList;
UITextureRegion* mGfxPreview;
TextureAtlas* mCurSG;
UIScrollBar* mMapHScroll;
UIScrollBar* mMapVScroll;
UIDropDownList* mGOTypeList;
UIDropDownList* mLayerList;
UICheckBox* mChkMirrored;
UICheckBox* mChkFliped;
UICheckBox* mChkBlocked;
UICheckBox* mChkAnim;
UICheckBox* mChkRot90;
UICheckBox* mChkAutoFix;
UICheckBox* mChkBlendAdd;
MapLayer* mCurLayer;
UIPushButton* mBtnGOTypeAdd;
Uint32 mCurGOType;
Uint32 mCurGOFlags;
UIWidget* mTextureRegionCont;
UIWidget* mLightCont;
UIWidget* mObjectCont;
UIWidget* mSGCont;
UIWidget* mDICont;
UICheckBox* mChkDI;
UITextInput* mDataIdInput;
UIMenuCheckBox* mLayerChkVisible;
UIMenuCheckBox* mLayerChkLights;
UITabWidget* mTabWidget;
UIMenuCheckBox* mChkShowGrid;
UIMenuCheckBox* mChkMarkTileOver;
UIMenuCheckBox* mChkShowBlocked;
UICheckBox* mChkClampToTile;
//! Light Color
UIWidget* mUIBaseColor;
UISlider* mUIRedSlider;
UISlider* mUIGreenSlider;
UISlider* mUIBlueSlider;
UITextView* mUIRedTxt;
UITextView* mUIGreenTxt;
UITextView* mUIBlueTxt;
UISpinBox* mLightRadius;
UICheckBox* mLightTypeChk;
UITextView* mTileBox;
Int32 mLastSelButtonY;
bool mMouseScrolling;
std::list<UISelectButton*> mObjContButton;
void onRedChange( const Event* Event );
void onGreenChange( const Event* Event );
void onBlueChange( const Event* Event );
void createLighContainer();
UISelectButton* addObjContButton( String text, Uint32 mode );
void createObjectsContainer();
void createTextureRegionContainer( Int32 Width );
void windowClose( const Event* Event );
void cextureAtlasOpen( const Event* Event );
void createME();
void createMenuBar();
void createETGMenu();
void createUIMap();
void fillSGCombo();
void fillTextureRegionList();
void createNewMap();
void fileMenuClick( const Event* Event );
void viewMenuClick( const Event* Event );
void mapMenuClick( const Event* Event );
void layerMenuClick( const Event* Event );
void onTextureAtlasChange( const Event* Event );
void mapOpen( const Event* Event );
void mapSave( const Event* Event );
void onTextureRegionChange( const Event* Event );
void onTypeChange( const Event* Event );
void onScrollMapH( const Event* Event );
void onScrollMapV( const Event* Event );
void onMapSizeChange( const Event* Event = NULL );
void onLayerSelect( const Event* Event );
void mapCreated();
void chkClickMirrored( const Event* Event );
void chkClickFlipped( const Event* Event );
void chkClickBlocked( const Event* Event );
void chkClickAnimated( const Event* Event );
void chkClickRot90( const Event* Event );
void chkClickAutoFix( const Event* Event );
void chkClickDI( const Event* Event );
void chkClickClampToTile( const Event* Event );
void onMapMouseDown( const Event* Event );
void onMapMouseClick( const Event* Event );
void onLayerAdd( Private::UIMapLayerNew* UILayer );
void addNewGOType( const Event* Event );
void onMapClose( const Event* Event );
void onNewLight( const Event* Event );
void onLightRadiusChangeVal( const Event* Event );
void onLightTypeChange( const Event* Event );
void onLightSelect( MapLight* Light );
void onLightRadiusChange( MapLight* Light );
void onObjectModeSel( const Event* Event );
void onNewGOTypeAdded( std::string name, String::HashType hash );
void onAddObject( Uint32 Type, Polygon2f poly );
void updateGfx();
void updateFlags();
void addGameObjectToTile();
void removeGameObjectFromTile();
void addGameObject();
void removeGameObject();
GameObject* createGameObject();
void moveLayerUp();
void moveLayerDown();
void removeLayer();
void refreshLayersList();
void createNewEmptyMap();
void fillGotyList();
void refreshGotyList();
void setViewOptions();
GameObject* getCurrentGOOver();
void zoomIn();
void zoomOut();
UIMessageBox* createAlert( const String& title, const String& text );
UIMessageBox* createNoLayerAlert( const String title );
void onTabSelected( const Event* Event );
void createTabs();
void onMapLoad();
void updateScroll();
void addShortcut( const KeyBindings::Shortcut& shortcut, const std::string& cmd,
std::function<void()> func );
};
}} // namespace EE::Maps
#endif

View File

@@ -1,127 +0,0 @@
#ifndef EE_MAPS_MAPHELPER_HPP
#define EE_MAPS_MAPHELPER_HPP
#include <eepp/config.hpp>
#include <eepp/core/string.hpp>
namespace EE { namespace Maps {
#define MAP_PROPERTY_SIZE ( 64 )
#define LAYER_NAME_SIZE ( 64 )
#define MAP_TEXTUREATLAS_PATH_SIZE ( 128 )
struct sPropertyHdr {
char Name[MAP_PROPERTY_SIZE];
char Value[MAP_PROPERTY_SIZE];
};
struct sMapTextureAtlas {
char Path[MAP_TEXTUREATLAS_PATH_SIZE];
};
struct sVirtualObj {
char Name[MAP_PROPERTY_SIZE];
};
struct sMapHdr {
Uint32 Magic;
Uint32 SizeX;
Uint32 SizeY;
Uint32 TileSizeX;
Uint32 TileSizeY;
Uint32 MaxLayers;
Uint32 LayerCount;
Uint32 Flags;
Uint32 PropertyCount;
Uint32 TextureAtlasCount;
Uint32 VirtualObjectTypesCount;
Uint32 BaseColor;
Uint32 LightsCount;
};
struct sLayerHdr {
char Name[LAYER_NAME_SIZE];
Uint32 Type;
Uint32 Flags;
Int32 OffsetX;
Int32 OffsetY;
Uint32 PropertyCount;
Uint32 ObjectCount; //! Only used by the Object Layer
};
struct sMapTileGOHdr {
Uint32 Type;
Uint32 Id;
Uint32 Flags;
};
struct sMapObjGOHdr {
Uint32 Type;
Uint32 Id;
Uint32 Flags;
Int32 PosX;
Int32 PosY;
};
struct sMapLightHdr {
Uint32 Radius;
Int32 PosX;
Int32 PosY;
Uint32 Color;
Uint32 Type;
};
struct sMapObjObjHdr {
char Name[MAP_PROPERTY_SIZE];
char Type[MAP_PROPERTY_SIZE];
Uint32 PointCount;
Uint32 PropertyCount;
};
class GObjFlags {
public:
enum EE_GAMEOBJECT_FLAGS {
GAMEOBJECT_STATIC = ( 1 << 0 ),
GAMEOBJECT_ANIMATED = ( 1 << 1 ),
GAMEOBJECT_MIRRORED = ( 1 << 2 ),
GAMEOBJECT_FLIPED = ( 1 << 3 ),
GAMEOBJECT_BLOCKED = ( 1 << 4 ),
GAMEOBJECT_ROTATE_90DEG = ( 1 << 5 ),
GAMEOBJECT_AUTO_FIX_TILE_POS = ( 1 << 6 ),
GAMEOBJECT_BLEND_ADD = ( 1 << 7 )
};
};
enum EE_GAMEOBJECT_TYPE {
GAMEOBJECT_TYPE_BASE = String::hash( "Base" ),
GAMEOBJECT_TYPE_VIRTUAL = String::hash( "Virtual" ),
GAMEOBJECT_TYPE_TEXTUREREGION = String::hash( "SubTexture" ),
GAMEOBJECT_TYPE_TEXTUREREGIONEX = String::hash( "SubTextureEx" ),
GAMEOBJECT_TYPE_SPRITE = String::hash( "Sprite" ),
GAMEOBJECT_TYPE_OBJECT = String::hash( "Object" ),
GAMEOBJECT_TYPE_POLYGON = String::hash( "Polygon" ),
GAMEOBJECT_TYPE_POLYLINE = String::hash( "Polyline" )
};
enum EE_LAYER_TYPE { MAP_LAYER_TILED, MAP_LAYER_OBJECT };
enum EE_MAP_FLAGS {
MAP_FLAG_CLAMP_BORDERS = ( 1 << 0 ),
MAP_FLAG_CLIP_AREA = ( 1 << 1 ),
MAP_FLAG_DRAW_GRID = ( 1 << 2 ),
MAP_FLAG_DRAW_TILE_OVER = ( 1 << 3 ),
MAP_FLAG_DRAW_BACKGROUND = ( 1 << 4 ),
MAP_FLAG_LIGHTS_ENABLED = ( 1 << 5 ),
MAP_FLAG_LIGHTS_BYVERTEX = ( 1 << 6 ),
MAP_FLAG_SHOW_BLOCKED = ( 1 << 7 )
};
#define MAP_EDITOR_DEFAULT_FLAGS \
( MAP_FLAG_LIGHTS_ENABLED | MAP_FLAG_LIGHTS_BYVERTEX | MAP_FLAG_CLAMP_BORDERS | \
MAP_FLAG_CLIP_AREA | MAP_FLAG_DRAW_GRID | MAP_FLAG_DRAW_BACKGROUND )
enum EE_LAYER_FLAGS { LAYER_FLAG_VISIBLE = ( 1 << 0 ), LAYER_FLAG_LIGHTS_ENABLED = ( 1 << 1 ) };
}} // namespace EE::Maps
#endif

View File

@@ -1,77 +0,0 @@
#ifndef EE_MAPS_CLAYER_HPP
#define EE_MAPS_CLAYER_HPP
#include <eepp/maps/base.hpp>
namespace EE { namespace Maps {
class TileMap;
class EE_API MapLayer {
public:
typedef std::map<std::string, std::string> PropertiesMap;
virtual ~MapLayer();
virtual void draw( const Vector2f& Offset = Vector2f( 0, 0 ) ) = 0;
virtual void update( const Time& dt ) = 0;
const Uint32& getFlags() const;
Uint32 getFlag( const Uint32& Flag );
void setFlag( const Uint32& Flag );
void clearFlag( const Uint32& Flag );
const Uint32& getType() const;
TileMap* getMap() const;
const Vector2f& getOffset() const;
void setOffset( const Vector2f& offset );
void setName( const std::string& name );
const std::string& getName() const;
const String::HashType& getId() 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 setVisible( const bool& visible );
bool isVisible();
bool getLightsEnabled();
void setLightsEnabled( const bool& enabled );
protected:
friend class TileMap;
TileMap* mMap;
Uint32 mType;
Uint32 mFlags;
Vector2f mOffset;
String::HashType mNameHash;
std::string mName;
PropertiesMap mProperties;
MapLayer( TileMap* map, Uint32 type, Uint32 flags, std::string name = "",
Vector2f offset = Vector2f( 0, 0 ) );
};
}} // namespace EE::Maps
#endif

View File

@@ -1,75 +0,0 @@
#ifndef EE_MAPS_CLIGHT_H
#define EE_MAPS_CLIGHT_H
#include <eepp/maps/base.hpp>
namespace EE { namespace Maps {
/** @enum MapLightType Define the light spot type */
enum MapLightType { Normal = 0, Isometric = 1 };
class EE_API MapLight {
public:
MapLight();
MapLight( const Float& Radius, const Float& x, const Float& y,
const RGB& Color = RGB( 255, 255, 255 ), MapLightType Type = MapLightType::Normal );
virtual ~MapLight();
void create( const Float& Radius, const Float& x, const Float& y,
const RGB& Color = RGB( 255, 255, 255 ),
MapLightType Type = MapLightType::Normal );
virtual RGB processVertex( const Float& PointX, const Float& PointY, const RGB& VertexColor,
const RGB& BaseColor );
virtual Color processVertex( const Float& PointX, const Float& PointY, const Color& VertexColor,
const Color& BaseColor );
RGB processVertex( const Vector2f& Pos, const RGB& VertexColor, const RGB& BaseColor );
Color processVertex( const Vector2f& Pos, const Color& VertexColor, const Color& BaseColor );
void move( const Float& addtox, const Float& addtoy );
void updatePos( const Float& x, const Float& y );
void updatePos( const Vector2f& newPos );
Rectf getAABB() const;
const Float& getRadius() const;
void setRadius( const Float& radio );
const bool& isActive() const;
void setActive( const bool& active );
void setColor( const RGB& color );
const RGB& getColor() const;
void setType( const MapLightType& type );
const MapLightType& getType() const;
const Vector2f& getPosition() const;
void setPosition( const Vector2f& newPos );
protected:
Float mRadius;
Vector2f mPos;
RGB mColor;
MapLightType mType;
Rectf mAABB;
bool mActive;
void updateAABB();
};
}} // namespace EE::Maps
#endif

View File

@@ -1,62 +0,0 @@
#ifndef EE_MAPS_CLIGHTMANAGER_HPP
#define EE_MAPS_CLIGHTMANAGER_HPP
#include <eepp/maps/base.hpp>
#include <eepp/maps/maplight.hpp>
#include <list>
namespace EE { namespace Maps {
class TileMap;
class EE_API MapLightManager {
public:
typedef std::list<MapLight*> LightsList;
MapLightManager( TileMap* Map, bool ByVertex );
virtual ~MapLightManager();
virtual void update();
void addLight( MapLight* Light );
void removeLight( const Vector2f& OverPos );
void removeLight( MapLight* Light );
Uint32 getCount();
const Color* getTileColor( const Vector2i& TilePos );
const Color* getTileColor( const Vector2i& TilePos, const Uint32& Vertex );
Color getColorFromPos( const Vector2f& Pos );
const bool& isByVertex() const;
LightsList& getLights();
MapLight* getLightOver( const Vector2f& OverPos, MapLight* LightCurrent = NULL );
protected:
TileMap* mMap;
Int32 mNumVertex;
Color**** mTileColors;
LightsList mLights;
bool mIsByVertex;
void allocateColors();
void deallocateColors();
void destroyLights();
virtual void updateByVertex();
virtual void updateByTile();
};
}} // namespace EE::Maps
#endif

View File

@@ -1,51 +0,0 @@
#ifndef EE_MAPS_COBJECTLAYER_HPP
#define EE_MAPS_COBJECTLAYER_HPP
#include <eepp/maps/gameobject.hpp>
#include <eepp/maps/maplayer.hpp>
#include <list>
namespace EE { namespace Maps {
class TileMap;
class EE_API MapObjectLayer : public MapLayer {
public:
enum SEARCH_TYPE { SEARCH_OBJECT = 1, SEARCH_POLY, SEARCH_ALL };
typedef std::list<GameObject*> ObjList;
virtual ~MapObjectLayer();
virtual void draw( const Vector2f& Offset = Vector2f( 0, 0 ) );
virtual void update( const Time& dt );
virtual void addGameObject( GameObject* obj );
virtual void removeGameObject( GameObject* obj );
virtual void removeGameObject( const Vector2i& pos );
virtual GameObject* getObjectOver( const Vector2i& pos, SEARCH_TYPE type = SEARCH_ALL );
virtual Uint32 getObjectCount() const;
protected:
friend class TileMap;
ObjList mObjects;
MapObjectLayer( TileMap* map, Uint32 flags, std::string name = "",
Vector2f offset = Vector2f( 0, 0 ) );
void allocateLayer();
void deallocateLayer();
ObjList& getObjectList();
};
}} // namespace EE::Maps
#endif

View File

@@ -1,318 +0,0 @@
#ifndef EE_MAPS_CTILEMAP_HPP
#define EE_MAPS_CTILEMAP_HPP
#include <eepp/maps/base.hpp>
#include <eepp/maps/gameobject.hpp>
#include <eepp/maps/gameobjectobject.hpp>
#include <eepp/maps/maplayer.hpp>
#include <eepp/maps/maplight.hpp>
#include <eepp/maps/maplightmanager.hpp>
#include <eepp/window/engine.hpp>
#include <eepp/window/input.hpp>
#include <eepp/window/window.hpp>
using namespace EE::Window;
#include <eepp/graphics/texture.hpp>
using namespace EE::Graphics;
namespace EE { namespace Maps {
namespace Private {
class UIMapNew;
}
#define EE_MAP_LAYER_UNKNOWN eeINDEX_NOT_FOUND
#define EE_MAP_MAGIC ( ( 'E' << 0 ) | ( 'E' << 8 ) | ( 'M' << 16 ) | ( 'P' << 24 ) )
class EE_API TileMap {
public:
typedef std::map<std::string, std::string> PropertiesMap;
typedef std::list<std::string> GOTypesList; //! Special object types used in this map
typedef std::function<GameObject*( const Uint32&, const Uint32&, MapLayer*, const Uint32& )>
CreateGOCb;
typedef std::function<void()> MapDrawCb;
typedef std::function<void()> MapUpdateCb;
TileMap();
virtual ~TileMap();
virtual void create( Sizei Size, Uint32 MaxLayers, Sizei TileSize, Uint32 Flags = 0,
Sizef viewSize = Sizef( 800, 600 ), EE::Window::Window* Window = NULL );
virtual MapLayer* addLayer( Uint32 Type, Uint32 flags, std::string name );
virtual MapLayer* getLayer( Uint32 index );
virtual Uint32 getLayerIndex( MapLayer* Layer );
virtual MapLayer* getLayerByHash( String::HashType hash );
virtual MapLayer* getLayer( const std::string& name );
virtual bool loadFromFile( const std::string& path );
virtual bool loadFromStream( IOStream& IOS );
virtual bool loadFromPack( Pack* Pack, const std::string& FilePackPath );
virtual bool loadFromMemory( const char* Data, const Uint32& DataSize );
virtual void saveToFile( const std::string& path );
virtual void saveToStream( IOStream& IOS );
virtual void draw();
virtual void update();
const Sizei& getTileSize() const;
const Sizei& getSize() const;
const Uint32& getLayerCount() const;
const Uint32& getMaxLayers() const;
const Sizef& getViewSize() const;
void setViewSize( const Sizef& viewSize );
const Vector2f& getOffset() const;
void setOffset( const Vector2f& offset );
const Vector2i& getPosition() const;
void setPosition( const Vector2i& position );
void move( const Vector2f& offset );
void move( const Float& offsetx, const Float& offsety );
const Vector2i& getStartTile() const;
const Vector2i& getEndTile() const;
const Uint32& getFlags() const;
bool getClampBorders() const;
void setClampBorders( const bool& clamp );
bool getClipedArea() const;
void setClipedArea( const bool& clip );
Uint32 getDrawGrid() const;
void setDrawGrid( const bool& draw );
Uint32 getShowBlocked() const;
void setShowBlocked( const bool& show );
Uint32 getDrawBackground() const;
void setDrawBackground( const bool& draw );
Uint32 getDrawTileOver() const;
void setDrawTileOver( const bool& draw );
bool getLightsEnabled();
void setLightsEnabled( const bool& enabled );
bool getLightsByVertex();
void reset();
bool moveLayerUp( MapLayer* Layer );
bool moveLayerDown( MapLayer* Layer );
bool removeLayer( MapLayer* Layer );
const Vector2i& getMouseTilePos() const;
Vector2i getMouseTilePosCoords();
Vector2f getMouseTilePosCoordsf();
Vector2i getTileCoords( const Vector2i& TilePos );
Vector2f getTileCoords( const Vector2f& TilePos );
const Vector2i& getRealMouseTilePos() const;
const Vector2i& getMouseMapPos() const;
Vector2f getMouseMapPosf() const;
const Sizei& getTotalSize() 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();
void setCreateGameObjectCallback( const CreateGOCb& Cb );
const std::string& getPath() const;
void setBaseColor( const Color& color );
const Color& getBaseColor() const;
const Rectf& getViewAreaAABB() const;
MapLightManager* getLightManager() const;
/** Tiles to add or subtract from the real values of StartTile and EndTile ( so it will loop
* over more/less tiles than the required to render every tile on screen ). */
void setExtraTiles( const Vector2i& extra );
const Vector2i& getExtraTiles() const;
void setDrawCallback( MapDrawCb Cb );
void setUpdateCallback( MapUpdateCb Cb );
Texture* getBlankTileTexture();
bool isTileBlocked( const Vector2i& TilePos );
void setData( void* value );
void* getData() const;
const bool& isMouseOver() const;
GameObject* IsTypeInTilePos( const Uint32& Type, const Vector2i& TilePos );
const Uint8& getBackAlpha() const;
void setBackAlpha( const Uint8& alpha );
const Color& getBackColor() const;
void setBackColor( const Color& col );
const Float& getScale() const;
void setScale( const Float& scale );
Vector2i getMaxOffset();
Uint32 getNewObjectId();
GameObjectPolyData& getPolyObjData( Uint32 Id );
void forceHeadersOnLoad( Sizei mapSize, Sizei tileSize, Uint32 numLayers, Uint32 flags );
void disableForcedHeaders();
void setGridLinesColor( const Color& Col );
const Color& setGridLinesColor() const;
protected:
friend class EE::Maps::Private::UIMapNew;
class ForcedHeaders {
public:
ForcedHeaders( Sizei mapSize, Sizei tileSize, Uint32 numLayers, Uint32 flags ) :
MapSize( mapSize ), TileSize( tileSize ), NumLayers( numLayers ), Flags( flags ) {}
Sizei MapSize;
Sizei TileSize;
Uint32 NumLayers;
Uint32 Flags;
};
typedef std::map<Uint32, GameObjectPolyData> PolyObjMap;
EE::Window::Window* mWindow;
MapLayer** mLayers;
Uint32 mFlags;
Uint32 mMaxLayers;
Uint32 mLayerCount;
Sizei mSize;
Sizei mPixelSize;
Sizei mTileSize;
Sizef mViewSize;
Vector2f mOffset;
Vector2i mScreenPos;
Vector2i mStartTile;
Vector2i mEndTile;
Vector2i mExtraTiles;
Vector2i mMouseOverTile;
Vector2i mMouseOverTileFinal;
Vector2i mMouseMapPos;
Color mBaseColor;
PropertiesMap mProperties;
GOTypesList mObjTypes;
CreateGOCb mCreateGOCb;
Texture* mTileTex;
Rectf mScreenAABB;
MapLightManager* mLightManager;
MapDrawCb mDrawCb;
MapUpdateCb mUpdateCb;
void* mData;
Color mTileOverColor;
Color mBackColor;
Color mGridLinesColor;
Uint8 mBackAlpha;
bool mMouseOver;
std::string mPath;
Float mScale;
Vector2f mOffscale;
Uint32 mLastObjId;
PolyObjMap mPolyObjs;
ForcedHeaders* mForcedHeaders;
virtual GameObject* createGameObject( const Uint32& Type, const Uint32& Flags, MapLayer* Layer,
const Uint32& DataId = 0 );
void calcTilesClip();
void clamp();
void getMouseOverTile();
void gridDraw();
void mouseOverDraw();
void deleteLayers();
std::vector<std::string> getTextureAtlases();
void createEmptyTile();
void updateScreenAABB();
void createLightManager();
virtual void onMapLoaded();
};
}} // namespace EE::Maps
#endif

View File

@@ -1,48 +0,0 @@
#ifndef EE_MAPS_CTILELAYER_HPP
#define EE_MAPS_CTILELAYER_HPP
#include <eepp/maps/gameobject.hpp>
#include <eepp/maps/maplayer.hpp>
namespace EE { namespace Maps {
class EE_API TileMapLayer : public MapLayer {
public:
virtual ~TileMapLayer();
virtual void draw( const Vector2f& Offset = Vector2f( 0, 0 ) );
virtual void update( const Time& dt );
virtual void addGameObject( GameObject* obj, const Vector2i& TilePos );
virtual void removeGameObject( const Vector2i& TilePos );
virtual void moveTileObject( const Vector2i& FromPos, const Vector2i& ToPos );
virtual GameObject* getGameObject( const Vector2i& TilePos );
const Vector2i& getCurrentTile() const;
Vector2i getTilePosFromPos( const Vector2f& Pos );
Vector2f getPosFromTilePos( const Vector2i& TilePos );
protected:
friend class TileMap;
GameObject*** mTiles;
Sizei mSize;
Vector2i mCurTile;
TileMapLayer( TileMap* map, Sizei size, Uint32 flags, std::string name = "",
Vector2f offset = Vector2f( 0, 0 ) );
void allocateLayer();
void deallocateLayer();
};
}} // namespace EE::Maps
#endif