diff --git a/Code/Game/DanBiasGame/DanBiasGame.vcxproj b/Code/Game/DanBiasGame/DanBiasGame.vcxproj
index 35cd832f..974736b4 100644
--- a/Code/Game/DanBiasGame/DanBiasGame.vcxproj
+++ b/Code/Game/DanBiasGame/DanBiasGame.vcxproj
@@ -211,6 +211,7 @@
+
@@ -234,6 +235,7 @@
+
diff --git a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp
index 0b14e89f..923e53fc 100644
--- a/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp
+++ b/Code/Game/DanBiasGame/DanBiasGame_Impl.cpp
@@ -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
@@ -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;
diff --git a/Code/Game/DanBiasGame/GameClientState/GameClientState.h b/Code/Game/DanBiasGame/GameClientState/GameClientState.h
index 96c4fd64..a1936bab 100644
--- a/Code/Game/DanBiasGame/GameClientState/GameClientState.h
+++ b/Code/Game/DanBiasGame/GameClientState/GameClientState.h
@@ -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
diff --git a/Code/Game/DanBiasGame/GameClientState/GameState.cpp b/Code/Game/DanBiasGame/GameClientState/GameState.cpp
index 088837c7..a1cdb32a 100644
--- a/Code/Game/DanBiasGame/GameClientState/GameState.cpp
+++ b/Code/Game/DanBiasGame/GameClientState/GameState.cpp
@@ -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;
diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp
new file mode 100644
index 00000000..e6e764ea
--- /dev/null
+++ b/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.cpp
@@ -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
+#include
+
+#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& 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 *button;
+
+ button = new ButtonRectangle( 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 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& e )
+{
+ switch( e.state )
+ {
+ case ButtonState_Released:
+ e.owner->ChangeState( GameClientState::ClientState_LobbyReady );
+ break;
+ default: break;
+ }
+}
\ No newline at end of file
diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.h b/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.h
new file mode 100644
index 00000000..06a9aced
--- /dev/null
+++ b/Code/Game/DanBiasGame/GameClientState/LobbyAdminState.h
@@ -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 privData;
+ };
+ }
+}
+#endif // ! DANBIAS_CLIENT_GAMECLIENTSTATE_H
diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp
index 7b3f88ea..77ec5a86 100644
--- a/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp
+++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.cpp
@@ -7,9 +7,14 @@
#include
#include
+#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& 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 *button;
+
+ button = new ButtonRectangle( 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())
- // {
- //
- // }
- // }
- //}
-
- //return ClientState_Same;
+ MouseInput mouseState;
+ {
+ mouseState.x = KeyInput->GetPitch();
+ mouseState.y = KeyInput->GetYaw();
+ mouseState.mouseButtonPressed = KeyInput->IsMousePressed();
+ }
+
+ 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;
@@ -112,4 +137,15 @@ void LobbyState::DataRecieved( NetEvent& e )
+{
+ switch( e.state )
+ {
+ case ButtonState_Released:
+ e.owner->ChangeState( GameClientState::ClientState_LobbyReady );
+ break;
+ default: break;
+ }
}
\ No newline at end of file
diff --git a/Code/Game/DanBiasGame/GameClientState/LobbyState.h b/Code/Game/DanBiasGame/GameClientState/LobbyState.h
index 8491827f..7b6e5909 100644
--- a/Code/Game/DanBiasGame/GameClientState/LobbyState.h
+++ b/Code/Game/DanBiasGame/GameClientState/LobbyState.h
@@ -5,34 +5,37 @@
#include "OysterMath.h"
#include "NetworkClient.h"
#include
+
+// 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 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 privData;
};
}
}
diff --git a/Code/Game/DanBiasGame/GameClientState/MainState.cpp b/Code/Game/DanBiasGame/GameClientState/MainState.cpp
index 79981baa..c7fe78c8 100644
--- a/Code/Game/DanBiasGame/GameClientState/MainState.cpp
+++ b/Code/Game/DanBiasGame/GameClientState/MainState.cpp
@@ -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& e )
{
switch( e.state )
diff --git a/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj.user b/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj.user
index 2e28d6f7..4b847ee6 100644
--- a/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj.user
+++ b/Code/Game/DanBiasLauncher/DanBiasLauncher.vcxproj.user
@@ -1,7 +1,7 @@
- true
+ false
$(OutDir)
diff --git a/Code/Game/GameServer/GameServer.vcxproj.user b/Code/Game/GameServer/GameServer.vcxproj.user
index 2e28d6f7..4b847ee6 100644
--- a/Code/Game/GameServer/GameServer.vcxproj.user
+++ b/Code/Game/GameServer/GameServer.vcxproj.user
@@ -1,7 +1,7 @@
- true
+ false
$(OutDir)