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')
-rw-r--r--src/client/chat.cc15
-rw-r--r--src/client/chat.h4
-rw-r--r--src/client/client.cc30
-rw-r--r--src/client/client.h4
-rw-r--r--src/client/console.cc28
-rw-r--r--src/client/console.h4
-rw-r--r--src/client/input.cc34
-rw-r--r--src/client/input.h2
-rw-r--r--src/client/targets.cc4
-rw-r--r--src/client/video.cc41
-rw-r--r--src/client/video.h11
-rw-r--r--src/client/view.cc170
12 files changed, 158 insertions, 189 deletions
diff --git a/src/client/chat.cc b/src/client/chat.cc
index 6d294ba..9d51adc 100644
--- a/src/client/chat.cc
+++ b/src/client/chat.cc
@@ -23,9 +23,10 @@ Chat::Chat(ui::Widget *parent) : ui::Window(parent)
chat_label = new ui::Label(this, "^BSay^F:^B");
chat_label->set_alignment(ui::AlignLeft | ui::AlignVCenter);
+ chat_label->set_border(false);
- chat_input = new ui::Input(this);
- chat_input->set_border(true);
+ chat_input = new ui::InputBox(this);
+ chat_input->set_border(false);
chat_input->set_focus();
@@ -79,19 +80,17 @@ bool Chat::on_keypress(const int key, const unsigned int modifier)
}
case SDLK_RETURN:
if (chat_input->text().size()) {
- (*history_pos).assign(chat_input->text());
-
// store input into history
while (history.size() >= DEFAULT_MAX_HISTO_LINES) {
history.pop_front();
}
- if ((*history_pos).c_str()[0] == '/' || (*history_pos).c_str()[0] == '\\') {
- core::cmd() << &(*history_pos).c_str()[1] << std::endl;
+ if (chat_input->text().c_str()[0] == '/' || chat_input->text().c_str()[0] == '\\') {
+ core::cmd() << &chat_input->text().c_str()[1] << std::endl;
} else {
- core::cmd() << "say " << (*history_pos) << std::endl;
+ core::cmd() << "say " << chat_input->text() << std::endl;
}
- (*history.rbegin()) = (*history_pos);
+ (*history.rbegin()) = chat_input->text();
history.push_back("");
history_pos = history.rbegin();
diff --git a/src/client/chat.h b/src/client/chat.h
index f076075..c7232a9 100644
--- a/src/client/chat.h
+++ b/src/client/chat.h
@@ -10,7 +10,7 @@
#include <sstream>
#include <deque>
-#include "ui/input.h"
+#include "ui/inputbox.h"
#include "ui/label.h"
#include "ui/window.h"
@@ -34,7 +34,7 @@ protected:
private:
ui::Label *chat_label;
- ui::Input *chat_input;
+ ui::InputBox *chat_input;
typedef std::deque<std::string> History;
diff --git a/src/client/client.cc b/src/client/client.cc
index 200becd..13c6214 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -41,9 +41,7 @@ void func_snd_restart(std::string const &args)
entity->state()->clearsound();
}
- audio::shutdown();
-
- audio::init();
+ audio::reset();
}
void func_r_restart(std::string const &args)
@@ -96,7 +94,7 @@ void Client::init(int count, char **arguments)
con_print << "^BInitializing client..." << std::endl;
// initialize core
- core::Cvar::sv_dedicated = core::Cvar::set("sv_private", "0");
+ core::Cvar::sv_private = core::Cvar::set("sv_private", "0");
core::Application::init(count, arguments);
// client variables
@@ -145,8 +143,10 @@ void Client::init(int count, char **arguments)
func = core::Func::add("ui_console", func_ui_console);
func->set_info("toggle console on or off");
- //func = core::Func::add("snd_restart", (core::FuncPtr) func_snd_restart);
- //func->set_info("restart audio subsystem");
+ func = core::Func::add("snd_restart", (core::FuncPtr) func_snd_restart);
+ func->set_info("restart audio subsystem");
+
+ previous_timestamp = 0;
}
void Client::run()
@@ -182,10 +182,7 @@ void Client::run()
Uint32 d = client_current_timestamp - client_previous_timestamp;
if ((d > 0)) {
if (d >= client_frame_lenght) {
- float elapsed = (float)(d) / 1000.f;
-
- frame(elapsed);
-
+ frame(client_current_timestamp);
client_previous_timestamp = client_current_timestamp;
} else {
SDL_Delay(client_frame_lenght - d);
@@ -197,9 +194,9 @@ void Client::run()
}
-void Client::frame(float seconds)
+void Client::frame(unsigned long timestamp)
{
- core::Application::frame(seconds);
+ core::Application::frame(timestamp);
if (!core::application()->connected()) {
// load the intro if nothing is running
@@ -217,8 +214,9 @@ void Client::frame(float seconds)
}
}
- video::frame(seconds);
- input::frame(seconds);
+ video::frame((float)(timestamp - previous_timestamp) / 1000.0f);
+ input::frame();
+ previous_timestamp = timestamp;
}
void Client::shutdown()
@@ -230,7 +228,7 @@ void Client::shutdown()
core::Func::remove("r_restart");
core::Func::remove("ui_chat");
core::Func::remove("ui_console");
- //core::Func::remove("snd_restart");
+ core::Func::remove("snd_restart");
audio::shutdown();
@@ -254,7 +252,7 @@ void Client::notify_connect()
void Client::notify_disconnect()
{
- // FIXME unload sounds
+ audio::reset();
render::reset();
input::reset();
}
diff --git a/src/client/client.h b/src/client/client.h
index 6e19848..67fba13 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -56,11 +56,13 @@ public:
protected:
/// run a client frame
- virtual void frame(float seconds);
+ virtual void frame(unsigned long timestamp);
private:
View *client_view;
Console *client_console;
+
+ unsigned long previous_timestamp;
};
diff --git a/src/client/console.cc b/src/client/console.cc
index 0ab0767..80b6224 100644
--- a/src/client/console.cc
+++ b/src/client/console.cc
@@ -48,18 +48,17 @@ Console::Console(ui::Widget *parent) : ui::Window(parent)
set_background(true);
set_label("console");
- //clear_notify();
- load_history();
-
console_scroll = 0;
history.clear();
history.push_back("");
history_pos = history.rbegin();
- console_input = new ui::Input(this);
+ console_input = new ui::InputBox(this);
console_input->set_focus();
console_input->set_border(false);
console_input->set_background(false);
+
+ load_history();
}
Console::~Console()
@@ -125,15 +124,12 @@ bool Console::on_keypress(const int key, const unsigned int modifier)
case SDLK_RETURN:
if (console_input->text().size()) {
// store input in history
- (*history_pos).assign(console_input->text());
while (history.size() >= DEFAULT_MAX_HISTO_LINES) {
history.pop_front();
}
-
- core::cmd() << (*history_pos) << std::endl;
- con_print << "^B>" << (*history_pos) << std::endl;
- (*history.rbegin()) = (*history_pos);
-
+ core::cmd() << console_input->text() << std::endl;
+ con_print << "^B>" << console_input->text() << std::endl;
+ (*history.rbegin()).assign(console_input->text());
history.push_back("");
history_pos = history.rbegin();
console_input->set_text((*history_pos));
@@ -209,10 +205,10 @@ void Console::draw()
if (console_scroll > log().size())
console_scroll = log().size();
- size_t height = (size_t) (this->height() / font()->height()) -1;
- size_t width = (size_t) ((this->width()-8) / font()->width());
- size_t bottom = log().size() - console_scroll;
- size_t current_line = 0;
+ int height = (size_t) (this->height() / font()->height()) -1;
+ int width = (size_t) ((this->width()-8) / font()->width());
+ int bottom = (int) log().size() - console_scroll;
+ int current_line = 0;
Text lines;
for (Text::iterator it = log().begin(); it != log().end() && current_line < bottom; it++) {
@@ -243,7 +239,7 @@ void Console::draw()
// new word, wrap if necessary
else if ((*c == '\n' ) || ( *c == ' ')) {
- if (line_length + word_length > width) {
+ if (line_length + word_length > (size_t) width) {
if (line.size()) {
lines.push_back(line);
line.clear();
@@ -277,7 +273,7 @@ void Console::draw()
word += *c;
word_length++;
- if (word_length == width) {
+ if (word_length == (size_t) width) {
if (line.size()) {
lines.push_back(line);
line.clear();
diff --git a/src/client/console.h b/src/client/console.h
index 4b2df20..7400c32 100644
--- a/src/client/console.h
+++ b/src/client/console.h
@@ -9,7 +9,7 @@
#include "sys/consoleinterface.h"
#include "ui/window.h"
-#include "ui/input.h"
+#include "ui/inputbox.h"
namespace client {
@@ -69,7 +69,7 @@ private:
size_t console_scroll;
// input widget
- ui::Input *console_input;
+ ui::InputBox *console_input;
// console buffer
static ConsoleBuffer con_buffer;
diff --git a/src/client/input.cc b/src/client/input.cc
index a72999e..1e018f5 100644
--- a/src/client/input.cc
+++ b/src/client/input.cc
@@ -486,8 +486,19 @@ void key_pressed(Key *key)
render::Camera::set_pitch(0.0f);
client()->console()->toggle();
+ return;
+ }
+
+ if (ui::root()->active()) {
+ local_direction = 0.0f;
+ local_pitch = 0.0f;
+ local_roll = 0.0f;
- } else if (ui::root()->input_key(true, Keyboard::translate_keysym(key->sym(), keyboard_modifiers), keyboard_modifiers)) {
+ render::Camera::set_direction(0.0f);
+ render::Camera::set_pitch(0.0f);
+ }
+
+ if (ui::root()->input_key(true, Keyboard::translate_keysym(key->sym(), keyboard_modifiers), keyboard_modifiers)) {
return;
} else if (core::application()->connected() && core::localcontrol()) {
@@ -609,8 +620,8 @@ void reset()
}
mouse_pitch = 0.0f;
mouse_direction = 0.0f;
- mouse_x = video::width / 2;
- mouse_y = video::height / 2;
+ mouse_x = render::Camera::width() / 2;
+ mouse_y = render::Camera::height() / 2;
render::Camera::reset();
render::Dust::reset();
mouse_control_override = false;
@@ -631,7 +642,7 @@ void reset()
joystick_lastmoved = 0;
}
-void frame(float seconds)
+void frame()
{
/* -- detect localcontrol() changes --------------- */
if (core::localcontrol() && (last_control != core::localcontrol()->id())) {
@@ -662,6 +673,9 @@ void frame(float seconds)
key = 0;
switch (event.type) {
+ case SDL_VIDEORESIZE:
+ video::resize((float) event.resize.w, (float) event.resize.h);
+ break;
case SDL_MOUSEMOTION:
mouse_x = event.motion.x;
@@ -774,26 +788,26 @@ void frame(float seconds)
mouse_deadzone = true;
// direction
- int l = mouse_x - (video::width >> 1);
+ int l = mouse_x - (render::Camera::width() >> 1);
if (abs(l) < ( deadzone_size >> 1 )) {
// dead zone
mouse_direction = 0;
} else {
- l = (mouse_x - deadzone_size) - ((video::width - deadzone_size) >> 1);
- mouse_direction = float (-l) / (float) ((video::width - deadzone_size) >> 1);
+ l = (mouse_x - deadzone_size) - ((render::Camera::width() - deadzone_size) >> 1);
+ mouse_direction = float (-l) / (float) ((render::Camera::width() - deadzone_size) >> 1);
mouse_deadzone = false;
}
// pitch
- int h = mouse_y - (video::height >> 1);
+ int h = mouse_y - (render::Camera::height() >> 1);
if (abs(h) < ( deadzone_size >> 1 )) {
// dead zone
mouse_pitch = 0;
} else {
- h = (mouse_y - deadzone_size) - ((video::height - deadzone_size) >> 1);
- mouse_pitch = float (-h) / (float) ((video::height - deadzone_size) >> 1);
+ h = (mouse_y - deadzone_size) - ((render::Camera::height() - deadzone_size) >> 1);
+ mouse_pitch = float (-h) / (float) ((render::Camera::height() - deadzone_size) >> 1);
mouse_deadzone = false;
}
diff --git a/src/client/input.h b/src/client/input.h
index a954040..88a65b3 100644
--- a/src/client/input.h
+++ b/src/client/input.h
@@ -23,7 +23,7 @@ void init();
void shutdown();
/// handle one frame of input events
-void frame(float seconds);
+void frame();
/// reset input state
void reset();
diff --git a/src/client/targets.cc b/src/client/targets.cc
index b533974..c7fcf9e 100644
--- a/src/client/targets.cc
+++ b/src/client/targets.cc
@@ -413,8 +413,8 @@ void draw()
x = 0;
y = 0;
} else {
- x = (float)(input::mouse_position_x() - video::width /2) / (float)video::width;
- y = (float)(input::mouse_position_y() - video::height /2) / (float)video::height / render::Camera::aspect();
+ x = (float)(input::mouse_position_x() - render::Camera::width() /2) / (float)render::Camera::width();
+ y = (float)(input::mouse_position_y() - render::Camera::height() /2) / (float)render::Camera::height() / render::Camera::aspect();
}
Vector3f cursor = render::Camera::eye() + render::Camera::axis().forward() * (render::Camera::frustum_front() + 0.001);
diff --git a/src/client/video.cc b/src/client/video.cc
index 7338d70..d8ba316 100644
--- a/src/client/video.cc
+++ b/src/client/video.cc
@@ -28,6 +28,9 @@ namespace video {
float fullscreen = 0;
+int bpp = 0;
+int flags = 0;
+
int width = 0;
int height = 0;
@@ -57,9 +60,6 @@ bool init()
r_fullscreen = core::Cvar::get("r_fullscreen", "0", core::Cvar::Archive);
r_fullscreen->set_info("[bool] enable or disable fullscreen video");
- int bpp = 0;
- int flags = 0;
-
if( SDL_InitSubSystem(SDL_INIT_VIDEO) < 0 ) {
con_error << "SDL_InitSubSystem() failed: " << SDL_GetError() << std::endl;
return false;
@@ -103,7 +103,7 @@ bool init()
if (r_fullscreen->value()) {
flags = SDL_OPENGL | SDL_FULLSCREEN;
} else {
- flags = SDL_OPENGL;
+ flags = SDL_OPENGL | SDL_RESIZABLE;
}
if(!SDL_SetVideoMode(width, height, bpp, flags )) {
@@ -147,17 +147,42 @@ bool init()
// resize user interface
ui::root()->set_size((float) width, (float) height);
ui::root()->event_resize();
+
+ // to grab or not to grab
+ if (client()->console()->visible()) {
+ SDL_WM_GrabInput(SDL_GRAB_OFF);
+ SDL_ShowCursor(SDL_ENABLE);
+ } else {
+ SDL_WM_GrabInput(SDL_GRAB_ON);
+ SDL_ShowCursor(SDL_DISABLE);
+ }
// initialize renderer
- render::Camera::resize(width, height);
render::init();
- render::Camera::resize(width, height); // yes twice, bug
+ render::resize(width, height);
view::init();
return true;
}
+void resize(float w, float h)
+{
+ if (fullscreen)
+ return;
+
+ if (h < 64) h = 64;
+ if (w < 64) w = 64;
+
+ if (SDL_SetVideoMode(w, h, bpp, flags )) {
+ render::resize(w, h);
+ ui::root()->set_size(w, h);
+ ui::root()->event_resize();
+ } else {
+ con_warn << "Could not resize window!" << std::endl;
+ }
+}
+
void restart()
{
shutdown();
@@ -168,14 +193,14 @@ void restart()
input::reset();
}
-void frame(float seconds)
+void frame(float elapsed)
{
// detect fullscreen/windowed mode switch
if (fullscreen != r_fullscreen->value())
restart();
// render a client frame
- view::frame(seconds);
+ view::frame(elapsed);
SDL_GL_SwapBuffers();
}
diff --git a/src/client/video.h b/src/client/video.h
index daa136c..a28b17d 100644
--- a/src/client/video.h
+++ b/src/client/video.h
@@ -24,14 +24,11 @@ namespace video
*/
void restart();
- /// draw the next client video frame
- void frame(float seconds);
-
- /// width of the application window in pixels
- extern int width;
+ /// application window resize event in windowed mode
+ void resize(float w, float h);
- /// height of the application window in pixels
- extern int height;
+ /// draw the next client video frame
+ void frame(float elapsed);
} // namespace video
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);