Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/client/reputationwindow.cc21
-rw-r--r--src/client/reputationwindow.h11
2 files changed, 31 insertions, 1 deletions
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