TITANIC: Add support for mouse wheel scrolling conversations log

This commit is contained in:
Paul Gilbert 2016-11-01 22:30:21 -04:00
parent 088cc0bff8
commit 0f4ca41dad
13 changed files with 57 additions and 0 deletions

View File

@ -835,6 +835,7 @@ DEFFN(CMouseDragMsg);
DEFFN(CMouseDragStartMsg);
DEFFN(CMouseDragMoveMsg);
DEFFN(CMouseDragEndMsg);
DEFFN(CMouseWheelMsg);
DEFFN(CMoveToStartPosMsg);
DEFFN(CMovieEndMsg);
DEFFN(CMovieFrameMsg);
@ -1426,6 +1427,7 @@ void CSaveableObject::initClassList() {
ADDFN(CMouseDragStartMsg, CMouseDragMsg);
ADDFN(CMouseDragMoveMsg, CMouseDragMsg);
ADDFN(CMouseDragEndMsg, CMouseDragMsg);
ADDFN(CMouseWheelMsg, CMouseMsg);
ADDFN(CMoveToStartPosMsg, CMessage);
ADDFN(CMovieEndMsg, CMessage);
ADDFN(CMovieFrameMsg, CMessage);

View File

@ -70,6 +70,11 @@ void Events::pollEvents() {
_mousePos = event.mouse;
eventTarget()->rightButtonUp(_mousePos);
break;
case Common::EVENT_WHEELUP:
case Common::EVENT_WHEELDOWN:
_mousePos = event.mouse;
eventTarget()->mouseWheel(_mousePos, event.type == Common::EVENT_WHEELUP);
break;
case Common::EVENT_KEYDOWN:
eventTarget()->keyDown(event.kbd);
break;

View File

@ -65,6 +65,7 @@ public:
virtual void middleButtonDoubleClick(const Point &mousePos) {}
virtual void rightButtonDown(const Point &mousePos) {}
virtual void rightButtonUp(const Point &mousePos) {}
virtual void mouseWheel(const Point &mousePos, bool wheelUp) {}
virtual void keyDown(Common::KeyState keyState) {}
virtual void keyUp(Common::KeyState keyState) {}
};

View File

@ -90,6 +90,11 @@ void CInputTranslator::rightButtonUp(int special, const Point &pt) {
_inputHandler->handleMessage(msg);
}
void CInputTranslator::mouseWheel(bool wheelUp, const Point &pt) {
CMouseWheelMsg msg(pt, wheelUp);
_inputHandler->handleMessage(msg);
}
void CInputTranslator::rightButtonDoubleClick(int special, const Point &pt) {
CMouseDoubleClickMsg msg(pt, MB_RIGHT);
_inputHandler->handleMessage(msg);

View File

@ -50,6 +50,7 @@ public:
void middleButtonDoubleClick(int special, const Point &pt);
void rightButtonDown(int special, const Point &pt);
void rightButtonUp(int special, const Point &pt);
void mouseWheel(bool wheelUp, const Point &pt);
void rightButtonDoubleClick(int special, const Point &pt);
void keyDown(const Common::KeyState &keyState);

View File

@ -341,6 +341,14 @@ void CMainGameWindow::rightButtonUp(const Point &mousePos) {
HANDLE_MESSAGE(rightButtonUp)
}
void CMainGameWindow::mouseWheel(const Point &mousePos, bool wheelUp) {
if (!isMouseControlEnabled())
return;
_gameManager->_inputTranslator.mouseWheel(wheelUp, mousePos);
mouseChanged();
}
void CMainGameWindow::rightButtonDoubleClick(const Point &mousePos) {
if (!isMouseControlEnabled())
return;

View File

@ -103,6 +103,7 @@ public:
virtual void middleButtonUp(const Point &mousePos);
virtual void rightButtonDown(const Point &mousePos);
virtual void rightButtonUp(const Point &mousePos);
virtual void mouseWheel(const Point &mousePos, bool wheelUp);
virtual void keyDown(Common::KeyState keyState);
virtual void keyUp(Common::KeyState keyState);

View File

@ -101,6 +101,20 @@ public:
static void generate();
};
class CMouseWheelMsg : public CMouseMsg {
public:
bool _wheelUp;
public:
CLASSDEF;
CMouseWheelMsg() : CMouseMsg(), _wheelUp(false) {}
CMouseWheelMsg(const Point &pt, bool wheelUp) :
CMouseMsg(pt, 0), _wheelUp(wheelUp) {}
static bool isSupportedBy(const CTreeItem *item) {
return supports(item, _type);
}
};
class CMouseDoubleClickMsg : public CMouseButtonMsg {
public:
CLASSDEF;

View File

@ -37,6 +37,7 @@ BEGIN_MESSAGE_MAP(CPetControl, CGameObject)
ON_MESSAGE(MouseDragEndMsg)
ON_MESSAGE(MouseButtonUpMsg)
ON_MESSAGE(MouseDoubleClickMsg)
ON_MESSAGE(MouseWheelMsg)
ON_MESSAGE(KeyCharMsg)
ON_MESSAGE(VirtualKeyCharMsg)
ON_MESSAGE(TimerMsg)
@ -317,6 +318,13 @@ bool CPetControl::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) {
return _sections[_currentArea]->MouseDoubleClickMsg(msg);
}
bool CPetControl::MouseWheelMsg(CMouseWheelMsg *msg) {
if (!containsPt(msg->_mousePos) || isInputLocked())
return false;
return _sections[_currentArea]->MouseWheelMsg(msg);
}
bool CPetControl::KeyCharMsg(CKeyCharMsg *msg) {
if (isInputLocked())
return false;

View File

@ -116,6 +116,7 @@ protected:
bool MouseDragEndMsg(CMouseDragEndMsg *msg);
bool MouseButtonUpMsg(CMouseButtonUpMsg *msg);
bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg);
bool MouseWheelMsg(CMouseWheelMsg *msg);
bool KeyCharMsg(CKeyCharMsg *msg);
bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg);
bool TimerMsg(CTimerMsg *msg);

View File

@ -203,6 +203,15 @@ bool CPetConversations::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) {
|| _scrollUp.MouseDoubleClickMsg(msg->_mousePos);
}
bool CPetConversations::MouseWheelMsg(CMouseWheelMsg *msg) {
if (msg->_wheelUp)
scrollUp();
else
scrollDown();
return true;
}
bool CPetConversations::KeyCharMsg(CKeyCharMsg *msg) {
Common::KeyState keyState;
keyState.ascii = msg->_key;

View File

@ -164,6 +164,7 @@ public:
virtual bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
virtual bool MouseButtonUpMsg(CMouseButtonUpMsg *msg);
virtual bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg);
virtual bool MouseWheelMsg(CMouseWheelMsg *msg);
virtual bool KeyCharMsg(CKeyCharMsg *msg);
virtual bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg);

View File

@ -106,6 +106,7 @@ public:
virtual bool MouseDragEndMsg(CMouseDragEndMsg *msg) { return false; }
virtual bool MouseButtonUpMsg(CMouseButtonUpMsg *msg) { return false; }
virtual bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) { return false; }
virtual bool MouseWheelMsg(CMouseWheelMsg *msg) { return false; }
virtual bool KeyCharMsg(CKeyCharMsg *msg) { return false; }
virtual bool VirtualKeyCharMsg(CVirtualKeyCharMsg *msg) { return false; }