void TEditor::setCurPtr( ushort p, uchar selectMode ) { ushort anchor; if( (selectMode & smExtend) == 0 ) anchor = p; else if( curPtr == selStart ) anchor = selEnd; else anchor = selStart; if( p < anchor ) { if( (selectMode & smDouble) != 0 ) { p = prevLine(nextLine(p)); anchor = nextLine(prevLine(anchor)); } setSelect(p, anchor, True); } else { if( (selectMode & smDouble) != 0 ) { p = nextLine(p); anchor = prevLine(nextLine(anchor)); } setSelect(anchor, p, False); } }
bool DeckScene::onTouchBegan(Touch * touch, Event * unused_event) { if (!isInGame) { return false; } Point point = touch->getLocation(); for (int i = player->leftCard.size() - 1; i >= 0; i--) { auto card = player->leftCard.at(i); if (card->getBoundingBox().containsPoint(point)) { if (!card->isSelect()) { card->setSelect(true); card->setPositionY(card->getPositionY() + cardIntervalVertical); } else { card->setSelect(false); card->setPositionY(card->getPositionY() - cardIntervalVertical); } break; } } return true; }
bool SqliteResult::reset(const QString &q) { if (!driver) return false; if (!driver->isOpen() || driver->isOpenError()) return false; setActive(false); setAt(QSql::BeforeFirst); query = q.stripWhiteSpace(); if (q.find("select", 0, false) == 0) setSelect(true); else setSelect(false); query.replace("'true'", "'1'"); query.replace("'false'", "'0'"); query.replace("=;", "= NULL;"); while (query.endsWith(";")) query.truncate(query.length() - 1); if (query.upper().endsWith("NOWAIT")) query.truncate(query.length() - 6); if (query.upper().endsWith("FOR UPDATE")) query.truncate(query.length() - 10); if (!isSelect()) { if (query.find("CREATE TABLE", 0, false) == 0) { Dataset *ds = ((SqliteDriver *) driver) ->dataBase() ->CreateDataset(); if (!ds) return false; if (!ds->exec(query.latin1())) { delete ds; return false; } delete ds; } else { if (dataSet) delete dataSet; dataSet = ((SqliteDriver *) driver) ->dataBase() ->CreateDataset(); if (!dataSet->exec(query.latin1())) return false; } return true; } if (dataSet) delete dataSet; dataSet = ((SqliteDriver *) driver) ->dataBase() ->CreateDataset(); if (dataSet->query(query.latin1())) { setActive(true); return true; } else return false; }
void TEditor::deleteRange( size_t startPtr, size_t endPtr, Boolean delSelect ) { if( hasSelection() == True && delSelect == True ) deleteSelect(); else { setSelect(curPtr, endPtr, True); deleteSelect(); setSelect(startPtr, curPtr, False); deleteSelect(); } }
bool HelloWorld::onTouchBegan( Touch *touch, Event *unused_event ) { if(_gameOver) { return false; } if (!_circles.empty()) { for (auto pair : _circles) { auto circle = pair.second; Point local = convertToNodeSpace(touch->getLocation()); Rect r = circle->getBoundingBox(); if (r.containsPoint(local)) { if (!circle->IsSelect()) { circle->setSelect(); addMove(); } break; } } } return true; }
void HelloWorld::initCircle() { for (int i = 0 ; i < MAXROW ; i++) { for (int j = 0 ; j < MAXCOLLUM; j++) { auto sp = CircleSprite::createFromCoorAndLayer(Point(i,j),this); sp->setPosition(getPositionFromCoor(Point(i,j))); } } long long tt; struct timeval tv; gettimeofday(&tv,NULL); tt = tv.tv_sec * 1000 + tv.tv_usec / 1000; srand(tv.tv_usec); auto circlecount = 5 + rand() % 15; for (int i = 0;i<circlecount;i++) { tt += 1000; srand(tt); auto value = rand() % (MAXCOLLUM * MAXROW); if (value != (MAXROW * MAXCOLLUM) / 2) { auto circle = _circles.at(value); circle->setSelect(); } } }
Boolean TEditor::search( const char *findStr, ushort opts ) { ushort pos = curPtr; ushort i; do { if( (opts & efCaseSensitive) != 0 ) i = scan( &buffer[bufPtr(pos)], bufLen - pos, findStr); else i = iScan( &buffer[bufPtr(pos)], bufLen - pos, findStr); if( i != sfSearchFailed ) { i += pos; if( (opts & efWholeWordsOnly) == 0 || !( ( i != 0 && isWordChar(bufChar(i - 1)) != 0 ) || ( i + strlen(findStr) != bufLen && isWordChar(bufChar(i + strlen(findStr))) ) )) { lock(); setSelect(i, i + strlen(findStr), False); trackCursor(Boolean(!cursorVisible())); unlock(); return True; } else pos = i + 1; } } while( i != sfSearchFailed ); return False; }
bool QSpatiaLiteResult::prepare(const QString &query) { if (!driver() || !driver()->isOpen() || driver()->isOpenError()) return false; d->cleanup(); setSelect(false); const void *pzTail = NULL; #if (SQLITE_VERSION_NUMBER >= 3003011) int res = sqlite3_prepare16_v2(d->access, query.constData(), (query.size() + 1) * sizeof(QChar), &d->stmt, &pzTail); #else int res = sqlite3_prepare16(d->access, query.constData(), (query.size() + 1) * sizeof(QChar), &d->stmt, &pzTail); #endif if (res != SQLITE_OK) { setLastError(qMakeError(d->access, QCoreApplication::translate("QSpatiaLiteResult", "Unable to execute statement"), QSqlError::StatementError, res)); d->finalize(); return false; } else if (pzTail && !QString::fromUtf16( (const ushort *) pzTail ).trimmed().isEmpty()) { setLastError(qMakeError(d->access, QCoreApplication::translate("QSpatiaLiteResult", "Unable to execute multiple statements at a time"), QSqlError::StatementError, SQLITE_MISUSE)); d->finalize(); return false; } return true; }
OscilloscopeChannel::OscilloscopeChannel() { setConfigurable(true); setSelect(false); YRange = 1.0 ; // 代表 +- 1.0 YRef = 0.0 ; YOffset = 0.0 ; YStretchRatio = 1.0 ; // 不拉伸。 ShowDelay = 0 ; SamplesType = Original_FLOAT64 ; unlockSamplesType() ; setDescription(NULL); setLockDescription(false) ; DeltaTimeStamp = 1 ; // 已被遗弃。 SamplesSize = MAX_SAMPLES_IN_EACH_CHANNEL ; reset(); }
bool SQLiteResult::prepare(const QString &query) { if (!driver() || !driver()->isOpen() || driver()->isOpenError()) return false; d->cleanup(); setSelect(false); const void *pzTail = NULL; #if (SQLITE_VERSION_NUMBER >= 3003011) int res = sqlite3_prepare16_v2(d->access, query.constData(), (query.size() + 1) * sizeof(QChar), &d->stmt, &pzTail); #else int res = sqlite3_prepare16(d->access, query.constData(), (query.size() + 1) * sizeof(QChar), &d->stmt, &pzTail); #endif if (res != SQLITE_OK) { #if defined(SQLITEDRIVER_DEBUG) trace(NULL, query.toUtf8().constData()); #endif setLastError(qMakeError(d->access, QCoreApplication::translate("SQLiteResult", "Unable to execute statement"), QSqlError::StatementError, res)); d->finalize(); return false; } else if (pzTail && !stringFromUnicode(reinterpret_cast<const QChar *>(pzTail)).trimmed().isEmpty()) { setLastError(qMakeError(d->access, QCoreApplication::translate("SQLiteResult", "Unable to execute multiple statements at a time"), QSqlError::StatementError, SQLITE_MISUSE)); d->finalize(); return false; } return true; }
void indicateValidity(QWidget *w, bool isValid) { auto *combo = qobject_cast<QComboBox*>(w->parentWidget()); setSelect(m_validWidgets, isValid, combo ? combo : w); styleSheetSelect(w, !isValid, QStringLiteral("%1 { background: yellow }") .arg(QLatin1String(w->metaObject()->className()))); emit newValidity(m_validWidgets.count() == m_needsValid); }
/* Execute \a query. */ bool QSQLite2Result::reset (const QString& query) { // this is where we build a query. if (!driver()) return false; if (!driver()-> isOpen() || driver()->isOpenError()) return false; d->cleanup(); // Um, ok. callback based so.... pass private static function for this. setSelect(false); char *err = 0; int res = sqlite_compile(d->access, d->utf8 ? query.toUtf8().constData() : query.toAscii().constData(), &(d->currentTail), &(d->currentMachine), &err); if (res != SQLITE_OK || err) { setLastError(QSqlError(QCoreApplication::translate("QSQLite2Result", "Unable to execute statement"), QString::fromAscii(err), QSqlError::StatementError, res)); sqlite_freemem(err); } //if (*d->currentTail != '\000' then there is more sql to eval if (!d->currentMachine) { setActive(false); return false; } // we have to fetch one row to find out about // the structure of the result set d->skippedStatus = d->fetchNext(d->firstRow, 0, true); if (lastError().isValid()) { setSelect(false); setActive(false); return false; } setSelect(!d->rInf.isEmpty()); setActive(true); return true; }
/* Execute \a query. */ bool QSQLiteResult::reset (const QString& query) { // this is where we build a query. if (!driver()) return FALSE; if (!driver()-> isOpen() || driver()->isOpenError()) return FALSE; d->cleanup(); // Um, ok. callback based so.... pass private static function for this. setSelect(FALSE); char *err = 0; int res = sqlite_compile(d->access, d->utf8 ? (const char*)query.utf8().data() : query.ascii(), &(d->currentTail), &(d->currentMachine), &err); if (res != SQLITE_OK || err) { setLastError(QSqlError("Unable to execute statement", err, QSqlError::Statement, res)); sqlite_freemem(err); } //if (*d->currentTail != '\000' then there is more sql to eval if (!d->currentMachine) { setActive(FALSE); return FALSE; } // we have to fetch one row to find out about // the structure of the result set d->skippedStatus = d->fetchNext(0); setSelect(!d->rInf.isEmpty()); if (isSelect()) init(d->rInf.count()); setActive(TRUE); return TRUE; }
void ewol::widget::ListFileSystem::onParameterChangeValue(const ewol::parameter::Ref& _paramPointer) { ewol::widget::List::onParameterChangeValue(_paramPointer); if (_paramPointer == m_folder) { regenerateView(); } else if (_paramPointer == m_selectFile) { setSelect(m_selectFile); } else if (_paramPointer == m_showFile) { regenerateView(); } else if (_paramPointer == m_showFolder) { regenerateView(); } else if (_paramPointer == m_showHidden) { regenerateView(); } else if (_paramPointer == m_showTemporaryFile) { regenerateView(); } }
void selectUnit(gameMap_t * self,sf::RenderWindow & window,sf::Sprite & cSel,selection_t*select,unsigned int player){ for(int i = 0;i<cellNumX;i++){ for(int j = 0;j<cellNumY;j++){ if(self->cell[i][j].unit!=NULL){ if (sf::IntRect(self->cell[i][j].X, self->cell[i][j].Y, cell_width, cell_height).contains(sf::Mouse::getPosition(window))&&self->cell[i][j].obj_un_null==1&&sf::Mouse::isButtonPressed(sf::Mouse::Left)&&self->cell[i][j].unit->player == player) { cSel.setPosition(self->cell[i][j].X,self->cell[i][j].Y); setSelect(&self->cell[i][j],select); } } } } }
void *TFileEditor::read( ipstream& is ) { TEditor::read( is ); is.readString( fileName, sizeof( fileName ) ); if( isValid ) { isValid = loadFile(); size_t sStart, sEnd, curs; is >> sStart >> sEnd >> curs; if( isValid && sEnd <= bufLen ) { setSelect( sStart, sEnd, Boolean(curs == sStart) ); trackCursor( True ); } } return this; }
YGroup::YGroup(YGroup* p){ resizing = FALSE; sPoint = p->getSPoint(); ePoint = p->getEPoint(); mixPoint = p->getMixPoint(); setOrder(p->getOrder()); setSelect(FALSE); setType(p->getType()); setRgn(); POSITION pos = p->getList()->GetHeadPosition(); groupList.RemoveAll(); while (pos){ YObject* object = p->getList()->GetNext(pos); groupList.AddTail(object); } }
void xQGanttBarViewPort::setMode(int mode) ///////////////////////////// { if(_mode == (Mode) mode) { return; } switch(_mode) { case Select: setSelect(); break; case Zoom: setZoom(); break; case Move: setMove(); break; default: setCursor(arrowCursor); setMouseTracking(false); break; } emit modeChanged(_mode); }
bool QSymSQLResult::prepare(const QString &query) { if (!driver() || !driver()->isOpen() || driver()->isOpenError()) return false; d->cleanup(); setSelect(false); TInt res = d->stmt.Prepare(d->access, qt_QString2TPtrC(query)); if (res != KErrNone) { setLastError(qMakeError(d->access, QCoreApplication::translate("QSymSQLResult", "Unable to execute statement"), QSqlError::StatementError, res)); d->finalize(); return false; } d->prepareCalled = true; return true; }
bool embeddedResult::reset (const QString& query) { if (!driver() || !driver()->isOpen() || driver()->isOpenError() || !d->driver) return false; d->preparedQuery = false; cleanup(); //qDebug() << "In reset: " + query; const QByteArray encQuery(fromUnicode(d->driver->d->tc, query)); //const QByteArray encQuery = query.toLocal8Bit(); if (mysql_real_query(d->driver->d->mysql, encQuery.data(), encQuery.length())) { setLastError(qMakeError(QCoreApplication::translate("embeddedResult", "Unable to execute query"), QSqlError::StatementError, d->driver->d)); return false; } d->result = mysql_store_result(d->driver->d->mysql); if (!d->result && mysql_field_count(d->driver->d->mysql) > 0) { setLastError(qMakeError(QCoreApplication::translate("embeddedResult", "Unable to store result"), QSqlError::StatementError, d->driver->d)); return false; } int numFields = mysql_field_count(d->driver->d->mysql); setSelect(numFields != 0); d->fields.resize(numFields); d->rowsAffected = mysql_affected_rows(d->driver->d->mysql); if (isSelect()) { for(int i = 0; i < numFields; i++) { MYSQL_FIELD* field = mysql_fetch_field_direct(d->result, i); d->fields[i].type = qDecodeMYSQLType(field->type, field->flags); } setAt(QSql::BeforeFirstRow); } setActive(true); return isActive(); }
bool QMYSQLResult::reset ( const QString& query ) { if ( !driver() ) return FALSE; if ( !driver()-> isOpen() || driver()->isOpenError() ) return FALSE; cleanup(); const char *encQuery = query.ascii(); if ( mysql_real_query( d->mysql, encQuery, qstrlen(encQuery) ) ) { setLastError( qMakeError("Unable to execute query", QSqlError::Statement, d ) ); return FALSE; } if ( isForwardOnly() ) { if ( isActive() || isValid() ) // have to empty the results from previous query fetchLast(); d->result = mysql_use_result( d->mysql ); } else { d->result = mysql_store_result( d->mysql ); } if ( !d->result && mysql_field_count( d->mysql ) > 0 ) { setLastError( qMakeError( "Unable to store result", QSqlError::Statement, d ) ); return FALSE; } int numFields = mysql_field_count( d->mysql ); setSelect( !( numFields == 0) ); d->fieldTypes.resize( numFields ); if ( isSelect() ) { for( int i = 0; i < numFields; i++) { MYSQL_FIELD* field = mysql_fetch_field_direct( d->result, i ); if ( field->type == FIELD_TYPE_DECIMAL ) d->fieldTypes[i] = QVariant::String; else d->fieldTypes[i] = qDecodeMYSQLType( field->type, field->flags ); } } setActive( TRUE ); return TRUE; }
void DeckScene::flashCard() { player->sortCard(); for (int i = 0; i < player->leftCard.size(); i++) { auto card = player->leftCard.at(i); int interval = i - player->leftCard.size() / 2; auto distance = cardIntervalHorizontal * interval; card->removeFromParentAndCleanup(true); if (card->isVisible()) { card->setPosition(origin.x + visible.width / 2 + distance, 100); } else { card->setPosition(origin.x + visible.width / 2 + distance, 100 + cardIntervalVertical); card->setVisible(true); card->setSelect(true); log("Index:%d, x:%f y:%f", i, card->getPositionX(), card->getPositionY()); } addChild(card); } }
bool QTDSResult::reset (const QString& query) { cleanup(); if (!driver() || !driver()-> isOpen() || driver()->isOpenError()) return false; setActive(false); setAt(QSql::BeforeFirstRow); if (dbcmd(d->dbproc, const_cast<char*>(query.toLocal8Bit().constData())) == FAIL) { setLastError(d->lastError); return false; } if (dbsqlexec(d->dbproc) == FAIL) { setLastError(d->lastError); dbfreebuf(d->dbproc); return false; } if (dbresults(d->dbproc) != SUCCEED) { setLastError(d->lastError); dbfreebuf(d->dbproc); return false; } setSelect((DBCMDROW(d->dbproc) == SUCCEED)); // decide whether or not we are dealing with a SELECT query int numCols = dbnumcols(d->dbproc); if (numCols > 0) { d->buffer.resize(numCols * 2); init(numCols); } for (int i = 0; i < numCols; ++i) { int dbType = dbcoltype(d->dbproc, i+1); QVariant::Type vType = qDecodeTDSType(dbType); QSqlField f(QString::fromAscii(dbcolname(d->dbproc, i+1)), vType); f.setSqlType(dbType); f.setLength(dbcollen(d->dbproc, i+1)); d->rec.append(f); RETCODE ret = -1; void* p = 0; switch (vType) { case QVariant::Int: p = malloc(4); ret = dbbind(d->dbproc, i+1, INTBIND, (DBINT) 4, (unsigned char *)p); break; case QVariant::Double: // use string binding to prevent loss of precision p = malloc(50); ret = dbbind(d->dbproc, i+1, STRINGBIND, 50, (unsigned char *)p); break; case QVariant::String: p = malloc(dbcollen(d->dbproc, i+1) + 1); ret = dbbind(d->dbproc, i+1, STRINGBIND, DBINT(dbcollen(d->dbproc, i+1) + 1), (unsigned char *)p); break; case QVariant::DateTime: p = malloc(8); ret = dbbind(d->dbproc, i+1, DATETIMEBIND, (DBINT) 8, (unsigned char *)p); break; case QVariant::ByteArray: p = malloc(dbcollen(d->dbproc, i+1) + 1); ret = dbbind(d->dbproc, i+1, BINARYBIND, DBINT(dbcollen(d->dbproc, i+1) + 1), (unsigned char *)p); break; default: //don't bind the field since we do not support it qWarning("QTDSResult::reset: Unsupported type for field \"%s\"", dbcolname(d->dbproc, i+1)); break; } if (ret == SUCCEED) { d->buffer[i * 2] = p; ret = dbnullbind(d->dbproc, i+1, (DBINT*)(&d->buffer[i * 2 + 1])); } else { d->buffer[i * 2] = 0; d->buffer[i * 2 + 1] = 0; free(p); } if ((ret != SUCCEED) && (ret != -1)) { setLastError(d->lastError); return false; } } setActive(true); return true; }
void findWay(gameMap_t * self, sf::RenderWindow & window, selection_t * cUnit, sf::Sprite & aCell, sf::Sprite & aEnemy, cursor_t * gCur, sf::Sprite & gameBackground, sf::Sprite & gameInterface, sf::Sprite & gameMenu, sf::Sprite & gameEndTurn, int player, sf::Sprite & cTc, player_t*pl, sf::Sprite & cBc){ if(cUnit->status==0){ return; } for(int i = 0;i<cellNumX;i++){ for(int j = 0;j<cellNumY;j++){ int added = 0; if (cUnit->cell!=NULL&&(float)sqrt((cUnit->cell->iX-i)*(cUnit->cell->iX-i)+(cUnit->cell->jY-j)*(cUnit->cell->jY-j)) <= (float)(cUnit->cell->unit->cPoints) || (float)sqrt((cUnit->cell->iX-i)*(cUnit->cell->iX-i)+(cUnit->cell->jY-j)*(cUnit->cell->jY-j)) <= (float)(cUnit->cell->unit->aRange)) { std::string tmp; int tmpSt = self->cell[i][j].obj_un_null; if(self->cell[i][j].unit!=NULL && self->cell[i][j].unit->player != cUnit->cell->unit->player && self->cell[i][j].obj_un_null == 1) { self->cell[i][j].obj_un_null = 0; tmpSt = 1; } tmp = pathFind(cUnit->cell->iX,cUnit->cell->jY,i,j,self); if(tmp!="" && calculateLength(tmp)<=cUnit->cell->unit->cPoints){ aCell.setPosition(self->cell[i][j].X,self->cell[i][j].Y); window.draw(aCell); if(gCur->status==1&&gCur->cell->iX == i &&gCur->cell->jY == j && tmp!=""&& self->cell[gCur->cell->iX][gCur->cell->jY].unit == NULL){ if (sf::Mouse::isButtonPressed(sf::Mouse::Left)){ cUnit->cell->unit->cPoints-=calculateLength(tmp); int tmpInt = tmp[0] - 48; cUnit->cell->unit->direction=tmpInt; int tmpX = 0, tmpY = 0; cUnit->cell->unit->direction = tmpInt; tmpX = cUnit->cell->iX; tmpY = cUnit->cell->jY; self->cell[tmpX][tmpY].obj_un_null=0; int tmpCX = cUnit->cell->X; int tmpCY = cUnit->cell->Y; for(int l = 0;l<tmp.length();l++){ int tmpD = tmp[l] - 48; cUnit->cell->unit->direction = tmpD; sf::Texture tmpT; sf::Sprite tmpS; tmpT.loadFromFile(cUnit->cell->unit->sprites.path[cUnit->cell->unit->direction]); tmpS.setTexture(tmpT); for(int a = 0 ; a<10;a++){ switch(tmpD){ case 0: tmpCX+=10; break; case 1: tmpCX+=10; tmpCY+=10; break; case 2: tmpCY+=10; break; case 3: tmpCX-=10; tmpCY+=10; break; case 4: tmpCX-=10; break; case 5: tmpCX-=10; tmpCY-=10; break; case 6: tmpCY-=10; break; case 7: tmpCY-=10; tmpCX+=10; break; } Sleep(20); window.clear(sf::Color::Black); window.draw(gameBackground); drawUnits(self,window); /* window.draw(gameInterface); window.draw(gameMenu); drawMinMap(window,player,self); window.draw(gameEndTurn); drawPlayer(window,player,pl);*/ tmpS.setPosition(tmpCX,tmpCY); window.draw(tmpS); window.draw(gameInterface); window.draw(gameMenu); drawMinMap(window,player,self); window.draw(gameEndTurn); drawPlayer(window,player,pl); window.draw(cTc); window.draw(cBc); pData(window,cUnit); window.display(); } } self->cell[gCur->cell->iX][gCur->cell->jY].unit = cUnit->cell->unit; self->cell[gCur->cell->iX][gCur->cell->jY].obj_un_null=1; added = 1; setSelect(&self->cell[gCur->cell->iX][gCur->cell->jY],cUnit); self->cell[tmpX][tmpY].unit = NULL; } } } if(tmpSt == 1 && tmp!="" && calculateLength(tmp)<=cUnit->cell->unit->aRange&&cUnit->cell->unit->cPoints>0){ aEnemy.setPosition(self->cell[i][j].X,self->cell[i][j].Y); window.draw(aEnemy); if(gCur->status==1&&gCur->cell->iX == i &&gCur->cell->jY == j&& self->cell[gCur->cell->iX][gCur->cell->jY].unit != NULL && cUnit->cell->unit->player!=self->cell[i][j].unit->player){ if (sf::Mouse::isButtonPressed(sf::Mouse::Left)){ if(added!=1){ self->cell[i][j].obj_un_null = tmpSt; } int tmpD = tmp[0] - 48; cUnit->cell->unit->direction = tmpD; window.clear(sf::Color::Black); window.draw(gameBackground); drawUnits(self,window); sf::Texture tmpT; sf::Sprite tmpS; tmpT.loadFromFile(self->cell[i][j].unit->sprites.path[10]); tmpS.setTexture(tmpT); tmpS.setPosition(self->cell[i][j].X + rand()%50+20,self->cell[i][j].Y + rand()%50+20); window.draw(tmpS); window.draw(gameInterface); window.draw(gameMenu); drawMinMap(window,player,self); window.draw(gameEndTurn); drawPlayer(window,player,pl); pData(window,cUnit); sf::Texture tmpT1; sf::Sprite tmpS1; tmpT1.loadFromFile(self->cell[i][j].unit->sprites.path[11+cUnit->cell->unit->direction]); tmpS1.setTexture(tmpT1); tmpS1.setPosition(cUnit->cell->X,cUnit->cell->Y); window.draw(tmpS1); window.display(); Sleep(400); cUnit->cell->unit->cPoints-=1; int tmpDmg = cUnit->cell->unit->dmg - self->cell[i][j].unit->armor; if(tmpDmg<0){tmpDmg=0;} self->cell[i][j].unit->hp-=tmpDmg; if(self->cell[i][j].unit->hp<=0){ sf::Texture tmpT; sf::Sprite tmpS; tmpT.loadFromFile(self->cell[i][j].unit->sprites.path[8]); tmpS.setTexture(tmpT); tmpS.setPosition(self->cell[i][j].X,self->cell[i][j].Y); window.clear(sf::Color::Black); window.draw(gameBackground); drawUnits(self,window); window.draw(gameInterface); window.draw(gameMenu); drawMinMap(window,player,self); window.draw(gameEndTurn); drawPlayer(window,player,pl); pData(window,cUnit); window.draw(cBc); window.draw(tmpS); window.display(); Sleep(400); deleteUnit(self->cell[i][j].unit); self->cell[i][j].unit = NULL; self->cell[i][j].obj_un_null = 0; return; } } } } if(added!=1){ self->cell[i][j].obj_un_null = tmpSt; } } } } }
bool QSpatiaLiteResult::exec() { const QVector<QVariant> values = boundValues(); d->skippedStatus = false; d->skipRow = false; d->rInf.clear(); clearValues(); setLastError(QSqlError()); int res = sqlite3_reset(d->stmt); if (res != SQLITE_OK) { setLastError(qMakeError(d->access, QCoreApplication::translate("QSpatiaLiteResult", "Unable to reset statement"), QSqlError::StatementError, res)); d->finalize(); return false; } int paramCount = sqlite3_bind_parameter_count(d->stmt); if (paramCount == values.count()) { for (int i = 0; i < paramCount; ++i) { res = SQLITE_OK; const QVariant value = values.at(i); if (value.isNull()) { res = sqlite3_bind_null(d->stmt, i + 1); } else { switch (value.type()) { case QVariant::ByteArray: { const QByteArray *ba = static_cast<const QByteArray*>(value.constData()); res = sqlite3_bind_blob(d->stmt, i + 1, ba->constData(), ba->size(), SQLITE_STATIC); break; } case QVariant::Int: res = sqlite3_bind_int(d->stmt, i + 1, value.toInt()); break; case QVariant::Double: res = sqlite3_bind_double(d->stmt, i + 1, value.toDouble()); break; case QVariant::UInt: case QVariant::LongLong: res = sqlite3_bind_int64(d->stmt, i + 1, value.toLongLong()); break; case QVariant::String: { // lifetime of string == lifetime of its qvariant const QString *str = static_cast<const QString*>(value.constData()); res = sqlite3_bind_text16(d->stmt, i + 1, str->utf16(), (str->size()) * sizeof(QChar), SQLITE_STATIC); break; } default: { QString str = value.toString(); // SQLITE_TRANSIENT makes sure that sqlite buffers the data res = sqlite3_bind_text16(d->stmt, i + 1, str.utf16(), (str.size()) * sizeof(QChar), SQLITE_TRANSIENT); break; } } } if (res != SQLITE_OK) { setLastError(qMakeError(d->access, QCoreApplication::translate("QSpatiaLiteResult", "Unable to bind parameters"), QSqlError::StatementError, res)); d->finalize(); return false; } } } else { setLastError(QSqlError(QCoreApplication::translate("QSpatiaLiteResult", "Parameter count mismatch"), QString(), QSqlError::StatementError)); return false; } d->skippedStatus = d->fetchNext(d->firstRow, 0, true); if (lastError().isValid()) { setSelect(false); setActive(false); return false; } setSelect(!d->rInf.isEmpty()); setActive(true); return true; }
void TEditor::hideSelect() { selecting = False; setSelect(curPtr, curPtr, False); }
bool QSymSQLResult::exec() { if (d->prepareCalled == false) { setLastError(qMakeError(d->access, QCoreApplication::translate("QSymSQLResult", "Statement is not prepared"), QSqlError::StatementError, KErrGeneral)); return false; } const QVector<QVariant> values = boundValues(); d->skippedStatus = false; d->skipRow = false; setAt(QSql::BeforeFirstRow); setLastError(QSqlError()); int res = d->stmt.Reset(); if (res != KErrNone) { setLastError(qMakeError(d->access, QCoreApplication::translate("QSymSQLResult", "Unable to reset statement"), QSqlError::StatementError, res)); d->finalize(); return false; } TPtrC tmp; TInt paramCount = 0; while (d->stmt.ParamName(paramCount, tmp) == KErrNone) paramCount++; if (paramCount == values.count()) { for (int i = 0; i < paramCount; ++i) { res = KErrNone; const QVariant value = values.at(i); if (value.isNull()) { res = d->stmt.BindNull(i); //replaced i + 1 with i } else { switch (value.type()) { case QVariant::ByteArray: { const QByteArray *ba = static_cast<const QByteArray*>(value.constData()); TPtrC8 data(reinterpret_cast<const TUint8 *>(ba->constData()), ba->length()); res = d->stmt.BindBinary(i, data); //replaced i + 1 with i break; } case QVariant::Int: res = d->stmt.BindInt(i, value.toInt()); //replaced i + 1 with i break; case QVariant::Double: res = d->stmt.BindReal(i, value.toDouble()); //replaced i + 1 with i break; case QVariant::UInt: case QVariant::LongLong: res = d->stmt.BindReal(i, value.toLongLong()); //replaced i + 1 with i break; case QVariant::String: { // lifetime of string == lifetime of its qvariant const QString *str = static_cast<const QString*>(value.constData()); res = d->stmt.BindText(i, qt_QString2TPtrC(*str)); // replaced i + 1 with i break; } default: { QString str = value.toString(); res = d->stmt.BindText(i, qt_QString2TPtrC(str)); //replaced i + 1 with i break; } } } if (res != KErrNone) { setLastError(qMakeError(d->access, QCoreApplication::translate("QSymSQLResult", "Unable to bind parameters"), QSqlError::StatementError, res)); d->finalize(); return false; } } } else { setLastError(QSqlError(QCoreApplication::translate("QSymSQLResult", "Parameter count mismatch"), QString(), QSqlError::StatementError)); return false; } d->skippedStatus = d->fetchNext(true); if (lastError().isValid()) { setSelect(false); setActive(false); return false; } if (d->stmt.ColumnCount() > 0) { //If there is something, it has to be select setSelect(true); } else { //If there isn't it might be just bad query, let's check manually whether we can find SELECT QString query = this->lastQuery(); query = query.trimmed(); query = query.toLower(); //Just check whether there is one in the beginning, don't know if this is enough //Comments should be at the end of line if those are passed //For some reason, case insensitive indexOf didn't work for me if (query.indexOf(QLatin1String("select")) == 0) { setSelect(true); } else { setSelect(false); } } setActive(true); return true; }
void overmind(gameMap_t * self, sf::RenderWindow & window, selection_t * cUnit,sf::Sprite & aCell, sf::Sprite & aEnemy, cursor_t * gCur, sf::Sprite & gameBackground, sf::Sprite & gameInterface, sf::Sprite & gameMenu, sf::Sprite & gameEndTurn, int player, sf::Sprite & cTc, player_t*pl, sf::Sprite & cBc){ resources_t r; r.count = 0; r.optimal = 0; int tCost=200; int bCost=150; int ran; if(pl->resourcesPlayer2>=bCost){ if(pl->resourcesPlayer2>=tCost){ createUnit(self,pl,1,3,window,cUnit,gameBackground,gameInterface,gameMenu,gameEndTurn,cTc,cBc); }else{ createUnit(self,pl,1,4,window,cUnit,gameBackground,gameInterface,gameMenu,gameEndTurn,cTc,cBc); } } for(int i = 0;i<cellNumX*cellNumY;i++){ r.op[i] = NULL; } for(int i = 0;i<cellNumX;i++){ for(int j = 0;j<cellNumY;j++){ if(self->cell[i][j].object!=NULL&&self->cell[i][j].obj_un_null==1&&self->cell[i][j].object->type==0){ r.op[r.count] = &self->cell[i][j]; r.count++; } } } for(int i = 0;i<cellNumX;i++){ for(int j = 0;j<cellNumY;j++){ if (self->cell[i][j].unit!=NULL&&self->cell[i][j].obj_un_null==1) { if(self->cell[i][j].unit->player == 1){ selection_t tSel; setSelect(&self->cell[i][j],&tSel); while(tSel.cell->unit->cPoints>0){ if(overmindAttack(self,window,&tSel,aCell,aEnemy,gCur,gameBackground,gameInterface,gameMenu,gameEndTurn,1,cTc,pl,cBc)==1){ continue; } if(overmindFoundResources(self,window,&tSel,aCell,aEnemy,gCur,gameBackground,gameInterface,gameMenu,gameEndTurn,1,cTc,pl,cBc,i,j,&r)==1){ continue; } tSel.cell->unit->cPoints-=1; } } } } } getOP(self,pl); getResources(self,1,pl); }
void xQGanttBarViewPort::initMenu() ///////////////////////////////// { _menu = new KPopupMenu(this); /* select */ _selectMenu = new KPopupMenu(_menu); QPixmap pix = _iconloader->loadIcon("ganttSelect.png", KIcon::Toolbar , 16); if(pix.isNull()) printf("ganttSelect.png not found !\n"); _selectMenu->insertItem(pix, i18n("Select Mode"), this, SLOT(setSelect())); _selectMenu->insertSeparator(); pix = _iconloader->loadIcon("ganttSelecttask.png", KIcon::Toolbar , 16); if(pix.isNull()) printf("ganttSelecttask.png not found !\n"); _selectMenu->insertItem(pix, i18n("Select All"), this, SLOT(selectAll())); pix = _iconloader->loadIcon("ganttUnselecttask", KIcon::Toolbar , 16); if(pix.isNull()) printf("ganttUnselecttask.png not found !\n"); _selectMenu->insertItem(pix, i18n("Unselect All"), this, SLOT(unselectAll())); _menu->insertItem(i18n("Select"), _selectMenu); /* zoom */ KPopupMenu *_zoomMenu = new KPopupMenu(_menu); pix = _iconloader->loadIcon("viewmag.png", KIcon::Toolbar , 16); if(pix.isNull()) printf("viewmag.png not found !\n"); _zoomMenu->insertItem(i18n("Zoom Mode"), this, SLOT(setZoom())); _zoomMenu->insertSeparator(); _zoomMenu->insertItem(pix, i18n("Zoom All"), this, SLOT(zoomAll())); _zoomMenu->insertSeparator(); pix = _iconloader->loadIcon("viewmag+.png", KIcon::Toolbar , 16); if(pix.isNull()) printf("viewmag+.png not found !\n"); _zoomMenu->insertItem(pix, i18n("Zoom In +"), this, SLOT(zoomIn())); pix = _iconloader->loadIcon("viewmag-.png", KIcon::Toolbar , 16); if(pix.isNull()) printf("viewmag-.png not found !\n"); _zoomMenu->insertItem(pix, i18n("Zoom Out -"), this, SLOT(zoomOut())); _menu->insertItem("Zoom", _zoomMenu); pix = _iconloader->loadIcon("move.png", KIcon::Toolbar , 16); if(pix.isNull()) printf("move.png not found !\n"); _menu->insertItem(pix, i18n("Move Mode"), this, SLOT(setMove())); _menu->insertSeparator(); pix = _iconloader->loadIcon("configure.png", KIcon::Toolbar , 16); if(pix.isNull()) printf("configure.png not found !\n"); _menu->insertItem(pix, i18n("Configure Gantt..."), _parent, SLOT(showConfig())); }
KToolBar * xQGanttBarViewPort::toolbar(QMainWindow *mw) { if(_toolbar || mw == 0) return _toolbar; _toolbar = new KToolBar(mw, QMainWindow::DockTop); mw->addToolBar(_toolbar); // KIconLoader* iconloader = new KIconLoader("kgantt"); _toolbar->insertButton("ganttSelect.png", 0, SIGNAL(clicked()), this, SLOT(setSelect()), true, i18n("Select")); KPopupMenu *selectMenu = new KPopupMenu(_toolbar); /* select all items */ QPixmap pix = _iconloader->loadIcon("ganttSelecttask.png", KIcon::Toolbar , 16); if(pix.isNull()) printf("ganttSelecttask.png not found !\n"); selectMenu->insertItem(pix, i18n("Select All"), this, SLOT(selectAll())); /* unselect all items */ pix = _iconloader->loadIcon("ganttUnselecttask", KIcon::Toolbar , 16); if(pix.isNull()) printf("ganttUnselecttask.png not found !\n"); selectMenu->insertItem(pix, i18n("Unselect All"), this, SLOT(unselectAll())); KToolBarButton *b = _toolbar->getButton(0); b->setDelayedPopup(selectMenu); _toolbar->insertButton("viewmag.png", 1, SIGNAL(clicked()), this, SLOT(setZoom()), true, i18n("Zoom")); KPopupMenu *zoomMenu = new KPopupMenu(_toolbar); pix = _iconloader->loadIcon("viewmag.png", KIcon::Toolbar , 16); if(pix.isNull()) printf("viewmag.png not found !\n"); zoomMenu->insertItem(pix, i18n("Zoom All"), this, SLOT(zoomAll())); zoomMenu->insertSeparator(); pix = _iconloader->loadIcon("viewmag+.png", KIcon::Toolbar , 16); if(pix.isNull()) printf("viewmag+.png not found !\n"); zoomMenu->insertItem(pix, i18n("Zoom In +"), this, SLOT(zoomIn())); pix = _iconloader->loadIcon("viewmag-.png", KIcon::Toolbar , 16); if(pix.isNull()) printf("viewmag-.png not found !\n"); zoomMenu->insertItem(pix, i18n("Zoom Out -"), this, SLOT(zoomOut())); b = _toolbar->getButton(1); b->setDelayedPopup(zoomMenu); _toolbar->insertButton("move.png", 2, SIGNAL(clicked()), this, SLOT(setMove()), true, i18n("Move")); return _toolbar; }