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-07-30 17:16:55 +0000
committerStijn Buys <ingar@osirion.org>2008-07-30 17:16:55 +0000
commit04050c1685855a0640c7c0d5147299fadbd2ebe8 (patch)
treeb0789947f5cc363950472c5f5a8b55048ca72d18 /src/client
parentd09a1be33a647aedc12ce5ddcb7ea4ee23a75c8c (diff)
select-on-release
Diffstat (limited to 'src/client')
-rw-r--r--src/client/input.cc41
-rw-r--r--src/client/input.h10
-rw-r--r--src/client/targets.cc4
-rw-r--r--src/client/view.cc61
4 files changed, 66 insertions, 50 deletions
diff --git a/src/client/input.cc b/src/client/input.cc
index 2f09d5b..751b3ca 100644
--- a/src/client/input.cc
+++ b/src/client/input.cc
@@ -63,6 +63,14 @@ bool mouse_control = false;
const float thruster_offset = 0.05f;
+int mouse_position_x() {
+ return mouse_x;
+}
+
+int mouse_position_y() {
+ return mouse_y;
+}
+
//--- engine functions --------------------------------------------
void func_screenshot(std::string const & args)
@@ -456,12 +464,6 @@ void key_pressed(Key *key)
} else if (core::application()->connected() && core::localcontrol()) {
- if ((key->sym() == 512 + SDL_BUTTON_LEFT) && targets::hover()) {
- // hovering target selected
- targets::select_target(targets::hover());
-
- } else {
-
char c = key->bind(convert_SDL_modifier(keyboard_modifiers)).c_str()[0];
if (c == '+') {
// action bind
@@ -471,7 +473,6 @@ void key_pressed(Key *key)
// normal bind
core::cmd() << key->bind(convert_SDL_modifier(keyboard_modifiers)) << "\n";
}
- }
} else if (core::application()->connected()) {
@@ -487,17 +488,37 @@ void key_pressed(Key *key)
void key_released(Key *key)
{
if (core::application()->connected() && core::localcontrol() && !console()->visible() && !chat::visible()) {
+ if ((key->sym() == 512 + SDL_BUTTON_LEFT) && targets::hover()) {
- // FIXME modifiers
- char c = key->bind(Key::None).c_str()[0];
+ // hovering target selected
+ targets::select_target(targets::hover());
+ }
+
+ // the release event still must be processed as usual
+ char c = 0;
+ c = key->bind(Key::None).c_str()[0];
if (c == '+') {
// action bind
action_release(key->bind(Key::None));
}
+ c = key->bind(Key::Shift).c_str()[0];
+ if (c == '+') {
+ // action bind
+ action_release(key->bind(Key::Shift));
+ }
+ c = key->bind(Key::Ctrl).c_str()[0];
+ if (c == '+') {
+ // action bind
+ action_release(key->bind(Key::Ctrl));
+ }
+ c = key->bind(Key::Alt).c_str()[0];
+ if (c == '+') {
+ // action bind
+ action_release(key->bind(Key::Alt));
+ }
}
}
-
void reset()
{
local_direction = 0.0f;
diff --git a/src/client/input.h b/src/client/input.h
index b2b44c8..78b813f 100644
--- a/src/client/input.h
+++ b/src/client/input.h
@@ -27,17 +27,17 @@ void frame(float seconds);
/// reset input state
void reset();
-extern int mouse_x;
-extern int mouse_y;
+/// current mouse x position
+int mouse_position_x();
+
+/// current mouse y position
+int mouse_position_y();
extern bool mouse_deadzone;
extern bool mouse_control;
-extern bool mouse_control_override;
} // namespace input
-extern core::Cvar *input_mousecontrol;
-
} // namespace client
#endif // __INCLUDED_cLIENT_INPUT_H__
diff --git a/src/client/targets.cc b/src/client/targets.cc
index 666ea6a..8dc5c07 100644
--- a/src/client/targets.cc
+++ b/src/client/targets.cc
@@ -290,8 +290,8 @@ void frame()
float z = -1;
// mouse cursor location in 3d world space
- float x = (float)(input::mouse_x - video::width /2) / (float)video::width;
- float y = (float)(input::mouse_y - video::height /2) / (float)video::height / render::Camera::aspect();
+ float x = (float)(input::mouse_position_x() - video::width /2) / (float)video::width;
+ float y = (float)(input::mouse_position_y() - video::height /2) / (float)video::height / render::Camera::aspect();
Vector3f cursor = render::Camera::eye() + render::Camera::axis().forward() * (render::Camera::frustum_front() + 0.001);
cursor -= render::Camera::axis().left() * x;
diff --git a/src/client/view.cc b/src/client/view.cc
index 75c4989..41cdd80 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -163,20 +163,15 @@ void draw_cursor()
if (!core::localcontrol() || console()->visible())
return;
+ float angle = 0;
float pointer_size = 48.0f;
- float x = input::mouse_x - (pointer_size /2);
- float y = input::mouse_y - (pointer_size /2);
-
- using namespace render;
-
- math::Color color;
- color.a = 0.5f;
-
+ 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 (render::Camera::mode() == render::Camera::Overview) {
render::Textures::bind("bitmaps/pointers/aim");
-
} else {
// draw center cursor in Cockpit and Track mode
if (input::mouse_control &&
@@ -191,25 +186,25 @@ void draw_cursor()
float cx = (video::width - pointer_size) /2;
float cy = (video::height - pointer_size) /2;
- gl::color(color);
- gl::begin(gl::Quads);
+ render::gl::color(color);
+ render::gl::begin(render::gl::Quads);
glTexCoord2f(0,0 );
- gl::vertex(cx,cy,0.0f);
+ render::gl::vertex(cx,cy,0.0f);
glTexCoord2f(1, 0);
- gl::vertex(cx+pointer_size, cy, 0.0f);
+ render::gl::vertex(cx+pointer_size, cy, 0.0f);
glTexCoord2f(1, 1);
- gl::vertex(cx+pointer_size, cy+pointer_size, 0.0f);
+ render::gl::vertex(cx+pointer_size, cy+pointer_size, 0.0f);
glTexCoord2f(0, 1);
- gl::vertex(cx, cy+pointer_size, 0.0f);
+ render::gl::vertex(cx, cy+pointer_size, 0.0f);
- gl::end();
+ render::gl::end();
}
- if (!input::mouse_control_override && targets::hover()) {
+ if (targets::hover()) {
if (ui_pointerhovercolor) {
std::stringstream colorstr(ui_pointerhovercolor->str());
@@ -229,8 +224,8 @@ void draw_cursor()
render::Textures::bind("bitmaps/pointers/control");
if (!input::mouse_deadzone) {
- x = input::mouse_x - (pointer_size /2);
- y = input::mouse_y - (pointer_size /2);
+ x = input::mouse_position_x() - (pointer_size /2);
+ y = input::mouse_position_y() - (pointer_size /2);
} else {
x = (video::width - pointer_size) /2;
@@ -245,34 +240,34 @@ void draw_cursor()
}
if (cursor_animated) {
- gl::push();
- gl::translate(x+pointer_size/2, y+pointer_size/2, 0.0f);
+ render::gl::push();
+ render::gl::translate(x+pointer_size/2, y+pointer_size/2, 0.0f);
- float angle = core::application()->time()* 0.75f - floorf(core::application()->time() * 0.75f);
+ angle = core::application()->time()* 0.75f - floorf(core::application()->time() * 0.75f);
angle *= 360.0f;
- gl::rotate(angle, math::Vector3f(0, 0, 1.0f));
- gl::translate(-x-pointer_size/2, -y-pointer_size/2, 0.0f);
+ render::gl::rotate(angle, math::Vector3f(0, 0, 1.0f));
+ render::gl::translate(-x-pointer_size/2, -y-pointer_size/2, 0.0f);
}
- gl::color(color);
- gl::begin(gl::Quads);
+ render::gl::color(color);
+ render::gl::begin(render::gl::Quads);
glTexCoord2f(0,0 );
- gl::vertex(x,y,0.0f);
+ render::gl::vertex(x,y,0.0f);
glTexCoord2f(1, 0);
- gl::vertex(x+pointer_size, y, 0.0f);
+ render::gl::vertex(x+pointer_size, y, 0.0f);
glTexCoord2f(1, 1);
- gl::vertex(x+pointer_size, y+pointer_size, 0.0f);
+ render::gl::vertex(x+pointer_size, y+pointer_size, 0.0f);
glTexCoord2f(0, 1);
- gl::vertex(x, y+pointer_size, 0.0f);
+ render::gl::vertex(x, y+pointer_size, 0.0f);
- gl::end();
+ render::gl::end();
if (cursor_animated) {
- gl::pop();
+ render::gl::pop();
}
}