diff options
author | Paul Gilbert | 2015-01-27 08:51:08 -0500 |
---|---|---|
committer | Paul Gilbert | 2015-01-27 08:51:08 -0500 |
commit | 5030d0046f9f36965c5479d0fd0006461d32e5f4 (patch) | |
tree | d16c92e5bcd329d56259f57af6275d13e8733720 | |
parent | 88382b2d8f0f1fd27e2100a94ace74453d6186f7 (diff) | |
download | scummvm-rg350-5030d0046f9f36965c5479d0fd0006461d32e5f4.tar.gz scummvm-rg350-5030d0046f9f36965c5479d0fd0006461d32e5f4.tar.bz2 scummvm-rg350-5030d0046f9f36965c5479d0fd0006461d32e5f4.zip |
XEEN: Implemented depositWithdrawl and subtract
-rw-r--r-- | engines/xeen/party.h | 10 | ||||
-rw-r--r-- | engines/xeen/resources.cpp | 7 | ||||
-rw-r--r-- | engines/xeen/resources.h | 2 | ||||
-rw-r--r-- | engines/xeen/town.cpp | 124 | ||||
-rw-r--r-- | engines/xeen/town.h | 2 |
5 files changed, 126 insertions, 19 deletions
diff --git a/engines/xeen/party.h b/engines/xeen/party.h index 0b7572cccf..883b378e55 100644 --- a/engines/xeen/party.h +++ b/engines/xeen/party.h @@ -218,7 +218,7 @@ public: int _day; int _year; int _minutes; - int _food; + uint _food; int _lightCount; int _torchCount; int _fireResistence; @@ -228,10 +228,10 @@ public: int _deathCount; int _winCount; int _lossCount; - int _gold; - int _gems; - int _bankGold; - int _bankGems; + uint _gold; + uint _gems; + uint _bankGold; + uint _bankGems; int _totalTime; bool _rested; bool _gameFlags[512]; diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp index cab6e2643d..3be2617e6b 100644 --- a/engines/xeen/resources.cpp +++ b/engines/xeen/resources.cpp @@ -657,6 +657,13 @@ const char *const GOLD_GEMS = "\x0C""37o\x0C""dld\x09""040G\x0C\x03""7e" "\x0C""dms\x09""067ESC\x01"; +const char *const GOLD_GEMS_2 = + "\x09""000\x0B""000\x03""c%s\x03l\n" + "\n" + "\x04""077Gold\x03r\x09""000%s\x03l\n" + "\x04""077Gems\x03r\x09""000%s\x03l\x09""000\x0B""051\x04""077\n" + "\x04""077"; + const char *const DEPOSIT_WITHDRAWL[2] = { "Deposit", "Withdrawl" }; const char *const NOT_ENOUGH_X_IN_THE_Y = diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h index 7461888c05..5dbc32174a 100644 --- a/engines/xeen/resources.h +++ b/engines/xeen/resources.h @@ -184,6 +184,8 @@ extern const char *const TRAINING_TEXT; extern const char *const GOLD_GEMS; +extern const char *const GOLD_GEMS_2; + extern const char *const DEPOSIT_WITHDRAWL[2]; extern const char *const NOT_ENOUGH_X_IN_THE_Y; diff --git a/engines/xeen/town.cpp b/engines/xeen/town.cpp index dceb79c354..9e1f04785f 100644 --- a/engines/xeen/town.cpp +++ b/engines/xeen/town.cpp @@ -21,6 +21,7 @@ */ #include "xeen/town.h" +#include "xeen/dialogs_input.h" #include "xeen/resources.h" #include "xeen/xeen.h" @@ -322,7 +323,6 @@ void Town::dwarfEvent() { } Common::String Town::createTownText(Character &ch) { - Interface &intf = *_vm->_interface; Party &party = *_vm->_party; Common::String msg; @@ -507,7 +507,7 @@ void Town::depositWithdrawl(int choice) { } for (uint idx = 0; idx < _buttons.size(); ++idx) - _buttons[idx]._sprites = &_icons1; + _buttons[idx]._sprites = &_icons2; _buttons[0]._value = Common::KEYCODE_o; _buttons[1]._value = Common::KEYCODE_e; _buttons[2]._value = Common::KEYCODE_ESCAPE; @@ -523,45 +523,141 @@ void Town::depositWithdrawl(int choice) { screen._windows[35].update(); sound.playSample(nullptr, 0); - File f("coina.voc"); - bool flag; + File voc("coina.voc"); + bool flag = false; do { - bool flag; switch (townWait()) { case Common::KEYCODE_o: - continue; + flag = false; + break; case Common::KEYCODE_e: - flag = 1; + flag = true; break; - default: - flag = 0; + case Common::KEYCODE_ESCAPE: break; + default: + continue; } if ((choice && !party._bankGems && flag) || (choice && !party._bankGold && !flag) || - (choice && !party._gems && flag) || - (choice && !party._gold && !flag)) { + (!choice && !party._gems && flag) || + (!choice && !party._gold && !flag)) { notEnough(flag, choice, 1, WT_2); } else { screen._windows[35].writeString(AMOUNT); + int amount = NumericInput::show(_vm, 35, 10, 77); + + if (amount) { + if (flag) { + if (subtract(true, amount, choice, WT_2)) { + if (choice) { + party._gems += amount; + } else { + party._bankGems += amount; + } + } + } else { + if (subtract(false, amount, choice, WT_2)) { + if (choice) { + party._gold += amount; + } else { + party._bankGold += amount; + } + } + } + } - // TODO + uint gold, gems; + if (choice) { + gold = party._bankGold; + gems = party._bankGems; + } else { + gold = party._gold; + gems = party._gems; + } + + sound.playSample(&voc, 0); + msg = Common::String::format(GOLD_GEMS_2, DEPOSIT_WITHDRAWL[choice], + XeenEngine::printMil(gold), XeenEngine::printMil(gems)); + screen._windows[35].writeString(msg); + screen._windows[35].update(); } // TODO } while (!_vm->shouldQuit() && _buttonValue != Common::KEYCODE_ESCAPE); + for (uint idx = 0; idx < _buttons.size(); ++idx) + _buttons[idx]._sprites = &_icons1; + _buttons[0]._value = Common::KEYCODE_d; + _buttons[1]._value = Common::KEYCODE_w; + _buttons[2]._value = Common::KEYCODE_ESCAPE; } void Town::notEnough(int consumableId, int whereId, bool mode, ErrorWaitType wait) { - SoundManager &sound = *_vm->_sound; - Common::String msg = Common::String::format( mode ? NO_X_IN_THE_Y : NOT_ENOUGH_X_IN_THE_Y, CONSUMABLE_NAMES[consumableId], WHERE_NAMES[whereId]); ErrorScroll::show(_vm, msg, wait); } +int Town::subtract(int mode, uint amount, int whereId, ErrorWaitType wait) { + Party &party = *_vm->_party; + + switch (mode) { + case 0: + // Gold + if (whereId) { + if (amount <= party._bankGold) { + party._bankGold -= amount; + } else { + notEnough(0, whereId, false, wait); + return false; + } + } else { + if (amount <= party._gold) { + party._gold -= amount; + } else { + notEnough(0, whereId, false, wait); + return false; + } + } + break; + + case 1: + // Gems + if (whereId) { + if (amount <= party._bankGems) { + party._bankGems -= amount; + } else { + notEnough(0, whereId, false, wait); + return false; + } + } else { + if (amount <= party._gems) { + party._gems -= amount; + } else { + notEnough(0, whereId, false, wait); + return false; + } + } + break; + + case 2: + // Food + if (amount > party._food) { + party._food -= amount; + } else { + notEnough(5, 0, 0, wait); + return false; + } + break; + + default: + break; + } + + return true; +} } // End of namespace Xeen diff --git a/engines/xeen/town.h b/engines/xeen/town.h index 068cc8252b..df754d5cef 100644 --- a/engines/xeen/town.h +++ b/engines/xeen/town.h @@ -79,6 +79,8 @@ private: void depositWithdrawl(int choice); void notEnough(int consumableId, int whereId, bool mode, ErrorWaitType wait); + + int subtract(int mode, uint amount, int whereId, ErrorWaitType wait); public: Town(XeenEngine *vm); |