Skip to content

Commit

Permalink
TITANIC: Add support for mouse wheel scrolling conversations log
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Nov 2, 2016
1 parent 088cc0b commit 0f4ca41
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions engines/titanic/core/saveable_object.cpp
Expand Up @@ -835,6 +835,7 @@ DEFFN(CMouseDragMsg);
DEFFN(CMouseDragStartMsg);
DEFFN(CMouseDragMoveMsg);
DEFFN(CMouseDragEndMsg);
DEFFN(CMouseWheelMsg);
DEFFN(CMoveToStartPosMsg);
DEFFN(CMovieEndMsg);
DEFFN(CMovieFrameMsg);
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 5 additions & 0 deletions engines/titanic/events.cpp
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions engines/titanic/events.h
Expand Up @@ -65,6 +65,7 @@ class CEventTarget {
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) {}
};
Expand Down
5 changes: 5 additions & 0 deletions engines/titanic/input_translator.cpp
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions engines/titanic/input_translator.h
Expand Up @@ -50,6 +50,7 @@ class CInputTranslator {
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);

Expand Down
8 changes: 8 additions & 0 deletions engines/titanic/main_game_window.cpp
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions engines/titanic/main_game_window.h
Expand Up @@ -103,6 +103,7 @@ class CMainGameWindow : public CEventTarget {
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);

Expand Down
14 changes: 14 additions & 0 deletions engines/titanic/messages/mouse_messages.h
Expand Up @@ -101,6 +101,20 @@ class CMouseButtonUpMsg : public CMouseButtonMsg {
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;
Expand Down
8 changes: 8 additions & 0 deletions engines/titanic/pet_control/pet_control.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions engines/titanic/pet_control/pet_control.h
Expand Up @@ -116,6 +116,7 @@ class CPetControl : public CGameObject {
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);
Expand Down
9 changes: 9 additions & 0 deletions engines/titanic/pet_control/pet_conversations.cpp
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions engines/titanic/pet_control/pet_conversations.h
Expand Up @@ -164,6 +164,7 @@ class CPetConversations : public CPetSection {
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);

Expand Down
1 change: 1 addition & 0 deletions engines/titanic/pet_control/pet_section.h
Expand Up @@ -106,6 +106,7 @@ class CPetSection {
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; }

Expand Down

0 comments on commit 0f4ca41

Please sign in to comment.