Add UI button to stop a game.

This adds a button along side the kick/kickban/ban buttons to stop the game the selected user is in.

Fixes #3635
This commit is contained in:
pentarctagon 2019-09-13 15:13:36 -05:00 committed by Pentarctagon
parent 1e221469d2
commit 2eccbab970
3 changed files with 40 additions and 1 deletions

View file

@ -170,7 +170,7 @@
horizontal_alignment = "left"
[label]
label = _ "Kick / ban reason:"
label = _ "Reason:"
[/label]
[/column]
@ -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]

View file

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

View file

@ -68,6 +68,10 @@ private:
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_;