Renamed the mp_chatbox widget simply "chatbox"

This commit is contained in:
Charles Dang 2016-09-09 08:25:04 +11:00
parent 765f0bfc6a
commit b07810608a
10 changed files with 76 additions and 76 deletions

View file

@ -839,7 +839,7 @@
[/tag]
[/tag]
[tag]
name="mp_chatbox_definition"
name="chatbox_definition"
min="0"
max="-1"
super="generic/widget_definition"
@ -1744,7 +1744,7 @@
super="generic/widget_instance"
[/tag]
[tag]
name="mp_chatbox"
name="chatbox"
min="0"
max="-1"
super="generic/widget_instance"

View file

@ -99,7 +99,7 @@
[/multi_page]
#enddef
[mp_chatbox_definition]
[chatbox_definition]
id = "default"
description = "Mp chatbox"
@ -177,7 +177,7 @@
[/resolution]
[/mp_chatbox_definition]
[/chatbox_definition]
#undef _GUI_ROOM_TAB_BAR
#undef _GUI_CHATLOG

View file

@ -822,9 +822,9 @@
grow_factor = 1
horizontal_grow = "true"
vertical_grow = "true"
[mp_chatbox]
[chatbox]
id = "chat"
[/mp_chatbox]
[/chatbox]
[/column]
[column]
grow_factor = 0
@ -911,9 +911,9 @@
horizontal_grow = "true"
vertical_grow = "true"
{GUI_FORCE_WIDGET_MINIMUM_SIZE 0 "((screen_height * 30 / 100))" (
[mp_chatbox]
[chatbox]
id = "chat"
[/mp_chatbox]
[/chatbox]
)}
[/column]
[/row]

View file

@ -656,6 +656,8 @@
<Unit filename="../../src/gui/dialogs/wml_message.hpp" />
<Unit filename="../../src/gui/widgets/button.cpp" />
<Unit filename="../../src/gui/widgets/button.hpp" />
<Unit filename="../../src/gui/widgets/chatbox.cpp" />
<Unit filename="../../src/gui/widgets/chatbox.hpp" />
<Unit filename="../../src/gui/widgets/clickable.hpp" />
<Unit filename="../../src/gui/widgets/container.cpp" />
<Unit filename="../../src/gui/widgets/container.hpp" />
@ -692,8 +694,6 @@
<Unit filename="../../src/gui/widgets/menu_button.hpp" />
<Unit filename="../../src/gui/widgets/minimap.cpp" />
<Unit filename="../../src/gui/widgets/minimap.hpp" />
<Unit filename="../../src/gui/widgets/mp_chatbox.cpp" />
<Unit filename="../../src/gui/widgets/mp_chatbox.hpp" />
<Unit filename="../../src/gui/widgets/multi_page.cpp" />
<Unit filename="../../src/gui/widgets/multi_page.hpp" />
<Unit filename="../../src/gui/widgets/pane.cpp" />

View file

