Tweaks and a new state: NetLoadState

This commit is contained in:
Dander7BD 2014-02-14 14:31:01 +01:00
parent c5c0047b5c
commit fe6742f9e2
7 changed files with 54 additions and 28 deletions

View File

@ -215,6 +215,7 @@
<ClCompile Include="GameClientState\LobbyState.cpp" /> <ClCompile Include="GameClientState\LobbyState.cpp" />
<ClCompile Include="GameClientState\C_Object.cpp" /> <ClCompile Include="GameClientState\C_Object.cpp" />
<ClCompile Include="GameClientState\MainState.cpp" /> <ClCompile Include="GameClientState\MainState.cpp" />
<ClCompile Include="GameClientState\NetLoadState.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="GameClientState\Camera_Basic.h" /> <ClInclude Include="GameClientState\Camera_Basic.h" />
@ -237,6 +238,7 @@
<ClInclude Include="GameClientState\LevelLoader\ParseFunctions.h" /> <ClInclude Include="GameClientState\LevelLoader\ParseFunctions.h" />
<ClInclude Include="GameClientState\LobbyAdminState.h" /> <ClInclude Include="GameClientState\LobbyAdminState.h" />
<ClInclude Include="GameClientState\MainState.h" /> <ClInclude Include="GameClientState\MainState.h" />
<ClInclude Include="GameClientState\NetLoadState.h" />
<ClInclude Include="Include\DanBiasGame.h" /> <ClInclude Include="Include\DanBiasGame.h" />
<ClInclude Include="GameClientState\LobbyState.h" /> <ClInclude Include="GameClientState\LobbyState.h" />
<ClInclude Include="GameClientState\C_Object.h" /> <ClInclude Include="GameClientState\C_Object.h" />

View File

