aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/xeen/dialogs/dialogs_spells.cpp19
-rw-r--r--engines/xeen/dialogs/dialogs_spells.h19
-rw-r--r--engines/xeen/locations.cpp6
3 files changed, 32 insertions, 12 deletions
diff --git a/engines/xeen/dialogs/dialogs_spells.cpp b/engines/xeen/dialogs/dialogs_spells.cpp
index 9148c41a07..5842416403 100644
--- a/engines/xeen/dialogs/dialogs_spells.cpp
+++ b/engines/xeen/dialogs/dialogs_spells.cpp
@@ -46,6 +46,7 @@ Character *SpellsDialog::execute(ButtonContainer *priorDialog, Character *c, int
Sound &sound = *_vm->_sound;
Spells &spells = *_vm->_spells;
Windows &windows = *_vm->_windows;
+ Window &w = windows[25];
int ccNum = _vm->_files->_ccNum;
loadButtons();
@@ -54,7 +55,7 @@ Character *SpellsDialog::execute(ButtonContainer *priorDialog, Character *c, int
int selection = -1;
int topIndex = 0;
int newSelection;
- windows[25].open();
+ w.open();
do {
if (!isCasting) {
@@ -69,13 +70,12 @@ Character *SpellsDialog::execute(ButtonContainer *priorDialog, Character *c, int
Common::String msg = Common::String::format(Res.GUILD_OPTIONS,
title.c_str(), XeenEngine::printMil(party._gold).c_str());
windows[10].writeString(msg);
-
- warning("TODO: Sprite draw using previously used button sprites");
+ priorDialog->drawButtons(&windows[10]);
}
_spells.clear();
const char *errorMsg = setSpellText(c, castingCopy);
- windows[25].writeString(Common::String::format(Res.SPELLS_FOR,
+ w.writeString(Common::String::format(Res.SPELLS_FOR,
errorMsg == nullptr ? Res.SPELL_LINES_0_TO_9 : "",
c->_name.c_str()));
@@ -111,9 +111,9 @@ Character *SpellsDialog::execute(ButtonContainer *priorDialog, Character *c, int
_scrollSprites.draw(0, 0, Common::Point(187, 26));
_scrollSprites.draw(0, 2, Common::Point(187, 111));
if (isCasting)
- _scrollSprites.draw(windows[25], 5, Common::Point(132, 123));
+ _scrollSprites.draw(w, 5, Common::Point(132, 123));
- windows[25].update();
+ w.update();
do {
events.pollEventsAndWait();
@@ -273,7 +273,7 @@ Character *SpellsDialog::execute(ButtonContainer *priorDialog, Character *c, int
}
} while (!_vm->shouldExit() && _buttonValue != Common::KEYCODE_ESCAPE);
- windows[25].close();
+ w.close();
if (_vm->shouldExit())
selection = -1;
@@ -379,9 +379,10 @@ const char *SpellsDialog::setSpellText(Character *c, int isCasting) {
for (int spellId = 0; spellId < 20; ++spellId) {
int idx = 0;
while (Res.CLOUDS_SPELL_OFFSETS[party._mazeId - 29][spellId] !=
- (int)Res.SPELLS_ALLOWED[category][idx] && idx < 40) ;
+ (int)Res.SPELLS_ALLOWED[category][idx] && idx <= MAX_SPELLS_PER_CLASS)
+ ++idx;
- if (idx < 40) {
+ if (idx <= MAX_SPELLS_PER_CLASS) {
if (!c->_spells[idx] || (isCasting & 0x80)) {
int cost = spells.calcSpellCost(Res.SPELLS_ALLOWED[category][idx], expenseFactor);
_spells.push_back(SpellEntry(Common::String::format("\x3l%s\x3r\x9""000%u",
diff --git a/engines/xeen/dialogs/dialogs_spells.h b/engines/xeen/dialogs/dialogs_spells.h
index 2bcaef43e5..bbe8fae856 100644
--- a/engines/xeen/dialogs/dialogs_spells.h
+++ b/engines/xeen/dialogs/dialogs_spells.h
@@ -39,20 +39,39 @@ struct SpellEntry {
_name(name), _spellIndex(spellIndex), _spellId(spellId), _color(9) {}
};
+/**
+ * Spells list dialog. Used for both selecting spells to cast, as well as the
+ * spells listing when visiting Guild locations
+ */
class SpellsDialog : public ButtonContainer {
private:
SpriteResource _iconSprites;
SpriteResource _scrollSprites;
Common::Array<SpellEntry> _spells;
+ /**
+ * Constructor
+ */
SpellsDialog(XeenEngine *vm) : ButtonContainer(vm) {}
+ /**
+ * Executes the dialog
+ */
Character *execute(ButtonContainer *priorDialog, Character *c, int isCasting);
+ /**
+ * Loads buttons for the dialog
+ */
void loadButtons();
+ /**
+ * Sets the spell text
+ */
const char *setSpellText(Character *c, int isCasting);
public:
+ /**
+ * Show the spells list dialog
+ */
static Character *show(XeenEngine *vm, ButtonContainer *priorDialog,
Character *c, int isCasting);
};
diff --git a/engines/xeen/locations.cpp b/engines/xeen/locations.cpp
index 7043f4a56e..e0fd9dfcc9 100644
--- a/engines/xeen/locations.cpp
+++ b/engines/xeen/locations.cpp
@@ -529,12 +529,12 @@ Character *GuildLocation::doOptions(Character *c) {
}
} else if (_buttonValue == Common::KEYCODE_s) {
if (c->guildMember())
- c = SpellsDialog::show(_vm, nullptr, c, 0x80);
+ c = SpellsDialog::show(_vm, this, c, 0x80);
_buttonValue = 0;
- } else if (_buttonValue == Common::KEYCODE_c) {
+ } else if (_buttonValue == Common::KEYCODE_b) {
if (!c->noActions()) {
if (c->guildMember())
- c = SpellsDialog::show(_vm, nullptr, c, 0);
+ c = SpellsDialog::show(_vm, this, c, 0);
_buttonValue = 0;
}
}