diff options
author | Paul Gilbert | 2015-02-18 22:11:59 -0500 |
---|---|---|
committer | Paul Gilbert | 2015-02-18 22:11:59 -0500 |
commit | 4c420a70be9124c224723a787d2335053f4986fe (patch) | |
tree | bc0378abd635505baee07c44623b34f7e3c93af2 /engines/xeen | |
parent | cd5bc0ec7ec7652a39d550aea4f387eec45fa382 (diff) | |
download | scummvm-rg350-4c420a70be9124c224723a787d2335053f4986fe.tar.gz scummvm-rg350-4c420a70be9124c224723a787d2335053f4986fe.tar.bz2 scummvm-rg350-4c420a70be9124c224723a787d2335053f4986fe.zip |
XEEN: Fix drawing buttons in Spells dialog when switching character
Diffstat (limited to 'engines/xeen')
-rw-r--r-- | engines/xeen/dialogs.h | 4 | ||||
-rw-r--r-- | engines/xeen/dialogs_spells.cpp | 24 | ||||
-rw-r--r-- | engines/xeen/dialogs_spells.h | 7 | ||||
-rw-r--r-- | engines/xeen/town.cpp | 4 |
4 files changed, 21 insertions, 18 deletions
diff --git a/engines/xeen/dialogs.h b/engines/xeen/dialogs.h index e2d8bc929c..c04b680ff1 100644 --- a/engines/xeen/dialogs.h +++ b/engines/xeen/dialogs.h @@ -55,8 +55,6 @@ protected: void doScroll(XeenEngine *vm, bool drawFlag, bool doFade); bool checkEvents(XeenEngine *vm); - - void drawButtons(XSurface *surface); public: ButtonContainer() : _buttonValue(0) {} @@ -71,6 +69,8 @@ public: void addButton(const Common::Rect &bounds, int val); void addPartyButtons(XeenEngine *vm); + + void drawButtons(XSurface *surface); }; class SettingsBaseDialog : public ButtonContainer { diff --git a/engines/xeen/dialogs_spells.cpp b/engines/xeen/dialogs_spells.cpp index 6a8b160dd8..e25d839a12 100644 --- a/engines/xeen/dialogs_spells.cpp +++ b/engines/xeen/dialogs_spells.cpp @@ -29,15 +29,16 @@ namespace Xeen { -Character *SpellsDialog::show(XeenEngine *vm, Character *c, int isCasting) { +Character *SpellsDialog::show(XeenEngine *vm, ButtonContainer *priorDialog, + Character *c, int isCasting) { SpellsDialog *dlg = new SpellsDialog(vm); - Character *result = dlg->execute(c, isCasting); + Character *result = dlg->execute(priorDialog, c, isCasting); delete dlg; return result; } -Character *SpellsDialog::execute(Character *c, int isCasting) { +Character *SpellsDialog::execute(ButtonContainer *priorDialog, Character *c, int isCasting) { EventsManager &events = *_vm->_events; Interface &intf = *_vm->_interface; Party &party = *_vm->_party; @@ -158,7 +159,8 @@ Character *SpellsDialog::execute(Character *c, int isCasting) { SPELL_GEM_COST[spellId], c->_currentSp)); } - drawButtons(&screen); + if (priorDialog != nullptr) + priorDialog->drawButtons(&screen); screen._windows[10].update(); } } @@ -299,7 +301,7 @@ void SpellsDialog::loadButtons() { addPartyButtons(_vm); } -const char *SpellsDialog::setSpellText(Character *c, int v2) { +const char *SpellsDialog::setSpellText(Character *c, int isCasting) { Party &party = *_vm->_party; Spells &spells = *_vm->_spells; bool isDarkCc = _vm->_files->_isDarkCc; @@ -307,7 +309,7 @@ const char *SpellsDialog::setSpellText(Character *c, int v2) { int currLevel = c->getCurrentLevel(); int category; - if ((v2 & 0x7f) == 0) { + if ((isCasting & 0x7f) == 0) { switch (c->_class) { case CLASS_PALADIN: expenseFactor = 1; @@ -344,7 +346,7 @@ const char *SpellsDialog::setSpellText(Character *c, int v2) { // Handling if the spell is appropriate for the character's class if (idx < MAX_SPELLS_PER_CLASS) { - if (!c->_spells[idx] || (v2 & 0x80)) { + if (!c->_spells[idx] || (isCasting & 0x80)) { int cost = spells.calcSpellCost(SPELLS_ALLOWED[category][idx], expenseFactor); _spells.push_back(SpellEntry(Common::String::format("\x3l%s\x3r\x9""000%u", spells._spellNames[SPELLS_ALLOWED[category][idx]], cost), @@ -361,7 +363,7 @@ const char *SpellsDialog::setSpellText(Character *c, int v2) { DARK_SPELL_OFFSETS[category][spellId]); if (idx < 40) { - if (!c->_spells[idx] || (v2 & 0x80)) { + if (!c->_spells[idx] || (isCasting & 0x80)) { int cost = spells.calcSpellCost(SPELLS_ALLOWED[category][idx], expenseFactor); _spells.push_back(SpellEntry(Common::String::format("\x3l%s\x3r\x9""000%u", spells._spellNames[SPELLS_ALLOWED[category][idx]], cost), @@ -376,7 +378,7 @@ const char *SpellsDialog::setSpellText(Character *c, int v2) { (int)SPELLS_ALLOWED[category][idx] && idx < 40) ; if (idx < 40) { - if (!c->_spells[idx] || (v2 & 0x80)) { + if (!c->_spells[idx] || (isCasting & 0x80)) { int cost = spells.calcSpellCost(SPELLS_ALLOWED[category][idx], expenseFactor); _spells.push_back(SpellEntry(Common::String::format("\x3l%s\x3r\x9""000%u", spells._spellNames[SPELLS_ALLOWED[category][idx]], cost), @@ -390,7 +392,7 @@ const char *SpellsDialog::setSpellText(Character *c, int v2) { if (c->getMaxSP() == 0) return NOT_A_SPELL_CASTER; - } else if ((v2 & 0x7f) == 1) { + } else if ((isCasting & 0x7f) == 1) { switch (c->_class) { case 0: case 12: @@ -546,7 +548,7 @@ int CastSpell::execute(Character *&c, int mode) { case Common::KEYCODE_n: // Select new spell _vm->_mode = oldMode; - c = SpellsDialog::show(_vm, c, 1); + c = SpellsDialog::show(_vm, this, c, 1); redrawFlag = true; break; diff --git a/engines/xeen/dialogs_spells.h b/engines/xeen/dialogs_spells.h index f091da66cf..32d079023d 100644 --- a/engines/xeen/dialogs_spells.h +++ b/engines/xeen/dialogs_spells.h @@ -48,13 +48,14 @@ private: SpellsDialog(XeenEngine *vm) : ButtonContainer(), _vm(vm) {} - Character *execute(Character *c, int v2); + Character *execute(ButtonContainer *priorDialog, Character *c, int isCasting); void loadButtons(); - const char *setSpellText(Character *c, int v2); + const char *setSpellText(Character *c, int isCasting); public: - static Character *show(XeenEngine *vm, Character *c, int isCasting); + static Character *show(XeenEngine *vm, ButtonContainer *priorDialog, + Character *c, int isCasting); }; class CastSpell : public ButtonContainer { diff --git a/engines/xeen/town.cpp b/engines/xeen/town.cpp index 2723226996..3a8b6d8231 100644 --- a/engines/xeen/town.cpp +++ b/engines/xeen/town.cpp @@ -567,12 +567,12 @@ Character *Town::doGuildOptions(Character *c) { } } else if (_buttonValue == Common::KEYCODE_s) { if (c->guildMember()) - c = SpellsDialog::show(_vm, c, 0x80); + c = SpellsDialog::show(_vm, nullptr, c, 0x80); _buttonValue = 0; } else if (_buttonValue == Common::KEYCODE_c) { if (!c->noActions()) { if (c->guildMember()) - c = SpellsDialog::show(_vm, c, 0); + c = SpellsDialog::show(_vm, nullptr, c, 0); _buttonValue = 0; } } |