修复了其他场景的按钮继续工作的bug;修复了监听器和定时器在某些情况下崩溃的bug
This commit is contained in:
		
							parent
							
								
									a7b29bbdf9
								
							
						
					
					
						commit
						07abf5cf96
					
				|  | @ -101,7 +101,7 @@ | ||||||
|       <Optimization>Disabled</Optimization> |       <Optimization>Disabled</Optimization> | ||||||
|       <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> |       <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||||||
|       <SDLCheck>true</SDLCheck> |       <SDLCheck>true</SDLCheck> | ||||||
|       <DebugInformationFormat>None</DebugInformationFormat> |       <DebugInformationFormat>EditAndContinue</DebugInformationFormat> | ||||||
|       <MinimalRebuild>false</MinimalRebuild> |       <MinimalRebuild>false</MinimalRebuild> | ||||||
|     </ClCompile> |     </ClCompile> | ||||||
|     <Link> |     <Link> | ||||||
|  |  | ||||||
|  | @ -1,4 +1,5 @@ | ||||||
| #include "..\elisteners.h" | #include "..\elisteners.h" | ||||||
|  | #include "..\enodes.h" | ||||||
| 
 | 
 | ||||||
| e2d::EListener::EListener() | e2d::EListener::EListener() | ||||||
| 	: m_bRunning(false) | 	: m_bRunning(false) | ||||||
|  | @ -53,3 +54,16 @@ void e2d::EListener::setAlwaysWorking(bool bAlways) | ||||||
| { | { | ||||||
| 	m_bAlways = bAlways; | 	m_bAlways = bAlways; | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | bool e2d::EListener::_isReady() const | ||||||
|  | { | ||||||
|  | 	if (m_bRunning && m_pParentNode) | ||||||
|  | 	{ | ||||||
|  | 		if (m_pParentNode->getParentScene() == EApp::getCurrentScene()) | ||||||
|  | 		{ | ||||||
|  | 			if (!EApp::isPaused() || m_bAlways) | ||||||
|  | 				return true; | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 	return false; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | @ -24,21 +24,13 @@ void e2d::EMsgManager::MouseProc(UINT message, WPARAM wParam, LPARAM lParam) | ||||||
| 
 | 
 | ||||||
| 	do | 	do | ||||||
| 	{ | 	{ | ||||||
| 		auto &mlistener = s_vMouseListeners[--i]; | 		auto mlistener = s_vMouseListeners[--i]; | ||||||
| 
 | 
 | ||||||
| 		if (EApp::isPaused() && !mlistener->m_bAlways) | 		if (mlistener->_isReady()) | ||||||
| 			continue; |  | ||||||
| 
 |  | ||||||
| 		if (mlistener->m_bAlways || mlistener->isRunning()) |  | ||||||
| 		{ | 		{ | ||||||
| 			if (mlistener->getParentNode() &&  | 			mlistener->_callOn(); | ||||||
| 				mlistener->getParentNode()->getParentScene() == EApp::getCurrentScene()) | 			if (mlistener->m_bSwallow) | ||||||
| 			{ | 				break; | ||||||
| 				mlistener->_callOn(); |  | ||||||
| 
 |  | ||||||
| 				if (mlistener->m_bSwallow) |  | ||||||
| 					break; |  | ||||||
| 			} |  | ||||||
| 		} | 		} | ||||||
| 	} while (i != 0); | 	} while (i != 0); | ||||||
| } | } | ||||||
|  | @ -57,21 +49,13 @@ void e2d::EMsgManager::KeyboardProc(UINT message, WPARAM wParam, LPARAM lParam) | ||||||
| 
 | 
 | ||||||
| 	do | 	do | ||||||
| 	{ | 	{ | ||||||
| 		auto &klistener = s_vKeyboardListeners[--i]; | 		auto klistener = s_vKeyboardListeners[--i]; | ||||||
| 
 | 
 | ||||||
| 		if (EApp::isPaused() && !klistener->m_bAlways) | 		if (klistener->_isReady()) | ||||||
| 			continue; |  | ||||||
| 
 |  | ||||||
| 		if (klistener->m_bAlways || klistener->isRunning()) |  | ||||||
| 		{ | 		{ | ||||||
| 			if (klistener->getParentNode() &&  | 			klistener->_callOn(); | ||||||
| 				klistener->getParentNode()->getParentScene() == EApp::getCurrentScene()) | 			if (klistener->m_bSwallow) | ||||||
| 			{ | 				break; | ||||||
| 				klistener->_callOn(); |  | ||||||
| 
 |  | ||||||
| 				if (klistener->m_bSwallow) |  | ||||||
| 					break; |  | ||||||
| 			} |  | ||||||
| 		} | 		} | ||||||
| 	} while (i != 0); | 	} while (i != 0); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -48,19 +48,19 @@ void e2d::EPhysicsManager::PhysicsGeometryProc(EGeometry * pActiveGeometry) | ||||||
| void e2d::EPhysicsManager::PhysicsListenerProc() | void e2d::EPhysicsManager::PhysicsListenerProc() | ||||||
| { | { | ||||||
| 	// 执行鼠标消息监听函数
 | 	// 执行鼠标消息监听函数
 | ||||||
| 	for (size_t i = 0; i < s_vListeners.size(); i++) | 	EVector<EListenerPhysics*>::size_type i = s_vListeners.size(); | ||||||
| 	{ |  | ||||||
| 		auto &listener = s_vListeners[i]; |  | ||||||
| 
 | 
 | ||||||
| 		if (listener->isRunning()) | 	do | ||||||
|  | 	{ | ||||||
|  | 		auto listener = s_vListeners[--i]; | ||||||
|  | 
 | ||||||
|  | 		if (listener->_isReady()) | ||||||
| 		{ | 		{ | ||||||
| 			if (listener->getParentNode() && | 			listener->_callOn(); | ||||||
| 				listener->getParentNode()->getParentScene() == EApp::getCurrentScene()) | 			if (listener->m_bSwallow) | ||||||
| 			{ | 				break; | ||||||
| 				listener->_callOn(); |  | ||||||
| 			} |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} while (i != 0); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void e2d::EPhysicsManager::bindListener(EListenerPhysics * listener, EScene * pParentScene) | void e2d::EPhysicsManager::bindListener(EListenerPhysics * listener, EScene * pParentScene) | ||||||
|  |  | ||||||
|  | @ -8,22 +8,15 @@ static e2d::EVector<e2d::ETimer*> s_vTimers; | ||||||
| 
 | 
 | ||||||
| void e2d::ETimerManager::TimerProc() | void e2d::ETimerManager::TimerProc() | ||||||
| { | { | ||||||
| 	if (EApp::isPaused()) | 	if (s_vTimers.empty() || EApp::isPaused()) | ||||||
| 		return; | 		return; | ||||||
| 
 | 
 | ||||||
| 	for (size_t i = 0; i < s_vTimers.size(); i++) | 	for (size_t i = 0; i < s_vTimers.size(); i++) | ||||||
| 	{ | 	{ | ||||||
| 		auto &t = s_vTimers[i]; | 		auto &t = s_vTimers[i]; | ||||||
| 		if (t->isRunning()) | 		if (t->_isReady()) | ||||||
| 		{ | 		{ | ||||||
| 			if (t->getParentNode() &&  | 			t->_callOn(); | ||||||
| 				t->getParentNode()->getParentScene() == EApp::getCurrentScene()) |  | ||||||
| 			{ |  | ||||||
| 				if (t->_isReady()) |  | ||||||
| 				{ |  | ||||||
| 					t->_callOn(); |  | ||||||
| 				} |  | ||||||
| 			} |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,4 +1,5 @@ | ||||||
| #include "..\etools.h" | #include "..\etools.h" | ||||||
|  | #include "..\enodes.h" | ||||||
| #include "..\emanagers.h" | #include "..\emanagers.h" | ||||||
| #include "..\Win\winbase.h" | #include "..\Win\winbase.h" | ||||||
| 
 | 
 | ||||||
|  | @ -105,16 +106,21 @@ void e2d::ETimer::_callOn() | ||||||
| 
 | 
 | ||||||
| bool e2d::ETimer::_isReady() | bool e2d::ETimer::_isReady() | ||||||
| { | { | ||||||
| 	if (m_bAtOnce && m_nRunTimes == 0) | 	if (m_bRunning &&  | ||||||
| 		return true; | 		m_pParentNode && | ||||||
| 
 | 		m_pParentNode->getParentScene() == EApp::getCurrentScene()) | ||||||
| 	if (m_nInterval == 0) |  | ||||||
| 		return true; |  | ||||||
| 
 |  | ||||||
| 	if (GetInterval(m_tLast) >= m_nInterval) |  | ||||||
| 	{ | 	{ | ||||||
| 		m_tLast += milliseconds(m_nInterval); | 		if (m_bAtOnce && m_nRunTimes == 0) | ||||||
| 		return true; | 			return true; | ||||||
|  | 
 | ||||||
|  | 		if (m_nInterval == 0) | ||||||
|  | 			return true; | ||||||
|  | 
 | ||||||
|  | 		if (GetInterval(m_tLast) >= m_nInterval) | ||||||
|  | 		{ | ||||||
|  | 			m_tLast += milliseconds(m_nInterval); | ||||||
|  | 			return true; | ||||||
|  | 		} | ||||||
| 	} | 	} | ||||||
| 	return false; | 	return false; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -66,6 +66,9 @@ protected: | ||||||
| 	// 执行监听器回调函数
 | 	// 执行监听器回调函数
 | ||||||
| 	virtual void _callOn() = 0; | 	virtual void _callOn() = 0; | ||||||
| 
 | 
 | ||||||
|  | 	// 获取监听器状态是否就绪
 | ||||||
|  | 	virtual bool _isReady() const; | ||||||
|  | 
 | ||||||
| protected: | protected: | ||||||
| 	EString		m_sName; | 	EString		m_sName; | ||||||
| 	bool		m_bRunning; | 	bool		m_bRunning; | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue