summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-10-25 01:13:56 +0300
committerAndrei Karas <akaras@inbox.ru>2012-10-25 01:18:02 +0300
commit1e4aa6a5e7476bea736b89fe5d7094b6a68705e5 (patch)
treee1f4bda6bcdf5497ae3e7a6b96afc1af563ee7f7 /src/gui
parentefcee136d7ab46a73286f1ac016d6e3b6a3faed4 (diff)
downloadmv-1e4aa6a5e7476bea736b89fe5d7094b6a68705e5.tar.gz
mv-1e4aa6a5e7476bea736b89fe5d7094b6a68705e5.tar.bz2
mv-1e4aa6a5e7476bea736b89fe5d7094b6a68705e5.tar.xz
mv-1e4aa6a5e7476bea736b89fe5d7094b6a68705e5.zip
Add support for different hover/pickup cursors for monsters, npc, items, etc.
In monsters.xml new monster attribute: hoverCursor - default value "attack". In npcs.xml new npc attribute: hoverCursor - default value "talk". In items.xml new item attribute: pickupCursor - default value "pickup". Warps using "up" cursor for now.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui.cpp2
-rw-r--r--src/gui/gui.h20
-rw-r--r--src/gui/viewport.cpp18
-rw-r--r--src/gui/widgets/window.cpp20
4 files changed, 24 insertions, 36 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index 5939345f0..6e78e3ac8 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -82,7 +82,7 @@ Gui::Gui(Graphics *const graphics) :
mMouseCursors(nullptr),
mMouseCursorAlpha(1.0f),
mMouseInactivityTimer(0),
- mCursorType(CURSOR_POINTER)
+ mCursorType(Cursor::CURSOR_POINTER)
{
logger->log1("Initializing GUI...");
// Set graphics
diff --git a/src/gui/gui.h b/src/gui/gui.h
index c327a4b81..e8969d666 100644
--- a/src/gui/gui.h
+++ b/src/gui/gui.h
@@ -23,6 +23,8 @@
#ifndef GUI_H
#define GUI_H
+#include "resources/cursor.h"
+
#include <guichan/gui.hpp>
#include "localconsts.h"
@@ -139,24 +141,6 @@ class Gui final : public gcn::Gui
void getAbsolutePosition(gcn::Widget *widget, int &x, int &y);
- /**
- * Cursors are in graphic order from left to right.
- * CURSOR_POINTER should be left untouched.
- * CURSOR_TOTAL should always be last.
- */
- enum
- {
- CURSOR_POINTER = 0,
- CURSOR_RESIZE_ACROSS,
- CURSOR_RESIZE_DOWN,
- CURSOR_RESIZE_DOWN_LEFT,
- CURSOR_RESIZE_DOWN_RIGHT,
- CURSOR_FIGHT,
- CURSOR_PICKUP,
- CURSOR_TALK,
- CURSOR_TOTAL
- };
-
protected:
void handleMouseMoved(const gcn::MouseInput &mouseInput);
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 42e6473ee..e7d7ab85d 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -788,6 +788,7 @@ void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED)
if (mTextPopup->isVisible())
mTextPopup->setVisible(false);
}
+ gui->setCursorType(Cursor::CURSOR_UP);
return;
}
}
@@ -801,31 +802,34 @@ void Viewport::mouseMoved(gcn::MouseEvent &event A_UNUSED)
{
// NPCs
case ActorSprite::NPC:
- gui->setCursorType(Gui::CURSOR_TALK);
+ gui->setCursorType(mHoverBeing->getHoverCursor());
break;
// Monsters
case ActorSprite::MONSTER:
- gui->setCursorType(Gui::CURSOR_FIGHT);
+ gui->setCursorType(mHoverBeing->getHoverCursor());
break;
+ case ActorSprite::PORTAL:
+ gui->setCursorType(mHoverBeing->getHoverCursor());
+ break;
+
+ case ActorSprite::FLOOR_ITEM:
case ActorSprite::UNKNOWN:
case ActorSprite::PLAYER:
- case ActorSprite::FLOOR_ITEM:
- case ActorSprite::PORTAL:
default:
- gui->setCursorType(Gui::CURSOR_POINTER);
+ gui->setCursorType(Cursor::CURSOR_POINTER);
break;
}
}
// Item mouseover
else if (mHoverItem)
{
- gui->setCursorType(Gui::CURSOR_PICKUP);
+ gui->setCursorType(mHoverItem->getHoverCursor());
}
else
{
- gui->setCursorType(Gui::CURSOR_POINTER);
+ gui->setCursorType(Cursor::CURSOR_POINTER);
}
}
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index 9128402ad..1a6eb334c 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -131,7 +131,7 @@ Window::Window(const std::string &caption, const bool modal,
if (mModal)
{
- gui->setCursorType(Gui::CURSOR_POINTER);
+ gui->setCursorType(Cursor::CURSOR_POINTER);
requestModalFocus();
}
@@ -443,7 +443,7 @@ void Window::widgetMoved(const gcn::Event& event A_UNUSED)
void Window::widgetHidden(const gcn::Event &event A_UNUSED)
{
if (gui)
- gui->setCursorType(Gui::CURSOR_POINTER);
+ gui->setCursorType(Cursor::CURSOR_POINTER);
if (!mFocusHandler)
return;
@@ -587,7 +587,7 @@ void Window::mouseReleased(gcn::MouseEvent &event A_UNUSED)
{
mouseResize = 0;
if (gui)
- gui->setCursorType(Gui::CURSOR_POINTER);
+ gui->setCursorType(Cursor::CURSOR_POINTER);
}
// This should be the responsibility of Guichan (and is from 0.8.0 on)
@@ -602,7 +602,7 @@ void Window::mouseEntered(gcn::MouseEvent &event)
void Window::mouseExited(gcn::MouseEvent &event A_UNUSED)
{
if (mGrip && !mouseResize && gui)
- gui->setCursorType(Gui::CURSOR_POINTER);
+ gui->setCursorType(Cursor::CURSOR_POINTER);
}
void Window::updateResizeHandler(gcn::MouseEvent &event)
@@ -617,22 +617,22 @@ void Window::updateResizeHandler(gcn::MouseEvent &event)
{
case BOTTOM | RIGHT:
case TOP | LEFT:
- gui->setCursorType(Gui::CURSOR_RESIZE_DOWN_RIGHT);
+ gui->setCursorType(Cursor::CURSOR_RESIZE_DOWN_RIGHT);
break;
case TOP | RIGHT:
case BOTTOM | LEFT:
- gui->setCursorType(Gui::CURSOR_RESIZE_DOWN_LEFT);
+ gui->setCursorType(Cursor::CURSOR_RESIZE_DOWN_LEFT);
break;
case BOTTOM:
case TOP:
- gui->setCursorType(Gui::CURSOR_RESIZE_DOWN);
+ gui->setCursorType(Cursor::CURSOR_RESIZE_DOWN);
break;
case RIGHT:
case LEFT:
- gui->setCursorType(Gui::CURSOR_RESIZE_ACROSS);
+ gui->setCursorType(Cursor::CURSOR_RESIZE_ACROSS);
break;
default:
- gui->setCursorType(Gui::CURSOR_POINTER);
+ gui->setCursorType(Cursor::CURSOR_POINTER);
}
}
@@ -735,7 +735,7 @@ void Window::setModal(bool modal)
if (mModal)
{
if (gui)
- gui->setCursorType(Gui::CURSOR_POINTER);
+ gui->setCursorType(Cursor::CURSOR_POINTER);
requestModalFocus();
}
else