@ -8,6 +8,7 @@
#include "GameClientState\LobbyAdminState.h" #include "GameClientState\LobbyAdminState.h"
#include "GameClientState\MainState.h" #include "GameClientState\MainState.h"
#include "GameClientState\LanMenuState.h" #include "GameClientState\LanMenuState.h"
#include "GameClientState\NetLoadState.h"
#include <Protocols.h> #include <Protocols.h>
#include "NetworkClient.h" #include "NetworkClient.h"
#include <GameServerAPI.h> #include <GameServerAPI.h>
@ -182,8 +183,8 @@ namespace DanBias
switch (state) switch (state)
{ {
case Client::GameClientState::ClientState_LobbyCreate: case Client::GameClientState::ClientState_Main:
data.state = new Client::LobbyAdminState(); data.state = new Client::MainState();
stateChanged = true; stateChanged = true;
break; break;
case Client::GameClientState::ClientState_Lan: case Client::GameClientState::ClientState_Lan:
@ -194,10 +195,18 @@ namespace DanBias
data.state = new Client::LobbyState(); data.state = new Client::LobbyState();
stateChanged = true; stateChanged = true;
break; break;
case Client::GameClientState::ClientState_LobbyCreate:
data.state = new Client::LobbyAdminState();
stateChanged = true;
break;
case Client::GameClientState::ClientState_Game: case Client::GameClientState::ClientState_Game:
data.state = new Client::GameState(); data.state = new Client::GameState();
stateChanged = true; stateChanged = true;
break; break;
case Client::GameClientState::ClientState_NetLoad:
data.state = new Client::NetLoadState();
stateChanged = true;
break;
case Client::GameClientState::ClientState_Quit: case Client::GameClientState::ClientState_Quit:
data.state->Release(); data.state->Release();
return Result_quit; return Result_quit;

View File

@ -78,37 +78,36 @@ namespace DanBias { namespace Client
{ {
::Oyster::Math::Float lineStep = this->fontHeight + this->lineSpacing; ::Oyster::Math::Float lineStep = this->fontHeight + this->lineSpacing;
::Oyster::Math::Float2 rowSize = ::Oyster::Math::Float2( this->size.x, this->fontHeight ); ::Oyster::Math::Float2 rowSize = ::Oyster::Math::Float2( this->size.x, this->fontHeight );
::Oyster::Math::Float3 fieldTopLeft = this->pos - Float3( this->size * 0.25f, 0.0f );
::Oyster::Math::Float3 topLeft = fieldTopLeft;
if( this->isBottomAligned ) if( this->isBottomAligned )
{ {
::Oyster::Math::Float3 topLeft = this->pos;
topLeft.y += this->size.y - lineStep; topLeft.y += this->size.y - lineStep;
auto line = this->lines.rbegin(); auto line = this->lines.rbegin();
for( ; line != this->lines.rend(); ++line ) for( ; line != this->lines.rend(); ++line )
{ {
if( topLeft.y - lineStep >= this->pos.y ) if( topLeft.y < fieldTopLeft.y )
{ break;
::Oyster::Graphics::API::RenderText( (*line), topLeft, rowSize, this->fontHeight, this->textColor ); ::Oyster::Graphics::API::RenderText( (*line), topLeft, rowSize, this->fontHeight, this->textColor );
topLeft.y -= lineStep; topLeft.y -= lineStep;
} }
else break;
}
} }
else else
{ {
::Oyster::Math::Float3 topLeft = this->pos; topLeft.y += this->lineSpacing;
auto line = this->lines.begin(); auto line = this->lines.begin();
for( ; line != this->lines.end(); ++line ) for( ; line != this->lines.end(); ++line )
{ {
if( topLeft.y + lineStep < this->size.y ) if( topLeft.y >= fieldTopLeft.y + this->size.y )
{ break;
::Oyster::Graphics::API::RenderText( (*line), topLeft, rowSize, this->fontHeight, this->textColor ); ::Oyster::Graphics::API::RenderText( (*line), topLeft, rowSize, this->fontHeight, this->textColor );
topLeft.y += lineStep; topLeft.y += lineStep;
} }
else break;
}
} }
} }

View File

@ -12,11 +12,12 @@ namespace DanBias { namespace Client
public: public:
enum ClientState enum ClientState
{ {
ClientState_Login, ClientState_Main,
ClientState_Lan, ClientState_Lan,
ClientState_Lobby, ClientState_Lobby,
ClientState_LobbyCreate, ClientState_LobbyCreate,
ClientState_LobbyReady, ClientState_LobbyReady,
ClientState_NetLoad,
ClientState_Game, ClientState_Game,
ClientState_Same, ClientState_Same,
ClientState_Quit ClientState_Quit

View File

@ -36,6 +36,7 @@ struct LanMenuState::MyData
} privData; } privData;
void OnButtonInteract_Connect( Oyster::Event::ButtonEvent<LanMenuState*>& e ); void OnButtonInteract_Connect( Oyster::Event::ButtonEvent<LanMenuState*>& e );
void OnButtonInteract_Exit( Oyster::Event::ButtonEvent<LanMenuState*>& e );
LanMenuState::LanMenuState() {} LanMenuState::LanMenuState() {}
@ -55,19 +56,22 @@ bool LanMenuState::Init(Network::NetworkClient* nwClient)
this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" ); this->privData->background = Graphics::API::CreateTexture( L"grass_md.png" );
// create guiElements // create guiElements
ButtonRectangle<LanMenuState*> *guiElements; this->privData->connectIP = new TextField<LanMenuState*>( L"earth_md.png", Float3(1.0f), this, Float3(0.5f, 0.3f, 0.5f), Float2(0.8f, 0.09f), ResizeAspectRatio_None );
guiElements = new ButtonRectangle<LanMenuState*>( L"earth_md.png", L"Connect", Float3(1.0f), OnButtonInteract_Connect, this, Float3(0.5f, 0.2f, 0.5f), Float2(0.3f, 0.1f), ResizeAspectRatio_Width );
this->privData->guiElements.AddButton( guiElements );
this->privData->connectIP = new TextField<LanMenuState*>( L"earth_md.png", Float3(1.0f), this, Float3(0.1f, 0.2f, 0.5f), Float2(0.45f, 0.1f), ResizeAspectRatio_Width );
this->privData->connectIP->ReserveLines( 1 ); this->privData->connectIP->ReserveLines( 1 );
this->privData->connectIP->AppendText( L"127.0.0.1" ); this->privData->connectIP->AppendText( L"127.0.0.1" );
this->privData->connectIP->SetFontHeight( 0.1f ); this->privData->connectIP->SetFontHeight( 0.08f );
this->privData->connectIP->SetLineSpacing( 0.0f ); this->privData->connectIP->SetLineSpacing( 0.005f );
this->privData->connectIP->SetTopAligned();
this->privData->guiElements.AddButton( this->privData->connectIP ); this->privData->guiElements.AddButton( this->privData->connectIP );
ButtonRectangle<LanMenuState*> *guiElements;
guiElements = new ButtonRectangle<LanMenuState*>( L"earth_md.png", L"Connect", Float3(1.0f), OnButtonInteract_Connect, this, Float3(0.5f, 0.4f, 0.5f), Float2(0.3f, 0.05f), ResizeAspectRatio_None );
this->privData->guiElements.AddButton( guiElements );
guiElements = new ButtonRectangle<LanMenuState*>( L"earth_md.png", L"Exit", Float3(1.0f), OnButtonInteract_Exit, this, Float3(0.5f, 0.5f, 0.5f), Float2(0.3f, 0.05f), ResizeAspectRatio_None );
this->privData->guiElements.AddButton( guiElements );
// bind guiElements collection to the singleton eventhandler // bind guiElements collection to the singleton eventhandler
EventHandler::Instance().AddCollection( &this->privData->guiElements ); EventHandler::Instance().AddCollection( &this->privData->guiElements );
@ -136,3 +140,14 @@ void OnButtonInteract_Connect( Oyster::Event::ButtonEvent<LanMenuState*>& e )
default: break; default: break;
} }
} }
void OnButtonInteract_Exit( Oyster::Event::ButtonEvent<LanMenuState*>& e )
{
switch( e.state )
{
case ButtonState_Released:
e.owner->ChangeState( GameClientState::ClientState_Main );
break;
default: break;
}
}

View File

@ -102,7 +102,7 @@ void LobbyState::ChangeState( ClientState next )
{ {
if( next == GameClientState::ClientState_LobbyReady ) if( next == GameClientState::ClientState_LobbyReady )
{ // Send ready signal to server lobby { // Send ready signal to server lobby
this->ChangeState( GameClientState::ClientState_NetLoad );
} }
else else
this->privData->nextState = next; this->privData->nextState = next;