-rw-r--r-- | noncore/games/sfcave/helpwindow.cpp | 77 | ||||
-rw-r--r-- | noncore/games/sfcave/helpwindow.h | 4 | ||||
-rw-r--r-- | noncore/games/sfcave/sfcave.cpp | 7 |
3 files changed, 42 insertions, 46 deletions
diff --git a/noncore/games/sfcave/helpwindow.cpp b/noncore/games/sfcave/helpwindow.cpp index 8a5d034..bd6035a 100644 --- a/noncore/games/sfcave/helpwindow.cpp +++ b/noncore/games/sfcave/helpwindow.cpp @@ -1,79 +1,76 @@ /*************************************************************************** helpwindow.cpp - description ------------------- begin : Sun Sep 8 2002 copyright : (C) 2002 by Andy Qua email : andy.qua@blueyonder.co.uk ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include <qlayout.h> #include <qtextview.h> #include <qpe/qpeapplication.h> #include "helpwindow.h" -#define HELP_TEXT \ -"<qt><h1>SFCave Help</h1><p> " \ -"SFCave is a flying game for the Zaurus.<br><br> " \ -"The aim is to stay alive for as long as possible and get the highest score " \ -"you can.<br><br>" \ -"There are three game types currently - SFCave, Gates, and Fly.<br>" \ -"<b>SFCave</b> is a remake of the classic SFCave game - fly through the " \ -"cavern avoiding all the blocks that just happen to be hanging in " \ -"midair<br><br>" \ -"<b>Gates</b> is similar to SFCave but instead you must fly through the " \ -"without crashing.<br><br>" \ -"<b>Fly</b> is somewhat different to SFCave and above. Instead, you have " \ -"are flying in the open air above a scrolling landscape, and the aim is to " \ -"hug the ground - the closer to the land you fly the more points " \ -"scored.<br><br><br>" \ -"Basic instruction - Press <b>Up</B> or <b>Down</b> on the circle pad to " \ -"start a new game, press the middle of the pad to apply thrust (makes you " \ -"go up), and release the pad to remove thrust and drop down.<br><br>" \ -"Also, if playing the Fly game, you can press z to toggle the display " \ -"of the scoring zones. This will display 4 red lines at varying heights " \ -"above the landscape - if your ship falls into this zone, point are scored. " \ -"The closer to the landscape you get the more points you get.<br><br>" \ -"In addition, SFCave has replays - save and load too so you can show off to all " \ -"your friends (or vice versa). Currently, this is in its infancy but will improve.<br>" \ -"To use, once you have crashed, press 'r' to replay the last game.<br>" \ -"To save the replay press 's'.<br>" \ -"To load a saved replay press 'l' (after you've crashed at least once).<br><br>" \ -"Replays are currently saved to your home directory in a file called sfcave.replay." \ -"This file can be copied and given to others as long as it it put in their home directory.<br><br>" \ -"Have lots of fun.<br>" \ -"Andy" \ -"</p></qt>" +static QString HELP_TEXT() { +return QObject::tr("<qt><h1>SFCave Help</h1><p> " + "SFCave is a flying game for the Zaurus.<br><br> " + "The aim is to stay alive for as long as possible and get the highest score " + "you can.<br><br>" + "There are three game types currently - SFCave, Gates, and Fly.<br>" + "<b>SFCave</b> is a remake of the classic SFCave game - fly through the " + "cavern avoiding all the blocks that just happen to be hanging in " + "midair<br><br>" + "<b>Gates</b> is similar to SFCave but instead you must fly through the " + "without crashing.<br><br>" + "<b>Fly</b> is somewhat different to SFCave and above. Instead, you have " + "are flying in the open air above a scrolling landscape, and the aim is to " + "hug the ground - the closer to the land you fly the more points " + "scored.<br><br><br>" + "Basic instruction - Press <b>Up</B> or <b>Down</b> on the circle pad to " + "start a new game, press the middle of the pad to apply thrust (makes you " + "go up), and release the pad to remove thrust and drop down.<br><br>" + "Also, if playing the Fly game, you can press z to toggle the display " + "of the scoring zones. This will display 4 red lines at varying heights " + "above the landscape - if your ship falls into this zone, point are scored. " + "The closer to the landscape you get the more points you get.<br><br>" + "In addition, SFCave has replays - save and load too so you can show off to all " + "your friends (or vice versa). Currently, this is in its infancy but will improve.<br>" + "To use, once you have crashed, press 'r' to replay the last game.<br>" + "To save the replay press 's'.<br>" + "To load a saved replay press 'l' (after you've crashed at least once).<br><br>" + "Replays are currently saved to your home directory in a file called sfcave.replay." + "This file can be copied and given to others as long as it it put in their home directory.<br><br>" + "Have lots of fun.<br>" + "Andy" + "</p></qt>"); +} -HelpWindow::HelpWindow( QWidget *parent, const char *name, bool modal, WFlags flags ) - : QDialog( parent, name, modal, flags ) +HelpWindow::HelpWindow( QWidget *parent, const char *name) + : QWidget( parent, name, WDestructiveClose ) { -// resize( 230, 280 ); - - setCaption( "Help for SFCave" ); + setCaption( tr("Help for SFCave") ); QVBoxLayout *layout = new QVBoxLayout( this ); - QString text = HELP_TEXT;; + QString text = HELP_TEXT();; QTextView *view = new QTextView( text, 0, this, "view" ); layout->insertSpacing( -1, 5 ); layout->insertWidget( -1, view ); layout->insertSpacing( -1, 5 ); - - QPEApplication::showDialog( this ); } HelpWindow::~HelpWindow() { } diff --git a/noncore/games/sfcave/helpwindow.h b/noncore/games/sfcave/helpwindow.h index edc1b6e..0aaba7e 100644 --- a/noncore/games/sfcave/helpwindow.h +++ b/noncore/games/sfcave/helpwindow.h @@ -1,34 +1,34 @@ /*************************************************************************** helpwindow.h - description ------------------- begin : Sun Sep 8 2002 copyright : (C) 2002 by Andy Qua email : andy.qua@blueyonder.co.uk ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef HELPWINDOW_H #define HELPWINDOW_H #include <qdialog.h> /** *@author Andy Qua */ -class HelpWindow : public QDialog +class HelpWindow : public QWidget { public: - HelpWindow( QWidget *parent = 0, const char *name = 0, bool modal = true, WFlags flags = 0 ); + HelpWindow( QWidget *parent = 0, const char *name = 0); ~HelpWindow(); }; #endif diff --git a/noncore/games/sfcave/sfcave.cpp b/noncore/games/sfcave/sfcave.cpp index d5aa38a..a6c92a0 100644 --- a/noncore/games/sfcave/sfcave.cpp +++ b/noncore/games/sfcave/sfcave.cpp @@ -1,106 +1,106 @@ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <time.h> #include <opie2/oapplicationfactory.h> +#include <qpe/qpeapplication.h> #include <qpe/config.h> #include <qpe/global.h> -#include <qapplication.h> #include <qdir.h> #include "helpwindow.h" #include "sfcave.h" #define CAPTION "SFCave 1.13 by AndyQ" #define UP_THRUST 0.6 #define NO_THRUST 0.8 #define MAX_DOWN_THRUST 4.0 #define MAX_UP_THRUST -3.5 // States #define STATE_BOSS 0 #define STATE_RUNNING 1 #define STATE_CRASHING 2 #define STATE_CRASHED 3 #define STATE_NEWGAME 4 #define STATE_MENU 5 #define STATE_REPLAY 6 // Menus #define MENU_MAIN_MENU 0 #define MENU_OPTIONS_MENU 1 #define MENU_REPLAY_MENU 2 // Main Menu Options #define MENU_START_GAME 0 #define MENU_REPLAY 1 #define MENU_OPTIONS 2 #define MENU_HELP 3 #define MENU_QUIT 4 // Option Menu Options #define MENU_GAME_TYPE 0 #define MENU_GAME_DIFFICULTY 1 #define MENU_CLEAR_HIGHSCORES 2 #define MENU_BACK 3 // Replay Menu Options #define MENU_REPLAY_START 0 #define MENU_REPLAY_LOAD 1 #define MENU_REPLAY_SAVE 2 #define MENU_REPLAY_BACK 3 #define NR_GAME_DIFFICULTIES 3 #define NR_GAME_TYPES 3 #define DIFICULTY_EASY 0 #define DIFICULTY_NORMAL 1 #define DIFICULTY_HARD 2 #define EASY "Easy" #define NORMAL "Normal" #define HARD "Hard" #define SFCAVE_GAME_TYPE 0 #define GATES_GAME_TYPE 1 #define FLY_GAME_TYPE 2 #define SFCAVE_GAME "SFCave" #define GATES_GAME "Gates" #define FLY_GAME "Fly" #define CURRENT_GAME_TYPE gameTypes[currentGameType] #define CURRENT_GAME_DIFFICULTY difficultyOption[currentGameDifficulty]; QString SFCave::dificultyOption[] = { EASY, NORMAL, HARD }; QString SFCave::gameTypes[] = { SFCAVE_GAME, GATES_GAME, FLY_GAME }; QString SFCave::menuOptions[NR_MENUS][MAX_MENU_OPTIONS] = { { "Start Game", "Replays", "Options", "Help", "Quit", "", "", "" }, { "Game Type - %s", "Game Difficulty - %s", "Clear High Scores for this game", "Back", "", "", "", "" }, { "Play Reply", "Load Replay", "Save Replay", "Back", "", "", "", "" } }; int SFCave::nrMenuOptions[NR_MENUS] = { 5, 4, 4 }; int SFCave ::currentMenuOption[NR_MENUS] = { 0, 0, 0 }; #define UP_THRUST 0.6 #define NO_THRUST 0.8 #define MAX_DOWN_THRUST 4.0 #define MAX_UP_THRUST -3.5 double SFCave::UpThrustVals[3][3] = {{ 0.6, 0.6, 0.6 }, // SFCave { 0.6, 0.6, 0.8 }, // Gates { 0.4, 0.7, 1.0 } }; // Fly double SFCave::DownThrustVals[3][3] = {{ 0.8, 0.8, 0.8 }, // SFCave { 0.8, 0.8, 1.0 }, // Gates { 0.4, 0.7, 1.0 } }; // Fly double SFCave::MaxUpThrustVals[3][3] = {{ -3.5, -3.5, -3.5 }, // SFCave { -3.5, -4.0, -5.0 }, // Gates { -3.5, -4.0, -5.0 } }; // Fly double SFCave::MaxDownThrustVals[3][3] = {{ 4.0, 4.0, 4.0 }, // SFCave { 4.0, 5.0, 5.5 }, // Gates { 3.5, 4.0, 5.0 } }; // Fly int SFCave::flyEasyScores[7][3] = { { 0, 10, 5 }, @@ -1046,167 +1046,166 @@ void SFCave :: handleMenuKeys( QKeyEvent *e ) if ( currentMenuOption[currentMenuNr] == MENU_GAME_TYPE ) { currentGameType ++; if ( currentGameType == NR_GAME_TYPES ) currentGameType = 0; } else if ( currentMenuOption[currentMenuNr] == MENU_GAME_DIFFICULTY ) { currentGameDifficulty ++; if ( currentGameDifficulty == NR_GAME_DIFFICULTIES ) currentGameDifficulty = 0; } } break; case Qt::Key_Space: case Qt::Key_Return: case Qt::Key_Enter: dealWithMenuSelection(); break; } } void SFCave :: displayMenu() { offscreen->fill( Qt::black ); QPainter p( offscreen ); p.setPen( Qt::white ); QFont f( "Helvetica", 16 ); p.setFont( f ); QFontMetrics fm = p.fontMetrics(); QString text = "SFCave"; p.drawText( (sWidth/2) - (fm.width( text )/2), 60, text ); text = "Written by Andy Qua"; p.drawText( (sWidth/2) - (fm.width( text )/2), 85, text ); // Draw options int pos = 140; for ( int i = 0 ; menuOptions[currentMenuNr][i] != "" ; ++i, pos += 25 ) { if ( currentMenuOption[currentMenuNr] == i ) p.setPen( Qt::yellow ); else p.setPen( Qt::white ); QString text; if ( menuOptions[currentMenuNr][i].find( "%s" ) != -1 ) { QString val; if ( i == MENU_GAME_TYPE ) val = gameTypes[currentGameType]; else val = dificultyOption[currentGameDifficulty]; text.sprintf( (const char *)menuOptions[currentMenuNr][i], (const char *)val ); } else text = menuOptions[currentMenuNr][i]; p.drawText( (sWidth/2) - (fm.width( text )/2), pos, text ); } p.end(); bitBlt( this, 0, 0, offscreen, 0, 0, sWidth, sHeight, Qt::CopyROP, true ); } void SFCave :: dealWithMenuSelection() { switch( currentMenuNr ) { case MENU_MAIN_MENU: { switch( currentMenuOption[currentMenuNr] ) { case MENU_START_GAME: state = STATE_NEWGAME; break; case MENU_REPLAY: currentMenuNr = MENU_REPLAY_MENU; currentMenuOption[currentMenuNr] = 0; break; case MENU_OPTIONS: currentMenuNr = MENU_OPTIONS_MENU; currentMenuOption[currentMenuNr] = 0; break; case MENU_HELP: { // Display Help Menu - HelpWindow *dlg = new HelpWindow( this ); - dlg->exec(); - delete dlg; + HelpWindow *win = new HelpWindow( ); + QPEApplication::showWidget( win ); break; } case MENU_QUIT: QApplication::exit(); break; } break; } case MENU_OPTIONS_MENU: { switch( currentMenuOption[currentMenuNr] ) { case MENU_GAME_TYPE: break; case MENU_GAME_DIFFICULTY: break; case MENU_CLEAR_HIGHSCORES: for ( int i = 0 ; i < 3 ; ++i ) highestScore[currentGameType][i] = 0; break; case MENU_BACK: currentMenuNr = MENU_MAIN_MENU; #ifdef QWS Config cfg( "sfcave" ); cfg.setGroup( "settings" ); cfg.writeEntry( "difficulty", currentGameDifficulty ); cfg.writeEntry( "gameType", currentGameType ); #endif break; } break; } case MENU_REPLAY_MENU: { switch( currentMenuOption[currentMenuNr] ) { case MENU_REPLAY_START: if ( currentSeed != 0 ) state = STATE_REPLAY; // Display No Replay break; case MENU_REPLAY_LOAD: loadReplay(); break; case MENU_REPLAY_SAVE: saveReplay(); break; case MENU_REPLAY_BACK: currentMenuNr = MENU_MAIN_MENU; break; } } } } |