diff --git a/core/Action/ActionSequence.cpp b/core/Action/ActionSequence.cpp index ebf7d07a..eee16ca2 100644 --- a/core/Action/ActionSequence.cpp +++ b/core/Action/ActionSequence.cpp @@ -5,7 +5,7 @@ e2d::ActionSequence::ActionSequence() { } -#if HIGHER_THAN_VS2012 +#ifdef HIGHER_THAN_VS2012 e2d::ActionSequence::ActionSequence(const InitList& vActions) : m_nActionIndex(0) { @@ -37,7 +37,7 @@ void e2d::ActionSequence::_init() // ½«ËùÓж¯×÷ÓëÄ¿±ê°ó¶¨ if (m_pTarget) { - FOR_LOOP(action, m_vActions) + for (auto action : m_vActions) { action->m_pTarget = m_pTarget; } @@ -49,7 +49,7 @@ void e2d::ActionSequence::_init() void e2d::ActionSequence::destroy() { Action::destroy(); - FOR_LOOP(action, m_vActions) + for (auto action : m_vActions) { SafeRelease(&action); } @@ -79,7 +79,7 @@ void e2d::ActionSequence::_update() void e2d::ActionSequence::reset() { Action::reset(); - FOR_LOOP(action, m_vActions) + for (auto action : m_vActions) { action->reset(); } @@ -88,7 +88,7 @@ void e2d::ActionSequence::reset() void e2d::ActionSequence::_resetTime() { - FOR_LOOP(action, m_vActions) + for (auto action : m_vActions) { action->_resetTime(); } @@ -103,7 +103,7 @@ void e2d::ActionSequence::add(Action * action) } } -#if HIGHER_THAN_VS2012 +#ifdef HIGHER_THAN_VS2012 void e2d::ActionSequence::add(const InitList& vActions) { for (const auto &action : vActions) @@ -129,7 +129,7 @@ void e2d::ActionSequence::add(int number, Action * action, ...) e2d::ActionSequence * e2d::ActionSequence::clone() const { auto a = new ActionSequence(); - FOR_LOOP(action, m_vActions) + for (auto action : m_vActions) { a->add(action->clone()); } @@ -139,7 +139,7 @@ e2d::ActionSequence * e2d::ActionSequence::clone() const e2d::ActionSequence * e2d::ActionSequence::reverse(bool actionReverse) const { auto a = new ActionSequence(); - FOR_LOOP(action, m_vActions) + for (auto action : m_vActions) { if (actionReverse) { diff --git a/core/Action/Animation.cpp b/core/Action/Animation.cpp index adbe207c..0acfe878 100644 --- a/core/Action/Animation.cpp +++ b/core/Action/Animation.cpp @@ -12,7 +12,7 @@ e2d::Animation::Animation(double interval) { } -#if HIGHER_THAN_VS2012 +#ifdef HIGHER_THAN_VS2012 e2d::Animation::Animation(const InitList& vImages) : m_nFrameIndex(0) @@ -112,7 +112,7 @@ void e2d::Animation::reset() void e2d::Animation::destroy() { Action::destroy(); - FOR_LOOP(frame, m_vFrames) + for (auto frame : m_vFrames) { SafeRelease(&frame); } @@ -127,7 +127,7 @@ void e2d::Animation::add(Image * frame) } } -#if HIGHER_THAN_VS2012 +#ifdef HIGHER_THAN_VS2012 void e2d::Animation::add(const InitList& vImages) { for (const auto &image : vImages) @@ -153,7 +153,7 @@ void e2d::Animation::add(int number, Image * frame, ...) e2d::Animation * e2d::Animation::clone() const { auto a = new Animation(m_fInterval); - FOR_LOOP(frame, m_vFrames) + for (auto frame : m_vFrames) { a->add(frame); } diff --git a/core/Base/Time.cpp b/core/Base/Time.cpp index 2ae2181d..64295d39 100644 --- a/core/Base/Time.cpp +++ b/core/Base/Time.cpp @@ -1,4 +1,19 @@ #include "..\e2dbase.h" +#include +#include +using namespace std::chrono; + + +// ÓÎÏ·¿ªÊ¼Ê±¼ä +static steady_clock::time_point s_tStart; +// µ±Ç°Ê±¼ä +static steady_clock::time_point s_tNow; +// ÉÏÒ»Ö¡Ë¢ÐÂʱ¼ä +static steady_clock::time_point s_tFixedUpdate; +// ÉÏÒ»´Î¸üÐÂʱ¼ä +static steady_clock::time_point s_tLastUpdate; +// ÿһ֡¼ä¸ô +static milliseconds s_tExceptedInvertal; // ÉÏÒ»Ö¡Ó뵱ǰ֡µÄʱ¼ä¼ä¸ô static unsigned int s_nInterval = 0; @@ -26,26 +41,6 @@ unsigned int e2d::Time::getDeltaTimeMilliseconds() return s_nInterval; } - -#if HIGHER_THAN_VS2010 - -#include -#include -using namespace std::chrono; - - -// ÓÎÏ·¿ªÊ¼Ê±¼ä -static steady_clock::time_point s_tStart; -// µ±Ç°Ê±¼ä -static steady_clock::time_point s_tNow; -// ÉÏÒ»Ö¡Ë¢ÐÂʱ¼ä -static steady_clock::time_point s_tFixedUpdate; -// ÉÏÒ»´Î¸üÐÂʱ¼ä -static steady_clock::time_point s_tLastUpdate; -// ÿһ֡¼ä¸ô -static milliseconds s_tExceptedInvertal; - - bool e2d::Time::__init() { s_tStart = s_tLastUpdate = s_tFixedUpdate = s_tNow = steady_clock::now(); @@ -89,73 +84,3 @@ void e2d::Time::__sleep() std::this_thread::sleep_for(milliseconds(nWaitMS)); } } - - -#else - - -#include -#pragma comment(lib, "winmm.lib") - -// ʱÖÓÆµÂÊ -static LARGE_INTEGER s_tFreq; -// ÓÎÏ·¿ªÊ¼Ê±¼ä -static LARGE_INTEGER s_tStart; -// µ±Ç°Ê±¼ä -static LARGE_INTEGER s_tNow; -// ÉÏÒ»Ö¡Ë¢ÐÂʱ¼ä -static LARGE_INTEGER s_tFixedUpdate; -// ÉÏÒ»´Î¸üÐÂʱ¼ä -static LARGE_INTEGER s_tLastUpdate; -// ÿһ֡¼ä¸ô -static LONGLONG s_tExceptedInvertal; - - -bool e2d::Time::__init() -{ - ::timeBeginPeriod(1); // ÐÞ¸Äʱ¼ä¾«¶È - ::QueryPerformanceFrequency(&s_tFreq); // »ñȡʱÖÓÆµÂÊ - ::QueryPerformanceCounter(&s_tNow); // ˢе±Ç°Ê±¼ä - s_tStart = s_tLastUpdate = s_tFixedUpdate = s_tNow; - s_tExceptedInvertal = 15LL * s_tFreq.QuadPart / 1000LL; - return true; -} - -void e2d::Time::__uninit() -{ - ::timeEndPeriod(1); // ÖØÖÃʱ¼ä¾«¶È -} - -bool e2d::Time::__isReady() -{ - return s_tExceptedInvertal < (s_tNow.QuadPart - s_tFixedUpdate.QuadPart); -} - -void e2d::Time::__updateNow() -{ - ::QueryPerformanceCounter(&s_tNow); -} - -void e2d::Time::__updateLast() -{ - s_tFixedUpdate.QuadPart += s_tExceptedInvertal; - s_tLastUpdate = s_tNow; - - ::QueryPerformanceCounter(&s_tNow); - s_nInterval = static_cast((s_tNow.QuadPart - s_tLastUpdate.QuadPart) * 1000LL / s_tFreq.QuadPart); - s_nTotalTime = static_cast((s_tNow.QuadPart - s_tStart.QuadPart) * 1000LL / s_tFreq.QuadPart); -} - -void e2d::Time::__sleep() -{ - // ¼ÆËã¹ÒÆðʱ³¤ - int nWaitMS = 16 - static_cast((s_tNow.QuadPart - s_tFixedUpdate.QuadPart) * 1000LL / s_tFreq.QuadPart); - // ¹ÒÆðỊ̈߳¬ÊÍ·Å CPU Õ¼Óà - if (nWaitMS > 1) - { - ::Sleep(nWaitMS); - } -} - - -#endif \ No newline at end of file diff --git a/core/Common/Scene.cpp b/core/Common/Scene.cpp index 4a9ad301..f943e87e 100644 --- a/core/Common/Scene.cpp +++ b/core/Common/Scene.cpp @@ -52,7 +52,7 @@ void e2d::Scene::add(Node * child, int order /* = 0 */) m_pRoot->addChild(child, order); } -#if HIGHER_THAN_VS2012 +#ifdef HIGHER_THAN_VS2012 void e2d::Scene::add(const InitList& vNodes, int order) { for (const auto &node : vNodes) diff --git a/core/Common/String.cpp b/core/Common/String.cpp index 2567fe7c..2daf7a3c 100644 --- a/core/Common/String.cpp +++ b/core/Common/String.cpp @@ -49,44 +49,28 @@ e2d::String & e2d::String::operator=(const char *cstr) e2d::String e2d::String::parse(int value) { String tmp; -#if HIGHER_THAN_VS2010 tmp.m_str = std::to_wstring(value); -#else - tmp.m_str = std::to_wstring(static_cast(value)); -#endif return std::move(tmp); } e2d::String e2d::String::parse(unsigned int value) { String tmp; -#if HIGHER_THAN_VS2010 tmp.m_str = std::to_wstring(value); -#else - tmp.m_str = std::to_wstring(static_cast(value)); -#endif return std::move(tmp); } e2d::String e2d::String::parse(float value) { String tmp; -#if HIGHER_THAN_VS2010 tmp.m_str = std::to_wstring(value); -#else - tmp.m_str = std::to_wstring(static_cast(value)); -#endif return std::move(tmp); } e2d::String e2d::String::parse(double value) { String tmp; -#if HIGHER_THAN_VS2010 tmp.m_str = std::to_wstring(value); -#else - tmp.m_str = std::to_wstring(static_cast(value)); -#endif return std::move(tmp); } diff --git a/core/Manager/ActionManager.cpp b/core/Manager/ActionManager.cpp index 5322b71d..69aaf8d3 100644 --- a/core/Manager/ActionManager.cpp +++ b/core/Manager/ActionManager.cpp @@ -37,7 +37,7 @@ void e2d::ActionManager::__add(Action * pAction) { if (pAction) { - FOR_LOOP(action, s_vActions) + for (auto action : s_vActions) { if (action == pAction) { @@ -76,7 +76,7 @@ void e2d::ActionManager::__resumeAllBindedWith(Node * pTargetNode) { if (pTargetNode) { - FOR_LOOP(action, s_vRunningActions) + for (auto action : s_vRunningActions) { if (action->getTarget() == pTargetNode) { @@ -90,7 +90,7 @@ void e2d::ActionManager::__pauseAllBindedWith(Node * pTargetNode) { if (pTargetNode) { - FOR_LOOP(action, s_vRunningActions) + for (auto action : s_vRunningActions) { if (action->getTarget() == pTargetNode) { @@ -104,7 +104,7 @@ void e2d::ActionManager::__stopAllBindedWith(Node * pTargetNode) { if (pTargetNode) { - FOR_LOOP(action, s_vRunningActions) + for (auto action : s_vRunningActions) { if (action->getTarget() == pTargetNode) { @@ -116,7 +116,7 @@ void e2d::ActionManager::__stopAllBindedWith(Node * pTargetNode) void e2d::ActionManager::resume(String strActionName) { - FOR_LOOP(action, s_vRunningActions) + for (auto action : s_vRunningActions) { if (action->getName() == strActionName) { @@ -127,7 +127,7 @@ void e2d::ActionManager::resume(String strActionName) void e2d::ActionManager::pause(String strActionName) { - FOR_LOOP(action, s_vRunningActions) + for (auto action : s_vRunningActions) { if (action->getName() == strActionName) { @@ -138,7 +138,7 @@ void e2d::ActionManager::pause(String strActionName) void e2d::ActionManager::stop(String strActionName) { - FOR_LOOP(action, s_vRunningActions) + for (auto action : s_vRunningActions) { if (action->getName() == strActionName) { @@ -169,9 +169,9 @@ void e2d::ActionManager::__clearAllBindedWith(Node * pTargetNode) void e2d::ActionManager::__uninit() { - FOR_LOOP(child, s_vActions) + for (auto action : s_vRunningActions) { - SafeRelease(&child); + SafeRelease(&action); } s_vActions.clear(); s_vRunningActions.clear(); @@ -179,7 +179,7 @@ void e2d::ActionManager::__uninit() void e2d::ActionManager::resumeAll() { - FOR_LOOP(child, SceneManager::getCurrentScene()->getRoot()->getAllChildren()) + for (auto child : SceneManager::getCurrentScene()->getRoot()->getAllChildren()) { ActionManager::__resumeAllBindedWith(child); } @@ -187,7 +187,7 @@ void e2d::ActionManager::resumeAll() void e2d::ActionManager::pauseAll() { - FOR_LOOP(child, SceneManager::getCurrentScene()->getRoot()->getAllChildren()) + for (auto child : SceneManager::getCurrentScene()->getRoot()->getAllChildren()) { ActionManager::__pauseAllBindedWith(child); } @@ -195,7 +195,7 @@ void e2d::ActionManager::pauseAll() void e2d::ActionManager::stopAll() { - FOR_LOOP(child, SceneManager::getCurrentScene()->getRoot()->getAllChildren()) + for (auto child : SceneManager::getCurrentScene()->getRoot()->getAllChildren()) { ActionManager::__stopAllBindedWith(child); } @@ -204,7 +204,7 @@ void e2d::ActionManager::stopAll() std::vector e2d::ActionManager::get(String strActionName) { std::vector vActions; - FOR_LOOP(action, s_vActions) + for (auto action : s_vActions) { if (action->getName() == strActionName) { @@ -221,7 +221,7 @@ std::vector e2d::ActionManager::getAll() void e2d::ActionManager::__resetAll() { - FOR_LOOP(action, s_vRunningActions) + for (auto action : s_vRunningActions) { action->_resetTime(); } diff --git a/core/Manager/ColliderManager.cpp b/core/Manager/ColliderManager.cpp index da8359ab..187c6c62 100644 --- a/core/Manager/ColliderManager.cpp +++ b/core/Manager/ColliderManager.cpp @@ -105,7 +105,7 @@ void e2d::ColliderManager::__updateCollider(e2d::Collider * pActiveCollider) auto IsCollideWith = [](Node * active, Node * passive) -> bool { unsigned int hash = passive->getHashName(); - FOR_LOOP(collider, active->m_vColliders) + for (auto collider : active->m_vColliders) if (collider == hash) return true; return false; @@ -141,7 +141,7 @@ void e2d::ColliderManager::add(Function func, String name, bool paused) void e2d::ColliderManager::pause(String name) { - FOR_LOOP(pListener, s_vListeners) + for (auto pListener : s_vListeners) { if (pListener->name == name) { @@ -152,7 +152,7 @@ void e2d::ColliderManager::pause(String name) void e2d::ColliderManager::resume(String name) { - FOR_LOOP(pListener, s_vListeners) + for (auto pListener : s_vListeners) { if (pListener->name == name) { @@ -163,7 +163,7 @@ void e2d::ColliderManager::resume(String name) void e2d::ColliderManager::stop(String name) { - FOR_LOOP(pListener, s_vListeners) + for (auto pListener : s_vListeners) { if (pListener->name == name) { @@ -174,7 +174,7 @@ void e2d::ColliderManager::stop(String name) void e2d::ColliderManager::pauseAll() { - FOR_LOOP(pListener, s_vListeners) + for (auto pListener : s_vListeners) { pListener->running = false; } @@ -182,7 +182,7 @@ void e2d::ColliderManager::pauseAll() void e2d::ColliderManager::resumeAll() { - FOR_LOOP(pListener, s_vListeners) + for (auto pListener : s_vListeners) { pListener->running = true; } @@ -190,7 +190,7 @@ void e2d::ColliderManager::resumeAll() void e2d::ColliderManager::stopAll() { - FOR_LOOP(pListener, s_vListeners) + for (auto pListener : s_vListeners) { pListener->stopped = true; } @@ -256,7 +256,7 @@ void e2d::ColliderManager::__removeCollider(Collider * pCollider) void e2d::ColliderManager::__uninit() { - FOR_LOOP(listener, s_vListeners) + for (auto listener : s_vListeners) { delete listener; } diff --git a/core/Manager/InputManager.cpp b/core/Manager/InputManager.cpp index 9edc9465..05d9840c 100644 --- a/core/Manager/InputManager.cpp +++ b/core/Manager/InputManager.cpp @@ -45,7 +45,7 @@ void e2d::InputManager::add(Function func, String name, bool paused) void e2d::InputManager::pause(String name) { - FOR_LOOP(pListener, s_vListeners) + for (auto pListener : s_vListeners) { if (pListener->name == name) { @@ -56,7 +56,7 @@ void e2d::InputManager::pause(String name) void e2d::InputManager::resume(String name) { - FOR_LOOP(pListener, s_vListeners) + for (auto pListener : s_vListeners) { if (pListener->name == name) { @@ -67,7 +67,7 @@ void e2d::InputManager::resume(String name) void e2d::InputManager::stop(String name) { - FOR_LOOP(pListener, s_vListeners) + for (auto pListener : s_vListeners) { if (pListener->name == name) { @@ -78,7 +78,7 @@ void e2d::InputManager::stop(String name) void e2d::InputManager::pauseAll() { - FOR_LOOP(pListener, s_vListeners) + for (auto pListener : s_vListeners) { pListener->running = false; } @@ -86,7 +86,7 @@ void e2d::InputManager::pauseAll() void e2d::InputManager::resumeAll() { - FOR_LOOP(pListener, s_vListeners) + for (auto pListener : s_vListeners) { pListener->running = true; } @@ -94,7 +94,7 @@ void e2d::InputManager::resumeAll() void e2d::InputManager::stopAll() { - FOR_LOOP(pListener, s_vListeners) + for (auto pListener : s_vListeners) { pListener->stopped = true; } @@ -125,7 +125,7 @@ void e2d::InputManager::__update() void e2d::InputManager::__uninit() { - FOR_LOOP(listener, s_vListeners) + for (auto listener : s_vListeners) { delete listener; } diff --git a/core/Manager/MusicManager.cpp b/core/Manager/MusicManager.cpp index 404ae2f3..939fcdd0 100644 --- a/core/Manager/MusicManager.cpp +++ b/core/Manager/MusicManager.cpp @@ -96,34 +96,34 @@ e2d::Music * e2d::MusicManager::get(String strFilePath) void e2d::MusicManager::pauseAll() { - for (auto iter = GetMusicList().begin(); iter != GetMusicList().end(); iter++) + for (auto pair : GetMusicList()) { - (*iter).second->pause(); + pair.second->pause(); } } void e2d::MusicManager::resumeAll() { - for (auto iter = GetMusicList().begin(); iter != GetMusicList().end(); iter++) + for (auto pair : GetMusicList()) { - (*iter).second->resume(); + pair.second->resume(); } } void e2d::MusicManager::stopAll() { - for (auto iter = GetMusicList().begin(); iter != GetMusicList().end(); iter++) + for (auto pair : GetMusicList()) { - (*iter).second->stop(); + pair.second->stop(); } } void e2d::MusicManager::__uninit() { - for (auto iter = GetMusicList().begin(); iter != GetMusicList().end(); iter++) + for (auto pair : GetMusicList()) { - (*iter).second->close(); - (*iter).second->release(); + pair.second->close(); + pair.second->release(); } GetMusicList().clear(); } diff --git a/core/Manager/ObjectManager.cpp b/core/Manager/ObjectManager.cpp index 4986c01d..3c6c64d8 100644 --- a/core/Manager/ObjectManager.cpp +++ b/core/Manager/ObjectManager.cpp @@ -37,7 +37,7 @@ void e2d::ObjectManager::__update() void e2d::ObjectManager::__clear() { - FOR_LOOP(pObj, s_vObjectPool) + for (auto pObj : s_vObjectPool) { delete pObj; } diff --git a/core/Node/Menu.cpp b/core/Node/Menu.cpp index 4b637cbc..448c4a6e 100644 --- a/core/Node/Menu.cpp +++ b/core/Node/Menu.cpp @@ -5,11 +5,11 @@ e2d::Menu::Menu() { } -#if HIGHER_THAN_VS2012 +#ifdef HIGHER_THAN_VS2012 e2d::Menu::Menu(const InitList& vButtons) : m_bEnable(true) { - FOR_LOOP(button, vButtons) + for (auto button : vButtons) { this->addButton(button); } @@ -47,7 +47,7 @@ void e2d::Menu::setEnable(bool enable) { m_bEnable = enable; - FOR_LOOP(button, m_vButtons) + for (auto button : m_vButtons) { button->setEnable(enable); } diff --git a/core/Node/Node.cpp b/core/Node/Node.cpp index eb50905d..07fdaf76 100644 --- a/core/Node/Node.cpp +++ b/core/Node/Node.cpp @@ -167,7 +167,7 @@ void e2d::Node::_drawCollider() } // »æÖÆËùÓÐ×Ó½ÚµãµÄ¼¸ºÎÅöײÌå - FOR_LOOP(child, m_vChildren) + for (auto child : m_vChildren) { child->_drawCollider(); } @@ -180,7 +180,7 @@ void e2d::Node::_onEnter() this->m_bDisplayedInScene = true; this->onEnter(); - FOR_LOOP(child, m_vChildren) + for (auto child : m_vChildren) { child->_onEnter(); } @@ -194,7 +194,7 @@ void e2d::Node::_onExit() this->m_bDisplayedInScene = false; this->onExit(); - FOR_LOOP(child, m_vChildren) + for (auto child : m_vChildren) { child->_onExit(); } @@ -243,7 +243,7 @@ void e2d::Node::_updateTransform() // ±êÖ¾ÒÑÖ´Ðйý±ä»» m_bTransformNeeded = false; // ±éÀú×Ó½ÚµãϵÄËùÓнڵã - FOR_LOOP(child, this->m_vChildren) + for (auto child : this->m_vChildren) { child->_updateTransform(); } @@ -255,7 +255,7 @@ void e2d::Node::_updateOpacity() { m_fDisplayOpacity = m_fRealOpacity * m_pParent->m_fDisplayOpacity; } - FOR_LOOP(child, m_vChildren) + for (auto child : m_vChildren) { child->_updateOpacity(); } @@ -616,7 +616,7 @@ void e2d::Node::addColliableName(String collliderName) m_vColliders.insert(hash); } -#if HIGHER_THAN_VS2012 +#ifdef HIGHER_THAN_VS2012 void e2d::Node::addColliableName(const InitList& vCollliderName) { for (const auto &name : vCollliderName) @@ -672,7 +672,7 @@ void e2d::Node::addChild(Node * child, int order /* = 0 */) } } -#if HIGHER_THAN_VS2012 +#ifdef HIGHER_THAN_VS2012 void e2d::Node::addChild(const InitList& vNodes, int order) { for (const auto &node : vNodes) @@ -697,7 +697,7 @@ std::vector e2d::Node::getChildren(String name) const std::vector vChildren; unsigned int hash = name.getHashCode(); - FOR_LOOP(child, m_vChildren) + for (auto child : m_vChildren) { // ²»Í¬µÄÃû³Æ¿ÉÄÜ»áÓÐÏàͬµÄ Hash Öµ£¬µ«ÊÇÏÈ±È½Ï Hash ¿ÉÒÔÌáÉýËÑË÷ËÙ¶È if (child->m_nHashName == hash && child->m_sName == name) @@ -712,7 +712,7 @@ e2d::Node * e2d::Node::getChild(String name) const { unsigned int hash = name.getHashCode(); - FOR_LOOP(child, m_vChildren) + for (auto child : m_vChildren) { // ²»Í¬µÄÃû³Æ¿ÉÄÜ»áÓÐÏàͬµÄ Hash Öµ£¬µ«ÊÇÏÈ±È½Ï Hash ¿ÉÒÔÌáÉýËÑË÷ËÙ¶È if (child->m_nHashName == hash && child->m_sName == name) @@ -813,7 +813,7 @@ void e2d::Node::removeChildren(String childName) void e2d::Node::clearAllChildren() { // ËùÓнڵãµÄÒýÓüÆÊý¼õÒ» - FOR_LOOP(child, m_vChildren) + for (auto child : m_vChildren) { if (child->m_bDisplayedInScene) { @@ -849,7 +849,7 @@ void e2d::Node::runAction(Action * action) void e2d::Node::resumeAction(String strActionName) { auto actions = ActionManager::get(strActionName); - FOR_LOOP(action, actions) + for (auto action : actions) { if (action->getTarget() == this) { @@ -861,7 +861,7 @@ void e2d::Node::resumeAction(String strActionName) void e2d::Node::pauseAction(String strActionName) { auto actions = ActionManager::get(strActionName); - FOR_LOOP(action, actions) + for (auto action : actions) { if (action->getTarget() == this) { @@ -873,7 +873,7 @@ void e2d::Node::pauseAction(String strActionName) void e2d::Node::stopAction(String strActionName) { auto actions = ActionManager::get(strActionName); - FOR_LOOP(action, actions) + for (auto action : actions) { if (action->getTarget() == this) { @@ -885,7 +885,7 @@ void e2d::Node::stopAction(String strActionName) e2d::Action * e2d::Node::getAction(String strActionName) { auto actions = ActionManager::get(strActionName); - FOR_LOOP(action, actions) + for (auto action : actions) { if (action->getTarget() == this) { @@ -1031,7 +1031,7 @@ void e2d::Node::destroy() { ActionManager::__clearAllBindedWith(this); ColliderManager::__removeCollider(m_pCollider); - FOR_LOOP(child, m_vChildren) + for (auto child : m_vChildren) { SafeRelease(&child); } @@ -1073,7 +1073,7 @@ void e2d::Node::setName(String name) void e2d::Node::_setParentScene(Scene * scene) { m_pParentScene = scene; - FOR_LOOP(child, m_vChildren) + for (auto child : m_vChildren) { child->_setParentScene(scene); } diff --git a/core/Tool/Music.cpp b/core/Tool/Music.cpp index b7eb1026..1dd8d678 100644 --- a/core/Tool/Music.cpp +++ b/core/Tool/Music.cpp @@ -3,8 +3,6 @@ using namespace e2d; -#if HIGHER_THAN_VS2010 - #ifndef SAFE_DELETE #define SAFE_DELETE(p) { if (p) { delete (p); (p)=nullptr; } } #endif @@ -536,221 +534,3 @@ bool Music::_findMediaFileCch(wchar_t* strDestPath, int cchDest, const wchar_t * } -#else - -#define MUSIC_CLASS_NAME L"Easy2DMusicCallbackWnd" - -static HINSTANCE s_hInstance = nullptr; - - -bool e2d::Music::__init() -{ - s_hInstance = HINST_THISCOMPONENT; - - WNDCLASS wc; - wc.style = 0; - wc.lpfnWndProc = Music::MusicProc; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = s_hInstance; - wc.hIcon = 0; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hbrBackground = NULL; - wc.lpszMenuName = NULL; - wc.lpszClassName = MUSIC_CLASS_NAME; - - if (!RegisterClass(&wc) && 1410 != GetLastError()) - { - return false; - } - return true; -} - -e2d::Music::Music() - : m_wnd(NULL) - , m_dev(0L) - , m_nMusicID(0) - , m_bPlaying(false) - , m_nRepeatTimes(0) -{ - m_wnd = CreateWindowEx( - WS_EX_APPWINDOW, - MUSIC_CLASS_NAME, - NULL, - WS_POPUPWINDOW, - 0, 0, 0, 0, - NULL, - NULL, - s_hInstance, - NULL); - - if (m_wnd) - { - SetWindowLongPtr(m_wnd, GWLP_USERDATA, (LONG_PTR)this); - } -} - -e2d::Music::~Music() -{ - close(); - DestroyWindow(m_wnd); -} - -bool e2d::Music::open(String pFileName) -{ - if (pFileName.isEmpty()) - return false; - - close(); - - MCI_OPEN_PARMS mciOpen = { 0 }; - mciOpen.lpstrDeviceType = 0; - mciOpen.lpstrElementName = pFileName; - - MCIERROR mciError; - mciError = mciSendCommand( - 0, - MCI_OPEN, - MCI_OPEN_ELEMENT, - reinterpret_cast(&mciOpen) - ); - - if (mciError == 0) - { - m_dev = mciOpen.wDeviceID; - m_nMusicID = pFileName.getHashCode(); - m_bPlaying = false; - return true; - } - return false; -} - -bool e2d::Music::play(int nLoopCount) -{ - if (!m_dev) - { - return false; - } - - MCI_PLAY_PARMS mciPlay = { 0 }; - mciPlay.dwCallback = reinterpret_cast(m_wnd); - - // ²¥·ÅÉùÒô - MCIERROR mciError = mciSendCommand( - m_dev, - MCI_PLAY, - MCI_FROM | MCI_NOTIFY, - reinterpret_cast(&mciPlay) - ); - - if (!mciError) - { - m_bPlaying = true; - m_nRepeatTimes = nLoopCount; - return true; - } - return false; -} - -void e2d::Music::close() -{ - if (m_bPlaying) - { - stop(); - } - - if (m_dev) - { - _sendCommand(MCI_CLOSE); - } - - m_dev = 0; - m_bPlaying = false; -} - -void e2d::Music::pause() -{ - _sendCommand(MCI_PAUSE); - m_bPlaying = false; -} - -void e2d::Music::resume() -{ - _sendCommand(MCI_RESUME); - m_bPlaying = true; -} - -void e2d::Music::stop() -{ - _sendCommand(MCI_STOP); - m_bPlaying = false; -} - -bool e2d::Music::isPlaying() const -{ - return m_bPlaying; -} - -double Music::getVolume() const -{ - return 1.0f; -} - -bool Music::setVolume(double fVolume) -{ - return false; -} - -double Music::getFrequencyRatio() const -{ - return 1.0f; -} - -bool Music::setFrequencyRatio(double fFrequencyRatio) -{ - return false; -} - -void e2d::Music::_sendCommand(int nCommand, DWORD_PTR param1, DWORD_PTR parma2) -{ - // ¿ÕÉ豸ʱºöÂÔÕâ´Î²Ù×÷ - if (!m_dev) - { - return; - } - // Ïòµ±Ç°É豸·¢ËͲÙ×÷ - mciSendCommand(m_dev, nCommand, param1, parma2); -} - - -LRESULT WINAPI e2d::Music::MusicProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) -{ - e2d::Music * pPlayer = NULL; - - if (Msg == MM_MCINOTIFY - && wParam == MCI_NOTIFY_SUCCESSFUL - && (pPlayer = (Music *)GetWindowLongPtr(hWnd, GWLP_USERDATA))) - { - if (pPlayer->m_nRepeatTimes > 0) - { - pPlayer->m_nRepeatTimes--; - } - - if (pPlayer->m_nRepeatTimes) - { - mciSendCommand(static_cast(lParam), MCI_SEEK, MCI_SEEK_TO_START, 0); - - MCI_PLAY_PARMS mciPlay = { 0 }; - mciPlay.dwCallback = reinterpret_cast(hWnd); - mciSendCommand(static_cast(lParam), MCI_PLAY, MCI_NOTIFY, reinterpret_cast(&mciPlay)); - } - else - { - pPlayer->m_bPlaying = false; - return 0; - } - } - return DefWindowProc(hWnd, Msg, wParam, lParam); -} - -#endif \ No newline at end of file diff --git a/core/Tool/Timer.cpp b/core/Tool/Timer.cpp index 85b2b43b..3e40e4f8 100644 --- a/core/Tool/Timer.cpp +++ b/core/Tool/Timer.cpp @@ -84,7 +84,7 @@ void e2d::Timer::startOnce(Function func, double timeOut) void e2d::Timer::pause(String name) { - FOR_LOOP(timer, s_vTimers) + for (auto timer : s_vTimers) { if (timer->name == name) { @@ -95,7 +95,7 @@ void e2d::Timer::pause(String name) void e2d::Timer::resume(String name) { - FOR_LOOP(timer, s_vTimers) + for (auto timer : s_vTimers) { if (timer->name == name) { @@ -106,7 +106,7 @@ void e2d::Timer::resume(String name) void e2d::Timer::stop(String name) { - FOR_LOOP(timer, s_vTimers) + for (auto timer : s_vTimers) { if (timer->name == name) { @@ -117,7 +117,7 @@ void e2d::Timer::stop(String name) void e2d::Timer::pauseAll() { - FOR_LOOP(timer, s_vTimers) + for (auto timer : s_vTimers) { timer->running = false; } @@ -125,7 +125,7 @@ void e2d::Timer::pauseAll() void e2d::Timer::resumeAll() { - FOR_LOOP(timer, s_vTimers) + for (auto timer : s_vTimers) { timer->running = true; } @@ -133,7 +133,7 @@ void e2d::Timer::resumeAll() void e2d::Timer::stopAll() { - FOR_LOOP(timer, s_vTimers) + for (auto timer : s_vTimers) { timer->stopped = true; } @@ -168,7 +168,7 @@ void e2d::Timer::__update() void e2d::Timer::__resetAll() { - FOR_LOOP(timer, s_vTimers) + for (auto timer : s_vTimers) { timer->lastTime = Time::getTotalTime(); } @@ -176,7 +176,7 @@ void e2d::Timer::__resetAll() void e2d::Timer::__uninit() { - FOR_LOOP(timer, s_vTimers) + for (auto timer : s_vTimers) { delete timer; } diff --git a/core/e2daction.h b/core/e2daction.h index de458db3..b524a1c9 100644 --- a/core/e2daction.h +++ b/core/e2daction.h @@ -406,7 +406,7 @@ public: // ´´½¨Ë³Ðò¶¯×÷ ActionSequence(); -#if HIGHER_THAN_VS2012 +#ifdef HIGHER_THAN_VS2012 // ´´½¨Ë³Ðò¶¯×÷ ActionSequence( const InitList& vActions /* ¶¯×÷Êý×é */ @@ -427,7 +427,7 @@ public: Action * action ); -#if HIGHER_THAN_VS2012 +#ifdef HIGHER_THAN_VS2012 // ÔÚ½áβÌí¼Ó¶à¸ö¶¯×÷ void add( const InitList& vActions /* ¶¯×÷Êý×é */ @@ -545,7 +545,7 @@ public: double interval /* Ö¡¼ä¸ô£¨Ã룩 */ ); -#if HIGHER_THAN_VS2012 +#ifdef HIGHER_THAN_VS2012 // ´´½¨Ö¡¶¯»­ Animation( const InitList& vImages /* ¹Ø¼üÖ¡Êý×é */ @@ -580,7 +580,7 @@ public: Image * frame /* ¹Ø¼üÖ¡ */ ); -#if HIGHER_THAN_VS2012 +#ifdef HIGHER_THAN_VS2012 // Ìí¼Ó¶à¸ö¹Ø¼üÖ¡ void add( const InitList& vImages /* ¹Ø¼üÖ¡Êý×é */ @@ -797,7 +797,7 @@ namespace e2d return new (std::nothrow) ActionFunc(func); } -#if HIGHER_THAN_VS2012 +#ifdef HIGHER_THAN_VS2012 // ´´½¨Ë³Ðò¶¯×÷ inline e2d::ActionSequence* Sequence( const InitList& vActions /* ¶¯×÷Êý×é */ diff --git a/core/e2dcommon.h b/core/e2dcommon.h index 1458d713..d8e298e7 100644 --- a/core/e2dcommon.h +++ b/core/e2dcommon.h @@ -11,7 +11,7 @@ namespace e2d { -#if HIGHER_THAN_VS2012 +#ifdef HIGHER_THAN_VS2012 // ³õʼ»¯Áбí template @@ -727,7 +727,7 @@ public: int zOrder = 0 /* äÖȾ˳Ðò */ ); -#if HIGHER_THAN_VS2012 +#ifdef HIGHER_THAN_VS2012 // Ìí¼Ó¶à¸ö½Úµãµ½³¡¾° virtual void add( const InitList& vNodes, /* ½ÚµãÊý×é */ diff --git a/core/e2dmacros.h b/core/e2dmacros.h index bad7addc..7cefc470 100644 --- a/core/e2dmacros.h +++ b/core/e2dmacros.h @@ -28,18 +28,6 @@ #define INITGUID -#if _MSC_VER > 1700 -#define HIGHER_THAN_VS2012 1 -#else -#define HIGHER_THAN_VS2012 0 -#endif - -#if _MSC_VER > 1600 -#define HIGHER_THAN_VS2010 1 -#else -#define HIGHER_THAN_VS2010 0 -#endif - // Windows Header Files #include #include @@ -48,6 +36,7 @@ #include #include #include +#include // C RunTime Header Files #include @@ -58,11 +47,7 @@ #pragma comment(lib, "dwrite.lib") #pragma comment(lib, "windowscodecs.lib") #pragma comment(lib, "winmm.lib") - -#if HIGHER_THAN_VS2010 -#include #pragma comment(lib, "xaudio2.lib") -#endif #ifndef HINST_THISCOMPONENT @@ -88,9 +73,16 @@ EXTERN_C IMAGE_DOS_HEADER __ImageBase; #endif -#if HIGHER_THAN_VS2010 -#define FOR_LOOP(i, container) for (auto i : (container)) +#if _MSC_VER > 1700 + +#ifndef HIGHER_THAN_VS2012 +#define HIGHER_THAN_VS2012 +#endif + #else -#define FOR_LOOP(i, container) auto i = (container.begin() == container.end()) ? NULL : (*(container.begin())); \ - for (auto __iter__=(container.begin()); (__iter__ != (container.end())) && (i = (*__iter__)); __iter__++) -#endif \ No newline at end of file + +#ifdef HIGHER_THAN_VS2012 +#undef HIGHER_THAN_VS2012 +#endif + +#endif diff --git a/core/e2dnode.h b/core/e2dnode.h index a270b653..39338882 100644 --- a/core/e2dnode.h +++ b/core/e2dnode.h @@ -339,7 +339,7 @@ public: String collliderName ); -#if HIGHER_THAN_VS2012 +#ifdef HIGHER_THAN_VS2012 // Ìí¼Ó¶à¸ö¿ÉÅöײ½ÚµãµÄÃû³Æ virtual void addColliableName( const InitList& vCollliderName /* Ãû³ÆÊý×é */ @@ -357,7 +357,7 @@ public: int order = 0 /* äÖȾ˳Ðò */ ); -#if HIGHER_THAN_VS2012 +#ifdef HIGHER_THAN_VS2012 // Ìí¼Ó¶à¸ö×Ó½Úµã virtual void addChild( const InitList& vNodes, /* ½ÚµãÊý×é */ @@ -942,7 +942,7 @@ public: // ´´½¨¿Õ²Ëµ¥ Menu(); -#if HIGHER_THAN_VS2012 +#ifdef HIGHER_THAN_VS2012 // ´´½¨²Ëµ¥ Menu( const InitList& vButtons /* °´Å¥Êý×é */ diff --git a/core/e2dtool.h b/core/e2dtool.h index a98010a9..cba6c90b 100644 --- a/core/e2dtool.h +++ b/core/e2dtool.h @@ -108,14 +108,6 @@ public: double fFrequencyRatio /* ƵÂʱȷ¶Î§Îª 1/1024.0f ~ 1024.0f£¬ÆäÖÐ 1.0 ΪÕý³£Éùµ÷ */ ); -private: - static bool __init(); - - static void __uninit(); - -#if HIGHER_THAN_VS2010 - -public: // »ñÈ¡ IXAudio2 ¶ÔÏó static IXAudio2 * getIXAudio2(); @@ -141,6 +133,11 @@ protected: const wchar_t * strFilename ); +private: + static bool __init(); + + static void __uninit(); + protected: bool m_bOpened; mutable bool m_bPlaying; @@ -152,22 +149,6 @@ protected: MMCKINFO m_ckRiff; WAVEFORMATEX* m_pwfx; IXAudio2SourceVoice* m_pSourceVoice; - -#else - -protected: - void _sendCommand(int nCommand, DWORD_PTR param1 = 0, DWORD_PTR parma2 = 0); - - static LRESULT WINAPI MusicProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam); - -protected: - MCIDEVICEID m_dev; - HWND m_wnd; - UINT m_nMusicID; - bool m_bPlaying; - int m_nRepeatTimes; - -#endif }; diff --git a/core/easy2d.h b/core/easy2d.h index 024405e3..3f5497a8 100644 --- a/core/easy2d.h +++ b/core/easy2d.h @@ -12,8 +12,8 @@ #error ½öÄÜÔÚ C++ »·¾³ÏÂʹÓà Easy2D #endif -#if _MSC_VER < 1600 - #error Easy2D ²»Ö§³Ö Visual Studio 2010 ÒÔϰ汾 +#if _MSC_VER < 1700 + #error Easy2D ²»Ö§³Ö Visual Studio 2012 ÒÔϰ汾 #endif diff --git a/project/vs2010/Easy2D.sln b/project/vs2010/Easy2D.sln deleted file mode 100644 index 6d924266..00000000 --- a/project/vs2010/Easy2D.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Easy2D", "Easy2D.vcxproj", "{47AF11E1-8725-4ECA-B8CF-951ABC397B31}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {47AF11E1-8725-4ECA-B8CF-951ABC397B31}.Debug|Win32.ActiveCfg = Debug|Win32 - {47AF11E1-8725-4ECA-B8CF-951ABC397B31}.Debug|Win32.Build.0 = Debug|Win32 - {47AF11E1-8725-4ECA-B8CF-951ABC397B31}.Debug|x64.ActiveCfg = Debug|x64 - {47AF11E1-8725-4ECA-B8CF-951ABC397B31}.Debug|x64.Build.0 = Debug|x64 - {47AF11E1-8725-4ECA-B8CF-951ABC397B31}.Release|Win32.ActiveCfg = Release|Win32 - {47AF11E1-8725-4ECA-B8CF-951ABC397B31}.Release|Win32.Build.0 = Release|Win32 - {47AF11E1-8725-4ECA-B8CF-951ABC397B31}.Release|x64.ActiveCfg = Release|x64 - {47AF11E1-8725-4ECA-B8CF-951ABC397B31}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/project/vs2010/Easy2D.vcxproj b/project/vs2010/Easy2D.vcxproj deleted file mode 100644 index 58189b39..00000000 --- a/project/vs2010/Easy2D.vcxproj +++ /dev/null @@ -1,239 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {47AF11E1-8725-4ECA-B8CF-951ABC397B31} - Win32Proj - Easy2D - - - - StaticLibrary - true - Unicode - - - StaticLibrary - true - Unicode - - - StaticLibrary - false - false - Unicode - - - StaticLibrary - false - false - Unicode - - - - - - - - - - - - - - - - - - - Easy2Dw - $(SolutionDir)$(Platform)\ - $(Configuration)\$(Platform)\ - - - Easy2Dw - $(SolutionDir)$(Platform)\ - $(Configuration)\$(Platform)\ - - - Easy2Ddw - $(SolutionDir)$(Platform)\ - $(Configuration)\$(Platform)\ - - - Easy2Ddw - $(SolutionDir)$(Platform)\ - $(Configuration)\$(Platform)\ - - - - - - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - - - false - true - - - Windows - true - - - - - - - Level3 - Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - - - false - true - - - Windows - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - - - true - - - Windows - true - true - true - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - - - true - - - Windows - true - true - true - - - - - - \ No newline at end of file diff --git a/project/vs2010/Easy2D.vcxproj.filters b/project/vs2010/Easy2D.vcxproj.filters deleted file mode 100644 index 26e49b3e..00000000 --- a/project/vs2010/Easy2D.vcxproj.filters +++ /dev/null @@ -1,234 +0,0 @@ - - - - - {5be538cb-a432-4f84-9678-bbf408eca288} - - - {d4a509dd-1bc0-4456-9554-d414de91b50c} - - - {c907d829-e510-472c-bd47-cf4eab6f9266} - - - {7b102f67-5905-4c0e-8400-51c128da026a} - - - {c536c42c-283d-4a10-b19b-0699b4f1e051} - - - {17bdc67b-1801-4b69-b79b-ffcbbee8dae0} - - - {6c760a81-9bc8-4fb0-a145-8e119b783365} - - - {4c1db04d-1ba5-4313-924e-c58c35265eed} - - - {fe2c1cba-f77d-4a33-bc8a-4f40ecd9d618} - - - {6f1847d1-aa22-4b3a-aeed-990b7645081f} - - - - - Action - - - Action - - - Action - - - Action - - - Action - - - Action - - - Action - - - Action - - - Action - - - Action - - - Action - - - Action - - - Action - - - Action - - - Action - - - Action - - - Base - - - Base - - - Base - - - Base - - - Base - - - Manager - - - Manager - - - Manager - - - Manager - - - Manager - - - Node - - - Node - - - Node - - - Node - - - Node - - - Node - - - Tool - - - Tool - - - Tool - - - Tool - - - Tool - - - Transition - - - Transition - - - Transition - - - Transition - - - Manager - - - Collider - - - Collider - - - Collider - - - Collider - - - Node\Shape - - - Node\Shape - - - Node\Shape - - - Node\Shape - - - Node\Shape - - - Common - - - Common - - - Common - - - Common - - - Common - - - Common - - - Common - - - Common - - - Common - - - Custom - - - - - - - - - - - - - - - - - \ No newline at end of file