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-11-16 18:47:01 +0000
committerStijn Buys <ingar@osirion.org>2008-11-16 18:47:01 +0000
commit44158ccfbe943b832c0e0bf9ce547212aa6c2b8b (patch)
tree3749d855271779b65283f86599c0faebdfdf4318 /src/client
parent315a8c2dff9b76ac5e1ebbef265f13ac19d65e3d (diff)
camera zoom
Diffstat (limited to 'src/client')
-rw-r--r--src/client/input.cc37
-rw-r--r--src/client/input.h3
-rw-r--r--src/client/keyboard.cc3
-rw-r--r--src/client/view.cc21
4 files changed, 45 insertions, 19 deletions
diff --git a/src/client/input.cc b/src/client/input.cc
index 8236b9b..a5af430 100644
--- a/src/client/input.cc
+++ b/src/client/input.cc
@@ -384,17 +384,24 @@ void action_press(Key const *key, std::string const &action)
local_afterburner = -1.0f;
/* -- camera control ------------------------------ */
+
+ } else if (action.compare("+zoomin") == 0) {
+ render::Camera::set_zoom(-0.1f);
+
+ } else if (action.compare("+zoomout") == 0) {
+ render::Camera::set_zoom(+0.1f);
+
} else if (action.compare("+camleft") == 0) {
- render::Camera::set_direction(1.0f);
+ render::Camera::set_direction( math::min(key->pressed() - core::application()->time(), 1.0f) );
} else if (action.compare("+camright") == 0) {
- render::Camera::set_direction(-1.0f);
+ render::Camera::set_direction(-math::min(key->pressed() - core::application()->time(),1.0f));
} else if (action.compare("+camup") == 0) {
- render::Camera::set_pitch(1.0f);
+ render::Camera::set_pitch(math::min(key->pressed() - core::application()->time(),1.0f));
} else if (action.compare("+camdown") == 0) {
- render::Camera::set_pitch(-1.0f);
+ render::Camera::set_pitch(-math::min(key->pressed() - core::application()->time(),1.0f));
} else
con_warn << "Unknown action " << action << std::endl;
}
@@ -471,17 +478,15 @@ void action_release(Key *key, std::string const &action)
}
}
-Key::Modifier convert_SDL_modifier(int const sdlmodifier)
-{
- if (sdlmodifier & Key::Shift)
+Key::Modifier modifier() {
+ if ((keyboard_modifiers & Key::Shift) > 0 )
return Key::Shift;
- else if (sdlmodifier & Key::Ctrl)
+ else if ((keyboard_modifiers & Key::Ctrl) > 0 )
return Key::Ctrl;
- else if (sdlmodifier & Key::Alt)
+ else if ((keyboard_modifiers & Key::Alt) > 0 )
return Key::Alt;
else
return Key::None;
-
}
void key_pressed(Key *key)
@@ -515,25 +520,25 @@ void key_pressed(Key *key)
} else if (!core::localplayer()->view() && core::application()->connected() && core::localcontrol()) {
- char c = key->bind(convert_SDL_modifier(keyboard_modifiers)).c_str()[0];
+ char c = key->bind(modifier()).c_str()[0];
if (c == '@') {
// target bind
if (targets::current_id())
- core::cmd() << key->bind(convert_SDL_modifier(keyboard_modifiers)) << " " << targets::current_id() <<"\n";
+ core::cmd() << key->bind(modifier()) << " " << targets::current_id() <<"\n";
} else if (c == '+') {
// action bind
- action_press(key, key->bind(convert_SDL_modifier(keyboard_modifiers)));
+ action_press(key, key->bind(modifier()));
} else {
// normal bind
- core::cmd() << key->bind(convert_SDL_modifier(keyboard_modifiers)) << "\n";
+ core::cmd() << key->bind(modifier()) << "\n";
}
} else if (core::application()->connected()) {
- char c = key->bind(convert_SDL_modifier(keyboard_modifiers)).c_str()[0];
+ char c = key->bind(modifier()).c_str()[0];
if (c && c != '+' && c != '@') {
// normal bind
- core::cmd() << key->bind(convert_SDL_modifier(keyboard_modifiers)) << "\n";
+ core::cmd() << key->bind(modifier()) << "\n";
}
}
}
diff --git a/src/client/input.h b/src/client/input.h
index 88a65b3..394e521 100644
--- a/src/client/input.h
+++ b/src/client/input.h
@@ -43,6 +43,9 @@ float mouse_lastmoved_time();
/// time the joystick was last moved
float joystick_lastmoved_time();
+/// current modifier
+Key::Modifier modifier();
+
extern bool mouse_deadzone;
extern bool mouse_control;
extern bool joystick_control;
diff --git a/src/client/keyboard.cc b/src/client/keyboard.cc
index a29b601..232e0bb 100644
--- a/src/client/keyboard.cc
+++ b/src/client/keyboard.cc
@@ -45,6 +45,9 @@ Keyboard::Keyboard()
add_action("+camup", Action::None, "rotate camera up");
add_action("+camdown", Action::None, "rotate camera down");
+ add_action("+zoomin", Action::None, "zoom camera in");
+ add_action("+zoomout", Action::None, "zoom camera out");
+
add_action("+thrustup", Action::None, "increase thruster");
add_action("+thrustdown", Action::None, "decrease thruster");
diff --git a/src/client/view.cc b/src/client/view.cc
index 0f981ca..de867c0 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -165,10 +165,25 @@ KeyPress::KeyPress(ui::Widget *parent) : Widget(parent)
void KeyPress::draw()
{
- if(input::last_key_pressed()) {
- ui::paint::color(palette()->highlight());
- ui::paint::label(global_location(), size(), font(), input::last_key_pressed()->name(), ui::AlignCenter);
+ std::string label;
+ ui::paint::color(palette()->highlight());
+
+ Key::Modifier mod = input::modifier();
+ if (mod != Key::None) {
+ if (mod == Key::Shift)
+ label.assign("shift+");
+ else if (mod == Key::Ctrl)
+ label.assign("ctrl+");
+ else if (mod == Key::Alt)
+ label.assign("alt+");
+ }
+
+ if(input::last_key_pressed()) {
+ label.append(input::last_key_pressed()->name());
}
+
+ if (label.size())
+ ui::paint::label(global_location(), size(), font(), label , ui::AlignCenter);
}
/* -- View --------------------------------------------------------- */