diff options
author | gregory guy <gregory-tde@laposte.net> | 2020-08-17 20:03:11 +0200 |
---|---|---|
committer | gregory guy <gregory-tde@laposte.net> | 2020-08-17 20:03:11 +0200 |
commit | 503fddb48f2229ecc6ed6930a99c4d740ff979e5 (patch) | |
tree | 81206d9572927fd636b43a00005808cec6c0ce3e /kpacman/score.cpp | |
parent | e0031ac458d4f414ae583a709d48c4cb0f14b09e (diff) | |
download | tdepacman-503fddb48f2229ecc6ed6930a99c4d740ff979e5.tar.gz tdepacman-503fddb48f2229ecc6ed6930a99c4d740ff979e5.zip |
Second step, convert to tqt3 libraries.
Signed-off-by: gregory guy <gregory-tde@laposte.net>
Diffstat (limited to 'kpacman/score.cpp')
-rw-r--r-- | kpacman/score.cpp | 126 |
1 files changed, 63 insertions, 63 deletions
diff --git a/kpacman/score.cpp b/kpacman/score.cpp index 1bbd427..aa2045a 100644 --- a/kpacman/score.cpp +++ b/kpacman/score.cpp @@ -9,18 +9,18 @@ #include <kconfig.h> #include <kstddirs.h> #include <kmessagebox.h> -#include <qpixmap.h> -#include <qstring.h> -#include <qdstream.h> -#include <qkeycode.h> -#include <qtimer.h> -#include <qfileinfo.h> +#include <ntqpixmap.h> +#include <ntqstring.h> +#include <ntqdstream.h> +#include <ntqkeycode.h> +#include <ntqtimer.h> +#include <ntqfileinfo.h> #include "bitfont.h" -Score::Score(QWidget *parent, const char *name, int Scheme, int Mode, Bitfont *font) : QWidget(parent, name) +Score::Score(TQWidget *parent, const char *name, int Scheme, int Mode, Bitfont *font) : TQWidget(parent, name) { - setFocusPolicy(QWidget::StrongFocus); + setFocusPolicy(TQWidget::StrongFocus); paused = FALSE; @@ -32,7 +32,7 @@ Score::Score(QWidget *parent, const char *name, int Scheme, int Mode, Bitfont *f cursor.x = -1; cursor.y = -1; cursor.on = FALSE; - cursor.chr = QChar('?'); + cursor.chr = TQChar('?'); initKeys(); @@ -63,11 +63,11 @@ Score::~Score() // write(); } -void Score::paintEvent( QPaintEvent *e) +void Score::paintEvent( TQPaintEvent *e) { if (rect(1, 0, i18n(" 1UP ")).intersects(e->rect())) { - QPixmap pix; - QColor fg = BLACK; + TQPixmap pix; + TQColor fg = BLACK; if (cursor.on || paused || lastPlayer != 0) fg = WHITE; pix = bitfont->text(i18n(" 1UP "), fg, BLACK); @@ -75,54 +75,54 @@ void Score::paintEvent( QPaintEvent *e) } if (rect(8, 0, i18n(" HIGH SCORE ")).intersects(e->rect())) { - QPixmap pix = bitfont->text(i18n(" HIGH SCORE "), WHITE, BLACK); + TQPixmap pix = bitfont->text(i18n(" HIGH SCORE "), WHITE, BLACK); bitBlt(this, x(8), y(0), &pix); } if (maxPlayer > 1 && rect(21, 0, i18n(" 2UP ")).intersects(e->rect())) { - QPixmap pix; - QColor fg = BLACK; + TQPixmap pix; + TQColor fg = BLACK; if (cursor.on || paused || lastPlayer != 1) fg = WHITE; pix = bitfont->text(i18n(" 2UP "), fg, BLACK); bitBlt(this, x(21), y(0), &pix); } - QString s; + TQString s; s.sprintf("%6d0", playerScore[0]/10); if (rect(0, 1, s).intersects(e->rect())) { - QPixmap pix = bitfont->text(s, WHITE, BLACK); + TQPixmap pix = bitfont->text(s, WHITE, BLACK); bitBlt(this, x(0), y(1), &pix); } s.sprintf("%8d0", HighScore/10); if (rect(8, 1, s).intersects(e->rect())) { - QPixmap pix = bitfont->text(s, WHITE, BLACK); + TQPixmap pix = bitfont->text(s, WHITE, BLACK); bitBlt(this, x(8), y(1), &pix); } if (lastScore >= 0) { if (rect(1, 4*1.25, i18n(" CONGRATULATIONS ")).intersects(e->rect())) { - QPixmap pix = bitfont->text(i18n(" CONGRATULATIONS "), YELLOW, BLACK); + TQPixmap pix = bitfont->text(i18n(" CONGRATULATIONS "), YELLOW, BLACK); bitBlt(this, x(1), y(4*1.25), &pix); } if (rect(1, 6*1.25, i18n(" YOU HAVE ARCHIEVED ")).intersects(e->rect())) { - QPixmap pix = bitfont->text(i18n(" YOU HAVE ARCHIEVED "), CYAN, BLACK); + TQPixmap pix = bitfont->text(i18n(" YOU HAVE ARCHIEVED "), CYAN, BLACK); bitBlt(this, x(1), y(6*1.25), &pix); } if (rect(1, 7*1.25, i18n(" A SCORE IN THE TOP 10. ")).intersects(e->rect())) { - QPixmap pix = bitfont->text(i18n(" A SCORE IN THE TOP 10. "), CYAN, BLACK); + TQPixmap pix = bitfont->text(i18n(" A SCORE IN THE TOP 10. "), CYAN, BLACK); bitBlt(this, x(1), y(7*1.25), &pix); } if (rect(1, 8*1.25, i18n(" ")).intersects(e->rect())) { - QPixmap pix = bitfont->text(i18n(" "), CYAN, BLACK); + TQPixmap pix = bitfont->text(i18n(" "), CYAN, BLACK); bitBlt(this, x(1), y(8*1.25), &pix); } } if (rect(1, 9.5*1.25, i18n("RNK SCORE NAME DATE")).intersects(e->rect())) { - QPixmap pix = bitfont->text(i18n("RNK SCORE NAME DATE"), WHITE, BLACK); + TQPixmap pix = bitfont->text(i18n("RNK SCORE NAME DATE"), WHITE, BLACK); bitBlt(this, x(1), y(9.5*1.25), &pix); } @@ -131,29 +131,29 @@ void Score::paintEvent( QPaintEvent *e) i+1, hallOfFame[i].points, hallOfFame[i].name.utf8().data(), formatDate(hallOfFame[i].moment.date()).data()); if (rect(1, (11+i)*1.25, s).intersects(e->rect())) { - QPixmap pix = bitfont->text(s, (i == lastScore) ? YELLOW : WHITE, BLACK); + TQPixmap pix = bitfont->text(s, (i == lastScore) ? YELLOW : WHITE, BLACK); bitBlt(this, x(1), y((11+i)*1.25), &pix); } } if (cursor.x != -1 && cursor.y != -1 && cursor.on) { if (rect(cursor.x, (cursor.y*1.25), cursor.chr).intersects(e->rect())) { - QPixmap pix = bitfont->text(cursor.chr, BLACK, YELLOW); + TQPixmap pix = bitfont->text(cursor.chr, BLACK, YELLOW); bitBlt(this, x(cursor.x), y(cursor.y*1.25), &pix); } } if (paused) { - QPixmap pix = bitfont->text(i18n("PAUSED"), RED, BLACK); - QRect r = bitfont->rect(i18n("PAUSED")); - r.moveCenter(QPoint(this->width()/2, this->height()/2)); + TQPixmap pix = bitfont->text(i18n("PAUSED"), RED, BLACK); + TQRect r = bitfont->rect(i18n("PAUSED")); + r.moveCenter(TQPoint(this->width()/2, this->height()/2)); bitBlt(this, r.x(), r.y(), &pix); } } -void Score::timerEvent(QTimerEvent *e) +void Score::timerEvent(TQTimerEvent *e) { cursor.on = !cursor.on; @@ -171,7 +171,7 @@ void Score::timerEvent(QTimerEvent *e) repaint(rect(21, 0, i18n(" 2UP ")), FALSE); } -void Score::keyPressEvent(QKeyEvent *k) +void Score::keyPressEvent(TQKeyEvent *k) { if (lastScore < 0 || lastPlayer < 0 || lastPlayer >= maxPlayer || paused) { k->ignore(); @@ -250,19 +250,19 @@ void Score::keyPressEvent(QKeyEvent *k) void Score::initKeys() { - QString up("Up"); + TQString up("Up"); up = kapp->config()->readEntry("upKey", (const char*) up); UpKey = KAccel::stringToKey(up); - QString down("Down"); + TQString down("Down"); down = kapp->config()->readEntry("downKey", (const char*) down); DownKey = KAccel::stringToKey(down); - QString left("Left"); + TQString left("Left"); left = kapp->config()->readEntry("leftKey", (const char*) left); LeftKey = KAccel::stringToKey(left); - QString right("Right"); + TQString right("Right"); right = kapp->config()->readEntry("rightKey", (const char*) right); RightKey = KAccel::stringToKey(right); } @@ -279,8 +279,8 @@ void Score::confTiming(bool defGroup) void Score::confScheme() { - QString oldgroup = kapp->config()->group(); - QString newgroup; + TQString oldgroup = kapp->config()->group(); + TQString newgroup; // if not set, read mode and scheme from the configfile if (mode == -1 && scheme == -1) { @@ -363,7 +363,7 @@ void Score::set(int score, int player) lastPlayer = player; playerScore[lastPlayer] = score; - QString s; + TQString s; s.sprintf("%6d0", playerScore[lastPlayer]/10); repaint(rect(0, 1, s), FALSE); @@ -403,7 +403,7 @@ void Score::setScore(int level, int player) // enable gameNew directly for an immediate next try emit gameFinished(); lastPlayer = -1; - QTimer::singleShot(hallOfFameMS, this, SLOT(end())); + TQTimer::singleShot(hallOfFameMS, this, SLOT(end())); return; } @@ -413,7 +413,7 @@ void Score::setScore(int level, int player) hallOfFame[lastScore].points = playerScore[lastPlayer]; hallOfFame[lastScore].levels = level; - hallOfFame[lastScore].moment = QDateTime::currentDateTime(); + hallOfFame[lastScore].moment = TQDateTime::currentDateTime(); hallOfFame[lastScore].name = playerName[lastPlayer]; cursor.x = 14; @@ -432,12 +432,12 @@ void Score::read() { if (highscoreFile.exists() && highscoreFile.size() > 4) { if (highscoreFile.open(IO_ReadOnly)) { - QDataStream s(&highscoreFile); + TQDataStream s(&highscoreFile); char *name; for (int i = 0; i < 10; i++) { s >> hallOfFame[i].points >> hallOfFame[i].levels >> hallOfFame[i].duration >> hallOfFame[i].moment >> name; - hallOfFame[i].name = QString::fromLatin1(name); + hallOfFame[i].name = TQString::fromLatin1(name); delete(name); } highscoreFile.close(); @@ -446,8 +446,8 @@ void Score::read() for (int i = 0; i < 10; i++) { hallOfFame[i].points = 5000; hallOfFame[i].levels = 0; - hallOfFame[i].duration = QTime(); - hallOfFame[i].moment = QDateTime(); + hallOfFame[i].duration = TQTime(); + hallOfFame[i].moment = TQDateTime(); hallOfFame[i].name = "???"; } // write(); @@ -489,10 +489,10 @@ void Score::write() "To use a different directory or filename for the highscores," "specify them in the configfile (kpacmanrc:highscoreFilePath)." ).arg(systemHighscoreFileInfo.filePath()), - QString::null, "PrivateHighscore"); + TQString::null, "PrivateHighscore"); if (highscoreFile.open(IO_WriteOnly)) { - QDataStream s(&highscoreFile); + TQDataStream s(&highscoreFile); for (int i = 0; i < 10; i++) s << hallOfFame[i].points << hallOfFame[i].levels << hallOfFame[i].duration << hallOfFame[i].moment << hallOfFame[i].name.latin1(); @@ -504,8 +504,8 @@ void Score::setPause(bool Paused) { paused = Paused; - QRect r = bitfont->rect(i18n("PAUSED")); - r.moveCenter(QPoint(this->width()/2, this->height()/2)); + TQRect r = bitfont->rect(i18n("PAUSED")); + r.moveCenter(TQPoint(this->width()/2, this->height()/2)); repaint(r, TRUE); // repaint 1UP or 2UP @@ -515,7 +515,7 @@ void Score::setPause(bool Paused) void Score::end() { if (paused) { - QTimer::singleShot(afterPauseMS, this, SLOT(end())); + TQTimer::singleShot(afterPauseMS, this, SLOT(end())); return; } @@ -528,27 +528,27 @@ void Score::end() } /* - * Return the date in a formatted QString. The format can be changed using internationalization - * of the string "YY/MM/DD". Invalid QDate's where returned as "00/00/00". + * Return the date in a formatted TQString. The format can be changed using internationalization + * of the string "YY/MM/DD". Invalid TQDate's where returned as "00/00/00". */ -QString Score::formatDate(QDate date) +TQString Score::formatDate(TQDate date) { - QString s = i18n("@YY@/@MM@/@DD@"); + TQString s = i18n("@YY@/@MM@/@DD@"); - QString dd; + TQString dd; dd.sprintf("%02d", date.isValid() ? date.year() % 100 : 0); - s.replace(QRegExp("@YY@"), dd); + s.replace(TQRegExp("@YY@"), dd); dd.sprintf("%02d", date.isValid() ? date.month() : 0); - s.replace(QRegExp("@MM@"), dd); + s.replace(TQRegExp("@MM@"), dd); dd.sprintf("%02d", date.isValid() ? date.day() : 0); - s.replace(QRegExp("@DD@"), dd); + s.replace(TQRegExp("@DD@"), dd); return s; } -QRect Score::rect(int col, float row, QString str, int align) +TQRect Score::rect(int col, float row, TQString str, int align) { - QRect r = bitfont->rect(str); + TQRect r = bitfont->rect(str); r.moveBy(x(col), y(row)); int dx = 0; @@ -589,10 +589,10 @@ int Score::y(float row) * Wenn die systemweite "highscore"-Datei nicht beschrieben werden kann, wird mit einer * privaten Datei gearbeitet. */ -QFileInfo Score::locateHighscoreFilePath() +TQFileInfo Score::locateHighscoreFilePath() { - QFileInfo systemHighscoreDirPath; - QStringList systemHighscoreDirs; + TQFileInfo systemHighscoreDirPath; + TQStringList systemHighscoreDirs; // Schreibfähige "private" highscore-Datei ermitteln für den fallback. privateHighscoreFileInfo.setFile(KGlobal::dirs()->saveLocation("appdata")+highscoreName); @@ -604,9 +604,9 @@ QFileInfo Score::locateHighscoreFilePath() if (systemHighscoreFileInfo.filePath().isEmpty()) systemHighscoreDirs = KGlobal::dirs()->resourceDirs("appdata"); else - systemHighscoreDirs = QStringList(systemHighscoreFileInfo.filePath()); + systemHighscoreDirs = TQStringList(systemHighscoreFileInfo.filePath()); - for (QStringList::Iterator i = systemHighscoreDirs.begin(); i != systemHighscoreDirs.end(); ++i) { + for (TQStringList::Iterator i = systemHighscoreDirs.begin(); i != systemHighscoreDirs.end(); ++i) { systemHighscoreFileInfo.setFile(*i); if (systemHighscoreFileInfo.fileName().isEmpty()) |