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
parenta8c367416c28edb47c8f8c447b515cca4080adc2 (diff)
interface with ui library
-rw-r--r--configure.in2
-rw-r--r--doc/models.html16
-rw-r--r--osirion.kdevelop2
-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
13 files changed, 140 insertions, 94 deletions
diff --git a/configure.in b/configure.in
index 1f6ada3..6dc6ab0 100644
--- a/configure.in
+++ b/configure.in
@@ -290,7 +290,7 @@ AM_CONDITIONAL(BUILD_DEDICATED, test "x$BUILD_CLIENT" = xno)
AC_OUTPUT(Makefile src/Makefile src/audio/Makefile src/auxiliary/Makefile \
src/client/Makefile src/core/Makefile src/filesystem/Makefile src/game/Makefile \
src/game/base/Makefile src/game/intro/Makefile src/math/Makefile src/model/Makefile \
- src/render/Makefile src/server/Makefile src/sys/Makefile)
+ src/render/Makefile src/server/Makefile src/sys/Makefile src/ui/Makefile)
dnl ---------------------------------------------------------------
dnl Configuration summary
diff --git a/doc/models.html b/doc/models.html
index d2dfdba..9e03330 100644
--- a/doc/models.html
+++ b/doc/models.html
@@ -96,9 +96,9 @@
<p>
The limits of map coordinates are placed on +/-16384 map units. Placing
brushes outside these bounds will have unpredictable results. The map
- will be scaled down to make 1024 map units correspond to 1 game unit.
+ will be scaled down to make 1024 units in radiant correspond to 1 game unit.
One game unit corresponds to 100m in-game. 16 units in radiant will
- therefor be 1.5625 meters.
+ therefor correspond to 1.5625 meters in-game.
<p>
The front of a model points along the positive X-axis, the positive
Z-axis is up, the positive Y-axis is left. In GtkRadiant, the nose of
@@ -185,26 +185,26 @@
<p>
The flare value indicates what texture will be used to draw the light.
The flare value is translated to a texture name, <i>bitmaps/fx/flare??</i>.
- The default flare textures is <i>flare00</i>.
+ The default flare texture is <i>flare00</i>.
<p>
The light value is used to determine the size of the flare. The engine
default is 100, resulting in rather large flares.
<p>
The default color is white, but the color can be set through radiant's
- color menu (K key). If the entity option (spawnflag 2) is set, the
+ color menu (K key). If the <i>entity</i> option (spawnflag 2) is set, the
color value will be ignored and the light will be rendered with the
color of the entity it is attached to.
<p>
- The strobe option (spawnflag 1) will create a blinking light. A number
+ The <i>strobe</i> option (spawnflag 1) will create a blinking light. A number
of options can be set to manipulate the flashing behaviour. By default
a strobe light will be half a second on, half a second off.
<p>
- The frequency value changes the number of flashes per second.
+ The <i>frequency</i> value changes the number of flashes per second.
<p>
- The offset value changes the moment the light will be on. Offset is
+ The <i>offset</i> value changes the moment the light will be on. Offset is
measured in seconds.
<p>
- The time value sets the fraction of the time the light will be on.
+ The <i>time</i> value sets the fraction of time the light will be on.
The default is 0.5.
<p>
Lights will only be rendered if the model is within detail range.
diff --git a/osirion.kdevelop b/osirion.kdevelop
index 39c38aa..0f07ee0 100644
--- a/osirion.kdevelop
+++ b/osirion.kdevelop
@@ -21,7 +21,7 @@
</general>
<kdevautoproject>
<general>
- <activetarget>src/game/intro/libintro.la</activetarget>
+ <activetarget>src/ui/libui.la</activetarget>
<useconfiguration>debug</useconfiguration>
</general>
<run>
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");