Skip to content

Commit

Permalink
Merge mouse move feature.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevingranade committed Nov 19, 2013
2 parents 45d91bb + e32a901 commit e585b53
Show file tree
Hide file tree
Showing 10 changed files with 383 additions and 84 deletions.
20 changes: 20 additions & 0 deletions data/raw/keybindings.json
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,16 @@
}
]
},
{
"id":"SEC_SELECT",
"name":"Select",
"bindings":[
{
"input_method":"mouse",
"key":"MOUSE_RIGHT"
}
]
},
{
"id":"SELECT",
"name":"Select",
Expand Down Expand Up @@ -396,5 +406,15 @@
"key":"f"
}
]
},
{
"id":"TOGGLE_SNAP_TO_TARGET",
"name":"Toggle Snap to Target",
"bindings":[
{
"input_method":"keyboard",
"key":"*"
}
]
}
]
20 changes: 20 additions & 0 deletions src/action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,3 +758,23 @@ std::string press_x(action_id act, std::string act_desc)
}
}

action_id get_movement_direction_from_delta(const int dx, const int dy)
{
if (dx == 0 && dy == -1) {
return ACTION_MOVE_N;
} else if (dx == 1 && dy == -1) {
return ACTION_MOVE_NE;
} else if (dx == 1 && dy == 0) {
return ACTION_MOVE_E;
} else if (dx == 1 && dy == 1) {
return ACTION_MOVE_SE;
} else if (dx == 0 && dy == 1) {
return ACTION_MOVE_S;
} else if (dx == -1 && dy == 1) {
return ACTION_MOVE_SW;
} else if (dx == -1 && dy == 0) {
return ACTION_MOVE_W;
} else {
return ACTION_MOVE_NW;
}
}
2 changes: 2 additions & 0 deletions src/action.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,7 @@ std::string press_x(action_id act, std::string key_bound_pre,
// ('Z'ing|zing) (X( or Y)))
std::string press_x(action_id act, std::string act_desc);

// Helper function to convert co-ordinate delta to a movement direction
action_id get_movement_direction_from_delta(const int dx, const int dy);

#endif
Loading

0 comments on commit e585b53

Please sign in to comment.