// remove lower line in game field // return true if there are still tiles that can be dropped down // in contest const bool GameField::removeLowerLine(const bool contest) { #ifdef DEBUG std::cout << "GameField::removeLowerLine(" << contest << ")" << std::endl; #endif bool ok = false; // create array with lower line ScoredTileArray tArray; ScoredTile sTile( FieldPos(0, 0), 10, ScoredTile::FIELDDIRECTION_RIGHT, m_field[0][0], 0 ); tArray.push_back(sTile); // remove tiles removeTiles(tArray); // let all existing tiles fall to the ground ok = fallTilesToGround(contest); // and fill with new ones fillEmptyTiles(); // clear array again tArray.clear(); return ok; }
BOOL COSMCtrlMapOperationsDlg::DeleteCachedTilesHelper() { //What will be the return value from this function (assume the best) BOOL bSuccess = TRUE; //Accumulate how many tiles we have deleted and not deleted int nTilesDeleted = 0; int nTilesNotDeleted = 0; //Work thro all the tiles CString sCacheDirectory(m_pOSMCtrl->GetCacheDirectory()); for (std::vector<COSMCtrlMapOperationsDlgTile>::size_type i=0; (i<m_Tiles.size()) && bSuccess; i++) { //Pull out the tile we are working on const COSMCtrlMapOperationsDlgTile& tile = m_Tiles[i]; //Do the deletion of the tile CString sTile(m_pOSMCtrl->GetTileCachePath(sCacheDirectory, tile.m_nZoom, tile.m_nTileX, tile.m_nTileY, FALSE)); COSMCtrlMapOperationsDlgEvent dlgEvent; if (GetFileAttributes(sTile) != INVALID_FILE_ATTRIBUTES) //Don't bother doing anything if the tile does not already exist { if (DeleteFile(sTile)) { //Update the stats ++nTilesDeleted; dlgEvent.m_bSuccess = true; } else { //Update the stats ++nTilesNotDeleted; dlgEvent.m_bSuccess = false; } } //Update the UI dlgEvent.m_Event = COSMCtrlMapOperationsDlgEvent::SimpleStringStatus; dlgEvent.m_sString = sTile; dlgEvent.m_nItemData = i + 1; AddEvent(dlgEvent); //Check if we have been cancelled before we loop around bSuccess = (WaitForSingleObject(m_WorkerTerminateEvent, 0) == WAIT_TIMEOUT); } //Finally add a event about how many items have been deleted COSMCtrlMapOperationsDlgEvent dlgEvent; dlgEvent.m_Event = COSMCtrlMapOperationsDlgEvent::SimpleStringStatus; CString sTilesDeleted; sTilesDeleted.Format(_T("%d"), nTilesDeleted); CString sTilesNotDeleted; sTilesNotDeleted.Format(_T("%d"), nTilesNotDeleted); AfxFormatString2(dlgEvent.m_sString, IDS_OSMCTRL_DELETE_FILES_STATS, sTilesDeleted, sTilesNotDeleted); AddEvent(dlgEvent); return bSuccess; }
menuWindow::menuWindow(GUIClient *pParent) : QObject(pParent), _parent(pParent), _windowMenu(0), _data(0) { setObjectName("winModule"); _data = new MenuWindowPrivate(); _windowMenu = new QMenu(tr("&Window"), _parent); _windowMenu->setObjectName("menu.window"); _data->_closeActive = new Action(_parent, "window.closeActiveWindow", tr("Close &Active Window"), this, SLOT(sCloseActive()), _windowMenu, true); _data->_closeAll = new Action(_parent, "window.closeAllWindows", tr("Close A&ll Windows"), this, SLOT(sCloseAll()), _windowMenu, true); _data->_cascade = new Action(_parent, "window.cascade", tr("&Cascade"), this, SLOT(sCascade()), _windowMenu, true); _data->_tile = new Action(_parent, "window.tile", tr("&Tile"), this, SLOT(sTile()), _windowMenu, true); _data->_rememberPos = new Action(_parent, "window.rememberPositionToggle", tr("Remember Position"), this, SLOT(sRememberPositionToggle()), _windowMenu, true); _data->_rememberPos->setCheckable(true); _data->_rememberSize = new Action(_parent, "window.rememberSizeToggle", tr("Remember Size"), this, SLOT(sRememberSizeToggle()), _windowMenu, true); _data->_rememberSize->setCheckable(true); (void)_parent->menuBar()->addMenu(_windowMenu); connect(_windowMenu, SIGNAL(aboutToShow()), this, SLOT(sPrepareWindowMenu())); connect(_windowMenu, SIGNAL(aboutToHide()), this, SLOT(sHideWindowMenu())); _parent->populateCustomMenu(_windowMenu, "Window"); }
// search for equal tiles in columns // return true if something has been found const bool GameField::findSameTilesInColumns(ScoredTileArray& tArray) const { bool found = false; // we will go through each column for ( unsigned int i = 0; i < FIELD_WIDTH; i++ ) { // reset length unsigned int length = 0; unsigned int bombValue = 0; for ( unsigned int j = 0; j < FIELD_HEIGHT; j++ ) { if ( 0 == j || m_field[i][j] == m_field[i][j-1] ) { // same tile as before or new start tile length++; // check if bomb and add bomb value if ( m_field[i][j].isBomb() ) { bombValue += m_field[i][j].getBombValue(); } // if the last tile in this column // we must check the length if ( FIELD_HEIGHT-1 == j && length >= 3 ) { // only store tiles if length is >= 3 ScoredTile sTile( FieldPos(i, j-length+1), length, ScoredTile::FIELDDIRECTION_UP, m_field[i][j], bombValue ); tArray.push_back(sTile); found = true; //std::cout << "GameField::findSameTilesInColumns1() " //<< i << " " //<< j-length+1 << " " //<< length << " " //<< (char)m_field[i][j].getType() << " " //<< bombValue //<< std::endl; } } else { // new tile here if ( length >= 3 ) { // only store tiles if length is >= 3 ScoredTile sTile( FieldPos(i, j-length), length, ScoredTile::FIELDDIRECTION_UP, m_field[i][j-1], bombValue ); tArray.push_back(sTile); found = true; //std::cout << "GameField::findSameTilesInColumns2() " //<< i << " " //<< j-length << " " //<< length << " " //<< (char)m_field[i][j-1].getType() << " " //<< bombValue //<< std::endl; } // set new length length = 1; bombValue = 0; // check if bomb and add bomb value if ( m_field[i][j].isBomb() ) { bombValue += m_field[i][j].getBombValue(); } } } } return found; }
void sTileset::AppendTiles(int num_tiles) { m_Tiles.insert(m_Tiles.end(), num_tiles, sTile(m_TileWidth, m_TileHeight)); }
void sTileset::InsertTiles(int insert_at, int num_tiles) { // resize the tile array m_Tiles.insert(m_Tiles.begin() + insert_at, num_tiles, sTile(m_TileWidth, m_TileHeight)); }