Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/client')
-rw-r--r--src/client/Makefile.am8
-rw-r--r--src/client/client.cc37
-rw-r--r--src/client/client.h8
-rw-r--r--src/client/mainwindow.cc103
-rw-r--r--src/client/mainwindow.h50
-rw-r--r--src/client/video.cc28
-rw-r--r--src/client/video.h3
-rw-r--r--src/client/worldview.cc101
-rw-r--r--src/client/worldview.h49
9 files changed, 194 insertions, 193 deletions
diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index c6d0ada..1ac7d54 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -23,6 +23,7 @@ noinst_HEADERS = \
joystick.h \
key.h \
keyboard.h \
+ mainwindow.h \
map.h \
notifications.h \
playerview.h \
@@ -31,8 +32,7 @@ noinst_HEADERS = \
targets.h \
testmodelview.h \
trademenu.h \
- video.h \
- worldview.h
+ video.h
libclient_la_SOURCES = \
action.cc \
@@ -49,6 +49,7 @@ libclient_la_SOURCES = \
joystick.cc \
key.cc \
keyboard.cc \
+ mainwindow.cc \
map.cc \
notifications.cc \
playerview.cc \
@@ -57,8 +58,7 @@ libclient_la_SOURCES = \
targets.cc \
testmodelview.cc \
trademenu.cc \
- video.cc \
- worldview.cc
+ video.cc
libclient_la_CFLAGS = $(LIBSDL_CFLAGS) $(GL_CFLAGS)
diff --git a/src/client/client.cc b/src/client/client.cc
index 7d4b7e6..4b27eb7 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -62,7 +62,7 @@ void Client::quit(int status)
void Client::init(int count, char **arguments)
{
- client_worldview = 0;
+ client_mainwindow = 0;
con_print << "^BInitializing client..." << std::endl;
// initialize core
@@ -103,8 +103,9 @@ void Client::init(int count, char **arguments)
// initialize user interface
ui::init();
- client_worldview = new WorldView(ui::root());
+ client_mainwindow = new MainWindow(ui::root());
+ // FIXME needs to be a mainwindow child
client_testmodelview = new TestModelView(ui::root());
client_testmodelview->hide();
@@ -308,10 +309,10 @@ void Client::notify_connect()
video::set_loader_message();
video::frame_loader();
- worldview()->clear();
+ mainwindow()->clear();
ui::root()->hide_menu();
- video::set_caption();
+ //video::set_caption();
}
void Client::notify_disconnect()
@@ -320,9 +321,9 @@ void Client::notify_disconnect()
render::reset();
input::reset();
- worldview()->clear();
+ mainwindow()->clear();
- video::set_caption();
+ //video::set_caption();
}
void Client::notify_zonechange()
@@ -384,8 +385,8 @@ void Client::notify_message(const core::Message::Channel channel, const std::str
break;
}
- if (worldview()) {
- worldview()->event_text(message);
+ if (mainwindow()) {
+ mainwindow()->event_text(message);
}
con_print << message << std::endl;
@@ -489,29 +490,29 @@ void Client::func_ui(std::string const &args)
void Client::func_ui_chat(std::string const &args)
{
- if (client()->connected() && client()->worldview()->playerview()->visible()) {
- client()->worldview()->playerview()->toggle_chat();
+ if (client()->connected() && client()->mainwindow()->playerview()->visible()) {
+ client()->mainwindow()->playerview()->toggle_chat();
}
}
void Client::func_ui_chatbar(std::string const &args)
{
- if (client()->connected() && client()->worldview()->playerview()->visible()) {
- client()->worldview()->playerview()->toggle_chatbar();
+ if (client()->connected() && client()->mainwindow()->playerview()->visible()) {
+ client()->mainwindow()->playerview()->toggle_chatbar();
}
}
void Client::func_ui_inventory(std::string const &args)
{
- if (client()->connected() && client()->worldview()->playerview()->visible()) {
- client()->worldview()->playerview()->toggle_inventory();
+ if (client()->connected() && client()->mainwindow()->playerview()->visible()) {
+ client()->mainwindow()->playerview()->toggle_inventory();
}
}
void Client::func_ui_map(std::string const &args)
{
- if (client()->connected() && client()->worldview()->playerview()->visible()) {
- client()->worldview()->playerview()->toggle_map();
+ if (client()->connected() && client()->mainwindow()->playerview()->visible()) {
+ client()->mainwindow()->playerview()->toggle_map();
}
}
@@ -536,8 +537,8 @@ void Client::func_ui_menu(std::string const &args)
// entity menus
void Client::func_view(std::string const &args)
{
- if (client()->worldview()) {
- client()->worldview()->playerview()->show_menu(args);
+ if (client()->mainwindow()) {
+ client()->mainwindow()->playerview()->show_menu(args);
}
}
diff --git a/src/client/client.h b/src/client/client.h
index 42b87e6..5b869ad 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -13,7 +13,7 @@
#include "client/clientext.h"
#include "client/soundext.h"
#include "client/testmodelview.h"
-#include "client/worldview.h"
+#include "client/mainwindow.h"
#include "render/renderext.h"
/// client part of the engine
@@ -61,8 +61,8 @@ public:
virtual void notify_disconnect();
/// the main client widget
- inline WorldView *worldview() {
- return client_worldview;
+ inline MainWindow *mainwindow() {
+ return client_mainwindow;
}
/// model test widget
@@ -102,7 +102,7 @@ private:
static void func_menu(std::string const &args);
static void func_view(std::string const &args);
- WorldView *client_worldview;
+ MainWindow *client_mainwindow;
TestModelView *client_testmodelview;
unsigned long previous_timestamp;
diff --git a/src/client/mainwindow.cc b/src/client/mainwindow.cc
new file mode 100644
index 0000000..91cb9b4
--- /dev/null
+++ b/src/client/mainwindow.cc
@@ -0,0 +1,103 @@
+/*
+ client/mainwindow.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/mainwindow.h"
+#include "client/video.h"
+#include "ui/ui.h"
+
+namespace client
+{
+
+MainWindow::MainWindow(ui::Widget *parent) : ui::Widget(parent)
+{
+ set_label("mainwindow");
+ set_border(false);
+ set_background(false);
+
+ // add child widgets
+ mainwindow_devinfo = new DevInfoWidget(this);
+ mainwindow_statsinfo = new StatsInfoWidget(this);
+ mainwindow_keyinfo = new KeyInfoWidget(this);
+ mainwindow_clock = new ClockInfoWidget(this);
+
+ mainwindow_playerview = new PlayerView(this);
+ mainwindow_playerview->raise();
+ mainwindow_playerview->hide();
+}
+
+MainWindow::~MainWindow()
+{
+
+}
+
+void MainWindow::resize()
+{
+ set_size(parent()->size());
+
+ //const float largemargin = ui::UI::elementsize.width() * 0.25
+ const float smallmargin = ui::UI::elementsize.height();
+
+ // resize player view
+ mainwindow_playerview->set_size(size());
+
+ // reposition devinfo widget
+ mainwindow_devinfo->set_size(font()->width()*32, font()->height()*5);
+ mainwindow_devinfo->set_location(smallmargin, smallmargin);
+
+ // reposition stats widget
+ mainwindow_statsinfo->set_size(font()->width()*12, font()->height()*5);
+ mainwindow_statsinfo->set_location(width() - mainwindow_statsinfo->width() - smallmargin, smallmargin);
+
+ // reposition clock
+ mainwindow_clock->set_size(font()->width()*7, font()->height());
+ mainwindow_clock->set_location(width() - mainwindow_clock->width() - smallmargin, mainwindow_statsinfo->bottom() + smallmargin);
+
+ // reposition keypress widget
+ mainwindow_keyinfo->set_size(font()->width()*12, font()->height()*1);
+ mainwindow_keyinfo->set_location(width() - mainwindow_keyinfo->width() - smallmargin,
+ height() - mainwindow_keyinfo->height() - smallmargin);
+}
+
+void MainWindow::clear()
+{
+ mainwindow_playerview->clear();
+}
+
+void MainWindow::event_text(const std::string & text)
+{
+ mainwindow_playerview->event_text(text);
+}
+
+void MainWindow::draw()
+{
+ // the mianwindow is only drawn when the application is connected
+ // and the loader screen is not shown
+ // FIXME the mainwindow should alway be visible, except in the loader screen
+
+ mainwindow_devinfo->set_visible(draw_devinfo->value() ? true : false);
+ mainwindow_statsinfo->set_visible(draw_stats->value() ? true : false);
+ mainwindow_keyinfo->set_visible(draw_keypress->value() ? true : false);
+ if (draw_clock->value() <= 0) {
+ mainwindow_clock->set_mode(ClockInfoWidget::ClockOff);
+ } else if (draw_clock->value() >= 2) {
+ mainwindow_clock->set_mode(ClockInfoWidget::Clock12Hours);
+ } else {
+ mainwindow_clock->set_mode(ClockInfoWidget::Clock24Hours);
+ }
+
+
+ // FIXME - either draw one of the menus or draw the playerview
+ if (ui::root()->active() || !core::game()->interactive() || !core::localcontrol() || (core::localplayer()->view() && !core::localplayer()->view()->menus().size())) {
+ mainwindow_playerview->hide();
+ } else {
+ mainwindow_playerview->show();
+ mainwindow_playerview->set_focus();
+
+ }
+}
+
+}
diff --git a/src/client/mainwindow.h b/src/client/mainwindow.h
new file mode 100644
index 0000000..12ea23f
--- /dev/null
+++ b/src/client/mainwindow.h
@@ -0,0 +1,50 @@
+/*
+ client/mainwindow.h
+ This file is part of the Osirion project and is distributed under
+ the terms and conditions of the GNU General Public License version 2
+*/
+
+#ifndef __INCLUDED_CLIENT_MAINWINDOW_H__
+#define __INCLUDED_CLIENT_MAINWINDOW_H__
+
+#include "ui/window.h"
+
+#include "client/playerview.h"
+#include "client/infowidget.h"
+
+namespace client
+{
+
+/// the world view when connected
+class MainWindow : public ui::Widget
+{
+public:
+ MainWindow(ui::Widget *parent = 0);
+ virtual ~MainWindow();
+
+ void clear();
+
+ void event_text(const std::string & text);
+
+ inline PlayerView *playerview() {
+ return mainwindow_playerview;
+ }
+
+protected:
+ virtual void draw();
+ virtual void resize();
+
+private:
+ DevInfoWidget *mainwindow_devinfo;
+ StatsInfoWidget *mainwindow_statsinfo;
+ KeyInfoWidget *mainwindow_keyinfo;
+ ClockInfoWidget *mainwindow_clock;
+ Notifications *mainwindow_notify;
+ PlayerView *mainwindow_playerview;
+
+};
+
+}
+
+#endif // __INCLUDED_CLIENT_MAINWINDOW_H__
+
diff --git a/src/client/video.cc b/src/client/video.cc
index a610b86..6be4ff6 100644
--- a/src/client/video.cc
+++ b/src/client/video.cc
@@ -59,6 +59,16 @@ const int height_default = 768;
std::string loader_message;
bool is_loading = false;
+void set_caption()
+{
+ // set window caption
+ std::string window_title(core::name());
+ window_title += ' ';
+ window_title.append(core::version());
+
+ SDL_WM_SetCaption(window_title.c_str(), core::name().c_str());
+}
+
bool init()
{
con_print << "^BInitializing video..." << std::endl;
@@ -237,16 +247,6 @@ bool init()
return true;
}
-void set_caption()
-{
- // set window caption
- std::string window_title(core::name());
- window_title += ' ';
- window_title.append(core::version());
-
- SDL_WM_SetCaption(window_title.c_str(), core::name().c_str());
-}
-
void resize(int w, int h)
{
if (fullscreen)
@@ -299,7 +299,7 @@ void set_cursor()
ui::root()->set_pointer();
- } else if (client()->worldview()->playerview()->map()->hover()) {
+ } else if (client()->mainwindow()->playerview()->map()->hover()) {
ui::root()->set_pointer("pointer");
@@ -411,15 +411,15 @@ void frame(float elapsed)
render::draw_target(targets::current());
render::Camera::ortho();
- client()->worldview()->show();
+ client()->mainwindow()->show();
} else {
draw_loader();
- client()->worldview()->hide();
+ client()->mainwindow()->hide();
}
} else {
- client()->worldview()->hide();
+ client()->mainwindow()->hide();
render::Camera::ortho();
}
diff --git a/src/client/video.h b/src/client/video.h
index 61cb9df..0a3ed73 100644
--- a/src/client/video.h
+++ b/src/client/video.h
@@ -42,9 +42,6 @@ void set_loader_message(const std::string message);
/// update the loader screen message
void set_loader_message(const char *message = 0);
-/// set the window caption
-void set_caption();
-
} // namespace video
extern core::Cvar *r_width;
diff --git a/src/client/worldview.cc b/src/client/worldview.cc
deleted file mode 100644
index 56ba77e..0000000
--- a/src/client/worldview.cc
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- 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/targeticonbutton.h"
-#include "client/worldview.h"
-#include "client/video.h"
-#include "ui/ui.h"
-
-namespace client
-{
-
-WorldView::WorldView(ui::Widget *parent) : 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_clock = new ClockInfoWidget(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 clock
- view_clock->set_size(font()->width()*7, font()->height());
- view_clock->set_location(width() - view_clock->width() - smallmargin, view_statsinfo->bottom() + 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 (draw_clock->value() <= 0) {
- view_clock->set_mode(ClockInfoWidget::ClockOff);
- } else if (draw_clock->value() >= 2) {
- view_clock->set_mode(ClockInfoWidget::Clock12Hours);
- } else {
- view_clock->set_mode(ClockInfoWidget::Clock24Hours);
- }
-
-
- if (ui::root()->active() || !core::game()->interactive() || !core::localcontrol() || (core::localplayer()->view() && !core::localplayer()->view()->menus().size())) {
- view_playerview->hide();
- } else {
- view_playerview->show();
- view_playerview->set_focus();
-
- }
-}
-
-}
diff --git a/src/client/worldview.h b/src/client/worldview.h
deleted file mode 100644
index 3012815..0000000
--- a/src/client/worldview.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- client/worldview.h
- This file is part of the Osirion project and is distributed under
- the terms and conditions of the GNU General Public License version 2
-*/
-
-#ifndef __INCLUDED_CLIENT_WORLDVIEW_H__
-#define __INCLUDED_CLIENT_WORLDVIEW_H__
-
-#include "ui/widget.h"
-#include "client/playerview.h"
-#include "client/infowidget.h"
-
-namespace client
-{
-
-/// the world view when connected
-class WorldView : public ui::Widget
-{
-public:
- WorldView(ui::Widget *parent = 0);
- virtual ~WorldView();
-
- void clear();
-
- void event_text(const std::string & text);
-
- inline PlayerView *playerview() {
- return view_playerview;
- }
-
-protected:
- virtual void draw();
- virtual void resize();
-
-private:
- DevInfoWidget *view_devinfo;
- StatsInfoWidget *view_statsinfo;
- KeyInfoWidget *view_keyinfo;
- ClockInfoWidget *view_clock;
- Notifications *view_notify;
- PlayerView *view_playerview;
-
-};
-
-}
-
-#endif // __INCLUDED_CLIENT_PLAYERVIEW_H__
-