From 2c1dc81db735d0da2cf25afd34b93c2f228ebb2d Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 12 Dec 2014 22:18:14 +0300 Subject: Add chat command for moving camera. New chat command: /movecamera x y Alias: /cameramove x y --- src/actions/commands.cpp | 14 ++++++++++++++ src/actions/commands.h | 1 + src/input/inputaction.h | 1 + src/input/inputactionmap.h | 9 +++++++++ 4 files changed, 25 insertions(+) diff --git a/src/actions/commands.cpp b/src/actions/commands.cpp index eb10e8a77..dd93da0e8 100644 --- a/src/actions/commands.cpp +++ b/src/actions/commands.cpp @@ -34,6 +34,7 @@ #include "being/playerrelations.h" #include "gui/chatconsts.h" +#include "gui/viewport.h" #include "gui/windows/chatwindow.h" #include "gui/windows/socialwindow.h" @@ -472,6 +473,19 @@ impHandler(navigateTo) return true; } +impHandler(moveCamera) +{ + int x = 0; + int y = 0; + + if (!viewport) + return false; + + if (parse2Int(event.args, x, y)) + viewport->moveCameraToPosition(x * mapTileSize, y * mapTileSize); + return true; +} + impHandler(imitation) { if (!localPlayer) diff --git a/src/actions/commands.h b/src/actions/commands.h index a8143275b..0aa226cb8 100644 --- a/src/actions/commands.h +++ b/src/actions/commands.h @@ -50,6 +50,7 @@ namespace Actions decHandler(follow); decHandler(navigate); decHandler(navigateTo); + decHandler(moveCamera); decHandler(imitation); decHandler(sendMail); decHandler(info); diff --git a/src/input/inputaction.h b/src/input/inputaction.h index f7b061e88..fb5db9913 100644 --- a/src/input/inputaction.h +++ b/src/input/inputaction.h @@ -499,6 +499,7 @@ namespace InputAction CHAT_ADD, WHISPER_TEXT, NAVIGATE_TO, + CAMERA_MOVE, TOTAL }; } // namespace InputAction diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index e9457058b..4b9d61047 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -4234,6 +4234,15 @@ static const InputActionData inputActionData[InputAction::TOTAL] = { InputCondition::INGAME, "navigateto", true}, + {"keyCameraMove", + InputType::UNKNOWN, InputAction::NO_VALUE, + InputType::UNKNOWN, InputAction::NO_VALUE, + Input::GRP_DEFAULT, + &Actions::moveCamera, + InputAction::NO_VALUE, 50, + InputCondition::INGAME, + "movecamera|cameramove", + true}, }; #endif // INPUT_INPUTACTIONMAP_H -- cgit v1.2.3-60-g2f50