Skip to content

Commit

Permalink
XEEN: Implemented Exchange character dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Feb 1, 2015
1 parent d855aa0 commit 3ae4958
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 8 deletions.
16 changes: 9 additions & 7 deletions engines/xeen/dialogs_char_info.cpp
Expand Up @@ -21,6 +21,7 @@
*/

#include "xeen/dialogs_char_info.h"
#include "xeen/dialogs_exchange.h"
#include "xeen/resources.h"
#include "xeen/xeen.h"

Expand All @@ -38,7 +39,7 @@ void CharacterInfo::execute(int charIndex) {
Interface &intf = *_vm->_interface;
Party &party = *_vm->_party;

bool redrawFlag = false;
bool redrawFlag = true;
Mode oldMode = _vm->_mode;
_vm->_mode = MODE_CHARACTER_INFO;
loadDrawStructs();
Expand All @@ -60,17 +61,19 @@ void CharacterInfo::execute(int charIndex) {

// Wait for keypress, showing a blinking cursor
events.updateGameCounter();
bool cursorFlag = false;
while (!_vm->shouldQuit() && !events.isKeyMousePressed()) {
bool cursorFlag = false;
_buttonValue = 0;
while (!_vm->shouldQuit() && !_buttonValue) {
events.pollEventsAndWait();
if (events.timeElapsed() > 4) {
cursorFlag = !cursorFlag;
events.updateGameCounter();
}

showCursor(cursorFlag);
w.update();
checkEvents(_vm);
}
checkEvents(_vm);
events.clearEvents();

switch (_buttonValue) {
Expand All @@ -84,8 +87,7 @@ void CharacterInfo::execute(int charIndex) {
if (_buttonValue < (int)(oldMode == MODE_InCombat ? party._combatParty.size() : party._activeParty.size())) {
charIndex = _buttonValue;
c = (oldMode != MODE_InCombat) ? &party._activeParty[charIndex] : party._combatParty[charIndex];
}
else {
} else {
_iconSprites.load("view.icn");
_vm->_mode = MODE_CHARACTER_INFO;
}
Expand Down Expand Up @@ -173,7 +175,7 @@ void CharacterInfo::execute(int charIndex) {
ErrorScroll::show(_vm, EXCHANGING_IN_COMBAT, WT_FREEZE_WAIT);
} else {
_vm->_mode = oldMode;
error("c = exchangeChar(&charIndex)");
ExchangeDialog::show(_vm, c, charIndex);
_vm->_mode = MODE_CHARACTER_INFO;
redrawFlag = true;
}
Expand Down
82 changes: 82 additions & 0 deletions engines/xeen/dialogs_exchange.cpp
@@ -0,0 +1,82 @@
/* 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.
*
*/

#include "xeen/dialogs_exchange.h"
#include "xeen/resources.h"
#include "xeen/xeen.h"

namespace Xeen {

void ExchangeDialog::show(XeenEngine *vm, Character *&c, int &charIndex) {
ExchangeDialog *dlg = new ExchangeDialog(vm);
dlg->execute(c, charIndex);
delete dlg;
}

void ExchangeDialog::execute(Character *&c, int &charIndex) {
Screen &screen = *_vm->_screen;
EventsManager &events = *_vm->_events;
Interface &intf = *_vm->_interface;
Party &party = *_vm->_party;
loadButtons();

Window &w = screen._windows[31];
w.open();
w.writeString(EXCHANGE_WITH_WHOM);
_iconSprites.draw(w, 0, Common::Point(225, 120));
w.update();

while (!_vm->shouldQuit()) {
events.pollEventsAndWait();
checkEvents(_vm);

if (_buttonValue >= Common::KEYCODE_F1 && _buttonValue <= Common::KEYCODE_F6) {
_buttonValue -= Common::KEYCODE_F1;
if (_buttonValue < party._partyCount) {
SWAP(party._activeParty[charIndex], party._activeParty[_buttonValue]);
SWAP(party._partyMembers[charIndex], party._partyMembers[_buttonValue]);
SWAP(intf._partyFaces[charIndex], intf._partyFaces[_buttonValue]);

charIndex = _buttonValue;
c = &party._activeParty[charIndex];
break;
}
} else if (_buttonValue == Common::KEYCODE_ESCAPE) {
break;
}
}

w.close();
intf.charIconsPrint(true);
intf.highlightChar(charIndex);
}

void ExchangeDialog::loadButtons() {
_iconSprites.load("esc.icn");
addButton(Common::Rect(225, 120, 249, 245), Common::KEYCODE_ESCAPE, &_iconSprites, true);
addButton(Common::Rect(16, 16, 48, 48), Common::KEYCODE_1, &_iconSprites, false);
addButton(Common::Rect(117, 16, 149, 48), Common::KEYCODE_2, &_iconSprites, false);
addButton(Common::Rect(16, 59, 48, 91), Common::KEYCODE_3, &_iconSprites, false);
addButton(Common::Rect(117, 59, 149, 91), Common::KEYCODE_4, &_iconSprites, false);
}

} // End of namespace Xeen
47 changes: 47 additions & 0 deletions engines/xeen/dialogs_exchange.h
@@ -0,0 +1,47 @@
/* 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.
*
*/

#ifndef XEEN_DIALOGS_EXCHANGE_H
#define XEEN_DIALOGS_EXCHANGE_H

#include "xeen/dialogs.h"
#include "xeen/party.h"

namespace Xeen {

class ExchangeDialog : public ButtonContainer {
private:
XeenEngine *_vm;
SpriteResource _iconSprites;

ExchangeDialog(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}

void execute(Character *&c, int &charIndex);

void loadButtons();
public:
static void show(XeenEngine *vm, Character *&c, int &charIndex);
};

} // End of namespace Xeen

#endif /* XEEN_DIALOGS_EXCHANGE_H */
2 changes: 1 addition & 1 deletion engines/xeen/interface.h
Expand Up @@ -45,7 +45,6 @@ class Interface: public ButtonContainer, public InterfaceMap {
SpriteResource _uiSprites;
SpriteResource _iconSprites;
SpriteResource _charFaces[TOTAL_CHARACTERS];
SpriteResource *_partyFaces[MAX_ACTIVE_PARTY];
DrawStruct _faceDrawStructs[4];
DrawStruct _mainList[16];
int _combatCharIds[8];
Expand Down Expand Up @@ -78,6 +77,7 @@ class Interface: public ButtonContainer, public InterfaceMap {
public:
int _intrIndex1;
Common::String _interfaceText;
SpriteResource *_partyFaces[MAX_ACTIVE_PARTY];
public:
Interface(XeenEngine *vm);

Expand Down
1 change: 1 addition & 0 deletions engines/xeen/module.mk
Expand Up @@ -13,6 +13,7 @@ MODULE_OBJS := \
dialogs_char_info.o \
dialogs_confirm.o \
dialogs_error.o \
dialogs_exchange.o \
dialogs_options.o \
dialogs_info.o \
dialogs_input.o \
Expand Down
2 changes: 2 additions & 0 deletions engines/xeen/resources.cpp
Expand Up @@ -969,4 +969,6 @@ const char *const FOOD_TEXT =
"%u on hand\n"
"Enough for %u day%s\x3l";

const char *const EXCHANGE_WITH_WHOM = "\t010\v005Exchange with whom?";

} // End of namespace Xeen
2 changes: 2 additions & 0 deletions engines/xeen/resources.h
Expand Up @@ -321,6 +321,8 @@ extern const char *const IN_PARTY_IN_BANK;

extern const char *const FOOD_TEXT;

extern const char *const EXCHANGE_WITH_WHOM;

} // End of namespace Xeen

#endif /* XEEN_RESOURCES_H */

0 comments on commit 3ae4958

Please sign in to comment.