15 #define GETTEXT_DOMAIN "wesnoth-lib" 42 #define DBG_CHAT_LOG LOG_STREAM(debug, log_chat_log) 43 #define LOG_CHAT_LOG LOG_STREAM(info, log_chat_log) 44 #define WRN_CHAT_LOG LOG_STREAM(warn, log_chat_log) 45 #define ERR_CHAT_LOG LOG_STREAM(err, log_chat_log) 62 , chat_log_history(r.build_chat_log())
79 static const int COUNT_PER_PAGE = 100;
94 int size = chat_log_history.size();
95 return (size % COUNT_PER_PAGE == 0) ? (size / COUNT_PER_PAGE)
96 : (size / COUNT_PER_PAGE) + 1;
109 LOG_CHAT_LOG <<
"entering chat_log::model::stream_log\n";
111 for(
const auto &
t : make_pair(chat_log_history.begin() + first,
112 chat_log_history.begin() + last))
117 if(!lcfilter.empty()) {
122 if(lcsample.find(lcfilter) == std::string::npos) {
127 const std::string me_prefix =
"/me";
128 const bool is_me =
t.text().compare(0, me_prefix.size(),
131 std::string nick_prefix, nick_suffix;
134 nick_prefix =
"<span color=\"" +
t.color() +
"\">";
135 nick_suffix =
"</span> ";
140 const std::string lbracket = raw ?
"<" :
"<";
141 const std::string rbracket = raw ?
">" :
">";
150 s << nick_prefix << lbracket;
164 s <<
t.text().substr(3);
166 s << rbracket << nick_suffix;
169 s << rbracket << nick_suffix;
183 std::ostringstream
s;
184 stream_log(s, first, last);
197 std::ostringstream
s;
198 stream_log(s, first, last,
true);
211 LOG_CHAT_LOG <<
"Entering chat_log::controller" << std::endl;
212 LOG_CHAT_LOG <<
"Exiting chat_log::controller" << std::endl;
217 LOG_CHAT_LOG <<
"Entering chat_log::controller::next_page" 225 LOG_CHAT_LOG <<
"Exiting chat_log::controller::next_page" << std::endl;
230 LOG_CHAT_LOG <<
"Entering chat_log::controller::previous_page" 238 LOG_CHAT_LOG <<
"Exiting chat_log::controller::previous_page" 244 LOG_CHAT_LOG <<
"Entering chat_log::controller::filter" << std::endl;
246 LOG_CHAT_LOG <<
"Exiting chat_log::controller::filter" << std::endl;
252 <<
"Entering chat_log::controller::handle_page_number_changed" 258 <<
"Exiting chat_log::controller::handle_page_number_changed" 270 LOG_CHAT_LOG <<
"Page: " << page + 1 <<
" of " << count_of_pages
273 const int first = page * page_size;
274 const int last = page < (count_of_pages - 1)
278 LOG_CHAT_LOG <<
"First " << first <<
", last " << last <<
'\n';
280 return std::make_pair(first, last);
285 LOG_CHAT_LOG <<
"Entering chat_log::controller::update_view_from_model" 289 LOG_CHAT_LOG <<
"Number of chat messages: " << size << std::endl;
292 if(select_last_page) {
299 const int first = range.first;
300 const int last = range.second;
302 bool has_next = page + 1 < count_of_pages;
303 bool has_previous = page > 0;
310 << count_of_pages << std::endl;
313 std::ostringstream cur_page_text;
314 cur_page_text << (page + 1) <<
'/' << std::max(1, count_of_pages);
317 LOG_CHAT_LOG <<
"Exiting chat_log::controller::update_view_from_model" 343 LOG_CHAT_LOG <<
"Entering chat_log::view::pre_show" << std::endl;
344 controller_.update_view_from_model(
true);
345 LOG_CHAT_LOG <<
"Exiting chat_log::view::pre_show" << std::endl;
350 controller_.handle_page_number_changed();
355 controller_.next_page();
360 controller_.previous_page();
365 controller_.filter();
370 controller_.handle_copy_button_clicked();
375 LOG_CHAT_LOG <<
"Entering chat_log::view::bind" << std::endl;
376 model_.
msg_label = find_widget<styled_widget>(&window,
"msg",
false,
true);
378 = find_widget<slider>(&window,
"page_number",
false,
true);
384 = find_widget<button>(&window,
"previous_page",
false,
true);
388 model_.
next_page = find_widget<button>(&window,
"next_page",
false,
true);
392 model_.
filter = find_widget<text_box>(&window,
"filter",
false,
true);
408 model_.
page_label = find_widget<styled_widget>(&window,
"page_label",
false,
true);
410 LOG_CHAT_LOG <<
"Exiting chat_log::view::bind" << std::endl;
421 LOG_CHAT_LOG <<
"Entering chat_log::chat_log" << std::endl;
422 view_ = std::make_shared<view>(cfg, r);
423 LOG_CHAT_LOG <<
"Exiting chat_log::chat_log" << std::endl;
433 LOG_CHAT_LOG <<
"Entering chat_log::pre_show" << std::endl;
436 LOG_CHAT_LOG <<
"Exiting chat_log::pre_show" << std::endl;
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
void set_text_changed_callback(std::function< void(text_box_base *textbox, const std::string text)> cb)
Set the text_changed callback.
std::shared_ptr< view > view_
void handle_copy_button_clicked(window &)
bool available()
Whether wesnoth was compiled with support for a clipboard.
std::string get_value() const
void chat_message_list_to_clipboard(int first, int last)
static lg::log_domain log_chat_log("chat_log")
std::pair< int, int > calculate_log_line_range()
static std::string _(const char *str)
virtual void pre_show(window &window) override
Inherited from modal_dialog.
styled_widget * msg_label
static const int COUNT_PER_PAGE
Class for a single line text area.
styled_widget * page_label
virtual void set_active(const bool active) override
See styled_widget::set_active.
void populate_chat_message_list(int first, int last)
void set_value_range(int min_value, int max_value)
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification_function &signal)
Connects a signal handler for getting a notification upon modification.
This file contains the settings handling of the widget library.
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal_function &signal)
Connects a signal handler for a left mouse button click.
model(const vconfig &c, const replay &r)
Various uncategorised dialogs.
std::shared_ptr< view > get_view() const
void handle_page_number_changed()
std::string escape_text(const std::string &text)
Escapes the pango markup characters in a text.
void clear_chat_msg_list()
view(const vconfig &cfg, const replay &r)
static map_location::DIRECTION s
const std::vector< chat_msg > & chat_log_history
std::string lowercase(const std::string &s)
Returns a lowercased version of the string.
virtual int get_value() const override
Inherited from integer_selector.
std::string get_chat_timestamp(const std::time_t &t)
void update_view_from_model(bool select_last_page=false)
void bind(window &window)
void copy_to_clipboard(const std::string &text, const bool)
Copies text to the clipboard.
void stream_log(std::ostringstream &s, int first, int last, bool raw=false)
chat_log(const vconfig &cfg, const replay &replay)
A slider is a control that can select a value by moving a grip on a groove.
A variable-expanding proxy for the config class.
Standard logging facilities (interface).
virtual void set_value(int value) override
Inherited from integer_selector.
void handle_page_number_changed()
void handle_copy_button_clicked()
base class of top level items, the only item which needs to store the final canvases to draw on...
int count_of_pages() const