From b2e4c7471c65d23b4661d3bb74775371a8f9e65f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Neun=C3=BCller?= Date: Fri, 26 Jul 2013 15:03:25 +0200 Subject: [PATCH] Components: Switch to new style events. --- src/comp/PositionComponent.cpp | 7 ++----- src/comp/RectCollisionComponent.hpp | 4 ++-- src/comp/TileCollisionComponent.hpp | 8 ++++---- src/luaexport/RectCollisionComponentMeta.cpp | 7 ++----- src/luaexport/TileCollisionComponentMeta.cpp | 9 +++------ src/luaexport/TilePositionComponentMeta.cpp | 7 ++----- 6 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/comp/PositionComponent.cpp b/src/comp/PositionComponent.cpp index 1b32e11..11dbc6d 100644 --- a/src/comp/PositionComponent.cpp +++ b/src/comp/PositionComponent.cpp @@ -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) { @@ -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 ]; diff --git a/src/comp/RectCollisionComponent.hpp b/src/comp/RectCollisionComponent.hpp index 03990cd..76fe85e 100644 --- a/src/comp/RectCollisionComponent.hpp +++ b/src/comp/RectCollisionComponent.hpp @@ -17,7 +17,7 @@ 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() { } @@ -25,7 +25,7 @@ class RectCollisionComponent: public Component { void notifyCollision(sf::FloatRect rect, Entity& other, sf::FloatRect otherRect) { - m_sig_collided(rect, other, otherRect); + m_sig_collided(rect, &other, otherRect); } }; diff --git a/src/comp/TileCollisionComponent.hpp b/src/comp/TileCollisionComponent.hpp index c1f1300..bc5c5f9 100644 --- a/src/comp/TileCollisionComponent.hpp +++ b/src/comp/TileCollisionComponent.hpp @@ -21,8 +21,8 @@ typedef sf::Vector3 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); @@ -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(); } diff --git a/src/luaexport/RectCollisionComponentMeta.cpp b/src/luaexport/RectCollisionComponentMeta.cpp index 22832bf..3785a46 100644 --- a/src/luaexport/RectCollisionComponentMeta.cpp +++ b/src/luaexport/RectCollisionComponentMeta.cpp @@ -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) { @@ -24,6 +20,7 @@ static void init(LuaVm& vm) # define LHCURCLASS RectCollisionComponent class_>("RectCollisionComponent") .def(constructor()) + .JD_EVENT(collided, Collided) # undef LHCURCLASS ]; diff --git a/src/luaexport/TileCollisionComponentMeta.cpp b/src/luaexport/TileCollisionComponentMeta.cpp index bdb3d92..65265d2 100644 --- a/src/luaexport/TileCollisionComponentMeta.cpp +++ b/src/luaexport/TileCollisionComponentMeta.cpp @@ -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) { @@ -28,6 +23,8 @@ static void init(LuaVm& vm) class_>("TileCollisionComponent") .def(constructor()) .def(constructor()) + .JD_EVENT(collided, Collided) + .JD_EVENT(overridden, Overriden) # undef LHCURCLASS ]; diff --git a/src/luaexport/TilePositionComponentMeta.cpp b/src/luaexport/TilePositionComponentMeta.cpp index 9ed189d..63de5c4 100644 --- a/src/luaexport/TilePositionComponentMeta.cpp +++ b/src/luaexport/TilePositionComponentMeta.cpp @@ -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) { @@ -29,6 +25,7 @@ static void init(LuaVm& vm) .def(constructor()) .def(constructor()) .LHPROPG(tilePosition) + .JD_EVENT(tilePositionChanged, TilePositionChanged) # undef LHCURCLASS ]; }