void DisconectedView::init() { removeAllButtons(); setBordered(true); setAllowResize(false); resize(screen->getWidth(),screen->getHeight()); moveTo(0,0); int bsize = Surface::getTextLength(" ") * 8; addButtonCenterText(iXY((getClientRect().getSizeX()/2)-(bsize/2), (getClientRect().getSizeY()/2)+(Surface::getFontHeight() * 2)), bsize, "Ok", "", buttonOk); }
// HostOptionsView //--------------------------------------------------------------------------- HostOptionsView::HostOptionsView() : RMouseHackView() { setSearchName("HostOptionsView"); setTitle("Host Options"); setSubTitle(""); setAllowResize(false); setAllowMove(false); setVisible(false); moveTo(bodyTextRect.min.x, bodyTextRect.min.y + 190); resizeClientArea(bodyTextRect.getSizeX(), 168); addMeterButtons(iXY(BORDER_SPACE, BORDER_SPACE)); } // end HostOptionsView::HostOptionsView
// RankView //--------------------------------------------------------------------------- RankView::RankView() : GameTemplateView() { setSearchName("RankView"); setTitle("Rankings"); setSubTitle(" - F6"); setAllowResize(false); moveTo(iXY(0, 0)); resize(iXY(450, 200)); centerAbsolute(); const unsigned MAX_NAME_CHARS = 20; const unsigned MAX_FLAG_CHARS = 5; const unsigned MAX_KILLS_CHARS = 6; const unsigned MAX_LOSSES_CHARS = 7; const unsigned MAX_POINTS_CHARS = 7; const unsigned MAX_OBJECTIVE_CHARS = 10; //addLabel(iXY nPos, char *nLabel, BYTE color); unsigned xOffset = 0; unsigned yOffset = 16; addLabel(iXY(xOffset, yOffset), "Name", Color::red); xOffset += MAX_NAME_CHARS*CHAR_XPIX; addLabel(iXY(xOffset, yOffset), "Flag", Color::red); xOffset += MAX_FLAG_CHARS*CHAR_XPIX; addLabel(iXY(xOffset, yOffset), "Kills", Color::red); xOffset += MAX_KILLS_CHARS*CHAR_XPIX; addLabel(iXY(xOffset, yOffset), "Losses", Color::red); xOffset += MAX_LOSSES_CHARS*CHAR_XPIX; addLabel(iXY(xOffset, yOffset), "Points", Color::red); xOffset += MAX_POINTS_CHARS*CHAR_XPIX; addLabel(iXY(xOffset, yOffset), "Objective", Color::red); xOffset += MAX_POINTS_CHARS*CHAR_XPIX; // Define the scrollBar fot this view. scrollBar = new ScrollBar(VERTICAL, 0, 1, 0, 100); if (scrollBar == 0) { throw Exception("ERROR: Unable to allocate the scrollBar."); } //iRect clientRect(getClientRect()); //scrollBar->setViewableAmount(clientRect.getSizeY() / (TEXT_GAP_SPACE + CHAR_YPIX) - 1); //scrollBar->setBlockIncrement(1); //add(scrollBar); } // end RankView::RankView
void Remove (int position, List *L) { ListNode *p, *q; if(position==0) { q=L->first; L->first=q->next; } else { p=moveTo(position-1,L); q=p->next; p->next=q->next; } destroyItem(&q->item); free(q); L->size--; }
void Insert (Item X, int position, List *L) { ListNode *p, *q; L->size++; q=(ListNode *)malloc(sizeof(ListNode)); copyItem(&q->item,X); if(position==0) { q->next=L->first; L->first=q; } else { p=moveTo(position-1,L); q->next=p->next; p->next=q; } }
// rMouseDrag //--------------------------------------------------------------------------- void GameTemplateView::rMouseDrag(const iXY&, const iXY &prevPos, const iXY &newPos) { // Check for view blending mode change. if (KeyboardInterface::getKeyPressed(SDLK_1)) { gameconfig->viewdrawbackgroundmode = VIEW_BACKGROUND_DARK_GRAY_BLEND; } else if (KeyboardInterface::getKeyPressed(SDLK_2)) { gameconfig->viewdrawbackgroundmode = VIEW_BACKGROUND_LIGHT_GRAY_BLEND; } else if (KeyboardInterface::getKeyPressed(SDLK_3)) { gameconfig->viewdrawbackgroundmode = VIEW_BACKGROUND_SOLID_BLACK; } else if (KeyboardInterface::getKeyPressed(SDLK_4)) { gameconfig->viewdrawbackgroundmode = VIEW_BACKGROUND_TRANSPARENT; } moveTo(min + newPos - prevPos); checkArea(iXY(screen->getWidth(),screen->getHeight())); notifyMoveTo(); }
BOOL ringFile::reName(LPCTSTR lpNewName) { if(m_bExtern || lpNewName == NULL || *lpNewName == '\0') return FALSE; char dbuf[MAX_PATH]; char szTemp[MAX_PATH]; strcpy(szTemp,Pathname()); if(szTemp[strlen(szTemp)-1] == '\\') szTemp[strlen(szTemp)-1] = 0; wsprintf(dbuf,"%s\\%s\0\0",szTemp,lpNewName); return moveTo((LPSTR)dbuf,FALSE); }
/* * Reset Robot * Returns 0 if successful */ int reset() { //Variables int i; u32 value; //Move to initial setting for (i = 0; i < NUMBER_OF_JOINTS; i++) { value = moveTo(jointVal[i], PWM_VAL_INIT); if (value != PWM_VAL_INIT) { return PWM_FAILURE; } } //Return return PWM_SUCCESS; }
// Simple setting and getting of properties for scripts and the set command. stError* cUObject::setProperty( const QString& name, const cVariant& value ) { changed( TOOLTIP ); changed_ = true; // \rproperty object.serial This integer property contains the serial for this object. if ( name == "serial" ) { if ( !value.canCast( cVariant::IntType ) ) { PROPERTY_ERROR( -3, QString( "Invalid integer value: '%1'" ).arg( value.toString() ) ); } setSerial( value.toInt() ); return 0; } // \property object.free This boolean property indicates that the object has been freed and is awaiting deletion. else SET_BOOL_PROPERTY( "free", free ) // \property object.name This string property contains the name of the object. else SET_STR_PROPERTY( "name", this->name_ ) // \property object.pos This property is a <object id="coord">coord</object> object (Python) or a string representation (Show/Set) of the objects position. else if ( name == "pos" ) { Coord pos; if ( !parseCoordinates( value.toString(), pos ) ) PROPERTY_ERROR( -3, QString( "Invalid coordinate value: '%1'" ).arg( value.toString() ) ) moveTo( pos ); return 0; } // \property object.eventlist This string property contains a comma separated list of the names of the scripts that are assigned to this object. else if ( name == "scriptlist" ) { clearScripts(); QStringList list = value.toString().split( "," ); for ( QStringList::const_iterator it( list.begin() ); it != list.end(); ++it ) { cPythonScript* script = ScriptManager::instance()->find( ( *it ).toLatin1() ); if ( script ) addScript( script ); else PROPERTY_ERROR( -3, QString( "Script not found: '%1'" ).arg( *it ) ) } return 0; }
void ofxSphereCam::randomPosM() { ofVec3f mt = ofVec3f( ofRandom(-300,300), ofRandom(-300,300), ofRandom(-300,300) ); moveTo(mt, ofRandom(1000,2000)); ofVec3f lt = ofVec3f( ofRandom(-300,300), ofRandom(-300,300), ofRandom(-300,300) ); lookAtTo(lt, ofRandom(1000,2000)); }
void GenericTetrix::dropDown() { if (currentLine == -1) return; int dropHeight = 0; int newLine = currentLine; while(newLine) { if (!canMoveTo(currentPos,newLine - 1)) break; newLine--; dropHeight++; } if (dropHeight != 0) moveTo(currentPos,newLine); internalPieceDropped(dropHeight); }
GraphRef copyGraph(GraphRef G){ int i, j; GraphRef Q = newGraph(G->order); for(i=1;i<=G->order;i++){ if(!isEmpty(G->adj[i])){ moveTo(G->adj[i], 0); for(j=0;j<getLength(G->adj[i]);j++){ addArc(Q, i, getCurrent(G->adj[i])); if(j<getLength(G->adj[i])-1){ moveNext(G->adj[i]); } } } } return(Q); }
void NPC::passNode() { if(!_path.empty()) { _map->setObstructingObjectF(_oriX, _oriY, 0); _map->setObstructingObjectF(_nxtX, _nxtY, 0); _oriX = _nxtX; _oriY = _nxtY; Point nxt = _path.back(); _path.pop_back(); _nxtX = nxt.x; _nxtY = nxt.z; if(_map->getObstructingObjectF(_nxtX, _nxtY) != 0) { moveTo(_dstX, _dstY); _map->setObstructingObjectF(_nxtX, _nxtY, _id); } _map->setObstructingObjectF(_oriX, _oriY, _id); } }
void Scorpion::doSomething() { int x, y; getLocation(x, y); //get current location if(getWorld()->mushroomThere(x, y) && randInt(1, 3)==1) //if it's on a mushroom getWorld()->makeMushroomPoisonous(x, y); //there's a 33% chance of making it poisonous int newx=x+1; if(newx<GARDEN_WIDTH-1) //move to the right if it's in bounds moveTo(newx, y); else setDead(); //otherwise, set it to dead getWorld()->killPlayer(newx, y); //if it lands on player, kill it }
/*! \internal \fn void SelectedItem::moveRequested(Direction direction) Moves this object in the given direction. Calls \l{function}{moveTo(GridItem *_destItem)}. */ void SelectedItem::moveRequested(Direction direction) { int row; int col; if ( destItem ) { // Move already in progress. row = destItem->row(); col = destItem->column(); } else { row = currentItem->row(); col = currentItem->column(); } switch( direction) { case Right: col++; break; case Left: col--; break; case Up: row--; break; case Down: row++; break; default: qWarning("SelectedItem::moveRequested(...): Error - invalid direction of %d.",direction); return; } if ( (row < 0) || (row > table.topRow()) || (col < 0) || (col > table.topColumn()) ) { // We ain't going nowhere. return; } // Retrieve the destination item. GridItem *_destItem = table.item(row,col); if ( !_destItem ) { qWarning("SelectedItem::moveRequested(...): Error - no item for row %d, column %d.",row,col); return; } // Move the selection. moveTo(_destItem); }
void Printer::startProbing(bool runScript) { float oldOffX = Printer::offsetX; float oldOffY = Printer::offsetY; float oldOffZ = Printer::offsetZ; if(runScript) GCode::executeFString(Com::tZProbeStartScript); float maxStartHeight = EEPROM::zProbeBedDistance() + (EEPROM::zProbeHeight() > 0 ? EEPROM::zProbeHeight() : 0) + 0.1; if(currentPosition[Z_AXIS] > maxStartHeight) { moveTo(IGNORE_COORDINATE, IGNORE_COORDINATE, maxStartHeight, IGNORE_COORDINATE, homingFeedrate[Z_AXIS]); } Printer::offsetX = -EEPROM::zProbeXOffset(); Printer::offsetY = -EEPROM::zProbeYOffset(); Printer::offsetZ = 0; // we correct this with probe height PrintLine::moveRelativeDistanceInSteps((Printer::offsetX - oldOffX) * Printer::axisStepsPerMM[X_AXIS], (Printer::offsetY - oldOffY) * Printer::axisStepsPerMM[Y_AXIS], 0, 0, EEPROM::zProbeXYSpeed(), true, ALWAYS_CHECK_ENDSTOPS); }
/* * Move to Absolute Angle */ float moveToAbsAngle(Joint joint, float dgr) { //Variables u32 val, realVal; float angle; //Get final steps val = angleToValue(joint, dgr); //Move realVal = moveTo(joint, val); //Get Current Angle angle = valToAngle(joint, realVal); //Return return angle; }
void Flea::doSomething() { int x, y; getLocation(x, y); //get its current location if(!getWorld()->mushroomThere(x, y) && y>0 && y<GARDEN_HEIGHT-1) //if there's no mushroom there and it's within height bounds if(randInt(1, 4)==1) getWorld()->dropMushroom(x, y); //there's a 25% chance to drop a regular mushroom y--; //make the flea move down if(y<0) //if it leaves bottom bounds, set it to dead setDead(); else moveTo(x, y); //otherwise, move to that new spot getWorld()->killPlayer(x, y); }
Brick::Brick(GameEngine *gameEngine, QString typeString, int x, int y) : Item(typeString, BRICK_WIDTH, BRICK_HEIGHT), m_game(gameEngine), m_deleted(false) { m_gift = 0; if (typeString != "UnbreakableBrick" && typeString != "HiddenBrick") { ++m_game->m_remainingBricks; } moveTo((x-1)*BRICK_WIDTH, (y-1)*BRICK_HEIGHT); repaint(); if (typeString == "HiddenBrick") { hide(); } }
// RankView //--------------------------------------------------------------------------- RankView::RankView() : GameTemplateView() { setSearchName("RankView"); setTitle("Rankings"); setSubTitle(" - TAB"); moveTo(gameconfig->rankposition); resize(iXY(450 + 20, 200)); checkArea(iXY(screen->getWidth(),screen->getHeight())); const unsigned MAX_ALLY_CHARS = 6; // const unsigned MAX_FLAG_CHARS = 5; const unsigned MAX_NAME_CHARS = 20; const unsigned MAX_KILLS_CHARS = 6; const unsigned MAX_LOSSES_CHARS = 7; const unsigned MAX_POINTS_CHARS = 7; // hardcoded for now int CHAR_XPIX = 8; unsigned xOffset = 0; unsigned yOffset = 16; add( new Label( xOffset, yOffset, "*Flag", Color::red, Color::gray64, true) ); xOffset += MAX_ALLY_CHARS*CHAR_XPIX; // add( new Label( xOffset, yOffset, "Flag", Color::red, Color::gray64, true) ); // xOffset += MAX_FLAG_CHARS*CHAR_XPIX; add( new Label( xOffset, yOffset, "Name", Color::red, Color::gray64, true) ); xOffset += MAX_NAME_CHARS*CHAR_XPIX; add( new Label( xOffset, yOffset, "Kills", Color::red, Color::gray64, true) ); xOffset += MAX_KILLS_CHARS*CHAR_XPIX; add( new Label( xOffset, yOffset, "Losses", Color::red, Color::gray64, true) ); xOffset += MAX_LOSSES_CHARS*CHAR_XPIX; add( new Label( xOffset, yOffset, "Points", Color::red, Color::gray64, true) ); xOffset += MAX_POINTS_CHARS*CHAR_XPIX; add( new Label( xOffset, yOffset, "Objective", Color::red, Color::gray64, true) ); xOffset += MAX_POINTS_CHARS*CHAR_XPIX; // shall be in resource manager allyImage.loadPNG("pics/default/ally.png"); allyRequestImage.loadPNG("pics/default/allyRequest.png"); allyOtherImage.loadPNG("pics/default/allyOther.png"); noAllyImage.loadPNG("pics/default/noAlly.png"); states.clear(); } // end RankView::RankView
// GetSessionHostView //--------------------------------------------------------------------------- GetSessionHostView::GetSessionHostView() : View() { setSearchName("GetSessionHostView"); setTitle("Select Session Host"); setSubTitle(""); setAllowResize(false); setAllowMove(false); //setDisplayStatusBar(true); setVisible(false); moveTo(bodyTextRect.min.x, bodyTextRect.min.y + 190); resizeClientArea(bodyTextRect.getSizeX(), 158); //moveTo(68, 204); //resize(610 - 68, 161); //setScrollBar(true); viewableItemCount = 0; highlightedItem = -1; selectedItem = -1; maxYOffset = 0; // Define the scrollBar fot this view. //scrollBar = new ScrollBar(VERTICAL, 0, 1, 0, 100); //add(scrollBar); maxViewableItems = getClientRect().getSizeY() / (TEXT_GAP_SPACE + CHAR_YPIX) - 1; topViewableItem = 0; iXY size(20, 20); iXY pos(getClientRect().getSizeX() - size.x, 0); //upButton.setLabel("+"); //upButton.setBounds(iRect(pos, pos + size)); //add(&upButton); // //pos = iXY(getClientRect().getSizeX() - size.x, getClientRect().getSizeY() - size.y); //downButton.setLabel("-"); //downButton.setBounds(iRect(pos, pos + size)); //add(&downButton); } // end GetSessionHostView constructor
//handle mouse move events // void SystemTopologyDrawing::mouseMoveEvent( QMouseEvent* event ) { if ( event->buttons() & Qt::LeftButton ) { //if mouse is left-clicked and moved while shift is pressed, then //move the topology if ( shiftPressed ) { moveTo( event->pos() ); } //if mouse is left-clicked and moved while control is pressed, //then increase the plane distance else if ( controlPressed ) { int planeDistance = transform->getPlaneDistance(); planeDistance += ( int )event->pos().y() - lastPoint.y(); if ( planeDistance <= 0.0 ) { planeDistance = 1; } lastPoint = event->pos(); transform->setPlaneDistance( planeDistance ); draw(); } //if mouse is left-clicked and moved, rotate the topology else { rotateTo( event->pos() ); } event->accept(); } else if ( event->buttons() & Qt::RightButton ) { //if mouse is right-clicked and moved, then change the item for //which the info box is displayed lastPoint = event->pos(); draw(); event->accept(); } else { event->ignore(); } }
//Returns a reference to a new graph object representing the transpose of G Graph transpose(Graph G){ if( G == NULL ) { printf("Graph Error: calling transpose() on NULL Graph reference\n"); exit(1); } Graph H; H=newGraph(getOrder(G)); for(int i=1; i <= getOrder(G); i++) { if(length(G->vneighbor[i]) != 0) { moveTo(G->vneighbor[i], 0); while(getIndex(G->vneighbor[i]) > -1) { addArc(H, getElement(G->vneighbor[i]),i); moveNext(G->vneighbor[i]); } } } return H; }
void Human_Guard_MoveToTarget::execute() { Human_Guard* pAI = dynamic_cast<Human_Guard*>( m_ai ); P_CHAR pTarget = ( pAI ? pAI->currentVictim() : NULL ); // Make sure we are attacking the target // If there is no target, stop. m_npc->fight( pTarget ); if ( !pTarget ) return; if ( Config::instance()->pathfind4Combat() ) movePath( pTarget->pos() ); else moveTo( pTarget->pos() ); }
void _drawBorder( float x1, float y1, float x2, float y2, float xoff, float size, const osgWidget::Color& lc, const osgWidget::Color& fc ) { setSourceRGBA(lc); moveTo(x1 + xoff, 0.0f); lineTo(x1 + xoff, size); stroke(); rectangle(x1, y1, x2, y2); setSourceRGBA(fc); fill(); }
void CharacterMovement::moveTo(QVector3D destination) { // new destination _destination = destination; stopMoving(); // qreal dist = UtilFunctions::calculateDistance(_position, destination); if (dist <= _minDistance) { qWarning() << "[CharacterMovement::moveTo(QVector3D)] Distance to next point is smaller than the minimum distance variable." << dist; qDebug() << "[CharacterMovement::moveTo(QVector3D)] - Emited stopedMoving"; emit stopedMoving(); } else { moveTo(); } }
int BasicMonster::doFlee() { if (lastSeenPlayer.x < 0) return 0; Point diff = position - lastSeenPlayer; std::vector<Point> locations; for (int i=0; i<9; i++) { Point target = position + Point(Player::dx[i], Player::dy[i]); if (Point::sqlen(target - lastSeenPlayer) > Point::sqlen(diff) && level->isWalkable(target)) locations.push_back(target); } if (locations.size() == 0) return 0; Point step = Level::chooseRandomPoint(locations, false); float diagonal = (step.x - position.x != 0 && step.y - position.y != 0) ? std::sqrt(2.f) : 1.f; moveTo(step); return static_cast<int>(getWalkingSpeed() * diagonal); }
FPTRLIST_INLINE bool FPtrList::FPtrListPrivate::replace(int nIndex, LPVOID pVal) { if (!moveTo(nIndex)) { return false; } FASSERT(NULL != m_pCursor); if (m_pCursor->pVal != pVal) { /** 调用移除回调函数 */ removeCallBack(m_pCursor->pVal); m_pCursor->pVal = pVal; } return true; }
// init //--------------------------------------------------------------------------- void AreYouSureResignView::init() { setBordered(false); setDisplayStatusBar(false); resize(screen->getWidth(), screen->getHeight()); moveTo(0,0); int x = (getClientRect().getSize().x - (141 * 2 + 20)) / 2; int y = getClientRect().getSize().y/2 + 30; iXY pos(x,y); add( Button::createSpecialButton("yes","Yes", pos, BTN_YES)); pos.x += 141 + 10; add( Button::createSpecialButton("no","No", pos, BTN_NO)); } // end AreYouSureResignView::init
// PlayerNameView //--------------------------------------------------------------------------- PlayerNameView::PlayerNameView() : View() { setSearchName("PlayerNameView"); setTitle("Player Name"); setSubTitle(""); setAllowResize(false); setAllowMove(false); setVisible(false); moveTo(bodyTextRect.min); // The plus 8 for x and 4 for y are what I put in input field. Add function to find out, // inpit field dimension. int CHAR_XPIX = 8; // XXX hardcoded :-/ resizeClientArea((INPUT_FIELD_CHARACTERS+1) * CHAR_XPIX + 8 + BORDER_SPACE * 2, Surface::getFontHeight() + 4 + BORDER_SPACE * 2); init(); } // end PlayerNameView::PlayerNameView