16 #define GETTEXT_DOMAIN "wesnoth-lib"
41 #define DBG_CHAT_LOG LOG_STREAM(debug, log_chat_log)
42 #define LOG_CHAT_LOG LOG_STREAM(info, log_chat_log)
43 #define WRN_CHAT_LOG LOG_STREAM(warn, log_chat_log)
44 #define ERR_CHAT_LOG LOG_STREAM(err, log_chat_log)
59 , chat_log_history(r.build_chat_log())
76 static const int COUNT_PER_PAGE = 100;
91 int size = chat_log_history.size();
92 return (
size % COUNT_PER_PAGE == 0) ? (
size / COUNT_PER_PAGE)
93 : (
size / COUNT_PER_PAGE) + 1;
108 for(
const auto &
t : make_pair(chat_log_history.begin() + first,
109 chat_log_history.begin() + last))
114 if(!lcfilter.empty()) {
119 if(lcsample.find(lcfilter) == std::string::npos) {
124 const std::string me_prefix =
"/me";
125 const bool is_me =
t.text().compare(0, me_prefix.size(),
128 std::string nick_prefix, nick_suffix;
131 nick_prefix =
"<span color=\"" +
t.color() +
"\">";
132 nick_suffix =
"</span> ";
137 const std::string lbracket = raw ?
"<" :
"<";
138 const std::string rbracket = raw ?
">" :
">";
147 s << nick_prefix << lbracket;
161 s <<
t.text().substr(3);
163 s << rbracket << nick_suffix;
166 s << rbracket << nick_suffix;
180 std::ostringstream
s;
181 stream_log(
s, first, last);
194 std::ostringstream
s;
195 stream_log(
s, first, last,
true);
214 LOG_CHAT_LOG <<
"Entering chat_log::controller::next_page";
221 LOG_CHAT_LOG <<
"Exiting chat_log::controller::next_page";
226 LOG_CHAT_LOG <<
"Entering chat_log::controller::previous_page";
233 LOG_CHAT_LOG <<
"Exiting chat_log::controller::previous_page";
238 LOG_CHAT_LOG <<
"Entering chat_log::controller::filter";
246 <<
"Entering chat_log::controller::handle_page_number_changed";
251 <<
"Exiting chat_log::controller::handle_page_number_changed";
262 LOG_CHAT_LOG <<
"Page: " << page + 1 <<
" of " << count_of_pages;
264 const int first = page * page_size;
265 const int last = page < (count_of_pages - 1)
271 return std::pair(first, last);
277 <<
"Entering chat_log::controller::update_view_from_model";
283 if(select_last_page) {
290 const int first = range.first;
291 const int last = range.second;
293 bool has_next = page + 1 < count_of_pages;
294 bool has_previous = page > 0;
301 <<
"Maximum value of page number slider: " << count_of_pages;
304 std::ostringstream cur_page_text;
305 cur_page_text << (page + 1) <<
'/' << std::max(1, count_of_pages);
309 <<
"Exiting chat_log::controller::update_view_from_model";
369 = find_widget<slider>(&
window,
"page_number",
false,
true);
375 = find_widget<button>(&
window,
"previous_page",
false,
true);
415 view_ = std::make_shared<view>(cfg, r);
void handle_page_number_changed()
void update_view_from_model(bool select_last_page=false)
void handle_copy_button_clicked()
std::pair< int, int > calculate_log_line_range()
static const int COUNT_PER_PAGE
styled_widget * page_label
void populate_chat_message_list(int first, int last)
void chat_message_list_to_clipboard(int first, int last)
void clear_chat_msg_list()
model(const vconfig &c, const replay &r)
const std::vector< chat_msg > & chat_log_history
int count_of_pages() const
void stream_log(std::ostringstream &s, int first, int last, bool raw=false)
styled_widget * msg_label
void handle_copy_button_clicked(window &)
void handle_page_number_changed()
view(const vconfig &cfg, const replay &r)
void bind(window &window)
std::shared_ptr< view > get_view() const
chat_log(const vconfig &cfg, const replay &replay)
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
std::shared_ptr< view > view_
Abstract base class for all modal dialogs.
virtual void set_active(const bool active) override
See styled_widget::set_active.
virtual void set_value(int value) override
Inherited from integer_selector.
void set_value_range(int min_value, int max_value)
virtual int get_value() const override
Inherited from integer_selector.
std::string get_value() const
void set_text_changed_callback(std::function< void(text_box_base *textbox, const std::string text)> cb)
Set the text_changed callback.
A widget that allows the user to input text in single line.
base class of top level items, the only item which needs to store the final canvases to draw on.
void keyboard_capture(widget *widget)
std::string get_chat_timestamp(const std::time_t &t)
A variable-expanding proxy for the config class.
static std::string _(const char *str)
static lg::log_domain log_chat_log("chat_log")
Standard logging facilities (interface).
void copy_to_clipboard(const std::string &text, const bool)
Copies text to the clipboard.
bool available()
Whether wesnoth was compiled with support for a clipboard.
std::string escape_text(const std::string &text)
Escapes the pango markup characters in a text.
REGISTER_DIALOG(editor_edit_unit)
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification &signal)
Connects a signal handler for getting a notification upon modification.
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button click.
std::string lowercase(const std::string &s)
Returns a lowercased version of the string.
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
static map_location::DIRECTION s