From d0b6e591fbaf3db5fc9898e75913e57a3c32169a Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 9 Nov 2013 13:31:30 +0000 Subject: Update player statistics while the reputation menu is open. --- src/client/reputationwindow.cc | 21 +++++++++++++++++++++ src/client/reputationwindow.h | 11 ++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) (limited to 'src/client') diff --git a/src/client/reputationwindow.cc b/src/client/reputationwindow.cc index bc1217c..2d15319 100644 --- a/src/client/reputationwindow.cc +++ b/src/client/reputationwindow.cc @@ -85,6 +85,9 @@ private: ReputationWindow::ReputationWindow(ui::Widget *parent) : ui::Window(parent) { + reputationwindow_info = 0; + reputationwindow_timestamp = 0; + // window title reputationwindow_titlelabel = new ui::Label(this); reputationwindow_titlelabel->set_label("title"); @@ -181,8 +184,11 @@ void ReputationWindow::set_info(const core::Info *info) { reputationwindow_infotext.clear(); reputationwindow_targetlabel->clear(); + reputationwindow_info = info; if (!info) { + reputationwindow_timestamp = 0; + // player name reputationwindow_targetlabel->set_text(core::localplayer()->name()); @@ -248,6 +254,7 @@ void ReputationWindow::set_info(const core::Info *info) core::game()->request_info(info->id()); reputationwindow_targetlabel->set_text(info->name()); + reputationwindow_timestamp = info->timestamp(); for (core::Info::Text::const_iterator it = info->text().begin(); it != info->text().end(); it++) { reputationwindow_infotext.push_back((*it)); @@ -255,6 +262,20 @@ void ReputationWindow::set_info(const core::Info *info) } } +void ReputationWindow::draw() +{ + if (!reputationwindow_info) { + // update player info + set_info(0); + + } else if (reputationwindow_timestamp != reputationwindow_info->timestamp()) { + // update faction info if we received updates from the server + set_info(reputationwindow_info); + } + + ui::Window::draw(); +} + void ReputationWindow::resize() { const float padding = ui::root()->font_large()->height(); diff --git a/src/client/reputationwindow.h b/src/client/reputationwindow.h index ca0c56b..b6c95c7 100644 --- a/src/client/reputationwindow.h +++ b/src/client/reputationwindow.h @@ -39,7 +39,12 @@ public: * */ virtual void show(); -protected: +protected: + /** + * @brief draw event handler + * */ + virtual void draw(); + /** * @brief resize event handler * */ @@ -73,6 +78,10 @@ private: ui::Widget *reputationwindow_pane_right; + const core::Info *reputationwindow_info; + + unsigned long reputationwindow_timestamp; + }; // class ReputationWindow } // namespace client -- cgit v1.2.3