Changeset View
Changeset View
Standalone View
Standalone View
source/graphics/CameraController.cpp
/* Copyright (C) 2019 Wildfire Games. | /* Copyright (C) 2020 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 625 Lines • ▼ Show 20 Lines | void CCameraController::FocusHeight(bool smooth) | ||||
else | else | ||||
m_PosY.Add(diff); | m_PosY.Add(diff); | ||||
} | } | ||||
InReaction CCameraController::HandleEvent(const SDL_Event_* ev) | InReaction CCameraController::HandleEvent(const SDL_Event_* ev) | ||||
{ | { | ||||
switch (ev->ev.type) | switch (ev->ev.type) | ||||
{ | { | ||||
case SDL_HOTKEYPRESS: | |||||
{ | |||||
std::string hotkey = static_cast<const char*>(ev->ev.user.data1); | |||||
if (hotkey == "camera.reset") | |||||
Stan: Could invert that to make it early return :) | |||||
Done Inline ActionsI would not neglect the odds of more (new) hotkeys being added here, and then we can't (or at least we shouldn't) invert the case. bb: I would not neglect the odds of more (new) hotkeys being added here, and then we can't (or at… | |||||
{ | |||||
ResetCameraAngleZoom(); | |||||
return IN_HANDLED; | |||||
} | |||||
return IN_PASS; | |||||
} | |||||
case SDL_HOTKEYDOWN: | case SDL_HOTKEYDOWN: | ||||
{ | |||||
std::string hotkey = static_cast<const char*>(ev->ev.user.data1); | std::string hotkey = static_cast<const char*>(ev->ev.user.data1); | ||||
// Mouse wheel must be treated using events instead of polling, | // Mouse wheel must be treated using events instead of polling, | ||||
// because SDL auto-generates a sequence of mousedown/mouseup events | // because SDL auto-generates a sequence of mousedown/mouseup events | ||||
// and we never get to see the "down" state inside Update(). | // and we never get to see the "down" state inside Update(). | ||||
if (hotkey == "camera.zoom.wheel.in") | if (hotkey == "camera.zoom.wheel.in") | ||||
{ | { | ||||
m_Zoom.AddSmoothly(-m_ViewZoomSpeedWheel); | m_Zoom.AddSmoothly(-m_ViewZoomSpeedWheel); | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | else if (hotkey == "camera.zoom.speed.increase") | ||||
m_ViewZoomSpeed *= m_ViewZoomSpeedModifier; | m_ViewZoomSpeed *= m_ViewZoomSpeedModifier; | ||||
return IN_HANDLED; | return IN_HANDLED; | ||||
} | } | ||||
else if (hotkey == "camera.zoom.speed.decrease") | else if (hotkey == "camera.zoom.speed.decrease") | ||||
{ | { | ||||
m_ViewZoomSpeed /= m_ViewZoomSpeedModifier; | m_ViewZoomSpeed /= m_ViewZoomSpeedModifier; | ||||
return IN_HANDLED; | return IN_HANDLED; | ||||
} | } | ||||
else if (hotkey == "camera.reset") | return IN_PASS; | ||||
{ | |||||
ResetCameraAngleZoom(); | |||||
return IN_HANDLED; | |||||
} | } | ||||
} | } | ||||
return IN_PASS; | return IN_PASS; | ||||
} | } |
Wildfire Games · Phabricator
Could invert that to make it early return :)