aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2009-12-20 07:09:40 +0000
committerPaul Gilbert2009-12-20 07:09:40 +0000
commitb729218bb6f48a7e57cd938f76ca0065983b792e (patch)
treef939869ed15565eabab224fb831493e34169bd89
parent3da285432b0debb46e2f544b06a442cce47c256f (diff)
downloadscummvm-rg350-b729218bb6f48a7e57cd938f76ca0065983b792e.tar.gz
scummvm-rg350-b729218bb6f48a7e57cd938f76ca0065983b792e.tar.bz2
scummvm-rg350-b729218bb6f48a7e57cd938f76ca0065983b792e.zip
Changed the M4 event handler to encode the keyboard flags into KEVENT_KEY events
svn-id: r46424
-rw-r--r--engines/m4/converse.cpp2
-rw-r--r--engines/m4/converse.h2
-rw-r--r--engines/m4/events.cpp15
-rw-r--r--engines/m4/events.h3
-rw-r--r--engines/m4/gui.cpp12
-rw-r--r--engines/m4/gui.h16
-rw-r--r--engines/m4/m4_menus.cpp2
-rw-r--r--engines/m4/m4_menus.h2
-rw-r--r--engines/m4/m4_views.cpp4
-rw-r--r--engines/m4/m4_views.h4
-rw-r--r--engines/m4/mads_anim.cpp4
-rw-r--r--engines/m4/mads_anim.h4
-rw-r--r--engines/m4/mads_menus.cpp6
-rw-r--r--engines/m4/mads_menus.h6
-rw-r--r--engines/m4/viewmgr.h2
15 files changed, 47 insertions, 37 deletions
diff --git a/engines/m4/converse.cpp b/engines/m4/converse.cpp
index 79baebeb18..63c56c09fa 100644
--- a/engines/m4/converse.cpp
+++ b/engines/m4/converse.cpp
@@ -173,7 +173,7 @@ void ConversationView::onRefresh(RectList *rects, M4Surface *destSurface) {
View::onRefresh(rects, destSurface);
}
-bool ConversationView::onEvent(M4EventType eventType, int param, int x, int y, bool &captureEvents) {
+bool ConversationView::onEvent(M4EventType eventType, int32 param, int x, int y, bool &captureEvents) {
//if (!this->isVisible())
// return false;
if (!_entriesShown)
diff --git a/engines/m4/converse.h b/engines/m4/converse.h
index 4bd4524029..791497b403 100644
--- a/engines/m4/converse.h
+++ b/engines/m4/converse.h
@@ -142,7 +142,7 @@ public:
void setNode(int32 nodeIndex);
void onRefresh(RectList *rects, M4Surface *destSurface);
- bool onEvent(M4EventType eventType, int param, int x, int y, bool &captureEvents);
+ bool onEvent(M4EventType eventType, int32 param, int x, int y, bool &captureEvents);
int32 getCurrentNodeIndex() { return _currentNodeIndex; }
void selectEntry(int entryIndex);
diff --git a/engines/m4/events.cpp b/engines/m4/events.cpp
index 498c40561b..751fe8a353 100644
--- a/engines/m4/events.cpp
+++ b/engines/m4/events.cpp
@@ -50,6 +50,7 @@ Events::Events(M4Engine *vm) : _vm(vm) {
_keyCode = 0;
_console = new Console(_vm);
_mouseButtons = 0;
+ _ctrlFlag = false;
}
M4EventType Events::handleEvents() {
@@ -63,12 +64,20 @@ M4EventType Events::handleEvents() {
quitFlag = true;
break;
case Common::EVENT_KEYDOWN:
- if (_event.kbd.flags == Common::KBD_CTRL) {
- if (_event.kbd.keycode == Common::KEYCODE_d)
+ // Note: The Ctrl-D ScummVM shortcut has been specialised so it will only activate the debugger
+ // if it's the first key pressed after the Ctrl key is held down
+ if ((_event.kbd.keycode == Common::KEYCODE_LCTRL) || (_event.kbd.keycode == Common::KEYCODE_RCTRL))
+ _ctrlFlag = true;
+
+ else if (_event.kbd.flags == Common::KBD_CTRL) {
+ if ((_event.kbd.keycode == Common::KEYCODE_d) && _ctrlFlag) {
_console->attach();
_console->onFrame();
+ }
+ _ctrlFlag = false;
}
- _keyCode = (int)_event.kbd.keycode;
+ _keyCode = (int32)_event.kbd.keycode | (_event.kbd.flags << 24);
+
break;
case Common::EVENT_LBUTTONDOWN:
diff --git a/engines/m4/events.h b/engines/m4/events.h
index c31a870b89..b6b05137cb 100644
--- a/engines/m4/events.h
+++ b/engines/m4/events.h
@@ -71,9 +71,10 @@ private:
M4Engine *_vm;
Common::Event _event;
M4MouseState _mouseState;
- int _keyCode;
+ int32 _keyCode;
int _mouseButtons;
Console *_console;
+ bool _ctrlFlag;
public:
bool quitFlag;
Events(M4Engine *vm);
diff --git a/engines/m4/gui.cpp b/engines/m4/gui.cpp
index 42fc068909..e11a654e64 100644
--- a/engines/m4/gui.cpp
+++ b/engines/m4/gui.cpp
@@ -115,7 +115,7 @@ MenuButton::MenuButton(DialogView *owner, int buttonId, int xs, int ys, int widt
_callback = callbackFn;
}
-bool MenuButton::onEvent(M4EventType event, int param, int x, int y, MenuObject *&currentItem) {
+bool MenuButton::onEvent(M4EventType event, int32 param, int x, int y, MenuObject *&currentItem) {
bool redrawFlag = false;
bool callbackFlag = false;
bool handledFlag = true;
@@ -386,7 +386,7 @@ void MenuHorizSlider::onRefresh() {
sprite->copyTo(parent(), _bounds.left + _thumbX, _bounds.top, 0);
}
-bool MenuHorizSlider::onEvent(M4EventType event, int param, int x, int y, MenuObject *&currentItem) {
+bool MenuHorizSlider::onEvent(M4EventType event, int32 param, int x, int y, MenuObject *&currentItem) {
static bool movingFlag = false;
static int movingX = 0;
bool redrawFlag = false, handledFlag = false, callbackFlag = false;
@@ -568,7 +568,7 @@ void MenuVertSlider::onRefresh() {
thumbSprite->copyTo(parent(), _bounds.left, _bounds.top + _thumbY, 0);
}
-bool MenuVertSlider::onEvent(M4EventType event, int param, int x, int y, MenuObject *&currentItem) {
+bool MenuVertSlider::onEvent(M4EventType event, int32 param, int x, int y, MenuObject *&currentItem) {
static bool movingFlag = false;
static int movingY = 0;
static uint32 callbackTime;
@@ -858,7 +858,7 @@ void MenuSaveLoadText::onRefresh() {
}
}
-bool MenuSaveLoadText::onEvent(M4::M4EventType event, int param, int x, int y, M4::MenuObject *&currentItem) {
+bool MenuSaveLoadText::onEvent(M4::M4EventType event, int32 param, int x, int y, M4::MenuObject *&currentItem) {
if (!_visible) return false;
bool handledFlag = MenuButton::onEvent(event, param, x, y, currentItem);
@@ -985,7 +985,7 @@ void MenuTextField::onRefresh() {
}
}
-bool MenuTextField::onEvent(M4EventType event, int param, int x, int y, MenuObject *&currentItem) {
+bool MenuTextField::onEvent(M4EventType event, int32 param, int x, int y, MenuObject *&currentItem) {
char tempStr[MAX_SAVEGAME_NAME];
int tempLen;
char *tempP;
@@ -1177,7 +1177,7 @@ void GUIButton::onRefresh() {
}
}
-bool GUIButton::onEvent(M4EventType eventType, int param, int x, int y, GUIObject *&currentItem) {
+bool GUIButton::onEvent(M4EventType eventType, int32 param, int x, int y, GUIObject *&currentItem) {
bool result = false;
bool isPressed = (eventType == MEVENT_LEFT_CLICK) || (eventType == MEVENT_LEFT_HOLD) ||
(eventType == MEVENT_LEFT_DRAG);
diff --git a/engines/m4/gui.h b/engines/m4/gui.h
index 9bef495f76..731824518d 100644
--- a/engines/m4/gui.h
+++ b/engines/m4/gui.h
@@ -268,7 +268,7 @@ public:
int getObjectId() { return _objectId; }
void onExecute();
- virtual bool onEvent(M4EventType event, int param, int x, int y, MenuObject *&currentItem) { return false; }
+ virtual bool onEvent(M4EventType event, int32 param, int x, int y, MenuObject *&currentItem) { return false; }
};
class MenuButton: public MenuObject {
@@ -278,7 +278,7 @@ public:
ObjectType buttonType = OBJTYPE_BUTTON);
void onRefresh();
- bool onEvent(M4EventType event, int param, int x, int y, MenuObject *&currentItem);
+ bool onEvent(M4EventType event, int32 param, int x, int y, MenuObject *&currentItem);
bool getToggled() { return _objectType == OBJTYPE_OM_SWITCH_ON; }
};
@@ -297,7 +297,7 @@ public:
int initialPercentage, Callback callbackFn = NULL, bool transparent = false);
void onRefresh();
- bool onEvent(M4EventType event, int param, int x, int y, MenuObject *&currentItem);
+ bool onEvent(M4EventType event, int32 param, int x, int y, MenuObject *&currentItem);
int percent() { return _percent; }
};
@@ -326,7 +326,7 @@ public:
int initialPercentage, Callback callbackFn = NULL, bool transparent = false);
void onRefresh();
- bool onEvent(M4EventType event, int param, int x, int y, MenuObject *&currentItem);
+ bool onEvent(M4EventType event, int32 param, int x, int y, MenuObject *&currentItem);
MenuVertSliderState sliderState() { return _sliderState; }
int percent() { return _percent; }
void setPercentage(int value);
@@ -367,7 +367,7 @@ public:
bool loadFlag = false, const char *displayText = NULL, int displayValue = 0);
void onRefresh();
- bool onEvent(M4EventType event, int param, int x, int y, MenuObject *&currentItem);
+ bool onEvent(M4EventType event, int32 param, int x, int y, MenuObject *&currentItem);
void setDisplay(int value, const char *text) { _displayValue = value; _displayText = text; }
int getIndex() { return _index; }
const char *getText() { return _displayText; }
@@ -388,7 +388,7 @@ public:
int displayValue = 0, bool transparent = true);
void onRefresh();
- bool onEvent(M4EventType event, int param, int x, int y, MenuObject *&currentItem);
+ bool onEvent(M4EventType event, int32 param, int x, int y, MenuObject *&currentItem);
const char *getText() { return _displayText; }
int getDisplayValue() { return _displayValue; }
@@ -401,7 +401,7 @@ private:
public:
GUIRect(View *owner, const Common::Rect &bounds, int tag): GUIObject(owner, bounds) { _tag = tag; };
- virtual bool onEvent(M4EventType eventType, int param, int x, int y, GUIObject *&currentItem) { return false; }
+ virtual bool onEvent(M4EventType eventType, int32 param, int x, int y, GUIObject *&currentItem) { return false; }
int getTag() const { return _tag; }
};
@@ -418,7 +418,7 @@ public:
M4Surface *normalSprite, M4Surface *mouseOverSprite, M4Surface *pressedSprite);
void onRefresh();
- bool onEvent(M4EventType eventType, int param, int x, int y, GUIObject *&currentItem);
+ bool onEvent(M4EventType eventType, int32 param, int x, int y, GUIObject *&currentItem);
GUIButtonState getState() const { return _buttonState; }
};
diff --git a/engines/m4/m4_menus.cpp b/engines/m4/m4_menus.cpp
index 0f36139b45..220f58aac9 100644
--- a/engines/m4/m4_menus.cpp
+++ b/engines/m4/m4_menus.cpp
@@ -532,7 +532,7 @@ void OrionMenuView::destroyView() {
}
}
-bool OrionMenuView::onEvent(M4EventType eventType, int param, int x, int y, bool &captureEvents) {
+bool OrionMenuView::onEvent(M4EventType eventType, int32 param, int x, int y, bool &captureEvents) {
static Common::Point movingPos(0, 0);
static bool movingFlag = false;
diff --git a/engines/m4/m4_menus.h b/engines/m4/m4_menus.h
index f0a0f07333..25d5527957 100644
--- a/engines/m4/m4_menus.h
+++ b/engines/m4/m4_menus.h
@@ -70,7 +70,7 @@ public:
void refresh(const Common::Rect &areaRect);
void close() { _closeFlag = true; }
- bool onEvent(M4EventType eventType, int param, int x, int y, bool &captureEvents);
+ bool onEvent(M4EventType eventType, int32 param, int x, int y, bool &captureEvents);
int _originalMidiVolume;
SaveGameList *_saveNames;
diff --git a/engines/m4/m4_views.cpp b/engines/m4/m4_views.cpp
index f9ad5a6fbd..f089207279 100644
--- a/engines/m4/m4_views.cpp
+++ b/engines/m4/m4_views.cpp
@@ -91,7 +91,7 @@ void GUIInventory::onRefresh() {
}
}
-bool GUIInventory::onEvent(M4EventType eventType, int param, int x, int y, GUIObject *&currentItem) {
+bool GUIInventory::onEvent(M4EventType eventType, int32 param, int x, int y, GUIObject *&currentItem) {
bool result = false;
int overIndex = getInsideIndex(x, y);
bool isPressed = (eventType == MEVENT_LEFT_CLICK) || (eventType == MEVENT_LEFT_HOLD) ||
@@ -268,7 +268,7 @@ void GameInterfaceView::setHighlightedButton(int index) {
_highlightedIndex = index;
}
-bool GameInterfaceView::onEvent(M4EventType eventType, int param, int x, int y, bool &captureEvents) {
+bool GameInterfaceView::onEvent(M4EventType eventType, int32 param, int x, int y, bool &captureEvents) {
static bool selectionFlag = false;
if (eventType == MEVENT_LEFT_RELEASE)
selectionFlag = false;
diff --git a/engines/m4/m4_views.h b/engines/m4/m4_views.h
index ac1a2537ca..577d00b0ec 100644
--- a/engines/m4/m4_views.h
+++ b/engines/m4/m4_views.h
@@ -64,7 +64,7 @@ public:
int horizCells, int vertCells, int cellWidth, int cellHeight, int tag);
void onRefresh();
- bool onEvent(M4EventType eventType, int param, int x, int y, GUIObject *&currentItem);
+ bool onEvent(M4EventType eventType, int32 param, int x, int y, GUIObject *&currentItem);
void add(const char *name, const char *verb, M4Surface *icon, int iconIndex);
bool remove(const char *name);
@@ -104,7 +104,7 @@ public:
~GameInterfaceView();
void onRefresh(RectList *rects, M4Surface *destSurface);
- bool onEvent(M4EventType eventType, int param, int x, int y, bool &captureEvents);
+ bool onEvent(M4EventType eventType, int32 param, int x, int y, bool &captureEvents);
void setStatusText(const char *text) { _statusText.setText(text); }
void cancelSentence() { setStatusText(NULL); }
void inventoryAdd(const char *name, const char *verb, int iconIndex) {
diff --git a/engines/m4/mads_anim.cpp b/engines/m4/mads_anim.cpp
index ef099a6bcc..c8e0ddd89d 100644
--- a/engines/m4/mads_anim.cpp
+++ b/engines/m4/mads_anim.cpp
@@ -120,7 +120,7 @@ void TextviewView::setScript(const char *resourceName, TextviewCallback callback
processLines();
}
-bool TextviewView::onEvent(M4EventType eventType, int param, int x, int y, bool &captureEvents) {
+bool TextviewView::onEvent(M4EventType eventType, int32 param, int x, int y, bool &captureEvents) {
if (!_processEvents)
return false;
@@ -494,7 +494,7 @@ void AnimviewView::setScript(const char *resourceName, AnimviewCallback callback
_script = _vm->res()->get(_resourceName);
}
-bool AnimviewView::onEvent(M4EventType eventType, int param, int x, int y, bool &captureEvents) {
+bool AnimviewView::onEvent(M4EventType eventType, int32 param, int x, int y, bool &captureEvents) {
// Wait for the Escape key or a mouse press
if (((eventType == KEVENT_KEY) && (param == Common::KEYCODE_ESCAPE)) ||
(eventType == MEVENT_LEFT_RELEASE) || (eventType == MEVENT_RIGHT_RELEASE)) {
diff --git a/engines/m4/mads_anim.h b/engines/m4/mads_anim.h
index ad43e57cc7..825d9b8563 100644
--- a/engines/m4/mads_anim.h
+++ b/engines/m4/mads_anim.h
@@ -81,7 +81,7 @@ public:
bool isAnimating() { return _animating; }
void scriptDone();
- bool onEvent(M4EventType eventType, int param1, int x, int y, bool &captureEvents);
+ bool onEvent(M4EventType eventType, int32 param1, int x, int y, bool &captureEvents);
void updateState();
};
@@ -128,7 +128,7 @@ public:
void setScript(const char *resourceName, AnimviewCallback callback);
void scriptDone();
- bool onEvent(M4EventType eventType, int param1, int x, int y, bool &captureEvents);
+ bool onEvent(M4EventType eventType, int32 param1, int x, int y, bool &captureEvents);
void updateState();
};
diff --git a/engines/m4/mads_menus.cpp b/engines/m4/mads_menus.cpp
index d20e04c2e4..2f5a0107bd 100644
--- a/engines/m4/mads_menus.cpp
+++ b/engines/m4/mads_menus.cpp
@@ -88,7 +88,7 @@ RexMainMenuView::~RexMainMenuView() {
}
}
-bool RexMainMenuView::onEvent(M4EventType eventType, int param, int x, int y, bool &captureEvents) {
+bool RexMainMenuView::onEvent(M4EventType eventType, int32 param, int x, int y, bool &captureEvents) {
// Handle keypresses - these can be done at any time, even when the menu items are being drawn
if (eventType == KEVENT_KEY) {
switch (param) {
@@ -351,7 +351,7 @@ MadsMainMenuView::MadsMainMenuView(M4Engine *vm):
}
-bool MadsMainMenuView::onEvent(M4EventType eventType, int param, int x, int y, bool &captureEvents) {
+bool MadsMainMenuView::onEvent(M4EventType eventType, int32 param, int x, int y, bool &captureEvents) {
return false;
}
@@ -394,7 +394,7 @@ DragonMainMenuView::~DragonMainMenuView() {
}
}
-bool DragonMainMenuView::onEvent(M4EventType eventType, int param, int x, int y, bool &captureEvents) {
+bool DragonMainMenuView::onEvent(M4EventType eventType, int32 param, int x, int y, bool &captureEvents) {
char resName[20];
Common::SeekableReadStream *data;
diff --git a/engines/m4/mads_menus.h b/engines/m4/mads_menus.h
index 36d1e1e640..fade6ad5ab 100644
--- a/engines/m4/mads_menus.h
+++ b/engines/m4/mads_menus.h
@@ -52,7 +52,7 @@ public:
RexMainMenuView(M4Engine *vm);
~RexMainMenuView();
- bool onEvent(M4EventType eventType, int param, int x, int y, bool &captureEvents);
+ bool onEvent(M4EventType eventType, int32 param, int x, int y, bool &captureEvents);
void updateState();
};
@@ -74,7 +74,7 @@ public:
DragonMainMenuView(M4Engine *vm);
~DragonMainMenuView();
- bool onEvent(M4EventType eventType, int param, int x, int y, bool &captureEvents);
+ bool onEvent(M4EventType eventType, int32 param, int x, int y, bool &captureEvents);
void updateState();
};
@@ -82,7 +82,7 @@ class MadsMainMenuView: public View {
public:
MadsMainMenuView(M4Engine *vm);
- bool onEvent(M4EventType eventType, int param, int x, int y, bool &captureEvents);
+ bool onEvent(M4EventType eventType, int32 param, int x, int y, bool &captureEvents);
void updateState();
};
diff --git a/engines/m4/viewmgr.h b/engines/m4/viewmgr.h
index 59bd02019b..0da41f1b5e 100644
--- a/engines/m4/viewmgr.h
+++ b/engines/m4/viewmgr.h
@@ -135,7 +135,7 @@ public:
HotkeyList &hotkeys() { return _hotkeys; }
virtual void onRefresh(RectList *rects, M4Surface *destSurface);
- virtual bool onEvent(M4EventType eventType, int param, int x, int y, bool &captureEvents) { return false; }
+ virtual bool onEvent(M4EventType eventType, int32 param, int x, int y, bool &captureEvents) { return false; }
virtual void updateState() {};
protected: