WINTERMUTE: Format platform_osystem.cpp, wintermute.cpp and detection_tables.h

This commit is contained in:
Einar Johan Trøan Sømåen 2012-08-11 02:44:12 +02:00
parent 089920377f
commit 5ecc1fd7f0
3 changed files with 87 additions and 52 deletions

View file

@ -51,37 +51,55 @@ void BasePlatform::handleEvent(Common::Event *event) {
if (_gameRef) { if (_gameRef) {
if (_gameRef->isLeftDoubleClick()) { if (_gameRef->isLeftDoubleClick()) {
_gameRef->onMouseLeftDblClick(); _gameRef->onMouseLeftDblClick();
} else {
_gameRef->onMouseLeftDown();
} }
else _gameRef->onMouseLeftDown();
} }
break; break;
case Common::EVENT_RBUTTONDOWN: case Common::EVENT_RBUTTONDOWN:
if (_gameRef) { if (_gameRef) {
if (_gameRef->isRightDoubleClick()) _gameRef->onMouseRightDblClick(); if (_gameRef->isRightDoubleClick()) {
else _gameRef->onMouseRightDown(); _gameRef->onMouseRightDblClick();
} else {
_gameRef->onMouseRightDown();
}
} }
break; break;
case Common::EVENT_MBUTTONDOWN: case Common::EVENT_MBUTTONDOWN:
if (_gameRef) _gameRef->onMouseMiddleDown(); if (_gameRef) {
_gameRef->onMouseMiddleDown();
}
break; break;
case Common::EVENT_LBUTTONUP: case Common::EVENT_LBUTTONUP:
if (_gameRef) _gameRef->onMouseLeftUp(); if (_gameRef) {
_gameRef->onMouseLeftUp();
}
break; break;
case Common::EVENT_RBUTTONUP: case Common::EVENT_RBUTTONUP:
if (_gameRef) _gameRef->onMouseRightUp(); if (_gameRef) {
_gameRef->onMouseRightUp();
}
break; break;
case Common::EVENT_MBUTTONUP: case Common::EVENT_MBUTTONUP:
if (_gameRef) _gameRef->onMouseMiddleUp(); if (_gameRef) {
_gameRef->onMouseMiddleUp();
}
break; break;
case Common::EVENT_KEYDOWN: case Common::EVENT_KEYDOWN:
if (_gameRef) _gameRef->handleKeypress(event); if (_gameRef) {
_gameRef->handleKeypress(event);
}
break; break;
case Common::EVENT_KEYUP: case Common::EVENT_KEYUP:
if (_gameRef) _gameRef->handleKeyRelease(event); if (_gameRef) {
_gameRef->handleKeyRelease(event);
}
break; break;
case Common::EVENT_WHEELUP: case Common::EVENT_WHEELUP:
case Common::EVENT_WHEELDOWN: case Common::EVENT_WHEELDOWN:
if (_gameRef) _gameRef->handleMouseWheel(event->mouse.y); if (_gameRef) {
_gameRef->handleMouseWheel(event->mouse.y);
}
break; break;
// Focus-events have been removed (_gameRef->onActivate originally) // Focus-events have been removed (_gameRef->onActivate originally)
case Common::EVENT_RTL: case Common::EVENT_RTL:
@ -216,7 +234,9 @@ bool BasePlatform::unionRect(Rect32 *lprcDst, Rect32 *lprcSrc1, Rect32 *lprcSrc2
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
bool BasePlatform::copyRect(Rect32 *lprcDst, Rect32 *lprcSrc) { bool BasePlatform::copyRect(Rect32 *lprcDst, Rect32 *lprcSrc) {
if (lprcDst == NULL || lprcSrc == NULL) return false; if (lprcDst == NULL || lprcSrc == NULL) {
return false;
}
*lprcDst = *lprcSrc; *lprcDst = *lprcSrc;
return true; return true;

View file

@ -127,7 +127,9 @@ Common::Error WinterMuteEngine::run() {
int WinterMuteEngine::init() { int WinterMuteEngine::init() {
BaseEngine::createInstance(_targetName); BaseEngine::createInstance(_targetName);
_game = new AdGame(_targetName); _game = new AdGame(_targetName);
if (!_game) return 1; if (!_game) {
return 1;
}
BaseEngine::instance().setGameRef(_game); BaseEngine::instance().setGameRef(_game);
BasePlatform::initialize(_game, 0, NULL); BasePlatform::initialize(_game, 0, NULL);
@ -241,15 +243,22 @@ int WinterMuteEngine::messageLoop() {
time = _system->getMillis(); time = _system->getMillis();
diff = time - prevTime; diff = time - prevTime;
if (frameTime > diff) // Avoid overflows if (frameTime > diff) { // Avoid overflows
_system->delayMillis(frameTime - diff); _system->delayMillis(frameTime - diff);
}
// ***** flip // ***** flip
if (!_game->_suspendedRendering) _game->_renderer->flip(); if (!_game->_suspendedRendering) {
if (_game->_loading) _game->loadGame(_game->_scheduledLoadSlot); _game->_renderer->flip();
}
if (_game->_loading) {
_game->loadGame(_game->_scheduledLoadSlot);
}
prevTime = time; prevTime = time;
} }
if (_game->_quitting) break; if (_game->_quitting) {
break;
}
} }
if (_game) { if (_game) {
@ -302,21 +311,24 @@ bool WinterMuteEngine::getGameInfo(const Common::FSList &fslist, Common::String
Common::String line = stream->readLine(); Common::String line = stream->readLine();
line.trim(); // Get rid of indentation line.trim(); // Get rid of indentation
// Expect "SETTINGS {" or comment, or empty line // Expect "SETTINGS {" or comment, or empty line
if (line.size() == 0 || line[0] == ';' || (line.contains("{"))) if (line.size() == 0 || line[0] == ';' || (line.contains("{"))) {
continue; continue;
else { } else {
// We are looking for "GAME =" // We are looking for "GAME ="
Common::StringTokenizer token(line, "="); Common::StringTokenizer token(line, "=");
Common::String key = token.nextToken(); Common::String key = token.nextToken();
Common::String value = token.nextToken(); Common::String value = token.nextToken();
if (value.size() == 0) if (value.size() == 0) {
continue; continue;
if (value[0] == '\"') }
if (value[0] == '\"') {
value.deleteChar(0); value.deleteChar(0);
else } else {
continue; continue;
if (value.lastChar() == '\"') }
if (value.lastChar() == '\"') {
value.deleteLastChar(); value.deleteLastChar();
}
if (key == "GAME") { if (key == "GAME") {
settingsGameFile = value; settingsGameFile = value;
break; break;
@ -333,20 +345,23 @@ bool WinterMuteEngine::getGameInfo(const Common::FSList &fslist, Common::String
Common::String line = stream->readLine(); Common::String line = stream->readLine();
line.trim(); // Get rid of indentation line.trim(); // Get rid of indentation
// Expect "GAME {" or comment, or empty line // Expect "GAME {" or comment, or empty line
if (line.size() == 0 || line[0] == ';' || (line.contains("{"))) if (line.size() == 0 || line[0] == ';' || (line.contains("{"))) {
continue; continue;
else { } else {
Common::StringTokenizer token(line, "="); Common::StringTokenizer token(line, "=");
Common::String key = token.nextToken(); Common::String key = token.nextToken();
Common::String value = token.nextToken(); Common::String value = token.nextToken();
if (value.size() == 0) if (value.size() == 0) {
continue; continue;
if (value[0] == '\"') }
if (value[0] == '\"') {
value.deleteChar(0); value.deleteChar(0);
else } else {
continue; // not a string continue; // not a string
if (value.lastChar() == '\"') }
if (value.lastChar() == '\"') {
value.deleteLastChar(); value.deleteLastChar();
}
if (key == "NAME") { if (key == "NAME") {
retVal = true; retVal = true;
name = value; name = value;