Ejemplo n.º 1
0
//*********************************************************************//
// WindowProc
//	- window message handler
LRESULT CALLBACK WindowProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
	// What is the message?
	switch( msg )
	{
	case WM_CREATE:			// Window constructed
		break;
	
	case WM_CLOSE:	
		// Window closed
		//Game::GetInstance()->Terminate();
		DestroyWindow( hWnd );	// completely destroy the window
		break;

	case WM_DESTROY:		// Window destroyed
		PostQuitMessage( 0 );	// completely quit the application
		break;

	case WM_SYSKEYUP:		// System menu (ALT pop-up)
	case WM_SYSCHAR:
		break;

	case WM_ACTIVATE:		// Window activated / deactivated
		if( LOWORD( wParam ) != WA_INACTIVE )	//	gaining focus (unpause)
		{
			Game * zstrike = Game::GetInstance();
			zstrike->isActive = true;
			//if (zstrike->GetCurrState() == PauseState::GetInstance())
			//	zstrike->RemoveState();
		}
		else									//	losing focus (pause)
		{
			//Game * zstrike = (Game *)GetWindowLongPtr(hWnd, GWLP_USERDATA);
			Game * zstrike = Game::GetInstance();

			if (zstrike->GetCurrState() == GameplayState::GetInstance() 
				|| (zstrike->GetCurrState() == HTPGameState::GetInstance() && HTPGameState::GetInstance()->GetChoiceScreen() == false)
				|| zstrike->GetCurrState() == ShopState::GetInstance())
				zstrike->AddState(PauseState::GetInstance());

			zstrike->isActive = false;

		}
		break;

	case WM_PAINT:			// Window needs repainting
		ValidateRect( hWnd, nullptr );	// ignore painting
		break;

	case WM_MOUSEWHEEL:
		{
			WeaponManager * zstrike = WeaponManager::GetInstance();


			// if owner == nullptr, weapon manager wasn't initialized
			if (zstrike->GetOwner() != nullptr)
			{
				int wheel = GET_WHEEL_DELTA_WPARAM(wParam);
				zstrike->SetMouseWheelRotation(wheel);
			}
		}
		//OnMouseWheel(hWnd, wParam, lParam);
		break;

	
	default:				// Any unhandled messages
		return DefWindowProcW( hWnd, msg, wParam, lParam );	// handled by default proc
	}


	// Message has been handled by this proc.
	return 0;
}