aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/graphics
diff options
context:
space:
mode:
authorWillem Jan Palenstijn2010-10-03 20:58:50 +0000
committerWillem Jan Palenstijn2010-10-03 20:58:50 +0000
commit11d9f1ec54351bcaf8eed8a55a96a474370808d9 (patch)
treec9fceb5a1bf51ad88dd3c4ce798673d5d1959ab6 /engines/sci/graphics
parent0596971decae5d64857cf01eb11cf5694043440d (diff)
downloadscummvm-rg350-11d9f1ec54351bcaf8eed8a55a96a474370808d9.tar.gz
scummvm-rg350-11d9f1ec54351bcaf8eed8a55a96a474370808d9.tar.bz2
scummvm-rg350-11d9f1ec54351bcaf8eed8a55a96a474370808d9.zip
SCI: Support alternative inputs from vocab 913
This allows the input of accented characters and Japanese using plain ascii in non-English games. svn-id: r53001
Diffstat (limited to 'engines/sci/graphics')
-rw-r--r--engines/sci/graphics/controls.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/engines/sci/graphics/controls.cpp b/engines/sci/graphics/controls.cpp
index 70ff70daab..e4e7bc0c92 100644
--- a/engines/sci/graphics/controls.cpp
+++ b/engines/sci/graphics/controls.cpp
@@ -159,6 +159,8 @@ void GfxControls::kernelTexteditChange(reg_t controlObject, reg_t eventObject) {
error("kEditControl called on object that doesnt have a text reference");
text = _segMan->getString(textReference);
+ uint16 oldCursorPos = cursorPos;
+
if (!eventObject.isNull()) {
textSize = text.size();
eventType = readSelectorValue(_segMan, eventObject, SELECTOR(type));
@@ -223,6 +225,11 @@ void GfxControls::kernelTexteditChange(reg_t controlObject, reg_t eventObject) {
}
}
+ if (!textChanged && oldCursorPos != cursorPos) {
+ assert(!textAddChar);
+ textChanged = g_sci->getVocabulary()->checkAltInput(text, cursorPos);
+ }
+
if (textChanged) {
GuiResourceId oldFontId = _text16->GetFontId();
GuiResourceId fontId = readSelectorValue(_segMan, controlObject, SELECTOR(font));
@@ -230,18 +237,27 @@ void GfxControls::kernelTexteditChange(reg_t controlObject, reg_t eventObject) {
readSelectorValue(_segMan, controlObject, SELECTOR(nsRight)), readSelectorValue(_segMan, controlObject, SELECTOR(nsBottom)));
_text16->SetFont(fontId);
if (textAddChar) {
- // We check, if we are really able to add the new char
- uint16 textWidth = 0;
+
const char *textPtr = text.c_str();
+
+ // We check if we are really able to add the new char
+ uint16 textWidth = 0;
while (*textPtr)
textWidth += _text16->_font->getCharWidth((byte)*textPtr++);
textWidth += _text16->_font->getCharWidth(eventKey);
+
+ // Does it fit?
if (textWidth >= rect.width()) {
_text16->SetFont(oldFontId);
return;
}
+
text.insertChar(eventKey, cursorPos++);
+
+ // Note: the following checkAltInput call might make the text
+ // too wide to fit, but SSCI fails to check that too.
}
+ g_sci->getVocabulary()->checkAltInput(text, cursorPos);
texteditCursorErase();
_paint16->eraseRect(rect);
_text16->Box(text.c_str(), 0, rect, SCI_TEXT16_ALIGNMENT_LEFT, -1);