branch jumping
This commit is contained in:
parent
fa2c4455f1
commit
3e8595f52c
|
@ -14,13 +14,13 @@
|
||||||
#include <GameServerAPI.h>
|
#include <GameServerAPI.h>
|
||||||
|
|
||||||
#include "../WindowManager/WindowShell.h"
|
#include "../WindowManager/WindowShell.h"
|
||||||
#include "Win32\Win32Input.h"
|
|
||||||
#include "WinTimer.h"
|
#include "WinTimer.h"
|
||||||
#include "vld.h"
|
#include "vld.h"
|
||||||
|
|
||||||
#include "EventHandler/EventHandler.h"
|
#include "EventHandler/EventHandler.h"
|
||||||
|
|
||||||
#include "GameClientState\SharedStateContent.h"
|
#include "GameClientState/SharedStateContent.h"
|
||||||
|
#include "Win32/Win32ApplicationKeyboard.h"
|
||||||
|
|
||||||
using namespace ::Oyster;
|
using namespace ::Oyster;
|
||||||
using namespace ::Oyster::Event;
|
using namespace ::Oyster::Event;
|
||||||
|
@ -38,13 +38,13 @@ namespace DanBias
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WindowShell* window;
|
WindowShell* window;
|
||||||
InputClass inputObj;
|
|
||||||
Utility::WinTimer timer;
|
Utility::WinTimer timer;
|
||||||
|
|
||||||
UniquePointer<Client::GameClientState> state;
|
UniquePointer<Client::GameClientState> state;
|
||||||
SharedStateContent sharedStateContent;
|
|
||||||
NetworkClient networkClient;
|
NetworkClient networkClient;
|
||||||
|
|
||||||
|
SharedStateContent sharedStateContent;
|
||||||
|
::Input::Win32ApplicationKeyboard *keyboardDevice_application;
|
||||||
|
|
||||||
bool serverOwner;
|
bool serverOwner;
|
||||||
float capFrame;
|
float capFrame;
|
||||||
|
@ -61,7 +61,7 @@ namespace DanBias
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// Interface API functions
|
// Interface API functions
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
DanBiasClientReturn DanBiasGame::Initiate(DanBiasGameDesc& desc)
|
DanBiasClientReturn DanBiasGame::Initiate( DanBiasGameDesc& desc )
|
||||||
{
|
{
|
||||||
WindowShell::CreateConsoleWindow();
|
WindowShell::CreateConsoleWindow();
|
||||||
//if(! data.window->CreateWin(WindowShell::WINDOW_INIT_DESC(L"Window", cPOINT(1600, 900), cPOINT())))
|
//if(! data.window->CreateWin(WindowShell::WINDOW_INIT_DESC(L"Window", cPOINT(1600, 900), cPOINT())))
|
||||||
|
@ -77,7 +77,7 @@ namespace DanBias
|
||||||
if( FAILED( InitDirect3D() ) )
|
if( FAILED( InitDirect3D() ) )
|
||||||
return DanBiasClientReturn_Error;
|
return DanBiasClientReturn_Error;
|
||||||
|
|
||||||
if( FAILED( InitInput() ) )
|
if( FAILED( InitInput(&desc.hinst) ) )
|
||||||
return DanBiasClientReturn_Error;
|
return DanBiasClientReturn_Error;
|
||||||
|
|
||||||
data.serverOwner = false;
|
data.serverOwner = false;
|
||||||
|
@ -85,7 +85,6 @@ namespace DanBias
|
||||||
data.networkClient.SetMessagePump( ClientEventFunction );
|
data.networkClient.SetMessagePump( ClientEventFunction );
|
||||||
|
|
||||||
data.sharedStateContent.network = &data.networkClient;
|
data.sharedStateContent.network = &data.networkClient;
|
||||||
data.sharedStateContent.input = &data.inputObj;
|
|
||||||
|
|
||||||
// Start in main menu state
|
// Start in main menu state
|
||||||
data.state = new Client::MainState();
|
data.state = new Client::MainState();
|
||||||
|
@ -155,35 +154,50 @@ namespace DanBias
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// Init the input
|
// Init the input
|
||||||
//-------------------------------------------------------------------------------------
|
//-------------------------------------------------------------------------------------
|
||||||
HRESULT DanBiasGame::InitInput()
|
HRESULT DanBiasGame::InitInput( HINSTANCE *handle )
|
||||||
{
|
{
|
||||||
if(!data.inputObj.Initialize(data.window->GetHINSTANCE(), data.window->GetHWND(), data.window->GetHeight(), data.window->GetWidth()))
|
data.sharedStateContent.mouseDevice = (Input::Mouse*)::Input::InputManager::Instance()->CreateDevice( Input::Enum::SAIType_Mouse, handle );
|
||||||
|
if( !data.sharedStateContent.mouseDevice )
|
||||||
{
|
{
|
||||||
MessageBox(0, L"Could not initialize the input object.", L"Error", MB_OK);
|
data.sharedStateContent.mouseDevice = nullptr;
|
||||||
|
|
||||||
|
MessageBox( 0, L"Could not initialize the mouseDevice.", L"Error", MB_OK );
|
||||||
return E_FAIL;
|
return E_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.sharedStateContent.keyboardDevice_raw = (Input::Keyboard*)::Input::InputManager::Instance()->CreateDevice( Input::Enum::SAIType_Keyboard, handle );
|
||||||
|
if( !data.sharedStateContent.keyboardDevice_raw )
|
||||||
|
{
|
||||||
|
delete data.sharedStateContent.mouseDevice;
|
||||||
|
data.sharedStateContent.mouseDevice = nullptr;
|
||||||
|
data.sharedStateContent.keyboardDevice_raw = nullptr;
|
||||||
|
|
||||||
|
MessageBox( 0, L"Could not initialize the raw keyboard device.", L"Error", MB_OK );
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
data.keyboardDevice_application = (Input::Win32ApplicationKeyboard*)::Input::InputManager::Instance()->CreateDevice( Input::Enum::SAIType_ApplicationKeyboard, handle );
|
||||||
|
data.sharedStateContent.keyboardDevice_application = data.keyboardDevice_application;
|
||||||
|
if( !data.sharedStateContent.keyboardDevice_application )
|
||||||
|
{
|
||||||
|
delete data.sharedStateContent.mouseDevice;
|
||||||
|
data.sharedStateContent.mouseDevice = nullptr;
|
||||||
|
|
||||||
|
delete data.sharedStateContent.keyboardDevice_raw;
|
||||||
|
data.sharedStateContent.keyboardDevice_raw = nullptr;
|
||||||
|
|
||||||
|
data.sharedStateContent.keyboardDevice_application = data.keyboardDevice_application = nullptr;
|
||||||
|
|
||||||
|
MessageBox( 0, L"Could not initialize the application keyboard device.", L"Error", MB_OK );
|
||||||
|
return E_FAIL;
|
||||||
|
}
|
||||||
|
|
||||||
|
data.keyboardDevice_application->Disable();
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
DanBiasGame::Result DanBiasGame::Update(float deltaTime)
|
DanBiasGame::Result DanBiasGame::Update(float deltaTime)
|
||||||
{
|
{
|
||||||
{ // updating mouse input
|
|
||||||
// TODO: Is obosolete when Dennis's input system is wired in
|
|
||||||
POINT mousePos;
|
|
||||||
GetCursorPos( &mousePos );
|
|
||||||
|
|
||||||
RECT windowVertex;
|
|
||||||
GetWindowRect( data.window->GetHWND(), &windowVertex );
|
|
||||||
|
|
||||||
float mouseNormalisedX = (float)(mousePos.x - windowVertex.left);
|
|
||||||
mouseNormalisedX /= (float)(windowVertex.right - windowVertex.left);
|
|
||||||
|
|
||||||
float mouseNormalisedY = (float)(mousePos.y - windowVertex.top);
|
|
||||||
mouseNormalisedY /= (float)(windowVertex.bottom - windowVertex.top);
|
|
||||||
|
|
||||||
data.inputObj.Update( mouseNormalisedX, mouseNormalisedY );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( data.serverOwner )
|
if( data.serverOwner )
|
||||||
{
|
{
|
||||||
DanBias::GameServerAPI::ServerUpdate();
|
DanBias::GameServerAPI::ServerUpdate();
|
||||||
|
@ -253,6 +267,11 @@ namespace DanBias
|
||||||
data.networkClient.Disconnect();
|
data.networkClient.Disconnect();
|
||||||
|
|
||||||
data.state = nullptr;
|
data.state = nullptr;
|
||||||
|
delete data.sharedStateContent.network;
|
||||||
|
delete data.sharedStateContent.mouseDevice;
|
||||||
|
delete data.sharedStateContent.keyboardDevice_raw;
|
||||||
|
delete data.sharedStateContent.keyboardDevice_application;
|
||||||
|
|
||||||
EventHandler::Instance().Clean();
|
EventHandler::Instance().Clean();
|
||||||
Graphics::API::Clean();
|
Graphics::API::Clean();
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,9 @@ struct GameState::MyData
|
||||||
MyData(){}
|
MyData(){}
|
||||||
GameClientState::ClientState nextState;
|
GameClientState::ClientState nextState;
|
||||||
NetworkClient *nwClient;
|
NetworkClient *nwClient;
|
||||||
InputClass *input;
|
::Input::Mouse *mouseInput;
|
||||||
|
::Input::Keyboard *keyboardInput_raw;
|
||||||
|
::Input::ApplicationKeyboard *keyboardInput_app;
|
||||||
|
|
||||||
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_StaticObj>> *staticObjects;
|
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_StaticObj>> *staticObjects;
|
||||||
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_DynamicObj>> *dynamicObjects;
|
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_DynamicObj>> *dynamicObjects;
|
||||||
|
@ -80,11 +82,15 @@ bool GameState::Init( SharedStateContent &shared )
|
||||||
|
|
||||||
this->privData->nextState = GameClientState::ClientState_Same;
|
this->privData->nextState = GameClientState::ClientState_Same;
|
||||||
this->privData->nwClient = shared.network;
|
this->privData->nwClient = shared.network;
|
||||||
this->privData->input = shared.input;
|
this->privData->mouseInput = shared.mouseDevice;
|
||||||
|
this->privData->keyboardInput_raw = shared.keyboardDevice_raw;
|
||||||
|
this->privData->keyboardInput_app = shared.keyboardDevice_application;
|
||||||
this->privData->staticObjects = &shared.staticObjects;
|
this->privData->staticObjects = &shared.staticObjects;
|
||||||
this->privData->dynamicObjects = &shared.dynamicObjects;
|
this->privData->dynamicObjects = &shared.dynamicObjects;
|
||||||
this->privData->lights = &shared.lights;
|
this->privData->lights = &shared.lights;
|
||||||
|
|
||||||
|
this->privData->keyboardInput_app->Deactivate();
|
||||||
|
|
||||||
Graphics::API::Option gfxOp = Graphics::API::GetOption();
|
Graphics::API::Option gfxOp = Graphics::API::GetOption();
|
||||||
Float aspectRatio = gfxOp.Resolution.x / gfxOp.Resolution.y;
|
Float aspectRatio = gfxOp.Resolution.x / gfxOp.Resolution.y;
|
||||||
this->privData->camera.SetPerspectiveProjection( Utility::Value::Radian(90.0f), aspectRatio, 0.1f, 1000.0f );
|
this->privData->camera.SetPerspectiveProjection( Utility::Value::Radian(90.0f), aspectRatio, 0.1f, 1000.0f );
|
||||||
|
@ -285,29 +291,19 @@ void GameState::ChangeState( ClientState next )
|
||||||
|
|
||||||
void GameState::ReadKeyInput()
|
void GameState::ReadKeyInput()
|
||||||
{
|
{
|
||||||
if( this->privData->input->IsKeyPressed(DIK_W) )
|
if( this->privData->keyboardInput_raw->IsKeyDown(::Input::Enum::SAKI_W) )
|
||||||
{
|
|
||||||
//if(!this->privData->key_forward)
|
|
||||||
{
|
{
|
||||||
this->privData->nwClient->Send( Protocol_PlayerMovementForward() );
|
this->privData->nwClient->Send( Protocol_PlayerMovementForward() );
|
||||||
this->privData->key_forward = true;
|
this->privData->key_forward = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
this->privData->key_forward = false;
|
|
||||||
|
|
||||||
if( this->privData->input->IsKeyPressed(DIK_S) )
|
if( this->privData->keyboardInput_raw->IsKeyDown(::Input::Enum::SAKI_S) )
|
||||||
{
|
|
||||||
//if( !this->privData->key_backward )
|
|
||||||
{
|
{
|
||||||
this->privData->nwClient->Send( Protocol_PlayerMovementBackward() );
|
this->privData->nwClient->Send( Protocol_PlayerMovementBackward() );
|
||||||
this->privData->key_backward = true;
|
this->privData->key_backward = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
this->privData->key_backward = false;
|
|
||||||
|
|
||||||
if( this->privData->input->IsKeyPressed(DIK_A) )
|
if( this->privData->mouseInput->IsKeyPressed(DIK_A) )
|
||||||
{
|
{
|
||||||
//if( !this->privData->key_strafeLeft )
|
//if( !this->privData->key_strafeLeft )
|
||||||
{
|
{
|
||||||
|
@ -318,7 +314,7 @@ void GameState::ReadKeyInput()
|
||||||
else
|
else
|
||||||
this->privData->key_strafeLeft = false;
|
this->privData->key_strafeLeft = false;
|
||||||
|
|
||||||
if( this->privData->input->IsKeyPressed(DIK_D) )
|
if( this->privData->mouseInput->IsKeyPressed(DIK_D) )
|
||||||
{
|
{
|
||||||
//if( !this->privData->key_strafeRight )
|
//if( !this->privData->key_strafeRight )
|
||||||
{
|
{
|
||||||
|
@ -332,8 +328,8 @@ void GameState::ReadKeyInput()
|
||||||
//send delta mouse movement
|
//send delta mouse movement
|
||||||
{
|
{
|
||||||
static const float mouseSensitivity = Radian( 1.0f );
|
static const float mouseSensitivity = Radian( 1.0f );
|
||||||
this->privData->camera.PitchDown( this->privData->input->GetPitch() * mouseSensitivity );
|
this->privData->camera.PitchDown( this->privData->mouseInput->GetPitch() * mouseSensitivity );
|
||||||
float yaw = this->privData->input->GetYaw();
|
float yaw = this->privData->mouseInput->GetYaw();
|
||||||
//if( yaw != 0.0f ) //This made the camera reset to a specific rotation.
|
//if( yaw != 0.0f ) //This made the camera reset to a specific rotation.
|
||||||
{
|
{
|
||||||
this->privData->nwClient->Send( Protocol_PlayerLeftTurn(yaw * mouseSensitivity) );
|
this->privData->nwClient->Send( Protocol_PlayerLeftTurn(yaw * mouseSensitivity) );
|
||||||
|
@ -341,7 +337,7 @@ void GameState::ReadKeyInput()
|
||||||
}
|
}
|
||||||
|
|
||||||
// shoot
|
// shoot
|
||||||
if( this->privData->input->IsKeyPressed(DIK_Z) )
|
if( this->privData->mouseInput->IsKeyPressed(DIK_Z) )
|
||||||
{
|
{
|
||||||
if( !this->privData->key_Shoot )
|
if( !this->privData->key_Shoot )
|
||||||
{
|
{
|
||||||
|
@ -355,7 +351,7 @@ void GameState::ReadKeyInput()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
this->privData->key_Shoot = false;
|
this->privData->key_Shoot = false;
|
||||||
if( this->privData->input->IsKeyPressed(DIK_X) )
|
if( this->privData->mouseInput->IsKeyPressed(DIK_X) )
|
||||||
{
|
{
|
||||||
if( !this->privData->key_Shoot )
|
if( !this->privData->key_Shoot )
|
||||||
{
|
{
|
||||||
|
@ -369,7 +365,7 @@ void GameState::ReadKeyInput()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
this->privData->key_Shoot = false;
|
this->privData->key_Shoot = false;
|
||||||
if( this->privData->input->IsKeyPressed(DIK_C) )
|
if( this->privData->mouseInput->IsKeyPressed(DIK_C) )
|
||||||
{
|
{
|
||||||
if( !this->privData->key_Shoot )
|
if( !this->privData->key_Shoot )
|
||||||
{
|
{
|
||||||
|
@ -385,7 +381,7 @@ void GameState::ReadKeyInput()
|
||||||
this->privData->key_Shoot = false;
|
this->privData->key_Shoot = false;
|
||||||
|
|
||||||
// jump
|
// jump
|
||||||
if( this->privData->input->IsKeyPressed(DIK_SPACE) )
|
if( this->privData->mouseInput->IsKeyPressed(DIK_SPACE) )
|
||||||
{
|
{
|
||||||
if(!this->privData->key_Jump)
|
if(!this->privData->key_Jump)
|
||||||
{
|
{
|
||||||
|
@ -400,7 +396,7 @@ void GameState::ReadKeyInput()
|
||||||
// DEGUG KEYS
|
// DEGUG KEYS
|
||||||
|
|
||||||
// Reload shaders
|
// Reload shaders
|
||||||
if( this->privData->input->IsKeyPressed(DIK_R) )
|
if( this->privData->mouseInput->IsKeyPressed(DIK_R) )
|
||||||
{
|
{
|
||||||
if( !this->privData->key_Reload_Shaders )
|
if( !this->privData->key_Reload_Shaders )
|
||||||
{
|
{
|
||||||
|
@ -414,7 +410,7 @@ void GameState::ReadKeyInput()
|
||||||
this->privData->key_Reload_Shaders = false;
|
this->privData->key_Reload_Shaders = false;
|
||||||
|
|
||||||
// toggle wire frame render
|
// toggle wire frame render
|
||||||
if( this->privData->input->IsKeyPressed(DIK_T) )
|
if( this->privData->mouseInput->IsKeyPressed(DIK_T) )
|
||||||
{
|
{
|
||||||
if( !this->privData->key_Wireframe_Toggle )
|
if( !this->privData->key_Wireframe_Toggle )
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,7 +28,8 @@ struct LanMenuState::MyData
|
||||||
|
|
||||||
GameClientState::ClientState nextState;
|
GameClientState::ClientState nextState;
|
||||||
NetworkClient *nwClient;
|
NetworkClient *nwClient;
|
||||||
InputClass *input;
|
::Input::Mouse *mouseInput;
|
||||||
|
::Input::ApplicationKeyboard *keyboardInput;
|
||||||
Graphics::API::Texture background;
|
Graphics::API::Texture background;
|
||||||
EventButtonCollection guiElements;
|
EventButtonCollection guiElements;
|
||||||
|
|
||||||
|
@ -53,7 +54,9 @@ bool LanMenuState::Init( SharedStateContent &shared )
|
||||||
|
|
||||||
this->privData->nextState = GameClientState::ClientState_Same;
|
this->privData->nextState = GameClientState::ClientState_Same;
|
||||||
this->privData->nwClient = shared.network;
|
this->privData->nwClient = shared.network;
|
||||||
this->privData->input = shared.input;
|
this->privData->mouseInput = shared.mouseDevice;
|
||||||
|
this->privData->keyboardInput = shared.keyboardDevice_application;
|
||||||
|
this->privData->keyboardInput->Activate();
|
||||||
|
|
||||||
this->privData->background = Graphics::API::CreateTexture( L"color_white.png" );
|
this->privData->background = Graphics::API::CreateTexture( L"color_white.png" );
|
||||||
|
|
||||||
|
@ -80,6 +83,9 @@ bool LanMenuState::Init( SharedStateContent &shared )
|
||||||
|
|
||||||
this->privData->connectPort = 15151;
|
this->privData->connectPort = 15151;
|
||||||
|
|
||||||
|
this->privData->keyboardInput->BindTextTarget( &(*this->privData->connectIP)[0] );
|
||||||
|
this->privData->keyboardInput->Activate();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,10 +93,13 @@ GameClientState::ClientState LanMenuState::Update( float deltaTime )
|
||||||
{
|
{
|
||||||
MouseInput mouseState;
|
MouseInput mouseState;
|
||||||
{
|
{
|
||||||
this->privData->input->GetMousePos( mouseState.x, mouseState.y );
|
::Input::Struct::SAIPoint2D pos;
|
||||||
mouseState.mouseButtonPressed = this->privData->input->IsMousePressed();
|
this->privData->mouseInput->GetPixelPosition( pos );
|
||||||
}
|
|
||||||
|
|
||||||
|
mouseState.x = pos.x;
|
||||||
|
mouseState.y = pos.y;
|
||||||
|
mouseState.mouseButtonPressed = this->privData->mouseInput->IsBtnDown( ::Input::Enum::SAMI_MouseLeftBtn );
|
||||||
|
}
|
||||||
EventHandler::Instance().Update( mouseState );
|
EventHandler::Instance().Update( mouseState );
|
||||||
|
|
||||||
return this->privData->nextState;
|
return this->privData->nextState;
|
||||||
|
|
|
@ -22,7 +22,7 @@ struct LobbyAdminState::MyData
|
||||||
|
|
||||||
GameClientState::ClientState nextState;
|
GameClientState::ClientState nextState;
|
||||||
NetworkClient *nwClient;
|
NetworkClient *nwClient;
|
||||||
InputClass *input;
|
::Input::Mouse *mouseInput;
|
||||||
Graphics::API::Texture background;
|
Graphics::API::Texture background;
|
||||||
EventButtonCollection guiElements;
|
EventButtonCollection guiElements;
|
||||||
} privData;
|
} privData;
|
||||||
|
@ -43,7 +43,7 @@ bool LobbyAdminState::Init( SharedStateContent &shared )
|
||||||
|
|
||||||
this->privData->nextState = GameClientState::ClientState_Same;
|
this->privData->nextState = GameClientState::ClientState_Same;
|
||||||
this->privData->nwClient = shared.network;
|
this->privData->nwClient = shared.network;
|
||||||
this->privData->input = shared.input;
|
this->privData->mouseInput = shared.mouseDevice;
|
||||||
|
|
||||||
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
|
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
|
||||||
|
|
||||||
|
@ -61,21 +61,15 @@ bool LobbyAdminState::Init( SharedStateContent &shared )
|
||||||
|
|
||||||
GameClientState::ClientState LobbyAdminState::Update( float deltaTime )
|
GameClientState::ClientState LobbyAdminState::Update( float deltaTime )
|
||||||
{
|
{
|
||||||
// Wishlist:
|
|
||||||
// picking
|
|
||||||
// mouse events
|
|
||||||
// different menus
|
|
||||||
// play sounds
|
|
||||||
// update animation
|
|
||||||
// send data to server
|
|
||||||
// check data from server
|
|
||||||
|
|
||||||
MouseInput mouseState;
|
MouseInput mouseState;
|
||||||
{
|
{
|
||||||
this->privData->input->GetMousePos( mouseState.x, mouseState.y );
|
::Input::Struct::SAIPoint2D pos;
|
||||||
mouseState.mouseButtonPressed = this->privData->input->IsMousePressed();
|
this->privData->mouseInput->GetPixelPosition( pos );
|
||||||
}
|
|
||||||
|
|
||||||
|
mouseState.x = pos.x;
|
||||||
|
mouseState.y = pos.y;
|
||||||
|
mouseState.mouseButtonPressed = this->privData->mouseInput->IsBtnDown( ::Input::Enum::SAMI_MouseLeftBtn );
|
||||||
|
}
|
||||||
EventHandler::Instance().Update( mouseState );
|
EventHandler::Instance().Update( mouseState );
|
||||||
|
|
||||||
return this->privData->nextState;
|
return this->privData->nextState;
|
||||||
|
|
|
@ -22,7 +22,7 @@ struct LobbyState::MyData
|
||||||
|
|
||||||
GameClientState::ClientState nextState;
|
GameClientState::ClientState nextState;
|
||||||
NetworkClient *nwClient;
|
NetworkClient *nwClient;
|
||||||
InputClass *input;
|
::Input::Mouse *mouseInput;
|
||||||
Graphics::API::Texture background;
|
Graphics::API::Texture background;
|
||||||
EventButtonCollection guiElements;
|
EventButtonCollection guiElements;
|
||||||
} privData;
|
} privData;
|
||||||
|
@ -43,7 +43,7 @@ bool LobbyState::Init( SharedStateContent &shared )
|
||||||
|
|
||||||
this->privData->nextState = GameClientState::ClientState_Same;
|
this->privData->nextState = GameClientState::ClientState_Same;
|
||||||
this->privData->nwClient = shared.network;
|
this->privData->nwClient = shared.network;
|
||||||
this->privData->input = shared.input;
|
this->privData->mouseInput = shared.mouseDevice;
|
||||||
|
|
||||||
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
|
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
|
||||||
|
|
||||||
|
@ -61,21 +61,15 @@ bool LobbyState::Init( SharedStateContent &shared )
|
||||||
|
|
||||||
GameClientState::ClientState LobbyState::Update( float deltaTime )
|
GameClientState::ClientState LobbyState::Update( float deltaTime )
|
||||||
{
|
{
|
||||||
// Wishlist:
|
|
||||||
// picking
|
|
||||||
// mouse events
|
|
||||||
// different menus
|
|
||||||
// play sounds
|
|
||||||
// update animation
|
|
||||||
// send data to server
|
|
||||||
// check data from server
|
|
||||||
|
|
||||||
MouseInput mouseState;
|
MouseInput mouseState;
|
||||||
{
|
{
|
||||||
this->privData->input->GetMousePos( mouseState.x, mouseState.y );
|
::Input::Struct::SAIPoint2D pos;
|
||||||
mouseState.mouseButtonPressed = this->privData->input->IsMousePressed();
|
this->privData->mouseInput->GetPixelPosition( pos );
|
||||||
}
|
|
||||||
|
|
||||||
|
mouseState.x = pos.x;
|
||||||
|
mouseState.y = pos.y;
|
||||||
|
mouseState.mouseButtonPressed = this->privData->mouseInput->IsBtnDown( ::Input::Enum::SAMI_MouseLeftBtn );
|
||||||
|
}
|
||||||
EventHandler::Instance().Update( mouseState );
|
EventHandler::Instance().Update( mouseState );
|
||||||
|
|
||||||
return this->privData->nextState;
|
return this->privData->nextState;
|
||||||
|
|
|
@ -24,7 +24,7 @@ struct MainState::MyData
|
||||||
|
|
||||||
GameClientState::ClientState nextState;
|
GameClientState::ClientState nextState;
|
||||||
NetworkClient *nwClient;
|
NetworkClient *nwClient;
|
||||||
InputClass *input;
|
::Input::Mouse *mouseInput;
|
||||||
Graphics::API::Texture background;
|
Graphics::API::Texture background;
|
||||||
EventButtonCollection guiElements;
|
EventButtonCollection guiElements;
|
||||||
};
|
};
|
||||||
|
@ -47,7 +47,7 @@ bool MainState::Init( SharedStateContent &shared )
|
||||||
|
|
||||||
this->privData->nextState = GameClientState::ClientState_Same;
|
this->privData->nextState = GameClientState::ClientState_Same;
|
||||||
this->privData->nwClient = shared.network;
|
this->privData->nwClient = shared.network;
|
||||||
this->privData->input = shared.input;
|
this->privData->mouseInput = shared.mouseDevice;
|
||||||
|
|
||||||
this->privData->background = Graphics::API::CreateTexture( L"color_white.png" );
|
this->privData->background = Graphics::API::CreateTexture( L"color_white.png" );
|
||||||
|
|
||||||
|
@ -77,16 +77,13 @@ GameClientState::ClientState MainState::Update( float deltaTime )
|
||||||
{
|
{
|
||||||
MouseInput mouseState;
|
MouseInput mouseState;
|
||||||
{
|
{
|
||||||
bool test = this->privData->input->IsMousePressed();
|
::Input::Struct::SAIPoint2D pos;
|
||||||
if(test)
|
this->privData->mouseInput->GetPixelPosition( pos );
|
||||||
{ // HACK: debug trap still in use?
|
|
||||||
int i = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
this->privData->input->GetMousePos( mouseState.x, mouseState.y );
|
mouseState.x = pos.x;
|
||||||
mouseState.mouseButtonPressed = this->privData->input->IsMousePressed();
|
mouseState.y = pos.y;
|
||||||
|
mouseState.mouseButtonPressed = this->privData->mouseInput->IsBtnDown( ::Input::Enum::SAMI_MouseLeftBtn );
|
||||||
}
|
}
|
||||||
|
|
||||||
EventHandler::Instance().Update( mouseState );
|
EventHandler::Instance().Update( mouseState );
|
||||||
|
|
||||||
return this->privData->nextState;
|
return this->privData->nextState;
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "C_obj\C_DynamicObj.h"
|
#include "C_obj\C_DynamicObj.h"
|
||||||
#include "C_Light.h"
|
#include "C_Light.h"
|
||||||
#include "NetworkClient.h"
|
#include "NetworkClient.h"
|
||||||
#include "L_inputClass.h"
|
#include "Input.h"
|
||||||
|
|
||||||
namespace DanBias { namespace Client
|
namespace DanBias { namespace Client
|
||||||
{
|
{
|
||||||
|
@ -26,7 +26,10 @@ namespace DanBias { namespace Client
|
||||||
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_DynamicObj>> dynamicObjects;
|
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_DynamicObj>> dynamicObjects;
|
||||||
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_Light>> lights;
|
::std::map<int, ::Utility::DynamicMemory::UniquePointer<::DanBias::Client::C_Light>> lights;
|
||||||
::Oyster::Network::NetworkClient *network;
|
::Oyster::Network::NetworkClient *network;
|
||||||
InputClass* input;
|
|
||||||
|
::Input::Mouse *mouseDevice;
|
||||||
|
::Input::Keyboard *keyboardDevice_raw;
|
||||||
|
::Input::ApplicationKeyboard *keyboardDevice_application;
|
||||||
};
|
};
|
||||||
} }
|
} }
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace DanBias
|
||||||
};
|
};
|
||||||
|
|
||||||
static HRESULT InitDirect3D();
|
static HRESULT InitDirect3D();
|
||||||
static HRESULT InitInput();
|
static HRESULT InitInput( HINSTANCE *handle );
|
||||||
|
|
||||||
static Result Update(float deltaTime);
|
static Result Update(float deltaTime);
|
||||||
static HRESULT Render();
|
static HRESULT Render();
|
||||||
|
|
|
@ -12,6 +12,8 @@ namespace Input
|
||||||
class ApplicationKeyboard : public InputObject
|
class ApplicationKeyboard : public InputObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
virtual ~ApplicationKeyboard();
|
||||||
|
|
||||||
bool IsActive() const;
|
bool IsActive() const;
|
||||||
|
|
||||||
void Activate();
|
void Activate();
|
||||||
|
@ -25,7 +27,6 @@ namespace Input
|
||||||
::std::wstring::size_type writePos;
|
::std::wstring::size_type writePos;
|
||||||
|
|
||||||
ApplicationKeyboard();
|
ApplicationKeyboard();
|
||||||
~ApplicationKeyboard();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool active;
|
bool active;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "InputManager.h"
|
#include "InputManager.h"
|
||||||
#include "InputObject.h"
|
#include "InputObject.h"
|
||||||
#include "Keyboard.h"
|
#include "Keyboard.h"
|
||||||
|
#include "ApplicationKeyboard.h"
|
||||||
#include "Mouse.h"
|
#include "Mouse.h"
|
||||||
|
|
||||||
#endif // !INPUT_INPUT_H
|
#endif // !INPUT_INPUT_H
|
||||||
|
|
|
@ -151,6 +151,8 @@ namespace Input
|
||||||
};
|
};
|
||||||
|
|
||||||
public: /* Manual check functions */
|
public: /* Manual check functions */
|
||||||
|
virtual ~Keyboard();
|
||||||
|
|
||||||
virtual bool IsKeyUp (Enum::SAKI key) = 0;
|
virtual bool IsKeyUp (Enum::SAKI key) = 0;
|
||||||
virtual bool IsKeyDown (Enum::SAKI key) = 0;
|
virtual bool IsKeyDown (Enum::SAKI key) = 0;
|
||||||
virtual const wchar_t* GetAsText(Enum::SAKI key) = 0;
|
virtual const wchar_t* GetAsText(Enum::SAKI key) = 0;
|
||||||
|
@ -170,7 +172,6 @@ namespace Input
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Keyboard();
|
Keyboard();
|
||||||
~Keyboard();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
struct KeyboardCallbackList
|
struct KeyboardCallbackList
|
||||||
|
|
|
@ -66,6 +66,8 @@ namespace Input
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual ~Mouse();
|
||||||
|
|
||||||
virtual bool IsBtnUp(Enum::SAMI key) = 0;
|
virtual bool IsBtnUp(Enum::SAMI key) = 0;
|
||||||
virtual bool IsBtnDown(Enum::SAMI key) = 0;
|
virtual bool IsBtnDown(Enum::SAMI key) = 0;
|
||||||
virtual int GetWheelDelta() = 0;
|
virtual int GetWheelDelta() = 0;
|
||||||
|
@ -93,7 +95,6 @@ namespace Input
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Mouse();
|
Mouse();
|
||||||
~Mouse();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
struct MouseCallbackList
|
struct MouseCallbackList
|
||||||
|
|
Loading…
Reference in New Issue