aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2008-03-30 18:27:46 +0000
committerJohannes Schickel2008-03-30 18:27:46 +0000
commitf4e6109b33b4e6bbece5949ff5a06980c89c7c09 (patch)
tree7516905715997ae64a9074faec11ec09d6068128
parent5f3529ce782b21c352500385966c531100aa476b (diff)
downloadscummvm-rg350-f4e6109b33b4e6bbece5949ff5a06980c89c7c09.tar.gz
scummvm-rg350-f4e6109b33b4e6bbece5949ff5a06980c89c7c09.tar.bz2
scummvm-rg350-f4e6109b33b4e6bbece5949ff5a06980c89c7c09.zip
- fixed savegame description loading in kyra1
- added Kyra2 load menu, currently just accessable from startup menu though svn-id: r31331
-rw-r--r--engines/kyra/gui.cpp12
-rw-r--r--engines/kyra/gui_v1.cpp10
-rw-r--r--engines/kyra/gui_v2.cpp269
-rw-r--r--engines/kyra/gui_v2.h83
-rw-r--r--engines/kyra/kyra.h2
-rw-r--r--engines/kyra/kyra_v1.cpp1
-rw-r--r--engines/kyra/kyra_v2.cpp13
-rw-r--r--engines/kyra/kyra_v2.h7
-rw-r--r--engines/kyra/saveload.cpp4
-rw-r--r--engines/kyra/saveload_v1.cpp4
-rw-r--r--engines/kyra/saveload_v2.cpp4
-rw-r--r--engines/kyra/staticres.cpp26
12 files changed, 395 insertions, 40 deletions
diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp
index f949ab81bd..c1d0ba1085 100644
--- a/engines/kyra/gui.cpp
+++ b/engines/kyra/gui.cpp
@@ -112,7 +112,6 @@ void GUI::initMenu(Menu &menu) {
menuButtonData->width = menu.item[i].width - 1;
menuButtonData->height = menu.item[i].height - 1;
menuButtonData->buttonCallback = menu.item[i].callback;
- menuButtonData->index = menu.item[i].saveSlot;
menuButtonData->unk6 = menu.item[i].unk1F;
menuButtonData->unk8 = 0;
@@ -122,19 +121,19 @@ void GUI::initMenu(Menu &menu) {
_screen->fillRect(x1, y1, x2, y2, menu.item[i].bkgdColor);
_screen->drawShadedBox(x1, y1, x2, y2, menu.item[i].color1, menu.item[i].color2);
- if (menu.item[i].itemString) {
+ if (getMenuItemTitle(menu.item[i])) {
if (menu.item[i].titleX != -1)
textX = x1 + menu.item[i].titleX + 3;
else
- textX = _text->getCenterStringX(menu.item[i].itemString, x1, x2);
+ textX = _text->getCenterStringX(getMenuItemTitle(menu.item[i]), x1, x2);
textY = y1 + 2;
- _text->printText(menu.item[i].itemString, textX - 1, textY + 1, defaultColor1(), 0, 0);
+ _text->printText(getMenuItemTitle(menu.item[i]), textX - 1, textY + 1, defaultColor1(), 0, 0);
if (i == menu.highlightedItem)
- _text->printText(menu.item[i].itemString, textX, textY, menu.item[i].highlightColor, 0, 0);
+ _text->printText(getMenuItemTitle(menu.item[i]), textX, textY, menu.item[i].highlightColor, 0, 0);
else
- _text->printText(menu.item[i].itemString, textX, textY, menu.item[i].textColor, 0, 0);
+ _text->printText(getMenuItemTitle(menu.item[i]), textX, textY, menu.item[i].textColor, 0, 0);
if (getMenuItemLabel(menu.item[i])) {
_text->printText(getMenuItemLabel(menu.item[i]), menu.x + menu.item[i].labelX - 1, menu.y + menu.item[i].labelY + 1, defaultColor1(), 0, 0);
@@ -248,6 +247,7 @@ void GUI::updateMenuButton(Button *button) {
_screen->hideMouse();
updateButton(button);
+ _screen->updateScreen();
_screen->showMouse();
}
diff --git a/engines/kyra/gui_v1.cpp b/engines/kyra/gui_v1.cpp
index c39d889741..c86521a625 100644
--- a/engines/kyra/gui_v1.cpp
+++ b/engines/kyra/gui_v1.cpp
@@ -625,10 +625,10 @@ void GUI_v1::setupSavegames(Menu &menu, int num) {
startSlot = 0;
}
+ KyraEngine::SaveHeader header;
for (int i = startSlot; i < num; i++) {
- if ((in = _vm->_saveFileMan->openForLoading(_vm->getSavegameFilename(i + _savegameOffset)))) {
- in->skip(8);
- in->read(savenames[i], 31);
+ if ((in = _vm->openSaveForReading(_vm->getSavegameFilename(i + _savegameOffset), header))) {
+ strncpy(savenames[i], header.description.c_str(), 31);
menu.item[i].itemString = savenames[i];
menu.item[i].enabled = 1;
menu.item[i].saveSlot = i + _savegameOffset;
@@ -772,7 +772,7 @@ void GUI_v1::updateSavegameString() {
int GUI_v1::saveGame(Button *button) {
debugC(9, kDebugLevelGUI, "GUI_v1::saveGame()");
updateMenuButton(button);
- _vm->_gameToLoad = button->index;
+ _vm->_gameToLoad = _menu[2].item[button->index-0xC].saveSlot;
_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
_screen->savePageToDisk("SEENPAGE.TMP", 0);
@@ -830,7 +830,7 @@ int GUI_v1::loadGame(Button *button) {
debugC(9, kDebugLevelGUI, "GUI_v1::loadGame()");
updateMenuButton(button);
_displaySubMenu = false;
- _vm->_gameToLoad = button->index;
+ _vm->_gameToLoad = _menu[2].item[button->index-0xC].saveSlot;
return 0;
}
diff --git a/engines/kyra/gui_v2.cpp b/engines/kyra/gui_v2.cpp
index dfc82ac5fd..7ea0748cf0 100644
--- a/engines/kyra/gui_v2.cpp
+++ b/engines/kyra/gui_v2.cpp
@@ -27,6 +27,9 @@
#include "kyra/kyra_v2.h"
#include "kyra/screen.h"
#include "kyra/wsamovie.h"
+#include "kyra/timer.h"
+
+#include "common/savefile.h"
namespace Kyra {
@@ -226,12 +229,12 @@ void KyraEngine_v2::gui_printString(const char *format, int x, int y, int col1,
void KyraEngine_v2::loadButtonShapes() {
const uint8 *src = _screen->getCPagePtr(3);
_screen->loadBitmap("_BUTTONS.CSH", 3, 3, 0);
- _buttonShapes[0] = _screen->makeShapeCopy(src, 0);
- _buttonShapes[1] = _screen->makeShapeCopy(src, 1);
- _buttonShapes[2] = _screen->makeShapeCopy(src, 2);
- _buttonShapes[3] = _screen->makeShapeCopy(src, 3);
- _buttonShapes[4] = _screen->makeShapeCopy(src, 4);
- _buttonShapes[5] = _screen->makeShapeCopy(src, 5);
+ _gui->_scrollUpButton.data0ShapePtr = _buttonShapes[0] = _screen->makeShapeCopy(src, 0);
+ _gui->_scrollUpButton.data2ShapePtr = _buttonShapes[1] = _screen->makeShapeCopy(src, 1);
+ _gui->_scrollUpButton.data1ShapePtr = _buttonShapes[2] = _screen->makeShapeCopy(src, 2);
+ _gui->_scrollDownButton.data0ShapePtr = _buttonShapes[3] = _screen->makeShapeCopy(src, 3);
+ _gui->_scrollDownButton.data2ShapePtr = _buttonShapes[4] = _screen->makeShapeCopy(src, 4);
+ _gui->_scrollDownButton.data1ShapePtr = _buttonShapes[5] = _screen->makeShapeCopy(src, 5);
_buttonShapes[6] = _screen->makeShapeCopy(src, 6);
_buttonShapes[7] = _screen->makeShapeCopy(src, 7);
_buttonShapes[8] = _screen->makeShapeCopy(src, 6);
@@ -245,6 +248,12 @@ void KyraEngine_v2::loadButtonShapes() {
GUI_v2::GUI_v2(KyraEngine_v2 *vm) : GUI(vm), _vm(vm), _screen(vm->screen_v2()) {
_backUpButtonList = _unknownButtonList = 0;
+ initStaticData();
+ _currentMenu = 0;
+ _isDeathMenu = false;
+ _isSaveMenu = false;
+ _scrollUpFunctor = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::scrollUpButton);
+ _scrollDownFunctor = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::scrollDownButton);
}
Button *GUI_v2::addButtonToList(Button *list, Button *newButton) {
@@ -268,19 +277,23 @@ void GUI_v2::processButton(Button *button) {
byte val1 = 0, val2 = 0, val3 = 0;
const uint8 *dataPtr = 0;
+ Button::Callback callback;
if (entry == 1) {
val1 = button->data1Val1;
dataPtr = button->data1ShapePtr;
+ callback = button->data1Callback;
val2 = button->data1Val2;
val3 = button->data1Val3;
} else if (entry == 4 || entry == 5) {
val1 = button->data2Val1;
dataPtr = button->data2ShapePtr;
+ callback = button->data2Callback;
val2 = button->data2Val2;
val3 = button->data2Val3;
} else {
val1 = button->data0Val1;
dataPtr = button->data0ShapePtr;
+ callback = button->data0Callback;
val2 = button->data0Val2;
val3 = button->data0Val3;
}
@@ -313,14 +326,13 @@ void GUI_v2::processButton(Button *button) {
break;
case 3:
- warning("STUB processButton with func 3");
- //XXX
+ if (callback)
+ (*callback)(button);
break;
case 4:
- warning("STUB processButton with func 4");
_screen->hideMouse();
- //XXX
+ _screen->drawBox(x, y, x2, y2, val2);
_screen->showMouse();
break;
@@ -1141,4 +1153,241 @@ int KyraEngine_v2::cauldronButton(Button *button) {
return 0;
}
+#pragma mark -
+
+int GUI_v2::optionsButton(Button *button) {
+ _restartGame = false;
+ _reloadTemporarySave = false;
+
+ _screen->hideMouse();
+ updateButton(&_vm->_inventoryButtons[0]);
+ _screen->showMouse();
+
+ if (!_screen->isMouseVisible())
+ return 0;
+
+ _vm->showMessage(0, 0xCF);
+
+ if (_vm->_handItemSet < -1) {
+ _vm->_handItemSet = -1;
+ _screen->hideMouse();
+ _screen->setMouseCursor(1, 1, _vm->getShapePtr(0));
+ _screen->showMouse();
+ return 0;
+ }
+
+ //int oldHandItem = _vm->_itemInHand;
+ _screen->setMouseCursor(0, 0, _vm->getShapePtr(0));
+ _vm->displayInvWsaLastFrame();
+ //XXX
+ _displayMenu = true;
+
+ if (!_vm->gameFlags().isTalkie) {
+ //XXX
+ }
+
+ for (uint i = 0; i < ARRAYSIZE(_menuButtons); ++i) {
+ _menuButtons[i].data0Val1 = _menuButtons[i].data1Val1 = _menuButtons[i].data2Val1 = 4;
+ _menuButtons[i].data0Callback = _redrawShadedButtonFunctor;
+ _menuButtons[i].data1Callback = _menuButtons[i].data2Callback = _redrawButtonFunctor;
+ }
+
+ //XXX
+ _loadMenu.numberOfItems = 6;
+ initMenuLayout(_loadMenu);
+
+ if (_vm->_menuDirectlyToLoad) {
+ backUpPage1(_vm->_screenBuffer);
+ setupPalette();
+
+ _loadedSave = false;
+
+ loadMenu(0);
+
+ if (_loadedSave) {
+ if (_restartGame)
+ _vm->_itemInHand = -1;
+ } else {
+ restorePage1(_vm->_screenBuffer);
+ restorePalette();
+ }
+
+ resetState(-1);
+ _vm->_menuDirectlyToLoad = false;
+ return 0;
+ }
+
+ return 0;
+}
+
+#pragma mark -
+
+void GUI_v2::setupPalette() {
+ //if (_isDeathMenu)
+ // memcpy(_vm->_unkBuffer1040Bytes, _screen->getPalette(0), 768);
+
+ memcpy(_screen->getPalette(1), _screen->getPalette(0), 768);
+
+ uint8 *palette = _screen->getPalette(0);
+ for (int i = 0; i < 768; ++i)
+ palette[i] >>= 1;
+
+ static const uint8 guiPal[] = { 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFc, 0xFD, 0xFE };
+
+ for (uint i = 0; i < ARRAYSIZE(guiPal); ++i)
+ memcpy(_screen->getPalette(0)+guiPal[i]*3, _screen->getPalette(1)+guiPal[i]*3, 3);
+
+ if (_isDeathMenu)
+ _screen->fadePalette(_screen->getPalette(0), 0x64);
+ else
+ _screen->setScreenPalette(_screen->getPalette(0));
+}
+
+void GUI_v2::restorePalette() {
+ memcpy(_screen->getPalette(0), _screen->getPalette(1), 768);
+ _screen->setScreenPalette(_screen->getPalette(0));
+}
+
+void GUI_v2::backUpPage1(uint8 *buffer) {
+ _screen->copyRegionToBuffer(1, 0, 0, 320, 200, buffer);
+}
+
+void GUI_v2::restorePage1(const uint8 *buffer) {
+ _screen->copyBlockToPage(1, 0, 0, 320, 200, buffer);
+}
+
+void GUI_v2::resetState(int item) {
+ _vm->_timer->resetNextRun();
+ _vm->setNextIdleAnimTimer();
+ _isDeathMenu = false;
+ if (!_loadedSave) {
+ _vm->setHandItem(item);
+ } else {
+ _vm->setHandItem(_vm->_itemInHand);
+ _vm->setTimer1DelaySecs(7);
+ _vm->_shownMessage = " ";
+ _vm->_fadeMessagePalette = false;
+ }
+ _buttonListChanged = true;
+}
+
+void GUI_v2::setupSavegameNames(Menu &menu, int num) {
+ for (int i = 0; i < num; ++i) {
+ strcpy(_vm->getTableString(menu.item[i].itemId, _vm->_optionsBuffer, 0), "");
+ menu.item[i].saveSlot = -1;
+ menu.item[i].enabled = false;
+ }
+
+ KyraEngine::SaveHeader header;
+ Common::InSaveFile *in;
+ for (int i = 0; i < num; ++i) {
+ if ((in = _vm->openSaveForReading(_vm->getSavegameFilename(i + _savegameOffset), header)) != 0) {
+ strncpy(_vm->getTableString(menu.item[i].itemId, _vm->_optionsBuffer, 0), header.description.c_str(), 80);
+ menu.item[i].saveSlot = i + _savegameOffset;
+ menu.item[i].enabled = true;
+ delete in;
+ }
+ }
+
+ if (_savegameOffset == 0) {
+ char *dst = _vm->getTableString(menu.item[0].itemId, _vm->_optionsBuffer, 0);
+ const char *src = _vm->getTableString(34, _vm->_optionsBuffer, 0);
+ strcpy(dst, src);
+ }
+}
+
+int GUI_v2::scrollUpButton(Button *button) {
+ int startSlot = _isSaveMenu ? 1 : 0;
+ updateMenuButton(button);
+
+ if (_savegameOffset <= startSlot)
+ return 0;
+
+ --_savegameOffset;
+ if (_displaySubMenu) {
+ setupSavegameNames(_loadMenu, 5);
+ // original calls something different here...
+ initMenu(_loadMenu);
+ } else if (_isSaveMenu) {
+ }
+
+ return 0;
+}
+
+int GUI_v2::scrollDownButton(Button *button) {
+ updateMenuButton(button);
+ ++_savegameOffset;
+ if (_displaySubMenu) {
+ setupSavegameNames(_loadMenu, 5);
+ // original calls something different here...
+ initMenu(_loadMenu);
+ } else if (_isSaveMenu) {
+ }
+
+ return 0;
+}
+
+#pragma mark -
+
+int GUI_v2::loadMenu(Button *caller) {
+ if (!_vm->_menuDirectlyToLoad) {
+ updateMenuButton(caller);
+ restorePage1(_vm->_screenBuffer);
+ backUpPage1(_vm->_screenBuffer);
+ }
+
+ _savegameOffset = 0;
+ setupSavegameNames(_loadMenu, 5);
+ initMenu(_loadMenu);
+ _displaySubMenu = true;
+ _cancelSubMenu = false;
+ _vm->_gameToLoad = -1;
+ updateAllMenuButtons();
+
+ _screen->updateScreen();
+ while (_displaySubMenu) {
+ Common::Point mouse = _vm->getMousePos();
+ processHighlights(_loadMenu, mouse.x, mouse.y);
+ _vm->checkInput(_menuButtonList);
+ }
+
+ if (_cancelSubMenu) {
+ if (!_vm->_menuDirectlyToLoad) {
+ restorePage1(_vm->_screenBuffer);
+ backUpPage1(_vm->_screenBuffer);
+ initMenu(*_currentMenu);
+ updateAllMenuButtons();
+ }
+ } else {
+ restorePage1(_vm->_screenBuffer);
+ restorePalette();
+ _vm->loadGame(_vm->getSavegameFilename(_vm->_gameToLoad));
+ if (_vm->_gameToLoad == 0) {
+ _restartGame = true;
+ for (int i = 0; i < 23; ++i)
+ _vm->resetCauldronStateTable(i);
+ _vm->runStartScript(1, 1);
+ }
+ _displayMenu = false;
+ _loadedSave = true;
+ }
+
+ return 0;
+}
+
+int GUI_v2::clickLoadSlot(Button *caller) {
+ updateMenuButton(caller);
+
+ assert((caller->index-0x10) >= 0 && (caller->index-0x10 <= 6));
+ MenuItem &item = _loadMenu.item[caller->index-0x10];
+
+ if (item.saveSlot >= 0) {
+ _vm->_gameToLoad = item.saveSlot;
+ _displaySubMenu = false;
+ }
+
+ return 0;
+}
+
} // end of namespace Kyra
+
diff --git a/engines/kyra/gui_v2.h b/engines/kyra/gui_v2.h
index a430754575..5c8f61adab 100644
--- a/engines/kyra/gui_v2.h
+++ b/engines/kyra/gui_v2.h
@@ -51,6 +51,44 @@
button.data2Val3 = s; \
button.flags2 = t;
+#define GUI_V2_MENU(menu, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) \
+ menu.x = a; \
+ menu.y = b; \
+ menu.width = c; \
+ menu.height = d; \
+ menu.bkgdColor = e; \
+ menu.color1 = f; \
+ menu.color2 = g; \
+ menu.menuNameId = h; \
+ menu.textColor = i; \
+ menu.titleX = j; \
+ menu.titleY = k; \
+ menu.highlightedItem = l; \
+ menu.numberOfItems = m; \
+ menu.scrollUpButtonX = n; \
+ menu.scrollUpButtonY = o; \
+ menu.scrollDownButtonX = p; \
+ menu.scrollDownButtonY = q
+
+#define GUI_V2_MENU_ITEM(item, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) \
+ item.enabled = a; \
+ item.itemId = b; \
+ item.x = c; \
+ item.y = d; \
+ item.width = e; \
+ item.height = f; \
+ item.textColor = g; \
+ item.highlightColor = h; \
+ item.titleX = i; \
+ item.bkgdColor = j; \
+ item.color1 = k; \
+ item.color2 = l; \
+ item.saveSlot = m; \
+ item.labelString = n; \
+ item.labelX = o; \
+ item.labelY = p; \
+ item.unk1F = q
+
namespace Kyra {
class KyraEngine_v2;
@@ -66,27 +104,62 @@ public:
void processButton(Button *button);
int processButtonList(Button *button, uint16 inputFlag);
+ int optionsButton(Button *button);
private:
+ Button _menuButtons[7];
+ Button _scrollUpButton;
+ Button _scrollDownButton;
+ Menu _loadMenu;
+ void initStaticData();
+
const char *getMenuTitle(const Menu &menu);
const char *getMenuItemTitle(const MenuItem &menuItem);
const char *getMenuItemLabel(const MenuItem &menuItem);
- Button *getButtonListData() { return 0; }
- Button *getScrollUpButton() { return 0; }
- Button *getScrollDownButton() { return 0; }
+ Button *getButtonListData() { return _menuButtons; }
+
+ Button *getScrollUpButton() { return &_scrollUpButton; }
+ Button *getScrollDownButton() { return &_scrollDownButton; }
- Button::Callback getScrollUpButtonHandler() const { return Button::Callback(); }
- Button::Callback getScrollDownButtonHandler() const { return Button::Callback(); }
+ int scrollUpButton(Button *button);
+ int scrollDownButton(Button *button);
+ Button::Callback _scrollUpFunctor;
+ Button::Callback _scrollDownFunctor;
+ Button::Callback getScrollUpButtonHandler() const { return _scrollUpFunctor; }
+ Button::Callback getScrollDownButtonHandler() const { return _scrollDownFunctor; }
uint8 defaultColor1() const { return 0xCF; }
uint8 defaultColor2() const { return 0xF8; }
+ void setupPalette();
+ void restorePalette();
+
+ void backUpPage1(uint8 *buffer);
+ void restorePage1(const uint8 *buffer);
+
+ void resetState(int item);
+
KyraEngine_v2 *_vm;
Screen_v2 *_screen;
bool _buttonListChanged;
Button *_backUpButtonList;
Button *_unknownButtonList;
+
+ Menu *_currentMenu;
+ bool _isDeathMenu;
+ bool _isSaveMenu;
+ bool _loadedSave;
+ bool _restartGame;
+ bool _reloadTemporarySave;
+
+ int _savegameOffset;
+
+ void setupSavegameNames(Menu &menu, int num);
+
+ // load menu
+ int loadMenu(Button *caller);
+ int clickLoadSlot(Button *caller);
};
} // end of namespace Kyra
diff --git a/engines/kyra/kyra.h b/engines/kyra/kyra.h
index 0e8b91a55d..0f760997c1 100644
--- a/engines/kyra/kyra.h
+++ b/engines/kyra/kyra.h
@@ -116,7 +116,7 @@ public:
// access to Kyra specific functionallity
Resource *resource() { return _res; }
virtual Screen *screen() = 0;
- TextDisplayer *text() { return _text; }
+ virtual TextDisplayer *text() { return _text; }
Sound *sound() { return _sound; }
StaticResource *staticres() { return _staticres; }
TimerManager *timer() { return _timer; }
diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp
index 39df3bbcc6..3031987aba 100644
--- a/engines/kyra/kyra_v1.cpp
+++ b/engines/kyra/kyra_v1.cpp
@@ -408,7 +408,6 @@ void KyraEngine_v1::startup() {
snd_playTheme(1);
if (_gameToLoad == -1) {
enterNewScene(_currentCharacter->sceneId, _currentCharacter->facing, 0, 0, 1);
-
if (_abortIntroFlag && _skipIntroFlag) {
_menuDirectlyToLoad = true;
_screen->setMouseCursor(1, 1, _shapes[0]);
diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp
index 3385d4ff0a..0924a649fb 100644
--- a/engines/kyra/kyra_v2.cpp
+++ b/engines/kyra/kyra_v2.cpp
@@ -142,6 +142,8 @@ KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags) : KyraEngi
_cauldronState = 0;
_cauldronUseCount = 0;
memset(_cauldronStateTables, 0, sizeof(_cauldronStateTables));
+
+ _menuDirectlyToLoad = false;
}
KyraEngine_v2::~KyraEngine_v2() {
@@ -263,7 +265,7 @@ int KyraEngine_v2::go() {
_res->loadFileList(_ingamePakList, _ingamePakListSize);
}
- //_menuDirectlyToLoad = (_menuChoice == 3) ? true : false;
+ _menuDirectlyToLoad = (_menuChoice == 3) ? true : false;
if (_menuChoice & 1) {
startup();
@@ -394,6 +396,9 @@ void KyraEngine_v2::startup() {
_screen->showMouse();
+ if (_menuDirectlyToLoad)
+ (*_inventoryButtons[0].buttonCallback)(&_inventoryButtons[0]);
+
setNextIdleAnimTimer();
//XXX
_timer->setDelay(0, 5);
@@ -953,12 +958,12 @@ void KyraEngine_v2::changeFileExtension(char *buffer) {
strcpy(buffer, _languageExtension[_lang]);
}
-const uint8 *KyraEngine_v2::getTableEntry(const uint8 *buffer, int id) {
+uint8 *KyraEngine_v2::getTableEntry(uint8 *buffer, int id) {
return buffer + READ_LE_UINT16(buffer + (id<<1));
}
-const char *KyraEngine_v2::getTableString(int id, const uint8 *buffer, int decode) {
- const char *string = (const char*)getTableEntry(buffer, id);
+char *KyraEngine_v2::getTableString(int id, uint8 *buffer, int decode) {
+ char *string = (char*)getTableEntry(buffer, id);
if (decode && _flags.lang != Common::JA_JPN) {
decodeString1(string, _internStringBuf);
diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h
index 3eaf06d67a..fc4e223f01 100644
--- a/engines/kyra/kyra_v2.h
+++ b/engines/kyra/kyra_v2.h
@@ -29,6 +29,7 @@
#include "kyra/kyra.h"
#include "kyra/script.h"
#include "kyra/screen_v2.h"
+#include "kyra/text_v2.h"
#include "kyra/gui_v2.h"
#include "common/list.h"
@@ -169,6 +170,7 @@ public:
virtual Screen *screen() { return _screen; }
Screen_v2 *screen_v2() { return _screen; }
+ virtual TextDisplayer *text() { return _text; }
int language() const { return _lang; }
virtual Movie *createWSAMovie();
@@ -606,6 +608,7 @@ protected:
int _nextAnimItem;
// gui
+ bool _menuDirectlyToLoad;
GUI_v2 *_gui;
void loadButtonShapes();
@@ -676,8 +679,8 @@ protected:
int _currentChapter;
int _newChapterFile;
- const uint8 *getTableEntry(const uint8 *buffer, int id);
- const char *getTableString(int id, const uint8 *buffer, int decode);
+ uint8 *getTableEntry(uint8 *buffer, int id);
+ char *getTableString(int id, uint8 *buffer, int decode);
const char *getChapterString(int id);
int decodeString1(const char *src, char *dst);
void decodeString2(const char *src, char *dst);
diff --git a/engines/kyra/saveload.cpp b/engines/kyra/saveload.cpp
index 0635fa02b5..358f61addf 100644
--- a/engines/kyra/saveload.cpp
+++ b/engines/kyra/saveload.cpp
@@ -107,10 +107,8 @@ Common::InSaveFile *KyraEngine::openSaveForReading(const char *filename, SaveHea
debugC(9, kDebugLevelMain, "KyraEngine::openSaveForReading('%s', -)", filename);
Common::InSaveFile *in = 0;
- if (!(in = _saveFileMan->openForLoading(filename))) {
- warning("Can't open file '%s', game not loadable", filename);
+ if (!(in = _saveFileMan->openForLoading(filename)))
return 0;
- }
kReadSaveHeaderError errorCode = KyraEngine::readSaveHeader(in, header);
if (errorCode != kRSHENoError) {
diff --git a/engines/kyra/saveload_v1.cpp b/engines/kyra/saveload_v1.cpp
index d5e7e2d3d8..7e871876a0 100644
--- a/engines/kyra/saveload_v1.cpp
+++ b/engines/kyra/saveload_v1.cpp
@@ -40,8 +40,10 @@ void KyraEngine_v1::loadGame(const char *fileName) {
SaveHeader header;
Common::InSaveFile *in = openSaveForReading(fileName, header);
- if (!in)
+ if (!in) {
+ warning("Can't open file '%s', game not loadable", fileName);
return;
+ }
if (header.originalSave) {
// no support for original savefile in Kyrandia 1 (yet)
diff --git a/engines/kyra/saveload_v2.cpp b/engines/kyra/saveload_v2.cpp
index 4f301fa68b..fea7ea5c19 100644
--- a/engines/kyra/saveload_v2.cpp
+++ b/engines/kyra/saveload_v2.cpp
@@ -39,8 +39,10 @@ void KyraEngine_v2::saveGame(const char *fileName, const char *saveName) {
debugC(9, kDebugLevelMain, "KyraEngine_v2::saveGame('%s', '%s')", fileName, saveName);
Common::OutSaveFile *out = openSaveForWriting(fileName, saveName);
- if (!out)
+ if (!out) {
+ warning("Can't open file '%s', game not loadable", fileName);
return;
+ }
_timer->saveDataToFile(*out);
diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp
index 613d0e1069..6084213aa2 100644
--- a/engines/kyra/staticres.cpp
+++ b/engines/kyra/staticres.cpp
@@ -1431,7 +1431,7 @@ void KyraEngine_v2::initInventoryButtonList() {
assert(_inventoryButtons);
GUI_V2_BUTTON(_inventoryButtons[0], 0x1, 0x4F, 0, 1, 1, 1, 0x4487, 0, 0x00A, 0x95, 0x39, 0x1D, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0);
- /*&KyraEngine_v2::sub_C9A1*/
+ _inventoryButtons[0].buttonCallback = BUTTON_FUNCTOR(GUI_v2, _gui, &GUI_v2::optionsButton);
GUI_V2_BUTTON(_inventoryButtons[1], 0x2, 0x00, 0, 1, 1, 1, 0x4487, 0, 0x104, 0x90, 0x3C, 0x2C, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0);
_inventoryButtons[1].buttonCallback = BUTTON_FUNCTOR(KyraEngine_v2, this, &KyraEngine_v2::cauldronButton);
@@ -1487,6 +1487,30 @@ void KyraEngine_v2::initInventoryButtonList() {
_buttonList = _gui->addButtonToList(_buttonList, &_inventoryButtons[i]);
}
+void GUI_v2::initStaticData() {
+ GUI_V2_BUTTON(_scrollUpButton, 0x17, 0, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0x18, 0x0F, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0);
+ GUI_V2_BUTTON(_scrollDownButton, 0x18, 0, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0x18, 0x0F, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0);
+
+ for (uint i = 0; i < ARRAYSIZE(_menuButtons); ++i) {
+ GUI_V2_BUTTON(_menuButtons[i], 0x10+i, 0, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0, 0, 0xC7, 0xCF, 0xC7, 0xCF, 0xC7, 0xCF, 0);
+ }
+
+ Button::Callback clickLoadSlotFunctor = BUTTON_FUNCTOR(GUI_v2, this, &GUI_v2::clickLoadSlot);
+
+ memset(&_loadMenu, 0, sizeof(_loadMenu));
+ GUI_V2_MENU(_loadMenu, -1, -1, 0x120, 0xA0, 0xF8, 0xF9, 0xFA, 8, 0xFB, -1, 8, 0, 6, 0x84, 0x16, 0x84, 0x7C);
+ GUI_V2_MENU_ITEM(_loadMenu.item[0], 1, 0x29, -1, 0x27, 0x100, 0xF, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
+ GUI_V2_MENU_ITEM(_loadMenu.item[1], 1, 0x2A, -1, 0x38, 0x100, 0xF, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
+ GUI_V2_MENU_ITEM(_loadMenu.item[2], 1, 0x2B, -1, 0x49, 0x100, 0xF, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
+ GUI_V2_MENU_ITEM(_loadMenu.item[3], 1, 0x2C, -1, 0x5A, 0x100, 0xF, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
+ GUI_V2_MENU_ITEM(_loadMenu.item[4], 1, 0x2D, -1, 0x6B, 0x100, 0xF, 0xFC, 0xFD, 5, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
+ for (int i = 0; i <= 4; ++i)
+ _loadMenu.item[i].callback = clickLoadSlotFunctor;
+
+ GUI_V2_MENU_ITEM(_loadMenu.item[5], 1, 0x0B, 0xB8, 0x86, 0x58, 0xF, 0xFC, 0xFD, -1, 0xF8, 0xF9, 0xFA, -1, 0, 0, 0, 0);
+ _loadMenu.item[6].enabled = false;
+}
+
const uint16 KyraEngine_v2::_itemMagicTable[] = {
0x0D, 0x0A, 0x0B, 0,
0x0D, 0x0B, 0x0A, 0,