Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-01-26 20:18:22 +0000
committerStijn Buys <ingar@osirion.org>2009-01-26 20:18:22 +0000
commit597b3e0921dd24fa5e224377da4754da93a782c1 (patch)
treea096cf3ade876d09dcdf5501908fe24efc50539f /src/client/worldview.cc
parent60749486f978b8220b707541cf478fc87d8d0b36 (diff)
new widgets to replace the "View" class
Diffstat (limited to 'src/client/worldview.cc')
-rw-r--r--src/client/worldview.cc85
1 files changed, 85 insertions, 0 deletions
diff --git a/src/client/worldview.cc b/src/client/worldview.cc
new file mode 100644
index 0000000..ae16e33
--- /dev/null
+++ b/src/client/worldview.cc
@@ -0,0 +1,85 @@
+/*
+ client/worldview.cc
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
+*/
+
+#include "core/application.h"
+#include "client/worldview.h"
+#include "client/video.h"
+#include "ui/ui.h"
+
+namespace client {
+
+WorldView::WorldView(ui::Widget *parent)
+{
+ set_label("worldview");
+ set_border(false);
+ set_background(false);
+
+ // add child widgets
+ view_devinfo = new DevInfoWidget(this);
+ view_statsinfo = new StatsInfoWidget(this);
+ view_keyinfo = new KeyInfoWidget(this);
+
+ view_playerview = new PlayerView(this);
+ view_playerview->raise();
+ view_playerview->hide();
+}
+
+WorldView::~WorldView()
+{
+
+}
+
+void WorldView::resize()
+{
+ set_size(parent()->size());
+
+ //const float largemargin = ui::UI::elementsize.width() * 0.25
+ const float smallmargin = ui::UI::elementsize.height();
+
+ // resize player view
+ view_playerview->set_size(size());
+
+ // reposition devinfo widget
+ view_devinfo->set_size(font()->width()*32, font()->height()*5);
+ view_devinfo->set_location(smallmargin, smallmargin);
+
+ // reposition stats widget
+ view_statsinfo->set_size(font()->width()*12, font()->height()*5);
+ view_statsinfo->set_location(width() - view_statsinfo->width() - smallmargin, smallmargin);
+
+ // reposition keypress widget
+ view_keyinfo->set_size(font()->width()*12, font()->height()*1);
+ view_keyinfo->set_location(width() - view_keyinfo->width() - smallmargin,
+ height() - view_keyinfo->height() - smallmargin);
+}
+
+void WorldView::clear()
+{
+ view_playerview->clear();
+}
+
+void WorldView::event_text(const std::string & text)
+{
+ view_playerview->event_text(text);
+}
+
+void WorldView::draw()
+{
+ // worldview is only drawn when the application is connected
+ // and the loader screen is not shown
+
+ view_devinfo->set_visible(draw_devinfo->value() ? true : false);
+ view_statsinfo->set_visible(draw_stats->value() ? true : false);
+ view_keyinfo->set_visible(draw_keypress->value() ? true : false);
+
+ if (ui::root()->active() || !core::game()->interactive() || !core::localcontrol()) {
+ view_playerview->hide();
+ } else {
+ view_playerview->show();
+ }
+}
+
+}