Skip to content

Commit 706c9ff

Browse files
Dmytro Lysaipingw33n
authored andcommitted
[game,ui] Apply speed up to mouse movement in action menu
1 parent fdd86c8 commit 706c9ff

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/game/ui/action_menu.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ impl ActionMenu {
122122
}
123123
}
124124

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

0 commit comments

Comments
 (0)