summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-08-03 00:46:38 +0300
committerAndrei Karas <akaras@inbox.ru>2014-08-03 13:17:37 +0300
commit8b2464a723f7039a3efbc0c7d2e883729b3fa7dd (patch)
tree0564c85d8f6301d8a0b916f37612e27788d82853 /src/gui
parent63054bddcc1a306787250209b03c04086b9b472f (diff)
downloadmv-8b2464a723f7039a3efbc0c7d2e883729b3fa7dd.tar.gz
mv-8b2464a723f7039a3efbc0c7d2e883729b3fa7dd.tar.bz2
mv-8b2464a723f7039a3efbc0c7d2e883729b3fa7dd.tar.xz
mv-8b2464a723f7039a3efbc0c7d2e883729b3fa7dd.zip
Fix some casts.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui.cpp5
-rw-r--r--src/gui/popupmanager.cpp2
-rw-r--r--src/gui/popupmanager.h14
-rw-r--r--src/gui/popups/popupmenu.cpp3
-rw-r--r--src/gui/viewport.cpp4
-rw-r--r--src/gui/widgets/avatarlistbox.cpp23
-rw-r--r--src/gui/widgets/dropdown.cpp2
-rw-r--r--src/gui/widgets/dropshortcutcontainer.cpp2
-rw-r--r--src/gui/widgets/itemcontainer.cpp2
-rw-r--r--src/gui/widgets/itemlinkhandler.cpp2
-rw-r--r--src/gui/widgets/scrollarea.cpp2
-rw-r--r--src/gui/widgets/spellshortcutcontainer.cpp4
-rw-r--r--src/gui/widgets/window.cpp2
13 files changed, 39 insertions, 28 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 7ac1273bd..0f8561643 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -488,7 +488,8 @@ void Gui::draw()
const int posY = mouseY - (image->mBounds.h / 2);
mGraphics->drawImage(image, posX, posY);
}
- Image *const mouseCursor = mMouseCursors->get(mCursorType);
+ Image *const mouseCursor = mMouseCursors->get(
+ static_cast<int>(mCursorType));
if (mouseCursor)
{
mouseCursor->setAlpha(mMouseCursorAlpha);
@@ -845,7 +846,7 @@ void Gui::distributeMouseEvent(Widget *const source,
std::list<MouseListener*> mouseListeners
= widget->getMouseListeners();
- unsigned int mouseType = event.getType();
+ const MouseEventType::Type mouseType = event.getType();
// Send the event to all mouse listeners of the widget.
FOR_EACH (std::list<MouseListener*>::const_iterator,
it, mouseListeners)
diff --git a/src/gui/popupmanager.cpp b/src/gui/popupmanager.cpp
index 24c816008..45899a380 100644
--- a/src/gui/popupmanager.cpp
+++ b/src/gui/popupmanager.cpp
@@ -168,7 +168,7 @@ void PopupManager::showPopup(const int x, const int y,
}
void PopupManager::showAttackMonsterPopup(const std::string &name,
- const int type)
+ const ActorType::Type &type)
{
mPopupMenu->showAttackMonsterPopup(viewport->getMouseX(),
viewport->getMouseY(),
diff --git a/src/gui/popupmanager.h b/src/gui/popupmanager.h
index fcd0f0919..3e54b1742 100644
--- a/src/gui/popupmanager.h
+++ b/src/gui/popupmanager.h
@@ -23,6 +23,13 @@
#ifndef GUI_POPUPMANAGER_H
#define GUI_POPUPMANAGER_H
+#include "being/actortype.h"
+
+#include <string>
+#include <vector>
+
+#include "localconsts.h"
+
class ActorSprite;
class Button;
class Being;
@@ -38,11 +45,6 @@ class TextField;
class TextPopup;
class Window;
-#include <string>
-#include <vector>
-
-#include "localconsts.h"
-
class PopupManager final
{
public:
@@ -115,7 +117,7 @@ class PopupManager final
void showSpellPopup(TextCommand *const cmd);
void showAttackMonsterPopup(const std::string &name,
- const int type);
+ const ActorType::Type &type);
void showPickupItemPopup(const std::string &name);
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index bd8ed9206..aac6c1b21 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -1419,7 +1419,8 @@ void PopupMenu::handleLink(const std::string &link,
}
else
{
- dialog->setText(Being::loadComment(mNick, mType));
+ dialog->setText(Being::loadComment(mNick,
+ static_cast<ActorType::Type>(mType)));
}
dialog->setActionEventId("ok");
dialog->addActionListener(&mPlayerListener);
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index d0ac02d4c..353a5595f 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -500,7 +500,7 @@ void Viewport::mousePressed(MouseEvent &event)
mMousePressX = event.getX();
mMousePressY = event.getY();
- const unsigned int eventButton = event.getButton();
+ const MouseButton::Type eventButton = event.getButton();
const int pixelX = mMousePressX + mPixelViewX;
const int pixelY = mMousePressY + mPixelViewY;
@@ -697,7 +697,7 @@ void Viewport::mouseReleased(MouseEvent &event)
mMouseClicked = false;
if (event.getSource() != this || event.isConsumed())
return;
- const unsigned int eventButton = event.getButton();
+ const MouseButton::Type eventButton = event.getButton();
if (eventButton == MouseButton::LEFT)
{
// long button press
diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp
index 6369efce8..36c6592fd 100644
--- a/src/gui/widgets/avatarlistbox.cpp
+++ b/src/gui/widgets/avatarlistbox.cpp
@@ -129,7 +129,9 @@ void AvatarListBox::draw(Graphics *graphics)
if (!a)
continue;
- if (a->getType() != MapItemType::SEPARATOR)
+ const MapItemType::Type type = static_cast<MapItemType::Type>(
+ a->getType());
+ if (type != MapItemType::SEPARATOR)
{
// Draw online status
const Image *const icon = a->getOnline()
@@ -165,6 +167,8 @@ void AvatarListBox::draw(Graphics *graphics)
if (!a)
continue;
+ const MapItemType::Type type = static_cast<MapItemType::Type>(
+ a->getType());
std::string text;
if (a->getMaxHp() > 0)
@@ -304,7 +308,7 @@ void AvatarListBox::draw(Graphics *graphics)
// Draw Name
if (a->getDisplayBold())
{
- if (a->getType() == MapItemType::SEPARATOR)
+ if (type == MapItemType::SEPARATOR)
{
boldFont->drawString(graphics, text,
mImagePadding + mPadding, y + mPadding);
@@ -317,7 +321,7 @@ void AvatarListBox::draw(Graphics *graphics)
}
else
{
- if (a->getType() == MapItemType::SEPARATOR)
+ if (type == MapItemType::SEPARATOR)
{
font->drawString(graphics, text, mImagePadding + mPadding,
y + mPadding);
@@ -357,11 +361,14 @@ void AvatarListBox::mousePressed(MouseEvent &event)
if (!ava)
return;
+ const MapItemType::Type type = static_cast<MapItemType::Type>(
+ ava->getType());
+
event.consume();
const unsigned int eventButton = event.getButton();
if (eventButton == MouseButton::LEFT)
{
- if (ava->getType() == AVATAR_PLAYER)
+ if (type == MapItemType::EMPTY)
{
const Being *const being = actorManager->findBeingByName(
ava->getName(), ActorType::PLAYER);
@@ -375,9 +382,8 @@ void AvatarListBox::mousePressed(MouseEvent &event)
}
else if (eventButton == MouseButton::RIGHT)
{
- switch (ava->getType())
+ switch (type)
{
- // AVATAR_PLAYER
case MapItemType::EMPTY:
{
const Avatar *const avatar = model->getAvatarAt(selected);
@@ -403,7 +409,8 @@ void AvatarListBox::mousePressed(MouseEvent &event)
name = model->getAvatarAt(selected)->getName();
popupManager->showAttackMonsterPopup(name,
- model->getAvatarAt(selected)->getType());
+ static_cast<ActorType::Type>(model->getAvatarAt(
+ selected)->getType()));
break;
}
case MapItemType::PICKUP:
@@ -434,7 +441,7 @@ void AvatarListBox::mousePressed(MouseEvent &event)
}
else if (eventButton == MouseButton::MIDDLE)
{
- if (ava->getType() == AVATAR_PLAYER && chatWindow)
+ if (type == MapItemType::EMPTY && chatWindow)
{
const WhisperTab *const tab = chatWindow->addWhisperTab(
model->getAvatarAt(selected)->getName(), true);
diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp
index 6647a768f..7957b0587 100644
--- a/src/gui/widgets/dropdown.cpp
+++ b/src/gui/widgets/dropdown.cpp
@@ -380,7 +380,7 @@ void DropDown::mouseReleased(MouseEvent &event)
if (mIsDragged)
mPushed = false;
- const int button = event.getButton();
+ const MouseButton::Type button = event.getButton();
const int x = event.getX();
const int y = event.getY();
// Released outside of widget. Can happen when we have modal
diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp
index 5ec847922..b57c98273 100644
--- a/src/gui/widgets/dropshortcutcontainer.cpp
+++ b/src/gui/widgets/dropshortcutcontainer.cpp
@@ -189,7 +189,7 @@ void DropShortcutContainer::mousePressed(MouseEvent &event)
event.consume();
- const int eventButton = event.getButton();
+ const MouseButton::Type eventButton = event.getButton();
if (eventButton == MouseButton::LEFT)
{
if (dropShortcut->getItem(index) > 0)
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index ef00913e7..3842daf17 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -403,7 +403,7 @@ void ItemContainer::mousePressed(MouseEvent &event)
if (!mInventory)
return;
- const int button = event.getButton();
+ const MouseButton::Type button = event.getButton();
mClicks = event.getClickCount();
if (button == MouseButton::LEFT || button == MouseButton::RIGHT)
diff --git a/src/gui/widgets/itemlinkhandler.cpp b/src/gui/widgets/itemlinkhandler.cpp
index e8976da67..2217b051f 100644
--- a/src/gui/widgets/itemlinkhandler.cpp
+++ b/src/gui/widgets/itemlinkhandler.cpp
@@ -68,7 +68,7 @@ void ItemLinkHandler::handleLink(const std::string &link, MouseEvent *event)
std::string url = link;
replaceAll(url, " ", "");
listener.url = url;
- const int button = event->getButton();
+ const MouseButton::Type button = event->getButton();
if (button == MouseButton::LEFT)
{
ConfirmDialog *const confirmDlg = new ConfirmDialog(
diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp
index 028c2e7b1..12b9a8e7f 100644
--- a/src/gui/widgets/scrollarea.cpp
+++ b/src/gui/widgets/scrollarea.cpp
@@ -486,7 +486,7 @@ Image *ScrollArea::getImageByState(Rect &dim, const BUTTON_DIR dir)
+ toString(static_cast<unsigned>(dir)));
return nullptr;
}
- return buttons[dir][state];
+ return buttons[static_cast<size_t>(dir)][state];
}
void ScrollArea::drawButton(Graphics *const graphics,
diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp
index 33579b5a9..8960725d5 100644
--- a/src/gui/widgets/spellshortcutcontainer.cpp
+++ b/src/gui/widgets/spellshortcutcontainer.cpp
@@ -164,7 +164,7 @@ void SpellShortcutContainer::mousePressed(MouseEvent &event)
if (index == -1)
return;
- const unsigned int eventButton = event.getButton();
+ const MouseButton::Type eventButton = event.getButton();
if (eventButton == MouseButton::LEFT)
{
const int itemId = getItemByIndex(index);
@@ -200,7 +200,7 @@ void SpellShortcutContainer::mouseReleased(MouseEvent &event)
}
const int itemId = getItemByIndex(index);
- const unsigned int eventButton = event.getButton();
+ const MouseButton::Type eventButton = event.getButton();
if (eventButton == MouseButton::LEFT)
{
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index a4fb2d57f..2078c4cef 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -727,7 +727,7 @@ void Window::mousePressed(MouseEvent &event)
mMoved = event.getY() <= static_cast<int>(mTitleBarHeight);
}
- const unsigned int button = event.getButton();
+ const MouseButton::Type button = event.getButton();
if (button == MouseButton::LEFT)
{
const int x = event.getX();