diff options
author | Paul Gilbert | 2018-04-08 15:36:07 -0400 |
---|---|---|
committer | Paul Gilbert | 2018-04-08 15:36:17 -0400 |
commit | fa9218f2d2b0113afdc839b1edeb7b56f6889c04 (patch) | |
tree | dbaf822eab769c5fd47c6788d506eaf306926031 /engines/xeen | |
parent | 2888953c7b556b74295152acec2d04aad2d128db (diff) | |
download | scummvm-rg350-fa9218f2d2b0113afdc839b1edeb7b56f6889c04.tar.gz scummvm-rg350-fa9218f2d2b0113afdc839b1edeb7b56f6889c04.tar.bz2 scummvm-rg350-fa9218f2d2b0113afdc839b1edeb7b56f6889c04.zip |
XEEN: Further numeric fixes for dialog with Gremlin King
Diffstat (limited to 'engines/xeen')
-rw-r--r-- | engines/xeen/dialogs/dialogs_input.cpp | 37 | ||||
-rw-r--r-- | engines/xeen/dialogs/dialogs_input.h | 6 | ||||
-rw-r--r-- | engines/xeen/scripts.cpp | 2 |
3 files changed, 19 insertions, 26 deletions
diff --git a/engines/xeen/dialogs/dialogs_input.cpp b/engines/xeen/dialogs/dialogs_input.cpp index a50dfd00f2..6092fc4f3e 100644 --- a/engines/xeen/dialogs/dialogs_input.cpp +++ b/engines/xeen/dialogs/dialogs_input.cpp @@ -215,7 +215,7 @@ int NumericInput::execute(int maxLength, int maxWidth) { /*------------------------------------------------------------------------*/ -int Choose123::show(XeenEngine *vm, int numOptions) { +int Choose123::show(XeenEngine *vm, uint numOptions) { assert(numOptions <= 3); Choose123 *dlg = new Choose123(vm); int result = dlg->execute(numOptions); @@ -224,7 +224,7 @@ int Choose123::show(XeenEngine *vm, int numOptions) { return result; } -int Choose123::execute(int numOptions) { +int Choose123::execute(uint numOptions) { EventsManager &events = *_vm->_events; Interface &intf = *_vm->_interface; LocationManager &loc = *_vm->_locations; @@ -258,20 +258,11 @@ int Choose123::execute(int numOptions) { return 0; } while (!_buttonValue); - switch (_buttonValue) { - case Common::KEYCODE_ESCAPE: + if (_buttonValue == Common::KEYCODE_ESCAPE) { result = 0; - break; - case Common::KEYCODE_1: - case Common::KEYCODE_2: - case Common::KEYCODE_3: { - int v = _buttonValue - Common::KEYCODE_1 + 1; - if (v <= numOptions) - result = v; - break; - } - default: - break; + } else if (_buttonValue >= Common::KEYCODE_1 && _buttonValue < (Common::KEYCODE_1 + (int)numOptions)) { + _buttonValue -= Common::KEYCODE_0; + result = (_buttonValue == numOptions) ? 0 : _buttonValue; } } @@ -281,15 +272,17 @@ int Choose123::execute(int numOptions) { return result; } -void Choose123::loadButtons(int numOptions) { +void Choose123::loadButtons(uint numOptions) { + assert(numOptions > 0 && numOptions <= 9); _iconSprites.load("choose.icn"); + const int XPOS[3] = { 235, 260, 286 }; + const int YPOS[3] = { 75, 96, 117 }; - if (numOptions >= 1) - addButton(Common::Rect(235, 75, 259, 95), Common::KEYCODE_1, &_iconSprites); - if (numOptions >= 2) - addButton(Common::Rect(260, 75, 284, 95), Common::KEYCODE_2, &_iconSprites); - if (numOptions >= 3) - addButton(Common::Rect(286, 75, 311, 95), Common::KEYCODE_3, &_iconSprites); + for (uint idx = 0; idx < numOptions; ++idx) { + Common::Rect r(24, 20); + r.moveTo(XPOS[idx % 3], YPOS[idx / 3]); + addButton(r, Common::KEYCODE_1 + idx, &_iconSprites); + } } /*------------------------------------------------------------------------*/ diff --git a/engines/xeen/dialogs/dialogs_input.h b/engines/xeen/dialogs/dialogs_input.h index 270495ffd5..8cb41f3d36 100644 --- a/engines/xeen/dialogs/dialogs_input.h +++ b/engines/xeen/dialogs/dialogs_input.h @@ -82,11 +82,11 @@ private: Choose123(XeenEngine *vm) : ButtonContainer(vm) {} - int execute(int numOptions); + int execute(uint numOptions); - void loadButtons(int numOptions); + void loadButtons(uint numOptions); public: - static int show(XeenEngine *vm, int numOptions); + static int show(XeenEngine *vm, uint numOptions); }; class HowMuch : public ButtonContainer { diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp index c21f14c211..df94845ce8 100644 --- a/engines/xeen/scripts.cpp +++ b/engines/xeen/scripts.cpp @@ -1318,7 +1318,7 @@ bool Scripts::cmdCheckProtection(ParamsIterator ¶ms) { bool Scripts::cmdChooseNumeric(ParamsIterator ¶ms) { int choice = Choose123::show(_vm, params.readByte()); if (choice) { - _lineNum = _event->_parameters[choice - 1]; + _lineNum = _event->_parameters[choice]; return false; } |