diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-07-13 12:20:19 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-07-13 12:20:19 +0300 |
commit | f0b7627b7d88c1d5bb484961377114b210c8dd53 (patch) | |
tree | a978c3b8eca88759fa71b5fc34112f4bea9bbcec /src/gui | |
parent | d9be27bba8941260500066cdd43ebb016356bc67 (diff) | |
download | mv-f0b7627b7d88c1d5bb484961377114b210c8dd53.tar.gz mv-f0b7627b7d88c1d5bb484961377114b210c8dd53.tar.bz2 mv-f0b7627b7d88c1d5bb484961377114b210c8dd53.tar.xz mv-f0b7627b7d88c1d5bb484961377114b210c8dd53.zip |
Fix code style.
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/focushandler.h | 2 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 42 | ||||
-rw-r--r-- | src/gui/widgets/itemlinkhandler.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/listbox.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/passwordfield.h | 2 |
5 files changed, 28 insertions, 24 deletions
diff --git a/src/gui/focushandler.h b/src/gui/focushandler.h index 99ba45094..1537312f8 100644 --- a/src/gui/focushandler.h +++ b/src/gui/focushandler.h @@ -66,8 +66,6 @@ #ifndef GUI_FOCUSHANDLER_H #define GUI_FOCUSHANDLER_H -#include "gui/focushandler.h" - #include <list> #include <vector> diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 1c0694ca3..fb52607c7 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -166,27 +166,31 @@ void Viewport::draw(Graphics *graphics) { if (player_x > mPixelViewX + mScrollRadius) { - mPixelViewX += static_cast<float>(player_x + mPixelViewX += static_cast<int>( + static_cast<float>(player_x - mPixelViewX - mScrollRadius) / - static_cast<float>(mScrollLaziness); + static_cast<float>(mScrollLaziness)); } if (player_x < mPixelViewX - mScrollRadius) { - mPixelViewX += static_cast<float>(player_x + mPixelViewX += static_cast<int>( + static_cast<float>(player_x - mPixelViewX + mScrollRadius) / - static_cast<float>(mScrollLaziness); + static_cast<float>(mScrollLaziness)); } if (player_y > mPixelViewY + mScrollRadius) { - mPixelViewY += static_cast<float>(player_y - - mPixelViewY - mScrollRadius) / - static_cast<float>(mScrollLaziness); + mPixelViewY += static_cast<int>( + static_cast<float>(player_y + - mPixelViewY - mScrollRadius) / + static_cast<float>(mScrollLaziness)); } if (player_y < mPixelViewY - mScrollRadius) { - mPixelViewY += static_cast<float>(player_y - - mPixelViewY + mScrollRadius) / - static_cast<float>(mScrollLaziness); + mPixelViewY += static_cast<int>( + static_cast<float>(player_y + - mPixelViewY + mScrollRadius) / + static_cast<float>(mScrollLaziness)); } lastTick ++; cnt ++; @@ -407,6 +411,8 @@ bool Viewport::openContextMenu(const MouseEvent &event) } else if (mCameraMode) { + if (!mMap) + return false; mPopupMenu->showMapPopup(eventX, eventY, (mMouseX + mPixelViewX) / mMap->getTileWidth(), (mMouseY + mPixelViewY) / mMap->getTileHeight()); @@ -654,10 +660,10 @@ void Viewport::walkByMouse(const MouseEvent &event) } else { - const int destX = (event.getX() + mPixelViewX) - / static_cast<float>(mMap->getTileWidth()); - const int destY = (event.getY() + mPixelViewY) - / static_cast<float>(mMap->getTileHeight()); + const int destX = static_cast<int>((event.getX() + mPixelViewX) + / static_cast<float>(mMap->getTileWidth())); + const int destY = static_cast<int>((event.getY() + mPixelViewY) + / static_cast<float>(mMap->getTileHeight())); if (playerX != destX || playerY != destY) { if (!player_node->navigateTo(destX, destY)) @@ -1062,8 +1068,8 @@ void Viewport::moveCameraToActor(const int actorId, const Vector &actorPos = actor->getPosition(); const Vector &playerPos = player_node->getPosition(); mCameraMode = 1; - mCameraRelativeX = actorPos.x - playerPos.x + x; - mCameraRelativeY = actorPos.y - playerPos.y + y; + mCameraRelativeX = static_cast<int>(actorPos.x - playerPos.x) + x; + mCameraRelativeY = static_cast<int>(actorPos.y - playerPos.y) + y; } void Viewport::moveCameraToPosition(const int x, const int y) @@ -1074,8 +1080,8 @@ void Viewport::moveCameraToPosition(const int x, const int y) const Vector &playerPos = player_node->getPosition(); mCameraMode = 1; - mCameraRelativeX = x - playerPos.x; - mCameraRelativeY = y - playerPos.y; + mCameraRelativeX = x - static_cast<int>(playerPos.x); + mCameraRelativeY = y - static_cast<int>(playerPos.y); } void Viewport::moveCameraRelative(const int x, const int y) diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp index e5c6c06b3..50e99a24c 100644 --- a/src/gui/widgets/itemlinkhandler.cpp +++ b/src/gui/widgets/itemlinkhandler.cpp @@ -111,9 +111,9 @@ void ItemLinkHandler::handleLink(const std::string &link, MouseEvent *event) splitToIntVector(str, link, ','); if (str.empty()) return; - int color = 1; + unsigned char color = 1; if (str.size() > 1) - color = str[1]; + color = static_cast<unsigned char>(str[1]); const int id = str[0]; if (id > 0) { diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 68b50c458..5a8cc26e8 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -366,7 +366,7 @@ int ListBox::getSelectionByMouse(const int y) const { if (y < mPadding) return -1; - return (y - mPadding) / getRowHeight(); + return static_cast<unsigned int>(y - mPadding) / getRowHeight(); } void ListBox::setSelected(const int selected) diff --git a/src/gui/widgets/passwordfield.h b/src/gui/widgets/passwordfield.h index f72350763..4c05afd40 100644 --- a/src/gui/widgets/passwordfield.h +++ b/src/gui/widgets/passwordfield.h @@ -47,7 +47,7 @@ class PasswordField final : public TextField void draw(Graphics *graphics) override final; protected: - int mPasswordChar; + char mPasswordChar; }; #endif // GUI_WIDGETS_PASSWORDFIELD_H |