diff options
Diffstat (limited to 'kgoldrunner/src/kgrgame.cpp')
-rw-r--r-- | kgoldrunner/src/kgrgame.cpp | 200 |
1 files changed, 100 insertions, 100 deletions
diff --git a/kgoldrunner/src/kgrgame.cpp b/kgoldrunner/src/kgrgame.cpp index 985d0783..b83b35ed 100644 --- a/kgoldrunner/src/kgrgame.cpp +++ b/kgoldrunner/src/kgrgame.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2003 by Ian Wadham and Marco Krüger * + * Copyright (C) 2003 by Ian Wadham and Marco Kr�ger * * ianw2@optusnet.com.au * * * * This program is free software; you can redistribute it and/or modify * @@ -190,7 +190,7 @@ void KGrGame::goUpOneLevel() KGrMessage::information (view, collection->name, i18n("<b>CONGRATULATIONS !!!!</b>" "<p>You have conquered the last level in the %1 game !!</p>") - .arg("<b>\"" + collection->name + "\"</b>")); + .tqarg("<b>\"" + collection->name + "\"</b>")); checkHighScore(); // Check if there is a high score for this game. unfreeze(); @@ -384,7 +384,7 @@ void KGrGame::startTutorial() KGrMessage::information (view, i18n("Start Tutorial"), i18n("Cannot find the tutorial game (file-prefix %1) in " "the %2 files.") - .arg("'tute'").arg("'games.dat'")); + .tqarg("'tute'").tqarg("'games.dat'")); } } @@ -514,14 +514,14 @@ bool KGrGame::openLevelFile (int levelNo, TQFile & openlevel) KGrMessage::information (view, i18n("Load Level"), i18n("Cannot find file '%1'. Please make sure '%2' has been " "run in the '%3' folder.") - .arg(filePath).arg("tar xf levels.tar").arg(systemDataDir.myStr())); + .tqarg(filePath).tqarg("tar xf levels.tar").tqarg(systemDataDir.myStr())); return (FALSE); } - // öffne Level zum lesen + // �ffne Level zum lesen if (! openlevel.open (IO_ReadOnly)) { KGrMessage::information (view, i18n("Load Level"), - i18n("Cannot open file '%1' for read-only.").arg(filePath)); + i18n("Cannot open file '%1' for read-only.").tqarg(filePath)); return (FALSE); } @@ -741,8 +741,8 @@ void KGrGame::doDig (int button) { startPlaying(); // If first player-input, start playing. } switch (button) { - case LeftButton: hero->digLeft (); break; - case RightButton: hero->digRight (); break; + case Qt::LeftButton: hero->digLeft (); break; + case Qt::RightButton: hero->digRight (); break; default: break; } } @@ -769,7 +769,7 @@ void KGrGame::saveGame() // Save game ID, score and level. { if (editMode) {myMessage (view, i18n("Save Game"), i18n("Sorry, you cannot save your game play while you are editing. " - "Please try menu item %1.").arg("\"" + i18n("&Save Edits...") + "\"")); + "Please try menu item %1.").tqarg("\"" + i18n("&Save Edits...") + "\"")); return; } if (hero->started) {myMessage (view, i18n("Save Game"), @@ -778,7 +778,7 @@ void KGrGame::saveGame() // Save game ID, score and level. "level, not as they are now.")); } - TQDate today = TQDate::currentDate(); + TQDate today = TQDate::tqcurrentDate(); TQTime now = TQTime::currentTime(); TQString saved; TQString day; @@ -800,7 +800,7 @@ void KGrGame::saveGame() // Save game ID, score and level. if (! file2.open (IO_WriteOnly)) { KGrMessage::information (view, i18n("Save Game"), i18n("Cannot open file '%1' for output.") - .arg(userDataDir + "savegame.tmp")); + .tqarg(userDataDir + "savegame.tmp")); return; } TQTextStream text2 (&file2); @@ -810,7 +810,7 @@ void KGrGame::saveGame() // Save game ID, score and level. if (! file1.open (IO_ReadOnly)) { KGrMessage::information (view, i18n("Save Game"), i18n("Cannot open file '%1' for read-only.") - .arg(userDataDir + "savegame.dat")); + .tqarg(userDataDir + "savegame.dat")); return; } @@ -848,7 +848,7 @@ void KGrGame::loadGame() // Re-load game, score and level. if (! savedGames.open (IO_ReadOnly)) { KGrMessage::information (view, i18n("Load Game"), i18n("Cannot open file '%1' for read-only.") - .arg(userDataDir + "savegame.dat")); + .tqarg(userDataDir + "savegame.dat")); return; } @@ -876,7 +876,7 @@ void KGrGame::loadGame() // Re-load game, score and level. if (! s.isNull()) { pr = s.mid (21, 7); // Get the collection prefix. - pr = pr.left (pr.find (" ", 0, FALSE)); + pr = pr.left (pr.tqfind (" ", 0, FALSE)); for (i = 0; i < imax; i++) { // Find the collection. if (collections.at(i)->prefix == pr) { @@ -899,7 +899,7 @@ void KGrGame::loadGame() // Re-load game, score and level. } else { KGrMessage::information (view, i18n("Load Game"), - i18n("Cannot find the game with prefix '%1'.").arg(pr)); + i18n("Cannot find the game with prefix '%1'.").tqarg(pr)); } } @@ -919,9 +919,9 @@ void KGrGame::loadGame() // Re-load game, score and level. void KGrGame::checkHighScore() { bool prevHigh = TRUE; - Q_INT16 prevLevel = 0; - Q_INT32 prevScore = 0; - QString thisUser = i18n("Unknown"); + TQ_INT16 prevLevel = 0; + TQ_INT32 prevScore = 0; + TQString thisUser = i18n("Unknown"); int highCount = 0; // Don't keep high scores for tutorial games. @@ -947,7 +947,7 @@ void KGrGame::checkHighScore() if (! high1.open (IO_ReadOnly)) { TQString high1_name = high1.name(); KGrMessage::information (view, i18n("Check for High Score"), - i18n("Cannot open file '%1' for read-only.").arg(high1_name)); + i18n("Cannot open file '%1' for read-only.").tqarg(high1_name)); return; } @@ -987,7 +987,7 @@ void KGrGame::checkHighScore() if (! high2.open (IO_WriteOnly)) { KGrMessage::information (view, i18n("Check for High Score"), i18n("Cannot open file '%1' for output.") - .arg(userDataDir + "hi_" + collection->prefix + ".tmp")); + .tqarg(userDataDir + "hi_" + collection->prefix + ".tmp")); return; } @@ -1014,7 +1014,7 @@ void KGrGame::checkHighScore() hsn-> setCaption (i18n("Save High Score")); - QPoint p = view->mapToGlobal (TQPoint (0,0)); + TQPoint p = view->mapToGlobal (TQPoint (0,0)); hsn-> move (p.x() + 50, p.y() + 50); OK-> setAccel (Key_Return); @@ -1034,7 +1034,7 @@ void KGrGame::checkHighScore() delete hsn; - TQDate today = TQDate::currentDate(); + TQDate today = TQDate::tqcurrentDate(); TQString hsDate; #ifdef QT3 TQString day = today.shortDayName(today.dayOfWeek()); @@ -1061,11 +1061,11 @@ void KGrGame::checkHighScore() s1 >> prevDate; if ((! scoreRecorded) && (score > prevScore)) { highCount++; - // Recode the user's name as UTF-8, in case it contains - // non-ASCII chars (e.g. "Krüger" is encoded as "Krüger"). + // Recode the user's name as UTF-8, in case it tqcontains + // non-ASCII chars (e.g. "Kr�ger" is encoded as "Krüger"). s2 << (const char *) thisUser.utf8(); - s2 << (Q_INT16) level; - s2 << (Q_INT32) score; + s2 << (TQ_INT16) level; + s2 << (TQ_INT32) score; s2 << hsDate.myStr(); scoreRecorded = TRUE; } @@ -1080,21 +1080,21 @@ void KGrGame::checkHighScore() delete prevDate; } if ((! scoreRecorded) && (highCount < 10)) { - // Recode the user's name as UTF-8, in case it contains - // non-ASCII chars (e.g. "Krüger" is encoded as "Krüger"). + // Recode the user's name as UTF-8, in case it tqcontains + // non-ASCII chars (e.g. "Kr�ger" is encoded as "Krüger"). s2 << (const char *) thisUser.utf8(); - s2 << (Q_INT16) level; - s2 << (Q_INT32) score; + s2 << (TQ_INT16) level; + s2 << (TQ_INT32) score; s2 << hsDate.myStr(); } high1.close(); } else { - // Recode the user's name as UTF-8, in case it contains - // non-ASCII chars (e.g. "Krüger" is encoded as "Krüger"). + // Recode the user's name as UTF-8, in case it tqcontains + // non-ASCII chars (e.g. "Kr�ger" is encoded as "Krüger"). s2 << (const char *) thisUser.utf8(); - s2 << (Q_INT16) level; - s2 << (Q_INT32) score; + s2 << (TQ_INT16) level; + s2 << (TQ_INT32) score; s2 << hsDate.myStr(); } @@ -1119,8 +1119,8 @@ void KGrGame::showHighScores() return; } - Q_INT16 prevLevel = 0; - Q_INT32 prevScore = 0; + TQ_INT16 prevLevel = 0; + TQ_INT32 prevScore = 0; int n = 0; // Look for user's high-score file or for a released high-score file. @@ -1132,7 +1132,7 @@ void KGrGame::showHighScores() if (! high1.exists()) { KGrMessage::information (view, i18n("Show High Scores"), i18n("Sorry, there are no high scores for the %1 game yet.") - .arg("\"" + collection->name + "\"")); + .tqarg("\"" + collection->name + "\"")); return; } } @@ -1140,7 +1140,7 @@ void KGrGame::showHighScores() if (! high1.open (IO_ReadOnly)) { TQString high1_name = high1.name(); KGrMessage::information (view, i18n("Show High Scores"), - i18n("Cannot open file '%1' for read-only.").arg(high1_name)); + i18n("Cannot open file '%1' for read-only.").tqarg(high1_name)); return; } @@ -1154,15 +1154,15 @@ void KGrGame::showHighScores() TQLabel * hsHeader = new TQLabel (i18n ( "<center><h2>KGoldrunner Hall of Fame</h2></center><br>" "<center><h3>\"%1\" Game</h3></center>") - .arg(collection->name), + .tqarg(collection->name), hs); TQLabel * hsColHeader = new TQLabel ( i18n(" Name " "Level Score Date"), hs); #ifdef KGR_PORTABLE - QFont f ("courier", 12); + TQFont f ("courier", 12); #else - QFont f = KGlobalSettings::fixedFont(); // KDE version. + TQFont f = KGlobalSettings::fixedFont(); // KDE version. #endif f. setFixedPitch (TRUE); f. setBold (TRUE); @@ -1183,7 +1183,7 @@ void KGrGame::showHighScores() // Set up the format for the high-score lines. f. setBold (FALSE); - QString line; + TQString line; const char * hsFormat = "%2d. %-30.30s %3d %7ld %s"; // Read and display the users, levels and scores from the high score file. @@ -1199,7 +1199,7 @@ void KGrGame::showHighScores() // TQString::sprintf expects UTF-8 encoding in its string arguments, so // prevUser has been saved on file as UTF-8 to allow non=ASCII chars - // in the user's name (e.g. "Krüger" is encoded as "Krüger" in UTF-8). + // in the user's name (e.g. "Kr�ger" is encoded as "Krüger" in UTF-8). line = line.sprintf (hsFormat, n+1, prevUser, prevLevel, prevScore, prevDate); @@ -1219,7 +1219,7 @@ void KGrGame::showHighScores() OK-> setMaximumWidth (100); mainLayout-> addWidget (buttons); - QPoint p = view->mapToGlobal (TQPoint (0,0)); + TQPoint p = view->mapToGlobal (TQPoint (0,0)); hs-> move (p.x() + 50, p.y() + 50); // Start up the dialog box. @@ -1481,7 +1481,7 @@ void KGrGame::loadEditLevel (int lev) // Retain the original language of the name and hint when editing, // but remove the final \n and convert non-ASCII, UTF-8 substrings - // to Unicode (eg. ü to ü). + // to Unicode (eg. ü to �). int len = levelHintC.length(); if (len > 0) levelHint = TQString::fromUtf8((const char *) levelHintC.left(len-1)); @@ -1584,7 +1584,7 @@ bool KGrGame::saveLevelFile() // Open the output file. if (! levelFile.open (IO_WriteOnly)) { KGrMessage::information (view, i18n("Save Level"), - i18n("Cannot open file '%1' for output.").arg(filePath)); + i18n("Cannot open file '%1' for output.").tqarg(filePath)); return (FALSE); } @@ -1596,7 +1596,7 @@ bool KGrGame::saveLevelFile() } levelFile.putch ('\n'); - // Save the level name, changing non-ASCII chars to UTF-8 (eg. ü to ü). + // Save the level name, changing non-ASCII chars to UTF-8 (eg. � to ü). TQCString levelNameC = levelName.utf8(); int len1 = levelNameC.length(); if (len1 > 0) { @@ -1605,7 +1605,7 @@ bool KGrGame::saveLevelFile() levelFile.putch ('\n'); // Add a newline. } - // Save the level hint, changing non-ASCII chars to UTF-8 (eg. ü to ü). + // Save the level hint, changing non-ASCII chars to UTF-8 (eg. � to ü). TQCString levelHintC = levelHint.utf8(); int len2 = levelHintC.length(); char ch = '\0'; @@ -1642,8 +1642,8 @@ void KGrGame::moveLevelFile () KGrMessage::information (view, i18n("Move Level"), i18n("You must first load a level to be moved. Use " "the %1 or %2 menu.") - .arg("\"" + i18n("Game") + "\"") - .arg("\"" + i18n("Editor") + "\"")); + .tqarg("\"" + i18n("Game") + "\"") + .tqarg("\"" + i18n("Editor") + "\"")); return; } @@ -1780,7 +1780,7 @@ void KGrGame::deleteLevelFile () } else { KGrMessage::information (view, i18n("Delete Level"), - i18n("Cannot find file '%1' to be deleted.").arg(filePath)); + i18n("Cannot find file '%1' to be deleted.").tqarg(filePath)); return; } @@ -1883,7 +1883,7 @@ void KGrGame::editCollection (int action) if (duplicatePrefix) { KGrMessage::information (view, i18n("Save Game Info"), i18n("The filename prefix '%1' is already in use.") - .arg(ecPrefix)); + .tqarg(ecPrefix)); continue; } } @@ -1919,7 +1919,7 @@ bool KGrGame::saveOK (bool exiting) { int i, j; bool result; - QString option2 = i18n("&Go on editing"); + TQString option2 = i18n("&Go on editing"); result = TRUE; @@ -2061,7 +2061,7 @@ bool KGrGame::reNumberLevels (int cIndex, int first, int last, int inc) if (! dir.rename (file1, file2, TRUE)) { // Allow absolute paths. KGrMessage::information (view, i18n("Save Level"), i18n("Cannot rename file '%1' to '%2'.") - .arg(file1).arg(file2)); + .tqarg(file1).tqarg(file2)); return (FALSE); } i = i + step; @@ -2090,8 +2090,8 @@ void KGrGame::doEdit (int button) i = p.x(); j = p.y(); switch (button) { - case LeftButton: - case RightButton: + case Qt::LeftButton: + case Qt::RightButton: paintEditObj = TRUE; insertEditObj (i, j); view->updateCanvas(); @@ -2113,8 +2113,8 @@ void KGrGame::endEdit (int button) i = p.x(); j = p.y(); switch (button) { - case LeftButton: - case RightButton: + case Qt::LeftButton: + case Qt::RightButton: paintEditObj = FALSE; if ((i != oldI) || (j != oldJ)) { insertEditObj (i, j); @@ -2181,8 +2181,8 @@ int KGrGame::selectLevel (int action, int requestedLevel) KGrMessage::information (view, i18n("Select Level"), i18n("There is no level %1 in %2, " "so you cannot play or edit it.") - .arg(selectedLevel) - .arg("\"" + collections.at(selectedGame)->name + "\"")); + .tqarg(selectedLevel) + .tqarg("\"" + collections.at(selectedGame)->name + "\"")); selectedLevel = 0; // Set an invalid selection. continue; // Re-run the dialog box. } @@ -2226,10 +2226,10 @@ bool KGrGame::ownerOK (Owner o) /********************** CLASS TO DISPLAY THUMBNAIL ***********************/ /******************************************************************************/ -KGrThumbNail::KGrThumbNail (TQWidget * parent, const char * name) - : TQFrame (parent, name) +KGrThumbNail::KGrThumbNail (TQWidget * tqparent, const char * name) + : TQFrame (tqparent, name) { - // Let the parent do all the work. We need a class here so that + // Let the tqparent do all the work. We need a class here so that // TQFrame::drawContents (TQPainter *) can be re-implemented and // the thumbnail can be automatically re-painted when required. } @@ -2247,8 +2247,8 @@ void KGrThumbNail::setFilePath (TQString & fp, TQLabel * sln) void KGrThumbNail::drawContents (TQPainter * p) // Activated via "paintEvent". { - QFile openFile; - QPen pen = p->pen(); + TQFile openFile; + TQPen pen = p->pen(); char obj = FREE; int fw = 1; // Set frame width. int n = width() / FIELDWIDTH; // Set thumbnail cell-size. @@ -2330,7 +2330,7 @@ void KGrThumbNail::drawContents (TQPainter * p) // Activated via "paintEvent". /******************************************************************************/ // NOTE: Macros "myStr" and "myChar", defined in "kgrgame.h", are used -// to smooth out differences between Qt 1 and Qt2 TQString classes. +// to smooth out differences between TQt 1 and TQt2 TQString classes. bool KGrGame::initCollections () { @@ -2354,11 +2354,11 @@ bool KGrGame::initCollections () void KGrGame::mapCollections() { - QDir d; + TQDir d; KGrCollection * colln; - QString d_path; - QString fileName1; - QString fileName2; + TQString d_path; + TQString fileName1; + TQString fileName2; // Find KGoldrunner level files, sorted by name (same as numerical order). for (colln = collections.first(); colln != 0; colln = collections.next()) { @@ -2372,25 +2372,25 @@ void KGrGame::mapCollections() i18n("There is no folder '%1' to hold levels for" " the '%2' game. Please make sure '%3' " "has been run in the '%4' folder.") - .arg(d_path) - .arg(colln->name) - .arg("tar xf levels.tar") - .arg(systemDataDir)); + .tqarg(d_path) + .tqarg(colln->name) + .tqarg("tar xf levels.tar") + .tqarg(systemDataDir)); } continue; } - const QFileInfoList * files = d.entryInfoList + const TQFileInfoList * files = d.entryInfoList (colln->prefix + "???.grl", TQDir::Files, TQDir::Name); - QFileInfoListIterator i (* files); + TQFileInfoListIterator i (* files); TQFileInfo * file; if ((files->count() <= 0) && (colln->nLevels > 0)) { KGrMessage::information (view, i18n("Check Games & Levels"), i18n("There are no files '%1/%2???.grl' for the %3 game.") - .arg(d_path) - .arg(colln->prefix) - .arg("\"" + colln->name + "\"")); + .tqarg(d_path) + .tqarg(colln->prefix) + .tqarg("\"" + colln->name + "\"")); continue; } @@ -2413,8 +2413,8 @@ void KGrGame::mapCollections() i18n("Check Games & Levels"), i18n("File '%1' is beyond the highest level for " "the %2 game and cannot be played.") - .arg(fileName1) - .arg("\"" + colln->name + "\"")); + .tqarg(fileName1) + .tqarg("\"" + colln->name + "\"")); break; } else if (fileName1 == fileName2) { @@ -2426,16 +2426,16 @@ void KGrGame::mapCollections() i18n("Check Games & Levels"), i18n("File '%1' is before the lowest level for " "the %2 game and cannot be played.") - .arg(fileName1) - .arg("\"" + colln->name + "\"")); + .tqarg(fileName1) + .tqarg("\"" + colln->name + "\"")); break; } else { KGrMessage::information (view, i18n("Check Games & Levels"), i18n("Cannot find file '%1' for the %2 game.") - .arg(fileName2) - .arg("\"" + colln->name + "\"")); + .tqarg(fileName2) + .tqarg("\"" + colln->name + "\"")); lev++; } } @@ -2446,7 +2446,7 @@ void KGrGame::mapCollections() bool KGrGame::loadCollections (Owner o) { - QString filePath; + TQString filePath; filePath = ((o == SYSTEM)? systemDataDir : userDataDir) + "games.dat"; @@ -2457,20 +2457,20 @@ bool KGrGame::loadCollections (Owner o) if (o == SYSTEM) { KGrMessage::information (view, i18n("Load Game Info"), i18n("Cannot find game info file '%1'.") - .arg(filePath)); + .tqarg(filePath)); } return (FALSE); } if (! c.open (IO_ReadOnly)) { KGrMessage::information (view, i18n("Load Game Info"), - i18n("Cannot open file '%1' for read-only.").arg(filePath)); + i18n("Cannot open file '%1' for read-only.").tqarg(filePath)); return (FALSE); } - QCString line = ""; - QCString name = ""; - QString prefix = ""; + TQCString line = ""; + TQCString name = ""; + TQString prefix = ""; char settings = ' '; int nLevels = -1; @@ -2496,9 +2496,9 @@ bool KGrGame::loadCollections (Owner o) line = line.simplifyWhiteSpace(); int i, j, len; len = line.length(); - i = 0; j = line.find(' ',i); nLevels = line.left(j).toInt(); - i = j+1; j = line.find(' ',i); settings = line[i]; - i = j+1; j = line.find(' ',i); prefix = line.mid(i,j-i); + i = 0; j = line.tqfind(' ',i); nLevels = line.left(j).toInt(); + i = j+1; j = line.tqfind(' ',i); settings = line[i]; + i = j+1; j = line.tqfind(' ',i); prefix = line.mid(i,j-i); i = j+1; name = line.right(len-i); } // If first character is not a digit, the line should be an "about". @@ -2513,7 +2513,7 @@ bool KGrGame::loadCollections (Owner o) // Not EOF: it's an empty line or out-of-context "about" line. KGrMessage::information (view, i18n("Load Game Info"), i18n("Format error in game info file '%1'.") - .arg(filePath)); + .tqarg(filePath)); c.close(); return (FALSE); } @@ -2527,7 +2527,7 @@ bool KGrGame::loadCollections (Owner o) bool KGrGame::saveCollections (Owner o) { - QString filePath; + TQString filePath; if (o != USER) { KGrMessage::information (view, i18n("Save Game Info"), @@ -2542,13 +2542,13 @@ bool KGrGame::saveCollections (Owner o) // Open the output file. if (! c.open (IO_WriteOnly)) { KGrMessage::information (view, i18n("Save Game Info"), - i18n("Cannot open file '%1' for output.").arg(filePath)); + i18n("Cannot open file '%1' for output.").tqarg(filePath)); return (FALSE); } // Save the collections. KGrCollection * colln; - QCString line; + TQCString line; int i, len; char ch; @@ -2588,12 +2588,12 @@ bool KGrGame::saveCollections (Owner o) /********************** WORD-WRAPPED MESSAGE BOX ************************/ /******************************************************************************/ -void KGrGame::myMessage (TQWidget * parent, TQString title, TQString contents) +void KGrGame::myMessage (TQWidget * tqparent, TQString title, TQString contents) { // Halt the game while the message is displayed. setMessageFreeze (TRUE); - KGrMessage::wrapped (parent, title, contents); + KGrMessage::wrapped (tqparent, title, contents); // Unfreeze the game, but only if it was previously unfrozen. setMessageFreeze (FALSE); |