decide to add a return at message system, and corection of the position event for the scean
This commit is contained in:
parent
527ff05b2c
commit
6b98ad543c
@ -148,7 +148,7 @@ namespace ewol {
|
|||||||
virtual bool HaveImpact(int32_t group, int32_t type, Vector2D<float> position, float size);
|
virtual bool HaveImpact(int32_t group, int32_t type, Vector2D<float> position, float size);
|
||||||
virtual bool Explosion(int32_t group, int32_t type, Vector2D<float> position, float pxAtenuation, float power) { return false; } ;
|
virtual bool Explosion(int32_t group, int32_t type, Vector2D<float> position, float pxAtenuation, float power) { return false; } ;
|
||||||
|
|
||||||
virtual void Message(etk::UString control, etk::UString message) { } ;
|
virtual etk::UString Message(etk::UString control, etk::UString message) { return ""; } ;
|
||||||
virtual void StatusUpdate(void) { };
|
virtual void StatusUpdate(void) { };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -890,7 +890,7 @@ bool ewol::GameElementLua::Explosion(int32_t group, int32_t type, Vector2D<float
|
|||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ewol::GameElementLua::Message(etk::UString control, etk::UString message)
|
etk::UString ewol::GameElementLua::Message(etk::UString control, etk::UString message)
|
||||||
{
|
{
|
||||||
tmpObj = this;
|
tmpObj = this;
|
||||||
if (NULL != m_luaState) {
|
if (NULL != m_luaState) {
|
||||||
@ -908,6 +908,7 @@ void ewol::GameElementLua::Message(etk::UString control, etk::UString message)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
tmpObj = NULL;
|
tmpObj = NULL;
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
static ewol::GameElement* LoadSceneElement_lua(ewol::SceneElement & sceneElement, etk::UString& elementName, etk::UString& userString)
|
static ewol::GameElement* LoadSceneElement_lua(ewol::SceneElement & sceneElement, etk::UString& elementName, etk::UString& userString)
|
||||||
|
@ -49,7 +49,7 @@ namespace ewol {
|
|||||||
virtual void Draw(void);
|
virtual void Draw(void);
|
||||||
virtual bool HaveImpact(int32_t group, int32_t type, Vector2D<float> position, float size);
|
virtual bool HaveImpact(int32_t group, int32_t type, Vector2D<float> position, float size);
|
||||||
virtual bool Explosion(int32_t group, int32_t type, Vector2D<float> position, float pxAtenuation, float power);
|
virtual bool Explosion(int32_t group, int32_t type, Vector2D<float> position, float pxAtenuation, float power);
|
||||||
virtual void Message(etk::UString control, etk::UString message);
|
virtual etk::UString Message(etk::UString control, etk::UString message);
|
||||||
};
|
};
|
||||||
void RegisterLuaElementInFolder(ewol::SceneElement & sceneElement, etk::UString folder);
|
void RegisterLuaElementInFolder(ewol::SceneElement & sceneElement, etk::UString folder);
|
||||||
void RegisterLuaElementSpecify(ewol::SceneElement & sceneElement, etk::UString folder, etk::UString name);
|
void RegisterLuaElementSpecify(ewol::SceneElement & sceneElement, etk::UString folder, etk::UString name);
|
||||||
|
@ -104,7 +104,7 @@ void ewol::SceneElement::RegisterElementType(etk::UString name, creatorElement_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ewol::SceneElement::RmElement(int32_t group, int32_t idElement)
|
void ewol::SceneElement::RmElement(int16_t group, int16_t idElement)
|
||||||
{
|
{
|
||||||
if (group < 0 || group >= MAX_GROUP_NUMBER) {
|
if (group < 0 || group >= MAX_GROUP_NUMBER) {
|
||||||
EWOL_ERROR("group is wrong " << group << "!=[0," << MAX_GROUP_NUMBER << "]==> not rm at the system ...");
|
EWOL_ERROR("group is wrong " << group << "!=[0," << MAX_GROUP_NUMBER << "]==> not rm at the system ...");
|
||||||
@ -117,6 +117,9 @@ void ewol::SceneElement::RmElement(int32_t group, int32_t idElement)
|
|||||||
if (NULL == listAnimatedElements[group][idElement]) {
|
if (NULL == listAnimatedElements[group][idElement]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// inform remove system :
|
||||||
|
SendEventRemove(createUniqueId(listAnimatedElements[group][idElement]->GetUniqueId(), idElement) );
|
||||||
|
|
||||||
// try to find an empty slot :
|
// try to find an empty slot :
|
||||||
for (int32_t iii=0; iii<listGarbage.Size(); iii++) {
|
for (int32_t iii=0; iii<listGarbage.Size(); iii++) {
|
||||||
if (NULL == listGarbage[iii]) {
|
if (NULL == listGarbage[iii]) {
|
||||||
@ -132,6 +135,23 @@ void ewol::SceneElement::RmElement(int32_t group, int32_t idElement)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ewol::SceneElement::RmElement(int32_t idElement)
|
||||||
|
{
|
||||||
|
if (0 == idElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uint16_t realUniqueId = (uint16_t)((idElement >> 16 ) & 0x0000FFFF);
|
||||||
|
uint16_t posInList = (uint16_t)(idElement & 0x0000FFFF);
|
||||||
|
for (int32_t iii=0; iii<numberOfGroup; iii++) {
|
||||||
|
if( posInList < listAnimatedElements[iii].Size()
|
||||||
|
&& NULL != listAnimatedElements[iii][posInList]
|
||||||
|
&& realUniqueId == listAnimatedElements[iii][posInList]->GetUniqueId()) {
|
||||||
|
RmElement(iii, posInList);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t ewol::SceneElement::AddElement(int32_t group, ewol::GameElement* newElement)
|
uint32_t ewol::SceneElement::AddElement(int32_t group, ewol::GameElement* newElement)
|
||||||
{
|
{
|
||||||
if (NULL == newElement) {
|
if (NULL == newElement) {
|
||||||
@ -235,10 +255,7 @@ uint32_t ewol::SceneElement::GetNearestEnemy(Vector2D<float> position, int32_t g
|
|||||||
Vector2D<float> tmpPos = listAnimatedElements[gId][iii]->PositionGet();
|
Vector2D<float> tmpPos = listAnimatedElements[gId][iii]->PositionGet();
|
||||||
float distance = quadDist(position, tmpPos);
|
float distance = quadDist(position, tmpPos);
|
||||||
if( distance <= lastQuadDistance
|
if( distance <= lastQuadDistance
|
||||||
&& ( ( maxRange>0
|
&& maxRange >= distance ) {
|
||||||
&& maxRange >= lastQuadDistance)
|
|
||||||
|| maxRange==0)
|
|
||||||
) {
|
|
||||||
lastQuadDistance = distance;
|
lastQuadDistance = distance;
|
||||||
result = createUniqueId(listAnimatedElements[gId][iii]->GetUniqueId(), iii);
|
result = createUniqueId(listAnimatedElements[gId][iii]->GetUniqueId(), iii);
|
||||||
}
|
}
|
||||||
@ -456,3 +473,41 @@ void ewol::SceneElement::UnLoadSprite(int32_t spriteId)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ewol::SceneElement::AddEarrerDestroy(uint32_t uId)
|
||||||
|
{
|
||||||
|
//EWOL_DEBUG("ADD eraer : " << uId);
|
||||||
|
if (uId==0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
eventDestroy.PushBack(uId);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::SceneElement::RmEarrerDestroy(uint32_t uId)
|
||||||
|
{
|
||||||
|
//EWOL_DEBUG("RM eraer : " << uId);
|
||||||
|
if (uId==0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int32_t iii=0; iii<eventDestroy.Size(); iii++) {
|
||||||
|
if (eventDestroy[iii] == uId) {
|
||||||
|
eventDestroy.Erase(iii);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ewol::SceneElement::SendEventRemove(uint32_t uId)
|
||||||
|
{
|
||||||
|
//EWOL_DEBUG("EVENT eraer : " << uId << " nb earer " << eventDestroy.Size());
|
||||||
|
for (int32_t iii=0; iii<eventDestroy.Size(); iii++) {
|
||||||
|
if (eventDestroy[iii] == uId) {
|
||||||
|
eventDestroy.Erase(iii);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
ewol::GameElement* tmpElem = GetElement(eventDestroy[iii]);
|
||||||
|
if (tmpElem!=NULL) {
|
||||||
|
tmpElem->Message("Destroy", uId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -51,6 +51,7 @@ namespace ewol {
|
|||||||
public:
|
public:
|
||||||
SceneElement(void);
|
SceneElement(void);
|
||||||
~SceneElement(void);
|
~SceneElement(void);
|
||||||
|
etk::Vector<uint32_t> eventDestroy; //!< element uid when element is destroy
|
||||||
int32_t numberOfGroup; //!< curent scene number of group
|
int32_t numberOfGroup; //!< curent scene number of group
|
||||||
etk::UString groupDescription[MAX_GROUP_NUMBER]; //!< name of all the groups
|
etk::UString groupDescription[MAX_GROUP_NUMBER]; //!< name of all the groups
|
||||||
int32_t groupEnemy[MAX_GROUP_NUMBER][MAX_GROUP_NUMBER]; //!< list of the ennemy
|
int32_t groupEnemy[MAX_GROUP_NUMBER][MAX_GROUP_NUMBER]; //!< list of the ennemy
|
||||||
@ -60,11 +61,12 @@ namespace ewol {
|
|||||||
etk::Vector<listRegisteElement*> listCreatorElement; //!< list of all creatable elements
|
etk::Vector<listRegisteElement*> listCreatorElement; //!< list of all creatable elements
|
||||||
int16_t GetUniqueId(void) { int16_t iddd = m_id; m_id++; return iddd; };
|
int16_t GetUniqueId(void) { int16_t iddd = m_id; m_id++; return iddd; };
|
||||||
void RegisterElementType(etk::UString name, creatorElement_tf * loadElement, etk::UString userString);
|
void RegisterElementType(etk::UString name, creatorElement_tf * loadElement, etk::UString userString);
|
||||||
void RmElement(int32_t group, int32_t idElement);
|
void RmElement(int16_t group, int16_t posInList);
|
||||||
|
void RmElement(int32_t elementID);
|
||||||
uint32_t AddElement(int32_t group, ewol::GameElement* newElement);
|
uint32_t AddElement(int32_t group, ewol::GameElement* newElement);
|
||||||
uint32_t AddElementNamed(int32_t group, etk::UString &elementName);
|
uint32_t AddElementNamed(int32_t group, etk::UString &elementName);
|
||||||
ewol::GameElement* GetElement(uint32_t idElement);
|
ewol::GameElement* GetElement(uint32_t idElement);
|
||||||
uint32_t GetNearestEnemy(Vector2D<float> position, int32_t groupId, float maxRange=0);
|
uint32_t GetNearestEnemy(Vector2D<float> position, int32_t groupId, float maxRange=9999999999999999.0);
|
||||||
void GetNearestEnemy(Vector2D<float> position, int32_t groupId, float maxRange, etk::Vector<uint32_t>& list);
|
void GetNearestEnemy(Vector2D<float> position, int32_t groupId, float maxRange, etk::Vector<uint32_t>& list);
|
||||||
uint32_t GetNearestFriend(Vector2D<float> position, int32_t groupId, uint32_t us);
|
uint32_t GetNearestFriend(Vector2D<float> position, int32_t groupId, uint32_t us);
|
||||||
void GetNearestFriend(Vector2D<float> position, int32_t groupId, float maxRange, etk::Vector<uint32_t>& list, uint32_t us);
|
void GetNearestFriend(Vector2D<float> position, int32_t groupId, float maxRange, etk::Vector<uint32_t>& list, uint32_t us);
|
||||||
@ -88,6 +90,9 @@ namespace ewol {
|
|||||||
* @return ---
|
* @return ---
|
||||||
*/
|
*/
|
||||||
void UnLoadSprite(int32_t spriteId);
|
void UnLoadSprite(int32_t spriteId);
|
||||||
|
void AddEarrerDestroy(uint32_t uId);
|
||||||
|
void RmEarrerDestroy(uint32_t uId);
|
||||||
|
void SendEventRemove(uint32_t uId);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -166,7 +166,7 @@ void ewol::Scene::GenDraw(DrawProperty displayProp)
|
|||||||
#ifdef __VIDEO__OPENGL_ES_2
|
#ifdef __VIDEO__OPENGL_ES_2
|
||||||
etk::Matrix tmpProjection;
|
etk::Matrix tmpProjection;
|
||||||
|
|
||||||
if (ratio >= 0.0) {
|
if (ratio >= 1.0) {
|
||||||
tmpProjection = etk::matrix::Perspective(-ratio, ratio, -1, 1, -1, 1);
|
tmpProjection = etk::matrix::Perspective(-ratio, ratio, -1, 1, -1, 1);
|
||||||
} else {
|
} else {
|
||||||
ratio = 1.0/ratio;
|
ratio = 1.0/ratio;
|
||||||
@ -179,7 +179,7 @@ void ewol::Scene::GenDraw(DrawProperty displayProp)
|
|||||||
#else
|
#else
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
if (ratio >= 0.0) {
|
if (ratio >= 1.0) {
|
||||||
glOrthoEwol(-ratio, ratio, -1, 1, -1, 1);
|
glOrthoEwol(-ratio, ratio, -1, 1, -1, 1);
|
||||||
} else {
|
} else {
|
||||||
ratio = 1.0/ratio;
|
ratio = 1.0/ratio;
|
||||||
@ -210,12 +210,30 @@ void ewol::Scene::GenDraw(DrawProperty displayProp)
|
|||||||
*/
|
*/
|
||||||
Vector2D<float> ewol::Scene::RelativePosition(Vector2D<float> pos)
|
Vector2D<float> ewol::Scene::RelativePosition(Vector2D<float> pos)
|
||||||
{
|
{
|
||||||
|
// Remove origin of the widget
|
||||||
pos.x -= m_origin.x;
|
pos.x -= m_origin.x;
|
||||||
pos.y -= m_origin.y;
|
pos.y -= m_origin.y;
|
||||||
|
// move the position at the center (openGl system
|
||||||
pos.x -= m_size.x/2;
|
pos.x -= m_size.x/2;
|
||||||
pos.y -= m_size.y/2;
|
pos.y -= m_size.y/2;
|
||||||
pos.x *= m_zoom;
|
// scale the position with the ratio display of the screen
|
||||||
pos.y *= m_zoom;
|
float ratio = m_size.x / m_size.y;
|
||||||
|
if (ratio >= 1.0) {
|
||||||
|
pos.x /= m_size.x;
|
||||||
|
pos.x *= ratio;
|
||||||
|
pos.y /= m_size.y;
|
||||||
|
} else {
|
||||||
|
ratio = 1.0/ratio;
|
||||||
|
pos.x /= m_size.x;
|
||||||
|
pos.y /= m_size.y;
|
||||||
|
pos.y *= ratio;
|
||||||
|
}
|
||||||
|
// integrate zoom
|
||||||
|
pos.x /= m_zoom;
|
||||||
|
pos.y /= m_zoom;
|
||||||
|
// all the position are half the size due to the fact -1 --> 1
|
||||||
|
pos.x *= 2;
|
||||||
|
pos.y *= 2;
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user