aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2008-03-28 09:00:30 +0000
committerJohannes Schickel2008-03-28 09:00:30 +0000
commitb910d8d9bb0cd103d30511e61e00c72a89b50748 (patch)
treeeb52aa1ceca26129d3fb84849ece4a697b92ee1a
parent7f81de679480acbcc9d2b13e52e0938675252d27 (diff)
downloadscummvm-rg350-b910d8d9bb0cd103d30511e61e00c72a89b50748.tar.gz
scummvm-rg350-b910d8d9bb0cd103d30511e61e00c72a89b50748.tar.bz2
scummvm-rg350-b910d8d9bb0cd103d30511e61e00c72a89b50748.zip
Refactored Kyrandia GUI code a bit.
svn-id: r31290
-rw-r--r--engines/kyra/debugger.cpp2
-rw-r--r--engines/kyra/debugger.h2
-rw-r--r--engines/kyra/gui.cpp298
-rw-r--r--engines/kyra/gui.h192
-rw-r--r--engines/kyra/gui_v1.cpp789
-rw-r--r--engines/kyra/gui_v1.h176
-rw-r--r--engines/kyra/kyra_v1.cpp30
-rw-r--r--engines/kyra/kyra_v1.h149
-rw-r--r--engines/kyra/module.mk1
-rw-r--r--engines/kyra/script_v1.cpp2
-rw-r--r--engines/kyra/staticres.cpp264
11 files changed, 1089 insertions, 816 deletions
diff --git a/engines/kyra/debugger.cpp b/engines/kyra/debugger.cpp
index 51d3b77ffc..b378382be8 100644
--- a/engines/kyra/debugger.cpp
+++ b/engines/kyra/debugger.cpp
@@ -36,7 +36,7 @@
namespace Kyra {
Debugger::Debugger(KyraEngine *vm)
- : GUI::Debugger() {
+ : ::GUI::Debugger() {
_vm = vm;
DCmd_Register("screen_debug_mode", WRAP_METHOD(Debugger, cmd_setScreenDebug));
diff --git a/engines/kyra/debugger.h b/engines/kyra/debugger.h
index 3bcefbf133..dedcd672c7 100644
--- a/engines/kyra/debugger.h
+++ b/engines/kyra/debugger.h
@@ -34,7 +34,7 @@ class KyraEngine;
class KyraEngine_v1;
class KyraEngine_v2;
-class Debugger : public GUI::Debugger {
+class Debugger : public ::GUI::Debugger {
public:
Debugger(KyraEngine *vm);
virtual ~Debugger() {} // we need this for __SYMBIAN32__ archaic gcc/UIQ
diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp
new file mode 100644
index 0000000000..f949ab81bd
--- /dev/null
+++ b/engines/kyra/gui.cpp
@@ -0,0 +1,298 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "kyra/gui.h"
+
+#include "kyra/screen.h"
+#include "kyra/text.h"
+
+namespace Kyra {
+
+GUI::GUI(KyraEngine *kyra)
+ : _vm(kyra), _screen(kyra->screen()), _text(kyra->text()) {
+ _menuButtonList = 0;
+ _haveScrollButtons = false;
+
+ _redrawButtonFunctor = BUTTON_FUNCTOR(GUI, this, &GUI::redrawButtonCallback);
+ _redrawShadedButtonFunctor = BUTTON_FUNCTOR(GUI, this, &GUI::redrawShadedButtonCallback);
+}
+
+Button *GUI::addButtonToList(Button *list, Button *newButton) {
+ if (!newButton)
+ return list;
+
+ newButton->nextButton = 0;
+
+ if (list) {
+ Button *cur = list;
+ while (cur->nextButton)
+ cur = cur->nextButton;
+ cur->nextButton = newButton;
+ } else {
+ list = newButton;
+ }
+
+ return list;
+}
+
+void GUI::initMenuLayout(Menu &menu) {
+ if (menu.x == -1)
+ menu.x = (320 - menu.width) >> 1;
+ if (menu.y == -1)
+ menu.y = (200 - menu.height) >> 1;
+
+ for (int i = 0; i < menu.numberOfItems; ++i) {
+ if (menu.item[i].x == -1)
+ menu.item[i].x = (menu.width - menu.item[i].width) >> 1;
+ }
+}
+
+void GUI::initMenu(Menu &menu) {
+ _menuButtonList = 0;
+
+ _screen->hideMouse();
+
+ int textX;
+ int textY;
+
+ int menu_x2 = menu.width + menu.x - 1;
+ int menu_y2 = menu.height + menu.y - 1;
+
+ _screen->fillRect(menu.x + 2, menu.y + 2, menu_x2 - 2, menu_y2 - 2, menu.bkgdColor);
+ _screen->drawShadedBox(menu.x, menu.y, menu_x2, menu_y2, menu.color1, menu.color2);
+
+ if (menu.titleX != -1)
+ textX = menu.titleX;
+ else
+ textX = _text->getCenterStringX(getMenuTitle(menu), menu.x, menu_x2);
+
+ textY = menu.y + menu.titleY;
+
+ _text->printText(getMenuTitle(menu), textX - 1, textY + 1, defaultColor1(), defaultColor2(), 0);
+ _text->printText(getMenuTitle(menu), textX, textY, menu.textColor, 0, 0);
+
+ int x1, y1, x2, y2;
+ for (int i = 0; i < menu.numberOfItems; ++i) {
+ if (!menu.item[i].enabled)
+ continue;
+
+ x1 = menu.x + menu.item[i].x;
+ y1 = menu.y + menu.item[i].y;
+
+ x2 = x1 + menu.item[i].width - 1;
+ y2 = y1 + menu.item[i].height - 1;
+
+ if (i < 7) {
+ Button *menuButtonData = getButtonListData() + i;
+ menuButtonData->nextButton = 0;
+ menuButtonData->x = x1;
+ menuButtonData->y = y1;
+ menuButtonData->width = menu.item[i].width - 1;
+ menuButtonData->height = menu.item[i].height - 1;
+ menuButtonData->buttonCallback = menu.item[i].callback;
+ menuButtonData->index = menu.item[i].saveSlot;
+ menuButtonData->unk6 = menu.item[i].unk1F;
+ menuButtonData->unk8 = 0;
+
+ _menuButtonList = addButtonToList(_menuButtonList, menuButtonData);
+ }
+
+ _screen->fillRect(x1, y1, x2, y2, menu.item[i].bkgdColor);
+ _screen->drawShadedBox(x1, y1, x2, y2, menu.item[i].color1, menu.item[i].color2);
+
+ if (menu.item[i].itemString) {
+ if (menu.item[i].titleX != -1)
+ textX = x1 + menu.item[i].titleX + 3;
+ else
+ textX = _text->getCenterStringX(menu.item[i].itemString, x1, x2);
+
+ textY = y1 + 2;
+ _text->printText(menu.item[i].itemString, textX - 1, textY + 1, defaultColor1(), 0, 0);
+
+ if (i == menu.highlightedItem)
+ _text->printText(menu.item[i].itemString, textX, textY, menu.item[i].highlightColor, 0, 0);
+ else
+ _text->printText(menu.item[i].itemString, textX, textY, menu.item[i].textColor, 0, 0);
+
+ if (getMenuItemLabel(menu.item[i])) {
+ _text->printText(getMenuItemLabel(menu.item[i]), menu.x + menu.item[i].labelX - 1, menu.y + menu.item[i].labelY + 1, defaultColor1(), 0, 0);
+ _text->printText(getMenuItemLabel(menu.item[i]), menu.x + menu.item[i].labelX, menu.y + menu.item[i].labelY, menu.item[i].textColor, 0, 0);
+ }
+ }
+ }
+
+ if (menu.scrollUpButtonX != -1) {
+ _haveScrollButtons = true;
+
+ Button *scrollUpButton = getScrollUpButton();
+ scrollUpButton->x = menu.scrollUpButtonX + menu.x;
+ scrollUpButton->y = menu.scrollUpButtonY + menu.y;
+ scrollUpButton->buttonCallback = getScrollUpButtonHandler();
+ scrollUpButton->nextButton = 0;
+
+ _menuButtonList = addButtonToList(_menuButtonList, scrollUpButton);
+ updateMenuButton(scrollUpButton);
+
+ Button *scrollDownButton = getScrollDownButton();
+ scrollDownButton->x = menu.scrollDownButtonX + menu.x;
+ scrollDownButton->y = menu.scrollDownButtonY + menu.y;
+ scrollDownButton->buttonCallback = getScrollDownButtonHandler();
+ scrollDownButton->nextButton = 0;
+
+ _menuButtonList = addButtonToList(_menuButtonList, scrollDownButton);
+ updateMenuButton(scrollDownButton);
+ } else {
+ _haveScrollButtons = false;
+ }
+
+ _screen->showMouse();
+ _screen->updateScreen();
+}
+
+void GUI::processHighlights(Menu &menu, int mouseX, int mouseY) {
+ int x1, y1, x2, y2;
+
+ for (int i = 0; i < menu.numberOfItems; ++i) {
+ if (!menu.item[i].enabled)
+ continue;
+
+ x1 = menu.x + menu.item[i].x;
+ y1 = menu.y + menu.item[i].y;
+
+ x2 = x1 + menu.item[i].width;
+ y2 = y1 + menu.item[i].height;
+
+ if (mouseX > x1 && mouseX < x2 &&
+ mouseY > y1 && mouseY < y2) {
+
+ if (menu.highlightedItem != i) {
+ if (menu.item[menu.highlightedItem].enabled)
+ redrawText(menu);
+
+ menu.highlightedItem = i;
+ redrawHighlight(menu);
+ _screen->updateScreen();
+ }
+ }
+ }
+}
+
+void GUI::redrawText(const Menu &menu) {
+ int textX;
+ int i = menu.highlightedItem;
+
+ int x1 = menu.x + menu.item[i].x;
+ int y1 = menu.y + menu.item[i].y;
+
+ int x2 = x1 + menu.item[i].width - 1;
+
+ if (menu.item[i].titleX >= 0)
+ textX = x1 + menu.item[i].titleX + 3;
+ else
+ textX = _text->getCenterStringX(getMenuItemTitle(menu.item[i]), x1, x2);
+
+ int textY = y1 + 2;
+ _text->printText(getMenuItemTitle(menu.item[i]), textX - 1, textY + 1, defaultColor1(), 0, 0);
+ _text->printText(getMenuItemTitle(menu.item[i]), textX, textY, menu.item[i].textColor, 0, 0);
+}
+
+void GUI::redrawHighlight(const Menu &menu) {
+ int textX;
+ int i = menu.highlightedItem;
+
+ int x1 = menu.x + menu.item[i].x;
+ int y1 = menu.y + menu.item[i].y;
+
+ int x2 = x1 + menu.item[i].width - 1;
+
+ if (menu.item[i].titleX != -1)
+ textX = x1 + menu.item[i].titleX + 3;
+ else
+ textX = _text->getCenterStringX(getMenuItemTitle(menu.item[i]), x1, x2);
+
+ int textY = y1 + 2;
+ _text->printText(getMenuItemTitle(menu.item[i]), textX - 1, textY + 1, defaultColor1(), 0, 0);
+ _text->printText(getMenuItemTitle(menu.item[i]), textX, textY, menu.item[i].highlightColor, 0, 0);
+}
+
+void GUI::updateAllMenuButtons() {
+ for (Button *cur = _menuButtonList; cur; cur = cur->nextButton)
+ updateMenuButton(cur);
+}
+
+void GUI::updateMenuButton(Button *button) {
+ if (!_displayMenu)
+ return;
+
+ _screen->hideMouse();
+ updateButton(button);
+ _screen->showMouse();
+}
+
+void GUI::updateButton(Button *button) {
+ if (!button || (button->flags & 8))
+ return;
+
+ if (button->flags2 & 1)
+ button->flags2 &= 0xFFF7;
+ else
+ button->flags2 |= 8;
+
+ button->flags2 &= 0xFFFC;
+
+ if (button->flags2 & 4)
+ button->flags2 |= 0x10;
+ else
+ button->flags2 &= 0xEEEF;
+
+ button->flags2 &= 0xFFFB;
+
+ processButton(button);
+}
+
+int GUI::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, 0xF8);
+ _screen->showMouse();
+
+ return 0;
+}
+
+int GUI::redrawShadedButtonCallback(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;
+}
+
+} // end of namespace Kyra
+
diff --git a/engines/kyra/gui.h b/engines/kyra/gui.h
new file mode 100644
index 0000000000..2724424ff9
--- /dev/null
+++ b/engines/kyra/gui.h
@@ -0,0 +1,192 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef KYRA_GUI_H
+#define KYRA_GUI_H
+
+#include "kyra/util.h"
+#include "kyra/kyra.h"
+
+#include "common/ptr.h"
+
+namespace Kyra {
+
+#define BUTTON_FUNCTOR(type, x, y) Button::Callback(new Functor1Mem<Button*, int, type>(x, y))
+
+struct Button {
+ typedef Functor1<Button*, int> CallbackFunctor;
+ typedef Common::SharedPtr<CallbackFunctor> Callback;
+
+ Button *nextButton;
+ uint16 index;
+
+ uint16 unk6;
+ uint16 unk8;
+
+ byte data0Val1;
+ byte data1Val1;
+ byte data2Val1;
+
+ uint16 flags;
+
+ const uint8 *data0ShapePtr;
+ const uint8 *data1ShapePtr;
+ const uint8 *data2ShapePtr;
+ Callback data0Callback;
+ Callback data1Callback;
+ Callback data2Callback;
+
+ uint16 dimTableIndex;
+
+ int16 x, y;
+ uint16 width, height;
+
+ uint8 data0Val2;
+ uint8 data0Val3;
+
+ uint8 data1Val2;
+ uint8 data1Val3;
+
+ uint8 data2Val2;
+ uint8 data2Val3;
+
+ uint16 flags2;
+
+ Callback buttonCallback;
+};
+
+struct MenuItem {
+ bool enabled;
+
+ const char *itemString;
+ uint16 itemId;
+
+ int16 x, y;
+ uint16 width, height;
+
+ uint8 textColor, highlightColor;
+
+ int16 titleX;
+
+ uint8 color1, color2;
+ uint8 bkgdColor;
+
+ Button::Callback callback;
+
+ int16 saveSlot;
+
+ const char *labelString;
+ uint16 labelId;
+ int16 labelX, labelY;
+
+ uint16 unk1F;
+};
+
+struct Menu {
+ int16 x, y;
+ uint16 width, height;
+
+ uint8 bkgdColor;
+ uint8 color1, color2;
+
+ const char *menuNameString;
+ uint16 menuNameId;
+
+ uint8 textColor;
+ int16 titleX, titleY;
+
+ uint8 highlightedItem;
+
+ uint8 numberOfItems;
+
+ int16 scrollUpButtonX, scrollUpButtonY;
+ int16 scrollDownButtonX, scrollDownButtonY;
+
+ MenuItem item[7];
+};
+
+class Screen;
+class TextDisplayer;
+
+class GUI {
+public:
+ GUI(KyraEngine *vm);
+ virtual ~GUI() {}
+
+ // button specific
+ virtual Button *addButtonToList(Button *list, Button *newButton);
+
+ virtual void processButton(Button *button) = 0;
+ virtual int processButtonList(Button *buttonList, uint16 inputFlags) = 0;
+
+ int redrawShadedButtonCallback(Button *button);
+ int redrawButtonCallback(Button *button);
+
+ // menu specific
+ virtual void initMenuLayout(Menu &menu);
+ void initMenu(Menu &menu);
+
+ void processHighlights(Menu &menu, int mouseX, int mouseY);
+
+protected:
+ KyraEngine *_vm;
+ Screen *_screen;
+ TextDisplayer *_text;
+
+ Button *_menuButtonList;
+ bool _haveScrollButtons;
+ bool _displayMenu;
+ bool _displaySubMenu;
+ bool _cancelSubMenu;
+
+ Button::Callback _redrawShadedButtonFunctor;
+ Button::Callback _redrawButtonFunctor;
+
+ virtual Button *getButtonListData() = 0;
+ virtual Button *getScrollUpButton() = 0;
+ virtual Button *getScrollDownButton() = 0;
+
+ virtual Button::Callback getScrollUpButtonHandler() const = 0;
+ virtual Button::Callback getScrollDownButtonHandler() const = 0;
+
+ virtual uint8 defaultColor1() const = 0;
+ virtual uint8 defaultColor2() const = 0;
+
+ virtual const char *getMenuTitle(const Menu &menu) = 0;
+ virtual const char *getMenuItemTitle(const MenuItem &menuItem) = 0;
+ virtual const char *getMenuItemLabel(const MenuItem &menuItem) = 0;
+
+ void updateAllMenuButtons();
+ void updateMenuButton(Button *button);
+ virtual void updateButton(Button *button);
+
+ void redrawText(const Menu &menu);
+ void redrawHighlight(const Menu &menu);
+};
+
+} // end of namesapce Kyra
+
+#endif
+
diff --git a/engines/kyra/gui_v1.cpp b/engines/kyra/gui_v1.cpp
index 1b86b1bb80..5c8b382f14 100644
--- a/engines/kyra/gui_v1.cpp
+++ b/engines/kyra/gui_v1.cpp
@@ -29,6 +29,7 @@
#include "kyra/text.h"
#include "kyra/animator_v1.h"
#include "kyra/sound.h"
+#include "kyra/gui_v1.h"
#include "common/config-manager.h"
#include "common/savefile.h"
@@ -38,31 +39,13 @@
namespace Kyra {
void KyraEngine_v1::initMainButtonList() {
- _haveScrollButtons = false;
_buttonList = &_buttonData[0];
for (int i = 0; _buttonDataListPtr[i]; ++i)
- _buttonList = initButton(_buttonList, _buttonDataListPtr[i]);
-}
-
-Button *KyraEngine_v1::initButton(Button *list, Button *newButton) {
- if (!newButton)
- return list;
- if (!list)
- return newButton;
- Button *cur = list;
-
- while (true) {
- if (!cur->nextButton)
- break;
- cur = cur->nextButton;
- }
-
- cur->nextButton = newButton;
- return list;
+ _buttonList = _gui->addButtonToList(_buttonList, _buttonDataListPtr[i]);
}
int KyraEngine_v1::buttonInventoryCallback(Button *caller) {
- int itemOffset = caller->specialValue - 2;
+ int itemOffset = caller->index - 2;
uint8 inventoryItem = _currentCharacter->inventoryItems[itemOffset];
if (_itemInHand == -1) {
if (inventoryItem == 0xFF) {
@@ -108,7 +91,7 @@ int KyraEngine_v1::buttonInventoryCallback(Button *caller) {
int KyraEngine_v1::buttonAmuletCallback(Button *caller) {
if (!(_deathHandler & 8))
return 1;
- int jewel = caller->specialValue - 0x14;
+ int jewel = caller->index - 0x14;
if (_currentCharacter->sceneId == 210) {
if (_beadStateVar == 4 || _beadStateVar == 6)
return 1;
@@ -201,12 +184,25 @@ int KyraEngine_v1::buttonAmuletCallback(Button *caller) {
return 1;
}
-void KyraEngine_v1::processButtonList(Button *list) {
+#pragma mark -
+
+GUI_v1::GUI_v1(KyraEngine_v1 *vm) : GUI(vm), _vm(vm) {
+ _menu = 0;
+ initStaticResource();
+ _scrollUpFunctor = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::scrollUp);
+ _scrollDownFunctor = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::scrollDown);
+}
+
+GUI_v1::~GUI_v1() {
+ delete [] _menu;
+}
+
+int GUI_v1::processButtonList(Button *list, uint16 inputFlag) {
if (_haveScrollButtons) {
if (_mouseWheel < 0)
- gui_scrollUp(&_scrollUpButton);
+ scrollUp(&_scrollUpButton);
else if (_mouseWheel > 0)
- gui_scrollDown(&_scrollDownButton);
+ scrollDown(&_scrollDownButton);
}
while (list) {
if (list->flags & 8) {
@@ -227,11 +223,11 @@ void KyraEngine_v1::processButtonList(Button *list) {
}
y += _screen->_screenDimTable[list->dimTableIndex].sy;
- Common::Point mouse = getMousePos();
+ Common::Point mouse = _vm->getMousePos();
if (mouse.x >= x && mouse.y >= y && x + list->width >= mouse.x && y + list->height >= mouse.y) {
int processMouseClick = 0;
if (list->flags & 0x400) {
- if (_mousePressFlag) {
+ if (_vm->_mousePressFlag) {
if (!(list->flags2 & 1)) {
list->flags2 |= 1;
list->flags2 |= 4;
@@ -245,13 +241,13 @@ void KyraEngine_v1::processButtonList(Button *list) {
processMouseClick = 1;
}
}
- } else if (_mousePressFlag) {
+ } else if (_vm->_mousePressFlag) {
processMouseClick = 1;
}
if (processMouseClick) {
if (list->buttonCallback) {
- if ((this->*(list->buttonCallback))(list)) {
+ if ((*list->buttonCallback.get())(list)) {
break;
}
}
@@ -272,35 +268,36 @@ void KyraEngine_v1::processButtonList(Button *list) {
list = list->nextButton;
}
+ return 0;
}
-void KyraEngine_v1::processButton(Button *button) {
+void GUI_v1::processButton(Button *button) {
if (!button)
return;
int processType = 0;
- uint8 *shape = 0;
- Button::ButtonCallback callback = 0;
+ const uint8 *shape = 0;
+ Button::Callback callback;
int flags = (button->flags2 & 5);
if (flags == 1) {
- processType = button->process2;
+ processType = button->data2Val1;
if (processType == 1)
- shape = button->process2PtrShape;
+ shape = button->data2ShapePtr;
else if (processType == 4)
- callback = button->process2PtrCallback;
+ callback = button->data2Callback;
} else if (flags == 4 || flags == 5) {
- processType = button->process1;
+ processType = button->data1Val1;
if (processType == 1)
- shape = button->process1PtrShape;
+ shape = button->data1ShapePtr;
else if (processType == 4)
- callback = button->process1PtrCallback;
+ callback = button->data1Callback;
} else {
- processType = button->process0;
+ processType = button->data0Val1;
if (processType == 1)
- shape = button->process0PtrShape;
+ shape = button->data0ShapePtr;
else if (processType == 4)
- callback = button->process0PtrCallback;
+ callback = button->data0Callback;
}
int x = button->x;
@@ -315,70 +312,10 @@ void KyraEngine_v1::processButton(Button *button) {
if (processType == 1 && shape)
_screen->drawShape(_screen->_curPage, shape, x, y, button->dimTableIndex, 0x10);
else if (processType == 4 && callback)
- (this->*callback)(button);
+ (*callback.get())(button);
}
-void KyraEngine_v1::processAllMenuButtons() {
- if (!_menuButtonList)
- return;
-
- Button *cur = _menuButtonList;
- while (true) {
- if (!cur->nextButton)
- break;
- processMenuButton(cur);
- cur = cur->nextButton;
- }
- return;
-}
-
-void KyraEngine_v1::processMenuButton(Button *button) {
- if (!_displayMenu)
- return;
-
- 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);
-}
-
-int KyraEngine_v1::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_v1::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;
-}
-
-void KyraEngine_v1::setGUILabels() {
+void GUI_v1::setGUILabels() {
int offset = 0;
int offsetOptions = 0;
int offsetMainMenu = 0;
@@ -387,146 +324,147 @@ void KyraEngine_v1::setGUILabels() {
int walkspeedGarbageOffset = 36;
int menuLabelGarbageOffset = 0;
- if (_flags.isTalkie) {
- if (_flags.lang == Common::EN_ANY)
+ if (_vm->gameFlags().isTalkie) {
+ if (_vm->gameFlags().lang == Common::EN_ANY)
offset = 52;
- else if (_flags.lang == Common::DE_DEU)
+ else if (_vm->gameFlags().lang == Common::DE_DEU)
offset = 30;
- else if (_flags.lang == Common::FR_FRA || _flags.lang == Common::IT_ITA)
+ else if (_vm->gameFlags().lang == Common::FR_FRA || _vm->gameFlags().lang == Common::IT_ITA)
offset = 6;
offsetOn = offsetMainMenu = offsetOptions = offset;
walkspeedGarbageOffset = 48;
- } else if (_flags.lang == Common::ES_ESP) {
+ } else if (_vm->gameFlags().lang == Common::ES_ESP) {
offsetOn = offsetMainMenu = offsetOptions = offset = -4;
menuLabelGarbageOffset = 72;
- } else if (_flags.lang == Common::DE_DEU) {
+ } else if (_vm->gameFlags().lang == Common::DE_DEU) {
offset = offsetMainMenu = offsetOn = offsetOptions = 24;
- } else if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98) {
+ } else if (_vm->gameFlags().platform == Common::kPlatformFMTowns || _vm->gameFlags().platform == Common::kPlatformPC98) {
offset = 1;
offsetOptions = 10;
offsetOn = 0;
walkspeedGarbageOffset = 0;
}
- assert(offset + 27 < _guiStringsSize);
+ assert(offset + 27 < _vm->_guiStringsSize);
// The Legend of Kyrandia
- _menu[0].menuName = _guiStrings[0];
+ _menu[0].menuNameString = _vm->_guiStrings[0];
// Load a Game
- _menu[0].item[0].itemString = _guiStrings[1];
+ _menu[0].item[0].itemString = _vm->_guiStrings[1];
// Save a Game
- _menu[0].item[1].itemString = _guiStrings[2];
+ _menu[0].item[1].itemString = _vm->_guiStrings[2];
// Game controls
- _menu[0].item[2].itemString = _guiStrings[3];
+ _menu[0].item[2].itemString = _vm->_guiStrings[3];
// Quit playing
- _menu[0].item[3].itemString = _guiStrings[4];
+ _menu[0].item[3].itemString = _vm->_guiStrings[4];
// Resume game
- _menu[0].item[4].itemString = _guiStrings[5];
+ _menu[0].item[4].itemString = _vm->_guiStrings[5];
// Cancel
- _menu[2].item[5].itemString = _guiStrings[10];
+ _menu[2].item[5].itemString = _vm->_guiStrings[10];
// Enter a description of your saved game:
- _menu[3].menuName = _guiStrings[11];
+ _menu[3].menuNameString = _vm->_guiStrings[11];
// Save
- _menu[3].item[0].itemString = _guiStrings[12];
+ _menu[3].item[0].itemString = _vm->_guiStrings[12];
// Cancel
- _menu[3].item[1].itemString = _guiStrings[10];
+ _menu[3].item[1].itemString = _vm->_guiStrings[10];
// Rest in peace, Brandon
- _menu[4].menuName = _guiStrings[13];
+ _menu[4].menuNameString = _vm->_guiStrings[13];
// Load a game
- _menu[4].item[0].itemString = _guiStrings[1];
+ _menu[4].item[0].itemString = _vm->_guiStrings[1];
// Quit playing
- _menu[4].item[1].itemString = _guiStrings[4];
+ _menu[4].item[1].itemString = _vm->_guiStrings[4];
// Game Controls
- _menu[5].menuName = _guiStrings[6];
+ _menu[5].menuNameString = _vm->_guiStrings[6];
// Yes
- _menu[1].item[0].itemString = _guiStrings[22 + offset];
+ _menu[1].item[0].itemString = _vm->_guiStrings[22 + offset];
// No
- _menu[1].item[1].itemString = _guiStrings[23 + offset];
+ _menu[1].item[1].itemString = _vm->_guiStrings[23 + offset];
// Music is
- _menu[5].item[0].labelString = _guiStrings[26 + offsetOptions];
+ _menu[5].item[0].labelString = _vm->_guiStrings[26 + offsetOptions];
// Sounds are
- _menu[5].item[1].labelString = _guiStrings[27 + offsetOptions];
+ _menu[5].item[1].labelString = _vm->_guiStrings[27 + offsetOptions];
// Walk speed
- _menu[5].item[2].labelString = &_guiStrings[24 + offsetOptions][walkspeedGarbageOffset];
+ _menu[5].item[2].labelString = &_vm->_guiStrings[24 + offsetOptions][walkspeedGarbageOffset];
// Text speed
- _menu[5].item[4].labelString = _guiStrings[25 + offsetOptions];
+ _menu[5].item[4].labelString = _vm->_guiStrings[25 + offsetOptions];
// Main Menu
- _menu[5].item[5].itemString = &_guiStrings[19 + offsetMainMenu][menuLabelGarbageOffset];
+ _menu[5].item[5].itemString = &_vm->_guiStrings[19 + offsetMainMenu][menuLabelGarbageOffset];
- if (_flags.isTalkie)
+ if (_vm->gameFlags().isTalkie)
// Text & Voice
- _voiceTextString = _guiStrings[28 + offset];
+ _voiceTextString = _vm->_guiStrings[28 + offset];
- _textSpeedString = _guiStrings[25 + offsetOptions];
- _onString = _guiStrings[20 + offsetOn];
- _offString = _guiStrings[21 + offset];
- _onCDString = _guiStrings[21];
+ _textSpeedString = _vm->_guiStrings[25 + offsetOptions];
+ _onString = _vm->_guiStrings[20 + offsetOn];
+ _offString = _vm->_guiStrings[21 + offset];
+ _onCDString = _vm->_guiStrings[21];
}
-int KyraEngine_v1::buttonMenuCallback(Button *caller) {
+int GUI_v1::buttonMenuCallback(Button *caller) {
_displayMenu = true;
- assert(_guiStrings);
- assert(_configStrings);
+ assert(_vm->_guiStrings);
+ assert(_vm->_configStrings);
/*
- for (int i = 0; i < _guiStringsSize; i++)
- debug("GUI string %i: %s", i, _guiStrings[i]);
+ for (int i = 0; i < _vm->_guiStringsSize; i++)
+ debug("GUI string %i: %s", i, _vm->_guiStrings[i]);
- for (int i = 0; i < _configStringsSize; i++)
- debug("Config string %i: %s", i, _configStrings[i]);
+ for (int i = 0; i < _vm->_configStringsSize; i++)
+ debug("Config string %i: %s", i, _vm->_configStrings[i]);
*/
setGUILabels();
- if (_currentCharacter->sceneId == 210 && _deathHandler == 0xFF) {
- snd_playSoundEffect(0x36);
+ if (_vm->_currentCharacter->sceneId == 210 && _vm->_deathHandler == 0xFF) {
+ _vm->snd_playSoundEffect(0x36);
return 0;
}
// XXX
_screen->setPaletteIndex(0xFE, 60, 60, 0);
for (int i = 0; i < 6; i++) {
- _menuButtonData[i].process0 = _menuButtonData[i].process1 = _menuButtonData[i].process2 = 4;
- _menuButtonData[i].process0PtrCallback = &KyraEngine_v1::drawShadedBoxCallback;
- _menuButtonData[i].process1PtrCallback = &KyraEngine_v1::drawBoxCallback;
- _menuButtonData[i].process2PtrCallback = &KyraEngine_v1::drawShadedBoxCallback;
+ _menuButtonData[i].data0Val1 = _menuButtonData[i].data1Val1 = _menuButtonData[i].data2Val1 = 4;
+ _menuButtonData[i].data0Callback = _redrawShadedButtonFunctor;
+ _menuButtonData[i].data1Callback = _redrawButtonFunctor;
+ _menuButtonData[i].data2Callback = _redrawButtonFunctor;
}
_screen->savePageToDisk("SEENPAGE.TMP", 0);
- gui_fadePalette();
+ fadePalette();
for (int i = 0; i < 5; i++)
- calcCoords(_menu[i]);
+ initMenuLayout(_menu[i]);
_menuRestoreScreen = true;
_keyPressed.reset();
- _mousePressFlag = false;
+ _vm->_mousePressFlag = false;
_toplevelMenu = 0;
- if (_menuDirectlyToLoad) {
- gui_loadGameMenu(0);
+ if (_vm->_menuDirectlyToLoad) {
+ loadGameMenu(0);
} else {
if (!caller)
_toplevelMenu = 4;
initMenu(_menu[_toplevelMenu]);
- processAllMenuButtons();
+ updateAllMenuButtons();
}
- while (_displayMenu && !_quitFlag) {
- gui_processHighlights(_menu[_toplevelMenu]);
- processButtonList(_menuButtonList);
- gui_getInput();
+ while (_displayMenu && !_vm->_quitFlag) {
+ Common::Point mouse = _vm->getMousePos();
+ processHighlights(_menu[_toplevelMenu], mouse.x, mouse.y);
+ processButtonList(_menuButtonList, 0);
+ getInput();
}
if (_menuRestoreScreen) {
- gui_restorePalette();
+ restorePalette();
_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
- _animator->_updateScreen = true;
+ _vm->_animator->_updateScreen = true;
} else {
_screen->deletePageFromDisk(0);
}
@@ -534,106 +472,7 @@ int KyraEngine_v1::buttonMenuCallback(Button *caller) {
return 0;
}
-void KyraEngine_v1::initMenu(Menu &menu) {
- _menuButtonList = 0;
-
- _screen->hideMouse();
-
- int textX;
- int textY;
-
- int menu_x2 = menu.width + menu.x - 1;
- int menu_y2 = menu.height + menu.y - 1;
-
- _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);
-
- 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 = x1 + menu.item[i].width - 1;
- y2 = y1 + 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].saveSlot;
- //_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].itemString) {
- if (menu.item[i].field_12 != -1 && _flags.lang == Common::EN_ANY)
- 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.highlightedItem)
- _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].labelX - 1, menu.y + menu.item[i].labelY + 1, 12, 0, 0);
- _text->printText(menu.item[i].labelString, menu.x + menu.item[i].labelX, menu.y + menu.item[i].labelY, 253, 0, 0);
- }
- }
- }
-
- if (menu.scrollUpBtnX != -1) {
- _haveScrollButtons = true;
-
- _scrollUpButton.x = menu.scrollUpBtnX + menu.x;
- _scrollUpButton.y = menu.scrollUpBtnY + menu.y;
- _scrollUpButton.buttonCallback = &KyraEngine_v1::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_v1::gui_scrollDown;
- _scrollDownButton.nextButton = 0;
- _menuButtonList = initButton(_menuButtonList, &_scrollDownButton);
- processMenuButton(&_scrollDownButton);
- } else {
- _haveScrollButtons = false;
- }
-
- _screen->showMouse();
- _screen->updateScreen();
-}
-
-void KyraEngine_v1::calcCoords(Menu &menu) {
+/*void KyraEngine_v1::initMenuLayout(Menu &menu) {
assert(menu.nrOfItems < 7);
int widthBackup = _screen->_charWidth;
@@ -688,10 +527,10 @@ void KyraEngine_v1::calcCoords(Menu &menu) {
menu.width += maxOffset;
}
- if (menu.menuName != 0) {
- int menuNameLength = _screen->getTextWidth(menu.menuName);
- if (menuNameLength > menu.width)
- menu.width = menuNameLength;
+ if (menu.menuNameString != 0) {
+ int menuNameStringLength = _screen->getTextWidth(menu.menuNameString);
+ if (menuNameStringLength > menu.width)
+ menu.width = menuNameStringLength;
}
if (menu.width > 310)
@@ -703,27 +542,27 @@ void KyraEngine_v1::calcCoords(Menu &menu) {
menu.y = (200 - menu.height)/2;
_screen->_charWidth = widthBackup;
-}
+}*/
-void KyraEngine_v1::gui_getInput() {
+void GUI_v1::getInput() {
Common::Event event;
static uint32 lastScreenUpdate = 0;
- uint32 now = _system->getMillis();
+ uint32 now = _vm->_system->getMillis();
_mouseWheel = 0;
- while (_eventMan->pollEvent(event)) {
+ while (_vm->_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_QUIT:
- quitGame();
+ _vm->quitGame();
break;
case Common::EVENT_LBUTTONDOWN:
- _mousePressFlag = true;
+ _vm->_mousePressFlag = true;
break;
case Common::EVENT_LBUTTONUP:
- _mousePressFlag = false;
+ _vm->_mousePressFlag = false;
break;
case Common::EVENT_MOUSEMOVE:
- _system->updateScreen();
+ _vm->_system->updateScreen();
lastScreenUpdate = now;
break;
case Common::EVENT_WHEELUP:
@@ -741,35 +580,35 @@ void KyraEngine_v1::gui_getInput() {
}
if (now - lastScreenUpdate > 50) {
- _system->updateScreen();
+ _vm->_system->updateScreen();
lastScreenUpdate = now;
}
- _system->delayMillis(3);
+ _vm->_system->delayMillis(3);
}
-int KyraEngine_v1::gui_resumeGame(Button *button) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_resumeGame()");
- processMenuButton(button);
+int GUI_v1::resumeGame(Button *button) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::resumeGame()");
+ updateMenuButton(button);
_displayMenu = false;
return 0;
}
-int KyraEngine_v1::getNextSavegameSlot() {
+int GUI_v1::getNextSavegameSlot() {
Common::InSaveFile *in;
for (int i = 1; i < 1000; i++) {
- if ((in = _saveFileMan->openForLoading(getSavegameFilename(i))))
+ if ((in = _vm->_saveFileMan->openForLoading(_vm->getSavegameFilename(i))))
delete in;
else
return i;
}
- warning("Didn't save: Ran out of savegame filenames");
+ warning("Didn't save: Ran out of saveGame filenames");
return 0;
}
-void KyraEngine_v1::setupSavegames(Menu &menu, int num) {
+void GUI_v1::setupSavegames(Menu &menu, int num) {
Common::InSaveFile *in;
static char savenames[5][31];
uint8 startSlot;
@@ -785,7 +624,7 @@ void KyraEngine_v1::setupSavegames(Menu &menu, int num) {
}
for (int i = startSlot; i < num; i++) {
- if ((in = _saveFileMan->openForLoading(getSavegameFilename(i + _savegameOffset)))) {
+ if ((in = _vm->_saveFileMan->openForLoading(_vm->getSavegameFilename(i + _savegameOffset)))) {
in->skip(8);
in->read(savenames[i], 31);
menu.item[i].itemString = savenames[i];
@@ -800,32 +639,33 @@ void KyraEngine_v1::setupSavegames(Menu &menu, int num) {
}
}
-int KyraEngine_v1::gui_saveGameMenu(Button *button) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_saveGameMenu()");
- processMenuButton(button);
+int GUI_v1::saveGameMenu(Button *button) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::saveGameMenu()");
+ updateMenuButton(button);
_menu[2].item[5].enabled = true;
_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
_screen->savePageToDisk("SEENPAGE.TMP", 0);
- _menu[2].menuName = _guiStrings[8]; // Select a position to save to:
- _specialSavegameString = _guiStrings[9]; // [ EMPTY SLOT ]
+ _menu[2].menuNameString = _vm->_guiStrings[8]; // Select a position to save to:
+ _specialSavegameString = _vm->_guiStrings[9]; // [ EMPTY SLOT ]
for (int i = 0; i < 5; i++)
- _menu[2].item[i].callback = &KyraEngine_v1::gui_saveGame;
+ _menu[2].item[i].callback = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::saveGame);
_savegameOffset = 0;
setupSavegames(_menu[2], 5);
initMenu(_menu[2]);
- processAllMenuButtons();
+ updateAllMenuButtons();
_displaySubMenu = true;
_cancelSubMenu = false;
- while (_displaySubMenu && !_quitFlag) {
- gui_getInput();
- gui_processHighlights(_menu[2]);
- processButtonList(_menuButtonList);
+ while (_displaySubMenu && !_vm->_quitFlag) {
+ getInput();
+ Common::Point mouse = _vm->getMousePos();
+ processHighlights(_menu[2], mouse.x, mouse.y);
+ processButtonList(_menuButtonList, 0);
}
_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
@@ -833,43 +673,44 @@ int KyraEngine_v1::gui_saveGameMenu(Button *button) {
if (_cancelSubMenu) {
initMenu(_menu[0]);
- processAllMenuButtons();
+ updateAllMenuButtons();
} else {
_displayMenu = false;
}
return 0;
}
-int KyraEngine_v1::gui_loadGameMenu(Button *button) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_loadGameMenu()");
- if (_menuDirectlyToLoad) {
+int GUI_v1::loadGameMenu(Button *button) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::loadGameMenu()");
+ if (_vm->_menuDirectlyToLoad) {
_menu[2].item[5].enabled = false;
} else {
- processMenuButton(button);
+ updateMenuButton(button);
_menu[2].item[5].enabled = true;
}
_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
_screen->savePageToDisk("SEENPAGE.TMP", 0);
- _specialSavegameString = _newGameString[0]; //[ START A NEW GAME ]
- _menu[2].menuName = _guiStrings[7]; // Which game would you like to reload?
+ _specialSavegameString = _vm->_newGameString[0]; //[ START A NEW GAME ]
+ _menu[2].menuNameString = _vm->_guiStrings[7]; // Which game would you like to reload?
for (int i = 0; i < 5; i++)
- _menu[2].item[i].callback = &KyraEngine_v1::gui_loadGame;
+ _menu[2].item[i].callback = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::loadGame);
_savegameOffset = 0;
setupSavegames(_menu[2], 5);
initMenu(_menu[2]);
- processAllMenuButtons();
+ updateAllMenuButtons();
_displaySubMenu = true;
_cancelSubMenu = false;
- while (_displaySubMenu && !_quitFlag) {
- gui_getInput();
- gui_processHighlights(_menu[2]);
- processButtonList(_menuButtonList);
+ while (_displaySubMenu && !_vm->_quitFlag) {
+ getInput();
+ Common::Point mouse = _vm->getMousePos();
+ processHighlights(_menu[2], mouse.x, mouse.y);
+ processButtonList(_menuButtonList, 0);
}
_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
@@ -877,17 +718,17 @@ int KyraEngine_v1::gui_loadGameMenu(Button *button) {
if (_cancelSubMenu) {
initMenu(_menu[_toplevelMenu]);
- processAllMenuButtons();
+ updateAllMenuButtons();
} else {
- gui_restorePalette();
- loadGame(getSavegameFilename(_gameToLoad));
+ restorePalette();
+ _vm->loadGame(_vm->getSavegameFilename(_vm->_gameToLoad));
_displayMenu = false;
_menuRestoreScreen = false;
}
return 0;
}
-void KyraEngine_v1::gui_redrawTextfield() {
+void GUI_v1::redrawTextfield() {
_screen->fillRect(38, 91, 287, 102, 250);
_text->printText(_savegameName, 38, 92, 253, 0, 0);
@@ -899,7 +740,7 @@ void KyraEngine_v1::gui_redrawTextfield() {
_screen->updateScreen();
}
-void KyraEngine_v1::gui_updateSavegameString() {
+void GUI_v1::updateSavegameString() {
int length;
if (_keyPressed.keycode) {
@@ -909,13 +750,13 @@ void KyraEngine_v1::gui_updateSavegameString() {
if (length < 31) {
_savegameName[length] = _keyPressed.ascii;
_savegameName[length+1] = 0;
- gui_redrawTextfield();
+ redrawTextfield();
}
} else if (_keyPressed.keycode == Common::KEYCODE_BACKSPACE ||
_keyPressed.keycode == Common::KEYCODE_DELETE) {
if (length > 0) {
_savegameName[length-1] = 0;
- gui_redrawTextfield();
+ redrawTextfield();
}
} else if (_keyPressed.keycode == Common::KEYCODE_RETURN ||
_keyPressed.keycode == Common::KEYCODE_KP_ENTER) {
@@ -926,111 +767,113 @@ void KyraEngine_v1::gui_updateSavegameString() {
_keyPressed.reset();
}
-int KyraEngine_v1::gui_saveGame(Button *button) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_saveGame()");
- processMenuButton(button);
- _gameToLoad = button->specialValue;
+int GUI_v1::saveGame(Button *button) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::saveGame()");
+ updateMenuButton(button);
+ _vm->_gameToLoad = button->index;
_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
_screen->savePageToDisk("SEENPAGE.TMP", 0);
initMenu(_menu[3]);
- processAllMenuButtons();
+ updateAllMenuButtons();
_displaySubMenu = true;
_cancelSubMenu = false;
- if (_savegameOffset == 0 && _gameToLoad == 0) {
+ if (_savegameOffset == 0 && _vm->_gameToLoad == 0) {
_savegameName[0] = 0;
} else {
for (int i = 0; i < 5; i++) {
- if (_menu[2].item[i].saveSlot == _gameToLoad) {
+ if (_menu[2].item[i].saveSlot == _vm->_gameToLoad) {
strncpy(_savegameName, _menu[2].item[i].itemString, 31);
break;
}
}
}
- gui_redrawTextfield();
-
- while (_displaySubMenu && !_quitFlag) {
- gui_getInput();
- gui_updateSavegameString();
- gui_processHighlights(_menu[3]);
- processButtonList(_menuButtonList);
+ redrawTextfield();
+
+ while (_displaySubMenu && !_vm->_quitFlag) {
+ getInput();
+ updateSavegameString();
+ Common::Point mouse = _vm->getMousePos();
+ processHighlights(_menu[3], mouse.x, mouse.y);
+ processButtonList(_menuButtonList, 0);
}
if (_cancelSubMenu) {
_displaySubMenu = true;
_cancelSubMenu = false;
initMenu(_menu[2]);
- processAllMenuButtons();
+ updateAllMenuButtons();
} else {
- if (_savegameOffset == 0 && _gameToLoad == 0)
- _gameToLoad = getNextSavegameSlot();
- if (_gameToLoad > 0)
- saveGame(getSavegameFilename(_gameToLoad), _savegameName);
+ if (_savegameOffset == 0 && _vm->_gameToLoad == 0)
+ _vm->_gameToLoad = getNextSavegameSlot();
+ if (_vm->_gameToLoad > 0)
+ _vm->saveGame(_vm->getSavegameFilename(_vm->_gameToLoad), _savegameName);
}
return 0;
}
-int KyraEngine_v1::gui_savegameConfirm(Button *button) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_savegameConfirm()");
- processMenuButton(button);
+int GUI_v1::savegameConfirm(Button *button) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::savegameConfirm()");
+ updateMenuButton(button);
_displaySubMenu = false;
return 0;
}
-int KyraEngine_v1::gui_loadGame(Button *button) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_loadGame()");
- processMenuButton(button);
+int GUI_v1::loadGame(Button *button) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::loadGame()");
+ updateMenuButton(button);
_displaySubMenu = false;
- _gameToLoad = button->specialValue;
+ _vm->_gameToLoad = button->index;
return 0;
}
-int KyraEngine_v1::gui_cancelSubMenu(Button *button) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_cancelLoadGameMenu()");
- processMenuButton(button);
+int GUI_v1::cancelSubMenu(Button *button) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::cancelSubMenu()");
+ updateMenuButton(button);
_displaySubMenu = false;
_cancelSubMenu = true;
return 0;
}
-int KyraEngine_v1::gui_quitPlaying(Button *button) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_quitPlaying()");
- processMenuButton(button);
+int GUI_v1::quitPlaying(Button *button) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::quitPlaying()");
+ updateMenuButton(button);
- if (gui_quitConfirm(_guiStrings[14])) { // Are you sure you want to quit playing?
- quitGame();
+ if (quitConfirm(_vm->_guiStrings[14])) { // Are you sure you want to quit playing?
+ _vm->quitGame();
} else {
initMenu(_menu[_toplevelMenu]);
- processAllMenuButtons();
+ updateAllMenuButtons();
}
return 0;
}
-bool KyraEngine_v1::gui_quitConfirm(const char *str) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_quitConfirm()");
+bool GUI_v1::quitConfirm(const char *str) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::quitConfirm()");
_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
_screen->savePageToDisk("SEENPAGE.TMP", 0);
- _menu[1].menuName = str;
- calcCoords(_menu[1]);
+ _menu[1].menuNameString = str;
+ initMenuLayout(_menu[1]);
initMenu(_menu[1]);
_displaySubMenu = true;
_cancelSubMenu = true;
- while (_displaySubMenu && !_quitFlag) {
- gui_getInput();
- gui_processHighlights(_menu[1]);
- processButtonList(_menuButtonList);
+ while (_displaySubMenu && !_vm->_quitFlag) {
+ getInput();
+ Common::Point mouse = _vm->getMousePos();
+ processHighlights(_menu[1], mouse.x, mouse.y);
+ processButtonList(_menuButtonList, 0);
}
_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
@@ -1039,33 +882,33 @@ bool KyraEngine_v1::gui_quitConfirm(const char *str) {
return !_cancelSubMenu;
}
-int KyraEngine_v1::gui_quitConfirmYes(Button *button) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_quitConfirmYes()");
- processMenuButton(button);
+int GUI_v1::quitConfirmYes(Button *button) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::quitConfirmYes()");
+ updateMenuButton(button);
_displaySubMenu = false;
_cancelSubMenu = false;
return 0;
}
-int KyraEngine_v1::gui_quitConfirmNo(Button *button) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_quitConfirmNo()");
- processMenuButton(button);
+int GUI_v1::quitConfirmNo(Button *button) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::quitConfirmNo()");
+ updateMenuButton(button);
_displaySubMenu = false;
_cancelSubMenu = true;
return 0;
}
-int KyraEngine_v1::gui_gameControlsMenu(Button *button) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_gameControlsMenu()");
+int GUI_v1::gameControlsMenu(Button *button) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::gameControlsMenu()");
- readSettings();
+ _vm->readSettings();
_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
_screen->savePageToDisk("SEENPAGE.TMP", 0);
- if (_flags.isTalkie) {
+ if (_vm->gameFlags().isTalkie) {
//_menu[5].width = 230;
for (int i = 0; i < 5; i++) {
@@ -1075,27 +918,28 @@ int KyraEngine_v1::gui_gameControlsMenu(Button *button) {
}
_menu[5].item[3].labelString = _voiceTextString; //"Voice / Text "
- _menu[5].item[3].callback = &KyraEngine_v1::gui_controlsChangeVoice;
+ _menu[5].item[3].callback = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::controlsChangeVoice);
} else {
//_menu[5].height = 136;
//_menu[5].item[5].y = 110;
_menu[5].item[4].enabled = 0;
_menu[5].item[3].labelString = _textSpeedString; // "Text speed "
- _menu[5].item[3].callback = &KyraEngine_v1::gui_controlsChangeText;
+ _menu[5].item[3].callback = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::controlsChangeText);
}
- gui_setupControls(_menu[5]);
+ setupControls(_menu[5]);
- processAllMenuButtons();
+ updateAllMenuButtons();
_displaySubMenu = true;
_cancelSubMenu = false;
- while (_displaySubMenu && !_quitFlag) {
- gui_getInput();
- gui_processHighlights(_menu[5]);
- processButtonList(_menuButtonList);
+ while (_displaySubMenu && !_vm->_quitFlag) {
+ getInput();
+ Common::Point mouse = _vm->getMousePos();
+ processHighlights(_menu[5], mouse.x, mouse.y);
+ processButtonList(_menuButtonList, 0);
}
_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
@@ -1103,15 +947,15 @@ int KyraEngine_v1::gui_gameControlsMenu(Button *button) {
if (_cancelSubMenu) {
initMenu(_menu[_toplevelMenu]);
- processAllMenuButtons();
+ updateAllMenuButtons();
}
return 0;
}
-void KyraEngine_v1::gui_setupControls(Menu &menu) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_setupControls()");
+void GUI_v1::setupControls(Menu &menu) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::setupControls()");
- switch (_configMusic) {
+ switch (_vm->_configMusic) {
case 0:
menu.item[0].itemString = _offString; //"Off"
break;
@@ -1123,27 +967,27 @@ void KyraEngine_v1::gui_setupControls(Menu &menu) {
break;
}
- if (_configSounds)
+ if (_vm->_configSounds)
menu.item[1].itemString = _onString; //"On"
else
menu.item[1].itemString = _offString; //"Off"
- switch (_configWalkspeed) {
+ switch (_vm->_configWalkspeed) {
case 0:
- menu.item[2].itemString = _configStrings[0]; //"Slowest"
+ menu.item[2].itemString = _vm->_configStrings[0]; //"Slowest"
break;
case 1:
- menu.item[2].itemString = _configStrings[1]; //"Slow"
+ menu.item[2].itemString = _vm->_configStrings[1]; //"Slow"
break;
case 2:
- menu.item[2].itemString = _configStrings[2]; //"Normal"
+ menu.item[2].itemString = _vm->_configStrings[2]; //"Normal"
break;
case 3:
- menu.item[2].itemString = _configStrings[3]; //"Fast"
+ menu.item[2].itemString = _vm->_configStrings[3]; //"Fast"
break;
case 4:
- menu.item[2].itemString = _configStrings[4]; //"Fastest"
+ menu.item[2].itemString = _vm->_configStrings[4]; //"Fastest"
break;
default:
menu.item[2].itemString = "ERROR";
@@ -1152,24 +996,24 @@ void KyraEngine_v1::gui_setupControls(Menu &menu) {
int textControl = 3;
int clickableOffset = 8;
- if (_flags.isTalkie) {
+ if (_vm->gameFlags().isTalkie) {
textControl = 4;
clickableOffset = 11;
- if (_configVoice == 0)
+ if (_vm->_configVoice == 0)
_menu[5].item[4].enabled = 1;
else
_menu[5].item[4].enabled = 0;
- switch (_configVoice) {
+ switch (_vm->_configVoice) {
case 0:
- menu.item[3].itemString = _configStrings[5]; //"Text only"
+ menu.item[3].itemString = _vm->_configStrings[5]; //"Text only"
break;
case 1:
- menu.item[3].itemString = _configStrings[6]; //"Voice only"
+ menu.item[3].itemString = _vm->_configStrings[6]; //"Voice only"
break;
case 2:
- menu.item[3].itemString = _configStrings[7]; //"Voice & Text"
+ menu.item[3].itemString = _vm->_configStrings[7]; //"Voice & Text"
break;
default:
menu.item[3].itemString = "ERROR";
@@ -1177,83 +1021,83 @@ void KyraEngine_v1::gui_setupControls(Menu &menu) {
}
}
- switch (_configTextspeed) {
+ switch (_vm->_configTextspeed) {
case 0:
- menu.item[textControl].itemString = _configStrings[1]; //"Slow"
+ menu.item[textControl].itemString = _vm->_configStrings[1]; //"Slow"
break;
case 1:
- menu.item[textControl].itemString = _configStrings[2]; //"Normal"
+ menu.item[textControl].itemString = _vm->_configStrings[2]; //"Normal"
break;
case 2:
- menu.item[textControl].itemString = _configStrings[3]; //"Fast"
+ menu.item[textControl].itemString = _vm->_configStrings[3]; //"Fast"
break;
case 3:
- menu.item[textControl].itemString = _configStrings[clickableOffset]; //"Clickable"
+ menu.item[textControl].itemString = _vm->_configStrings[clickableOffset]; //"Clickable"
break;
default:
menu.item[textControl].itemString = "ERROR";
break;
}
- calcCoords(menu);
+ initMenuLayout(menu);
initMenu(menu);
}
-int KyraEngine_v1::gui_controlsChangeMusic(Button *button) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_controlsChangeMusic()");
- processMenuButton(button);
+int GUI_v1::controlsChangeMusic(Button *button) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::controlsChangeMusic()");
+ updateMenuButton(button);
- _configMusic = ++_configMusic % ((_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98) ? 3 : 2);
- gui_setupControls(_menu[5]);
+ _vm->_configMusic = ++_vm->_configMusic % ((_vm->gameFlags().platform == Common::kPlatformFMTowns || _vm->gameFlags().platform == Common::kPlatformPC98) ? 3 : 2);
+ setupControls(_menu[5]);
return 0;
}
-int KyraEngine_v1::gui_controlsChangeSounds(Button *button) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_controlsChangeSounds()");
- processMenuButton(button);
+int GUI_v1::controlsChangeSounds(Button *button) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::controlsChangeSounds()");
+ updateMenuButton(button);
- _configSounds = !_configSounds;
- gui_setupControls(_menu[5]);
+ _vm->_configSounds = !_vm->_configSounds;
+ setupControls(_menu[5]);
return 0;
}
-int KyraEngine_v1::gui_controlsChangeWalk(Button *button) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_controlsChangeWalk()");
- processMenuButton(button);
+int GUI_v1::controlsChangeWalk(Button *button) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::controlsChangeWalk()");
+ updateMenuButton(button);
- _configWalkspeed = ++_configWalkspeed % 5;
- setWalkspeed(_configWalkspeed);
- gui_setupControls(_menu[5]);
+ _vm->_configWalkspeed = ++_vm->_configWalkspeed % 5;
+ _vm->setWalkspeed(_vm->_configWalkspeed);
+ setupControls(_menu[5]);
return 0;
}
-int KyraEngine_v1::gui_controlsChangeText(Button *button) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_controlsChangeText()");
- processMenuButton(button);
+int GUI_v1::controlsChangeText(Button *button) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::controlsChangeText()");
+ updateMenuButton(button);
- _configTextspeed = ++_configTextspeed % 4;
- gui_setupControls(_menu[5]);
+ _vm->_configTextspeed = ++_vm->_configTextspeed % 4;
+ setupControls(_menu[5]);
return 0;
}
-int KyraEngine_v1::gui_controlsChangeVoice(Button *button) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_controlsChangeVoice()");
- processMenuButton(button);
+int GUI_v1::controlsChangeVoice(Button *button) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::controlsChangeVoice()");
+ updateMenuButton(button);
- _configVoice = ++_configVoice % 3;
- gui_setupControls(_menu[5]);
+ _vm->_configVoice = ++_vm->_configVoice % 3;
+ setupControls(_menu[5]);
return 0;
}
-int KyraEngine_v1::gui_controlsApply(Button *button) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_controlsApply()");
- writeSettings();
- return gui_cancelSubMenu(button);
+int GUI_v1::controlsApply(Button *button) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::controlsApply()");
+ _vm->writeSettings();
+ return cancelSubMenu(button);
}
-int KyraEngine_v1::gui_scrollUp(Button *button) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_scrollUp()");
- processMenuButton(button);
+int GUI_v1::scrollUp(Button *button) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::scrollUp()");
+ updateMenuButton(button);
if (_savegameOffset > 0) {
_savegameOffset--;
@@ -1263,9 +1107,9 @@ int KyraEngine_v1::gui_scrollUp(Button *button) {
return 0;
}
-int KyraEngine_v1::gui_scrollDown(Button *button) {
- debugC(9, kDebugLevelGUI, "KyraEngine_v1::gui_scrollDown()");
- processMenuButton(button);
+int GUI_v1::scrollDown(Button *button) {
+ debugC(9, kDebugLevelGUI, "GUI_v1::scrollDown()");
+ updateMenuButton(button);
_savegameOffset++;
setupSavegames(_menu[2], 5);
@@ -1274,75 +1118,8 @@ int KyraEngine_v1::gui_scrollDown(Button *button) {
return 0;
}
-void KyraEngine_v1::gui_processHighlights(Menu &menu) {
- int x1, y1, x2, y2;
-
- Common::Point mouse = getMousePos();
- 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 = x1 + menu.item[i].width;
- y2 = y1 + menu.item[i].height;
-
- if (mouse.x > x1 && mouse.x < x2 &&
- mouse.y > y1 && mouse.y < y2) {
-
- if (menu.highlightedItem != i) {
- if (menu.item[menu.highlightedItem].enabled )
- gui_redrawText(menu);
-
- menu.highlightedItem = i;
- gui_redrawHighlight(menu);
- _screen->updateScreen();
- }
- }
- }
-}
-
-void KyraEngine_v1::gui_redrawText(Menu menu) {
- int textX;
- int i = menu.highlightedItem;
-
- int x1 = menu.x + menu.item[i].x;
- int y1 = menu.y + menu.item[i].y;
-
- int x2 = x1 + menu.item[i].width - 1;
-
- if (menu.item[i].field_12 != -1 &&_flags.lang == Common::EN_ANY)
- textX = x1 + menu.item[i].field_12 + 3;
- else
- textX = _text->getCenterStringX(menu.item[i].itemString, x1, x2);
-
- int textY = y1 + 2;
- _text->printText(menu.item[i].itemString, textX - 1, textY + 1, 12, 0, 0);
- _text->printText(menu.item[i].itemString, textX, textY, menu.item[i].textColor, 0, 0);
-}
-
-void KyraEngine_v1::gui_redrawHighlight(Menu menu) {
- int textX;
- int i = menu.highlightedItem;
-
- int x1 = menu.x + menu.item[i].x;
- int y1 = menu.y + menu.item[i].y;
-
- int x2 = x1 + menu.item[i].width - 1;
-
- if (menu.item[i].field_12 != -1 &&_flags.lang == Common::EN_ANY)
- textX = x1 + menu.item[i].field_12 + 3;
- else
- textX = _text->getCenterStringX(menu.item[i].itemString, x1, x2);
-
- int textY = y1 + 2;
- _text->printText(menu.item[i].itemString, textX - 1, textY + 1, 12, 0, 0);
- _text->printText(menu.item[i].itemString, textX, textY, menu.item[i].highlightColor, 0, 0);
-}
-
-void KyraEngine_v1::gui_fadePalette() {
- if (_flags.platform == Common::kPlatformAmiga)
+void GUI_v1::fadePalette() {
+ if (_vm->gameFlags().platform == Common::kPlatformAmiga)
return;
static int16 menuPalIndexes[] = {248, 249, 250, 251, 252, 253, 254, -1};
@@ -1361,8 +1138,8 @@ void KyraEngine_v1::gui_fadePalette() {
_screen->fadePalette(_screen->_currentPalette, 2);
}
-void KyraEngine_v1::gui_restorePalette() {
- if (_flags.platform == Common::kPlatformAmiga)
+void GUI_v1::restorePalette() {
+ if (_vm->gameFlags().platform == Common::kPlatformAmiga)
return;
memcpy(_screen->_currentPalette, _screen->getPalette(2), 768);
diff --git a/engines/kyra/gui_v1.h b/engines/kyra/gui_v1.h
new file mode 100644
index 0000000000..b4376a14f3
--- /dev/null
+++ b/engines/kyra/gui_v1.h
@@ -0,0 +1,176 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef KYRA_GUI_V1_H
+#define KYRA_GUI_V1_H
+
+#include "kyra/gui.h"
+
+namespace Kyra {
+
+#define GUI_V1_BUTTON(button, a, b, c, d, e, f, g, h, i, j, k) \
+ button.nextButton = 0; \
+ button.index = a; \
+ button.unk6 = button.unk8 = 0; \
+ button.data0Val1 = b; \
+ button.data1Val1 = c; \
+ button.data2Val1 = d; \
+ button.data0ShapePtr = button.data1ShapePtr = button.data2ShapePtr = 0; \
+ button.flags = e; \
+ button.dimTableIndex = f; \
+ button.x = g; \
+ button.y = h; \
+ button.width = i; \
+ button.height = j; \
+ button.flags2 = k
+
+#define GUI_V1_MENU(menu, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) \
+ menu.x = a; \
+ menu.y = b; \
+ menu.width = c; \
+ menu.height = d; \
+ menu.bkgdColor = e; \
+ menu.color1 = f; \
+ menu.color2 = g; \
+ menu.menuNameString = h; \
+ menu.textColor = i; \
+ menu.titleX = j; \
+ menu.titleY = k; \
+ menu.highlightedItem = l; \
+ menu.numberOfItems = m; \
+ menu.scrollUpButtonX = n; \
+ menu.scrollUpButtonY = o; \
+ menu.scrollDownButtonX = p; \
+ menu.scrollDownButtonY = q
+
+#define GUI_V1_MENU_ITEM(item, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v) \
+ item.enabled = a; \
+ item.itemString = d; \
+ item.x = e; \
+ item.y = g; \
+ item.width = h; \
+ item.height = i; \
+ item.textColor = j; \
+ item.highlightColor = k; \
+ item.titleX = l; \
+ item.bkgdColor = n; \
+ item.color1 = o; \
+ item.color2 = p; \
+ item.saveSlot = q; \
+ item.labelString = r; \
+ item.labelX = s; \
+ item.labelY = t; \
+ item.unk1F = v
+
+class KyraEngine_v1;
+
+class GUI_v1 : public GUI {
+ friend class KyraEngine_v1;
+public:
+ GUI_v1(KyraEngine_v1 *vm);
+ ~GUI_v1();
+
+ void processButton(Button *button);
+ int processButtonList(Button *buttonList, uint16 inputFlags);
+
+ int buttonMenuCallback(Button *caller);
+private:
+ void initStaticResource();
+
+ Button _menuButtonData[6];
+ Button _scrollUpButton;
+ Button _scrollDownButton;
+ Button *getButtonListData() { return _menuButtonData; }
+ Button *getScrollUpButton() { return &_scrollUpButton; }
+ Button *getScrollDownButton() { return &_scrollDownButton; }
+
+ Menu *_menu;
+
+ void setGUILabels();
+
+ void setupSavegames(Menu &menu, int num);
+ int getNextSavegameSlot();
+
+ int resumeGame(Button *button);
+ int loadGameMenu(Button *button);
+ int saveGameMenu(Button *button);
+ int gameControlsMenu(Button *button);
+ int quitPlaying(Button *button);
+ int quitConfirmYes(Button *button);
+ int quitConfirmNo(Button *button);
+ int loadGame(Button *button);
+ int saveGame(Button *button);
+ int savegameConfirm(Button *button);
+ int cancelSubMenu(Button *button);
+ int scrollUp(Button *button);
+ int scrollDown(Button *button);
+ int controlsChangeMusic(Button *button);
+ int controlsChangeSounds(Button *button);
+ int controlsChangeWalk(Button *button);
+ int controlsChangeText(Button *button);
+ int controlsChangeVoice(Button *button);
+ int controlsApply(Button *button);
+
+ bool quitConfirm(const char *str);
+ void getInput();
+ void updateSavegameString();
+ void redrawTextfield();
+ void fadePalette();
+ void restorePalette();
+ void setupControls(Menu &menu);
+
+ uint8 defaultColor1() const { return 12; }
+ uint8 defaultColor2() const { return 248; }
+
+ const char *getMenuTitle(const Menu &menu) { return menu.menuNameString; }
+ const char *getMenuItemTitle(const MenuItem &menuItem) { return menuItem.itemString; }
+ const char *getMenuItemLabel(const MenuItem &menuItem) { return menuItem.labelString; }
+
+ KyraEngine_v1 *_vm;
+
+ bool _menuRestoreScreen;
+ uint8 _toplevelMenu;
+ int _savegameOffset;
+ char _savegameName[31];
+ const char *_specialSavegameString;
+ Common::KeyState _keyPressed;
+ int8 _mouseWheel;
+
+ Button::Callback _scrollUpFunctor;
+ Button::Callback _scrollDownFunctor;
+ Button::Callback getScrollUpButtonHandler() const { return _scrollUpFunctor; }
+ Button::Callback getScrollDownButtonHandler() const { return _scrollDownFunctor; }
+
+ const char *_voiceTextString;
+ const char *_textSpeedString;
+ const char *_onString;
+ const char *_offString;
+ const char *_onCDString;
+};
+
+} // end of namespace Kyra
+
+#endif
+
diff --git a/engines/kyra/kyra_v1.cpp b/engines/kyra/kyra_v1.cpp
index 08fdd117cc..39df3bbcc6 100644
--- a/engines/kyra/kyra_v1.cpp
+++ b/engines/kyra/kyra_v1.cpp
@@ -88,14 +88,14 @@ KyraEngine_v1::KyraEngine_v1(OSystem *system, const GameFlags &flags)
_scriptClick = 0;
_characterList = 0;
_movFacingTable = 0;
+ _buttonData = 0;
+ _buttonDataListPtr = 0;
memset(_shapes, 0, sizeof(_shapes));
memset(_movieObjects, 0, sizeof(_movieObjects));
_finalA = _finalB = _finalC = 0;
_endSequenceBackUpRect = 0;
memset(_panPagesTable, 0, sizeof(_panPagesTable));
_npcScriptData = _scriptClickData = 0;
- _scrollUpButton.process0PtrShape = _scrollUpButton.process1PtrShape = _scrollUpButton.process2PtrShape = 0;
- _scrollDownButton.process0PtrShape = _scrollDownButton.process1PtrShape = _scrollDownButton.process2PtrShape = 0;
memset(_sceneAnimTable, 0, sizeof(_sceneAnimTable));
_currHeadShape = 0;
@@ -134,12 +134,17 @@ KyraEngine_v1::~KyraEngine_v1() {
delete [] _movFacingTable;
- delete [] _scrollUpButton.process0PtrShape;
- delete [] _scrollUpButton.process1PtrShape;
- delete [] _scrollUpButton.process2PtrShape;
- delete [] _scrollDownButton.process0PtrShape;
- delete [] _scrollDownButton.process1PtrShape;
- delete [] _scrollDownButton.process2PtrShape;
+ delete [] _gui->_scrollUpButton.data0ShapePtr;
+ delete [] _gui->_scrollUpButton.data1ShapePtr;
+ delete [] _gui->_scrollUpButton.data2ShapePtr;
+ delete [] _gui->_scrollDownButton.data0ShapePtr;
+ delete [] _gui->_scrollDownButton.data1ShapePtr;
+ delete [] _gui->_scrollDownButton.data2ShapePtr;
+
+ delete [] _buttonData;
+ delete [] _buttonDataListPtr;
+
+ delete _gui;
delete [] _itemBkgBackUp[0];
delete [] _itemBkgBackUp[1];
@@ -178,6 +183,8 @@ int KyraEngine_v1::init() {
assert(*_animator);
_text = new TextDisplayer(this, screen());
assert(_text);
+ _gui = new GUI_v1(this);
+ assert(_gui);
initStaticResource();
@@ -193,7 +200,6 @@ int KyraEngine_v1::init() {
_sound->loadSoundFile(0);
setupButtonData();
- setupMenu();
_paletteChanged = 1;
_currentCharacter = 0;
@@ -407,7 +413,7 @@ void KyraEngine_v1::startup() {
_menuDirectlyToLoad = true;
_screen->setMouseCursor(1, 1, _shapes[0]);
_screen->showMouse();
- buttonMenuCallback(0);
+ _gui->buttonMenuCallback(0);
_menuDirectlyToLoad = false;
} else
saveGame(getSavegameFilename(0), "New game");
@@ -437,7 +443,7 @@ void KyraEngine_v1::mainLoop() {
_screen->setMouseCursor(1, 1, _shapes[0]);
destroyMouseItem();
_screen->showMouse();
- buttonMenuCallback(0);
+ _gui->buttonMenuCallback(0);
_deathHandler = 0xFF;
}
@@ -451,7 +457,7 @@ void KyraEngine_v1::mainLoop() {
_screen->showMouse();
- processButtonList(_buttonList);
+ _gui->processButtonList(_buttonList, 0);
updateMousePointer();
_timer->update();
updateTextFade();
diff --git a/engines/kyra/kyra_v1.h b/engines/kyra/kyra_v1.h
index b78539ee59..3fa089e0d5 100644
--- a/engines/kyra/kyra_v1.h
+++ b/engines/kyra/kyra_v1.h
@@ -29,6 +29,7 @@
#include "kyra/kyra.h"
#include "kyra/script.h"
#include "kyra/screen_v1.h"
+#include "kyra/gui_v1.h"
namespace Kyra {
@@ -104,85 +105,11 @@ struct BeadState {
int16 tableIndex;
};
-struct Button {
- Button *nextButton;
- uint16 specialValue;
- // uint8 unk[4];
- uint8 process0;
- uint8 process1;
- uint8 process2;
- // uint8 unk
- uint16 flags;
- typedef int (KyraEngine_v1::*ButtonCallback)(Button*);
- // using 6 pointers instead of 3 as in the orignal here (safer for use with classes)
- uint8 *process0PtrShape;
- uint8 *process1PtrShape;
- uint8 *process2PtrShape;
- ButtonCallback process0PtrCallback;
- ButtonCallback process1PtrCallback;
- ButtonCallback process2PtrCallback;
- uint16 dimTableIndex;
- uint16 x;
- uint16 y;
- uint16 width;
- uint16 height;
- // uint8 unk[8];
- uint32 flags2;
- ButtonCallback buttonCallback;
- // uint8 unk[8];
-};
-
-struct MenuItem {
- bool enabled;
- uint16 field_1;
- uint8 field_3;
- const char *itemString;
- int16 x;
- int16 field_9;
- uint16 y;
- uint16 width;
- uint16 height;
- uint8 textColor;
- uint8 highlightColor;
- int16 field_12;
- uint8 field_13;
- uint8 bgcolor;
- uint8 color1;
- uint8 color2;
- int (KyraEngine_v1::*callback)(Button*);
- int16 saveSlot;
- const char *labelString;
- uint16 labelX;
- uint8 labelY;
- 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 highlightedItem;
- uint8 nrOfItems;
- int16 scrollUpBtnX;
- int16 scrollUpBtnY;
- int16 scrollDownBtnX;
- int16 scrollDownBtnY;
- MenuItem item[6];
-};
-
class KyraEngine_v1 : public KyraEngine {
friend class MusicPlayer;
friend class Debugger_v1;
friend class ScreenAnimator;
+ friend class GUI_v1;
public:
KyraEngine_v1(OSystem *system, const GameFlags &flags);
~KyraEngine_v1();
@@ -456,52 +383,6 @@ 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);
- void setGUILabels();
-
- Button *initButton(Button *list, Button *newButton);
- void processButtonList(Button *list);
- void processButton(Button *button);
- void processMenuButton(Button *button);
- void processAllMenuButtons();
-
- void setupSavegames(Menu &menu, int num);
- int getNextSavegameSlot();
-
- int gui_resumeGame(Button *button);
- int gui_loadGameMenu(Button *button);
- int gui_saveGameMenu(Button *button);
- int gui_gameControlsMenu(Button *button);
- int gui_quitPlaying(Button *button);
- int gui_quitConfirmYes(Button *button);
- int gui_quitConfirmNo(Button *button);
- int gui_loadGame(Button *button);
- int gui_saveGame(Button *button);
- int gui_savegameConfirm(Button *button);
- int gui_cancelSubMenu(Button *button);
- int gui_scrollUp(Button *button);
- int gui_scrollDown(Button *button);
- int gui_controlsChangeMusic(Button *button);
- int gui_controlsChangeSounds(Button *button);
- int gui_controlsChangeWalk(Button *button);
- int gui_controlsChangeText(Button *button);
- int gui_controlsChangeVoice(Button *button);
- int gui_controlsApply(Button *button);
-
- bool gui_quitConfirm(const char *str);
- void gui_getInput();
- void gui_redrawText(Menu menu);
- void gui_redrawHighlight(Menu menu);
- void gui_processHighlights(Menu &menu);
- void gui_updateSavegameString();
- void gui_redrawTextfield();
- void gui_fadePalette();
- void gui_restorePalette();
- void gui_setupControls(Menu &menu);
bool _skipIntroFlag;
bool _abortIntroFlag;
@@ -509,7 +390,6 @@ protected:
bool _abortWalkFlag;
bool _abortWalkFlag2;
bool _mousePressFlag;
- int8 _mouseWheel;
uint8 *_itemBkgBackUp[2];
uint8 *_shapes[373];
int8 _itemInHand;
@@ -614,16 +494,7 @@ protected:
Character *_currentCharacter;
Button *_buttonList;
- Button *_menuButtonList;
- bool _displayMenu;
- bool _menuRestoreScreen;
- bool _displaySubMenu;
- bool _cancelSubMenu;
- uint8 _toplevelMenu;
- int _savegameOffset;
- char _savegameName[31];
- const char *_specialSavegameString;
- Common::KeyState _keyPressed;
+ GUI_v1 *_gui;
struct KyragemState {
uint16 nextOperation;
@@ -682,12 +553,6 @@ protected:
const char * const*_homeString;
const char * const*_newGameString;
- const char *_voiceTextString;
- const char *_textSpeedString;
- const char *_onString;
- const char *_offString;
- const char *_onCDString;
-
int _itemList_Size;
int _takenList_Size;
int _placedList_Size;
@@ -777,14 +642,6 @@ protected:
void setupButtonData();
Button *_buttonData;
Button **_buttonDataListPtr;
- static Button _menuButtonData[];
- static Button _scrollUpButton;
- static Button _scrollDownButton;
-
- bool _haveScrollButtons;
-
- void setupMenu();
- Menu *_menu;
static const uint8 _magicMouseItemStartFrame[];
static const uint8 _magicMouseItemEndFrame[];
diff --git a/engines/kyra/module.mk b/engines/kyra/module.mk
index 866cb61280..ce7b5ccd0a 100644
--- a/engines/kyra/module.mk
+++ b/engines/kyra/module.mk
@@ -5,6 +5,7 @@ MODULE_OBJS := \
animator_v2.o \
debugger.o \
detection.o \
+ gui.o \
gui_v1.o \
gui_v2.o \
items_v1.o \
diff --git a/engines/kyra/script_v1.cpp b/engines/kyra/script_v1.cpp
index 768848c616..901812e8e5 100644
--- a/engines/kyra/script_v1.cpp
+++ b/engines/kyra/script_v1.cpp
@@ -1378,7 +1378,7 @@ int KyraEngine_v1::o1_waitForConfirmationMouseClick(ScriptState *script) {
delay(10);
}
// }
- processButtonList(_buttonList);
+ _gui->processButtonList(_buttonList, 0);
_skipFlag = false;
Common::Point mouse = getMousePos();
script->regs[1] = mouse.x;
diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp
index 71c13cc932..865839b1bf 100644
--- a/engines/kyra/staticres.cpp
+++ b/engines/kyra/staticres.cpp
@@ -32,6 +32,7 @@
#include "kyra/kyra_v3.h"
#include "kyra/screen.h"
#include "kyra/resource.h"
+#include "kyra/gui_v1.h"
namespace Kyra {
@@ -881,12 +882,12 @@ void KyraEngine_v1::loadItems() {
void KyraEngine_v1::loadButtonShapes() {
_screen->loadBitmap("BUTTONS2.CPS", 3, 3, 0);
_screen->_curPage = 2;
- _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);
+ _gui->_scrollUpButton.data0ShapePtr = _screen->encodeShape(0, 0, 24, 14, 1);
+ _gui->_scrollUpButton.data1ShapePtr = _screen->encodeShape(24, 0, 24, 14, 1);
+ _gui->_scrollUpButton.data2ShapePtr = _screen->encodeShape(48, 0, 24, 14, 1);
+ _gui->_scrollDownButton.data0ShapePtr = _screen->encodeShape(0, 15, 24, 14, 1);
+ _gui->_scrollDownButton.data1ShapePtr = _screen->encodeShape(24, 15, 24, 14, 1);
+ _gui->_scrollDownButton.data2ShapePtr = _screen->encodeShape(48, 15, 24, 14, 1);
_screen->_curPage = 0;
}
@@ -1164,151 +1165,116 @@ const uint8 KyraEngine_v1::_itemPosY[] = {
160, 160, 160, 160, 160, 181, 181, 181, 181, 181
};
-void KyraEngine_v1::setupButtonData() {
- static Button buttonData[] = {
- { 0, 0x02, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x05D, 0x9E, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine_v1::buttonInventoryCallback/*, XXX*/ },
- { 0, 0x01, /*XXX,*/1, 1, 1, /*XXX,*/ 0x0487, 0, 0, 0, 0, 0, 0, 0, 0x009, 0xA4, 0x36, 0x1E, /*XXX,*/ 0, &KyraEngine_v1::buttonMenuCallback/*, XXX*/ },
- { 0, 0x03, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x071, 0x9E, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine_v1::buttonInventoryCallback/*, XXX*/ },
- { 0, 0x04, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x085, 0x9E, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine_v1::buttonInventoryCallback/*, XXX*/ },
- { 0, 0x05, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x099, 0x9E, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine_v1::buttonInventoryCallback/*, XXX*/ },
- { 0, 0x06, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x0AD, 0x9E, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine_v1::buttonInventoryCallback/*, XXX*/ },
- { 0, 0x07, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x05D, 0xB3, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine_v1::buttonInventoryCallback/*, XXX*/ },
- { 0, 0x08, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x071, 0xB3, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine_v1::buttonInventoryCallback/*, XXX*/ },
- { 0, 0x09, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x085, 0xB3, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine_v1::buttonInventoryCallback/*, XXX*/ },
- { 0, 0x0A, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x099, 0xB3, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine_v1::buttonInventoryCallback/*, XXX*/ },
- { 0, 0x0B, /*XXX,*/0, 0, 0, /*XXX,*/ 0x0400, 0, 0, 0, 0, 0, 0, 0, 0x0AD, 0xB3, 0x13, 0x14, /*XXX,*/ 0, &KyraEngine_v1::buttonInventoryCallback/*, XXX*/ },
- { 0, 0x15, /*XXX,*/1, 1, 1, /*XXX,*/ 0x0487, 0, 0, 0, 0, 0, 0, 0, 0x0FD, 0x9C, 0x1A, 0x12, /*XXX,*/ 0, &KyraEngine_v1::buttonAmuletCallback/*, XXX*/ },
- { 0, 0x16, /*XXX,*/1, 1, 1, /*XXX,*/ 0x0487, 0, 0, 0, 0, 0, 0, 0, 0x0E7, 0xAA, 0x1A, 0x12, /*XXX,*/ 0, &KyraEngine_v1::buttonAmuletCallback/*, XXX*/ },
- { 0, 0x17, /*XXX,*/1, 1, 1, /*XXX,*/ 0x0487, 0, 0, 0, 0, 0, 0, 0, 0x0FD, 0xB5, 0x1A, 0x12, /*XXX,*/ 0, &KyraEngine_v1::buttonAmuletCallback/*, XXX*/ },
- { 0, 0x18, /*XXX,*/1, 1, 1, /*XXX,*/ 0x0487, 0, 0, 0, 0, 0, 0, 0, 0x113, 0xAA, 0x1A, 0x12, /*XXX,*/ 0, &KyraEngine_v1::buttonAmuletCallback/*, XXX*/ }
- };
-
- static Button *buttonDataListPtr[] = {
- &buttonData[1],
- &buttonData[2],
- &buttonData[3],
- &buttonData[4],
- &buttonData[5],
- &buttonData[6],
- &buttonData[7],
- &buttonData[8],
- &buttonData[9],
- &buttonData[10],
- &buttonData[11],
- &buttonData[12],
- &buttonData[13],
- &buttonData[14],
- 0
- };
-
- _buttonData = buttonData;
- _buttonDataListPtr = buttonDataListPtr;
+void GUI_v1::initStaticResource() {
+ GUI_V1_BUTTON(_scrollUpButton, 0x12, 1, 1, 1, 0x483, 0, 0, 0, 0x18, 0x0f, 0);
+ GUI_V1_BUTTON(_scrollDownButton, 0x13, 1, 1, 1, 0x483, 0, 0, 0, 0x18, 0x0f, 0);
+
+ GUI_V1_BUTTON(_menuButtonData[0], 0x0c, 1, 1, 1, 0x487, 0, 0, 0, 0, 0, 0);
+ GUI_V1_BUTTON(_menuButtonData[1], 0x0d, 1, 1, 1, 0x487, 0, 0, 0, 0, 0, 0);
+ GUI_V1_BUTTON(_menuButtonData[2], 0x0e, 1, 1, 1, 0x487, 0, 0, 0, 0, 0, 0);
+ GUI_V1_BUTTON(_menuButtonData[3], 0x0f, 1, 1, 1, 0x487, 0, 0, 0, 0, 0, 0);
+ GUI_V1_BUTTON(_menuButtonData[4], 0x10, 1, 1, 1, 0x487, 0, 0, 0, 0, 0, 0);
+ GUI_V1_BUTTON(_menuButtonData[5], 0x11, 1, 1, 1, 0x487, 0, 0, 0, 0, 0, 0);
+
+ delete [] _menu;
+ _menu = new Menu[6];
+ assert(_menu);
+
+ Button::Callback quitPlayingFunctor = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::quitPlaying);
+ Button::Callback loadGameMenuFunctor = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::loadGameMenu);
+ Button::Callback cancelSubMenuFunctor = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::cancelSubMenu);
+
+ GUI_V1_MENU(_menu[0], -1, -1, 208, 136, 248, 249, 250, 0, 251, -1, 8, 0, 5, -1, -1, -1, -1);
+ GUI_V1_MENU_ITEM(_menu[0].item[0], 1, 0, 0, 0, -1, -1, 30, 148, 15, 252, 253, 24, 0, 248, 249, 250, -1, 0, 0, 0, 0, 0);
+ GUI_V1_MENU_ITEM(_menu[0].item[1], 1, 0, 0, 0, -1, -1, 47, 148, 15, 252, 253, 24, 0, 248, 249, 250, -1, 0, 0, 0, 0, 0);
+ GUI_V1_MENU_ITEM(_menu[0].item[2], 1, 0, 0, 0, -1, -1, 64, 148, 15, 252, 253, 24, 0, 248, 249, 250, -1, 0, 0, 0, 0, 0);
+ GUI_V1_MENU_ITEM(_menu[0].item[3], 1, 0, 0, 0, -1, -1, 81, 148, 15, 252, 253, 24, 0, 248, 249, 250, -1, 0, 0, 0, 0, 0);
+ GUI_V1_MENU_ITEM(_menu[0].item[4], 1, 0, 0, 0, 86, 0, 110, 92, 15, 252, 253, -1, 255, 248, 249, 250, -1, 0, 0, 0, 0, 0);
+ _menu[0].item[0].callback = loadGameMenuFunctor;
+ _menu[0].item[1].callback = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::saveGameMenu);
+ _menu[0].item[2].callback = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::gameControlsMenu);
+ _menu[0].item[3].callback = quitPlayingFunctor;
+ _menu[0].item[4].callback = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::resumeGame);
+
+ GUI_V1_MENU(_menu[1], -1, -1, 288, 56, 248, 249, 250, 0, 254,-1, 8, 0, 2, -1, -1, -1, -1);
+ GUI_V1_MENU_ITEM(_menu[1].item[0], 1, 0, 0, 0, 24, 0, 30, 72, 15, 252, 253, -1, 255, 248, 249, 250, -1, 0, 0, 0, 0, 0);
+ GUI_V1_MENU_ITEM(_menu[1].item[1], 1, 0, 0, 0, 192, 0, 30, 72, 15, 252, 253, -1, 255, 248, 249, 250, -1, 0, 0, 0, 0, 0);
+ _menu[1].item[0].callback = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::quitConfirmYes);
+ _menu[1].item[1].callback = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::quitConfirmNo);
+
+ GUI_V1_MENU(_menu[2], -1, -1, 288, 160, 248, 249, 250, 0, 251, -1, 8, 0, 6, 132, 22, 132, 124);
+ GUI_V1_MENU_ITEM(_menu[2].item[0], 1, 0, 0, 0, -1, 255, 39, 256, 15, 252, 253, 5, 0, 248, 249, 250, -1, 0, 0, 0, 0, 0);
+ GUI_V1_MENU_ITEM(_menu[2].item[1], 1, 0, 0, 0, -1, 255, 56, 256, 15, 252, 253, 5, 0, 248, 249, 250, -1, 0, 0, 0, 0, 0);
+ GUI_V1_MENU_ITEM(_menu[2].item[2], 1, 0, 0, 0, -1, 255, 73, 256, 15, 252, 253, 5, 0, 248, 249, 250, -1, 0, 0, 0, 0, 0);
+ GUI_V1_MENU_ITEM(_menu[2].item[3], 1, 0, 0, 0, -1, 255, 90, 256, 15, 252, 253, 5, 0, 248, 249, 250, -1, 0, 0, 0, 0, 0);
+ GUI_V1_MENU_ITEM(_menu[2].item[4], 1, 0, 0, 0, -1, 255, 107, 256, 15, 252, 253, 5, 0, 248, 249, 250, -1, 0, 0, 0, 0, 0);
+ GUI_V1_MENU_ITEM(_menu[2].item[5], 1, 0, 0, 0, 184, 0, 134, 88, 15, 252, 253, -1, 255, 248, 249, 250, -1, 0, 0, 0, 0, 0);
+ _menu[2].item[5].callback = cancelSubMenuFunctor;
+
+ GUI_V1_MENU(_menu[3], -1, -1, 288, 67, 248, 249, 250, 0, 251, -1, 8, 0, 2, -1, -1, -1, -1);
+ GUI_V1_MENU_ITEM(_menu[3].item[0], 1, 0, 0, 0, 24, 0, 44, 72, 15, 252, 253, -1, 255, 248, 249, 250, -1, 0, 0, 0, 0, 0);
+ GUI_V1_MENU_ITEM(_menu[3].item[1], 1, 0, 0, 0, 192, 0, 44, 72, 15, 252, 253, -1, 255, 248, 249, 250, -1, 0, 0, 0, 0, 0);
+ _menu[3].item[0].callback = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::savegameConfirm);
+ _menu[3].item[1].callback = cancelSubMenuFunctor;
+
+ GUI_V1_MENU(_menu[4], -1, -1, 208, 76, 248, 249, 250, 0, 251, -1, 8, 0, 2, -1, -1, -1, -1);
+ GUI_V1_MENU_ITEM(_menu[4].item[0], 1, 0, 0, 0, -1, -1, 30, 148, 15, 252, 253, 24, 0, 248, 249, 250, -1, 0, 0, 0, 0, 0);
+ GUI_V1_MENU_ITEM(_menu[4].item[1], 1, 0, 0, 0, -1, -1, 47, 148, 15, 252, 253, 24, 0, 248, 249, 250, -1, 0, 0, 0, 0, 0);
+ _menu[4].item[0].callback = loadGameMenuFunctor;
+ _menu[4].item[1].callback = quitPlayingFunctor;
+
+ GUI_V1_MENU(_menu[5], -1, -1, 208, 153, 248, 249, 250, 0, 251, -1, 8, 0, 6, -1, -1, -1, -1);
+ GUI_V1_MENU_ITEM(_menu[5].item[0], 1, 0, 0, 0, 110, 0, 30, 64, 15, 252, 253, 5, 0, 248, 249, 250, -1, 0, 34, 32, 0, 0);
+ GUI_V1_MENU_ITEM(_menu[5].item[1], 1, 0, 0, 0, 110, 0, 47, 64, 15, 252, 253, 5, 0, 248, 249, 250, -1, 0, 34, 49, 0, 0);
+ GUI_V1_MENU_ITEM(_menu[5].item[2], 1, 0, 0, 0, 110, 0, 64, 64, 15, 252, 253, 5, 0, 248, 249, 250, -1, 0, 34, 66, 0, 0);
+ GUI_V1_MENU_ITEM(_menu[5].item[3], 1, 0, 0, 0, 110, 0, 81, 64, 15, 252, 253, 5, 0, 248, 249, 250, -1, 0, 34, 83, 0, 0);
+ GUI_V1_MENU_ITEM(_menu[5].item[4], 1, 0, 0, 0, 110, 0, 98, 64, 15, 252, 253, 5, 0, 248, 249, 250, -1, 0, 34, 100, 0, 0);
+ GUI_V1_MENU_ITEM(_menu[5].item[5], 1, 0, 0, 0, 64, 0, 127, 92, 15, 252, 253, -1, 255, 248, 249, 250, -1, -0, 0, 0, 0, 0);
+ _menu[5].item[0].callback = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::controlsChangeMusic);
+ _menu[5].item[1].callback = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::controlsChangeSounds);
+ _menu[5].item[2].callback = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::controlsChangeWalk);
+ _menu[5].item[4].callback = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::controlsChangeText);
+ _menu[5].item[5].callback = BUTTON_FUNCTOR(GUI_v1, this, &GUI_v1::controlsApply);
}
-Button KyraEngine_v1::_scrollUpButton = {0, 0x12, 1, 1, 1, 0x483, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x18, 0x0f, 0, 0};
-Button KyraEngine_v1::_scrollDownButton = {0, 0x13, 1, 1, 1, 0x483, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x18, 0x0f, 0, 0};
-
-Button KyraEngine_v1::_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*/ }
-};
-
-void KyraEngine_v1::setupMenu() {
- static Menu menu[] = {
- { -1, -1, 208, 136, 248, 249, 250, 0, 251, -1, 8, 0, 5, -1, -1, -1, -1,
- {
- {1, 0, 0, 0, -1, -1, 30, 148, 15, 252, 253, 24, 0,
- 248, 249, 250, &KyraEngine_v1::gui_loadGameMenu, -1, 0, 0, 0, 0, 0},
-
- {1, 0, 0, 0, -1, -1, 47, 148, 15, 252, 253, 24, 0,
- 248, 249, 250, &KyraEngine_v1::gui_saveGameMenu, -1, 0, 0, 0, 0, 0},
-
- {1, 0, 0, 0, -1, -1, 64, 148, 15, 252, 253, 24, 0,
- 248, 249, 250, &KyraEngine_v1::gui_gameControlsMenu, -1, 0, 0, 0, 0, 0},
-
- {1, 0, 0, 0, -1, -1, 81, 148, 15, 252, 253, 24, 0,
- 248, 249, 250, &KyraEngine_v1::gui_quitPlaying, -1, 0, 0, 0, 0, 0},
-
- {1, 0, 0, 0, 86, 0, 110, 92, 15, 252, 253, -1, 255,
- 248, 249, 250, &KyraEngine_v1::gui_resumeGame, -1, 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, 0, 24, 0, 30, 72, 15, 252, 253, -1, 255,
- 248, 249, 250, &KyraEngine_v1::gui_quitConfirmYes, -1, 0, 0, 0, 0, 0},
-
- {1, 0, 0, 0, 192, 0, 30, 72, 15, 252, 253, -1, 255,
- 248, 249, 250, &KyraEngine_v1::gui_quitConfirmNo, -1, 0, 0, 0, 0, 0}
- }
- },
- { -1, -1, 288, 160, 248, 249, 250, 0, 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, 0, -1, 0, 0, 0, 0, 0},
-
- {1, 0, 0, 0, -1, 255, 56, 256, 15, 252, 253, 5, 0,
- 248, 249, 250, 0, -1, 0, 0, 0, 0, 0},
-
- {1, 0, 0, 0, -1, 255, 73, 256, 15, 252, 253, 5, 0,
- 248, 249, 250, 0, -1, 0, 0, 0, 0, 0},
-
- {1, 0, 0, 0, -1, 255, 90, 256, 15, 252, 253, 5, 0,
- 248, 249, 250, 0, -1, 0, 0, 0, 0, 0},
-
- {1, 0, 0, 0, -1, 255, 107, 256, 15, 252, 253, 5, 0,
- 248, 249, 250, 0, -1, 0, 0, 0, 0, 0},
-
- {1, 0, 0, 0, 184, 0, 134, 88, 15, 252, 253, -1, 255,
- 248, 249, 250, &KyraEngine_v1::gui_cancelSubMenu, -1, 0, 0, 0, 0, 0},
- }
- },
- { -1, -1, 288, 67, 248, 249, 250, 0, 251, -1, 8, 0, 3, -1, -1, -1, -1,
- {
- {1, 0, 0, 0, 24, 0, 44, 72, 15, 252, 253, -1, 255,
- 248, 249, 250, &KyraEngine_v1::gui_savegameConfirm, -1, 0, 0, 0, 0, 0},
-
- {1, 0, 0, 0, 192, 0, 44, 72, 15, 252, 253, -1, 255,
- 248, 249, 250, &KyraEngine_v1::gui_cancelSubMenu, -1, 0, 0, 0, 0, 0}
- }
- },
- { -1, -1, 208, 76, 248, 249, 250, 0, 251, -1, 8, 0, 2, -1, -1, -1, -1,
- {
- {1, 0, 0, 0, -1, -1, 30, 148, 15, 252, 253, 24, 0,
- 248, 249, 250, &KyraEngine_v1::gui_loadGameMenu, -1, 0, 0, 0, 0, 0},
-
- {1, 0, 0, 0, -1, -1, 47, 148, 15, 252, 253, 24, 0,
- 248, 249, 250, &KyraEngine_v1::gui_quitPlaying, -1, 0, 0, 0, 0, 0}
- }
- },
- { -1, -1, 208, 153, 248, 249, 250, 0, 251, -1, 8, 0, 6, -1, -1, -1, -1,
- {
- {1, 0, 0, 0, 110, 0, 30, 64, 15, 252, 253, 5, 0,
- 248, 249, 250, &KyraEngine_v1::gui_controlsChangeMusic, -1, 0, 34, 32, 0, 0},
-
- {1, 0, 0, 0, 110, 0, 47, 64, 15, 252, 253, 5, 0,
- 248, 249, 250, &KyraEngine_v1::gui_controlsChangeSounds, -1, 0, 34, 49, 0, 0},
-
- {1, 0, 0, 0, 110, 0, 64, 64, 15, 252, 253, 5, 0,
- 248, 249, 250, &KyraEngine_v1::gui_controlsChangeWalk, -1, 0, 34, 66, 0, 0},
-
- {1, 0, 0, 0, 110, 0, 81, 64, 15, 252, 253, 5, 0,
- 248, 249, 250, 0, -1, 0, 34, 83, 0, 0 },
-
- {1, 0, 0, 0, 110, 0, 98, 64, 15, 252, 253, 5, 0,
- 248, 249, 250, &KyraEngine_v1::gui_controlsChangeText, -1, 0, 34, 100, 0, 0 },
-
- {1, 0, 0, 0, 64, 0, 127, 92, 15, 252, 253, -1, 255,
- 248, 249, 250, &KyraEngine_v1::gui_controlsApply, -1, -0, 0, 0, 0, 0}
- }
- }
- };
-
- _menu = menu;
+void KyraEngine_v1::setupButtonData() {
+ delete [] _buttonData;
+ delete [] _buttonDataListPtr;
+
+ _buttonData = new Button[15];
+ assert(_buttonData);
+ _buttonDataListPtr = new Button*[15];
+ assert(_buttonDataListPtr);
+
+ GUI_V1_BUTTON(_buttonData[1], 0x01, 1, 1, 1, 0x0487, 0, 0x009, 0xA4, 0x36, 0x1E, 0);
+ _buttonData[1].buttonCallback = BUTTON_FUNCTOR(GUI_v1, _gui, &GUI_v1::buttonMenuCallback);
+
+ Button::Callback inventoryFunctor = BUTTON_FUNCTOR(KyraEngine_v1, this, &KyraEngine_v1::buttonInventoryCallback);
+ for (int i = 2; i <= 10; ++i)
+ _buttonData[i].buttonCallback = inventoryFunctor;
+ _buttonData[0].buttonCallback = inventoryFunctor;
+ GUI_V1_BUTTON(_buttonData[0], 0x02, 0, 0, 0, 0x0400, 0, 0x05D, 0x9E, 0x13, 0x13, 0);
+ GUI_V1_BUTTON(_buttonData[2], 0x03, 0, 0, 0, 0x0400, 0, 0x071, 0x9E, 0x13, 0x14, 0);
+ GUI_V1_BUTTON(_buttonData[3], 0x04, 0, 0, 0, 0x0400, 0, 0x085, 0x9E, 0x13, 0x14, 0);
+ GUI_V1_BUTTON(_buttonData[4], 0x05, 0, 0, 0, 0x0400, 0, 0x099, 0x9E, 0x13, 0x14, 0);
+ GUI_V1_BUTTON(_buttonData[5], 0x06, 0, 0, 0, 0x0400, 0, 0x0AD, 0x9E, 0x13, 0x14, 0);
+ GUI_V1_BUTTON(_buttonData[6], 0x07, 0, 0, 0, 0x0400, 0, 0x05D, 0xB3, 0x13, 0x14, 0);
+ GUI_V1_BUTTON(_buttonData[7], 0x08, 0, 0, 0, 0x0400, 0, 0x071, 0xB3, 0x13, 0x14, 0);
+ GUI_V1_BUTTON(_buttonData[8], 0x09, 0, 0, 0, 0x0400, 0, 0x085, 0xB3, 0x13, 0x14, 0);
+ GUI_V1_BUTTON(_buttonData[9], 0x0A, 0, 0, 0, 0x0400, 0, 0x099, 0xB3, 0x13, 0x14, 0);
+ GUI_V1_BUTTON(_buttonData[10], 0x0B, 0, 0, 0, 0x0400, 0, 0x0AD, 0xB3, 0x13, 0x14, 0);
+
+ Button::Callback amuletFunctor = BUTTON_FUNCTOR(KyraEngine_v1, this, &KyraEngine_v1::buttonAmuletCallback);
+ GUI_V1_BUTTON(_buttonData[11], 0x15, 1, 1, 1, 0x0487, 0, 0x0FD, 0x9C, 0x1A, 0x12, 0);
+ GUI_V1_BUTTON(_buttonData[12], 0x16, 1, 1, 1, 0x0487, 0, 0x0E7, 0xAA, 0x1A, 0x12, 0);
+ GUI_V1_BUTTON(_buttonData[13], 0x17, 1, 1, 1, 0x0487, 0, 0x0FD, 0xB5, 0x1A, 0x12, 0);
+ GUI_V1_BUTTON(_buttonData[14], 0x18, 1, 1, 1, 0x0487, 0, 0x113, 0xAA, 0x1A, 0x12, 0);
+ for (int i = 11; i <= 14; ++i)
+ _buttonData[i].buttonCallback = amuletFunctor;
+
+ for (int i = 1; i < 15; ++i)
+ _buttonDataListPtr[i-1] = &_buttonData[i];
+ _buttonDataListPtr[14] = 0;
}
const uint8 KyraEngine_v1::_magicMouseItemStartFrame[] = {