Added LobbyAdminState + other stuff
This commit is contained in:
parent
d60fd65805
commit
d705e73dc5
|
@ -211,6 +211,7 @@
|
|||
<ClCompile Include="GameClientState\LevelLoader\LevelParser.cpp" />
|
||||
<ClCompile Include="GameClientState\LevelLoader\Loader.cpp" />
|
||||
<ClCompile Include="GameClientState\LevelLoader\ParseFunctions.cpp" />
|
||||
<ClCompile Include="GameClientState\LobbyAdminState.cpp" />
|
||||
<ClCompile Include="GameClientState\LobbyState.cpp" />
|
||||
<ClCompile Include="GameClientState\C_Object.cpp" />
|
||||
<ClCompile Include="GameClientState\MainState.cpp" />
|
||||
|
@ -234,6 +235,7 @@
|
|||
<ClInclude Include="GameClientState\LevelLoader\Loader.h" />
|
||||
<ClInclude Include="GameClientState\LevelLoader\ObjectDefines.h" />
|
||||
<ClInclude Include="GameClientState\LevelLoader\ParseFunctions.h" />
|
||||
<ClInclude Include="GameClientState\LobbyAdminState.h" />
|
||||
<ClInclude Include="GameClientState\MainState.h" />
|
||||
<ClInclude Include="Include\DanBiasGame.h" />
|
||||
<ClInclude Include="GameClientState\LobbyState.h" />
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "GameClientState/GameClientState.h"
|
||||
#include "GameClientState\GameState.h"
|
||||
#include "GameClientState\LobbyState.h"
|
||||
#include "GameClientState\LobbyAdminState.h"
|
||||
#include "GameClientState\MainState.h"
|
||||
#include "GameClientState\LanMenuState.h"
|
||||
#include <Protocols.h>
|
||||
|
@ -169,16 +170,9 @@ namespace DanBias
|
|||
switch (state)
|
||||
{
|
||||
case Client::GameClientState::ClientState_LobbyCreate:
|
||||
{
|
||||
//DanBias::GameServerAPI::ServerInitiate( .. );
|
||||
//DanBias::GameServerAPI::ServerStart();
|
||||
//data.serverOwner = true;
|
||||
//if( data.networkClient.Connect(15151, "127.0.0.1") )
|
||||
//{
|
||||
// data.state = new Client::LobbyState();
|
||||
// stateChanged = true;
|
||||
//}
|
||||
}
|
||||
data.state = new Client::LobbyAdminState();
|
||||
stateChanged = true;
|
||||
break;
|
||||
case Client::GameClientState::ClientState_Lan:
|
||||
data.state = new Client::LanMenuState();
|
||||
stateChanged = true;
|
||||
|
|
|
@ -13,9 +13,10 @@ namespace DanBias { namespace Client
|
|||
enum ClientState
|
||||
{
|
||||
ClientState_Login,
|
||||
ClientState_Lobby,
|
||||
ClientState_Lan,
|
||||
ClientState_Lobby,
|
||||
ClientState_LobbyCreate,
|
||||
ClientState_LobbyReady,
|
||||
ClientState_Game,
|
||||
ClientState_Same,
|
||||
ClientState_Quit
|
||||
|
|
|
@ -15,7 +15,6 @@ struct GameState::MyData
|
|||
MyData(){}
|
||||
GameClientState::ClientState nextState;
|
||||
NetworkClient *nwClient;
|
||||
|
||||
} privData;
|
||||
|
||||
GameState::GameState(void)
|
||||
|
@ -137,14 +136,19 @@ bool GameState::LoadModels(std::string mapFile)
|
|||
{
|
||||
GameLogic::BasicLight* lightData = ((GameLogic::BasicLight*)obj);
|
||||
|
||||
if(lightData->lightType == GameLogic::LightType_PointLight)
|
||||
switch( lightData->lightType )
|
||||
{
|
||||
Oyster::Graphics::Definitions::Pointlight plight;
|
||||
plight.Pos = ((GameLogic::PointLight*)lightData)->position;
|
||||
plight.Color = lightData->diffuseColor;
|
||||
plight.Radius = 100;
|
||||
plight.Bright = 0.9f;
|
||||
Oyster::Graphics::API::AddLight(plight);
|
||||
case GameLogic::LightType_PointLight:
|
||||
{
|
||||
//Oyster::Graphics::Definitions::Pointlight plight;
|
||||
//plight.Pos = ((GameLogic::PointLight*)lightData)->position;
|
||||
//plight.Color = lightData->diffuseColor;
|
||||
//plight.Radius = 100;
|
||||
//plight.Bright = 0.9f;
|
||||
//Oyster::Graphics::API::AddLight(plight);
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,151 @@
|
|||
#include "LobbyAdminState.h"
|
||||
#include "DllInterfaces/GFXAPI.h"
|
||||
#include "OysterMath.h"
|
||||
#include "C_obj/C_Player.h"
|
||||
#include "C_obj/C_StaticObj.h"
|
||||
#include "C_obj/C_DynamicObj.h"
|
||||
#include <GameServerAPI.h>
|
||||
#include <Protocols.h>
|
||||
|
||||
#include "EventHandler\EventHandler.h"
|
||||
#include "Buttons\ButtonRectangle.h"
|
||||
|
||||
using namespace ::DanBias::Client;
|
||||
using namespace ::Oyster;
|
||||
using namespace ::Oyster::Network;
|
||||
using namespace ::Oyster::Event;
|
||||
using namespace ::Oyster::Math3D;
|
||||
|
||||
struct LobbyAdminState::MyData
|
||||
{
|
||||
MyData(){}
|
||||
|
||||
GameClientState::ClientState nextState;
|
||||
NetworkClient *nwClient;
|
||||
Graphics::API::Texture background;
|
||||
EventButtonCollection button;
|
||||
} privData;
|
||||
|
||||
void OnButtonInteract_Ready( Oyster::Event::ButtonEvent<GameClientState*>& e );
|
||||
|
||||
LobbyAdminState::LobbyAdminState(void) {}
|
||||
|
||||
LobbyAdminState::~LobbyAdminState(void)
|
||||
{
|
||||
if( this->privData )
|
||||
this->Release();
|
||||
}
|
||||
|
||||
bool LobbyAdminState::Init(NetworkClient* nwClient)
|
||||
{
|
||||
privData = new MyData();
|
||||
|
||||
this->privData->nextState = GameClientState::ClientState_Same;
|
||||
this->privData->nwClient = nwClient;
|
||||
|
||||
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
|
||||
|
||||
// create buttons
|
||||
ButtonRectangle<GameClientState*> *button;
|
||||
|
||||
button = new ButtonRectangle<GameClientState*>( L"earth_md.png", OnButtonInteract_Ready, this, 0.5f, 0.2f, 0.3f, 0.1f, true );
|
||||
this->privData->button.AddButton( button );
|
||||
|
||||
// bind button collection to the singleton eventhandler
|
||||
EventHandler::Instance().AddCollection( &this->privData->button );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
GameClientState::ClientState LobbyAdminState::Update(float deltaTime, InputClass* KeyInput)
|
||||
{
|
||||
// Wishlist:
|
||||
// picking
|
||||
// mouse events
|
||||
// different menus
|
||||
// play sounds
|
||||
// update animation
|
||||
// send data to server
|
||||
// check data from server
|
||||
|
||||
MouseInput mouseState;
|
||||
{
|
||||
mouseState.x = KeyInput->GetPitch();
|
||||
mouseState.y = KeyInput->GetYaw();
|
||||
mouseState.mouseButtonPressed = KeyInput->IsMousePressed();
|
||||
}
|
||||
|
||||
EventHandler::Instance().Update( mouseState );
|
||||
|
||||
return this->privData->nextState;
|
||||
}
|
||||
bool LobbyAdminState::Render( )
|
||||
{
|
||||
Graphics::API::NewFrame();
|
||||
Graphics::API::StartGuiRender();
|
||||
|
||||
Graphics::API::RenderGuiElement( this->privData->background, Float2(0.5f), Float2(1.0f) );
|
||||
this->privData->button.Render();
|
||||
|
||||
Graphics::API::EndFrame();
|
||||
return true;
|
||||
}
|
||||
bool LobbyAdminState::Release()
|
||||
{
|
||||
privData = NULL;
|
||||
return true;
|
||||
}
|
||||
|
||||
void LobbyAdminState::ChangeState( ClientState next )
|
||||
{
|
||||
if( next == GameClientState::ClientState_LobbyReady )
|
||||
{ // If all is ready start server
|
||||
|
||||
}
|
||||
else
|
||||
this->privData->nextState = next;
|
||||
}
|
||||
|
||||
using namespace ::Oyster::Network;
|
||||
|
||||
void LobbyAdminState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEventArgs> e )
|
||||
{
|
||||
CustomNetProtocol data = e.args.data.protocol;
|
||||
short ID = data[0].value.netShort; // fetching the id data.
|
||||
|
||||
// Block irrelevant messages.
|
||||
if( ProtocolIsLobby(ID) )
|
||||
{
|
||||
switch(ID)
|
||||
{
|
||||
case protocol_Lobby_Create: break; /** @todo TODO: implement */
|
||||
case protocol_Lobby_Start: break; /** @todo TODO: implement */
|
||||
case protocol_Lobby_Join: break; /** @todo TODO: implement */
|
||||
case protocol_Lobby_Login: break; /** @todo TODO: implement */
|
||||
case protocol_Lobby_Refresh: break; /** @todo TODO: implement */
|
||||
case protocol_Lobby_ClientData: break; /** @todo TODO: implement */
|
||||
case protocol_Lobby_GameData: break; /** @todo TODO: implement */
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
else if( ProtocolIsGeneral(ID) )
|
||||
{
|
||||
switch( ID )
|
||||
{
|
||||
case protocol_General_Status: break; /** @todo TODO: implement */
|
||||
case protocol_General_Text: break; /** @todo TODO: implement */
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnButtonInteract_Ready( Oyster::Event::ButtonEvent<GameClientState*>& e )
|
||||
{
|
||||
switch( e.state )
|
||||
{
|
||||
case ButtonState_Released:
|
||||
e.owner->ChangeState( GameClientState::ClientState_LobbyReady );
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
#ifndef DANBIAS_CLIENT_LOBBYADMINSTATE_H
|
||||
#define DANBIAS_CLIENT_LOBBYADMINSTATE_H
|
||||
|
||||
#include "GameClientState.h"
|
||||
#include "NetworkClient.h"
|
||||
|
||||
// Feature wishlist:
|
||||
// create session lobby
|
||||
// join session lobby
|
||||
// set name
|
||||
// set rules
|
||||
// set map
|
||||
// ready
|
||||
// chat
|
||||
// kick
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
namespace Client
|
||||
{
|
||||
class LobbyAdminState : public GameClientState
|
||||
{
|
||||
public:
|
||||
LobbyAdminState();
|
||||
~LobbyAdminState();
|
||||
|
||||
bool Init( Oyster::Network::NetworkClient* nwClient );
|
||||
ClientState Update( float deltaTime, InputClass* KeyInput );
|
||||
bool Render();
|
||||
bool Release();
|
||||
void ChangeState( ClientState next );
|
||||
void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
|
||||
|
||||
private:
|
||||
struct MyData;
|
||||
::Utility::DynamicMemory::UniquePointer<MyData> privData;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // ! DANBIAS_CLIENT_GAMECLIENTSTATE_H
|
|
@ -7,9 +7,14 @@
|
|||
#include <GameServerAPI.h>
|
||||
#include <Protocols.h>
|
||||
|
||||
#include "EventHandler\EventHandler.h"
|
||||
#include "Buttons\ButtonRectangle.h"
|
||||
|
||||
using namespace ::DanBias::Client;
|
||||
using namespace ::Oyster;
|
||||
using namespace ::Oyster::Network;
|
||||
using namespace ::DanBias::Client;
|
||||
using namespace ::Oyster::Event;
|
||||
using namespace ::Oyster::Math3D;
|
||||
|
||||
struct LobbyState::MyData
|
||||
{
|
||||
|
@ -17,8 +22,12 @@ struct LobbyState::MyData
|
|||
|
||||
GameClientState::ClientState nextState;
|
||||
NetworkClient *nwClient;
|
||||
Graphics::API::Texture background;
|
||||
EventButtonCollection button;
|
||||
} privData;
|
||||
|
||||
void OnButtonInteract_Ready( Oyster::Event::ButtonEvent<GameClientState*>& e );
|
||||
|
||||
LobbyState::LobbyState(void) {}
|
||||
|
||||
LobbyState::~LobbyState(void)
|
||||
|
@ -34,31 +43,39 @@ bool LobbyState::Init(NetworkClient* nwClient)
|
|||
this->privData->nextState = GameClientState::ClientState_Same;
|
||||
this->privData->nwClient = nwClient;
|
||||
|
||||
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
|
||||
|
||||
// create buttons
|
||||
ButtonRectangle<GameClientState*> *button;
|
||||
|
||||
button = new ButtonRectangle<GameClientState*>( L"earth_md.png", OnButtonInteract_Ready, this, 0.5f, 0.2f, 0.3f, 0.1f, true );
|
||||
this->privData->button.AddButton( button );
|
||||
|
||||
// bind button collection to the singleton eventhandler
|
||||
EventHandler::Instance().AddCollection( &this->privData->button );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
GameClientState::ClientState LobbyState::Update(float deltaTime, InputClass* KeyInput)
|
||||
{
|
||||
//// picking
|
||||
//// mouse events
|
||||
//// different menus
|
||||
//// play sounds
|
||||
//// update animation
|
||||
//// send data to server
|
||||
//// check data from server
|
||||
// Wishlist:
|
||||
// picking
|
||||
// mouse events
|
||||
// different menus
|
||||
// play sounds
|
||||
// update animation
|
||||
// send data to server
|
||||
// check data from server
|
||||
|
||||
//if(GameServerAPI::ServerIsRunning() && GameServerAPI::ServerIsRunning()) //May be a problem if server is not shut down properly after lan session.
|
||||
//{
|
||||
// if( KeyInput->IsKeyPressed(DIK_G))
|
||||
// {
|
||||
// if(!DanBias::GameServerAPI::GameStart())
|
||||
// {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
MouseInput mouseState;
|
||||
{
|
||||
mouseState.x = KeyInput->GetPitch();
|
||||
mouseState.y = KeyInput->GetYaw();
|
||||
mouseState.mouseButtonPressed = KeyInput->IsMousePressed();
|
||||
}
|
||||
|
||||
//return ClientState_Same;
|
||||
EventHandler::Instance().Update( mouseState );
|
||||
|
||||
return this->privData->nextState;
|
||||
}
|
||||
|
@ -67,6 +84,9 @@ bool LobbyState::Render( )
|
|||
Graphics::API::NewFrame();
|
||||
Graphics::API::StartGuiRender();
|
||||
|
||||
Graphics::API::RenderGuiElement( this->privData->background, Float2(0.5f), Float2(1.0f) );
|
||||
this->privData->button.Render();
|
||||
|
||||
Graphics::API::EndFrame();
|
||||
return true;
|
||||
}
|
||||
|
@ -78,7 +98,12 @@ bool LobbyState::Release()
|
|||
|
||||
void LobbyState::ChangeState( ClientState next )
|
||||
{
|
||||
this->privData->nextState = next;
|
||||
if( next == GameClientState::ClientState_LobbyReady )
|
||||
{ // Send ready signal to server lobby
|
||||
|
||||
}
|
||||
else
|
||||
this->privData->nextState = next;
|
||||
}
|
||||
|
||||
using namespace ::Oyster::Network;
|
||||
|
@ -113,3 +138,14 @@ void LobbyState::DataRecieved( NetEvent<NetworkClient*, NetworkClient::ClientEve
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnButtonInteract_Ready( Oyster::Event::ButtonEvent<GameClientState*>& e )
|
||||
{
|
||||
switch( e.state )
|
||||
{
|
||||
case ButtonState_Released:
|
||||
e.owner->ChangeState( GameClientState::ClientState_LobbyReady );
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
|
@ -5,34 +5,37 @@
|
|||
#include "OysterMath.h"
|
||||
#include "NetworkClient.h"
|
||||
#include <string>
|
||||
|
||||
// Feature wishlist:
|
||||
// create session lobby
|
||||
// join session lobby
|
||||
// set name
|
||||
// set rules
|
||||
// set map
|
||||
// ready
|
||||
// chat
|
||||
// kick
|
||||
|
||||
namespace DanBias
|
||||
{
|
||||
namespace Client
|
||||
{
|
||||
class LobbyState : public GameClientState
|
||||
{
|
||||
private:
|
||||
struct MyData;
|
||||
::Utility::DynamicMemory::UniquePointer<MyData> privData;
|
||||
public:
|
||||
LobbyState(void);
|
||||
~LobbyState(void);
|
||||
bool Init(Oyster::Network::NetworkClient* nwClient);
|
||||
ClientState Update(float deltaTime, InputClass* KeyInput);
|
||||
// create session lobby
|
||||
// join session lobby
|
||||
// set name
|
||||
// set rules
|
||||
// set map
|
||||
// ready
|
||||
// chat
|
||||
// kick
|
||||
|
||||
bool Init( Oyster::Network::NetworkClient* nwClient );
|
||||
ClientState Update( float deltaTime, InputClass* KeyInput );
|
||||
bool Render();
|
||||
bool Release();
|
||||
void ChangeState( ClientState next );
|
||||
|
||||
void DataRecieved( ::Oyster::Network::NetEvent<::Oyster::Network::NetworkClient*, ::Oyster::Network::NetworkClient::ClientEventArgs> e );
|
||||
|
||||
private:
|
||||
struct MyData;
|
||||
::Utility::DynamicMemory::UniquePointer<MyData> privData;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,7 +69,14 @@ bool MainState::Init( NetworkClient* nwClient )
|
|||
|
||||
GameClientState::ClientState MainState::Update(float deltaTime, InputClass* KeyInput)
|
||||
{
|
||||
EventHandler::Instance().Update( KeyInput );
|
||||
MouseInput mouseState;
|
||||
{
|
||||
mouseState.x = KeyInput->GetPitch();
|
||||
mouseState.y = KeyInput->GetYaw();
|
||||
mouseState.mouseButtonPressed = KeyInput->IsMousePressed();
|
||||
}
|
||||
|
||||
EventHandler::Instance().Update( mouseState );
|
||||
|
||||
return this->privData->nextState;
|
||||
}
|
||||
|
@ -88,11 +95,12 @@ bool MainState::Render()
|
|||
|
||||
bool MainState::Release()
|
||||
{
|
||||
if( privData )
|
||||
if( this->privData )
|
||||
{
|
||||
Graphics::API::DeleteTexture( this->privData->background );
|
||||
Graphics::API::DeleteTexture( this->privData->background ); // TODO: @todo bug caught when exiting by X
|
||||
EventHandler::Instance().ReleaseCollection( &this->privData->button );
|
||||
|
||||
privData = NULL;
|
||||
this->privData = NULL;
|
||||
// button collection will be autoreleased from EventHandler
|
||||
}
|
||||
return true;
|
||||
|
@ -103,14 +111,6 @@ void MainState::ChangeState( ClientState next )
|
|||
this->privData->nextState = next;
|
||||
}
|
||||
|
||||
/// button actions
|
||||
|
||||
//ButtonState_None, // onExit
|
||||
//ButtonState_Hover,
|
||||
//ButtonState_Pressed,
|
||||
//ButtonState_Down,
|
||||
//ButtonState_Released,
|
||||
|
||||
void OnButtonInteract_Create( Oyster::Event::ButtonEvent<GameClientState*>& e )
|
||||
{
|
||||
switch( e.state )
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ShowAllFiles>true</ShowAllFiles>
|
||||
<ShowAllFiles>false</ShowAllFiles>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ShowAllFiles>true</ShowAllFiles>
|
||||
<ShowAllFiles>false</ShowAllFiles>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
|
||||
|
|
Loading…
Reference in New Issue