mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Implement #505
This commit is contained in:
parent
9cb8dc1df1
commit
03396eb77e
@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Added authentication system (to play on the official server register on https://account.veloren.net)
|
||||
- Added gamepad/controller support
|
||||
- Added player feedback when attempting to pickup an item with a full inventory
|
||||
- Added free look
|
||||
|
||||
### Changed
|
||||
|
||||
|
@ -327,6 +327,8 @@ Chat commands:
|
||||
"hud.social.play_online_fmt": "{nb_player} player(s) online",
|
||||
|
||||
"hud.spell": "Spell",
|
||||
|
||||
"hud.free_look_indicator": "Free look active",
|
||||
/// End HUD section
|
||||
|
||||
|
||||
|
@ -56,6 +56,7 @@ use vek::*;
|
||||
|
||||
const XP_COLOR: Color = Color::Rgba(0.59, 0.41, 0.67, 1.0);
|
||||
const TEXT_COLOR: Color = Color::Rgba(1.0, 1.0, 1.0, 1.0);
|
||||
const TEXT_BG: Color = Color::Rgba(0.0, 0.0, 0.0, 1.0);
|
||||
//const TEXT_COLOR_GREY: Color = Color::Rgba(1.0, 1.0, 1.0, 0.5);
|
||||
const MENU_BG: Color = Color::Rgba(0.0, 0.0, 0.0, 0.4);
|
||||
//const TEXT_COLOR_2: Color = Color::Rgba(0.0, 0.0, 0.0, 1.0);
|
||||
@ -175,6 +176,10 @@ widget_ids! {
|
||||
small_window,
|
||||
social_window,
|
||||
settings_window,
|
||||
|
||||
// Free look indicator
|
||||
free_look_txt,
|
||||
free_look_bg,
|
||||
}
|
||||
}
|
||||
|
||||
@ -285,6 +290,7 @@ pub struct Show {
|
||||
settings_tab: SettingsTab,
|
||||
social_tab: SocialTab,
|
||||
want_grab: bool,
|
||||
free_look: bool,
|
||||
}
|
||||
impl Show {
|
||||
fn bag(&mut self, open: bool) {
|
||||
@ -507,6 +513,7 @@ impl Hud {
|
||||
social_tab: SocialTab::Online,
|
||||
want_grab: true,
|
||||
ingame: true,
|
||||
free_look: false,
|
||||
},
|
||||
to_focus: None,
|
||||
never_show: false,
|
||||
@ -1961,6 +1968,22 @@ impl Hud {
|
||||
}
|
||||
}
|
||||
|
||||
// Free look indicator
|
||||
if self.show.free_look {
|
||||
Text::new(&self.voxygen_i18n.get("hud.free_look_indicator"))
|
||||
.color(TEXT_BG)
|
||||
.mid_top_with_margin_on(ui_widgets.window, 100.0)
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.font_size(self.fonts.cyri.scale(20))
|
||||
.set(self.ids.free_look_bg, ui_widgets);
|
||||
Text::new(&self.voxygen_i18n.get("hud.free_look_indicator"))
|
||||
.color(KILL_COLOR)
|
||||
.top_left_with_margins_on(self.ids.free_look_bg, -1.0, -1.0)
|
||||
.font_id(self.fonts.cyri.conrod_id)
|
||||
.font_size(self.fonts.cyri.scale(20))
|
||||
.set(self.ids.free_look_txt, ui_widgets);
|
||||
}
|
||||
|
||||
events
|
||||
}
|
||||
|
||||
@ -2132,4 +2155,6 @@ impl Hud {
|
||||
self.ui.render(renderer, Some(globals));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn free_look(&mut self, free_look: bool) { self.show.free_look = free_look; }
|
||||
}
|
||||
|
@ -154,6 +154,9 @@ impl PlayState for SessionState {
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let mut ori = self.scene.camera().get_orientation();
|
||||
let mut free_look = false;
|
||||
|
||||
// Game loop
|
||||
let mut current_client_state = self.client.borrow().get_client_state();
|
||||
while let ClientState::Pending | ClientState::Character = current_client_state {
|
||||
@ -399,6 +402,10 @@ impl PlayState for SessionState {
|
||||
Event::InputUpdate(GameInput::Charge, state) => {
|
||||
self.inputs.charge.set_state(state);
|
||||
},
|
||||
Event::InputUpdate(GameInput::FreeLook, true) => {
|
||||
free_look = !free_look;
|
||||
self.hud.free_look(free_look);
|
||||
},
|
||||
Event::AnalogGameInput(input) => match input {
|
||||
AnalogGameInput::MovementX(v) => {
|
||||
self.key_state.analog_matrix.x = v;
|
||||
@ -418,9 +425,12 @@ impl PlayState for SessionState {
|
||||
}
|
||||
}
|
||||
|
||||
if !free_look {
|
||||
ori = self.scene.camera().get_orientation();
|
||||
self.inputs.look_dir = cam_dir;
|
||||
}
|
||||
// Calculate the movement input vector of the player from the current key
|
||||
// presses and the camera direction.
|
||||
let ori = self.scene.camera().get_orientation();
|
||||
let unit_vecs = (
|
||||
Vec2::new(ori[0].cos(), -ori[0].sin()),
|
||||
Vec2::new(ori[0].sin(), ori[0].cos()),
|
||||
@ -428,8 +438,6 @@ impl PlayState for SessionState {
|
||||
let dir_vec = self.key_state.dir_vec();
|
||||
self.inputs.move_dir = unit_vecs.0 * dir_vec[0] + unit_vecs.1 * dir_vec[1];
|
||||
|
||||
self.inputs.look_dir = cam_dir;
|
||||
|
||||
// Runs if either in a multiplayer server or the singleplayer server is unpaused
|
||||
if global_state.singleplayer.is_none()
|
||||
|| !global_state.singleplayer.as_ref().unwrap().is_paused()
|
||||
|
@ -51,6 +51,7 @@ pub struct ControlSettings {
|
||||
pub interact: KeyMouse,
|
||||
pub toggle_wield: KeyMouse,
|
||||
pub charge: KeyMouse,
|
||||
pub free_look: KeyMouse,
|
||||
}
|
||||
|
||||
/// Since Macbook trackpads lack middle click, on OS X we default to LShift
|
||||
@ -101,6 +102,7 @@ impl Default for ControlSettings {
|
||||
interact: KeyMouse::Mouse(MouseButton::Right),
|
||||
toggle_wield: KeyMouse::Key(VirtualKeyCode::T),
|
||||
charge: KeyMouse::Key(VirtualKeyCode::Key1),
|
||||
free_look: KeyMouse::Key(VirtualKeyCode::LAlt),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ pub enum GameInput {
|
||||
Interact,
|
||||
ToggleWield,
|
||||
Charge,
|
||||
FreeLook,
|
||||
}
|
||||
|
||||
/// Represents a key that the game menus recognise after input mapping
|
||||
@ -458,6 +459,9 @@ impl Window {
|
||||
map.entry(settings.controls.charge)
|
||||
.or_default()
|
||||
.push(GameInput::Charge);
|
||||
map.entry(settings.controls.free_look)
|
||||
.or_default()
|
||||
.push(GameInput::FreeLook);
|
||||
|
||||
let keypress_map = HashMap::new();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user