void RInterface::processRCallbackRequest (RCallbackArgs *args) { RK_TRACE (RBACKEND); // first, copy out the type. Allows for easier typing below RCallbackArgs::RCallbackType type = args->type; if (type == RCallbackArgs::RShowMessage) { KMessageBox::information (0, QString (*(args->chars_a)), i18n ("Message from the R backend")); } else if (type == RCallbackArgs::RReadConsole) { QString result; bool ok = RKReadLineDialog::readLine (0, i18n ("R backend requests information"), *(args->chars_a), runningCommand (), &result); result = result.left (args->int_a - 2) + "\n"; qstrcpy (*(args->chars_b), result.latin1 ()); if (!ok) { args->done = true; // need to do this at once. Else we risk getting stuck in the standard callback event loop cancelCommand (runningCommand ()); return; } } else if ((type == RCallbackArgs::RShowFiles) || (type == RCallbackArgs::REditFiles)) { if ((type == RCallbackArgs::RShowFiles) && (QString (*(args->chars_d)) == "rkwardhtml")) { // not to worry, just some help file to display // TODO: maybe move this to ShowEditTextFileAgent instead for (int n=0; n < args->int_a; ++n) { RKwardApp::getApp ()->openHTML (args->chars_a[n]); } } else { ShowEditTextFileAgent::showEditFiles (args); return; } } else if (type ==RCallbackArgs::RChooseFile) { QString filename; if (args->int_a) { filename = KFileDialog::getSaveFileName (); } else { filename = KFileDialog::getOpenFileName (); } filename = filename.left (args->int_b - 2); args->int_c = filename.length (); qstrcpy (*(args->chars_a), filename.latin1 ()); } else if (type ==RCallbackArgs::RSuicide) { QString message = i18n ("The R engine has encountered a fatal error:\n") + QString (*(args->chars_a)); message += i18n ("It will be shut down immediately. This means, you can not use any more functions that rely on the R backend. I.e. you can do hardly anything at all, not even save the workspace. What you can do, however, is save any open command-files, the output, or copy data out of open data editors. Quit RKWard after that. Sorry!"); KMessageBox::error (0, message, i18n ("R engine has died")); r_thread->terminate (); } else if (type ==RCallbackArgs::RCleanUp) { QString message = i18n ("The R engine has shut down with status: ") + QString::number (args->int_a); message += i18n ("\nIt will be shut down immediately. This means, you can not use any more functions that rely on the R backend. I.e. you can do hardly anything at all, not even save the workspace. Hopefully, however, R has already saved the workspace. What you can do, however, is save any open command-files, the output, or copy data out of open data editors. Quit RKWard after that.\nSince this should never happen, please write a mail to [email protected], and tell us, what you were trying to do, when this happened. Sorry!"); KMessageBox::error (0, message, i18n ("R engine has died")); r_thread->terminate (); } args->done = true; }
void Player::move() { Scene &scene = _vm->_game->_scene; Rails &rails = scene._rails; bool newFacing = false; if (_moving) { while (!_walkOffScreen && _playerPos == _targetPos) { bool isRouteEmpty = rails.empty(); if (!isRouteEmpty) { const WalkNode &node = rails.popNode(); _targetPos = node._walkPos; newFacing = true; } else if (!_walkOffScreenSceneId) { // End of walking path rails.resetRoute(); _moving = false; setFinalFacing(); newFacing = true; } else { _walkOffScreen = _walkOffScreenSceneId; _walkAnywhere = true; _walkOffScreenSceneId = 0; _stepEnabled = false; newFacing = false; } if (!_moving) break; } } if (newFacing && _moving) startMovement(); if (_turnToFacing != _facing) { changeFacing(); } else if (!_moving) { updateFrame(); activateTrigger(); } int velocity = _velocity; if (_scalingVelocity && (_totalDistance > 0)) { int angleRange = 100 - _currentScale; int angleScale = angleRange * (_posDiff.x - 1) / _totalDistance + _currentScale; velocity = MAX(1L, (angleScale * _currentScale * velocity) / 10000L); } if (!_moving || (_facing != _turnToFacing)) return; Common::Point newPos = _playerPos; newFacing = false; _special = 0; if (_distAccum < velocity) { do { if (_pixelAccum < _posDiff.x) _pixelAccum += _posDiff.y; if (_pixelAccum >= _posDiff.x) { if ((_posChange.y > 0) || _walkOffScreen) newPos.y += _yDirection; --_posChange.y; _pixelAccum -= _posDiff.x; } if (_pixelAccum < _posDiff.x) { if ((_posChange.x > 0) || _walkOffScreen) newPos.x += _xDirection; --_posChange.x; } if (!_walkAnywhere && !_walkOffScreen && (_walkOffScreenSceneId == 0)) { newFacing = scene._depthSurface.getDepthHighBit(newPos); if (_special == 0) _special = scene.getDepthHighBits(newPos); } _distAccum += _deltaDistance; } while ((_distAccum < velocity) && !newFacing && ((_posChange.x > 0) || (_posChange.y > 0) || (_walkOffScreen != 0))); } _distAccum -= velocity; if (newFacing) { cancelCommand(); } else { if (!_walkOffScreen) { // If the move is complete, make sure the position is exactly on the given destination if (_posChange.x == 0) newPos.x = _targetPos.x; if (_posChange.y == 0) newPos.y = _targetPos.y; } _playerPos = newPos; } }