⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userinput.cpp

📁 墨香最新私服
💻 CPP
字号:
// UserInput.cpp: implementation of the CUserInput class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "UserInput.h"
#include "../Gamein.h"
#include "../MHCamera.h"
#include "../Object.h"
#include "../MoveManager.h"
#include "../Monster.h"
#include "../Player.h"
#include "../Npc.h"
#include "../MHNetwork.h"
#include "../ObjectManager.h"
#include "../ItemGround.h"
#include "../Interface\cWindowManager.h"
#include "../Interface\cEditBox.h"
#include "../WindowIDEnum.h"

#include "CameraRotate.inl"
#include "CameraWheelZoom.inl"

#include "MacroManager.h"
#include "MainGame.h"



CUserInput	g_UserInput;
extern HWND g_hWnd;


//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CUserInput::CUserInput()
{
	m_MouseEventThrower.SetDefaultReceiver(&m_HeroMove);
	m_MouseEventThrower.SetReceiverToDefault();
	
	m_bFocus = TRUE;
}

CUserInput::~CUserInput()
{

}


void CUserInput::Init()
{
	HRESULT hr;

	hr = DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, 
								IID_IDirectInput8, (VOID**)&m_pdi, NULL );

	ASSERT(hr==S_OK);

	m_Keyboard.Init( m_pdi );
	m_Mouse.Init();
}


void CUserInput::Release()
{
	SAFE_RELEASE( m_pdi );

	m_Keyboard.Release();
	m_Mouse.Release();
}


void CUserInput::Process()
{
//////////////
//Update Input
	m_Keyboard.UpdateKeyboardState();
	//付快胶绰 winproc俊辑 流立 诀单捞飘

///////////////////
//Key Input Process
	StartGetKeyState();
//	do	//Key Input event啊 绝歹扼档 茄锅篮 角青登具窃.(press锭巩捞瘤?)
//	{
//		GetNextKeyState();
//		MACROMGR->KeyboardInput( &m_Keyboard );
//		WINDOWMGR->KeyboardInput( &m_Keyboard );
//	}
//	while( !m_Keyboard.IsEmptyKeyboardEvent() );

	if( m_bFocus )
	{
		while( GetNextKeyState() )
		{
			MACROMGR->KeyboardInput( &m_Keyboard );
			WINDOWMGR->KeyboardInput( &m_Keyboard );
		}

		MACROMGR->KeyboardPressInput( &m_Keyboard );
	}

/////////////////////
//Mouse Input Process
	do	//mouse event啊 绝歹扼档 茄锅篮 角青登具窃.
	{
		m_Mouse.GetNextMouseEvent();	//器目胶啊 绝绢档 que俊辑 pop篮 登具窍聪..

		if( m_bFocus )
		{
			WINDOWMGR->MouseInput( &m_Mouse );
			//if( !WINDOWMGR->IsMouseInputProcessed() )	//MouseEventThrower.Process()救栏肺 颗辫
			if( MAINGAME->GetCurStateNum() == eGAMESTATE_GAMEIN )
				m_MouseEventThrower.Process( &m_Mouse );
		}

	}
	while( !m_Mouse.IsEmptyMouseEvent() );
	
////////
//Camera
	CameraRotate( &m_Keyboard, &m_Mouse );
	CameraWheelZoom( &m_Keyboard, &m_Mouse );

}


void CUserInput::StartGetKeyState()
{
	m_Keyboard.StartGetKeyState();
}


BOOL CUserInput::GetNextKeyState()
{
	return m_Keyboard.GetNextKeyState();
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -