iOS: Touch-hex action added.

This commit is contained in:
Victor Sergienko 2018-06-17 18:23:52 -07:00 committed by Jyrki Vesterinen
parent 912453df4c
commit b4ef4c9b34
11 changed files with 29 additions and 7 deletions

View file

@ -42,7 +42,7 @@
[/hotkey]
[hotkey]
button=1
command="selectmoveaction"
command="touchhex"
# Which means "touch"
mouse=255
[/hotkey]

View file

@ -331,6 +331,9 @@ bool command_executor::do_execute_command(const hotkey_command& cmd, int /*inde
case HOTKEY_SELECT_AND_ACTION:
select_and_action();
break;
case HOTKEY_TOUCH_HEX:
touch_hex();
break;
case HOTKEY_ACCELERATED:
toggle_accelerated_speed();
break;

View file

@ -103,6 +103,7 @@ public:
virtual void deselect_hex() {}
virtual void move_action() {}
virtual void select_and_action() {}
virtual void touch_hex() {}
virtual void left_mouse_click() {}
virtual void right_mouse_click() {}
virtual void toggle_accelerated_speed() {}

View file

@ -75,6 +75,7 @@ std::array<hotkey_command_temp, HOTKEY_NULL - 1> master_hotkey_list {{
{ HOTKEY_DESELECT_HEX, "deselecthex", N_("Deselect Hex"), false, scope_game, HKCAT_MAP, "" },
{ HOTKEY_MOVE_ACTION, "moveaction", N_("Move/Attack"), false, scope_game, HKCAT_UNITS, "" },
{ HOTKEY_SELECT_AND_ACTION, "selectmoveaction", N_("Select/Move/Attack"), false, scope_game, HKCAT_UNITS, "" },
{ HOTKEY_TOUCH_HEX, "touchhex", N_("Touch"), false, scope_game, HKCAT_UNITS, "" },
{ HOTKEY_ANIMATE_MAP, "animatemap", N_("Animate Map"), false, scope_game | scope_editor, HKCAT_MAP, "" },
{ HOTKEY_CYCLE_UNITS, "cycle", N_("Next Unit"), false, scope_game, HKCAT_UNITS, "" },
{ HOTKEY_CYCLE_BACK_UNITS, "cycleback", N_("Previous Unit"), false, scope_game, HKCAT_UNITS, "" },

View file

@ -65,7 +65,7 @@ enum HOTKEY_COMMAND {
// Controls
HOTKEY_SELECT_HEX, HOTKEY_DESELECT_HEX,
HOTKEY_MOVE_ACTION, HOTKEY_SELECT_AND_ACTION,
HOTKEY_MOVE_ACTION, HOTKEY_SELECT_AND_ACTION, HOTKEY_TOUCH_HEX,
// Camera movement
HOTKEY_SCROLL_UP, HOTKEY_SCROLL_DOWN, HOTKEY_SCROLL_LEFT, HOTKEY_SCROLL_RIGHT,

View file

@ -122,6 +122,11 @@ void play_controller::hotkey_handler::select_and_action() {
mouse_handler_.select_or_action(browse());
}
void play_controller::hotkey_handler::touch_hex() {
auto touched_hex = gui()->mouseover_hex();
mouse_handler_.touch_action(touched_hex, false);
}
void play_controller::hotkey_handler::move_action(){
mouse_handler_.move_action(browse());
}
@ -307,6 +312,7 @@ bool play_controller::hotkey_handler::can_execute_command(const hotkey::hotkey_c
case hotkey::HOTKEY_DESELECT_HEX:
case hotkey::HOTKEY_MOVE_ACTION:
case hotkey::HOTKEY_SELECT_AND_ACTION:
case hotkey::HOTKEY_TOUCH_HEX:
case hotkey::HOTKEY_MINIMAP_CODING_TERRAIN:
case hotkey::HOTKEY_MINIMAP_CODING_UNIT:
case hotkey::HOTKEY_MINIMAP_DRAW_UNITS:

View file

@ -88,6 +88,7 @@ public:
virtual void left_mouse_click() override;
virtual void move_action() override;
virtual void select_and_action() override;
virtual void touch_hex() override;
virtual void select_hex() override;
virtual void deselect_hex() override;
virtual void right_mouse_click() override;

View file

@ -1008,6 +1008,17 @@ void mouse_handler::move_action(bool browse)
}
}
void mouse_handler::touch_action(const map_location touched_hex, bool browse)
{
unit_map::iterator unit = find_unit(touched_hex);
if (touched_hex.valid() && unit.valid() && !unit->get_hidden()) {
select_or_action(browse);
} else {
deselect_hex();
}
}
void mouse_handler::select_hex(const map_location& hex, const bool browse, const bool highlight, const bool fire_event)
{
selected_hex_ = hex;

View file

@ -84,6 +84,8 @@ public:
const bool fire_event = true);
void move_action(bool browse);
void touch_action(const map_location hex, bool browse);
void select_or_action(bool browse);

View file

@ -293,11 +293,6 @@ bool mouse_handler_base::left_click(int x, int y, const bool /*browse*/)
return false;
}
void mouse_handler_base::move_action(const bool /*browse*/)
{
// Overridden with unit move code elsewhere
}
void mouse_handler_base::touch_action(const map_location /*hex*/, bool /*browse*/)
{
}

View file

@ -126,6 +126,8 @@ public:
// Overridden with unit move code elsewhere
}
virtual void touch_action(const map_location hex, bool browse);
/** Called whenever the left mouse drag has "ended". */
virtual void left_drag_end(int /*x*/, int /*y*/, const bool /*browse*/);