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>2008-10-05 19:05:50 +0000
committerStijn Buys <ingar@osirion.org>2008-10-05 19:05:50 +0000
commit9c3baab33a0fa48e7379f0485116452779a1cd37 (patch)
tree12f76da066d4fe7e062ff9cf33dd75fd80e0154e /src/client
parenta8c367416c28edb47c8f8c447b515cca4080adc2 (diff)
interface with ui library
Diffstat (limited to 'src/client')
-rw-r--r--src/client/Makefile.am4
-rw-r--r--src/client/client.cc6
-rw-r--r--src/client/video.cc7
-rw-r--r--src/client/view.cc171
4 files changed, 110 insertions, 78 deletions
diff --git a/src/client/Makefile.am b/src/client/Makefile.am
index b3261b5..09046d9 100644
--- a/src/client/Makefile.am
+++ b/src/client/Makefile.am
@@ -14,5 +14,5 @@ libclient_la_LDFLAGS = -avoid-version -no-undefined $(GL_LIBS) $(LIBSDL_LIBS)
noinst_HEADERS = action.h chat.h client.h console.h input.h joystick.h key.h \
keyboard.h targets.h video.h view.h
-libclient_la_LIBADD = $(top_builddir)/src/render/librender.la \
- $(top_builddir)/src/core/libcore.la
+libclient_la_LIBADD = $(top_builddir)/src/core/libcore.la \
+ $(top_builddir)/src/render/librender.la $(top_builddir)/src/ui/libui.la
diff --git a/src/client/client.cc b/src/client/client.cc
index ca88f88..b218166 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -21,6 +21,7 @@
#include "core/core.h"
#include "core/zone.h"
#include "render/render.h"
+#include "ui/ui.h"
namespace client
{
@@ -105,6 +106,9 @@ void Client::init(int count, char **arguments)
// initialize SDL, but do not initialize any subsystems
SDL_Init(0);
+ // initialize user interface
+ ui::init();
+
// Initialize the video subsystem
if (!video::init()) {
quit(1);
@@ -199,6 +203,8 @@ void Client::shutdown()
video::shutdown();
+ ui::shutdown();
+
core::Application::shutdown();
quit(0);
diff --git a/src/client/video.cc b/src/client/video.cc
index ef1f82e..4046260 100644
--- a/src/client/video.cc
+++ b/src/client/video.cc
@@ -20,6 +20,7 @@
#include "core/core.h"
#include "filesystem/filesystem.h"
#include "sys/sys.h"
+#include "ui/ui.h"
#include <SDL/SDL.h>
@@ -70,6 +71,12 @@ void reset()
// recalculate the video aspect
render::Camera::set_aspect(width, height);
+ // resize user interface
+ if (ui::root()) {
+ ui::root()->set_size((float) width, (float) height);
+ ui::root()->resize_event();
+ }
+
// reset the view
view::reset();
}
diff --git a/src/client/view.cc b/src/client/view.cc
index 03ce42b..2667938 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -22,6 +22,7 @@
#include "core/core.h"
#include "math/mathlib.h"
#include "sys/sys.h"
+#include "ui/ui.h"
namespace client
{
@@ -578,7 +579,7 @@ void draw_status()
void draw_cursor()
{
- if (!core::localcontrol() || console()->visible())
+ if (console()->visible())
return;
float angle = 0;
@@ -588,83 +589,92 @@ void draw_cursor()
bool cursor_animated = false;
math::Color color(1.0, 0.5);
- if (render::Camera::mode() == render::Camera::Overview) {
- render::Textures::bind("bitmaps/pointers/aim");
+ if(ui::root()->active()) {
+ render::Textures::bind("bitmaps/pointers/pointer");
- } else {
- // draw center cursor in Cockpit and Track mode
- if ((input::mouse_control || input::joystick_control) &&
- (render::Camera::mode() == render::Camera::Cockpit || render::Camera::mode() == render::Camera::Track)) {
-
- if (ui_pointercolor) {
- std::stringstream colorstr(ui_pointercolor->str());
- colorstr >> color;
- }
-
- render::Textures::bind("bitmaps/pointers/center");
- float cx = (video::width - pointer_size) /2;
- float cy = (video::height - pointer_size) /2;
-
- render::gl::color(color);
- render::gl::begin(render::gl::Quads);
-
- glTexCoord2f(0,0 );
- render::gl::vertex(cx,cy,0.0f);
-
- glTexCoord2f(1, 0);
- render::gl::vertex(cx+pointer_size, cy, 0.0f);
-
- glTexCoord2f(1, 1);
- render::gl::vertex(cx+pointer_size, cy+pointer_size, 0.0f);
-
- glTexCoord2f(0, 1);
- render::gl::vertex(cx, cy+pointer_size, 0.0f);
-
- render::gl::end();
- }
-
- if (targets::hover()) {
-
- if (ui_pointerhovercolor) {
- std::stringstream colorstr(ui_pointerhovercolor->str());
- colorstr >> color;
- }
- render::Textures::bind("bitmaps/pointers/target");
-
- cursor_animated = true;
-
- if (input::joystick_lastmoved_time() > input::mouse_lastmoved_time()) {
- x = (video::width - pointer_size) /2;
- y = (video::height - pointer_size) /2;
- }
-
- } else if (input::mouse_control) {
-
- if (ui_pointercolor) {
- std::stringstream colorstr(ui_pointercolor->str());
- colorstr >> color;
- }
-
- render::Textures::bind("bitmaps/pointers/control");
-
- if (!input::mouse_deadzone) {
- x = input::mouse_position_x() - (pointer_size /2);
- y = input::mouse_position_y() - (pointer_size /2);
-
- } else {
- x = (video::width - pointer_size) /2;
- y = (video::height - pointer_size) /2;
- }
+ } else if (core::localcontrol()) {
+ if (render::Camera::mode() == render::Camera::Overview) {
+ render::Textures::bind("bitmaps/pointers/aim");
+
} else {
- if ((input::joystick_lastmoved_time() > input::mouse_lastmoved_time()) && (render::Camera::mode() == render::Camera::Cockpit || render::Camera::mode() == render::Camera::Track)) {
- color.assign(1.0, 0.0);
+ // draw center cursor in Cockpit and Track mode
+ if ((input::mouse_control || input::joystick_control) &&
+ (render::Camera::mode() == render::Camera::Cockpit || render::Camera::mode() == render::Camera::Track)) {
+
+ if (ui_pointercolor) {
+ std::stringstream colorstr(ui_pointercolor->str());
+ colorstr >> color;
+ }
+
+ render::Textures::bind("bitmaps/pointers/center");
+ float cx = (video::width - pointer_size) /2;
+ float cy = (video::height - pointer_size) /2;
+
+ render::gl::color(color);
+ render::gl::begin(render::gl::Quads);
+
+ glTexCoord2f(0,0 );
+ render::gl::vertex(cx,cy,0.0f);
+
+ glTexCoord2f(1, 0);
+ render::gl::vertex(cx+pointer_size, cy, 0.0f);
+
+ glTexCoord2f(1, 1);
+ render::gl::vertex(cx+pointer_size, cy+pointer_size, 0.0f);
+
+ glTexCoord2f(0, 1);
+ render::gl::vertex(cx, cy+pointer_size, 0.0f);
+
+ render::gl::end();
+ }
+
+ if (targets::hover()) {
+
+ if (ui_pointerhovercolor) {
+ std::stringstream colorstr(ui_pointerhovercolor->str());
+ colorstr >> color;
+ }
+ render::Textures::bind("bitmaps/pointers/target");
+
+ cursor_animated = true;
+
+ if (input::joystick_lastmoved_time() > input::mouse_lastmoved_time()) {
+ x = (video::width - pointer_size) /2;
+ y = (video::height - pointer_size) /2;
+ }
+
+ } else if (input::mouse_control) {
+
+ if (ui_pointercolor) {
+ std::stringstream colorstr(ui_pointercolor->str());
+ colorstr >> color;
+ }
+
+ render::Textures::bind("bitmaps/pointers/control");
+
+ if (!input::mouse_deadzone) {
+ x = input::mouse_position_x() - (pointer_size /2);
+ y = input::mouse_position_y() - (pointer_size /2);
+
+ } else {
+ x = (video::width - pointer_size) /2;
+ y = (video::height - pointer_size) /2;
+ }
+
} else {
- color.assign(1.0, 0.5);
+ if ((input::joystick_lastmoved_time() > input::mouse_lastmoved_time()) && (render::Camera::mode() == render::Camera::Cockpit || render::Camera::mode() == render::Camera::Track)) {
+ color.assign(1.0, 0.0);
+ } else {
+ color.assign(1.0, 0.5);
+ }
+ render::Textures::bind("bitmaps/pointers/aim");
}
- render::Textures::bind("bitmaps/pointers/aim");
+
}
+ } else {
+ return;
}
if (cursor_animated) {
@@ -772,13 +782,16 @@ void frame(float seconds)
if (core::application()->load("intro")) {
current_zone = 0;
core::application()->connect("");
- if (!console()->visible())
- console()->toggle();
}
+ } else {
+ /*
+ if (!core::game()->interactive() && !ui::root()->active()) {
+ ui::root()->show_window("main");
+ }
+ */
}
if (core::application()->connected() && core::game()->serverframetime()) {
-
if (core::localplayer()->zone() != current_zone) {
if (current_zone)
clear_zone(current_zone);
@@ -799,14 +812,20 @@ void frame(float seconds)
// switch to orthographic projection to draw the GUI
gl::matrixmode(GL_PROJECTION);
gl::loadidentity();
- glOrtho(0, video::width, video::height, 0, -1024.0f, 1024.0f);
+ glOrtho(0, video::width, video::height, 0, -16.0f, 16.0f);
gl::matrixmode(GL_MODELVIEW);
gl::loadidentity();
+ // draw the user interface
+ gl::color(1.0f, 1.0f, 1.0f, 1.0f);
+ gl::disable(GL_TEXTURE_2D);
+
+ ui::frame();
+
+ // draw the hud - TODO move as much as possible into ui::
gl::enable(GL_BLEND);
gl::enable(GL_TEXTURE_2D);
-
gl::color(1.0f, 1.0f, 1.0f, 1.0f);
if (!core::application()->connected()) {