From: Marja Hassinen Date: Tue, 5 Jan 2010 20:54:02 +0000 (+0200) Subject: Cleanup X-Git-Tag: 0.1~14 X-Git-Url: https://vcs.maemo.org/git/?p=evilplumber;a=commitdiff_plain;h=82b1825a596f468f0bbfcd22fcd5c0d8bd64ff00 Cleanup --- diff --git a/src/game.cpp b/src/game.cpp index 370114d..5f9c12d 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -49,7 +49,6 @@ QString pieceToIconId(const Piece* piece, bool flow1 = false, bool flow2 = false fileName += (QString("_flow_") + (flow1? "1" : "0") + (flow2? "1" : "0")); } - //qDebug() << "need: " << fileName; return fileName + ".png"; } @@ -68,11 +67,6 @@ int flowCount(const Piece* piece) Direction flowsTo(const Piece* piece, Direction flowFrom) { - //qDebug() << piece->flows[0]; - //qDebug() << piece->flows[1]; - //qDebug() << piece->flows[2]; - //qDebug() << piece->flows[3]; - //qDebug() << "check" << flowFrom; if (piece->flows[0] == flowFrom) return piece->flows[1]; if (piece->flows[1] == flowFrom) @@ -136,8 +130,6 @@ int GameField::toIndex(int row, int col) bool GameField::setPiece(int row, int col, const Piece* piece, bool fixed) { - qDebug() << "set piece" << row << col; - if (row < 0 || row >= rows || col < 0 || col >= cols) { qWarning() << "Invalid piece index"; return false; @@ -145,7 +137,6 @@ bool GameField::setPiece(int row, int col, const Piece* piece, bool fixed) int index = toIndex(row, col); if (field[index].piece->type == PieceNone) { - qDebug() << "really setting"; field[index].piece = piece; field[index].fixed = fixed; @@ -190,7 +181,7 @@ void GameField::indicateFlow(int row, int col, Direction dir) // Indicate the flow: fill the piece in question with the // liquid. (The piece can also be an empty one, or an illegal // one.) - qDebug() << "ind flow" << row << col << dir; + if (row < 0 || col < 0 || row >= rows || col >= cols) { return; } @@ -219,7 +210,6 @@ void GameField::indicateFlow(int row, int col, Direction dir) } QString iconId = pieceToIconId(field[index].piece, field[index].flow[0], field[index].flow[1]); - qDebug() << "icon id" << iconId; QModelIndex mIndex = fieldUi->model()->index(row, col); QLabel* label = (QLabel*)fieldUi->indexWidget(mIndex); @@ -233,8 +223,6 @@ AvailablePieces::AvailablePieces(QTableWidget* ui) // Setup ui - qDebug() << pieceUi->rowCount() << pieceUi->columnCount(); - for (int i = 0; i < 2; ++i) pieceUi->setColumnWidth(i, 120); @@ -244,7 +232,6 @@ AvailablePieces::AvailablePieces(QTableWidget* ui) for (int i = 0; ppieces[i].type != PiecesEnd; ++i) { if (ppieces[i].userCanAdd == false) continue; - //qDebug() << ppieces[i].type << ppieces[i].rotation; QString fileName = pieceToIconId(&(ppieces[i])); QTableWidgetItem* item = new QTableWidgetItem(QIcon(fileName), "0", QTableWidgetItem::UserType + pieceToId(&(ppieces[i]))); @@ -282,7 +269,6 @@ void AvailablePieces::initGame(int count, AvailablePiece* pieces) void AvailablePieces::onItemClicked(QTableWidgetItem* item) { - qDebug() << "piece clicked"; int id = item->type() - QTableWidgetItem::UserType; const Piece* piece = idToPiece(id); @@ -347,7 +333,6 @@ void GameController::startLevel(QString fileName) gameData >> rows; gameData >> cols; - qDebug() << rows << cols; if (rows < 2 || rows > 10 || cols < 2 || cols > 10) qFatal("Error reading game file: rows and cols"); @@ -437,16 +422,14 @@ void GameController::onTimeout() void GameController::onCellClicked(int row, int column) { - qDebug() << "clicked: " << row << column; - if (!levelRunning) return; - if (currentPiece->type == PieceNone) return; - if (fieldUi->setPiece(row, column, currentPiece)) - emit pieceUsed(currentPiece); + if (!levelRunning) return; + if (currentPiece->type == PieceNone) return; + if (fieldUi->setPiece(row, column, currentPiece)) + emit pieceUsed(currentPiece); } void GameController::onValidPieceSelected(const Piece* piece) { - qDebug() << "selected: " << piece->type << piece->rotation; currentPiece = piece; } @@ -540,11 +523,9 @@ void GameController::computeFlow() } // Now we know the next piece and where the flow comes *from* - qDebug() << "flow to" << flowRow << flowCol; // Check which piece is there const Piece* piece = fieldUi->pieceAt(flowRow, flowCol); - qDebug() << "there is" << piece->type << piece->rotation; flowDir = flowsTo(piece, flowDir); // If the piece was pre-placed, record that the liquid has // flown through it once @@ -619,7 +600,6 @@ void LevelSwitcher::onLevelCollectionChosen() level = 0; // Go to the level the user has not yet passed if (savedGames.contains(curColl)) { - qDebug() << "going to saved level" << savedGames[curColl]; level = savedGames[curColl]; if (level >= levels.size()) { level = 0; @@ -713,7 +693,7 @@ void LevelSwitcher::readSavedGames() while (!saveData.atEnd()) { saveData >> collection; saveData >> level; - qDebug() << "Got saved game: " << collection << level; + if (collection != "") savedGames.insert(collection, level); } @@ -724,7 +704,7 @@ void LevelSwitcher::readLevelCollections(QStringList collections) { foreach (const QString& coll, collections) { QFile file(QString(LEVDIR) + "/" + coll + ".dat"); - qDebug() << "Trying to read" << file.fileName(); + if (!file.exists()) qFatal("Error reading level collection: doesn't exist"); file.open(QIODevice::ReadOnly); @@ -744,7 +724,6 @@ void LevelSwitcher::writeSavedGames() file.open(QIODevice::Truncate | QIODevice::WriteOnly); QTextStream saveData(&file); foreach (const QString& collection, savedGames.keys()) { - qDebug() << "writing" << collection << savedGames[collection]; saveData << collection << " " << savedGames[collection] << endl; } file.close(); @@ -753,12 +732,9 @@ void LevelSwitcher::writeSavedGames() // TODO: // --- 0.1 --- // more levels to the basic collection -// make fixed pipes look different than non-fixed ones -// get rid of debug prints // --- 0.2 --- // ability to install level sets as different packages // better graphics -// color theme // re-placing pieces // graphical hints on what to do next // graphical help, showing the ui elements: demo diff --git a/src/main.cpp b/src/main.cpp index 29c8791..d0441eb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -14,9 +14,6 @@ int main(int argc, char** argv) { QApplication app(argc, argv); - qDebug() << "Reading levels from" << LEVDIR; - qDebug() << "Reading images from" << IMGDIR; - QWidget mainWindow; Ui::Main ui;