aboutsummaryrefslogtreecommitdiff
path: root/kyra
diff options
context:
space:
mode:
authorOystein Eftevaag2006-01-22 09:34:12 +0000
committerOystein Eftevaag2006-01-22 09:34:12 +0000
commite14b7fe8ac25ab743f1db0d2cb47362f089b528a (patch)
treea18fd0ee0c6fe931a87ac3ca7c46d3c09a6a11e6 /kyra
parentd4d95adab8bed63f03eb365b61ed9fc24ebf103d (diff)
downloadscummvm-rg350-e14b7fe8ac25ab743f1db0d2cb47362f089b528a.tar.gz
scummvm-rg350-e14b7fe8ac25ab743f1db0d2cb47362f089b528a.tar.bz2
scummvm-rg350-e14b7fe8ac25ab743f1db0d2cb47362f089b528a.zip
Kyrandia:
* Partial GUI implementation -Loading games and quitting works. -Colors are wrong in most room; saving and configuration doesn't work. * Moved stuff around in kyra.h, so struct definitions are adjacent. * Slight modification of Joostp's mousefix, should be more efficient and still work svn-id: r20135
Diffstat (limited to 'kyra')
-rw-r--r--kyra/gui.cpp408
-rw-r--r--kyra/kyra.cpp45
-rw-r--r--kyra/kyra.h128
-rw-r--r--kyra/screen.cpp26
-rw-r--r--kyra/screen.h4
-rw-r--r--kyra/staticres.cpp61
6 files changed, 617 insertions, 55 deletions
diff --git a/kyra/gui.cpp b/kyra/gui.cpp
index b224053aff..cdc531644e 100644
--- a/kyra/gui.cpp
+++ b/kyra/gui.cpp
@@ -22,6 +22,11 @@
#include "kyra/kyra.h"
#include "kyra/screen.h"
#include "kyra/script.h"
+#include "kyra/text.h"
+#include "kyra/animator.h"
+
+#include "common/savefile.h"
+#include "common/system.h"
namespace Kyra {
Button *KyraEngine::initButton(Button *list, Button *newButton) {
@@ -267,7 +272,7 @@ void KyraEngine::processButtonList(Button *list) {
void KyraEngine::processButton(Button *button) {
if (!button)
return;
-
+
int processType = 0;
uint8 *shape = 0;
Button::ButtonCallback callback = 0;
@@ -314,8 +319,407 @@ void KyraEngine::processButton(Button *button) {
}
}
+void KyraEngine::processAllMenuButtons() {
+ if (!_menuButtonList)
+ return;
+
+ Button *cur = _menuButtonList;
+ while (true) {
+ if (!cur->nextButton) {
+ break;
+ }
+ processMenuButton(cur);
+ cur = cur->nextButton;
+ }
+ return;
+}
+
+void KyraEngine::processMenuButton(Button *button) {
+ if (!_displayMenu)
+ return;
+
+ //_screen->hideMouse();
+
+ if ( !button || (button->flags & 8))
+ return;
+
+ if (button->flags2 & 1)
+ button->flags2 &= 0xf7;
+ else
+ button->flags2 |= 8;
+
+ button->flags2 &= 0xfc;
+
+ if (button->flags2 & 4)
+ button->flags2 |= 0x10;
+ else
+ button->flags2 &= 0xef;
+
+ button->flags2 &= 0xfb;
+
+ processButton(button);
+
+ //_screen->showMouse();
+}
+
+int KyraEngine::drawBoxCallback(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, 0xf8);
+ _screen->showMouse();
+
+ return 0;
+}
+
+int KyraEngine::drawShadedBoxCallback(Button *button) {
+
+ if (!_displayMenu)
+ return 0;
+
+ _screen->hideMouse();
+ _screen->drawShadedBox(button->x, button->y, button->x + button->width, button->y + button->height, 0xf9, 0xfa);
+ _screen->showMouse();
+
+ return 0;
+}
+
int KyraEngine::buttonMenuCallback(Button *caller) {
- warning("Menu not implemented yet!");
+ _displayMenu = true;
+
+ // XXX setLabels
+ if (_currentCharacter->sceneId == 210 || caller == 0) {
+ snd_playSoundEffect(0x36);
+ return 0;
+ }
+ // XXX
+
+ for (int i = 0; i < 6; i++) {
+ _menuButtonData[i].process0 = _menuButtonData[i].process1 = _menuButtonData[i].process2 = 4;
+ _menuButtonData[i].process0PtrCallback = &KyraEngine::drawShadedBoxCallback;
+ _menuButtonData[i].process1PtrCallback = &KyraEngine::drawBoxCallback;
+ _menuButtonData[i].process2PtrCallback = &KyraEngine::drawShadedBoxCallback;
+ }
+
+ _screen->savePageToDisk("SEENPAGE.TMP", 0);
+
+ calcCoords(_menu[0]);
+ calcCoords(_menu[1]);
+ calcCoords(_menu[2]);
+
+ initMenu(_menu[0]);
+ processAllMenuButtons();
+
+ _menuRestoreScreen = true;
+ while (_displayMenu) {
+ processButtonList(_menuButtonList);
+ gui_getInput();
+ }
+
+ if (_menuRestoreScreen) {
+ _screen->loadPageFromDisk("SEENPAGE.TMP", 0);
+ _animator->_updateScreen = true;
+ }
+ else
+ _screen->deletePageFromDisk(0);
+
+ return 0;
+}
+
+void KyraEngine::initMenu(Menu menu) {
+ int menu_x2 = menu.width + menu.x - 1;
+ int menu_y2 = menu.height + menu.y - 1;
+
+ _menuButtonList = 0;
+
+ _screen->hideMouse();
+ _screen->fillRect(menu.x + 2, menu.y + 2, menu_x2 - 2, menu_y2 - 2, menu.bgcolor);
+ _screen->drawShadedBox(menu.x, menu.y, menu_x2, menu_y2, menu.color1, menu.color2);
+
+ int textX;
+ int textY;
+
+ if (menu.field_10 != -1)
+ textX = menu.x;
+ else
+ textX = _text->getCenterStringX(menu.menuName, menu.x, menu_x2);
+
+ textY = menu.y + menu.field_12;
+
+ _text->printText(menu.menuName, textX - 1, textY + 1, 12, 248, 0);
+ _text->printText(menu.menuName, textX, textY, menu.textColor, 0, 0);
+
+ int x1, y1, x2, y2;
+ for (int i = 0; i < menu.nrOfItems; i++) {
+ if (!menu.item[i].enabled)
+ continue;
+
+ x1 = menu.x + menu.item[i].x;
+ y1 = menu.y + menu.item[i].y;
+
+ x2 = menu.x + menu.item[i].x + menu.item[i].width - 1;
+ y2 = menu.y + menu.item[i].y + menu.item[i].height - 1;
+
+ if (i < 6) {
+ _menuButtonData[i].nextButton = 0;
+ _menuButtonData[i].x = x1;
+ _menuButtonData[i].y = y1;
+ _menuButtonData[i].width = menu.item[i].width - 1;
+ _menuButtonData[i].height = menu.item[i].height - 1;
+ _menuButtonData[i].buttonCallback = menu.item[i].callback;
+ _menuButtonData[i].specialValue = menu.item[i].field_1b;
+ //_menuButtonData[i].field_6 = menu.item[i].field_25;
+ //_menuButtonData[i].field_8 = 0;
+
+ if (!_menuButtonList)
+ _menuButtonList = &_menuButtonData[i];
+ else
+ _menuButtonList = initButton(_menuButtonList, &_menuButtonData[i]);
+ }
+ _screen->fillRect(x1, y1, x2, y2, menu.item[i].bgcolor);
+ _screen->drawShadedBox(x1, y1, x2, y2, menu.item[i].color1, menu.item[i].color2);
+
+ if (menu.item[i].field_12 != -1)
+ textX = x1 + menu.item[i].field_12 + 3;
+ else
+ textX = _text->getCenterStringX(menu.item[i].itemString, x1, x2);
+
+ textY = y1 + 2;
+ _text->printText(menu.item[i].itemString, textX - 1, textY + 1, 12, 0, 0);
+
+ if (i == menu.field_14)
+ _text->printText(menu.item[i].itemString, textX, textY, menu.item[i].highlightColor, 0, 0);
+ else
+ _text->printText(menu.item[i].itemString, textX, textY, menu.item[i].textColor, 0, 0);
+
+ if (menu.item[i].labelString) {
+ _text->printText(menu.item[i].labelString, menu.x + menu.item[i].field_21 - 1, menu.y + menu.item[i].field_23 + 1, 12, 0, 0);
+ _text->printText(menu.item[i].labelString, menu.x + menu.item[i].field_21, menu.y + menu.item[i].field_23, 253, 0, 0);
+ }
+ }
+
+ if (menu.scrollUpBtnX != -1) {
+ _scrollUpButton.x = menu.scrollUpBtnX + menu.x;
+ _scrollUpButton.y = menu.scrollUpBtnY + menu.y;
+ _scrollUpButton.buttonCallback = &KyraEngine::gui_scrollUp;
+ _scrollUpButton.nextButton = 0;
+ _menuButtonList = initButton(_menuButtonList, &_scrollUpButton);
+ processMenuButton(&_scrollUpButton);
+
+ _scrollDownButton.x = menu.scrollDownBtnX + menu.x;
+ _scrollDownButton.y = menu.scrollDownBtnY + menu.y;
+ _scrollDownButton.buttonCallback = &KyraEngine::gui_scrollDown;
+ _scrollDownButton.nextButton = 0;
+ _menuButtonList = initButton(_menuButtonList, &_scrollDownButton);
+ processMenuButton(&_scrollDownButton);
+ }
+
+ _screen->showMouse();
+ _screen->updateScreen();
+}
+
+void KyraEngine::calcCoords(Menu &menu) {
+ if (menu.x == -1)
+ menu.x = (320 - menu.width)/2;
+
+ if (menu.y == -1)
+ menu.y = (200 - menu.height)/2;
+
+ assert(menu.nrOfItems < 7);
+ for (int i = 0; i < menu.nrOfItems; i++)
+ if (menu.item[i].x == -1)
+ menu.item[i].x = (menu.width - menu.item[i].width)/2;
+}
+
+void KyraEngine::gui_getInput() {
+ OSystem::Event event;
+
+ _mousePressFlag = false;
+ while (_system->pollEvent(event)) {
+ switch (event.type) {
+ case OSystem::EVENT_QUIT:
+ quitGame();
+ break;
+ case OSystem::EVENT_LBUTTONUP:
+ _mousePressFlag = true;
+ break;
+ case OSystem::EVENT_MOUSEMOVE:
+ _mouseX = event.mouse.x;
+ _mouseY = event.mouse.y;
+ _system->updateScreen();
+ break;
+ default:
+ break;
+ }
+ }
+ _system->delayMillis(10);
+}
+
+int KyraEngine::gui_resumeGame(Button *button) {
+ debug(9, "KyraEngine::gui_resumeGame()");
+ processMenuButton(button);
+ _displayMenu = false;
+
+ return 0;
+}
+
+const char *KyraEngine::getSavegameName(int num) {
+ static char saveLoadSlot[12];
+
+ sprintf(saveLoadSlot, "%s.%.3d", _targetName.c_str(), num);
+ return saveLoadSlot;
+}
+
+void KyraEngine::setupSavegames(Menu &menu, int num) {
+ Common::InSaveFile *in;
+ static char savenames[5][31];
+
+ assert(num <= 5);
+
+ for (int i = 0; i < num; i++) {
+ if ((in = _saveFileMan->openForLoading(getSavegameName(i + _savegameOffset)))) {
+ in->skip(8);
+ in->read(savenames[i], 31);
+ menu.item[i].itemString = savenames[i];
+ menu.item[i].enabled = 1;
+ menu.item[i].field_1b = i + _savegameOffset;
+ delete in;
+ } else {
+ menu.item[i].enabled = 0;
+ //menu.item[i].itemString = "";
+ //menu.item[i].field_1b = -1;
+ }
+ }
+}
+
+int KyraEngine::gui_loadGameMenu(Button *button) {
+ debug(9, "KyraEngine::gui_loadGameMenu()");
+ processMenuButton(button);
+ _screen->loadPageFromDisk("SEENPAGE.TMP", 0);
+ _screen->savePageToDisk("SEENPAGE.TMP", 0);
+
+ _savegameOffset = 0;
+ setupSavegames(_menu[2], 5);
+ initMenu(_menu[2]);
+
+ _displayLoadGameMenu = true;
+ _cancelLoadGameMenu = false;
+
+ while (_displayLoadGameMenu) {
+ gui_getInput();
+ //processHighlights();
+ processButtonList(_menuButtonList);
+ }
+
+ _screen->loadPageFromDisk("SEENPAGE.TMP", 0);
+ _screen->savePageToDisk("SEENPAGE.TMP", 0);
+
+ if (_cancelLoadGameMenu) {
+ initMenu(_menu[0]);
+ processAllMenuButtons();
+ } else {
+ loadGame(getSavegameName(_gameToLoad));
+ _displayMenu = false;
+ _menuRestoreScreen = false;
+ }
+ return 0;
+}
+
+int KyraEngine::gui_loadGame(Button *button) {
+ debug(9, "KyraEngine::gui_loadGame()");
+ processMenuButton(button);
+ _displayLoadGameMenu = false;
+ _gameToLoad = button->specialValue;
+
+ return 0;
+}
+
+int KyraEngine::gui_cancelLoadGameMenu(Button *button) {
+ debug(9, "KyraEngine::gui_cancelLoadGameMenu()");
+ processMenuButton(button);
+ _displayLoadGameMenu = false;
+ _cancelLoadGameMenu = true;
+
+ return 0;
+}
+
+int KyraEngine::gui_quitPlaying(Button *button) {
+ debug(9, "KyraEngine::gui_quitPlaying()");
+
+ processMenuButton(button);
+ if (gui_quitConfirm("Are you sure you want to quit playing?"))
+ quitGame();
+ else {
+ initMenu(_menu[0]);
+ processAllMenuButtons();
+ }
+
+ return 0;
+}
+
+bool KyraEngine::gui_quitConfirm(const char *str) {
+ debug(9, "KyraEngine::gui_quitConfirm()");
+
+ _screen->loadPageFromDisk("SEENPAGE.TMP", 0);
+ _screen->savePageToDisk("SEENPAGE.TMP", 0);
+
+ _menu[1].menuName = str;
+ initMenu(_menu[1]);
+
+ _displayQuitConfirmDialog = true;
+ _quitConfirmed = false;
+
+ while (_displayQuitConfirmDialog) {
+ gui_getInput();
+ //processHighlights();
+ processButtonList(_menuButtonList);
+ }
+
+ _screen->loadPageFromDisk("SEENPAGE.TMP", 0);
+ _screen->savePageToDisk("SEENPAGE.TMP", 0);
+
+ return _quitConfirmed;
+}
+
+int KyraEngine::gui_quitConfirmYes(Button *button) {
+ debug(9, "KyraEngine::gui_quitConfirmYes()");
+ processMenuButton(button);
+ _displayQuitConfirmDialog = false;
+ _quitConfirmed = true;
+
+ return 0;
+}
+
+int KyraEngine::gui_quitConfirmNo(Button *button) {
+ debug(9, "KyraEngine::gui_quitConfirmNo()");
+ processMenuButton(button);
+ _displayQuitConfirmDialog = false;
+ _quitConfirmed = false;
+
+ return 0;
+}
+
+int KyraEngine::gui_scrollUp(Button *button) {
+ debug(9, "KyraEngine::gui_scrollUp()");
+ processMenuButton(button);
+
+ if (_savegameOffset > 0) {
+ _savegameOffset--;
+ setupSavegames(_menu[2], 5);
+ initMenu(_menu[2]);
+ }
+ return 0;
+}
+
+int KyraEngine::gui_scrollDown(Button *button) {
+ debug(9, "KyraEngine::gui_scrollDown()");
+ processMenuButton(button);
+
+ _savegameOffset++;
+ setupSavegames(_menu[2], 5);
+ initMenu(_menu[2]);
+
return 0;
}
diff --git a/kyra/kyra.cpp b/kyra/kyra.cpp
index 73cbe20aaf..307bc2d02f 100644
--- a/kyra/kyra.cpp
+++ b/kyra/kyra.cpp
@@ -441,14 +441,14 @@ KyraEngine::~KyraEngine() {
delete [] _characterList;
delete [] _movFacingTable;
-
- free(_buttonShape0);
- free(_buttonShape1);
- free(_buttonShape2);
- free(_buttonShape3);
- free(_buttonShape4);
- free(_buttonShape5);
-
+
+ free(_scrollUpButton.process0PtrShape);
+ free(_scrollUpButton.process1PtrShape);
+ free(_scrollUpButton.process2PtrShape);
+ free(_scrollDownButton.process0PtrShape);
+ free(_scrollDownButton.process1PtrShape);
+ free(_scrollDownButton.process2PtrShape);
+
for (int i = 0; i < ARRAYSIZE(_shapes); ++i) {
if (_shapes[i] != 0) {
free(_shapes[i]);
@@ -581,6 +581,7 @@ void KyraEngine::startup() {
void KyraEngine::delay(uint32 amount, bool update, bool isMainLoop) {
OSystem::Event event;
char saveLoadSlot[20];
+ char savegameName[14];
_mousePressFlag = false;
uint32 start = _system->getMillis();
@@ -588,26 +589,28 @@ void KyraEngine::delay(uint32 amount, bool update, bool isMainLoop) {
while (_system->pollEvent(event)) {
switch (event.type) {
case OSystem::EVENT_KEYDOWN:
- if (event.kbd.keycode == 'q') {
- _quitFlag = true;
- } else if (event.kbd.keycode >= '0' && event.kbd.keycode <= '9' &&
+ if (event.kbd.keycode >= '0' && event.kbd.keycode <= '9' &&
(event.kbd.flags == OSystem::KBD_CTRL || event.kbd.flags == OSystem::KBD_ALT) && isMainLoop) {
sprintf(saveLoadSlot, "%s.00%d", _targetName.c_str(), event.kbd.keycode - '0');
if (event.kbd.flags == OSystem::KBD_CTRL)
loadGame(saveLoadSlot);
- else
- saveGame(saveLoadSlot, saveLoadSlot);
+ else {
+ sprintf(savegameName, "Quicksave %d", event.kbd.keycode - '0');
+ saveGame(saveLoadSlot, savegameName);
+ }
} else if (event.kbd.flags == OSystem::KBD_CTRL) {
if (event.kbd.keycode == 'f')
_fastMode = !_fastMode;
else if (event.kbd.keycode == 'd')
_debugger->attach();
+ else if (event.kbd.keycode == 'q')
+ _quitFlag = true;
}
break;
case OSystem::EVENT_MOUSEMOVE:
_mouseX = event.mouse.x;
_mouseY = event.mouse.y;
- _animator->_updateScreen = true;
+ _system->updateScreen();
break;
case OSystem::EVENT_QUIT:
quitGame();
@@ -711,6 +714,8 @@ void KyraEngine::mainLoop() {
}
}
+ _screen->showMouse();
+
processButtonList(_buttonList);
updateMousePointer();
updateGameTimers();
@@ -1974,12 +1979,12 @@ void KyraEngine::loadItems() {
void KyraEngine::loadButtonShapes() {
loadBitmap("BUTTONS2.CPS", 3, 3, 0);
_screen->_curPage = 2;
- _buttonShape0 = _screen->encodeShape(0, 0, 24, 14, 1);
- _buttonShape1 = _screen->encodeShape(24, 0, 24, 14, 1);
- _buttonShape2 = _screen->encodeShape(48, 0, 24, 14, 1);
- _buttonShape3 = _screen->encodeShape(0, 15, 24, 14, 1);
- _buttonShape4 = _screen->encodeShape(24, 15, 24, 14, 1);
- _buttonShape5 = _screen->encodeShape(48, 15, 24, 14, 1);
+ _scrollUpButton.process0PtrShape = _screen->encodeShape(0, 0, 24, 14, 1);
+ _scrollUpButton.process1PtrShape = _screen->encodeShape(24, 0, 24, 14, 1);
+ _scrollUpButton.process2PtrShape = _screen->encodeShape(48, 0, 24, 14, 1);
+ _scrollDownButton.process0PtrShape = _screen->encodeShape(0, 15, 24, 14, 1);
+ _scrollDownButton.process1PtrShape = _screen->encodeShape(24, 15, 24, 14, 1);
+ _scrollDownButton.process2PtrShape = _screen->encodeShape(48, 15, 24, 14, 1);
_screen->_curPage = 0;
}
diff --git a/kyra/kyra.h b/kyra/kyra.h
index e2031fa3f0..c0f51e00c1 100644
--- a/kyra/kyra.h
+++ b/kyra/kyra.h
@@ -31,6 +31,22 @@ class AudioStream;
namespace Kyra {
+class Movie;
+class Sound;
+class SeqPlayer;
+class Resource;
+class PAKFile;
+class Screen;
+class Sprites;
+class ScriptHelper;
+class Debugger;
+class ScreenAnimator;
+class TextDisplayer;
+class KyraEngine;
+
+struct ScriptState;
+struct ScriptData;
+
enum {
GF_FLOPPY = 1 << 0,
GF_TALKIE = 1 << 1,
@@ -116,22 +132,6 @@ struct BeadState {
int16 tableIndex;
};
-class Movie;
-
-class Sound;
-class SeqPlayer;
-class Resource;
-class PAKFile;
-class Screen;
-class Sprites;
-struct ScriptState;
-struct ScriptData;
-class ScriptHelper;
-class Debugger;
-class ScreenAnimator;
-class TextDisplayer;
-class KyraEngine;
-
struct Timer {
uint8 active;
int32 countdown;
@@ -148,7 +148,7 @@ struct Button {
uint8 process2;
// uint8 unk
uint16 flags;
- typedef int (KyraEngine::*ButtonCallback)(Button*);
+ typedef int (KyraEngine::*ButtonCallback)(Button*);
// using 6 pointers instead of 3 as in the orignal here (safer for use with classes)
uint8 *process0PtrShape;
uint8 *process1PtrShape;
@@ -167,6 +167,53 @@ struct Button {
// uint8 unk[8];
};
+struct MenuItem {
+ bool enabled;
+ uint16 field_1;
+ uint8 field_3;
+ const char *itemString;
+ int16 x;
+ int8 field_9;
+ uint16 y;
+ uint16 width;
+ uint16 height;
+ uint8 textColor;
+ uint8 highlightColor;
+ int8 field_12;
+ uint8 field_13;
+ uint8 bgcolor;
+ uint8 color1;
+ uint8 color2;
+ int (KyraEngine::*callback)(Button*);
+ int16 field_1b;
+ const char *labelString;
+ uint16 field_21;
+ uint8 field_23;
+ uint8 field_24;
+ uint32 field_25;
+};
+
+struct Menu {
+ int16 x;
+ int16 y;
+ uint16 width;
+ uint16 height;
+ uint8 bgcolor;
+ uint8 color1;
+ uint8 color2;
+ const char *menuName;
+ uint8 textColor;
+ int16 field_10;
+ uint16 field_12;
+ uint16 field_14;
+ uint8 nrOfItems;
+ int16 scrollUpBtnX;
+ int16 scrollUpBtnY;
+ int16 scrollDownBtnX;
+ int16 scrollDownBtnY;
+ MenuItem item[6];
+};
+
class KyraEngine : public Engine {
friend class MusicPlayer;
friend class Debugger;
@@ -599,11 +646,33 @@ protected:
int buttonInventoryCallback(Button *caller);
int buttonAmuletCallback(Button *caller);
int buttonMenuCallback(Button *caller);
+ int drawBoxCallback(Button *button);
+ int drawShadedBoxCallback(Button *button);
+ void calcCoords(Menu &menu);
+ void initMenu(Menu menu);
Button *initButton(Button *list, Button *newButton);
void processButtonList(Button *list);
void processButton(Button *button);
-
+ void processMenuButton(Button *button);
+ void processAllMenuButtons();
+
+ const char *getSavegameName(int num);
+ void setupSavegames(Menu &menu, int num);
+
+ int gui_resumeGame(Button *button);
+ int gui_loadGameMenu(Button *button);
+ int gui_quitPlaying(Button *button);
+ int gui_quitConfirmYes(Button *button);
+ int gui_quitConfirmNo(Button *button);
+ int gui_loadGame(Button *button);
+ int gui_cancelLoadGameMenu(Button *button);
+ int gui_scrollUp(Button *button);
+ int gui_scrollDown(Button *button);
+
+ bool gui_quitConfirm(const char *str);
+ void gui_getInput();
+
uint8 _game;
bool _fastMode;
bool _quitFlag;
@@ -738,14 +807,16 @@ protected:
Character *_characterList;
Button *_buttonList;
-
- uint8 *_buttonShape0;
- uint8 *_buttonShape1;
- uint8 *_buttonShape2;
- uint8 *_buttonShape3;
- uint8 *_buttonShape4;
- uint8 *_buttonShape5;
-
+ Button *_menuButtonList;
+ bool _displayMenu;
+ bool _menuRestoreScreen;
+ bool _displayQuitConfirmDialog;
+ bool _displayLoadGameMenu;
+ bool _cancelLoadGameMenu;
+ bool _quitConfirmed;
+ int _savegameOffset;
+ int _gameToLoad;
+
uint8 *_seq_Forest;
uint8 *_seq_KallakWriting;
uint8 *_seq_KyrandiaLogo;
@@ -867,6 +938,11 @@ protected:
static Button _buttonData[];
static Button *_buttonDataListPtr[];
+ static Button _menuButtonData[];
+ static Button _scrollUpButton;
+ static Button _scrollDownButton;
+
+ static Menu _menu[];
static const uint8 _magicMouseItemStartFrame[];
static const uint8 _magicMouseItemEndFrame[];
diff --git a/kyra/screen.cpp b/kyra/screen.cpp
index 725df9ebd0..30b8ac6987 100644
--- a/kyra/screen.cpp
+++ b/kyra/screen.cpp
@@ -440,11 +440,17 @@ void Screen::fillRect(int x1, int y1, int x2, int y2, uint8 color, int pageNum)
}
}
-void Screen::drawBox(int x1, int y1, int x2, int y2, int color1, int color2) {
- debug(9, "Screen::drawBox(%i, %i, %i, %i, %i, %i)", x1, y1, x2, y2, color1, color2);
+void Screen::drawBox(int x1, int y1, int x2, int y2, int color) {
+ debug(9, "Screen::drawBox(%i, %i, %i, %i, %i)", x1, y1, x2, y2, color);
- //if (_menuUnk1 == 0)
- //return;
+ drawClippedLine(x1, y1, x2, y1, color);
+ drawClippedLine(x1, y1, x1, y2, color);
+ drawClippedLine(x2, y1, x2, y2, color);
+ drawClippedLine(x1, y2, x2, y2, color);
+}
+
+void Screen::drawShadedBox(int x1, int y1, int x2, int y2, int color1, int color2) {
+ debug(9, "Screen::drawShadedBox(%i, %i, %i, %i, %i, %i)", x1, y1, x2, y2, color1, color2);
hideMouse();
@@ -1750,11 +1756,12 @@ void Screen::hideMouse() {
void Screen::showMouse() {
debug(9, "Screen::showMouse()");
+ if (_mouseLockCount == 1)
+ _system->showMouse(true);
+
if (_mouseLockCount > 0)
_mouseLockCount--;
- if (_mouseLockCount == 0)
- _system->showMouse(true);
}
void Screen::setShapePages(int page1, int page2) {
@@ -1902,4 +1909,11 @@ void Screen::loadPageFromDisk(const char *file, int page) {
delete [] _saveLoadPage[page/2];
_saveLoadPage[page/2] = 0;
}
+
+void Screen::deletePageFromDisk(int page) {
+ debug(9, "Screen::deletePageFromDisk(%d)", page);
+ delete [] _saveLoadPage[page/2];
+ _saveLoadPage[page/2] = 0;
+}
+
} // End of namespace Kyra
diff --git a/kyra/screen.h b/kyra/screen.h
index e85b6af258..ac3e8e0b51 100644
--- a/kyra/screen.h
+++ b/kyra/screen.h
@@ -109,7 +109,8 @@ public:
void fillRect(int x1, int y1, int x2, int y2, uint8 color, int pageNum = -1);
void drawLine(bool horizontal, int x, int y, int length, int color);
void drawClippedLine(int x1, int y1, int x2, int y2, int color);
- void drawBox(int x1, int y1, int x2, int y2, int color1, int color2);
+ void drawShadedBox(int x1, int y1, int x2, int y2, int color1, int color2);
+ void drawBox(int x1, int y1, int x2, int y2, int color);
void setAnimBlockPtr(int size);
void setTextColorMap(const uint8 *cmap);
void setTextColor(const uint8 *cmap, int a, int b);
@@ -146,6 +147,7 @@ public:
void savePageToDisk(const char *file, int page);
void loadPageFromDisk(const char *file, int page);
+ void deletePageFromDisk(int page);
int _charWidth;
int _charOffset;
diff --git a/kyra/staticres.cpp b/kyra/staticres.cpp
index dbe1636e62..91a78aa633 100644
--- a/kyra/staticres.cpp
+++ b/kyra/staticres.cpp
@@ -748,6 +748,67 @@ Button *KyraEngine::_buttonDataListPtr[] = {
0
};
+Button KyraEngine::_scrollUpButton = {0, 0x12, 1, 1, 1, 0x483, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x18, 0x0f, 0, 0};
+Button KyraEngine::_scrollDownButton = {0, 0x13, 1, 1, 1, 0x483, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x18, 0x0f, 0, 0};
+
+
+
+Button KyraEngine::_menuButtonData[] = {
+ { 0, 0x0c, /*XXX,*/1, 1, 1, /*XXX,*/ 0x487, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*XXX,*/ 0, 0 /*, XXX*/ },
+ { 0, 0x0d, /*XXX,*/1, 1, 1, /*XXX,*/ 0x487, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*XXX,*/ 0, 0 /*, XXX*/ },
+ { 0, 0x0e, /*XXX,*/1, 1, 1, /*XXX,*/ 0x487, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*XXX,*/ 0, 0 /*, XXX*/ },
+ { 0, 0x0f, /*XXX,*/1, 1, 1, /*XXX,*/ 0x487, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*XXX,*/ 0, 0 /*, XXX*/ },
+ { 0, 0x10, /*XXX,*/1, 1, 1, /*XXX,*/ 0x487, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*XXX,*/ 0, 0 /*, XXX*/ },
+ { 0, 0x11, /*XXX,*/1, 1, 1, /*XXX,*/ 0x487, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /*XXX,*/ 0, 0 /*, XXX*/ }
+};
+
+Menu KyraEngine::_menu[] = {
+ { -1, -1, 208, 136, 248, 249, 250, "The Legend of Kyrandia", 251, -1, 8, 0, 5, -1, -1, -1, -1,
+ {
+ {1, 0, 0, "Load a Game", -1, -1, 30, 148, 15, 252, 253, 24, 0,
+ 248, 249, 250, &KyraEngine::gui_loadGameMenu, -1, 0, 0, 0, 0, 0},
+ {1, 0, 0, "Save this Game", -1, -1, 47, 148, 15, 252, 253, 24, 0,
+ 248, 249, 250, /*&menu_saveGame*/ 0, -1, 0, 0, 0, 0, 0},
+ {1, 0, 0, "Game Controls", -1, -1, 64, 148, 15, 252, 253, 24, 0,
+ 248, 249, 250, /*&menu_gameControls*/ 0, -1, 0, 0, 0, 0, 0},
+ {1, 0, 0, "Quit playing", -1, -1, 81, 148, 15, 252, 253, 24, 0,
+ 248, 249, 250, &KyraEngine::gui_quitPlaying, -1, 0, 0, 0, 0, 0},
+ {1, 0, 0, "Resume game", 86, 0, 110, 92, 15, 252, 253, 255, 255,
+ 248, 249, 250, &KyraEngine::gui_resumeGame, -1, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ }
+ },
+ { -1, -1, 288, 56, 248, 249, 250, 0, 254,-1, 8, 0, 2, -1, -1, -1, -1,
+ {
+ {1, 0, 0, "Yes", 24, 0, 30, 72, 15, 252, 253, 255, 255,
+ 248, 249, 250, &KyraEngine::gui_quitConfirmYes, -1, 0, 0, 0, 0, 0},
+ {1, 0, 0, "No", 192, 0, 30, 72, 15, 252, 253, 255, 255,
+ 248, 249, 250, &KyraEngine::gui_quitConfirmNo, -1, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ }
+ },
+ { -1, -1, 288, 160, 248, 249, 250, "Which game would you like to reload?", 251, -1, 8, 0, 6, 132, 22, 132, 124,
+ {
+ {1, 0, 0, 0, -1, 255, 39, 256, 15, 252, 253, 5, 0,
+ 248, 249, 250, &KyraEngine::gui_loadGame, -1, 0, 0, 0, 0, 0},
+ {1, 0, 0, "", -1, 255, 56, 256, 15, 252, 253, 5, 0,
+ 248, 249, 250, &KyraEngine::gui_loadGame, -1, 0, 0, 0, 0, 0},
+ {1, 0, 0, "", -1, 255, 73, 256, 15, 252, 253, 5, 0,
+ 248, 249, 250, &KyraEngine::gui_loadGame, -1, 0, 0, 0, 0, 0},
+ {1, 0, 0, "", -1, 255, 90, 256, 15, 252, 253, 5, 0,
+ 248, 249, 250, &KyraEngine::gui_loadGame, -1, 0, 0, 0, 0, 0},
+ {1, 0, 0, "", -1, 255, 107, 256, 15, 252, 253, 5, 0,
+ 248, 249, 250, &KyraEngine::gui_loadGame, -1, 0, 0, 0, 0, 0},
+ //{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
+ {1, 0, 0, "Cancel", 184, 0, 134, 88, 15, 252, 253, 255, 255,
+ 248, 249, 250, &KyraEngine::gui_cancelLoadGameMenu, -1, 0, 0, 0, 0, 0},
+ }
+ }
+};
+
const uint8 KyraEngine::_magicMouseItemStartFrame[] = {
0xAD, 0xB7, 0xBE, 0x00
};