diff options
author | athrxx | 2011-07-04 19:51:01 +0200 |
---|---|---|
committer | athrxx | 2011-07-04 19:52:11 +0200 |
commit | 38d18a6e78e19d12a3d6e56fe5b92821354c3e08 (patch) | |
tree | 4bbbc981f7308f371be35df05c433dabc4c98e6d /engines/kyra | |
parent | 19fd9c066cedd7d3e2cc9d1494137766a0a65ceb (diff) | |
download | scummvm-rg350-38d18a6e78e19d12a3d6e56fe5b92821354c3e08.tar.gz scummvm-rg350-38d18a6e78e19d12a3d6e56fe5b92821354c3e08.tar.bz2 scummvm-rg350-38d18a6e78e19d12a3d6e56fe5b92821354c3e08.zip |
KYRA: fix ingame menu save slots
- long GMM save descriptions will be trimmed to fit the ingame menu save slots
- prevent writing beyond the right margin in Kyra 1 save slots
Diffstat (limited to 'engines/kyra')
-rw-r--r-- | engines/kyra/gui_lok.cpp | 14 | ||||
-rw-r--r-- | engines/kyra/gui_lol.cpp | 10 | ||||
-rw-r--r-- | engines/kyra/gui_v2.cpp | 9 |
3 files changed, 32 insertions, 1 deletions
diff --git a/engines/kyra/gui_lok.cpp b/engines/kyra/gui_lok.cpp index eac82ec2c5..4153edc29d 100644 --- a/engines/kyra/gui_lok.cpp +++ b/engines/kyra/gui_lok.cpp @@ -576,6 +576,15 @@ void GUI_LoK::setupSavegames(Menu &menu, int num) { if ((in = _vm->openSaveForReading(_vm->getSavegameFilename(_saveSlots[i + _savegameOffset]), header))) { Common::strlcpy(_savegameNames[i], header.description.c_str(), ARRAYSIZE(_savegameNames[0])); + // Trim long GMM save descriptions to fit our save slots + _screen->_charWidth = -2; + int fC = _screen->getTextWidth(_savegameNames[i]); + while (strlen(_savegameNames[i]) && (fC > 240 || strlen(_savegameNames[i]) >= ARRAYSIZE(_savegameNames[0]))) { + _savegameNames[i][strlen(_savegameNames[i]) - 1] = 0; + fC = _screen->getTextWidth(_savegameNames[i]); + } + _screen->_charWidth = 0; + Util::convertISOToDOS(_savegameNames[i]); menu.item[i].itemString = _savegameNames[i]; @@ -693,12 +702,15 @@ void GUI_LoK::updateSavegameString() { if (_keyPressed.keycode) { length = strlen(_savegameName); + _screen->_charWidth = -2; + int width = _screen->getTextWidth(_savegameName) + 7; + _screen->_charWidth = 0; char inputKey = _keyPressed.ascii; Util::convertISOToDOS(inputKey); if ((uint8)inputKey > 31 && (uint8)inputKey < (_vm->gameFlags().lang == Common::JA_JPN ? 128 : 226)) { - if (length < ARRAYSIZE(_savegameName)-1) { + if ((length < ARRAYSIZE(_savegameName)-1) && (width <= 240)) { _savegameName[length] = inputKey; _savegameName[length+1] = 0; redrawTextfield(); diff --git a/engines/kyra/gui_lol.cpp b/engines/kyra/gui_lol.cpp index fb11040168..531079bc98 100644 --- a/engines/kyra/gui_lol.cpp +++ b/engines/kyra/gui_lol.cpp @@ -2572,9 +2572,19 @@ void GUI_LoL::setupSaveMenuSlots(Menu &menu, int num) { slotOffs = 1; } + int saveSlotMaxLen = ((_screen->getScreenDim(8))->w << 3) - _screen->getCharWidth('W'); + for (int i = startSlot; i < num && _savegameOffset + i - slotOffs < _savegameListSize; ++i) { if (_savegameList[_saveSlots[i + _savegameOffset - slotOffs]]) { Common::strlcpy(s, _savegameList[_saveSlots[i + _savegameOffset - slotOffs]], 80); + + // Trim long GMM save descriptions to fit our save slots + int fC = _screen->getTextWidth(s); + while (strlen(s) && fC >= saveSlotMaxLen) { + s[strlen(s) - 1] = 0; + fC = _screen->getTextWidth(s); + } + menu.item[i].itemString = s; s += (strlen(s) + 1); menu.item[i].saveSlot = _saveSlots[i + _savegameOffset - slotOffs]; diff --git a/engines/kyra/gui_v2.cpp b/engines/kyra/gui_v2.cpp index 0b82df8cd5..f086ef368f 100644 --- a/engines/kyra/gui_v2.cpp +++ b/engines/kyra/gui_v2.cpp @@ -457,6 +457,15 @@ void GUI_v2::setupSavegameNames(Menu &menu, int num) { Common::strlcpy(s, header.description.c_str(), 80); Util::convertISOToDOS(s); + // Trim long GMM save descriptions to fit our save slots + _screen->_charWidth = -2; + int fC = _screen->getTextWidth(s); + while (strlen(s) && fC > 240) { + s[strlen(s) - 1] = 0; + fC = _screen->getTextWidth(s); + } + _screen->_charWidth = 0; + menu.item[i].saveSlot = _saveSlots[i + _savegameOffset]; menu.item[i].enabled = true; delete in; |