Skip to content

Commit

Permalink
XEEN: Further refactoring for party dialog setup
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Feb 10, 2015
1 parent c798a55 commit a612dd6
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 52 deletions.
36 changes: 13 additions & 23 deletions engines/xeen/dialogs_party.cpp
Expand Up @@ -40,6 +40,7 @@ void PartyDialog::execute() {
Map &map = *_vm->_map;
Party &party = *_vm->_party;
Screen &screen = *_vm->_screen;
bool modeFlag = false;

loadButtons();
setupBackground();
Expand Down Expand Up @@ -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);
Expand All @@ -94,7 +92,6 @@ void PartyDialog::execute() {
}
}

// TODO
bool breakFlag = false;
while (!_vm->shouldQuit() && !breakFlag) {
events.pollEventsAndWait();
Expand All @@ -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)
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -187,12 +183,6 @@ void PartyDialog::execute() {
}
}
}
for (int i = 0; i < TOTAL_CHARACTERS; ++i)
_charFaces[i].clear();
*/
// TODO
}
}

void PartyDialog::loadButtons() {
Expand Down Expand Up @@ -237,7 +227,7 @@ void PartyDialog::setupFaces(int charIndex, Common::Array<int> 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))
Expand Down
22 changes: 0 additions & 22 deletions engines/xeen/interface.cpp
Expand Up @@ -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));
Expand Down Expand Up @@ -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");
Expand Down
4 changes: 0 additions & 4 deletions engines/xeen/interface.h
Expand Up @@ -57,10 +57,6 @@ class Interface: public ButtonContainer, public InterfaceMap {

void setupBackground();

void drawViewBackground(int bgType);

void moveCharacterToRoster();

void setMainButtons();

void chargeStep();
Expand Down
4 changes: 2 additions & 2 deletions engines/xeen/party.cpp
Expand Up @@ -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];
}
}

Expand Down
2 changes: 1 addition & 1 deletion engines/xeen/party.h
Expand Up @@ -138,7 +138,7 @@ class Party {

bool isInParty(int charId);

void copyPartyToRoster(Roster &r);
void copyPartyToRoster();

void changeTime(int numMinutes);

Expand Down
16 changes: 16 additions & 0 deletions engines/xeen/screen.cpp
Expand Up @@ -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
2 changes: 2 additions & 0 deletions engines/xeen/screen.h
Expand Up @@ -156,6 +156,8 @@ class Screen: public FontSurface {
void saveBackground(int slot = 1);

void restoreBackground(int slot = 1);

void frameWindow(uint bgType);
};

} // End of namespace Xeen
Expand Down

0 comments on commit a612dd6

Please sign in to comment.