[Scummvm-cvs-logs] SF.net SVN: scummvm: [28967] scummvm/trunk/engines/agi
sev at users.sourceforge.net
sev at users.sourceforge.net
Wed Sep 19 11:54:42 CEST 2007
Revision: 28967
http://scummvm.svn.sourceforge.net/scummvm/?rev=28967&view=rev
Author: sev
Date: 2007-09-19 02:54:42 -0700 (Wed, 19 Sep 2007)
Log Message:
-----------
Merge several choice-related functions
Modified Paths:
--------------
scummvm/trunk/engines/agi/preagi.h
scummvm/trunk/engines/agi/preagi_common.cpp
scummvm/trunk/engines/agi/preagi_common.h
scummvm/trunk/engines/agi/preagi_mickey.cpp
scummvm/trunk/engines/agi/preagi_troll.cpp
scummvm/trunk/engines/agi/preagi_winnie.cpp
Modified: scummvm/trunk/engines/agi/preagi.h
===================================================================
--- scummvm/trunk/engines/agi/preagi.h 2007-09-19 08:40:12 UTC (rev 28966)
+++ scummvm/trunk/engines/agi/preagi.h 2007-09-19 09:54:42 UTC (rev 28967)
@@ -74,8 +74,6 @@
// Keyboard
int getSelection(SelectionTypes type);
- bool waitAnyKeyChoice();
- bool getSelOkBack();
int rnd(int hi) { return (_rnd->getRandomNumber(hi) + 1); }
Modified: scummvm/trunk/engines/agi/preagi_common.cpp
===================================================================
--- scummvm/trunk/engines/agi/preagi_common.cpp 2007-09-19 08:40:12 UTC (rev 28966)
+++ scummvm/trunk/engines/agi/preagi_common.cpp 2007-09-19 09:54:42 UTC (rev 28967)
@@ -122,19 +122,16 @@
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 @@
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 @@
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 @@
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;
- }
- }
- }
-}
-
-}
Modified: scummvm/trunk/engines/agi/preagi_common.h
===================================================================
--- scummvm/trunk/engines/agi/preagi_common.h 2007-09-19 08:40:12 UTC (rev 28966)
+++ scummvm/trunk/engines/agi/preagi_common.h 2007-09-19 09:54:42 UTC (rev 28967)
@@ -41,7 +41,9 @@
enum SelectionTypes {
kSelYesNo,
kSelNumber,
- kSelSpace
+ kSelSpace,
+ kSelAnyKey,
+ kSelBackspace
};
} // End of namespace Agi
Modified: scummvm/trunk/engines/agi/preagi_mickey.cpp
===================================================================
--- scummvm/trunk/engines/agi/preagi_mickey.cpp 2007-09-19 08:40:12 UTC (rev 28966)
+++ scummvm/trunk/engines/agi/preagi_mickey.cpp 2007-09-19 09:54:42 UTC (rev 28967)
@@ -184,7 +184,7 @@
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 @@
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 @@
else
printExeStr(IDO_MSA_SAVE_GAME[2]);
- if (!_vm->waitAnyKeyChoice())
+ if (_vm->getSelection(kSelAnyKey) == 0)
return;
while (diskerror) {
@@ -995,14 +995,14 @@
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::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 @@
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);
}
}
Modified: scummvm/trunk/engines/agi/preagi_troll.cpp
===================================================================
--- scummvm/trunk/engines/agi/preagi_troll.cpp 2007-09-19 08:40:12 UTC (rev 28966)
+++ scummvm/trunk/engines/agi/preagi_troll.cpp 2007-09-19 09:54:42 UTC (rev 28967)
@@ -42,7 +42,7 @@
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 @@
_vm->drawStr(24, 6, kColorDefault, IDS_TRO_PRESSANYKEY);
_vm->_gfx->doUpdate();
- _vm->waitAnyKeyChoice();
+ _vm->getSelection(kSelAnyKey);
}
void Troll::waitAnyKeyIntro() {
Modified: scummvm/trunk/engines/agi/preagi_winnie.cpp
===================================================================
--- scummvm/trunk/engines/agi/preagi_winnie.cpp 2007-09-19 08:40:12 UTC (rev 28966)
+++ scummvm/trunk/engines/agi/preagi_winnie.cpp 2007-09-19 09:54:42 UTC (rev 28967)
@@ -218,7 +218,7 @@
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 @@
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 @@
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 @@
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 @@
_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 @@
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 @@
// 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 @@
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 @@
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 @@
// 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 @@
// 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 @@
_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::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 @@
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 @@
//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);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list