aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorJohannes Schickel2008-05-05 16:05:56 +0000
committerJohannes Schickel2008-05-05 16:05:56 +0000
commit2afff044689a9d25c11d46b56a42d5948b95da1a (patch)
tree5fbebdea8b2c52858d4542a61e1b79d2ca55270e /engines
parent4eb9abe99f27d867f3d549bb15c8a4d71af7df3c (diff)
downloadscummvm-rg350-2afff044689a9d25c11d46b56a42d5948b95da1a.tar.gz
scummvm-rg350-2afff044689a9d25c11d46b56a42d5948b95da1a.tar.bz2
scummvm-rg350-2afff044689a9d25c11d46b56a42d5948b95da1a.zip
- Added support for Kyra3 GUI (audio and game options not working yet)
- Added support for loading directly from command line for Kyra3 svn-id: r31876
Diffstat (limited to 'engines')
-rw-r--r--engines/kyra/gui.cpp2
-rw-r--r--engines/kyra/gui.h4
-rw-r--r--engines/kyra/gui_hof.cpp602
-rw-r--r--engines/kyra/gui_hof.h101
-rw-r--r--engines/kyra/gui_mr.cpp331
-rw-r--r--engines/kyra/gui_mr.h28
-rw-r--r--engines/kyra/gui_v2.cpp473
-rw-r--r--engines/kyra/gui_v2.h102
-rw-r--r--engines/kyra/kyra_hof.cpp4
-rw-r--r--engines/kyra/kyra_hof.h1
-rw-r--r--engines/kyra/kyra_mr.cpp90
-rw-r--r--engines/kyra/kyra_mr.h9
-rw-r--r--engines/kyra/kyra_v2.cpp8
-rw-r--r--engines/kyra/kyra_v2.h2
-rw-r--r--engines/kyra/scene_mr.cpp2
-rw-r--r--engines/kyra/staticres.cpp115
-rw-r--r--engines/kyra/timer_v1.cpp2
17 files changed, 1194 insertions, 682 deletions
diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp
index 43137ac866..d2e02671c9 100644
--- a/engines/kyra/gui.cpp
+++ b/engines/kyra/gui.cpp
@@ -314,6 +314,8 @@ void GUI::updateSaveList() {
s1 -= '0';
s2 -= '0';
s3 -= '0';
+ if (s1 == 9 && s2 == 9 && s3 == 9)
+ continue;
_saveSlots.push_back(s1*100+s2*10+s3);
}
diff --git a/engines/kyra/gui.h b/engines/kyra/gui.h
index dfbca22441..a04ac20de3 100644
--- a/engines/kyra/gui.h
+++ b/engines/kyra/gui.h
@@ -142,8 +142,8 @@ public:
virtual void processButton(Button *button) = 0;
virtual int processButtonList(Button *buttonList, uint16 inputFlags) = 0;
- int redrawShadedButtonCallback(Button *button);
- int redrawButtonCallback(Button *button);
+ virtual int redrawShadedButtonCallback(Button *button);
+ virtual int redrawButtonCallback(Button *button);
// menu specific
virtual void initMenuLayout(Menu &menu);
diff --git a/engines/kyra/gui_hof.cpp b/engines/kyra/gui_hof.cpp
index 9916104a30..ce00a418f6 100644
--- a/engines/kyra/gui_hof.cpp
+++ b/engines/kyra/gui_hof.cpp
@@ -81,13 +81,6 @@ void KyraEngine_HoF::setupLangButtonShapes() {
}
GUI_HoF::GUI_HoF(KyraEngine_HoF *vm) : GUI_v2(vm), _vm(vm), _screen(_vm->_screen) {
- initStaticData();
- _currentMenu = 0;
- _isDeathMenu = false;
- _isSaveMenu = false;
- _isLoadMenu = false;
- _scrollUpFunctor = BUTTON_FUNCTOR(GUI_HoF, this, &GUI_HoF::scrollUpButton);
- _scrollDownFunctor = BUTTON_FUNCTOR(GUI_HoF, this, &GUI_HoF::scrollDownButton);
_sliderHandlerFunctor = BUTTON_FUNCTOR(GUI_HoF, this, &GUI_HoF::sliderHandler);
}
@@ -112,6 +105,10 @@ const char *GUI_HoF::getMenuItemLabel(const MenuItem &menuItem) {
return _vm->getTableString(menuItem.labelId, _vm->_optionsBuffer, 1);
}
+char *GUI_HoF::getTableString(int id) {
+ return _vm->getTableString(id, _vm->_optionsBuffer, 0);
+}
+
#pragma mark -
@@ -669,21 +666,6 @@ int KyraEngine_HoF::cauldronButton(Button *button) {
#pragma mark -
-void GUI_HoF::getInput() {
- if (!_displayMenu)
- return;
-
- _vm->checkInput(_menuButtonList);
- _vm->removeInputTop();
- if (_vm->quit()) {
- _displayMenu = false;
- _isLoadMenu = false;
- _isSaveMenu = false;
- _isOptionsMenu = false;
- _isDeleteMenu = false;
- }
-}
-
int GUI_HoF::optionsButton(Button *button) {
_restartGame = false;
_reloadTemporarySave = false;
@@ -797,19 +779,6 @@ int GUI_HoF::optionsButton(Button *button) {
#pragma mark -
-void GUI_HoF::renewHighlight(Menu &menu) {
- if (!_displayMenu)
- return;
-
- MenuItem &item = menu.item[menu.highlightedItem];
- int x = item.x + menu.x; int y = item.y + menu.y;
- int x2 = x + item.width - 1; int y2 = y + item.height - 1;
- redrawText(menu);
- _screen->fillRect(x+2, y+2, x2-2, y2-2, item.bkgdColor);
- redrawHighlight(menu);
- _screen->updateScreen();
-}
-
void GUI_HoF::setupPalette() {
memcpy(_screen->getPalette(1), _screen->getPalette(0), 768);
@@ -833,14 +802,6 @@ void GUI_HoF::restorePalette() {
_screen->setScreenPalette(_screen->getPalette(0));
}
-void GUI_HoF::backUpPage1(uint8 *buffer) {
- _screen->copyRegionToBuffer(1, 0, 0, 320, 200, buffer);
-}
-
-void GUI_HoF::restorePage1(const uint8 *buffer) {
- _screen->copyBlockToPage(1, 0, 0, 320, 200, buffer);
-}
-
void GUI_HoF::resetState(int item) {
_vm->_timer->resetNextRun();
_vm->setNextIdleAnimTimer();
@@ -856,81 +817,27 @@ void GUI_HoF::resetState(int item) {
_buttonListChanged = true;
}
-void GUI_HoF::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;
- }
-
- int startSlot = 0;
- if (_isSaveMenu && _savegameOffset == 0)
- startSlot = 1;
-
- KyraEngine::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) {
- strncpy(_vm->getTableString(menu.item[i].itemId, _vm->_optionsBuffer, 0), header.description.c_str(), 80);
- menu.item[i].saveSlot = _saveSlots[i + _savegameOffset];
- menu.item[i].enabled = true;
- delete in;
- }
- }
-
- if (_savegameOffset == 0) {
- if (_isSaveMenu) {
- char *dst = _vm->getTableString(menu.item[0].itemId, _vm->_optionsBuffer, 0);
- const char *src = _vm->getTableString(_vm->gameFlags().isTalkie ? 10 : 18, _vm->_optionsBuffer, 0);
- strcpy(dst, src);
- menu.item[0].saveSlot = -2;
- menu.item[0].enabled = true;
- } else {
- char *dst = _vm->getTableString(menu.item[0].itemId, _vm->_optionsBuffer, 0);
- const char *src = _vm->getTableString(_vm->gameFlags().isTalkie ? 34 : 42, _vm->_optionsBuffer, 0);
- strcpy(dst, src);
- }
- }
-}
-
-int GUI_HoF::scrollUpButton(Button *button) {
- updateMenuButton(button);
-
- if (_savegameOffset == (_isDeleteMenu ? 1 : 0))
- return 0;
-
- --_savegameOffset;
- if (_isLoadMenu) {
- setupSavegameNames(_loadMenu, 5);
- // original calls something different here...
- initMenu(_loadMenu);
- } else if (_isSaveMenu || _isDeleteMenu) {
- setupSavegameNames(_saveMenu, 5);
- // original calls something different here...
- initMenu(_saveMenu);
- }
-
- return 0;
-}
+void GUI_HoF::drawSliderBar(int slider, const uint8 *shape) {
+ const int menuX = _audioOptions.x;
+ const int menuY = _audioOptions.y;
+ int x = menuX + _sliderBarsPosition[slider*2+0] + 10;
+ int y = menuY + _sliderBarsPosition[slider*2+1];
-int GUI_HoF::scrollDownButton(Button *button) {
- updateMenuButton(button);
- ++_savegameOffset;
-
- if (uint(_savegameOffset + 5) >= _saveSlots.size())
- _savegameOffset = MAX<int>(_saveSlots.size() - 5, _isDeleteMenu ? 1 : 0);
-
- if (_isLoadMenu) {
- setupSavegameNames(_loadMenu, 5);
- // original calls something different here...
- initMenu(_loadMenu);
- } else if (_isSaveMenu || _isDeleteMenu) {
- setupSavegameNames(_saveMenu, 5);
- // original calls something different here...
- initMenu(_saveMenu);
+ int position = 0;
+ if (_vm->gameFlags().isTalkie) {
+ position = _vm->getVolume(KyraEngine::kVolumeEntry(slider));
+ } else {
+ if (slider < 2)
+ position = _vm->getVolume(KyraEngine::kVolumeEntry(slider));
+ else if (slider == 2)
+ position = (_vm->_configWalkspeed == 3) ? 97 : 2;
+ else if (slider == 3)
+ position = _vm->_configTextspeed;
}
- return 0;
+ position = MAX(2, position);
+ position = MIN(97, position);
+ _screen->drawShape(0, shape, x+position, y, 0, 0);
}
#pragma mark -
@@ -953,9 +860,54 @@ int GUI_HoF::quitGame(Button *caller) {
return 0;
}
-int GUI_HoF::resumeGame(Button *caller) {
+int GUI_HoF::audioOptions(Button *caller) {
updateMenuButton(caller);
- _displayMenu = false;
+ restorePage1(_vm->_screenBuffer);
+ backUpPage1(_vm->_screenBuffer);
+ initMenu(_audioOptions);
+ const int menuX = _audioOptions.x;
+ const int menuY = _audioOptions.y;
+ const int maxButton = 3; // 2 if voc is disabled
+
+ for (int i = 0; i < maxButton; ++i) {
+ int x = menuX + _sliderBarsPosition[i*2+0];
+ int y = menuY + _sliderBarsPosition[i*2+1];
+ _screen->drawShape(0, _vm->_buttonShapes[16], x, y, 0, 0);
+ drawSliderBar(i, _vm->_buttonShapes[17]);
+ _sliderButtons[0][i].buttonCallback = _sliderHandlerFunctor;
+ _sliderButtons[0][i].x = x;
+ _sliderButtons[0][i].y = y;
+ _menuButtonList = addButtonToList(_menuButtonList, &_sliderButtons[0][i]);
+ _sliderButtons[2][i].buttonCallback = _sliderHandlerFunctor;
+ _sliderButtons[2][i].x = x + 10;
+ _sliderButtons[2][i].y = y;
+ _menuButtonList = addButtonToList(_menuButtonList, &_sliderButtons[2][i]);
+ _sliderButtons[1][i].buttonCallback = _sliderHandlerFunctor;
+ _sliderButtons[1][i].x = x + 120;
+ _sliderButtons[1][i].y = y;
+ _menuButtonList = addButtonToList(_menuButtonList, &_sliderButtons[1][i]);
+ }
+
+ _isOptionsMenu = true;
+ updateAllMenuButtons();
+ bool speechEnabled = _vm->speechEnabled();
+ while (_isOptionsMenu) {
+ processHighlights(_audioOptions, _vm->_mouseX, _vm->_mouseY);
+ getInput();
+ }
+
+ restorePage1(_vm->_screenBuffer);
+ backUpPage1(_vm->_screenBuffer);
+ if (speechEnabled && !_vm->textEnabled() && (!_vm->speechEnabled() || _vm->getVolume(KyraEngine::kVolumeSpeech) == 2)) {
+ _vm->_configVoice = 0;
+ _vm->setVolume(KyraEngine::kVolumeSpeech, 75);
+ choiceDialog(0x1D, 0);
+ }
+
+ _vm->writeSettings();
+
+ initMenu(*_currentMenu);
+ updateAllMenuButtons();
return 0;
}
@@ -1048,12 +1000,6 @@ int GUI_HoF::gameOptionsTalkie(Button *caller) {
return 0;
}
-int GUI_HoF::quitOptionsMenu(Button *caller) {
- updateMenuButton(caller);
- _isOptionsMenu = false;
- return 0;
-}
-
int GUI_HoF::toggleWalkspeed(Button *caller) {
updateMenuButton(caller);
if (_vm->_configWalkspeed == 5)
@@ -1124,57 +1070,6 @@ void GUI_HoF::setupOptionsButtons() {
}
}
-int GUI_HoF::audioOptions(Button *caller) {
- updateMenuButton(caller);
- restorePage1(_vm->_screenBuffer);
- backUpPage1(_vm->_screenBuffer);
- initMenu(_audioOptions);
- const int menuX = _audioOptions.x;
- const int menuY = _audioOptions.y;
- const int maxButton = 3; // 2 if voc is disabled
-
- for (int i = 0; i < maxButton; ++i) {
- int x = menuX + _sliderBarsPosition[i*2+0];
- int y = menuY + _sliderBarsPosition[i*2+1];
- _screen->drawShape(0, _vm->_buttonShapes[16], x, y, 0, 0);
- drawSliderBar(i, _vm->_buttonShapes[17]);
- _sliderButtons[0][i].buttonCallback = _sliderHandlerFunctor;
- _sliderButtons[0][i].x = x;
- _sliderButtons[0][i].y = y;
- _menuButtonList = addButtonToList(_menuButtonList, &_sliderButtons[0][i]);
- _sliderButtons[2][i].buttonCallback = _sliderHandlerFunctor;
- _sliderButtons[2][i].x = x + 10;
- _sliderButtons[2][i].y = y;
- _menuButtonList = addButtonToList(_menuButtonList, &_sliderButtons[2][i]);
- _sliderButtons[1][i].buttonCallback = _sliderHandlerFunctor;
- _sliderButtons[1][i].x = x + 120;
- _sliderButtons[1][i].y = y;
- _menuButtonList = addButtonToList(_menuButtonList, &_sliderButtons[1][i]);
- }
-
- _isOptionsMenu = true;
- updateAllMenuButtons();
- bool speechEnabled = _vm->speechEnabled();
- while (_isOptionsMenu) {
- processHighlights(_audioOptions, _vm->_mouseX, _vm->_mouseY);
- getInput();
- }
-
- restorePage1(_vm->_screenBuffer);
- backUpPage1(_vm->_screenBuffer);
- if (speechEnabled && !_vm->textEnabled() && (!_vm->speechEnabled() || _vm->getVolume(KyraEngine::kVolumeSpeech) == 2)) {
- _vm->_configVoice = 0;
- _vm->setVolume(KyraEngine::kVolumeSpeech, 75);
- choiceDialog(0x1D, 0);
- }
-
- _vm->writeSettings();
-
- initMenu(*_currentMenu);
- updateAllMenuButtons();
- return 0;
-}
-
int GUI_HoF::sliderHandler(Button *caller) {
int button = 0;
if (caller->index >= 24 && caller->index <= 27)
@@ -1270,29 +1165,6 @@ int GUI_HoF::sliderHandler(Button *caller) {
return 0;
}
-void GUI_HoF::drawSliderBar(int slider, const uint8 *shape) {
- const int menuX = _audioOptions.x;
- const int menuY = _audioOptions.y;
- int x = menuX + _sliderBarsPosition[slider*2+0] + 10;
- int y = menuY + _sliderBarsPosition[slider*2+1];
-
- int position = 0;
- if (_vm->gameFlags().isTalkie) {
- position = _vm->getVolume(KyraEngine::kVolumeEntry(slider));
- } else {
- if (slider < 2)
- position = _vm->getVolume(KyraEngine::kVolumeEntry(slider));
- else if (slider == 2)
- position = (_vm->_configWalkspeed == 3) ? 97 : 2;
- else if (slider == 3)
- position = _vm->_configTextspeed;
- }
-
- position = MAX(2, position);
- position = MIN(97, position);
- _screen->drawShape(0, shape, x+position, y, 0, 0);
-}
-
int GUI_HoF::loadMenu(Button *caller) {
updateSaveList();
@@ -1340,341 +1212,5 @@ int GUI_HoF::loadMenu(Button *caller) {
return 0;
}
-int GUI_HoF::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;
- _isLoadMenu = false;
- }
-
- return 0;
-}
-
-int GUI_HoF::cancelLoadMenu(Button *caller) {
- updateMenuButton(caller);
- _isLoadMenu = false;
- _noLoadProcess = true;
- return 0;
-}
-
-int GUI_HoF::saveMenu(Button *caller) {
- updateSaveList();
-
- updateMenuButton(caller);
-
- restorePage1(_vm->_screenBuffer);
- backUpPage1(_vm->_screenBuffer);
-
- _isSaveMenu = true;
- _noSaveProcess = false;
- _saveSlot = -1;
- _savegameOffset = 0;
- setupSavegameNames(_saveMenu, 5);
- initMenu(_saveMenu);
-
- updateAllMenuButtons();
-
- while (_isSaveMenu) {
- processHighlights(_saveMenu, _vm->_mouseX, _vm->_mouseY);
- getInput();
- }
-
- if (_noSaveProcess) {
- restorePage1(_vm->_screenBuffer);
- backUpPage1(_vm->_screenBuffer);
- initMenu(*_currentMenu);
- updateAllMenuButtons();
- return 0;
- } else if(_saveSlot <= -1) {
- return 0;
- }
-
- restorePage1(_vm->_screenBuffer);
- restorePalette();
- _vm->saveGame(_vm->getSavegameFilename(_saveSlot), _saveDescription);
- _displayMenu = false;
- _madeSave = true;
-
- return 0;
-}
-
-int GUI_HoF::clickSaveSlot(Button *caller) {
- updateMenuButton(caller);
-
- assert((caller->index-0x10) >= 0 && (caller->index-0x10 <= 6));
- MenuItem &item = _saveMenu.item[caller->index-0x10];
-
- if (item.saveSlot >= 0) {
- if (_isDeleteMenu) {
- _slotToDelete = item.saveSlot;
- _isDeleteMenu = false;
- return 0;
- } else {
- _saveSlot = item.saveSlot;
- strcpy(_saveDescription, _vm->getTableString(item.itemId, _vm->_optionsBuffer, 0));
- }
- } else if (item.saveSlot == -2) {
- _saveSlot = getNextSavegameSlot();
- memset(_saveDescription, 0, sizeof(_saveDescription));
- }
-
- restorePage1(_vm->_screenBuffer);
- backUpPage1(_vm->_screenBuffer);
-
- initMenu(_savenameMenu);
- _screen->fillRect(0x26, 0x5B, 0x11F, 0x66, 0xFA);
- const char *desc = nameInputProcess(_saveDescription, 0x27, 0x5C, 0xFD, 0xFA, 0xFE, 0x50);
- restorePage1(_vm->_screenBuffer);
- backUpPage1(_vm->_screenBuffer);
- if (desc) {
- _isSaveMenu = false;
- _isDeleteMenu = false;
- } else {
- initMenu(_saveMenu);
- }
-
- return 0;
-}
-
-int GUI_HoF::cancelSaveMenu(Button *caller) {
- updateMenuButton(caller);
- _isSaveMenu = false;
- _isDeleteMenu = false;
- _noSaveProcess = true;
- return 0;
-}
-
-int GUI_HoF::deleteMenu(Button *caller) {
- updateSaveList();
-
- updateMenuButton(caller);
- if (_saveSlots.size() < 2) {
- _vm->snd_playSoundEffect(0x0D);
- return 0;
- }
-
- do {
- restorePage1(_vm->_screenBuffer);
- backUpPage1(_vm->_screenBuffer);
- _savegameOffset = 1;
- _saveMenu.menuNameId = _vm->gameFlags().isTalkie ? 35 : 1;
- setupSavegameNames(_saveMenu, 5);
- initMenu(_saveMenu);
- _isDeleteMenu = true;
- _slotToDelete = -1;
- updateAllMenuButtons();
-
- while (_isDeleteMenu) {
- processHighlights(_saveMenu, _vm->_mouseX, _vm->_mouseY);
- getInput();
- }
-
- if (_slotToDelete < 1) {
- restorePage1(_vm->_screenBuffer);
- backUpPage1(_vm->_screenBuffer);
- initMenu(*_currentMenu);
- updateAllMenuButtons();
- _saveMenu.menuNameId = _vm->gameFlags().isTalkie ? 9 : 17;
- return 0;
- }
- } while (choiceDialog(_vm->gameFlags().isTalkie ? 0x24 : 2, 1) == 0);
-
- restorePage1(_vm->_screenBuffer);
- backUpPage1(_vm->_screenBuffer);
- initMenu(*_currentMenu);
- updateAllMenuButtons();
- _vm->_saveFileMan->removeSavefile(_vm->getSavegameFilename(_slotToDelete));
- Common::Array<int>::iterator i = Common::find(_saveSlots.begin(), _saveSlots.end(), _slotToDelete);
- 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.c_str(), newName.c_str());
- }
- _saveMenu.menuNameId = _vm->gameFlags().isTalkie ? 9 : 17;
- return 0;
-}
-
-const char *GUI_HoF::nameInputProcess(char *buffer, int x, int y, uint8 c1, uint8 c2, uint8 c3, int bufferSize) {
- bool running = true;
- int curPos = strlen(buffer);
-
- int x2 = x, y2 = y;
- _text->printText(buffer, x, y, c1, c2, c2);
-
- for (int i = 0; i < curPos; ++i)
- x2 += getCharWidth(buffer[i]);
-
- drawTextfieldBlock(x2, y2, c3);
-
- _keyPressed.reset();
- _cancelNameInput = _finishNameInput = false;
- while (running && !_vm->quit()) {
- processHighlights(_savenameMenu, _vm->_mouseX, _vm->_mouseY);
- checkTextfieldInput();
- if (_keyPressed.keycode == Common::KEYCODE_RETURN || _keyPressed.keycode == Common::KEYCODE_KP_ENTER || _finishNameInput) {
- if (checkSavegameDescription(buffer, curPos)) {
- buffer[curPos] = 0;
- running = false;
- } else {
- _finishNameInput = false;
- }
- } else if (_keyPressed.keycode == Common::KEYCODE_ESCAPE || _cancelNameInput) {
- running = false;
- return 0;
- } else if ((_keyPressed.keycode == Common::KEYCODE_BACKSPACE || _keyPressed.keycode == Common::KEYCODE_DELETE) && curPos > 0) {
- drawTextfieldBlock(x2, y2, c2);
- --curPos;
- x2 -= getCharWidth(buffer[curPos]);
- drawTextfieldBlock(x2, y2, c3);
- _screen->updateScreen();
- } else if (_keyPressed.ascii > 31 && _keyPressed.ascii < 127 && curPos < bufferSize) {
- if (x2 + getCharWidth(_keyPressed.ascii) + 7 < 0x11F) {
- buffer[curPos] = _keyPressed.ascii;
- const char text[2] = { buffer[curPos], 0 };
- _text->printText(text, x2, y2, c1, c2, c2);
- x2 += getCharWidth(_keyPressed.ascii);
- drawTextfieldBlock(x2, y2, c3);
- ++curPos;
- _screen->updateScreen();
- }
- }
-
- _keyPressed.reset();
- }
-
- return buffer;
-}
-
-int GUI_HoF::finishSavename(Button *caller) {
- updateMenuButton(caller);
- _finishNameInput = true;
- return 0;
-}
-
-int GUI_HoF::cancelSavename(Button *caller) {
- updateMenuButton(caller);
- _cancelNameInput = true;
- return 0;
-}
-
-bool GUI_HoF::checkSavegameDescription(const char *buffer, int size) {
- if (!buffer || !size)
- return false;
- if (buffer[0] == 0)
- return false;
- for (int i = 0; i < size; ++i) {
- if (buffer[i] != 0x20)
- return true;
- else if (buffer[i] == 0x00)
- return false;
- }
- return false;
-}
-
-int GUI_HoF::getCharWidth(uint8 c) {
- Screen::FontId old = _screen->setFont(Screen::FID_8_FNT);
- _screen->_charWidth = -2;
- int width = _screen->getCharWidth(c);
- _screen->_charWidth = 0;
- _screen->setFont(old);
- return width;
-}
-
-void GUI_HoF::checkTextfieldInput() {
- Common::Event event;
-
- bool running = true;
- int keys = 0;
- while (_vm->_eventMan->pollEvent(event) && running) {
- switch (event.type) {
- case Common::EVENT_QUIT:
- _vm->_quitFlag = true;
- break;
-
- case Common::EVENT_KEYDOWN:
- if (event.kbd.keycode == 'q' && event.kbd.flags == Common::KBD_CTRL)
- _vm->_quitFlag = true;
- else
- _keyPressed = event.kbd;
- running = false;
- break;
-
- case Common::EVENT_LBUTTONDOWN:
- case Common::EVENT_LBUTTONUP: {
- Common::Point pos = _vm->getMousePos();
- _vm->_mouseX = pos.x;
- _vm->_mouseY = pos.y;
- keys = event.type == Common::EVENT_LBUTTONDOWN ? 199 : (200 | 0x800);
- running = false;
- } break;
-
- case Common::EVENT_MOUSEMOVE: {
- Common::Point pos = _vm->getMousePos();
- _vm->_mouseX = pos.x;
- _vm->_mouseY = pos.y;
- _screen->updateScreen();
- } break;
-
- default:
- break;
- }
- }
-
- processButtonList(_menuButtonList, keys | 0x8000);
-}
-
-void GUI_HoF::drawTextfieldBlock(int x, int y, uint8 c) {
- _screen->fillRect(x+1, y+1, x+7, y+8, c);
-}
-
-bool GUI_HoF::choiceDialog(int name, bool type) {
- _choiceMenu.highlightedItem = 0;
- restorePage1(_vm->_screenBuffer);
- backUpPage1(_vm->_screenBuffer);
- if (type)
- _choiceMenu.numberOfItems = 2;
- else
- _choiceMenu.numberOfItems = 1;
- _choiceMenu.menuNameId = name;
-
- initMenu(_choiceMenu);
- _isChoiceMenu = true;
- _choice = false;
-
- while (_isChoiceMenu) {
- processHighlights(_choiceMenu, _vm->_mouseX, _vm->_mouseY);
- getInput();
- }
-
- restorePage1(_vm->_screenBuffer);
- backUpPage1(_vm->_screenBuffer);
- return _choice;
-}
-
-int GUI_HoF::choiceYes(Button *caller) {
- updateMenuButton(caller);
- _choice = true;
- _isChoiceMenu = false;
- return 0;
-}
-
-int GUI_HoF::choiceNo(Button *caller) {
- updateMenuButton(caller);
- _choice = false;
- _isChoiceMenu = false;
- return 0;
-}
-
} // end of namespace Kyra
diff --git a/engines/kyra/gui_hof.h b/engines/kyra/gui_hof.h
index f48f6c88c9..6abaff3797 100644
--- a/engines/kyra/gui_hof.h
+++ b/engines/kyra/gui_hof.h
@@ -38,74 +38,36 @@ friend class KyraEngine_HoF;
public:
GUI_HoF(KyraEngine_HoF *engine);
- int optionsButton(Button *button);
-private:
- void getInput();
-
- Button _menuButtons[7];
- Button _scrollUpButton;
- Button _scrollDownButton;
- Menu _mainMenu, _gameOptions, _audioOptions, _choiceMenu, _loadMenu, _saveMenu, _savenameMenu, _deathMenu;
void initStaticData();
+ int optionsButton(Button *button);
+private:
const char *getMenuTitle(const Menu &menu);
const char *getMenuItemTitle(const MenuItem &menuItem);
const char *getMenuItemLabel(const MenuItem &menuItem);
- Button *getButtonListData() { return _menuButtons; }
-
- Button *getScrollUpButton() { return &_scrollUpButton; }
- Button *getScrollDownButton() { return &_scrollDownButton; }
-
- 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; }
-
- Button _sliderButtons[3][4];
-
uint8 defaultColor1() const { return 0xCF; }
uint8 defaultColor2() const { return 0xF8; }
- void renewHighlight(Menu &menu);
+ uint8 textFieldColor1() const { return 0xFD; }
+ uint8 textFieldColor2() const { return 0xFA; }
+ uint8 textFieldColor3() const { return 0xFE; }
void setupPalette();
void restorePalette();
- void backUpPage1(uint8 *buffer);
- void restorePage1(const uint8 *buffer);
-
void resetState(int item);
+ char *getTableString(int id);
+
KyraEngine_HoF *_vm;
Screen_HoF *_screen;
- Menu *_currentMenu;
- bool _isLoadMenu;
- bool _isDeathMenu;
- bool _isSaveMenu;
- bool _isDeleteMenu;
- bool _isChoiceMenu;
- bool _isOptionsMenu;
- bool _madeSave;
- bool _loadedSave;
- bool _restartGame;
- bool _reloadTemporarySave;
-
- int _savegameOffset;
-
- void setupSavegameNames(Menu &menu, int num);
-
- // main menu
int quitGame(Button *caller);
- int resumeGame(Button *caller);
-
- // options menu
+ int loadMenu(Button *caller);
+ int audioOptions(Button *caller);
int gameOptions(Button *caller);
int gameOptionsTalkie(Button *caller);
- int quitOptionsMenu(Button *caller);
int toggleWalkspeed(Button *caller);
int changeLanguage(Button *caller);
@@ -113,55 +75,10 @@ private:
void setupOptionsButtons();
- // audio menu
- int audioOptions(Button *caller);
-
Button::Callback _sliderHandlerFunctor;
int sliderHandler(Button *caller);
-
void drawSliderBar(int slider, const uint8 *shape);
- static const int _sliderBarsPosition[];
-
- // load menu
- bool _noLoadProcess;
- int loadMenu(Button *caller);
- int clickLoadSlot(Button *caller);
- int cancelLoadMenu(Button *caller);
-
- // save menu
- bool _noSaveProcess;
- int _saveSlot;
- char _saveDescription[0x50];
-
- int saveMenu(Button *caller);
- int clickSaveSlot(Button *caller);
- int cancelSaveMenu(Button *caller);
-
- // delete menu
- int _slotToDelete;
- int deleteMenu(Button *caller);
-
- // savename menu
- bool _finishNameInput, _cancelNameInput;
- Common::KeyState _keyPressed;
-
- const char *nameInputProcess(char *buffer, int x, int y, uint8 c1, uint8 c2, uint8 c3, int bufferSize);
- int finishSavename(Button *caller);
- int cancelSavename(Button *caller);
-
- bool checkSavegameDescription(const char *buffer, int size);
- int getCharWidth(uint8 c);
- void checkTextfieldInput();
- void drawTextfieldBlock(int x, int y, uint8 c);
-
- // choice menu
- bool _choice;
-
- bool choiceDialog(int name, bool type);
- int choiceYes(Button *caller);
- int choiceNo(Button *caller);
-
static const uint16 _menuStringsTalkie[];
static const uint16 _menuStringsOther[];
};
diff --git a/engines/kyra/gui_mr.cpp b/engines/kyra/gui_mr.cpp
index 7ca6bbae7a..c894c3ed74 100644
--- a/engines/kyra/gui_mr.cpp
+++ b/engines/kyra/gui_mr.cpp
@@ -28,9 +28,83 @@
#include "kyra/text_mr.h"
#include "kyra/wsamovie.h"
#include "kyra/resource.h"
+#include "kyra/sound.h"
+#include "kyra/timer.h"
+
+#include "common/savefile.h"
namespace Kyra {
+void KyraEngine_MR::loadButtonShapes() {
+ debugC(9, kDebugLevelMain, "KyraEngine_MR::loadButtonShapes()");
+ _res->exists("BUTTONS.SHP", true);
+ uint8 *data = _res->fileData("BUTTONS.SHP", 0);
+ assert(data);
+ for (int i = 0; i <= 10; ++i)
+ addShapeToPool(data, 0x1C7+i, i);
+ delete[] data;
+
+ Button::Callback callback1 = BUTTON_FUNCTOR(KyraEngine_MR, this, &KyraEngine_MR::callbackButton1);
+ Button::Callback callback2 = BUTTON_FUNCTOR(KyraEngine_MR, this, &KyraEngine_MR::callbackButton2);
+ Button::Callback callback3 = BUTTON_FUNCTOR(KyraEngine_MR, this, &KyraEngine_MR::callbackButton3);
+
+ _gui->getScrollUpButton()->data0Callback = callback1;
+ _gui->getScrollUpButton()->data1Callback = callback2;
+ _gui->getScrollUpButton()->data2Callback = callback3;
+ _gui->getScrollDownButton()->data0Callback = callback1;
+ _gui->getScrollDownButton()->data1Callback = callback2;
+ _gui->getScrollDownButton()->data2Callback = callback3;
+
+ _mainButtonData[0].data0Callback = callback1;
+ _mainButtonData[0].data1Callback = callback2;
+ _mainButtonData[0].data2Callback = callback3;
+}
+
+int KyraEngine_MR::callbackButton1(Button *button) {
+ const uint8 *shapePtr = 0;
+ if (button->index == 1)
+ shapePtr = getShapePtr(0x1CD);
+ else if (button->index == 22)
+ shapePtr = getShapePtr(0x1C7);
+ else if (button->index == 23)
+ shapePtr = getShapePtr(0x1CA);
+
+ if (shapePtr)
+ _screen->drawShape(0, shapePtr, button->x, button->y, 0, 0, 0);
+
+ return 0;
+}
+
+int KyraEngine_MR::callbackButton2(Button *button) {
+ const uint8 *shapePtr = 0;
+ if (button->index == 1)
+ shapePtr = getShapePtr(0x1CE);
+ else if (button->index == 22)
+ shapePtr = getShapePtr(0x1C9);
+ else if (button->index == 23)
+ shapePtr = getShapePtr(0x1CC);
+
+ if (shapePtr)
+ _screen->drawShape(0, shapePtr, button->x, button->y, 0, 0, 0);
+
+ return 0;
+}
+
+int KyraEngine_MR::callbackButton3(Button *button) {
+ const uint8 *shapePtr = 0;
+ if (button->index == 1)
+ shapePtr = getShapePtr(0x1CE);
+ else if (button->index == 22)
+ shapePtr = getShapePtr(0x1C8);
+ else if (button->index == 23)
+ shapePtr = getShapePtr(0x1CB);
+
+ if (shapePtr)
+ _screen->drawShape(0, shapePtr, button->x, button->y, 0, 0, 0);
+
+ return 0;
+}
+
void KyraEngine_MR::showMessage(const char *string, uint8 c0, uint8 c1) {
debugC(9, kDebugLevelMain, "KyraEngine_MR::showMessage('%s', %d, %d)", string, c0, c1);
_shownMessage = string;
@@ -630,5 +704,262 @@ void GUI_MR::flagButtonDisable(Button *button) {
}
}
+const char *GUI_MR::getMenuTitle(const Menu &menu) {
+ if (!menu.menuNameId)
+ return 0;
+
+ return (const char *)_vm->getTableEntry(_vm->_optionsFile, menu.menuNameId);
+}
+
+const char *GUI_MR::getMenuItemTitle(const MenuItem &menuItem) {
+ if (!menuItem.itemId)
+ return 0;
+
+ return (const char *)_vm->getTableEntry(_vm->_optionsFile, menuItem.itemId);
+}
+
+const char *GUI_MR::getMenuItemLabel(const MenuItem &menuItem) {
+ if (!menuItem.labelId)
+ return 0;
+
+ return (const char *)_vm->getTableEntry(_vm->_optionsFile, menuItem.labelId);
+}
+
+char *GUI_MR::getTableString(int id) {
+ return (char *)_vm->getTableEntry(_vm->_optionsFile, id);
+}
+
+int GUI_MR::redrawButtonCallback(Button *button) {
+ if (!_displayMenu)
+ return 0;
+
+ _screen->hideMouse();
+ _screen->drawBox(button->x + 1, button->y + 1, button->x + button->width - 1, button->y + button->height - 1, 0xD0);
+ _screen->showMouse();
+
+ return 0;
+}
+
+int GUI_MR::redrawShadedButtonCallback(Button *button) {
+ if (!_displayMenu)
+ return 0;
+
+ _screen->hideMouse();
+ _screen->drawShadedBox(button->x, button->y, button->x + button->width, button->y + button->height, 0xD1, 0xCF);
+ _screen->showMouse();
+
+ return 0;
+}
+void GUI_MR::resetState(int item) {
+ _vm->_timer->resetNextRun();
+ _vm->setNextIdleAnimTimer();
+ _isDeathMenu = false;
+ if (!_loadedSave) {
+ _vm->setHandItem(item);
+ } else {
+ _vm->setHandItem(_vm->_itemInHand);
+ _vm->setCommandLineRestoreTimer(7);
+ _vm->_shownMessage = " ";
+ _vm->_restoreCommandLine = false;
+ }
+ _buttonListChanged = true;
+}
+
+int GUI_MR::quitGame(Button *caller) {
+ updateMenuButton(caller);
+ if (choiceDialog(0x0F, 1)) {
+ _displayMenu = false;
+ _vm->_runFlag = false;
+ _vm->fadeOutMusic(60);
+ _screen->fadeToBlack();
+ _screen->clearCurPage();
+ }
+
+ if (_vm->_runFlag) {
+ initMenu(*_currentMenu);
+ updateAllMenuButtons();
+ }
+
+ return 0;
+}
+
+int GUI_MR::optionsButton(Button *button) {
+ _vm->musicUpdate(0);
+
+ _screen->hideMouse();
+ updateButton(&_vm->_mainButtonData[0]);
+ _screen->showMouse();
+
+ if (!_vm->_inventoryState && button && !_vm->_menuDirectlyToLoad)
+ return 0;
+
+ _restartGame = false;
+ _reloadTemporarySave = false;
+
+ if (!_screen->isMouseVisible() && button && !_vm->_menuDirectlyToLoad)
+ return 0;
+
+ _vm->showMessage(0, 0xF0, 0xF0);
+
+ 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->musicUpdate(0);
+
+ _displayMenu = true;
+ for (int i = 0; i < 4; ++i) {
+ if (_vm->_musicSoundChannel != i)
+ _vm->_soundDigital->stopSound(i);
+ }
+
+ 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;
+ }
+
+ initMenuLayout(_mainMenu);
+ initMenuLayout(_gameOptions);
+ initMenuLayout(_audioOptions);
+ initMenuLayout(_choiceMenu);
+ _loadMenu.numberOfItems = 6;
+ initMenuLayout(_loadMenu);
+ initMenuLayout(_saveMenu);
+ initMenuLayout(_savenameMenu);
+ initMenuLayout(_deathMenu);
+
+ _currentMenu = &_mainMenu;
+
+ _vm->musicUpdate(0);
+
+ if (_vm->_menuDirectlyToLoad) {
+ backUpPage1(_vm->_screenBuffer);
+
+ _loadedSave = false;
+
+ --_loadMenu.numberOfItems;
+ loadMenu(0);
+ ++_loadMenu.numberOfItems;
+
+ if (_loadedSave) {
+ if (_restartGame)
+ _vm->_itemInHand = -1;
+ } else {
+ restorePage1(_vm->_screenBuffer);
+ }
+
+ resetState(-1);
+ _vm->_menuDirectlyToLoad = false;
+ return 0;
+ }
+
+ if (!button) {
+ _currentMenu = &_deathMenu;
+ _isDeathMenu = true;
+ } else {
+ _isDeathMenu = false;
+ }
+
+ _vm->musicUpdate(0);
+ backUpPage1(_vm->_screenBuffer);
+ initMenu(*_currentMenu);
+ _madeSave = false;
+ _loadedSave = false;
+ _vm->_itemInHand = -1;
+ updateAllMenuButtons();
+
+ if (_isDeathMenu) {
+ while (!_screen->isMouseVisible())
+ _screen->showMouse();
+ }
+
+ while (_displayMenu) {
+ processHighlights(*_currentMenu, _vm->_mouseX, _vm->_mouseY);
+ getInput();
+ }
+
+ if (_vm->_runFlag && !_loadedSave && !_madeSave) {
+ restorePalette();
+ restorePage1(_vm->_screenBuffer);
+ }
+
+ if (_vm->_runFlag)
+ updateMenuButton(&_vm->_mainButtonData[0]);
+
+ resetState(oldHandItem);
+
+ if (!_loadedSave && _reloadTemporarySave) {
+ _vm->_unkSceneScreenFlag1 = true;
+ _vm->loadGame(_vm->getSavegameFilename(999));
+ _vm->_saveFileMan->removeSavefile(_vm->getSavegameFilename(999));
+ _vm->_unkSceneScreenFlag1 = false;
+ }
+
+ return 0;
+}
+
+int GUI_MR::loadMenu(Button *caller) {
+ updateSaveList();
+
+ if (!_vm->_menuDirectlyToLoad) {
+ updateMenuButton(caller);
+ restorePage1(_vm->_screenBuffer);
+ backUpPage1(_vm->_screenBuffer);
+ }
+
+ _savegameOffset = 0;
+ setupSavegameNames(_loadMenu, 5);
+ initMenu(_loadMenu);
+ _isLoadMenu = true;
+ _noLoadProcess = false;
+ _vm->_gameToLoad = -1;
+ updateAllMenuButtons();
+
+ _screen->updateScreen();
+ while (_isLoadMenu) {
+ processHighlights(_loadMenu, _vm->_mouseX, _vm->_mouseY);
+ getInput();
+ }
+
+ if (_noLoadProcess) {
+ if (!_vm->_menuDirectlyToLoad) {
+ restorePage1(_vm->_screenBuffer);
+ backUpPage1(_vm->_screenBuffer);
+ initMenu(*_currentMenu);
+ updateAllMenuButtons();
+ }
+ } else if (_vm->_gameToLoad >= 0) {
+ restorePage1(_vm->_screenBuffer);
+ restorePalette();
+ _vm->loadGame(_vm->getSavegameFilename(_vm->_gameToLoad));
+ if (_vm->_gameToLoad == 0) {
+ _restartGame = true;
+ _vm->runStartupScript(1, 1);
+ }
+ _displayMenu = false;
+ _loadedSave = true;
+ }
+
+ return 0;
+}
+
+int GUI_MR::loadSecondChance(Button *button) {
+ updateMenuButton(button);
+
+ _vm->_gameToLoad = 999;
+ restorePage1(_vm->_screenBuffer);
+ _vm->loadGame(_vm->getSavegameFilename(_vm->_gameToLoad));
+ _displayMenu = false;
+ _loadedSave = true;
+ return 0;
+}
+
} // end of namespace Kyra
diff --git a/engines/kyra/gui_mr.h b/engines/kyra/gui_mr.h
index 5eeb829703..36c250d32b 100644
--- a/engines/kyra/gui_mr.h
+++ b/engines/kyra/gui_mr.h
@@ -38,24 +38,34 @@ friend class KyraEngine_MR;
public:
GUI_MR(KyraEngine_MR *engine);
+ void initStaticData();
+
void flagButtonEnable(Button *button);
void flagButtonDisable(Button *button);
-private:
- const char *getMenuTitle(const Menu &menu) { return 0; }
- const char *getMenuItemTitle(const MenuItem &menuItem) { return 0; }
- const char *getMenuItemLabel(const MenuItem &menuItem) { return 0; }
- Button *getButtonListData() { return 0; }
+ int redrawShadedButtonCallback(Button *button);
+ int redrawButtonCallback(Button *button);
- Button *getScrollUpButton() { return 0; }
- Button *getScrollDownButton() { return 0; }
+ int optionsButton(Button *button);
+private:
+ const char *getMenuTitle(const Menu &menu);
+ const char *getMenuItemTitle(const MenuItem &menuItem);
+ const char *getMenuItemLabel(const MenuItem &menuItem);
+ char *getTableString(int id);
- Button::Callback getScrollUpButtonHandler() const { return Button::Callback(); }
- Button::Callback getScrollDownButtonHandler() const { return Button::Callback(); }
+ uint8 textFieldColor1() const { return 0xFF; }
+ uint8 textFieldColor2() const { return 0xCF; }
+ uint8 textFieldColor3() const { return 0xBA; }
uint8 defaultColor1() const { return 0xF0; }
uint8 defaultColor2() const { return 0xD0; }
+ void resetState(int item);
+
+ int quitGame(Button *button);
+ int loadMenu(Button *button);
+ int loadSecondChance(Button *button);
+
KyraEngine_MR *_vm;
Screen_MR *_screen;
};
diff --git a/engines/kyra/gui_v2.cpp b/engines/kyra/gui_v2.cpp
index e449c6b22c..dd6a774ca0 100644
--- a/engines/kyra/gui_v2.cpp
+++ b/engines/kyra/gui_v2.cpp
@@ -26,12 +26,22 @@
#include "kyra/gui_v2.h"
#include "kyra/kyra_v2.h"
#include "kyra/screen_v2.h"
+#include "kyra/text.h"
+
+#include "common/savefile.h"
namespace Kyra {
GUI_v2::GUI_v2(KyraEngine_v2 *vm) : GUI(vm), _vm(vm), _screen(vm->screen_v2()) {
_backUpButtonList = _unknownButtonList = 0;
_buttonListChanged = false;
+
+ _currentMenu = 0;
+ _isDeathMenu = false;
+ _isSaveMenu = false;
+ _isLoadMenu = 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) {
@@ -383,5 +393,468 @@ void GUI_v2::updateButton(Button *button) {
processButton(button);
}
+void GUI_v2::getInput() {
+ if (!_displayMenu)
+ return;
+
+ _vm->checkInput(_menuButtonList);
+ _vm->removeInputTop();
+ if (_vm->quit()) {
+ _displayMenu = false;
+ _isLoadMenu = false;
+ _isSaveMenu = false;
+ _isOptionsMenu = false;
+ _isDeleteMenu = false;
+ }
+}
+
+void GUI_v2::renewHighlight(Menu &menu) {
+ if (!_displayMenu)
+ return;
+
+ MenuItem &item = menu.item[menu.highlightedItem];
+ int x = item.x + menu.x; int y = item.y + menu.y;
+ int x2 = x + item.width - 1; int y2 = y + item.height - 1;
+ redrawText(menu);
+ _screen->fillRect(x+2, y+2, x2-2, y2-2, item.bkgdColor);
+ redrawHighlight(menu);
+ _screen->updateScreen();
+}
+
+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::setupSavegameNames(Menu &menu, int num) {
+ for (int i = 0; i < num; ++i) {
+ strcpy(getTableString(menu.item[i].itemId), "");
+ menu.item[i].saveSlot = -1;
+ menu.item[i].enabled = false;
+ }
+
+ int startSlot = 0;
+ if (_isSaveMenu && _savegameOffset == 0)
+ startSlot = 1;
+
+ KyraEngine::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) {
+ strncpy(getTableString(menu.item[i].itemId), header.description.c_str(), 80);
+ menu.item[i].saveSlot = _saveSlots[i + _savegameOffset];
+ menu.item[i].enabled = true;
+ delete in;
+ }
+ }
+
+ if (_savegameOffset == 0) {
+ if (_isSaveMenu) {
+ char *dst = getTableString(menu.item[0].itemId);
+ const char *src = getTableString(_vm->gameFlags().isTalkie ? 10 : 18);
+ strcpy(dst, src);
+ menu.item[0].saveSlot = -2;
+ menu.item[0].enabled = true;
+ } else {
+ char *dst = getTableString(menu.item[0].itemId);
+ const char *src = getTableString(_vm->gameFlags().isTalkie ? 34 : 42);
+ strcpy(dst, src);
+ }
+ }
+}
+
+int GUI_v2::scrollUpButton(Button *button) {
+ updateMenuButton(button);
+
+ if (_savegameOffset == (_isDeleteMenu ? 1 : 0))
+ return 0;
+
+ --_savegameOffset;
+ if (_isLoadMenu) {
+ setupSavegameNames(_loadMenu, 5);
+ // original calls something different here...
+ initMenu(_loadMenu);
+ } else if (_isSaveMenu || _isDeleteMenu) {
+ setupSavegameNames(_saveMenu, 5);
+ // original calls something different here...
+ initMenu(_saveMenu);
+ }
+
+ return 0;
+}
+
+int GUI_v2::scrollDownButton(Button *button) {
+ updateMenuButton(button);
+ ++_savegameOffset;
+
+ if (uint(_savegameOffset + 5) >= _saveSlots.size())
+ _savegameOffset = MAX<int>(_saveSlots.size() - 5, _isDeleteMenu ? 1 : 0);
+
+ if (_isLoadMenu) {
+ setupSavegameNames(_loadMenu, 5);
+ // original calls something different here...
+ initMenu(_loadMenu);
+ } else if (_isSaveMenu || _isDeleteMenu) {
+ setupSavegameNames(_saveMenu, 5);
+ // original calls something different here...
+ initMenu(_saveMenu);
+ }
+
+ return 0;
+}
+
+int GUI_v2::resumeGame(Button *caller) {
+ updateMenuButton(caller);
+ _displayMenu = false;
+ return 0;
+}
+
+int GUI_v2::quitOptionsMenu(Button *caller) {
+ updateMenuButton(caller);
+ _isOptionsMenu = false;
+ return 0;
+}
+
+int GUI_v2::clickLoadSlot(Button *caller) {
+ updateMenuButton(caller);
+
+ int index = caller->index - _menuButtons[0].index;
+ assert(index >= 0 && index <= 6);
+ MenuItem &item = _loadMenu.item[index];
+
+ if (item.saveSlot >= 0) {
+ _vm->_gameToLoad = item.saveSlot;
+ _isLoadMenu = false;
+ }
+
+ return 0;
+}
+
+int GUI_v2::cancelLoadMenu(Button *caller) {
+ updateMenuButton(caller);
+ _isLoadMenu = false;
+ _noLoadProcess = true;
+ return 0;
+}
+
+int GUI_v2::saveMenu(Button *caller) {
+ updateSaveList();
+
+ updateMenuButton(caller);
+
+ restorePage1(_vm->_screenBuffer);
+ backUpPage1(_vm->_screenBuffer);
+
+ _isSaveMenu = true;
+ _noSaveProcess = false;
+ _saveSlot = -1;
+ _savegameOffset = 0;
+ setupSavegameNames(_saveMenu, 5);
+ initMenu(_saveMenu);
+
+ updateAllMenuButtons();
+
+ while (_isSaveMenu) {
+ processHighlights(_saveMenu, _vm->_mouseX, _vm->_mouseY);
+ getInput();
+ }
+
+ if (_noSaveProcess) {
+ restorePage1(_vm->_screenBuffer);
+ backUpPage1(_vm->_screenBuffer);
+ initMenu(*_currentMenu);
+ updateAllMenuButtons();
+ return 0;
+ } else if(_saveSlot <= -1) {
+ return 0;
+ }
+
+ restorePage1(_vm->_screenBuffer);
+ restorePalette();
+ _vm->saveGame(_vm->getSavegameFilename(_saveSlot), _saveDescription);
+ _displayMenu = false;
+ _madeSave = true;
+
+ return 0;
+}
+
+int GUI_v2::clickSaveSlot(Button *caller) {
+ updateMenuButton(caller);
+
+ int index = caller->index - _menuButtons[0].index;
+ assert(index >= 0 && index <= 6);
+ MenuItem &item = _saveMenu.item[index];
+
+ if (item.saveSlot >= 0) {
+ if (_isDeleteMenu) {
+ _slotToDelete = item.saveSlot;
+ _isDeleteMenu = false;
+ return 0;
+ } else {
+ _saveSlot = item.saveSlot;
+ strcpy(_saveDescription, getTableString(item.itemId));
+ }
+ } else if (item.saveSlot == -2) {
+ _saveSlot = getNextSavegameSlot();
+ memset(_saveDescription, 0, sizeof(_saveDescription));
+ }
+
+ restorePage1(_vm->_screenBuffer);
+ backUpPage1(_vm->_screenBuffer);
+
+ initMenu(_savenameMenu);
+ _screen->fillRect(0x26, 0x5B, 0x11F, 0x66, textFieldColor2());
+ const char *desc = nameInputProcess(_saveDescription, 0x27, 0x5C, textFieldColor1(), textFieldColor2(), textFieldColor3(), 0x50);
+ restorePage1(_vm->_screenBuffer);
+ backUpPage1(_vm->_screenBuffer);
+ if (desc) {
+ _isSaveMenu = false;
+ _isDeleteMenu = false;
+ } else {
+ initMenu(_saveMenu);
+ }
+
+ return 0;
+}
+
+int GUI_v2::cancelSaveMenu(Button *caller) {
+ updateMenuButton(caller);
+ _isSaveMenu = false;
+ _isDeleteMenu = false;
+ _noSaveProcess = true;
+ return 0;
+}
+
+int GUI_v2::deleteMenu(Button *caller) {
+ updateSaveList();
+
+ updateMenuButton(caller);
+ if (_saveSlots.size() < 2) {
+ _vm->snd_playSoundEffect(0x0D);
+ return 0;
+ }
+
+ do {
+ restorePage1(_vm->_screenBuffer);
+ backUpPage1(_vm->_screenBuffer);
+ _savegameOffset = 1;
+ _saveMenu.menuNameId = _vm->gameFlags().isTalkie ? 35 : 1;
+ setupSavegameNames(_saveMenu, 5);
+ initMenu(_saveMenu);
+ _isDeleteMenu = true;
+ _slotToDelete = -1;
+ updateAllMenuButtons();
+
+ while (_isDeleteMenu) {
+ processHighlights(_saveMenu, _vm->_mouseX, _vm->_mouseY);
+ getInput();
+ }
+
+ if (_slotToDelete < 1) {
+ restorePage1(_vm->_screenBuffer);
+ backUpPage1(_vm->_screenBuffer);
+ initMenu(*_currentMenu);
+ updateAllMenuButtons();
+ _saveMenu.menuNameId = _vm->gameFlags().isTalkie ? 9 : 17;
+ return 0;
+ }
+ } while (choiceDialog(_vm->gameFlags().isTalkie ? 0x24 : 2, 1) == 0);
+
+ restorePage1(_vm->_screenBuffer);
+ backUpPage1(_vm->_screenBuffer);
+ initMenu(*_currentMenu);
+ updateAllMenuButtons();
+ _vm->_saveFileMan->removeSavefile(_vm->getSavegameFilename(_slotToDelete));
+ Common::Array<int>::iterator i = Common::find(_saveSlots.begin(), _saveSlots.end(), _slotToDelete);
+ 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.c_str(), newName.c_str());
+ }
+ _saveMenu.menuNameId = _vm->gameFlags().isTalkie ? 9 : 17;
+ return 0;
+}
+
+const char *GUI_v2::nameInputProcess(char *buffer, int x, int y, uint8 c1, uint8 c2, uint8 c3, int bufferSize) {
+ bool running = true;
+ int curPos = strlen(buffer);
+
+ int x2 = x, y2 = y;
+ _text->printText(buffer, x, y, c1, c2, c2);
+
+ for (int i = 0; i < curPos; ++i)
+ x2 += getCharWidth(buffer[i]);
+
+ drawTextfieldBlock(x2, y2, c3);
+
+ _keyPressed.reset();
+ _cancelNameInput = _finishNameInput = false;
+ while (running && !_vm->quit()) {
+ processHighlights(_savenameMenu, _vm->_mouseX, _vm->_mouseY);
+ checkTextfieldInput();
+ if (_keyPressed.keycode == Common::KEYCODE_RETURN || _keyPressed.keycode == Common::KEYCODE_KP_ENTER || _finishNameInput) {
+ if (checkSavegameDescription(buffer, curPos)) {
+ buffer[curPos] = 0;
+ running = false;
+ } else {
+ _finishNameInput = false;
+ }
+ } else if (_keyPressed.keycode == Common::KEYCODE_ESCAPE || _cancelNameInput) {
+ running = false;
+ return 0;
+ } else if ((_keyPressed.keycode == Common::KEYCODE_BACKSPACE || _keyPressed.keycode == Common::KEYCODE_DELETE) && curPos > 0) {
+ drawTextfieldBlock(x2, y2, c2);
+ --curPos;
+ x2 -= getCharWidth(buffer[curPos]);
+ drawTextfieldBlock(x2, y2, c3);
+ _screen->updateScreen();
+ } else if (_keyPressed.ascii > 31 && _keyPressed.ascii < 127 && curPos < bufferSize) {
+ if (x2 + getCharWidth(_keyPressed.ascii) + 7 < 0x11F) {
+ buffer[curPos] = _keyPressed.ascii;
+ const char text[2] = { buffer[curPos], 0 };
+ _text->printText(text, x2, y2, c1, c2, c2);
+ x2 += getCharWidth(_keyPressed.ascii);
+ drawTextfieldBlock(x2, y2, c3);
+ ++curPos;
+ _screen->updateScreen();
+ }
+ }
+
+ _keyPressed.reset();
+ }
+
+ return buffer;
+}
+
+int GUI_v2::finishSavename(Button *caller) {
+ updateMenuButton(caller);
+ _finishNameInput = true;
+ return 0;
+}
+
+int GUI_v2::cancelSavename(Button *caller) {
+ updateMenuButton(caller);
+ _cancelNameInput = true;
+ return 0;
+}
+
+bool GUI_v2::checkSavegameDescription(const char *buffer, int size) {
+ if (!buffer || !size)
+ return false;
+ if (buffer[0] == 0)
+ return false;
+ for (int i = 0; i < size; ++i) {
+ if (buffer[i] != 0x20)
+ return true;
+ else if (buffer[i] == 0x00)
+ return false;
+ }
+ return false;
+}
+
+int GUI_v2::getCharWidth(uint8 c) {
+ Screen::FontId old = _screen->setFont(Screen::FID_8_FNT);
+ _screen->_charWidth = -2;
+ int width = _screen->getCharWidth(c);
+ _screen->_charWidth = 0;
+ _screen->setFont(old);
+ return width;
+}
+
+void GUI_v2::checkTextfieldInput() {
+ Common::Event event;
+
+ bool running = true;
+ int keys = 0;
+ while (_vm->_eventMan->pollEvent(event) && running) {
+ switch (event.type) {
+ case Common::EVENT_QUIT:
+ _vm->_quitFlag = true;
+ break;
+
+ case Common::EVENT_KEYDOWN:
+ if (event.kbd.keycode == 'q' && event.kbd.flags == Common::KBD_CTRL)
+ _vm->_quitFlag = true;
+ else
+ _keyPressed = event.kbd;
+ running = false;
+ break;
+
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_LBUTTONUP: {
+ Common::Point pos = _vm->getMousePos();
+ _vm->_mouseX = pos.x;
+ _vm->_mouseY = pos.y;
+ keys = event.type == Common::EVENT_LBUTTONDOWN ? 199 : (200 | 0x800);
+ running = false;
+ } break;
+
+ case Common::EVENT_MOUSEMOVE: {
+ Common::Point pos = _vm->getMousePos();
+ _vm->_mouseX = pos.x;
+ _vm->_mouseY = pos.y;
+ _screen->updateScreen();
+ } break;
+
+ default:
+ break;
+ }
+ }
+
+ processButtonList(_menuButtonList, keys | 0x8000);
+}
+
+void GUI_v2::drawTextfieldBlock(int x, int y, uint8 c) {
+ _screen->fillRect(x+1, y+1, x+7, y+8, c);
+}
+
+bool GUI_v2::choiceDialog(int name, bool type) {
+ _choiceMenu.highlightedItem = 0;
+ restorePage1(_vm->_screenBuffer);
+ backUpPage1(_vm->_screenBuffer);
+ if (type)
+ _choiceMenu.numberOfItems = 2;
+ else
+ _choiceMenu.numberOfItems = 1;
+ _choiceMenu.menuNameId = name;
+
+ initMenu(_choiceMenu);
+ _isChoiceMenu = true;
+ _choice = false;
+
+ while (_isChoiceMenu) {
+ processHighlights(_choiceMenu, _vm->_mouseX, _vm->_mouseY);
+ getInput();
+ }
+
+ restorePage1(_vm->_screenBuffer);
+ backUpPage1(_vm->_screenBuffer);
+ return _choice;
+}
+
+int GUI_v2::choiceYes(Button *caller) {
+ updateMenuButton(caller);
+ _choice = true;
+ _isChoiceMenu = false;
+ return 0;
+}
+
+int GUI_v2::choiceNo(Button *caller) {
+ updateMenuButton(caller);
+ _choice = false;
+ _isChoiceMenu = false;
+ return 0;
+}
+
} // end of namespace Kyra
diff --git a/engines/kyra/gui_v2.h b/engines/kyra/gui_v2.h
index 3fdc64e34f..a007ce84d8 100644
--- a/engines/kyra/gui_v2.h
+++ b/engines/kyra/gui_v2.h
@@ -98,6 +98,8 @@ class GUI_v2 : public GUI {
public:
GUI_v2(KyraEngine_v2 *vm);
+ virtual void initStaticData() = 0;
+
Button *addButtonToList(Button *list, Button *newButton);
void processButton(Button *button);
@@ -112,6 +114,106 @@ protected:
bool _buttonListChanged;
Button *_backUpButtonList;
Button *_unknownButtonList;
+
+protected:
+ virtual void setupPalette() {}
+ virtual void restorePalette() {}
+
+ virtual char *getTableString(int id) = 0;
+
+ virtual uint8 textFieldColor1() const = 0;
+ virtual uint8 textFieldColor2() const = 0;
+ virtual uint8 textFieldColor3() const = 0;
+protected:
+ void getInput();
+
+ Button _menuButtons[7];
+ Button _scrollUpButton;
+ Button _scrollDownButton;
+ Menu _mainMenu, _gameOptions, _audioOptions, _choiceMenu, _loadMenu, _saveMenu, _savenameMenu, _deathMenu;
+
+ Button *getButtonListData() { return _menuButtons; }
+
+ Button *getScrollUpButton() { return &_scrollUpButton; }
+ Button *getScrollDownButton() { return &_scrollDownButton; }
+
+ 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; }
+
+ Button _sliderButtons[3][4];
+
+ void renewHighlight(Menu &menu);
+
+ void backUpPage1(uint8 *buffer);
+ void restorePage1(const uint8 *buffer);
+
+ Menu *_currentMenu;
+ bool _isLoadMenu;
+ bool _isDeathMenu;
+ bool _isSaveMenu;
+ bool _isDeleteMenu;
+ bool _isChoiceMenu;
+ bool _isOptionsMenu;
+ bool _madeSave;
+ bool _loadedSave;
+ bool _restartGame;
+ bool _reloadTemporarySave;
+
+ int _savegameOffset;
+
+ void setupSavegameNames(Menu &menu, int num);
+
+ // main menu
+ int resumeGame(Button *caller);
+
+ // audio menu
+ static const int _sliderBarsPosition[];
+
+ // load menu
+ bool _noLoadProcess;
+ int clickLoadSlot(Button *caller);
+ int cancelLoadMenu(Button *caller);
+
+ // save menu
+ bool _noSaveProcess;
+ int _saveSlot;
+ char _saveDescription[0x50];
+
+ int saveMenu(Button *caller);
+ int clickSaveSlot(Button *caller);
+ int cancelSaveMenu(Button *caller);
+
+ // delete menu
+ int _slotToDelete;
+ int deleteMenu(Button *caller);
+
+ // options menu
+ int quitOptionsMenu(Button *caller);
+
+ // savename menu
+ bool _finishNameInput, _cancelNameInput;
+ Common::KeyState _keyPressed;
+
+ const char *nameInputProcess(char *buffer, int x, int y, uint8 c1, uint8 c2, uint8 c3, int bufferSize);
+ int finishSavename(Button *caller);
+ int cancelSavename(Button *caller);
+
+ bool checkSavegameDescription(const char *buffer, int size);
+ int getCharWidth(uint8 c);
+ void checkTextfieldInput();
+ void drawTextfieldBlock(int x, int y, uint8 c);
+
+ // choice menu
+ bool _choice;
+
+ bool choiceDialog(int name, bool type);
+ int choiceYes(Button *caller);
+ int choiceNo(Button *caller);
+
};
} // end of namespace Kyra
diff --git a/engines/kyra/kyra_hof.cpp b/engines/kyra/kyra_hof.cpp
index 64ec7e2905..fff96f456c 100644
--- a/engines/kyra/kyra_hof.cpp
+++ b/engines/kyra/kyra_hof.cpp
@@ -105,7 +105,6 @@ KyraEngine_HoF::KyraEngine_HoF(OSystem *system, const GameFlags &flags) : KyraEn
_gamePlayBuffer = 0;
_unkBuf500Bytes = 0;
- _screenBuffer = 0;
_inventorySaved = false;
_unkBuf200kByte = 0;
memset(&_sceneShapeTable, 0, sizeof(_sceneShapeTable));
@@ -189,6 +188,7 @@ int KyraEngine_HoF::init() {
assert(_text);
_gui = new GUI_HoF(this);
assert(_gui);
+ _gui->initStaticData();
_tim = new TIMInterpreter(this, _system);
assert(_tim);
@@ -255,6 +255,7 @@ int KyraEngine_HoF::go() {
}
_menuDirectlyToLoad = (_menuChoice == 3) ? true : false;
+ _menuDirectlyToLoad &= saveFileLoadable(0);
if (_menuChoice & 1) {
startup();
@@ -764,7 +765,6 @@ void KyraEngine_HoF::cleanup() {
delete [] _gamePlayBuffer; _gamePlayBuffer = 0;
delete [] _unkBuf500Bytes; _unkBuf500Bytes = 0;
- delete [] _screenBuffer; _screenBuffer = 0;
delete [] _unkBuf200kByte; _unkBuf200kByte = 0;
freeSceneShapePtrs();
diff --git a/engines/kyra/kyra_hof.h b/engines/kyra/kyra_hof.h
index b24ea02262..1e6c23331e 100644
--- a/engines/kyra/kyra_hof.h
+++ b/engines/kyra/kyra_hof.h
@@ -337,7 +337,6 @@ protected:
int inputSceneChange(int x, int y, int unk1, int unk2);
// gfx/animation specific
- uint8 *_screenBuffer;
bool _inventorySaved;
void backUpPage0();
void restorePage0();
diff --git a/engines/kyra/kyra_mr.cpp b/engines/kyra/kyra_mr.cpp
index fbd5ed5492..ab9c558abb 100644
--- a/engines/kyra/kyra_mr.cpp
+++ b/engines/kyra/kyra_mr.cpp
@@ -137,41 +137,43 @@ KyraEngine_MR::KyraEngine_MR(OSystem *system, const GameFlags &flags) : KyraEngi
_goodConscienceShown = false;
_goodConscienceAnim = -1;
_goodConsciencePosition = false;
+ _menuDirectlyToLoad = false;
+ _optionsFile = 0;
}
KyraEngine_MR::~KyraEngine_MR() {
delete _screen;
delete _soundDigital;
- delete [] _itemBuffer1;
- delete [] _itemBuffer2;
- delete [] _scoreFile;
- delete [] _cCodeFile;
- delete [] _scenesFile;
- delete [] _itemFile;
- delete [] _gamePlayBuffer;
- delete [] _interface;
- delete [] _interfaceCommandLine;
- delete [] _costPalBuffer;
+ delete[] _itemBuffer1;
+ delete[] _itemBuffer2;
+ delete[] _scoreFile;
+ delete[] _cCodeFile;
+ delete[] _scenesFile;
+ delete[] _itemFile;
+ delete[] _gamePlayBuffer;
+ delete[] _interface;
+ delete[] _interfaceCommandLine;
+ delete[] _costPalBuffer;
for (uint i = 0; i < ARRAYSIZE(_sceneShapes); ++i)
- delete [] _sceneShapes[i];
+ delete[] _sceneShapes[i];
for (uint i = 0; i < ARRAYSIZE(_sceneAnimMovie); ++i)
delete _sceneAnimMovie[i];
- delete [] _gfxBackUpRect;
- delete [] _paletteOverlay;
- delete [] _sceneList;
+ delete[] _gfxBackUpRect;
+ delete[] _paletteOverlay;
+ delete[] _sceneList;
for (ShapeMap::iterator i = _gameShapes.begin(); i != _gameShapes.end(); ++i) {
- delete [] i->_value;
+ delete[] i->_value;
i->_value = 0;
}
_gameShapes.clear();
- delete [] _sceneStrings;
- delete [] _talkObjectList;
+ delete[] _sceneStrings;
+ delete[] _talkObjectList;
for (Common::Array<const Opcode*>::iterator i = _opcodesDialog.begin(); i != _opcodesDialog.end(); ++i)
delete *i;
@@ -179,10 +181,11 @@ KyraEngine_MR::~KyraEngine_MR() {
delete _cnvFile;
delete _dlgBuffer;
- delete [] _stringBuffer;
+ delete[] _stringBuffer;
delete _invWsa;
- delete [] _mainButtonData;
+ delete[] _mainButtonData;
delete _gui;
+ delete[] _optionsFile;
}
int KyraEngine_MR::init() {
@@ -203,6 +206,7 @@ int KyraEngine_MR::init() {
assert(_text);
_gui = new GUI_MR(this);
assert(_gui);
+ _gui->initStaticData();
_screen->loadFont(Screen::FID_6_FNT, "6.FNT");
_screen->loadFont(Screen::FID_8_FNT, "8FAT.FNT");
@@ -226,6 +230,14 @@ int KyraEngine_MR::go() {
_screen->clearPage(0);
_screen->clearPage(2);
+ if (_gameToLoad != -1) {
+ uninitMainMenu();
+ _musicSoundChannel = -1;
+ startup();
+ runLoop();
+ running = false;
+ }
+
while (running && !_quitFlag) {
_screen->_curPage = 0;
_screen->clearPage(0);
@@ -250,6 +262,12 @@ int KyraEngine_MR::go() {
}
switch (_menu->handle(3)) {
+ case 2:
+ if (saveFileLoadable(0))
+ _menuDirectlyToLoad = true;
+ else
+ break;
+
case 0:
uninitMainMenu();
@@ -267,12 +285,6 @@ int KyraEngine_MR::go() {
_screen->hideMouse();
break;
- case 2:
- //uninitMainMenu();
- //show load dialog
- //running = false;
- break;
-
case 3:
default:
fadeOutMusic(60);
@@ -548,9 +560,8 @@ void KyraEngine_MR::startup() {
error("Couldn't load C_CODE");
if (!loadLanguageFile("SCENES.", _scenesFile))
error("Couldn't load SCENES");
-
- //XXX
-
+ if (!loadLanguageFile("OPTIONS.", _optionsFile))
+ error("Couldn't load OPTIONS");
if ((_actorFileSize = loadLanguageFile("_ACTOR.", _actorFile)) == 0)
error("couldn't load _ACTOR");
@@ -584,7 +595,6 @@ void KyraEngine_MR::startup() {
resetItemList();
loadShadowShape();
- //loadButtonShapes();
musicUpdate(0);
loadExtrasShapes();
musicUpdate(0);
@@ -593,6 +603,7 @@ void KyraEngine_MR::startup() {
updateMalcolmShapes();
musicUpdate(0);
initMainButtonList(true);
+ loadButtonShapes();
loadInterfaceShapes();
musicUpdate(0);
@@ -628,13 +639,23 @@ void KyraEngine_MR::startup() {
assert(_invWsa);
_invWsa->open("MOODOMTR.WSA", 1, 0);
_invWsaFrame = 6;
+ saveGame(getSavegameFilename(0), (const char*)getTableEntry(_optionsFile, 33));
_soundDigital->beginFadeOut(_musicSoundChannel, 60);
delayWithTicks(60);
- enterNewScene(_mainCharacter.sceneId, _mainCharacter.facing, 0, 0, 1);
+ if (_gameToLoad == -1)
+ enterNewScene(_mainCharacter.sceneId, _mainCharacter.facing, 0, 0, 1);
+ else
+ loadGame(getSavegameFilename(_gameToLoad));
+
+ if (_menuDirectlyToLoad)
+ (*_mainButtonData[0].buttonCallback)(&_mainButtonData[0]);
+
_screen->updateScreen();
musicUpdate(0);
_screen->showMouse();
- //XXX
+
+ setNextIdleAnimTimer();
+ setWalkspeed(_configWalkspeed);
}
void KyraEngine_MR::loadCostPal() {
@@ -926,8 +947,11 @@ void KyraEngine_MR::runLoop() {
_runFlag = true;
while (_runFlag && !_quitFlag) {
if (_deathHandler >= 0) {
- // TODO: add menu etc.
- loadGame(getSavegameFilename(999));
+ removeHandItem();
+ delay(5);
+ _drawNoShapeFlag = 0;
+ _gui->optionsButton(0);
+ _deathHandler = -1;
}
if (_system->getMillis() >= _nextIdleAnim)
diff --git a/engines/kyra/kyra_mr.h b/engines/kyra/kyra_mr.h
index 4d83eee7bb..359228ef7a 100644
--- a/engines/kyra/kyra_mr.h
+++ b/engines/kyra/kyra_mr.h
@@ -76,6 +76,8 @@ protected:
void setupOpcodeTable();
// run
+ bool _menuDirectlyToLoad;
+
void runLoop();
void handleInput(int x, int y);
int inputSceneChange(int x, int y, int unk1, int unk2);
@@ -134,6 +136,11 @@ private:
int buttonShowScore(Button *button);
int buttonJesterStaff(Button *button);
+ void loadButtonShapes();
+ int callbackButton1(Button *button);
+ int callbackButton2(Button *button);
+ int callbackButton3(Button *button);
+
// -> main menu
void initMainMenu();
void uninitMainMenu();
@@ -236,6 +243,7 @@ private:
uint8 *_cCodeFile;
uint8 *_scenesFile;
uint8 *_itemFile;
+ uint8 *_optionsFile;
uint8 *_actorFile;
uint32 _actorFileSize;
uint8 *_sceneStrings;
@@ -462,7 +470,6 @@ private:
// unk
uint8 *_costPalBuffer;
- uint8 *_screenBuffer;
uint8 *_paletteOverlay;
bool _useActorBuffer;
diff --git a/engines/kyra/kyra_v2.cpp b/engines/kyra/kyra_v2.cpp
index 6e58d8592a..e981522662 100644
--- a/engines/kyra/kyra_v2.cpp
+++ b/engines/kyra/kyra_v2.cpp
@@ -65,26 +65,28 @@ KyraEngine_v2::KyraEngine_v2(OSystem *system, const GameFlags &flags, const Engi
memset(_hiddenItems, -1, sizeof(_hiddenItems));
_debugger = 0;
+ _screenBuffer = 0;
}
KyraEngine_v2::~KyraEngine_v2() {
for (ShapeMap::iterator i = _gameShapes.begin(); i != _gameShapes.end(); ++i) {
- delete [] i->_value;
+ delete[] i->_value;
i->_value = 0;
}
_gameShapes.clear();
- delete [] _itemList;
+ delete[] _itemList;
_emc->unload(&_sceneScriptData);
- delete [] _animObjects;
+ delete[] _animObjects;
for (Common::Array<const Opcode*>::iterator i = _opcodesAnimation.begin(); i != _opcodesAnimation.end(); ++i)
delete *i;
_opcodesAnimation.clear();
delete _debugger;
+ delete[] _screenBuffer;
}
int KyraEngine_v2::checkInput(Button *buttonList, bool mainLoop) {
diff --git a/engines/kyra/kyra_v2.h b/engines/kyra/kyra_v2.h
index 7134d62872..7636f92e7c 100644
--- a/engines/kyra/kyra_v2.h
+++ b/engines/kyra/kyra_v2.h
@@ -162,6 +162,8 @@ protected:
virtual int getScale(int x, int y) = 0;
+ uint8 *_screenBuffer;
+
// Scene
struct SceneDesc {
char filename1[10];
diff --git a/engines/kyra/scene_mr.cpp b/engines/kyra/scene_mr.cpp
index 17fbdac87b..27f4fabb49 100644
--- a/engines/kyra/scene_mr.cpp
+++ b/engines/kyra/scene_mr.cpp
@@ -634,7 +634,7 @@ void KyraEngine_MR::initSceneScreen(int unk1) {
updateCharPal(0);
- if (1/*!_menuDirectlyToLoad*/) {
+ if (!_menuDirectlyToLoad) {
_emc->start(&_sceneScriptState, 3);
_sceneScriptState.regs[5] = unk1;
diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp
index a6b2588b7b..83ae17ba1c 100644
--- a/engines/kyra/staticres.cpp
+++ b/engines/kyra/staticres.cpp
@@ -1518,6 +1518,10 @@ const int8 KyraEngine_v2::_updateCharPosYTable[] = {
-2, -2, 0, 2, 2, 2, 0, -2
};
+const int GUI_v2::_sliderBarsPosition[] = {
+ 0x92, 0x1F, 0x92, 0x30, 0x92, 0x41, 0x92, 0x52
+};
+
// kyra 2 static res
const uint8 KyraEngine_HoF::_seqTextColorPresets[] = { 0x01, 0x01, 0x00, 0x3f, 0x3f, 0x3f };
@@ -1819,10 +1823,6 @@ const uint16 GUI_HoF::_menuStringsOther[] = {
0x016, 0x00A, 0x00D, 0x000, 0x000, 0x000, 0x000, 0x000 // Death Menu String IDs
};
-const int GUI_HoF::_sliderBarsPosition[] = {
- 0x92, 0x1F, 0x92, 0x30, 0x92, 0x41, 0x92, 0x52
-};
-
const uint16 KyraEngine_HoF::_itemMagicTable[] = {
0x0D, 0x0A, 0x0B, 0,
0x0D, 0x0B, 0x0A, 0,
@@ -2446,6 +2446,7 @@ void KyraEngine_MR::initMainButtonList(bool disable) {
assert(_mainButtonData);
GUI_V2_BUTTON(_mainButtonData[0], 1, 0, 0, 4, 4, 4, 0x4487, 0, 5, 162, 50, 25, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0);
+ _mainButtonData[0].buttonCallback = BUTTON_FUNCTOR(GUI_MR, _gui, &GUI_MR::optionsButton);
GUI_V2_BUTTON(_mainButtonData[1], 2, 0, 0, 1, 1, 1, 0x4487, 0, 245, 156, 69, 33, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0);
_mainButtonData[1].buttonCallback = BUTTON_FUNCTOR(KyraEngine_MR, this, &KyraEngine_MR::buttonMoodChange);
GUI_V2_BUTTON(_mainButtonData[2], 3, 0, 0, 1, 1, 1, 0x4487, 0, 215, 191, 24, 9, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0);
@@ -2478,5 +2479,111 @@ void KyraEngine_MR::initMainButtonList(bool disable) {
}
}
+void GUI_MR::initStaticData() {
+ GUI_V2_BUTTON(_scrollUpButton, 22, 0, 0, 4, 4, 4, 0x4487, 0, 0, 0, 0x18, 0x0F, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0);
+ GUI_V2_BUTTON(_scrollDownButton, 23, 0, 0, 4, 4, 4, 0x4487, 0, 0, 0, 0x18, 0x0F, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0);
+
+ for (int i = 0; i < 4; ++i) {
+ GUI_V2_BUTTON(_sliderButtons[0][i], 0x18+i, 0, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0x0A, 0x0E, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0);
+ }
+ for (int i = 0; i < 4; ++i) {
+ GUI_V2_BUTTON(_sliderButtons[1][i], 0x1C+i, 0, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0x0A, 0x0E, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0);
+ }
+ for (int i = 0; i < 4; ++i) {
+ GUI_V2_BUTTON(_sliderButtons[2][i], 0x20+i, 0, 0, 0, 0, 0, 0x2200, 0, 0, 0, 0x6E, 0x0E, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0);
+ }
+
+ for (uint i = 0; i < ARRAYSIZE(_menuButtons); ++i) {
+ GUI_V2_BUTTON(_menuButtons[i], 0x0F+i, 0, 0, 1, 1, 1, 0x4487, 0, 0, 0, 0, 0, 0xFF, 0xF0, 0xFF, 0xF0, 0xFF, 0xF0, 0);
+ }
+
+ Button::Callback clickLoadSlotFunctor = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::clickLoadSlot);
+ Button::Callback clickSaveSlotFunctor = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::clickSaveSlot);
+ Button::Callback clickLoadMenuFunctor = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::loadMenu);
+ Button::Callback clickQuitOptionsFunctor = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::quitOptionsMenu);
+
+ GUI_V2_MENU(_mainMenu, -1, -1, 256, 172, 0xD0, 0xD1, 0xCF, 1, 0xBD, -1, 8, 0, 7, -1, -1, -1, -1);
+ GUI_V2_MENU_ITEM(_mainMenu.item[0], 1, 2, -1, 30, 220, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ _mainMenu.item[0].callback = clickLoadMenuFunctor;
+ GUI_V2_MENU_ITEM(_mainMenu.item[1], 1, 3, -1, 47, 220, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ _mainMenu.item[1].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::saveMenu);
+ GUI_V2_MENU_ITEM(_mainMenu.item[2], 1, 35, -1, 64, 220, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ _mainMenu.item[2].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::deleteMenu);
+ GUI_V2_MENU_ITEM(_mainMenu.item[3], 1, 4, -1, 81, 220, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ GUI_V2_MENU_ITEM(_mainMenu.item[4], 1, 37, -1, 98, 220, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ GUI_V2_MENU_ITEM(_mainMenu.item[5], 1, 5, -1, 115, 220, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ _mainMenu.item[5].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::quitGame);
+ GUI_V2_MENU_ITEM(_mainMenu.item[6], 1, 6, -1, 144, 220, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ _mainMenu.item[6].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::resumeGame);
+
+ GUI_V2_MENU(_audioOptions, -1, -1, 288, 136, 0xD0, 0xD1, 0xCF, 37, 0xBD, -1, 8, 4, 5, -1, -1, -1, -1);
+ GUI_V2_MENU_ITEM(_audioOptions.item[0], 0, 0, 160, 30, 116, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 23, 8, 32, 0x0000);
+ GUI_V2_MENU_ITEM(_audioOptions.item[1], 0, 0, 160, 47, 116, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 24, 8, 49, 0x0000);
+ GUI_V2_MENU_ITEM(_audioOptions.item[2], 0, 0, 160, 64, 116, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 39, 8, 66, 0x0000);
+ GUI_V2_MENU_ITEM(_audioOptions.item[3], 1, 0, 152, 81, 116, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 47, 8, 83, 0x0000);
+ GUI_V2_MENU_ITEM(_audioOptions.item[4], 1, 16, -1, 110, 92, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ _audioOptions.item[4].callback = clickQuitOptionsFunctor;
+ for (int i = 5; i < 7; ++i)
+ _audioOptions.item[i].enabled = false;
+
+ GUI_V2_MENU(_gameOptions, -1, -1, 288, 154, 0xD0, 0xD1, 0xCF, 7, 0xBD, -1, 8, 0, 6, -1, -1, -1, -1);
+ GUI_V2_MENU_ITEM(_gameOptions.item[0], 1, 0, 160, 30, 116, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 21, 8, 32, 0x0000);
+ GUI_V2_MENU_ITEM(_gameOptions.item[1], 1, 0, 160, 47, 116, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 26, 8, 49, 0x0000);
+ GUI_V2_MENU_ITEM(_gameOptions.item[2], 1, 0, 160, 64, 116, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 40, 8, 66, 0x0000);
+ GUI_V2_MENU_ITEM(_gameOptions.item[3], 1, 0, 160, 81, 116, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 46, 8, 83, 0x0000);
+ GUI_V2_MENU_ITEM(_gameOptions.item[4], 1, 0, 160, 98, 116, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 22, 8, 100, 0x0000);
+ GUI_V2_MENU_ITEM(_gameOptions.item[5], 1, 16, -1, 127, 125, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ _gameOptions.item[5].callback = clickQuitOptionsFunctor;
+ _gameOptions.item[6].enabled = false;
+
+ GUI_V2_MENU(_choiceMenu, -1, -1, 320, 56, 0xD0, 0xD1, 0xCF, 0, 0xBA, -1, 8, 0, 2, -1, -1, -1, -1);
+ GUI_V2_MENU_ITEM(_choiceMenu.item[0], 1, 20, 24, 30, 72, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ _choiceMenu.item[0].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::choiceYes);
+ GUI_V2_MENU_ITEM(_choiceMenu.item[1], 1, 19, 216, 30, 72, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ _choiceMenu.item[1].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::choiceNo);
+ for (int i = 2; i < 7; ++i)
+ _choiceMenu.item[i].enabled = false;
+
+ GUI_V2_MENU(_loadMenu, -1, -1, 288, 160, 0xD0, 0xD1, 0xCF, 8, 0xBD, -1, 8, 0, 6, 132, 22, 132, 124);
+ GUI_V2_MENU_ITEM(_loadMenu.item[0], 1, 41, -1, 39, 256, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ GUI_V2_MENU_ITEM(_loadMenu.item[1], 1, 42, -1, 56, 256, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ GUI_V2_MENU_ITEM(_loadMenu.item[2], 1, 43, -1, 73, 256, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ GUI_V2_MENU_ITEM(_loadMenu.item[3], 1, 44, -1, 90, 256, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ GUI_V2_MENU_ITEM(_loadMenu.item[4], 1, 45, -1, 107, 256, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ for (int i = 0; i <= 4; ++i)
+ _loadMenu.item[i].callback = clickLoadSlotFunctor;
+ GUI_V2_MENU_ITEM(_loadMenu.item[5], 1, 11, 184, 134, 88, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ _loadMenu.item[5].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::cancelLoadMenu);
+ _loadMenu.item[6].enabled = false;
+
+ GUI_V2_MENU(_saveMenu, -1, -1, 288, 160, 0xD0, 0xD1, 0xCF, 9, 0xBD, -1, 8, 0, 6, 132, 22, 132, 124);
+ GUI_V2_MENU_ITEM(_saveMenu.item[0], 1, 41, -1, 39, 256, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ GUI_V2_MENU_ITEM(_saveMenu.item[1], 1, 42, -1, 56, 256, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ GUI_V2_MENU_ITEM(_saveMenu.item[2], 1, 43, -1, 73, 256, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ GUI_V2_MENU_ITEM(_saveMenu.item[3], 1, 44, -1, 90, 256, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ GUI_V2_MENU_ITEM(_saveMenu.item[4], 1, 45, -1, 107, 256, 15, 0xFA, 0xFF, 5, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ for (int i = 0; i <= 4; ++i)
+ _saveMenu.item[i].callback = clickSaveSlotFunctor;
+ GUI_V2_MENU_ITEM(_saveMenu.item[5], 1, 11, 184, 134, 88, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ _saveMenu.item[5].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::cancelSaveMenu);
+ _saveMenu.item[6].enabled = false;
+
+ GUI_V2_MENU(_savenameMenu, -1, -1, 320, 67, 0xD0, 0xD1, 0xCF, 12, 0xBD, -1, 8, 0, 2, -1, -1, -1, -1);
+ GUI_V2_MENU_ITEM(_savenameMenu.item[0], 1, 13, 24, 44, 88, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ _savenameMenu.item[0].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::finishSavename);
+ GUI_V2_MENU_ITEM(_savenameMenu.item[1], 1, 11, 208, 44, 88, 15, 0xFA, 0xFF, -1, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ _savenameMenu.item[1].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::cancelSavename);
+ for (int i = 2; i < 7; ++i)
+ _savenameMenu.item[i].enabled = false;
+
+ GUI_V2_MENU(_deathMenu, -1, -1, 208, 76, 0xD0, 0xD1, 0xCF, 14, 0xBD, -1, 8, 0, 2, -1, -1, -1, -1);
+ GUI_V2_MENU_ITEM(_deathMenu.item[0], 1, 2, -1, 30, 180, 15, 0xFA, 0xFF, 8, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ _deathMenu.item[0].callback = clickLoadMenuFunctor;
+ GUI_V2_MENU_ITEM(_deathMenu.item[1], 1, 38, -1, 47, 180, 15, 0xFA, 0xFF, 8, 0xD0, 0xD1, 0xCF, -1, 0, 0, 0, 0x0000);
+ _deathMenu.item[1].callback = BUTTON_FUNCTOR(GUI_MR, this, &GUI_MR::loadSecondChance);
+ for (int i = 2; i < 7; ++i)
+ _deathMenu.item[i].enabled = false;
+}
+
} // End of namespace Kyra
diff --git a/engines/kyra/timer_v1.cpp b/engines/kyra/timer_v1.cpp
index f2a31da554..f5e7c52ba1 100644
--- a/engines/kyra/timer_v1.cpp
+++ b/engines/kyra/timer_v1.cpp
@@ -170,7 +170,7 @@ void KyraEngine_v1::timerRedrawAmulet(int timerNum) {
void KyraEngine_v1::setWalkspeed(uint8 newSpeed) {
debugC(9, kDebugLevelMain | kDebugLevelTimer, "KyraEngine_v1::setWalkspeed(%i)", newSpeed);
- static const uint8 speeds[] = {11, 9, 6, 5, 3};
+ static const uint8 speeds[] = { 11, 9, 6, 5, 3 };
assert(newSpeed < ARRAYSIZE(speeds));
_timer->setDelay(5, speeds[newSpeed]);