diff --git a/core/Action/ActionSequence.cpp b/core/Action/ActionSequence.cpp index f5dcebfe..ab8abb7f 100644 --- a/core/Action/ActionSequence.cpp +++ b/core/Action/ActionSequence.cpp @@ -29,7 +29,7 @@ e2d::ActionSequence::ActionSequence(int number, Action * action1, ...) : e2d::ActionSequence::~ActionSequence() { - for (auto action : m_vActions) + FOR_LOOP(action, m_vActions) { SafeRelease(&action); } @@ -41,7 +41,7 @@ void e2d::ActionSequence::_init() // ½«ËùÓж¯×÷ÓëÄ¿±ê°ó¶¨ if (m_pTarget) { - for (auto action : m_vActions) + FOR_LOOP(action, m_vActions) { action->m_pTarget = m_pTarget; } @@ -74,7 +74,7 @@ void e2d::ActionSequence::_update() void e2d::ActionSequence::reset() { Action::reset(); - for (auto action : m_vActions) + FOR_LOOP(action, m_vActions) { action->reset(); } @@ -83,7 +83,7 @@ void e2d::ActionSequence::reset() void e2d::ActionSequence::_resetTime() { - for (auto action : m_vActions) + FOR_LOOP(action, m_vActions) { action->_resetTime(); } @@ -124,7 +124,7 @@ void e2d::ActionSequence::add(int number, Action * action, ...) e2d::ActionSequence * e2d::ActionSequence::clone() const { auto a = new ActionSequence(); - for (auto action : m_vActions) + FOR_LOOP(action, m_vActions) { a->add(action->clone()); } @@ -134,7 +134,7 @@ e2d::ActionSequence * e2d::ActionSequence::clone() const e2d::ActionSequence * e2d::ActionSequence::reverse(bool actionReverse) const { auto a = new ActionSequence(); - for (auto action : m_vActions) + FOR_LOOP(action, m_vActions) { if (actionReverse) { diff --git a/core/Action/Animation.cpp b/core/Action/Animation.cpp index fde05399..a94a237f 100644 --- a/core/Action/Animation.cpp +++ b/core/Action/Animation.cpp @@ -64,7 +64,7 @@ e2d::Animation::Animation(double interval, int number, Image * frame, ...) e2d::Animation::~Animation() { - for (auto frame : m_vFrames) + FOR_LOOP(frame, m_vFrames) { SafeRelease(&frame); } @@ -148,7 +148,7 @@ void e2d::Animation::add(int number, Image * frame, ...) e2d::Animation * e2d::Animation::clone() const { auto a = new Animation(m_fInterval); - for (auto frame : m_vFrames) + FOR_LOOP(frame, m_vFrames) { a->add(frame); } diff --git a/core/Base/Input.cpp b/core/Base/Input.cpp index 6214cf58..452454d7 100644 --- a/core/Base/Input.cpp +++ b/core/Base/Input.cpp @@ -3,7 +3,6 @@ #include "..\emanagers.h" #pragma comment(lib, "dinput8.lib") -#pragma comment(lib, "dxguid.lib") using namespace e2d; @@ -142,14 +141,14 @@ void Input::__updateDeviceState() ScreenToClient(Window::getHWnd(), &s_MousePosition); } -bool Input::isKeyDown(KeyCode nKeyCode) +bool Input::isKeyDown(int nKeyCode) { if (s_KeyBuffer[static_cast(nKeyCode)] & 0x80) return true; return false; } -bool Input::isKeyPress(KeyCode nKeyCode) +bool Input::isKeyPress(int nKeyCode) { if ((s_KeyBuffer[static_cast(nKeyCode)] & 0x80) && !(s_KeyRecordBuffer[static_cast(nKeyCode)] & 0x80)) @@ -157,7 +156,7 @@ bool Input::isKeyPress(KeyCode nKeyCode) return false; } -bool Input::isKeyRelease(KeyCode nKeyCode) +bool Input::isKeyRelease(int nKeyCode) { if (!(s_KeyBuffer[static_cast(nKeyCode)] & 0x80) && (s_KeyRecordBuffer[static_cast(nKeyCode)] & 0x80)) diff --git a/core/Base/Time.cpp b/core/Base/Time.cpp index a2b57872..7a01fccb 100644 --- a/core/Base/Time.cpp +++ b/core/Base/Time.cpp @@ -1,4 +1,24 @@ #include "..\ebase.h" + +// ÉÏÒ»Ö¡Ó뵱ǰ֡µÄʱ¼ä¼ä¸ô +static int s_nInterval = 0; +// ÓÎÏ·¿ªÊ¼Ê±³¤ +static double s_fTotalTime = 0; + + +double e2d::Time::getTotalTime() +{ + return s_fTotalTime; +} + +int e2d::Time::getDeltaTime() +{ + return s_nInterval; +} + + +#if HIGHER_THAN_VS2010 + #include #include using namespace std::chrono; @@ -12,24 +32,10 @@ static steady_clock::time_point s_tNow; static steady_clock::time_point s_tFixedUpdate; // ÉÏÒ»´Î¸üÐÂʱ¼ä static steady_clock::time_point s_tLastUpdate; -// ÉÏÒ»Ö¡Ó뵱ǰ֡µÄʱ¼ä¼ä¸ô -static int s_nInterval = 0; -// ÓÎÏ·¿ªÊ¼Ê±³¤ -static double s_fTotalTime = 0; // ÿһ֡¼ä¸ô static milliseconds s_tExceptedInvertal; -double e2d::Time::getTotalTime() -{ - return s_fTotalTime; -} - -int e2d::Time::getDeltaTime() -{ - return s_nInterval; -} - bool e2d::Time::__init() { s_tStart = s_tLastUpdate = s_tFixedUpdate = s_tNow = steady_clock::now(); @@ -72,4 +78,74 @@ void e2d::Time::__sleep() // ¹ÒÆðỊ̈߳¬ÊÍ·Å CPU Õ¼Óà std::this_thread::sleep_for(milliseconds(nWaitMS)); } -} \ No newline at end of file +} + + +#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 = 17LL * 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_fTotalTime = static_cast(s_tNow.QuadPart - s_tStart.QuadPart) / 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/Image.cpp b/core/Common/Image.cpp index b77c06fd..4a0f6139 100644 --- a/core/Common/Image.cpp +++ b/core/Common/Image.cpp @@ -202,9 +202,9 @@ bool e2d::Image::preload(String fileName) void e2d::Image::clearCache() { - for (auto child : s_mBitmapsFromFile) + for (auto child = s_mBitmapsFromFile.begin(); child != s_mBitmapsFromFile.end(); child++) { - SafeReleaseInterface(&child.second); + SafeReleaseInterface(&(*child).second); } s_mBitmapsFromFile.clear(); } diff --git a/core/Common/String.cpp b/core/Common/String.cpp index cd44d168..c655ab08 100644 --- a/core/Common/String.cpp +++ b/core/Common/String.cpp @@ -46,6 +46,39 @@ e2d::String & e2d::String::operator=(const char *cstr) return (*this); } +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(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); +} + e2d::String & e2d::String::format(const char * format, ...) { std::string tmp; @@ -266,25 +299,19 @@ e2d::String & e2d::String::operator<<(char * cstr) e2d::String & e2d::String::operator<<(int value) { - (*this) += String::toString(value); - return (*this); -} - -e2d::String & e2d::String::operator<<(unsigned int value) -{ - (*this) += String::toString(value); + (*this) += String::parse(value); return (*this); } e2d::String & e2d::String::operator<<(float value) { - (*this) += String::toString(value); + (*this) += String::parse(value); return (*this); } e2d::String & e2d::String::operator<<(double value) { - (*this) += String::toString(value); + (*this) += String::parse(value); return (*this); } diff --git a/core/Manager/ActionManager.cpp b/core/Manager/ActionManager.cpp index b9904ceb..6624957a 100644 --- a/core/Manager/ActionManager.cpp +++ b/core/Manager/ActionManager.cpp @@ -37,7 +37,7 @@ void e2d::ActionManager::__add(Action * pAction) { if (pAction) { - for (const auto action : s_vActions) + FOR_LOOP(action, s_vActions) { if (action == pAction) { @@ -76,7 +76,7 @@ void e2d::ActionManager::__resumeAllBindedWith(Node * pTargetNode) { if (pTargetNode) { - for (auto action : s_vRunningActions) + FOR_LOOP(action, s_vRunningActions) { if (action->getTarget() == pTargetNode) { @@ -90,7 +90,7 @@ void e2d::ActionManager::__pauseAllBindedWith(Node * pTargetNode) { if (pTargetNode) { - for (auto action : s_vRunningActions) + FOR_LOOP(action, s_vRunningActions) { if (action->getTarget() == pTargetNode) { @@ -104,7 +104,7 @@ void e2d::ActionManager::__stopAllBindedWith(Node * pTargetNode) { if (pTargetNode) { - for (auto action : s_vRunningActions) + FOR_LOOP(action, s_vRunningActions) { if (action->getTarget() == pTargetNode) { @@ -116,7 +116,7 @@ void e2d::ActionManager::__stopAllBindedWith(Node * pTargetNode) void e2d::ActionManager::resume(String strActionName) { - for (auto action : s_vRunningActions) + FOR_LOOP(action, s_vRunningActions) { if (action->getName() == strActionName) { @@ -127,7 +127,7 @@ void e2d::ActionManager::resume(String strActionName) void e2d::ActionManager::pause(String strActionName) { - for (auto action : s_vRunningActions) + FOR_LOOP(action, s_vRunningActions) { if (action->getName() == strActionName) { @@ -138,7 +138,7 @@ void e2d::ActionManager::pause(String strActionName) void e2d::ActionManager::stop(String strActionName) { - for (auto action : s_vRunningActions) + FOR_LOOP(action, s_vRunningActions) { if (action->getName() == strActionName) { @@ -169,7 +169,7 @@ void e2d::ActionManager::__clearAllBindedWith(Node * pTargetNode) void e2d::ActionManager::resumeAll() { - for (auto child : SceneManager::getCurrentScene()->getRoot()->getChildren()) + FOR_LOOP(child, SceneManager::getCurrentScene()->getRoot()->getChildren()) { ActionManager::__resumeAllBindedWith(child); } @@ -177,7 +177,7 @@ void e2d::ActionManager::resumeAll() void e2d::ActionManager::pauseAll() { - for (auto child : SceneManager::getCurrentScene()->getRoot()->getChildren()) + FOR_LOOP(child, SceneManager::getCurrentScene()->getRoot()->getChildren()) { ActionManager::__pauseAllBindedWith(child); } @@ -185,7 +185,7 @@ void e2d::ActionManager::pauseAll() void e2d::ActionManager::stopAll() { - for (auto child : SceneManager::getCurrentScene()->getRoot()->getChildren()) + FOR_LOOP(child, SceneManager::getCurrentScene()->getRoot()->getChildren()) { ActionManager::__stopAllBindedWith(child); } @@ -194,7 +194,7 @@ void e2d::ActionManager::stopAll() std::vector e2d::ActionManager::get(String strActionName) { std::vector vActions; - for (const auto action : s_vActions) + FOR_LOOP(action, s_vActions) { if (action->getName() == strActionName) { @@ -211,7 +211,7 @@ std::vector e2d::ActionManager::getAll() void e2d::ActionManager::__resetAllActions() { - for (auto action : s_vRunningActions) + FOR_LOOP(action, s_vRunningActions) { action->_resetTime(); } diff --git a/core/Manager/CollisionManager.cpp b/core/Manager/CollisionManager.cpp index 580deef2..b0ca1cf6 100644 --- a/core/Manager/CollisionManager.cpp +++ b/core/Manager/CollisionManager.cpp @@ -67,9 +67,9 @@ void e2d::CollisionManager::__updateShape(e2d::ShapeBase * pActiveShape) pPassiveNode->getParentScene() == pCurrentScene) { // ÅжÏÁ½ÎïÌåÊÇ·ñÊÇÏ໥³åÍ»µÄÎïÌå - auto IsCollideWith = [](Node * active, unsigned int hash) + auto IsCollideWith = [](Node * active, unsigned int hash) -> bool { - for (auto collider : active->m_vColliders) + FOR_LOOP(collider, active->m_vColliders) if (collider == hash) return true; return false; @@ -78,7 +78,7 @@ void e2d::CollisionManager::__updateShape(e2d::ShapeBase * pActiveShape) if (IsCollideWith(pActiveNode, pPassiveNode->getHashName())) { // ÅжÏÁ½ÐÎ×´½»¼¯Çé¿ö - Relation relation = pActiveShape->getRelationWith(pPassiveShape); + int relation = pActiveShape->getRelationWith(pPassiveShape); // ºöÂÔ UNKNOWN ºÍ DISJOINT Çé¿ö if (relation != Relation::UNKNOWN && relation != Relation::DISJOINT) { @@ -105,7 +105,7 @@ void e2d::CollisionManager::__add(CollisionListener * pListener) { auto findListener = [](CollisionListener * pListener) -> bool { - for (const auto &l : s_vListeners) + FOR_LOOP(l, s_vListeners) { if (pListener == l) { @@ -133,7 +133,7 @@ void e2d::CollisionManager::add(Function func, String name) void e2d::CollisionManager::start(String name) { - for (const auto & pListener : s_vListeners) + FOR_LOOP(pListener, s_vListeners) { if (pListener->getName() == name) { @@ -144,7 +144,7 @@ void e2d::CollisionManager::start(String name) void e2d::CollisionManager::stop(String name) { - for (const auto & pListener : s_vListeners) + FOR_LOOP(pListener, s_vListeners) { if (pListener->getName() == name) { @@ -155,7 +155,7 @@ void e2d::CollisionManager::stop(String name) void e2d::CollisionManager::clear(String name) { - for (const auto & pListener : s_vListeners) + FOR_LOOP(pListener, s_vListeners) { if (pListener->getName() == name) { @@ -166,7 +166,7 @@ void e2d::CollisionManager::clear(String name) void e2d::CollisionManager::startAll() { - for (const auto & pListener : s_vListeners) + FOR_LOOP(pListener, s_vListeners) { pListener->start(); } @@ -174,7 +174,7 @@ void e2d::CollisionManager::startAll() void e2d::CollisionManager::stopAll() { - for (const auto & pListener : s_vListeners) + FOR_LOOP(pListener, s_vListeners) { pListener->stop(); } @@ -182,7 +182,7 @@ void e2d::CollisionManager::stopAll() void e2d::CollisionManager::clearAll() { - for (const auto & pListener : s_vListeners) + FOR_LOOP(pListener, s_vListeners) { pListener->stopAndClear(); } @@ -191,7 +191,7 @@ void e2d::CollisionManager::clearAll() std::vector e2d::CollisionManager::get(String name) { std::vector vListeners; - for (auto pListener : s_vListeners) + FOR_LOOP(pListener, s_vListeners) { if (pListener->getName() == name) { diff --git a/core/Manager/InputManager.cpp b/core/Manager/InputManager.cpp index 9f8b7871..4f04e304 100644 --- a/core/Manager/InputManager.cpp +++ b/core/Manager/InputManager.cpp @@ -31,7 +31,7 @@ void e2d::InputManager::__add(InputListener * pListener) { auto findListener = [](InputListener * pListener) -> bool { - for (const auto &l : s_vListeners) + FOR_LOOP(l, s_vListeners) { if (pListener == l) { @@ -59,7 +59,7 @@ void e2d::InputManager::add(Function func, String name) void e2d::InputManager::start(String name) { - for (const auto & pListener : s_vListeners) + FOR_LOOP(pListener, s_vListeners) { if (pListener->getName() == name) { @@ -70,7 +70,7 @@ void e2d::InputManager::start(String name) void e2d::InputManager::stop(String name) { - for (const auto & pListener : s_vListeners) + FOR_LOOP(pListener, s_vListeners) { if (pListener->getName() == name) { @@ -81,7 +81,7 @@ void e2d::InputManager::stop(String name) void e2d::InputManager::clear(String name) { - for (const auto & pListener : s_vListeners) + FOR_LOOP(pListener, s_vListeners) { if (pListener->getName() == name) { @@ -92,7 +92,7 @@ void e2d::InputManager::clear(String name) void e2d::InputManager::startAll() { - for (const auto & pListener : s_vListeners) + FOR_LOOP(pListener, s_vListeners) { pListener->start(); } @@ -100,7 +100,7 @@ void e2d::InputManager::startAll() void e2d::InputManager::stopAll() { - for (const auto & pListener : s_vListeners) + FOR_LOOP(pListener, s_vListeners) { pListener->stop(); } @@ -108,7 +108,7 @@ void e2d::InputManager::stopAll() void e2d::InputManager::clearAll() { - for (const auto & pListener : s_vListeners) + FOR_LOOP(pListener, s_vListeners) { pListener->stopAndClear(); } @@ -117,7 +117,7 @@ void e2d::InputManager::clearAll() std::vector e2d::InputManager::get(String name) { std::vector vListeners; - for (auto pListener : s_vListeners) + FOR_LOOP(pListener, s_vListeners) { if (pListener->getName() == name) { diff --git a/core/Manager/MusicManager.cpp b/core/Manager/MusicManager.cpp index 85006d24..52a873df 100644 --- a/core/Manager/MusicManager.cpp +++ b/core/Manager/MusicManager.cpp @@ -2,9 +2,18 @@ #include "..\etools.h" #include +#if HIGHER_THAN_VS2010 + static IXAudio2 * s_pXAudio2 = nullptr; static IXAudio2MasteringVoice * s_pMasteringVoice = nullptr; +#else + +static HINSTANCE s_hInstance = nullptr; + +#endif + + typedef std::pair MusicPair; typedef std::map MusicList; @@ -98,28 +107,31 @@ e2d::Music * e2d::MusicManager::get(String strFilePath) void e2d::MusicManager::pauseAll() { - for (auto iter : getMusicList()) + for (auto iter = getMusicList().begin(); iter != getMusicList().end(); iter++) { - iter.second->pause(); + (*iter).second->pause(); } } void e2d::MusicManager::resumeAll() { - for (auto iter : getMusicList()) + for (auto iter = getMusicList().begin(); iter != getMusicList().end(); iter++) { - iter.second->resume(); + (*iter).second->resume(); } } void e2d::MusicManager::stopAll() { - for (auto iter : getMusicList()) + for (auto iter = getMusicList().begin(); iter != getMusicList().end(); iter++) { - iter.second->stop(); + (*iter).second->stop(); } } + +#if HIGHER_THAN_VS2010 + IXAudio2 * e2d::MusicManager::getIXAudio2() { return s_pXAudio2; @@ -165,4 +177,46 @@ void e2d::MusicManager::__uninit() } SafeReleaseInterface(&s_pXAudio2); -} \ No newline at end of file +} + +#else + +HINSTANCE e2d::MusicManager::getHInstance() +{ + return s_hInstance; +} + +bool e2d::MusicManager::__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; +} + +void e2d::MusicManager::__uninit() +{ + for (auto iter = getMusicList().begin(); iter != getMusicList().end(); iter++) + { + (*iter).second->close(); + (*iter).second->release(); + } + getMusicList().clear(); +} + +#endif \ No newline at end of file diff --git a/core/Manager/TimerManager.cpp b/core/Manager/TimerManager.cpp index e48a1657..9c6d2a2c 100644 --- a/core/Manager/TimerManager.cpp +++ b/core/Manager/TimerManager.cpp @@ -41,7 +41,7 @@ void e2d::TimerManager::__add(Timer * pTimer) { auto findTimer = [](Timer * pTimer) -> bool { - for (const auto &t : s_vTimers) + FOR_LOOP(t, s_vTimers) { if (pTimer == t) { @@ -64,7 +64,7 @@ void e2d::TimerManager::__add(Timer * pTimer) void e2d::TimerManager::start(String name) { - for (auto timer : s_vTimers) + FOR_LOOP(timer, s_vTimers) { if (timer->getName() == name) { @@ -75,7 +75,7 @@ void e2d::TimerManager::start(String name) void e2d::TimerManager::stop(String name) { - for (auto timer : s_vTimers) + FOR_LOOP(timer, s_vTimers) { if (timer->getName() == name) { @@ -86,7 +86,7 @@ void e2d::TimerManager::stop(String name) void e2d::TimerManager::clear(String name) { - for (auto timer : s_vTimers) + FOR_LOOP(timer, s_vTimers) { if (timer->getName() == name) { @@ -98,7 +98,7 @@ void e2d::TimerManager::clear(String name) std::vector e2d::TimerManager::get(String name) { std::vector vTimers; - for (auto timer : s_vTimers) + FOR_LOOP(timer, s_vTimers) { if (timer->getName() == name) { @@ -110,7 +110,7 @@ std::vector e2d::TimerManager::get(String name) void e2d::TimerManager::startAll() { - for (auto timer : s_vTimers) + FOR_LOOP(timer, s_vTimers) { timer->start(); } @@ -118,7 +118,7 @@ void e2d::TimerManager::startAll() void e2d::TimerManager::stopAll() { - for (auto timer : s_vTimers) + FOR_LOOP(timer, s_vTimers) { timer->stop(); } @@ -126,7 +126,7 @@ void e2d::TimerManager::stopAll() void e2d::TimerManager::stopAndClearAll() { - for (auto timer : s_vTimers) + FOR_LOOP(timer, s_vTimers) { timer->stop(); timer->release(); @@ -141,7 +141,7 @@ std::vector e2d::TimerManager::getAll() void e2d::TimerManager::__resetAllTimers() { - for (auto timer : s_vTimers) + FOR_LOOP(timer, s_vTimers) { timer->m_fLast = Time::getTotalTime(); } @@ -149,7 +149,7 @@ void e2d::TimerManager::__resetAllTimers() void e2d::TimerManager::__uninit() { - for (const auto timer : s_vTimers) + FOR_LOOP(timer, s_vTimers) { timer->release(); } diff --git a/core/Node/Menu.cpp b/core/Node/Menu.cpp index 33362752..9828a5ac 100644 --- a/core/Node/Menu.cpp +++ b/core/Node/Menu.cpp @@ -34,7 +34,7 @@ void e2d::Menu::setEnable(bool enable) { m_bEnable = enable; - for (auto button : m_vButtons) + FOR_LOOP(button, m_vButtons) { button->setEnable(enable); } diff --git a/core/Node/Node.cpp b/core/Node/Node.cpp index 1d43e90e..6a60b0b0 100644 --- a/core/Node/Node.cpp +++ b/core/Node/Node.cpp @@ -48,7 +48,7 @@ e2d::Node::~Node() { ActionManager::__clearAllBindedWith(this); CollisionManager::__removeShape(m_pShape); - for (auto child : m_vChildren) + FOR_LOOP(child, m_vChildren) { SafeRelease(&child); } @@ -174,7 +174,7 @@ void e2d::Node::_drawShape() } // »æÖÆËùÓÐ×Ó½ÚµãµÄ¼¸ºÎÐÎ×´ - for (auto child : m_vChildren) + FOR_LOOP(child, m_vChildren) { child->_drawShape(); } @@ -187,7 +187,7 @@ void e2d::Node::_onEnter() this->m_bDisplayedInScene = true; this->onEnter(); - for (auto child : m_vChildren) + FOR_LOOP(child, m_vChildren) { child->_onEnter(); } @@ -201,7 +201,7 @@ void e2d::Node::_onExit() this->m_bDisplayedInScene = false; this->onExit(); - for (auto child : m_vChildren) + FOR_LOOP(child, m_vChildren) { child->_onExit(); } @@ -240,7 +240,7 @@ void e2d::Node::_updateTransform() void e2d::Node::_updateChildrenTransform() { - for (auto child : m_vChildren) + FOR_LOOP(child, m_vChildren) { _updateTransform(child); } @@ -263,7 +263,7 @@ void e2d::Node::_updateTransform(Node * node) void e2d::Node::_updateChildrenOpacity() { - for (auto child : m_vChildren) + FOR_LOOP(child, m_vChildren) { _updateOpacity(child); } @@ -547,7 +547,7 @@ void e2d::Node::setSize(Size size) this->setSize(size.width, size.height); } -void e2d::Node::setShape(Shape type) +void e2d::Node::setShape(int type) { switch (type) { @@ -683,7 +683,7 @@ std::vector e2d::Node::getChildren(String name) std::vector vChildren; unsigned int hash = name.getHashCode(); - for (auto child : m_vChildren) + FOR_LOOP(child, m_vChildren) { // ²»Í¬µÄÃû³Æ¿ÉÄÜ»áÓÐÏàͬµÄ Hash Öµ£¬µ«ÊÇÏÈ±È½Ï Hash ¿ÉÒÔÌáÉýËÑË÷ËÙ¶È if (child->m_nHashName == hash && child->m_sName == name) @@ -784,7 +784,7 @@ void e2d::Node::removeChildren(String childName) void e2d::Node::clearAllChildren() { // ËùÓнڵãµÄÒýÓüÆÊý¼õÒ» - for (auto child : m_vChildren) + FOR_LOOP(child, m_vChildren) { if (child->m_bDisplayedInScene) { @@ -820,7 +820,7 @@ void e2d::Node::runAction(Action * action) void e2d::Node::resumeAction(String strActionName) { auto actions = ActionManager::get(strActionName); - for (auto action : actions) + FOR_LOOP(action, actions) { if (action->getTarget() == this) { @@ -832,7 +832,7 @@ void e2d::Node::resumeAction(String strActionName) void e2d::Node::pauseAction(String strActionName) { auto actions = ActionManager::get(strActionName); - for (auto action : actions) + FOR_LOOP(action, actions) { if (action->getTarget() == this) { @@ -844,7 +844,7 @@ void e2d::Node::pauseAction(String strActionName) void e2d::Node::stopAction(String strActionName) { auto actions = ActionManager::get(strActionName); - for (auto action : actions) + FOR_LOOP(action, actions) { if (action->getTarget() == this) { @@ -856,7 +856,7 @@ void e2d::Node::stopAction(String strActionName) e2d::Action * e2d::Node::getAction(String strActionName) { auto actions = ActionManager::get(strActionName); - for (auto action : actions) + FOR_LOOP(action, actions) { if (action->getTarget() == this) { @@ -924,7 +924,7 @@ bool e2d::Node::isPointIn(Point point) const } // ÅжϵãÊÇ·ñÔÚ×Ó½ÚµãÄÚ - for (auto child : m_vChildren) + FOR_LOOP(child, m_vChildren) if (child->isPointIn(point)) return true; @@ -936,7 +936,7 @@ bool e2d::Node::isIntersectWith(const Node * pNode) const // Èç¹û´æÔÚÐÎ×´£¬ÓÃÐÎ×´ÅÐ¶Ï if (this->m_pShape && pNode->m_pShape) { - Relation relation = this->m_pShape->getRelationWith(pNode->m_pShape); + int relation = this->m_pShape->getRelationWith(pNode->m_pShape); if ((relation != Relation::UNKNOWN) && (relation != Relation::DISJOINT)) { @@ -977,20 +977,20 @@ bool e2d::Node::isIntersectWith(const Node * pNode) const SafeReleaseInterface(&pRect1); SafeReleaseInterface(&pRect2); SafeReleaseInterface(&pShape); - if ((relation != D2D1_GEOMETRY_RELATION::D2D1_GEOMETRY_RELATION_UNKNOWN) && - (relation != D2D1_GEOMETRY_RELATION::D2D1_GEOMETRY_RELATION_DISJOINT)) + if ((relation != D2D1_GEOMETRY_RELATION_UNKNOWN) && + (relation != D2D1_GEOMETRY_RELATION_DISJOINT)) { return true; } } // ÅÐ¶ÏºÍÆä×Ó½ÚµãÊÇ·ñÏཻ - for (auto child : pNode->m_vChildren) - if (this->isIntersectWith(child)) + FOR_LOOP(pNodeChild, pNode->m_vChildren) + if (this->isIntersectWith(pNodeChild)) return true; // ÅжÏ×Ó½ÚµãºÍÆäÊÇ·ñÏཻ - for (auto child : m_vChildren) + FOR_LOOP(child, m_vChildren) if (child->isIntersectWith(pNode)) return true; @@ -1050,7 +1050,7 @@ void e2d::Node::setName(String name) void e2d::Node::_setParentScene(Scene * scene) { m_pParentScene = scene; - for (auto child : m_vChildren) + FOR_LOOP(child, m_vChildren) { child->_setParentScene(scene); } diff --git a/core/Node/Text.cpp b/core/Node/Text.cpp index 98c007f8..d9797f29 100644 --- a/core/Node/Text.cpp +++ b/core/Node/Text.cpp @@ -164,7 +164,7 @@ void e2d::Text::setLineSpacing(double fLineSpacing) } } -void e2d::Text::setAlignment(TextAlign nAlign) +void e2d::Text::setAlignment(int nAlign) { if (m_nAlign != nAlign) { diff --git a/core/Shape/ShapeBase.cpp b/core/Shape/ShapeBase.cpp index 1b733cc5..d3f299fa 100644 --- a/core/Shape/ShapeBase.cpp +++ b/core/Shape/ShapeBase.cpp @@ -65,7 +65,7 @@ void e2d::ShapeBase::_render() } } -e2d::Relation e2d::ShapeBase::getRelationWith(ShapeBase * pShape) const +int e2d::ShapeBase::getRelationWith(ShapeBase * pShape) const { if (m_pTransformedShape && pShape->m_pTransformedShape) { @@ -79,7 +79,7 @@ e2d::Relation e2d::ShapeBase::getRelationWith(ShapeBase * pShape) const &relation ); - return Relation(relation); + return relation; } } return Relation::UNKNOWN; diff --git a/core/Tool/Data.cpp b/core/Tool/Data.cpp index 26896b95..4fc5dce4 100644 --- a/core/Tool/Data.cpp +++ b/core/Tool/Data.cpp @@ -4,12 +4,12 @@ static e2d::String s_sDefaultFileName = L"DefaultData.ini"; void e2d::Data::saveInt(String key, int value, String field) { - ::WritePrivateProfileString(field, key, String::toString(value), Data::getDataFilePath()); + ::WritePrivateProfileString(field, key, String::parse(value), Data::getDataFilePath()); } void e2d::Data::saveDouble(String key, double value, String field) { - ::WritePrivateProfileString(field, key, String::toString(value), Data::getDataFilePath()); + ::WritePrivateProfileString(field, key, String::parse(value), Data::getDataFilePath()); } void e2d::Data::saveBool(String key, bool value, String field) @@ -31,7 +31,7 @@ int e2d::Data::getInt(String key, int defaultValue, String field) double e2d::Data::getDouble(String key, double defaultValue, String field) { wchar_t temp[32] = { 0 }; - ::GetPrivateProfileString(field, key, String::toString(defaultValue), temp, 31, Data::getDataFilePath()); + ::GetPrivateProfileString(field, key, String::parse(defaultValue), temp, 31, Data::getDataFilePath()); return std::stof(temp); } diff --git a/core/Tool/Music.cpp b/core/Tool/Music.cpp index b66cc39a..d295ebc3 100644 --- a/core/Tool/Music.cpp +++ b/core/Tool/Music.cpp @@ -3,6 +3,8 @@ using namespace e2d; +#if HIGHER_THAN_VS2010 + #ifndef SAFE_DELETE #define SAFE_DELETE(p) { if (p) { delete (p); (p)=nullptr; } } #endif @@ -231,7 +233,7 @@ void Music::close() m_bPlaying = false; } -bool Music::isPlaying() +bool Music::isPlaying() const { if (m_bOpened && m_pSourceVoice) { @@ -490,3 +492,196 @@ bool Music::_findMediaFileCch(wchar_t* strDestPath, int cchDest, const wchar_t * return false; } + + +#else + + +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, + MusicManager::getHInstance(), + 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/easy2d.h b/core/easy2d.h index 8291a36a..013eb464 100644 --- a/core/easy2d.h +++ b/core/easy2d.h @@ -12,8 +12,8 @@ #error ½öÄÜÔÚ C++ »·¾³ÏÂʹÓà Easy2D #endif -#if _MSC_VER < 1700 - #error Easy2D ²»Ö§³Ö Visual Studio 2012 ÒÔϰ汾 +#if _MSC_VER < 1600 + #error Easy2D ²»Ö§³Ö Visual Studio 2010 ÒÔϰ汾 #endif diff --git a/core/ebase.h b/core/ebase.h index 39325b4d..35d42cd4 100644 --- a/core/ebase.h +++ b/core/ebase.h @@ -152,17 +152,17 @@ class Input public: // ¼ì²â¼üÅÌij°´¼üÊÇ·ñÕý±»°´Ï static bool isKeyDown( - KeyCode nKeyCode + int nKeyCode ); // ¼ì²â¼üÅÌij°´¼üÊÇ·ñ±»µã»÷ static bool isKeyPress( - KeyCode nKeyCode + int nKeyCode ); // ¼ì²â¼üÅÌij°´¼üÊÇ·ñÕýÔÚËÉ¿ª static bool isKeyRelease( - KeyCode nKeyCode + int nKeyCode ); // ¼ì²âÊó±ê×ó¼üÊÇ·ñÕý±»°´Ï diff --git a/core/ecommon.h b/core/ecommon.h index d961f65f..1bfdc055 100644 --- a/core/ecommon.h +++ b/core/ecommon.h @@ -135,10 +135,12 @@ public: // ½«×Ö·û´®×ª»¯Îª bool ÐÍ bool toBool() const; - // ½«Êý×Öת»¯Îª×Ö·û´® - template - static String toString(T value); + // Êý×ÖÀàÐÍת×Ö·û´® + static String parse(int value); + static String parse(float value); + static String parse(double value); + // ¸ñʽ»¯×Ö·û´® String& format(const char * format, ...); String& format(const wchar_t * format, ...); @@ -182,7 +184,6 @@ public: String& operator<< (const wchar_t *); String& operator<< (wchar_t *); String& operator<< (int value); - String& operator<< (unsigned int value); String& operator<< (float value); String& operator<< (double value); @@ -300,93 +301,109 @@ public: // Îı¾¶ÔÆë·½Ê½ -enum class TextAlign : int +class TextAlign { - LEFT, /* ×ó¶ÔÆë */ - RIGHT, /* ÓÒ¶ÔÆë */ - CENTER /* ¾ÓÖÐ¶ÔÆë */ +public: + enum : int + { + LEFT, /* ×ó¶ÔÆë */ + RIGHT, /* ÓÒ¶ÔÆë */ + CENTER /* ¾ÓÖÐ¶ÔÆë */ + }; }; // ¼üÖµ¼¯ºÏ -enum class KeyCode : int +class KeyCode { - UP = 0xC8, - LEFT = 0xCB, - RIGHT = 0xCD, - DOWN = 0xD0, - ENTER = 0x1C, - SPACE = 0x39, - ESC = 0x01, - BACK = 0x0E, - TAB = 0x0F, - PAUSE = 0xC5, - Q = 0x10, - W = 0x11, - E = 0x12, - R = 0x13, - T = 0x14, - Y = 0x15, - U = 0x16, - I = 0x17, - O = 0x18, - P = 0x19, - A = 0x1E, - S = 0x1F, - D = 0x20, - F = 0x21, - G = 0x22, - H = 0x23, - J = 0x24, - K = 0x25, - L = 0x26, - Z = 0x2C, - X = 0x2D, - C = 0x2E, - V = 0x2F, - B = 0x30, - N = 0x31, - M = 0x32, - NUM1 = 0x02, - NUM2 = 0x03, - NUM3 = 0x04, - NUM4 = 0x05, - NUM5 = 0x06, - NUM6 = 0x07, - NUM7 = 0x08, - NUM8 = 0x09, - NUM9 = 0x0A, - NUM0 = 0x0B, - NUMPAD7 = 0x47, - NUMPAD8 = 0x48, - NUMPAD9 = 0x49, - NUMPAD4 = 0x4B, - NUMPAD5 = 0x4C, - NUMPAD6 = 0x4D, - NUMPAD1 = 0x4F, - NUMPAD2 = 0x50, - NUMPAD3 = 0x51, - NUMPAD0 = 0x52 +public: + enum : int + { + UP = 0xC8, + LEFT = 0xCB, + RIGHT = 0xCD, + DOWN = 0xD0, + ENTER = 0x1C, + SPACE = 0x39, + ESC = 0x01, + BACK = 0x0E, + TAB = 0x0F, + PAUSE = 0xC5, + Q = 0x10, + W = 0x11, + E = 0x12, + R = 0x13, + T = 0x14, + Y = 0x15, + U = 0x16, + I = 0x17, + O = 0x18, + P = 0x19, + A = 0x1E, + S = 0x1F, + D = 0x20, + F = 0x21, + G = 0x22, + H = 0x23, + J = 0x24, + K = 0x25, + L = 0x26, + Z = 0x2C, + X = 0x2D, + C = 0x2E, + V = 0x2F, + B = 0x30, + N = 0x31, + M = 0x32, + NUM1 = 0x02, + NUM2 = 0x03, + NUM3 = 0x04, + NUM4 = 0x05, + NUM5 = 0x06, + NUM6 = 0x07, + NUM7 = 0x08, + NUM8 = 0x09, + NUM9 = 0x0A, + NUM0 = 0x0B, + NUMPAD7 = 0x47, + NUMPAD8 = 0x48, + NUMPAD9 = 0x49, + NUMPAD4 = 0x4B, + NUMPAD5 = 0x4C, + NUMPAD6 = 0x4D, + NUMPAD1 = 0x4F, + NUMPAD2 = 0x50, + NUMPAD3 = 0x51, + NUMPAD0 = 0x52 + }; }; // ÐÎ×´½»¼¯¹ØÏµ -enum class Relation : int +class Relation { - UNKNOWN = 0, /* ¹ØÏµ²»È·¶¨ */ - DISJOINT = 1, /* ûÓн»¼¯ */ - IS_CONTAINED = 2, /* ÍêÈ«±»°üº¬ */ - CONTAINS = 3, /* ÍêÈ«°üº¬ */ - OVERLAP = 4 /* ²¿·ÖÖØµþ */ +public: + enum : int + { + UNKNOWN = 0, /* ¹ØÏµ²»È·¶¨ */ + DISJOINT = 1, /* ûÓн»¼¯ */ + IS_CONTAINED = 2, /* ÍêÈ«±»°üº¬ */ + CONTAINS = 3, /* ÍêÈ«°üº¬ */ + OVERLAP = 4 /* ²¿·ÖÖØµþ */ + }; }; // ÐÎ×´Àà±ð -enum class Shape : int +class Shape { - RECTANGLE, /* ¾ØÐÎ */ - CIRCLE, /* Ô²ÐÎ */ - ELLIPSE /* ÍÖÔ²ÐÎ */ +public: + enum : int + { + RECTANGLE, /* ¾ØÐÎ */ + CIRCLE, /* Ô²ÐÎ */ + ELLIPSE /* ÍÖÔ²ÐÎ */ + }; }; @@ -604,15 +621,6 @@ protected: }; -// String ÀàÄ£°åº¯Êý¶¨Òå -template -inline e2d::String e2d::String::toString(T value) -{ - String tmp; - tmp.m_str = std::to_wstring(value); - return std::move(tmp); -} - template inline void SafeDelete(T** p) { if (*p) { delete *p; *p = nullptr; } } diff --git a/core/emacros.h b/core/emacros.h index 0a18e361..0aa0f251 100644 --- a/core/emacros.h +++ b/core/emacros.h @@ -28,6 +28,8 @@ #define DIRECTINPUT_VERSION 0x0800 #endif +#define INITGUID + // Windows Header Files #include #include @@ -35,7 +37,6 @@ #include #include #include -#include #include // C RunTime Header Files @@ -45,16 +46,35 @@ // Import Libraries #pragma comment(lib, "d2d1.lib") #pragma comment(lib, "dwrite.lib") -#pragma comment(lib, "xaudio2.lib") #pragma comment(lib, "windowscodecs.lib") #pragma comment(lib, "winmm.lib") +#if _MSC_VER > 1600 +#include +#pragma comment(lib, "xaudio2.lib") +#endif + #ifndef HINST_THISCOMPONENT EXTERN_C IMAGE_DOS_HEADER __ImageBase; #define HINST_THISCOMPONENT ((HINSTANCE)&__ImageBase) #endif +#define MUSIC_CLASS_NAME L"Easy2DMusicCallbackWnd" + + +#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 + #ifndef ASSERT #if defined( DEBUG ) || defined( _DEBUG ) @@ -73,8 +93,9 @@ EXTERN_C IMAGE_DOS_HEADER __ImageBase; #endif -#if _MSC_VER > 1700 -#define HIGHER_THAN_VS2012 1 +#if HIGHER_THAN_VS2010 +#define FOR_LOOP(i, container) for (auto i : (container)) #else -#define HIGHER_THAN_VS2012 0 +#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 diff --git a/core/emanagers.h b/core/emanagers.h index fcce3c4d..ca78f9be 100644 --- a/core/emanagers.h +++ b/core/emanagers.h @@ -280,12 +280,21 @@ public: // Í£Ö¹ËùÓÐÒôÀÖ static void stopAll(); +#if HIGHER_THAN_VS2010 + // »ñÈ¡ IXAudio2 ¶ÔÏó static IXAudio2 * getIXAudio2(); // »ñÈ¡ IXAudio2MasteringVoice ¶ÔÏó static IXAudio2MasteringVoice * getIXAudio2MasteringVoice(); +#else + + // »ñÈ¡ HINSTANCE + static HINSTANCE getHInstance(); + +#endif + private: // ³õʼ»¯ XAudio2 static bool __init(); diff --git a/core/enodes.h b/core/enodes.h index 4dc1cd23..68b0c3da 100644 --- a/core/enodes.h +++ b/core/enodes.h @@ -313,7 +313,7 @@ public: // ÉèÖýڵãÐÎ×´ virtual void setShape( - Shape type + int type ); // ÉèÖýڵãÐÎ×´ @@ -627,7 +627,7 @@ public: // ÉèÖÃ¶ÔÆë·½Ê½£¨Ä¬ÈÏΪ TextAlign::LEFT£© void setAlignment( - TextAlign nAlign + int nAlign ); // ÉèÖÃÏ»®Ïߣ¨Ä¬ÈÏֵΪ false£© @@ -659,7 +659,7 @@ protected: float m_fWrappingWidth; Font m_Font; float m_fLineSpacing; - TextAlign m_nAlign; + int m_nAlign; IDWriteTextFormat * m_pDWriteTextFormat; IDWriteTextLayout * m_pDWriteTextLayout; }; diff --git a/core/eshape.h b/core/eshape.h index 2ff4e290..eaced236 100644 --- a/core/eshape.h +++ b/core/eshape.h @@ -21,7 +21,7 @@ public: virtual ~ShapeBase(); // ÅжÏÁ½ÐÎ×´µÄ½»¼¯¹ØÏµ - virtual Relation getRelationWith( + virtual int getRelationWith( ShapeBase * pShape ) const; diff --git a/core/etools.h b/core/etools.h index 64ca1dd1..a03848be 100644 --- a/core/etools.h +++ b/core/etools.h @@ -362,7 +362,7 @@ public: void close(); // »ñÈ¡ÒôÀÖ²¥·Å״̬ - bool isPlaying(); + bool isPlaying() const; // »ñÈ¡ÒôÁ¿ double getVolume() const; @@ -372,7 +372,7 @@ public: // ÉèÖÃÒôÁ¿ bool setVolume( - double fVolume /* ÒôÁ¿·¶Î§Îª -224 ~ 224£¬ÆäÖÐ 0 ÊǾ²Òô£¬1 ÊÇÕý³£ÒôÁ¿ */ + double fVolume /* ÒôÁ¿·¶Î§Îª -224 ~ 224£¬ÆäÖÐ 0 ÊǾ²Òô£¬1 ÊÇÕý³£ÒôÁ¿ */ ); // ÉèÖÃÆµÂÊ±È @@ -380,6 +380,8 @@ public: double fFrequencyRatio /* ƵÂʱȷ¶Î§Îª 1/1024.0f ~ 1024.0f£¬ÆäÖÐ 1.0 ΪÕý³£Éùµ÷ */ ); +#if HIGHER_THAN_VS2010 + // »ñÈ¡ IXAudio2SourceVoice ¶ÔÏó IXAudio2SourceVoice* getIXAudio2SourceVoice() const; @@ -401,7 +403,7 @@ protected: protected: bool m_bOpened; - bool m_bPlaying; + mutable bool m_bPlaying; DWORD m_dwSize; CHAR* m_pResourceBuffer; BYTE* m_pbWaveData; @@ -410,6 +412,22 @@ 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 }; } \ No newline at end of file diff --git a/project/vs2010/Easy2D.sln b/project/vs2010/Easy2D.sln new file mode 100644 index 00000000..9b743ffb --- /dev/null +++ b/project/vs2010/Easy2D.sln @@ -0,0 +1,20 @@ + +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 + Release|Win32 = Release|Win32 + 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}.Release|Win32.ActiveCfg = Release|Win32 + {47AF11E1-8725-4ECA-B8CF-951ABC397B31}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/project/vs2010/Easy2D.vcxproj b/project/vs2010/Easy2D.vcxproj new file mode 100644 index 00000000..6306736d --- /dev/null +++ b/project/vs2010/Easy2D.vcxproj @@ -0,0 +1,158 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {47AF11E1-8725-4ECA-B8CF-951ABC397B31} + Win32Proj + Easy2D + + + + StaticLibrary + true + Unicode + + + StaticLibrary + false + false + Unicode + + + + + + + + + + + + + Easy2Dw + $(SolutionDir)$(Platform)\ + $(Configuration)\$(Platform)\ + + + Easy2Ddw + $(SolutionDir)$(Platform)\ + $(Configuration)\$(Platform)\ + + + + + + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + EditAndContinue + false + + + Windows + true + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + + + + + Windows + true + true + true + + + + + + \ No newline at end of file diff --git a/project/vs2010/Easy2D.vcxproj.filters b/project/vs2010/Easy2D.vcxproj.filters new file mode 100644 index 00000000..cc4ecc9c --- /dev/null +++ b/project/vs2010/Easy2D.vcxproj.filters @@ -0,0 +1,214 @@ + + + + + {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} + + + {508b39c8-a430-45c3-9405-364fbc281220} + + + + + Action + + + Action + + + Action + + + Action + + + Action + + + Action + + + Action + + + Action + + + Action + + + Action + + + Action + + + Action + + + Action + + + Action + + + Action + + + Action + + + Base + + + Base + + + Base + + + Base + + + Base + + + Common + + + Common + + + Common + + + Common + + + Common + + + Common + + + Common + + + Shape + + + Shape + + + Shape + + + Shape + + + Manager + + + Manager + + + Manager + + + Manager + + + Manager + + + Manager + + + Manager + + + Node + + + Node + + + Node + + + Node + + + Node + + + Node + + + Tool + + + Tool + + + Tool + + + Tool + + + Tool + + + Tool + + + Tool + + + Tool + + + Transition + + + Transition + + + Transition + + + Transition + + + + + + + + + + + + + + + \ No newline at end of file