//////////////////////////////////////////////////////////////////////////////// // Scan Keyboard and update user actions as requested by the user // void updateUser(TCharacter* user) { // Scan Keyboard cpct_scanKeyboard_f(); // // Check possible keys to press, and do actions // // KEY = Cursor Up, ACTION = Jump (only when not already jumping) if ( cpct_isKeyPressed(Key_CursorUp) && user->status != es_jump ) { performAction(user, es_jump, user->side); // Perform the action of jumping getRandomUniform(user->entity.nx); // Use X coordinate of the user when jumping to forward update the random seed // KEY = Cursor Right, ACTION = Walk Right } else if ( cpct_isKeyPressed(Key_CursorRight) ) performAction(user, es_walk, s_right); // Move player to the right // KEY = Cursor Left, ACTION = Walk Left else if ( cpct_isKeyPressed(Key_CursorLeft) ) performAction(user, es_walk, s_left); // Move player to the left // KEY = Cursor Down, ACTION = Move Floor else if ( cpct_isKeyPressed(Key_CursorDown) ) performAction(user, es_moveFloor, user->side); // Enable moving floor // KEY = None pressed, ACTION = Change user to static else performAction(user, es_static, user->side); }
int main(int argc, char* argv){ memset(world,0,sizeof(world)); int i; char c; rNum = 0; int trash = scanf("%d %d\n",&maxX,&maxY); while ((trash = scanf("%d %d %c\n", &x, &y, &orientation)) != -1){ rNum++; bool result = performAction(orientation); c = getchar(); while (c != '\n' && c != EOF && result){ result = performAction(c); c = getchar(); } if (c != '\n' && c != EOF) flushLine(); if (!result){ printf("%d %d %c LOST\n",x,y, orientation); } else { printf("%d %d %c\n",x,y,orientation); } } printWorld(); return 0; }
bool CSuccUBus::LeaveViewMsg(CLeaveViewMsg *msg) { petDisplayMessage(2, BLANK); if (_startFrame8 >= 0) loadFrame(_startFrame8); else if (!_field15C && _startFrame9 >= 0) loadFrame(_startFrame9); petClear(); if (_soundHandle != -1) { stopSound(_soundHandle, 1); _soundHandle = -1; } if (_enabled) { _enabled = false; if (_startFrame10 >= 0) playSound("z#27.wav", 100); if (_field15C) setVisible(false); } performAction(true, findView()); CSUBTransition transMsg; transMsg.execute(this); return true; }
bool CBellBot::DismissBotMsg(CDismissBotMsg *msg) { if (_npcFlags & NPCFLAG_10000) { playClip("Walk Off", MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); if (_npcFlags & NPCFLAG_START_IDLING) { _npcFlags &= ~NPCFLAG_START_IDLING; performAction(true); } else { performAction(false); } CActMsg actMsg("BellbotDismissed"); actMsg.execute("BotIdleSummons"); } return true; }
bool CSuccUBus::LeaveViewMsg(CLeaveViewMsg *msg) { petDisplayMessage(2, BLANK); if (_initialStartFrame >= 0) loadFrame(_initialStartFrame); else if (!_signalFlag && _onStartFrame >= 0) loadFrame(_onStartFrame); petClear(); if (_soundHandle != -1) { stopSound(_soundHandle, 1); _soundHandle = -1; } if (_isOn) { _isOn = false; if (_offStartFrame >= 0) playSound("z#27.wav", 100); if (_signalFlag) setVisible(false); } performAction(true, findView()); CSUBTransition transMsg; transMsg.execute(this); return true; }
bool LRParser::parse(std::string input) { input_ = input; counter_ = 0; // Push state 1 stack_.push("1"); while (input_.length()+1 != counter_) { // As long as not all of the input has been consumed. // Read the symbol std::pair<EAction, std::string> theAction = processSymbol(); // Perform the action bool accept = performAction(theAction); // If we ended up in a blank entry or another error our input is invalid. if (!accept) { return false; } // If we had the accept action and we have consumed our whole input: our input is valid. else if (stack_.empty() && accept && (counter_ == input_.length())) { //std::cout << *this << std::endl; return true; } } // Our input has been consumed and we do not have a startsymbol: our input is invalid. return false; }
bool CDoorbot::PutBotBackInHisBoxMsg(CPutBotBackInHisBoxMsg *msg) { petMoveToHiddenRoom(); _npcFlags &= ~(NPCFLAG_START_IDLING | NPCFLAG_100000 | NPCFLAG_200000 | NPCFLAG_DOORBOT_INTRO); if (msg->_value) performAction(true); return true; }
bool CDoorbot::LeaveViewMsg(CLeaveViewMsg *msg) { if (!(_npcFlags & NPCFLAG_DOORBOT_INTRO) && (_npcFlags & NPCFLAG_400000)) { performAction(true); _npcFlags &= ~NPCFLAG_START_IDLING; } return true; }
void ActionBox::currentChanged(int i) { if (m_ui->action_box->currentText().toStdString() == action_list[0]) { return; } emit performAction(m_name, (e_action) i); }
bool CMaitreD::LeaveViewMsg(CLeaveViewMsg *msg) { _field134 = _field12C; performAction(true); stopAnimTimer(_timerId); _timerId = 0; _field12C = 0; return true; }
void ItemsViewDelegate::slotInstallClicked() { QModelIndex index = focusedIndex(); if (index.isValid()) { const QSortFilterProxyModel * model = qobject_cast<const QSortFilterProxyModel*>(index.model()); const ItemsModel * realmodel = qobject_cast<const ItemsModel*>(model->sourceModel()); KNS::Entry * entry = realmodel->entryForIndex(model->mapToSource(index)); if ( !entry ) return; if (entry->status() == Entry::Installed) { emit performAction(DownloadDialog::kUninstall, entry); } else { emit performAction(DownloadDialog::kInstall, entry); } } }
void KeyBinding::handleEvent(int key, int action) { if(action == GLFW_RELEASE) { if(binding.find(key) != binding.end()) { performAction(binding[key]); } else { DEBUG("Unbound key: " << key); } } }
void fileOpenCb(Widget w, XEvent *event, String *params, Cardinal *num_params) { FileWindowRec *fw; FileRec *file; int item; char path[MAXPATHLEN]; String *argv, push_action; if (!(fw = findFileWidget(w, &item))) return; zzz(); file = fw->files[item]; strcpy(path, fw->directory); if (path[strlen(path)-1] != '/') strcat(path, "/"); strcat(path, file->name); if (S_ISDIR(file->stats.st_mode)) { contractPath(path); chFileDir(fw, path); } else if (file->stats.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) { String arguments = XtNewString(file->name); String action = (String) XtMalloc((strlen(path) + 6) * sizeof(char)); strcat(strcpy(action, "exec "), path); argv = makeArgv(action, 1, &arguments); executeApplication(user.shell, fw->directory, argv); XTFREE(action); freeArgv(argv); } else if (file->type) { if (*(push_action = file->type->push_action)) { if (!(strcmp(push_action, "EDIT"))) doEdit(fw->directory, file->name); else if (!(strcmp(push_action, "VIEW"))) doView(fw->directory, file->name); else if (!(strcmp(push_action, "LOAD"))) { zzz(); newApplicationWindow(path, NULL); wakeUp(); } else { argv = (String *) XtMalloc(sizeof(String)); argv[0] = XtNewString(file->name); performAction(fw->shell, file->type->icon_pm.bm, push_action, fw->directory, 1, argv); XTFREE(argv); } } } else doEdit(fw->directory, file->name); wakeUp(); }
bool CDoorbot::DismissBotMsg(CDismissBotMsg *msg) { if (_npcFlags & NPCFLAG_400000) { playClip(getRandomNumber(1) ? "Whizz Off Left" : "Whizz Off Right", MOVIE_STOP_PREVIOUS | MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); movieEvent(); if (_npcFlags & NPCFLAG_START_IDLING) { _npcFlags &= ~NPCFLAG_START_IDLING; performAction(true); } else { performAction(false); } CActMsg actMsg("DoorbotDismissed"); actMsg.execute("BotIdleSummons"); } return true; }
void ItemsViewDelegate::slotActionTriggered(QAction *action) { QModelIndex index = focusedIndex(); Q_ASSERT(index.isValid()); const QSortFilterProxyModel * model = qobject_cast<const QSortFilterProxyModel*>(index.model()); const ItemsModel * realmodel = qobject_cast<const ItemsModel*>(model->sourceModel()); KNS::Entry * entry = realmodel->entryForIndex(model->mapToSource(index)); emit performAction(DownloadDialog::EntryAction(action->data().toInt()), entry); }
void BaseFilter::initAction() { if (m_action) return; m_action = new QAction(getIcon(), getEntryName(), this); m_action->setStatusTip(getStatusTip()); //connect this action connect(m_action, SIGNAL(triggered()), this, SLOT(performAction())); }
bool CBellBot::LeaveViewMsg(CLeaveViewMsg *msg) { if (_npcFlags & NPCFLAG_10000) { performAction(1); _npcFlags &= ~NPCFLAG_START_IDLING; CDismissBotMsg dismissMsg; dismissMsg.execute(this); } return true; }
void KeyBinding::handleStartup(string start) { if(start.find('#') != start.npos) start.erase(start.find('#')); vector<string> splitVec; boost::split(splitVec, start, boost::is_any_of(" =\t\n"), boost::token_compress_on); if(start.empty()) return; if(splitVec.size()!=1) { WARN("Malformed startup command: " << start); return; } performAction(splitVec[0]); }
void ItemsViewDelegate::slotLinkClicked(const QString & url) { Q_UNUSED(url) QModelIndex index = focusedIndex(); Q_ASSERT(index.isValid()); const QSortFilterProxyModel * model = qobject_cast<const QSortFilterProxyModel*>(index.model()); const ItemsModel * realmodel = qobject_cast<const ItemsModel*>(model->sourceModel()); KNS::Entry * entry = realmodel->entryForIndex(model->mapToSource(index)); emit performAction(DownloadDialog::kContactEmail, entry); }
bool CDeskbot::TurnOff(CTurnOff *msg) { if (_deskbotActive) { stopMovie(); performAction(1, findView()); _npcFlags = (_npcFlags & ~(NPCFLAG_SPEAKING | NPCFLAG_IDLING | NPCFLAG_START_IDLING)) | NPCFLAG_40000; playClip("Closing", MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); } return true; }
void testHarness (ConveyorBelt *cv){ // while action!= shutdown provide input to reflexagent int action = -1; int i = 0; while(action != SHUT_DOWN){ printf("INPUT PERCEPTION: %d %d\n", getItem(cv, i), getItem(cv, i+1)); action = ReflexAgent ( getItem(cv,i) , getItem(cv, i+1) ); i = performAction(cv, action, i); } }
void RobotEntity::update() { SimpleMovingEntity::update(); // test for action m_actionCounter--; if (m_actionCounter <= 0) { performAction(); int range = m_maxActionCount - m_minActionCount; m_actionCounter = m_minActionCount + (rand()%range); } }
void fileExecProc(XtPointer fnm, int conf) { ExecFileRec *data = (ExecFileRec *) fnm; String action; if (conf == YES) { action = (String) XtMalloc((strlen(data->action) + strlen(data->arguments) + 2) * sizeof(char)); sprintf(action, "%s %s", data->action, data->arguments); performAction(data->shell, data->icon.bm, action, data->directory, 0, NULL); XTFREE(action); } XTFREE(data->arguments); XTFREE(data->directory); XTFREE(data->action); XTFREE(data); }
void first4thread::incomingRequest() { if(tcpSocket->canReadLine()) { QDomDocument incReq("req"); QByteArray request; request = tcpSocket->read(tcpSocket->bytesAvailable()); incReq.setContent(request); QDomElement docElem = incReq.documentElement(); QDomNodeList nlist = docElem.elementsByTagName("Request"); if(nlist.size() > 0) { QDomElement e = nlist.at(0).toElement(); if(!e.isNull()) performAction(e.attribute("Action"), e); } } }
bool CSuccUBus::TurnOff(CTurnOff *msg) { if (_soundHandle != -1) { stopSound(_soundHandle); _soundHandle = -1; } if (_offStartFrame >= 0) { playSound("z#27.wav", 100); playMovie(_offStartFrame, _offEndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); } if (!_signalFlag && _endingStartFrame >= 0) playMovie(_endingStartFrame, _endingEndFrame, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); _isOn = false; performAction(true); CSUBTransition transMsg; transMsg.execute(this); return true; }
bool CBilgeSuccUBus::LeaveViewMsg(CLeaveViewMsg *msg) { petDisplayMessage(2, BLANK); petClear(); if (_soundHandle != -1) { stopSound(_soundHandle); _soundHandle = -1; } if (_enabled) { _enabled = false; if (_startFrame10 >= 0) playSound("z#27.wav"); } performAction(true); CSUBTransition transMsg; transMsg.execute(this); return true; }
bool CSuccUBus::TurnOff(CTurnOff *msg) { if (_soundHandle != -1) { stopSound(_soundHandle); _soundHandle = -1; } if (_startFrame10 >= 0) { playSound("z#27.wav", 100); playMovie(_startFrame10, _endFrame10, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); } if (!_field15C && _startFrame11 >= 0) playMovie(_startFrame11, _endFrame11, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); _enabled = false; performAction(true); CSUBTransition transMsg; transMsg.execute(this); return true; }
bool Cursor::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id) { //plant seed switch(id){ case OIS::MouseButtonID::MB_Left: //create if (mPressed==false) performAction(); mPressed=true; break; case OIS::MouseButtonID::MB_Right: //delete mCanvas->removeObject(mCurrentSelection); break; } return true; }
int runInterpreter(void) { AST M = getTree("main"); if(M != NULL) { AST R = simplify(M); if((R->kind == ACTION_NK) || ((R->kind == BASIC_FUNC_NK) && ((R->extra == PRILST_FK) || (R->extra == PRINT_FK) || (R->extra == PROD_FK) || (R->extra == READI_FK) || (R->extra == READC_FK)))) { AST ret = performAction(R); if(ret->kind != EMPTYLIST) { if(ret->kind == CONS_NK) displayList(ret); else displayAST(ret); } } else { AST S = simplify(R); if(S->kind != EMPTYLIST) { if(S->kind == CONS_NK) displayList(S); else displayAST(R); } } printf("\n"); } return 0; }
bool performEffectiveAction(QAccessibleInterface *iface, const QString &actionName) { if (!iface) return false; if (performAction(iface, actionName)) return true; if (actionName != QAccessibleActionInterface::increaseAction() && actionName != QAccessibleActionInterface::decreaseAction()) return false; QAccessibleValueInterface *valueIface = iface->valueInterface(); if (!valueIface) return false; bool success; const QVariant currentVariant = valueIface->currentValue(); double stepSize = valueIface->minimumStepSize().toDouble(&success); if (!success || qFuzzyIsNull(stepSize)) { const double min = valueIface->minimumValue().toDouble(&success); if (!success) return false; const double max = valueIface->maximumValue().toDouble(&success); if (!success) return false; stepSize = (max - min) / 10; // this is pretty arbitrary, we just need to provide something const int typ = currentVariant.type(); if (typ != QMetaType::Float && typ != QMetaType::Double) { // currentValue is an integer. Round it up to ensure stepping in case it was below 1 stepSize = qCeil(stepSize); } } const double current = currentVariant.toDouble(&success); if (!success) return false; if (actionName == QAccessibleActionInterface::decreaseAction()) stepSize = -stepSize; valueIface->setCurrentValue(current + stepSize); return true; }