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/view.cc')
-rw-r--r--src/client/view.cc170
1 files changed, 54 insertions, 116 deletions
diff --git a/src/client/view.cc b/src/client/view.cc
index a8d9c4f..22d39a7 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -38,7 +38,7 @@ core::Cvar *draw_keypress = 0;
core::Cvar *ui_pointercolor = 0;
core::Cvar *ui_pointerhovercolor = 0;
-const float pointer_size = 48.0f;
+unsigned long previousframe = 0;
void time_to_stream(std::stringstream &str, float time)
{
@@ -127,7 +127,7 @@ void Stats::draw()
if (core::game()) {
textstream << "^Ntime ^B";
- time_to_stream(textstream, core::game()->clientframetime());
+ time_to_stream(textstream, core::game()->time());
}
textstream << std::setfill(' ') << "\n";
@@ -226,7 +226,7 @@ void View::resize()
height() - view_keypress->height() - font()->height() * 0.5f);
// reposition center
- view_center->set_size(pointer_size, pointer_size);
+ view_center->set_size(ui::pointer_size, ui::pointer_size);
view_center->set_location((size() - view_center->size()) * 0.5f);
view_center->set_color(palette()->pointer());
}
@@ -263,6 +263,8 @@ void init()
ui_pointerhovercolor->set_info("[r g b] mouse pointer hover color");
targets::init();
+
+ previousframe = 0;
}
void shutdown()
@@ -366,9 +368,9 @@ void draw_entity_offscreen_target(core::Entity *entity, bool is_active_target)
const float r = 16;
const float margin = 24;
- cx = (0.5f - cx) * ((float) video::width - margin*2);
+ cx = (0.5f - cx) * ((float) render::Camera::width() - margin*2);
cx += margin;
- cy = (0.5f - cy) * ((float)video::height - margin*2);
+ cy = (0.5f - cy) * ((float) render::Camera::height() - margin*2);
cy += margin;
render::gl::disable(GL_TEXTURE_2D);
@@ -419,16 +421,15 @@ void draw_entity_target(core::Entity *entity, bool is_active_target)
float t = (render::Camera::frustum_front() + 0.001f) / target.x;
Vector3f center(target *t);
- float cx = video::width * (0.5 - center.y);
- float cy = video::height * (0.5 - center.z * render::Camera::aspect());
+ float cx = render::Camera::width() * (0.5 - center.y);
+ float cy = render::Camera::height() * (0.5 - center.z * render::Camera::aspect());
- if ((cx < 0 ) || (cy < 0) || (cx > video::width) || (cy > video::height)) {
+ if ((cx < 0 ) || (cy < 0) || (cx > render::Camera::width()) || (cy > render::Camera::height())) {
draw_entity_offscreen_target(entity, is_active_target);
return;
}
- const float pointer_size = 48.0f;
- float r = pointer_size;
+ float r = ui::pointer_size;
if (!is_active_target)
r *= 0.5;
@@ -524,7 +525,7 @@ void draw_hud()
statestr << "^FJumping...";
}
- Text::draw(4, video::height - Text::fontheight()*3-4, statestr);
+ Text::draw(4, render::Camera::height() - Text::fontheight()*3-4, statestr);
}
core::Entity *target = targets::current();
@@ -550,28 +551,28 @@ void draw_hud()
strtarget << " --";
}
strtarget << '\n';
- Text::draw(video::width - 4-Text::fontwidth()*32, video::height - Text::fontheight()*2 -4, strtarget);
+ Text::draw(render::Camera::width() - 4-Text::fontwidth()*32, render::Camera::height() - Text::fontheight()*2 -4, strtarget);
y = 3.0f;
}
Text::setcolor('N'); //set normal color
- Text::draw(video::width-4-Text::fontwidth()*32, video::height-Text::fontheight()*y-4, core::localcontrol()->zone()->name());
+ Text::draw(render::Camera::width()-4-Text::fontwidth()*32, render::Camera::height()-Text::fontheight()*y-4, core::localcontrol()->zone()->name());
Textures::bind("bitmaps/hud/thruster_base"); // 316 x 32 bitmap
gl::color(1, 1, 1, 1);
gl::begin(render::gl::Quads);
glTexCoord2f(0, 0);
- gl::vertex(4, video::height - 4 - 32, 0);
+ gl::vertex(4, render::Camera::height() - 4 - 32, 0);
glTexCoord2f(1, 0);
- gl::vertex(4 + 316, video::height - 4 - 32, 0);
+ gl::vertex(4 + 316, render::Camera::height() - 4 - 32, 0);
glTexCoord2f(1, 1);
- gl::vertex(4 + 316, video::height - 4 , 0);
+ gl::vertex(4 + 316, render::Camera::height() - 4 , 0);
glTexCoord2f(0, 1);
- gl::vertex(4, video::height - 4 , 0);
+ gl::vertex(4, render::Camera::height() - 4 , 0);
gl::end();
@@ -594,16 +595,16 @@ void draw_hud()
Textures::bind("bitmaps/hud/thruster_indicator"); // 316 x 32 bitmap
gl::begin(render::gl::Quads);
glTexCoord2f(0, 0);
- gl::vertex(4, video::height - 4 - 32, 0);
+ gl::vertex(4, render::Camera::height() - 4 - 32, 0);
glTexCoord2f(u, 0);
- gl::vertex(4.0f + u * 316.0f, video::height - 4 - 32, 0);
+ gl::vertex(4.0f + u * 316.0f, render::Camera::height() - 4 - 32, 0);
glTexCoord2f(u, 1);
- gl::vertex(4.0f + u * 316.0f, video::height - 4 , 0);
+ gl::vertex(4.0f + u * 316.0f, render::Camera::height() - 4 , 0);
glTexCoord2f(0, 1);
- gl::vertex(4, video::height - 4 , 0);
+ gl::vertex(4, render::Camera::height() - 4 , 0);
gl::end();
}
@@ -613,7 +614,7 @@ void draw_hud()
std::stringstream speedstr;
speedstr << "^B" << roundf(core::localcontrol()->speed() * 100.0f);
- Text::draw( 316+4+10, video::height - 6 -16 - render::Text::fontwidth() /2, speedstr);
+ Text::draw( 316+4+10, render::Camera::height() - 6 -16 - render::Text::fontwidth() /2, speedstr);
Text::setfont("gui", 12, 18);
Text::setcolor('N'); //set normal color
@@ -622,102 +623,45 @@ void draw_hud()
void draw_cursor()
{
- if (client()->console()->visible())
- return;
+ if (client()->console()->visible()) {
+ ui::root()->set_pointer();
- float angle = 0;
-
- float x = (float) input::mouse_position_x() - (pointer_size / 2.0f);
- float y = (float) input::mouse_position_y() - (pointer_size / 2.0f);
- bool cursor_animated = false;
- math::Color color(1.0, 0.5);
-
- if(ui::root()->active()) {
- render::Textures::bind("bitmaps/pointers/pointer");
+ } else if(ui::root()->active()) {
- } else if (core::localcontrol()) {
+ ui::root()->set_pointer("pointer");
- if (render::Camera::mode() == render::Camera::Overview) {
- render::Textures::bind("bitmaps/pointers/aim");
-
- } else {
- 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 ((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");
- }
-
- }
+ } else if (!core::localcontrol()) {
- } else {
- return;
- }
+ ui::root()->set_pointer();
- if (cursor_animated) {
- render::gl::push();
- render::gl::translate(x+pointer_size/2, y+pointer_size/2, 0.0f);
+ } else if (render::Camera::mode() == render::Camera::Overview) {
- angle = core::application()->time()* 0.75f - floorf(core::application()->time() * 0.75f);
- angle *= 360.0f;
- render::gl::rotate(angle, math::Vector3f(0, 0, 1.0f));
- render::gl::translate(-x-pointer_size/2, -y-pointer_size/2, 0.0f);
- }
+ ui::root()->set_pointer("aim");
- render::gl::color(color);
- render::gl::begin(render::gl::Quads);
+ } else if (targets::hover()) {
- glTexCoord2f(0,0 );
- render::gl::vertex(x,y,0.0f);
+ ui::root()->set_pointer("target", ui::Palette::Active, true);
- glTexCoord2f(1, 0);
- render::gl::vertex(x+pointer_size, y, 0.0f);
+ if (input::joystick_lastmoved_time() > input::mouse_lastmoved_time()) {
+ ui::root()->input_mouse(render::Camera::width()/2, render::Camera::height() /2);
+ }
- glTexCoord2f(1, 1);
- render::gl::vertex(x+pointer_size, y+pointer_size, 0.0f);
+ } else if (input::mouse_control) {
- glTexCoord2f(0, 1);
- render::gl::vertex(x, y+pointer_size, 0.0f);
+ ui::root()->set_pointer("control", ui::Palette::Pointer);
- render::gl::end();
+ if (input::mouse_deadzone) {
+ ui::root()->input_mouse(render::Camera::width()/2, render::Camera::height() /2);
+ }
+
+ } else if ((input::joystick_lastmoved_time() > input::mouse_lastmoved_time()) &&
+ (render::Camera::mode() == render::Camera::Cockpit || render::Camera::mode() == render::Camera::Track)) {
+
+ ui::root()->set_pointer();
+
+ } else {
- if (cursor_animated) {
- render::gl::pop();
+ ui::root()->set_pointer("aim", ui::Palette::Foreground);
}
}
@@ -730,7 +674,7 @@ void frame(float elapsed)
render::Stats::clear();
- if (core::application()->connected() && core::game()->serverframetime() && core::localplayer()->zone()) {
+ if (core::application()->connected() && core::game()->time() && core::localplayer()->zone()) {
render::Camera::frame(elapsed);
render::Camera::frustum();
@@ -751,24 +695,18 @@ void frame(float elapsed)
gl::disable(GL_TEXTURE_2D);
gl::enable(GL_BLEND);
+ draw_cursor();
ui::root()->frame();
// draw the hud - TODO move as much as possible into ui::
-
- gl::enable(GL_TEXTURE_2D);
- gl::color(1.0f, 1.0f, 1.0f, 1.0f);
-
- // draw text elements
- if (draw_ui->value()) {
+ if (draw_ui->value() && !ui::root()->active()) {
+ gl::enable(GL_TEXTURE_2D);
+ gl::color(1.0f, 1.0f, 1.0f, 1.0f);
Text::setfont("gui", 12, 18);
// draw the hud
draw_hud();
-
- // draw the mouse cursor
- draw_cursor();
}
-
gl::disable(GL_TEXTURE_2D);
gl::disable(GL_BLEND);