From 11d9f1ec54351bcaf8eed8a55a96a474370808d9 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sun, 3 Oct 2010 20:58:50 +0000 Subject: 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 --- engines/sci/graphics/controls.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'engines/sci/graphics') 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); -- cgit v1.2.3