diff options
-rw-r--r-- | src/gui/viewport.cpp | 67 | ||||
-rw-r--r-- | src/gui/viewport.h | 42 |
2 files changed, 68 insertions, 41 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index c2000b562..1a28511ed 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -235,7 +235,7 @@ void Viewport::draw(Graphics *graphics) mMap->drawCollision(graphics, mPixelViewX, mPixelViewY, mShowDebugPath); if (mShowDebugPath == Map::MAP_DEBUG) - _drawDebugPath(graphics); + drawDebugPath(graphics); } if (player_node->getCheckNameSetting()) @@ -272,11 +272,11 @@ void Viewport::logic() BLOCK_START("Viewport::logic") // Make the player follow the mouse position // if the mouse is dragged elsewhere than in a window. - _followMouse(); + followMouse(); BLOCK_END("Viewport::logic") } -void Viewport::_followMouse() +void Viewport::followMouse() { if (!gui) return; @@ -296,7 +296,7 @@ void Viewport::_followMouse() } } -void Viewport::_drawDebugPath(Graphics *const graphics) +void Viewport::drawDebugPath(Graphics *const graphics) { if (!player_node || !userPalette || !actorManager || !mMap || !gui) return; @@ -322,7 +322,7 @@ void Viewport::_drawDebugPath(Graphics *const graphics) 500); lastMouseDestination = mouseDestination; } - _drawPath(graphics, debugPath, userPalette->getColorWithAlpha( + drawPath(graphics, debugPath, userPalette->getColorWithAlpha( UserPalette::ROAD_POINT)); const ActorSprites &actors = actorManager->getAll(); @@ -332,14 +332,15 @@ void Viewport::_drawDebugPath(Graphics *const graphics) if (being && being != player_node) { const Path &beingPath = being->getPath(); - _drawPath(graphics, beingPath, userPalette->getColorWithAlpha( + drawPath(graphics, beingPath, userPalette->getColorWithAlpha( UserPalette::ROAD_POINT)); } } } -void Viewport::_drawPath(Graphics *const graphics, const Path &path, - const Color &color) const +void Viewport::drawPath(Graphics *const graphics, + const Path &path, + const Color &color) const { graphics->setColor(color); Font *const font = getFont(); @@ -477,7 +478,7 @@ bool Viewport::leftMouseAction() mPlayerFollowMouse = true; // Make the player go to the mouse position - _followMouse(); + followMouse(); } return false; } @@ -547,9 +548,9 @@ void Viewport::walkByMouse(const MouseEvent &event) { if (!mMap || !player_node) return; - if (mPlayerFollowMouse && !inputManager.isActionActive( - Input::KEY_STOP_ATTACK) && !inputManager.isActionActive( - Input::KEY_UNTARGET)) + if (mPlayerFollowMouse + && !inputManager.isActionActive(Input::KEY_STOP_ATTACK) + && !inputManager.isActionActive(Input::KEY_UNTARGET)) { if (!mMouseDirectionMove) mPlayerFollowMouse = false; @@ -712,8 +713,10 @@ void Viewport::mouseReleased(MouseEvent &event) } } -void Viewport::showPopup(Window *const parent, const int x, const int y, - Item *const item, const bool isInventory) +void Viewport::showPopup(Window *const parent, + const int x, const int y, + Item *const item, + const bool isInventory) { mPopupMenu->showPopup(parent, x, y, item, isInventory); } @@ -723,7 +726,8 @@ void Viewport::showPopup(MapItem *const item) mPopupMenu->showPopup(mMouseX, mMouseY, item); } -void Viewport::showPopup(Window *const parent, Item *const item, +void Viewport::showPopup(Window *const parent, + Item *const item, const bool isInventory) { mPopupMenu->showPopup(parent, mMouseX, mMouseY, item, isInventory); @@ -734,7 +738,8 @@ void Viewport::showItemPopup(Item *const item) mPopupMenu->showItemPopup(mMouseX, mMouseY, item); } -void Viewport::showItemPopup(const int itemId, const unsigned char color) +void Viewport::showItemPopup(const int itemId, + const unsigned char color) { mPopupMenu->showItemPopup(mMouseX, mMouseY, itemId, color); } @@ -759,7 +764,8 @@ void Viewport::showSpellPopup(TextCommand *const cmd) mPopupMenu->showSpellPopup(mMouseX, mMouseY, cmd); } -void Viewport::showChatPopup(const int x, const int y, ChatTab *const tab) +void Viewport::showChatPopup(const int x, const int y, + ChatTab *const tab) { mPopupMenu->showChatPopup(x, y, tab); } @@ -769,7 +775,8 @@ void Viewport::showChatPopup(ChatTab *const tab) mPopupMenu->showChatPopup(mMouseX, mMouseY, tab); } -void Viewport::showPopup(const int x, const int y, const Being *const being) +void Viewport::showPopup(const int x, const int y, + const Being *const being) { mPopupMenu->showPopup(x, y, being); } @@ -784,7 +791,8 @@ void Viewport::showPlayerPopup(const std::string &nick) mPopupMenu->showPlayerPopup(mMouseX, mMouseY, nick); } -void Viewport::showPopup(const int x, const int y, Button *const button) +void Viewport::showPopup(const int x, const int y, + Button *const button) { mPopupMenu->showPopup(x, y, button); } @@ -795,7 +803,8 @@ void Viewport::showPopup(const int x, const int y, mPopupMenu->showPopup(x, y, bar); } -void Viewport::showAttackMonsterPopup(const std::string &name, const int type) +void Viewport::showAttackMonsterPopup(const std::string &name, + const int type) { mPopupMenu->showAttackMonsterPopup(mMouseX, mMouseY, name, type); } @@ -806,7 +815,8 @@ void Viewport::showPickupItemPopup(const std::string &name) } void Viewport::showUndressPopup(const int x, const int y, - const Being *const being, Item *const item) + const Being *const being, + Item *const item) { mPopupMenu->showUndressPopup(x, y, being, item); } @@ -869,10 +879,14 @@ void Viewport::mouseMoved(MouseEvent &event A_UNUSED) const int x = mMouseX + mPixelViewX; const int y = mMouseY + mPixelViewY; + ActorSprite::Type type = ActorSprite::UNKNOWN; + if (mHoverBeing) + type = mHoverBeing->getType(); mHoverBeing = actorManager->findBeingByPixel(x, y, true); - if (mHoverBeing && (mHoverBeing->getType() == Being::PLAYER - || mHoverBeing->getType() == Being::NPC - || mHoverBeing->getType() == Being::PET)) + if (mHoverBeing + && (type == Being::PLAYER + || type == Being::NPC + || type == Being::PET)) { mTextPopup->setVisible(false); if (mShowBeingPopup) @@ -920,7 +934,7 @@ void Viewport::mouseMoved(MouseEvent &event A_UNUSED) if (mHoverBeing) { - switch (mHoverBeing->getType()) + switch (type) { case ActorSprite::NPC: gui->setCursorType(mHoverBeing->getHoverCursor()); @@ -1013,7 +1027,8 @@ bool Viewport::isPopupMenuVisible() const return mPopupMenu ? mPopupMenu->isPopupVisible() : false; } -void Viewport::moveCameraToActor(const int actorId, const int x, const int y) +void Viewport::moveCameraToActor(const int actorId, + const int x, const int y) { if (!player_node || !actorManager) return; diff --git a/src/gui/viewport.h b/src/gui/viewport.h index c98350744..a627702d8 100644 --- a/src/gui/viewport.h +++ b/src/gui/viewport.h @@ -124,32 +124,39 @@ class Viewport final : public WindowContainer, * Shows a popup for an item. * TODO Find some way to get rid of Item here */ - void showPopup(Window *const parent, const int x, const int y, - Item *const item, const bool isInventory = true); + void showPopup(Window *const parent, + const int x, const int y, + Item *const item, + const bool isInventory = true); /** * Shows a popup for an item. * TODO Find some way to get rid of Item here */ - void showPopup(Window *const parent, Item *const item, + void showPopup(Window *const parent, + Item *const item, const bool isInventory = true); - void showPopup(const int x, const int y, Button *const button); + void showPopup(const int x, const int y, + Button *const button); - void showPopup(const int x, const int y, const ProgressBar *const bar); + void showPopup(const int x, const int y, + const ProgressBar *const bar); void showPopup(MapItem *const item); void showItemPopup(Item *const item); - void showItemPopup(const int itemId, const unsigned char color = 1); + void showItemPopup(const int itemId, + const unsigned char color = 1); void showDropPopup(Item *const item); /** * Shows a popup for being. */ - void showPopup(const int x, const int y, const Being *const being); + void showPopup(const int x, const int y, + const Being *const being); void showPopup(const Being *const being); @@ -161,7 +168,8 @@ class Viewport final : public WindowContainer, void showSpellPopup(TextCommand *const cmd); - void showAttackMonsterPopup(const std::string &name, const int type); + void showAttackMonsterPopup(const std::string &name, + const int type); void showPickupItemPopup(const std::string &name); @@ -169,7 +177,8 @@ class Viewport final : public WindowContainer, * Shows the related popup menu when right click on the chat * at the specified mouse coordinates. */ - void showChatPopup(const int x, const int y, ChatTab *const tab); + void showChatPopup(const int x, const int y, + ChatTab *const tab); /** * Shows the related popup menu when right click on the chat @@ -177,7 +186,8 @@ class Viewport final : public WindowContainer, void showChatPopup(ChatTab *const tab); void showUndressPopup(const int x, const int y, - const Being *const being, Item *const item); + const Being *const being, + Item *const item); void showMapPopup(const int x, const int y); @@ -268,7 +278,8 @@ class Viewport final : public WindowContainer, bool isPopupMenuVisible() const A_WARN_UNUSED; - void moveCameraToActor(const int actorId, const int x = 0, + void moveCameraToActor(const int actorId, + const int x = 0, const int y = 0); void moveCameraToPosition(const int x, const int y); @@ -292,13 +303,14 @@ class Viewport final : public WindowContainer, * Finds a path from the player to the mouse, and draws it. This is for * debug purposes. */ - void _drawDebugPath(Graphics *const graphics); + void drawDebugPath(Graphics *const graphics); /** * Draws the given path. */ - void _drawPath(Graphics *const graphics, const Path &path, - const Color &color = Color(255, 0, 0)) const; + void drawPath(Graphics *const graphics, + const Path &path, + const Color &color = Color(255, 0, 0)) const; bool leftMouseAction(); @@ -309,7 +321,7 @@ class Viewport final : public WindowContainer, /** * Make the player go to the mouse position. */ - void _followMouse(); + void followMouse(); Map *mMap; /**< The current map. */ |