Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
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
parenta8c367416c28edb47c8f8c447b515cca4080adc2 (diff)
interface with ui library
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-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
-rw-r--r--src/render/Makefile.am4
-rw-r--r--src/render/draw.cc2
-rw-r--r--src/render/gl.cc10
-rw-r--r--src/render/gl.h5
-rw-r--r--src/render/textures.cc1
10 files changed, 130 insertions, 84 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index aad662b..738bcaa 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -4,8 +4,8 @@ SUFFIXES = .rc
.rc.o:
windres $< -o $@
-SUBDIRS = sys auxiliary math filesystem model core server audio render client \
- game
+SUBDIRS = sys math auxiliary filesystem model core server audio render ui \
+ client game
noinst_HEADERS = config.h
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()) {
diff --git a/src/render/Makefile.am b/src/render/Makefile.am
index 27ad8bb..dd2f5f8 100644
--- a/src/render/Makefile.am
+++ b/src/render/Makefile.am
@@ -10,6 +10,6 @@ endif
librender_la_LDFLAGS = -avoid-version -no-undefined @GL_LIBS@
librender_la_LIBADD = $(top_builddir)/src/math/libmath.la
librender_la_SOURCES = camera.cc draw.cc dust.cc gl.cc image.cc jpgfile.cc \
- pngfile.cc render.cc text.cc textures.cc tga.cc
+ pngfile.cc primitives.cc render.cc text.cc textures.cc tga.cc
noinst_HEADERS = camera.h draw.h dust.h gl.h image.h render.h text.h textures.h \
- tga.h pngfile.h jpgfile.h
+ tga.h pngfile.h jpgfile.h primitives.h
diff --git a/src/render/draw.cc b/src/render/draw.cc
index c74f65f..6de398a 100644
--- a/src/render/draw.cc
+++ b/src/render/draw.cc
@@ -749,7 +749,7 @@ void draw_pass_model_fx(float elapsed)
math::Axis flare_axis;
- size_t circle_texture = Textures::load("bitmaps/fx/circle00");
+ size_t circle_texture = Textures::load("bitmaps/fx/circle01");
size_t current_texture = Textures::bind("bitmaps/fx/flare00");
gl::enable(GL_TEXTURE_2D);
diff --git a/src/render/gl.cc b/src/render/gl.cc
index 5540af0..47a0420 100644
--- a/src/render/gl.cc
+++ b/src/render/gl.cc
@@ -7,7 +7,7 @@
#include "render/gl.h"
#include "math/matrix4f.h"
-
+using math::Vector2f;
using math::Vector3f;
using math::Color;
@@ -120,6 +120,14 @@ void scale(const float x, const float y, const float z) {
glScalef(x, y, z);
}
+void vertex(const Vector2f& vector) {
+ glVertex2fv(vector.ptr());
+}
+
+void vertex(const float x, const float y) {
+ glVertex2f(x, y);
+}
+
void vertex(const Vector3f& vector) {
glVertex3fv(vector.ptr());
}
diff --git a/src/render/gl.h b/src/render/gl.h
index fb8bdf2..6e32e35 100644
--- a/src/render/gl.h
+++ b/src/render/gl.h
@@ -10,6 +10,7 @@
#include "GL/gl.h"
#include "GL/glu.h"
+#include "math/vector2f.h"
#include "math/vector3f.h"
#include "math/matrix4f.h"
#include "math/axis.h"
@@ -105,6 +106,10 @@ namespace gl
void vertex(const float x, const float y, const float z);
+ void vertex(const math::Vector2f& vector);
+
+ void vertex(const float x, const float y);
+
/// glNormal
void normal(const math::Vector3f & vector);
diff --git a/src/render/textures.cc b/src/render/textures.cc
index b6b7f05..bf0cc84 100644
--- a/src/render/textures.cc
+++ b/src/render/textures.cc
@@ -44,6 +44,7 @@ void Textures::init()
load("bitmaps/loader");
// crosshairs
+ load("bitmaps/pointers/pointer");
load("bitmaps/pointers/aim");
load("bitmaps/pointers/center");
load("bitmaps/pointers/control");