KYRA: (EOB) - implement save menu

This commit is contained in:
athrxx 2011-07-02 03:19:46 +02:00 committed by Johannes Schickel
parent c53589bcda
commit 5baabf037d
16 changed files with 159 additions and 63 deletions

View File

@ -272,6 +272,7 @@ const ExtractFilename extractFilenames[] = {
{ kEobBaseMenuStringsTransfer, kTypeStringList, true },
{ kEobBaseMenuStringsSpec, kTypeStringList, true },
{ kEobBaseMenuStringsSpellNo, kTypeStringList, false },
{ kEobBaseMenuYesNoStrings, kTypeStringList, true },
{ kEobBaseSpellLevelsMage, kTypeRawData, false },
{ kEobBaseSpellLevelsCleric, kTypeRawData, false },
@ -1363,6 +1364,8 @@ const char *getIdString(const int id) {
return "kEobBaseMenuStringsSpec";
case kEobBaseMenuStringsSpellNo:
return "kEobBaseMenuStringsSpellNo";
case kEobBaseMenuYesNoStrings:
return "kEobBaseMenuYesNoStrings";
case kEobBaseSpellLevelsMage:
return "kEobBaseSpellLevelsMage";
case kEobBaseSpellLevelsCleric:

View File

@ -247,6 +247,7 @@ enum kExtractID {
kEobBaseMenuStringsTransfer,
kEobBaseMenuStringsSpec,
kEobBaseMenuStringsSpellNo,
kEobBaseMenuYesNoStrings,
kEobBaseSpellLevelsMage,
kEobBaseSpellLevelsCleric,

View File

@ -1094,6 +1094,7 @@ const int eob1FloppyNeed[] = {
kEobBaseMenuStringsRest2,
kEobBaseMenuStringsRest4,
kEobBaseMenuStringsDefeat,
kEobBaseMenuYesNoStrings,
kEobBaseSpellLevelsMage,
kEobBaseSpellLevelsCleric,
@ -1282,6 +1283,7 @@ const int eob2FloppyNeed[] = {
kEobBaseMenuStringsTransfer,
kEobBaseMenuStringsSpec,
kEobBaseMenuStringsSpellNo,
kEobBaseMenuYesNoStrings,
kEobBaseSpellLevelsMage,
kEobBaseSpellLevelsCleric,

View File

@ -1675,6 +1675,12 @@ const ExtractEntrySearchData kEobBaseMenuStringsSpellNoProvider[] = {
EXTRACT_END_ENTRY
};
const ExtractEntrySearchData kEobBaseMenuYesNoStringsProvider[] = {
{ EN_ANY, kPlatformUnknown, { 0x00000007, 0x000001EE, { { 0x8C, 0xF1, 0x35, 0x1F, 0xD6, 0x1F, 0xA4, 0xA1, 0xD6, 0xD6, 0x0A, 0x27, 0xB9, 0xFC, 0x9E, 0x62 } } } },
{ DE_DEU, kPlatformUnknown, { 0x00000008, 0x00000235, { { 0xC7, 0x06, 0xCF, 0xA8, 0xC0, 0xDE, 0xD4, 0x8C, 0x7F, 0xA2, 0x3A, 0xD3, 0x48, 0x51, 0x36, 0x89 } } } },
EXTRACT_END_ENTRY
};
const ExtractEntrySearchData kEobBaseSpellLevelsMageProvider[] = {
{ UNK_LANG, kPlatformUnknown, { 0x0000001A, 0x00000042, { { 0x4F, 0xA3, 0x70, 0x0F, 0x6D, 0xB4, 0xC2, 0xAF, 0x12, 0xB4, 0x2E, 0x26, 0xEF, 0x0B, 0x37, 0x92 } } } }, // EOB1
{ UNK_LANG, kPlatformUnknown, { 0x00000023, 0x00000074, { { 0xBE, 0x10, 0xFA, 0xD9, 0xB3, 0xB0, 0x4E, 0x73, 0xC9, 0xA1, 0xE2, 0xCE, 0xE8, 0xEC, 0x85, 0x0F } } } }, // EOB2
@ -3434,7 +3440,8 @@ const ExtractEntry extractProviders[] = {
{ kEobBaseMenuStringsTransfer, kEobBaseMenuStringsTransferProvider },
{ kEobBaseMenuStringsSpec, kEobBaseMenuStringsSpecProvider },
{ kEobBaseMenuStringsSpellNo, kEobBaseMenuStringsSpellNoProvider },
{ kEobBaseMenuYesNoStrings, kEobBaseMenuYesNoStringsProvider },
{ kEobBaseSpellLevelsMage, kEobBaseSpellLevelsMageProvider },
{ kEobBaseSpellLevelsCleric, kEobBaseSpellLevelsClericProvider },
{ kEobBaseNumSpellsCleric, kEobBaseNumSpellsClericProvider },

View File

@ -77,12 +77,6 @@ void EobEngine::startupNew() {
EobCoreEngine::startupNew();
}
void EobEngine::startupLoad() {
setHandItem(_itemInHand);
loadLevel(_currentLevel, _currentSub);
_saveLoadMode = 0;
}
void EobEngine::npcSequence(int npcIndex) {

View File

@ -48,7 +48,7 @@ private:
// Main loop
void startupNew();
void startupLoad();
void startupLoad() {}
// Intro/Outro
void seq_playOpeningCredits();

View File

@ -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);

View File

@ -64,7 +64,7 @@ private:
// Main loop
void startupNew();
void startupLoad();
void startupLoad() {}
// Intro/Outro
void seq_playIntro();

View File

@ -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();

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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() {

View File

@ -320,6 +320,7 @@ enum KyraResources {
kEobBaseMenuStringsTransfer,
kEobBaseMenuStringsSpec,
kEobBaseMenuStringsSpellNo,
kEobBaseMenuYesNoStrings,
kEobBaseSpellLevelsMage,
kEobBaseSpellLevelsCleric,

View File

@ -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);

View File

@ -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);