diff options
author | athrxx | 2011-07-02 03:19:46 +0200 |
---|---|---|
committer | Johannes Schickel | 2011-12-26 16:18:12 +0100 |
commit | 5baabf037df661e4730500ecebca6347031aa295 (patch) | |
tree | 1138d0eb7d473353c0e82452017dbb0a885f91c2 /engines | |
parent | c53589bcda2875154b2590f264838b1be728d1f3 (diff) | |
download | scummvm-rg350-5baabf037df661e4730500ecebca6347031aa295.tar.gz scummvm-rg350-5baabf037df661e4730500ecebca6347031aa295.tar.bz2 scummvm-rg350-5baabf037df661e4730500ecebca6347031aa295.zip |
KYRA: (EOB) - implement save menu
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/eob1.cpp | 6 | ||||
-rw-r--r-- | engines/kyra/eob1.h | 2 | ||||
-rw-r--r-- | engines/kyra/eob2.cpp | 6 | ||||
-rw-r--r-- | engines/kyra/eob2.h | 2 | ||||
-rw-r--r-- | engines/kyra/eobcommon.cpp | 5 | ||||
-rw-r--r-- | engines/kyra/eobcommon.h | 3 | ||||
-rw-r--r-- | engines/kyra/gui_eob.cpp | 149 | ||||
-rw-r--r-- | engines/kyra/gui_eob.h | 11 | ||||
-rw-r--r-- | engines/kyra/magic_eob.cpp | 4 | ||||
-rw-r--r-- | engines/kyra/resource.h | 1 | ||||
-rw-r--r-- | engines/kyra/saveload_eob.cpp | 17 | ||||
-rw-r--r-- | engines/kyra/staticres_eob.cpp | 1 |
12 files changed, 145 insertions, 62 deletions
diff --git a/engines/kyra/eob1.cpp b/engines/kyra/eob1.cpp index 69071d3aef..3992b2284e 100644 --- a/engines/kyra/eob1.cpp +++ b/engines/kyra/eob1.cpp @@ -77,12 +77,6 @@ void EobEngine::startupNew() { EobCoreEngine::startupNew(); } -void EobEngine::startupLoad() { - setHandItem(_itemInHand); - loadLevel(_currentLevel, _currentSub); - _saveLoadMode = 0; -} - void EobEngine::npcSequence(int npcIndex) { diff --git a/engines/kyra/eob1.h b/engines/kyra/eob1.h index 8a959e9fa4..8181f3281e 100644 --- a/engines/kyra/eob1.h +++ b/engines/kyra/eob1.h @@ -48,7 +48,7 @@ private: // Main loop void startupNew(); - void startupLoad(); + void startupLoad() {} // Intro/Outro void seq_playOpeningCredits(); diff --git a/engines/kyra/eob2.cpp b/engines/kyra/eob2.cpp index 56ef838e54..baed595e8c 100644 --- a/engines/kyra/eob2.cpp +++ b/engines/kyra/eob2.cpp @@ -77,12 +77,6 @@ void DarkMoonEngine::startupNew() { EobCoreEngine::startupNew(); } -void DarkMoonEngine::startupLoad() { - setHandItem(_itemInHand); - loadLevel(_currentLevel, _currentSub); - _saveLoadMode = 0; -} - void DarkMoonEngine::npcSequence(int npcIndex) { _screen->loadEobBitmap("OUTTAKE", 5, 3); _screen->copyRegion(0, 0, 0, 0, 176, 120, 0, 6, Screen::CR_NO_P_CHECK); diff --git a/engines/kyra/eob2.h b/engines/kyra/eob2.h index 3fabe44bf0..22193cecf2 100644 --- a/engines/kyra/eob2.h +++ b/engines/kyra/eob2.h @@ -64,7 +64,7 @@ private: // Main loop void startupNew(); - void startupLoad(); + void startupLoad() {} // Intro/Outro void seq_playIntro(); diff --git a/engines/kyra/eobcommon.cpp b/engines/kyra/eobcommon.cpp index 2d5c4e61c3..4c8d4886fd 100644 --- a/engines/kyra/eobcommon.cpp +++ b/engines/kyra/eobcommon.cpp @@ -45,7 +45,6 @@ EobCoreEngine::EobCoreEngine(OSystem *system, const GameFlags &flags) : LolEobBa //_runLoopTimerUnk = 0; _playFinale = false; _runFlag = true; - _saveLoadMode = 0; _configMouse = true; _largeItemShapes = _smallItemShapes = _thrownItemShapes = _spellShapes = _firebeamShapes = _itemIconShapes = @@ -360,10 +359,8 @@ Common::Error EobCoreEngine::go() { if (action == -1) { // load game repeatLoop = _gui->runLoadMenu(72, 14); - if (repeatLoop && !shouldQuit()) { - _saveLoadMode = -1; + if (repeatLoop && !shouldQuit()) startupLoad(); - } } else if (action == -2) { // new game repeatLoop = startCharacterGeneration(); diff --git a/engines/kyra/eobcommon.h b/engines/kyra/eobcommon.h index eae03ac221..e6b816e291 100644 --- a/engines/kyra/eobcommon.h +++ b/engines/kyra/eobcommon.h @@ -785,8 +785,6 @@ protected: void restoreMonsterTempData(LevelTempData *tmp); void releaseMonsterTempData(LevelTempData *tmp); - int _saveLoadMode; - const char * const *_saveLoadStrings; Screen_Eob *_screen; @@ -1006,6 +1004,7 @@ protected: const char *const *_menuStringsTransfer; const char *const *_menuStringsSpec; const char *const *_menuStringsSpellNo; + const char *const *_menuYesNoStrings; const uint8 *_spellLevelsMage; int _spellLevelsMageSize; diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp index 4eb2497539..1d69a901e5 100644 --- a/engines/kyra/gui_eob.cpp +++ b/engines/kyra/gui_eob.cpp @@ -30,6 +30,7 @@ #include "common/system.h" #include "common/savefile.h" +#include "graphics/scaler.h" namespace Kyra { @@ -849,9 +850,10 @@ int EobCoreEngine::clickedCamp(Button *button) { } _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 14, Screen::CR_NO_P_CHECK); + _screen->copyPage(0, 7); - _gui->runCampMenu(); - + _gui->runCampMenu(); + _screen->copyRegion(0, 0, 0, 120, 176, 24, 14, 2, Screen::CR_NO_P_CHECK); _screen->setScreenDim(cd); drawScene(0); @@ -862,10 +864,7 @@ int EobCoreEngine::clickedCamp(Button *button) { _screen->setCurPage(0); const ScreenDim *dm = _screen->getScreenDim(10); _screen->copyRegion(dm->sx << 3, dm->sy, dm->sx << 3, dm->sy, dm->w << 3, dm->h, 2, 0, Screen::CR_NO_P_CHECK); - - /*if (reloadInv) - _screen->loadEobCpsFileToPage("INVENT", 0, 5, 3, 2);*/ - + _screen->updateScreen(); enableSysTimer(2); @@ -1430,7 +1429,7 @@ void EobCoreEngine::gui_processInventorySlotClick(int slot) { } GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) { - _scrollUpFunctor = _scrollDownFunctor = BUTTON_FUNCTOR(GUI_Eob, this, 0); + //_scrollUpFunctor = _scrollDownFunctor = BUTTON_FUNCTOR(GUI_Eob, this, 0); _menuStringsPrefsTemp = new char*[4]; memset(_menuStringsPrefsTemp, 0, 4 * sizeof(char*)); @@ -2230,8 +2229,7 @@ void GUI_Eob::runCampMenu() { case 0x8009: if (runSaveMenu(0, 0)) displayTextBox(14); - else - newMenu = 1; + newMenu = 1; break; case 0x800a: @@ -2316,9 +2314,7 @@ bool GUI_Eob::runLoadMenu(int x, int y) { _screen->modifyScreenDim(11, dm->sx + (x >> 3), dm->sy + y, dm->w, dm->h); - updateSavegameList(); - - for (bool runLoop = true; runLoop; ) { + for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { int slot = selectSaveSlotDialogue(x, y, 1); if (slot > 5) { runLoop = result = false; @@ -2490,6 +2486,13 @@ int GUI_Eob::getTextInput(char *dest, int x, int y, int destMaxLen, int textColo return _keyPressed.keycode == Common::KEYCODE_ESCAPE ? -1 : len; } +void GUI_Eob::createScreenThumbnail(Graphics::Surface &dst) { + uint8 *screenPal = new uint8[768]; + _screen->getRealPalette(0, screenPal); + ::createThumbnail(&dst, _screen->getCPagePtr(7), Screen::SCREEN_W, Screen::SCREEN_H, screenPal); + delete[] screenPal; +} + void GUI_Eob::simpleMenu_initMenuItemsMask(int menuId, int maxItem, int32 menuItemsMask, int itemOffset) { if (menuItemsMask == -1) { _menuNumItems = _screen->getScreenDim(19 + menuId)->h; @@ -2516,23 +2519,49 @@ bool GUI_Eob::runSaveMenu(int x, int y) { _screen->modifyScreenDim(11, dm->sx + (x >> 3), dm->sy + y, dm->w, dm->h); - updateSavegameList(); - - /*for (bool runLoop = true; runLoop; ) { - int slot = selectSaveSlotDialogue(x, y, 1); + for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + int slot = selectSaveSlotDialogue(x, y, 0); if (slot > 5) { runLoop = result = false; } else if (slot >= 0) { - if (_saveSlotIdTemp[slot] == -1) { - messageDialogue(11, 65, 6); - } else { - if (_vm->loadGameState(_saveSlotIdTemp[slot]).getCode() != Common::kNoError) - messageDialogue(11, 16, 6); - runLoop = false; + bool useSlot = (_saveSlotIdTemp[slot] == -1); + if (useSlot) + _saveSlotStringsTemp[slot][0] = 0; + else + useSlot = confirmDialogue2(11, 55, 1); + + if (!useSlot) + continue; + + int fx = (x + 1) << 3; + int fy = y + slot * 17 + 23; + + for (int in = -1; in == -1 && !_vm->shouldQuit(); ) { + _screen->fillRect(fx - 2, fy, fx + 160, fy + 8, _vm->_bkgColor_1); + in = getTextInput(_saveSlotStringsTemp[slot], x + 1, fy, 19, 2, 0, 8); + if (!strlen(_saveSlotStringsTemp[slot])) { + messageDialogue(11, 54, 6); + in = -1; + } + }; + + _screen->fillRect(fx - 2, fy, fx + 160, fy + 8, _vm->_bkgColor_1); + _screen->printShadedText(_saveSlotStringsTemp[slot], (x + 1) << 3, fy, 15, 0); + + Graphics::Surface thumb; + createScreenThumbnail(thumb); + Common::Error err = _vm->saveGameStateIntern(_savegameOffset + slot, _saveSlotStringsTemp[slot], &thumb); + thumb.free(); + + if (err.getCode() == Common::kNoError) { + _savegameListUpdateNeeded = true; result = true; + } else { + messageDialogue(11, 15, 6); } + runLoop = false; } - }*/ + } _screen->modifyScreenDim(11, xo, yo, dm->w, dm->h); return result; @@ -2544,7 +2573,9 @@ int GUI_Eob::selectSaveSlotDialogue(int x, int y, int id) { _saveSlotX = _saveSlotY = 0; _screen->setCurPage(2); + updateSavegameList(); setupSaveMenuSlots(); + drawMenuButtonBox(0, 0, 176, 144, false, false); _screen->printShadedText(_vm->_saveLoadStrings[2 + id], 52, 5, 15, 0); @@ -2943,6 +2974,74 @@ bool GUI_Eob::confirmDialogue(int id) { return result; } +bool GUI_Eob::confirmDialogue2(int dim, int id, int deflt) { + int od = _screen->curDimIndex(); + Screen::FontId of = _screen->setFont(Screen::FID_8_FNT); + _screen->setScreenDim(dim); + + drawTextBox(dim, id); + + int16 x[2]; + x[0] = (_screen->_curDim->sx << 3) + 8; + x[1] = (_screen->_curDim->sx + _screen->_curDim->w - 5) << 3; + int16 y = _screen->_curDim->sy + _screen->_curDim->h - 21; + int newHighlight = deflt ^ 1; + int lastHighlight = -1; + + for (int i = 0; i < 2; i++) + drawMenuButtonBox(x[i], y, 32, 14, false, false); + + for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) { + Common::Point p = _vm->getMousePos(); + if (_vm->posWithinRect(p.x, p.y, x[0], y, x[0] + 32, y + 14)) + newHighlight = 0; + else if (_vm->posWithinRect(p.x, p.y, x[1], y, x[1] + 32, y + 14)) + newHighlight = 1; + + int inputFlag = _vm->checkInput(0, false, 0) & 0x8ff; + _vm->removeInputTop(); + + if (inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]) { + runLoop = false; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_LEFT] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP4] || inputFlag == _vm->_keyMap[Common::KEYCODE_RIGHT] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP6]) { + newHighlight ^= 1; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_n]) { + newHighlight = 1; + runLoop = false; + } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_y]) { + newHighlight = 0; + runLoop = false; + } else if (inputFlag == 199 || inputFlag == 201) { + if (_vm->posWithinRect(p.x, p.y, x[0], y, x[0] + 32, y + 14)) { + newHighlight = 0; + runLoop = false; + } else if (_vm->posWithinRect(p.x, p.y, x[1], y, x[1] + 32, y + 14)) { + newHighlight = 1; + runLoop = false; + } + } + + if (newHighlight != lastHighlight) { + for (int i = 0; i < 2; i++) + _screen->printShadedText(_vm->_menuYesNoStrings[i], x[i] + 16 - (strlen(_vm->_menuYesNoStrings[i]) << 2) + 1, y + 3, i == newHighlight ? 6 : 15, 0); + _screen->updateScreen(); + lastHighlight = newHighlight; + } + } + + drawMenuButtonBox(x[newHighlight], y, 32, 14, true, true); + _screen->updateScreen(); + _vm->_system->delayMillis(80); + drawMenuButtonBox(x[newHighlight], y, 32, 14, false, true); + _screen->updateScreen(); + + _screen->copyRegion(0, _screen->_curDim->h, _screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->w << 3, _screen->_curDim->h, 2, 0, Screen::CR_NO_P_CHECK); + _screen->setFont(of); + _screen->setScreenDim(od); + + return newHighlight ? false : true; +} + void GUI_Eob::messageDialogue(int dim, int id, int buttonTextCol) { static const char buttonText[] = "OK"; @@ -2979,9 +3078,11 @@ void GUI_Eob::messageDialogue(int dim, int id, int buttonTextCol) { _vm->_system->delayMillis(80); drawMenuButtonBox(bx, by, bw, 14, false, true); _screen->updateScreen(); - + + _screen->copyRegion(0, dm->h, dm->sx << 3, dm->sy, dm->w << 3, dm->h, 2, 0, Screen::CR_NO_P_CHECK); _screen->setScreenDim(od); _screen->setFont(of); + dm = _screen->getScreenDim(dim); } int GUI_Eob::selectCharacterDialogue(int id) { diff --git a/engines/kyra/gui_eob.h b/engines/kyra/gui_eob.h index f866c9e341..234f2f6ae5 100644 --- a/engines/kyra/gui_eob.h +++ b/engines/kyra/gui_eob.h @@ -67,11 +67,7 @@ public: int getTextInput(char *dest, int x, int y, int destMaxLen, int textColor1, int textColor2, int cursorColor); // utilities for thumbnail creation - void createScreenThumbnail(Graphics::Surface &dst) {} - - // unused - int redrawShadedButtonCallback(Button *button) { return 0; } - int redrawButtonCallback(Button *button) { return 0; } + void createScreenThumbnail(Graphics::Surface &dst); private: int simpleMenu_getMenuItem(int index, int32 menuItemsMask, int itemOffset); @@ -84,6 +80,7 @@ private: void scribeScrollDialogue(); bool confirmDialogue(int id); + bool confirmDialogue2(int dim, int id, int deflt); void messageDialogue(int dim, int id, int buttonTextCol); int selectCharacterDialogue(int id); void displayTextBox(int id); @@ -127,8 +124,8 @@ private: uint16 _prcButtonUnk3; uint16 _cflag; - Button::Callback _scrollUpFunctor; - Button::Callback _scrollDownFunctor; + //Button::Callback _scrollUpFunctor; + //Button::Callback _scrollDownFunctor; int _menuLineSpacing; int _menuLastInFlags; diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp index 77971da441..7a9750fb69 100644 --- a/engines/kyra/magic_eob.cpp +++ b/engines/kyra/magic_eob.cpp @@ -694,11 +694,11 @@ void EobCoreEngine::spellCallback_start_removeParalysis() { } void EobCoreEngine::spellCallback_start_causeSeriousWounds() { - modifyCharacterHitpoints(_activeSpellCaster, rollDice(2, 8, 1)); + } void EobCoreEngine::spellCallback_start_cureSeriousWounds() { - + modifyCharacterHitpoints(_activeSpellCaster, rollDice(2, 8, 1)); } void EobCoreEngine::spellCallback_start_neutralizePoison() { diff --git a/engines/kyra/resource.h b/engines/kyra/resource.h index 441199ce6b..599539c2d2 100644 --- a/engines/kyra/resource.h +++ b/engines/kyra/resource.h @@ -320,6 +320,7 @@ enum KyraResources { kEobBaseMenuStringsTransfer, kEobBaseMenuStringsSpec, kEobBaseMenuStringsSpellNo, + kEobBaseMenuYesNoStrings, kEobBaseSpellLevelsMage, kEobBaseSpellLevelsCleric, diff --git a/engines/kyra/saveload_eob.cpp b/engines/kyra/saveload_eob.cpp index 72bebf997b..a5b2a69c09 100644 --- a/engines/kyra/saveload_eob.cpp +++ b/engines/kyra/saveload_eob.cpp @@ -349,17 +349,14 @@ Common::Error EobCoreEngine::loadGameState(int slot) { } } - if (_saveLoadMode != -1) { - if (_flags.gameID == GI_EOB1) - _screen->loadPalette("EOBPAL.COL", _screen->getPalette(0)); - loadLevel(_currentLevel, _currentSub); - _sceneUpdateRequired = true; - _screen->setFont(Screen::FID_6_FNT); - _saveLoadMode = 1; - } + if (_flags.gameID == GI_EOB1) + _screen->loadPalette("EOBPAL.COL", _screen->getPalette(0)); + loadLevel(_currentLevel, _currentSub); + _sceneUpdateRequired = true; + _screen->setFont(Screen::FID_6_FNT); _screen->setCurPage(0); - gui_drawPlayField(0); + gui_drawPlayField(0); if (_currentControlMode) _screen->copyRegion(176, 0, 0, 0, 144, 168, 0, 5, Screen::CR_NO_P_CHECK); @@ -373,6 +370,8 @@ Common::Error EobCoreEngine::loadGameState(int slot) { useMagicBookOrSymbol(_openBookChar, _openBookType); } + _screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 14, Screen::CR_NO_P_CHECK); + gui_toggleButtons(); setHandItem(_itemInHand); diff --git a/engines/kyra/staticres_eob.cpp b/engines/kyra/staticres_eob.cpp index 6cc7606a21..efc5b854b8 100644 --- a/engines/kyra/staticres_eob.cpp +++ b/engines/kyra/staticres_eob.cpp @@ -387,6 +387,7 @@ void EobCoreEngine::initStaticResource() { _menuStringsTransfer = _staticres->loadStrings(kEobBaseMenuStringsTransfer, temp); _menuStringsSpec = _staticres->loadStrings(kEobBaseMenuStringsSpec, temp); _menuStringsSpellNo = _staticres->loadStrings(kEobBaseMenuStringsSpellNo, temp); + _menuYesNoStrings = _staticres->loadStrings(kEobBaseMenuYesNoStrings, temp); _spellLevelsMage = _staticres->loadRawData(kEobBaseSpellLevelsMage, _spellLevelsMageSize); _spellLevelsCleric = _staticres->loadRawData(kEobBaseSpellLevelsCleric, _spellLevelsClericSize); |