aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMartin Kiewitz2010-04-15 16:40:37 +0000
committerMartin Kiewitz2010-04-15 16:40:37 +0000
commit20392ebee8b5d5869e55199e3042d57d66f7ad9d (patch)
treee15b3d6b7a77020301022ac91437d7af26e414ff /engines
parentcbee83a5363851d6ec35042417ffe653f329454c (diff)
downloadscummvm-rg350-20392ebee8b5d5869e55199e3042d57d66f7ad9d.tar.gz
scummvm-rg350-20392ebee8b5d5869e55199e3042d57d66f7ad9d.tar.bz2
scummvm-rg350-20392ebee8b5d5869e55199e3042d57d66f7ad9d.zip
SCI: split menu/item strings when displaying instead of when initializing - makes on-the-fly menu language changes possible (used by multilingual SCI01 games)
svn-id: r48659
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/kmenu.cpp2
-rw-r--r--engines/sci/graphics/menu.cpp17
-rw-r--r--engines/sci/graphics/menu.h2
3 files changed, 14 insertions, 7 deletions
diff --git a/engines/sci/engine/kmenu.cpp b/engines/sci/engine/kmenu.cpp
index 32d0bc1839..a5f2f01297 100644
--- a/engines/sci/engine/kmenu.cpp
+++ b/engines/sci/engine/kmenu.cpp
@@ -34,7 +34,7 @@
namespace Sci {
reg_t kAddMenu(EngineState *s, int argc, reg_t *argv) {
- Common::String title = g_sci->strSplit(s->_segMan->getString(argv[0]).c_str());
+ Common::String title = s->_segMan->getString(argv[0]);
Common::String content = s->_segMan->getString(argv[1]);
g_sci->_gfxMenu->kernelAddEntry(title, content, argv[1]);
diff --git a/engines/sci/graphics/menu.cpp b/engines/sci/graphics/menu.cpp
index 0acd64ac1f..42ae4de1ff 100644
--- a/engines/sci/graphics/menu.cpp
+++ b/engines/sci/graphics/menu.cpp
@@ -190,7 +190,9 @@ void GfxMenu::kernelAddEntry(Common::String title, Common::String content, reg_t
if (separatorCount == tempPos - beginPos) {
itemEntry->separatorLine = true;
} else {
- itemEntry->text = g_sci->strSplit(Common::String(content.c_str() + beginPos, tempPos - beginPos).c_str());
+ // we don't strSplit here, because multilingual SCI01 support language switching on the fly, so we have to do
+ // this everytime the menu is called
+ itemEntry->text = Common::String(content.c_str() + beginPos, tempPos - beginPos);
// LSL6 uses "Ctrl-" prefix string instead of ^ like all the other games do
tempPtr = itemEntry->text.c_str();
@@ -260,7 +262,7 @@ void GfxMenu::kernelSetAttribute(uint16 menuId, uint16 itemId, uint16 attributeI
itemEntry->saidVmPtr = value;
break;
case SCI_MENU_ATTRIBUTE_TEXT:
- itemEntry->text = g_sci->strSplit(_segMan->getString(value).c_str());
+ itemEntry->text = _segMan->getString(value);
itemEntry->textVmPtr = value;
// We assume here that no script ever creates a separatorLine dynamically
break;
@@ -317,7 +319,7 @@ void GfxMenu::drawBar() {
listIterator = _list.begin();
while (listIterator != listEnd) {
listEntry = *listIterator;
- _text16->Draw_String(listEntry->text.c_str());
+ _text16->Draw_String(listEntry->textSplit.c_str());
listIterator++;
}
@@ -336,7 +338,8 @@ void GfxMenu::calculateTextWidth() {
menuIterator = _list.begin();
while (menuIterator != menuEnd) {
menuEntry = *menuIterator;
- _text16->StringWidth(menuEntry->text.c_str(), 0, menuEntry->textWidth, dummyHeight);
+ menuEntry->textSplit = g_sci->strSplit(menuEntry->text.c_str());
+ _text16->StringWidth(menuEntry->textSplit.c_str(), 0, menuEntry->textWidth, dummyHeight);
menuIterator++;
}
@@ -344,7 +347,9 @@ void GfxMenu::calculateTextWidth() {
itemIterator = _itemList.begin();
while (itemIterator != itemEnd) {
itemEntry = *itemIterator;
- _text16->StringWidth(itemEntry->text.c_str(), 0, itemEntry->textWidth, dummyHeight);
+ // Split the text now for multilingual SCI01 games
+ itemEntry->textSplit = g_sci->strSplit(itemEntry->text.c_str());
+ _text16->StringWidth(itemEntry->textSplit.c_str(), 0, itemEntry->textWidth, dummyHeight);
_text16->StringWidth(itemEntry->textRightAligned.c_str(), 0, itemEntry->textRightAlignedWidth, dummyHeight);
itemIterator++;
@@ -548,7 +553,7 @@ void GfxMenu::drawMenu(uint16 oldMenuId, uint16 newMenuId) {
if (!listItemEntry->separatorLine) {
_ports->textGreyedOutput(listItemEntry->enabled ? false : true);
_ports->moveTo(_menuRect.left, topPos);
- _text16->Draw_String(listItemEntry->text.c_str());
+ _text16->Draw_String(listItemEntry->textSplit.c_str());
_ports->moveTo(_menuRect.right - listItemEntry->textRightAlignedWidth - 5, topPos);
_text16->Draw_String(listItemEntry->textRightAligned.c_str());
} else {
diff --git a/engines/sci/graphics/menu.h b/engines/sci/graphics/menu.h
index b515ba4826..3730cb49ae 100644
--- a/engines/sci/graphics/menu.h
+++ b/engines/sci/graphics/menu.h
@@ -45,6 +45,7 @@ enum {
struct GuiMenuEntry {
uint16 id;
Common::String text;
+ Common::String textSplit;
int16 textWidth;
GuiMenuEntry(uint16 curId)
@@ -62,6 +63,7 @@ struct GuiMenuItemEntry {
bool separatorLine;
reg_t saidVmPtr;
Common::String text;
+ Common::String textSplit;
reg_t textVmPtr;
int16 textWidth;
Common::String textRightAligned;