2017-10-12 23:34:13 +08:00
|
|
|
#include "..\ebase.h"
|
|
|
|
|
#include "..\enodes.h"
|
2017-10-14 01:07:34 +08:00
|
|
|
#include "..\emsg.h"
|
2017-10-17 21:22:25 +08:00
|
|
|
#include "..\etools.h"
|
2017-10-14 18:43:32 +08:00
|
|
|
#include <algorithm>
|
2017-09-10 23:56:52 +08:00
|
|
|
|
2017-10-14 18:43:32 +08:00
|
|
|
e2d::EScene::EScene()
|
|
|
|
|
: m_bWillSave(true)
|
|
|
|
|
, m_bSortNeeded(false)
|
2017-10-19 13:06:14 +08:00
|
|
|
, m_pRoot(new ENode())
|
2017-10-14 18:43:32 +08:00
|
|
|
{
|
2017-10-19 13:06:14 +08:00
|
|
|
m_pRoot->_onEnter();
|
|
|
|
|
m_pRoot->_setParentScene(this);
|
2017-10-14 18:43:32 +08:00
|
|
|
}
|
2017-09-10 23:56:52 +08:00
|
|
|
|
2017-10-12 23:34:13 +08:00
|
|
|
e2d::EScene::~EScene()
|
2017-09-10 23:56:52 +08:00
|
|
|
{
|
2017-10-19 13:06:14 +08:00
|
|
|
ETimerManager::clearAllTimersBindedWith(this);
|
|
|
|
|
EMsgManager::clearAllMouseListenersBindedWith(this);
|
|
|
|
|
EMsgManager::clearAllKeyboardListenersBindedWith(this);
|
|
|
|
|
EActionManager::clearAllActionsBindedWith(this);
|
2017-10-20 00:59:26 +08:00
|
|
|
SafeRelease(&m_pRoot);
|
2017-09-10 23:56:52 +08:00
|
|
|
}
|
|
|
|
|
|
2017-10-15 23:58:39 +08:00
|
|
|
void e2d::EScene::onEnter()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void e2d::EScene::onExit()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-20 00:59:26 +08:00
|
|
|
bool e2d::EScene::onActivate()
|
2017-10-17 23:50:02 +08:00
|
|
|
{
|
2017-10-20 00:59:26 +08:00
|
|
|
return true;
|
2017-10-17 23:50:02 +08:00
|
|
|
}
|
|
|
|
|
|
2017-10-18 22:13:20 +08:00
|
|
|
bool e2d::EScene::onInactive()
|
2017-10-17 23:50:02 +08:00
|
|
|
{
|
2017-10-18 22:13:20 +08:00
|
|
|
return true;
|
2017-10-17 23:50:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool e2d::EScene::onCloseWindow()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-14 18:43:32 +08:00
|
|
|
void e2d::EScene::_onRender()
|
2017-09-10 23:56:52 +08:00
|
|
|
{
|
2017-10-19 13:06:14 +08:00
|
|
|
m_pRoot->_callOn();
|
2017-09-10 23:56:52 +08:00
|
|
|
}
|
|
|
|
|
|
2017-10-14 18:43:32 +08:00
|
|
|
void e2d::EScene::add(ENode * child, int order /* = 0 */)
|
2017-09-10 23:56:52 +08:00
|
|
|
{
|
2017-10-19 13:06:14 +08:00
|
|
|
m_pRoot->addChild(child, order);
|
2017-09-10 23:56:52 +08:00
|
|
|
}
|
|
|
|
|
|
2017-10-17 21:22:25 +08:00
|
|
|
bool e2d::EScene::remove(ENode * child, bool release /* = false */)
|
2017-09-10 23:56:52 +08:00
|
|
|
{
|
2017-10-19 13:06:14 +08:00
|
|
|
return m_pRoot->removeChild(child, release);
|
2017-10-17 21:22:25 +08:00
|
|
|
}
|
2017-09-10 23:56:52 +08:00
|
|
|
|
2017-10-17 21:22:25 +08:00
|
|
|
void e2d::EScene::remove(const EString &childName, bool release /* = false */)
|
|
|
|
|
{
|
2017-10-19 13:06:14 +08:00
|
|
|
return m_pRoot->removeChild(childName, release);
|
2017-09-10 23:56:52 +08:00
|
|
|
}
|
|
|
|
|
|
2017-10-17 21:22:25 +08:00
|
|
|
e2d::EVector<e2d::ENode*>& e2d::EScene::getChildren()
|
2017-10-12 23:34:13 +08:00
|
|
|
{
|
2017-10-19 13:06:14 +08:00
|
|
|
return m_pRoot->m_vChildren;
|
2017-10-12 23:34:13 +08:00
|
|
|
}
|
|
|
|
|
|
2017-10-14 18:43:32 +08:00
|
|
|
size_t e2d::EScene::getChildrenCount() const
|
|
|
|
|
{
|
2017-10-19 13:06:14 +08:00
|
|
|
return m_pRoot->getChildrenCount();
|
2017-10-14 18:43:32 +08:00
|
|
|
}
|
|
|
|
|
|
2017-10-17 21:22:25 +08:00
|
|
|
e2d::ENode * e2d::EScene::getChild(const EString &childName)
|
2017-10-14 18:43:32 +08:00
|
|
|
{
|
2017-10-19 13:06:14 +08:00
|
|
|
return m_pRoot->getChild(childName);
|
2017-10-14 18:43:32 +08:00
|
|
|
}
|
|
|
|
|
|
2017-10-20 00:59:26 +08:00
|
|
|
e2d::ENode * e2d::EScene::getRoot() const
|
|
|
|
|
{
|
|
|
|
|
return m_pRoot;
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-12 23:34:13 +08:00
|
|
|
void e2d::EScene::clearAllChildren()
|
2017-09-10 23:56:52 +08:00
|
|
|
{
|
2017-10-19 13:06:14 +08:00
|
|
|
m_pRoot->clearAllChildren();
|
2017-10-14 01:07:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void e2d::EScene::bindListener(EMouseListener * listener)
|
|
|
|
|
{
|
2017-10-17 21:22:25 +08:00
|
|
|
EMsgManager::bindListener(listener, this);
|
2017-10-14 01:07:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void e2d::EScene::bindListener(EKeyboardListener * listener)
|
|
|
|
|
{
|
2017-10-17 21:22:25 +08:00
|
|
|
EMsgManager::bindListener(listener, this);
|
2017-10-14 01:07:34 +08:00
|
|
|
}
|