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, 56 insertions, 114 deletions
diff --git a/src/client/view.cc b/src/client/view.cc
index 15f70bc..463d254 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -38,6 +38,15 @@ core::Cvar *draw_keypress = 0;
core::Cvar *ui_pointercolor = 0;
core::Cvar *ui_pointerhovercolor = 0;
+const float pointer_size = 48.0f;
+
+void time_to_stream(std::stringstream &str, float time)
+{
+ int minutes = (int) floorf(time / 60.0f);
+ int seconds = (int) floorf( time - (float) minutes* 60.0f);
+ str << std::setfill(' ') << std::setw(4) << minutes << ":" << std::setfill('0') << std::setw(2) << seconds;
+}
+
/* -- DevInfo------------------------------------------------------- */
DevInfo::DevInfo(ui::Widget *parent) : ui::Widget(parent)
@@ -54,24 +63,27 @@ void DevInfo::draw()
core::Entity *target = targets::current();
float d = 0;
- textstream << "^Ntime: ^B" << std::fixed << std::setprecision(4) << client()->time() << '\n';
+ textstream << "^Ncore ^B";
+ time_to_stream(textstream, core::application()->time());
+ textstream << '\n';
if (core::game()) {
- textstream << "^Ngame: ^B" << core::game()->time();
+ textstream << "^Ntime ^B";
+ time_to_stream(textstream, core::game()->time());
}
textstream << '\n';
if (core::localcontrol()) {
textstream << std::fixed << std::setprecision(2)
- << "^Nx:^B" << core::localcontrol()->location().x << " "
- << "^Ny:^B" << core::localcontrol()->location().y << " "
- << "^Nz:^B" << core::localcontrol()->location().z << '\n';
+ << "^Nx ^B" << core::localcontrol()->location().x << " "
+ << "^Ny ^B" << core::localcontrol()->location().y << " "
+ << "^Nz ^B" << core::localcontrol()->location().z << '\n';
- textstream << "^Nthurst:^B " << core::localcontrol()->thrust() << " "
- << "^Nspeed:^B " << core::localcontrol()->speed() << '\n';
+ textstream << "^Nthurst ^B" << core::localcontrol()->thrust() << " "
+ << "^Nspeed ^B" << core::localcontrol()->speed() << '\n';
if (target) {
d = math::distance(core::localcontrol()->location(), target->state()->location()) - target->radius() - core::localcontrol()->radius();
- textstream << "^Ndist:^B " << d << '\n';
+ textstream << "^Ndist ^B" << d << '\n';
}
}
@@ -114,10 +126,8 @@ void Stats::draw()
std::stringstream textstream;
if (core::game()) {
- int minutes = (int) floorf(core::game()->clientframetime() / 60.0f);
- int seconds = (int) floorf( core::game()->clientframetime() - (float) minutes* 60.0f);
-
- textstream << "^Ntime ^B" << std::setfill(' ') << std::setw(3) << minutes << ":" << std::setfill('0') << std::setw(2) << seconds;
+ textstream << "^Ntime ^B";
+ time_to_stream(textstream, core::game()->clientframetime());
}
textstream << std::setfill(' ') << "\n";
@@ -183,10 +193,13 @@ View::View(ui::Widget *parent) : ui::Widget(parent)
draw_keypress->set_info("[bool] draw keypress key names");
// add child widgets
+ view_center = new ui::Bitmap(this, "pointers/center");
view_devinfo = new DevInfo(this);
view_stats = new Stats(this);
view_keypress = new KeyPress(this);
+ view_chat = new Chat(this);
+
// make sure the view is at the bottom of the draw stack
lower();
}
@@ -195,6 +208,10 @@ void View::resize()
{
set_size(parent()->size());
+ // reposition chat widget
+ view_chat->set_size(font()->width()*64, font()->height()*5);
+ view_chat->set_location(font()->width() * 0.5f, height() *0.5f);
+
// reposition devinfo widget
view_devinfo->set_size(font()->width()*32, font()->height()*5);
view_devinfo->set_location(font()->width() * 0.5f, font()->height() * 0.5f);
@@ -207,6 +224,11 @@ void View::resize()
view_keypress->set_size(font()->width()*12, font()->height()*1);
view_keypress->set_location(width() - view_keypress->width() - font()->width() * 0.5,
height() - view_keypress->height() - font()->height() * 0.5f);
+
+ // reposition center
+ view_center->set_size(pointer_size, pointer_size);
+ view_center->set_location((size() - view_center->size()) * 0.5f);
+ view_center->set_color(palette()->pointer());
}
void View::draw()
@@ -214,8 +236,19 @@ void View::draw()
view_devinfo->set_visible(draw_devinfo->value() ? true : false);
view_stats->set_visible(draw_stats->value() ? true : false);
view_keypress->set_visible(draw_keypress->value() ? true : false);
+
+ if (core::localcontrol() && (input::mouse_control || input::joystick_control) &&
+ (render::Camera::mode() == render::Camera::Cockpit || render::Camera::mode() == render::Camera::Track)) {
+ view_center->set_visible(true);
+ } else {
+ view_center->set_visible(false);
+ }
+
+ if (!ui::root()->active() && !has_input_focus()) {
+ set_focus();
+ }
+
- //draw_world();
}
/* -- namespace view ----------------------------------------------- */
@@ -599,7 +632,7 @@ void draw_cursor()
return;
float angle = 0;
- const float pointer_size = 48.0f;
+
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;
@@ -614,37 +647,6 @@ void draw_cursor()
render::Textures::bind("bitmaps/pointers/aim");
} 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) {
@@ -725,63 +727,7 @@ void draw_cursor()
}
}
-void reset()
-{
- using namespace render;
-
- // set clear color
- gl::clearcolor(0.0f, 0.0f, 0.0f, 1.0f);
-
- // load identity matrices
- gl::matrixmode(GL_MODELVIEW);
- gl::loadidentity();
-
- gl::matrixmode(GL_MODELVIEW);
- gl::loadidentity();
-
- // shading model: Gouraud (smooth, the default)
- gl::shademodel(GL_SMOOTH);
- //gl::shademodel(GL_FLAT);
-
- // lighting settings for the default light GL_LIGHT0
- GLfloat light_position[] = { 0.0, 0.0, 0.0, 1.0 };
- GLfloat ambient_light[] = { 0.01f, 0.01f, 0.01f, 1.0f };
- GLfloat diffuse_light[] = { 0.2f, 0.2f, 0.2f, 1.0f };
- GLfloat specular_light[] = { 0.2f, 0.2f, 0.2f, 1.0f };
-
- glLightfv(GL_LIGHT0, GL_POSITION, light_position);
- glLightfv(GL_LIGHT0, GL_AMBIENT, ambient_light);
- glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse_light);
- glLightfv(GL_LIGHT0, GL_SPECULAR, specular_light);
-
- // GL_LIGHT0 is always enabled
- gl::enable(GL_LIGHT0);
-
- // color tracking
- glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
-
- // material settings
- GLfloat specular_reflectance[] = { 0.2f, 0.2f, 0.2f, 1.0f };
- glMaterialfv(GL_FRONT, GL_SPECULAR, specular_reflectance);
- glMateriali(GL_FRONT, GL_SHININESS, 128); // shininess 1-128
-
- // alpha blending function
- gl::blendfunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
- gl::disable(GL_LIGHTING);
- gl::disable(GL_COLOR_MATERIAL);
-
- gl::cullface(GL_BACK);
- gl::frontface(GL_CCW);
- gl::disable(GL_CULL_FACE);
- gl::disable(GL_DEPTH_TEST);
- gl::disable(GL_BLEND);
-
- gl::disable(GL_TEXTURE_2D);
-
-}
-
-void frame(float seconds)
+void frame(float elapsed)
{
using namespace render;
@@ -793,22 +739,21 @@ void frame(float seconds)
render::Stats::clear();
- if (core::application()->connected() && core::game()->serverframetime()) {
+ if (core::application()->connected() && core::game()->serverframetime() && core::localplayer()->zone()) {
+ render::Camera::frame(elapsed);
+ render::Camera::frustum();
- render::draw(seconds); // draw the world
+ render::draw(elapsed); // draw the world
targets::draw(); // validate current target, render sound
if (targets::current()) // draw target docks etc
draw_entity_world_target(targets::current());
- }
- // switch to orthographic projection to draw the GUI
- gl::matrixmode(GL_PROJECTION);
- gl::loadidentity();
- glOrtho(0, video::width, video::height, 0, -16.0f, 16.0f);
+ render::Camera::ortho();
- gl::matrixmode(GL_MODELVIEW);
- gl::loadidentity();
+ } else {
+ render::Camera::ortho();
+ }
// draw the user interface
gl::color(1.0f, 1.0f, 1.0f, 1.0f);
@@ -829,9 +774,6 @@ void frame(float seconds)
// draw the hud
draw_hud();
- // draw the chat box
- chat::draw();
-
// draw the mouse cursor
draw_cursor();
}