[DEV] update new property interface

This commit is contained in:
Edouard DUPIN 2016-03-02 21:51:44 +01:00
parent 7214cbbe8c
commit bf465ce304
6 changed files with 50 additions and 108 deletions

View File

@ -289,15 +289,20 @@ void ege::Environement::generateInteraction(ege::ElementInteraction& _event) {
} }
ege::Environement::Environement() : ege::Environement::Environement() :
signalPlayTimeChange(*this, "time-change"), signalPlayTimeChange(this, "time-change", ""),
propertyStatus(this, "status",
gameStop,
"Satus of the activity of the Environement",
&ege::Environement::onChangePropertyStatus),
propertyRatio(this, "ratio",
1.0f,
"game speed ratio"),
m_listElement(), m_listElement(),
m_status(*this, "status", gameStop, "Satus of the activity of the Environement"),
m_ratio(*this, "ratio", 1.0f, "game speed ratio"),
m_particuleEngine(this) { m_particuleEngine(this) {
// nothing to do ... // nothing to do ...
m_status.add(gameStart, "start", "Scene is started"); propertyStatus.add(gameStart, "start", "Scene is started");
m_status.add(gamePause, "pause", "Scene is paused"); propertyStatus.add(gamePause, "pause", "Scene is paused");
m_status.add(gameStop, "stop", "Scene is stopped"); propertyStatus.add(gameStop, "stop", "Scene is stopped");
} }
void ege::Environement::init(const std::string& _name) { void ege::Environement::init(const std::string& _name) {
@ -310,13 +315,13 @@ void ege::Environement::clear() {
} }
void ege::Environement::periodicCall(const ewol::event::Time& _event) { void ege::Environement::onCallbackPeriodicCall(const ewol::event::Time& _event) {
float curentDelta = _event.getDeltaCall(); float curentDelta = _event.getDeltaCall();
EGE_VERBOSE("periodic call : " << _event); EGE_VERBOSE("periodic call : " << _event);
// small hack to change speed ... // small hack to change speed ...
curentDelta *= m_ratio; curentDelta *= *propertyRatio;
// check if the processing is availlable // check if the processing is availlable
if (m_status.get() == gameStop) { if (propertyStatus.get() == gameStop) {
return; return;
} }
// update game time: // update game time:
@ -388,12 +393,12 @@ std::shared_ptr<ege::Camera> ege::Environement::getCamera(const std::string& _na
} }
void ege::Environement::onPropertyChangeValue(const eproperty::Ref& _paramPointer) { void ege::Environement::onChangePropertyStatus() {
if (_paramPointer == m_status) { if (propertyStatus.get() == gameStart) {
if (m_status.get() == gameStart) { m_periodicCallConnection = getObjectManager().periodicCall.connect(this, &ege::Environement::onCallbackPeriodicCall);
getObjectManager().periodicCall.bind(shared_from_this(), &ege::Environement::periodicCall); } else {
} else { m_periodicCallConnection.disconnect();
getObjectManager().periodicCall.release(shared_from_this());
}
} }
} }

View File

@ -88,8 +88,11 @@ namespace ege {
class Environement : public ewol::Object { class Environement : public ewol::Object {
public: public:
// extern event // Signals
esignal::Signal<float> signalPlayTimeChange; esignal::ISignal<float> signalPlayTimeChange;
// properties:
eproperty::List<enum gameStatus> propertyStatus; //!< the display is running (not in pause)
eproperty::Value<float> propertyRatio; //!< Speed ratio
private: private:
//std::shared_ptr<btDynamicsWorld> m_dynamicsWorld; //!< curent system world description //std::shared_ptr<btDynamicsWorld> m_dynamicsWorld; //!< curent system world description
ege::physics::Engine m_physicEngine; //!< EGE physic engine interface. ege::physics::Engine m_physicEngine; //!< EGE physic engine interface.
@ -101,39 +104,6 @@ namespace ege {
DECLARE_FACTORY(Environement); DECLARE_FACTORY(Environement);
virtual ~Environement() { }; virtual ~Environement() { };
protected: protected:
eproperty::List<enum gameStatus> m_status; //!< the display is running (not in pause)
public:
/**
* @brief Get the game status.
* @return the current status.
*/
enum gameStatus getGameStatus() {
return m_status.get();
}
/**
* @brief Set the game status.
* @param[in] _value New game status.
*/
void setGameStatus(enum gameStatus _value) {
m_status.set(_value);
}
protected:
eproperty::Value<float> m_ratio; //!< Speed ratio
public:
/**
* @brief Get the game speed ratio.
* @return the current ratio.
*/
float getSpeedRatio() {
return m_ratio.get();
}
/**
* @brief Set the game ratio.
* @param[in] _value New game ratio.
*/
void setSpeedRatio(float _value) {
m_ratio.set(_value);
}
protected: protected:
std::map<std::string, std::shared_ptr<ege::Camera>> m_listCamera; //!< list of all camera in the world std::map<std::string, std::shared_ptr<ege::Camera>> m_listCamera; //!< list of all camera in the world
public: public:
@ -260,9 +230,9 @@ namespace ege {
protected: protected:
int64_t m_gameTime; //!< time of the game running int64_t m_gameTime; //!< time of the game running
public: public:
esignal::Connection m_periodicCallConnection;
private: private:
void periodicCall(const ewol::event::Time& _event); void onCallbackPeriodicCall(const ewol::event::Time& _event);
protected: protected:
std::vector<std::shared_ptr<ege::resource::Mesh>> m_listMeshToDrawFirst; std::vector<std::shared_ptr<ege::resource::Mesh>> m_listMeshToDrawFirst;
public: public:
@ -272,7 +242,7 @@ namespace ege {
const std::vector<std::shared_ptr<ege::resource::Mesh>>& getStaticMeshToDraw() { const std::vector<std::shared_ptr<ege::resource::Mesh>>& getStaticMeshToDraw() {
return m_listMeshToDrawFirst; return m_listMeshToDrawFirst;
} }
virtual void onPropertyChangeValue(const eproperty::Ref& _paramPointer); virtual void onChangePropertyStatus();
}; };
} }

View File

@ -17,7 +17,7 @@
ege::widget::Mesh::Mesh(): ege::widget::Mesh::Mesh():
signalPressed(*this, "pressed"), signalPressed(this, "pressed", ""),
m_position(0,0,0), m_position(0,0,0),
m_angle(0,0,0), m_angle(0,0,0),
m_angleSpeed(0,0,0), m_angleSpeed(0,0,0),

View File

@ -18,7 +18,7 @@ namespace ege {
*/ */
class Mesh :public ewol::Widget { class Mesh :public ewol::Widget {
public: public:
esignal::Signal<void> signalPressed; esignal::ISignal<> signalPressed;
private: private:
// mesh name : // mesh name :
std::string m_meshName; std::string m_meshName;

View File

@ -36,10 +36,14 @@ namespace etk {
}; };
ege::widget::Scene::Scene() : ege::widget::Scene::Scene() :
signalDisplayDebug(*this, "drawDebug", "Call to draw debug after all elements"), signalDisplayDebug(this, "drawDebug", "Call to draw debug after all elements"),
m_cameraName("default"), propertyDebugPhysic(this, "debugPhysic",
m_debugPhysic(*this, "debugPhysic", false, "Display debug of the physic interface"), false,
m_debugApplication(*this, "debugApplication", false, "Display debug of the application") { "Display debug of the physic interface"),
propertyDebugApplication(this, "debugApplication",
false,
"Display debug of the application"),
m_cameraName("default") {
addObjectType("ege::widget::Scene"); addObjectType("ege::widget::Scene");
} }
@ -118,7 +122,7 @@ void ege::widget::Scene::onDraw() {
m_displayElementOrdered[iii].element->draw(pass); m_displayElementOrdered[iii].element->draw(pass);
} }
} }
if (m_debugPhysic.get() == true) { if (propertyDebugPhysic.get() == true) {
// Draw debug ... (Object) // Draw debug ... (Object)
for (int32_t iii=m_displayElementOrdered.size()-1; iii >= 0; iii--) { for (int32_t iii=m_displayElementOrdered.size()-1; iii >= 0; iii--) {
m_displayElementOrdered[iii].element->drawDebug(m_debugDrawProperty, camera); m_displayElementOrdered[iii].element->drawDebug(m_debugDrawProperty, camera);
@ -131,7 +135,7 @@ void ege::widget::Scene::onDraw() {
} }
} }
} }
if (m_debugApplication.get() == true) { if (propertyDebugApplication.get() == true) {
// Draw debug ... (User) // Draw debug ... (User)
signalDisplayDebug.emit(m_debugDrawProperty); signalDisplayDebug.emit(m_debugDrawProperty);
} }
@ -185,15 +189,6 @@ void ege::widget::Scene::systemDraw(const ewol::DrawProperty& _displayProp) {
#endif #endif
} }
void ege::widget::Scene::onPropertyChangeValue(const eproperty::Ref& _paramPointer) {
ewol::Widget::onPropertyChangeValue(_paramPointer);
/*
if (_paramPointer == m_isRunning) {
// nothing to do ...
}
*/
}
void ege::widget::Scene::setCamera(const std::string& _cameraName) { void ege::widget::Scene::setCamera(const std::string& _cameraName) {
if (m_cameraName == _cameraName) { if (m_cameraName == _cameraName) {
@ -216,4 +211,6 @@ void ege::widget::Scene::calculateSize() {
} }
} }
#include <esignal/details/ISignal.hxx>
template class esignal::ISignal<std::shared_ptr<ewol::resource::Colored3DObject>>;

View File

@ -35,11 +35,16 @@ class btVector3;
namespace ege { namespace ege {
namespace widget { namespace widget {
class Scene : public ewol::Widget { class Scene : public ewol::Widget {
public:
// signals
esignal::ISignal<std::shared_ptr<ewol::resource::Colored3DObject>/*, std::shared_ptr<ege::Camera>*/> signalDisplayDebug; //!< emit a signal to the application to draw the debug (@ref setDebugPhysic)
// properties
eproperty::Value<bool> propertyDebugPhysic; //!< display Physic Debug
eproperty::Value<bool> propertyDebugApplication; //!< display Application Debug
protected: protected:
std::shared_ptr<ege::Environement> m_env; std::shared_ptr<ege::Environement> m_env;
std::shared_ptr<ewol::resource::Colored3DObject> m_debugDrawProperty; std::shared_ptr<ewol::resource::Colored3DObject> m_debugDrawProperty;
public: public:
esignal::Signal<std::shared_ptr<ewol::resource::Colored3DObject>/*, std::shared_ptr<ege::Camera>*/> signalDisplayDebug; //!< emit a signal to the application to draw the debug (@ref setDebugPhysic)
protected: protected:
/** /**
* @brief Constructor of the widget classes * @brief Constructor of the widget classes
@ -73,46 +78,11 @@ namespace ege {
std::vector<ege::Environement::ResultNearestElement> m_displayElementOrdered; std::vector<ege::Environement::ResultNearestElement> m_displayElementOrdered;
protected: // Derived function protected: // Derived function
virtual void onDraw(); virtual void onDraw();
virtual void onPropertyChangeValue(const eproperty::Ref& _paramPointer);
public: // Derived function public: // Derived function
virtual void systemDraw(const ewol::DrawProperty& _displayProp); virtual void systemDraw(const ewol::DrawProperty& _displayProp);
virtual void onRegenerateDisplay(); virtual void onRegenerateDisplay();
virtual void periodicCall(const ewol::event::Time& _event); virtual void periodicCall(const ewol::event::Time& _event);
virtual void calculateSize(); virtual void calculateSize();
protected:
eproperty::Value<bool> m_debugPhysic; //!< display Physic Debug
public:
/**
* @brief Set the debug display of the physic engine
* @param[in] _status new status of the debug
*/
void setDebugPhysic(bool _status) {
m_debugPhysic.set(_status);
}
/**
* @brief Get the debug display status of the physic engine
* @return The current status of the debug.
*/
bool getDebugPhysic() {
return m_debugPhysic.get();
}
protected:
eproperty::Value<bool> m_debugApplication; //!< display Application Debug
public:
/**
* @brief Set the debug display of the application
* @param[in] _status new status of the debug
*/
void setDebugApplication(bool _status) {
m_debugApplication.set(_status);
}
/**
* @brief Get the debug display status of the application
* @return The current status of the debug.
*/
bool getDebugApplication() {
return m_debugApplication.get();
}
}; };
} }
} }