From a612dd686c27303bdbe6b2dba89aef79bc8db8e0 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Mon, 9 Feb 2015 22:01:01 -0500 Subject: XEEN: Further refactoring for party dialog setup --- engines/xeen/dialogs_party.cpp | 36 +++++++++++++----------------------- engines/xeen/interface.cpp | 22 ---------------------- engines/xeen/interface.h | 4 ---- engines/xeen/party.cpp | 4 ++-- engines/xeen/party.h | 2 +- engines/xeen/screen.cpp | 16 ++++++++++++++++ engines/xeen/screen.h | 2 ++ 7 files changed, 34 insertions(+), 52 deletions(-) (limited to 'engines/xeen') diff --git a/engines/xeen/dialogs_party.cpp b/engines/xeen/dialogs_party.cpp index aa8d58f32b..3da4a2ae3a 100644 --- a/engines/xeen/dialogs_party.cpp +++ b/engines/xeen/dialogs_party.cpp @@ -40,6 +40,7 @@ void PartyDialog::execute() { Map &map = *_vm->_map; Party &party = *_vm->_party; Screen &screen = *_vm->_screen; + bool modeFlag = false; loadButtons(); setupBackground(); @@ -73,10 +74,7 @@ void PartyDialog::execute() { _iconSprites.draw(w, 10, Common::Point(192, 100)); screen.loadPalette("mm4.pal"); - /* - - - if (flag) { + if (modeFlag) { screen._windows[0].update(); events.setCursor(0); screen.fadeIn(4); @@ -94,7 +92,6 @@ void PartyDialog::execute() { } } - // TODO bool breakFlag = false; while (!_vm->shouldQuit() && !breakFlag) { events.pollEventsAndWait(); @@ -105,13 +102,13 @@ void PartyDialog::execute() { case Common::KEYCODE_SPACE: case Common::KEYCODE_e: case Common::KEYCODE_x: - if (_vm->_party->_partyCount == 0) { + if (party._partyCount == 0) { ErrorScroll::show(_vm, NO_ONE_TO_ADVENTURE_WITH); } else { if (_vm->_mode != MODE_0) { - for (_intrIndex1 = 4; _intrIndex1 >= 0; --_intrIndex1) { + for (int idx = 4; idx >= 0; --idx) { events.updateGameCounter(); - drawViewBackground(_intrIndex1); + screen.frameWindow(idx); w.update(); while (events.timeElapsed() < 1) @@ -120,10 +117,10 @@ void PartyDialog::execute() { } w.close(); - _vm->_party->_realPartyCount = _vm->_party->_partyCount; - _vm->_party->_mazeId = _vm->_party->_priorMazeId; + party._realPartyCount = party._partyCount; + party._mazeId = party._priorMazeId; - _vm->_party->copyPartyToRoster(_vm->_roster); + party.copyPartyToRoster(); _vm->_saves->writeCharFile(); breakFlag = true; break; @@ -143,18 +140,17 @@ void PartyDialog::execute() { } else { screen.fadeOut(4); w.close(); - moveCharacterToRoster(); + party.copyPartyToRoster(); _vm->_saves->writeCharFile(); screen.fadeOut(4); - flag = true; - _buttonsLoaded = true; - goto start; + modeFlag = true; + breakFlag = true; } break; case Common::KEYCODE_d: break; case Common::KEYCODE_r: - if (_vm->_party->_partyCount > 0) { + if (party._partyCount > 0) { // TODO } break; @@ -187,12 +183,6 @@ void PartyDialog::execute() { } } } - - for (int i = 0; i < TOTAL_CHARACTERS; ++i) - _charFaces[i].clear(); - */ - // TODO - } } void PartyDialog::loadButtons() { @@ -237,7 +227,7 @@ void PartyDialog::setupFaces(int charIndex, Common::Array xeenSideChars, bo for (posIndex = 0; posIndex < 4; ++posIndex) { charId = xeenSideChars[charIndex]; - bool isInParty = _vm->_party->isInParty(charId); + bool isInParty = party.isInParty(charId); if (charId == 0xff) { while ((int)_buttons.size() >(7 + posIndex)) diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp index 8aa938b583..13a12f085a 100644 --- a/engines/xeen/interface.cpp +++ b/engines/xeen/interface.cpp @@ -85,7 +85,6 @@ void Interface::loadPartyIcons() { } void Interface::charIconsPrint(bool updateFlag) { - Resources &res = *_vm->_resources; Screen &screen = *_vm->_screen; bool stateFlag = _vm->_mode == MODE_COMBAT; _restoreSprites.draw(screen, 0, Common::Point(8, 149)); @@ -153,27 +152,6 @@ void Interface::sortFaces() { } } -void Interface::drawViewBackground(int bgType) { - if (bgType >= 4) - return; - - if (bgType == 0) { - // Totally black background - _vm->_screen->fillRect(Common::Rect(8, 8, 224, 140), 0); - } else { - const byte *lookup = BACKGROUND_XLAT + bgType; - for (int yp = 8; yp < 140; ++yp) { - byte *destP = (byte *)_vm->_screen->getBasePtr(8, yp); - for (int xp = 8; xp < 224; ++xp, ++destP) - *destP = lookup[*destP]; - } - } -} - -void Interface::moveCharacterToRoster() { - error("TODO"); -} - void Interface::startup() { Screen &screen = *_vm->_screen; _iconSprites.load("main.icn"); diff --git a/engines/xeen/interface.h b/engines/xeen/interface.h index cce2eaaa30..3d496aa2b1 100644 --- a/engines/xeen/interface.h +++ b/engines/xeen/interface.h @@ -57,10 +57,6 @@ private: void setupBackground(); - void drawViewBackground(int bgType); - - void moveCharacterToRoster(); - void setMainButtons(); void chargeStep(); diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp index 5cf5181142..6bff8fd995 100644 --- a/engines/xeen/party.cpp +++ b/engines/xeen/party.cpp @@ -231,9 +231,9 @@ bool Party::isInParty(int charId) { return false; } -void Party::copyPartyToRoster(Roster &r) { +void Party::copyPartyToRoster() { for (int i = 0; i < _partyCount; ++i) { - r[_partyMembers[i]] = _activeParty[i]; + _roster[_partyMembers[i]] = _activeParty[i]; } } diff --git a/engines/xeen/party.h b/engines/xeen/party.h index 1382969477..c37a673ee5 100644 --- a/engines/xeen/party.h +++ b/engines/xeen/party.h @@ -138,7 +138,7 @@ public: bool isInParty(int charId); - void copyPartyToRoster(Roster &r); + void copyPartyToRoster(); void changeTime(int numMinutes); diff --git a/engines/xeen/screen.cpp b/engines/xeen/screen.cpp index bb2f356f1b..3b3ea6969b 100644 --- a/engines/xeen/screen.cpp +++ b/engines/xeen/screen.cpp @@ -481,5 +481,21 @@ void Screen::restoreBackground(int slot) { _savedScreens[slot - 1].blitTo(*this); } +void Screen::frameWindow(uint bgType) { + if (bgType >= 4) + return; + + if (bgType == 0) { + // Totally black background + _vm->_screen->fillRect(Common::Rect(8, 8, 224, 140), 0); + } else { + const byte *lookup = BACKGROUND_XLAT + bgType; + for (int yp = 8; yp < 140; ++yp) { + byte *destP = (byte *)_vm->_screen->getBasePtr(8, yp); + for (int xp = 8; xp < 224; ++xp, ++destP) + *destP = lookup[*destP]; + } + } +} } // End of namespace Xeen diff --git a/engines/xeen/screen.h b/engines/xeen/screen.h index e3ced06236..526fd6f845 100644 --- a/engines/xeen/screen.h +++ b/engines/xeen/screen.h @@ -156,6 +156,8 @@ public: void saveBackground(int slot = 1); void restoreBackground(int slot = 1); + + void frameWindow(uint bgType); }; } // End of namespace Xeen -- cgit v1.2.3