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

View file

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