diff --git a/src/gui/dialogs/lobby/lobby.cpp b/src/gui/dialogs/lobby/lobby.cpp index 3c372c43d0b..b4a08cf7b97 100644 --- a/src/gui/dialogs/lobby/lobby.cpp +++ b/src/gui/dialogs/lobby/lobby.cpp @@ -759,7 +759,7 @@ void tlobby_main::pre_show(twindow& window) *filter_text_, std::bind(&tlobby_main::game_filter_keypress_callback, this, _5)); - chatbox_->room_window_open("lobby", true); + chatbox_->room_window_open("lobby", true, false); chatbox_->active_window_changed(); game_filter_reload(); diff --git a/src/gui/dialogs/multiplayer/mp_join_game.cpp b/src/gui/dialogs/multiplayer/mp_join_game.cpp index 2006a3cdf01..473f46e8658 100644 --- a/src/gui/dialogs/multiplayer/mp_join_game.cpp +++ b/src/gui/dialogs/multiplayer/mp_join_game.cpp @@ -274,7 +274,7 @@ void tmp_join_game::pre_show(twindow& window) chat.set_lobby_info(lobby_info_); chat.set_wesnothd_connection(wesnothd_connection_); - chat.room_window_open("this game", true); // TODO: better title? + chat.room_window_open("this game", true, false); // TODO: better title? chat.active_window_changed(); // diff --git a/src/gui/dialogs/multiplayer/mp_staging.cpp b/src/gui/dialogs/multiplayer/mp_staging.cpp index 3f97b02246c..c5db666f532 100644 --- a/src/gui/dialogs/multiplayer/mp_staging.cpp +++ b/src/gui/dialogs/multiplayer/mp_staging.cpp @@ -122,7 +122,7 @@ void tmp_staging::pre_show(twindow& window) chat.set_wesnothd_connection(*wesnothd_connection_); } - chat.room_window_open("this game", true); // TODO: better title? + chat.room_window_open("this game", true, false); // TODO: better title? chat.active_window_changed(); // diff --git a/src/gui/widgets/chatbox.cpp b/src/gui/widgets/chatbox.cpp index 8dc3e02368b..42a7cf13417 100644 --- a/src/gui/widgets/chatbox.cpp +++ b/src/gui/widgets/chatbox.cpp @@ -360,19 +360,20 @@ bool tchatbox::room_window_active(const std::string& room) return t.name == room && t.whisper == false; } -tlobby_chat_window* tchatbox::room_window_open(const std::string& room, bool open_new) +tlobby_chat_window* tchatbox::room_window_open(const std::string& room, const bool open_new, const bool allow_close) { - return search_create_window(room, false, open_new); + return search_create_window(room, false, open_new, allow_close); } tlobby_chat_window* tchatbox::whisper_window_open(const std::string& name, bool open_new) { - return search_create_window(name, true, open_new); + return search_create_window(name, true, open_new, true); } tlobby_chat_window* tchatbox::search_create_window(const std::string& name, - bool whisper, - bool open_new) + const bool whisper, + const bool open_new, + const bool allow_close) { for(auto& t : open_windows_) { if(t.name == name && t.whisper == whisper) { @@ -415,7 +416,7 @@ tlobby_chat_window* tchatbox::search_create_window(const std::string& name, connect_signal_mouse_left_click(close_button, std::bind(&tchatbox::close_window_button_callback, this, open_windows_.back(), _3, _4)); - if(name == "lobby") { + if(!allow_close) { close_button.set_visible(tcontrol::tvisible::hidden); } diff --git a/src/gui/widgets/chatbox.hpp b/src/gui/widgets/chatbox.hpp index be819d944e7..aaf624cf319 100644 --- a/src/gui/widgets/chatbox.hpp +++ b/src/gui/widgets/chatbox.hpp @@ -219,11 +219,12 @@ public: /** * Check if a room window for "room" is open, if open_new is true - * then it will be created if not found. + * then it will be created if not found. If allow_close is false, the + * 'close' button will be disabled. * @return valid ptr if the window was found or added, null otherwise */ tlobby_chat_window* room_window_open(const std::string& room, - bool open_new); + const bool open_new, const bool allow_close = true); /** * Check if a whisper window for user "name" is open, if open_new is true @@ -236,7 +237,7 @@ public: /** * Helper function to find and open a new window, used by *_window_open */ - tlobby_chat_window* search_create_window(const std::string& name, bool whisper, bool open_new); + tlobby_chat_window* search_create_window(const std::string& name, const bool whisper, const bool open_new, const bool allow_close); void do_notify(t_notify_mode mode) { do_notify(mode, "", ""); } void do_notify(t_notify_mode mode, const std::string & sender, const std::string & message) { do_mp_notify(mode, sender, message); }