aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/xeen/dialogs/dialogs_input.cpp37
-rw-r--r--engines/xeen/dialogs/dialogs_input.h6
-rw-r--r--engines/xeen/scripts.cpp2
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 &params) {
bool Scripts::cmdChooseNumeric(ParamsIterator &params) {
int choice = Choose123::show(_vm, params.readByte());
if (choice) {
- _lineNum = _event->_parameters[choice - 1];
+ _lineNum = _event->_parameters[choice];
return false;
}