diff --git a/include/client/render/gui/GameMenu.h b/include/client/render/gui/GameMenu.h index d0c59c3..9c08ca3 100644 --- a/include/client/render/gui/GameMenu.h +++ b/include/client/render/gui/GameMenu.h @@ -18,6 +18,8 @@ private: void ShowPlayers(); void ShowLobbyProgress(); void ShowTeamSelection(); + + void DisconnectButton(); }; } // namespace gui diff --git a/src/client/Client.cpp b/src/client/Client.cpp index c123445..6c1a6b9 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -37,6 +37,9 @@ void Client::CloseConnection() { protocol::DisconnectPacket packet; m_Connexion.SendPacket(&packet); + + m_Game->SetGameState(game::GameState::Disconnected); + m_Connexion.CloseConnection(); } void Client::Tick(std::uint64_t delta) { diff --git a/src/client/render/gui/GameMenu.cpp b/src/client/render/gui/GameMenu.cpp index 923ee48..0d13c86 100644 --- a/src/client/render/gui/GameMenu.cpp +++ b/src/client/render/gui/GameMenu.cpp @@ -24,6 +24,8 @@ void GameMenu::Render() { ShowPlayers(); ShowLobbyProgress(); ShowTeamSelection(); + ImGui::Separator(); + DisconnectButton(); ImGui::End(); } @@ -33,6 +35,8 @@ void GameMenu::Render() { ShowTPS(); ShowStats(); ShowPlayers(); + ImGui::Separator(); + DisconnectButton(); ImGui::End(); @@ -95,5 +99,11 @@ void GameMenu::ShowStats() { ImGui::Text("EXP: %i", GetClient()->GetGame().GetPlayer()->GetExp()); } +void GameMenu::DisconnectButton() { + if (ImGui::Button("Disconnect")) { + m_Client->CloseConnection(); + } +} + } // namespace gui } // namespace td