aboutsummaryrefslogtreecommitdiff
path: root/engines/xeen
diff options
context:
space:
mode:
Diffstat (limited to 'engines/xeen')
-rw-r--r--engines/xeen/dialogs_input.cpp74
-rw-r--r--engines/xeen/dialogs_input.h14
-rw-r--r--engines/xeen/scripts.cpp28
-rw-r--r--engines/xeen/xeen.h1
4 files changed, 113 insertions, 4 deletions
diff --git a/engines/xeen/dialogs_input.cpp b/engines/xeen/dialogs_input.cpp
index 3626441c7c..8b754ab6de 100644
--- a/engines/xeen/dialogs_input.cpp
+++ b/engines/xeen/dialogs_input.cpp
@@ -201,5 +201,79 @@ int NumericInput::execute(int maxLength, int maxWidth) {
return 0;
}
+/*------------------------------------------------------------------------*/
+
+int Choose123::show(XeenEngine *vm, int numOptions) {
+ assert(numOptions <= 3);
+ Choose123 *dlg = new Choose123(vm);
+ int result = dlg->execute(numOptions);
+ delete dlg;
+
+ return result;
+}
+
+int Choose123::execute(int numOptions) {
+ EventsManager &events = *_vm->_events;
+ Interface &intf = *_vm->_interface;
+ Screen &screen = *_vm->_screen;
+ Town &town = *_vm->_town;
+
+ Mode oldMode = _vm->_mode;
+ _vm->_mode = MODE_DIALOG_123;
+
+ loadButtons(numOptions);
+ _iconSprites.draw(screen, 7, Common::Point(232, 74));
+ drawButtons(&screen);
+ screen._windows[34].update();
+
+ int result = -1;
+ while (result == -1) {
+ do {
+ events.updateGameCounter();
+ int delay;
+ if (town.isActive()) {
+ town.drawTownAnim(true);
+ delay = 3;
+ } else {
+ intf.draw3d(true);
+ delay = 1;
+ }
+
+ events.wait(delay, true);
+ if (_vm->shouldQuit())
+ return 0;
+ } while (!_buttonValue);
+
+ switch (_buttonValue) {
+ case 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;
+ }
+ }
+
+ _vm->_mode = oldMode;
+ intf.mainIconsPrint();
+}
+
+void Choose123::loadButtons(int numOptions) {
+ _iconSprites.load("choose.icn");
+
+ 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);
+}
} // End of namespace Xeen
diff --git a/engines/xeen/dialogs_input.h b/engines/xeen/dialogs_input.h
index 30e4cb2854..2f30b73973 100644
--- a/engines/xeen/dialogs_input.h
+++ b/engines/xeen/dialogs_input.h
@@ -64,6 +64,20 @@ public:
static int show(XeenEngine *vm, int window, int maxLength, int maxWidth);
};
+class Choose123 : public ButtonContainer {
+private:
+ XeenEngine *_vm;
+ SpriteResource _iconSprites;
+
+ Choose123(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+
+ int execute(int numOptions);
+
+ void loadButtons(int numOptions);
+public:
+ static int show(XeenEngine *vm, int numOptions);
+};
+
} // End of namespace Xeen
#endif /* XEEN_DIALOGS_STRING_INPUT_H */
diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp
index 1656acd2ee..790e3d729e 100644
--- a/engines/xeen/scripts.cpp
+++ b/engines/xeen/scripts.cpp
@@ -954,7 +954,20 @@ void Scripts::cmdConfirmWord(Common::Array<byte> &params) {
cmdNoAction(params);
}
-void Scripts::cmdDamage(Common::Array<byte> &params) { error("TODO"); }
+void Scripts::cmdDamage(Common::Array<byte> &params) {
+ Combat &combat = *_vm->_combat;
+ Interface &intf = *_vm->_interface;
+
+ if (!_redrawDone) {
+ intf.draw3d(true);
+ _redrawDone = true;
+ }
+
+ int damage = (params[1] << 8) | params[0];
+ combat.giveCharDamage(damage, (DamageType)params[2], _charIndex);
+
+ cmdNoAction(params);
+}
/**
* Jump if a random number matches a given value
@@ -1164,7 +1177,6 @@ void Scripts::cmdSelRndChar(Common::Array<byte> &params) {
void Scripts::cmdGiveEnchanted(Common::Array<byte> &params) {
Party &party = *_vm->_party;
- bool isDarkCc = _vm->_files->_isDarkCc;
if (params[0] >= 35) {
if (params[0] < 49) {
@@ -1257,12 +1269,20 @@ void Scripts::cmdCheckProtection(Common::Array<byte> &params) {
cmdExit(params);
}
+/**
+ * Given a number of options, and a list of line numbers associated with
+ * those options, jumps to whichever line for the option the user selects
+ */
void Scripts::cmdChooseNumeric(Common::Array<byte> &params) {
- error("TODO");
+ int choice = Choose123::show(_vm, params[0]);
+ if (choice) {
+ _lineNum = params[choice] - 1;
+ }
+
+ cmdNoAction(params);
}
void Scripts::cmdDisplayBottomTwoLines(Common::Array<byte> &params) {
- Interface &intf = *_vm->_interface;
Map &map = *_vm->_map;
Window &w = _vm->_screen->_windows[12];
diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h
index 71859413aa..4180a17650 100644
--- a/engines/xeen/xeen.h
+++ b/engines/xeen/xeen.h
@@ -88,6 +88,7 @@ enum Mode {
MODE_9 = 9,
MODE_CHARACTER_INFO = 10,
MODE_12 = 12,
+ MODE_DIALOG_123 = 13,
MODE_17 = 17,
MODE_86 = 86
};