Basic scene, correct sprite display, basic game element, some SVG parser error correction
This commit is contained in:
parent
f2b777f3c0
commit
b7362f524a
125
Sources/libewol/ewol/Game/GameElement.cpp
Normal file
125
Sources/libewol/ewol/Game/GameElement.cpp
Normal file
@ -0,0 +1,125 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/Game/GameElement.cpp
|
||||
* @brief ewol game element system (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 06/04/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#include <ewol/Game/GameElement.h>
|
||||
|
||||
|
||||
/**
|
||||
* @brief Constructor : here are requested all the needed sprite and effect that can be used in the game
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
ewol::GameElement::GameElement(void)
|
||||
{
|
||||
m_visible = true;
|
||||
m_position.x = 0.0;
|
||||
m_position.y = 0.0;
|
||||
m_acceleration.x = 0.0;
|
||||
m_acceleration.y = 0.0;
|
||||
m_size = 64.0;
|
||||
m_angle = 0.0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Destructor : This does not remove the sprite requested, they will be supressed when the scene is removed ...
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
ewol::GameElement::~GameElement(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Periodicly this fuction will be call tu change property of all the dynamic obbjects
|
||||
* @param[in] time Current game time (start at 0)
|
||||
* @param[in] deltaTime delta time before the previous call
|
||||
* @param[in,out] listOfSprite Reference on the list where the display must be done for every sprite
|
||||
* @param[in,out] listOfEffects Reference on the list where the display must be done for every effects
|
||||
* @return true if the object must be remove
|
||||
* @return false if the object must be keep
|
||||
*/
|
||||
bool ewol::GameElement::Process(int64_t time, int32_t deltaTime, etk::VectorType<ewol::GameElement*> & listOfElement)
|
||||
{
|
||||
// nothing to do here ...
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Requuest the draw of the current element, it will be done on the current Sprite list
|
||||
* @param[in,out] listOfSprite Reference on the list where the display must be done for every sprite
|
||||
* @param[in,out] listOfEffects Reference on the list where the display must be done for every effects
|
||||
* @return ---
|
||||
*/
|
||||
void ewol::GameElement::Draw(etk::VectorType<ewol::Sprite*> & listOfSprite, etk::VectorType<ewol::Sprite*> & listOfEffects)
|
||||
{
|
||||
// nothing to do here ...
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief an element has been remove, just remove reference on it or ID on IT, it can be replace whith an other that have no link
|
||||
* @param[in] idOfElement Id of the element that has been removed
|
||||
* @return ---
|
||||
*/
|
||||
void ewol::GameElement::RemoveElement(int32_t idOfElement)
|
||||
{
|
||||
// nothing to do here ...
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Requuest the draw of the current element, it will be done on the current Sprite list
|
||||
* @param[in,out] listOfElement Reference on the list of sprite that we need to find if it exist or added a new one
|
||||
* @param[in] fileName Sprite name
|
||||
* @param[in] maxSize maximum size of the sprite
|
||||
* @return the id of the sprite requested or -1 if it does not existed
|
||||
*/
|
||||
int32_t ewol::GameElement::LoadSprite(etk::VectorType<ewol::Sprite*> listOfElement[NB_BOUBLE_BUFFER], etk::UString fileName, coord2D_ts maxSize)
|
||||
{
|
||||
for (int32_t iii=0; iii<listOfElement[0].Size(); iii++) {
|
||||
if (listOfElement[0][iii] != NULL) {
|
||||
if (listOfElement[0][iii]->HasName(fileName) == true) {
|
||||
// TODO : control the size ...
|
||||
return iii;
|
||||
}
|
||||
}
|
||||
}
|
||||
for(int32_t iii=0; iii<NB_BOUBLE_BUFFER; iii++) {
|
||||
// we did not find the sprite ==> created it ...
|
||||
ewol::Sprite* tmpSprite = new ewol::Sprite(fileName, maxSize.x, maxSize.y);
|
||||
if (NULL == tmpSprite) {
|
||||
EWOL_ERROR("Allocation error on the sprite : " << fileName);
|
||||
return -1;
|
||||
}
|
||||
// add it :
|
||||
listOfElement[iii].PushBack(tmpSprite);
|
||||
}
|
||||
return listOfElement[0].Size() -1;
|
||||
}
|
||||
|
65
Sources/libewol/ewol/Game/GameElement.h
Normal file
65
Sources/libewol/ewol/Game/GameElement.h
Normal file
@ -0,0 +1,65 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file ewol/Game/GameElement.h
|
||||
* @brief ewol game element system (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 06/04/2012
|
||||
* @par Project
|
||||
* ewol
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __EWOL_GAME_ELEMENT_H__
|
||||
#define __EWOL_GAME_ELEMENT_H__
|
||||
|
||||
#include <etk/Types.h>
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/OObject/Sprite.h>
|
||||
#include <ewol/Widget.h>
|
||||
|
||||
|
||||
namespace ewol {
|
||||
class GameElement
|
||||
{
|
||||
protected:
|
||||
bool m_visible;
|
||||
coord2D_ts m_position;
|
||||
coord2D_ts m_acceleration;
|
||||
etkFloat_t m_size;
|
||||
etkFloat_t m_angle;
|
||||
public:
|
||||
GameElement(void);
|
||||
virtual ~GameElement(void);
|
||||
bool IsVisible(void) { return m_visible; };
|
||||
void SetVisible(bool state) { m_visible = state; };
|
||||
coord2D_ts PositionGet(void) { return m_position; };
|
||||
void PositionSet(coord2D_ts state) { m_position = state; };
|
||||
void PositionSet(etkFloat_t xxx, etkFloat_t yyy) { m_position.x = xxx; m_position.y = yyy; };
|
||||
coord2D_ts AccelerationGet(void) { return m_acceleration; };
|
||||
void AccelerationSet(coord2D_ts state) { m_acceleration = state; };
|
||||
etkFloat_t SizeGet(void) { return m_size; };
|
||||
void SizeSet(etkFloat_t state) { m_size = state; };
|
||||
etkFloat_t AngleGet(void) { return m_angle; };
|
||||
void AngleSet(etkFloat_t state) { m_angle = state; };
|
||||
virtual bool Process(int64_t time, int32_t deltaTime, etk::VectorType<ewol::GameElement*> & listOfElement);
|
||||
virtual void Draw(etk::VectorType<ewol::Sprite*> & listOfSprite, etk::VectorType<ewol::Sprite*> & listOfEffects);
|
||||
virtual void RemoveElement(int32_t idOfElement);
|
||||
int32_t LoadSprite(etk::VectorType<ewol::Sprite*> listOfElement[NB_BOUBLE_BUFFER], etk::UString fileName, coord2D_ts maxSize);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
#endif
|
@ -25,6 +25,7 @@
|
||||
#include <ewol/OObject/Sprite.h>
|
||||
#include <ewol/Texture.h>
|
||||
#include <ewol/importgl.h>
|
||||
#include <math.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "Sprite"
|
||||
@ -53,7 +54,7 @@ ewol::Sprite::~Sprite(void)
|
||||
void ewol::Sprite::Draw(void)
|
||||
{
|
||||
if (m_coord.Size()<=0) {
|
||||
EWOL_WARNING("Nothink to draw...");
|
||||
//EWOL_WARNING("Nothink to draw...");
|
||||
return;
|
||||
}
|
||||
if (m_textureId == -1) {
|
||||
@ -75,56 +76,56 @@ void ewol::Sprite::Draw(void)
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
void ewol::Sprite::Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t texX, etkFloat_t texY, etkFloat_t texSX, etkFloat_t texSY)
|
||||
void ewol::Sprite::Clear(void)
|
||||
{
|
||||
//EWOL_DEBUG("Add rectangle : ...");
|
||||
coord2D_ts point;
|
||||
texCoord_ts tex;
|
||||
|
||||
tex.u = texX;
|
||||
tex.v = texY;
|
||||
point.x = x;
|
||||
point.y = y;
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
|
||||
|
||||
tex.u = texSX;
|
||||
tex.v = texY;
|
||||
point.x = x + w;
|
||||
point.y = y;
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
|
||||
|
||||
tex.u = texSX;
|
||||
tex.v = texSY;
|
||||
point.x = x + w;
|
||||
point.y = y + h;
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
|
||||
tex.u = texX;
|
||||
tex.v = texSY;
|
||||
point.x = x;
|
||||
point.y = y + h;
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
|
||||
tex.u = texX;
|
||||
tex.v = texY;
|
||||
point.x = x;
|
||||
point.y = y;
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(tex);
|
||||
m_coord.Clear();
|
||||
m_coordTex.Clear();
|
||||
}
|
||||
|
||||
|
||||
void Element(coord2D_ts pos, etkFloat_t size, etkFloat_t angle)
|
||||
void ewol::Sprite::Element(coord2D_ts pos, etkFloat_t size, etkFloat_t angle)
|
||||
{
|
||||
angle -= M_PI/4;
|
||||
size *= 0.7;
|
||||
texCoord_ts texA, texB, texC, texD;
|
||||
texA.u = 0.0;
|
||||
texA.v = 0.0;
|
||||
texB.u = 0.0;
|
||||
texB.v = 1.0;
|
||||
texC.u = 1.0;
|
||||
texC.v = 1.0;
|
||||
texD.u = 1.0;
|
||||
texD.v = 0.0;
|
||||
|
||||
coord2D_ts point;
|
||||
etkFloat_t yyySin = sin(angle) * size;
|
||||
etkFloat_t xxxCos = cos(angle) * size;
|
||||
|
||||
point.x = xxxCos + pos.x;
|
||||
point.y = yyySin + pos.y;
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(texB);
|
||||
|
||||
point.x = yyySin + pos.x;
|
||||
point.y = -xxxCos + pos.y;
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(texC);
|
||||
|
||||
point.x = -xxxCos + pos.x;
|
||||
point.y = -yyySin + pos.y;
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(texD);
|
||||
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(texD);
|
||||
|
||||
point.x = -yyySin + pos.x;
|
||||
point.y = xxxCos + pos.y;
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(texA);
|
||||
|
||||
point.x = xxxCos + pos.x;
|
||||
point.y = yyySin + pos.y;
|
||||
m_coord.PushBack(point);
|
||||
m_coordTex.PushBack(texB);
|
||||
}
|
||||
|
||||
|
@ -36,10 +36,10 @@ namespace ewol {
|
||||
Sprite(etk::UString spriteName);
|
||||
Sprite(etk::UString spriteName, etkFloat_t sizeX, etkFloat_t sizeY);
|
||||
virtual ~Sprite(void);
|
||||
public:
|
||||
virtual void Draw(void);
|
||||
void Rectangle(etkFloat_t x, etkFloat_t y, etkFloat_t w, etkFloat_t h, etkFloat_t texX=0.0, etkFloat_t texY=0.0, etkFloat_t texSX=1.0, etkFloat_t texSY=1.0);
|
||||
void Clear(void);
|
||||
void Element(coord2D_ts pos, etkFloat_t size, etkFloat_t angle);
|
||||
bool HasName(etk::UString& name) { return name == m_name; };
|
||||
protected:
|
||||
int32_t m_textureId; //!< texture internal ID
|
||||
etk::VectorType<coord2D_ts> m_coord; //!< internal coord of the object
|
||||
|
@ -276,3 +276,17 @@ void ewol::Widget::GenDraw(void)
|
||||
glPopMatrix();
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Request that the current widegt have a periodic call
|
||||
* @param statusToSet true if the periodic call is needed
|
||||
* @return ---
|
||||
*/
|
||||
void ewol::Widget::PeriodicCallSet(bool statusToSet)
|
||||
{
|
||||
if (true == statusToSet) {
|
||||
ewol::widgetManager::PeriodicCallAdd(this);
|
||||
} else {
|
||||
ewol::widgetManager::PeriodicCallRm(this);
|
||||
}
|
||||
}
|
@ -317,7 +317,21 @@ namespace ewol {
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnLostFocus(void) {};
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Request that the current widegt have a periodic call
|
||||
* @param statusToSet true if the periodic call is needed
|
||||
* @return ---
|
||||
*/
|
||||
void PeriodicCallSet(bool statusToSet);
|
||||
public:
|
||||
/**
|
||||
* @brief Periodic call of this widget
|
||||
* @param localTime curent system time
|
||||
* @return ---
|
||||
*/
|
||||
virtual void PeriodicCall(int64_t localTime) { };
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Get the widget at the specific windows absolute position
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include <ewol/widget/Button.h>
|
||||
#include <ewol/widget/ButtonColor.h>
|
||||
//#include <ewol/widget/Scene.h>
|
||||
#include <etk/VectorType.h>
|
||||
|
||||
#undef __class__
|
||||
#define __class__ "WidgetManager"
|
||||
@ -37,6 +38,8 @@ static bool IsInit = false;
|
||||
// For the focus Management
|
||||
static ewol::Widget * m_focusWidgetDefault = NULL;
|
||||
static ewol::Widget * m_focusWidgetCurrent = NULL;
|
||||
static etk::VectorType<ewol::Widget*> l_listOfPeriodicWidget;
|
||||
static bool l_havePeriodic = false;
|
||||
|
||||
void ewol::widgetManager::Init(void)
|
||||
{
|
||||
@ -47,6 +50,8 @@ void ewol::widgetManager::Init(void)
|
||||
// prevent android error ==> can create memory leak but I prefer
|
||||
m_focusWidgetDefault = NULL;
|
||||
m_focusWidgetCurrent = NULL;
|
||||
l_listOfPeriodicWidget.Clear();
|
||||
l_havePeriodic = false;
|
||||
// init all the widget global parameters :
|
||||
ewol::WIDGET_JoystickInit();
|
||||
ewol::WIDGET_ButtonInit();
|
||||
@ -64,12 +69,14 @@ void ewol::widgetManager::UnInit(void)
|
||||
|
||||
IsInit = false;
|
||||
|
||||
l_listOfPeriodicWidget.Clear();
|
||||
int ret = pthread_mutex_destroy(&localMutex);
|
||||
EWOL_ASSERT(ret == 0, "Error destroying Mutex ...");
|
||||
}
|
||||
|
||||
void ewol::widgetManager::Rm(ewol::Widget * newWidget)
|
||||
{
|
||||
PeriodicCallRm(newWidget);
|
||||
FocusRemoveIfRemove(newWidget);
|
||||
}
|
||||
|
||||
@ -160,6 +167,54 @@ void ewol::widgetManager::FocusRemoveIfRemove(ewol::Widget * newWidget)
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ewol::widgetManager::PeriodicCallAdd(ewol::Widget * pWidget)
|
||||
{
|
||||
for (int32_t iii=0; iii < l_listOfPeriodicWidget.Size(); iii++) {
|
||||
if (l_listOfPeriodicWidget[iii] == pWidget) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (int32_t iii=0; iii < l_listOfPeriodicWidget.Size(); iii++) {
|
||||
if (NULL == l_listOfPeriodicWidget[iii]) {
|
||||
l_listOfPeriodicWidget[iii] = pWidget;
|
||||
return;
|
||||
}
|
||||
}
|
||||
l_listOfPeriodicWidget.PushBack(pWidget);
|
||||
l_havePeriodic = true;
|
||||
}
|
||||
|
||||
void ewol::widgetManager::PeriodicCallRm(ewol::Widget * pWidget)
|
||||
{
|
||||
int32_t nbElement = 0;
|
||||
for (int32_t iii=0; iii < l_listOfPeriodicWidget.Size(); iii++) {
|
||||
if (l_listOfPeriodicWidget[iii] == pWidget) {
|
||||
l_listOfPeriodicWidget[iii] = NULL;
|
||||
} else {
|
||||
nbElement++;
|
||||
}
|
||||
}
|
||||
if (0 == nbElement) {
|
||||
l_havePeriodic = false;
|
||||
}
|
||||
}
|
||||
|
||||
void ewol::widgetManager::PeriodicCall(int64_t localTime)
|
||||
{
|
||||
for (int32_t iii=0; iii < l_listOfPeriodicWidget.Size(); iii++) {
|
||||
if (NULL != l_listOfPeriodicWidget[iii]) {
|
||||
l_listOfPeriodicWidget[iii]->PeriodicCall(localTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ewol::widgetManager::PeriodicCallHave(void)
|
||||
{
|
||||
return l_havePeriodic;
|
||||
}
|
||||
|
||||
|
||||
static bool needRedraw = true;
|
||||
|
||||
void ewol::widgetManager::DoubleBufferLock(void)
|
||||
|
@ -44,6 +44,13 @@ namespace ewol {
|
||||
ewol::Widget * FocusGet( void);
|
||||
void FocusRemoveIfRemove(ewol::Widget * newWidget);
|
||||
|
||||
|
||||
void PeriodicCallAdd(ewol::Widget * pWidget);
|
||||
void PeriodicCallRm( ewol::Widget * pWidget);
|
||||
void PeriodicCall(int64_t localTime);
|
||||
bool PeriodicCallHave(void);
|
||||
|
||||
|
||||
// TODO : Remove this from here ...
|
||||
int32_t GetDoubleBufferCreate(void);
|
||||
int32_t GetDoubleBufferDraw(void);
|
||||
|
@ -194,6 +194,10 @@ static void* BaseAppEntry(void* param)
|
||||
}
|
||||
if (0 == ewol::threadMsg::WaitingMessage(androidJniMsg)) {
|
||||
if (countNbEvent > 0) {
|
||||
if(true == ewol::threadMsg::HasDisplayDone(androidJniMsg)) {
|
||||
|
||||
ewol::widgetManager::PeriodicCall(0);
|
||||
}
|
||||
EWOL_NativeRegenerateDisplay();
|
||||
countNbEvent = 0;
|
||||
}
|
||||
|
@ -173,6 +173,9 @@ void EWOL_GenericDraw(bool everyTime)
|
||||
if ( (currentTime - startTime) > DISPLAY_PERIODE_MS) {
|
||||
display = true;
|
||||
}
|
||||
if (ewol::widgetManager::PeriodicCallHave()) {
|
||||
everyTime = true;
|
||||
}
|
||||
ewol::widgetManager::DoubleBufferLock();
|
||||
if( true == ewol::widgetManager::GetDoubleBufferNeedDraw()
|
||||
|| true == everyTime)
|
||||
|
@ -182,10 +182,31 @@ int32_t ewol::threadMsg::WaitingMessage(threadMsg_ts& messageData)
|
||||
|
||||
void ewol::threadMsg::SendDisplayDone(threadMsg_ts& messageData)
|
||||
{
|
||||
if (false == messageData.isInit) {
|
||||
return;
|
||||
}
|
||||
pthread_mutex_lock(&messageData.mutex);
|
||||
messageData.displayHasDone = true;
|
||||
pthread_cond_broadcast(&messageData.condition);
|
||||
pthread_mutex_unlock(&messageData.mutex);
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool ewol::threadMsg::HasDisplayDone(threadMsg_ts& messageData)
|
||||
{
|
||||
if (false == messageData.isInit) {
|
||||
return false;
|
||||
}
|
||||
bool state = false;
|
||||
pthread_mutex_lock(&messageData.mutex);
|
||||
state = messageData.displayHasDone;
|
||||
messageData.displayHasDone = false;;
|
||||
pthread_mutex_unlock(&messageData.mutex);
|
||||
return state;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
|
@ -65,6 +65,7 @@ namespace ewol {
|
||||
int32_t WaitingMessage(threadMsg_ts& messageData);
|
||||
bool SendMessage(threadMsg_ts& messageData, uint32_t type, msgPriority_te prio = MSG_PRIO_NONE, void * data = NULL, uint32_t size = 0);
|
||||
void SendDisplayDone(threadMsg_ts& messageData);
|
||||
bool HasDisplayDone(threadMsg_ts& messageData);
|
||||
};
|
||||
|
||||
namespace simpleMsg {
|
||||
|
@ -343,3 +343,17 @@ void ewol::Joystick::Foreground(etk::UString imageNameInData)
|
||||
EWOL_INFO("Set default Joystick Foreground at " << m_foreground);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the property of the joystick
|
||||
* @param[out] distance distance to the center
|
||||
* @param[out] angle angle of the joy
|
||||
* @return ---
|
||||
*/
|
||||
void ewol::Joystick::GetProperty(etkFloat_t& distance, etkFloat_t& angle)
|
||||
{
|
||||
distance = m_distance;
|
||||
angle = m_angle+M_PI/2;
|
||||
}
|
||||
|
||||
|
||||
|
@ -112,6 +112,15 @@ namespace ewol {
|
||||
* @return ---
|
||||
*/
|
||||
void Foreground(etk::UString imageNameInData);
|
||||
|
||||
/**
|
||||
* @brief Get the property of the joystick
|
||||
* @param[out] distance distance to the center
|
||||
* @param[out] angle angle of the joy
|
||||
* @return ---
|
||||
*/
|
||||
void GetProperty(etkFloat_t& distance, etkFloat_t& angle);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -45,6 +45,7 @@ void ewol::WIDGET_SceneInit(void)
|
||||
ewol::Scene::Scene(void)
|
||||
{
|
||||
SetCanHaveFocus(true);
|
||||
PeriodicCallSet(true);
|
||||
}
|
||||
|
||||
|
||||
@ -95,5 +96,85 @@ const char * const ewol::Scene::GetObjectType(void)
|
||||
void ewol::Scene::OnRegenerateDisplay(void)
|
||||
{
|
||||
if (true == NeedRedraw()) {
|
||||
// clean elements
|
||||
for (int32_t iii=0; iii<m_animated[m_currentCreateId].Size(); iii++) {
|
||||
if (NULL != m_animated[m_currentCreateId][iii]) {
|
||||
m_animated[m_currentCreateId][iii]->Clear();
|
||||
}
|
||||
}
|
||||
// clean effects
|
||||
for (int32_t iii=0; iii<m_effects[m_currentCreateId].Size(); iii++) {
|
||||
if (NULL != m_effects[m_currentCreateId][iii]) {
|
||||
m_effects[m_currentCreateId][iii]->Clear();
|
||||
}
|
||||
}
|
||||
for (int32_t iii=0; iii<m_listAnimatedElements.Size(); iii++) {
|
||||
if (NULL != m_listAnimatedElements[iii]) {
|
||||
// find an empty slot ...
|
||||
m_listAnimatedElements[iii]->Draw(m_animated[m_currentCreateId], m_effects[m_currentCreateId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Common widget drawing function (called by the drawing thread [Android, X11, ...])
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
void ewol::Scene::OnDraw(void)
|
||||
{
|
||||
//EWOL_ERROR(" On draw : " << m_currentDrawId);
|
||||
// draw background
|
||||
// TODO : ...
|
||||
// draw elements
|
||||
for (int32_t iii=0; iii<m_animated[m_currentDrawId].Size(); iii++) {
|
||||
if (NULL != m_animated[m_currentDrawId][iii]) {
|
||||
m_animated[m_currentDrawId][iii]->Draw();
|
||||
}
|
||||
}
|
||||
// draw effects
|
||||
for (int32_t iii=0; iii<m_effects[m_currentDrawId].Size(); iii++) {
|
||||
if (NULL != m_effects[m_currentDrawId][iii]) {
|
||||
m_effects[m_currentDrawId][iii]->Draw();
|
||||
}
|
||||
}
|
||||
m_needFlipFlop = true;
|
||||
}
|
||||
|
||||
|
||||
void ewol::Scene::AddElement(ewol::GameElement* newElement)
|
||||
{
|
||||
if (NULL == newElement) {
|
||||
return;
|
||||
}
|
||||
for (int32_t iii=0; iii<m_listAnimatedElements.Size(); iii++) {
|
||||
if (NULL == m_listAnimatedElements[iii]) {
|
||||
// find an empty slot ...
|
||||
m_listAnimatedElements[iii] = newElement;
|
||||
return;
|
||||
}
|
||||
}
|
||||
//did not find empty slot :
|
||||
m_listAnimatedElements.PushBack(newElement);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Periodic call of this widget
|
||||
* @param localTime curent system time
|
||||
* @return ---
|
||||
*/
|
||||
void ewol::Scene::PeriodicCall(int64_t localTime)
|
||||
{
|
||||
//EWOL_ERROR("Periodic Call ... " << localTime);
|
||||
for (int32_t iii=0; iii<m_listAnimatedElements.Size(); iii++) {
|
||||
if (NULL != m_listAnimatedElements[iii]) {
|
||||
// find an empty slot ...
|
||||
m_listAnimatedElements[iii]->Process(localTime, 100, m_listAnimatedElements);
|
||||
}
|
||||
}
|
||||
MarkToReedraw();
|
||||
}
|
||||
|
||||
|
||||
|
@ -27,27 +27,19 @@
|
||||
|
||||
#include <etk/Types.h>
|
||||
#include <ewol/Debug.h>
|
||||
#include <ewol/OObject/Sprite.h>
|
||||
#include <ewol/widget/WidgetScrolled.h>
|
||||
#include <ewol/OObject/Sprite.h>
|
||||
#include <ewol/Game/GameElement.h>
|
||||
|
||||
|
||||
namespace ewol {
|
||||
class GameElement
|
||||
{
|
||||
private:
|
||||
bool m_visible;
|
||||
coord2D_ts m_position;
|
||||
public:
|
||||
GameElement(void) { m_visible = true; m_position.x=0.0; m_position.y=0.0;};
|
||||
virtual ~GameElement(void) {};
|
||||
};
|
||||
|
||||
class Scene :public ewol::WidgetScrooled
|
||||
{
|
||||
// TODO : Set it in private ...
|
||||
protected:
|
||||
etk::VectorType<ewol::OObject*> m_backgroundElements[NB_BOUBLE_BUFFER]; //!< element that must be display the first
|
||||
etk::VectorType<ewol::Sprite*> m_backgrouanimatedElements[NB_BOUBLE_BUFFER]; //!< element that must be display the first
|
||||
etk::VectorType<ewol::Sprite*> m_animated[NB_BOUBLE_BUFFER]; //!< element that must be display the first
|
||||
etk::VectorType<ewol::Sprite*> m_effects[NB_BOUBLE_BUFFER]; //!< element that must be display the first
|
||||
etk::VectorType<ewol::GameElement*> m_listAnimatedElements; //!< generic element to display...
|
||||
public:
|
||||
Scene(void);
|
||||
@ -68,6 +60,20 @@ namespace ewol {
|
||||
*/
|
||||
virtual const char * const GetObjectType(void);
|
||||
virtual void OnRegenerateDisplay(void);
|
||||
|
||||
/**
|
||||
* @brief Periodic call of this widget
|
||||
* @param localTime curent system time
|
||||
* @return ---
|
||||
*/
|
||||
virtual void PeriodicCall(int64_t localTime);
|
||||
/**
|
||||
* @brief Common widget drawing function (called by the drawing thread [Android, X11, ...])
|
||||
* @param ---
|
||||
* @return ---
|
||||
*/
|
||||
virtual void OnDraw(void);
|
||||
void AddElement(ewol::GameElement* newElement);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -10,6 +10,7 @@ FILE_LIST = ewol/ewol.cpp \
|
||||
ewol/EObject.cpp \
|
||||
ewol/EObjectManager.cpp \
|
||||
ewol/OObject.cpp \
|
||||
ewol/Game/GameElement.cpp \
|
||||
ewol/OObject/2DText.cpp \
|
||||
ewol/OObject/2DTextColored.cpp \
|
||||
ewol/OObject/2DColored.cpp \
|
||||
|
@ -228,6 +228,61 @@ void svg::Base::ParsePaintAttr(const TiXmlNode *node)
|
||||
if (NULL != content) {
|
||||
m_paint.strokeWidth = ParseLength(content);
|
||||
}
|
||||
content = node->ToElement()->Attribute("opacity");
|
||||
if (NULL != content) {
|
||||
etkFloat_t opacity = ParseLength(content);
|
||||
opacity = etk_max(0.0, etk_min(1.0, opacity));
|
||||
m_paint.fill.alpha = opacity*0xFF;
|
||||
m_paint.stroke.alpha = opacity*0xFF;
|
||||
}
|
||||
content = node->ToElement()->Attribute("fill-opacity");
|
||||
if (NULL != content) {
|
||||
etkFloat_t opacity = ParseLength(content);
|
||||
opacity = etk_max(0.0, etk_min(1.0, opacity));
|
||||
m_paint.fill.alpha = opacity*0xFF;
|
||||
}
|
||||
content = node->ToElement()->Attribute("stroke-opacity");
|
||||
if (NULL != content) {
|
||||
etkFloat_t opacity = ParseLength(content);
|
||||
opacity = etk_max(0.0, etk_min(1.0, opacity));
|
||||
m_paint.stroke.alpha = opacity*0xFF;
|
||||
}
|
||||
content = node->ToElement()->Attribute("fill-rule");
|
||||
if (NULL != content) {
|
||||
if (0 == strcmp(content, "nonzero") ) {
|
||||
m_paint.flagEvenOdd = false;
|
||||
} else if (0 == strcmp(content, "evenodd") ) {
|
||||
m_paint.flagEvenOdd = true;
|
||||
} else {
|
||||
SVG_ERROR("not know fill-rule value : \"" << content << "\", not in [nonzero,evenodd]");
|
||||
}
|
||||
}
|
||||
content = node->ToElement()->Attribute("stroke-linecap");
|
||||
if (NULL != content) {
|
||||
if (0 == strcmp(content, "butt") ) {
|
||||
m_paint.lineCap = svg::LINECAP_BUTT;
|
||||
} else if (0 == strcmp(content, "round") ) {
|
||||
m_paint.lineCap = svg::LINECAP_ROUND;
|
||||
} else if (0 == strcmp(content, "square") ) {
|
||||
m_paint.lineCap = svg::LINECAP_SQUARE;
|
||||
} else {
|
||||
m_paint.lineCap = svg::LINECAP_BUTT;
|
||||
SVG_ERROR("not know stroke-linecap value : \"" << content << "\", not in [butt,round,square]");
|
||||
}
|
||||
}
|
||||
content = node->ToElement()->Attribute("stroke-linejoin");
|
||||
if (NULL != content) {
|
||||
if (0 == strcmp(content, "miter") ) {
|
||||
m_paint.lineJoin = svg::LINEJOIN_MITER;
|
||||
} else if (0 == strcmp(content, "round") ) {
|
||||
m_paint.lineJoin = svg::LINEJOIN_ROUND;
|
||||
} else if (0 == strcmp(content, "bevel") ) {
|
||||
m_paint.lineJoin = svg::LINEJOIN_BEVEL;
|
||||
} else {
|
||||
m_paint.lineJoin = svg::LINEJOIN_MITER;
|
||||
SVG_ERROR("not know stroke-linejoin value : \"" << content << "\", not in [miter,round,bevel]");
|
||||
}
|
||||
}
|
||||
content = node->ToElement()->Attribute("style");
|
||||
if (NULL != content) {
|
||||
char outputType[1024] = "";
|
||||
@ -287,6 +342,8 @@ void svg::Base::ParsePaintAttr(const TiXmlNode *node)
|
||||
m_paint.lineJoin = svg::LINEJOIN_MITER;
|
||||
SVG_ERROR("not know " << outputType << " value : \"" << outputValue << "\", not in [miter,round,bevel]");
|
||||
}
|
||||
} else if (0 == strcmp(outputType, "marker-start") ) {
|
||||
// TODO : ...
|
||||
} else {
|
||||
SVG_ERROR("not know painting element in style balise : \"" << outputType << "\" with value : \"" << outputValue << "\"");
|
||||
}
|
||||
@ -491,7 +548,7 @@ color8_ts svg::Base::ParseColor(const char *inputData)
|
||||
uint32_t red, green, blue, alpha;
|
||||
float fred, fgreen, fblue, falpha;
|
||||
size_t len = strlen(inputData);
|
||||
|
||||
|
||||
if( len >=1
|
||||
&& inputData[0] == '#') {
|
||||
if(len == 4) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user