mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-22 20:21:06 +00:00
XEEN: Implement cmdChooseNumeric script opcode
This commit is contained in:
parent
15d375bc44
commit
652a662315
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -954,7 +954,20 @@ void Scripts::cmdConfirmWord(Common::Array<byte> ¶ms) {
|
||||
cmdNoAction(params);
|
||||
}
|
||||
|
||||
void Scripts::cmdDamage(Common::Array<byte> ¶ms) { error("TODO"); }
|
||||
void Scripts::cmdDamage(Common::Array<byte> ¶ms) {
|
||||
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> ¶ms) {
|
||||
|
||||
void Scripts::cmdGiveEnchanted(Common::Array<byte> ¶ms) {
|
||||
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> ¶ms) {
|
||||
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> ¶ms) {
|
||||
error("TODO");
|
||||
int choice = Choose123::show(_vm, params[0]);
|
||||
if (choice) {
|
||||
_lineNum = params[choice] - 1;
|
||||
}
|
||||
|
||||
cmdNoAction(params);
|
||||
}
|
||||
|
||||
void Scripts::cmdDisplayBottomTwoLines(Common::Array<byte> ¶ms) {
|
||||
Interface &intf = *_vm->_interface;
|
||||
Map &map = *_vm->_map;
|
||||
Window &w = _vm->_screen->_windows[12];
|
||||
|
||||
|
@ -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
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user