Skip to content

Commit

Permalink
Components: Switch to new style events.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oberon00 committed Jul 26, 2013
1 parent 9459970 commit b2e4c74
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 27 deletions.
7 changes: 2 additions & 5 deletions src/comp/PositionComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ static char const libname[] = "PositionComponent";
#include "luaexport/ExportThis.hpp"


JD_BASIC_EVT_COMPONENT_IMPL(PositionComponent)

JD_EVENT_TABLE_BEGIN(PositionComponent)
JD_EVENT_ENTRY(rectChanged, void, _1, _2)
JD_EVENT_TABLE_END
JD_BASIC_COMPONENT_IMPL(PositionComponent)

PositionComponent::PositionComponent(Entity& parent)
{
Expand Down Expand Up @@ -78,6 +74,7 @@ static void init(LuaVm& vm)
.property("rect", &LHCURCLASS::rect, &LHCURCLASS::setRect)
.property("position", &LHCURCLASS::position, &LHCURCLASS::setPosition)
.property("size", &LHCURCLASS::size, &LHCURCLASS::setSize)
.JD_EVENT(rectChanged, RectChanged)
.LHMEMFN(move)
#undef LHCURCLASS
];
Expand Down
4 changes: 2 additions & 2 deletions src/comp/RectCollisionComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@

class RectCollisionComponent: public Component {
JD_COMPONENT
SSIG_DEFINE_MEMBERSIGNAL(collided, void(sf::FloatRect, Entity&, sf::FloatRect))
SSIG_DEFINE_MEMBERSIGNAL(collided, void(sf::FloatRect, Entity*, sf::FloatRect))

public:
RectCollisionComponent() { }
explicit RectCollisionComponent(Entity& parent) { parent.add(*this); }

void notifyCollision(sf::FloatRect rect, Entity& other, sf::FloatRect otherRect)
{
m_sig_collided(rect, other, otherRect);
m_sig_collided(rect, &other, otherRect);
}
};

Expand Down
8 changes: 4 additions & 4 deletions src/comp/TileCollisionComponent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ typedef sf::Vector3<unsigned> Vector3u;
class TileCollisionComponent: public Component {
JD_COMPONENT

SSIG_DEFINE_MEMBERSIGNAL(collided, void(Vector3u, Entity&, sf::FloatRect))
SSIG_DEFINE_MEMBERSIGNAL(overridden, void(Vector3u, TileCollisionComponent&))
SSIG_DEFINE_MEMBERSIGNAL(collided, void(Vector3u, Entity*, sf::FloatRect))
SSIG_DEFINE_MEMBERSIGNAL(overridden, void(Vector3u, TileCollisionComponent*))

public:
explicit TileCollisionComponent(Entity& parent);
Expand All @@ -35,12 +35,12 @@ class TileCollisionComponent: public Component {

void notifyCollision(Vector3u p, Entity& c, sf::FloatRect cr)
{
m_sig_collided(p, c, cr);
m_sig_collided(p, &c, cr);
}

void notifyOverride(Vector3u p, TileCollisionComponent& c)
{
m_sig_overridden(p, c);
m_sig_overridden(p, &c);
}

TileCollideableInfo const* tileInfo() const { return m_tileinfo.getOpt(); }
Expand Down
7 changes: 2 additions & 5 deletions src/luaexport/RectCollisionComponentMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ static char const libname[] = "RectCollisionComponent";
#include "ExportThis.hpp"


JD_BASIC_EVT_COMPONENT_IMPL(RectCollisionComponent)

JD_EVENT_TABLE_BEGIN(RectCollisionComponent)
JD_EVENT_ENTRY(collided, void, _1, ref(_2), _3)
JD_EVENT_TABLE_END
JD_BASIC_COMPONENT_IMPL(RectCollisionComponent)

static void init(LuaVm& vm)
{
Expand All @@ -24,6 +20,7 @@ static void init(LuaVm& vm)
# define LHCURCLASS RectCollisionComponent
class_<LHCURCLASS, Component, WeakRef<Component>>("RectCollisionComponent")
.def(constructor<Entity&>())
.JD_EVENT(collided, Collided)

# undef LHCURCLASS
];
Expand Down
9 changes: 3 additions & 6 deletions src/luaexport/TileCollisionComponentMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,7 @@ static char const libname[] = "TileCollisionComponent";
#include "ExportThis.hpp"


JD_BASIC_EVT_COMPONENT_IMPL(TileCollisionComponent)

JD_EVENT_TABLE_BEGIN(TileCollisionComponent)
JD_EVENT_ENTRY(collided, void, _1, ref(_2), _3)
JD_EVENT_ENTRY(overridden, void, _1, ref(_2))
JD_EVENT_TABLE_END
JD_BASIC_COMPONENT_IMPL(TileCollisionComponent)

static void init(LuaVm& vm)
{
Expand All @@ -28,6 +23,8 @@ static void init(LuaVm& vm)
class_<LHCURCLASS, Component, WeakRef<Component>>("TileCollisionComponent")
.def(constructor<Entity&, TileCollideableInfo&>())
.def(constructor<Entity&>())
.JD_EVENT(collided, Collided)
.JD_EVENT(overridden, Overriden)

# undef LHCURCLASS
];
Expand Down
7 changes: 2 additions & 5 deletions src/luaexport/TilePositionComponentMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ static char const libname[] = "TilePositionComponent";
#include "ExportThis.hpp"


JD_BASIC_EVT_COMPONENT_IMPL(TilePositionComponent)

JD_EVENT_TABLE_BEGIN(TilePositionComponent)
JD_EVENT_ENTRY(tilePositionChanged, void, _1, _2)
JD_EVENT_TABLE_END
JD_BASIC_COMPONENT_IMPL(TilePositionComponent)

static void init(LuaVm& vm)
{
Expand All @@ -29,6 +25,7 @@ static void init(LuaVm& vm)
.def(constructor<Entity&, jd::Tilemap const&, unsigned>())
.def(constructor<Entity&, jd::Tilemap const&>())
.LHPROPG(tilePosition)
.JD_EVENT(tilePositionChanged, TilePositionChanged)
# undef LHCURCLASS
];
}

0 comments on commit b2e4c74

Please sign in to comment.