aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra
diff options
context:
space:
mode:
authorathrxx2011-06-22 01:08:28 +0200
committerJohannes Schickel2011-12-26 16:18:11 +0100
commit045d08986d3accc3fc7d55d76eb550db01ad7fc7 (patch)
treef62e1096f48621ed0b923aa531f04dfe4eb22438 /engines/kyra
parent69ad70afbb16f25f62432fb497e39c9d5633c10a (diff)
downloadscummvm-rg350-045d08986d3accc3fc7d55d76eb550db01ad7fc7.tar.gz
scummvm-rg350-045d08986d3accc3fc7d55d76eb550db01ad7fc7.tar.bz2
scummvm-rg350-045d08986d3accc3fc7d55d76eb550db01ad7fc7.zip
KYRA: (EOB) - start implementing camp menu
Diffstat (limited to 'engines/kyra')
-rw-r--r--engines/kyra/chargen.cpp2
-rw-r--r--engines/kyra/eobcommon.cpp17
-rw-r--r--engines/kyra/eobcommon.h24
-rw-r--r--engines/kyra/gui.h2
-rw-r--r--engines/kyra/gui_eob.cpp393
-rw-r--r--engines/kyra/gui_eob.h28
-rw-r--r--engines/kyra/magic_eob.cpp4
-rw-r--r--engines/kyra/screen_eob.cpp5
-rw-r--r--engines/kyra/script_eob.cpp11
-rw-r--r--engines/kyra/staticres_eob.cpp58
10 files changed, 487 insertions, 57 deletions
diff --git a/engines/kyra/chargen.cpp b/engines/kyra/chargen.cpp
index fc3e874de3..03ab45363f 100644
--- a/engines/kyra/chargen.cpp
+++ b/engines/kyra/chargen.cpp
@@ -319,7 +319,7 @@ void CharacterGenerator::initButton(int index, int x, int y, int w, int h, int k
b->width = w;
b->height = h;
b->keyCode = keyCode;
- b->keyCode2 = keyCode + 0x100;
+ b->keyCode2 = keyCode | 0x100;
}
void CharacterGenerator::checkForCompleteParty() {
diff --git a/engines/kyra/eobcommon.cpp b/engines/kyra/eobcommon.cpp
index 3f9782a343..d193bc0842 100644
--- a/engines/kyra/eobcommon.cpp
+++ b/engines/kyra/eobcommon.cpp
@@ -55,8 +55,6 @@ EobCoreEngine::EobCoreEngine(OSystem *system, const GameFlags &flags) : LolEobBa
_weaponSlotGrid = _blackBoxWideGrid = _lightningColumnShape = 0;
_tempIconShape = 0;
- _menuStringsPrefsTemp = 0;
-
_monsterDustStrings = 0;
_monsterDistAttType10 = 0;
_monsterDistAttSfx10 = 0;
@@ -106,6 +104,8 @@ EobCoreEngine::EobCoreEngine(OSystem *system, const GameFlags &flags) : LolEobBa
_color10 = 23;
_color11 = 20;
+ _menuDefs = 0;
+
_exchangeCharacterId = -1;
_charExchangeSwap = 0;
_configHpBarGraphs = true;
@@ -143,12 +143,6 @@ EobCoreEngine::~EobCoreEngine() {
releaseItemsAndDecorationsShapes();
releaseTempData();
- if (_menuStringsPrefsTemp) {
- for (int i = 0; i < 4; i++)
- delete _menuStringsPrefsTemp[i];
- delete[] _menuStringsPrefsTemp;
- }
-
if (_faceShapes) {
for (int i = 0; i < 44; i++) {
if (_characters) {
@@ -207,6 +201,9 @@ EobCoreEngine::~EobCoreEngine() {
delete _gui;
_gui = 0;
+ delete[] _menuDefs;
+ _menuDefs = 0;
+
delete _inf;
delete _timer;
_timer = 0;
@@ -265,12 +262,10 @@ Common::Error EobCoreEngine::init() {
return err;
initButtonData();
+ initMenus();
initStaticResource();
initSpells();
- _menuStringsPrefsTemp = new char*[4];
- memset(_menuStringsPrefsTemp, 0, 4 * sizeof(char*));
-
_timer = new TimerManager(this, _system);
assert(_timer);
setupTimers();
diff --git a/engines/kyra/eobcommon.h b/engines/kyra/eobcommon.h
index 4ad4ebfe99..a4fb0d7735 100644
--- a/engines/kyra/eobcommon.h
+++ b/engines/kyra/eobcommon.h
@@ -228,6 +228,23 @@ struct ScriptTimer {
uint32 next;
};
+struct EobMenuDef {
+ int8 titleStrId;
+ uint8 dim;
+ uint8 firstButtonStrId;
+ int8 numButtons;
+ int8 titleCol;
+};
+struct EobMenuButtonDef {
+ int8 labelId;
+ int16 x;
+ int8 y;
+ uint8 width;
+ uint8 height;
+ int16 keyCode;
+ int16 flags;
+};
+
class EobInfProcessor;
class EobCoreEngine : public LolEobBaseEngine {
@@ -258,8 +275,9 @@ protected:
void releaseItemsAndDecorationsShapes();
void initButtonData();
+ void initMenus();
void initStaticResource();
- virtual void initSpells();
+ virtual void initSpells();
const uint8 **_largeItemShapes;
const uint8 **_smallItemShapes;
@@ -825,6 +843,7 @@ protected:
void sparkEffectDefensive(int charIndex);
void sparkEffectOffensive();
void setSpellEventTimer(int spell, int timerBaseFactor, int timerLength, int timerLevelFactor, int updateExistingTimer);
+ void cleanupCharacterSpellList(int charIndex);
bool magicObjectHit(EobFlyingObject *fo, int dcTimes, int dcPips, int dcOffs, int level);
@@ -957,7 +976,8 @@ protected:
const uint8 *_magicFlightObjectProperties;
// Menu
- char **_menuStringsPrefsTemp;
+ EobMenuDef *_menuDefs;
+ const EobMenuButtonDef *_menuButtonDefs;
bool _configMouse;
diff --git a/engines/kyra/gui.h b/engines/kyra/gui.h
index 04fc9b5523..ad0e0d630f 100644
--- a/engines/kyra/gui.h
+++ b/engines/kyra/gui.h
@@ -88,6 +88,8 @@ struct Button {
Callback buttonCallback;
+ const void *extButtonDef;
+
uint16 arg;
};
diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp
index 10eabe937f..9baed752a3 100644
--- a/engines/kyra/gui_eob.cpp
+++ b/engines/kyra/gui_eob.cpp
@@ -24,6 +24,7 @@
#include "kyra/eobcommon.h"
#include "kyra/gui_eob.h"
+#include "kyra/text_eob.h"
#include "kyra/timer.h"
#include "kyra/util.h"
@@ -847,25 +848,15 @@ int EobCoreEngine::clickedCamp(Button *button) {
}
_screen->copyRegion(0, 120, 0, 0, 176, 24, 0, 14, Screen::CR_NO_P_CHECK);
- Screen::FontId of = _screen->setFont(Screen::FID_8_FNT);
- for (int i = 0; i < 4; i++) {
- delete _menuStringsPrefsTemp[i];
- _menuStringsPrefsTemp[i] = new char[strlen(_menuStringsPrefs[i]) + 8];
- }
-
- Common::strlcpy(_menuStringsPrefsTemp[0], Common::String::format(_menuStringsPrefs[0], _menuStringsOnOff[_configMusic ? 0 : 1]).c_str(), strlen(_menuStringsPrefs[0]) + 8);
- Common::strlcpy(_menuStringsPrefsTemp[1], Common::String::format(_menuStringsPrefs[1], _menuStringsOnOff[_configSounds ? 0 : 1]).c_str(), strlen(_menuStringsPrefs[1]) + 8);
- Common::strlcpy(_menuStringsPrefsTemp[2], Common::String::format(_menuStringsPrefs[2], _menuStringsOnOff[_configHpBarGraphs ? 0 : 1]).c_str(), strlen(_menuStringsPrefs[2]) + 8);
- Common::strlcpy(_menuStringsPrefsTemp[3], Common::String::format(_menuStringsPrefs[3], _menuStringsOnOff[_configMouse ? 0 : 1]).c_str(), strlen(_menuStringsPrefs[3]) + 8);
+ _gui->runCampMenu();
- _screen->setFont(of);
_screen->copyRegion(0, 0, 0, 120, 176, 24, 14, 2, Screen::CR_NO_P_CHECK);
_screen->setScreenDim(cd);
drawScene(0);
- //for (int i = 0; i < 6; i++)
- // cleanupCharacterSpellList(i);
+ for (int i = 0; i < 6; i++)
+ cleanupCharacterSpellList(i);
_screen->setCurPage(0);
const ScreenDim *dm = _screen->getScreenDim(10);
@@ -1447,18 +1438,30 @@ GUI_Eob::GUI_Eob(EobCoreEngine *vm) : GUI(vm), _vm(vm), _screen(vm->_screen) {
_redrawButtonFunctor = BUTTON_FUNCTOR(GUI, this, &GUI::redrawButtonCallback);
_redrawShadedButtonFunctor = BUTTON_FUNCTOR(GUI, this, &GUI::redrawShadedButtonCallback);
+ _menuStringsPrefsTemp = new char*[4];
+ memset(_menuStringsPrefsTemp, 0, 4 * sizeof(char*));
+
_specialProcessButton = _backupButtonList = 0;
_flagsMouseLeft = _flagsMouseRight = _flagsModifier = 0;
_backupButtonList = 0;
_progress = 0;
_prcButtonUnk3 = 1;
_cflag = 0xffff;
-
+
_menuLineSpacing = 0;
_menuUnk1 = 0;
_menuLastInFlags = 0;
_menuCur = 0;
_menuNumItems = 0;
+ _menuButtons = 0;
+}
+
+GUI_Eob::~GUI_Eob() {
+ if (_menuStringsPrefsTemp) {
+ for (int i = 0; i < 4; i++)
+ delete _menuStringsPrefsTemp[i];
+ delete[] _menuStringsPrefsTemp;
+ }
}
void GUI_Eob::processButton(Button *button) {
@@ -2028,23 +2031,6 @@ int GUI_Eob::handleMenu(int sd, const char *const *strings, void *b, int32 menuI
return result;
}
-void GUI_Eob::initMenuItemsMask(int menuId, int maxItem, int32 menuItemsMask, int unk) {
- if (menuItemsMask == -1) {
- _menuNumItems = _screen->getScreenDim(19 + menuId)->h;
- _menuCur = _screen->getScreenDim(19 + menuId)->unk8;
- return;
- }
-
- _menuNumItems = 0;
-
- for (int i = 0; i < maxItem; i++) {
- if (menuItemsMask & (1 << (i + unk)))
- _menuNumItems++;
- }
-
- _menuCur = 0;
-}
-
int GUI_Eob::getMenuItem(int index, int32 menuItemsMask, int unk) {
if (menuItemsMask == -1)
return index;
@@ -2074,6 +2060,172 @@ void GUI_Eob::menuFlashSelection(const char *str, int x, int y, int color1, int
}
}
+int GUI_Eob::runCampMenu() {
+ Screen::FontId of = _screen->setFont(Screen::FID_8_FNT);
+
+ Button *highlightButton = 0;
+ Button *prevHighlightButton = 0;
+
+ int newMenu = 0;
+ int lastMenu = -1;
+ int e = 0;
+ int menuG = 0;
+ int menuH = 0;
+ _menuButtons = 0;
+
+ for (bool runLoop = true; runLoop && !_vm->shouldQuit(); ) {
+ if (newMenu == 2)
+ updateOptionsStrings();
+
+ if (newMenu != -1) {
+ releaseButtons(_menuButtons);
+
+ _vm->_menuDefs[0].titleStrId = newMenu ? 1 : 56;
+ if (newMenu == 2)
+ _vm->_menuDefs[2].titleStrId = 57;
+ else if (newMenu == 1)
+ _vm->_menuDefs[1].titleStrId = 58;
+
+ _menuButtons = initMenu(newMenu);
+
+ if (newMenu != lastMenu) {
+ highlightButton = _menuButtons;
+ prevHighlightButton = 0;
+ }
+
+ lastMenu = newMenu;
+ newMenu = -1;
+ }
+
+ int inputFlag = _vm->checkInput(_menuButtons, false, 0) & 0x80ff;
+ _vm->removeInputTop();
+
+ if (inputFlag == _vm->_keyMap[Common::KEYCODE_ESCAPE])
+ inputFlag = 0x8007;
+ else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP5] || inputFlag == _vm->_keyMap[Common::KEYCODE_SPACE] || inputFlag == _vm->_keyMap[Common::KEYCODE_RETURN]) {
+ inputFlag = 0x8000 + prevHighlightButton->index;
+ }
+
+ Button *clickedButton = _vm->gui_getButton(_menuButtons, inputFlag & 0x7fff);
+
+ if (clickedButton) {
+ drawMenuButton(prevHighlightButton, false, false, true);
+ drawMenuButton(clickedButton, true, true, true);
+ _screen->updateScreen();
+ _vm->_system->delayMillis(80);
+ drawMenuButton(clickedButton, false, true, true);
+ _screen->updateScreen();
+ highlightButton = clickedButton;
+ prevHighlightButton = 0;
+ }
+
+ if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP3] || inputFlag == _vm->_keyMap[Common::KEYCODE_PAGEDOWN] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP1] || inputFlag == _vm->_keyMap[Common::KEYCODE_END]) {
+ highlightButton = _vm->gui_getButton(_menuButtons, _vm->_menuDefs[lastMenu].firstButtonStrId + _vm->_menuDefs[lastMenu].numButtons);
+ inputFlag = _vm->_keyMap[Common::KEYCODE_UP];
+ } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP7] || inputFlag == _vm->_keyMap[Common::KEYCODE_HOME] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP9] || inputFlag == _vm->_keyMap[Common::KEYCODE_PAGEUP]) {
+ highlightButton = _vm->gui_getButton(_menuButtons, _vm->_menuDefs[lastMenu].firstButtonStrId + 1);
+ } else if (inputFlag == _vm->_keyMap[Common::KEYCODE_KP8] || inputFlag == _vm->_keyMap[Common::KEYCODE_UP] || inputFlag == _vm->_keyMap[Common::KEYCODE_KP2] || inputFlag == _vm->_keyMap[Common::KEYCODE_DOWN]) {
+ if (prevHighlightButton) {
+ int dir = (inputFlag == _vm->_keyMap[Common::KEYCODE_UP]) ? -1 : 1;
+ int s = prevHighlightButton->index + dir;
+ int a = _vm->_menuDefs[lastMenu].firstButtonStrId + 1;
+ int b = a + _vm->_menuDefs[lastMenu].numButtons - 1;
+
+ do {
+ if (s < a)
+ s = b;
+ if (s > b)
+ s = a;
+ if (_vm->_menuButtonDefs[s - 1].flags & 2)
+ break;
+ s += dir;
+ } while(!_vm->shouldQuit());
+
+ highlightButton = _vm->gui_getButton(_menuButtons, s);
+ }
+
+ } else if (inputFlag > 0x8001 && inputFlag < 0x8010) {
+ switch (inputFlag) {
+ case 0x8001:
+ break;
+ case 0x8002:
+ break;
+ case 0x8003:
+ break;
+ case 0x8004:
+ break;
+ case 0x8005:
+ newMenu = 2;
+ break;
+ case 0x8006:
+ newMenu = 1;
+ break;
+ case 0x8007:
+ if (menuH)
+ displayTextBox(44);
+ // fall through
+ case 0x800c:
+ case 0x800f:
+ if (lastMenu == 1 || lastMenu == 2)
+ newMenu = 0;
+ else if (inputFlag == _vm->_keyMap[Common::KEYCODE_ESCAPE])
+ newMenu = 0;
+ else
+ runLoop = false;
+ break;
+ case 0x8008:
+ break;
+ case 0x8009:
+ break;
+ case 0x800a:
+ break;
+ case 0x800b:
+ break;
+ case 0x800d:
+ break;
+ case 0x800e:
+ break;
+ default:
+ break;
+ }
+
+ } else {
+ Common::Point p = _vm->getMousePos();
+ for (Button *b = _menuButtons; b; b = b->nextButton) {
+ if ((b->arg & 2) && _vm->posWithinRect(p.x, p.y, b->x, b->y, b->x + b->width, b->y + b->height))
+ highlightButton = b;
+ }
+ }
+
+ if (menuG || e) {
+ for (int i = 0; i < 6; i++) {
+ _vm->gui_drawCharPortraitWithStats(i);
+ _vm->cleanupCharacterSpellList(i);
+ }
+ }
+
+ menuG = e = 0;
+
+ if (prevHighlightButton != highlightButton && newMenu == -1 && runLoop) {
+ drawMenuButton(prevHighlightButton, false, false, true);
+ drawMenuButton(highlightButton, false, true, true);
+ _screen->updateScreen();
+ prevHighlightButton = highlightButton;
+ }
+ }
+
+ releaseButtons(_menuButtons);
+ _menuButtons = 0;
+
+ _screen->setFont(of);
+
+ return 0;
+}
+
+int GUI_Eob::runLoadMenu(int x, int y) {
+ return 0;
+}
+
int GUI_Eob::getTextInput(char *dest, int x, int y, int destMaxLen, int textColor1, int textColor2, int cursorColor) {
uint8 cursorState = 1;
char sufx[] = " ";
@@ -2192,6 +2344,185 @@ int GUI_Eob::getTextInput(char *dest, int x, int y, int destMaxLen, int textColo
return _keyPressed.keycode == Common::KEYCODE_ESCAPE ? -1 : len;
}
+void GUI_Eob::initMenuItemsMask(int menuId, int maxItem, int32 menuItemsMask, int unk) {
+ if (menuItemsMask == -1) {
+ _menuNumItems = _screen->getScreenDim(19 + menuId)->h;
+ _menuCur = _screen->getScreenDim(19 + menuId)->unk8;
+ return;
+ }
+
+ _menuNumItems = 0;
+
+ for (int i = 0; i < maxItem; i++) {
+ if (menuItemsMask & (1 << (i + unk)))
+ _menuNumItems++;
+ }
+
+ _menuCur = 0;
+}
+
+Button *GUI_Eob::initMenu(int id) {
+ _screen->setCurPage(2);
+
+ EobMenuDef *m = &_vm->_menuDefs[id];
+
+ if (m->dim) {
+ const ScreenDim *dm = _screen->getScreenDim(m->dim);
+ _screen->fillRect(dm->sx << 3, dm->sy, ((dm->sx + dm->w) << 3) - 1, (dm->sy + dm->h) - 1, _vm->_bkgColor_1);
+ _screen->setScreenDim(m->dim);
+ drawMenuButtonBox(dm->sx << 3, dm->sy, dm->w << 3, dm->h, false, false);
+ }
+
+ _screen->printShadedText(getMenuString(m->titleStrId), 5, 5, m->titleCol, 0);
+
+ Button *buttons = 0;
+ for (int i = 0; i < m->numButtons; i++) {
+ const EobMenuButtonDef *df = &_vm->_menuButtonDefs[m->firstButtonStrId + i];
+ Button *b = new Button;
+ b->index = m->firstButtonStrId + i + 1;
+ b->data0Val2 = 12;
+ b->data1Val2 = b->data2Val2 = 15;
+ b->data3Val2 = 8;
+ b->flags = 0x1100;
+ b->keyCode = df->keyCode;
+ b->keyCode2 = df->keyCode | 0x100;
+ b->x = df->x;
+ b->y = df->y;
+ b->width = df->width;
+ b->height = df->height;
+ b->extButtonDef = df;
+ b->arg = df->flags;
+
+ drawMenuButton(b, false, false, false);
+ buttons = linkButton(buttons, b);
+ }
+
+ _screen->copyRegion(_screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->sx << 3, _screen->_curDim->sy, _screen->_curDim->w << 3, _screen->_curDim->h, 2, 0, Screen::CR_NO_P_CHECK);
+ _vm->gui_notifyButtonListChanged();
+ _screen->setCurPage(0);
+ _screen->updateScreen();
+
+ return buttons;
+}
+
+void GUI_Eob::drawMenuButton(Button *b, bool clicked, bool highlight, bool noFill) {
+ if (!b)
+ return;
+
+ EobMenuButtonDef *d = (EobMenuButtonDef*)b->extButtonDef;
+
+ if (d->flags & 1)
+ drawMenuButtonBox(b->x, b->y, b->width, b->height, clicked, noFill);
+
+ if (d->labelId) {
+ const char *s = getMenuString(d->labelId);
+
+ int xOffs = 4;
+ int yOffs = 3;
+
+ if (d->flags & 4) {
+ xOffs = ((b->width - (strlen(s) << 3)) >> 1) + 1;
+ yOffs = (b->height - 7) >> 1;
+ }
+
+ if (noFill || clicked)
+ _screen->printText(s, b->x + xOffs, b->y + yOffs, highlight ? 6 : 15, 0);
+ else
+ _screen->printShadedText(s, b->x + xOffs, b->y + yOffs, highlight ? 6 : 15, 0);
+ }
+}
+
+void GUI_Eob::drawMenuButtonBox(int x, int y, int w, int h, bool clicked, bool noFill) {
+ uint8 col1 = _vm->_color1_1;
+ uint8 col2 = _vm->_color2_1;
+
+ if (clicked)
+ col1 = col2 = _vm->_bkgColor_1;
+
+ _vm->gui_drawBox(x, y, w, h, col1, col2, -1);
+ _vm->gui_drawBox(x + 1, y + 1, w - 2, h - 2, _vm->_color1_1, _vm->_color2_1, noFill ? -1 : _vm->_bkgColor_1);
+}
+
+void GUI_Eob::displayTextBox(int id) {
+
+}
+
+void GUI_Eob::updateOptionsStrings() {
+ for (int i = 0; i < 4; i++) {
+ delete _menuStringsPrefsTemp[i];
+ _menuStringsPrefsTemp[i] = new char[strlen(_vm->_menuStringsPrefs[i]) + 8];
+ }
+
+ Common::strlcpy(_menuStringsPrefsTemp[0], Common::String::format(_vm->_menuStringsPrefs[0], _vm->_menuStringsOnOff[_vm->_configMusic ? 0 : 1]).c_str(), strlen(_vm->_menuStringsPrefs[0]) + 8);
+ Common::strlcpy(_menuStringsPrefsTemp[1], Common::String::format(_vm->_menuStringsPrefs[1], _vm->_menuStringsOnOff[_vm->_configSounds ? 0 : 1]).c_str(), strlen(_vm->_menuStringsPrefs[1]) + 8);
+ Common::strlcpy(_menuStringsPrefsTemp[2], Common::String::format(_vm->_menuStringsPrefs[2], _vm->_menuStringsOnOff[_vm->_configHpBarGraphs ? 0 : 1]).c_str(), strlen(_vm->_menuStringsPrefs[2]) + 8);
+ Common::strlcpy(_menuStringsPrefsTemp[3], Common::String::format(_vm->_menuStringsPrefs[3], _vm->_menuStringsOnOff[_vm->_configMouse ? 0 : 1]).c_str(), strlen(_vm->_menuStringsPrefs[3]) + 8);
+}
+
+const char *GUI_Eob::getMenuString(int id) {
+ if (id >= 69)
+ return _vm->_menuStringsTransfer[id - 69];
+ else if (id >= 67)
+ return _vm->_menuStringsDefeat[id - 67];
+ else if (id >= 63)
+ return _vm->_menuStringsSpec[id - 63];
+ else if (id >= 60)
+ return _vm->_menuStringsSpellNo[id - 60];
+ else if (id == 59)
+ return _vm->_menuStringsPoison[0];
+ else if (id >= 56)
+ return _vm->_menuStringsHead[id - 56];
+ else if (id >= 53)
+ return _vm->_menuStringsDrop2[id - 53];
+ else if (id >= 48)
+ return _vm->_menuStringsScribe[id - 48];
+ else if (id == 47)
+ _vm->_menuStringsStarve[0];
+ else if (id == 46)
+ _vm->_menuStringsExit[0];
+ else if (id == 45)
+ _vm->_menuStringsDrop[0];
+ else if (id >= 40)
+ return _vm->_menuStringsRest[id - 40];
+ else if (id >= 23)
+ return _vm->_menuStringsSpells[id - 23];
+ else if (id >= 21)
+ return _vm->_menuStringsOnOff[id - 21];
+ else if (id >= 17)
+ return _menuStringsPrefsTemp[id - 17];
+ else if (id >= 9)
+ return _vm->_menuStringsSaveLoad[id - 9];
+ else if (id >= 1)
+ return _vm->_menuStringsMain[id - 1];
+ return 0;
+}
+
+Button *GUI_Eob::linkButton(Button *list, Button *newbt) {
+ if (!list) {
+ list = newbt;
+ return list;
+ }
+
+ if (!newbt)
+ return list;
+
+ Button *resList = list;
+ while (list->nextButton)
+ list = list->nextButton;
+ list->nextButton = newbt;
+ newbt->nextButton = 0;
+
+ return resList;
+}
+
+void GUI_Eob::releaseButtons(Button *list) {
+ while (list) {
+ Button *n = list->nextButton;
+ delete list;
+ list = n;
+ }
+}
+
#endif // ENABLE_EOB
} // End of namespace Kyra
diff --git a/engines/kyra/gui_eob.h b/engines/kyra/gui_eob.h
index 2ad69e700a..3eddee553b 100644
--- a/engines/kyra/gui_eob.h
+++ b/engines/kyra/gui_eob.h
@@ -39,6 +39,7 @@ class GUI_Eob : public GUI {
friend class CharacterGenerator;
public:
GUI_Eob(EobCoreEngine *vm);
+ virtual ~GUI_Eob();
void initStaticData() {}
@@ -49,15 +50,17 @@ public:
int redrawShadedButtonCallback(Button *button) { return 0; }
int redrawButtonCallback(Button *button) { return 0; }
- // general menu handling (main menu, character generation, ingame menus, etc.)
+ // Non button based menu handling (main menu, character generation)
void setupMenu(int sd, int maxItem, const char *const *strings, int32 menuItemsMask, int unk, int lineSpacing);
- int handleMenu(int sd, const char *const *strings, void *b, int32 menuItemsMask, int unk);
+ int handleMenu(int sd, const char *const *strings, void *b, int32 menuItemsMask, int unk);
int getMenuItem(int index, int32 menuItemsMask, int unk);
void menuFlashSelection(const char *str, int x, int y, int color1, int color2, int color3);
- int getTextInput(char *dest, int x, int y, int destMaxLen, int textColor1, int textColor2, int cursorColor);
+ // Button based menus (camp menu, options, save/load)
+ int runCampMenu();
+ int runLoadMenu(int x, int y);
- // int runMenu(Menu &menu);
+ int getTextInput(char *dest, int x, int y, int destMaxLen, int textColor1, int textColor2, int cursorColor);
// utilities for thumbnail creation
void createScreenThumbnail(Graphics::Surface &dst) {}
@@ -73,7 +76,17 @@ private:
//int getMenuCenterStringX(const char *str, int x1, int x2);
- int getInput();
+ //int getInput();
+ Button *initMenu(int id);
+
+ void drawMenuButton(Button *b, bool clicked, bool highlight, bool noFill);
+ void drawMenuButtonBox(int x, int y, int w, int h, bool clicked, bool noFill);
+ void displayTextBox(int id);
+ void updateOptionsStrings();
+ const char *getMenuString(int id);
+
+ Button *linkButton(Button *list, Button *newbt);
+ void releaseButtons(Button *list);
Button *getButtonListData() { return _menuButtons; }
Button *getScrollUpButton() { return &_scrollUpButton; }
@@ -89,7 +102,8 @@ private:
const char *getMenuItemTitle(const MenuItem &menuItem) { return 0; }
const char *getMenuItemLabel(const MenuItem &menuItem) { return 0; }
- Button _menuButtons[10];
+ //Button _menuButtons[10];
+ Button *_menuButtons;
Button _scrollUpButton;
Button _scrollDownButton;
//Menu _mainMenu, _gameOptions, _audioOptions, _choiceMenu, _loadMenu, _saveMenu, _deleteMenu, _savenameMenu, _deathMenu;
@@ -97,6 +111,8 @@ private:
//int _menuResult;
//char *_saveDescription;
+ char **_menuStringsPrefsTemp;
+
EobCoreEngine *_vm;
Screen_Eob *_screen;
diff --git a/engines/kyra/magic_eob.cpp b/engines/kyra/magic_eob.cpp
index 2c83c26b83..8b6de927bf 100644
--- a/engines/kyra/magic_eob.cpp
+++ b/engines/kyra/magic_eob.cpp
@@ -415,6 +415,10 @@ void EobCoreEngine::setSpellEventTimer(int spell, int timerBaseFactor, int timer
setCharEventTimer(_activeSpellCaster, countdown, -spell, updateExistingTimer);
}
+void EobCoreEngine::cleanupCharacterSpellList(int charIndex) {
+
+}
+
bool EobCoreEngine::magicObjectHit(EobFlyingObject *fo, int dcTimes, int dcPips, int dcOffs, int level) {
int ignoreAttackerId = fo->flags & 0x10;
int singleTargetCheckAdjacent = fo->flags & 1;
diff --git a/engines/kyra/screen_eob.cpp b/engines/kyra/screen_eob.cpp
index f6b0eafcf4..d3c2187177 100644
--- a/engines/kyra/screen_eob.cpp
+++ b/engines/kyra/screen_eob.cpp
@@ -91,8 +91,9 @@ const ScreenDim *Screen_Eob::getScreenDim(int dim) {
}
void Screen_Eob::modifyScreenDim(int dim, int x, int y, int w, int h) {
- delete _customDimTable[dim];
- _customDimTable[dim] = new ScreenDim;
+ if (!_customDimTable[dim])
+ _customDimTable[dim] = new ScreenDim;
+
memcpy(_customDimTable[dim], &_screenDimTable[dim], sizeof(ScreenDim));
_customDimTable[dim]->sx = x;
_customDimTable[dim]->sy = y;
diff --git a/engines/kyra/script_eob.cpp b/engines/kyra/script_eob.cpp
index 40656c575a..ef3a623e83 100644
--- a/engines/kyra/script_eob.cpp
+++ b/engines/kyra/script_eob.cpp
@@ -80,7 +80,9 @@ EobInfProcessor::EobInfProcessor(EobCoreEngine *engine, Screen_Eob *screen) : _v
_commandMin(engine->game() == GI_EOB1 ? -27 : -31) {
#define Opcode(x) _opcodes.push_back(new InfProc(this, &EobInfProcessor::x))
-#define OpcodeAlt(x, y) if (_vm->game() == GI_EOB1) Opcode(x); else Opcode(y);
+//#define OpcodeAltV(x, y) if (_vm->game() == GI_EOB1) Opcode(x); else Opcode(y);
+//#define OpcodeAlt(x) OpcodeAltV(x##_v1, x##_v2)
+#define OpcodeAlt(x) if (_vm->game() == GI_EOB1) Opcode(x##_v1); else Opcode(x##_v2);
Opcode(oeob_setWallType);
Opcode(oeob_toggleWallState);
Opcode(oeob_openDoor);
@@ -88,7 +90,7 @@ EobInfProcessor::EobInfProcessor(EobCoreEngine *engine, Screen_Eob *screen) : _v
Opcode(oeob_replaceMonster);
Opcode(oeob_movePartyOrObject);
Opcode(oeob_moveInventoryItemToBlock);
- OpcodeAlt(oeob_printMessage_v1, oeob_printMessage_v2);
+ OpcodeAlt(oeob_printMessage);
Opcode(oeob_setFlags);
Opcode(oeob_playSoundEffect);
Opcode(oeob_removeFlags);
@@ -98,11 +100,11 @@ EobInfProcessor::EobInfProcessor(EobCoreEngine *engine, Screen_Eob *screen) : _v
Opcode(oeob_end);
Opcode(oeob_popPosAndReturn);
Opcode(oeob_pushPosAndJump);
- OpcodeAlt(oeob_eval_v1, oeob_eval_v2);
+ OpcodeAlt(oeob_eval);
Opcode(oeob_deleteItem);
Opcode(oeob_loadNewLevelOrMonsters);
Opcode(oeob_increasePartyExperience);
- OpcodeAlt(oeob_createItem_v1, oeob_createItem_v2);
+ OpcodeAlt(oeob_createItem);
Opcode(oeob_launchObject);
Opcode(oeob_changeDirection);
Opcode(oeob_identifyItems);
@@ -112,6 +114,7 @@ EobInfProcessor::EobInfProcessor(EobCoreEngine *engine, Screen_Eob *screen) : _v
Opcode(oeob_dialogue);
Opcode(oeob_specialEvent);
#undef Opcode
+//#undef OpcodeAltV
#undef OpcodeAlt
_scriptData = 0;
diff --git a/engines/kyra/staticres_eob.cpp b/engines/kyra/staticres_eob.cpp
index da4e6752b0..bf06ba66bd 100644
--- a/engines/kyra/staticres_eob.cpp
+++ b/engines/kyra/staticres_eob.cpp
@@ -610,6 +610,64 @@ void EobCoreEngine::initButtonData() {
_buttonDefs = buttonDefs;
}
+void EobCoreEngine::initMenus() {
+ static const EobMenuButtonDef buttonDefs[] = {
+ { 2, 12, 20, 158, 14, 20, 3 },
+ { 3, 12, 37, 158, 14, 52, 3 },
+ { 4, 12, 54, 158, 14, 26, 3 },
+ { 5, 12, 71, 158, 14, 32, 3 },
+ { 6, 12, 88, 158, 14, 0, 3 },
+ { 7, 12, 105, 158, 14, 35, 3 },
+ { 8, 128, 122, 40, 14, 19, 7 },
+ { 9, 12, 20, 158, 14, 39, 3 },
+ { 10, 12, 37, 158, 14, 32, 3 },
+ { 11, 12, 54, 158, 14, 33, 3 },
+ { 12, 12, 71, 158, 14, 17, 3 },
+ { 8, 128, 122, 40, 14, 19, 7 },
+ { 18, 12, 20, 158, 14, 32, 3 },
+ { 19, 12, 37, 158, 14, 50, 3 },
+ { 8, 128, 122, 40, 14, 19, 7 },
+ { 8, 128, 122, 40, 14, 19, 5 },
+ { 0, 184, 0, 64, 48, 112, 0 },
+ { 0, 256, 0, 64, 48, 113, 0 },
+ { 0, 184, 56, 64, 48, 114, 0 },
+ { 0, 256, 56, 64, 48, 115, 0 },
+ { 0, 184, 112, 64, 48, 116, 0 },
+ { 0, 256, 112, 64, 48, 117, 0 },
+ { 36, 8, 126, 48, 14, 48, 5 },
+ { 8, 128, 126, 40, 14, 19, 5 },
+ { 0, 0, 50, 168, 72, 61, 0 },
+ { 31, 11, 16, 20, 18, 2, 5 },
+ { 32, 38, 16, 20, 18, 3, 5 },
+ { 33, 65, 16, 20, 18, 4, 5 },
+ { 34, 92, 16, 20, 18, 5, 5 },
+ { 35, 119, 16, 20, 18, 6, 5 },
+ { 60, 146, 16, 20, 18, 7, 5 },
+ { 61, 150, 16, 20, 18, 8, 5 },
+ { 38, 16, 57, 32, 14, 22, 7 },
+ { 39, 128, 57, 32, 14, 51, 7 },
+ { 8, 128, 126, 40, 14, 19, 7 },
+ { 0, 0, 50, 168, 72, 61, 0 }
+ };
+
+ _menuButtonDefs = buttonDefs;
+
+ static const EobMenuDef menuDefs[] = {
+ { 1, 10, 0, 7, 9 },
+ { 1, 10, 7, 5, 9 },
+ { 1, 10, 12, 3, 9 },
+ { 0, 10, 15, 7, 15 },
+ { 37, 10, 22, 9, 9 },
+ { 0, 11, 32, 2, 15 },
+ { 48, 10, 34, 2, 9 }
+ };
+
+ delete[] _menuDefs;
+ _menuDefs = new EobMenuDef[ARRAYSIZE(menuDefs)];
+ memcpy(_menuDefs, menuDefs, sizeof(menuDefs));
+}
+
+
void EobCoreEngine::initSpells() {
#define mpn magicTimingParaAssign.push_back(0);
#define mp1n if (_flags.gameID == GI_EOB1) magicTimingParaAssign.push_back(0);