aboutsummaryrefslogtreecommitdiff
path: root/engines/xeen/interface.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/xeen/interface.cpp')
-rw-r--r--engines/xeen/interface.cpp246
1 files changed, 112 insertions, 134 deletions
diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp
index b9f1e2bb2c..5d667e3a2c 100644
--- a/engines/xeen/interface.cpp
+++ b/engines/xeen/interface.cpp
@@ -39,6 +39,10 @@
namespace Xeen {
+enum {
+ SCENE_WINDOW = 11, SCENE_WIDTH = 216, SCENE_HEIGHT = 132
+};
+
PartyDrawer::PartyDrawer(XeenEngine *vm): _vm(vm) {
_restoreSprites.load("restorex.icn");
_hpSprites.load("hpbars.icn");
@@ -136,7 +140,7 @@ Interface::Interface(XeenEngine *vm) : ButtonContainer(vm), InterfaceScene(vm),
_buttonsLoaded = false;
_obscurity = OBSCURITY_NONE;
_steppingFX = 0;
- _falling = false;
+ _falling = FALL_NONE;
_blessedUIFrame = 0;
_powerShieldUIFrame = 0;
_holyBonusUIFrame = 0;
@@ -151,27 +155,6 @@ Interface::Interface(XeenEngine *vm) : ButtonContainer(vm), InterfaceScene(vm),
_upDoorText = false;
_tillMove = 0;
Common::fill(&_charFX[0], &_charFX[MAX_ACTIVE_PARTY], 0);
-
- initDrawStructs();
-}
-
-void Interface::initDrawStructs() {
- _mainList[0] = DrawStruct(7, 232, 74);
- _mainList[1] = DrawStruct(0, 235, 75);
- _mainList[2] = DrawStruct(2, 260, 75);
- _mainList[3] = DrawStruct(4, 286, 75);
- _mainList[4] = DrawStruct(6, 235, 96);
- _mainList[5] = DrawStruct(8, 260, 96);
- _mainList[6] = DrawStruct(10, 286, 96);
- _mainList[7] = DrawStruct(12, 235, 117);
- _mainList[8] = DrawStruct(14, 260, 117);
- _mainList[9] = DrawStruct(16, 286, 117);
- _mainList[10] = DrawStruct(20, 235, 148);
- _mainList[11] = DrawStruct(22, 260, 148);
- _mainList[12] = DrawStruct(24, 286, 148);
- _mainList[13] = DrawStruct(26, 235, 169);
- _mainList[14] = DrawStruct(28, 260, 169);
- _mainList[15] = DrawStruct(30, 286, 169);
}
void Interface::setup() {
@@ -181,6 +164,8 @@ void Interface::setup() {
_blessSprites.load("bless.icn");
_charPowSprites.load("charpow.icn");
_uiSprites.load("inn.icn");
+ _stdIcons.load("main.icn");
+ _combatIcons.load("combat.icn");
Party &party = *_vm->_party;
party.loadActiveParty();
@@ -190,7 +175,6 @@ void Interface::setup() {
void Interface::startup() {
Resources &res = *_vm->_resources;
Windows &windows = *_vm->_windows;
- _iconSprites.load("main.icn");
animate3d();
if (_vm->_map->_isOutdoors) {
@@ -204,50 +188,50 @@ void Interface::startup() {
res._globalSprites.draw(windows[1], 5, Common::Point(232, 9));
drawParty(false);
-
- _mainList[0]._sprites = &res._globalSprites;
- for (int i = 1; i < 16; ++i)
- _mainList[i]._sprites = &_iconSprites;
-
setMainButtons();
_tillMove = false;
}
void Interface::mainIconsPrint() {
+ Resources &res = *_vm->_resources;
Windows &windows = *_vm->_windows;
windows[38].close();
windows[12].close();
- windows[0].drawList(_mainList, 16);
+
+ res._globalSprites.draw(0, 7, Common::Point(232, 74));
+ drawButtons(&windows[0]);
windows[34].update();
}
-void Interface::setMainButtons(bool combatMode) {
+void Interface::setMainButtons(IconsMode mode) {
clearButtons();
-
- addButton(Common::Rect(235, 75, 259, 95), Common::KEYCODE_s, &_iconSprites);
- addButton(Common::Rect(260, 75, 284, 95), Common::KEYCODE_c, &_iconSprites);
- addButton(Common::Rect(286, 75, 310, 95), Common::KEYCODE_r, &_iconSprites);
- addButton(Common::Rect(235, 96, 259, 116), Common::KEYCODE_b, &_iconSprites);
- addButton(Common::Rect(260, 96, 284, 116), Common::KEYCODE_d, &_iconSprites);
- addButton(Common::Rect(286, 96, 310, 116), Common::KEYCODE_v, &_iconSprites);
- addButton(Common::Rect(235, 117, 259, 137), Common::KEYCODE_m, &_iconSprites);
- addButton(Common::Rect(260, 117, 284, 137), Common::KEYCODE_i, &_iconSprites);
- addButton(Common::Rect(286, 117, 310, 137), Common::KEYCODE_q, &_iconSprites);
- addButton(Common::Rect(109, 137, 122, 147), Common::KEYCODE_TAB, &_iconSprites);
- addButton(Common::Rect(235, 148, 259, 168), Common::KEYCODE_LEFT, &_iconSprites);
- addButton(Common::Rect(260, 148, 284, 168), Common::KEYCODE_UP, &_iconSprites);
- addButton(Common::Rect(286, 148, 310, 168), Common::KEYCODE_RIGHT, &_iconSprites);
- addButton(Common::Rect(235, 169, 259, 189), (Common::KBD_CTRL << 16) |Common::KEYCODE_LEFT, &_iconSprites);
- addButton(Common::Rect(260, 169, 284, 189), Common::KEYCODE_DOWN, &_iconSprites);
- addButton(Common::Rect(286, 169, 310, 189), (Common::KBD_CTRL << 16) | Common::KEYCODE_RIGHT, &_iconSprites);
+ _iconsMode = mode;
+ SpriteResource *spr = mode == ICONS_COMBAT ? &_combatIcons : &_stdIcons;
+
+ addButton(Common::Rect(235, 75, 259, 95), Common::KEYCODE_s, spr);
+ addButton(Common::Rect(260, 75, 284, 95), Common::KEYCODE_c, spr);
+ addButton(Common::Rect(286, 75, 310, 95), Common::KEYCODE_r, spr);
+ addButton(Common::Rect(235, 96, 259, 116), Common::KEYCODE_b, spr);
+ addButton(Common::Rect(260, 96, 284, 116), Common::KEYCODE_d, spr);
+ addButton(Common::Rect(286, 96, 310, 116), Common::KEYCODE_v, spr);
+ addButton(Common::Rect(235, 117, 259, 137), Common::KEYCODE_m, spr);
+ addButton(Common::Rect(260, 117, 284, 137), Common::KEYCODE_i, spr);
+ addButton(Common::Rect(286, 117, 310, 137), Common::KEYCODE_q, spr);
+ addButton(Common::Rect(109, 137, 122, 147), Common::KEYCODE_TAB, spr);
+ addButton(Common::Rect(235, 148, 259, 168), Common::KEYCODE_LEFT, spr);
+ addButton(Common::Rect(260, 148, 284, 168), Common::KEYCODE_UP, spr);
+ addButton(Common::Rect(286, 148, 310, 168), Common::KEYCODE_RIGHT, spr);
+ addButton(Common::Rect(235, 169, 259, 189), (Common::KBD_CTRL << 16) |Common::KEYCODE_LEFT, spr);
+ addButton(Common::Rect(260, 169, 284, 189), Common::KEYCODE_DOWN, spr);
+ addButton(Common::Rect(286, 169, 310, 189), (Common::KBD_CTRL << 16) | Common::KEYCODE_RIGHT, spr);
addButton(Common::Rect(236, 11, 308, 69), Common::KEYCODE_EQUALS);
addButton(Common::Rect(239, 27, 312, 37), Common::KEYCODE_1);
addButton(Common::Rect(239, 37, 312, 47), Common::KEYCODE_2);
addButton(Common::Rect(239, 47, 312, 57), Common::KEYCODE_3);
addPartyButtons(_vm);
- if (combatMode) {
+ if (mode == ICONS_COMBAT) {
_buttons[0]._value = Common::KEYCODE_f;
_buttons[1]._value = Common::KEYCODE_c;
_buttons[2]._value = Common::KEYCODE_a;
@@ -659,7 +643,7 @@ void Interface::doStepCode() {
// We can fly, we can.. oh wait, we can't!
damage = 100;
party._damageType = DT_PHYSICAL;
- _falling = true;
+ _falling = FALL_IN_PROGRESS;
break;
case SURFTYPE_DESERT:
// Without navigation skills, simulate getting lost by adding extra time
@@ -669,7 +653,7 @@ void Interface::doStepCode() {
case SURFTYPE_CLOUD:
if (!party._levitateCount) {
party._damageType = DT_PHYSICAL;
- _falling = true;
+ _falling = FALL_IN_PROGRESS;
damage = 100;
}
break;
@@ -678,9 +662,9 @@ void Interface::doStepCode() {
}
if (_vm->_files->_isDarkCc && party._gameFlags[1][118]) {
- _falling = false;
+ _falling = FALL_NONE;
} else {
- if (_falling)
+ if (_falling != FALL_NONE)
startFalling(false);
if ((party._mazePosition.x & 16) || (party._mazePosition.y & 16)) {
@@ -712,32 +696,19 @@ void Interface::startFalling(bool flag) {
bool isDarkCc = _vm->_files->_isDarkCc;
if (isDarkCc && party._gameFlags[1][118]) {
- _falling = 0;
+ _falling = FALL_NONE;
return;
}
- _falling = false;
+ _falling = FALL_NONE;
draw3d(true);
- _falling = 2;
+ _falling = FALL_START;
draw3d(false);
- if (flag) {
- if (!isDarkCc || party._fallMaze != 0) {
- party._mazeId = party._fallMaze;
- party._mazePosition = party._fallPosition;
- }
- }
-
- _falling = true;
- map.load(party._mazeId);
- if (flag) {
- if (((party._mazePosition.x & 16) || (party._mazePosition.y & 16)) &&
- map._isOutdoors) {
- map.getNewMaze();
- }
- }
-
- if (isDarkCc) {
+ if (flag && (!isDarkCc || party._fallMaze != 0)) {
+ party._mazeId = party._fallMaze;
+ party._mazePosition = party._fallPosition;
+ } else if (!isDarkCc) {
switch (party._mazeId - 25) {
case 0:
case 26:
@@ -908,14 +879,22 @@ void Interface::startFalling(bool flag) {
}
}
- _flipGround ^= 1;
- draw3d(true);
- int tempVal = scripts._v2;
- scripts._v2 = 0;
- combat.giveCharDamage(party._fallDamage, DT_PHYSICAL, 0);
- scripts._v2 = tempVal;
+ _falling = FALL_IN_PROGRESS;
+ map.load(party._mazeId);
- _flipGround ^= 1;
+ if (flag) {
+ if (map._isOutdoors && ((party._mazePosition.x & 16) || (party._mazePosition.y & 16)))
+ map.getNewMaze();
+
+ _flipGround ^= 1;
+ draw3d(true);
+ int tempVal = scripts._v2;
+ scripts._v2 = 0;
+ combat.giveCharDamage(party._fallDamage, DT_PHYSICAL, 0);
+
+ scripts._v2 = tempVal;
+ _flipGround ^= 1;
+ }
}
bool Interface::checkMoveDirection(int key) {
@@ -1240,12 +1219,11 @@ void Interface::draw3d(bool updateFlag, bool pauseFlag) {
Combat &combat = *_vm->_combat;
EventsManager &events = *_vm->_events;
Party &party = *_vm->_party;
- Screen &screen = *_vm->_screen;
Scripts &scripts = *_vm->_scripts;
Windows &windows = *_vm->_windows;
events.timeMark5();
- if (windows[11]._enabled)
+ if (windows[SCENE_WINDOW]._enabled)
return;
_flipUIFrame = (_flipUIFrame + 1) % 4;
@@ -1266,11 +1244,11 @@ void Interface::draw3d(bool updateFlag, bool pauseFlag) {
// Handle any darkness-based oscurity
obscureScene(_obscurity);
- if (_falling == 1)
+ if (_falling == FALL_IN_PROGRESS)
handleFalling();
- if (_falling == 2) {
- screen.saveBackground(1);
+ if (_falling == FALL_START) {
+ setupFallSurface(true);
}
assembleBorder();
@@ -1301,14 +1279,19 @@ void Interface::draw3d(bool updateFlag, bool pauseFlag) {
}
void Interface::handleFalling() {
+ EventsManager &events = *g_vm->_events;
Party &party = *_vm->_party;
+ Screen &screen = *_vm->_screen;
Sound &sound = *_vm->_sound;
Windows &windows = *_vm->_windows;
Window &w = windows[3];
- saveFall();
+ // Set the bottom half of the fall surface (area that is being fallen to)
+ setupFallSurface(false);
+
+ // Update character faces and start scream
for (uint idx = 0; idx < party._activeParty.size(); ++idx) {
- party._activeParty[idx]._faceSprites->draw(windows[0], 4,
+ party._activeParty[idx]._faceSprites->draw(0, 4,
Common::Point(Res.CHAR_FACES_X[idx], 150));
}
@@ -1316,45 +1299,42 @@ void Interface::handleFalling() {
sound.playFX(11);
sound.playSound("scream.voc");
- for (int idx = 0, incr = 2; idx < 133; ++incr, idx += incr) {
- fall(idx);
+ // Fall down to the ground
+ #define YINDEX (SCENE_HEIGHT / 2)
+ const int Y_LIST[] = {
+ SCENE_HEIGHT, SCENE_HEIGHT - 5, SCENE_HEIGHT, SCENE_HEIGHT - 3, SCENE_HEIGHT
+ };
+ for (int idx = 1; idx < YINDEX + 5; ++idx) {
+ fall((idx < YINDEX) ? idx * 2 : Y_LIST[idx - YINDEX]);
assembleBorder();
w.update();
- }
+ screen.update();
+ g_system->delayMillis(5);
- fall(132);
- assembleBorder();
- w.update();
-
- sound.stopSound();
- sound.playSound("unnh.voc");
- sound.playFX(31);
-
- fall(127);
- assembleBorder();
- w.update();
-
- fall(132);
- assembleBorder();
- w.update();
-
- fall(129);
- assembleBorder();
- w.update();
-
- fall(132);
- assembleBorder();
- w.update();
+ if (idx == YINDEX) {
+ sound.stopSound();
+ sound.playSound("unnh.voc");
+ sound.playFX(31);
+ }
+ }
shake(10);
+
+ _falling = FALL_NONE;
+ drawParty(true);
}
-void Interface::saveFall() {
- // TODO
+void Interface::setupFallSurface(bool isTop) {
+ Window &w = (*g_vm->_windows)[SCENE_WINDOW];
+
+ if (_fallSurface.empty())
+ _fallSurface.create(SCENE_WIDTH, SCENE_HEIGHT * 2);
+ _fallSurface.blitFrom(w, w.getBounds(), Common::Point(0, isTop ? 0 : SCENE_HEIGHT));
}
-void Interface::fall(int v) {
- // TODO
+void Interface::fall(int yp) {
+ Window &w = (*g_vm->_windows)[SCENE_WINDOW];
+ w.blitFrom(_fallSurface, Common::Rect(0, yp, SCENE_WIDTH, yp + SCENE_HEIGHT), Common::Point(8, 8));
}
void Interface::shake(int time) {
@@ -1487,12 +1467,9 @@ void Interface::doCombat() {
combat._combatMode = COMBATMODE_2;
_vm->_mode = MODE_COMBAT;
- _iconSprites.load("combat.icn");
- for (int idx = 1; idx < 16; ++idx)
- _mainList[idx]._sprites = &_iconSprites;
-
// Set the combat buttons
- setMainButtons(true);
+ IconsMode oldMode = _iconsMode;
+ setMainButtons(ICONS_COMBAT);
mainIconsPrint();
combat._combatParty.clear();
@@ -1501,7 +1478,7 @@ void Interface::doCombat() {
combat._charsArray1[0] = 0;
combat._charsArray1[1] = 0;
combat._charsArray1[2] = 0;
- combat._monstersAttacking = 0;
+ combat._monstersAttacking = false;
combat._partyRan = false;
// Set up the combat party
@@ -1537,8 +1514,8 @@ void Interface::doCombat() {
// Write out the description of the monsters being battled
w.writeString(combat.getMonsterDescriptions());
- _iconSprites.draw(0, 32, Common::Point(233, combat._monsterIndex * 10 + 27),
- 0x8010000);
+ _combatIcons.draw(0, 32, Common::Point(233, combat._monsterIndex * 10 + 27),
+ SPRFLAG_800, 1);
w.update();
// Wait for keypress
@@ -1637,7 +1614,9 @@ void Interface::doCombat() {
nextChar();
if (_vm->_mode == MODE_1) {
- warning("TODO: loss of treasure");
+ party._treasure._gems = 0;
+ party._treasure._gold = 0;
+ party._treasure._hasItems = false;
party.moveToRunLocation();
breakFlag = true;
}
@@ -1699,7 +1678,9 @@ void Interface::doCombat() {
for (uint idx = 0; idx < map._mobData._monsters.size(); ++idx) {
MazeMonster &monster = map._mobData._monsters[idx];
if (monster._spriteId == 53) {
- warning("TODO: Monster 53's HP is altered here?!");
+ // For Medusa sprites, their HP keeps getting reset
+ MonsterStruct &monsData = map._monsterData[53];
+ monster._hp = monsData._hp;
}
}
@@ -1752,11 +1733,8 @@ void Interface::doCombat() {
drawParty(true);
}
- _iconSprites.load("main.icn");
- for (int idx = 1; idx < 16; ++idx)
- _mainList[idx]._sprites = &_iconSprites;
-
- setMainButtons();
+ // Restore old icons
+ setMainButtons(oldMode);
mainIconsPrint();
combat._monster2Attack = -1;
@@ -1815,7 +1793,7 @@ void Interface::nextChar() {
if (combat._whosTurn < (int)combat._combatParty.size()) {
// If it's a party member, only allow them to become active if
// they're still conscious
- if (combat._combatParty[idx]->isDisabledOrDead())
+ if (combat._combatParty[combat._whosTurn]->isDisabledOrDead())
continue;
}
@@ -1888,11 +1866,11 @@ void Interface::spellFX(Character *c) {
_spellFxSprites.draw(0, frameNum, Common::Point(
Res.CHAR_FACES_X[charIndex], 150));
- if (!windows[11]._enabled)
+ if (!windows[SCENE_WINDOW]._enabled)
draw3d(false);
windows[0].update();
- events.wait(windows[11]._enabled ? 2 : 1,false);
+ events.wait(windows[SCENE_WINDOW]._enabled ? 2 : 1,false);
}
drawParty(true);