mirror of
https://github.com/libretro/scummvm.git
synced 2024-11-30 12:50:51 +00:00
Merge several choice-related functions
svn-id: r28967
This commit is contained in:
parent
258901bab9
commit
2254028365
@ -74,8 +74,6 @@ public:
|
||||
|
||||
// Keyboard
|
||||
int getSelection(SelectionTypes type);
|
||||
bool waitAnyKeyChoice();
|
||||
bool getSelOkBack();
|
||||
|
||||
int rnd(int hi) { return (_rnd->getRandomNumber(hi) + 1); }
|
||||
|
||||
|
@ -122,19 +122,16 @@ void PreAgiEngine::printStrXOR(char *szMsg) {
|
||||
int PreAgiEngine::getSelection(SelectionTypes type) {
|
||||
Common::Event event;
|
||||
|
||||
// Selection types:
|
||||
// 0: Y/N
|
||||
// 1: 1-9
|
||||
for (;;) {
|
||||
while (_eventMan->pollEvent(event)) {
|
||||
switch(event.type) {
|
||||
case Common::EVENT_QUIT:
|
||||
_system->quit();
|
||||
case Common::EVENT_LBUTTONUP:
|
||||
if (type == kSelYesNo)
|
||||
return 1;
|
||||
case Common::EVENT_RBUTTONUP:
|
||||
return 0;
|
||||
case Common::EVENT_LBUTTONUP:
|
||||
if (type == kSelYesNo || type == kSelAnyKey)
|
||||
return 1;
|
||||
case Common::EVENT_KEYDOWN:
|
||||
switch (event.kbd.keycode) {
|
||||
case Common::KEYCODE_y:
|
||||
@ -144,7 +141,7 @@ int PreAgiEngine::getSelection(SelectionTypes type) {
|
||||
if (type == kSelYesNo)
|
||||
return 0;
|
||||
case Common::KEYCODE_ESCAPE:
|
||||
if (type == kSelNumber)
|
||||
if (type == kSelNumber || type == kSelAnyKey)
|
||||
return 0;
|
||||
case Common::KEYCODE_1:
|
||||
case Common::KEYCODE_2:
|
||||
@ -160,11 +157,16 @@ int PreAgiEngine::getSelection(SelectionTypes type) {
|
||||
case Common::KEYCODE_SPACE:
|
||||
if (type == kSelSpace)
|
||||
return 1;
|
||||
case Common::KEYCODE_BACKSPACE:
|
||||
if (type == kSelBackspace)
|
||||
return 0;
|
||||
default:
|
||||
if (type == kSelYesNo) {
|
||||
return 2;
|
||||
} else if (type == kSelNumber) {
|
||||
return 10;
|
||||
} else if (type == kSelAnyKey || type == kSelBackspace) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -178,60 +180,4 @@ int PreAgiEngine::getSelection(SelectionTypes type) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool PreAgiEngine::waitAnyKeyChoice() {
|
||||
Common::Event event;
|
||||
|
||||
for (;;) {
|
||||
while (_eventMan->pollEvent(event)) {
|
||||
switch(event.type) {
|
||||
case Common::EVENT_QUIT:
|
||||
_system->quit();
|
||||
case Common::EVENT_LBUTTONUP:
|
||||
return true;
|
||||
case Common::EVENT_RBUTTONUP:
|
||||
return false;
|
||||
case Common::EVENT_KEYDOWN:
|
||||
switch (event.kbd.keycode) {
|
||||
case Common::KEYCODE_ESCAPE: //Escape
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
_system->updateScreen();
|
||||
_system->delayMillis(10);
|
||||
}
|
||||
}
|
||||
|
||||
bool PreAgiEngine::getSelOkBack() {
|
||||
Common::Event event;
|
||||
|
||||
for (;;) {
|
||||
while (_eventMan->pollEvent(event)) {
|
||||
switch (event.type) {
|
||||
case Common::EVENT_QUIT:
|
||||
_system->quit();
|
||||
break;
|
||||
case Common::EVENT_LBUTTONUP:
|
||||
return true;
|
||||
case Common::EVENT_RBUTTONUP:
|
||||
return false;
|
||||
case Common::EVENT_KEYDOWN:
|
||||
switch (event.kbd.keycode) {
|
||||
case Common::KEYCODE_BACKSPACE:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -41,7 +41,9 @@ namespace Agi {
|
||||
enum SelectionTypes {
|
||||
kSelYesNo,
|
||||
kSelNumber,
|
||||
kSelSpace
|
||||
kSelSpace,
|
||||
kSelAnyKey,
|
||||
kSelBackspace
|
||||
};
|
||||
|
||||
} // End of namespace Agi
|
||||
|
@ -184,7 +184,7 @@ int Mickey::choose1to9(int ofsPrompt) {
|
||||
for (;;) {
|
||||
if (a == 10) {
|
||||
printExeStr(IDO_MSA_PRESS_1_TO_9);
|
||||
if (!_vm->waitAnyKeyChoice())
|
||||
if (_vm->getSelection(kSelAnyKey) == 0)
|
||||
return 0;
|
||||
printExeStr(ofsPrompt);
|
||||
} else return a;
|
||||
@ -956,7 +956,7 @@ bool Mickey::loadGame() {
|
||||
sprintf(szFile, "%s.s%2d", _vm->getTargetName().c_str(), sel);
|
||||
if (!(infile = _vm->getSaveFileMan()->openForLoading(szFile))) {
|
||||
printExeStr(IDO_MSA_CHECK_DISK_DRIVE);
|
||||
if (!_vm->waitAnyKeyChoice())
|
||||
if (_vm->getSelection(kSelAnyKey) == 0)
|
||||
return false;
|
||||
} else {
|
||||
infile->read(&game, sizeof(MSA_GAME));
|
||||
@ -982,7 +982,7 @@ void Mickey::saveGame() {
|
||||
else
|
||||
printExeStr(IDO_MSA_SAVE_GAME[2]);
|
||||
|
||||
if (!_vm->waitAnyKeyChoice())
|
||||
if (_vm->getSelection(kSelAnyKey) == 0)
|
||||
return;
|
||||
|
||||
while (diskerror) {
|
||||
@ -995,14 +995,14 @@ void Mickey::saveGame() {
|
||||
else
|
||||
printExeStr(IDO_MSA_SAVE_GAME[4]);
|
||||
|
||||
if (!_vm->waitAnyKeyChoice())
|
||||
if (_vm->getSelection(kSelAnyKey) == 0)
|
||||
return;
|
||||
|
||||
// save game
|
||||
sprintf(szFile, "%s.s%2d", _vm->getTargetName().c_str(), sel);
|
||||
if (!(outfile = _vm->getSaveFileMan()->openForSaving(szFile))) {
|
||||
printExeStr(IDO_MSA_CHECK_DISK_DRIVE);
|
||||
if (!_vm->waitAnyKeyChoice())
|
||||
if (_vm->getSelection(kSelAnyKey) == 0)
|
||||
return;
|
||||
} else {
|
||||
outfile->write(&game, sizeof(MSA_GAME));
|
||||
@ -2082,10 +2082,8 @@ void Mickey::waitAnyKeyAnim() {
|
||||
void Mickey::waitAnyKey(bool anim) {
|
||||
Common::Event event;
|
||||
|
||||
if (!anim) {
|
||||
if (!anim)
|
||||
_vm->_gfx->doUpdate();
|
||||
_vm->_system->updateScreen(); // TODO: this should go in the game's main loop
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
while (_vm->_system->getEventManager()->pollEvent(event)) {
|
||||
@ -2103,8 +2101,10 @@ void Mickey::waitAnyKey(bool anim) {
|
||||
if (anim) {
|
||||
animate();
|
||||
_vm->_gfx->doUpdate();
|
||||
_vm->_system->updateScreen(); // TODO: this should go in the game's main loop
|
||||
}
|
||||
|
||||
_vm->_system->updateScreen();
|
||||
_vm->_system->delayMillis(10);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ Troll::Troll(PreAgiEngine* vm) : _vm(vm) {
|
||||
void Troll::pressAnyKey() {
|
||||
_vm->drawStr(24, 4, kColorDefault, IDS_TRO_PRESSANYKEY);
|
||||
_vm->_gfx->doUpdate();
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
}
|
||||
|
||||
void Troll::drawMenu(const char *szMenu, int iSel) {
|
||||
@ -163,7 +163,7 @@ void Troll::inventory() {
|
||||
|
||||
_vm->drawStr(24, 6, kColorDefault, IDS_TRO_PRESSANYKEY);
|
||||
_vm->_gfx->doUpdate();
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
}
|
||||
|
||||
void Troll::waitAnyKeyIntro() {
|
||||
|
@ -218,7 +218,7 @@ int Winnie::parser(int pc, int index, uint8 *buffer) {
|
||||
default:
|
||||
// print description
|
||||
_vm->printStrXOR((char *)(buffer + pc));
|
||||
if (_vm->getSelOkBack())
|
||||
if (_vm->getSelection(kSelBackspace) == 1)
|
||||
return IDI_WTP_PAR_OK;
|
||||
else
|
||||
return IDI_WTP_PAR_BACK;
|
||||
@ -277,7 +277,7 @@ int Winnie::parser(int pc, int index, uint8 *buffer) {
|
||||
iDir = iSel - IDI_WTP_SEL_NORTH;
|
||||
if (hdr.roomNew[iDir] == IDI_WTP_ROOM_NONE) {
|
||||
_vm->printStr(IDS_WTP_CANT_GO);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
} else {
|
||||
room = hdr.roomNew[iDir];
|
||||
return IDI_WTP_PAR_GOTO;
|
||||
@ -310,7 +310,7 @@ int Winnie::parser(int pc, int index, uint8 *buffer) {
|
||||
case IDO_WTP_PRINT_MSG:
|
||||
opcode = *(buffer + pc++);
|
||||
printRoomStr(room, opcode);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
break;
|
||||
case IDO_WTP_PRINT_STR:
|
||||
opcode = *(buffer + pc++);
|
||||
@ -377,9 +377,9 @@ int Winnie::parser(int pc, int index, uint8 *buffer) {
|
||||
void Winnie::keyHelp() {
|
||||
//Winnie_PlaySound(IDI_WTP_SND_KEYHELP);
|
||||
_vm->printStr(IDS_WTP_HELP_0);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
_vm->printStr(IDS_WTP_HELP_1);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
}
|
||||
|
||||
void Winnie::inventory() {
|
||||
@ -396,7 +396,7 @@ void Winnie::inventory() {
|
||||
_vm->drawStr(IDI_WTP_ROW_OPTION_4, IDI_WTP_COL_MENU, IDA_DEFAULT, szMissing);
|
||||
_vm->_gfx->doUpdate();
|
||||
_vm->_system->updateScreen();
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
}
|
||||
|
||||
void Winnie::printObjStr(int iObj, int iStr) {
|
||||
@ -438,7 +438,7 @@ void Winnie::takeObj(int iRoom) {
|
||||
if (game.iObjHave) {
|
||||
// player is already carrying an object, can't take
|
||||
_vm->printStr(IDS_WTP_CANT_TAKE);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
} else {
|
||||
// take object
|
||||
int iObj = getObjInRoom(iRoom);
|
||||
@ -452,7 +452,7 @@ void Winnie::takeObj(int iRoom) {
|
||||
|
||||
// print object "take" string
|
||||
printObjStr(game.iObjHave, IDI_WTP_OBJ_TAKE);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
|
||||
// HACK WARNING
|
||||
if (iObj == 18) {
|
||||
@ -467,7 +467,7 @@ void Winnie::dropObj(int iRoom) {
|
||||
if (getObjInRoom(iRoom)) {
|
||||
// there already is an object in the room, can't drop
|
||||
_vm->printStr(IDS_WTP_CANT_DROP);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
} else {
|
||||
// HACK WARNING
|
||||
if (game.iObjHave == 18) {
|
||||
@ -477,10 +477,10 @@ void Winnie::dropObj(int iRoom) {
|
||||
if (isRightObj(iRoom, game.iObjHave, &iCode)) {
|
||||
// object has been dropped in the right place
|
||||
_vm->printStr(IDS_WTP_OK);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
//Winnie_PlaySound(IDI_WTP_SND_DROP_OK);
|
||||
printObjStr(game.iObjHave, IDI_WTP_OBJ_DROP);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
|
||||
// increase amount of objects returned, decrease amount of objects missing
|
||||
game.nObjMiss--;
|
||||
@ -504,9 +504,9 @@ void Winnie::dropObj(int iRoom) {
|
||||
// all objects returned, tell player to find party
|
||||
//Winnie_PlaySound(IDI_WTP_SND_FANFARE);
|
||||
_vm->printStr(IDS_WTP_GAME_OVER_0);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
_vm->printStr(IDS_WTP_GAME_OVER_1);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
}
|
||||
} else {
|
||||
// drop object in the given room
|
||||
@ -514,15 +514,15 @@ void Winnie::dropObj(int iRoom) {
|
||||
|
||||
// object has been dropped in the wrong place
|
||||
_vm->printStr(IDS_WTP_WRONG_PLACE);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
//Winnie_PlaySound(IDI_WTP_SND_DROP);
|
||||
drawRoomPic();
|
||||
_vm->printStr(IDS_WTP_WRONG_PLACE);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
|
||||
// print object description
|
||||
printObjStr(game.iObjHave, IDI_WTP_OBJ_DESC);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
|
||||
game.iObjHave = 0;
|
||||
}
|
||||
@ -563,10 +563,10 @@ void Winnie::wind() {
|
||||
|
||||
_vm->printStr(IDS_WTP_WIND_0);
|
||||
//Winnie_PlaySound(IDI_WTP_SND_WIND_0);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
_vm->printStr(IDS_WTP_WIND_1);
|
||||
//Winnie_PlaySound(IDI_WTP_SND_WIND_0);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
|
||||
dropObjRnd();
|
||||
|
||||
@ -591,15 +591,15 @@ void Winnie::wind() {
|
||||
void Winnie::showOwlHelp() {
|
||||
if (game.iObjHave) {
|
||||
_vm->printStr(IDS_WTP_OWL_0);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
printObjStr(game.iObjHave, IDI_WTP_OBJ_HELP);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
}
|
||||
if (getObjInRoom(room)) {
|
||||
_vm->printStr(IDS_WTP_OWL_0);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
printObjStr(getObjInRoom(room), IDI_WTP_OBJ_HELP);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
}
|
||||
}
|
||||
|
||||
@ -927,7 +927,7 @@ phase0:
|
||||
phase1:
|
||||
if (getObjInRoom(room)) {
|
||||
printObjStr(getObjInRoom(room), IDI_WTP_OBJ_DESC);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
}
|
||||
phase2:
|
||||
for (iBlock = 0; iBlock < IDI_WTP_MAX_BLOCK; iBlock++) {
|
||||
@ -1045,7 +1045,7 @@ void Winnie::gameOver() {
|
||||
//Winnie_PlaySound(IDI_WTP_SND_POOH_1);
|
||||
_vm->printStr(IDS_WTP_SONG_2);
|
||||
//Winnie_PlaySound(IDI_WTP_SND_POOH_2);
|
||||
_vm->waitAnyKeyChoice();
|
||||
_vm->getSelection(kSelAnyKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user