mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-04 22:43:17 +00:00
Chatbox: allow new rooms to specify if they can be closed or not
This removes the hardcoded "room name is 'lobby" predicate.
This commit is contained in:
parent
7edad9669a
commit
497dcac47a
@ -759,7 +759,7 @@ void tlobby_main::pre_show(twindow& window)
|
|||||||
*filter_text_,
|
*filter_text_,
|
||||||
std::bind(&tlobby_main::game_filter_keypress_callback, this, _5));
|
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();
|
chatbox_->active_window_changed();
|
||||||
game_filter_reload();
|
game_filter_reload();
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ void tmp_join_game::pre_show(twindow& window)
|
|||||||
chat.set_lobby_info(lobby_info_);
|
chat.set_lobby_info(lobby_info_);
|
||||||
chat.set_wesnothd_connection(wesnothd_connection_);
|
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();
|
chat.active_window_changed();
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -122,7 +122,7 @@ void tmp_staging::pre_show(twindow& window)
|
|||||||
chat.set_wesnothd_connection(*wesnothd_connection_);
|
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();
|
chat.active_window_changed();
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -360,19 +360,20 @@ bool tchatbox::room_window_active(const std::string& room)
|
|||||||
return t.name == room && t.whisper == false;
|
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)
|
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,
|
tlobby_chat_window* tchatbox::search_create_window(const std::string& name,
|
||||||
bool whisper,
|
const bool whisper,
|
||||||
bool open_new)
|
const bool open_new,
|
||||||
|
const bool allow_close)
|
||||||
{
|
{
|
||||||
for(auto& t : open_windows_) {
|
for(auto& t : open_windows_) {
|
||||||
if(t.name == name && t.whisper == whisper) {
|
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,
|
connect_signal_mouse_left_click(close_button,
|
||||||
std::bind(&tchatbox::close_window_button_callback, this, open_windows_.back(), _3, _4));
|
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);
|
close_button.set_visible(tcontrol::tvisible::hidden);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,11 +219,12 @@ public:
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a room window for "room" is open, if open_new is true
|
* 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
|
* @return valid ptr if the window was found or added, null otherwise
|
||||||
*/
|
*/
|
||||||
tlobby_chat_window* room_window_open(const std::string& room,
|
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
|
* 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
|
* 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) { do_notify(mode, "", ""); }
|
||||||
void do_notify(t_notify_mode mode, const std::string & sender, const std::string & message) { do_mp_notify(mode, sender, message); }
|
void do_notify(t_notify_mode mode, const std::string & sender, const std::string & message) { do_mp_notify(mode, sender, message); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user