aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute
diff options
context:
space:
mode:
authorEinar Johan Trøan Sømåen2012-06-14 16:13:26 +0200
committerEinar Johan Trøan Sømåen2012-06-14 16:13:26 +0200
commitfbc71915493f8162a674e0c83d470bfe6eb80a42 (patch)
treeb4950a65c01f996e28f226180e5a9080422582c7 /engines/wintermute
parentd14fd7b1a352df6e94247e325f679cc25fef671c (diff)
downloadscummvm-rg350-fbc71915493f8162a674e0c83d470bfe6eb80a42.tar.gz
scummvm-rg350-fbc71915493f8162a674e0c83d470bfe6eb80a42.tar.bz2
scummvm-rg350-fbc71915493f8162a674e0c83d470bfe6eb80a42.zip
WINTERMUTE: Add a quick-fix to replace SDL_TEXTINPUT.
Diffstat (limited to 'engines/wintermute')
-rw-r--r--engines/wintermute/Base/BGame.cpp4
-rw-r--r--engines/wintermute/Base/BGame.h2
-rw-r--r--engines/wintermute/Base/BKeyboardState.cpp2
-rw-r--r--engines/wintermute/Base/BObject.cpp2
-rw-r--r--engines/wintermute/Base/BObject.h2
-rw-r--r--engines/wintermute/UI/UIEdit.cpp13
-rw-r--r--engines/wintermute/UI/UIEdit.h2
-rw-r--r--engines/wintermute/UI/UIWindow.cpp4
-rw-r--r--engines/wintermute/UI/UIWindow.h2
9 files changed, 17 insertions, 16 deletions
diff --git a/engines/wintermute/Base/BGame.cpp b/engines/wintermute/Base/BGame.cpp
index 4aea2816e4..46abfe16cf 100644
--- a/engines/wintermute/Base/BGame.cpp
+++ b/engines/wintermute/Base/BGame.cpp
@@ -3793,7 +3793,7 @@ HRESULT CBGame::Unfreeze() {
//////////////////////////////////////////////////////////////////////////
-bool CBGame::HandleKeypress(Common::Event *event) {
+bool CBGame::HandleKeypress(Common::Event *event, bool printable) {
if(IsVideoPlaying()) {
if(event->kbd.keycode == Common::KEYCODE_ESCAPE)
StopVideo();
@@ -3821,7 +3821,7 @@ bool CBGame::HandleKeypress(Common::Event *event) {
// TODO
if (_focusedWindow) {
- if (!Game->_focusedWindow->HandleKeypress(event)) {
+ if (!Game->_focusedWindow->HandleKeypress(event, _keyboardState->_currentPrintable)) {
/*if (event->type != SDL_TEXTINPUT) {*/
if (Game->_focusedWindow->CanHandleEvent("Keypress"))
Game->_focusedWindow->ApplyEvent("Keypress");
diff --git a/engines/wintermute/Base/BGame.h b/engines/wintermute/Base/BGame.h
index 897ae7c40a..a727978dd3 100644
--- a/engines/wintermute/Base/BGame.h
+++ b/engines/wintermute/Base/BGame.h
@@ -260,7 +260,7 @@ public:
bool _quitting;
virtual HRESULT GetVersion(byte *VerMajor, byte *VerMinor, byte *ExtMajor, byte *ExtMinor);
- virtual bool HandleKeypress(Common::Event *event);
+ virtual bool HandleKeypress(Common::Event *event, bool printable = false);
virtual bool handleKeyRelease(Common::Event *event);
int _freezeLevel;
HRESULT Unfreeze();
diff --git a/engines/wintermute/Base/BKeyboardState.cpp b/engines/wintermute/Base/BKeyboardState.cpp
index 4b1ba919bb..32a5d529eb 100644
--- a/engines/wintermute/Base/BKeyboardState.cpp
+++ b/engines/wintermute/Base/BKeyboardState.cpp
@@ -201,6 +201,8 @@ HRESULT CBKeyboardState::ReadKey(Common::Event *event) {
if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) ||
(_currentCharCode <= Common::KEYCODE_9 && _currentCharCode >= Common::KEYCODE_0)) {
_currentPrintable = true;
+ } else {
+ _currentPrintable = false;
}
//_currentKeyData = KeyData;
diff --git a/engines/wintermute/Base/BObject.cpp b/engines/wintermute/Base/BObject.cpp
index 9f34541087..f947fdb1f5 100644
--- a/engines/wintermute/Base/BObject.cpp
+++ b/engines/wintermute/Base/BObject.cpp
@@ -960,7 +960,7 @@ HRESULT CBObject::HandleMouse(TMouseEvent Event, TMouseButton Button) {
//////////////////////////////////////////////////////////////////////////
-bool CBObject::HandleKeypress(Common::Event *event) {
+bool CBObject::HandleKeypress(Common::Event *event, bool printable) {
return false;
}
diff --git a/engines/wintermute/Base/BObject.h b/engines/wintermute/Base/BObject.h
index 475325e8e2..20bc17baac 100644
--- a/engines/wintermute/Base/BObject.h
+++ b/engines/wintermute/Base/BObject.h
@@ -81,7 +81,7 @@ public:
virtual bool HandleMouseWheel(int Delta);
virtual HRESULT HandleMouse(TMouseEvent Event, TMouseButton Button);
- virtual bool HandleKeypress(Common::Event *event);
+ virtual bool HandleKeypress(Common::Event *event, bool printable = false);
virtual int GetHeight();
HRESULT SetCursor(const char *Filename);
HRESULT SetActiveCursor(const char *Filename);
diff --git a/engines/wintermute/UI/UIEdit.cpp b/engines/wintermute/UI/UIEdit.cpp
index b85159240f..54c85021c9 100644
--- a/engines/wintermute/UI/UIEdit.cpp
+++ b/engines/wintermute/UI/UIEdit.cpp
@@ -686,10 +686,10 @@ HRESULT CUIEdit::Display(int OffsetX, int OffsetY) {
//////////////////////////////////////////////////////////////////////////
-bool CUIEdit::HandleKeypress(Common::Event *event) {
+bool CUIEdit::HandleKeypress(Common::Event *event, bool printable) {
bool Handled = false;
- if (event->type == Common::EVENT_KEYDOWN) {
+ if (event->type == Common::EVENT_KEYDOWN && !printable) {
switch (event->kbd.keycode) {
case Common::KEYCODE_ESCAPE:
case Common::KEYCODE_TAB:
@@ -769,12 +769,11 @@ bool CUIEdit::HandleKeypress(Common::Event *event) {
break;
}
return Handled;
- }
-#if 0
- else if (event->type == SDL_TEXTINPUT) {
+ } else if (event->type == Common::EVENT_KEYDOWN && printable) {
if (_selStart != _selEnd) DeleteChars(_selStart, _selEnd);
- WideString wstr = StringUtil::Utf8ToWide(event->text.text);
+ //WideString wstr = StringUtil::Utf8ToWide(event->kbd.ascii);
+ WideString wstr; wstr += (char)event->kbd.ascii;
_selEnd += InsertChars(_selEnd, (byte *)StringUtil::WideToAnsi(wstr).c_str(), 1);
if (Game->_textRTL) _selEnd = _selStart;
@@ -782,7 +781,7 @@ bool CUIEdit::HandleKeypress(Common::Event *event) {
return true;
}
-#endif
+
return false;
}
diff --git a/engines/wintermute/UI/UIEdit.h b/engines/wintermute/UI/UIEdit.h
index 3b8698d55d..4771a0f772 100644
--- a/engines/wintermute/UI/UIEdit.h
+++ b/engines/wintermute/UI/UIEdit.h
@@ -44,7 +44,7 @@ public:
bool _cursorVisible;
uint32 _lastBlinkTime;
virtual HRESULT Display(int OffsetX, int OffsetY);
- virtual bool HandleKeypress(Common::Event *event);
+ virtual bool HandleKeypress(Common::Event *event, bool printable = false);
int _scrollOffset;
int _frameWidth;
uint32 _cursorBlinkRate;
diff --git a/engines/wintermute/UI/UIWindow.cpp b/engines/wintermute/UI/UIWindow.cpp
index 53ce72fe4a..94c76a60ea 100644
--- a/engines/wintermute/UI/UIWindow.cpp
+++ b/engines/wintermute/UI/UIWindow.cpp
@@ -1100,12 +1100,12 @@ const char *CUIWindow::ScToString() {
//////////////////////////////////////////////////////////////////////////
-bool CUIWindow::HandleKeypress(Common::Event *event) {
+bool CUIWindow::HandleKeypress(Common::Event *event, bool printable) {
//TODO
if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_TAB) {
return SUCCEEDED(MoveFocus(!CBKeyboardState::IsShiftDown()));
} else {
- if (_focusedWidget) return _focusedWidget->HandleKeypress(event);
+ if (_focusedWidget) return _focusedWidget->HandleKeypress(event, printable);
else return false;
}
return false;
diff --git a/engines/wintermute/UI/UIWindow.h b/engines/wintermute/UI/UIWindow.h
index 4bdef647a3..43d5961e7e 100644
--- a/engines/wintermute/UI/UIWindow.h
+++ b/engines/wintermute/UI/UIWindow.h
@@ -70,7 +70,7 @@ public:
virtual HRESULT Display(int OffsetX = 0, int OffsetY = 0);
CUIWindow(CBGame *inGame);
virtual ~CUIWindow();
- virtual bool HandleKeypress(Common::Event *event);
+ virtual bool HandleKeypress(Common::Event *event, bool printable = false);
CBArray<CUIObject *, CUIObject *> _widgets;
TTextAlign _titleAlign;
HRESULT LoadFile(const char *Filename);