Skip to content

Commit

Permalink
Add UI button to stop a game.
Browse files Browse the repository at this point in the history
This adds a button along side the kick/kickban/ban buttons to stop the game the selected user is in.

Fixes #3635
  • Loading branch information
Pentarctagon committed Sep 14, 2019
1 parent 1e22146 commit 2eccbab
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
14 changes: 13 additions & 1 deletion data/gui/window/lobby_player_info.cfg
Expand Up @@ -170,7 +170,7 @@
horizontal_alignment = "left"

[label]
label = _ "Kick / ban reason:"
label = _ "Reason:"
[/label]
[/column]

Expand Down Expand Up @@ -262,6 +262,18 @@
label = _ "Kick + Ban"
[/button]
[/column]

[column]
grow_factor = 0
border = "all"
border_size = 5

[button]
definition = "default"
id = "stopgame"
label = _ "Stop Game"
[/button]
[/column]
[/row]

[/grid]
Expand Down
23 changes: 23 additions & 0 deletions src/gui/dialogs/multiplayer/player_info.cpp
Expand Up @@ -96,6 +96,12 @@ void lobby_player_info::pre_show(window& window)
this,
std::ref(window)));

connect_signal_mouse_left_click(
find_widget<button>(&window, "stopgame", false),
std::bind(&lobby_player_info::stopgame_button_callback,
this,
std::ref(window)));

find_widget<label>(&window, "player_name", false).set_label(info_.name);

std::stringstream loc;
Expand Down Expand Up @@ -204,6 +210,23 @@ void lobby_player_info::kick_ban_button_callback(window& w)
w.close();
}

void lobby_player_info::stopgame_button_callback(window& w)
{
do_stopgame();
w.close();
}

void lobby_player_info::do_stopgame()
{
std::stringstream ss;
ss << "stopgame " << info_.name;
if(!reason_->get_value().empty()) {
ss << " " << reason_->get_value();
}

chat_.send_command("query", ss.str());
}

void lobby_player_info::do_kick_ban(bool ban)
{
std::stringstream ss;
Expand Down
4 changes: 4 additions & 0 deletions src/gui/dialogs/multiplayer/player_info.hpp
Expand Up @@ -68,6 +68,10 @@ class lobby_player_info : public modal_dialog

void kick_ban_button_callback(window& w);

void stopgame_button_callback(window& w);

void do_stopgame();

void do_kick_ban(bool ban);

events::chat_handler& chat_;
Expand Down

0 comments on commit 2eccbab

Please sign in to comment.