Improve mouse interaction
This commit is contained in:
parent
b1f60894ed
commit
04fac2ddb2
@ -66,17 +66,11 @@ pub fn set_boat_layout<B: Backend>(
|
|||||||
// Start mouse action
|
// Start mouse action
|
||||||
if MouseEventKind::Down(MouseButton::Left) == mouse.kind {
|
if MouseEventKind::Down(MouseButton::Left) == mouse.kind {
|
||||||
is_moving_boat = if let Some(pos) = coordinates_mapper.get(&src_pos) {
|
is_moving_boat = if let Some(pos) = coordinates_mapper.get(&src_pos) {
|
||||||
match model.layout.find_boat_at_position(*pos).cloned() {
|
if let Some(b) = model.layout.find_boat_at_position(*pos) {
|
||||||
// Change of selected boat
|
model.curr_boat = model.layout.0.iter().position(|s| s == b).unwrap();
|
||||||
Some(b) if b != model.layout.0[model.curr_boat] => {
|
|
||||||
model.curr_boat =
|
|
||||||
model.layout.0.iter().position(|s| s == &b).unwrap();
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move current boat
|
|
||||||
_ => true,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user