Skip to content

Commit

Permalink
gui2/tchat_log: Start dialog displaying the last chat log page
Browse files Browse the repository at this point in the history
  • Loading branch information
irydacea committed Jun 5, 2015
1 parent dd36c4e commit 292b09e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 2 additions & 0 deletions changelog
Expand Up @@ -15,6 +15,8 @@ Version 1.12.2+dev:
* Fixed unit bars, ellipses, and orbs disappearing for individual units in
replay mode when using Skip Animations/Quick Replays if they moved without
attacking or otherwise switching to a new animation.
* Chat Log dialog now starts on the last log page when there are multiple
pages.
* Miscellaneous and bug fixes:
* Fixed bug #23445: set default build type in cmake to "Release" to ensure
that the game is not unoptimized
Expand Down
2 changes: 2 additions & 0 deletions players_changelog
Expand Up @@ -13,6 +13,8 @@ Version 1.12.2+dev:
* Fixed unit bars, ellipses, and orbs disappearing for individual units in
replay mode when using Skip Animations/Quick Replays if they moved without
attacking or otherwise switching to a new animation.
* Chat Log dialog now starts on the last log page when there are multiple
pages.


Version 1.12.2:
Expand Down
11 changes: 7 additions & 4 deletions src/gui/dialogs/chat_log.cpp
Expand Up @@ -286,17 +286,20 @@ class tchat_log::controller
return std::make_pair(first, last);
}

void update_view_from_model()
void update_view_from_model(bool select_last_page = false)
{
LOG_CHAT_LOG << "Entering tchat_log::controller::update_view_from_model"
<< std::endl;
model_.msg_label->set_use_markup(true);
int size = model_.chat_log_history.size();
LOG_CHAT_LOG << "Number of chat messages: " << size << std::endl;
// get page
const int page = model_.page;
// determine count of pages
const int count_of_pages = std::max(1, model_.count_of_pages());
if(select_last_page) {
model_.page = count_of_pages - 1;
}
// get page
const int page = model_.page;
// determine first and last
const std::pair<int, int>& range = calculate_log_line_range();
const int first = range.first;
Expand Down Expand Up @@ -345,7 +348,7 @@ class tchat_log::view
void pre_show(CVideo& /*video*/, twindow& window)
{
LOG_CHAT_LOG << "Entering tchat_log::view::pre_show" << std::endl;
controller_.update_view_from_model();
controller_.update_view_from_model(true);
window.invalidate_layout(); // workaround for assertion failure
LOG_CHAT_LOG << "Exiting tchat_log::view::pre_show" << std::endl;
}
Expand Down

0 comments on commit 292b09e

Please sign in to comment.