Skip to content

Commit

Permalink
[game,ui] Apply speed up to mouse movement in action menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmytro Lysai authored and pingw33n committed Jun 15, 2020
1 parent fdd86c8 commit 706c9ff
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/game/ui/action_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@ impl ActionMenu {
}
}

fn update_selection(&mut self, base: &Base, pos: Point) {
let rel = pos - base.rect().top_left();
self.selection = clamp(rel.y / Action::ICON_HEIGHT, 0, self.actions.len() as i32 - 1) as u32;
fn update_selection(&mut self, base: &Base, mouse_pos: Point) {
let rel_y = mouse_pos.y - base.rect().top;
// Apply speed up to mouse movement.
let rel_y = (rel_y as f64 * 1.5) as i32;
self.selection = clamp(rel_y / Action::ICON_HEIGHT, 0, self.actions.len() as i32 - 1) as u32;
}
}

Expand Down

0 comments on commit 706c9ff

Please sign in to comment.