aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2015-02-11 23:37:03 -0500
committerPaul Gilbert2015-02-11 23:37:03 -0500
commit2772cd33c1f62d0e0ea41507f6b809704d569254 (patch)
treef105544069fb0ffd870687e23cb37e805a10033b
parenta39b0b24a1dccec3e91f45deb047fa027372d84f (diff)
downloadscummvm-rg350-2772cd33c1f62d0e0ea41507f6b809704d569254.tar.gz
scummvm-rg350-2772cd33c1f62d0e0ea41507f6b809704d569254.tar.bz2
scummvm-rg350-2772cd33c1f62d0e0ea41507f6b809704d569254.zip
XEEN: Implemented code for deleting characters in Party dialog
-rw-r--r--engines/xeen/character.cpp9
-rw-r--r--engines/xeen/character.h2
-rw-r--r--engines/xeen/dialogs_party.cpp41
-rw-r--r--engines/xeen/resources.cpp5
-rw-r--r--engines/xeen/resources.h3
5 files changed, 59 insertions, 1 deletions
diff --git a/engines/xeen/character.cpp b/engines/xeen/character.cpp
index e7b5d23ecc..ac25b32c55 100644
--- a/engines/xeen/character.cpp
+++ b/engines/xeen/character.cpp
@@ -1787,5 +1787,14 @@ void Character::subtractHitPoints(int amount) {
}
}
+bool Character::hasSpecialItem() const {
+ for (uint idx = 0; idx < INV_ITEMS_TOTAL; ++idx) {
+ if (_weapons[idx]._id == 34)
+ // Character has Xeen Slayer sword
+ return true;
+ }
+
+ return false;
+}
} // End of namespace Xeen
diff --git a/engines/xeen/character.h b/engines/xeen/character.h
index 59f4ba65b6..492e5e298f 100644
--- a/engines/xeen/character.h
+++ b/engines/xeen/character.h
@@ -315,6 +315,8 @@ public:
int makeItem(int p1, int itemIndex, int p3);
void subtractHitPoints(int amount);
+
+ bool hasSpecialItem() const;
};
} // End of namespace Xeen
diff --git a/engines/xeen/dialogs_party.cpp b/engines/xeen/dialogs_party.cpp
index e1a6dbc92a..eece1e36fe 100644
--- a/engines/xeen/dialogs_party.cpp
+++ b/engines/xeen/dialogs_party.cpp
@@ -23,6 +23,7 @@
#include "common/scummsys.h"
#include "xeen/dialogs_char_info.h"
#include "xeen/dialogs_party.h"
+#include "xeen/dialogs_query.h"
#include "xeen/character.h"
#include "xeen/events.h"
#include "xeen/party.h"
@@ -187,7 +188,7 @@ void PartyDialog::execute() {
case Common::KEYCODE_DOWN:
case Common::KEYCODE_KP2:
// Down arrow
- if (startingChar < (_charList.size() - 4)) {
+ if (startingChar < ((int)_charList.size() - 4)) {
startingChar += 4;
startingCharChanged(startingChar);
}
@@ -210,9 +211,47 @@ void PartyDialog::execute() {
breakFlag = true;
}
break;
+
case Common::KEYCODE_d:
// Delete character
+ if (_charList.size() > 0) {
+ int charButtonValue = selectCharacter(true, startingChar);
+ if (charButtonValue != 0) {
+ int charIndex = charButtonValue - Common::KEYCODE_1 + startingChar;
+ Character &c = party._roster[_charList[charIndex]];
+ if (c.hasSpecialItem()) {
+ ErrorScroll::show(_vm, HAS_SLAYER_SWORD);
+ } else {
+ Common::String msg = Common::String::format(SURE_TO_DELETE_CHAR,
+ c._name.c_str(), CLASS_NAMES[c._class]);
+ if (Confirm::show(_vm, msg)) {
+ // If the character is in the party, remove it
+ for (uint idx = 0; idx < party._activeParty.size(); ++idx) {
+ if (party._activeParty[idx]._rosterId == c._rosterId) {
+ party._activeParty.remove_at(idx);
+ break;
+ }
+ }
+
+ // Empty the character in the roster
+ c.clear();
+
+ // Rebuild the character list
+ _charList.clear();
+ for (int idx = 0; idx < XEEN_TOTAL_CHARACTERS; ++idx) {
+ Character &c = party._roster[idx];
+ if (!c._name.empty() && c._savedMazeId == party._priorMazeId) {
+ _charList.push_back(idx);
+ }
+ }
+
+ startingCharChanged(startingChar);
+ }
+ }
+ }
+ }
break;
+
case Common::KEYCODE_r:
// Remove character
if (party._activeParty.size() > 0) {
diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp
index d79ef8061d..8f1475308d 100644
--- a/engines/xeen/resources.cpp
+++ b/engines/xeen/resources.cpp
@@ -1445,4 +1445,9 @@ const char *const REMOVE_OR_DELETE_WHICH = "\x3l\t010\v005%s which character?";
const char *const YOUR_PARTY_IS_FULL = "\v007Your party is full!";
+const char *const HAS_SLAYER_SWORD =
+ "\v000\t000This character has the Xeen Slayer Sword and cannot be deleted!";
+const char *const SURE_TO_DELETE_CHAR =
+ "Are you sure you want to delete %s the %s?";
+
} // End of namespace Xeen
diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h
index 0e90a29a68..2ca9dbbfda 100644
--- a/engines/xeen/resources.h
+++ b/engines/xeen/resources.h
@@ -501,6 +501,9 @@ extern const char *const REMOVE_OR_DELETE_WHICH;
extern const char *const YOUR_PARTY_IS_FULL;
+extern const char *const HAS_SLAYER_SWORD;
+extern const char *const SURE_TO_DELETE_CHAR;
+
} // End of namespace Xeen
#endif /* XEEN_RESOURCES_H */