diff options
Diffstat (limited to 'kasteroids/toplevel.cpp')
-rw-r--r-- | kasteroids/toplevel.cpp | 184 |
1 files changed, 92 insertions, 92 deletions
diff --git a/kasteroids/toplevel.cpp b/kasteroids/toplevel.cpp index a4286d2f..256174b6 100644 --- a/kasteroids/toplevel.cpp +++ b/kasteroids/toplevel.cpp @@ -4,11 +4,11 @@ * Part of the KDE project */ -#include <qlabel.h> -#include <qlayout.h> -#include <qlcdnumber.h> -#include <qspinbox.h> -#include <qcheckbox.h> +#include <tqlabel.h> +#include <tqlayout.h> +#include <tqlcdnumber.h> +#include <tqspinbox.h> +#include <tqcheckbox.h> #include <kdebug.h> #include <kapplication.h> @@ -75,76 +75,76 @@ Arts::SimpleSoundServer *soundServer = 0; KAstTopLevel::KAstTopLevel() { - QWidget *mainWin = new QWidget( this ); + TQWidget *mainWin = new TQWidget( this ); mainWin->setFixedSize(640, 480); view = new KAsteroidsView( mainWin ); - connect( view, SIGNAL( shipKilled() ), SLOT( slotShipKilled() ) ); - connect( view, SIGNAL( rockHit(int) ), SLOT( slotRockHit(int) ) ); - connect( view, SIGNAL( rocksRemoved() ), SLOT( slotRocksRemoved() ) ); - connect( view, SIGNAL( updateVitals() ), SLOT( slotUpdateVitals() ) ); - - QVBoxLayout *vb = new QVBoxLayout( mainWin ); - QHBoxLayout *hb = new QHBoxLayout; - QHBoxLayout *hbd = new QHBoxLayout; + connect( view, TQT_SIGNAL( shipKilled() ), TQT_SLOT( slotShipKilled() ) ); + connect( view, TQT_SIGNAL( rockHit(int) ), TQT_SLOT( slotRockHit(int) ) ); + connect( view, TQT_SIGNAL( rocksRemoved() ), TQT_SLOT( slotRocksRemoved() ) ); + connect( view, TQT_SIGNAL( updateVitals() ), TQT_SLOT( slotUpdateVitals() ) ); + + TQVBoxLayout *vb = new TQVBoxLayout( mainWin ); + TQHBoxLayout *hb = new QHBoxLayout; + TQHBoxLayout *hbd = new QHBoxLayout; vb->addLayout( hb ); - QFont labelFont( KGlobalSettings::generalFont().family(), 24 ); - QColorGroup grp( darkGreen, black, QColor( 128, 128, 128 ), - QColor( 64, 64, 64 ), black, darkGreen, black ); - QPalette pal( grp, grp, grp ); + TQFont labelFont( KGlobalSettings::generalFont().family(), 24 ); + TQColorGroup grp( darkGreen, black, TQColor( 128, 128, 128 ), + TQColor( 64, 64, 64 ), black, darkGreen, black ); + TQPalette pal( grp, grp, grp ); mainWin->setPalette( pal ); hb->addSpacing( 10 ); - QLabel *label; - label = new QLabel( i18n("Score"), mainWin ); + TQLabel *label; + label = new TQLabel( i18n("Score"), mainWin ); label->setFont( labelFont ); label->setPalette( pal ); label->setFixedWidth( label->sizeHint().width() ); hb->addWidget( label ); - scoreLCD = new QLCDNumber( 6, mainWin ); - scoreLCD->setFrameStyle( QFrame::NoFrame ); - scoreLCD->setSegmentStyle( QLCDNumber::Flat ); + scoreLCD = new TQLCDNumber( 6, mainWin ); + scoreLCD->setFrameStyle( TQFrame::NoFrame ); + scoreLCD->setSegmentStyle( TQLCDNumber::Flat ); scoreLCD->setFixedWidth( 150 ); scoreLCD->setPalette( pal ); hb->addWidget( scoreLCD ); hb->addStretch( 10 ); - label = new QLabel( i18n("Level"), mainWin ); + label = new TQLabel( i18n("Level"), mainWin ); label->setFont( labelFont ); label->setPalette( pal ); label->setFixedWidth( label->sizeHint().width() ); hb->addWidget( label ); - levelLCD = new QLCDNumber( 2, mainWin ); - levelLCD->setFrameStyle( QFrame::NoFrame ); - levelLCD->setSegmentStyle( QLCDNumber::Flat ); + levelLCD = new TQLCDNumber( 2, mainWin ); + levelLCD->setFrameStyle( TQFrame::NoFrame ); + levelLCD->setSegmentStyle( TQLCDNumber::Flat ); levelLCD->setFixedWidth( 70 ); levelLCD->setPalette( pal ); hb->addWidget( levelLCD ); hb->addStretch( 10 ); - label = new QLabel( i18n("Ships"), mainWin ); + label = new TQLabel( i18n("Ships"), mainWin ); label->setFont( labelFont ); label->setFixedWidth( label->sizeHint().width() ); label->setPalette( pal ); hb->addWidget( label ); - shipsLCD = new QLCDNumber( 1, mainWin ); - shipsLCD->setFrameStyle( QFrame::NoFrame ); - shipsLCD->setSegmentStyle( QLCDNumber::Flat ); + shipsLCD = new TQLCDNumber( 1, mainWin ); + shipsLCD->setFrameStyle( TQFrame::NoFrame ); + shipsLCD->setSegmentStyle( TQLCDNumber::Flat ); shipsLCD->setFixedWidth( 40 ); shipsLCD->setPalette( pal ); hb->addWidget( shipsLCD ); hb->addStrut( 30 ); - QFrame *sep = new QFrame( mainWin ); + TQFrame *sep = new TQFrame( mainWin ); sep->setMaximumHeight( 5 ); - sep->setFrameStyle( QFrame::HLine | QFrame::Raised ); + sep->setFrameStyle( TQFrame::HLine | TQFrame::Raised ); sep->setPalette( pal ); vb->addWidget( sep ); @@ -152,45 +152,45 @@ KAstTopLevel::KAstTopLevel() vb->addWidget( view, 10 ); // -- bottom layout: - QFrame *sep2 = new QFrame( mainWin ); + TQFrame *sep2 = new TQFrame( mainWin ); sep2->setMaximumHeight( 1 ); - sep2->setFrameStyle( QFrame::HLine | QFrame::Raised ); + sep2->setFrameStyle( TQFrame::HLine | TQFrame::Raised ); sep2->setPalette( pal ); vb->addWidget( sep2, 1 ); vb->addLayout( hbd ); - QFont smallFont( KGlobalSettings::generalFont().family(), 14 ); + TQFont smallFont( KGlobalSettings::generalFont().family(), 14 ); hbd->addSpacing( 10 ); - QString sprites_prefix = + TQString sprites_prefix = KGlobal::dirs()->findResourceDir("sprite", "rock1/rock10000.png"); /* - label = new QLabel( i18n( "T" ), mainWin ); + label = new TQLabel( i18n( "T" ), mainWin ); label->setFont( smallFont ); label->setFixedWidth( label->sizeHint().width() ); label->setPalette( pal ); hbd->addWidget( label ); - teleportsLCD = new QLCDNumber( 1, mainWin ); - teleportsLCD->setFrameStyle( QFrame::NoFrame ); - teleportsLCD->setSegmentStyle( QLCDNumber::Flat ); + teleportsLCD = new TQLCDNumber( 1, mainWin ); + teleportsLCD->setFrameStyle( TQFrame::NoFrame ); + teleportsLCD->setSegmentStyle( TQLCDNumber::Flat ); teleportsLCD->setPalette( pal ); teleportsLCD->setFixedHeight( 20 ); hbd->addWidget( teleportsLCD ); hbd->addSpacing( 10 ); */ - QPixmap pm( sprites_prefix + "powerups/brake.png" ); - label = new QLabel( mainWin ); + TQPixmap pm( sprites_prefix + "powerups/brake.png" ); + label = new TQLabel( mainWin ); label->setPixmap( pm ); label->setFixedWidth( label->sizeHint().width() ); label->setPalette( pal ); hbd->addWidget( label ); - brakesLCD = new QLCDNumber( 1, mainWin ); - brakesLCD->setFrameStyle( QFrame::NoFrame ); - brakesLCD->setSegmentStyle( QLCDNumber::Flat ); + brakesLCD = new TQLCDNumber( 1, mainWin ); + brakesLCD->setFrameStyle( TQFrame::NoFrame ); + brakesLCD->setSegmentStyle( TQLCDNumber::Flat ); brakesLCD->setPalette( pal ); brakesLCD->setFixedHeight( 20 ); hbd->addWidget( brakesLCD ); @@ -198,15 +198,15 @@ KAstTopLevel::KAstTopLevel() hbd->addSpacing( 10 ); pm.load( sprites_prefix + "powerups/shield.png" ); - label = new QLabel( mainWin ); + label = new TQLabel( mainWin ); label->setPixmap( pm ); label->setFixedWidth( label->sizeHint().width() ); label->setPalette( pal ); hbd->addWidget( label ); - shieldLCD = new QLCDNumber( 1, mainWin ); - shieldLCD->setFrameStyle( QFrame::NoFrame ); - shieldLCD->setSegmentStyle( QLCDNumber::Flat ); + shieldLCD = new TQLCDNumber( 1, mainWin ); + shieldLCD->setFrameStyle( TQFrame::NoFrame ); + shieldLCD->setSegmentStyle( TQLCDNumber::Flat ); shieldLCD->setPalette( pal ); shieldLCD->setFixedHeight( 20 ); hbd->addWidget( shieldLCD ); @@ -214,32 +214,32 @@ KAstTopLevel::KAstTopLevel() hbd->addSpacing( 10 ); pm.load( sprites_prefix + "powerups/shoot.png" ); - label = new QLabel( mainWin ); + label = new TQLabel( mainWin ); label->setPixmap( pm ); label->setFixedWidth( label->sizeHint().width() ); label->setPalette( pal ); hbd->addWidget( label ); - shootLCD = new QLCDNumber( 1, mainWin ); - shootLCD->setFrameStyle( QFrame::NoFrame ); - shootLCD->setSegmentStyle( QLCDNumber::Flat ); + shootLCD = new TQLCDNumber( 1, mainWin ); + shootLCD->setFrameStyle( TQFrame::NoFrame ); + shootLCD->setSegmentStyle( TQLCDNumber::Flat ); shootLCD->setPalette( pal ); shootLCD->setFixedHeight( 20 ); hbd->addWidget( shootLCD ); hbd->addStretch( 1 ); - label = new QLabel( i18n( "Fuel" ), mainWin ); + label = new TQLabel( i18n( "Fuel" ), mainWin ); label->setFont( smallFont ); label->setFixedWidth( label->sizeHint().width() + 10 ); label->setPalette( pal ); hbd->addWidget( label ); powerMeter = new KALedMeter( mainWin ); - powerMeter->setFrameStyle( QFrame::Box | QFrame::Plain ); + powerMeter->setFrameStyle( TQFrame::Box | TQFrame::Plain ); powerMeter->setRange( MAX_POWER_LEVEL ); powerMeter->addColorRange( 10, darkRed ); - powerMeter->addColorRange( 20, QColor(160, 96, 0) ); + powerMeter->addColorRange( 20, TQColor(160, 96, 0) ); powerMeter->addColorRange( 70, darkGreen ); powerMeter->setCount( 40 ); powerMeter->setPalette( pal ); @@ -280,14 +280,14 @@ KAstTopLevel::~KAstTopLevel() void KAstTopLevel::initKAction() { // game - KStdGameAction::gameNew( this, SLOT( slotNewGame() ), actionCollection() ); - KStdGameAction::highscores( this, SLOT( slotShowHighscores() ), actionCollection() ); - KStdGameAction::pause( this, SLOT( slotPause() ), actionCollection() ); - KStdGameAction::quit(this, SLOT( close() ), actionCollection()); + KStdGameAction::gameNew( this, TQT_SLOT( slotNewGame() ), actionCollection() ); + KStdGameAction::highscores( this, TQT_SLOT( slotShowHighscores() ), actionCollection() ); + KStdGameAction::pause( this, TQT_SLOT( slotPause() ), actionCollection() ); + KStdGameAction::quit(this, TQT_SLOT( close() ), actionCollection()); // settings - KStdAction::keyBindings(this, SLOT( slotKeyConfig() ), actionCollection()); - KStdAction::preferences(this, SLOT( slotPref() ), actionCollection()); + KStdAction::keyBindings(this, TQT_SLOT( slotKeyConfig() ), actionCollection()); + KStdAction::preferences(this, TQT_SLOT( slotPref() ), actionCollection()); // keyboard-only actions keycodes.insert(Thrust, new KAction(i18n("Thrust"), Qt::Key_Up, 0, 0, actionCollection(), "Thrust")); @@ -297,16 +297,16 @@ void KAstTopLevel::initKAction() // keycodes.insert(Teleport, new KAction(i18n("Teleport"), Qt::Key_Z, 0, 0, actionCollection(), "Teleport")); keycodes.insert(Brake, new KAction(i18n("Brake"), Qt::Key_X, 0, 0, actionCollection(), "Brake")); keycodes.insert(Shield, new KAction(i18n("Shield"), Qt::Key_S, 0, 0, actionCollection(), "Shield")); - launchAction = new KAction(i18n("Launch"), Qt::Key_L, this, SLOT(slotLaunch()), actionCollection(), "Launch"); + launchAction = new KAction(i18n("Launch"), Qt::Key_L, this, TQT_SLOT(slotLaunch()), actionCollection(), "Launch"); } void KAstTopLevel::loadSettings() { soundDict.insert("ShipDestroyed", - new QString( locate("sounds", Settings::soundShipDestroyed())) ); + new TQString( locate("sounds", Settings::soundShipDestroyed())) ); soundDict.insert("RockDestroyed", - new QString( locate("sounds", Settings::soundRockDestroyed())) ); + new TQString( locate("sounds", Settings::soundRockDestroyed())) ); shipsRemain = Settings::numShips(); } @@ -319,14 +319,14 @@ void KAstTopLevel::playSound( const char *snd ) if (!Settings::playSounds()) return; - QString *filename = soundDict[ snd ]; + TQString *filename = soundDict[ snd ]; if (filename) { KAudioPlayer::play(*filename); } return; // remove this and the above when the sound below is working correctly #ifdef KA_ENABLE_SOUND - QString *filename = soundDict[ snd ]; + TQString *filename = soundDict[ snd ]; if (filename) { kdDebug(12012)<< "playing " << *filename << endl; if(!soundServer->isNull()) soundServer->play(filename->latin1()); @@ -334,15 +334,15 @@ return; // remove this and the above when the sound below is working correctly #endif } -bool KAstTopLevel::eventFilter( QObject* /* object */, QEvent *event ) +bool KAstTopLevel::eventFilter( TQObject* /* object */, TQEvent *event ) { - QKeyEvent *e = static_cast<QKeyEvent*>(event); - if (event->type() == QEvent::AccelOverride) + TQKeyEvent *e = static_cast<TQKeyEvent*>(event); + if (event->type() == TQEvent::AccelOverride) { if (processKeyPress(e)) return true; else return false; } - else if (event->type() == QEvent::KeyRelease) + else if (event->type() == TQEvent::KeyRelease) { if (processKeyRelease(e)) return true; else return false; @@ -350,11 +350,11 @@ bool KAstTopLevel::eventFilter( QObject* /* object */, QEvent *event ) return false; } -bool KAstTopLevel::processKeyPress( QKeyEvent *event ) +bool KAstTopLevel::processKeyPress( TQKeyEvent *event ) { KKey key(event); Action a = Invalid; - QMap<Action, KAction*>::Iterator it = keycodes.begin(); + TQMap<Action, KAction*>::Iterator it = keycodes.begin(); for (; it != keycodes.end(); ++it) { if ( (*it)->shortcut().contains(key) ) @@ -403,11 +403,11 @@ bool KAstTopLevel::processKeyPress( QKeyEvent *event ) return true; } -bool KAstTopLevel::processKeyRelease( QKeyEvent *event ) +bool KAstTopLevel::processKeyRelease( TQKeyEvent *event ) { KKey key(event); Action a = Invalid; - QMap<Action, KAction*>::Iterator it = keycodes.begin(); + TQMap<Action, KAction*>::Iterator it = keycodes.begin(); for (; it != keycodes.end(); ++it) { if ( (*it)->shortcut().contains(key) ) @@ -454,7 +454,7 @@ bool KAstTopLevel::processKeyRelease( QKeyEvent *event ) return true; } -void KAstTopLevel::focusInEvent( QFocusEvent *e ) +void KAstTopLevel::focusInEvent( TQFocusEvent *e ) { view->pause( false ); #if defined Q_WS_X11 && ! defined K_WS_QTONLY @@ -463,7 +463,7 @@ void KAstTopLevel::focusInEvent( QFocusEvent *e ) KMainWindow::focusInEvent(e); } -void KAstTopLevel::focusOutEvent( QFocusEvent *e ) +void KAstTopLevel::focusOutEvent( TQFocusEvent *e ) { view->pause( true ); #if defined Q_WS_X11 && ! defined K_WS_QTONLY @@ -529,7 +529,7 @@ void KAstTopLevel::slotShipKilled() } else { - QTimer::singleShot(1000, this, SLOT(slotGameOver())); + TQTimer::singleShot(1000, this, TQT_SLOT(slotGameOver())); } } } @@ -589,31 +589,31 @@ void KAstTopLevel::slotPref() KConfigDialog *dialog = new KConfigDialog(this, "settings", Settings::self(), KDialogBase::Swallow); /* Make widget */ - QWidget *w = new QWidget(0, "Settings"); - QVBoxLayout *page = new QVBoxLayout( w, 11 ); + TQWidget *w = new TQWidget(0, "Settings"); + TQVBoxLayout *page = new TQVBoxLayout( w, 11 ); - QHBoxLayout *hb = new QHBoxLayout( page, 11 ); - QLabel *label = new QLabel( i18n("Start new game with"), w ); - QSpinBox* sb = new QSpinBox( 1, 5, 1, w, "kcfg_numShips" ); + TQHBoxLayout *hb = new TQHBoxLayout( page, 11 ); + TQLabel *label = new TQLabel( i18n("Start new game with"), w ); + TQSpinBox* sb = new TQSpinBox( 1, 5, 1, w, "kcfg_numShips" ); sb->setValue(3); - QLabel *lb = new QLabel( i18n(" ships."), w ); - QSpacerItem* hspacer = new QSpacerItem( 16, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); + TQLabel *lb = new TQLabel( i18n(" ships."), w ); + TQSpacerItem* hspacer = new TQSpacerItem( 16, 20, TQSizePolicy::Minimum, TQSizePolicy::Expanding ); hb->addWidget(label); hb->addWidget(sb); hb->addWidget(lb); hb->addItem(hspacer); - QCheckBox *f1 = new QCheckBox(i18n("Show highscores on Game Over"), w, "kcfg_showHiscores"); - QCheckBox *f2 = new QCheckBox(i18n("Player can destroy Powerups"), w, "kcfg_canDestroyPowerups"); + TQCheckBox *f1 = new TQCheckBox(i18n("Show highscores on Game Over"), w, "kcfg_showHiscores"); + TQCheckBox *f2 = new TQCheckBox(i18n("Player can destroy Powerups"), w, "kcfg_canDestroyPowerups"); f2->setChecked(true); page->addWidget(f1); page->addWidget(f2); - QSpacerItem* spacer = new QSpacerItem( 20, 16, QSizePolicy::Minimum, QSizePolicy::Expanding ); + TQSpacerItem* spacer = new TQSpacerItem( 20, 16, TQSizePolicy::Minimum, TQSizePolicy::Expanding ); page->addItem( spacer ); /* Done */ dialog->addPage(w, i18n("General"), "package_settings"); - connect(dialog, SIGNAL(settingsChanged()), this, SLOT(loadSettings())); + connect(dialog, TQT_SIGNAL(settingsChanged()), this, TQT_SLOT(loadSettings())); dialog->show(); } @@ -625,14 +625,14 @@ void KAstTopLevel::slotShowHighscores() void KAstTopLevel::doStats() { - QString r; + TQString r; if ( view->shots() ) r = KGlobal::locale()->formatNumber(( (float)view->hits() / (float)view->shots() ) * 100, 2 ); else r = KGlobal::locale()->formatNumber( 0.0, 2 ); - QString s = i18n( "Game Over\n\n" + TQString s = i18n( "Game Over\n\n" "Shots fired:\t%1\n" " Hit:\t%2\n" " Missed:\t%3\n" |