@ -519,6 +519,7 @@ add_library(wesnoth-gui_tooltip
set(wesnoth-gui_widget_SRC
gui/dialogs/drop_down_list.cpp
gui/widgets/button.cpp
gui/widgets/chatbox.cpp
gui/widgets/container.cpp
gui/widgets/control.cpp
gui/widgets/debug.cpp
@ -534,7 +535,6 @@ set(wesnoth-gui_widget_SRC
gui/widgets/matrix.cpp
gui/widgets/menu_button.cpp
gui/widgets/minimap.cpp
gui/widgets/mp_chatbox.cpp
gui/widgets/multi_page.cpp
gui/widgets/pane.cpp
gui/widgets/panel.cpp

View file

@ -433,6 +433,7 @@ wesnoth_sources = Split("""
gui/dialogs/wml_error.cpp
gui/dialogs/wml_message.cpp
gui/widgets/button.cpp
gui/widgets/chatbox.cpp
gui/widgets/container.cpp
gui/widgets/control.cpp
gui/widgets/drawing.cpp
@ -447,7 +448,6 @@ wesnoth_sources = Split("""
gui/widgets/matrix.cpp
gui/widgets/menu_button.cpp
gui/widgets/minimap.cpp
gui/widgets/mp_chatbox.cpp
gui/widgets/multi_page.cpp
gui/widgets/pane.cpp
gui/widgets/panel.cpp

View file

@ -33,7 +33,7 @@
#endif
#include "gui/widgets/menu_button.hpp"
#include "gui/widgets/minimap.hpp"
#include "gui/widgets/mp_chatbox.hpp"
#include "gui/widgets/chatbox.hpp"
#include "gui/widgets/multi_page.hpp"
#include "gui/widgets/scroll_label.hpp"
#include "gui/widgets/settings.hpp"
@ -739,7 +739,7 @@ void tlobby_main::pre_show(twindow& window)
window_ = &window;
chatbox_ = find_widget<tmp_chatbox>(&window, "chat", false, true);
chatbox_ = find_widget<tchatbox>(&window, "chat", false, true);
chatbox_->set_lobby_info(lobby_info_);
chatbox_->set_active_window_changed_callback([this]() { player_list_dirty_ = true; });

View file

@ -41,7 +41,7 @@ class ttext_box;
class twindow;
class tmulti_page;
class ttoggle_button;
class tmp_chatbox;
class tchatbox;
struct tsub_player_list
{
@ -192,7 +192,7 @@ private:
lobby_info& lobby_info_;
tmp_chatbox* chatbox_;
tchatbox* chatbox_;
std::function<void()> preferences_callback_;

View file

@ -13,7 +13,7 @@
#define GETTEXT_DOMAIN "wesnoth-lib"
#include "gui/widgets/mp_chatbox.hpp"
#include "gui/widgets/chatbox.hpp"
#include "gui/auxiliary/find_widget.hpp"
@ -75,9 +75,9 @@ namespace gui2
// ------------ WIDGET -----------{
REGISTER_WIDGET(mp_chatbox)
REGISTER_WIDGET(chatbox)
tmp_chatbox::tmp_chatbox()
tchatbox::tchatbox()
: tcontainer_(1)
, roomlistbox_(nullptr)
, chat_log_container_(nullptr)
@ -88,7 +88,7 @@ tmp_chatbox::tmp_chatbox()
{
}
void tmp_chatbox::active_window_changed()
void tchatbox::active_window_changed()
{
tlobby_chat_window& t = open_windows_[active_window_];
@ -101,12 +101,12 @@ void tmp_chatbox::active_window_changed()
}
}
void tmp_chatbox::switch_to_window(tlobby_chat_window* t)
void tchatbox::switch_to_window(tlobby_chat_window* t)
{
switch_to_window(t - &open_windows_[0]);
}
void tmp_chatbox::switch_to_window(size_t id)
void tchatbox::switch_to_window(size_t id)
{
active_window_ = id;
assert(active_window_ < open_windows_.size());
@ -115,7 +115,7 @@ void tmp_chatbox::switch_to_window(size_t id)
active_window_changed();
}
void tmp_chatbox::finalize_setup()
void tchatbox::finalize_setup()
{
roomlistbox_ = find_widget<tlistbox>(this, "room_list", false, true);
@ -129,7 +129,7 @@ void tmp_chatbox::finalize_setup()
connect_signal_pre_key_press(
*chat_input_,
std::bind(&tmp_chatbox::chat_input_keypress_callback,
std::bind(&tchatbox::chat_input_keypress_callback,
this,
_3,
_4,
@ -137,7 +137,7 @@ void tmp_chatbox::finalize_setup()
}
void tmp_chatbox::send_message_button_callback()
void tchatbox::send_message_button_callback()
{
const std::string& input = chat_input_->get_value();
if (input.empty())
@ -164,7 +164,7 @@ void tmp_chatbox::send_message_button_callback()
}
void tmp_chatbox::chat_input_keypress_callback(bool& handled, bool& halt, const SDLKey key)
void tchatbox::chat_input_keypress_callback(bool& handled, bool& halt, const SDLKey key)
{
if (key == SDLK_RETURN || key == SDLK_KP_ENTER) {
send_message_button_callback();
@ -201,12 +201,12 @@ void tmp_chatbox::chat_input_keypress_callback(bool& handled, bool& halt, const
}
}
void tmp_chatbox::append_to_chatbox(const std::string& text, const bool force_scroll)
void tchatbox::append_to_chatbox(const std::string& text, const bool force_scroll)
{
append_to_chatbox(text, active_window_, force_scroll);
}
void tmp_chatbox::append_to_chatbox(const std::string& text, size_t id, const bool force_scroll)
void tchatbox::append_to_chatbox(const std::string& text, size_t id, const bool force_scroll)
{
tgrid& grid = chat_log_container_->page_grid(id);
tscroll_label& log = find_widget<tscroll_label>(&grid, "log_text", false);
@ -224,28 +224,28 @@ void tmp_chatbox::append_to_chatbox(const std::string& text, size_t id, const bo
}
}
void tmp_chatbox::set_active(const bool /*active*/)
void tchatbox::set_active(const bool /*active*/)
{
/* DO NOTHING */
}
bool tmp_chatbox::get_active() const
bool tchatbox::get_active() const
{
return true;
}
const std::string& tmp_chatbox::get_control_type() const
const std::string& tchatbox::get_control_type() const
{
static const std::string type = "mp_chatbox";
static const std::string type = "chatbox";
return type;
}
void tmp_chatbox::set_self_active(const bool /*active*/)
void tchatbox::set_self_active(const bool /*active*/)
{
/* DO NOTHING */
}
void tmp_chatbox::send_chat_message(const std::string& message,
void tchatbox::send_chat_message(const std::string& message,
bool /*allies_only*/)
{
::config c = config_of("message", config_of("message", message)("sender", preferences::login()));
@ -254,14 +254,14 @@ void tmp_chatbox::send_chat_message(const std::string& message,
lobby_info().wesnothd_connection().send_data(c);
}
void tmp_chatbox::user_relation_changed(const std::string& /*name*/)
void tchatbox::user_relation_changed(const std::string& /*name*/)
{
if (active_window_changed_callback_) {
active_window_changed_callback_();
}
}
void tmp_chatbox::add_chat_message(const time_t& /*time*/,
void tchatbox::add_chat_message(const time_t& /*time*/,
const std::string& speaker,
int /*side*/,
const std::string& message,
@ -274,7 +274,7 @@ void tmp_chatbox::add_chat_message(const time_t& /*time*/,
}
void tmp_chatbox::add_whisper_sent(const std::string& receiver,
void tchatbox::add_whisper_sent(const std::string& receiver,
const std::string& message)
{
if (whisper_window_active(receiver)) {
@ -295,7 +295,7 @@ void tmp_chatbox::add_whisper_sent(const std::string& receiver,
.add_message(preferences::login(), message);
}
void tmp_chatbox::add_whisper_received(const std::string& sender,
void tchatbox::add_whisper_received(const std::string& sender,
const std::string& message)
{
bool can_go_to_active = !preferences::whisper_friends_only()
@ -323,7 +323,7 @@ void tmp_chatbox::add_whisper_received(const std::string& sender,
}
}
void tmp_chatbox::add_chat_room_message_sent(const std::string& room,
void tchatbox::add_chat_room_message_sent(const std::string& room,
const std::string& message)
{
// do not open room window here, player should be in the room before sending
@ -343,7 +343,7 @@ void tmp_chatbox::add_chat_room_message_sent(const std::string& room,
}
}
void tmp_chatbox::add_chat_room_message_received(const std::string& room,
void tchatbox::add_chat_room_message_received(const std::string& room,
const std::string& speaker,
const std::string& message)
{
@ -375,32 +375,32 @@ void tmp_chatbox::add_chat_room_message_received(const std::string& room,
<< " (room not open)\n";
}
}
bool tmp_chatbox::whisper_window_active(const std::string& name)
bool tchatbox::whisper_window_active(const std::string& name)
{
const tlobby_chat_window& t = open_windows_[active_window_];
return t.name == name && t.whisper == true;
}
bool tmp_chatbox::room_window_active(const std::string& room)
bool tchatbox::room_window_active(const std::string& room)
{
const tlobby_chat_window& t = open_windows_[active_window_];
return t.name == room && t.whisper == false;
}
tlobby_chat_window* tmp_chatbox::room_window_open(const std::string& room,
tlobby_chat_window* tchatbox::room_window_open(const std::string& room,
bool open_new)
{
return search_create_window(room, false, open_new);
}
tlobby_chat_window* tmp_chatbox::whisper_window_open(const std::string& name,
tlobby_chat_window* tchatbox::whisper_window_open(const std::string& name,
bool open_new)
{
return search_create_window(name, true, open_new);
}
tlobby_chat_window* tmp_chatbox::search_create_window(const std::string& name,
tlobby_chat_window* tchatbox::search_create_window(const std::string& name,
bool whisper,
bool open_new)
{
@ -434,7 +434,7 @@ tlobby_chat_window* tmp_chatbox::search_create_window(const std::string& name,
tbutton& close_button = find_widget<tbutton>(row_grid, "close_window", false);
connect_signal_mouse_left_click(close_button,
std::bind(&tmp_chatbox::close_window_button_callback, this, open_windows_.back(),
std::bind(&tchatbox::close_window_button_callback, this, open_windows_.back(),
_3, _4));
if (name == "lobby") {
@ -446,7 +446,7 @@ tlobby_chat_window* tmp_chatbox::search_create_window(const std::string& name,
return nullptr;
}
void tmp_chatbox::close_window_button_callback(tlobby_chat_window& chat_window, bool& handled, bool& halt)
void tchatbox::close_window_button_callback(tlobby_chat_window& chat_window, bool& handled, bool& halt)
{
const int index = std::find_if(open_windows_.begin(), open_windows_.end(), [&chat_window](const tlobby_chat_window& room) {
return room.name == chat_window.name;
@ -458,13 +458,13 @@ void tmp_chatbox::close_window_button_callback(tlobby_chat_window& chat_window,
halt = true;
}
void tmp_chatbox::send_to_server(const ::config& cfg)
void tchatbox::send_to_server(const ::config& cfg)
{
lobby_info().wesnothd_connection().send_data(cfg);
}
void tmp_chatbox::increment_waiting_whsipers(const std::string& name)
void tchatbox::increment_waiting_whsipers(const std::string& name)
{
if (tlobby_chat_window* t = whisper_window_open(name, false)) {
t->pending_messages++;
@ -482,7 +482,7 @@ void tmp_chatbox::increment_waiting_whsipers(const std::string& name)
}
}
void tmp_chatbox::increment_waiting_messages(const std::string& room)
void tchatbox::increment_waiting_messages(const std::string& room)
{
if (tlobby_chat_window* t = room_window_open(room, false)) {
t->pending_messages++;
@ -501,7 +501,7 @@ void tmp_chatbox::increment_waiting_messages(const std::string& room)
}
}
void tmp_chatbox::add_whisper_window_whisper(const std::string& sender,
void tchatbox::add_whisper_window_whisper(const std::string& sender,
const std::string& message)
{
std::stringstream ss;
@ -515,7 +515,7 @@ void tmp_chatbox::add_whisper_window_whisper(const std::string& sender,
append_to_chatbox(ss.str(), t - &open_windows_[0], false);
}
void tmp_chatbox::add_active_window_whisper(const std::string& sender,
void tchatbox::add_active_window_whisper(const std::string& sender,
const std::string& message,
const bool force_scroll)
{
@ -525,7 +525,7 @@ void tmp_chatbox::add_active_window_whisper(const std::string& sender,
append_to_chatbox(ss.str(), force_scroll);
}
void tmp_chatbox::close_window(size_t idx)
void tchatbox::close_window(size_t idx)
{
const tlobby_chat_window& t = open_windows_[idx];
bool active_changed = idx == active_window_;
@ -564,7 +564,7 @@ void tmp_chatbox::close_window(size_t idx)
active_window_changed();
}
void tmp_chatbox::add_room_window_message(const std::string& room,
void tchatbox::add_room_window_message(const std::string& room,
const std::string& sender,
const std::string& message)
{
@ -579,7 +579,7 @@ void tmp_chatbox::add_room_window_message(const std::string& room,
append_to_chatbox(ss.str(), t - &open_windows_[0], false);
}
void tmp_chatbox::add_active_window_message(const std::string& sender,
void tchatbox::add_active_window_message(const std::string& sender,
const std::string& message,
const bool force_scroll)
{
@ -589,7 +589,7 @@ void tmp_chatbox::add_active_window_message(const std::string& sender,
}
room_info* tmp_chatbox::active_window_room()
room_info* tchatbox::active_window_room()
{
const tlobby_chat_window& t = open_windows_[active_window_];
if (t.whisper)
@ -599,7 +599,7 @@ room_info* tmp_chatbox::active_window_room()
void tmp_chatbox::process_room_join(const ::config& data)
void tchatbox::process_room_join(const ::config& data)
{
const std::string& room = data["room"];
const std::string& player = data["player"];
@ -650,7 +650,7 @@ void tmp_chatbox::process_room_join(const ::config& data)
}
}
void tmp_chatbox::process_room_part(const ::config& data)
void tchatbox::process_room_part(const ::config& data)
{
// todo close room window when the part message is sent
const std::string& room = data["room"];
@ -673,7 +673,7 @@ void tmp_chatbox::process_room_part(const ::config& data)
}
}
void tmp_chatbox::process_room_query_response(const ::config& data)
void tchatbox::process_room_query_response(const ::config& data)
{
const std::string& room = data["room"];
const std::string& message = data["message"];
@ -715,7 +715,7 @@ void tmp_chatbox::process_room_query_response(const ::config& data)
}
}
void tmp_chatbox::process_message(const ::config& data, bool whisper /*= false*/)
void tchatbox::process_message(const ::config& data, bool whisper /*= false*/)
{
std::string sender = data["sender"];
DBG_LB << "process message from " << sender << " " << (whisper ? "(w)" : "")
@ -738,7 +738,7 @@ void tmp_chatbox::process_message(const ::config& data, bool whisper /*= false*/
}
}
bool tmp_chatbox::process_network_data(const ::config& data)
bool tchatbox::process_network_data(const ::config& data)
{
if (const ::config& c = data.child("message")) {
@ -764,13 +764,13 @@ bool tmp_chatbox::process_network_data(const ::config& data)
// }---------- DEFINITION ---------{
tmp_chatbox_definition::tmp_chatbox_definition(const config& cfg)
tchatbox_definition::tchatbox_definition(const config& cfg)
: tcontrol_definition(cfg)
{
load_resolutions<tresolution>(cfg);
}
tmp_chatbox_definition::tresolution::tresolution(const config& cfg)
tchatbox_definition::tresolution::tresolution(const config& cfg)
: tresolution_definition_(cfg), grid()
{
state.push_back(tstate_definition(cfg.child("background")));
@ -786,23 +786,23 @@ tmp_chatbox_definition::tresolution::tresolution(const config& cfg)
namespace implementation
{
tbuilder_mp_chatbox::tbuilder_mp_chatbox(const config& cfg)
tbuilder_chatbox::tbuilder_chatbox(const config& cfg)
: tbuilder_control(cfg)
{
}
twidget* tbuilder_mp_chatbox::build() const
twidget* tbuilder_chatbox::build() const
{
tmp_chatbox* widget = new tmp_chatbox();
tchatbox* widget = new tchatbox();
init_control(widget);
DBG_GUI_G << "Window builder: placed unit preview pane '" << id
<< "' with definition '" << definition << "'.\n";
std::shared_ptr<const tmp_chatbox_definition::tresolution> conf
std::shared_ptr<const tchatbox_definition::tresolution> conf
= std::static_pointer_cast<
const tmp_chatbox_definition::tresolution>(widget->config());
const tchatbox_definition::tresolution>(widget->config());
assert(conf);

View file

@ -37,7 +37,7 @@ class ttext_box;
namespace implementation
{
struct tbuilder_mp_chatbox;
struct tbuilder_chatbox;
}
@ -52,12 +52,12 @@ struct tlobby_chat_window
int pending_messages;
};
class tmp_chatbox : public tcontainer_, public events::chat_handler
class tchatbox : public tcontainer_, public events::chat_handler
{
friend struct implementation::tbuilder_mp_chatbox;
friend struct implementation::tbuilder_chatbox;
public:
tmp_chatbox();
tchatbox();
/** See @ref tcontrol::set_active. */
virtual void set_active(const bool active) override;
@ -253,10 +253,10 @@ public:
// }---------- DEFINITION ---------{
struct tmp_chatbox_definition : public tcontrol_definition
struct tchatbox_definition : public tcontrol_definition
{
explicit tmp_chatbox_definition(const config& cfg);
explicit tchatbox_definition(const config& cfg);
struct tresolution : public tresolution_definition_
{
@ -271,10 +271,10 @@ struct tmp_chatbox_definition : public tcontrol_definition
namespace implementation
{
struct tbuilder_mp_chatbox : public tbuilder_control
struct tbuilder_chatbox : public tbuilder_control
{
public:
explicit tbuilder_mp_chatbox(const config& cfg);
explicit tbuilder_chatbox(const config& cfg);
using tbuilder_control::build;