add client disconnect button

This commit is contained in:
2023-08-14 13:46:10 +02:00
parent 7f650f282c
commit 0c0fd155ed
3 changed files with 15 additions and 0 deletions

View File

@@ -18,6 +18,8 @@ private:
void ShowPlayers();
void ShowLobbyProgress();
void ShowTeamSelection();
void DisconnectButton();
};
} // namespace gui

View File

@@ -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) {

View File

@@ -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