Quick fixes of unknown cleanliness: The mouse cursor is no longer unbelievably

sluggish on my computer, and I've added delays to some busy-wait loops to make
it less of a CPU hog.

I hope I didn't break anything.

svn-id: r20581
This commit is contained in:
Torbjörn Andersson 2006-02-11 21:09:01 +00:00
parent bd39c3cb3e
commit 2a9a0d4211
3 changed files with 10 additions and 3 deletions

View File

@ -99,6 +99,7 @@ void Mouse::waitForRelease() {
do {
e.pollEvent();
_system.delayMillis(10);
} while (!e.quitFlag && (lButton() || rButton()));
}
@ -153,6 +154,7 @@ void Events::waitForPress() {
_mouse.waitForRelease();
}
}
_system.delayMillis(10);
}
}

View File

@ -95,8 +95,9 @@ void Game::execute() {
}
res.delayList().tick();
r.update();
system.delayMillis(10);
if (events.pollEvent()) {
while (events.pollEvent()) {
if (events.type() == OSystem::EVENT_KEYDOWN) {
uint16 roomNum = r.roomNumber();
@ -170,7 +171,7 @@ void Game::execute() {
// This code eventually needs to be moved into the main loop so that,
// amongst other things, the tick handlers controlling animation can work
while (!events.quitFlag && !mouse.lButton() && !mouse.rButton()) {
if (events.pollEvent()) {
while (events.pollEvent()) {
if ((events.type() == OSystem::EVENT_KEYDOWN) &&
(events.event().kbd.ascii == 27))
events.quitFlag = true;
@ -184,6 +185,7 @@ void Game::execute() {
}
res.delayList().tick();
r.update();
system.delayMillis(10);
}
fields.setField(NEW_ROOM_NUMBER, 0);
@ -373,6 +375,7 @@ void Game::doShowCredits() {
}
void Game::doQuit() {
OSystem &system = System::getReference();
Mouse &mouse = Mouse::getReference();
Events &events = Events::getReference();
Screen &screen = Screen::getReference();
@ -390,6 +393,7 @@ void Game::doQuit() {
if ((key >= 'A') && (key <= 'Z')) key += 'a' - 'A';
}
}
system.delayMillis(10);
} while (((uint8) key != 27) && (key != 'y') && (key != 'n'));
events.quitFlag = key == 'y';

View File

@ -105,7 +105,7 @@ uint8 Menu::execute() {
_selectedIndex = 0;
while (_mouse.lButton()) {
if (_events.pollEvent()) {
while (_events.pollEvent()) {
// handle events
}
@ -147,6 +147,7 @@ uint8 Menu::execute() {
_selectedIndex = index;
if (_selectedIndex != 0) toggleHighlightItem(_selectedIndex);
}
_system.delayMillis(10);
}
if (_surfaceMenu) delete _surfaceMenu;