aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2018-03-30 20:08:31 -0400
committerPaul Gilbert2018-03-30 20:08:31 -0400
commiteca76ea91ec0b932d90d20608db2f4c1b9aae1cf (patch)
tree867935f98f76058e274071b259cc3f9eb856848b
parent83412c91af9d66084923150df2bb1ded3a67824a (diff)
downloadscummvm-rg350-eca76ea91ec0b932d90d20608db2f4c1b9aae1cf.tar.gz
scummvm-rg350-eca76ea91ec0b932d90d20608db2f4c1b9aae1cf.tar.bz2
scummvm-rg350-eca76ea91ec0b932d90d20608db2f4c1b9aae1cf.zip
XEEN: Fix highlighting of character when Cast Spell dialog is opened
-rw-r--r--engines/xeen/character.cpp11
-rw-r--r--engines/xeen/character.h18
-rw-r--r--engines/xeen/dialogs/dialogs_spells.cpp7
-rw-r--r--engines/xeen/interface.cpp6
-rw-r--r--engines/xeen/interface.h10
-rw-r--r--engines/xeen/party.h2
6 files changed, 50 insertions, 4 deletions
diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp
index 333bad80fe..72d8ed653e 100644
--- a/engines/xeen/character.cpp
+++ b/engines/xeen/character.cpp
@@ -37,6 +37,17 @@ void AttributePair::synchronize(Common::Serializer &s) {
/*------------------------------------------------------------------------*/
+int CharacterArray::indexOf(const Character &c) {
+ for (uint idx = 0; idx < size(); ++idx) {
+ if ((*this)[idx] == c)
+ return idx;
+ }
+
+ return -1;
+}
+
+/*------------------------------------------------------------------------*/
+
Character::Character(): _weapons(this), _armor(this), _accessories(this), _misc(this), _items(this) {
clear();
_faceSprites = nullptr;
diff --git a/engines/xeen/character.h b/engines/xeen/character.h
index b45cfaf5ad..43531c74cf 100644
--- a/engines/xeen/character.h
+++ b/engines/xeen/character.h
@@ -166,6 +166,16 @@ public:
Character(const Character &src);
/**
+ * Equality operator
+ */
+ bool operator==(const Character &src) const { return src._rosterId == _rosterId; }
+
+ /**
+ * Inequality operator
+ */
+ bool operator!=(const Character &src) const { return src._rosterId != _rosterId; }
+
+ /**
* Clears the data for a character
*/
void clear();
@@ -346,6 +356,14 @@ public:
void clearConditions();
};
+class CharacterArray : public Common::Array<Character> {
+public:
+ /**
+ * Returns the index of a given character in the array
+ */
+ int indexOf(const Character &c);
+};
+
} // End of namespace Xeen
#endif /* XEEN_CHARACTER_H */
diff --git a/engines/xeen/dialogs/dialogs_spells.cpp b/engines/xeen/dialogs/dialogs_spells.cpp
index 21bd7e2776..828281e688 100644
--- a/engines/xeen/dialogs/dialogs_spells.cpp
+++ b/engines/xeen/dialogs/dialogs_spells.cpp
@@ -383,7 +383,6 @@ CastSpell::~CastSpell() {
int CastSpell::show(XeenEngine *vm) {
Combat &combat = *vm->_combat;
- Interface &intf = *vm->_interface;
Party &party = *vm->_party;
Spells &spells = *vm->_spells;
int charNum;
@@ -403,17 +402,19 @@ int CastSpell::show(XeenEngine *vm) {
}
Character *c = &party._activeParty[charNum];
- intf.highlightChar(charNum);
-
return show(vm, c);
}
int CastSpell::show(XeenEngine *vm, Character *&c) {
+ Interface &intf = *vm->_interface;
Spells &spells = *vm->_spells;
CastSpell *dlg = new CastSpell(vm);
int spellId;
int result = -1;
+ // Highlight the character
+ intf.highlightChar(c);
+
do {
spellId = dlg->execute(c);
diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp
index de343feb15..648b01f2c9 100644
--- a/engines/xeen/interface.cpp
+++ b/engines/xeen/interface.cpp
@@ -118,6 +118,12 @@ void PartyDrawer::highlightChar(int charId) {
}
}
+void PartyDrawer::highlightChar(const Character *c) {
+ int charNum = _vm->_party->_activeParty.indexOf(*c);
+ if (charNum != -1)
+ highlightChar(charNum);
+}
+
void PartyDrawer::unhighlightChar() {
Resources &res = *_vm->_resources;
Windows &windows = *_vm->_windows;
diff --git a/engines/xeen/interface.h b/engines/xeen/interface.h
index bbc2a77f1e..6de04495b2 100644
--- a/engines/xeen/interface.h
+++ b/engines/xeen/interface.h
@@ -71,8 +71,18 @@ public:
void drawParty(bool updateFlag);
+ /**
+ * Highlights the specified character in the party display at the bottom of the screen
+ * @param charId Character number
+ */
void highlightChar(int charId);
+ /**
+ * Highlights the specified character in the party display at the bottom of the screen
+ * @param c Character to highlight
+ */
+ void highlightChar(const Character *c);
+
void unhighlightChar();
void resetHighlight();
diff --git a/engines/xeen/party.h b/engines/xeen/party.h
index 23a9407a76..322ae2b052 100644
--- a/engines/xeen/party.h
+++ b/engines/xeen/party.h
@@ -215,7 +215,7 @@ public:
public:
// Other party related runtime data
Roster _roster;
- Common::Array<Character> _activeParty;
+ CharacterArray _activeParty;
bool _newDay;
bool _isNight;
bool _stepped;