diff options
Diffstat (limited to 'engines/kyra')
-rw-r--r-- | engines/kyra/gui_lol.cpp | 176 | ||||
-rw-r--r-- | engines/kyra/gui_lol.h | 4 | ||||
-rw-r--r-- | engines/kyra/kyra_v1.cpp | 4 | ||||
-rw-r--r-- | engines/kyra/lol.h | 4 | ||||
-rw-r--r-- | engines/kyra/staticres.cpp | 21 |
5 files changed, 183 insertions, 26 deletions
diff --git a/engines/kyra/gui_lol.cpp b/engines/kyra/gui_lol.cpp index a6d70c507f..962097995b 100644 --- a/engines/kyra/gui_lol.cpp +++ b/engines/kyra/gui_lol.cpp @@ -31,6 +31,7 @@ #include "kyra/resource.h" #include "common/savefile.h" +#include "graphics/scaler.h" #include "base/version.h" @@ -2227,6 +2228,13 @@ int GUI_LoL::runMenu(Menu &menu) { _savegameOffset = 0; backupPage0(); + const ScreenDim *d = _screen->getScreenDim(8); + uint32 textCursorTimer = 0; + uint8 textCursorStatus = 1; + int wW = _screen->getCharWidth('W'); + int fW = (d->w << 3) - wW; + int fC = 0; + // LoL doesnt't have default higlighted items. No item should be // highlighted when entering a new menu. // Instead, the respevtive struct entry is used to determine whether @@ -2305,9 +2313,47 @@ int GUI_LoL::runMenu(Menu &menu) { _screen->updateScreen(); } + if (_currentMenu == &_savenameMenu) { + int mx = (d->sx << 3) - 1; + int my = d->sy - 1; + int mw = (d->w << 3) + 1; + int mh = d->h + 1; + _screen->drawShadedBox(mx, my, mx + mw, my + mh, 227, 223, Screen::kShadeTypeLol); + int pg = _screen->setCurPage(0); + _vm->_txt->clearDim(8); + textCursorTimer = 0; + textCursorStatus = 1; + + fC = _screen->getTextWidth(_saveDescription); + while (fC >= fW) { + _saveDescription[strlen(_saveDescription) - 1] = 0; + fC = _screen->getTextWidth(_saveDescription); + } + + _screen->fprintString(_saveDescription, (d->sx << 3), d->sy + 2, d->unk8, d->unkA, 0); + _screen->fillRect((d->sx << 3) + fC, d->sy, (d->sx << 3) + fC + wW, d->sy + d->h - 1, d->unk8, 0); + _screen->setCurPage(pg); + _screen->updateScreen(); + } + while (!_newMenu && _displayMenu) { - processHighlights(*_currentMenu); - if (getInput()) { + processHighlights(*_currentMenu); + + if (_currentMenu == &_savenameMenu) { + fC = _screen->getTextWidth(_saveDescription); + int pg = _screen->setCurPage(0); + + if (textCursorTimer <= _vm->_system->getMillis()) { + textCursorStatus ^= 1; + textCursorTimer = _vm->_system->getMillis() + 20 * _vm->_tickLength; + _screen->fillRect((d->sx << 3) + fC, d->sy, (d->sx << 3) + fC + wW, d->sy + d->h - 1, textCursorStatus ? d->unk8 : d->unkA, 0); + } + + _screen->updateScreen(); + _screen->setCurPage(pg); + } + + if (getInput()) { if (!_newMenu) _newMenu = _currentMenu; else @@ -2332,6 +2378,13 @@ int GUI_LoL::runMenu(Menu &menu) { return _menuResult; } +void GUI_LoL::createScreenThumbnail(Graphics::Surface &dst) { + uint8 *screenPal = new uint8[768]; + _screen->getRealPalette(1, screenPal); + ::createThumbnail(&dst, _screen->getCPagePtr(7), Screen::SCREEN_W, Screen::SCREEN_H, screenPal); + delete[] screenPal; +} + void GUI_LoL::backupPage0() { _screen->copyPage(0, 7); } @@ -2356,14 +2409,14 @@ void GUI_LoL::setupSavegameNames(Menu &menu, int num) { KyraEngine_v1::SaveHeader header; Common::InSaveFile *in; for (int i = startSlot; i < num && uint(_savegameOffset + i) < _saveSlots.size(); ++i) { - if ((in = _vm->openSaveForReading(_vm->getSavegameFilename(_saveSlots[i + _savegameOffset]), header)) != 0) { + if ((in = _vm->openSaveForReading(_vm->getSavegameFilename(_saveSlots[i + _savegameOffset - startSlot]), header)) != 0) { strncpy(s, header.description.c_str(), 80); s[79] = 0; for (uint32 ii = 0; ii < strlen(s); ii++) { - for (int iii = 0; iii < _vm->_fontConversionTableGermanSize; iii += 2) { - if ((uint8)s[ii] == _vm->_fontConversionTableGerman[iii]) { - s[ii] = (uint8)_vm->_fontConversionTableGerman[iii + 1]; + for (int iii = 0; iii < _vm->_fontConversionTableSize; iii += 2) { + if ((uint8)s[ii] == _vm->_fontConversionTable[iii]) { + s[ii] = (uint8)_vm->_fontConversionTable[iii + 1]; break; } } @@ -2378,13 +2431,12 @@ void GUI_LoL::setupSavegameNames(Menu &menu, int num) { } if (_savegameOffset == 0) { - /*if (&menu == &_saveMenu) { - char *dst = _vm->getLangString(menu.item[0].itemId); - const char *src = _vm->getLangString(_vm->gameFlags().isTalkie ? 10 : 18); - strcpy(dst, src); - menu.item[0].saveSlot = -2; + if (&menu == &_saveMenu) { + strcpy(s, _vm->getLangString(0x4010)); + menu.item[0].itemString = s; + menu.item[0].saveSlot = -3; menu.item[0].enabled = true; - }*/ + } } } @@ -2408,13 +2460,45 @@ int GUI_LoL::getInput() { Common::Point p = _vm->getMousePos(); _vm->_mouseX = p.x; _vm->_mouseY = p.y; + + if (_currentMenu == &_savenameMenu) { + _vm->updateInput(); + + for (Common::List<KyraEngine_v1::Event>::const_iterator evt = _vm->_eventList.begin(); evt != _vm->_eventList.end(); evt++) { + if (evt->event.type == Common::EVENT_KEYDOWN) + _keyPressed = evt->event.kbd; + } + } + int inputFlag = _vm->checkInput(_menuButtonList); + + if (_currentMenu == &_savenameMenu && _keyPressed.ascii){ + for (int i = 0; i < _vm->_fontConversionTableSize; i += 2) { + if (_keyPressed.ascii == _vm->_fontConversionTable[i]) { + _keyPressed.ascii = _vm->_fontConversionTable[i + 1]; + break; + } + } + + if (_keyPressed.ascii > 31 && _keyPressed.ascii < 226) { + _saveDescription[strlen(_saveDescription) + 1] = 0; + _saveDescription[strlen(_saveDescription)] = _keyPressed.ascii; + inputFlag |= 0x8000; + } else if (_keyPressed.keycode == Common::KEYCODE_BACKSPACE && strlen(_saveDescription)) { + _saveDescription[strlen(_saveDescription) - 1] = 0; + inputFlag |= 0x8000; + } else { + + } + } + _vm->removeInputTop(); + _keyPressed.reset(); if (_vm->shouldQuit()) _displayMenu = false; - _vm->delay(10); + _vm->delay(8); return inputFlag & 0x8000 ? 1 : 0; } @@ -2427,7 +2511,7 @@ int GUI_LoL::clickedMainMenu(Button *button) { break; case 0x4002: _savegameOffset = 0; - //_newMenu = &_saveMenu; + _newMenu = &_saveMenu; break; case 0x4003: _savegameOffset = 0; @@ -2471,16 +2555,34 @@ int GUI_LoL::clickedLoadMenu(Button *button) { int GUI_LoL::clickedSaveMenu(Button *button) { updateMenuButton(button); + if (button->arg == 0x4011) { + _newMenu = &_mainMenu; + return 1; + } + + _newMenu = &_savenameMenu; + int16 s = (int16)button->arg; + _menuResult = _saveMenu.item[-s - 2].saveSlot + 1; + _saveDescription = (char*)_vm->_tempBuffer5120 + 1000; + _saveDescription[0] = 0; + if (_saveMenu.item[-s - 2].saveSlot != -3) + strcpy(_saveDescription, _saveMenu.item[-s - 2].itemString); + return 1; } int GUI_LoL::clickedDeleteMenu(Button *button) { updateMenuButton(button); + if (button->arg == 0x4011) { + _newMenu = &_mainMenu; + return 1; + } + _choiceMenu.menuNameId = 0x400b; - _newMenu = (button->arg == 0x4011) ? _lastMenu : &_choiceMenu; + _newMenu = &_choiceMenu; int16 s = (int16)button->arg; - _menuResult = _deleteMenu.item[-s - 2].saveSlot; + _menuResult = _deleteMenu.item[-s - 2].saveSlot + 1; return 1; } @@ -2531,13 +2633,53 @@ int GUI_LoL::clickedDeathMenu(Button *button) { return 1; } +int GUI_LoL::clickedSavenameMenu(Button *button) { + updateMenuButton(button); + if (button->arg == _savenameMenu.item[0].itemId) { + for (uint32 i = 0; i < strlen(_saveDescription); i++) { + for (int ii = 0; ii < _vm->_fontConversionTableSize; ii += 2) { + if ((uint8)_saveDescription[i] == _vm->_fontConversionTable[ii + 1]) { + _saveDescription[i] = (char)_vm->_fontConversionTable[ii]; + break; + } + } + } + + int slot = _menuResult == -2 ? getNextSavegameSlot() : _menuResult; + Graphics::Surface thumb; + createScreenThumbnail(thumb); + _vm->saveGameState(slot, _saveDescription, &thumb); + thumb.free(); + + _displayMenu = false; + + } else if (button->arg == _savenameMenu.item[1].itemId) { + _newMenu = &_saveMenu; + } + + return 1; +} + int GUI_LoL::clickedChoiceMenu(Button *button) { updateMenuButton(button); if (button->arg == _choiceMenu.item[0].itemId) { if (_lastMenu == &_mainMenu) { _vm->quitGame(); } else if (_lastMenu == &_deleteMenu) { - _vm->_saveFileMan->removeSavefile(_vm->getSavegameFilename(_menuResult)); + _vm->_saveFileMan->removeSavefile(_vm->getSavegameFilename(_menuResult - 1)); + Common::Array<int>::iterator i = Common::find(_saveSlots.begin(), _saveSlots.end(), _menuResult); + while (i != _saveSlots.end()) { + ++i; + if (i == _saveSlots.end()) + break; + // We are only renaming all savefiles until we get some slots missing + // Also not rename quicksave slot filenames + if (*(i-1) != *i || *i >= 990) + break; + Common::String oldName = _vm->getSavegameFilename(*i); + Common::String newName = _vm->getSavegameFilename(*i-1); + _vm->_saveFileMan->renameSavefile(oldName, newName); + } _newMenu = &_mainMenu; } } else if (button->arg == _choiceMenu.item[1].itemId) { diff --git a/engines/kyra/gui_lol.h b/engines/kyra/gui_lol.h index 8489a2a7fc..da41eebf0c 100644 --- a/engines/kyra/gui_lol.h +++ b/engines/kyra/gui_lol.h @@ -96,7 +96,7 @@ public: int runMenu(Menu &menu); // utilities for thumbnail creation - void createScreenThumbnail(Graphics::Surface &dst) {} + void createScreenThumbnail(Graphics::Surface &dst); private: void backupPage0(); @@ -115,6 +115,7 @@ private: int clickedDeleteMenu(Button *button); int clickedOptionsMenu(Button *button); int clickedDeathMenu(Button *button); + int clickedSavenameMenu(Button *button); int clickedChoiceMenu(Button *button); int scrollUp(Button *button); @@ -141,6 +142,7 @@ private: Menu _mainMenu, _gameOptions, _audioOptions, _choiceMenu, _loadMenu, _saveMenu, _deleteMenu, _savenameMenu, _deathMenu; Menu *_currentMenu, *_lastMenu, *_newMenu; int _menuResult; + char *_saveDescription; LoLEngine *_vm; Screen_LoL *_screen; diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp index 55084a169e..fa53fde696 100644 --- a/engines/kyra/kyra_v1.cpp +++ b/engines/kyra/kyra_v1.cpp @@ -278,10 +278,10 @@ int KyraEngine_v1::checkInput(Button *buttonList, bool mainLoop, int eventFlag) } else { switch(event.kbd.keycode) { case Common::KEYCODE_SPACE: - keys = 43; + keys = 61; break; case Common::KEYCODE_RETURN: - keys = 61; + keys = 43; break; case Common::KEYCODE_UP: case Common::KEYCODE_KP8: diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h index c4b7ea7819..32adc8347d 100644 --- a/engines/kyra/lol.h +++ b/engines/kyra/lol.h @@ -855,8 +855,8 @@ private: // TODO: Rethink of a proper way for conversion, currently our GUI charset isn't defined // properly, thus this might not work on every system. - static const uint8 _fontConversionTableGerman[]; - static const int _fontConversionTableGermanSize; + static const uint8 _fontConversionTable[]; + static const int _fontConversionTableSize; // graphics void setupScreenDims(); diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp index 81c045ba2f..d5c75bf89e 100644 --- a/engines/kyra/staticres.cpp +++ b/engines/kyra/staticres.cpp @@ -2078,6 +2078,13 @@ void GUI_LoL::initStaticData() { for (int i = 0; i < 2; ++i) _deathMenu.item[i].callback = deathMenuFunctor; + GUI_LOL_MENU(_savenameMenu, 7, 0x4053, 0, 2, -1, -1, -1, -1); + GUI_LOL_MENU_ITEM(_savenameMenu.item[0], 0x4012, 8, 38, 72, 15, 0, 43); + GUI_LOL_MENU_ITEM(_savenameMenu.item[1], 0x4011, 176, 38, 72, 15, 0, 110); + Button::Callback savenameMenuFunctor = BUTTON_FUNCTOR(GUI_LoL, this, &GUI_LoL::clickedSavenameMenu); + for (int i = 0; i < 2; ++i) + _savenameMenu.item[i].callback = savenameMenuFunctor; + GUI_LOL_MENU(_choiceMenu, 11, 0, 0, 2, -1, -1, -1, -1); GUI_LOL_MENU_ITEM(_choiceMenu.item[0], 0x4007, 8, 30, 72, 15, 0, 0); GUI_LOL_MENU_ITEM(_choiceMenu.item[1], 0x4008, 208, 30, 72, 15, 0, 0); @@ -3316,15 +3323,21 @@ const int LoLEngine::_outroMonsterScaleTableY[] = { 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100, 0x100 }; -const uint8 LoLEngine::_fontConversionTableGerman[] = { +const uint8 LoLEngine::_fontConversionTable[] = { (const uint8)'Ä', 0x8e, (const uint8)'ä', 0x84, (const uint8)'Ö', 0x99, (const uint8)'ö', 0x94, (const uint8)'Ü', 0x9a, (const uint8)'ü', 0x81, - (const uint8)'ß', 0xe1 + (const uint8)'ß', 0xe1, (const uint8)'É', 0x90, (const uint8)'é', 0x82, + (const uint8)'è', 0x8a, (const uint8)'ê', 0x88, (const uint8)'à', 0x85, + (const uint8)'â', 0x83, (const uint8)'ô', 0x93, (const uint8)'Ç', 0x80, + (const uint8)'ç', 0x87, (const uint8)'ë', 0x89, (const uint8)'å', 0x86, + (const uint8)'ï', 0x8b, (const uint8)'î', 0x8c, (const uint8)'ì', 0x8d, + (const uint8)'Å', 0x8f, (const uint8)'æ', 0x91, (const uint8)'Æ', 0x92, + (const uint8)'ò', 0x95, (const uint8)'û', 0x96, (const uint8)'ù', 0x97, + (const uint8)'á', 0xa0 }; -const int LoLEngine::_fontConversionTableGermanSize = ARRAYSIZE(LoLEngine::_fontConversionTableGerman); +const int LoLEngine::_fontConversionTableSize = ARRAYSIZE(LoLEngine::_fontConversionTable); #endif // ENABLE_LOL } // End of namespace Kyra - |