aboutsummaryrefslogtreecommitdiff
path: root/engines/xeen
diff options
context:
space:
mode:
Diffstat (limited to 'engines/xeen')
-rw-r--r--engines/xeen/dialogs_char_info.cpp16
-rw-r--r--engines/xeen/dialogs_exchange.cpp82
-rw-r--r--engines/xeen/dialogs_exchange.h47
-rw-r--r--engines/xeen/interface.h2
-rw-r--r--engines/xeen/module.mk1
-rw-r--r--engines/xeen/resources.cpp2
-rw-r--r--engines/xeen/resources.h2
7 files changed, 144 insertions, 8 deletions
diff --git a/engines/xeen/dialogs_char_info.cpp b/engines/xeen/dialogs_char_info.cpp
index 3ff40034a3..9fedb56fcf 100644
--- a/engines/xeen/dialogs_char_info.cpp
+++ b/engines/xeen/dialogs_char_info.cpp
@@ -21,6 +21,7 @@
*/
#include "xeen/dialogs_char_info.h"
+#include "xeen/dialogs_exchange.h"
#include "xeen/resources.h"
#include "xeen/xeen.h"
@@ -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();
@@ -60,8 +61,10 @@ 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();
@@ -69,8 +72,8 @@ void CharacterInfo::execute(int charIndex) {
showCursor(cursorFlag);
w.update();
+ checkEvents(_vm);
}
- checkEvents(_vm);
events.clearEvents();
switch (_buttonValue) {
@@ -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;
}
@@ -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;
}
diff --git a/engines/xeen/dialogs_exchange.cpp b/engines/xeen/dialogs_exchange.cpp
new file mode 100644
index 0000000000..56a310a928
--- /dev/null
+++ b/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
diff --git a/engines/xeen/dialogs_exchange.h b/engines/xeen/dialogs_exchange.h
new file mode 100644
index 0000000000..e8c4a2dfb1
--- /dev/null
+++ b/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 */
diff --git a/engines/xeen/interface.h b/engines/xeen/interface.h
index 73cd50977b..103b8b6607 100644
--- a/engines/xeen/interface.h
+++ b/engines/xeen/interface.h
@@ -45,7 +45,6 @@ private:
SpriteResource _uiSprites;
SpriteResource _iconSprites;
SpriteResource _charFaces[TOTAL_CHARACTERS];
- SpriteResource *_partyFaces[MAX_ACTIVE_PARTY];
DrawStruct _faceDrawStructs[4];
DrawStruct _mainList[16];
int _combatCharIds[8];
@@ -78,6 +77,7 @@ private:
public:
int _intrIndex1;
Common::String _interfaceText;
+ SpriteResource *_partyFaces[MAX_ACTIVE_PARTY];
public:
Interface(XeenEngine *vm);
diff --git a/engines/xeen/module.mk b/engines/xeen/module.mk
index 6a9ff3012c..8d3a5e52bf 100644
--- a/engines/xeen/module.mk
+++ b/engines/xeen/module.mk
@@ -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 \
diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp
index 4e958a155d..467dbe21f8 100644
--- a/engines/xeen/resources.cpp
+++ b/engines/xeen/resources.cpp
@@ -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
diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h
index a696e540e1..64387e7f54 100644
--- a/engines/xeen/resources.h
+++ b/engines/xeen/resources.h
@@ -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 */