summaryrefslogtreecommitdiff
authorchicken <chicken>2004-03-01 20:30:56 (UTC)
committer chicken <chicken>2004-03-01 20:30:56 (UTC)
commit7b0bdb05e4ae29b2643d73e3b8f20a86a86dcccc (patch) (unidiff)
tree0ec283bce345770910a2630e868afcde3d7c3dc9
parent054b3c3e032bdb0a6061a3345487b4ff877eebfd (diff)
downloadopie-7b0bdb05e4ae29b2643d73e3b8f20a86a86dcccc.zip
opie-7b0bdb05e4ae29b2643d73e3b8f20a86a86dcccc.tar.gz
opie-7b0bdb05e4ae29b2643d73e3b8f20a86a86dcccc.tar.bz2
fix includes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/backgammon/backgammon.cpp3
-rw-r--r--noncore/games/backgammon/filedialog.cpp4
-rw-r--r--noncore/games/backgammon/main.cpp1
-rw-r--r--noncore/games/backgammon/moveengine.cpp1
-rw-r--r--noncore/games/backgammon/themedialog.cpp2
-rw-r--r--noncore/games/bounce/game.cpp1
-rw-r--r--noncore/games/bounce/kbounce.cpp4
-rw-r--r--noncore/games/bounce/main.cpp1
-rw-r--r--noncore/games/buzzword/buzzword.cpp1
-rw-r--r--noncore/games/buzzword/main.cpp1
-rw-r--r--noncore/games/fifteen/fifteen.cpp5
-rw-r--r--noncore/games/go/gowidget.cpp4
-rw-r--r--noncore/games/go/main.cpp1
-rw-r--r--noncore/games/kbill/MCursor.cc5
-rw-r--r--noncore/games/kbill/Picture.cc2
-rw-r--r--noncore/games/kbill/UI.cpp3
-rw-r--r--noncore/games/kbill/field.cpp1
-rw-r--r--noncore/games/kbill/inputbox.cpp1
-rw-r--r--noncore/games/kbill/kbill.cpp4
-rw-r--r--noncore/games/kcheckers/kcheckers.cpp1
-rw-r--r--noncore/games/kcheckers/main.cpp2
-rw-r--r--noncore/games/kpacman/board.cpp3
-rw-r--r--noncore/games/kpacman/keys.cpp5
-rw-r--r--noncore/games/kpacman/kpacman.cpp5
-rw-r--r--noncore/games/kpacman/kpacmanwidget.cpp5
-rw-r--r--noncore/games/kpacman/monster.cpp1
-rw-r--r--noncore/games/kpacman/pacman.cpp1
-rw-r--r--noncore/games/kpacman/painter.cpp10
-rw-r--r--noncore/games/kpacman/referee.cpp9
-rw-r--r--noncore/games/kpacman/score.cpp6
-rw-r--r--noncore/games/kpacman/status.cpp2
-rw-r--r--noncore/games/mindbreaker/mindbreaker.cpp4
-rw-r--r--noncore/games/minesweep/main.cpp1
-rw-r--r--noncore/games/minesweep/minefield.cpp4
-rw-r--r--noncore/games/minesweep/minesweep.cpp5
-rw-r--r--noncore/games/oyatzee/oyatzee.cpp6
-rw-r--r--noncore/games/parashoot/base.cpp2
-rw-r--r--noncore/games/parashoot/cannon.cpp1
-rw-r--r--noncore/games/parashoot/helicopter.cpp1
-rw-r--r--noncore/games/parashoot/interface.cpp4
-rw-r--r--noncore/games/parashoot/main.cpp1
-rw-r--r--noncore/games/parashoot/man.cpp1
-rw-r--r--noncore/games/qasteroids/main.cpp1
-rw-r--r--noncore/games/qasteroids/toplevel.cpp2
-rw-r--r--noncore/games/qasteroids/view.cpp3
-rw-r--r--noncore/games/sfcave/helpwindow.cpp2
-rw-r--r--noncore/games/snake/interface.cpp4
-rw-r--r--noncore/games/snake/main.cpp1
-rw-r--r--noncore/games/snake/snake.cpp2
-rw-r--r--noncore/games/solitaire/canvascard.cpp5
-rw-r--r--noncore/games/solitaire/canvascardgame.cpp8
-rw-r--r--noncore/games/solitaire/canvascardwindow.cpp5
-rw-r--r--noncore/games/solitaire/canvasshapes.cpp2
-rw-r--r--noncore/games/solitaire/card.cpp3
-rw-r--r--noncore/games/solitaire/cardpile.cpp2
-rw-r--r--noncore/games/solitaire/chicanecardgame.cpp1
-rw-r--r--noncore/games/solitaire/freecellcardgame.cpp1
-rw-r--r--noncore/games/solitaire/harpcardgame.cpp1
-rw-r--r--noncore/games/solitaire/main.cpp1
-rw-r--r--noncore/games/solitaire/patiencecardgame.cpp1
-rw-r--r--noncore/games/solitaire/teeclubcardgame.cpp1
-rw-r--r--noncore/games/tetrix/main.cpp1
-rw-r--r--noncore/games/tetrix/ohighscoredlg.cpp3
-rw-r--r--noncore/games/tetrix/qtetrix.cpp3
-rw-r--r--noncore/games/tetrix/qtetrixb.cpp2
-rw-r--r--noncore/games/tictac/main.cpp1
-rw-r--r--noncore/games/tictac/tictac.cpp4
-rw-r--r--noncore/games/wordgame/main.cpp1
-rw-r--r--noncore/games/wordgame/wordgame.cpp9
-rw-r--r--noncore/games/zlines/ballpainter.cpp3
-rw-r--r--noncore/games/zlines/field.cpp1
-rw-r--r--noncore/games/zlines/klines.cpp9
-rw-r--r--noncore/games/zlines/linesboard.cpp3
-rw-r--r--noncore/games/zlines/main.cpp1
-rw-r--r--noncore/games/zlines/mwidget.cpp1
-rw-r--r--noncore/games/zsame/StoneWidget.cpp5
-rw-r--r--noncore/games/zsame/ZSameWidget.cpp7
77 files changed, 2 insertions, 223 deletions
diff --git a/noncore/games/backgammon/backgammon.cpp b/noncore/games/backgammon/backgammon.cpp
index e9e5467..51020a0 100644
--- a/noncore/games/backgammon/backgammon.cpp
+++ b/noncore/games/backgammon/backgammon.cpp
@@ -1,111 +1,108 @@
1#include "backgammon.h" 1#include "backgammon.h"
2 2
3#include "aidialog.h" 3#include "aidialog.h"
4#include "filedialog.h" 4#include "filedialog.h"
5#include "playerdialog.h" 5#include "playerdialog.h"
6#include "rulesdialog.h" 6#include "rulesdialog.h"
7#include "themedialog.h" 7#include "themedialog.h"
8 8
9#include <qdatetime.h>
10#include <qfile.h> 9#include <qfile.h>
11#include <qlayout.h> 10#include <qlayout.h>
12#include <qmessagebox.h> 11#include <qmessagebox.h>
13#include <qstring.h>
14#include <qtimer.h> 12#include <qtimer.h>
15#include <qmainwindow.h>
16#include <qpe/qpeapplication.h> 13#include <qpe/qpeapplication.h>
17#include <qpe/config.h> 14#include <qpe/config.h>
18#include <qmenubar.h> 15#include <qmenubar.h>
19#include <qpe/resource.h> 16#include <qpe/resource.h>
20 17
21#include <stdlib.h> 18#include <stdlib.h>
22 19
23 20
24BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) 21BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl)
25 : QMainWindow(parent, name, fl) 22 : QMainWindow(parent, name, fl)
26{ 23{
27 if (!name) setName("BackGammon"); 24 if (!name) setName("BackGammon");
28 setCaption(tr( "Backgammon") ); 25 setCaption(tr( "Backgammon") );
29 setIcon( Resource::loadPixmap( "backgammon" ) ); 26 setIcon( Resource::loadPixmap( "backgammon" ) );
30 //general counter varaible 27 //general counter varaible
31 int a=0; 28 int a=0;
32 //the game engine 29 //the game engine
33 move=new MoveEngine(); 30 move=new MoveEngine();
34 31
35 //load the default theme 32 //load the default theme
36 Config conf("backgammon"); 33 Config conf("backgammon");
37 if(!conf.isValid()) 34 if(!conf.isValid())
38 { 35 {
39 qDebug("config file does not exist"); 36 qDebug("config file does not exist");
40 conf.setGroup("general"); 37 conf.setGroup("general");
41 conf.writeEntry("theme","default"); 38 conf.writeEntry("theme","default");
42 conf.setGroup("rules"); 39 conf.setGroup("rules");
43 conf.writeEntry("move_with_pieces_out",false); 40 conf.writeEntry("move_with_pieces_out",false);
44 conf.writeEntry("nice_dice",false); 41 conf.writeEntry("nice_dice",false);
45 conf.setGroup("display"); 42 conf.setGroup("display");
46 conf.writeEntry("small",false); 43 conf.writeEntry("small",false);
47 conf.writeEntry("warning",true); 44 conf.writeEntry("warning",true);
48 conf.setGroup("ai"); 45 conf.setGroup("ai");
49 conf.writeEntry("rescue",6); 46 conf.writeEntry("rescue",6);
50 conf.writeEntry("eliminate",4); 47 conf.writeEntry("eliminate",4);
51 conf.writeEntry("expose",1); 48 conf.writeEntry("expose",1);
52 conf.writeEntry("protect",5); 49 conf.writeEntry("protect",5);
53 conf.writeEntry("safe",3); 50 conf.writeEntry("safe",3);
54 conf.writeEntry("empty",2); 51 conf.writeEntry("empty",2);
55 52
56 } 53 }
57 conf.setGroup("general"); 54 conf.setGroup("general");
58 theme_name=conf.readEntry("theme","default"); 55 theme_name=conf.readEntry("theme","default");
59 QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme"; 56 QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme";
60 57
61 //the rules 58 //the rules
62 conf.setGroup("rules"); 59 conf.setGroup("rules");
63 rules.move_with_pieces_out=conf.readBoolEntry("move_with_pieces_out",false); 60 rules.move_with_pieces_out=conf.readBoolEntry("move_with_pieces_out",false);
64 rules.generous_dice=conf.readBoolEntry("nice_dice",false); 61 rules.generous_dice=conf.readBoolEntry("nice_dice",false);
65 62
66 move->setRules(rules); 63 move->setRules(rules);
67 64
68 //get the AI settings 65 //get the AI settings
69 AISettings ai; 66 AISettings ai;
70 conf.setGroup("ai"); 67 conf.setGroup("ai");
71 ai.rescue=conf.readNumEntry("rescue",6); 68 ai.rescue=conf.readNumEntry("rescue",6);
72 ai.eliminate=conf.readNumEntry("eliminate",4); 69 ai.eliminate=conf.readNumEntry("eliminate",4);
73 ai.expose=conf.readNumEntry("expose",1); 70 ai.expose=conf.readNumEntry("expose",1);
74 ai.protect=conf.readNumEntry("protect",5); 71 ai.protect=conf.readNumEntry("protect",5);
75 ai.safe=conf.readNumEntry("safe",3); 72 ai.safe=conf.readNumEntry("safe",3);
76 ai.empty=conf.readNumEntry("empty",2); 73 ai.empty=conf.readNumEntry("empty",2);
77 move->setAISettings(ai); 74 move->setAISettings(ai);
78 75
79 76
80 //get the theme component names 77 //get the theme component names
81 Config theme(theme_file,Config::File); 78 Config theme(theme_file,Config::File);
82 if(!theme.isValid()) 79 if(!theme.isValid())
83 { 80 {
84 qDebug("theme file does not exist"); 81 qDebug("theme file does not exist");
85 theme.setGroup("theme"); 82 theme.setGroup("theme");
86 theme.writeEntry("board","casino_board_1"); 83 theme.writeEntry("board","casino_board_1");
87 theme.writeEntry("pieces1","casino_pieces_blue"); 84 theme.writeEntry("pieces1","casino_pieces_blue");
88 theme.writeEntry("pieces2","casino_pieces_white"); 85 theme.writeEntry("pieces2","casino_pieces_white");
89 theme.writeEntry("dice1","casino_dice"); 86 theme.writeEntry("dice1","casino_dice");
90 theme.writeEntry("dice2","casino_dice"); 87 theme.writeEntry("dice2","casino_dice");
91 theme.writeEntry("table","casino_table_green"); 88 theme.writeEntry("table","casino_table_green");
92 theme.writeEntry("odds","casino_odds"); 89 theme.writeEntry("odds","casino_odds");
93 } 90 }
94 theme.setGroup("theme"); 91 theme.setGroup("theme");
95 board_name=theme.readEntry("board","casino_board_1"); 92 board_name=theme.readEntry("board","casino_board_1");
96 piecesA_name=theme.readEntry("pieces1","casino_pieces_blue"); 93 piecesA_name=theme.readEntry("pieces1","casino_pieces_blue");
97 piecesB_name=theme.readEntry("pieces2","casino_pieces_white"); 94 piecesB_name=theme.readEntry("pieces2","casino_pieces_white");
98 diceA_name=theme.readEntry("dice1","casino_dice"); 95 diceA_name=theme.readEntry("dice1","casino_dice");
99 diceB_name=theme.readEntry("dice2","casino_dice"); 96 diceB_name=theme.readEntry("dice2","casino_dice");
100 table_name=theme.readEntry("table","casino_table_green"); 97 table_name=theme.readEntry("table","casino_table_green");
101 odds_name=theme.readEntry("odds","casino_odds"); 98 odds_name=theme.readEntry("odds","casino_odds");
102 99
103 100
104 //the menu 101 //the menu
105 QMenuBar* menuBar = new QMenuBar(this); 102 QMenuBar* menuBar = new QMenuBar(this);
106 103
107 QPopupMenu* gamemenu= new QPopupMenu(this); 104 QPopupMenu* gamemenu= new QPopupMenu(this);
108 gamemenu->insertItem(tr( "New" ),this,SLOT(newgame())); 105 gamemenu->insertItem(tr( "New" ),this,SLOT(newgame()));
109 gamemenu->insertSeparator(); 106 gamemenu->insertSeparator();
110 gamemenu->insertItem(tr( "Load" ),this,SLOT(loadgame())); 107 gamemenu->insertItem(tr( "Load" ),this,SLOT(loadgame()));
111 gamemenu->insertItem(tr( "Save" ),this,SLOT(savegame())); 108 gamemenu->insertItem(tr( "Save" ),this,SLOT(savegame()));
diff --git a/noncore/games/backgammon/filedialog.cpp b/noncore/games/backgammon/filedialog.cpp
index a5e71c9..e0a2914 100644
--- a/noncore/games/backgammon/filedialog.cpp
+++ b/noncore/games/backgammon/filedialog.cpp
@@ -1,65 +1,61 @@
1#include "filedialog.h" 1#include "filedialog.h"
2 2
3#include <qdir.h> 3#include <qdir.h>
4#include <qfileinfo.h>
5#include <qmessagebox.h>
6#include <qpixmap.h>
7#include <qpushbutton.h>
8#include <qpe/qpeapplication.h> 4#include <qpe/qpeapplication.h>
9 5
10FileDialog::FileDialog(QWidget* parent,QString header,QString extension,const char* name,bool modal,WFlags f) 6FileDialog::FileDialog(QWidget* parent,QString header,QString extension,const char* name,bool modal,WFlags f)
11 :QDialog(parent,name,modal,f) 7 :QDialog(parent,name,modal,f)
12{ 8{
13 setCaption(header); 9 setCaption(header);
14 ext=extension; 10 ext=extension;
15 dirselector=new QListView(this); 11 dirselector=new QListView(this);
16 dirselector->setGeometry(1,10,235,200); 12 dirselector->setGeometry(1,10,235,200);
17 dirselector->addColumn("Files"); 13 dirselector->addColumn("Files");
18 connect(dirselector,SIGNAL(clicked(QListViewItem*)),this,SLOT(selectorclicked(QListViewItem*))); 14 connect(dirselector,SIGNAL(clicked(QListViewItem*)),this,SLOT(selectorclicked(QListViewItem*)));
19 15
20 getCurrentDir(); 16 getCurrentDir();
21 17
22 file_name="user"; 18 file_name="user";
23 fileinput=new QLineEdit(file_name,this); 19 fileinput=new QLineEdit(file_name,this);
24 fileinput->setGeometry(1,220,235,20); 20 fileinput->setGeometry(1,220,235,20);
25 21
26 QPEApplication::showDialog( this ); 22 QPEApplication::showDialog( this );
27} 23}
28 24
29FileDialog::~FileDialog() 25FileDialog::~FileDialog()
30{} 26{}
31 27
32 28
33void FileDialog::selectorclicked(QListViewItem* entry) 29void FileDialog::selectorclicked(QListViewItem* entry)
34{ 30{
35 if(entry==NULL) 31 if(entry==NULL)
36 return; 32 return;
37 file_name=entry->text(0); 33 file_name=entry->text(0);
38 fileinput->setText(file_name); 34 fileinput->setText(file_name);
39} 35}
40 36
41void FileDialog::getCurrentDir() 37void FileDialog::getCurrentDir()
42{ 38{
43 dirselector->clear(); 39 dirselector->clear();
44 QDir dir(QPEApplication::qpeDir()+"/backgammon"); 40 QDir dir(QPEApplication::qpeDir()+"/backgammon");
45 dir.setFilter(QDir::Files); 41 dir.setFilter(QDir::Files);
46 QFileInfoListIterator it(*(dir.entryInfoList())); 42 QFileInfoListIterator it(*(dir.entryInfoList()));
47 QFileInfo* fi; 43 QFileInfo* fi;
48 44
49 int ext_length=ext.length(); 45 int ext_length=ext.length();
50 while((fi=it.current())) // go through all file and subdirs 46 while((fi=it.current())) // go through all file and subdirs
51 { 47 {
52 QString file=fi->fileName(); 48 QString file=fi->fileName();
53 if(file.right(ext_length)==ext && file) 49 if(file.right(ext_length)==ext && file)
54 { 50 {
55 file=file.left(file.length()-ext_length); 51 file=file.left(file.length()-ext_length);
56 new QListViewItem(dirselector,file); 52 new QListViewItem(dirselector,file);
57 } 53 }
58 ++it; 54 ++it;
59 } 55 }
60} 56}
61 57
62QString FileDialog::filename() 58QString FileDialog::filename()
63{ 59{
64 return file_name; 60 return file_name;
65} 61}
diff --git a/noncore/games/backgammon/main.cpp b/noncore/games/backgammon/main.cpp
index 58ced10..6316040 100644
--- a/noncore/games/backgammon/main.cpp
+++ b/noncore/games/backgammon/main.cpp
@@ -1,8 +1,7 @@
1#include <qpe/qpeapplication.h>
2#include "backgammon.h" 1#include "backgammon.h"
3 2
4#include <opie/oapplicationfactory.h> 3#include <opie/oapplicationfactory.h>
5 4
6OPIE_EXPORT_APP( OApplicationFactory<BackGammon> ) 5OPIE_EXPORT_APP( OApplicationFactory<BackGammon> )
7 6
8 7
diff --git a/noncore/games/backgammon/moveengine.cpp b/noncore/games/backgammon/moveengine.cpp
index 37b73a6..7de7147 100644
--- a/noncore/games/backgammon/moveengine.cpp
+++ b/noncore/games/backgammon/moveengine.cpp
@@ -1,99 +1,98 @@
1#include "moveengine.h" 1#include "moveengine.h"
2 2
3#include <qmessagebox.h>
4#include <qtimer.h> 3#include <qtimer.h>
5#include <stdlib.h> 4#include <stdlib.h>
6 5
7MoveEngine::MoveEngine() 6MoveEngine::MoveEngine()
8 : QObject() 7 : QObject()
9{ 8{
10 int offset=7; 9 int offset=7;
11 int a=0; //counter variable 10 int a=0; //counter variable
12 int xfill[]={210,185,170,155,140,125,110,85,70,55,40,25,10,10,25,40,55,70,85,110,125,140,155,170,185,210}; 11 int xfill[]={210,185,170,155,140,125,110,85,70,55,40,25,10,10,25,40,55,70,85,110,125,140,155,170,185,210};
13 for(a=0;a<26;a++) 12 for(a=0;a<26;a++)
14 { 13 {
15 x_coord[a]=xfill[a]; 14 x_coord[a]=xfill[a];
16 } 15 }
17 16
18 int yfill[]={10,25,40,55,70,10+offset,25+offset,40+offset,55+offset,25,40,55, 25+offset,40+offset,40}; 17 int yfill[]={10,25,40,55,70,10+offset,25+offset,40+offset,55+offset,25,40,55, 25+offset,40+offset,40};
19 int zfill[]={1,1,1,1,1,2,2,2,2,3,3,3,4,4,5}; 18 int zfill[]={1,1,1,1,1,2,2,2,2,3,3,3,4,4,5};
20 for(a=0;a<15;a++) 19 for(a=0;a<15;a++)
21 { 20 {
22 yup_coord[a]=yfill[a]; 21 yup_coord[a]=yfill[a];
23 ylow_coord[a]=185-(yfill[a]); 22 ylow_coord[a]=185-(yfill[a]);
24 z_coord[a]=zfill[a]; 23 z_coord[a]=zfill[a];
25 } 24 }
26 for(a=0;a<5;a++) 25 for(a=0;a<5;a++)
27 { 26 {
28 if(a<3) 27 if(a<3)
29 { 28 {
30 x_fin1[a]=65+a*15; 29 x_fin1[a]=65+a*15;
31 x_fin2[a]=155-a*15; 30 x_fin2[a]=155-a*15;
32 } 31 }
33 y_fin[a]=225-a*5; 32 y_fin[a]=225-a*5;
34 } 33 }
35 z_fin=1; 34 z_fin=1;
36 35
37 reset(); 36 reset();
38} 37}
39 38
40MoveEngine::~MoveEngine() 39MoveEngine::~MoveEngine()
41{} 40{}
42 41
43void MoveEngine::position(Pieces& pieces,bool non_qte) 42void MoveEngine::position(Pieces& pieces,bool non_qte)
44{ 43{
45 int player1_counter=0; 44 int player1_counter=0;
46 int player2_counter=0; 45 int player2_counter=0;
47 46
48 //non qte styles are smaller !! 47 //non qte styles are smaller !!
49 int offset=(non_qte) ? 5 : 0; 48 int offset=(non_qte) ? 5 : 0;
50 49
51 for(int a=0;a<28;a++) 50 for(int a=0;a<28;a++)
52 { 51 {
53 for(int b=0;b<abs(population[a].total);b++) 52 for(int b=0;b<abs(population[a].total);b++)
54 { 53 {
55 if(population[a].total>0) //player 1 pieces 54 if(population[a].total>0) //player 1 pieces
56 { 55 {
57 pieces.player1[player1_counter].x=x_coord[a]-offset; 56 pieces.player1[player1_counter].x=x_coord[a]-offset;
58 if(a>=0 && a<13) 57 if(a>=0 && a<13)
59 { 58 {
60 pieces.player1[player1_counter].y=yup_coord[b]-offset; 59 pieces.player1[player1_counter].y=yup_coord[b]-offset;
61 pieces.player1[player1_counter].z=z_coord[b]; 60 pieces.player1[player1_counter].z=z_coord[b];
62 pieces.player1[player1_counter].side=false; 61 pieces.player1[player1_counter].side=false;
63 player1_counter++; 62 player1_counter++;
64 } 63 }
65 else if(a>12 && a<26) 64 else if(a>12 && a<26)
66 { 65 {
67 pieces.player1[player1_counter].y=ylow_coord[b]-offset; 66 pieces.player1[player1_counter].y=ylow_coord[b]-offset;
68 pieces.player1[player1_counter].z=z_coord[b]; 67 pieces.player1[player1_counter].z=z_coord[b];
69 pieces.player1[player1_counter].side=false; 68 pieces.player1[player1_counter].side=false;
70 player1_counter++; 69 player1_counter++;
71 } 70 }
72 else if(a==26) 71 else if(a==26)
73 { 72 {
74 if(b<5) 73 if(b<5)
75 { 74 {
76 pieces.player1[player1_counter].x=x_fin1[0]-offset; 75 pieces.player1[player1_counter].x=x_fin1[0]-offset;
77 pieces.player1[player1_counter].y=y_fin[b]-offset; 76 pieces.player1[player1_counter].y=y_fin[b]-offset;
78 pieces.player1[player1_counter].z=z_fin; 77 pieces.player1[player1_counter].z=z_fin;
79 } 78 }
80 else if(b>=5 && b<10) 79 else if(b>=5 && b<10)
81 { 80 {
82 pieces.player1[player1_counter].x=x_fin1[1]-offset; 81 pieces.player1[player1_counter].x=x_fin1[1]-offset;
83 pieces.player1[player1_counter].y=y_fin[b-5]-offset; 82 pieces.player1[player1_counter].y=y_fin[b-5]-offset;
84 pieces.player1[player1_counter].z=z_fin; 83 pieces.player1[player1_counter].z=z_fin;
85 } 84 }
86 else 85 else
87 { 86 {
88 pieces.player1[player1_counter].x=x_fin1[2]-offset; 87 pieces.player1[player1_counter].x=x_fin1[2]-offset;
89 pieces.player1[player1_counter].y=y_fin[b-10]-offset; 88 pieces.player1[player1_counter].y=y_fin[b-10]-offset;
90 pieces.player1[player1_counter].z=z_fin; 89 pieces.player1[player1_counter].z=z_fin;
91 } 90 }
92 pieces.player1[player1_counter].side=true; 91 pieces.player1[player1_counter].side=true;
93 player1_counter++; 92 player1_counter++;
94 93
95 } 94 }
96 } 95 }
97 96
98 else if(population[a].total<0) //player 2 pieces 97 else if(population[a].total<0) //player 2 pieces
99 { 98 {
diff --git a/noncore/games/backgammon/themedialog.cpp b/noncore/games/backgammon/themedialog.cpp
index f342381..afd6a1b 100644
--- a/noncore/games/backgammon/themedialog.cpp
+++ b/noncore/games/backgammon/themedialog.cpp
@@ -1,102 +1,100 @@
1#include "themedialog.h" 1#include "themedialog.h"
2 2
3#include <qdir.h> 3#include <qdir.h>
4#include <qfileinfo.h>
5#include <qlabel.h> 4#include <qlabel.h>
6#include <qpushbutton.h>
7#include <qpe/qpeapplication.h> 5#include <qpe/qpeapplication.h>
8 6
9 7
10ThemeDialog::ThemeDialog(QWidget* parent,const char* name,bool modal,WFlags f) 8ThemeDialog::ThemeDialog(QWidget* parent,const char* name,bool modal,WFlags f)
11 :QDialog(parent,name,modal,f) 9 :QDialog(parent,name,modal,f)
12{ 10{
13 setCaption("Theme Dialog"); 11 setCaption("Theme Dialog");
14 QLabel* labelname=new QLabel("name",this); 12 QLabel* labelname=new QLabel("name",this);
15 labelname->setGeometry(0,5,40,20); 13 labelname->setGeometry(0,5,40,20);
16 lineName=new QLineEdit("user",this); 14 lineName=new QLineEdit("user",this);
17 lineName->setGeometry(40,5,195,20); 15 lineName->setGeometry(40,5,195,20);
18 16
19 QLabel* labelboard=new QLabel("board",this); 17 QLabel* labelboard=new QLabel("board",this);
20 labelboard->setGeometry(0,30,40,20); 18 labelboard->setGeometry(0,30,40,20);
21 boxboard=new QComboBox(this,""); 19 boxboard=new QComboBox(this,"");
22 boxboard->setGeometry(40,30,195,20); 20 boxboard->setGeometry(40,30,195,20);
23 fillBox("boards",boxboard); 21 fillBox("boards",boxboard);
24 22
25 QLabel* labelpiecesA=new QLabel("pieces1",this); 23 QLabel* labelpiecesA=new QLabel("pieces1",this);
26 labelpiecesA->setGeometry(0,70,40,20); 24 labelpiecesA->setGeometry(0,70,40,20);
27 boxpiecesA=new QComboBox(this); 25 boxpiecesA=new QComboBox(this);
28 boxpiecesA->setGeometry(40,70,195,20); 26 boxpiecesA->setGeometry(40,70,195,20);
29 fillBox("pieces",boxpiecesA); 27 fillBox("pieces",boxpiecesA);
30 28
31 QLabel* labelpiecesB=new QLabel("pieces2",this); 29 QLabel* labelpiecesB=new QLabel("pieces2",this);
32 labelpiecesB->setGeometry(0,95,40,20); 30 labelpiecesB->setGeometry(0,95,40,20);
33 boxpiecesB=new QComboBox(this); 31 boxpiecesB=new QComboBox(this);
34 boxpiecesB->setGeometry(40,95,195,20); 32 boxpiecesB->setGeometry(40,95,195,20);
35 fillBox("pieces",boxpiecesB); 33 fillBox("pieces",boxpiecesB);
36 34
37 QLabel* labeldiceA=new QLabel("dice1",this); 35 QLabel* labeldiceA=new QLabel("dice1",this);
38 labeldiceA->setGeometry(0,135,40,20); 36 labeldiceA->setGeometry(0,135,40,20);
39 boxdiceA=new QComboBox(this); 37 boxdiceA=new QComboBox(this);
40 boxdiceA->setGeometry(40,135,195,20); 38 boxdiceA->setGeometry(40,135,195,20);
41 fillBox("dice",boxdiceA); 39 fillBox("dice",boxdiceA);
42 40
43 QLabel* labeldiceB=new QLabel("dice2",this); 41 QLabel* labeldiceB=new QLabel("dice2",this);
44 labeldiceB->setGeometry(0,160,40,20); 42 labeldiceB->setGeometry(0,160,40,20);
45 boxdiceB=new QComboBox(this); 43 boxdiceB=new QComboBox(this);
46 boxdiceB->setGeometry(40,160,195,20); 44 boxdiceB->setGeometry(40,160,195,20);
47 fillBox("dice",boxdiceB); 45 fillBox("dice",boxdiceB);
48 46
49 QLabel* labelodds=new QLabel("odds",this); 47 QLabel* labelodds=new QLabel("odds",this);
50 labelodds->setGeometry(0,200,40,20); 48 labelodds->setGeometry(0,200,40,20);
51 boxodds=new QComboBox(this); 49 boxodds=new QComboBox(this);
52 boxodds->setGeometry(40,200,195,20); 50 boxodds->setGeometry(40,200,195,20);
53 fillBox("odds",boxodds); 51 fillBox("odds",boxodds);
54 boxodds->setEnabled(false); 52 boxodds->setEnabled(false);
55 53
56 QLabel* labeltable=new QLabel("table",this); 54 QLabel* labeltable=new QLabel("table",this);
57 labeltable->setGeometry(0,225,40,20); 55 labeltable->setGeometry(0,225,40,20);
58 boxtable=new QComboBox(this); 56 boxtable=new QComboBox(this);
59 boxtable->setGeometry(40,225,195,20); 57 boxtable->setGeometry(40,225,195,20);
60 fillBox("table",boxtable); 58 fillBox("table",boxtable);
61 59
62 QPEApplication::showDialog( this ); 60 QPEApplication::showDialog( this );
63} 61}
64 62
65ThemeDialog::~ThemeDialog() 63ThemeDialog::~ThemeDialog()
66{} 64{}
67 65
68 66
69ImageNames ThemeDialog::getNames() 67ImageNames ThemeDialog::getNames()
70{ 68{
71 ImageNames names; 69 ImageNames names;
72 names.theme=lineName->text(); 70 names.theme=lineName->text();
73 names.board=boxboard->currentText(); 71 names.board=boxboard->currentText();
74 names.pieces1=boxpiecesA->currentText(); 72 names.pieces1=boxpiecesA->currentText();
75 names.pieces2=boxpiecesB->currentText(); 73 names.pieces2=boxpiecesB->currentText();
76 names.dice1=boxdiceA->currentText(); 74 names.dice1=boxdiceA->currentText();
77 names.dice2=boxdiceB->currentText(); 75 names.dice2=boxdiceB->currentText();
78 names.odds=boxodds->currentText(); 76 names.odds=boxodds->currentText();
79 names.table=boxtable->currentText(); 77 names.table=boxtable->currentText();
80 return names; 78 return names;
81} 79}
82 80
83void ThemeDialog::setCurrent(const ImageNames& current) 81void ThemeDialog::setCurrent(const ImageNames& current)
84{ 82{
85 int a=0; 83 int a=0;
86 lineName->setText(current.theme); 84 lineName->setText(current.theme);
87 for(a=0;a<boxboard->count();a++) 85 for(a=0;a<boxboard->count();a++)
88 { 86 {
89 if(boxboard->text(a)==current.board) 87 if(boxboard->text(a)==current.board)
90 { 88 {
91 boxboard->setCurrentItem(a); 89 boxboard->setCurrentItem(a);
92 break; 90 break;
93 } 91 }
94 } 92 }
95 for(a=0;a<boxpiecesA->count();a++) 93 for(a=0;a<boxpiecesA->count();a++)
96 { 94 {
97 if(boxpiecesA->text(a)==current.pieces1) 95 if(boxpiecesA->text(a)==current.pieces1)
98 { 96 {
99 boxpiecesA->setCurrentItem(a); 97 boxpiecesA->setCurrentItem(a);
100 break; 98 break;
101 } 99 }
102 } 100 }
diff --git a/noncore/games/bounce/game.cpp b/noncore/games/bounce/game.cpp
index 6ded218..c07f453 100644
--- a/noncore/games/bounce/game.cpp
+++ b/noncore/games/bounce/game.cpp
@@ -1,119 +1,118 @@
1/* 1/*
2 * Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de> 2 * Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de>
3 * 3 *
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public 14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the Free 15 * License along with this program; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 17 */
18 18
19 19
20#include <stdlib.h> 20#include <stdlib.h>
21#include <qtimer.h> 21#include <qtimer.h>
22#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
23#include <qimage.h>
24 23
25#include "game.h" 24#include "game.h"
26 25
27#define TILE_SIZE 9 26#define TILE_SIZE 9
28 27
29#define TILE_FIRST ((FIELD_WIDTH-2)*(FIELD_HEIGHT-2)) 28#define TILE_FIRST ((FIELD_WIDTH-2)*(FIELD_HEIGHT-2))
30#define TILE_FREE (TILE_FIRST + 0) 29#define TILE_FREE (TILE_FIRST + 0)
31#define TILE_BORDER (TILE_FIRST + 1) 30#define TILE_BORDER (TILE_FIRST + 1)
32#define TILE_WALLEND (TILE_FIRST + 2) 31#define TILE_WALLEND (TILE_FIRST + 2)
33#define TILE_WALLUP (TILE_FIRST + 3) 32#define TILE_WALLUP (TILE_FIRST + 3)
34#define TILE_WALLDOWN (TILE_FIRST + 4) 33#define TILE_WALLDOWN (TILE_FIRST + 4)
35#define TILE_WALLLEFT (TILE_FIRST + 5) 34#define TILE_WALLLEFT (TILE_FIRST + 5)
36#define TILE_WALLRIGHT (TILE_FIRST + 6) 35#define TILE_WALLRIGHT (TILE_FIRST + 6)
37 36
38#define GAME_DELAY 15 37#define GAME_DELAY 15
39#define BALL_ANIM_DELAY 60 38#define BALL_ANIM_DELAY 60
40#define WALL_DELAY 100 39#define WALL_DELAY 100
41 40
42#define MS2TICKS( ms ) ((ms)/GAME_DELAY) 41#define MS2TICKS( ms ) ((ms)/GAME_DELAY)
43 42
44Arrow::Arrow(QCanvasPixmapArray* array, QCanvas* canvas) 43Arrow::Arrow(QCanvasPixmapArray* array, QCanvas* canvas)
45 : QCanvasSprite( array, canvas ) 44 : QCanvasSprite( array, canvas )
46{ 45{
47 m_vertical = true; 46 m_vertical = true;
48 move(3,3); 47 move(3,3);
49} 48}
50 49
51void Arrow::update() 50void Arrow::update()
52{ 51{
53 if ( m_vertical ) 52 if ( m_vertical )
54 setFrame( 0 ); 53 setFrame( 0 );
55 else 54 else
56 setFrame( 1 ); 55 setFrame( 1 );
57} 56}
58 57
59void Arrow::changeDirection() 58void Arrow::changeDirection()
60{ 59{
61 m_vertical = ! m_vertical; 60 m_vertical = ! m_vertical;
62 update(); 61 update();
63} 62}
64 63
65 64
66Ball::Ball(QCanvasPixmapArray* array, QCanvas* canvas) 65Ball::Ball(QCanvasPixmapArray* array, QCanvas* canvas)
67 : QCanvasSprite( array, canvas ), m_animDelay( 0 ), m_soundDelay( MS2TICKS(BALL_ANIM_DELAY)/2 ) 66 : QCanvasSprite( array, canvas ), m_animDelay( 0 ), m_soundDelay( MS2TICKS(BALL_ANIM_DELAY)/2 )
68{ 67{
69} 68}
70 69
71void Ball::update() 70void Ball::update()
72{ 71{
73 m_animDelay--; 72 m_animDelay--;
74 if ( m_animDelay<=0 ) 73 if ( m_animDelay<=0 )
75 { 74 {
76 m_animDelay = MS2TICKS(BALL_ANIM_DELAY); 75 m_animDelay = MS2TICKS(BALL_ANIM_DELAY);
77 int frameNum = frame(); 76 int frameNum = frame();
78 frameNum++; 77 frameNum++;
79 if ( frameNum>=frameCount() ) 78 if ( frameNum>=frameCount() )
80 frameNum = 0; 79 frameNum = 0;
81 setFrame( frameNum ); 80 setFrame( frameNum );
82 } 81 }
83} 82}
84 83
85void Ball::advance(int stage) 84void Ball::advance(int stage)
86{ 85{
87 bool reflectX = false; 86 bool reflectX = false;
88 bool reflectY = false; 87 bool reflectY = false;
89 88
90 // check for collisions 89 // check for collisions
91 if ( collide(xVelocity(), 0) ) reflectX = true; 90 if ( collide(xVelocity(), 0) ) reflectX = true;
92 if ( collide(0, yVelocity()) ) reflectY = true; 91 if ( collide(0, yVelocity()) ) reflectY = true;
93 if ( !reflectX && !reflectY && collide(xVelocity(), yVelocity()) ) reflectX = reflectY = true; 92 if ( !reflectX && !reflectY && collide(xVelocity(), yVelocity()) ) reflectX = reflectY = true;
94 93
95 // emit collision 94 // emit collision
96 QRect r = boundingRect(); 95 QRect r = boundingRect();
97 r.moveBy( xVelocity(), yVelocity() ); 96 r.moveBy( xVelocity(), yVelocity() );
98 JezzField* field = (JezzField *)canvas(); 97 JezzField* field = (JezzField *)canvas();
99 98
100 int ul = field->tile( r.left() / TILE_SIZE, r.top() / TILE_SIZE ); 99 int ul = field->tile( r.left() / TILE_SIZE, r.top() / TILE_SIZE );
101 int ur = field->tile( r.right() / TILE_SIZE, r.top() / TILE_SIZE ); 100 int ur = field->tile( r.right() / TILE_SIZE, r.top() / TILE_SIZE );
102 int bl = field->tile( r.left() / TILE_SIZE, r.bottom() / TILE_SIZE ); 101 int bl = field->tile( r.left() / TILE_SIZE, r.bottom() / TILE_SIZE );
103 int br = field->tile( r.right() / TILE_SIZE, r.bottom() / TILE_SIZE ); 102 int br = field->tile( r.right() / TILE_SIZE, r.bottom() / TILE_SIZE );
104 103
105 if ( ul!=TILE_FREE ) field->emitBallCollisiton( this, r.left() / TILE_SIZE, r.top() / TILE_SIZE, ul ); else 104 if ( ul!=TILE_FREE ) field->emitBallCollisiton( this, r.left() / TILE_SIZE, r.top() / TILE_SIZE, ul ); else
106 if ( ur!=TILE_FREE ) field->emitBallCollisiton( this, r.right() / TILE_SIZE, r.top() / TILE_SIZE, ur ); else 105 if ( ur!=TILE_FREE ) field->emitBallCollisiton( this, r.right() / TILE_SIZE, r.top() / TILE_SIZE, ur ); else
107 if ( bl!=TILE_FREE ) field->emitBallCollisiton( this, r.left() / TILE_SIZE, r.bottom() / TILE_SIZE, bl ); else 106 if ( bl!=TILE_FREE ) field->emitBallCollisiton( this, r.left() / TILE_SIZE, r.bottom() / TILE_SIZE, bl ); else
108 if ( br!=TILE_FREE ) field->emitBallCollisiton( this, r.right() / TILE_SIZE, r.bottom() / TILE_SIZE, br ); 107 if ( br!=TILE_FREE ) field->emitBallCollisiton( this, r.right() / TILE_SIZE, r.bottom() / TILE_SIZE, br );
109 108
110 // apply reflection 109 // apply reflection
111 if ( reflectX ) setXVelocity( -xVelocity() ); 110 if ( reflectX ) setXVelocity( -xVelocity() );
112 if ( reflectY ) setYVelocity( -yVelocity() ); 111 if ( reflectY ) setYVelocity( -yVelocity() );
113 112
114 // update field 113 // update field
115 update(); 114 update();
116 QCanvasSprite::advance( stage ); 115 QCanvasSprite::advance( stage );
117} 116}
118 117
119bool Ball::collide( double dx, double dy ) 118bool Ball::collide( double dx, double dy )
diff --git a/noncore/games/bounce/kbounce.cpp b/noncore/games/bounce/kbounce.cpp
index 211f0ff..3b0cb6f 100644
--- a/noncore/games/bounce/kbounce.cpp
+++ b/noncore/games/bounce/kbounce.cpp
@@ -1,124 +1,120 @@
1/* 1/*
2 * Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de> 2 * Copyright (C) 2000 Stefan Schimanski <1Stein@gmx.de>
3 * 3 *
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License,Life or (at your option) any later version. 7 * version 2 of the License,Life or (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public 14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the Free 15 * License along with this program; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 17 */
18 18
19#include <qlayout.h> 19#include <qlayout.h>
20#include <qtimer.h> 20#include <qtimer.h>
21#include <qlcdnumber.h>
22#include <qmessagebox.h> 21#include <qmessagebox.h>
23#include <qmainwindow.h>
24#include <qpe/qpeapplication.h>
25 22
26#include "kbounce.h" 23#include "kbounce.h"
27#include "game.h" 24#include "game.h"
28#include <qlabel.h>
29 25
30KJezzball::KJezzball(QWidget *p, const char* n, WFlags f) 26KJezzball::KJezzball(QWidget *p, const char* n, WFlags f)
31 : QMainWindow(p,n,f), m_gameWidget( 0 ) 27 : QMainWindow(p,n,f), m_gameWidget( 0 )
32{ 28{
33 setCaption(tr("Bounce")); 29 setCaption(tr("Bounce"));
34 // setup variables 30 // setup variables
35 m_game.level = 1; 31 m_game.level = 1;
36 m_game.score = 0; 32 m_game.score = 0;
37 m_state = Idle; 33 m_state = Idle;
38 34
39 35
40 menu = menuBar(); 36 menu = menuBar();
41 game = new QPopupMenu; 37 game = new QPopupMenu;
42 game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N ); 38 game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N );
43 game->insertItem(tr("&Pause game"), this, SLOT(pauseGame()), Key_P ); 39 game->insertItem(tr("&Pause game"), this, SLOT(pauseGame()), Key_P );
44 game->insertSeparator(); 40 game->insertSeparator();
45 game->insertItem(tr("&About"), this, SLOT(about())); 41 game->insertItem(tr("&About"), this, SLOT(about()));
46 menu->insertItem( tr("&Game"), game ); 42 menu->insertItem( tr("&Game"), game );
47 43
48 // create widgets 44 // create widgets
49 m_view = new QWidget( this, "m_view" ); 45 m_view = new QWidget( this, "m_view" );
50 setCentralWidget( m_view ); 46 setCentralWidget( m_view );
51 47
52 m_layout = new QGridLayout( m_view ); 48 m_layout = new QGridLayout( m_view );
53 m_layout->setSpacing( 0 ); 49 m_layout->setSpacing( 0 );
54 m_layout->setMargin( 0 ); 50 m_layout->setMargin( 0 );
55 51
56 ScoreLabel = new QLabel( m_view, "ScoreLabel" ); 52 ScoreLabel = new QLabel( m_view, "ScoreLabel" );
57 ScoreLabel->setText( tr( "Score: 00" ) ); 53 ScoreLabel->setText( tr( "Score: 00" ) );
58 ScoreLabel->setAlignment( int( QLabel::AlignCenter ) ); 54 ScoreLabel->setAlignment( int( QLabel::AlignCenter ) );
59 55
60 m_layout->addWidget( ScoreLabel, 1, 0 ); 56 m_layout->addWidget( ScoreLabel, 1, 0 );
61 57
62 LivesLabel = new QLabel( m_view, "LivesLabel" ); 58 LivesLabel = new QLabel( m_view, "LivesLabel" );
63 LivesLabel->setText( tr( "Lives: 0%" ) ); 59 LivesLabel->setText( tr( "Lives: 0%" ) );
64 LivesLabel->setAlignment( int( QLabel::AlignCenter ) ); 60 LivesLabel->setAlignment( int( QLabel::AlignCenter ) );
65 61
66 m_layout->addWidget( LivesLabel, 1, 2 ); 62 m_layout->addWidget( LivesLabel, 1, 2 );
67 63
68 FilledLabel = new QLabel( m_view, "FilledLabel" ); 64 FilledLabel = new QLabel( m_view, "FilledLabel" );
69 FilledLabel->setText( tr( "Filled: 00%" ) ); 65 FilledLabel->setText( tr( "Filled: 00%" ) );
70 FilledLabel->setAlignment( int( QLabel::AlignCenter ) ); 66 FilledLabel->setAlignment( int( QLabel::AlignCenter ) );
71 67
72 m_layout->addWidget( FilledLabel, 1, 1 ); 68 m_layout->addWidget( FilledLabel, 1, 1 );
73 69
74 TimeLabel = new QLabel( m_view, "TimeLabel" ); 70 TimeLabel = new QLabel( m_view, "TimeLabel" );
75 TimeLabel->setText( tr( "Time: 00" ) ); 71 TimeLabel->setText( tr( "Time: 00" ) );
76 TimeLabel->setAlignment( int( QLabel::AlignCenter ) ); 72 TimeLabel->setAlignment( int( QLabel::AlignCenter ) );
77 73
78 m_layout->addWidget( TimeLabel, 1, 3 ); 74 m_layout->addWidget( TimeLabel, 1, 3 );
79 75
80 // create timers 76 // create timers
81 m_nextLevelTimer = new QTimer( this, "m_nextLevelTimer" ); 77 m_nextLevelTimer = new QTimer( this, "m_nextLevelTimer" );
82 connect( m_nextLevelTimer, SIGNAL(timeout()), this, SLOT(switchLevel()) ); 78 connect( m_nextLevelTimer, SIGNAL(timeout()), this, SLOT(switchLevel()) );
83 79
84 m_gameOverTimer = new QTimer( this, "m_gameOverTimer" ); 80 m_gameOverTimer = new QTimer( this, "m_gameOverTimer" );
85 connect( m_gameOverTimer, SIGNAL(timeout()), this, SLOT(gameOverNow()) ); 81 connect( m_gameOverTimer, SIGNAL(timeout()), this, SLOT(gameOverNow()) );
86 82
87 m_timer = new QTimer( this, "m_timer" ); 83 m_timer = new QTimer( this, "m_timer" );
88 connect( m_timer, SIGNAL(timeout()), this, SLOT(second()) ); 84 connect( m_timer, SIGNAL(timeout()), this, SLOT(second()) );
89 85
90 // create demo game 86 // create demo game
91 createLevel( 1 ); 87 createLevel( 1 );
92} 88}
93 89
94void KJezzball::newGame() 90void KJezzball::newGame()
95{ 91{
96 // Check for running game 92 // Check for running game
97 closeGame(); 93 closeGame();
98 if ( m_state==Idle ) 94 if ( m_state==Idle )
99 { 95 {
100 // update displays 96 // update displays
101 m_game.level = 1; 97 m_game.level = 1;
102 m_game.score = 0; 98 m_game.score = 0;
103 99
104 setCaption(tr("Bounce Level %1").arg(m_game.level)); 100 setCaption(tr("Bounce Level %1").arg(m_game.level));
105 ScoreLabel->setText( tr( "Score: %1" ).arg(m_game.score) ); 101 ScoreLabel->setText( tr( "Score: %1" ).arg(m_game.score) );
106 102
107 // start new game 103 // start new game
108 m_state = Running; 104 m_state = Running;
109 105
110 createLevel( m_game.level ); 106 createLevel( m_game.level );
111 startLevel(); 107 startLevel();
112 } 108 }
113} 109}
114 110
115void KJezzball::about() 111void KJezzball::about()
116{ 112{
117 QMessageBox::information( this, tr("About"), 113 QMessageBox::information( this, tr("About"),
118 tr("Written by: Stefan Schimanski\n" 114 tr("Written by: Stefan Schimanski\n"
119 "Ported by: Martin Imobersteg\n" 115 "Ported by: Martin Imobersteg\n"
120 "\n" 116 "\n"
121 "Click to form walls.\n" 117 "Click to form walls.\n"
122 "Hit space to switch wall direction.\n" 118 "Hit space to switch wall direction.\n"
123 "Try to reduce total space by 75%.\n" 119 "Try to reduce total space by 75%.\n"
124 "\n" 120 "\n"
diff --git a/noncore/games/bounce/main.cpp b/noncore/games/bounce/main.cpp
index 9ea86a6..a070c4b 100644
--- a/noncore/games/bounce/main.cpp
+++ b/noncore/games/bounce/main.cpp
@@ -1,24 +1,23 @@
1/* 1/*
2 * Copyright (C) 2000 Stefan Schimanski <schimmi@kde.org> 2 * Copyright (C) 2000 Stefan Schimanski <schimmi@kde.org>
3 * 3 *
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public 14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the Free 15 * License along with this program; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 17 */
18 18
19#include <qpe/qpeapplication.h>
20#include "kbounce.h" 19#include "kbounce.h"
21#include <opie/oapplicationfactory.h> 20#include <opie/oapplicationfactory.h>
22 21
23OPIE_EXPORT_APP( OApplicationFactory<KJezzball> ) 22OPIE_EXPORT_APP( OApplicationFactory<KJezzball> )
24 23
diff --git a/noncore/games/buzzword/buzzword.cpp b/noncore/games/buzzword/buzzword.cpp
index f746065..13eb481 100644
--- a/noncore/games/buzzword/buzzword.cpp
+++ b/noncore/games/buzzword/buzzword.cpp
@@ -1,116 +1,115 @@
1/* 1/*
2 * Copyright (C) 2002 Martin Imobersteg <imm@gmx.ch> 2 * Copyright (C) 2002 Martin Imobersteg <imm@gmx.ch>
3 * 3 *
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public 5 * modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License,Life or (at your option) any later version. 7 * version 2 of the License,Life or (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public 14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the Free 15 * License along with this program; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 17 */
18 18
19#include <qlayout.h> 19#include <qlayout.h>
20#include <qmessagebox.h>
21#include <qmainwindow.h> 20#include <qmainwindow.h>
22#include <qlabel.h> 21#include <qlabel.h>
23#include <qgrid.h> 22#include <qgrid.h>
24#include <qcolor.h> 23#include <qcolor.h>
25#include <qbutton.h> 24#include <qbutton.h>
26#include <qfile.h> 25#include <qfile.h>
27#include <qtextstream.h> 26#include <qtextstream.h>
28#include <qstringlist.h> 27#include <qstringlist.h>
29#include <qmessagebox.h> 28#include <qmessagebox.h>
30#include <qdir.h> 29#include <qdir.h>
31 30
32#include <math.h> 31#include <math.h>
33#include <stdlib.h> 32#include <stdlib.h>
34 33
35#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
36 35
37#include "buzzword.h" 36#include "buzzword.h"
38 37
39BuzzLabel::BuzzLabel( QWidget *parent, const char *name ) 38BuzzLabel::BuzzLabel( QWidget *parent, const char *name )
40: QLabel( parent, name ) 39: QLabel( parent, name )
41{ 40{
42} 41}
43 42
44void BuzzLabel::mousePressEvent(QMouseEvent *e) 43void BuzzLabel::mousePressEvent(QMouseEvent *e)
45{ 44{
46 if(e->button() == LeftButton) 45 if(e->button() == LeftButton)
47 { 46 {
48 emit clicked(); 47 emit clicked();
49 } 48 }
50} 49}
51 50
52BuzzItem::BuzzItem( int row, int column, QString text, QWidget *parent, const char *name ) 51BuzzItem::BuzzItem( int row, int column, QString text, QWidget *parent, const char *name )
53: QVBox( parent, name ), _row(row), _column(column) 52: QVBox( parent, name ), _row(row), _column(column)
54{ 53{
55 setFrameStyle( QFrame::Panel | QFrame::Raised ); 54 setFrameStyle( QFrame::Panel | QFrame::Raised );
56 setLineWidth( 1 ); 55 setLineWidth( 1 );
57 label = new BuzzLabel(this, "label"); 56 label = new BuzzLabel(this, "label");
58 label->setText(text); 57 label->setText(text);
59 label->setAlignment( int( QLabel::AlignCenter ) ); 58 label->setAlignment( int( QLabel::AlignCenter ) );
60 59
61 connect( label, SIGNAL(clicked()), this, SLOT(flip()) ); 60 connect( label, SIGNAL(clicked()), this, SLOT(flip()) );
62} 61}
63 62
64void BuzzItem::flip() 63void BuzzItem::flip()
65{ 64{
66 setLineWidth( 1 ); 65 setLineWidth( 1 );
67 label->setBackgroundColor(label->colorGroup().highlight()); 66 label->setBackgroundColor(label->colorGroup().highlight());
68 emit clicked(_row, _column); 67 emit clicked(_row, _column);
69} 68}
70 69
71BuzzWord::BuzzWord(QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl ) 70BuzzWord::BuzzWord(QWidget* parent, const char* name, WFlags fl ) : QMainWindow( parent, name, fl )
72{ 71{
73 setCaption(tr("buZzword")); 72 setCaption(tr("buZzword"));
74 73
75 menu = menuBar(); 74 menu = menuBar();
76 game = new QPopupMenu; 75 game = new QPopupMenu;
77 game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N ); 76 game->insertItem(tr("&New game"), this, SLOT(newGame()), Key_N );
78 menu->insertItem( tr("&Game"), game ); 77 menu->insertItem( tr("&Game"), game );
79 78
80 gridVal = 4; 79 gridVal = 4;
81 grid = NULL; 80 grid = NULL;
82 gameOver = false; 81 gameOver = false;
83 newGame(); 82 newGame();
84} 83}
85 84
86void BuzzWord::drawGrid() 85void BuzzWord::drawGrid()
87{ 86{
88 QStringList l; 87 QStringList l;
89 88
90 QString path = QPEApplication::qpeDir()+"share/buzzword/"; 89 QString path = QPEApplication::qpeDir()+"share/buzzword/";
91 QFile f( path + "buzzwords" ); 90 QFile f( path + "buzzwords" );
92 if ( !f.open( IO_ReadOnly ) ) 91 if ( !f.open( IO_ReadOnly ) )
93 return; 92 return;
94 93
95 QTextStream t( &f ); 94 QTextStream t( &f );
96 95
97 while (!t.atEnd()) 96 while (!t.atEnd())
98 { 97 {
99 l << t.readLine(); 98 l << t.readLine();
100 } 99 }
101 100
102 f.close(); 101 f.close();
103 102
104 grid = new QGrid(gridVal, this); 103 grid = new QGrid(gridVal, this);
105 //grid->setFixedSize( 480, 480 ); 104 //grid->setFixedSize( 480, 480 );
106 105
107 for( int c = 0 ; c < gridVal ; c++ ) 106 for( int c = 0 ; c < gridVal ; c++ )
108 { 107 {
109 for( int r = 0 ; r < gridVal ; r++ ) 108 for( int r = 0 ; r < gridVal ; r++ )
110 { 109 {
111 uint pos = rand() % l. count(); 110 uint pos = rand() % l. count();
112 111
113 QString word = QStringList::split(" ", l[pos]).join("\n"); 112 QString word = QStringList::split(" ", l[pos]).join("\n");
114 BuzzItem* bi = new BuzzItem( c, r, word, grid ); 113 BuzzItem* bi = new BuzzItem( c, r, word, grid );
115 connect( bi, SIGNAL(clicked(int, int)), this, SLOT(clicked(int,int)) ); 114 connect( bi, SIGNAL(clicked(int, int)), this, SLOT(clicked(int,int)) );
116 map[c][r] = 0; 115 map[c][r] = 0;
diff --git a/noncore/games/buzzword/main.cpp b/noncore/games/buzzword/main.cpp
index 67f2c26..95b3176 100644
--- a/noncore/games/buzzword/main.cpp
+++ b/noncore/games/buzzword/main.cpp
@@ -1,24 +1,23 @@
1/* 1/*
2 * Copyright (C) 2002 Martin Imobersteg <imm@gmx.ch> 2 * Copyright (C) 2002 Martin Imobersteg <imm@gmx.ch>
3 * 3 *
4 * This program is free software; you can redistribute it and/or 4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public 5 * modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License,Life or (at your option) any later version. 7 * version 2 of the License,Life or (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public 14 * You should have received a copy of the GNU Library General Public
15 * License along with this program; if not, write to the Free 15 * License along with this program; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 */ 17 */
18 18
19#include <qpe/qpeapplication.h>
20#include <opie/oapplicationfactory.h> 19#include <opie/oapplicationfactory.h>
21 20
22#include "buzzword.h" 21#include "buzzword.h"
23 22
24OPIE_EXPORT_APP( OApplicationFactory<BuzzWord> ) 23OPIE_EXPORT_APP( OApplicationFactory<BuzzWord> )
diff --git a/noncore/games/fifteen/fifteen.cpp b/noncore/games/fifteen/fifteen.cpp
index b4e0308..506e87a 100644
--- a/noncore/games/fifteen/fifteen.cpp
+++ b/noncore/games/fifteen/fifteen.cpp
@@ -1,132 +1,127 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "fifteen.h" 21#include "fifteen.h"
22 22
23#include <qtopia/resource.h> 23#include <qtopia/resource.h>
24#include <qtopia/config.h> 24#include <qtopia/config.h>
25 25
26#include <qvbox.h> 26#include <qvbox.h>
27#include <qaction.h> 27#include <qaction.h>
28#include <qlayout.h>
29#include <qpainter.h> 28#include <qpainter.h>
30#include <qpopupmenu.h>
31#include <qmessagebox.h> 29#include <qmessagebox.h>
32#include <qtoolbar.h> 30#include <qtoolbar.h>
33#include <qmenubar.h> 31#include <qmenubar.h>
34#include <qstringlist.h>
35#include <qapplication.h>
36#include <qtoolbutton.h>
37 32
38#include <stdlib.h> 33#include <stdlib.h>
39#include <time.h> 34#include <time.h>
40 35
41FifteenMainWindow::FifteenMainWindow(QWidget *parent, const char* name, WFlags fl) 36FifteenMainWindow::FifteenMainWindow(QWidget *parent, const char* name, WFlags fl)
42 : QMainWindow( parent, name, fl ) 37 : QMainWindow( parent, name, fl )
43{ 38{
44 // random seed 39 // random seed
45 srand(time(0)); 40 srand(time(0));
46 setCaption( tr("Fifteen Pieces") ); 41 setCaption( tr("Fifteen Pieces") );
47 42
48 QToolBar *toolbar = new QToolBar(this); 43 QToolBar *toolbar = new QToolBar(this);
49 toolbar->setHorizontalStretchable( FALSE ); 44 toolbar->setHorizontalStretchable( FALSE );
50 QMenuBar *menubar = new QMenuBar( toolbar ); 45 QMenuBar *menubar = new QMenuBar( toolbar );
51 menubar->setMargin(0); 46 menubar->setMargin(0);
52 QPopupMenu *game = new QPopupMenu( this ); 47 QPopupMenu *game = new QPopupMenu( this );
53 48
54 QWidget *spacer = new QWidget( toolbar ); 49 QWidget *spacer = new QWidget( toolbar );
55 spacer->setBackgroundMode( PaletteButton ); 50 spacer->setBackgroundMode( PaletteButton );
56 toolbar->setStretchableWidget( spacer ); 51 toolbar->setStretchableWidget( spacer );
57 52
58 53
59 setToolBarsMovable( FALSE ); 54 setToolBarsMovable( FALSE );
60 QVBox *vbox = new QVBox( this ); 55 QVBox *vbox = new QVBox( this );
61 PiecesTable *table = new PiecesTable( vbox ); 56 PiecesTable *table = new PiecesTable( vbox );
62 setCentralWidget(vbox); 57 setCentralWidget(vbox);
63 58
64 59
65 60
66 QAction *a = new QAction( tr( "Randomize" ), Resource::loadPixmap( "new" ), 61 QAction *a = new QAction( tr( "Randomize" ), Resource::loadPixmap( "new" ),
67 QString::null, 0, this, 0 ); 62 QString::null, 0, this, 0 );
68 connect( a, SIGNAL( activated() ), table, SLOT( slotRandomize() ) ); 63 connect( a, SIGNAL( activated() ), table, SLOT( slotRandomize() ) );
69 a->addTo( game ); 64 a->addTo( game );
70 a->addTo( toolbar ); 65 a->addTo( toolbar );
71 66
72 /* This is pointless and confusing. 67 /* This is pointless and confusing.
73 a = new QAction( tr( "Solve" ), Resource::loadIconSet( "repeat" ), 68 a = new QAction( tr( "Solve" ), Resource::loadIconSet( "repeat" ),
74 QString::null, 0, this, 0 ); 69 QString::null, 0, this, 0 );
75 connect( a, SIGNAL( activated() ), table, SLOT( slotReset() ) ); 70 connect( a, SIGNAL( activated() ), table, SLOT( slotReset() ) );
76 a->addTo( game ); 71 a->addTo( game );
77 a->addTo( toolbar ); 72 a->addTo( toolbar );
78 */ 73 */
79 menubar->insertItem( tr( "Game" ), game ); 74 menubar->insertItem( tr( "Game" ), game );
80} 75}
81 76
82PiecesTable::PiecesTable(QWidget* parent, const char* name ) 77PiecesTable::PiecesTable(QWidget* parent, const char* name )
83 : QTableView(parent, name), _menu(0), _randomized(false) 78 : QTableView(parent, name), _menu(0), _randomized(false)
84{ 79{
85 // setup table view 80 // setup table view
86 setFrameStyle(StyledPanel | Sunken); 81 setFrameStyle(StyledPanel | Sunken);
87 setBackgroundMode(NoBackground); 82 setBackgroundMode(NoBackground);
88 setMouseTracking(true); 83 setMouseTracking(true);
89 84
90 setNumRows(4); 85 setNumRows(4);
91 setNumCols(4); 86 setNumCols(4);
92 87
93 // init arrays 88 // init arrays
94 initMap(); 89 initMap();
95 readConfig(); 90 readConfig();
96 initColors(); 91 initColors();
97 92
98 // set font 93 // set font
99 QFont f = font(); 94 QFont f = font();
100 f.setPixelSize(18); 95 f.setPixelSize(18);
101 f.setBold( TRUE ); 96 f.setBold( TRUE );
102 setFont(f); 97 setFont(f);
103} 98}
104 99
105PiecesTable::~PiecesTable() 100PiecesTable::~PiecesTable()
106{ 101{
107 writeConfig(); 102 writeConfig();
108} 103}
109 104
110void PiecesTable::writeConfig() 105void PiecesTable::writeConfig()
111{ 106{
112 Config cfg("Fifteen"); 107 Config cfg("Fifteen");
113 cfg.setGroup("Game"); 108 cfg.setGroup("Game");
114 QStringList map; 109 QStringList map;
115 for (int i = 0; i < 16; i++) 110 for (int i = 0; i < 16; i++)
116 map.append( QString::number( _map[i] ) ); 111 map.append( QString::number( _map[i] ) );
117 cfg.writeEntry("Map", map, '-'); 112 cfg.writeEntry("Map", map, '-');
118 cfg.writeEntry("Randomized", _randomized ); 113 cfg.writeEntry("Randomized", _randomized );
119} 114}
120 115
121void PiecesTable::readConfig() 116void PiecesTable::readConfig()
122{ 117{
123 Config cfg("Fifteen"); 118 Config cfg("Fifteen");
124 cfg.setGroup("Game"); 119 cfg.setGroup("Game");
125 QStringList map = cfg.readListEntry("Map", '-'); 120 QStringList map = cfg.readListEntry("Map", '-');
126 _randomized = cfg.readBoolEntry( "Randomized", FALSE ); 121 _randomized = cfg.readBoolEntry( "Randomized", FALSE );
127 int i = 0; 122 int i = 0;
128 for ( QStringList::Iterator it = map.begin(); it != map.end(); ++it ) { 123 for ( QStringList::Iterator it = map.begin(); it != map.end(); ++it ) {
129 _map[i] = (*it).toInt(); 124 _map[i] = (*it).toInt();
130 i++; 125 i++;
131 if ( i > 15 ) break; 126 if ( i > 15 ) break;
132 } 127 }
diff --git a/noncore/games/go/gowidget.cpp b/noncore/games/go/gowidget.cpp
index cf89267..79820b1 100644
--- a/noncore/games/go/gowidget.cpp
+++ b/noncore/games/go/gowidget.cpp
@@ -1,134 +1,130 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "gowidget.h" 21#include "gowidget.h"
22 22
23#include <qpe/config.h> 23#include <qpe/config.h>
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25 25
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qpixmap.h>
28#include <qpe/qpetoolbar.h> 27#include <qpe/qpetoolbar.h>
29#include <qmenubar.h> 28#include <qmenubar.h>
30#include <qpopupmenu.h>
31#include <qaction.h> 29#include <qaction.h>
32#include <qapplication.h> //processEvents() 30#include <qapplication.h> //processEvents()
33#include <qlabel.h> 31#include <qlabel.h>
34 32
35//#include <stdio.h> 33//#include <stdio.h>
36 34
37#include "amigo.h"
38#include "goplayutils.h"
39 35
40static const enum bVal computer_color = BLACK; 36static const enum bVal computer_color = BLACK;
41 37
42static int current_handicap = 1; 38static int current_handicap = 1;
43 39
44static QBrush *goBrush; 40static QBrush *goBrush;
45//static QImage *newBlackStone; 41//static QImage *newBlackStone;
46//static QImage *blackStone; 42//static QImage *blackStone;
47//static QImage *whiteStone; 43//static QImage *whiteStone;
48static QPixmap *newBlackStone; 44static QPixmap *newBlackStone;
49static QPixmap *blackStone; 45static QPixmap *blackStone;
50static QPixmap *whiteStone; 46static QPixmap *whiteStone;
51 47
52static bool smallStones = FALSE; 48static bool smallStones = FALSE;
53 49
54GoMainWidget::GoMainWidget( QWidget *parent, const char* name, WFlags fl) : 50GoMainWidget::GoMainWidget( QWidget *parent, const char* name, WFlags fl) :
55 QMainWindow( parent, name, fl ) 51 QMainWindow( parent, name, fl )
56{ 52{
57 setToolBarsMovable( FALSE ); 53 setToolBarsMovable( FALSE );
58 GoWidget *go = new GoWidget(this); 54 GoWidget *go = new GoWidget(this);
59 55
60 setCentralWidget(go); 56 setCentralWidget(go);
61 toolbar = new QToolBar(this); 57 toolbar = new QToolBar(this);
62 toolbar->setHorizontalStretchable( TRUE ); 58 toolbar->setHorizontalStretchable( TRUE );
63 addToolBar(toolbar); 59 addToolBar(toolbar);
64 60
65 QMenuBar *mb = new QMenuBar( toolbar ); 61 QMenuBar *mb = new QMenuBar( toolbar );
66 mb->setMargin(0); 62 mb->setMargin(0);
67 QPopupMenu *file = new QPopupMenu( this ); 63 QPopupMenu *file = new QPopupMenu( this );
68 64
69 QAction *a = new QAction( tr( "New Game" ), QString::null, 0, this, 0 ); 65 QAction *a = new QAction( tr( "New Game" ), QString::null, 0, this, 0 );
70 connect( a, SIGNAL( activated() ), go, SLOT( newGame() ) ); 66 connect( a, SIGNAL( activated() ), go, SLOT( newGame() ) );
71 a->addTo( file ); 67 a->addTo( file );
72 68
73 a = new QAction( tr( "Pass" ), Resource::loadPixmap( "pass" ), QString::null, 0, this, 0 ); 69 a = new QAction( tr( "Pass" ), Resource::loadPixmap( "pass" ), QString::null, 0, this, 0 );
74 connect( a, SIGNAL( activated() ), go, SLOT( pass() ) ); 70 connect( a, SIGNAL( activated() ), go, SLOT( pass() ) );
75 a->addTo( file ); 71 a->addTo( file );
76 a->addTo( toolbar ); 72 a->addTo( toolbar );
77 73
78 74
79 a = new QAction( tr( "Resign" ), Resource::loadPixmap( "reset" ), QString::null, 0, this, 0 ); 75 a = new QAction( tr( "Resign" ), Resource::loadPixmap( "reset" ), QString::null, 0, this, 0 );
80 connect( a, SIGNAL( activated() ), go, SLOT( resign() ) ); 76 connect( a, SIGNAL( activated() ), go, SLOT( resign() ) );
81 a->addTo( file ); 77 a->addTo( file );
82 78
83 a = new QAction( tr( "Two player option" ), QString::null, 0, this, 0 ); 79 a = new QAction( tr( "Two player option" ), QString::null, 0, this, 0 );
84 a->setToggleAction( TRUE ); 80 a->setToggleAction( TRUE );
85 connect( a, SIGNAL( toggled(bool) ), go, SLOT( setTwoplayer(bool) ) ); 81 connect( a, SIGNAL( toggled(bool) ), go, SLOT( setTwoplayer(bool) ) );
86 a->addTo( file ); 82 a->addTo( file );
87 83
88 mb->insertItem( tr( "Game" ), file ); 84 mb->insertItem( tr( "Game" ), file );
89 85
90 QLabel *turnLabel = new QLabel( toolbar ); 86 QLabel *turnLabel = new QLabel( toolbar );
91 turnLabel->setBackgroundMode( PaletteButton ); 87 turnLabel->setBackgroundMode( PaletteButton );
92 connect( go, SIGNAL(showTurn(const QPixmap&)), 88 connect( go, SIGNAL(showTurn(const QPixmap&)),
93 turnLabel, SLOT(setPixmap(const QPixmap&)) ); 89 turnLabel, SLOT(setPixmap(const QPixmap&)) );
94 90
95 91
96 QLabel * scoreLabel = new QLabel( toolbar ); 92 QLabel * scoreLabel = new QLabel( toolbar );
97 scoreLabel->setBackgroundMode( PaletteButton ); 93 scoreLabel->setBackgroundMode( PaletteButton );
98 connect( go, SIGNAL(showScore(const QString&)), 94 connect( go, SIGNAL(showScore(const QString&)),
99 scoreLabel, SLOT(setText(const QString&)) ); 95 scoreLabel, SLOT(setText(const QString&)) );
100 96
101 toolbar->setStretchableWidget( scoreLabel ); 97 toolbar->setStretchableWidget( scoreLabel );
102 98
103 go->readConfig(); 99 go->readConfig();
104} 100}
105 101
106void GoMainWidget::resizeEvent( QResizeEvent * ) 102void GoMainWidget::resizeEvent( QResizeEvent * )
107{ 103{
108 //### this won't work because of the text label... 104 //### this won't work because of the text label...
109 /* 105 /*
110 if ( width() > height() ) 106 if ( width() > height() )
111 moveToolBar( toolbar, Left ); 107 moveToolBar( toolbar, Left );
112 else 108 else
113 moveToolBar( toolbar, Top ); 109 moveToolBar( toolbar, Top );
114 */ 110 */
115} 111}
116 112
117GoWidget *GoWidget::self = 0; 113GoWidget *GoWidget::self = 0;
118 114
119GoWidget::GoWidget( QWidget *parent, const char* name) : 115GoWidget::GoWidget( QWidget *parent, const char* name) :
120 QWidget( parent, name ) 116 QWidget( parent, name )
121{ 117{
122 if ( self ) 118 if ( self )
123 fatal( "Only one Go widget allowed" ); 119 fatal( "Only one Go widget allowed" );
124 self = this; 120 self = this;
125 twoplayer = FALSE; 121 twoplayer = FALSE;
126 122
127 123
128 d = bx = by = 1; 124 d = bx = by = 1;
129 125
130 QPixmap pix = Resource::loadPixmap( "go/pine" ); 126 QPixmap pix = Resource::loadPixmap( "go/pine" );
131 goBrush = new QBrush( black, pix ); 127 goBrush = new QBrush( black, pix );
132 /* 128 /*
133 QString fn = Resource::findPixmap("Go-black"); 129 QString fn = Resource::findPixmap("Go-black");
134 blackStone = new QImage( fn ); 130 blackStone = new QImage( fn );
diff --git a/noncore/games/go/main.cpp b/noncore/games/go/main.cpp
index f24e3c3..66f34ab 100644
--- a/noncore/games/go/main.cpp
+++ b/noncore/games/go/main.cpp
@@ -1,28 +1,27 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "gowidget.h" 21#include "gowidget.h"
22 22
23#include <qpe/qpeapplication.h>
24 23
25#include <opie/oapplicationfactory.h> 24#include <opie/oapplicationfactory.h>
26 25
27OPIE_EXPORT_APP( OApplicationFactory<GoMainWidget> ) 26OPIE_EXPORT_APP( OApplicationFactory<GoMainWidget> )
28 27
diff --git a/noncore/games/kbill/MCursor.cc b/noncore/games/kbill/MCursor.cc
index a3cb340..c581693 100644
--- a/noncore/games/kbill/MCursor.cc
+++ b/noncore/games/kbill/MCursor.cc
@@ -1,69 +1,64 @@
1/*************************************************************************** 1/***************************************************************************
2 MCursor.cc - description 2 MCursor.cc - description
3 ------------------- 3 -------------------
4 begin : Thu Dec 30 1999 4 begin : Thu Dec 30 1999
5 copyright : (C) 1999 by Jurrien Loonstra 5 copyright : (C) 1999 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl 6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17#include "MCursor.h" 17#include "MCursor.h"
18#include "objects.h"
19 18
20#include <qcursor.h>
21#include <qbitmap.h>
22#include <qwidget.h>
23#include <qstring.h>
24#ifdef KDEVER 19#ifdef KDEVER
25#include <kapp.h> 20#include <kapp.h>
26#include <kstandarddirs.h> 21#include <kstandarddirs.h>
27#endif 22#endif
28#include <iostream> 23#include <iostream>
29#include <qpe/resource.h> 24#include <qpe/resource.h>
30MCursor::~MCursor() { 25MCursor::~MCursor() {
31 delete cursor; 26 delete cursor;
32} 27}
33 28
34void MCursor::load(const char *name, int masked) { 29void MCursor::load(const char *name, int masked) {
35 30
36 #ifdef KDEVER 31 #ifdef KDEVER
37 QString file, mfile; 32 QString file, mfile;
38 KStandardDirs dirs; 33 KStandardDirs dirs;
39 34
40 35
41 file = dirs.findResource("data","kbill/bitmaps/" + QString::fromLocal8Bit(name) + ".xbm"); 36 file = dirs.findResource("data","kbill/bitmaps/" + QString::fromLocal8Bit(name) + ".xbm");
42 37
43 QBitmap bitmap, mask; 38 QBitmap bitmap, mask;
44 if (bitmap.load(file) == FALSE) { 39 if (bitmap.load(file) == FALSE) {
45 std::cerr << "cannot open " << file << std::endl; 40 std::cerr << "cannot open " << file << std::endl;
46 exit(1); 41 exit(1);
47 } 42 }
48 if (masked == SEP_MASK) { 43 if (masked == SEP_MASK) {
49 // mfile.sprintf ("%sbitmaps/%s_mask.xbm", (const char*)dir, name); 44 // mfile.sprintf ("%sbitmaps/%s_mask.xbm", (const char*)dir, name);
50 mfile = file = dirs.findResource("data","kbill/bitmaps/" + QString::fromLocal8Bit(name) + "_mask.xbm"); 45 mfile = file = dirs.findResource("data","kbill/bitmaps/" + QString::fromLocal8Bit(name) + "_mask.xbm");
51 if (mask.load(mfile) == FALSE) { 46 if (mask.load(mfile) == FALSE) {
52 std::cerr << "cannot open " << file << std::endl; 47 std::cerr << "cannot open " << file << std::endl;
53 exit(1); 48 exit(1);
54 } 49 }
55 } 50 }
56 else 51 else
57 mask = bitmap; 52 mask = bitmap;
58 #endif 53 #endif
59 54
60 QBitmap bitmap, mask; 55 QBitmap bitmap, mask;
61 bitmap = Resource::loadBitmap("kbill/bitmaps/" + QString::fromLocal8Bit(name)); 56 bitmap = Resource::loadBitmap("kbill/bitmaps/" + QString::fromLocal8Bit(name));
62 57
63 if (masked == SEP_MASK) 58 if (masked == SEP_MASK)
64 mask = bitmap = Resource::loadBitmap("kbill/bitmaps/" + QString::fromLocal8Bit(name) + "_mask.xbm"); 59 mask = bitmap = Resource::loadBitmap("kbill/bitmaps/" + QString::fromLocal8Bit(name) + "_mask.xbm");
65 else 60 else
66 mask = bitmap; 61 mask = bitmap;
67 cursor = new QCursor(bitmap, mask, bitmap.width() / 2, bitmap.height() / 2); 62 cursor = new QCursor(bitmap, mask, bitmap.width() / 2, bitmap.height() / 2);
68} 63}
69 64
diff --git a/noncore/games/kbill/Picture.cc b/noncore/games/kbill/Picture.cc
index fe0eff8..9d46257 100644
--- a/noncore/games/kbill/Picture.cc
+++ b/noncore/games/kbill/Picture.cc
@@ -1,72 +1,70 @@
1/*************************************************************************** 1/***************************************************************************
2 Picture.cc - description 2 Picture.cc - description
3 ------------------- 3 -------------------
4 begin : Thu Dec 30 1999 4 begin : Thu Dec 30 1999
5 copyright : (C) 1999 by Jurrien Loonstra 5 copyright : (C) 1999 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl 6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17#include "Picture.h" 17#include "Picture.h"
18#include "objects.h"
19 18
20#include <iostream> 19#include <iostream>
21 20
22#include <qstring.h>
23#include <qpe/resource.h> 21#include <qpe/resource.h>
24#ifdef KDEVER 22#ifdef KDEVER
25#include <kapp.h> 23#include <kapp.h>
26#include <kstandarddirs.h> 24#include <kstandarddirs.h>
27#include <kdebug.h> 25#include <kdebug.h>
28#endif 26#endif
29void Picture::load(const char *name, int index) { 27void Picture::load(const char *name, int index) {
30 //QString dir = KApplication::kde_datadir(), file; 28 //QString dir = KApplication::kde_datadir(), file;
31 // QString dir = locate("data",""),file; 29 // QString dir = locate("data",""),file;
32 // dir += "/kbill/"; 30 // dir += "/kbill/";
33 // if (index>=0) 31 // if (index>=0)
34 // file.sprintf ("%spixmaps/%s_%d.xpm", (const char *)dir, name, index); 32 // file.sprintf ("%spixmaps/%s_%d.xpm", (const char *)dir, name, index);
35 // else 33 // else
36 // file.sprintf("%spixmaps/%s.xpm", (const char *)dir, name); 34 // file.sprintf("%spixmaps/%s.xpm", (const char *)dir, name);
37#ifdef KDEVER 35#ifdef KDEVER
38 KStandardDirs dirs; 36 KStandardDirs dirs;
39 QString file; 37 QString file;
40 38
41 if (index>=0) { 39 if (index>=0) {
42 //kdDebug() << "Here"; 40 //kdDebug() << "Here";
43 QString sindex; 41 QString sindex;
44 sindex.setNum(index); 42 sindex.setNum(index);
45 // kdDebug() << "kbill/pixmaps/" + QString::fromLocal8Bit(name) + "_" + sindex + ".xpm"; 43 // kdDebug() << "kbill/pixmaps/" + QString::fromLocal8Bit(name) + "_" + sindex + ".xpm";
46 file = dirs.findResource("data","kbill/pixmaps/" + QString::fromLocal8Bit(name) + "_" + sindex + ".xpm"); 44 file = dirs.findResource("data","kbill/pixmaps/" + QString::fromLocal8Bit(name) + "_" + sindex + ".xpm");
47 } else { 45 } else {
48 file = dirs.findResource("data","kbill/pixmaps/" + QString::fromLocal8Bit(name) + ".xpm"); 46 file = dirs.findResource("data","kbill/pixmaps/" + QString::fromLocal8Bit(name) + ".xpm");
49 } 47 }
50 kdDebug() << file << std::endl; 48 kdDebug() << file << std::endl;
51 pix = new QPixmap(); 49 pix = new QPixmap();
52 if (pix->load(file) == FALSE) 50 if (pix->load(file) == FALSE)
53 std::cerr << "cannot open " << file << std::endl; 51 std::cerr << "cannot open " << file << std::endl;
54 width = pix->width(); 52 width = pix->width();
55 height = pix->height(); 53 height = pix->height();
56#endif 54#endif
57QString sindex; 55QString sindex;
58pix = new QPixmap(); 56pix = new QPixmap();
59sindex.setNum(index); 57sindex.setNum(index);
60if (index>=0) 58if (index>=0)
61pix->load(Resource::findPixmap("kbill/pixmaps/" + QString::fromLocal8Bit(name) +"_"+ sindex)); 59pix->load(Resource::findPixmap("kbill/pixmaps/" + QString::fromLocal8Bit(name) +"_"+ sindex));
62else 60else
63pix->load(Resource::findPixmap("kbill/pixmaps/" + QString::fromLocal8Bit(name))); 61pix->load(Resource::findPixmap("kbill/pixmaps/" + QString::fromLocal8Bit(name)));
64 62
65 width = pix->width(); 63 width = pix->width();
66 height = pix->height(); 64 height = pix->height();
67 65
68} 66}
69 67
70QPixmap* Picture::getPixmap() { 68QPixmap* Picture::getPixmap() {
71 return pix; 69 return pix;
72} 70}
diff --git a/noncore/games/kbill/UI.cpp b/noncore/games/kbill/UI.cpp
index 2afaf9b..611cebf 100644
--- a/noncore/games/kbill/UI.cpp
+++ b/noncore/games/kbill/UI.cpp
@@ -1,121 +1,118 @@
1/*************************************************************************** 1/***************************************************************************
2 UI.cc - description 2 UI.cc - description
3 ------------------- 3 -------------------
4 begin : Thu Dec 30 1999 4 begin : Thu Dec 30 1999
5 copyright : (C) 1999 by Jurrien Loonstra 5 copyright : (C) 1999 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl 6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17#include "kbill.h"
18#include "objects.h" 17#include "objects.h"
19#include "Strings.h" 18#include "Strings.h"
20#ifdef KDEVER 19#ifdef KDEVER
21#include <kapplication.h> 20#include <kapplication.h>
22#endif 21#endif
23#include <qpixmap.h>
24#include <qmessagebox.h> 22#include <qmessagebox.h>
25#include <qnamespace.h>
26 23
27#include "inputbox.h" 24#include "inputbox.h"
28 25
29/**************************/ 26/**************************/
30/* Timer control routines */ 27/* Timer control routines */
31/**************************/ 28/**************************/
32 29
33UI::~UI() { 30UI::~UI() {
34 paint.end(); 31 paint.end();
35 delete pix; 32 delete pix;
36} 33}
37 34
38void UI::restart_timer() { 35void UI::restart_timer() {
39 field->startTimer(); 36 field->startTimer();
40} 37}
41 38
42void UI::kill_timer() { 39void UI::kill_timer() {
43 field->stopTimer(); 40 field->stopTimer();
44} 41}
45 42
46/*******************/ 43/*******************/
47/* Window routines */ 44/* Window routines */
48/*******************/ 45/*******************/
49 46
50void UI::initialize(int *argc, char **argv) { 47void UI::initialize(int *argc, char **argv) {
51 #ifdef KDEVER 48 #ifdef KDEVER
52 app = new KApplication(*argc, argv, "kbill"); 49 app = new KApplication(*argc, argv, "kbill");
53 #endif 50 #endif
54 app = new QPEApplication(*argc, argv); 51 app = new QPEApplication(*argc, argv);
55} 52}
56 53
57void UI::graph_init() { 54void UI::graph_init() {
58 pix = new QPixmap(Game::scrwidth, Game::scrheight); 55 pix = new QPixmap(Game::scrwidth, Game::scrheight);
59 paint.begin(pix, field); 56 paint.begin(pix, field);
60 paint.setPen(QPen(Qt::black, 3)); 57 paint.setPen(QPen(Qt::black, 3));
61} 58}
62 59
63void UI::make_mainwin() { 60void UI::make_mainwin() {
64 main = new KBill(); 61 main = new KBill();
65 app->showMainWidget(main,true); 62 app->showMainWidget(main,true);
66 main->showMaximized(); 63 main->showMaximized();
67 field = main->getField(); 64 field = main->getField();
68} 65}
69 66
70void UI::popup_dialog (int dialog) { 67void UI::popup_dialog (int dialog) {
71 kill_timer(); 68 kill_timer();
72 switch (dialog) { 69 switch (dialog) {
73 case Game::ENDGAME: 70 case Game::ENDGAME:
74 QMessageBox::message(("Endgame"), QT_TR_NOOP(endgamestr)); 71 QMessageBox::message(("Endgame"), QT_TR_NOOP(endgamestr));
75 break; 72 break;
76 case Game::HIGHSCORE: 73 case Game::HIGHSCORE:
77 //QMessageBox::message(("HighScore"), highscorestr); 74 //QMessageBox::message(("HighScore"), highscorestr);
78 break; 75 break;
79 case Game::ENTERNAME: { 76 case Game::ENTERNAME: {
80 InputBox b(main, 0, ("Enter Name"), QT_TR_NOOP(enternamestr)); 77 InputBox b(main, 0, ("Enter Name"), QT_TR_NOOP(enternamestr));
81 bool state = b.exec() == 2; 78 bool state = b.exec() == 2;
82 char str[20], *nl; 79 char str[20], *nl;
83 strcpy(str, b.getText()); 80 strcpy(str, b.getText());
84 if (!str[0] || state) 81 if (!str[0] || state)
85 strcpy(str, "Anonymous"); 82 strcpy(str, "Anonymous");
86 else if ((nl = strchr(str, '\n'))) 83 else if ((nl = strchr(str, '\n')))
87 *nl = '\0'; 84 *nl = '\0';
88 if (strlen(str) > 20) 85 if (strlen(str) > 20)
89 str[20] = 0; /* truncate string if too long */ 86 str[20] = 0; /* truncate string if too long */
90 // scores.recalc(str); 87 // scores.recalc(str);
91 } 88 }
92 break; 89 break;
93 case Game::SCORE: 90 case Game::SCORE:
94 QMessageBox::message(("Score"), scorestr); 91 QMessageBox::message(("Score"), scorestr);
95 break; 92 break;
96 } 93 }
97 restart_timer(); 94 restart_timer();
98} 95}
99 96
100/*********************/ 97/*********************/
101/* Graphics routines */ 98/* Graphics routines */
102/*********************/ 99/*********************/
103 100
104void UI::set_cursor(int cursor) { 101void UI::set_cursor(int cursor) {
105 QCursor *cur; 102 QCursor *cur;
106 switch (cursor) { 103 switch (cursor) {
107 case Game::BUCKETC: 104 case Game::BUCKETC:
108 cur = bucket.cursor.cursor; 105 cur = bucket.cursor.cursor;
109 break; 106 break;
110 case Game::DOWNC: 107 case Game::DOWNC:
111 cur = downcursor.cursor; 108 cur = downcursor.cursor;
112 break; 109 break;
113 case Game::DEFAULTC: 110 case Game::DEFAULTC:
114 cur = defaultcursor.cursor; 111 cur = defaultcursor.cursor;
115 break; 112 break;
116 default: 113 default:
117 cur = OS.cursor[cursor].cursor; 114 cur = OS.cursor[cursor].cursor;
118 } 115 }
119 field->setCursor(*cur); 116 field->setCursor(*cur);
120} 117}
121 118
diff --git a/noncore/games/kbill/field.cpp b/noncore/games/kbill/field.cpp
index a1b3560..a974ab2 100644
--- a/noncore/games/kbill/field.cpp
+++ b/noncore/games/kbill/field.cpp
@@ -1,84 +1,83 @@
1/*************************************************************************** 1/***************************************************************************
2 field.cpp - description 2 field.cpp - description
3 ------------------- 3 -------------------
4 begin : Thu Dec 30 1999 4 begin : Thu Dec 30 1999
5 copyright : (C) 1999 by Jurrien Loonstra 5 copyright : (C) 1999 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl 6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include <qpainter.h>
19 18
20#include "objects.h" 19#include "objects.h"
21 20
22#include "field.h" 21#include "field.h"
23 22
24Field::Field(QWidget *parent, const char *name ) : QWidget(parent,name) { 23Field::Field(QWidget *parent, const char *name ) : QWidget(parent,name) {
25 setFixedSize(game.scrwidth, game.scrheight); 24 setFixedSize(game.scrwidth, game.scrheight);
26 setBackgroundColor(white); 25 setBackgroundColor(white);
27 timer = new QTimer(this); 26 timer = new QTimer(this);
28 27
29 playing = false; 28 playing = false;
30 29
31 connect(timer, SIGNAL(timeout()), SLOT(Timer())); 30 connect(timer, SIGNAL(timeout()), SLOT(Timer()));
32} 31}
33 32
34Field::~Field(){ 33Field::~Field(){
35 delete timer; 34 delete timer;
36} 35}
37 36
38void Field::setPixmap(QPixmap *pix) { 37void Field::setPixmap(QPixmap *pix) {
39 this->pix = pix; 38 this->pix = pix;
40} 39}
41 40
42// -------------------------------------------------------- 41// --------------------------------------------------------
43 42
44void Field::mousePressEvent(QMouseEvent *e){ 43void Field::mousePressEvent(QMouseEvent *e){
45 game.button_press(e->x(), e->y()); 44 game.button_press(e->x(), e->y());
46} 45}
47 46
48void Field::mouseReleaseEvent(QMouseEvent *e){ 47void Field::mouseReleaseEvent(QMouseEvent *e){
49 game.button_release(e->x(), e->y()); 48 game.button_release(e->x(), e->y());
50} 49}
51 50
52void Field::enterEvent(QEvent *) { 51void Field::enterEvent(QEvent *) {
53 if (playing && !timer->isActive()) { 52 if (playing && !timer->isActive()) {
54 playing = true; 53 playing = true;
55 timer->start(250, FALSE); 54 timer->start(250, FALSE);
56 } 55 }
57} 56}
58 57
59void Field::leaveEvent(QEvent *) { 58void Field::leaveEvent(QEvent *) {
60 if (timer->isActive() && playing) { 59 if (timer->isActive() && playing) {
61 playing = true; 60 playing = true;
62 timer->stop(); 61 timer->stop();
63 } 62 }
64} 63}
65 64
66void Field::stopTimer() { 65void Field::stopTimer() {
67 playing = false; 66 playing = false;
68 if (timer->isActive()) 67 if (timer->isActive())
69 timer->stop(); 68 timer->stop();
70} 69}
71 70
72void Field::startTimer() { 71void Field::startTimer() {
73 playing = true; 72 playing = true;
74 if (!timer->isActive()) 73 if (!timer->isActive())
75 timer->start(250, FALSE); 74 timer->start(250, FALSE);
76} 75}
77 76
78void Field::Timer(){ 77void Field::Timer(){
79 game.update(); 78 game.update();
80} 79}
81 80
82void Field::paintEvent(QPaintEvent *) { 81void Field::paintEvent(QPaintEvent *) {
83 bitBlt(this, 0, 0, pix); 82 bitBlt(this, 0, 0, pix);
84 } \ No newline at end of file 83 } \ No newline at end of file
diff --git a/noncore/games/kbill/inputbox.cpp b/noncore/games/kbill/inputbox.cpp
index b191ea8..5087fbb 100644
--- a/noncore/games/kbill/inputbox.cpp
+++ b/noncore/games/kbill/inputbox.cpp
@@ -1,51 +1,50 @@
1/*************************************************************************** 1/***************************************************************************
2 inputbox.cpp - description 2 inputbox.cpp - description
3 ------------------- 3 -------------------
4 begin : Sat Jan 1 2000 4 begin : Sat Jan 1 2000
5 copyright : (C) 2000 by Jurrien Loonstra 5 copyright : (C) 2000 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl 6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include "inputbox.h" 18#include "inputbox.h"
19#include <qdialog.h>
20InputBox::InputBox(QWidget *parent, const char *name, const char *caption, const char *text) : QDialog(parent, name, TRUE) { 19InputBox::InputBox(QWidget *parent, const char *name, const char *caption, const char *text) : QDialog(parent, name, TRUE) {
21 // setCaption(caption); 20 // setCaption(caption);
22// 21//
23 // question = new QLabel(this); 22 // question = new QLabel(this);
24 // question->setText(text); 23 // question->setText(text);
25 // question->setGeometry(10, 10, 240, 50); 24 // question->setGeometry(10, 10, 240, 50);
26// 25//
27 // input = new QLineEdit(this); 26 // input = new QLineEdit(this);
28// input->setGeometry(10, 60, 240, 30); 27// input->setGeometry(10, 60, 240, 30);
29 // input->setFocus(); 28 // input->setFocus();
30 // input->setMaxLength(19); 29 // input->setMaxLength(19);
31// 30//
32// ok = new QPushButton( "Ok", this ); 31// ok = new QPushButton( "Ok", this );
33// ok->setGeometry(10, 100, 100,30 ); 32// ok->setGeometry(10, 100, 100,30 );
34 // ok->setDefault(TRUE); 33 // ok->setDefault(TRUE);
35// connect( ok, SIGNAL(clicked()), SLOT(accept()) ); 34// connect( ok, SIGNAL(clicked()), SLOT(accept()) );
36// 35//
37// cancel = new QPushButton( "Cancel", this ); 36// cancel = new QPushButton( "Cancel", this );
38// cancel->setGeometry(150, 100, 100,30 ); 37// cancel->setGeometry(150, 100, 100,30 );
39// connect( cancel, SIGNAL(clicked()), SLOT(reject()) ); 38// connect( cancel, SIGNAL(clicked()), SLOT(reject()) );
40} 39}
41 40
42InputBox::~InputBox(){ 41InputBox::~InputBox(){
43 delete ok; 42 delete ok;
44 delete cancel; 43 delete cancel;
45 delete question; 44 delete question;
46 delete input; 45 delete input;
47} 46}
48 47
49QString InputBox::getText() const{ 48QString InputBox::getText() const{
50 return input->text(); 49 return input->text();
51} 50}
diff --git a/noncore/games/kbill/kbill.cpp b/noncore/games/kbill/kbill.cpp
index 18a6875..74d7c75 100644
--- a/noncore/games/kbill/kbill.cpp
+++ b/noncore/games/kbill/kbill.cpp
@@ -1,121 +1,117 @@
1/*************************************************************************** 1/***************************************************************************
2 kbill.cpp - description 2 kbill.cpp - description
3 ------------------- 3 -------------------
4 begin : Thu Dec 30 16:55:55 CET 1999 4 begin : Thu Dec 30 16:55:55 CET 1999
5 copyright : (C) 1999 by Jurrien Loonstra 5 copyright : (C) 1999 by Jurrien Loonstra
6 email : j.h.loonstra@st.hanze.nl 6 email : j.h.loonstra@st.hanze.nl
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include <qmessagebox.h> 18#include <qmessagebox.h>
19#include <qmultilinedit.h>
20#include <qmenubar.h> 19#include <qmenubar.h>
21#include <qtextbrowser.h> 20#include <qtextbrowser.h>
22#include <qfont.h>
23#include <qwidget.h>
24#include "kbill.h" 21#include "kbill.h"
25#include "inputbox.h"
26#include "helpdialog.h" 22#include "helpdialog.h"
27#include "objects.h" 23#include "objects.h"
28#include "Strings.h" 24#include "Strings.h"
29 25
30KBill::KBill() : QMainWindow() { 26KBill::KBill() : QMainWindow() {
31 setCaption(tr("kBill")); 27 setCaption(tr("kBill"));
32 file = new QPopupMenu(); 28 file = new QPopupMenu();
33 file->insertItem(tr("New game"), this, SLOT(NewGame())); 29 file->insertItem(tr("New game"), this, SLOT(NewGame()));
34 pauseid = file->insertItem(tr("Pause game"), this, SLOT(Pause())); 30 pauseid = file->insertItem(tr("Pause game"), this, SLOT(Pause()));
35 //these are dissabled until I fix them 31 //these are dissabled until I fix them
36 //file->insertItem(tr("Warp to level..."), this, SLOT(WarpTo())); 32 //file->insertItem(tr("Warp to level..."), this, SLOT(WarpTo()));
37 //file->insertItem(tr("View high scores"), this, SLOT(ViewHighScores())); 33 //file->insertItem(tr("View high scores"), this, SLOT(ViewHighScores()));
38 34
39 35
40 help = new QPopupMenu(); 36 help = new QPopupMenu();
41 help->insertItem(tr("Story of kBill"), this, SLOT(Story())); 37 help->insertItem(tr("Story of kBill"), this, SLOT(Story()));
42 help->insertItem(tr("Rules"), this, SLOT(Rules())); 38 help->insertItem(tr("Rules"), this, SLOT(Rules()));
43 39
44 40
45 menu = new QMenuBar(this); 41 menu = new QMenuBar(this);
46 menu->insertItem(tr("&File"), file); 42 menu->insertItem(tr("&File"), file);
47 menu->insertSeparator(); 43 menu->insertSeparator();
48 menu->insertItem(tr("&Help"), help); 44 menu->insertItem(tr("&Help"), help);
49 45
50 field = new Field(this); 46 field = new Field(this);
51 //setView(field); 47 //setView(field);
52 //setMainWidget(field); 48 //setMainWidget(field);
53 //setMenu(menu); 49 //setMenu(menu);
54} 50}
55 51
56KBill::~KBill() { 52KBill::~KBill() {
57} 53}
58 54
59Field* KBill::getField() { 55Field* KBill::getField() {
60 return field; 56 return field;
61} 57}
62 58
63// ----------------------------------------------------------------------- 59// -----------------------------------------------------------------------
64 60
65void KBill::Quit() { 61void KBill::Quit() {
66 field->stopTimer(); 62 field->stopTimer();
67 qApp->quit(); 63 qApp->quit();
68 64
69} 65}
70 66
71void KBill::About(){ 67void KBill::About(){
72 // field->stopTimer(); 68 // field->stopTimer();
73 // AboutBox about(this); 69 // AboutBox about(this);
74 // about.exec(); 70 // about.exec();
75 // field->startTimer(); 71 // field->startTimer();
76} 72}
77 73
78void KBill::NewGame() { 74void KBill::NewGame() {
79 field->stopTimer(); 75 field->stopTimer();
80 // if (KMsgBox::yesNo(this, i18n("New Game"), i18n(newgamestr), KMsgBox::QUESTION) == 1) 76 // if (KMsgBox::yesNo(this, i18n("New Game"), i18n(newgamestr), KMsgBox::QUESTION) == 1)
81 game.start(1); 77 game.start(1);
82 // else 78 // else
83 field->startTimer(); 79 field->startTimer();
84} 80}
85 81
86void KBill::Pause() { 82void KBill::Pause() {
87 field->stopTimer(); 83 field->stopTimer();
88 QMessageBox::message(tr("Pause Game"), tr(pausestr), 0); 84 QMessageBox::message(tr("Pause Game"), tr(pausestr), 0);
89 field->startTimer(); 85 field->startTimer();
90} 86}
91 87
92void KBill::WarpTo() { 88void KBill::WarpTo() {
93 /* field->stopTimer(); 89 /* field->stopTimer();
94 InputBox b(this, 0, "Warp To Level", tr(warpstr)); 90 InputBox b(this, 0, "Warp To Level", tr(warpstr));
95 bool status = b.exec() == 1; 91 bool status = b.exec() == 1;
96 field->startTimer(); 92 field->startTimer();
97 if (status) { 93 if (status) {
98 bool ok; 94 bool ok;
99 int level = b.getText().toUInt(&ok); 95 int level = b.getText().toUInt(&ok);
100 if (ok) { 96 if (ok) {
101 field->startTimer(); 97 field->startTimer();
102 game.warp_to_level(level); 98 game.warp_to_level(level);
103 return; 99 return;
104 } 100 }
105 }*/ 101 }*/
106} 102}
107 103
108void KBill::ViewHighScores() { 104void KBill::ViewHighScores() {
109 //ui.popup_dialog(Game::HIGHSCORE); 105 //ui.popup_dialog(Game::HIGHSCORE);
110} 106}
111 107
112void KBill::Story() { 108void KBill::Story() {
113 field->stopTimer(); 109 field->stopTimer();
114 HelpDialog *stryDialog = new HelpDialog(this,"helpdialog",1); 110 HelpDialog *stryDialog = new HelpDialog(this,"helpdialog",1);
115 QString stryString = tr("<b>The Story</b><p>Yet again, the fate of the world rests in your hands! An evil computer hacker, known only by his handle 'Bill', has created the ultimate computer virus. A virus so powerful that it has the power to transmute an ordinary computer into a toaster oven. (oooh!) 'Bill' has cloned himself into a billion-jillion micro-Bills. Their sole purpose is to deliver the nefarious virus, which has been cleverly disguised as a popular operating system. As System Administrator and Exterminator, your job is to keep Bill from succeeding at his task."); 111 QString stryString = tr("<b>The Story</b><p>Yet again, the fate of the world rests in your hands! An evil computer hacker, known only by his handle 'Bill', has created the ultimate computer virus. A virus so powerful that it has the power to transmute an ordinary computer into a toaster oven. (oooh!) 'Bill' has cloned himself into a billion-jillion micro-Bills. Their sole purpose is to deliver the nefarious virus, which has been cleverly disguised as a popular operating system. As System Administrator and Exterminator, your job is to keep Bill from succeeding at his task.");
116 stryDialog->setCaption(tr("The story of KBill")); 112 stryDialog->setCaption(tr("The story of KBill"));
117 stryDialog->TextBrowser1->setText(stryString); 113 stryDialog->TextBrowser1->setText(stryString);
118 stryDialog->resize(200,200); 114 stryDialog->resize(200,200);
119 stryDialog->show(); 115 stryDialog->show();
120 field->startTimer(); 116 field->startTimer();
121} 117}
diff --git a/noncore/games/kcheckers/kcheckers.cpp b/noncore/games/kcheckers/kcheckers.cpp
index 2eb37e5..a27dd18 100644
--- a/noncore/games/kcheckers/kcheckers.cpp
+++ b/noncore/games/kcheckers/kcheckers.cpp
@@ -1,99 +1,98 @@
1 1
2#include <qimage.h> 2#include <qimage.h>
3#include <qframe.h>
4#include <qlayout.h> 3#include <qlayout.h>
5#include <qmenubar.h> 4#include <qmenubar.h>
6#include <qtoolbar.h> 5#include <qtoolbar.h>
7#include <qpe/config.h> 6#include <qpe/config.h>
8#include <qwhatsthis.h> 7#include <qwhatsthis.h>
9#include <qtoolbutton.h> 8#include <qtoolbutton.h>
10#include <qmessagebox.h> 9#include <qmessagebox.h>
11#include <qapplication.h> 10#include <qapplication.h>
12 11
13#include "kcheckers.h" 12#include "kcheckers.h"
14#include "echeckers.h" 13#include "echeckers.h"
15#include "rcheckers.h" 14#include "rcheckers.h"
16 15
17#include "pics/logo.xpm" 16#include "pics/logo.xpm"
18#include "pics/undo.xpm" 17#include "pics/undo.xpm"
19#include "pics/exit.xpm" 18#include "pics/exit.xpm"
20#include "pics/help.xpm" 19#include "pics/help.xpm"
21#include "pics/wood1.xpm" 20#include "pics/wood1.xpm"
22#include "pics/wood2.xpm" 21#include "pics/wood2.xpm"
23#include "pics/wood3.xpm" 22#include "pics/wood3.xpm"
24#include "pics/green1.xpm" 23#include "pics/green1.xpm"
25#include "pics/green2.xpm" 24#include "pics/green2.xpm"
26#include "pics/green3.xpm" 25#include "pics/green3.xpm"
27#include "pics/marble1.xpm" 26#include "pics/marble1.xpm"
28#include "pics/marble2.xpm" 27#include "pics/marble2.xpm"
29#include "pics/marble3.xpm" 28#include "pics/marble3.xpm"
30#include "pics/biglogo.xpm" 29#include "pics/biglogo.xpm"
31#include "pics/man_black.xpm" 30#include "pics/man_black.xpm"
32#include "pics/man_white.xpm" 31#include "pics/man_white.xpm"
33#include "pics/king_black.xpm" 32#include "pics/king_black.xpm"
34#include "pics/king_white.xpm" 33#include "pics/king_white.xpm"
35#include "pics/contexthelp.xpm" 34#include "pics/contexthelp.xpm"
36 35
37 36
38QString KCheckers::enNumeration="1 2 3 4 5 6 7 8 9 1011121314151617181920212223242526272829303132"; 37QString KCheckers::enNumeration="1 2 3 4 5 6 7 8 9 1011121314151617181920212223242526272829303132";
39QString KCheckers::ruNumeration="B8D8F8H8A7C7E7G7B6D6F6H6A5C5E5G5B4D4F4H4A3C3E3G3B2D2F2H2A1C1E1G1"; 38QString KCheckers::ruNumeration="B8D8F8H8A7C7E7G7B6D6F6H6A5C5E5G5B4D4F4H4A3C3E3G3B2D2F2H2A1C1E1G1";
40 39
41const int KCheckers::t[]={6,7,8,9,11,12,13,14,17,18,19,20,22,23, 40const int KCheckers::t[]={6,7,8,9,11,12,13,14,17,18,19,20,22,23,
42 24,25,28,29,30,31,33,34,35,36,39,40,41,42,44,45,46,47}; 41 24,25,28,29,30,31,33,34,35,36,39,40,41,42,44,45,46,47};
43 42
44 43
45KCheckers::KCheckers(QWidget *p, const char* n, WFlags ) 44KCheckers::KCheckers(QWidget *p, const char* n, WFlags )
46 :QMainWindow(p,n,WStyle_DialogBorder) 45 :QMainWindow(p,n,WStyle_DialogBorder)
47{ 46{
48 setCaption(tr("KCheckers") ); 47 setCaption(tr("KCheckers") );
49 setIcon(QPixmap(biglogo_xpm)); 48 setIcon(QPixmap(biglogo_xpm));
50 49
51 setToolBarsMovable(false); 50 setToolBarsMovable(false);
52 51
53 // Make a menubar 52 // Make a menubar
54 53
55 gameMenu=new QPopupMenu; 54 gameMenu=new QPopupMenu;
56 CHECK_PTR(gameMenu); 55 CHECK_PTR(gameMenu);
57 56
58 gameMenu->insertItem(QPixmap(logo_xpm),tr("&New"),this,SLOT(newGame()),CTRL+Key_N); 57 gameMenu->insertItem(QPixmap(logo_xpm),tr("&New"),this,SLOT(newGame()),CTRL+Key_N);
59 gameMenu->insertSeparator(); 58 gameMenu->insertSeparator();
60 undoID=gameMenu->insertItem(QPixmap(undo_xpm),tr("&Undo Move"),this,SLOT(undoMove()),CTRL+Key_Z); 59 undoID=gameMenu->insertItem(QPixmap(undo_xpm),tr("&Undo Move"),this,SLOT(undoMove()),CTRL+Key_Z);
61 gameMenu->insertSeparator(); 60 gameMenu->insertSeparator();
62 gameMenu->insertItem(QPixmap(exit_xpm),tr("&Quit"),qApp,SLOT(closeAllWindows()),CTRL+Key_Q); 61 gameMenu->insertItem(QPixmap(exit_xpm),tr("&Quit"),qApp,SLOT(closeAllWindows()),CTRL+Key_Q);
63 62
64 skillMenu=new QPopupMenu; 63 skillMenu=new QPopupMenu;
65 CHECK_PTR(skillMenu); 64 CHECK_PTR(skillMenu);
66 65
67 skillMenu->insertItem(tr("&Beginner"),this,SLOT(setSkillBeginner()),CTRL+Key_1,BEGINNER); 66 skillMenu->insertItem(tr("&Beginner"),this,SLOT(setSkillBeginner()),CTRL+Key_1,BEGINNER);
68 skillMenu->insertItem(tr("&Novice"), this,SLOT(setSkillNovice()), CTRL+Key_2,NOVICE); 67 skillMenu->insertItem(tr("&Novice"), this,SLOT(setSkillNovice()), CTRL+Key_2,NOVICE);
69 skillMenu->insertItem(tr("&Average"), this,SLOT(setSkillAverage()), CTRL+Key_3,AVERAGE); 68 skillMenu->insertItem(tr("&Average"), this,SLOT(setSkillAverage()), CTRL+Key_3,AVERAGE);
70 skillMenu->insertItem(tr("&Good"), this,SLOT(setSkillGood()), CTRL+Key_4,GOOD); 69 skillMenu->insertItem(tr("&Good"), this,SLOT(setSkillGood()), CTRL+Key_4,GOOD);
71 skillMenu->insertItem(tr("&Expert"), this,SLOT(setSkillExpert()), CTRL+Key_5,EXPERT); 70 skillMenu->insertItem(tr("&Expert"), this,SLOT(setSkillExpert()), CTRL+Key_5,EXPERT);
72 skillMenu->insertItem(tr("&Master"), this,SLOT(setSkillMaster()), CTRL+Key_6,MASTER); 71 skillMenu->insertItem(tr("&Master"), this,SLOT(setSkillMaster()), CTRL+Key_6,MASTER);
73 72
74 optionsMenu=new QPopupMenu; 73 optionsMenu=new QPopupMenu;
75 CHECK_PTR(optionsMenu); 74 CHECK_PTR(optionsMenu);
76 75
77 numID=optionsMenu->insertItem(tr("&Show Numeration"),this,SLOT(showNumeration())); 76 numID=optionsMenu->insertItem(tr("&Show Numeration"),this,SLOT(showNumeration()));
78 optionsMenu->insertSeparator(); 77 optionsMenu->insertSeparator();
79 optionsMenu->insertItem(tr("&English Rules"),this,SLOT(setRulesEnglish()),0,ENGLISH); 78 optionsMenu->insertItem(tr("&English Rules"),this,SLOT(setRulesEnglish()),0,ENGLISH);
80 optionsMenu->insertItem(tr("&Russian Rules"),this,SLOT(setRulesRussian()),0,RUSSIAN); 79 optionsMenu->insertItem(tr("&Russian Rules"),this,SLOT(setRulesRussian()),0,RUSSIAN);
81 optionsMenu->insertSeparator(); 80 optionsMenu->insertSeparator();
82 optionsMenu->insertItem(tr("&Green Board"), this,SLOT(setPatternGreen()), 0,GREEN); 81 optionsMenu->insertItem(tr("&Green Board"), this,SLOT(setPatternGreen()), 0,GREEN);
83 optionsMenu->insertItem(tr("&Marble Board"),this,SLOT(setPatternMarble()),0,MARBLE); 82 optionsMenu->insertItem(tr("&Marble Board"),this,SLOT(setPatternMarble()),0,MARBLE);
84 optionsMenu->insertItem(tr("&Wooden Board"),this,SLOT(setPatternWooden()),0,WOODEN); 83 optionsMenu->insertItem(tr("&Wooden Board"),this,SLOT(setPatternWooden()),0,WOODEN);
85 84
86 QPopupMenu* helpMenu=new QPopupMenu; 85 QPopupMenu* helpMenu=new QPopupMenu;
87 CHECK_PTR(helpMenu); 86 CHECK_PTR(helpMenu);
88 87
89 helpMenu->insertItem(QPixmap(contexthelp_xpm),tr("What's This"),this,SLOT(whatsThis()),SHIFT+Key_F1); 88 helpMenu->insertItem(QPixmap(contexthelp_xpm),tr("What's This"),this,SLOT(whatsThis()),SHIFT+Key_F1);
90 helpMenu->insertItem(QPixmap(help_xpm),tr("&Rules of Play"),this,SLOT(help()),Key_F1); 89 helpMenu->insertItem(QPixmap(help_xpm),tr("&Rules of Play"),this,SLOT(help()),Key_F1);
91 helpMenu->insertSeparator(); 90 helpMenu->insertSeparator();
92 helpMenu->insertItem(QPixmap(logo_xpm),tr("&About KCheckers"),this,SLOT(about())); 91 helpMenu->insertItem(QPixmap(logo_xpm),tr("&About KCheckers"),this,SLOT(about()));
93 helpMenu->insertItem(tr("About &Qt"),this,SLOT(aboutQt())); 92 helpMenu->insertItem(tr("About &Qt"),this,SLOT(aboutQt()));
94 93
95 QToolBar* menuToolBar=new QToolBar(this); 94 QToolBar* menuToolBar=new QToolBar(this);
96 CHECK_PTR(menuToolBar); 95 CHECK_PTR(menuToolBar);
97 QMenuBar* menuBar=new QMenuBar(menuToolBar); 96 QMenuBar* menuBar=new QMenuBar(menuToolBar);
98 CHECK_PTR(menuBar); 97 CHECK_PTR(menuBar);
99 98
diff --git a/noncore/games/kcheckers/main.cpp b/noncore/games/kcheckers/main.cpp
index 6ac570a..e22dbcc 100644
--- a/noncore/games/kcheckers/main.cpp
+++ b/noncore/games/kcheckers/main.cpp
@@ -1,10 +1,8 @@
1 1
2#include <qpe/qpeapplication.h>
3#include <qfont.h>
4 2
5#include "kcheckers.h" 3#include "kcheckers.h"
6#include <opie/oapplicationfactory.h> 4#include <opie/oapplicationfactory.h>
7 5
8OPIE_EXPORT_APP( OApplicationFactory<KCheckers> ) 6OPIE_EXPORT_APP( OApplicationFactory<KCheckers> )
9 7
10 8
diff --git a/noncore/games/kpacman/board.cpp b/noncore/games/kpacman/board.cpp
index f95f699..f82b5f9 100644
--- a/noncore/games/kpacman/board.cpp
+++ b/noncore/games/kpacman/board.cpp
@@ -1,106 +1,103 @@
1 1
2#include "portable.h"
3 2
4#if defined( KDE2_PORT ) 3#if defined( KDE2_PORT )
5#include <kapp.h> 4#include <kapp.h>
6#include <klocale.h> 5#include <klocale.h>
7#endif 6#endif
8 7
9#include <qrect.h>
10#include <qregexp.h>
11#include <qmessagebox.h> 8#include <qmessagebox.h>
12#include <qfile.h> 9#include <qfile.h>
13#include <qtextstream.h> 10#include <qtextstream.h>
14 11
15#include "board.h" 12#include "board.h"
16#include "bitmaps.h" 13#include "bitmaps.h"
17 14
18Board::Board(int size) : QArray<int> (size) 15Board::Board(int size) : QArray<int> (size)
19{ 16{
20 sz = size; // set size of board 17 sz = size; // set size of board
21 18
22 map = ""; 19 map = "";
23 mapName = ""; // no map loaded so far 20 mapName = ""; // no map loaded so far
24 21
25 init(None); // initialize varibales 22 init(None); // initialize varibales
26} 23}
27 24
28void Board::init(Image image, QString levelName) 25void Board::init(Image image, QString levelName)
29{ 26{
30 prisonEntry = OUT; 27 prisonEntry = OUT;
31 prisonExit = OUT; 28 prisonExit = OUT;
32 fruitHome = OUT; 29 fruitHome = OUT;
33 fruitPosition = OUT; 30 fruitPosition = OUT;
34 pacmanHome = OUT; 31 pacmanHome = OUT;
35 pacmanPosition = OUT; 32 pacmanPosition = OUT;
36 for (int m = 0; m < 8; m++) { 33 for (int m = 0; m < 8; m++) {
37 monsterHome[m] = OUT; 34 monsterHome[m] = OUT;
38 monsterPosition[m] = OUT; 35 monsterPosition[m] = OUT;
39 } 36 }
40 for (int e = 0; e < 8; e++) { 37 for (int e = 0; e < 8; e++) {
41 energizerPosition[e] = OUT; 38 energizerPosition[e] = OUT;
42 } 39 }
43 for (int e = 0; e < 8; e++) { 40 for (int e = 0; e < 8; e++) {
44 tunnelPosition[e] = OUT; 41 tunnelPosition[e] = OUT;
45 } 42 }
46 43
47 fill(0); 44 fill(0);
48 numPoints = 0; 45 numPoints = 0;
49 numEnergizers = 0; 46 numEnergizers = 0;
50 numMonsters = 0; 47 numMonsters = 0;
51 numTunnels = 0; 48 numTunnels = 0;
52 49
53 if (!levelName.isNull() && !levelName.isEmpty()) 50 if (!levelName.isNull() && !levelName.isEmpty())
54 if (mapName == levelName) 51 if (mapName == levelName)
55 image = File; 52 image = File;
56 else { 53 else {
57 QFile levelFile(levelName); 54 QFile levelFile(levelName);
58 if (!levelFile.open(IO_ReadOnly)) { 55 if (!levelFile.open(IO_ReadOnly)) {
59 56
60 QString msg = "The levelmap could not be constructed.\n\n" 57 QString msg = "The levelmap could not be constructed.\n\n"
61 "The file '@LEVELNAME@' does not exist,\n" 58 "The file '@LEVELNAME@' does not exist,\n"
62 "or could not be opened for reading."; 59 "or could not be opened for reading.";
63 msg.replace(QRegExp("@LEVELNAME@"), levelName); 60 msg.replace(QRegExp("@LEVELNAME@"), levelName);
64 // QMessageBox::information(0, tr("Initialization Error"), msg); 61 // QMessageBox::information(0, tr("Initialization Error"), msg);
65 printf("%s\n", msg.data()); 62 printf("%s\n", msg.data());
66 } else { 63 } else {
67 map.fill(' ', BoardHeight*BoardWidth); 64 map.fill(' ', BoardHeight*BoardWidth);
68 int height = 0; 65 int height = 0;
69 66
70 QTextStream levelStream(&levelFile); 67 QTextStream levelStream(&levelFile);
71 while (!levelStream.eof() && height < BoardHeight) { 68 while (!levelStream.eof() && height < BoardHeight) {
72 QString line = levelStream.readLine(); 69 QString line = levelStream.readLine();
73 70
74 if (line.find(QRegExp("^ *;")) == -1) { 71 if (line.find(QRegExp("^ *;")) == -1) {
75 72
76 line.replace(QRegExp(";.*"), ""); // strip off comments 73 line.replace(QRegExp(";.*"), ""); // strip off comments
77 line.replace(QRegExp("\" *$"), ""); // strip off trailing " 74 line.replace(QRegExp("\" *$"), ""); // strip off trailing "
78 line.replace(QRegExp("^ *\""), ""); // strip off leading " 75 line.replace(QRegExp("^ *\""), ""); // strip off leading "
79 76
80 map.replace(height*BoardWidth, 77 map.replace(height*BoardWidth,
81 (line.length() > BoardWidth) ? BoardWidth : line.length(), 78 (line.length() > BoardWidth) ? BoardWidth : line.length(),
82 line.data()); 79 line.data());
83 80
84 height++; 81 height++;
85 } 82 }
86 } 83 }
87 mapName = levelName; 84 mapName = levelName;
88 levelFile.close(); 85 levelFile.close();
89 image = File; 86 image = File;
90 } 87 }
91 } 88 }
92 89
93 switch (image) { 90 switch (image) {
94 case Intro : // setup(demo_bits); 91 case Intro : // setup(demo_bits);
95 break; 92 break;
96 case Demo : setup(demo_bits); 93 case Demo : setup(demo_bits);
97 break; 94 break;
98 case Level : setup(demo_bits); 95 case Level : setup(demo_bits);
99 break; 96 break;
100 case File : setup((uchar *) map.data()); 97 case File : setup((uchar *) map.data());
101 break; 98 break;
102 default : break; 99 default : break;
103 } 100 }
104} 101}
105 102
106void Board::setup(const uchar *buf) 103void Board::setup(const uchar *buf)
diff --git a/noncore/games/kpacman/keys.cpp b/noncore/games/kpacman/keys.cpp
index 07ce135..5200bc2 100644
--- a/noncore/games/kpacman/keys.cpp
+++ b/noncore/games/kpacman/keys.cpp
@@ -1,121 +1,116 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <kapp.h> 5#include <kapp.h>
6#include <kconfig.h> 6#include <kconfig.h>
7#include <klocale.h> 7#include <klocale.h>
8#include <kstddirs.h> 8#include <kstddirs.h>
9#include <kaccel.h> 9#include <kaccel.h>
10 10
11#include <keys.h> 11#include <keys.h>
12#include <keys.moc> 12#include <keys.moc>
13#elif defined( QPE_PORT ) 13#elif defined( QPE_PORT )
14#include <qaccel.h> 14#include <qaccel.h>
15#include <qpe/qpeapplication.h> 15#include <qpe/qpeapplication.h>
16#include <qpe/config.h> 16#include <qpe/config.h>
17#include "keys.h" 17#include "keys.h"
18#endif 18#endif
19 19
20#include <qpushbt.h> 20#include <qpushbt.h>
21#include <qlabel.h>
22#include <qframe.h>
23#include <qkeycode.h>
24#include <qpixmap.h>
25#include <qstring.h>
26 21
27Keys::Keys( QWidget *parent, const char *name) 22Keys::Keys( QWidget *parent, const char *name)
28 : QDialog( parent, name, TRUE ) 23 : QDialog( parent, name, TRUE )
29{ 24{
30 //KStandardDirs *dirs = KGlobal::dirs(); 25 //KStandardDirs *dirs = KGlobal::dirs();
31 26
32 QPushButton *okButton = new QPushButton(this); 27 QPushButton *okButton = new QPushButton(this);
33 okButton->setText(tr("Ok")); 28 okButton->setText(tr("Ok"));
34 okButton->setFixedSize(okButton->size()); 29 okButton->setFixedSize(okButton->size());
35 connect( okButton, SIGNAL(clicked()),this, SLOT(ok()) ); 30 connect( okButton, SIGNAL(clicked()),this, SLOT(ok()) );
36 okButton->move(20,210); 31 okButton->move(20,210);
37 32
38 QPushButton *defaultButton = new QPushButton(this); 33 QPushButton *defaultButton = new QPushButton(this);
39 defaultButton->setText(tr("Defaults")); 34 defaultButton->setText(tr("Defaults"));
40 defaultButton->setFixedSize(defaultButton->size()); 35 defaultButton->setFixedSize(defaultButton->size());
41 connect( defaultButton, SIGNAL(clicked()),this, SLOT(defaults()) ); 36 connect( defaultButton, SIGNAL(clicked()),this, SLOT(defaults()) );
42 defaultButton->move(140,210); 37 defaultButton->move(140,210);
43 38
44 QPushButton *cancelButton = new QPushButton(this); 39 QPushButton *cancelButton = new QPushButton(this);
45 cancelButton->setText(tr("Cancel")); 40 cancelButton->setText(tr("Cancel"));
46 cancelButton->setFixedSize(cancelButton->size()); 41 cancelButton->setFixedSize(cancelButton->size());
47 connect( cancelButton, SIGNAL(clicked()),this, SLOT(reject()) ); 42 connect( cancelButton, SIGNAL(clicked()),this, SLOT(reject()) );
48 cancelButton->move(260,210); 43 cancelButton->move(260,210);
49 44
50 QFrame *separator = new QFrame(this); 45 QFrame *separator = new QFrame(this);
51 separator->setFrameStyle( QFrame::HLine | QFrame::Sunken ); 46 separator->setFrameStyle( QFrame::HLine | QFrame::Sunken );
52 separator->setGeometry( 20, 190, 340, 4 ); 47 separator->setGeometry( 20, 190, 340, 4 );
53 48
54 for ( int x = 0; x < 4; x++) { 49 for ( int x = 0; x < 4; x++) {
55 QLabel *l = new QLabel(this); 50 QLabel *l = new QLabel(this);
56 l->setAlignment(AlignCenter); 51 l->setAlignment(AlignCenter);
57 labels[x] = l; 52 labels[x] = l;
58 } 53 }
59 54
60 labels[0]->setGeometry(120, 20, 140, 20 ); 55 labels[0]->setGeometry(120, 20, 140, 20 );
61 labels[1]->setGeometry(120,160, 140, 20 ); 56 labels[1]->setGeometry(120,160, 140, 20 );
62 labels[2]->setGeometry( 20, 92, 100, 20 ); 57 labels[2]->setGeometry( 20, 92, 100, 20 );
63 labels[3]->setGeometry(265, 92, 100, 20 ); 58 labels[3]->setGeometry(265, 92, 100, 20 );
64 59
65 QString pixPath; 60 QString pixPath;
66 61
67 QPushButton *up = new QPushButton(this); 62 QPushButton *up = new QPushButton(this);
68 pixPath = FIND_APP_DATA( "pics/up.xpm" ); 63 pixPath = FIND_APP_DATA( "pics/up.xpm" );
69 up->setPixmap( QPixmap(pixPath)); 64 up->setPixmap( QPixmap(pixPath));
70 up->setFixedSize(up->pixmap()->size()); 65 up->setFixedSize(up->pixmap()->size());
71 connect( up, SIGNAL(clicked()),this, SLOT(butUp()) ); 66 connect( up, SIGNAL(clicked()),this, SLOT(butUp()) );
72 up->move(180, 50); 67 up->move(180, 50);
73 68
74 QPushButton *down = new QPushButton(this); 69 QPushButton *down = new QPushButton(this);
75 pixPath = FIND_APP_DATA( "pics/down.xpm"); 70 pixPath = FIND_APP_DATA( "pics/down.xpm");
76 down->setPixmap( QPixmap(pixPath)); 71 down->setPixmap( QPixmap(pixPath));
77 down->setFixedSize(down->pixmap()->size()); 72 down->setFixedSize(down->pixmap()->size());
78 connect( down, SIGNAL(clicked()),this, SLOT(butDown()) ); 73 connect( down, SIGNAL(clicked()),this, SLOT(butDown()) );
79 down->move(180, 130); 74 down->move(180, 130);
80 75
81 QPushButton *left = new QPushButton(this); 76 QPushButton *left = new QPushButton(this);
82 pixPath = FIND_APP_DATA( "pics/left.xpm"); 77 pixPath = FIND_APP_DATA( "pics/left.xpm");
83 left->setPixmap( QPixmap(pixPath)); 78 left->setPixmap( QPixmap(pixPath));
84 left->setFixedSize(left->pixmap()->size()); 79 left->setFixedSize(left->pixmap()->size());
85 connect( left, SIGNAL(clicked()),this, SLOT(butLeft()) ); 80 connect( left, SIGNAL(clicked()),this, SLOT(butLeft()) );
86 left->move(140, 90); 81 left->move(140, 90);
87 82
88 QPushButton *right = new QPushButton(this); 83 QPushButton *right = new QPushButton(this);
89 pixPath = FIND_APP_DATA( "pics/right.xpm"); 84 pixPath = FIND_APP_DATA( "pics/right.xpm");
90 right->setPixmap( QPixmap(pixPath)); 85 right->setPixmap( QPixmap(pixPath));
91 right->setFixedSize(right->pixmap()->size()); 86 right->setFixedSize(right->pixmap()->size());
92 connect( right, SIGNAL(clicked()),this, SLOT(butRight()) ); 87 connect( right, SIGNAL(clicked()),this, SLOT(butRight()) );
93 right->move(220, 90); 88 right->move(220, 90);
94 89
95 90
96 setCaption(tr("Change Direction Keys")); 91 setCaption(tr("Change Direction Keys"));
97 setFixedSize(380, 260); 92 setFixedSize(380, 260);
98 lab = 0; 93 lab = 0;
99 init(); 94 init();
100} 95}
101 96
102void Keys::keyPressEvent( QKeyEvent *e ) 97void Keys::keyPressEvent( QKeyEvent *e )
103{ 98{
104 uint kCode = e->key() & ~(SHIFT | CTRL | ALT); 99 uint kCode = e->key() & ~(SHIFT | CTRL | ALT);
105 QString string = KAccel::keyToString(kCode); 100 QString string = KAccel::keyToString(kCode);
106 101
107 if (lab != 0) { 102 if (lab != 0) {
108 if ( string.isNull() ) 103 if ( string.isNull() )
109 lab->setText(tr("Undefined key")); 104 lab->setText(tr("Undefined key"));
110 else 105 else
111 lab->setText(string); 106 lab->setText(string);
112 } 107 }
113 else if ( lab == 0 && e->key() == Key_Escape) 108 else if ( lab == 0 && e->key() == Key_Escape)
114 reject(); 109 reject();
115} 110}
116 111
117void Keys::butUp() 112void Keys::butUp()
118{ 113{
119 getKey(0); 114 getKey(0);
120} 115}
121 116
diff --git a/noncore/games/kpacman/kpacman.cpp b/noncore/games/kpacman/kpacman.cpp
index df27c76..be2e46d 100644
--- a/noncore/games/kpacman/kpacman.cpp
+++ b/noncore/games/kpacman/kpacman.cpp
@@ -1,115 +1,110 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <kpacman.h> 5#include <kpacman.h>
6#include <kpacman.moc> 6#include <kpacman.moc>
7#include <kcolordlg.h> 7#include <kcolordlg.h>
8#elif defined( QPE_PORT ) 8#elif defined( QPE_PORT )
9#include <qmenubar.h> 9#include <qmenubar.h>
10#include <qpe/config.h> 10#include <qpe/config.h>
11#include <qapplication.h> 11#include <qapplication.h>
12#include "kpacman.h" 12#include "kpacman.h"
13#endif 13#endif
14 14
15#include <qkeycode.h>
16#include <qcolor.h>
17#include <qstring.h>
18#include <qpopmenu.h>
19#include <qmsgbox.h>
20 15
21Kpacman::Kpacman(QWidget *parent, const char *name) 16Kpacman::Kpacman(QWidget *parent, const char *name)
22 : KTMainWindow(parent, name) 17 : KTMainWindow(parent, name)
23{ 18{
24 schemesPopup = new QList<QPopupMenu>; 19 schemesPopup = new QList<QPopupMenu>;
25 schemesPopup->setAutoDelete(TRUE); 20 schemesPopup->setAutoDelete(TRUE);
26 21
27 menu(); 22 menu();
28 23
29 m_view = new QWidget( this, "m_view" ); 24 m_view = new QWidget( this, "m_view" );
30 m_view->setBackgroundColor( black ); 25 m_view->setBackgroundColor( black );
31 m_layout = new QGridLayout( m_view ); 26 m_layout = new QGridLayout( m_view );
32 m_layout->setMargin( 7 ); 27 m_layout->setMargin( 7 );
33 28
34 view = new KpacmanWidget( this, QString(name)+"widget"); 29 view = new KpacmanWidget( this, QString(name)+"widget");
35 m_layout->addWidget( view, 0, 0 ); 30 m_layout->addWidget( view, 0, 0 );
36 31
37 setCaption( tr("KPacman") ); 32 setCaption( tr("KPacman") );
38 33
39 view->referee->setFocus(); 34 view->referee->setFocus();
40 35
41 connect(view->referee, SIGNAL(setScore(int, int)), 36 connect(view->referee, SIGNAL(setScore(int, int)),
42 view->score, SLOT(setScore(int, int))); 37 view->score, SLOT(setScore(int, int)));
43 connect(view->referee, SIGNAL(setPoints(int)), 38 connect(view->referee, SIGNAL(setPoints(int)),
44 view->score, SLOT(set(int))); 39 view->score, SLOT(set(int)));
45 connect(view->referee, SIGNAL(setLifes(int)), 40 connect(view->referee, SIGNAL(setLifes(int)),
46 view->status, SLOT(setLifes(int))); 41 view->status, SLOT(setLifes(int)));
47 connect(view->referee, SIGNAL(setLevel(int)), 42 connect(view->referee, SIGNAL(setLevel(int)),
48 view->status, SLOT(setLevel(int))); 43 view->status, SLOT(setLevel(int)));
49 connect(view->referee, SIGNAL(forcedHallOfFame(bool)), 44 connect(view->referee, SIGNAL(forcedHallOfFame(bool)),
50 this, SLOT(forcedHallOfFame(bool))); 45 this, SLOT(forcedHallOfFame(bool)));
51 connect(view->referee, SIGNAL(togglePaused()), this, SLOT(togglePaused())); 46 connect(view->referee, SIGNAL(togglePaused()), this, SLOT(togglePaused()));
52 connect(view->referee, SIGNAL(toggleNew()), this, SLOT(toggleNew())); 47 connect(view->referee, SIGNAL(toggleNew()), this, SLOT(toggleNew()));
53 48
54 connect(view->score, SIGNAL(toggleNew()), this, SLOT(toggleNew())); 49 connect(view->score, SIGNAL(toggleNew()), this, SLOT(toggleNew()));
55 connect(view->score, SIGNAL(forcedHallOfFame(bool)), 50 connect(view->score, SIGNAL(forcedHallOfFame(bool)),
56 this, SLOT(forcedHallOfFame(bool))); 51 this, SLOT(forcedHallOfFame(bool)));
57 52
58 APP_CONFIG_BEGIN( cfg ); 53 APP_CONFIG_BEGIN( cfg );
59 focusOutPause = !cfg->readBoolEntry("FocusOutPause", TRUE); 54 focusOutPause = !cfg->readBoolEntry("FocusOutPause", TRUE);
60 focusInContinue = !cfg->readBoolEntry("FocusInContinue", TRUE); 55 focusInContinue = !cfg->readBoolEntry("FocusInContinue", TRUE);
61 hideMouseCursor = !cfg->readBoolEntry("HideMouseCursor", TRUE); 56 hideMouseCursor = !cfg->readBoolEntry("HideMouseCursor", TRUE);
62 APP_CONFIG_END( cfg ); 57 APP_CONFIG_END( cfg );
63 58
64 toggleFocusOutPause(); 59 toggleFocusOutPause();
65 toggleFocusInContinue(); 60 toggleFocusInContinue();
66 toggleHideMouseCursor(); 61 toggleHideMouseCursor();
67 62
68 setCentralWidget( m_view ); 63 setCentralWidget( m_view );
69} 64}
70 65
71Kpacman::~Kpacman() 66Kpacman::~Kpacman()
72{ 67{
73 /* APP_CONFIG_BEGIN( cfg ); 68 /* APP_CONFIG_BEGIN( cfg );
74 cfg->writeEntry("FocusOutPause", focusOutPause); 69 cfg->writeEntry("FocusOutPause", focusOutPause);
75 cfg->writeEntry("FocusInContinue", focusInContinue); 70 cfg->writeEntry("FocusInContinue", focusInContinue);
76 cfg->writeEntry("HideMouseCursor", hideMouseCursor); 71 cfg->writeEntry("HideMouseCursor", hideMouseCursor);
77 APP_CONFIG_END( cfg ); 72 APP_CONFIG_END( cfg );
78 */ 73 */
79 delete _menuBar; 74 delete _menuBar;
80} 75}
81 76
82void Kpacman::menu() 77void Kpacman::menu()
83{ 78{
84 gamePopup = new QPopupMenu(); 79 gamePopup = new QPopupMenu();
85 CHECK_PTR( gamePopup ); 80 CHECK_PTR( gamePopup );
86 newID = gamePopup->insertItem(tr("&New"), this, SLOT(newKpacman()),Key_F2); 81 newID = gamePopup->insertItem(tr("&New"), this, SLOT(newKpacman()),Key_F2);
87 pauseID = gamePopup->insertItem(tr("&Pause"), 82 pauseID = gamePopup->insertItem(tr("&Pause"),
88 this, SLOT(pauseKpacman()), Key_F3); 83 this, SLOT(pauseKpacman()), Key_F3);
89 hofID = gamePopup->insertItem(tr("&Hall of fame"), 84 hofID = gamePopup->insertItem(tr("&Hall of fame"),
90 this, SLOT(toggleHallOfFame()), Key_F4); 85 this, SLOT(toggleHallOfFame()), Key_F4);
91 gamePopup->insertSeparator(); 86 gamePopup->insertSeparator();
92 gamePopup->insertItem(tr("&Quit"), this, SLOT(quitKpacman()), CTRL+Key_Q); 87 gamePopup->insertItem(tr("&Quit"), this, SLOT(quitKpacman()), CTRL+Key_Q);
93 gamePopup->setCheckable(TRUE); 88 gamePopup->setCheckable(TRUE);
94 89
95 optionsPopup = new QPopupMenu(); 90 optionsPopup = new QPopupMenu();
96 CHECK_PTR(optionsPopup); 91 CHECK_PTR(optionsPopup);
97 92
98 modesPopup = new QPopupMenu(); 93 modesPopup = new QPopupMenu();
99 CHECK_PTR(modesPopup); 94 CHECK_PTR(modesPopup);
100 95
101 hideMouseCursorID = optionsPopup->insertItem(tr("&Hide Mousecursor"), 96 hideMouseCursorID = optionsPopup->insertItem(tr("&Hide Mousecursor"),
102 this, SLOT(toggleHideMouseCursor()), 97 this, SLOT(toggleHideMouseCursor()),
103 CTRL+Key_H); 98 CTRL+Key_H);
104 optionsPopup->insertSeparator(); 99 optionsPopup->insertSeparator();
105 100
106 if (lookupSchemes() > 0) { 101 if (lookupSchemes() > 0) {
107 optionsPopup->insertItem(tr("&Select graphic scheme"), modesPopup); 102 optionsPopup->insertItem(tr("&Select graphic scheme"), modesPopup);
108 optionsPopup->insertSeparator(); 103 optionsPopup->insertSeparator();
109 } 104 }
110 105
111 focusOutPauseID = optionsPopup->insertItem(tr("&Pause in Background"), 106 focusOutPauseID = optionsPopup->insertItem(tr("&Pause in Background"),
112 this, SLOT(toggleFocusOutPause())); 107 this, SLOT(toggleFocusOutPause()));
113 focusInContinueID = optionsPopup->insertItem(tr("&Continue in Foreground"), 108 focusInContinueID = optionsPopup->insertItem(tr("&Continue in Foreground"),
114 this, SLOT(toggleFocusInContinue())); 109 this, SLOT(toggleFocusInContinue()));
115 optionsPopup->insertSeparator(); 110 optionsPopup->insertSeparator();
diff --git a/noncore/games/kpacman/kpacmanwidget.cpp b/noncore/games/kpacman/kpacmanwidget.cpp
index 823d2bf..9631495 100644
--- a/noncore/games/kpacman/kpacmanwidget.cpp
+++ b/noncore/games/kpacman/kpacmanwidget.cpp
@@ -1,117 +1,112 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <kapp.h> 5#include <kapp.h>
6#include <kconfig.h> 6#include <kconfig.h>
7#include <kstddirs.h> 7#include <kstddirs.h>
8#include <kpacmanwidget.h> 8#include <kpacmanwidget.h>
9#include <kpacmanwidget.moc> 9#include <kpacmanwidget.moc>
10#elif defined( QPE_PORT ) 10#elif defined( QPE_PORT )
11#include <qpe/qpeapplication.h> 11#include <qpe/qpeapplication.h>
12#include <qpe/config.h> 12#include <qpe/config.h>
13#include "kpacmanwidget.h" 13#include "kpacmanwidget.h"
14#endif 14#endif
15 15
16#include <qmessagebox.h>
17 16
18#include "bitfont.h"
19#include "score.h"
20#include "referee.h"
21#include "status.h"
22 17
23KpacmanWidget::KpacmanWidget( QWidget *parent, const char *name) 18KpacmanWidget::KpacmanWidget( QWidget *parent, const char *name)
24 : QWidget( parent, name ) 19 : QWidget( parent, name )
25{ 20{
26 score = 0l; 21 score = 0l;
27 referee = 0l; 22 referee = 0l;
28 status = 0l; 23 status = 0l;
29 bitfont = NULL; 24 bitfont = NULL;
30 fontName = ""; 25 fontName = "";
31 26
32 scheme = mode = -1; 27 scheme = mode = -1;
33 confScheme(); 28 confScheme();
34 29
35 score = new Score(this, name, scheme, mode, bitfont); 30 score = new Score(this, name, scheme, mode, bitfont);
36 referee = new Referee( this, name, scheme, mode, bitfont); 31 referee = new Referee( this, name, scheme, mode, bitfont);
37 status = new Status(this, name, scheme, mode); 32 status = new Status(this, name, scheme, mode);
38 33
39 setBackgroundColor( black ); 34 setBackgroundColor( black );
40} 35}
41 36
42KpacmanWidget::~KpacmanWidget() 37KpacmanWidget::~KpacmanWidget()
43{ 38{
44} 39}
45 40
46void KpacmanWidget::confMisc(bool defGroup) 41void KpacmanWidget::confMisc(bool defGroup)
47{ 42{
48 APP_CONFIG_BEGIN( cfg ); 43 APP_CONFIG_BEGIN( cfg );
49 //KStandardDirs *dirs = KGlobal::dirs(); 44 //KStandardDirs *dirs = KGlobal::dirs();
50 QString findPath; 45 QString findPath;
51 46
52 if (defGroup || cfg->hasKey("Font")) { 47 if (defGroup || cfg->hasKey("Font")) {
53 fontName = cfg->readEntry("Font"); 48 fontName = cfg->readEntry("Font");
54 49
55 if (fontName.left(1) != "/" && fontName.left(1) != "~") 50 if (fontName.left(1) != "/" && fontName.left(1) != "~")
56 fontName.insert(0, "fonts/"); 51 fontName.insert(0, "fonts/");
57 if (fontName.right(1) == "/") 52 if (fontName.right(1) == "/")
58 fontName.append("font.xbm"); 53 fontName.append("font.xbm");
59 54
60 //findPath = dirs->findResource("appdata", fontName); 55 //findPath = dirs->findResource("appdata", fontName);
61 findPath = FIND_APP_DATA( fontName ); 56 findPath = FIND_APP_DATA( fontName );
62 if (!findPath.isEmpty()) 57 if (!findPath.isEmpty())
63 fontName = findPath; 58 fontName = findPath;
64 59
65 bitfontFirstChar = cfg->readNumEntry("FontFirstChar", 0x0e); 60 bitfontFirstChar = cfg->readNumEntry("FontFirstChar", 0x0e);
66 bitfontLastChar = cfg->readNumEntry("FontLastChar", 0x5f); 61 bitfontLastChar = cfg->readNumEntry("FontLastChar", 0x5f);
67 } 62 }
68 APP_CONFIG_END( cfg ); 63 APP_CONFIG_END( cfg );
69} 64}
70 65
71void KpacmanWidget::confScheme() 66void KpacmanWidget::confScheme()
72{ 67{
73 APP_CONFIG_BEGIN( cfg ); 68 APP_CONFIG_BEGIN( cfg );
74 QString lastFontName = fontName; 69 QString lastFontName = fontName;
75 SAVE_CONFIG_GROUP( cfg, oldgroup ); 70 SAVE_CONFIG_GROUP( cfg, oldgroup );
76 QString newgroup; 71 QString newgroup;
77 72
78 // if not set, read mode and scheme from the configfile 73 // if not set, read mode and scheme from the configfile
79 if (mode == -1 && scheme == -1) { 74 if (mode == -1 && scheme == -1) {
80 scheme = cfg->readNumEntry("Scheme", -1); 75 scheme = cfg->readNumEntry("Scheme", -1);
81 mode = cfg->readNumEntry("Mode", -1); 76 mode = cfg->readNumEntry("Mode", -1);
82 77
83 // if mode is not set in the defGroup-group, lookup the scheme group 78 // if mode is not set in the defGroup-group, lookup the scheme group
84 if (scheme != -1 || mode == -1) { 79 if (scheme != -1 || mode == -1) {
85 newgroup.sprintf("Scheme %d", scheme); 80 newgroup.sprintf("Scheme %d", scheme);
86 cfg->setGroup(newgroup); 81 cfg->setGroup(newgroup);
87 82
88 mode = cfg->readNumEntry("Mode", -1); 83 mode = cfg->readNumEntry("Mode", -1);
89 RESTORE_CONFIG_GROUP( cfg, oldgroup ); 84 RESTORE_CONFIG_GROUP( cfg, oldgroup );
90 } 85 }
91 } 86 }
92 87
93 confMisc(); 88 confMisc();
94 89
95 if (mode != -1) { 90 if (mode != -1) {
96 newgroup.sprintf("Mode %d", mode); 91 newgroup.sprintf("Mode %d", mode);
97 cfg->setGroup(newgroup); 92 cfg->setGroup(newgroup);
98 93
99 confMisc(FALSE); 94 confMisc(FALSE);
100 } 95 }
101 96
102 if (scheme != -1) { 97 if (scheme != -1) {
103 newgroup.sprintf("Scheme %d", scheme); 98 newgroup.sprintf("Scheme %d", scheme);
104 cfg->setGroup(newgroup); 99 cfg->setGroup(newgroup);
105 100
106 confMisc(FALSE); 101 confMisc(FALSE);
107 } 102 }
108 103
109 if (lastFontName != fontName) { 104 if (lastFontName != fontName) {
110 105
111 if (bitfont != 0) 106 if (bitfont != 0)
112 delete bitfont; 107 delete bitfont;
113 108
114 bitfont = new Bitfont(fontName, bitfontFirstChar, bitfontLastChar); 109 bitfont = new Bitfont(fontName, bitfontFirstChar, bitfontLastChar);
115 if (bitfont->width() == 0 || bitfont->height() == 0) { 110 if (bitfont->width() == 0 || bitfont->height() == 0) {
116 QString msg = tr("The bitfont could not be contructed.\n\n" 111 QString msg = tr("The bitfont could not be contructed.\n\n"
117 "The file '@FONTNAME@' does not exist,\n" 112 "The file '@FONTNAME@' does not exist,\n"
diff --git a/noncore/games/kpacman/monster.cpp b/noncore/games/kpacman/monster.cpp
index 2f402b4..80b4655 100644
--- a/noncore/games/kpacman/monster.cpp
+++ b/noncore/games/kpacman/monster.cpp
@@ -1,98 +1,97 @@
1#include "monster.h" 1#include "monster.h"
2#include "board.h"
3 2
4Monster::Monster(Board *b, int mid) 3Monster::Monster(Board *b, int mid)
5{ 4{
6 board = b; 5 board = b;
7 ID = mid; 6 ID = mid;
8 7
9 setREM(0); 8 setREM(0);
10 setHarmless(0, 0, 0); 9 setHarmless(0, 0, 0);
11 setArrested(0, 0); 10 setArrested(0, 0);
12 setFreedom(board->position(prisonexit)); 11 setFreedom(board->position(prisonexit));
13 if (mid == 0) 12 if (mid == 0)
14 setPrison(board->position(prisonentry)); 13 setPrison(board->position(prisonentry));
15 else 14 else
16 setPrison(board->position(monsterhome, mid)); 15 setPrison(board->position(monsterhome, mid));
17 16
18 actualPosition = lastPosition = OUT; 17 actualPosition = lastPosition = OUT;
19 feetPosition = 0; 18 feetPosition = 0;
20 IQ = 0; 19 IQ = 0;
21 maxBodyPixmaps = 0; 20 maxBodyPixmaps = 0;
22 maxEyesPixmaps = 0; 21 maxEyesPixmaps = 0;
23} 22}
24 23
25void Monster::setMaxPixmaps(int maxBody, int maxEyes) 24void Monster::setMaxPixmaps(int maxBody, int maxEyes)
26{ 25{
27 if (feetPosition >= (maxBody/10)) 26 if (feetPosition >= (maxBody/10))
28 feetPosition = 0; 27 feetPosition = 0;
29 maxBodyPixmaps = maxBody; 28 maxBodyPixmaps = maxBody;
30 maxEyesPixmaps = maxEyes; 29 maxEyesPixmaps = maxEyes;
31} 30}
32 31
33void Monster::setArrested(int ticks, int duration) 32void Monster::setArrested(int ticks, int duration)
34{ 33{
35 actualState = dangerous; 34 actualState = dangerous;
36 pauseDuration = ticks; 35 pauseDuration = ticks;
37 pause = 0; 36 pause = 0;
38 arrestDuration = arrestLeft = duration; 37 arrestDuration = arrestLeft = duration;
39 arrestPause = ticks; 38 arrestPause = ticks;
40 harmlessLeft = 0; 39 harmlessLeft = 0;
41} 40}
42 41
43void Monster::setDangerous(int ticks, int iq) 42void Monster::setDangerous(int ticks, int iq)
44{ 43{
45 actualState = dangerous; 44 actualState = dangerous;
46 pauseDuration = ticks; 45 pauseDuration = ticks;
47 pause = 0; 46 pause = 0;
48 dangerousPause = ticks; 47 dangerousPause = ticks;
49 harmlessLeft = 0; 48 harmlessLeft = 0;
50 IQ = iq; 49 IQ = iq;
51} 50}
52 51
53void Monster::setHarmless(int ticks, int hDuration, int wDuration) 52void Monster::setHarmless(int ticks, int hDuration, int wDuration)
54{ 53{
55 actualState = harmless; 54 actualState = harmless;
56 pauseDuration = ticks; 55 pauseDuration = ticks;
57 pause = 0; 56 pause = 0;
58 harmlessDuration = harmlessLeft = hDuration; 57 harmlessDuration = harmlessLeft = hDuration;
59 warningDuration = wDuration; 58 warningDuration = wDuration;
60} 59}
61 60
62void Monster::setREM(int ticks) 61void Monster::setREM(int ticks)
63{ 62{
64 actualState = rem; 63 actualState = rem;
65 pauseDuration = ticks; 64 pauseDuration = ticks;
66 pause = 0; 65 pause = 0;
67} 66}
68 67
69void Monster::setPosition(int pos) 68void Monster::setPosition(int pos)
70{ 69{
71 board->reset(lastPosition, monster, ID); // reset old position on the board 70 board->reset(lastPosition, monster, ID); // reset old position on the board
72 actualPosition = lastPosition = pos; // set position of monster 71 actualPosition = lastPosition = pos; // set position of monster
73 board->set(actualPosition, monster, ID); 72 board->set(actualPosition, monster, ID);
74 feetPosition = 0; 73 feetPosition = 0;
75} 74}
76 75
77void Monster::setPrison(int pos) 76void Monster::setPrison(int pos)
78{ 77{
79 prisonPosition = pos; 78 prisonPosition = pos;
80} 79}
81 80
82void Monster::setFreedom(int pos) 81void Monster::setFreedom(int pos)
83{ 82{
84 freedomPosition = pos; 83 freedomPosition = pos;
85} 84}
86 85
87void Monster::setDirection(int dir) 86void Monster::setDirection(int dir)
88{ 87{
89 if (dir == X) 88 if (dir == X)
90 lastDirection = actualDirection; 89 lastDirection = actualDirection;
91 actualDirection = dir; 90 actualDirection = dir;
92} 91}
93 92
94monsterState Monster::state() 93monsterState Monster::state()
95{ 94{
96 return actualState; 95 return actualState;
97} 96}
98 97
diff --git a/noncore/games/kpacman/pacman.cpp b/noncore/games/kpacman/pacman.cpp
index 40f60a8..82524b4 100644
--- a/noncore/games/kpacman/pacman.cpp
+++ b/noncore/games/kpacman/pacman.cpp
@@ -1,98 +1,97 @@
1#include "pacman.h" 1#include "pacman.h"
2#include "board.h"
3 2
4Pacman::Pacman(Board *b) 3Pacman::Pacman(Board *b)
5{ 4{
6 board = b; 5 board = b;
7 setDemo(FALSE); 6 setDemo(FALSE);
8 setAlive(0); 7 setAlive(0);
9 actualPosition = lastPosition = OUT; 8 actualPosition = lastPosition = OUT;
10 mouthPosition = 0; 9 mouthPosition = 0;
11 lastPix = 0; 10 lastPix = 0;
12 maxPixmaps = 0; 11 maxPixmaps = 0;
13} 12}
14 13
15void Pacman::setMaxPixmaps(int max) 14void Pacman::setMaxPixmaps(int max)
16{ 15{
17 if (actualDirection == X && lastPix >= 0) { 16 if (actualDirection == X && lastPix >= 0) {
18 actualDirection = lastPix / (maxPixmaps/4); 17 actualDirection = lastPix / (maxPixmaps/4);
19 if (max < maxPixmaps) 18 if (max < maxPixmaps)
20 mouthPosition = 0; 19 mouthPosition = 0;
21 else 20 else
22 mouthPosition = lastPix % (maxPixmaps/4); 21 mouthPosition = lastPix % (maxPixmaps/4);
23 maxPixmaps = max; 22 maxPixmaps = max;
24 23
25 lastPix = pix(); 24 lastPix = pix();
26 25
27 actualDirection = X; 26 actualDirection = X;
28 } else 27 } else
29 maxPixmaps = max; 28 maxPixmaps = max;
30} 29}
31 30
32void Pacman::setAlive(int ticks) 31void Pacman::setAlive(int ticks)
33{ 32{
34 actualState = alive; 33 actualState = alive;
35 pauseDuration = ticks; 34 pauseDuration = ticks;
36 pause = 0; 35 pause = 0;
37} 36}
38 37
39void Pacman::setPosition(int pos) 38void Pacman::setPosition(int pos)
40{ 39{
41 board->reset(lastPosition, pacman); 40 board->reset(lastPosition, pacman);
42 actualPosition = lastPosition = pos; 41 actualPosition = lastPosition = pos;
43 board->set(actualPosition, pacman); 42 board->set(actualPosition, pacman);
44 mouthPosition = 0; 43 mouthPosition = 0;
45} 44}
46 45
47void Pacman::setDirection(int dir, bool forced) 46void Pacman::setDirection(int dir, bool forced)
48{ 47{
49 if (forced || 48 if (forced ||
50 board->isWay(actualPosition, dir, empty) || 49 board->isWay(actualPosition, dir, empty) ||
51 board->isWay(actualPosition, dir, tunnel)) { 50 board->isWay(actualPosition, dir, tunnel)) {
52 if (dir == X) 51 if (dir == X)
53 lastPix = pix(); 52 lastPix = pix();
54 actualDirection = dir; 53 actualDirection = dir;
55 nextDirection = X; 54 nextDirection = X;
56 } else 55 } else
57 nextDirection = dir; 56 nextDirection = dir;
58} 57}
59 58
60void Pacman::setDemo(bool yes) 59void Pacman::setDemo(bool yes)
61{ 60{
62 demo = yes; 61 demo = yes;
63} 62}
64 63
65pacmanState Pacman::state() 64pacmanState Pacman::state()
66{ 65{
67 return actualState; 66 return actualState;
68} 67}
69 68
70int Pacman::position() 69int Pacman::position()
71{ 70{
72 return actualPosition; 71 return actualPosition;
73} 72}
74 73
75int Pacman::direction() 74int Pacman::direction()
76{ 75{
77 return actualDirection; 76 return actualDirection;
78} 77}
79 78
80bool Pacman::move() 79bool Pacman::move()
81{ 80{
82 if (pause-- > 0) 81 if (pause-- > 0)
83 return FALSE; 82 return FALSE;
84 else 83 else
85 pause = pauseDuration; 84 pause = pauseDuration;
86 85
87 if (actualDirection == X || actualPosition == OUT) 86 if (actualDirection == X || actualPosition == OUT)
88 return FALSE; 87 return FALSE;
89 88
90 lastPosition = actualPosition; 89 lastPosition = actualPosition;
91 90
92 if (demo) { 91 if (demo) {
93 int d = actualDirection; 92 int d = actualDirection;
94 93
95 do // try new direction, but not the opposite 94 do // try new direction, but not the opposite
96 d = rand() % 4; // direction, to prevent hectic movement. 95 d = rand() % 4; // direction, to prevent hectic movement.
97 while (d == board->turn(actualDirection)); 96 while (d == board->turn(actualDirection));
98 97
diff --git a/noncore/games/kpacman/painter.cpp b/noncore/games/kpacman/painter.cpp
index d8c7460..410d3f5 100644
--- a/noncore/games/kpacman/painter.cpp
+++ b/noncore/games/kpacman/painter.cpp
@@ -1,120 +1,112 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <kapp.h> 5#include <kapp.h>
6#include <kconfig.h> 6#include <kconfig.h>
7#include <kstddirs.h> 7#include <kstddirs.h>
8#elif defined( QPE_PORT ) 8#elif defined( QPE_PORT )
9#include <qpe/qpeapplication.h> 9#include <qpe/qpeapplication.h>
10#include <qpe/config.h> 10#include <qpe/config.h>
11#endif 11#endif
12 12
13#include <qcolor.h> 13
14#include <qpainter.h>
15#include <qpixmap.h>
16#include <qbitmap.h>
17#include <qrect.h>
18#include <qstring.h>
19
20#include <qmessagebox.h>
21#include <qfileinfo.h> 14#include <qfileinfo.h>
22 15
23#include "painter.h" 16#include "painter.h"
24#include "board.h"
25 17
26Painter::Painter( Board *b, QWidget *parent, int Scheme, int Mode, Bitfont *font) 18Painter::Painter( Board *b, QWidget *parent, int Scheme, int Mode, Bitfont *font)
27{ 19{
28 w = parent; 20 w = parent;
29 board = b; 21 board = b;
30 22
31 pointPix = NULL; 23 pointPix = NULL;
32 wallPix = NULL; 24 wallPix = NULL;
33 prisonPix = NULL; 25 prisonPix = NULL;
34 energizerPix = NULL; 26 energizerPix = NULL;
35 fruitPix = NULL; 27 fruitPix = NULL;
36 pacmanPix = NULL; 28 pacmanPix = NULL;
37 dyingPix = NULL; 29 dyingPix = NULL;
38 eyesPix = NULL; 30 eyesPix = NULL;
39 monsterPix = NULL; 31 monsterPix = NULL;
40 fruitScorePix = NULL; 32 fruitScorePix = NULL;
41 monsterScorePix = NULL; 33 monsterScorePix = NULL;
42 34
43 lastPointPixmapName = ""; 35 lastPointPixmapName = "";
44 lastWallPixmapName = ""; 36 lastWallPixmapName = "";
45 lastPrisonPixmapName = ""; 37 lastPrisonPixmapName = "";
46 lastEnergizerPixmapName = ""; 38 lastEnergizerPixmapName = "";
47 lastFruitPixmapName = ""; 39 lastFruitPixmapName = "";
48 lastPacmanPixmapName = ""; 40 lastPacmanPixmapName = "";
49 lastDyingPixmapName = ""; 41 lastDyingPixmapName = "";
50 lastEyesPixmapName = ""; 42 lastEyesPixmapName = "";
51 lastMonsterPixmapName = ""; 43 lastMonsterPixmapName = "";
52 lastFruitScorePixmapName = ""; 44 lastFruitScorePixmapName = "";
53 lastMonsterScorePixmapName = ""; 45 lastMonsterScorePixmapName = "";
54 46
55 bitfont = font; 47 bitfont = font;
56 48
57 scheme = Scheme; 49 scheme = Scheme;
58 mode = Mode; 50 mode = Mode;
59 level = 0; 51 level = 0;
60 52
61 confScheme(); 53 confScheme();
62} 54}
63 55
64QList<QPixmap> *Painter::loadPixmap(QWidget*, QString pixmapName, 56QList<QPixmap> *Painter::loadPixmap(QWidget*, QString pixmapName,
65 QList<QPixmap> *pixmaps) 57 QList<QPixmap> *pixmaps)
66{ 58{
67 if (pixmaps == NULL) { 59 if (pixmaps == NULL) {
68 pixmaps = new QList<QPixmap>; 60 pixmaps = new QList<QPixmap>;
69 pixmaps->setAutoDelete(TRUE); 61 pixmaps->setAutoDelete(TRUE);
70 } 62 }
71 63
72 if (!pixmaps->isEmpty()) 64 if (!pixmaps->isEmpty())
73 pixmaps->clear(); 65 pixmaps->clear();
74 66
75 QPixmap PIXMAP(pixmapName); 67 QPixmap PIXMAP(pixmapName);
76 if (PIXMAP.isNull() || PIXMAP.mask() == NULL) { 68 if (PIXMAP.isNull() || PIXMAP.mask() == NULL) {
77 QString msg = "The pixmap could not be contructed.\n\n" 69 QString msg = "The pixmap could not be contructed.\n\n"
78 "The file '@PIXMAPNAME@' does not exist,\n" 70 "The file '@PIXMAPNAME@' does not exist,\n"
79 "or is of an unknown format."; 71 "or is of an unknown format.";
80 msg.replace(QRegExp("@PIXMAPNAME@"), pixmapName); 72 msg.replace(QRegExp("@PIXMAPNAME@"), pixmapName);
81 // QMessageBox::critical(parent, tr("Initialization Error"), msg); 73 // QMessageBox::critical(parent, tr("Initialization Error"), msg);
82 printf("%s\n", msg.data()); 74 printf("%s\n", msg.data());
83 return 0; 75 return 0;
84 } 76 }
85 77
86 int height = PIXMAP.height(); 78 int height = PIXMAP.height();
87 int width = (height == 0) ? 0 : PIXMAP.width()/(PIXMAP.width()/height); 79 int width = (height == 0) ? 0 : PIXMAP.width()/(PIXMAP.width()/height);
88 80
89 QBitmap BITMAP; 81 QBitmap BITMAP;
90 QBitmap MASK; 82 QBitmap MASK;
91 83
92 BITMAP = *PIXMAP.mask(); 84 BITMAP = *PIXMAP.mask();
93 MASK.resize(width, height); 85 MASK.resize(width, height);
94 86
95 for (int x = 0; x < PIXMAP.width()/width; x++) { 87 for (int x = 0; x < PIXMAP.width()/width; x++) {
96 QPixmap *pixmap = new QPixmap(width, height); 88 QPixmap *pixmap = new QPixmap(width, height);
97 pixmaps->append(pixmap); 89 pixmaps->append(pixmap);
98 bitBlt(pixmap, 0, 0, &PIXMAP, x*width, 0, width, height, QPixmap::CopyROP, TRUE); 90 bitBlt(pixmap, 0, 0, &PIXMAP, x*width, 0, width, height, QPixmap::CopyROP, TRUE);
99 bitBlt(&MASK, 0, 0, &BITMAP, x*width, 0, width, height, QPixmap::CopyROP, TRUE); 91 bitBlt(&MASK, 0, 0, &BITMAP, x*width, 0, width, height, QPixmap::CopyROP, TRUE);
100 pixmap->setMask(MASK); 92 pixmap->setMask(MASK);
101 } 93 }
102 94
103 return pixmaps; 95 return pixmaps;
104} 96}
105 97
106QList<QPixmap> *Painter::textPixmap(QStrList &str, QList<QPixmap> *pixmaps, 98QList<QPixmap> *Painter::textPixmap(QStrList &str, QList<QPixmap> *pixmaps,
107 QColor fg, QColor bg) 99 QColor fg, QColor bg)
108{ 100{
109 if (pixmaps == NULL) { 101 if (pixmaps == NULL) {
110 pixmaps = new QList<QPixmap>; 102 pixmaps = new QList<QPixmap>;
111 pixmaps->setAutoDelete(TRUE); 103 pixmaps->setAutoDelete(TRUE);
112 } 104 }
113 105
114 if (!pixmaps->isEmpty()) 106 if (!pixmaps->isEmpty())
115 pixmaps->clear(); 107 pixmaps->clear();
116 108
117 for (uint s = 0; s < str.count(); s++) { 109 for (uint s = 0; s < str.count(); s++) {
118 QPixmap *pixmap = new QPixmap(bitfont->text(str.at(s), fg, bg)); 110 QPixmap *pixmap = new QPixmap(bitfont->text(str.at(s), fg, bg));
119 pixmaps->append(pixmap); 111 pixmaps->append(pixmap);
120 } 112 }
diff --git a/noncore/games/kpacman/referee.cpp b/noncore/games/kpacman/referee.cpp
index 1b810d8..2d0f3be 100644
--- a/noncore/games/kpacman/referee.cpp
+++ b/noncore/games/kpacman/referee.cpp
@@ -1,126 +1,117 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <kapp.h> 5#include <kapp.h>
6#include <kconfig.h> 6#include <kconfig.h>
7#include <kstddirs.h> 7#include <kstddirs.h>
8#include <kaccel.h> 8#include <kaccel.h>
9#include <referee.h> 9#include <referee.h>
10#include <referee.moc> 10#include <referee.moc>
11#elif defined( QPE_PORT ) 11#elif defined( QPE_PORT )
12#include <qaccel.h> 12#include <qaccel.h>
13#include <qpe/qpeapplication.h> 13#include <qpe/qpeapplication.h>
14#include <qpe/config.h> 14#include <qpe/config.h>
15#include "referee.h" 15#include "referee.h"
16#endif 16#endif
17 17
18#include <qdatetm.h>
19#include <stdlib.h> 18#include <stdlib.h>
20#include <qtimer.h> 19#include <qtimer.h>
21#include <qevent.h>
22#include <qcolor.h>
23#include <qkeycode.h>
24#include <qfileinfo.h> 20#include <qfileinfo.h>
25 21
26#include "board.h"
27#include "pacman.h"
28#include "monster.h"
29#include "fruit.h"
30#include "painter.h"
31 22
32Referee::Referee( QWidget *parent, const char *name, int Scheme, int Mode, Bitfont *font) 23Referee::Referee( QWidget *parent, const char *name, int Scheme, int Mode, Bitfont *font)
33 : QWidget( parent, name ) 24 : QWidget( parent, name )
34{ 25{
35 gameState.resize(12); 26 gameState.resize(12);
36 gameTimer = 0; 27 gameTimer = 0;
37 energizerTimer = 0; 28 energizerTimer = 0;
38 29
39 focusedPause = FALSE; 30 focusedPause = FALSE;
40 setFocusPolicy(QWidget::StrongFocus); 31 setFocusPolicy(QWidget::StrongFocus);
41 32
42 initKeys(); 33 initKeys();
43 34
44 scheme = Scheme; 35 scheme = Scheme;
45 mode = Mode; 36 mode = Mode;
46 confScheme(); 37 confScheme();
47 38
48 board = new Board(BoardWidth*BoardHeight); 39 board = new Board(BoardWidth*BoardHeight);
49 40
50 pix = new Painter(board, this, scheme, mode, font); 41 pix = new Painter(board, this, scheme, mode, font);
51 setFixedSize(pix->levelPix().size()); 42 setFixedSize(pix->levelPix().size());
52 43
53 pacman = new Pacman(board); 44 pacman = new Pacman(board);
54 45
55 fruit = new Fruit(board); 46 fruit = new Fruit(board);
56 47
57 monsters = new QList<Monster>; 48 monsters = new QList<Monster>;
58 monsters->setAutoDelete(TRUE); 49 monsters->setAutoDelete(TRUE);
59 50
60 monsterRect = new QList<QRect>; 51 monsterRect = new QList<QRect>;
61 monsterRect->setAutoDelete(TRUE); 52 monsterRect->setAutoDelete(TRUE);
62 53
63 energizers = new QList<Energizer>; 54 energizers = new QList<Energizer>;
64 energizers->setAutoDelete(TRUE); 55 energizers->setAutoDelete(TRUE);
65 56
66 energizerRect = new QList<QRect>; 57 energizerRect = new QList<QRect>;
67 energizerRect->setAutoDelete(TRUE); 58 energizerRect->setAutoDelete(TRUE);
68 59
69 pacmanRect.setRect(0, 0, 0, 0); 60 pacmanRect.setRect(0, 0, 0, 0);
70 fruitRect.setRect(0, 0, 0, 0); 61 fruitRect.setRect(0, 0, 0, 0);
71 62
72 QTime midnight( 0, 0, 0 ); 63 QTime midnight( 0, 0, 0 );
73 srand( midnight.secsTo(QTime::currentTime()) ); 64 srand( midnight.secsTo(QTime::currentTime()) );
74 65
75 lifes = 0; 66 lifes = 0;
76 points = 0; 67 points = 0;
77 68
78 emit setLifes(lifes); 69 emit setLifes(lifes);
79 emit setPoints(points); 70 emit setPoints(points);
80 71
81 intro(); 72 intro();
82} 73}
83 74
84void Referee::paintEvent( QPaintEvent *e) 75void Referee::paintEvent( QPaintEvent *e)
85{ 76{
86 if (gameState.testBit(HallOfFame)) 77 if (gameState.testBit(HallOfFame))
87 return; 78 return;
88 79
89 QRect rect = e->rect(); 80 QRect rect = e->rect();
90 81
91 if (!rect.isEmpty()) { 82 if (!rect.isEmpty()) {
92 QPixmap p = pix->levelPix(); 83 QPixmap p = pix->levelPix();
93 bitBlt(this, rect.x(), rect.y(), 84 bitBlt(this, rect.x(), rect.y(),
94 &p, rect.x(), rect.y(), rect.width(), rect.height()); 85 &p, rect.x(), rect.y(), rect.width(), rect.height());
95 } 86 }
96 87
97 if ((gameState.testBit(GameOver) || gameState.testBit(Demonstration)) && 88 if ((gameState.testBit(GameOver) || gameState.testBit(Demonstration)) &&
98 rect.intersects(pix->rect(board->position(fruithome), tr("GAME OVER")))) 89 rect.intersects(pix->rect(board->position(fruithome), tr("GAME OVER"))))
99 pix->draw(board->position(fruithome), Widget, tr("GAME OVER"), RED); 90 pix->draw(board->position(fruithome), Widget, tr("GAME OVER"), RED);
100 91
101 for (Energizer *e = energizers->first(); e != 0; e = energizers->next()) { 92 for (Energizer *e = energizers->first(); e != 0; e = energizers->next()) {
102 if (e && e->state() == on && 93 if (e && e->state() == on &&
103 rect.intersects(pix->rect(e->position(), EnergizerPix)) && 94 rect.intersects(pix->rect(e->position(), EnergizerPix)) &&
104 !(e->position() == pacman->position() && gameState.testBit(Scoring))) { 95 !(e->position() == pacman->position() && gameState.testBit(Scoring))) {
105 if (e->pix() != -1) 96 if (e->pix() != -1)
106 pix->draw(e->position(), Widget, EnergizerPix, e->pix()); 97 pix->draw(e->position(), Widget, EnergizerPix, e->pix());
107 } 98 }
108 } 99 }
109 100
110 if (!gameState.testBit(Init)) { 101 if (!gameState.testBit(Init)) {
111 102
112 if (!gameState.testBit(Dying) && (fruit->pix() != -1)) 103 if (!gameState.testBit(Dying) && (fruit->pix() != -1))
113 if (fruit->state() != active) { 104 if (fruit->state() != active) {
114 if (rect.intersects(pix->rect(fruit->position(), FruitScorePix, fruit->pix()))) 105 if (rect.intersects(pix->rect(fruit->position(), FruitScorePix, fruit->pix())))
115 pix->draw(fruit->position(), Widget, FruitScorePix, fruit->pix()); 106 pix->draw(fruit->position(), Widget, FruitScorePix, fruit->pix());
116 } else { 107 } else {
117 if (rect.intersects(pix->rect(fruit->position(), FruitPix, fruit->pix()))) 108 if (rect.intersects(pix->rect(fruit->position(), FruitPix, fruit->pix())))
118 pix->draw(fruit->position(), Widget, FruitPix, fruit->pix()); 109 pix->draw(fruit->position(), Widget, FruitPix, fruit->pix());
119 } 110 }
120 111
121 for (Monster *m = monsters->first(); m != 0; m = monsters->next()) 112 for (Monster *m = monsters->first(); m != 0; m = monsters->next())
122 if (m && m->state() == harmless && 113 if (m && m->state() == harmless &&
123 rect.intersects(pix->rect(m->position(), MonsterPix)) && 114 rect.intersects(pix->rect(m->position(), MonsterPix)) &&
124 !(m->position() == pacman->position() && gameState.testBit(Scoring))) { 115 !(m->position() == pacman->position() && gameState.testBit(Scoring))) {
125 if (m->body() != -1) 116 if (m->body() != -1)
126 pix->draw(m->position(), Widget, MonsterPix, m->body()); 117 pix->draw(m->position(), Widget, MonsterPix, m->body());
diff --git a/noncore/games/kpacman/score.cpp b/noncore/games/kpacman/score.cpp
index e91771b..6878b81 100644
--- a/noncore/games/kpacman/score.cpp
+++ b/noncore/games/kpacman/score.cpp
@@ -1,125 +1,119 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <score.h> 5#include <score.h>
6#include <score.moc> 6#include <score.moc>
7 7
8#include <kaccel.h> 8#include <kaccel.h>
9#include <kapp.h> 9#include <kapp.h>
10#include <kconfig.h> 10#include <kconfig.h>
11#include <kstddirs.h> 11#include <kstddirs.h>
12#include <kmessagebox.h> 12#include <kmessagebox.h>
13#elif defined( QPE_PORT ) 13#elif defined( QPE_PORT )
14#include <qaccel.h> 14#include <qaccel.h>
15#include <qpe/config.h> 15#include <qpe/config.h>
16#include "score.h" 16#include "score.h"
17#endif 17#endif
18 18
19#include <stdlib.h> 19#include <stdlib.h>
20#include <ctype.h> 20#include <ctype.h>
21 21
22#include <qpixmap.h>
23#include <qstring.h>
24#include <qdstream.h>
25#include <qkeycode.h>
26#include <qtimer.h> 22#include <qtimer.h>
27#include <qfileinfo.h>
28 23
29#include "bitfont.h"
30 24
31Score::Score(QWidget *parent, const char *name, int Scheme, int Mode, Bitfont *font) : QWidget(parent, name) 25Score::Score(QWidget *parent, const char *name, int Scheme, int Mode, Bitfont *font) : QWidget(parent, name)
32{ 26{
33 setFocusPolicy(QWidget::StrongFocus); 27 setFocusPolicy(QWidget::StrongFocus);
34 28
35 paused = FALSE; 29 paused = FALSE;
36 30
37 lastScore = -1; 31 lastScore = -1;
38 lastPlayer = -1; 32 lastPlayer = -1;
39 33
40 cursorBlinkTimer = 0; 34 cursorBlinkTimer = 0;
41 cursorBlinkMS = -1; 35 cursorBlinkMS = -1;
42 cursor.x = -1; 36 cursor.x = -1;
43 cursor.y = -1; 37 cursor.y = -1;
44 cursor.on = FALSE; 38 cursor.on = FALSE;
45 cursor.chr = QChar('?'); 39 cursor.chr = QChar('?');
46 40
47 initKeys(); 41 initKeys();
48 42
49 scheme = Scheme; 43 scheme = Scheme;
50 mode = Mode; 44 mode = Mode;
51 confScheme(); 45 confScheme();
52 46
53 bitfont = font; 47 bitfont = font;
54 48
55 highscoreFile.setName(locateHighscoreFilePath().filePath()); 49 highscoreFile.setName(locateHighscoreFilePath().filePath());
56 read(); 50 read();
57 51
58 for (int p = 0; p < maxPlayer; p++) { 52 for (int p = 0; p < maxPlayer; p++) {
59 playerScore[p] = 0; 53 playerScore[p] = 0;
60 playerName[p] = getenv("LOGNAME"); 54 playerName[p] = getenv("LOGNAME");
61 if (playerName[p].length() < minPlayerNameLength) 55 if (playerName[p].length() < minPlayerNameLength)
62 playerName[p].setExpand(minPlayerNameLength-1, ' '); 56 playerName[p].setExpand(minPlayerNameLength-1, ' ');
63 57
64 for (uint i = 0; i < playerName[p].length(); i++) 58 for (uint i = 0; i < playerName[p].length(); i++)
65 if (playerName[p].at(i) < bitfont->firstChar() || 59 if (playerName[p].at(i) < bitfont->firstChar() ||
66 playerName[p].at(i) > bitfont->lastChar()) 60 playerName[p].at(i) > bitfont->lastChar())
67 playerName[p].at(i) = playerName[p].at(i).upper(); 61 playerName[p].at(i) = playerName[p].at(i).upper();
68 } 62 }
69} 63}
70 64
71Score::~Score() 65Score::~Score()
72{ 66{
73 // write(); 67 // write();
74} 68}
75 69
76void Score::paintEvent( QPaintEvent *e) 70void Score::paintEvent( QPaintEvent *e)
77{ 71{
78 if (rect(1, 0, tr(" 1UP ")).intersects(e->rect())) { 72 if (rect(1, 0, tr(" 1UP ")).intersects(e->rect())) {
79 QPixmap pix; 73 QPixmap pix;
80 QColor fg = BLACK; 74 QColor fg = BLACK;
81 if (cursor.on || paused || lastPlayer != 0) 75 if (cursor.on || paused || lastPlayer != 0)
82 fg = WHITE; 76 fg = WHITE;
83 pix = bitfont->text(tr(" 1UP "), fg, BLACK); 77 pix = bitfont->text(tr(" 1UP "), fg, BLACK);
84 bitBlt(this, x(1), y(0), &pix); 78 bitBlt(this, x(1), y(0), &pix);
85 } 79 }
86 80
87 if (rect(8, 0, tr(" HIGH SCORE ")).intersects(e->rect())) { 81 if (rect(8, 0, tr(" HIGH SCORE ")).intersects(e->rect())) {
88 QPixmap pix = bitfont->text(tr(" HIGH SCORE "), WHITE, BLACK); 82 QPixmap pix = bitfont->text(tr(" HIGH SCORE "), WHITE, BLACK);
89 bitBlt(this, x(8), y(0), &pix); 83 bitBlt(this, x(8), y(0), &pix);
90 } 84 }
91 85
92 if (maxPlayer > 1 && rect(21, 0, tr(" 2UP ")).intersects(e->rect())) { 86 if (maxPlayer > 1 && rect(21, 0, tr(" 2UP ")).intersects(e->rect())) {
93 QPixmap pix; 87 QPixmap pix;
94 QColor fg = BLACK; 88 QColor fg = BLACK;
95 if (cursor.on || paused || lastPlayer != 1) 89 if (cursor.on || paused || lastPlayer != 1)
96 fg = WHITE; 90 fg = WHITE;
97 pix = bitfont->text(tr(" 2UP "), fg, BLACK); 91 pix = bitfont->text(tr(" 2UP "), fg, BLACK);
98 bitBlt(this, x(21), y(0), &pix); 92 bitBlt(this, x(21), y(0), &pix);
99 } 93 }
100 94
101 QString s; 95 QString s;
102 96
103 s.sprintf("%6d0", playerScore[0]/10); 97 s.sprintf("%6d0", playerScore[0]/10);
104 if (rect(0, 1, s).intersects(e->rect())) { 98 if (rect(0, 1, s).intersects(e->rect())) {
105 QPixmap pix = bitfont->text(s, WHITE, BLACK); 99 QPixmap pix = bitfont->text(s, WHITE, BLACK);
106 bitBlt(this, x(0), y(1), &pix); 100 bitBlt(this, x(0), y(1), &pix);
107 } 101 }
108 102
109 s.sprintf("%8d0", HighScore/10); 103 s.sprintf("%8d0", HighScore/10);
110 if (rect(8, 1, s).intersects(e->rect())) { 104 if (rect(8, 1, s).intersects(e->rect())) {
111 QPixmap pix = bitfont->text(s, WHITE, BLACK); 105 QPixmap pix = bitfont->text(s, WHITE, BLACK);
112 bitBlt(this, x(8), y(1), &pix); 106 bitBlt(this, x(8), y(1), &pix);
113 } 107 }
114 108
115 if (lastScore >= 0) { 109 if (lastScore >= 0) {
116 if (rect(1, 4*1.25, tr(" CONGRATULATIONS ")).intersects(e->rect())) { 110 if (rect(1, 4*1.25, tr(" CONGRATULATIONS ")).intersects(e->rect())) {
117 QPixmap pix = bitfont->text(tr(" CONGRATULATIONS "), YELLOW, BLACK); 111 QPixmap pix = bitfont->text(tr(" CONGRATULATIONS "), YELLOW, BLACK);
118 bitBlt(this, x(1), y(4*1.25), &pix); 112 bitBlt(this, x(1), y(4*1.25), &pix);
119 } 113 }
120 if (rect(1, 6*1.25, tr(" YOU HAVE ARCHIEVED ")).intersects(e->rect())) { 114 if (rect(1, 6*1.25, tr(" YOU HAVE ARCHIEVED ")).intersects(e->rect())) {
121 QPixmap pix = bitfont->text(tr(" YOU HAVE ARCHIEVED "), CYAN, BLACK); 115 QPixmap pix = bitfont->text(tr(" YOU HAVE ARCHIEVED "), CYAN, BLACK);
122 bitBlt(this, x(1), y(6*1.25), &pix); 116 bitBlt(this, x(1), y(6*1.25), &pix);
123 } 117 }
124 if (rect(1, 7*1.25, tr(" A SCORE IN THE TOP 10. ")).intersects(e->rect())) { 118 if (rect(1, 7*1.25, tr(" A SCORE IN THE TOP 10. ")).intersects(e->rect())) {
125 QPixmap pix = bitfont->text(tr(" A SCORE IN THE TOP 10. "), CYAN, BLACK); 119 QPixmap pix = bitfont->text(tr(" A SCORE IN THE TOP 10. "), CYAN, BLACK);
diff --git a/noncore/games/kpacman/status.cpp b/noncore/games/kpacman/status.cpp
index 2a17c21..02ff63d 100644
--- a/noncore/games/kpacman/status.cpp
+++ b/noncore/games/kpacman/status.cpp
@@ -1,114 +1,112 @@
1 1
2#include "portable.h" 2#include "portable.h"
3 3
4#if defined( KDE2_PORT ) 4#if defined( KDE2_PORT )
5#include <kapp.h> 5#include <kapp.h>
6#include <klocale.h> 6#include <klocale.h>
7#include <kstddirs.h> 7#include <kstddirs.h>
8#include <status.h> 8#include <status.h>
9#include <status.moc> 9#include <status.moc>
10#elif defined( QPE_PORT ) 10#elif defined( QPE_PORT )
11#include <qpe/qpeapplication.h> 11#include <qpe/qpeapplication.h>
12#include <qpe/config.h> 12#include <qpe/config.h>
13#include "status.h" 13#include "status.h"
14#endif 14#endif
15 15
16#include <qpixmap.h>
17#include <qbitmap.h> 16#include <qbitmap.h>
18#include <qstring.h>
19#include <qmsgbox.h> 17#include <qmsgbox.h>
20#include <qfileinfo.h> 18#include <qfileinfo.h>
21 19
22Status::Status( QWidget *parent, const char *name, int Scheme, int Mode ) : 20Status::Status( QWidget *parent, const char *name, int Scheme, int Mode ) :
23 QWidget( parent, name ) 21 QWidget( parent, name )
24{ 22{
25 qWarning("Status::Status"); 23 qWarning("Status::Status");
26 actualLifes = 0; 24 actualLifes = 0;
27 actualLevel = 0; 25 actualLevel = 0;
28 26
29 lifesPix = NULL; 27 lifesPix = NULL;
30 levelPix = NULL; 28 levelPix = NULL;
31 29
32 scheme = Scheme; 30 scheme = Scheme;
33 mode = Mode; 31 mode = Mode;
34 level = 0; 32 level = 0;
35 33
36 confScheme(); 34 confScheme();
37} 35}
38 36
39QList<QPixmap> *Status::loadPixmap(QWidget *parent, QString pixmapName, 37QList<QPixmap> *Status::loadPixmap(QWidget *parent, QString pixmapName,
40 QList<QPixmap> *pixmaps) 38 QList<QPixmap> *pixmaps)
41{ 39{
42 if (pixmaps == NULL) { 40 if (pixmaps == NULL) {
43 pixmaps = new QList<QPixmap>; 41 pixmaps = new QList<QPixmap>;
44 pixmaps->setAutoDelete(TRUE); 42 pixmaps->setAutoDelete(TRUE);
45 } 43 }
46 44
47 if (!pixmaps->isEmpty()) 45 if (!pixmaps->isEmpty())
48 pixmaps->clear(); 46 pixmaps->clear();
49 47
50 QPixmap PIXMAP(pixmapName); 48 QPixmap PIXMAP(pixmapName);
51 if (PIXMAP.isNull() || PIXMAP.mask() == NULL) { 49 if (PIXMAP.isNull() || PIXMAP.mask() == NULL) {
52 QString msg = tr("The pixmap could not be contructed.\n\n" 50 QString msg = tr("The pixmap could not be contructed.\n\n"
53 "The file '@PIXMAPNAME@' does not exist,\n" 51 "The file '@PIXMAPNAME@' does not exist,\n"
54 "or is of an unknown format."); 52 "or is of an unknown format.");
55 msg.replace(QRegExp("@PIXMAPNAME@"), pixmapName); 53 msg.replace(QRegExp("@PIXMAPNAME@"), pixmapName);
56 QMessageBox::information(parent, tr("Initialization Error"), 54 QMessageBox::information(parent, tr("Initialization Error"),
57 (const char *) msg); 55 (const char *) msg);
58 return 0; 56 return 0;
59 } 57 }
60 58
61 int height = PIXMAP.height(); 59 int height = PIXMAP.height();
62 int width = (height == 0) ? 0 : PIXMAP.width()/(PIXMAP.width()/height); 60 int width = (height == 0) ? 0 : PIXMAP.width()/(PIXMAP.width()/height);
63 61
64 QBitmap BITMAP; 62 QBitmap BITMAP;
65 QBitmap MASK; 63 QBitmap MASK;
66 64
67 BITMAP = *PIXMAP.mask(); 65 BITMAP = *PIXMAP.mask();
68 MASK.resize(width, height); 66 MASK.resize(width, height);
69 67
70 for (int x = 0; x < PIXMAP.width()/width; x++) { 68 for (int x = 0; x < PIXMAP.width()/width; x++) {
71 QPixmap *pixmap = new QPixmap(width, height); 69 QPixmap *pixmap = new QPixmap(width, height);
72 pixmaps->append(pixmap); 70 pixmaps->append(pixmap);
73 bitBlt(pixmap, 0, 0, &PIXMAP, x*width, 0, width, height, CopyROP, TRUE); 71 bitBlt(pixmap, 0, 0, &PIXMAP, x*width, 0, width, height, CopyROP, TRUE);
74 bitBlt(&MASK, 0, 0, &BITMAP, x*width, 0, width, height, CopyROP, TRUE); 72 bitBlt(&MASK, 0, 0, &BITMAP, x*width, 0, width, height, CopyROP, TRUE);
75 pixmap->setMask(MASK); 73 pixmap->setMask(MASK);
76 } 74 }
77 75
78 return pixmaps; 76 return pixmaps;
79} 77}
80 78
81void Status::paintEvent( QPaintEvent *) 79void Status::paintEvent( QPaintEvent *)
82{ 80{
83 for (int x = 0; x < actualLifes && !lifesPix->isEmpty(); x++) 81 for (int x = 0; x < actualLifes && !lifesPix->isEmpty(); x++)
84 bitBlt(this, lifesPix->at(0)->width()+(lifesPix->at(0)->width()*x), 82 bitBlt(this, lifesPix->at(0)->width()+(lifesPix->at(0)->width()*x),
85 (height()-lifesPix->at(0)->height())/2, 83 (height()-lifesPix->at(0)->height())/2,
86 lifesPix->at(0), 0, 0, 84 lifesPix->at(0), 0, 0,
87 lifesPix->at(0)->width(), lifesPix->at(0)->height()); 85 lifesPix->at(0)->width(), lifesPix->at(0)->height());
88 86
89 for (int x = 0; x < actualLevel && !levelPix->isEmpty(); x++) { 87 for (int x = 0; x < actualLevel && !levelPix->isEmpty(); x++) {
90 erase((width()-levelPix->at(x)->width()*2)-(levelPix->at(x)->width()*levelPos[x]), 88 erase((width()-levelPix->at(x)->width()*2)-(levelPix->at(x)->width()*levelPos[x]),
91 (height()-levelPix->at(x)->height())/2, 89 (height()-levelPix->at(x)->height())/2,
92 levelPix->at(x)->width(), levelPix->at(x)->height()); 90 levelPix->at(x)->width(), levelPix->at(x)->height());
93 bitBlt(this, (width()-levelPix->at(x)->width()*2)-(levelPix->at(x)->width()*levelPos[x]), 91 bitBlt(this, (width()-levelPix->at(x)->width()*2)-(levelPix->at(x)->width()*levelPos[x]),
94 (height()-levelPix->at(x)->height())/2, 92 (height()-levelPix->at(x)->height())/2,
95 levelPix->at(x), 0, 0, 93 levelPix->at(x), 0, 0,
96 levelPix->at(x)->width(), levelPix->at(x)->height()); 94 levelPix->at(x)->width(), levelPix->at(x)->height());
97 } 95 }
98} 96}
99 97
100void Status::initPixmaps() 98void Status::initPixmaps()
101{ 99{
102 if (lastLifesPixmapName != lifesPixmapName.at(level)) { 100 if (lastLifesPixmapName != lifesPixmapName.at(level)) {
103 lifesPix = loadPixmap(this, lifesPixmapName.at(level), lifesPix); 101 lifesPix = loadPixmap(this, lifesPixmapName.at(level), lifesPix);
104 lastLifesPixmapName = lifesPixmapName.at(level); 102 lastLifesPixmapName = lifesPixmapName.at(level);
105 } 103 }
106 if (lastLevelPixmapName != levelPixmapName.at(level)) { 104 if (lastLevelPixmapName != levelPixmapName.at(level)) {
107 levelPix = loadPixmap(this, levelPixmapName.at(level), levelPix); 105 levelPix = loadPixmap(this, levelPixmapName.at(level), levelPix);
108 lastLevelPixmapName = levelPixmapName.at(level); 106 lastLevelPixmapName = levelPixmapName.at(level);
109 } 107 }
110} 108}
111 109
112QString Status::decodeHexOctString(QString s) 110QString Status::decodeHexOctString(QString s)
113{ 111{
114 QString value; 112 QString value;
diff --git a/noncore/games/mindbreaker/mindbreaker.cpp b/noncore/games/mindbreaker/mindbreaker.cpp
index e1f43d0..2b924c6 100644
--- a/noncore/games/mindbreaker/mindbreaker.cpp
+++ b/noncore/games/mindbreaker/mindbreaker.cpp
@@ -1,129 +1,125 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "mindbreaker.h" 21#include "mindbreaker.h"
22 22
23#include <qtopia/resource.h> 23#include <qtopia/resource.h>
24#include <qtopia/config.h> 24#include <qtopia/config.h>
25#include <qtopia/qpeapplication.h> 25#include <qtopia/qpeapplication.h>
26#include <qtoolbar.h> 26#include <qtoolbar.h>
27 27
28#include <qpainter.h>
29#include <qpixmap.h>
30#include <qtoolbutton.h> 28#include <qtoolbutton.h>
31#include <qpushbutton.h>
32#include <qmessagebox.h> 29#include <qmessagebox.h>
33#include <qlabel.h>
34#include <qlayout.h> 30#include <qlayout.h>
35#include <qtimer.h> 31#include <qtimer.h>
36 32
37#include <stdlib.h> 33#include <stdlib.h>
38#include <sys/time.h> 34#include <sys/time.h>
39#include <unistd.h> 35#include <unistd.h>
40 36
41static int pegRTTI = 3393393; 37static int pegRTTI = 3393393;
42 38
43static int adjusted_panel_height; 39static int adjusted_panel_height;
44static int adjusted_panel_width; 40static int adjusted_panel_width;
45 41
46static int adjusted_bin_margin; 42static int adjusted_bin_margin;
47static int adjusted_peg_size; 43static int adjusted_peg_size;
48static int adjusted_answerpeg_size; 44static int adjusted_answerpeg_size;
49 45
50static int adjusted_title_height; 46static int adjusted_title_height;
51static int adjusted_title_width; 47static int adjusted_title_width;
52 48
53static int adjusted_first_peg_x_diff; 49static int adjusted_first_peg_x_diff;
54static int adjusted_first_peg_y_diff; 50static int adjusted_first_peg_y_diff;
55static int adjusted_peg_spacing; 51static int adjusted_peg_spacing;
56 52
57static int adjusted_answerpegx; 53static int adjusted_answerpegx;
58static int adjusted_answerpegy; 54static int adjusted_answerpegy;
59static int adjusted_answerpeg_xdiff; 55static int adjusted_answerpeg_xdiff;
60static int adjusted_answerpeg_ydiff; 56static int adjusted_answerpeg_ydiff;
61 57
62static int adjusted_board_height; 58static int adjusted_board_height;
63static int adjusted_board_width; 59static int adjusted_board_width;
64 60
65static void setupBoardSize(int w, int h) 61static void setupBoardSize(int w, int h)
66{ 62{
67 adjusted_panel_width = w * 3/4; 63 adjusted_panel_width = w * 3/4;
68 adjusted_title_width = w * 3/4; 64 adjusted_title_width = w * 3/4;
69 65
70 adjusted_title_height = h/10; 66 adjusted_title_height = h/10;
71 adjusted_panel_height = (h-adjusted_title_height)/9; 67 adjusted_panel_height = (h-adjusted_title_height)/9;
72 68
73 adjusted_bin_margin = w * 10/240; 69 adjusted_bin_margin = w * 10/240;
74 adjusted_peg_size = adjusted_panel_height*3/4; 70 adjusted_peg_size = adjusted_panel_height*3/4;
75 adjusted_answerpeg_size = QMIN(adjusted_panel_width*15/180,adjusted_panel_height*15/25); 71 adjusted_answerpeg_size = QMIN(adjusted_panel_width*15/180,adjusted_panel_height*15/25);
76 72
77 // looks a bit dodgy on larger sizes 73 // looks a bit dodgy on larger sizes
78 if ( adjusted_peg_size > 40 ) 74 if ( adjusted_peg_size > 40 )
79 adjusted_peg_size = 40; 75 adjusted_peg_size = 40;
80 76
81 adjusted_first_peg_x_diff = w * 31/240-adjusted_peg_size/2; 77 adjusted_first_peg_x_diff = w * 31/240-adjusted_peg_size/2;
82 adjusted_first_peg_y_diff = (adjusted_panel_height - adjusted_peg_size)/2; 78 adjusted_first_peg_y_diff = (adjusted_panel_height - adjusted_peg_size)/2;
83 adjusted_peg_spacing = w * 30/240; 79 adjusted_peg_spacing = w * 30/240;
84 80
85 // looks a bit dodgy on larger sizes (still does though, but not as much...) 81 // looks a bit dodgy on larger sizes (still does though, but not as much...)
86 if ( adjusted_answerpeg_size > 22 ) 82 if ( adjusted_answerpeg_size > 22 )
87 adjusted_answerpeg_size = 22; 83 adjusted_answerpeg_size = 22;
88 84
89 adjusted_answerpegx = adjusted_panel_width * 159/180 - adjusted_answerpeg_size/2; 85 adjusted_answerpegx = adjusted_panel_width * 159/180 - adjusted_answerpeg_size/2;
90 adjusted_answerpegy = adjusted_panel_height/3 - adjusted_answerpeg_size/2; 86 adjusted_answerpegy = adjusted_panel_height/3 - adjusted_answerpeg_size/2;
91 adjusted_answerpeg_xdiff = adjusted_panel_width * 10/180; 87 adjusted_answerpeg_xdiff = adjusted_panel_width * 10/180;
92 adjusted_answerpeg_ydiff = adjusted_panel_height * 9/25; 88 adjusted_answerpeg_ydiff = adjusted_panel_height * 9/25;
93 89
94 adjusted_board_height = adjusted_title_height + (adjusted_panel_height * 9); 90 adjusted_board_height = adjusted_title_height + (adjusted_panel_height * 9);
95 adjusted_board_width = adjusted_panel_width + (adjusted_bin_margin * 2) + adjusted_peg_size; 91 adjusted_board_width = adjusted_panel_width + (adjusted_bin_margin * 2) + adjusted_peg_size;
96 92
97// qDebug("Adjusted width %d height %d", adjusted_board_width, adjusted_board_height); 93// qDebug("Adjusted width %d height %d", adjusted_board_width, adjusted_board_height);
98} 94}
99 95
100 96
101/* helper class, */ 97/* helper class, */
102class Peg : public QCanvasRectangle 98class Peg : public QCanvasRectangle
103{ 99{
104public: 100public:
105 Peg(QCanvas *canvas, int type, int go = -1, int pos = -1); 101 Peg(QCanvas *canvas, int type, int go = -1, int pos = -1);
106 int rtti() const {return pegRTTI; } 102 int rtti() const {return pegRTTI; }
107 void advance(int phase); 103 void advance(int phase);
108 104
109 bool hit( const QPoint &) const; 105 bool hit( const QPoint &) const;
110 106
111/* a placed peg is one that has been set down on the board correctly and 107/* a placed peg is one that has been set down on the board correctly and
112 should not be moved, only copied */ 108 should not be moved, only copied */
113 bool placed() const; 109 bool placed() const;
114 void setPlaced(bool); 110 void setPlaced(bool);
115 111
116 int pegGo() const; 112 int pegGo() const;
117 int pegPos() const; 113 int pegPos() const;
118 void setPegPos(int); 114 void setPegPos(int);
119 115
120 int type() const; 116 int type() const;
121 117
122 static void buildImages(); 118 static void buildImages();
123 static QImage imageForType(int t); 119 static QImage imageForType(int t);
124 120
125 static int eggLevel; 121 static int eggLevel;
126 122
127protected: 123protected:
128 void drawShape(QPainter &); 124 void drawShape(QPainter &);
129private: 125private:
diff --git a/noncore/games/minesweep/main.cpp b/noncore/games/minesweep/main.cpp
index bd70f7c..e187be5 100644
--- a/noncore/games/minesweep/main.cpp
+++ b/noncore/games/minesweep/main.cpp
@@ -1,27 +1,26 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "minesweep.h" 21#include "minesweep.h"
22 22
23#include <qpe/qpeapplication.h>
24#include <opie/oapplicationfactory.h> 23#include <opie/oapplicationfactory.h>
25 24
26OPIE_EXPORT_APP( OApplicationFactory<MineSweep> ) 25OPIE_EXPORT_APP( OApplicationFactory<MineSweep> )
27 26
diff --git a/noncore/games/minesweep/minefield.cpp b/noncore/games/minesweep/minefield.cpp
index 1790110..72c05b0 100644
--- a/noncore/games/minesweep/minefield.cpp
+++ b/noncore/games/minesweep/minefield.cpp
@@ -1,124 +1,120 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "minefield.h" 20#include "minefield.h"
21 21
22#include <qtopia/config.h> 22#include <qtopia/config.h>
23#include <qtopia/qpeapplication.h> 23#include <qtopia/qpeapplication.h>
24 24
25#include <qpainter.h>
26#include <qdrawutil.h>
27#include <qpixmap.h>
28#include <qimage.h>
29#include <qtimer.h> 25#include <qtimer.h>
30 26
31#include <stdlib.h> 27#include <stdlib.h>
32 28
33static const char *pix_flag[]={ 29static const char *pix_flag[]={
34"13 13 3 1", 30"13 13 3 1",
35"# c #000000", 31"# c #000000",
36"x c #ff0000", 32"x c #ff0000",
37". c None", 33". c None",
38".............", 34".............",
39".............", 35".............",
40".....#xxxxxx.", 36".....#xxxxxx.",
41".....#xxxxxx.", 37".....#xxxxxx.",
42".....#xxxxxx.", 38".....#xxxxxx.",
43".....#xxxxxx.", 39".....#xxxxxx.",
44".....#.......", 40".....#.......",
45".....#.......", 41".....#.......",
46".....#.......", 42".....#.......",
47".....#.......", 43".....#.......",
48"...#####.....", 44"...#####.....",
49"..#######....", 45"..#######....",
50"............."}; 46"............."};
51 47
52static const char *pix_mine[]={ 48static const char *pix_mine[]={
53"13 13 3 1", 49"13 13 3 1",
54"# c #000000", 50"# c #000000",
55". c None", 51". c None",
56"a c #ffffff", 52"a c #ffffff",
57"......#......", 53"......#......",
58"......#......", 54"......#......",
59"..#.#####.#..", 55"..#.#####.#..",
60"...#######...", 56"...#######...",
61"..##aa#####..", 57"..##aa#####..",
62"..##aa#####..", 58"..##aa#####..",
63"#############", 59"#############",
64"..#########..", 60"..#########..",
65"..#########..", 61"..#########..",
66"...#######...", 62"...#######...",
67"..#.#####.#..", 63"..#.#####.#..",
68"......#......", 64"......#......",
69"......#......"}; 65"......#......"};
70 66
71 67
72static const int maxGrid = 28; 68static const int maxGrid = 28;
73static const int minGrid = 12; 69static const int minGrid = 12;
74 70
75 71
76 72
77class Mine : public Qt 73class Mine : public Qt
78{ 74{
79public: 75public:
80 enum MineState { 76 enum MineState {
81 Hidden = 0, 77 Hidden = 0,
82 Empty, 78 Empty,
83 Mined, 79 Mined,
84 Flagged, 80 Flagged,
85#ifdef MARK_UNSURE 81#ifdef MARK_UNSURE
86 Unsure, 82 Unsure,
87#endif 83#endif
88 Exploded, 84 Exploded,
89 Wrong 85 Wrong
90 }; 86 };
91 87
92 Mine( MineField* ); 88 Mine( MineField* );
93 void paint( QPainter * p, const QColorGroup & cg, const QRect & cr ); 89 void paint( QPainter * p, const QColorGroup & cg, const QRect & cr );
94 90
95 QSize sizeHint() const { return QSize( maxGrid, maxGrid ); } 91 QSize sizeHint() const { return QSize( maxGrid, maxGrid ); }
96 92
97 void activate( bool sure = TRUE ); 93 void activate( bool sure = TRUE );
98 void setHint( int ); 94 void setHint( int );
99 95
100 void setState( MineState ); 96 void setState( MineState );
101 MineState state() const { return st; } 97 MineState state() const { return st; }
102 98
103 bool isMined() const { return mined; } 99 bool isMined() const { return mined; }
104 void setMined( bool m ) { mined = m; } 100 void setMined( bool m ) { mined = m; }
105 101
106 static void paletteChange(); 102 static void paletteChange();
107 103
108private: 104private:
109 bool mined; 105 bool mined;
110 int hint; 106 int hint;
111 107
112 MineState st; 108 MineState st;
113 MineField *field; 109 MineField *field;
114 110
115 static QPixmap* knownField; 111 static QPixmap* knownField;
116 static QPixmap* unknownField; 112 static QPixmap* unknownField;
117 static QPixmap* flag_pix; 113 static QPixmap* flag_pix;
118 static QPixmap* mine_pix; 114 static QPixmap* mine_pix;
119}; 115};
120 116
121QPixmap* Mine::knownField = 0; 117QPixmap* Mine::knownField = 0;
122QPixmap* Mine::unknownField = 0; 118QPixmap* Mine::unknownField = 0;
123QPixmap* Mine::flag_pix = 0; 119QPixmap* Mine::flag_pix = 0;
124QPixmap* Mine::mine_pix = 0; 120QPixmap* Mine::mine_pix = 0;
diff --git a/noncore/games/minesweep/minesweep.cpp b/noncore/games/minesweep/minesweep.cpp
index d707dab..4a6a92c 100644
--- a/noncore/games/minesweep/minesweep.cpp
+++ b/noncore/games/minesweep/minesweep.cpp
@@ -1,133 +1,128 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "minesweep.h" 21#include "minesweep.h"
22#include "minefield.h" 22#include "minefield.h"
23 23
24#include <qtopia/qpeapplication.h> 24#include <qtopia/qpeapplication.h>
25#include <qtopia/resource.h> 25#include <qtopia/resource.h>
26#include <qtopia/config.h> 26#include <qtopia/config.h>
27 27
28#include <qtoolbar.h> 28#include <qtoolbar.h>
29#include <qmenubar.h> 29#include <qmenubar.h>
30#include <qpopupmenu.h>
31#include <qpushbutton.h> 30#include <qpushbutton.h>
32#include <qlcdnumber.h> 31#include <qlcdnumber.h>
33#include <qmessagebox.h>
34#include <qtimer.h> 32#include <qtimer.h>
35#include <qpalette.h>
36#include <qapplication.h>
37#include <qlayout.h>
38#include <qlabel.h> 33#include <qlabel.h>
39 34
40#include <stdlib.h> 35#include <stdlib.h>
41#include <time.h> 36#include <time.h>
42 37
43 38
44 39
45 40
46static const char *pix_new[]={ 41static const char *pix_new[]={
47"20 20 3 1", 42"20 20 3 1",
48" c None", 43" c None",
49"# c #00FF00", 44"# c #00FF00",
50". c #000000", 45". c #000000",
51" ", 46" ",
52" ...... ", 47" ...... ",
53" ..######.. ", 48" ..######.. ",
54" .##########. ", 49" .##########. ",
55" .############. ", 50" .############. ",
56" .##############. ", 51" .##############. ",
57" .##############. ", 52" .##############. ",
58" .################. ", 53" .################. ",
59" .################. ", 54" .################. ",
60" .################. ", 55" .################. ",
61" .################. ", 56" .################. ",
62" .################. ", 57" .################. ",
63" .################. ", 58" .################. ",
64" .##############. ", 59" .##############. ",
65" .##############. ", 60" .##############. ",
66" .############. ", 61" .############. ",
67" .##########. ", 62" .##########. ",
68" ..######.. ", 63" ..######.. ",
69" ...... ", 64" ...... ",
70" "}; 65" "};
71 66
72 67
73/* XPM */ 68/* XPM */
74static const char * happy_xpm[] = { 69static const char * happy_xpm[] = {
75"20 20 3 1", 70"20 20 3 1",
76 " c None", 71 " c None",
77 ".c #ffff3f ", 72 ".c #ffff3f ",
78 "#c #000000", 73 "#c #000000",
79" ", 74" ",
80" ###### ", 75" ###### ",
81" ##......## ", 76" ##......## ",
82" #..........# ", 77" #..........# ",
83" #............# ", 78" #............# ",
84" #..............# ", 79" #..............# ",
85" #..............# ", 80" #..............# ",
86" #....##....##....# ", 81" #....##....##....# ",
87" #....##....##....# ", 82" #....##....##....# ",
88" #................# ", 83" #................# ",
89" #................# ", 84" #................# ",
90" #................# ", 85" #................# ",
91" #...#........#...# ", 86" #...#........#...# ",
92" #.##........##.# ", 87" #.##........##.# ",
93" #...########...# ", 88" #...########...# ",
94" #...######...# ", 89" #...######...# ",
95" #..........# ", 90" #..........# ",
96" ##......## ", 91" ##......## ",
97" ###### ", 92" ###### ",
98" "}; 93" "};
99 94
100 95
101/* XPM */ 96/* XPM */
102static const char * worried_xpm[] = { 97static const char * worried_xpm[] = {
103"20 20 3 1", 98"20 20 3 1",
104 " c None", 99 " c None",
105 ".c #ffff3f", 100 ".c #ffff3f",
106 "#c #000000", 101 "#c #000000",
107" ", 102" ",
108" ###### ", 103" ###### ",
109" ##......## ", 104" ##......## ",
110" #..........# ", 105" #..........# ",
111" #............# ", 106" #............# ",
112" #..............# ", 107" #..............# ",
113" #..............# ", 108" #..............# ",
114" #....##....##....# ", 109" #....##....##....# ",
115" #....##....##....# ", 110" #....##....##....# ",
116" #................# ", 111" #................# ",
117" #................# ", 112" #................# ",
118" #................# ", 113" #................# ",
119" #................# ", 114" #................# ",
120" #....######....# ", 115" #....######....# ",
121" #..............# ", 116" #..............# ",
122" #............# ", 117" #............# ",
123" #..........# ", 118" #..........# ",
124" ##......## ", 119" ##......## ",
125" ###### ", 120" ###### ",
126" "}; 121" "};
127 122
128 123
129/* XPM */ 124/* XPM */
130static const char * dead_xpm[] = { 125static const char * dead_xpm[] = {
131"20 20 3 1", 126"20 20 3 1",
132 " c None", 127 " c None",
133 ".c #ffff3f", 128 ".c #ffff3f",
diff --git a/noncore/games/oyatzee/oyatzee.cpp b/noncore/games/oyatzee/oyatzee.cpp
index 0bd22f6..86318db 100644
--- a/noncore/games/oyatzee/oyatzee.cpp
+++ b/noncore/games/oyatzee/oyatzee.cpp
@@ -1,108 +1,102 @@
1#include "oyatzee.h" 1#include "oyatzee.h"
2 2
3#include <qmessagebox.h> 3#include <qmessagebox.h>
4#include <qapplication.h>
5#include <qdir.h>
6#include <qlabel.h>
7#include <qpushbutton.h> 4#include <qpushbutton.h>
8#include <qtimer.h>
9#include <qvbox.h>
10#include <qpainter.h> 5#include <qpainter.h>
11#include <qlayout.h> 6#include <qlayout.h>
12#include <qpoint.h>
13 7
14#include <stdlib.h> 8#include <stdlib.h>
15 9
16OYatzee::OYatzee( QWidget *parent , const char *name, WFlags fl ) : QMainWindow( parent , name , fl ) 10OYatzee::OYatzee( QWidget *parent , const char *name, WFlags fl ) : QMainWindow( parent , name , fl )
17{ 11{
18 QWidget *thing = new QWidget( this ); 12 QWidget *thing = new QWidget( this );
19 setCentralWidget( thing ); 13 setCentralWidget( thing );
20 14
21 setCaption( tr( "OYatzee" ) ); 15 setCaption( tr( "OYatzee" ) );
22 16
23 setPlayerNumber( 4 ); 17 setPlayerNumber( 4 );
24 setRoundsNumber( 1 ); 18 setRoundsNumber( 1 );
25 19
26 lastPlayerFinished = false; 20 lastPlayerFinished = false;
27 currentPlayer = 1; 21 currentPlayer = 1;
28 22
29 ps.append( new Player( "Carsten" ) ); 23 ps.append( new Player( "Carsten" ) );
30 ps.append( new Player( "Julia" ) ); 24 ps.append( new Player( "Julia" ) );
31 ps.append( new Player( "Christine" ) ); 25 ps.append( new Player( "Christine" ) );
32 ps.append( new Player( "Stephan" ) ); 26 ps.append( new Player( "Stephan" ) );
33 27
34 28
35 QVBoxLayout *vbox = new QVBoxLayout( thing ); 29 QVBoxLayout *vbox = new QVBoxLayout( thing );
36 30
37 sb = new Scoreboard( ps, thing , "sb" ); 31 sb = new Scoreboard( ps, thing , "sb" );
38 connect( sb->pb , SIGNAL( item( int ) ), this , SLOT( slotEndRound( int ) ) ); 32 connect( sb->pb , SIGNAL( item( int ) ), this , SLOT( slotEndRound( int ) ) );
39 33
40 dw = new DiceWidget( thing , "dw" ); 34 dw = new DiceWidget( thing , "dw" );
41 dw->setMaximumHeight( this->height()/4 ); 35 dw->setMaximumHeight( this->height()/4 );
42 connect( dw->rollButton, SIGNAL( clicked() ), this , SLOT( slotRollDices() ) ); 36 connect( dw->rollButton, SIGNAL( clicked() ), this , SLOT( slotRollDices() ) );
43 37
44 vbox->addWidget( sb ); 38 vbox->addWidget( sb );
45 vbox->addWidget( dw ); 39 vbox->addWidget( dw );
46} 40}
47 41
48void OYatzee::slotEndRound( int item ) 42void OYatzee::slotEndRound( int item )
49{ 43{
50 qDebug( "Der User hat Nummer %d ausgewählt" , item ); 44 qDebug( "Der User hat Nummer %d ausgewählt" , item );
51 45
52 /* 46 /*
53 * if the user clicked on Total, Bonus or Score and thus not on a 47 * if the user clicked on Total, Bonus or Score and thus not on a
54 * selectable item return and do nothing 48 * selectable item return and do nothing
55 */ 49 */
56 if ( item == 7 || item == 8 || item == 16 ) return; 50 if ( item == 7 || item == 8 || item == 16 ) return;
57 51
58 /* 52 /*
59 * check if the user can really click on that item 53 * check if the user can really click on that item
60 */ 54 */
61 if ( posibilities.find( item ) == posibilities.end() ) return; 55 if ( posibilities.find( item ) == posibilities.end() ) return;
62 56
63 QValueListInt numbers; 57 QValueListInt numbers;
64 58
65 Dice *d = dw->diceList.first(); 59 Dice *d = dw->diceList.first();
66 for ( ; d != 0 ; d = dw->diceList.next() ) 60 for ( ; d != 0 ; d = dw->diceList.next() )
67 { 61 {
68 numbers.append( d->hasValue() ); 62 numbers.append( d->hasValue() );
69 } 63 }
70 64
71 int points = 0; 65 int points = 0;
72 66
73 switch ( item ) 67 switch ( item )
74 { 68 {
75 case Ones: 69 case Ones:
76 points = getPoints( 1 , numbers ); 70 points = getPoints( 1 , numbers );
77 break; 71 break;
78 case Twos: 72 case Twos:
79 points = getPoints( 2 , numbers ); 73 points = getPoints( 2 , numbers );
80 break; 74 break;
81 case Threes: 75 case Threes:
82 points = getPoints( 3 , numbers ); 76 points = getPoints( 3 , numbers );
83 break; 77 break;
84 case Fours: 78 case Fours:
85 points = getPoints( 4 , numbers ); 79 points = getPoints( 4 , numbers );
86 break; 80 break;
87 case Fives: 81 case Fives:
88 points = getPoints( 5 , numbers ); 82 points = getPoints( 5 , numbers );
89 break; 83 break;
90 case Sixes: 84 case Sixes:
91 points = getPoints( 6 , numbers ); 85 points = getPoints( 6 , numbers );
92 break; 86 break;
93 case ThreeOfAKind: 87 case ThreeOfAKind:
94 points = oakPoints; 88 points = oakPoints;
95 break; 89 break;
96 case FourOfAKind: 90 case FourOfAKind:
97 points = oakPoints; 91 points = oakPoints;
98 break; 92 break;
99 case FullHouse: 93 case FullHouse:
100 points = 25; 94 points = 25;
101 break; 95 break;
102 case SStraight: 96 case SStraight:
103 points = 30; 97 points = 30;
104 break; 98 break;
105 case LStraight: 99 case LStraight:
106 points = 40; 100 points = 40;
107 break; 101 break;
108 case Yatzee: 102 case Yatzee:
diff --git a/noncore/games/parashoot/base.cpp b/noncore/games/parashoot/base.cpp
index cdf1dfa..5f3c79d 100644
--- a/noncore/games/parashoot/base.cpp
+++ b/noncore/games/parashoot/base.cpp
@@ -1,77 +1,75 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include "codes.h" 20#include "codes.h"
21#include "base.h" 21#include "base.h"
22#include "man.h"
23 22
24#include <qtopia/resource.h> 23#include <qtopia/resource.h>
25 24
26#include <qregexp.h>
27 25
28int damage; 26int damage;
29 27
30Base::Base(QCanvas* canvas) : 28Base::Base(QCanvas* canvas) :
31 QCanvasSprite(0, canvas), 29 QCanvasSprite(0, canvas),
32 kaboom("landmine"), 30 kaboom("landmine"),
33 ohdear("crmble01") 31 ohdear("crmble01")
34{ 32{
35 basearray = new QCanvasPixmapArray(); 33 basearray = new QCanvasPixmapArray();
36 QString b0 = Resource::findPixmap("parashoot/b0001"); 34 QString b0 = Resource::findPixmap("parashoot/b0001");
37 b0.replace(QRegExp("0001"),"%1"); 35 b0.replace(QRegExp("0001"),"%1");
38 basearray->readPixmaps(b0, 4); 36 basearray->readPixmaps(b0, 4);
39 setSequence(basearray); 37 setSequence(basearray);
40 setFrame(0); 38 setFrame(0);
41 move(2, canvas->height()-50); 39 move(2, canvas->height()-50);
42 setZ(10); 40 setZ(10);
43 show(); 41 show();
44 damage = 0; 42 damage = 0;
45} 43}
46 44
47void Base::damageBase() 45void Base::damageBase()
48{ 46{
49 damage++; 47 damage++;
50 48
51 switch(damage) { 49 switch(damage) {
52 case 1: setFrame(1); ohdear.play(); break; 50 case 1: setFrame(1); ohdear.play(); break;
53 case 2: setFrame(2); ohdear.play(); break; 51 case 2: setFrame(2); ohdear.play(); break;
54 case 3: setFrame(3); kaboom.play(); break; 52 case 3: setFrame(3); kaboom.play(); break;
55 } 53 }
56 show(); 54 show();
57} 55}
58 56
59bool Base::baseDestroyed() 57bool Base::baseDestroyed()
60{ 58{
61 return (damage >= 3); 59 return (damage >= 3);
62} 60}
63 61
64Base::~Base() 62Base::~Base()
65{ 63{
66} 64}
67 65
68int Base::rtti() const 66int Base::rtti() const
69{ 67{
70 return base_rtti; 68 return base_rtti;
71} 69}
72 70
73void 71void
74Base::reposition(void) 72Base::reposition(void)
75{ 73{
76 move(2, canvas()->height()-50); 74 move(2, canvas()->height()-50);
77} 75}
diff --git a/noncore/games/parashoot/cannon.cpp b/noncore/games/parashoot/cannon.cpp
index 5671351..330d850 100644
--- a/noncore/games/parashoot/cannon.cpp
+++ b/noncore/games/parashoot/cannon.cpp
@@ -1,119 +1,118 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include <qtopia/resource.h> 21#include <qtopia/resource.h>
22 22
23#include <qregexp.h>
24 23
25#include "codes.h" 24#include "codes.h"
26#include "cannon.h" 25#include "cannon.h"
27 26
28Cannon::Cannon(QCanvas* canvas) : 27Cannon::Cannon(QCanvas* canvas) :
29 QCanvasSprite(0, canvas) 28 QCanvasSprite(0, canvas)
30{ 29{
31shotsfired=0; 30shotsfired=0;
32 index = 8; 31 index = 8;
33 cannonx = 0; 32 cannonx = 0;
34 cannony = 0; 33 cannony = 0;
35 cannonarray = new QCanvasPixmapArray(); 34 cannonarray = new QCanvasPixmapArray();
36 QString c0 = Resource::findPixmap("parashoot/can0001"); 35 QString c0 = Resource::findPixmap("parashoot/can0001");
37 c0.replace(QRegExp("0001"),"%1"); 36 c0.replace(QRegExp("0001"),"%1");
38 cannonarray->readPixmaps(c0,17); 37 cannonarray->readPixmaps(c0,17);
39 setSequence(cannonarray); 38 setSequence(cannonarray);
40 setFrame(index); 39 setFrame(index);
41 40
42 reposition(); 41 reposition();
43 42
44 movedir = NoDir; 43 movedir = NoDir;
45 moveDelay = 0; 44 moveDelay = 0;
46 setAnimated(TRUE); 45 setAnimated(TRUE);
47 show(); 46 show();
48} 47}
49 48
50void Cannon::advance(int stage) 49void Cannon::advance(int stage)
51{ 50{
52 if ( stage == 1 && moveDelay-- == 0 ) { 51 if ( stage == 1 && moveDelay-- == 0 ) {
53 if (movedir == Left) { 52 if (movedir == Left) {
54 if (index > 0) { 53 if (index > 0) {
55 setFrame(index-1); 54 setFrame(index-1);
56 index--; 55 index--;
57 } 56 }
58 } 57 }
59 if (movedir == Right) { 58 if (movedir == Right) {
60 if (index < 16) { 59 if (index < 16) {
61 setFrame(index+1); 60 setFrame(index+1);
62 index++; 61 index++;
63 } 62 }
64 } 63 }
65 moveDelay = 0; 64 moveDelay = 0;
66 } 65 }
67} 66}
68 67
69void Cannon::pointCannon(Direction dir) 68void Cannon::pointCannon(Direction dir)
70{ 69{
71 movedir = dir; 70 movedir = dir;
72 moveDelay = 0; 71 moveDelay = 0;
73 advance(1); 72 advance(1);
74 moveDelay = 1; 73 moveDelay = 1;
75} 74}
76 75
77void Cannon::setCoords() 76void Cannon::setCoords()
78{ 77{
79 switch(index) { 78 switch(index) {
80 case 0: cannonx = barrelxpos-29; cannony = barrelypos-8; break; 79 case 0: cannonx = barrelxpos-29; cannony = barrelypos-8; break;
81 case 1: cannonx = barrelxpos-27; cannony = barrelypos-8; break; 80 case 1: cannonx = barrelxpos-27; cannony = barrelypos-8; break;
82 case 2: cannonx = barrelxpos-25; cannony = barrelypos-6; break; 81 case 2: cannonx = barrelxpos-25; cannony = barrelypos-6; break;
83 case 3: cannonx = barrelxpos-23; cannony = barrelypos-4; break; 82 case 3: cannonx = barrelxpos-23; cannony = barrelypos-4; break;
84 case 4: cannonx = barrelxpos-21; cannony = barrelypos-2; break; 83 case 4: cannonx = barrelxpos-21; cannony = barrelypos-2; break;
85 case 5: cannonx = barrelxpos-19; cannony = barrelypos; break; 84 case 5: cannonx = barrelxpos-19; cannony = barrelypos; break;
86 case 6: cannonx = barrelxpos-15; cannony = barrelypos; break; 85 case 6: cannonx = barrelxpos-15; cannony = barrelypos; break;
87 case 7: cannonx = barrelxpos-10; cannony = barrelypos; break; 86 case 7: cannonx = barrelxpos-10; cannony = barrelypos; break;
88 case 8: cannonx = barrelxpos; cannony = barrelypos; break; 87 case 8: cannonx = barrelxpos; cannony = barrelypos; break;
89 case 9: cannonx = barrelxpos+2; cannony = barrelypos; break; 88 case 9: cannonx = barrelxpos+2; cannony = barrelypos; break;
90 case 10: cannonx = barrelxpos+6; cannony = barrelypos; break; 89 case 10: cannonx = barrelxpos+6; cannony = barrelypos; break;
91 case 11: cannonx = barrelxpos+8; cannony = barrelypos; break; 90 case 11: cannonx = barrelxpos+8; cannony = barrelypos; break;
92 case 12: cannonx = barrelxpos+12; cannony = barrelypos-2; break; 91 case 12: cannonx = barrelxpos+12; cannony = barrelypos-2; break;
93 case 13: cannonx = barrelxpos+18; cannony = barrelypos-4; break; 92 case 13: cannonx = barrelxpos+18; cannony = barrelypos-4; break;
94 case 14: cannonx = barrelxpos+22; cannony = barrelypos-6; break; 93 case 14: cannonx = barrelxpos+22; cannony = barrelypos-6; break;
95 case 15: cannonx = barrelxpos+26; cannony = barrelypos-8; break; 94 case 15: cannonx = barrelxpos+26; cannony = barrelypos-8; break;
96 case 16: cannonx = barrelxpos+28; cannony = barrelypos-8; break; 95 case 16: cannonx = barrelxpos+28; cannony = barrelypos-8; break;
97 } 96 }
98} 97}
99 98
100double Cannon::shootAngle() 99double Cannon::shootAngle()
101{ 100{
102 switch(index) { 101 switch(index) {
103 case 0: return 30.0; 102 case 0: return 30.0;
104 case 1: return 37.5; 103 case 1: return 37.5;
105 case 2: return 45.0; 104 case 2: return 45.0;
106 case 3: return 52.5; 105 case 3: return 52.5;
107 case 4: return 60.0; 106 case 4: return 60.0;
108 case 5: return 67.5; 107 case 5: return 67.5;
109 case 6: return 75.0; 108 case 6: return 75.0;
110 case 7: return 82.5; 109 case 7: return 82.5;
111 case 8: return 90.0; 110 case 8: return 90.0;
112 case 9: return 97.5; 111 case 9: return 97.5;
113 case 10: return 105.0; 112 case 10: return 105.0;
114 case 11: return 112.5; 113 case 11: return 112.5;
115 case 12: return 120.0; 114 case 12: return 120.0;
116 case 13: return 127.5; 115 case 13: return 127.5;
117 case 14: return 135.0; 116 case 14: return 135.0;
118 case 15: return 142.5; 117 case 15: return 142.5;
119 case 16: return 150.0; 118 case 16: return 150.0;
diff --git a/noncore/games/parashoot/helicopter.cpp b/noncore/games/parashoot/helicopter.cpp
index 036b21e..7d91cd1 100644
--- a/noncore/games/parashoot/helicopter.cpp
+++ b/noncore/games/parashoot/helicopter.cpp
@@ -1,120 +1,119 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "helicopter.h" 21#include "helicopter.h"
22#include "man.h" 22#include "man.h"
23#include "codes.h" 23#include "codes.h"
24 24
25#include <qtopia/resource.h> 25#include <qtopia/resource.h>
26 26
27#include <qregexp.h>
28 27
29static QList<Helicopter> all; 28static QList<Helicopter> all;
30 29
31Helicopter::Helicopter(QCanvas* canvas) : 30Helicopter::Helicopter(QCanvas* canvas) :
32 QCanvasSprite(0, canvas), 31 QCanvasSprite(0, canvas),
33 chikachika("aland01") 32 chikachika("aland01")
34{ 33{
35 all.append(this); 34 all.append(this);
36 hits = 0; 35 hits = 0;
37 QCanvasPixmapArray* helicopterarray = new QCanvasPixmapArray(); 36 QCanvasPixmapArray* helicopterarray = new QCanvasPixmapArray();
38 QString h0 = Resource::findPixmap("parashoot/helicopter0001"); 37 QString h0 = Resource::findPixmap("parashoot/helicopter0001");
39 h0.replace(QRegExp("0001"),"%1"); 38 h0.replace(QRegExp("0001"),"%1");
40 helicopterarray->readPixmaps(h0,4 ); 39 helicopterarray->readPixmaps(h0,4 );
41 40
42 setSequence(helicopterarray); 41 setSequence(helicopterarray);
43 setAnimated(true); 42 setAnimated(true);
44 move(canvas->width(), 5); 43 move(canvas->width(), 5);
45 setVelocity(-2, 0); 44 setVelocity(-2, 0);
46 chikachika.playLoop(); 45 chikachika.playLoop();
47 show(); 46 show();
48} 47}
49 48
50Helicopter::~Helicopter() 49Helicopter::~Helicopter()
51{ 50{
52 all.remove(this); 51 all.remove(this);
53} 52}
54 53
55int fr = 0; 54int fr = 0;
56 55
57void Helicopter::advance(int phase) 56void Helicopter::advance(int phase)
58{ 57{
59 QCanvasSprite::advance(phase); 58 QCanvasSprite::advance(phase);
60 if (phase == 0) { 59 if (phase == 0) {
61 if (frame() == 3) { 60 if (frame() == 3) {
62 delete this; 61 delete this;
63 return; 62 return;
64 } 63 }
65 64
66 if (hits >= 2) { 65 if (hits >= 2) {
67 setFrame(3); 66 setFrame(3);
68 } else { 67 } else {
69 setFrame(fr%3); 68 setFrame(fr%3);
70 fr++; 69 fr++;
71 checkCollision(); 70 checkCollision();
72 } 71 }
73 } 72 }
74} 73}
75 74
76void Helicopter::checkCollision() 75void Helicopter::checkCollision()
77{ 76{
78 if (x() == 6) { 77 if (x() == 6) {
79 setAnimated(false); //setVelocity(0, 0); 78 setAnimated(false); //setVelocity(0, 0);
80 dropman(); 79 dropman();
81 } 80 }
82 if (x() < 0) 81 if (x() < 0)
83 done(); 82 done();
84} 83}
85 84
86void Helicopter::dropman() 85void Helicopter::dropman()
87{ 86{
88 (void)new Man(canvas(), 15, 25); 87 (void)new Man(canvas(), 15, 25);
89 (void)new Man(canvas(), 35, 25); 88 (void)new Man(canvas(), 35, 25);
90 takeOff(); 89 takeOff();
91} 90}
92 91
93void Helicopter::done() 92void Helicopter::done()
94{ 93{
95 hits++; 94 hits++;
96} 95}
97 96
98void Helicopter::takeOff() 97void Helicopter::takeOff()
99{ 98{
100 setVelocity(-1, 0); 99 setVelocity(-1, 0);
101} 100}
102 101
103int Helicopter::rtti() const 102int Helicopter::rtti() const
104{ 103{
105 return helicopter_rtti; 104 return helicopter_rtti;
106} 105}
107 106
108void Helicopter::silenceAll() 107void Helicopter::silenceAll()
109{ 108{
110 for (Helicopter* h = all.first(); h; h = all.next()) 109 for (Helicopter* h = all.first(); h; h = all.next())
111 h->chikachika.stop(); 110 h->chikachika.stop();
112} 111}
113 112
114void Helicopter::deleteAll() 113void Helicopter::deleteAll()
115{ 114{
116 Helicopter* h; 115 Helicopter* h;
117 while ((h = all.first())) 116 while ((h = all.first()))
118 delete h; 117 delete h;
119} 118}
120 119
diff --git a/noncore/games/parashoot/interface.cpp b/noncore/games/parashoot/interface.cpp
index 948b92c..5c9b0ef 100644
--- a/noncore/games/parashoot/interface.cpp
+++ b/noncore/games/parashoot/interface.cpp
@@ -1,126 +1,122 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "interface.h" 21#include "interface.h"
22#include "man.h" 22#include "man.h"
23 23
24#include <qtopia/qpeapplication.h> 24#include <qtopia/qpeapplication.h>
25#include <qtopia/resource.h> 25#include <qtopia/resource.h>
26 26
27#include <qlabel.h>
28#include <qmessagebox.h>
29#include <qapplication.h>
30#include <qstyle.h>
31#include <qtoolbar.h> 27#include <qtoolbar.h>
32#include <qtoolbutton.h> 28#include <qtoolbutton.h>
33 29
34ParaShoot::ParaShoot(QWidget* parent, const char* name, WFlags f) : 30ParaShoot::ParaShoot(QWidget* parent, const char* name, WFlags f) :
35 QMainWindow(parent,name,f), 31 QMainWindow(parent,name,f),
36 canvas( 232, 258 ), 32 canvas( 232, 258 ),
37 cannon(NULL), 33 cannon(NULL),
38 base(NULL), 34 base(NULL),
39 gamestopped( true ), 35 gamestopped( true ),
40 waitover( false ), 36 waitover( false ),
41 fanfare("level_up"), 37 fanfare("level_up"),
42 score(0) 38 score(0)
43{ 39{
44 QPEApplication::grabKeyboard(); 40 QPEApplication::grabKeyboard();
45 QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff ); 41 QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff );
46 42
47 updatespeed = 80; 43 updatespeed = 80;
48 canvas.setAdvancePeriod(80); 44 canvas.setAdvancePeriod(80);
49 45
50 pb = new QCanvasView(&canvas, this); 46 pb = new QCanvasView(&canvas, this);
51 pb->setFocus(); 47 pb->setFocus();
52 48
53 setToolBarsMovable( FALSE ); 49 setToolBarsMovable( FALSE );
54 50
55 QToolBar* toolbar = new QToolBar(this); 51 QToolBar* toolbar = new QToolBar(this);
56 toolbar->setHorizontalStretchable( TRUE ); 52 toolbar->setHorizontalStretchable( TRUE );
57 53
58 setCaption( tr("ParaShoot") ); 54 setCaption( tr("ParaShoot") );
59 new QToolButton( Resource::loadIconSet("new"), tr("New Game"), 0, 55 new QToolButton( Resource::loadIconSet("new"), tr("New Game"), 0,
60 this, SLOT(newGame()), toolbar, "New Game"); 56 this, SLOT(newGame()), toolbar, "New Game");
61 57
62 levelscore = new QLabel(toolbar); 58 levelscore = new QLabel(toolbar);
63 levelscore->setBackgroundMode( PaletteButton ); 59 levelscore->setBackgroundMode( PaletteButton );
64 levelscore->setAlignment( AlignRight | AlignVCenter | ExpandTabs ); 60 levelscore->setAlignment( AlignRight | AlignVCenter | ExpandTabs );
65 toolbar->setStretchableWidget( levelscore ); 61 toolbar->setStretchableWidget( levelscore );
66 showScore(0,0); 62 showScore(0,0);
67 63
68 setCentralWidget(pb); 64 setCentralWidget(pb);
69 65
70 autoDropTimer = new QTimer(this); 66 autoDropTimer = new QTimer(this);
71 connect (autoDropTimer, SIGNAL(timeout()), this, SLOT(play()) ); 67 connect (autoDropTimer, SIGNAL(timeout()), this, SLOT(play()) );
72 68
73 pauseTimer = new QTimer(this); 69 pauseTimer = new QTimer(this);
74 connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) ); 70 connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) );
75 71
76 setFocusPolicy(StrongFocus); 72 setFocusPolicy(StrongFocus);
77} 73}
78 74
79 75
80void ParaShoot::resizeEvent(QResizeEvent *) 76void ParaShoot::resizeEvent(QResizeEvent *)
81{ 77{
82 QSize s = centralWidget()->size(); 78 QSize s = centralWidget()->size();
83 int fw = style().defaultFrameWidth(); 79 int fw = style().defaultFrameWidth();
84 canvas.resize( s.width() - fw - 2, s.height() - fw - 2); 80 canvas.resize( s.width() - fw - 2, s.height() - fw - 2);
85 81
86 QImage bgimage = Resource::loadImage("parashoot/sky"); 82 QImage bgimage = Resource::loadImage("parashoot/sky");
87 QPixmap bgpixmap; 83 QPixmap bgpixmap;
88 84
89 bgpixmap.convertFromImage(bgimage.smoothScale(canvas.width(), 85 bgpixmap.convertFromImage(bgimage.smoothScale(canvas.width(),
90 canvas.height()), QPixmap::Auto); 86 canvas.height()), QPixmap::Auto);
91 canvas.setBackgroundPixmap(bgpixmap); 87 canvas.setBackgroundPixmap(bgpixmap);
92 88
93 if (base) { 89 if (base) {
94 base->reposition(); 90 base->reposition();
95 } 91 }
96 92
97 if (cannon) { 93 if (cannon) {
98 cannon->reposition(); 94 cannon->reposition();
99 } 95 }
100} 96}
101 97
102void ParaShoot::focusOutEvent (QFocusEvent *) 98void ParaShoot::focusOutEvent (QFocusEvent *)
103{ 99{
104 if (!gamestopped) 100 if (!gamestopped)
105 canvas.setAdvancePeriod(-1); 101 canvas.setAdvancePeriod(-1);
106} 102}
107 103
108void ParaShoot::focusInEvent (QFocusEvent *) 104void ParaShoot::focusInEvent (QFocusEvent *)
109{ 105{
110 if (!gamestopped) 106 if (!gamestopped)
111 canvas.setAdvancePeriod(updatespeed); 107 canvas.setAdvancePeriod(updatespeed);
112} 108}
113 109
114void ParaShoot::showScore( int score, int level ) 110void ParaShoot::showScore( int score, int level )
115{ 111{
116 levelscore->setText(tr(" Level: %1 Score: %2 ").arg(score).arg(level) ); 112 levelscore->setText(tr(" Level: %1 Score: %2 ").arg(score).arg(level) );
117} 113}
118 114
119 115
120void ParaShoot::newGame() 116void ParaShoot::newGame()
121{ 117{
122 clear(); 118 clear();
123 if (pauseTimer->isActive()) 119 if (pauseTimer->isActive())
124 pauseTimer->stop(); 120 pauseTimer->stop();
125 clear(); 121 clear();
126 Man::setManCount(0); 122 Man::setManCount(0);
diff --git a/noncore/games/parashoot/main.cpp b/noncore/games/parashoot/main.cpp
index ee36d26..40f809f 100644
--- a/noncore/games/parashoot/main.cpp
+++ b/noncore/games/parashoot/main.cpp
@@ -1,27 +1,26 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "interface.h" 21#include "interface.h"
22 22
23#include <qpe/qpeapplication.h>
24#include <opie/oapplicationfactory.h> 23#include <opie/oapplicationfactory.h>
25 24
26OPIE_EXPORT_APP( OApplicationFactory<ParaShoot> ) 25OPIE_EXPORT_APP( OApplicationFactory<ParaShoot> )
27 26
diff --git a/noncore/games/parashoot/man.cpp b/noncore/games/parashoot/man.cpp
index 94807c2..0a151b0 100644
--- a/noncore/games/parashoot/man.cpp
+++ b/noncore/games/parashoot/man.cpp
@@ -1,123 +1,122 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "codes.h" 21#include "codes.h"
22#include "man.h" 22#include "man.h"
23#include "base.h" 23#include "base.h"
24 24
25#include <qtopia/resource.h> 25#include <qtopia/resource.h>
26 26
27#include <qregexp.h>
28 27
29int mancount; 28int mancount;
30 29
31Man::Man(QCanvas* canvas) : 30Man::Man(QCanvas* canvas) :
32 QCanvasSprite(0, canvas), 31 QCanvasSprite(0, canvas),
33 splat("lose") // No tr 32 splat("lose") // No tr
34{ 33{
35 manarray = new QCanvasPixmapArray(); 34 manarray = new QCanvasPixmapArray();
36 QString m0 = Resource::findPixmap("parashoot/man0001"); 35 QString m0 = Resource::findPixmap("parashoot/man0001");
37 m0.replace(QRegExp("0001"),"%1"); 36 m0.replace(QRegExp("0001"),"%1");
38 manarray->readPixmaps(m0, 7); 37 manarray->readPixmaps(m0, 7);
39 setSequence(manarray); 38 setSequence(manarray);
40 setAnimated(true); 39 setAnimated(true);
41 mancount++; 40 mancount++;
42 dead = false; 41 dead = false;
43 start(); 42 start();
44} 43}
45 44
46Man::Man(QCanvas* canvas, int x, int y) : 45Man::Man(QCanvas* canvas, int x, int y) :
47 QCanvasSprite(0, canvas), 46 QCanvasSprite(0, canvas),
48 splat("bang") // No tr 47 splat("bang") // No tr
49{ 48{
50 manarray = new QCanvasPixmapArray(); 49 manarray = new QCanvasPixmapArray();
51 QString m0 = Resource::findPixmap("parashoot/man0001"); 50 QString m0 = Resource::findPixmap("parashoot/man0001");
52 m0.replace(QString("0001"),"%1"); 51 m0.replace(QString("0001"),"%1");
53 manarray->readPixmaps(m0, 7); 52 manarray->readPixmaps(m0, 7);
54 setSequence(manarray); 53 setSequence(manarray);
55 move(x, y); 54 move(x, y);
56 setFrame(5); 55 setFrame(5);
57 setZ(300); 56 setZ(300);
58 show(); 57 show();
59 58
60 static bool first_time = TRUE; 59 static bool first_time = TRUE;
61 if (first_time) { 60 if (first_time) {
62 first_time = FALSE; 61 first_time = FALSE;
63 QTime midnight(0, 0, 0); 62 QTime midnight(0, 0, 0);
64 srand(midnight.secsTo(QTime::currentTime()) ); 63 srand(midnight.secsTo(QTime::currentTime()) );
65 } 64 }
66 int yfallspeed = 0; 65 int yfallspeed = 0;
67 yfallspeed = (rand() % 3) + 1; 66 yfallspeed = (rand() % 3) + 1;
68 setVelocity(0, yfallspeed); 67 setVelocity(0, yfallspeed);
69 68
70 mancount++; 69 mancount++;
71 dead = false; 70 dead = false;
72} 71}
73int f = 0; 72int f = 0;
74 73
75void Man::advance(int phase) 74void Man::advance(int phase)
76{ 75{
77 QCanvasSprite::advance(phase); 76 QCanvasSprite::advance(phase);
78 if (phase == 0) { 77 if (phase == 0) {
79 checkCollision(); 78 checkCollision();
80 if (dead) { 79 if (dead) {
81 if (count < 10) { 80 if (count < 10) {
82 setFrame(6); 81 setFrame(6);
83 setVelocity(0,0); 82 setVelocity(0,0);
84 count++; 83 count++;
85 } else { 84 } else {
86 delete this; 85 delete this;
87 return; 86 return;
88 } 87 }
89 } 88 }
90 if (y() > canvas()->height()-43) { 89 if (y() > canvas()->height()-43) {
91 setFrame(f%5); 90 setFrame(f%5);
92 f++; 91 f++;
93 move(x(), canvas()->height()-26); 92 move(x(), canvas()->height()-26);
94 setVelocity(-2, 0); 93 setVelocity(-2, 0);
95 } else if (xVelocity() == -2) { 94 } else if (xVelocity() == -2) {
96 // 95 //
97 // There's been a resize event while this Man has 96 // There's been a resize event while this Man has
98 // been on the ground. Move the man back to the 97 // been on the ground. Move the man back to the
99 // new ground location. This is not neat. 98 // new ground location. This is not neat.
100 // 99 //
101 move(x(), canvas()->height()-26); 100 move(x(), canvas()->height()-26);
102 } 101 }
103 } 102 }
104} 103}
105 104
106void Man::setInitialCoords() 105void Man::setInitialCoords()
107{ 106{
108 static bool first_time = TRUE; 107 static bool first_time = TRUE;
109 if (first_time) { 108 if (first_time) {
110 first_time = FALSE; 109 first_time = FALSE;
111 QTime midnight(0, 0, 0); 110 QTime midnight(0, 0, 0);
112 srand(midnight.secsTo(QTime::currentTime()) ); 111 srand(midnight.secsTo(QTime::currentTime()) );
113 } 112 }
114 dx = rand() % (canvas()->width()-16); 113 dx = rand() % (canvas()->width()-16);
115 dy = -43; //height of a man off the screen 114 dy = -43; //height of a man off the screen
116} 115}
117 116
118//check if man has reached the base 117//check if man has reached the base
119void Man::checkCollision() 118void Man::checkCollision()
120{ 119{
121 if ( (x() < 23) && (y() == canvas()->height()-26)) { 120 if ( (x() < 23) && (y() == canvas()->height()-26)) {
122 QCanvasItem* item; 121 QCanvasItem* item;
123 QCanvasItemList l=collisions(FALSE); 122 QCanvasItemList l=collisions(FALSE);
diff --git a/noncore/games/qasteroids/main.cpp b/noncore/games/qasteroids/main.cpp
index c762990..18a13eb 100644
--- a/noncore/games/qasteroids/main.cpp
+++ b/noncore/games/qasteroids/main.cpp
@@ -1,27 +1,26 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "toplevel.h" 21#include "toplevel.h"
22 22
23#include <qpe/qpeapplication.h>
24#include <opie/oapplicationfactory.h> 23#include <opie/oapplicationfactory.h>
25 24
26 25
27OPIE_EXPORT_APP( OApplicationFactory<KAstTopLevel> ) 26OPIE_EXPORT_APP( OApplicationFactory<KAstTopLevel> )
diff --git a/noncore/games/qasteroids/toplevel.cpp b/noncore/games/qasteroids/toplevel.cpp
index c4fea89..9053d3d 100644
--- a/noncore/games/qasteroids/toplevel.cpp
+++ b/noncore/games/qasteroids/toplevel.cpp
@@ -1,132 +1,130 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************//* 19**********************************************************************//*
20 * KAsteroids - Copyright (c) Martin R. Jones 1997 20 * KAsteroids - Copyright (c) Martin R. Jones 1997
21 * 21 *
22 * Part of the KDE project 22 * Part of the KDE project
23 */ 23 */
24 //--- toplevel.cpp --- 24 //--- toplevel.cpp ---
25 25
26#include "toplevel.h" 26#include "toplevel.h"
27#include "ledmeter.h" 27#include "ledmeter.h"
28 28
29#include <qpe/qpeapplication.h> 29#include <qpe/qpeapplication.h>
30#include <qpe/resource.h> 30#include <qpe/resource.h>
31 31
32#include <qaccel.h>
33#include <qlabel.h> 32#include <qlabel.h>
34#include <qlayout.h> 33#include <qlayout.h>
35#include <qlcdnumber.h> 34#include <qlcdnumber.h>
36#include <qpushbutton.h>
37 35
38#include <sys/utsname.h> 36#include <sys/utsname.h>
39 37
40 38
41 #define SB_SCORE1 39 #define SB_SCORE1
42 #define SB_LEVEL2 40 #define SB_LEVEL2
43 #define SB_SHIPS3 41 #define SB_SHIPS3
44 42
45struct SLevel 43struct SLevel
46{ 44{
47 int nrocks; 45 int nrocks;
48 double rockSpeed; 46 double rockSpeed;
49}; 47};
50 48
51 #define MAX_LEVELS16 49 #define MAX_LEVELS16
52 50
53SLevel levels[MAX_LEVELS] = 51SLevel levels[MAX_LEVELS] =
54{ 52{
55 { 1, 0.4 }, 53 { 1, 0.4 },
56 { 1, 0.6 }, 54 { 1, 0.6 },
57 { 2, 0.5 }, 55 { 2, 0.5 },
58 { 2, 0.7 }, 56 { 2, 0.7 },
59 { 2, 0.8 }, 57 { 2, 0.8 },
60 { 3, 0.6 }, 58 { 3, 0.6 },
61 { 3, 0.7 }, 59 { 3, 0.7 },
62 { 3, 0.8 }, 60 { 3, 0.8 },
63 { 4, 0.6 }, 61 { 4, 0.6 },
64 { 4, 0.7 }, 62 { 4, 0.7 },
65 { 4, 0.8 }, 63 { 4, 0.8 },
66 { 5, 0.7 }, 64 { 5, 0.7 },
67 { 5, 0.8 }, 65 { 5, 0.8 },
68 { 5, 0.9 }, 66 { 5, 0.9 },
69 { 5, 1.0 } 67 { 5, 1.0 }
70}; 68};
71 69
72const char *soundEvents[] = 70const char *soundEvents[] =
73{ 71{
74 "ShipDestroyed", 72 "ShipDestroyed",
75 "RockDestroyed", 73 "RockDestroyed",
76 0 74 0
77}; 75};
78 76
79const char *soundDefaults[] = 77const char *soundDefaults[] =
80{ 78{
81 "Explosion.wav", 79 "Explosion.wav",
82 "ploop.wav", 80 "ploop.wav",
83 0 81 0
84}; 82};
85 83
86 84
87KAstTopLevel::KAstTopLevel( QWidget *parent, const char *_name, WFlags fl ) 85KAstTopLevel::KAstTopLevel( QWidget *parent, const char *_name, WFlags fl )
88 : QMainWindow( parent, _name, fl ) 86 : QMainWindow( parent, _name, fl )
89{ 87{
90 setCaption( tr("Asteroids") ); 88 setCaption( tr("Asteroids") );
91 89
92 QPEApplication::grabKeyboard(); 90 QPEApplication::grabKeyboard();
93 91
94 QWidget *border = new QWidget( this ); 92 QWidget *border = new QWidget( this );
95 border->setBackgroundColor( black ); 93 border->setBackgroundColor( black );
96 setCentralWidget( border ); 94 setCentralWidget( border );
97 95
98 QVBoxLayout *borderLayout = new QVBoxLayout( border ); 96 QVBoxLayout *borderLayout = new QVBoxLayout( border );
99 97
100 QWidget *mainWin = new QWidget( border ); 98 QWidget *mainWin = new QWidget( border );
101 borderLayout->addWidget( mainWin, 2, AlignHCenter ); 99 borderLayout->addWidget( mainWin, 2, AlignHCenter );
102 100
103 view = new KAsteroidsView( mainWin ); 101 view = new KAsteroidsView( mainWin );
104 connect( view, SIGNAL( shipKilled() ), SLOT( slotShipKilled() ) ); 102 connect( view, SIGNAL( shipKilled() ), SLOT( slotShipKilled() ) );
105 connect( view, SIGNAL( rockHit(int) ), SLOT( slotRockHit(int) ) ); 103 connect( view, SIGNAL( rockHit(int) ), SLOT( slotRockHit(int) ) );
106 connect( view, SIGNAL( rocksRemoved() ), SLOT( slotRocksRemoved() ) ); 104 connect( view, SIGNAL( rocksRemoved() ), SLOT( slotRocksRemoved() ) );
107 connect( view, SIGNAL( updateVitals() ), SLOT( slotUpdateVitals() ) ); 105 connect( view, SIGNAL( updateVitals() ), SLOT( slotUpdateVitals() ) );
108 106
109 QVBoxLayout *vb = new QVBoxLayout( mainWin ); 107 QVBoxLayout *vb = new QVBoxLayout( mainWin );
110 QHBoxLayout *hb = new QHBoxLayout; 108 QHBoxLayout *hb = new QHBoxLayout;
111 QHBoxLayout *hbd = new QHBoxLayout; 109 QHBoxLayout *hbd = new QHBoxLayout;
112 vb->addLayout( hb ); 110 vb->addLayout( hb );
113 111
114 QFont labelFont( "helvetica", 12 ); 112 QFont labelFont( "helvetica", 12 );
115 QColorGroup grp( darkGreen, black, QColor( 128, 128, 128 ), 113 QColorGroup grp( darkGreen, black, QColor( 128, 128, 128 ),
116 QColor( 64, 64, 64 ), black, darkGreen, black ); 114 QColor( 64, 64, 64 ), black, darkGreen, black );
117 QPalette pal( grp, grp, grp ); 115 QPalette pal( grp, grp, grp );
118 116
119 mainWin->setPalette( pal ); 117 mainWin->setPalette( pal );
120 118
121 QLabel *label; 119 QLabel *label;
122 label = new QLabel( tr("Score"), mainWin ); 120 label = new QLabel( tr("Score"), mainWin );
123 label->setFont( labelFont ); 121 label->setFont( labelFont );
124 label->setPalette( pal ); 122 label->setPalette( pal );
125// label->setFixedWidth( label->sizeHint().width() ); 123// label->setFixedWidth( label->sizeHint().width() );
126 hb->addWidget( label ); 124 hb->addWidget( label );
127 125
128 scoreLCD = new QLCDNumber( 5, mainWin ); 126 scoreLCD = new QLCDNumber( 5, mainWin );
129 scoreLCD->setFrameStyle( QFrame::NoFrame ); 127 scoreLCD->setFrameStyle( QFrame::NoFrame );
130 scoreLCD->setSegmentStyle( QLCDNumber::Flat ); 128 scoreLCD->setSegmentStyle( QLCDNumber::Flat );
131 scoreLCD->setFixedHeight( 16 ); 129 scoreLCD->setFixedHeight( 16 );
132 scoreLCD->setPalette( pal ); 130 scoreLCD->setPalette( pal );
diff --git a/noncore/games/qasteroids/view.cpp b/noncore/games/qasteroids/view.cpp
index 448a54a..352c63b 100644
--- a/noncore/games/qasteroids/view.cpp
+++ b/noncore/games/qasteroids/view.cpp
@@ -1,127 +1,124 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************//* 19**********************************************************************//*
20 * KAsteroids - Copyright (c) Martin R. Jones 1997 20 * KAsteroids - Copyright (c) Martin R. Jones 1997
21 * 21 *
22 * Part of the KDE project 22 * Part of the KDE project
23 */ 23 */
24 24
25#include "view.h" 25#include "view.h"
26 26
27#include <qpe/resource.h> 27#include <qpe/resource.h>
28 28
29#include <qapplication.h>
30#include <qkeycode.h>
31#include <qaccel.h>
32 29
33#include <stdlib.h> 30#include <stdlib.h>
34#include <math.h> 31#include <math.h>
35 32
36#define IMG_BACKGROUND "qasteroids/bg.png" 33#define IMG_BACKGROUND "qasteroids/bg.png"
37 34
38#define REFRESH_DELAY 33 35#define REFRESH_DELAY 33
39#define SHIP_SPEED 0.3 36#define SHIP_SPEED 0.3
40#define MISSILE_SPEED 10.0 37#define MISSILE_SPEED 10.0
41#define SHIP_STEPS 64 38#define SHIP_STEPS 64
42#define ROTATE_RATE 2 39#define ROTATE_RATE 2
43#define SHIELD_ON_COST 1 40#define SHIELD_ON_COST 1
44#define SHIELD_HIT_COST 30 41#define SHIELD_HIT_COST 30
45#define BRAKE_ON_COST 4 42#define BRAKE_ON_COST 4
46 43
47#define MAX_ROCK_SPEED 2.5 44#define MAX_ROCK_SPEED 2.5
48#define MAX_POWERUP_SPEED 1.5 45#define MAX_POWERUP_SPEED 1.5
49 #define MAX_SHIP_SPEED 8 46 #define MAX_SHIP_SPEED 8
50#define MAX_BRAKES 5 47#define MAX_BRAKES 5
51#define MAX_SHIELDS 5 48#define MAX_SHIELDS 5
52 #define MAX_FIREPOWER 5 49 #define MAX_FIREPOWER 5
53 50
54#define TEXT_SPEED 4 51#define TEXT_SPEED 4
55 52
56#define PI_X_2 6.283185307 53#define PI_X_2 6.283185307
57#ifndef M_PI 54#ifndef M_PI
58#define M_PI 3.141592654 55#define M_PI 3.141592654
59#endif 56#endif
60 57
61struct 58struct
62{ 59{
63 int id; 60 int id;
64 const char *path; 61 const char *path;
65 int frames; 62 int frames;
66} 63}
67kas_animations [] = 64kas_animations [] =
68{ 65{
69// { ID_ROCK_LARGE, "rock1/rock1\%1.png", 32 }, 66// { ID_ROCK_LARGE, "rock1/rock1\%1.png", 32 },
70 { ID_ROCK_MEDIUM, "rock2/rock2\%1.png", 32 }, 67 { ID_ROCK_MEDIUM, "rock2/rock2\%1.png", 32 },
71 { ID_ROCK_SMALL, "rock3/rock3\%1.png", 32 }, 68 { ID_ROCK_SMALL, "rock3/rock3\%1.png", 32 },
72 { ID_SHIP, "ship/ship\%1.png", 32 }, 69 { ID_SHIP, "ship/ship\%1.png", 32 },
73 { ID_MISSILE, "missile/missile.png", 0 }, 70 { ID_MISSILE, "missile/missile.png", 0 },
74 { ID_BIT, "bits/bits\%1.png", 16 }, 71 { ID_BIT, "bits/bits\%1.png", 16 },
75 { ID_EXHAUST, "exhaust/exhaust.png", 0 }, 72 { ID_EXHAUST, "exhaust/exhaust.png", 0 },
76 { ID_ENERGY_POWERUP, "powerups/energy.png", 0 }, 73 { ID_ENERGY_POWERUP, "powerups/energy.png", 0 },
77// { ID_TELEPORT_POWERUP, "powerups/teleport%1.png", 12 }, 74// { ID_TELEPORT_POWERUP, "powerups/teleport%1.png", 12 },
78 { ID_BRAKE_POWERUP, "powerups/brake.png", 0 }, 75 { ID_BRAKE_POWERUP, "powerups/brake.png", 0 },
79 { ID_SHIELD_POWERUP, "powerups/shield.png", 0 }, 76 { ID_SHIELD_POWERUP, "powerups/shield.png", 0 },
80 { ID_SHOOT_POWERUP, "powerups/shoot.png", 0 }, 77 { ID_SHOOT_POWERUP, "powerups/shoot.png", 0 },
81 { ID_SHIELD, "shield/shield\%1.png", 6 }, 78 { ID_SHIELD, "shield/shield\%1.png", 6 },
82 { 0, 0, 0 } 79 { 0, 0, 0 }
83}; 80};
84 81
85 82
86 83
87KAsteroidsView::KAsteroidsView( QWidget *parent, const char *name ) 84KAsteroidsView::KAsteroidsView( QWidget *parent, const char *name )
88 : QWidget( parent, name ), 85 : QWidget( parent, name ),
89 field(200, 200), 86 field(200, 200),
90 view(&field,this) 87 view(&field,this)
91{ 88{
92 view.setVScrollBarMode( QScrollView::AlwaysOff ); 89 view.setVScrollBarMode( QScrollView::AlwaysOff );
93 view.setHScrollBarMode( QScrollView::AlwaysOff ); 90 view.setHScrollBarMode( QScrollView::AlwaysOff );
94 rocks.setAutoDelete( TRUE ); 91 rocks.setAutoDelete( TRUE );
95 missiles.setAutoDelete( TRUE ); 92 missiles.setAutoDelete( TRUE );
96 bits.setAutoDelete( TRUE ); 93 bits.setAutoDelete( TRUE );
97 powerups.setAutoDelete( TRUE ); 94 powerups.setAutoDelete( TRUE );
98 exhaust.setAutoDelete( TRUE ); 95 exhaust.setAutoDelete( TRUE );
99 96
100 QPixmap pm( Resource::loadPixmap(IMG_BACKGROUND) ); 97 QPixmap pm( Resource::loadPixmap(IMG_BACKGROUND) );
101 field.setBackgroundPixmap( pm ); 98 field.setBackgroundPixmap( pm );
102 99
103 textSprite = new QCanvasText( &field ); 100 textSprite = new QCanvasText( &field );
104 QFont font( "helvetica", 14 ); 101 QFont font( "helvetica", 14 );
105 textSprite->setFont( font ); 102 textSprite->setFont( font );
106 103
107 shield = 0; 104 shield = 0;
108 shieldOn = FALSE; 105 shieldOn = FALSE;
109 refreshRate = REFRESH_DELAY; 106 refreshRate = REFRESH_DELAY;
110 107
111 readSprites(); 108 readSprites();
112 109
113 shieldTimer = new QTimer( this ); 110 shieldTimer = new QTimer( this );
114 connect( shieldTimer, SIGNAL(timeout()), this, SLOT(hideShield()) ); 111 connect( shieldTimer, SIGNAL(timeout()), this, SLOT(hideShield()) );
115 mTimerId = -1; 112 mTimerId = -1;
116 113
117 shipPower = MAX_POWER_LEVEL; 114 shipPower = MAX_POWER_LEVEL;
118 vitalsChanged = TRUE; 115 vitalsChanged = TRUE;
119 can_destroy_powerups = FALSE; 116 can_destroy_powerups = FALSE;
120 117
121 mPaused = TRUE; 118 mPaused = TRUE;
122} 119}
123 120
124// - - - 121// - - -
125 122
126KAsteroidsView::~KAsteroidsView() 123KAsteroidsView::~KAsteroidsView()
127{ 124{
diff --git a/noncore/games/sfcave/helpwindow.cpp b/noncore/games/sfcave/helpwindow.cpp
index 544e237..8a5d034 100644
--- a/noncore/games/sfcave/helpwindow.cpp
+++ b/noncore/games/sfcave/helpwindow.cpp
@@ -1,81 +1,79 @@
1/*************************************************************************** 1/***************************************************************************
2 helpwindow.cpp - description 2 helpwindow.cpp - description
3 ------------------- 3 -------------------
4 begin : Sun Sep 8 2002 4 begin : Sun Sep 8 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include <qwidget.h>
19#include <qlayout.h> 18#include <qlayout.h>
20#include <qstring.h>
21#include <qtextview.h> 19#include <qtextview.h>
22 20
23#include <qpe/qpeapplication.h> 21#include <qpe/qpeapplication.h>
24 22
25#include "helpwindow.h" 23#include "helpwindow.h"
26 24
27 25
28#define HELP_TEXT \ 26#define HELP_TEXT \
29"<qt><h1>SFCave Help</h1><p> " \ 27"<qt><h1>SFCave Help</h1><p> " \
30"SFCave is a flying game for the Zaurus.<br><br> " \ 28"SFCave is a flying game for the Zaurus.<br><br> " \
31"The aim is to stay alive for as long as possible and get the highest score " \ 29"The aim is to stay alive for as long as possible and get the highest score " \
32"you can.<br><br>" \ 30"you can.<br><br>" \
33"There are three game types currently - SFCave, Gates, and Fly.<br>" \ 31"There are three game types currently - SFCave, Gates, and Fly.<br>" \
34"<b>SFCave</b> is a remake of the classic SFCave game - fly through the " \ 32"<b>SFCave</b> is a remake of the classic SFCave game - fly through the " \
35"cavern avoiding all the blocks that just happen to be hanging in " \ 33"cavern avoiding all the blocks that just happen to be hanging in " \
36"midair<br><br>" \ 34"midair<br><br>" \
37"<b>Gates</b> is similar to SFCave but instead you must fly through the " \ 35"<b>Gates</b> is similar to SFCave but instead you must fly through the " \
38"without crashing.<br><br>" \ 36"without crashing.<br><br>" \
39"<b>Fly</b> is somewhat different to SFCave and above. Instead, you have " \ 37"<b>Fly</b> is somewhat different to SFCave and above. Instead, you have " \
40"are flying in the open air above a scrolling landscape, and the aim is to " \ 38"are flying in the open air above a scrolling landscape, and the aim is to " \
41"hug the ground - the closer to the land you fly the more points " \ 39"hug the ground - the closer to the land you fly the more points " \
42"scored.<br><br><br>" \ 40"scored.<br><br><br>" \
43"Basic instruction - Press <b>Up</B> or <b>Down</b> on the circle pad to " \ 41"Basic instruction - Press <b>Up</B> or <b>Down</b> on the circle pad to " \
44"start a new game, press the middle of the pad to apply thrust (makes you " \ 42"start a new game, press the middle of the pad to apply thrust (makes you " \
45"go up), and release the pad to remove thrust and drop down.<br><br>" \ 43"go up), and release the pad to remove thrust and drop down.<br><br>" \
46"Also, if playing the Fly game, you can press z to toggle the display " \ 44"Also, if playing the Fly game, you can press z to toggle the display " \
47"of the scoring zones. This will display 4 red lines at varying heights " \ 45"of the scoring zones. This will display 4 red lines at varying heights " \
48"above the landscape - if your ship falls into this zone, point are scored. " \ 46"above the landscape - if your ship falls into this zone, point are scored. " \
49"The closer to the landscape you get the more points you get.<br><br>" \ 47"The closer to the landscape you get the more points you get.<br><br>" \
50"In addition, SFCave has replays - save and load too so you can show off to all " \ 48"In addition, SFCave has replays - save and load too so you can show off to all " \
51"your friends (or vice versa). Currently, this is in its infancy but will improve.<br>" \ 49"your friends (or vice versa). Currently, this is in its infancy but will improve.<br>" \
52"To use, once you have crashed, press 'r' to replay the last game.<br>" \ 50"To use, once you have crashed, press 'r' to replay the last game.<br>" \
53"To save the replay press 's'.<br>" \ 51"To save the replay press 's'.<br>" \
54"To load a saved replay press 'l' (after you've crashed at least once).<br><br>" \ 52"To load a saved replay press 'l' (after you've crashed at least once).<br><br>" \
55"Replays are currently saved to your home directory in a file called sfcave.replay." \ 53"Replays are currently saved to your home directory in a file called sfcave.replay." \
56"This file can be copied and given to others as long as it it put in their home directory.<br><br>" \ 54"This file can be copied and given to others as long as it it put in their home directory.<br><br>" \
57"Have lots of fun.<br>" \ 55"Have lots of fun.<br>" \
58"Andy" \ 56"Andy" \
59"</p></qt>" 57"</p></qt>"
60 58
61 59
62HelpWindow::HelpWindow( QWidget *parent, const char *name, bool modal, WFlags flags ) 60HelpWindow::HelpWindow( QWidget *parent, const char *name, bool modal, WFlags flags )
63 : QDialog( parent, name, modal, flags ) 61 : QDialog( parent, name, modal, flags )
64{ 62{
65// resize( 230, 280 ); 63// resize( 230, 280 );
66 64
67 setCaption( "Help for SFCave" ); 65 setCaption( "Help for SFCave" );
68 66
69 QVBoxLayout *layout = new QVBoxLayout( this ); 67 QVBoxLayout *layout = new QVBoxLayout( this );
70 QString text = HELP_TEXT;; 68 QString text = HELP_TEXT;;
71 QTextView *view = new QTextView( text, 0, this, "view" ); 69 QTextView *view = new QTextView( text, 0, this, "view" );
72 layout->insertSpacing( -1, 5 ); 70 layout->insertSpacing( -1, 5 );
73 layout->insertWidget( -1, view ); 71 layout->insertWidget( -1, view );
74 layout->insertSpacing( -1, 5 ); 72 layout->insertSpacing( -1, 5 );
75 73
76 QPEApplication::showDialog( this ); 74 QPEApplication::showDialog( this );
77} 75}
78 76
79HelpWindow::~HelpWindow() 77HelpWindow::~HelpWindow()
80{ 78{
81} 79}
diff --git a/noncore/games/snake/interface.cpp b/noncore/games/snake/interface.cpp
index 2c60693..b5fb5bf 100644
--- a/noncore/games/snake/interface.cpp
+++ b/noncore/games/snake/interface.cpp
@@ -1,126 +1,122 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "interface.h" 21#include "interface.h"
22 22
23#include <qpe/resource.h> 23#include <qpe/resource.h>
24#include <qpe/qpeapplication.h>
25 24
26#include <qpe/qpetoolbar.h> 25#include <qpe/qpetoolbar.h>
27#include <qtoolbutton.h> 26#include <qtoolbutton.h>
28#include <qstyle.h>
29#include <qapplication.h>
30#include <qmessagebox.h>
31 27
32SnakeGame::SnakeGame(QWidget* parent, const char* name, WFlags f) : 28SnakeGame::SnakeGame(QWidget* parent, const char* name, WFlags f) :
33 QMainWindow(parent,name,f), 29 QMainWindow(parent,name,f),
34 canvas(232, 258) 30 canvas(232, 258)
35{ 31{
36 setCaption( tr("Snake") ); 32 setCaption( tr("Snake") );
37 QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff ); 33 QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff );
38 QPixmap bg = Resource::loadPixmap("snake/grass"); 34 QPixmap bg = Resource::loadPixmap("snake/grass");
39 canvas.setBackgroundPixmap(bg); 35 canvas.setBackgroundPixmap(bg);
40 canvas.setUpdatePeriod(100); 36 canvas.setUpdatePeriod(100);
41 snake = 0; 37 snake = 0;
42 38
43 cv = new QCanvasView(&canvas, this); 39 cv = new QCanvasView(&canvas, this);
44 40
45 pauseTimer = new QTimer(this); 41 pauseTimer = new QTimer(this);
46 connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) ); 42 connect(pauseTimer, SIGNAL(timeout()), this, SLOT(wait()) );
47 43
48 setToolBarsMovable( FALSE ); 44 setToolBarsMovable( FALSE );
49 45
50 QToolBar* toolbar = new QToolBar( this); 46 QToolBar* toolbar = new QToolBar( this);
51 toolbar->setHorizontalStretchable( TRUE ); 47 toolbar->setHorizontalStretchable( TRUE );
52 48
53 QPixmap newicon = Resource::loadPixmap("ksnake"); 49 QPixmap newicon = Resource::loadPixmap("ksnake");
54 setIcon(newicon); 50 setIcon(newicon);
55 (void)new QToolButton(newicon, tr("New Game"), 0, 51 (void)new QToolButton(newicon, tr("New Game"), 0,
56 this, SLOT(newGame()), toolbar, "New Game"); 52 this, SLOT(newGame()), toolbar, "New Game");
57 53
58 scorelabel = new QLabel(toolbar); 54 scorelabel = new QLabel(toolbar);
59 showScore(0); 55 showScore(0);
60 scorelabel->setBackgroundMode( PaletteButton ); 56 scorelabel->setBackgroundMode( PaletteButton );
61 scorelabel->setAlignment( AlignRight | AlignVCenter | ExpandTabs ); 57 scorelabel->setAlignment( AlignRight | AlignVCenter | ExpandTabs );
62 toolbar->setStretchableWidget( scorelabel ); 58 toolbar->setStretchableWidget( scorelabel );
63 59
64 setFocusPolicy(StrongFocus); 60 setFocusPolicy(StrongFocus);
65 61
66 setCentralWidget(cv); 62 setCentralWidget(cv);
67 63
68 QTimer::singleShot( 16, this, SLOT(welcomescreen()) ); 64 QTimer::singleShot( 16, this, SLOT(welcomescreen()) );
69 gamestopped = true; 65 gamestopped = true;
70 waitover = true; 66 waitover = true;
71} 67}
72 68
73SnakeGame::~SnakeGame() 69SnakeGame::~SnakeGame()
74{ 70{
75 delete snake; 71 delete snake;
76} 72}
77 73
78void SnakeGame::resizeEvent(QResizeEvent *) 74void SnakeGame::resizeEvent(QResizeEvent *)
79{ 75{
80 QSize s = centralWidget()->size(); 76 QSize s = centralWidget()->size();
81 int fw = style().defaultFrameWidth(); 77 int fw = style().defaultFrameWidth();
82 canvas.resize( s.width() - fw - 2, s.height() - fw - 2); 78 canvas.resize( s.width() - fw - 2, s.height() - fw - 2);
83} 79}
84 80
85void SnakeGame::welcomescreen() 81void SnakeGame::welcomescreen()
86{ 82{
87 QCanvasText* title = new QCanvasText(tr("SNAKE!"), &canvas); 83 QCanvasText* title = new QCanvasText(tr("SNAKE!"), &canvas);
88 title->setColor(yellow); 84 title->setColor(yellow);
89 title->setFont( QFont("times", 18, QFont::Bold) ); 85 title->setFont( QFont("times", 18, QFont::Bold) );
90 int w = title->boundingRect().width(); 86 int w = title->boundingRect().width();
91 title->move(canvas.width()/2 -w/2, canvas.height()/2-110); 87 title->move(canvas.width()/2 -w/2, canvas.height()/2-110);
92 title->show(); 88 title->show();
93 QCanvasPixmapArray* titlearray = new QCanvasPixmapArray(Resource::findPixmap("snake/title")); 89 QCanvasPixmapArray* titlearray = new QCanvasPixmapArray(Resource::findPixmap("snake/title"));
94 QCanvasSprite* titlepic = new QCanvasSprite(titlearray, &canvas); 90 QCanvasSprite* titlepic = new QCanvasSprite(titlearray, &canvas);
95 titlepic->move(canvas.width()/2 - 33, canvas.height()/2-85); 91 titlepic->move(canvas.width()/2 - 33, canvas.height()/2-85);
96 titlepic->show(); 92 titlepic->show();
97 QCanvasText* instr = new QCanvasText(tr("Use the arrow keys to guide the\n" 93 QCanvasText* instr = new QCanvasText(tr("Use the arrow keys to guide the\n"
98 "snake to eat the mouse. You must not\n" 94 "snake to eat the mouse. You must not\n"
99 "crash into the walls, edges or its tail."), 95 "crash into the walls, edges or its tail."),
100 &canvas); 96 &canvas);
101 w = instr->boundingRect().width(); 97 w = instr->boundingRect().width();
102 instr->move(canvas.width()/2-w/2, canvas.height()/2-20); 98 instr->move(canvas.width()/2-w/2, canvas.height()/2-20);
103 instr->setColor(white); 99 instr->setColor(white);
104 instr->show(); 100 instr->show();
105 QCanvasText* cont = new QCanvasText(tr("Press any key to start"), &canvas); 101 QCanvasText* cont = new QCanvasText(tr("Press any key to start"), &canvas);
106 w = cont->boundingRect().width(); 102 w = cont->boundingRect().width();
107 cont->move(canvas.width()/2-w/2, canvas.height()-20); 103 cont->move(canvas.width()/2-w/2, canvas.height()-20);
108 cont->setColor(yellow); 104 cont->setColor(yellow);
109 cont->show(); 105 cont->show();
110 106
111} 107}
112 108
113void SnakeGame::newGame() 109void SnakeGame::newGame()
114{ 110{
115 clear(); 111 clear();
116 snake = new Snake(&canvas); 112 snake = new Snake(&canvas);
117 connect(snake, SIGNAL(dead()), this, SLOT(gameOver()) ); 113 connect(snake, SIGNAL(dead()), this, SLOT(gameOver()) );
118 connect(snake, SIGNAL(targethit()), this, SLOT(levelUp()) ); 114 connect(snake, SIGNAL(targethit()), this, SLOT(levelUp()) );
119 connect(snake, SIGNAL(scorechanged()), this, SLOT(scoreInc()) ); 115 connect(snake, SIGNAL(scorechanged()), this, SLOT(scoreInc()) );
120 connect(this, SIGNAL(moveFaster()), snake, SLOT(increaseSpeed()) ); 116 connect(this, SIGNAL(moveFaster()), snake, SLOT(increaseSpeed()) );
121 last = 0; 117 last = 0;
122 targetamount = 1; 118 targetamount = 1;
123 notargets = 1; 119 notargets = 1;
124 level = 1; 120 level = 1;
125 stage = 1; 121 stage = 1;
126 showScore(0); 122 showScore(0);
diff --git a/noncore/games/snake/main.cpp b/noncore/games/snake/main.cpp
index 77a2769..9a9b167 100644
--- a/noncore/games/snake/main.cpp
+++ b/noncore/games/snake/main.cpp
@@ -1,29 +1,28 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "interface.h" 21#include "interface.h"
22 22
23#include <qpe/qpeapplication.h>
24#include <opie/oapplicationfactory.h> 23#include <opie/oapplicationfactory.h>
25 24
26 25
27OPIE_EXPORT_APP( OApplicationFactory<SnakeGame> ) 26OPIE_EXPORT_APP( OApplicationFactory<SnakeGame> )
28 27
29 28
diff --git a/noncore/games/snake/snake.cpp b/noncore/games/snake/snake.cpp
index 9f19841..8a683ab 100644
--- a/noncore/games/snake/snake.cpp
+++ b/noncore/games/snake/snake.cpp
@@ -1,123 +1,121 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "snake.h" 21#include "snake.h"
22#include "target.h" 22#include "target.h"
23#include "codes.h"
24 23
25#include <qpe/resource.h> 24#include <qpe/resource.h>
26 25
27#include <qregexp.h>
28 26
29static int Piecekey[4][4] = { {6, 0, 4, 3 }, {0, 6, 2, 1 }, { 1, 3, 5, 0 }, {2, 4, 0, 5 } }; 27static int Piecekey[4][4] = { {6, 0, 4, 3 }, {0, 6, 2, 1 }, { 1, 3, 5, 0 }, {2, 4, 0, 5 } };
30 28
31Snake::Snake(QCanvas* c) 29Snake::Snake(QCanvas* c)
32{ 30{
33 canvas = c; 31 canvas = c;
34 score = 0; 32 score = 0;
35 snakelist.setAutoDelete(true); 33 snakelist.setAutoDelete(true);
36 autoMoveTimer = new QTimer(this); 34 autoMoveTimer = new QTimer(this);
37 connect( autoMoveTimer, SIGNAL(timeout()), this, SLOT(moveSnake()) ); 35 connect( autoMoveTimer, SIGNAL(timeout()), this, SLOT(moveSnake()) );
38 createSnake(); 36 createSnake();
39} 37}
40 38
41void Snake::createSnake() 39void Snake::createSnake()
42{ 40{
43 snakeparts = new QCanvasPixmapArray(); 41 snakeparts = new QCanvasPixmapArray();
44 QString s0 = Resource::findPixmap("snake/s0001"); 42 QString s0 = Resource::findPixmap("snake/s0001");
45 s0.replace(QRegExp("0001"),"%1"); 43 s0.replace(QRegExp("0001"),"%1");
46 snakeparts->readPixmaps(s0, 15); 44 snakeparts->readPixmaps(s0, 15);
47 45
48 grow = 0; 46 grow = 0;
49 last = Key_Right; 47 last = Key_Right;
50 48
51 QCanvasSprite* head = new QCanvasSprite(snakeparts, canvas ); 49 QCanvasSprite* head = new QCanvasSprite(snakeparts, canvas );
52 head->setFrame(7); 50 head->setFrame(7);
53 snakelist.insert(0, head); 51 snakelist.insert(0, head);
54 head->show(); 52 head->show();
55 head->move(34, 16); 53 head->move(34, 16);
56 54
57 QCanvasSprite* body = new QCanvasSprite(snakeparts, canvas ); 55 QCanvasSprite* body = new QCanvasSprite(snakeparts, canvas );
58 body->setFrame(6); 56 body->setFrame(6);
59 snakelist.append( body ); 57 snakelist.append( body );
60 body->show(); 58 body->show();
61 body->move(18, 16); 59 body->move(18, 16);
62 60
63 QCanvasSprite* end = new QCanvasSprite(snakeparts, canvas ); 61 QCanvasSprite* end = new QCanvasSprite(snakeparts, canvas );
64 end->setFrame(11); 62 end->setFrame(11);
65 snakelist.append( end ); 63 snakelist.append( end );
66 end->show(); 64 end->show();
67 end->move(2, 16); 65 end->move(2, 16);
68 66
69 currentdir = right; 67 currentdir = right;
70 speed = 250; 68 speed = 250;
71 autoMoveTimer->start(speed); 69 autoMoveTimer->start(speed);
72 moveSnake(); 70 moveSnake();
73} 71}
74 72
75void Snake::increaseSpeed() 73void Snake::increaseSpeed()
76{ 74{
77 if (speed > 150) 75 if (speed > 150)
78 speed = speed - 5; 76 speed = speed - 5;
79 autoMoveTimer->start(speed); 77 autoMoveTimer->start(speed);
80} 78}
81 79
82void Snake::go(int newkey) 80void Snake::go(int newkey)
83{ 81{
84 // check key is a direction 82 // check key is a direction
85 if (!( (newkey == Key_Up) || (newkey == Key_Left) || 83 if (!( (newkey == Key_Up) || (newkey == Key_Left) ||
86 (newkey == Key_Right) || (newkey == Key_Down) )) 84 (newkey == Key_Right) || (newkey == Key_Down) ))
87 return; 85 return;
88 // check move is possible 86 // check move is possible
89 if ( ((currentdir == left) && ((newkey == Key_Right) || (newkey == Key_Left)) ) || 87 if ( ((currentdir == left) && ((newkey == Key_Right) || (newkey == Key_Left)) ) ||
90 ((currentdir == right) && ((newkey == Key_Left) || (newkey == Key_Right)) ) || 88 ((currentdir == right) && ((newkey == Key_Left) || (newkey == Key_Right)) ) ||
91 ((currentdir == up) && ((newkey == Key_Down) || (newkey == Key_Up)) ) || 89 ((currentdir == up) && ((newkey == Key_Down) || (newkey == Key_Up)) ) ||
92 ((currentdir == down) && ((newkey == Key_Up) || (newkey == Key_Down)) ) ) 90 ((currentdir == down) && ((newkey == Key_Up) || (newkey == Key_Down)) ) )
93 return; 91 return;
94 else { 92 else {
95 Snake::changeHead(newkey); 93 Snake::changeHead(newkey);
96 Snake::moveSnake(); 94 Snake::moveSnake();
97 } 95 }
98} 96}
99 97
100void Snake::move(Direction dir) 98void Snake::move(Direction dir)
101{ 99{
102 autoMoveTimer->start(speed); 100 autoMoveTimer->start(speed);
103 int x = 0; 101 int x = 0;
104 int y = 0; 102 int y = 0;
105 newdir = dir; 103 newdir = dir;
106 switch (dir) { 104 switch (dir) {
107 case right: x = 16; break; 105 case right: x = 16; break;
108 case left: x = -16; break; 106 case left: x = -16; break;
109 case down: y = 16; break; 107 case down: y = 16; break;
110 case up: y = -16; break; 108 case up: y = -16; break;
111 } 109 }
112 int index = lookUpPiece(currentdir, newdir); 110 int index = lookUpPiece(currentdir, newdir);
113 QCanvasSprite* sprite = new QCanvasSprite(snakeparts, canvas ); 111 QCanvasSprite* sprite = new QCanvasSprite(snakeparts, canvas );
114 sprite->setFrame(index); 112 sprite->setFrame(index);
115 snakelist.insert(1, sprite); 113 snakelist.insert(1, sprite);
116 sprite->move(snakelist.first()->x(), snakelist.first()->y() ); 114 sprite->move(snakelist.first()->x(), snakelist.first()->y() );
117 115
118 snakelist.first()->moveBy(x, y); 116 snakelist.first()->moveBy(x, y);
119 if (grow <= 0) 117 if (grow <= 0)
120 changeTail(); 118 changeTail();
121 else 119 else
122 grow--; 120 grow--;
123 sprite->show(); 121 sprite->show();
diff --git a/noncore/games/solitaire/canvascard.cpp b/noncore/games/solitaire/canvascard.cpp
index 7c4a5ba..c36da6c 100644
--- a/noncore/games/solitaire/canvascard.cpp
+++ b/noncore/games/solitaire/canvascard.cpp
@@ -1,125 +1,120 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "cardgame.h"
22#include "canvascard.h" 21#include "canvascard.h"
23 22
24#include <qpe/resource.h> 23#include <qpe/resource.h>
25 24
26#include <qpainter.h>
27#include <qimage.h>
28#include <qpaintdevice.h>
29#include <qbitmap.h>
30#include <qgfx_qws.h> // Needed to get the device's width 25#include <qgfx_qws.h> // Needed to get the device's width
31 26
32#include <math.h> 27#include <math.h>
33 28
34#if defined( QT_QWS_CASSIOPEIA ) 29#if defined( QT_QWS_CASSIOPEIA )
35#define SLOW_HARDWARE 30#define SLOW_HARDWARE
36#endif 31#endif
37 32
38// Seems to be fast enough to me even without Transformations in the library 33// Seems to be fast enough to me even without Transformations in the library
39//#if defined( QT_NO_TRANSFORMATIONS ) && defined( QT_QWS_IPAQ ) 34//#if defined( QT_NO_TRANSFORMATIONS ) && defined( QT_QWS_IPAQ )
40//#define SLOW_HARDWARE 35//#define SLOW_HARDWARE
41//#endif 36//#endif
42 37
43 38
44QBitmap *Create180RotatedBitmap(QBitmap *srcBitmap) 39QBitmap *Create180RotatedBitmap(QBitmap *srcBitmap)
45{ 40{
46#ifdef QT_NO_TRANSFORMATIONS 41#ifdef QT_NO_TRANSFORMATIONS
47 int w = srcBitmap->width(); 42 int w = srcBitmap->width();
48 int h = srcBitmap->height(); 43 int h = srcBitmap->height();
49 QBitmap *dstBitmap = new QBitmap( w, h ); 44 QBitmap *dstBitmap = new QBitmap( w, h );
50 // ### this is very poorly implemented and probably could be much faster 45 // ### this is very poorly implemented and probably could be much faster
51 for (int i = 0; i < w; i++) 46 for (int i = 0; i < w; i++)
52 for (int j = 0; j < h; j++) 47 for (int j = 0; j < h; j++)
53 bitBlt( dstBitmap, i, j, srcBitmap, w - i - 1, h - j - 1, 1, 1 ); 48 bitBlt( dstBitmap, i, j, srcBitmap, w - i - 1, h - j - 1, 1, 1 );
54 return dstBitmap; 49 return dstBitmap;
55#else 50#else
56 QWMatrix m; 51 QWMatrix m;
57 m.rotate( 180.0 ); 52 m.rotate( 180.0 );
58 return new QBitmap( srcBitmap->xForm( m ) ); 53 return new QBitmap( srcBitmap->xForm( m ) );
59#endif 54#endif
60} 55}
61 56
62 57
63QPixmap *CreateScaledPixmap(QPixmap *srcPixmap, double scaleX, double scaleY) 58QPixmap *CreateScaledPixmap(QPixmap *srcPixmap, double scaleX, double scaleY)
64{ 59{
65#ifdef QT_NO_TRANSFORMATIONS 60#ifdef QT_NO_TRANSFORMATIONS
66 int w = srcPixmap->width(); 61 int w = srcPixmap->width();
67 int h = srcPixmap->height(); 62 int h = srcPixmap->height();
68 int newW = (int)(w * scaleX); 63 int newW = (int)(w * scaleX);
69 int newH = (int)(h * scaleY); 64 int newH = (int)(h * scaleY);
70 QPixmap *dstPixmap = new QPixmap( newW, newH ); 65 QPixmap *dstPixmap = new QPixmap( newW, newH );
71 // ### this is very poorly implemented and probably could be much faster 66 // ### this is very poorly implemented and probably could be much faster
72 for (int i = 0; i < newW; i++) { 67 for (int i = 0; i < newW; i++) {
73 int srcX = w * i / newW; 68 int srcX = w * i / newW;
74 if (newH == h) { 69 if (newH == h) {
75 // Optimise for scaleing in the X-axis only 70 // Optimise for scaleing in the X-axis only
76 bitBlt( dstPixmap, i, 0, srcPixmap, srcX, 0, 1, h ); 71 bitBlt( dstPixmap, i, 0, srcPixmap, srcX, 0, 1, h );
77 } else { 72 } else {
78 for (int j = 0; j < newH; j++) { 73 for (int j = 0; j < newH; j++) {
79 int srcY = h * j / newH; 74 int srcY = h * j / newH;
80 bitBlt( dstPixmap, i, j, srcPixmap, srcX, srcY, 1, 1 ); 75 bitBlt( dstPixmap, i, j, srcPixmap, srcX, srcY, 1, 1 );
81 } 76 }
82 } 77 }
83 } 78 }
84 return dstPixmap; 79 return dstPixmap;
85#else 80#else
86 QWMatrix s; 81 QWMatrix s;
87 s.scale( scaleX, scaleY ); 82 s.scale( scaleX, scaleY );
88 return new QPixmap( srcPixmap->xForm( s ) ); 83 return new QPixmap( srcPixmap->xForm( s ) );
89#endif 84#endif
90} 85}
91 86
92 87
93// Initialise static member variables to NULL 88// Initialise static member variables to NULL
94QPixmap *CanvasCard::cardsFaces = NULL; 89QPixmap *CanvasCard::cardsFaces = NULL;
95QPixmap *CanvasCard::cardsBacks = NULL; 90QPixmap *CanvasCard::cardsBacks = NULL;
96QBitmap *CanvasCard::cardsChars = NULL; 91QBitmap *CanvasCard::cardsChars = NULL;
97QBitmap *CanvasCard::cardsSuits = NULL; 92QBitmap *CanvasCard::cardsSuits = NULL;
98QBitmap *CanvasCard::cardsCharsUpsideDown = NULL; 93QBitmap *CanvasCard::cardsCharsUpsideDown = NULL;
99QBitmap *CanvasCard::cardsSuitsUpsideDown = NULL; 94QBitmap *CanvasCard::cardsSuitsUpsideDown = NULL;
100 95
101 96
102CanvasCard::CanvasCard( eValue v, eSuit s, bool f, QCanvas *canvas ) : 97CanvasCard::CanvasCard( eValue v, eSuit s, bool f, QCanvas *canvas ) :
103 Card(v, s, f), QCanvasRectangle( 0, 0, 1, 1, canvas ), cardBack(1), scaleX(1.0), scaleY(1.0) 98 Card(v, s, f), QCanvasRectangle( 0, 0, 1, 1, canvas ), cardBack(1), scaleX(1.0), scaleY(1.0)
104{ 99{
105 if ( !cardsFaces ) { 100 if ( !cardsFaces ) {
106 if ( qt_screen->deviceWidth() < 200 ) { 101 if ( qt_screen->deviceWidth() < 200 ) {
107 cardsFaces = new QPixmap( Resource::loadPixmap( "cards/card_face_small" ) ); 102 cardsFaces = new QPixmap( Resource::loadPixmap( "cards/card_face_small" ) );
108 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001_small" ) ); 103 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001_small" ) );
109 cardsChars = new QBitmap( Resource::loadBitmap( "cards/card_chars_small" ) ); 104 cardsChars = new QBitmap( Resource::loadBitmap( "cards/card_chars_small" ) );
110 cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits_small" ) ); 105 cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits_small" ) );
111 } else { 106 } else {
112 cardsFaces = new QPixmap( Resource::loadPixmap( "cards/card_face" ) ); 107 cardsFaces = new QPixmap( Resource::loadPixmap( "cards/card_face" ) );
113 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) ); 108 cardsBacks = new QPixmap( Resource::loadPixmap( "cards/card_back0001" ) );
114 cardsChars = new QBitmap( Resource::loadBitmap( "cards/card_chars" ) ); 109 cardsChars = new QBitmap( Resource::loadBitmap( "cards/card_chars" ) );
115 cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits" ) ); 110 cardsSuits = new QBitmap( Resource::loadBitmap( "cards/card_suits" ) );
116 } 111 }
117 cardsCharsUpsideDown = Create180RotatedBitmap( cardsChars ); 112 cardsCharsUpsideDown = Create180RotatedBitmap( cardsChars );
118 cardsSuitsUpsideDown = Create180RotatedBitmap( cardsSuits ); 113 cardsSuitsUpsideDown = Create180RotatedBitmap( cardsSuits );
119 } 114 }
120 xOff = cardsFaces->width() / 2; 115 xOff = cardsFaces->width() / 2;
121 yOff = cardsFaces->height() / 2; 116 yOff = cardsFaces->height() / 2;
122 setSize( cardsFaces->width(), cardsFaces->height() ); 117 setSize( cardsFaces->width(), cardsFaces->height() );
123 setPen( NoPen ); 118 setPen( NoPen );
124 flipping = FALSE; 119 flipping = FALSE;
125} 120}
diff --git a/noncore/games/solitaire/canvascardgame.cpp b/noncore/games/solitaire/canvascardgame.cpp
index 9ae2a23..ed5748e 100644
--- a/noncore/games/solitaire/canvascardgame.cpp
+++ b/noncore/games/solitaire/canvascardgame.cpp
@@ -1,127 +1,119 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "cardgame.h"
22#include "canvasshapes.h"
23#include "canvascard.h"
24#include "canvascardgame.h" 21#include "canvascardgame.h"
25 22
26#include <qpe/resource.h>
27#include <qpe/config.h>
28 23
29#include <qmainwindow.h>
30#include <qmenubar.h>
31#include <qpainter.h>
32#include <qgfx_qws.h> 24#include <qgfx_qws.h>
33 25
34#include <stdlib.h> 26#include <stdlib.h>
35#include <limits.h> 27#include <limits.h>
36#include <time.h> 28#include <time.h>
37#include <math.h> 29#include <math.h>
38 30
39 31
40extern int highestZ; 32extern int highestZ;
41 33
42 34
43class CanvasCardPile : public QCanvasRectangle 35class CanvasCardPile : public QCanvasRectangle
44{ 36{
45public: 37public:
46 CanvasCardPile( CanvasCardGame *ccg, QCanvas *canvas ) : QCanvasRectangle( canvas ), parent( ccg ) { 38 CanvasCardPile( CanvasCardGame *ccg, QCanvas *canvas ) : QCanvasRectangle( canvas ), parent( ccg ) {
47 pile = new QPixmap( 0, 0 ); 39 pile = new QPixmap( 0, 0 );
48 pileHeight = 0; 40 pileHeight = 0;
49 firstCard = NULL; 41 firstCard = NULL;
50 } 42 }
51 43
52 void addCard( CanvasCard *card ); 44 void addCard( CanvasCard *card );
53 void advance(int stage); 45 void advance(int stage);
54 void animatedMove() { animatedMove(savedX, savedY); } 46 void animatedMove() { animatedMove(savedX, savedY); }
55 void savePos(void) { savedX = (int)x(); savedY = (int)y(); } 47 void savePos(void) { savedX = (int)x(); savedY = (int)y(); }
56 void animatedMove(int x2, int y2, int steps = 7 ); 48 void animatedMove(int x2, int y2, int steps = 7 );
57 49
58protected: 50protected:
59 virtual void draw( QPainter& p ); 51 virtual void draw( QPainter& p );
60 52
61private: 53private:
62 CanvasCardGame *parent; 54 CanvasCardGame *parent;
63 QPixmap *pile; 55 QPixmap *pile;
64 QImage tempImage32; 56 QImage tempImage32;
65 CanvasCard *firstCard; 57 CanvasCard *firstCard;
66 int pileHeight; 58 int pileHeight;
67 int destX, destY; 59 int destX, destY;
68 int savedX, savedY; 60 int savedX, savedY;
69 int animSteps; 61 int animSteps;
70}; 62};
71 63
72 64
73void CanvasCardPile::addCard( CanvasCard *card ) 65void CanvasCardPile::addCard( CanvasCard *card )
74{ 66{
75 int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13; 67 int offsetDown = ( qt_screen->deviceWidth() < 200 ) ? 9 : 13;
76 int cardHeight = ( qt_screen->deviceWidth() < 200 ) ? 27 : 36; 68 int cardHeight = ( qt_screen->deviceWidth() < 200 ) ? 27 : 36;
77 int cardWidth = ( qt_screen->deviceWidth() < 200 ) ? 20 : 23; 69 int cardWidth = ( qt_screen->deviceWidth() < 200 ) ? 20 : 23;
78 70
79 if ( !firstCard ) 71 if ( !firstCard )
80 firstCard = card; 72 firstCard = card;
81 73
82 int height = cardHeight + pileHeight * offsetDown; 74 int height = cardHeight + pileHeight * offsetDown;
83 setSize( cardWidth, height ); 75 setSize( cardWidth, height );
84 pile->resize( cardWidth, height ); 76 pile->resize( cardWidth, height );
85 QPainter p( pile ); 77 QPainter p( pile );
86 p.translate( -card->x(), -card->y() + pileHeight * offsetDown ); 78 p.translate( -card->x(), -card->y() + pileHeight * offsetDown );
87 card->draw( p ); 79 card->draw( p );
88 pileHeight++; 80 pileHeight++;
89 81
90 QImage tempImage; 82 QImage tempImage;
91 tempImage = *pile; 83 tempImage = *pile;
92 tempImage32 = tempImage.convertDepth( 32 ); 84 tempImage32 = tempImage.convertDepth( 32 );
93 tempImage32.setAlphaBuffer( TRUE ); 85 tempImage32.setAlphaBuffer( TRUE );
94 for ( int i = 0; i < tempImage32.width(); i++ ) 86 for ( int i = 0; i < tempImage32.width(); i++ )
95 for ( int j = 0; j < tempImage32.height(); j++ ) { 87 for ( int j = 0; j < tempImage32.height(); j++ ) {
96 QRgb col = tempImage32.pixel( i, j ); 88 QRgb col = tempImage32.pixel( i, j );
97 int a = 255-j*220/tempImage32.height(); 89 int a = 255-j*220/tempImage32.height();
98 QRgb alpha = qRgba( qRed( col ), qGreen( col ), qBlue( col ), a ); 90 QRgb alpha = qRgba( qRed( col ), qGreen( col ), qBlue( col ), a );
99 tempImage32.setPixel( i, j, alpha ); 91 tempImage32.setPixel( i, j, alpha );
100 } 92 }
101 93
102 QRgb alpha = qRgba( 0, 0, 0, 0 ); 94 QRgb alpha = qRgba( 0, 0, 0, 0 );
103 tempImage32.setPixel( 1, 0, alpha ); 95 tempImage32.setPixel( 1, 0, alpha );
104 tempImage32.setPixel( 0, 0, alpha ); 96 tempImage32.setPixel( 0, 0, alpha );
105 tempImage32.setPixel( 0, 1, alpha ); 97 tempImage32.setPixel( 0, 1, alpha );
106 98
107 tempImage32.setPixel( cardWidth - 2, 0, alpha ); 99 tempImage32.setPixel( cardWidth - 2, 0, alpha );
108 tempImage32.setPixel( cardWidth - 1, 0, alpha ); 100 tempImage32.setPixel( cardWidth - 1, 0, alpha );
109 tempImage32.setPixel( cardWidth - 1, 1, alpha ); 101 tempImage32.setPixel( cardWidth - 1, 1, alpha );
110 height--; 102 height--;
111 tempImage32.setPixel( 1, height, alpha ); 103 tempImage32.setPixel( 1, height, alpha );
112 tempImage32.setPixel( 0, height - 1, alpha ); 104 tempImage32.setPixel( 0, height - 1, alpha );
113 tempImage32.setPixel( 0, height, alpha ); 105 tempImage32.setPixel( 0, height, alpha );
114 106
115 tempImage32.setPixel( cardWidth - 2, height, alpha ); 107 tempImage32.setPixel( cardWidth - 2, height, alpha );
116 tempImage32.setPixel( cardWidth - 1, height, alpha ); 108 tempImage32.setPixel( cardWidth - 1, height, alpha );
117 tempImage32.setPixel( cardWidth - 1, height - 1, alpha ); 109 tempImage32.setPixel( cardWidth - 1, height - 1, alpha );
118} 110}
119 111
120 112
121void CanvasCardPile::advance(int stage) 113void CanvasCardPile::advance(int stage)
122{ 114{
123 if ( stage==1 ) { 115 if ( stage==1 ) {
124 if ( animSteps-- <= 0 ) { 116 if ( animSteps-- <= 0 ) {
125 CanvasCard *item = firstCard; 117 CanvasCard *item = firstCard;
126 while (item) { 118 while (item) {
127 item->show(); 119 item->show();
diff --git a/noncore/games/solitaire/canvascardwindow.cpp b/noncore/games/solitaire/canvascardwindow.cpp
index c12344a..503bc92 100644
--- a/noncore/games/solitaire/canvascardwindow.cpp
+++ b/noncore/games/solitaire/canvascardwindow.cpp
@@ -1,128 +1,123 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "canvascardwindow.h" 21#include "canvascardwindow.h"
22#include "patiencecardgame.h"
23#include "freecellcardgame.h" 22#include "freecellcardgame.h"
24#include "chicanecardgame.h" 23#include "chicanecardgame.h"
25#include "harpcardgame.h" 24#include "harpcardgame.h"
26#include "teeclubcardgame.h" 25#include "teeclubcardgame.h"
27 26
28#include <qpe/resource.h>
29 27
30#include <qmainwindow.h>
31#include <qpopupmenu.h>
32#include <qstyle.h>
33 28
34 29
35CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) : 30CanvasCardWindow::CanvasCardWindow(QWidget* parent, const char* name, WFlags f) :
36 QMainWindow(parent, name, f), canvas(230, 260), snapOn(TRUE), cardBack(4), gameType(0), 31 QMainWindow(parent, name, f), canvas(230, 260), snapOn(TRUE), cardBack(4), gameType(0),
37 cardGame(NULL) 32 cardGame(NULL)
38{ 33{
39 setIcon( Resource::loadPixmap( "cards" ) ); 34 setIcon( Resource::loadPixmap( "cards" ) );
40 setCaption(tr("Patience")); 35 setCaption(tr("Patience"));
41 36
42 // Create Playing Area for Games 37 // Create Playing Area for Games
43 if ( QPixmap::defaultDepth() < 12 ) { 38 if ( QPixmap::defaultDepth() < 12 ) {
44// canvas.setBackgroundColor(QColor(0x51, 0x74, 0x6B)); 39// canvas.setBackgroundColor(QColor(0x51, 0x74, 0x6B));
45// canvas.setBackgroundColor(QColor(0x20, 0xb0, 0x50)); 40// canvas.setBackgroundColor(QColor(0x20, 0xb0, 0x50));
46 canvas.setBackgroundColor(QColor(0x08, 0x98, 0x2D)); 41 canvas.setBackgroundColor(QColor(0x08, 0x98, 0x2D));
47 } else { 42 } else {
48 QPixmap bg; 43 QPixmap bg;
49 bg.convertFromImage( Resource::loadImage( "table_pattern" ), ThresholdDither ); 44 bg.convertFromImage( Resource::loadImage( "table_pattern" ), ThresholdDither );
50 canvas.setBackgroundPixmap(bg); 45 canvas.setBackgroundPixmap(bg);
51 } 46 }
52 47
53#if defined( QT_QWS_CASSIOPEIA ) 48#if defined( QT_QWS_CASSIOPEIA )
54 canvas.setAdvancePeriod(70); 49 canvas.setAdvancePeriod(70);
55#else 50#else
56 canvas.setAdvancePeriod(30); 51 canvas.setAdvancePeriod(30);
57#endif 52#endif
58 53
59 54
60#ifdef _PATIENCE_USE_ACCELS_ 55#ifdef _PATIENCE_USE_ACCELS_
61 QMenuBar* menu = menuBar(); 56 QMenuBar* menu = menuBar();
62 57
63 QPopupMenu* file = new QPopupMenu; 58 QPopupMenu* file = new QPopupMenu;
64 file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F); 59 file->insertItem(tr("Patience"), this, SLOT(initPatience()), CTRL+Key_F);
65 file->insertItem(tr("Freecell"), this, SLOT(initFreecell()), CTRL+Key_F); 60 file->insertItem(tr("Freecell"), this, SLOT(initFreecell()), CTRL+Key_F);
66 file->insertItem(tr("Chicane"), this, SLOT(initChicane()), CTRL+Key_F); 61 file->insertItem(tr("Chicane"), this, SLOT(initChicane()), CTRL+Key_F);
67 file->insertItem(tr("Harp"), this, SLOT(initHarp()), CTRL+Key_F); 62 file->insertItem(tr("Harp"), this, SLOT(initHarp()), CTRL+Key_F);
68 file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()), CTRL+Key_F); 63 file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()), CTRL+Key_F);
69 menu->insertItem(tr("&Game"), file); 64 menu->insertItem(tr("&Game"), file);
70 65
71 menu->insertSeparator(); 66 menu->insertSeparator();
72 67
73 settings = new QPopupMenu; 68 settings = new QPopupMenu;
74 settings->insertItem(tr("&Change card backs"), this, SLOT(changeCardBacks()), Key_F2); 69 settings->insertItem(tr("&Change card backs"), this, SLOT(changeCardBacks()), Key_F2);
75 snap_id = settings->insertItem(tr("&Snap to position"), this, SLOT(snapToggle()), Key_F3); 70 snap_id = settings->insertItem(tr("&Snap to position"), this, SLOT(snapToggle()), Key_F3);
76 settings->setCheckable(TRUE); 71 settings->setCheckable(TRUE);
77 menu->insertItem(tr("&Settings"),settings); 72 menu->insertItem(tr("&Settings"),settings);
78 73
79 menu->insertSeparator(); 74 menu->insertSeparator();
80 75
81 QPopupMenu* help = new QPopupMenu; 76 QPopupMenu* help = new QPopupMenu;
82 help->insertItem(tr("&About"), this, SLOT(help()), Key_F1); 77 help->insertItem(tr("&About"), this, SLOT(help()), Key_F1);
83 help->setItemChecked(dbf_id, TRUE); 78 help->setItemChecked(dbf_id, TRUE);
84 menu->insertItem(tr("&Help"),help); 79 menu->insertItem(tr("&Help"),help);
85#else 80#else
86 QMenuBar* menu = menuBar(); 81 QMenuBar* menu = menuBar();
87 82
88 QPopupMenu* file = new QPopupMenu; 83 QPopupMenu* file = new QPopupMenu;
89 file->insertItem(tr("Patience"), this, SLOT(initPatience())); 84 file->insertItem(tr("Patience"), this, SLOT(initPatience()));
90 file->insertItem(tr("Freecell"), this, SLOT(initFreecell())); 85 file->insertItem(tr("Freecell"), this, SLOT(initFreecell()));
91 file->insertItem(tr("Chicane"), this, SLOT(initChicane())); 86 file->insertItem(tr("Chicane"), this, SLOT(initChicane()));
92 file->insertItem(tr("Harp"), this, SLOT(initHarp())); 87 file->insertItem(tr("Harp"), this, SLOT(initHarp()));
93 file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub())); 88 file->insertItem(tr("Teeclub"), this, SLOT(initTeeclub()));
94 menu->insertItem(tr("Play"), file); 89 menu->insertItem(tr("Play"), file);
95 90
96 menu->insertSeparator(); 91 menu->insertSeparator();
97 92
98 settings = new QPopupMenu; 93 settings = new QPopupMenu;
99 settings->setCheckable(TRUE); 94 settings->setCheckable(TRUE);
100 settings->insertItem(tr("Change card backs"), this, SLOT(changeCardBacks())); 95 settings->insertItem(tr("Change card backs"), this, SLOT(changeCardBacks()));
101 snap_id = settings->insertItem(tr("Snap to position"), this, SLOT(snapToggle())); 96 snap_id = settings->insertItem(tr("Snap to position"), this, SLOT(snapToggle()));
102 QString m; 97 QString m;
103 98
104 drawId = settings->insertItem(tr("Turn one card"), this, SLOT(drawnToggle())); 99 drawId = settings->insertItem(tr("Turn one card"), this, SLOT(drawnToggle()));
105 menu->insertItem(tr("Settings"),settings); 100 menu->insertItem(tr("Settings"),settings);
106 settings->setCheckable(TRUE); 101 settings->setCheckable(TRUE);
107 102
108#endif 103#endif
109 104
110 menu->show(); 105 menu->show();
111 106
112 Config cfg( "Patience" ); 107 Config cfg( "Patience" );
113 cfg.setGroup( "GlobalSettings" ); 108 cfg.setGroup( "GlobalSettings" );
114 snapOn = cfg.readBoolEntry( "SnapOn", TRUE); 109 snapOn = cfg.readBoolEntry( "SnapOn", TRUE);
115 settings->setItemChecked(snap_id, snapOn); 110 settings->setItemChecked(snap_id, snapOn);
116 111
117 gameType = cfg.readNumEntry( "GameType", -1 ); 112 gameType = cfg.readNumEntry( "GameType", -1 );
118 drawThree = cfg.readBoolEntry( "DrawThree", FALSE); 113 drawThree = cfg.readBoolEntry( "DrawThree", FALSE);
119 if ( gameType == 0 ) { 114 if ( gameType == 0 ) {
120 cardGame = new PatienceCardGame( &canvas, snapOn, this ); 115 cardGame = new PatienceCardGame( &canvas, snapOn, this );
121 cardGame->setNumberToDraw(drawThree ? 3 : 1); 116 cardGame->setNumberToDraw(drawThree ? 3 : 1);
122 117
123 setCaption(tr("Patience")); 118 setCaption(tr("Patience"));
124 setCentralWidget(cardGame); 119 setCentralWidget(cardGame);
125 cardGame->readConfig( cfg ); 120 cardGame->readConfig( cfg );
126 setCardBacks(); 121 setCardBacks();
127 } else if ( gameType == 1 ) { 122 } else if ( gameType == 1 ) {
128 cardGame = new FreecellCardGame( &canvas, snapOn, this ); 123 cardGame = new FreecellCardGame( &canvas, snapOn, this );
diff --git a/noncore/games/solitaire/canvasshapes.cpp b/noncore/games/solitaire/canvasshapes.cpp
index 6ccd4a4..011958d 100644
--- a/noncore/games/solitaire/canvasshapes.cpp
+++ b/noncore/games/solitaire/canvasshapes.cpp
@@ -1,114 +1,112 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qpainter.h>
21#include <qcanvas.h>
22#include <qgfx_qws.h> 20#include <qgfx_qws.h>
23#include "canvasshapes.h" 21#include "canvasshapes.h"
24 22
25 23
26CanvasRoundRect::CanvasRoundRect(int x, int y, QCanvas *canvas) : 24CanvasRoundRect::CanvasRoundRect(int x, int y, QCanvas *canvas) :
27 QCanvasRectangle( x, y, ( qt_screen->deviceWidth() < 200 ) ? 20 : 23, ( qt_screen->deviceWidth() < 200 ) ? 27 : 36, canvas) 25 QCanvasRectangle( x, y, ( qt_screen->deviceWidth() < 200 ) ? 20 : 23, ( qt_screen->deviceWidth() < 200 ) ? 27 : 36, canvas)
28{ 26{
29 setZ(0); 27 setZ(0);
30 show(); 28 show();
31} 29}
32 30
33 31
34void CanvasRoundRect::redraw() 32void CanvasRoundRect::redraw()
35{ 33{
36 hide(); 34 hide();
37 show(); 35 show();
38} 36}
39 37
40 38
41void CanvasRoundRect::drawShape(QPainter &p) 39void CanvasRoundRect::drawShape(QPainter &p)
42{ 40{
43 if ( qt_screen->deviceWidth() < 200 ) 41 if ( qt_screen->deviceWidth() < 200 )
44 p.drawRoundRect( (int)x() + 1, (int)y() + 1, 18, 25); 42 p.drawRoundRect( (int)x() + 1, (int)y() + 1, 18, 25);
45 else 43 else
46 p.drawRoundRect( (int)x(), (int)y(), 23, 36); 44 p.drawRoundRect( (int)x(), (int)y(), 23, 36);
47} 45}
48 46
49 47
50CanvasCircleOrCross::CanvasCircleOrCross(int x, int y, QCanvas *canvas) : 48CanvasCircleOrCross::CanvasCircleOrCross(int x, int y, QCanvas *canvas) :
51 QCanvasRectangle( x, y, 21, 21, canvas), circleShape(TRUE) 49 QCanvasRectangle( x, y, 21, 21, canvas), circleShape(TRUE)
52{ 50{
53 show(); 51 show();
54} 52}
55 53
56 54
57void CanvasCircleOrCross::redraw() 55void CanvasCircleOrCross::redraw()
58{ 56{
59 hide(); 57 hide();
60 show(); 58 show();
61} 59}
62 60
63 61
64void CanvasCircleOrCross::setCircle() 62void CanvasCircleOrCross::setCircle()
65{ 63{
66 circleShape = TRUE; 64 circleShape = TRUE;
67 redraw(); 65 redraw();
68} 66}
69 67
70 68
71void CanvasCircleOrCross::setCross() 69void CanvasCircleOrCross::setCross()
72{ 70{
73 circleShape = FALSE; 71 circleShape = FALSE;
74 redraw(); 72 redraw();
75} 73}
76 74
77 75
78void CanvasCircleOrCross::drawShape(QPainter &p) 76void CanvasCircleOrCross::drawShape(QPainter &p)
79{ 77{
80 if ( qt_screen->deviceWidth() < 200 ) { 78 if ( qt_screen->deviceWidth() < 200 ) {
81 int x1 = (int)x(), y1 = (int)y(); 79 int x1 = (int)x(), y1 = (int)y();
82 // Green circle 80 // Green circle
83 if (circleShape == TRUE) { 81 if (circleShape == TRUE) {
84 p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) ); 82 p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) );
85 p.drawEllipse( x1 - 1, y1 - 1, 17, 17); 83 p.drawEllipse( x1 - 1, y1 - 1, 17, 17);
86 p.drawEllipse( x1 - 1, y1 - 0, 17, 15); 84 p.drawEllipse( x1 - 1, y1 - 0, 17, 15);
87 p.drawEllipse( x1 + 0, y1 + 0, 15, 15); 85 p.drawEllipse( x1 + 0, y1 + 0, 15, 15);
88 p.drawEllipse( x1 + 1, y1 + 0, 13, 15); 86 p.drawEllipse( x1 + 1, y1 + 0, 13, 15);
89 p.drawEllipse( x1 + 1, y1 + 1, 13, 13); 87 p.drawEllipse( x1 + 1, y1 + 1, 13, 13);
90 // Red cross 88 // Red cross
91 } else { 89 } else {
92 p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 4 ) ); 90 p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 4 ) );
93 p.drawLine( x1, y1, x1 + 14, y1 + 14); 91 p.drawLine( x1, y1, x1 + 14, y1 + 14);
94 p.drawLine( x1 + 14, y1, x1, y1 + 14); 92 p.drawLine( x1 + 14, y1, x1, y1 + 14);
95 } 93 }
96 } else { 94 } else {
97 int x1 = (int)x(), y1 = (int)y(); 95 int x1 = (int)x(), y1 = (int)y();
98 // Green circle 96 // Green circle
99 if (circleShape == TRUE) { 97 if (circleShape == TRUE) {
100 p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) ); 98 p.setPen( QPen( QColor(0x10, 0xE0, 0x10), 1 ) );
101 p.drawEllipse( x1 - 1, y1 - 1, 21, 21); 99 p.drawEllipse( x1 - 1, y1 - 1, 21, 21);
102 p.drawEllipse( x1 - 1, y1 - 0, 21, 19); 100 p.drawEllipse( x1 - 1, y1 - 0, 21, 19);
103 p.drawEllipse( x1 + 0, y1 + 0, 19, 19); 101 p.drawEllipse( x1 + 0, y1 + 0, 19, 19);
104 p.drawEllipse( x1 + 1, y1 + 0, 17, 19); 102 p.drawEllipse( x1 + 1, y1 + 0, 17, 19);
105 p.drawEllipse( x1 + 1, y1 + 1, 17, 17); 103 p.drawEllipse( x1 + 1, y1 + 1, 17, 17);
106 // Red cross 104 // Red cross
107 } else { 105 } else {
108 p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 5 ) ); 106 p.setPen( QPen( QColor(0xE0, 0x10, 0x10), 5 ) );
109 p.drawLine( x1, y1, x1 + 20, y1 + 20); 107 p.drawLine( x1, y1, x1 + 20, y1 + 20);
110 p.drawLine( x1 + 20, y1, x1, y1 + 20); 108 p.drawLine( x1 + 20, y1, x1, y1 + 20);
111 } 109 }
112 } 110 }
113} 111}
114 112
diff --git a/noncore/games/solitaire/card.cpp b/noncore/games/solitaire/card.cpp
index 609e280..52e38ac 100644
--- a/noncore/games/solitaire/card.cpp
+++ b/noncore/games/solitaire/card.cpp
@@ -1,53 +1,50 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "card.h" 21#include "card.h"
22 22
23#include <qpe/config.h>
24 23
25#include <qpoint.h>
26#include <qlist.h>
27 24
28/* 25/*
29Card( eValue v, eSuit s, bool f ) : 26Card( eValue v, eSuit s, bool f ) :
30 val(v), suit(s), faceUp(f), showing(FALSE), ix(0), iy(0), iz(0), cardPile(NULL) { } 27 val(v), suit(s), faceUp(f), showing(FALSE), ix(0), iy(0), iz(0), cardPile(NULL) { }
31virtual ~Card() { } 28virtual ~Card() { }
32eValue getValue() { return val; } 29eValue getValue() { return val; }
33eSuit getSuit() { return suit; } 30eSuit getSuit() { return suit; }
34CardPile *getCardPile() { return cardPile; } 31CardPile *getCardPile() { return cardPile; }
35bool isFacing() { return faceUp; } 32bool isFacing() { return faceUp; }
36bool isShowing() { return showing; } 33bool isShowing() { return showing; }
37bool isRed() { return ((suit == diamonds) || (suit == hearts)); } 34bool isRed() { return ((suit == diamonds) || (suit == hearts)); }
38int getX(void) { return ix; } 35int getX(void) { return ix; }
39int getY(void) { return iy; } 36int getY(void) { return iy; }
40int getZ(void) { return iz; } 37int getZ(void) { return iz; }
41void setCardPile(CardPile *p) { cardPile = p; } 38void setCardPile(CardPile *p) { cardPile = p; }
42void setFace(bool f) { faceUp = f; } 39void setFace(bool f) { faceUp = f; }
43void flip(void) { flipTo(getX(), getY()); } 40void flip(void) { flipTo(getX(), getY()); }
44virtual void setPos(int x, int y, int z) { ix = x; iy = y; iz = z; } 41virtual void setPos(int x, int y, int z) { ix = x; iy = y; iz = z; }
45virtual void move(int x, int y) { ix = x; iy = y; } 42virtual void move(int x, int y) { ix = x; iy = y; }
46virtual void move(QPoint p) { ix = p.x(); iy = p.y(); } 43virtual void move(QPoint p) { ix = p.x(); iy = p.y(); }
47virtual void flipTo(int x, int y, int steps = 8) { ix = x; iy = y; faceUp = !faceUp; redraw(); Q_UNUSED(steps); } 44virtual void flipTo(int x, int y, int steps = 8) { ix = x; iy = y; faceUp = !faceUp; redraw(); Q_UNUSED(steps); }
48virtual void showCard(void) { showing = TRUE; } 45virtual void showCard(void) { showing = TRUE; }
49virtual void hideCard(void) { showing = FALSE; } 46virtual void hideCard(void) { showing = FALSE; }
50virtual void redraw(void) { } 47virtual void redraw(void) { }
51*/ 48*/
52 49
53 50
diff --git a/noncore/games/solitaire/cardpile.cpp b/noncore/games/solitaire/cardpile.cpp
index aace2e2..1d572be 100644
--- a/noncore/games/solitaire/cardpile.cpp
+++ b/noncore/games/solitaire/cardpile.cpp
@@ -1,115 +1,113 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "cardpile.h" 21#include "cardpile.h"
22#include "card.h" 22#include "card.h"
23 23
24#include <qpe/config.h> 24#include <qpe/config.h>
25#include <qpoint.h>
26 25
27#include <qlist.h>
28 26
29 27
30CardPile::CardPile(int x, int y) : pileX(x), pileY(y), dealing(FALSE), PileResize(FALSE) { 28CardPile::CardPile(int x, int y) : pileX(x), pileY(y), dealing(FALSE), PileResize(FALSE) {
31 pileWidth = 0; 29 pileWidth = 0;
32 pileHeight = 0; 30 pileHeight = 0;
33 pileNextX = pileX; 31 pileNextX = pileX;
34 pileNextY = pileY; 32 pileNextY = pileY;
35 pileCenterX = x + pileWidth / 2; 33 pileCenterX = x + pileWidth / 2;
36 pileCenterY = y + pileHeight / 2; 34 pileCenterY = y + pileHeight / 2;
37 pileRadius = (pileWidth > pileHeight) ? pileWidth : pileHeight; 35 pileRadius = (pileWidth > pileHeight) ? pileWidth : pileHeight;
38 pileOffsetDown = 13; 36 pileOffsetDown = 13;
39} 37}
40 38
41 39
42int CardPile::distanceFromPile(int x, int y) { 40int CardPile::distanceFromPile(int x, int y) {
43 return (pileCenterX-x)*(pileCenterX-x)+(pileCenterY-y)*(pileCenterY-y); 41 return (pileCenterX-x)*(pileCenterX-x)+(pileCenterY-y)*(pileCenterY-y);
44} 42}
45 43
46 44
47int CardPile::distanceFromNextPos(int x, int y) { 45int CardPile::distanceFromNextPos(int x, int y) {
48 return (pileNextX-x)*(pileNextX-x)+(pileNextY-y)*(pileNextY-y); 46 return (pileNextX-x)*(pileNextX-x)+(pileNextY-y)*(pileNextY-y);
49} 47}
50 48
51 49
52Card *CardPile::cardInfront(Card *c) { 50Card *CardPile::cardInfront(Card *c) {
53 CardPile *p = c->getCardPile(); 51 CardPile *p = c->getCardPile();
54 if (p) { 52 if (p) {
55 p->at(p->find(c)); 53 p->at(p->find(c));
56 return p->next(); 54 return p->next();
57 } else { 55 } else {
58 return NULL; 56 return NULL;
59 } 57 }
60} 58}
61 59
62 60
63bool CardPile::kingOnTop() { 61bool CardPile::kingOnTop() {
64 Card *top = cardOnTop(); 62 Card *top = cardOnTop();
65 return top && top->getValue() == king; 63 return top && top->getValue() == king;
66} 64}
67 65
68 66
69bool CardPile::addCardToTop(Card *c) { 67bool CardPile::addCardToTop(Card *c) {
70 if (dealing || isAllowedOnTop(c)) { 68 if (dealing || isAllowedOnTop(c)) {
71 append((const Card *)c); 69 append((const Card *)c);
72 cardAddedToTop(c); 70 cardAddedToTop(c);
73 return TRUE; 71 return TRUE;
74 } 72 }
75 return FALSE; 73 return FALSE;
76} 74}
77 75
78 76
79bool CardPile::addCardToBottom(Card *c) { 77bool CardPile::addCardToBottom(Card *c) {
80 if (dealing || isAllowedOnBottom(c)) { 78 if (dealing || isAllowedOnBottom(c)) {
81 prepend((const Card *)c); 79 prepend((const Card *)c);
82 cardAddedToBottom(c); 80 cardAddedToBottom(c);
83 return TRUE; 81 return TRUE;
84 } 82 }
85 return FALSE; 83 return FALSE;
86} 84}
87 85
88 86
89bool CardPile::removeCard(Card *c) { 87bool CardPile::removeCard(Card *c) {
90 if (dealing || isAllowedToBeMoved(c)) { 88 if (dealing || isAllowedToBeMoved(c)) {
91 take(find(c)); 89 take(find(c));
92 cardRemoved(c); 90 cardRemoved(c);
93 return TRUE; 91 return TRUE;
94 } 92 }
95 return FALSE; 93 return FALSE;
96} 94}
97 95
98 96
99void CardPile::writeConfig( Config& cfg, QString name ) { 97void CardPile::writeConfig( Config& cfg, QString name ) {
100 int numberOfCards = 0; 98 int numberOfCards = 0;
101 cfg.setGroup( name ); 99 cfg.setGroup( name );
102 Card *card = cardOnBottom(); 100 Card *card = cardOnBottom();
103 while ( card ) { 101 while ( card ) {
104 QString cardStr; 102 QString cardStr;
105 cardStr.sprintf( "%i", numberOfCards ); 103 cardStr.sprintf( "%i", numberOfCards );
106 int val = (int)card->getValue()-1 + ((int)card->getSuit()-1)*13 + (int)card->getDeckNumber()*52; 104 int val = (int)card->getValue()-1 + ((int)card->getSuit()-1)*13 + (int)card->getDeckNumber()*52;
107 cfg.writeEntry( "Card" + cardStr, val ); 105 cfg.writeEntry( "Card" + cardStr, val );
108 cfg.writeEntry( "CardFacing" + cardStr, card->isFacing() ); 106 cfg.writeEntry( "CardFacing" + cardStr, card->isFacing() );
109 card = cardInfront( card ); 107 card = cardInfront( card );
110 numberOfCards++; 108 numberOfCards++;
111 } 109 }
112 cfg.writeEntry("NumberOfCards", numberOfCards); 110 cfg.writeEntry("NumberOfCards", numberOfCards);
113} 111}
114 112
115 113
diff --git a/noncore/games/solitaire/chicanecardgame.cpp b/noncore/games/solitaire/chicanecardgame.cpp
index 6729a94..6c607b9 100644
--- a/noncore/games/solitaire/chicanecardgame.cpp
+++ b/noncore/games/solitaire/chicanecardgame.cpp
@@ -1,125 +1,124 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19** 19**
20** created on base of patiencecardgame by cam (C.A.Mader) 2002 20** created on base of patiencecardgame by cam (C.A.Mader) 2002
21** Rules for this game: 21** Rules for this game:
22 **use 2 decks = 104 cards 22 **use 2 decks = 104 cards
23 **deal 8 rows with 3 hidden cards and one open card 23 **deal 8 rows with 3 hidden cards and one open card
24** append red to black and vice versa 24** append red to black and vice versa
25 **each card can be layed on a free place 25 **each card can be layed on a free place
26 **deal 8 cards at once 26 **deal 8 cards at once
27** 27**
28**********************************************************************/ 28**********************************************************************/
29#include <qgfx_qws.h>
30#include "chicanecardgame.h" 29#include "chicanecardgame.h"
31 30
32 31
33extern int highestZ; 32extern int highestZ;
34 33
35 34
36 ChicaneCardGame::ChicaneCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent, 2)// Use 2 Decks 35 ChicaneCardGame::ChicaneCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent, 2)// Use 2 Decks
37{ 36{
38 highestZ = 0; 37 highestZ = 0;
39 38
40 for (int i = 0; i < 8; i++) { 39 for (int i = 0; i < 8; i++) {
41 discardPiles[i] = new ChicaneDiscardPile( 27 + i * 26, 10, canvas() ); 40 discardPiles[i] = new ChicaneDiscardPile( 27 + i * 26, 10, canvas() );
42 addCardPile(discardPiles[i]); 41 addCardPile(discardPiles[i]);
43 } 42 }
44 for (int i = 0; i < 8; i++) { 43 for (int i = 0; i < 8; i++) {
45 workingPiles[i] = new ChicaneWorkingPile( 27 + i * 26, 50, canvas() ); 44 workingPiles[i] = new ChicaneWorkingPile( 27 + i * 26, 50, canvas() );
46 addCardPile(workingPiles[i]); 45 addCardPile(workingPiles[i]);
47 } 46 }
48 faceDownDealingPile = new ChicaneFaceDownDeck( 2, 10, canvas() ); 47 faceDownDealingPile = new ChicaneFaceDownDeck( 2, 10, canvas() );
49} 48}
50 49
51 50
52void ChicaneCardGame::deal(void) 51void ChicaneCardGame::deal(void)
53{ 52{
54 highestZ = 1; 53 highestZ = 1;
55 int t = 0; 54 int t = 0;
56 55
57 beginDealing(); 56 beginDealing();
58 57
59 for (int i = 0; i < 8; i++) { 58 for (int i = 0; i < 8; i++) {
60 for (int k = 0; k < 4; k++, t++) { 59 for (int k = 0; k < 4; k++, t++) {
61 Card *card = cards[t]; 60 Card *card = cards[t];
62 workingPiles[i]->addCardToTop(card); 61 workingPiles[i]->addCardToTop(card);
63 card->setCardPile( workingPiles[i] ); 62 card->setCardPile( workingPiles[i] );
64 card->setPos( 0, 0, highestZ ); 63 card->setPos( 0, 0, highestZ );
65 card->setFace(k==3); 64 card->setFace(k==3);
66 card->move( workingPiles[i]->getCardPos( card ) ); 65 card->move( workingPiles[i]->getCardPos( card ) );
67 card->showCard(); 66 card->showCard();
68 highestZ++; 67 highestZ++;
69 } 68 }
70 } 69 }
71 70
72 for ( ; t < getNumberOfCards(); t++) { 71 for ( ; t < getNumberOfCards(); t++) {
73 Card *card = cards[t]; 72 Card *card = cards[t];
74 faceDownDealingPile->addCardToTop(card); 73 faceDownDealingPile->addCardToTop(card);
75 card->setCardPile( faceDownDealingPile ); 74 card->setCardPile( faceDownDealingPile );
76 QPoint p = faceDownDealingPile->getCardPos( card ); 75 QPoint p = faceDownDealingPile->getCardPos( card );
77 card->setPos( p.x(), p.y(), highestZ ); 76 card->setPos( p.x(), p.y(), highestZ );
78 card->showCard(); 77 card->showCard();
79 highestZ++; 78 highestZ++;
80 } 79 }
81 80
82 endDealing(); 81 endDealing();
83} 82}
84 83
85 84
86void ChicaneCardGame::readConfig( Config& cfg ) 85void ChicaneCardGame::readConfig( Config& cfg )
87{ 86{
88 cfg.setGroup("GameState"); 87 cfg.setGroup("GameState");
89 88
90 // Create Cards, but don't shuffle or deal them yet 89 // Create Cards, but don't shuffle or deal them yet
91 createDeck(); 90 createDeck();
92 91
93 // Move the cards to their piles (deal them to their previous places) 92 // Move the cards to their piles (deal them to their previous places)
94 beginDealing(); 93 beginDealing();
95 94
96 highestZ = 1; 95 highestZ = 1;
97 96
98 for (int i = 0; i < 8; i++) { 97 for (int i = 0; i < 8; i++) {
99 QString pile; 98 QString pile;
100 pile.sprintf( "ChicaneDiscardPile%i", i ); 99 pile.sprintf( "ChicaneDiscardPile%i", i );
101 readPile( cfg, discardPiles[i], pile, highestZ ); 100 readPile( cfg, discardPiles[i], pile, highestZ );
102 } 101 }
103 102
104 for (int i = 0; i < 8; i++) { 103 for (int i = 0; i < 8; i++) {
105 QString pile; 104 QString pile;
106 pile.sprintf( "ChicaneWorkingPile%i", i ); 105 pile.sprintf( "ChicaneWorkingPile%i", i );
107 readPile( cfg, workingPiles[i], pile, highestZ ); 106 readPile( cfg, workingPiles[i], pile, highestZ );
108 } 107 }
109 108
110 readPile( cfg, faceDownDealingPile, "ChicaneFaceDownDealingPile", highestZ ); 109 readPile( cfg, faceDownDealingPile, "ChicaneFaceDownDealingPile", highestZ );
111 110
112 highestZ++; 111 highestZ++;
113 112
114 endDealing(); 113 endDealing();
115} 114}
116 115
117 116
118void ChicaneCardGame::writeConfig( Config& cfg ) 117void ChicaneCardGame::writeConfig( Config& cfg )
119{ 118{
120 cfg.setGroup("GameState"); 119 cfg.setGroup("GameState");
121 for ( int i = 0; i < 8; i++ ) { 120 for ( int i = 0; i < 8; i++ ) {
122 QString pile; 121 QString pile;
123 pile.sprintf( "ChicaneDiscardPile%i", i ); 122 pile.sprintf( "ChicaneDiscardPile%i", i );
124 discardPiles[i]->writeConfig( cfg, pile ); 123 discardPiles[i]->writeConfig( cfg, pile );
125 } 124 }
diff --git a/noncore/games/solitaire/freecellcardgame.cpp b/noncore/games/solitaire/freecellcardgame.cpp
index aeb32fc..d474f4e 100644
--- a/noncore/games/solitaire/freecellcardgame.cpp
+++ b/noncore/games/solitaire/freecellcardgame.cpp
@@ -1,116 +1,115 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qgfx_qws.h>
21#include "freecellcardgame.h" 20#include "freecellcardgame.h"
22 21
23 22
24extern int highestZ; 23extern int highestZ;
25int numberOfFreeCells = 4; 24int numberOfFreeCells = 4;
26 25
27 26
28FreecellCardGame::FreecellCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent) 27FreecellCardGame::FreecellCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent)
29{ 28{
30 numberOfFreeCells = 4; 29 numberOfFreeCells = 4;
31 highestZ = 0; 30 highestZ = 0;
32 31
33 int spaceBetweenPiles = ( qt_screen->deviceWidth() < 200 ) ? 21 : 28; 32 int spaceBetweenPiles = ( qt_screen->deviceWidth() < 200 ) ? 21 : 28;
34 int xOrigin = ( qt_screen->deviceWidth() < 200 ) ? 0 : 5; 33 int xOrigin = ( qt_screen->deviceWidth() < 200 ) ? 0 : 5;
35 int spacing = ( qt_screen->deviceWidth() < 200 ) ? 0 : 0; 34 int spacing = ( qt_screen->deviceWidth() < 200 ) ? 0 : 0;
36 35
37 for (int i = 0; i < 4; i++) { 36 for (int i = 0; i < 4; i++) {
38 freecellPiles[i] = new FreecellFreecellPile( xOrigin + i * spaceBetweenPiles, 10, canvas() ); 37 freecellPiles[i] = new FreecellFreecellPile( xOrigin + i * spaceBetweenPiles, 10, canvas() );
39 addCardPile(freecellPiles[i]); 38 addCardPile(freecellPiles[i]);
40 } 39 }
41 for (int i = 0; i < 4; i++) { 40 for (int i = 0; i < 4; i++) {
42 discardPiles[i] = new FreecellDiscardPile( xOrigin + spacing + 6 + (i + 4) * spaceBetweenPiles, 10, canvas() ); 41 discardPiles[i] = new FreecellDiscardPile( xOrigin + spacing + 6 + (i + 4) * spaceBetweenPiles, 10, canvas() );
43 addCardPile(discardPiles[i]); 42 addCardPile(discardPiles[i]);
44 } 43 }
45 for (int i = 0; i < 8; i++) { 44 for (int i = 0; i < 8; i++) {
46 workingPiles[i] = new FreecellWorkingPile( xOrigin + spacing + 2 + i * spaceBetweenPiles, 50, canvas() ); 45 workingPiles[i] = new FreecellWorkingPile( xOrigin + spacing + 2 + i * spaceBetweenPiles, 50, canvas() );
47 addCardPile(workingPiles[i]); 46 addCardPile(workingPiles[i]);
48 } 47 }
49} 48}
50 49
51 50
52void FreecellCardGame::deal(void) 51void FreecellCardGame::deal(void)
53{ 52{
54 highestZ = 1; 53 highestZ = 1;
55 54
56 beginDealing(); 55 beginDealing();
57 56
58 for (int i = 0; i < 52; i++) { 57 for (int i = 0; i < 52; i++) {
59 Card *card = cards[i]; 58 Card *card = cards[i];
60 card->setFace( TRUE ); 59 card->setFace( TRUE );
61 card->setPos( 0, 0, highestZ ); 60 card->setPos( 0, 0, highestZ );
62 card->setCardPile( workingPiles[i%8] ); 61 card->setCardPile( workingPiles[i%8] );
63 workingPiles[i%8]->addCardToTop( card ); 62 workingPiles[i%8]->addCardToTop( card );
64 card->move( workingPiles[i%8]->getCardPos( card ) ); 63 card->move( workingPiles[i%8]->getCardPos( card ) );
65 card->showCard(); 64 card->showCard();
66 highestZ++; 65 highestZ++;
67 } 66 }
68 67
69 endDealing(); 68 endDealing();
70} 69}
71 70
72 // checks if smaller card with different color, that could be put on top on the 71 // checks if smaller card with different color, that could be put on top on the
73 // card, is present in working or freecell pile 72 // card, is present in working or freecell pile
74bool FreecellCardGame::checkNeeded(Card *card) 73bool FreecellCardGame::checkNeeded(Card *card)
75{ 74{
76 if (card->getValue() > 2){ 75 if (card->getValue() > 2){
77 int i; 76 int i;
78 Card *c; 77 Card *c;
79 for (i=0;i<4;i++){ 78 for (i=0;i<4;i++){
80 c = freecellPiles[i]->cardOnBottom(); 79 c = freecellPiles[i]->cardOnBottom();
81 if (c != NULL){ 80 if (c != NULL){
82 if (card->isRed()!= c->isRed() && card->getValue()== c->getValue()+1){ 81 if (card->isRed()!= c->isRed() && card->getValue()== c->getValue()+1){
83 return (false); 82 return (false);
84 } 83 }
85 } 84 }
86 } 85 }
87 for (i=0;i<8;i++){ 86 for (i=0;i<8;i++){
88 c=workingPiles[i]->cardOnBottom(); 87 c=workingPiles[i]->cardOnBottom();
89 while (c!=NULL){ 88 while (c!=NULL){
90 if (card->isRed() != c->isRed()&& card->getValue() == c->getValue()+1) { 89 if (card->isRed() != c->isRed()&& card->getValue() == c->getValue()+1) {
91 return (false); 90 return (false);
92 } 91 }
93 c=workingPiles[i]->cardInfront(c); 92 c=workingPiles[i]->cardInfront(c);
94 } 93 }
95 } 94 }
96 } 95 }
97 return(true); 96 return(true);
98} 97}
99 98
100// added to move cards, on which no card can be moved, to discard pile 99// added to move cards, on which no card can be moved, to discard pile
101void FreecellCardGame::checkUnusable() 100void FreecellCardGame::checkUnusable()
102{ 101{
103 int i,j; 102 int i,j;
104 //printf("void FreecellCardGame::checkUnusable()\n"); 103 //printf("void FreecellCardGame::checkUnusable()\n");
105 Card *top_one; 104 Card *top_one;
106 for (i=0;i < 8;i++) 105 for (i=0;i < 8;i++)
107 { 106 {
108 top_one = workingPiles[i]->cardOnTop(); 107 top_one = workingPiles[i]->cardOnTop();
109 if (top_one != NULL) 108 if (top_one != NULL)
110 { 109 {
111 j = 0; 110 j = 0;
112 while ((j < 4)) 111 while ((j < 4))
113 { 112 {
114 if (discardPiles[j]->isAllowedOnTop(top_one)){ 113 if (discardPiles[j]->isAllowedOnTop(top_one)){
115 if (checkNeeded(top_one)){ 114 if (checkNeeded(top_one)){
116 top_one->setCardPile(discardPiles[j]); 115 top_one->setCardPile(discardPiles[j]);
diff --git a/noncore/games/solitaire/harpcardgame.cpp b/noncore/games/solitaire/harpcardgame.cpp
index 0711622..d13d73b 100644
--- a/noncore/games/solitaire/harpcardgame.cpp
+++ b/noncore/games/solitaire/harpcardgame.cpp
@@ -1,127 +1,126 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19** 19**
20** created on base of patiencecardgame by cam (C.A.Mader) 2002 20** created on base of patiencecardgame by cam (C.A.Mader) 2002
21** Rules for this game: 21** Rules for this game:
22** use 2 decks = 104 cards 22** use 2 decks = 104 cards
23** deal 8 rows with one open card in the first place 23** deal 8 rows with one open card in the first place
24** one hidden and one open in the second place and so on 24** one hidden and one open in the second place and so on
25** append red to black and vice versa 25** append red to black and vice versa
26** each card can be layed on a free place 26** each card can be layed on a free place
27** deal 8 cards at once 27** deal 8 cards at once
28** 28**
29** 29**
30**********************************************************************/ 30**********************************************************************/
31#include <qgfx_qws.h>
32#include "harpcardgame.h" 31#include "harpcardgame.h"
33 32
34 33
35extern int highestZ; 34extern int highestZ;
36 35
37 36
38 HarpCardGame::HarpCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent, 2)// Use 2 Decks 37 HarpCardGame::HarpCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent, 2)// Use 2 Decks
39{ 38{
40 highestZ = 0; 39 highestZ = 0;
41 40
42 for (int i = 0; i < 8; i++) { 41 for (int i = 0; i < 8; i++) {
43 discardPiles[i] = new HarpDiscardPile( 27 + i * 26, 10, canvas() ); 42 discardPiles[i] = new HarpDiscardPile( 27 + i * 26, 10, canvas() );
44 addCardPile(discardPiles[i]); 43 addCardPile(discardPiles[i]);
45 } 44 }
46 for (int i = 0; i < 8; i++) { 45 for (int i = 0; i < 8; i++) {
47 workingPiles[i] = new HarpWorkingPile( 27 + i * 26, 50, canvas() ); 46 workingPiles[i] = new HarpWorkingPile( 27 + i * 26, 50, canvas() );
48 addCardPile(workingPiles[i]); 47 addCardPile(workingPiles[i]);
49 } 48 }
50 faceDownDealingPile = new HarpFaceDownDeck( 2, 10, canvas() ); 49 faceDownDealingPile = new HarpFaceDownDeck( 2, 10, canvas() );
51} 50}
52 51
53 52
54void HarpCardGame::deal(void) 53void HarpCardGame::deal(void)
55{ 54{
56 highestZ = 1; 55 highestZ = 1;
57 int t = 0; 56 int t = 0;
58 57
59 beginDealing(); 58 beginDealing();
60 59
61 for (int i = 0; i < 8; i++) { 60 for (int i = 0; i < 8; i++) {
62 for (int k = 0; k < i+1; k++, t++) { 61 for (int k = 0; k < i+1; k++, t++) {
63 Card *card = cards[t]; 62 Card *card = cards[t];
64 workingPiles[i]->addCardToTop(card); 63 workingPiles[i]->addCardToTop(card);
65 card->setCardPile( workingPiles[i] ); 64 card->setCardPile( workingPiles[i] );
66 card->setPos( 0, 0, highestZ ); 65 card->setPos( 0, 0, highestZ );
67 card->setFace(k==i); 66 card->setFace(k==i);
68 card->move( workingPiles[i]->getCardPos( card ) ); 67 card->move( workingPiles[i]->getCardPos( card ) );
69 card->showCard(); 68 card->showCard();
70 highestZ++; 69 highestZ++;
71 } 70 }
72 } 71 }
73 72
74 for ( ; t < getNumberOfCards(); t++) { 73 for ( ; t < getNumberOfCards(); t++) {
75 Card *card = cards[t]; 74 Card *card = cards[t];
76 faceDownDealingPile->addCardToTop(card); 75 faceDownDealingPile->addCardToTop(card);
77 card->setCardPile( faceDownDealingPile ); 76 card->setCardPile( faceDownDealingPile );
78 QPoint p = faceDownDealingPile->getCardPos( card ); 77 QPoint p = faceDownDealingPile->getCardPos( card );
79 card->setPos( p.x(), p.y(), highestZ ); 78 card->setPos( p.x(), p.y(), highestZ );
80 card->showCard(); 79 card->showCard();
81 highestZ++; 80 highestZ++;
82 } 81 }
83 82
84 endDealing(); 83 endDealing();
85} 84}
86 85
87 86
88void HarpCardGame::readConfig( Config& cfg ) 87void HarpCardGame::readConfig( Config& cfg )
89{ 88{
90 cfg.setGroup("GameState"); 89 cfg.setGroup("GameState");
91 90
92 // Create Cards, but don't shuffle or deal them yet 91 // Create Cards, but don't shuffle or deal them yet
93 createDeck(); 92 createDeck();
94 93
95 // Move the cards to their piles (deal them to their previous places) 94 // Move the cards to their piles (deal them to their previous places)
96 beginDealing(); 95 beginDealing();
97 96
98 highestZ = 1; 97 highestZ = 1;
99 98
100 for (int i = 0; i < 8; i++) { 99 for (int i = 0; i < 8; i++) {
101 QString pile; 100 QString pile;
102 pile.sprintf( "HarpDiscardPile%i", i ); 101 pile.sprintf( "HarpDiscardPile%i", i );
103 readPile( cfg, discardPiles[i], pile, highestZ ); 102 readPile( cfg, discardPiles[i], pile, highestZ );
104 } 103 }
105 104
106 for (int i = 0; i < 8; i++) { 105 for (int i = 0; i < 8; i++) {
107 QString pile; 106 QString pile;
108 pile.sprintf( "HarpWorkingPile%i", i ); 107 pile.sprintf( "HarpWorkingPile%i", i );
109 readPile( cfg, workingPiles[i], pile, highestZ ); 108 readPile( cfg, workingPiles[i], pile, highestZ );
110 } 109 }
111 110
112 readPile( cfg, faceDownDealingPile, "HarpFaceDownDealingPile", highestZ ); 111 readPile( cfg, faceDownDealingPile, "HarpFaceDownDealingPile", highestZ );
113 112
114 highestZ++; 113 highestZ++;
115 114
116 endDealing(); 115 endDealing();
117} 116}
118 117
119 118
120void HarpCardGame::writeConfig( Config& cfg ) 119void HarpCardGame::writeConfig( Config& cfg )
121{ 120{
122 cfg.setGroup("GameState"); 121 cfg.setGroup("GameState");
123 for ( int i = 0; i < 8; i++ ) { 122 for ( int i = 0; i < 8; i++ ) {
124 QString pile; 123 QString pile;
125 pile.sprintf( "HarpDiscardPile%i", i ); 124 pile.sprintf( "HarpDiscardPile%i", i );
126 discardPiles[i]->writeConfig( cfg, pile ); 125 discardPiles[i]->writeConfig( cfg, pile );
127 } 126 }
diff --git a/noncore/games/solitaire/main.cpp b/noncore/games/solitaire/main.cpp
index bd3cf8b..9301171 100644
--- a/noncore/games/solitaire/main.cpp
+++ b/noncore/games/solitaire/main.cpp
@@ -1,26 +1,25 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "canvascardwindow.h" 21#include "canvascardwindow.h"
22 22
23#include <qpe/qpeapplication.h>
24#include <opie/oapplicationfactory.h> 23#include <opie/oapplicationfactory.h>
25 24
26OPIE_EXPORT_APP( OApplicationFactory<CanvasCardWindow> ) \ No newline at end of file 25OPIE_EXPORT_APP( OApplicationFactory<CanvasCardWindow> ) \ No newline at end of file
diff --git a/noncore/games/solitaire/patiencecardgame.cpp b/noncore/games/solitaire/patiencecardgame.cpp
index 96a599c..756577a 100644
--- a/noncore/games/solitaire/patiencecardgame.cpp
+++ b/noncore/games/solitaire/patiencecardgame.cpp
@@ -1,116 +1,115 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qgfx_qws.h>
21#include "patiencecardgame.h" 20#include "patiencecardgame.h"
22 21
23 22
24int highestZ = 0; 23int highestZ = 0;
25 24
26 25
27PatienceCardGame::PatienceCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent) 26PatienceCardGame::PatienceCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent)
28{ 27{
29 numberOfTimesThroughDeck = 0; 28 numberOfTimesThroughDeck = 0;
30 highestZ = 0; 29 highestZ = 0;
31 30
32 if ( qt_screen->deviceWidth() < 200 ) 31 if ( qt_screen->deviceWidth() < 200 )
33 { 32 {
34 circleCross = new CanvasCircleOrCross( 7, 16, canvas() ); 33 circleCross = new CanvasCircleOrCross( 7, 16, canvas() );
35 rectangle = new CanvasRoundRect( 30, 10, canvas() ); 34 rectangle = new CanvasRoundRect( 30, 10, canvas() );
36 35
37 for (int i = 0; i < 4; i++) 36 for (int i = 0; i < 4; i++)
38 { 37 {
39 discardPiles[i] = new PatienceDiscardPile( 78 + i * 23, 10, canvas() ); 38 discardPiles[i] = new PatienceDiscardPile( 78 + i * 23, 10, canvas() );
40 addCardPile(discardPiles[i]); 39 addCardPile(discardPiles[i]);
41 } 40 }
42 for (int i = 0; i < 7; i++) 41 for (int i = 0; i < 7; i++)
43 { 42 {
44 workingPiles[i] = new PatienceWorkingPile( 5 + i * 23, 50, canvas() ); 43 workingPiles[i] = new PatienceWorkingPile( 5 + i * 23, 50, canvas() );
45 addCardPile(workingPiles[i]); 44 addCardPile(workingPiles[i]);
46 } 45 }
47 faceDownDealingPile = new PatienceFaceDownDeck( 5, 10, canvas() ); 46 faceDownDealingPile = new PatienceFaceDownDeck( 5, 10, canvas() );
48 faceUpDealingPile = new PatienceFaceUpDeck( 30, 10, canvas() ); 47 faceUpDealingPile = new PatienceFaceUpDeck( 30, 10, canvas() );
49 } 48 }
50 else 49 else
51 { 50 {
52 circleCross = new CanvasCircleOrCross( 7, 18, canvas() ); 51 circleCross = new CanvasCircleOrCross( 7, 18, canvas() );
53 rectangle = new CanvasRoundRect( 35, 10, canvas() ); 52 rectangle = new CanvasRoundRect( 35, 10, canvas() );
54 53
55 for (int i = 0; i < 4; i++) 54 for (int i = 0; i < 4; i++)
56 { 55 {
57 discardPiles[i] = new PatienceDiscardPile( 110 + i * 30, 10, canvas() ); 56 discardPiles[i] = new PatienceDiscardPile( 110 + i * 30, 10, canvas() );
58 addCardPile(discardPiles[i]); 57 addCardPile(discardPiles[i]);
59 } 58 }
60 for (int i = 0; i < 7; i++) 59 for (int i = 0; i < 7; i++)
61 { 60 {
62 workingPiles[i] = new PatienceWorkingPile( 10 + i * 30, 50, canvas() ); 61 workingPiles[i] = new PatienceWorkingPile( 10 + i * 30, 50, canvas() );
63 addCardPile(workingPiles[i]); 62 addCardPile(workingPiles[i]);
64 } 63 }
65 faceDownDealingPile = new PatienceFaceDownDeck( 5, 10, canvas() ); 64 faceDownDealingPile = new PatienceFaceDownDeck( 5, 10, canvas() );
66 faceUpDealingPile = new PatienceFaceUpDeck( 35, 10, canvas() ); 65 faceUpDealingPile = new PatienceFaceUpDeck( 35, 10, canvas() );
67 } 66 }
68} 67}
69 68
70 69
71PatienceCardGame::~PatienceCardGame() 70PatienceCardGame::~PatienceCardGame()
72{ 71{
73 delete circleCross; 72 delete circleCross;
74 delete rectangle; 73 delete rectangle;
75 delete faceDownDealingPile; 74 delete faceDownDealingPile;
76 delete faceUpDealingPile; 75 delete faceUpDealingPile;
77} 76}
78 77
79 78
80void PatienceCardGame::deal(void) 79void PatienceCardGame::deal(void)
81{ 80{
82 highestZ = 1; 81 highestZ = 1;
83 int t = 0; 82 int t = 0;
84 83
85 beginDealing(); 84 beginDealing();
86 85
87 for (int i = 0; i < 7; i++) 86 for (int i = 0; i < 7; i++)
88 { 87 {
89 cards[t]->setFace(TRUE); 88 cards[t]->setFace(TRUE);
90 for (int k = i; k < 7; k++, t++) 89 for (int k = i; k < 7; k++, t++)
91 { 90 {
92 Card *card = cards[t]; 91 Card *card = cards[t];
93 workingPiles[k]->addCardToTop(card); 92 workingPiles[k]->addCardToTop(card);
94 card->setCardPile( workingPiles[k] ); 93 card->setCardPile( workingPiles[k] );
95 QPoint p = workingPiles[k]->getCardPos( card ); 94 QPoint p = workingPiles[k]->getCardPos( card );
96 card->setPos( p.x(), p.y(), highestZ ); 95 card->setPos( p.x(), p.y(), highestZ );
97 card->showCard(); 96 card->showCard();
98 highestZ++; 97 highestZ++;
99 } 98 }
100 } 99 }
101 100
102 for ( ; t < 52; t++) 101 for ( ; t < 52; t++)
103 { 102 {
104 Card *card = cards[t]; 103 Card *card = cards[t];
105 faceDownDealingPile->addCardToTop(card); 104 faceDownDealingPile->addCardToTop(card);
106 card->setCardPile( faceDownDealingPile ); 105 card->setCardPile( faceDownDealingPile );
107 QPoint p = faceDownDealingPile->getCardPos( card ); 106 QPoint p = faceDownDealingPile->getCardPos( card );
108 card->setPos( p.x(), p.y(), highestZ ); 107 card->setPos( p.x(), p.y(), highestZ );
109 card->showCard(); 108 card->showCard();
110 highestZ++; 109 highestZ++;
111 } 110 }
112 111
113 endDealing(); 112 endDealing();
114} 113}
115 114
116 115
diff --git a/noncore/games/solitaire/teeclubcardgame.cpp b/noncore/games/solitaire/teeclubcardgame.cpp
index 0941e0d..b1af757 100644
--- a/noncore/games/solitaire/teeclubcardgame.cpp
+++ b/noncore/games/solitaire/teeclubcardgame.cpp
@@ -1,127 +1,126 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19** 19**
20** created on base of patiencecardgame by cam (C.A.Mader) 2002 20** created on base of patiencecardgame by cam (C.A.Mader) 2002
21** Rules for this game: 21** Rules for this game:
22** use 2 decks = 104 cards 22** use 2 decks = 104 cards
23** deal 9 rows with 5 open cards each 23** deal 9 rows with 5 open cards each
24** append one card to each other card which is one step higher 24** append one card to each other card which is one step higher
25** move only columns of cards which are equal in suit 25** move only columns of cards which are equal in suit
26** each card can be layed on a free place 26** each card can be layed on a free place
27** deal 1 card at once on the first pile 27** deal 1 card at once on the first pile
28** 28**
29** 29**
30**********************************************************************/ 30**********************************************************************/
31#include <qgfx_qws.h>
32#include "teeclubcardgame.h" 31#include "teeclubcardgame.h"
33 32
34 33
35extern int highestZ; 34extern int highestZ;
36 35
37 36
38 TeeclubCardGame::TeeclubCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent, 2)// Use 2 Decks 37 TeeclubCardGame::TeeclubCardGame(QCanvas *c, bool snap, QWidget *parent) : CanvasCardGame(*c, snap, parent, 2)// Use 2 Decks
39{ 38{
40 highestZ = 0; 39 highestZ = 0;
41 40
42 for (int i = 0; i < 8; i++) { 41 for (int i = 0; i < 8; i++) {
43 discardPiles[i] = new TeeclubDiscardPile( 27 + i * 26, 10, canvas() ); 42 discardPiles[i] = new TeeclubDiscardPile( 27 + i * 26, 10, canvas() );
44 addCardPile(discardPiles[i]); 43 addCardPile(discardPiles[i]);
45 } 44 }
46 for (int i = 0; i < 9; i++) { 45 for (int i = 0; i < 9; i++) {
47 workingPiles[i] = new TeeclubWorkingPile( 2 + i * 26, 50, canvas() ); 46 workingPiles[i] = new TeeclubWorkingPile( 2 + i * 26, 50, canvas() );
48 addCardPile(workingPiles[i]); 47 addCardPile(workingPiles[i]);
49 } 48 }
50 faceDownDealingPile = new TeeclubFaceDownDeck( 2, 10, canvas() ); 49 faceDownDealingPile = new TeeclubFaceDownDeck( 2, 10, canvas() );
51} 50}
52 51
53 52
54void TeeclubCardGame::deal(void) 53void TeeclubCardGame::deal(void)
55{ 54{
56 highestZ = 1; 55 highestZ = 1;
57 int t = 0; 56 int t = 0;
58 57
59 beginDealing(); 58 beginDealing();
60 59
61 for (int i = 0; i < 9; i++) { 60 for (int i = 0; i < 9; i++) {
62 workingPiles[i]->setOffsetDown(13); 61 workingPiles[i]->setOffsetDown(13);
63 workingPiles[i]->beginPileResize(); 62 workingPiles[i]->beginPileResize();
64 for (int k = 0; k < 5; k++, t++) { 63 for (int k = 0; k < 5; k++, t++) {
65 Card *card = cards[t]; 64 Card *card = cards[t];
66 workingPiles[i]->addCardToTop(card); 65 workingPiles[i]->addCardToTop(card);
67 card->setCardPile( workingPiles[i] ); 66 card->setCardPile( workingPiles[i] );
68 card->setPos( 0, 0, highestZ ); 67 card->setPos( 0, 0, highestZ );
69 card->setFace(TRUE); 68 card->setFace(TRUE);
70 card->move( workingPiles[i]->getCardPos( card ) ); 69 card->move( workingPiles[i]->getCardPos( card ) );
71 card->showCard(); 70 card->showCard();
72 highestZ++; 71 highestZ++;
73 } 72 }
74 } 73 }
75 74
76 for ( ; t < getNumberOfCards(); t++) { 75 for ( ; t < getNumberOfCards(); t++) {
77 Card *card = cards[t]; 76 Card *card = cards[t];
78 faceDownDealingPile->addCardToTop(card); 77 faceDownDealingPile->addCardToTop(card);
79 card->setCardPile( faceDownDealingPile ); 78 card->setCardPile( faceDownDealingPile );
80 QPoint p = faceDownDealingPile->getCardPos( card ); 79 QPoint p = faceDownDealingPile->getCardPos( card );
81 card->setPos( p.x(), p.y(), highestZ ); 80 card->setPos( p.x(), p.y(), highestZ );
82 card->showCard(); 81 card->showCard();
83 highestZ++; 82 highestZ++;
84 } 83 }
85 84
86 endDealing(); 85 endDealing();
87} 86}
88 87
89 88
90void TeeclubCardGame::resizePiles() 89void TeeclubCardGame::resizePiles()
91{ 90{
92 beginDealing(); 91 beginDealing();
93 for (int i = 0; i < 9; i++) { 92 for (int i = 0; i < 9; i++) {
94 while ((workingPiles[i]->getCardPos(NULL).y() > 230) && (workingPiles[i]->getOffsetDown()>1)) { 93 while ((workingPiles[i]->getCardPos(NULL).y() > 230) && (workingPiles[i]->getOffsetDown()>1)) {
95 // resize the pile 94 // resize the pile
96 workingPiles[i]->setOffsetDown(workingPiles[i]->getOffsetDown()-1); 95 workingPiles[i]->setOffsetDown(workingPiles[i]->getOffsetDown()-1);
97 Card *card = workingPiles[i]->cardOnBottom(); 96 Card *card = workingPiles[i]->cardOnBottom();
98 int p=0; 97 int p=0;
99 while (card != NULL) { 98 while (card != NULL) {
100 card->setPos( 0, 0, p++ ); 99 card->setPos( 0, 0, p++ );
101 card->move( workingPiles[i]->getCardPos( card ) ); 100 card->move( workingPiles[i]->getCardPos( card ) );
102 card = workingPiles[i]->cardInfront(card); 101 card = workingPiles[i]->cardInfront(card);
103 } 102 }
104 } 103 }
105 } 104 }
106 endDealing(); 105 endDealing();
107} 106}
108 107
109 108
110void TeeclubCardGame::readConfig( Config& cfg ) 109void TeeclubCardGame::readConfig( Config& cfg )
111{ 110{
112 cfg.setGroup("GameState"); 111 cfg.setGroup("GameState");
113 112
114 // Create Cards, but don't shuffle or deal them yet 113 // Create Cards, but don't shuffle or deal them yet
115 createDeck(); 114 createDeck();
116 115
117 // Move the cards to their piles (deal them to their previous places) 116 // Move the cards to their piles (deal them to their previous places)
118 beginDealing(); 117 beginDealing();
119 118
120 highestZ = 1; 119 highestZ = 1;
121 120
122 for (int i = 0; i < 8; i++) { 121 for (int i = 0; i < 8; i++) {
123 QString pile; 122 QString pile;
124 pile.sprintf( "TeeclubDiscardPile%i", i ); 123 pile.sprintf( "TeeclubDiscardPile%i", i );
125 readPile( cfg, discardPiles[i], pile, highestZ ); 124 readPile( cfg, discardPiles[i], pile, highestZ );
126 } 125 }
127 126
diff --git a/noncore/games/tetrix/main.cpp b/noncore/games/tetrix/main.cpp
index fcf4b33..bf1242f 100644
--- a/noncore/games/tetrix/main.cpp
+++ b/noncore/games/tetrix/main.cpp
@@ -1,28 +1,27 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "qtetrix.h" 21#include "qtetrix.h"
22 22
23#include <qpe/qpeapplication.h>
24 23
25#include <opie/oapplicationfactory.h> 24#include <opie/oapplicationfactory.h>
26 25
27OPIE_EXPORT_APP( OApplicationFactory<QTetrix> ) 26OPIE_EXPORT_APP( OApplicationFactory<QTetrix> )
28 27
diff --git a/noncore/games/tetrix/ohighscoredlg.cpp b/noncore/games/tetrix/ohighscoredlg.cpp
index 7581f51..8d8079e 100644
--- a/noncore/games/tetrix/ohighscoredlg.cpp
+++ b/noncore/games/tetrix/ohighscoredlg.cpp
@@ -1,116 +1,115 @@
1/*************************************************************************** 1/***************************************************************************
2 begin : January 2003 2 begin : January 2003
3 copyright : ( C ) 2003 by Carsten Niehaus 3 copyright : ( C ) 2003 by Carsten Niehaus
4 email : cniehaus@handhelds.org 4 email : cniehaus@handhelds.org
5 **************************************************************************/ 5 **************************************************************************/
6 6
7/*************************************************************************** 7/***************************************************************************
8 * * 8 * *
9 * This program is free software; you can redistribute it and/or modify * 9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by * 10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or * 11 * the Free Software Foundation; either version 2 of the License, or *
12 * ( at your option ) any later version. * 12 * ( at your option ) any later version. *
13 * * 13 * *
14 **************************************************************************/ 14 **************************************************************************/
15 15
16#include <qdialog.h> 16#include <qdialog.h>
17#include <qpe/config.h>
18#include <qlayout.h> 17#include <qlayout.h>
19#include <qpe/config.h>
20#include <qpe/qpeapplication.h> 18#include <qpe/qpeapplication.h>
19#include <qpe/config.h>
21 20
22#include <qstring.h> 21#include <qstring.h>
23#include <qhbox.h> 22#include <qhbox.h>
24#include <qvbox.h> 23#include <qvbox.h>
25#include <qlabel.h> 24#include <qlabel.h>
26#include <qlistview.h> 25#include <qlistview.h>
27#include <qlineedit.h> 26#include <qlineedit.h>
28 27
29#include "ohighscoredlg.h" 28#include "ohighscoredlg.h"
30 29
31OHighscore::OHighscore( int score , int playerLevel ) 30OHighscore::OHighscore( int score , int playerLevel )
32{ 31{
33 pLevel = playerLevel; 32 pLevel = playerLevel;
34 getList(); 33 getList();
35 checkIfItIsANewhighscore( score ); 34 checkIfItIsANewhighscore( score );
36} 35}
37 36
38OHighscore::~OHighscore() 37OHighscore::~OHighscore()
39{ 38{
40 std::list<t_playerData*>::iterator deleteIterator = playerData.begin(); 39 std::list<t_playerData*>::iterator deleteIterator = playerData.begin();
41 for ( ; deleteIterator != playerData.end() ; deleteIterator++ ) 40 for ( ; deleteIterator != playerData.end() ; deleteIterator++ )
42 { 41 {
43 delete ( *deleteIterator ); 42 delete ( *deleteIterator );
44 } 43 }
45} 44}
46 45
47void OHighscore::getList() 46void OHighscore::getList()
48{ 47{
49 Config cfg ( "tetrix" ); 48 Config cfg ( "tetrix" );
50 cfg.setGroup( QString::number( 1 ) ); 49 cfg.setGroup( QString::number( 1 ) );
51 lowest = cfg.readNumEntry( "Points" ); 50 lowest = cfg.readNumEntry( "Points" );
52 playerData.clear(); 51 playerData.clear();
53 52
54 int rest = 1;//for the filling up later 53 int rest = 1;//for the filling up later
55 54
56 for ( int i = 1 ; i < 11 ; i++ ) 55 for ( int i = 1 ; i < 11 ; i++ )
57 { 56 {
58 if ( cfg.hasGroup( QString::number( i ) ) ) 57 if ( cfg.hasGroup( QString::number( i ) ) )
59 { 58 {
60 cfg.setGroup( QString::number( i ) ); 59 cfg.setGroup( QString::number( i ) );
61 int temp = cfg.readNumEntry( "Points" ); 60 int temp = cfg.readNumEntry( "Points" );
62 61
63 t_playerData *pPlayerData = new t_playerData; 62 t_playerData *pPlayerData = new t_playerData;
64 pPlayerData->sName = cfg.readEntry( "Name" ); 63 pPlayerData->sName = cfg.readEntry( "Name" );
65 pPlayerData->points = temp; 64 pPlayerData->points = temp;
66 pPlayerData->level = cfg.readNumEntry( "Level" ); 65 pPlayerData->level = cfg.readNumEntry( "Level" );
67 66
68 playerData.push_back( pPlayerData ); 67 playerData.push_back( pPlayerData );
69 68
70 if ( (temp < lowest) ) lowest = temp; 69 if ( (temp < lowest) ) lowest = temp;
71 rest++; 70 rest++;
72 } 71 }
73 } 72 }
74 73
75 //now I fill up the rest of the list 74 //now I fill up the rest of the list
76 if ( rest < 11 ) //only go in this loop if there are less than 75 if ( rest < 11 ) //only go in this loop if there are less than
77 //10 highscoreentries 76 //10 highscoreentries
78 { 77 {
79 lowest = 0; 78 lowest = 0;
80 for ( ; rest < 11 ; rest++ ) 79 for ( ; rest < 11 ; rest++ )
81 { 80 {
82 t_playerData *pPlayerData = new t_playerData; 81 t_playerData *pPlayerData = new t_playerData;
83 pPlayerData->sName = tr( "empty"); 82 pPlayerData->sName = tr( "empty");
84 pPlayerData->points = 0; 83 pPlayerData->points = 0;
85 pPlayerData->level = 0; 84 pPlayerData->level = 0;
86 85
87 playerData.push_back( pPlayerData ); 86 playerData.push_back( pPlayerData );
88 } 87 }
89 } 88 }
90 89
91} 90}
92 91
93void OHighscore::checkIfItIsANewhighscore( int points) 92void OHighscore::checkIfItIsANewhighscore( int points)
94{ 93{
95 if ( points > lowest ) 94 if ( points > lowest )
96 isNewhighscore = true; 95 isNewhighscore = true;
97 else 96 else
98 isNewhighscore = false; 97 isNewhighscore = false;
99} 98}
100 99
101void OHighscore::insertData( QString name , int punkte , int playerLevel ) 100void OHighscore::insertData( QString name , int punkte , int playerLevel )
102{ 101{
103 Config cfg ( "tetrix" ); 102 Config cfg ( "tetrix" );
104 int entryNumber = 1; 103 int entryNumber = 1;
105 std::list<t_playerData*>::iterator insertIterator = playerData.begin(); 104 std::list<t_playerData*>::iterator insertIterator = playerData.begin();
106 while ( insertIterator != playerData.end() ) 105 while ( insertIterator != playerData.end() )
107 { 106 {
108 if ( punkte > ( *insertIterator )->points ) 107 if ( punkte > ( *insertIterator )->points )
109 { 108 {
110 t_playerData* temp = new t_playerData; 109 t_playerData* temp = new t_playerData;
111 temp->sName = name; 110 temp->sName = name;
112 temp->points = punkte; 111 temp->points = punkte;
113 temp->level = playerLevel; 112 temp->level = playerLevel;
114 playerData.insert( insertIterator , temp ); 113 playerData.insert( insertIterator , temp );
115 114
116 //now we have to delete the last entry 115 //now we have to delete the last entry
diff --git a/noncore/games/tetrix/qtetrix.cpp b/noncore/games/tetrix/qtetrix.cpp
index 6d29c3f..20cf1a7 100644
--- a/noncore/games/tetrix/qtetrix.cpp
+++ b/noncore/games/tetrix/qtetrix.cpp
@@ -1,127 +1,124 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21 21
22#include "qtetrix.h" 22#include "qtetrix.h"
23 23
24#include <qpe/resource.h> 24#include <qpe/resource.h>
25#include <qpe/config.h>
26 25
27#include <qapplication.h>
28#include <qlabel.h> 26#include <qlabel.h>
29#include <qdatetime.h> 27#include <qdatetime.h>
30#include <qlayout.h> 28#include <qlayout.h>
31#include <qstring.h>
32 29
33#include "ohighscoredlg.h" 30#include "ohighscoredlg.h"
34 31
35 32
36void drawTetrixButton( QPainter *p, int x, int y, int w, int h, 33void drawTetrixButton( QPainter *p, int x, int y, int w, int h,
37 const QColor *color ) 34 const QColor *color )
38{ 35{
39 QColor fc; 36 QColor fc;
40 if ( color ) { 37 if ( color ) {
41 QPointArray a; 38 QPointArray a;
42 a.setPoints( 3, x,y+h-1, x,y, x+w-1,y ); 39 a.setPoints( 3, x,y+h-1, x,y, x+w-1,y );
43 p->setPen( color->light() ); 40 p->setPen( color->light() );
44 p->drawPolyline( a ); 41 p->drawPolyline( a );
45 a.setPoints( 3, x+1,y+h-1, x+w-1,y+h-1, x+w-1,y+1 ); 42 a.setPoints( 3, x+1,y+h-1, x+w-1,y+h-1, x+w-1,y+1 );
46 p->setPen( color->dark() ); 43 p->setPen( color->dark() );
47 p->drawPolyline( a ); 44 p->drawPolyline( a );
48 x++; 45 x++;
49 y++; 46 y++;
50 w -= 2; 47 w -= 2;
51 h -= 2; 48 h -= 2;
52 fc = *color; 49 fc = *color;
53 } 50 }
54 else 51 else
55 fc = p->backgroundColor(); 52 fc = p->backgroundColor();
56 p->fillRect( x, y, w, h, fc ); 53 p->fillRect( x, y, w, h, fc );
57} 54}
58 55
59 56
60ShowNextPiece::ShowNextPiece( QWidget *parent, const char *name ) 57ShowNextPiece::ShowNextPiece( QWidget *parent, const char *name )
61 : QFrame( parent, name ) 58 : QFrame( parent, name )
62{ 59{
63 setFrameStyle( QFrame::Panel | QFrame::Sunken ); 60 setFrameStyle( QFrame::Panel | QFrame::Sunken );
64 xOffset = -1; // -1 until first resizeEvent. 61 xOffset = -1; // -1 until first resizeEvent.
65} 62}
66 63
67void ShowNextPiece::resizeEvent( QResizeEvent *e ) 64void ShowNextPiece::resizeEvent( QResizeEvent *e )
68{ 65{
69 QSize sz = e->size(); 66 QSize sz = e->size();
70 blockWidth = (sz.width() - 3)/5; 67 blockWidth = (sz.width() - 3)/5;
71 blockHeight = (sz.height() - 3)/6; 68 blockHeight = (sz.height() - 3)/6;
72 xOffset = (sz.width() - 3)/5; 69 xOffset = (sz.width() - 3)/5;
73 yOffset = (sz.height() - 3)/6; 70 yOffset = (sz.height() - 3)/6;
74} 71}
75 72
76 73
77void ShowNextPiece::paintEvent( QPaintEvent * ) 74void ShowNextPiece::paintEvent( QPaintEvent * )
78{ 75{
79 QPainter p( this ); 76 QPainter p( this );
80 drawFrame( &p ); 77 drawFrame( &p );
81 p.end(); // explicit end() so any slots can paint too 78 p.end(); // explicit end() so any slots can paint too
82 emit update(); 79 emit update();
83} 80}
84 81
85 82
86void ShowNextPiece::drawNextSquare(int x, int y,QColor *color) 83void ShowNextPiece::drawNextSquare(int x, int y,QColor *color)
87{ 84{
88 if (xOffset == -1) // Before first resizeEvent? 85 if (xOffset == -1) // Before first resizeEvent?
89 return; 86 return;
90 87
91 QPainter paint; 88 QPainter paint;
92 paint.begin(this); 89 paint.begin(this);
93 drawTetrixButton( &paint, xOffset+x*blockWidth, yOffset+y*blockHeight, 90 drawTetrixButton( &paint, xOffset+x*blockWidth, yOffset+y*blockHeight,
94 blockWidth, blockHeight, color ); 91 blockWidth, blockHeight, color );
95 paint.end(); 92 paint.end();
96} 93}
97 94
98 95
99QTetrix::QTetrix( QWidget *parent, const char *name, WFlags f ) 96QTetrix::QTetrix( QWidget *parent, const char *name, WFlags f )
100 : QMainWindow( parent, name, f ) 97 : QMainWindow( parent, name, f )
101{ 98{
102 setIcon( Resource::loadPixmap( "tetrix_icon" ) ); 99 setIcon( Resource::loadPixmap( "tetrix_icon" ) );
103 setCaption( tr("Tetrix" ) ); 100 setCaption( tr("Tetrix" ) );
104 101
105 QTime t = QTime::currentTime(); 102 QTime t = QTime::currentTime();
106 TetrixPiece::setRandomSeed( (((double)t.hour())+t.minute()+t.second())/ 103 TetrixPiece::setRandomSeed( (((double)t.hour())+t.minute()+t.second())/
107 (24+60+60) ); 104 (24+60+60) );
108 105
109 QWidget *gameArea = new QWidget( this ); 106 QWidget *gameArea = new QWidget( this );
110 setCentralWidget( gameArea ); 107 setCentralWidget( gameArea );
111 108
112 QGridLayout *gl = new QGridLayout( gameArea, 5, 3, 8 ); 109 QGridLayout *gl = new QGridLayout( gameArea, 5, 3, 8 );
113 110
114 QLabel *l; 111 QLabel *l;
115 l = new QLabel( tr("Next"), gameArea ); 112 l = new QLabel( tr("Next"), gameArea );
116 gl->addWidget( l, 0, 0 ); 113 gl->addWidget( l, 0, 0 );
117 showNext = new ShowNextPiece(gameArea); 114 showNext = new ShowNextPiece(gameArea);
118 showNext->setBackgroundColor(QColor(0,0,0)); 115 showNext->setBackgroundColor(QColor(0,0,0));
119 gl->addWidget( showNext, 0, 1 ); 116 gl->addWidget( showNext, 0, 1 );
120 117
121 l = new QLabel( tr("Score"), gameArea ); 118 l = new QLabel( tr("Score"), gameArea );
122 gl->addWidget( l, 1, 0 ); 119 gl->addWidget( l, 1, 0 );
123 showScore = new QLabel(gameArea); 120 showScore = new QLabel(gameArea);
124 gl->addWidget( showScore, 1, 1 ); 121 gl->addWidget( showScore, 1, 1 );
125 l = new QLabel( tr("Level"), gameArea ); 122 l = new QLabel( tr("Level"), gameArea );
126 gl->addWidget( l, 2, 0 ); 123 gl->addWidget( l, 2, 0 );
127 showLevel = new QLabel(gameArea); 124 showLevel = new QLabel(gameArea);
diff --git a/noncore/games/tetrix/qtetrixb.cpp b/noncore/games/tetrix/qtetrixb.cpp
index 521f171..3c179df 100644
--- a/noncore/games/tetrix/qtetrixb.cpp
+++ b/noncore/games/tetrix/qtetrixb.cpp
@@ -1,122 +1,120 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21 21
22#include "qtetrixb.h" 22#include "qtetrixb.h"
23#include "qtetrix.h" 23#include "qtetrix.h"
24#include <qtimer.h> 24#include <qtimer.h>
25#include <qkeycode.h>
26#include <qpainter.h>
27 25
28const int waitAfterLineTime = 500; 26const int waitAfterLineTime = 500;
29 27
30QTetrixBoard::QTetrixBoard( QWidget *p, const char *name ) 28QTetrixBoard::QTetrixBoard( QWidget *p, const char *name )
31 : QFrame( p, name ) 29 : QFrame( p, name )
32{ 30{
33 setFrameStyle( QFrame::Panel | QFrame::Sunken ); 31 setFrameStyle( QFrame::Panel | QFrame::Sunken );
34 paint = 0; 32 paint = 0;
35 timer = new QTimer(this); 33 timer = new QTimer(this);
36 connect( timer, SIGNAL(timeout()), SLOT(timeout()) ); 34 connect( timer, SIGNAL(timeout()), SLOT(timeout()) );
37 35
38 colors[0].setRgb(200,100,100); 36 colors[0].setRgb(200,100,100);
39 colors[1].setRgb(100,200,100); 37 colors[1].setRgb(100,200,100);
40 colors[2].setRgb(100,100,200); 38 colors[2].setRgb(100,100,200);
41 colors[3].setRgb(200,200,100); 39 colors[3].setRgb(200,200,100);
42 colors[4].setRgb(200,100,200); 40 colors[4].setRgb(200,100,200);
43 colors[5].setRgb(100,200,200); 41 colors[5].setRgb(100,200,200);
44 colors[6].setRgb(218,170, 0); 42 colors[6].setRgb(218,170, 0);
45 43
46 xOffset = -1; // -1 until a resizeEvent is received. 44 xOffset = -1; // -1 until a resizeEvent is received.
47 blockWidth = 20; 45 blockWidth = 20;
48 yOffset = 30; 46 yOffset = 30;
49 blockHeight = 20; 47 blockHeight = 20;
50 noGame = TRUE; 48 noGame = TRUE;
51 isPaused = FALSE; 49 isPaused = FALSE;
52 waitingAfterLine = FALSE; 50 waitingAfterLine = FALSE;
53 updateTimeoutTime(); // Sets timeoutTime 51 updateTimeoutTime(); // Sets timeoutTime
54} 52}
55 53
56void QTetrixBoard::startGame(int gameType,int fillRandomLines) 54void QTetrixBoard::startGame(int gameType,int fillRandomLines)
57{ 55{
58 if ( isPaused ) 56 if ( isPaused )
59 return; // ignore if game is paused 57 return; // ignore if game is paused
60 noGame = FALSE; 58 noGame = FALSE;
61 GenericTetrix::startGame( gameType, fillRandomLines ); 59 GenericTetrix::startGame( gameType, fillRandomLines );
62 // Note that the timer is started by updateLevel! 60 // Note that the timer is started by updateLevel!
63} 61}
64 62
65 63
66void QTetrixBoard::pause() 64void QTetrixBoard::pause()
67{ 65{
68 if ( noGame ) // game not active 66 if ( noGame ) // game not active
69 return; 67 return;
70 isPaused = !isPaused; 68 isPaused = !isPaused;
71 if ( isPaused ) { 69 if ( isPaused ) {
72 timer->stop(); 70 timer->stop();
73 hideBoard(); 71 hideBoard();
74 } 72 }
75 else 73 else
76 timer->start(timeoutTime); 74 timer->start(timeoutTime);
77 update(); 75 update();
78} 76}
79 77
80 78
81void QTetrixBoard::drawSquare(int x,int y,int value) 79void QTetrixBoard::drawSquare(int x,int y,int value)
82{ 80{
83 if (xOffset == -1) // Before first resizeEvent? 81 if (xOffset == -1) // Before first resizeEvent?
84 return; 82 return;
85 83
86 const int X = xOffset + x*blockWidth; 84 const int X = xOffset + x*blockWidth;
87 const int Y = yOffset + (y - 1)*blockHeight; 85 const int Y = yOffset + (y - 1)*blockHeight;
88 86
89 bool localPainter = paint == 0; 87 bool localPainter = paint == 0;
90 QPainter *p; 88 QPainter *p;
91 if ( localPainter ) 89 if ( localPainter )
92 p = new QPainter( this ); 90 p = new QPainter( this );
93 else 91 else
94 p = paint; 92 p = paint;
95 drawTetrixButton( p, X, Y, blockWidth, blockHeight, 93 drawTetrixButton( p, X, Y, blockWidth, blockHeight,
96 value == 0 ? 0 : &colors[value-1] ); 94 value == 0 ? 0 : &colors[value-1] );
97 /* 95 /*
98 if ( value != 0 ) { 96 if ( value != 0 ) {
99 QColor tc, bc; 97 QColor tc, bc;
100 tc = colors[value-1].light(); 98 tc = colors[value-1].light();
101 bc = colors[value-1].dark(); 99 bc = colors[value-1].dark();
102 p->drawShadePanel( X, Y, blockWidth, blockHeight, 100 p->drawShadePanel( X, Y, blockWidth, blockHeight,
103 tc, bc, 1, colors[value-1], TRUE ); 101 tc, bc, 1, colors[value-1], TRUE );
104 } 102 }
105 else 103 else
106 p->fillRect( X, Y, blockWidth, blockHeight, backgroundColor() ); 104 p->fillRect( X, Y, blockWidth, blockHeight, backgroundColor() );
107 */ 105 */
108 if ( localPainter ) 106 if ( localPainter )
109 delete p; 107 delete p;
110} 108}
111 109
112void QTetrixBoard::drawNextSquare( int x, int y, int value ) 110void QTetrixBoard::drawNextSquare( int x, int y, int value )
113{ 111{
114 if ( value == 0 ) 112 if ( value == 0 )
115 emit drawNextSquareSignal (x, y, 0 ); 113 emit drawNextSquareSignal (x, y, 0 );
116 else 114 else
117 emit drawNextSquareSignal( x, y, &colors[value-1] ); 115 emit drawNextSquareSignal( x, y, &colors[value-1] );
118} 116}
119 117
120void QTetrixBoard::updateRemoved( int noOfLines ) 118void QTetrixBoard::updateRemoved( int noOfLines )
121{ 119{
122 if ( noOfLines > 0 ) { 120 if ( noOfLines > 0 ) {
diff --git a/noncore/games/tictac/main.cpp b/noncore/games/tictac/main.cpp
index cfff683..9aafe4c 100644
--- a/noncore/games/tictac/main.cpp
+++ b/noncore/games/tictac/main.cpp
@@ -1,13 +1,12 @@
1/**************************************************************************** 1/****************************************************************************
2** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 2** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of an example program for Qt. This example 4** This file is part of an example program for Qt. This example
5** program may be used, distributed and modified without limitation. 5** program may be used, distributed and modified without limitation.
6** 6**
7*****************************************************************************/ 7*****************************************************************************/
8 8
9#include <qpe/qpeapplication.h>
10#include <opie/oapplicationfactory.h> 9#include <opie/oapplicationfactory.h>
11#include "tictac.h" 10#include "tictac.h"
12 11
13OPIE_EXPORT_APP( OApplicationFactory<TicTacToe> ) 12OPIE_EXPORT_APP( OApplicationFactory<TicTacToe> )
diff --git a/noncore/games/tictac/tictac.cpp b/noncore/games/tictac/tictac.cpp
index 9de3b58..12ce35f 100644
--- a/noncore/games/tictac/tictac.cpp
+++ b/noncore/games/tictac/tictac.cpp
@@ -1,117 +1,113 @@
1/**************************************************************************** 1/****************************************************************************
2 ** tictac.cpp,v 1.3.8.1 2003/08/29 06:50:40 harlekin Exp 2 ** tictac.cpp,v 1.3.8.1 2003/08/29 06:50:40 harlekin Exp
3 ** 3 **
4 ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 4 ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
5 ** 5 **
6 ** This file is part of an example program for Qt. This example 6 ** This file is part of an example program for Qt. This example
7 ** program may be used, distributed and modified without limitation. 7 ** program may be used, distributed and modified without limitation.
8 ** 8 **
9 *****************************************************************************/ 9 *****************************************************************************/
10 10
11#include "tictac.h" 11#include "tictac.h"
12#include <qpe/qpeapplication.h> 12#include <qpe/qpeapplication.h>
13#include <qpainter.h>
14#include <qdrawutil.h> 13#include <qdrawutil.h>
15#include <qcombobox.h> 14#include <qcombobox.h>
16#include <qcheckbox.h>
17#include <qlabel.h> 15#include <qlabel.h>
18#include <qlayout.h> 16#include <qlayout.h>
19#include <stdlib.h> // rand() function 17#include <stdlib.h> // rand() function
20#include <qdatetime.h> // seed for rand()
21#include <qstringlist.h> //needed for proper internationalization
22 18
23 19
24//*************************************************************************** 20//***************************************************************************
25//* TicTacButton member functions 21//* TicTacButton member functions
26//*************************************************************************** 22//***************************************************************************
27 23
28// -------------------------------------------------------------------------- 24// --------------------------------------------------------------------------
29// Creates a TicTacButton 25// Creates a TicTacButton
30// 26//
31 27
32TicTacButton::TicTacButton( QWidget *parent ) : QPushButton( parent ) 28TicTacButton::TicTacButton( QWidget *parent ) : QPushButton( parent )
33{ 29{
34 t = Blank; // initial type 30 t = Blank; // initial type
35} 31}
36 32
37// -------------------------------------------------------------------------- 33// --------------------------------------------------------------------------
38// Paints TicTacButton 34// Paints TicTacButton
39// 35//
40 36
41void TicTacButton::drawButtonLabel( QPainter *p ) 37void TicTacButton::drawButtonLabel( QPainter *p )
42{ 38{
43 QRect r = rect(); 39 QRect r = rect();
44 p->setPen( QPen( white,2 ) ); // set fat pen 40 p->setPen( QPen( white,2 ) ); // set fat pen
45 if ( t == Circle ) { 41 if ( t == Circle ) {
46 p->drawEllipse( r.left()+4, r.top()+4, r.width()-8, r.height()-8 ); 42 p->drawEllipse( r.left()+4, r.top()+4, r.width()-8, r.height()-8 );
47 } else if ( t == Cross ) { // draw cross 43 } else if ( t == Cross ) { // draw cross
48 p->drawLine( r.topLeft() +QPoint(4,4), r.bottomRight()-QPoint(4,4)); 44 p->drawLine( r.topLeft() +QPoint(4,4), r.bottomRight()-QPoint(4,4));
49 p->drawLine( r.bottomLeft()+QPoint(4,-4),r.topRight() -QPoint(4,-4)); 45 p->drawLine( r.bottomLeft()+QPoint(4,-4),r.topRight() -QPoint(4,-4));
50 } 46 }
51} 47}
52 48
53 49
54//*************************************************************************** 50//***************************************************************************
55//* TicTacGameBoard member functions 51//* TicTacGameBoard member functions
56//*************************************************************************** 52//***************************************************************************
57 53
58// -------------------------------------------------------------------------- 54// --------------------------------------------------------------------------
59// Creates a game board with N x N buttons and connects the "clicked()" 55// Creates a game board with N x N buttons and connects the "clicked()"
60// signal of all buttons to the "buttonClicked()" slot. 56// signal of all buttons to the "buttonClicked()" slot.
61// 57//
62 58
63TicTacGameBoard::TicTacGameBoard( int n, QWidget *parent, const char *name ) 59TicTacGameBoard::TicTacGameBoard( int n, QWidget *parent, const char *name )
64 : QWidget( parent, name ) 60 : QWidget( parent, name )
65{ 61{
66 QPEApplication::showWidget( this ); 62 QPEApplication::showWidget( this );
67 st = Init; // initial state 63 st = Init; // initial state
68 nBoard = n; 64 nBoard = n;
69 n *= n; // make square 65 n *= n; // make square
70 comp_starts = FALSE; // human starts 66 comp_starts = FALSE; // human starts
71 buttons = new TicTacButtons(n); // create real buttons 67 buttons = new TicTacButtons(n); // create real buttons
72 btArray = new TicTacArray(n); // create button model 68 btArray = new TicTacArray(n); // create button model
73 QGridLayout * grid = new QGridLayout( this, 3, 3, 4 ); 69 QGridLayout * grid = new QGridLayout( this, 3, 3, 4 );
74 QPalette p( blue ); 70 QPalette p( blue );
75 for ( int i=0; i<n; i++ ) { // create and connect buttons 71 for ( int i=0; i<n; i++ ) { // create and connect buttons
76 TicTacButton *ttb = new TicTacButton( this ); 72 TicTacButton *ttb = new TicTacButton( this );
77 ttb->setPalette( p ); 73 ttb->setPalette( p );
78 ttb->setEnabled( FALSE ); 74 ttb->setEnabled( FALSE );
79 connect( ttb, SIGNAL(clicked()), SLOT(buttonClicked()) ); 75 connect( ttb, SIGNAL(clicked()), SLOT(buttonClicked()) );
80 grid->addWidget( ttb, i%3, i/3 ); 76 grid->addWidget( ttb, i%3, i/3 );
81 buttons->insert( i, ttb ); 77 buttons->insert( i, ttb );
82 btArray->at(i) = TicTacButton::Blank; // initial button type 78 btArray->at(i) = TicTacButton::Blank; // initial button type
83 } 79 }
84 QTime t = QTime::currentTime(); // set random seed 80 QTime t = QTime::currentTime(); // set random seed
85 srand( t.hour()*12+t.minute()*60+t.second()*60 ); 81 srand( t.hour()*12+t.minute()*60+t.second()*60 );
86} 82}
87 83
88TicTacGameBoard::~TicTacGameBoard() 84TicTacGameBoard::~TicTacGameBoard()
89{ 85{
90 delete buttons; 86 delete buttons;
91 delete btArray; 87 delete btArray;
92} 88}
93 89
94 90
95// -------------------------------------------------------------------------- 91// --------------------------------------------------------------------------
96// TicTacGameBoard::computerStarts( bool v ) 92// TicTacGameBoard::computerStarts( bool v )
97// 93//
98// Computer starts if v=TRUE. The human starts by default. 94// Computer starts if v=TRUE. The human starts by default.
99// 95//
100 96
101void TicTacGameBoard::computerStarts( bool v ) 97void TicTacGameBoard::computerStarts( bool v )
102{ 98{
103 comp_starts = v; 99 comp_starts = v;
104} 100}
105 101
106 102
107// -------------------------------------------------------------------------- 103// --------------------------------------------------------------------------
108// TicTacGameBoard::newGame() 104// TicTacGameBoard::newGame()
109// 105//
110// Clears the game board and prepares for a new game 106// Clears the game board and prepares for a new game
111// 107//
112 108
113void TicTacGameBoard::newGame() 109void TicTacGameBoard::newGame()
114{ 110{
115 st = HumansTurn; 111 st = HumansTurn;
116 for ( int i=0; i<nBoard*nBoard; i++ ) 112 for ( int i=0; i<nBoard*nBoard; i++ )
117 btArray->at(i) = TicTacButton::Blank; 113 btArray->at(i) = TicTacButton::Blank;
diff --git a/noncore/games/wordgame/main.cpp b/noncore/games/wordgame/main.cpp
index f32acff..eb3e2f2 100644
--- a/noncore/games/wordgame/main.cpp
+++ b/noncore/games/wordgame/main.cpp
@@ -1,28 +1,27 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "wordgame.h" 21#include "wordgame.h"
22 22
23#include <qpe/qpeapplication.h>
24#include <opie/oapplicationfactory.h> 23#include <opie/oapplicationfactory.h>
25 24
26 25
27OPIE_EXPORT_APP( OApplicationFactory<WordGame> ) 26OPIE_EXPORT_APP( OApplicationFactory<WordGame> )
28 27
diff --git a/noncore/games/wordgame/wordgame.cpp b/noncore/games/wordgame/wordgame.cpp
index c01551d..43a54f8 100644
--- a/noncore/games/wordgame/wordgame.cpp
+++ b/noncore/games/wordgame/wordgame.cpp
@@ -1,145 +1,136 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21 21
22#include "wordgame.h" 22#include "wordgame.h"
23 23
24#include <qpe/applnk.h>
25#include <qpe/global.h> 24#include <qpe/global.h>
26#include <qpe/filemanager.h>
27#include <qpe/resource.h> 25#include <qpe/resource.h>
28#include <qpe/config.h> 26#include <qpe/config.h>
29 27
30#include <qapplication.h> 28#include <qapplication.h>
31#include <qmessagebox.h> 29#include <qmessagebox.h>
32#include <qcombobox.h> 30#include <qcombobox.h>
33#include <qdatetime.h>
34#include <qfileinfo.h>
35#include <qfile.h>
36#include <qdir.h> 31#include <qdir.h>
37#include <qiconset.h>
38#include <qlabel.h>
39#include <qlineedit.h> 32#include <qlineedit.h>
40#include <qpushbutton.h> 33#include <qpushbutton.h>
41#include <qtextstream.h> 34#include <qtextstream.h>
42#include <qtimer.h> 35#include <qtimer.h>
43#include <qpe/qpetoolbar.h> 36#include <qpe/qpetoolbar.h>
44#include <qtoolbutton.h> 37#include <qtoolbutton.h>
45#include <qvbox.h> 38#include <qvbox.h>
46#include <qwidgetstack.h> 39#include <qwidgetstack.h>
47#include <qpainter.h>
48#include <qlayout.h> 40#include <qlayout.h>
49#include <qregexp.h>
50 41
51#include <stdlib.h> 42#include <stdlib.h>
52#include <unistd.h> 43#include <unistd.h>
53#include <pwd.h> 44#include <pwd.h>
54#include <sys/types.h> 45#include <sys/types.h>
55 46
56enum RuleEffects { 47enum RuleEffects {
57 Multiplier=15, 48 Multiplier=15,
58 MultiplyAll=64, 49 MultiplyAll=64,
59 Start=128 50 Start=128
60}; 51};
61 52
62static int tile_smallw = 16; 53static int tile_smallw = 16;
63static int tile_smallh = 16; 54static int tile_smallh = 16;
64static int tile_bigw = 22; 55static int tile_bigw = 22;
65static int tile_bigh = 22; 56static int tile_bigh = 22;
66static int tile_stweak = -2; 57static int tile_stweak = -2;
67static int tile_btweak = -1; 58static int tile_btweak = -1;
68 59
69static const int rack_tiles=7; 60static const int rack_tiles=7;
70 61
71const char* sampleWGR= 62const char* sampleWGR=
72 "wordgame_shapes\n" 63 "wordgame_shapes\n"
73 "15 15\n" 64 "15 15\n"
74 "400001040100004\n" 65 "400001040100004\n"
75 "030000000000030\n" 66 "030000000000030\n"
76 "002002000200200\n" 67 "002002000200200\n"
77 "000300020003000\n" 68 "000300020003000\n"
78 "000020000020000\n" 69 "000020000020000\n"
79 "102001000100201\n" 70 "102001000100201\n"
80 "000000202000000\n" 71 "000000202000000\n"
81 "400200050002004\n" 72 "400200050002004\n"
82 "000000202000000\n" 73 "000000202000000\n"
83 "102001000100201\n" 74 "102001000100201\n"
84 "000020000020000\n" 75 "000020000020000\n"
85 "000300020003000\n" 76 "000300020003000\n"
86 "002002000200200\n" 77 "002002000200200\n"
87 "030000000000030\n" 78 "030000000000030\n"
88 "400001040100004\n" 79 "400001040100004\n"
89 "1 2 3 66 67 194 100 0\n" 80 "1 2 3 66 67 194 100 0\n"
90 "1 j 8\n" 81 "1 j 8\n"
91 "1 q 7\n" 82 "1 q 7\n"
92 "1 x 6\n" 83 "1 x 6\n"
93 "1 z 6\n" 84 "1 z 6\n"
94 "1 w 4\n" 85 "1 w 4\n"
95 "1 k 4\n" 86 "1 k 4\n"
96 "1 v 3\n" 87 "1 v 3\n"
97 "1 f 3\n" 88 "1 f 3\n"
98 "2 y 3\n" 89 "2 y 3\n"
99 "2 h 2\n" 90 "2 h 2\n"
100 "2 b 2\n" 91 "2 b 2\n"
101 "2 m 2\n" 92 "2 m 2\n"
102 "3 p 2\n" 93 "3 p 2\n"
103 "3 g 2\n" 94 "3 g 2\n"
104 "3 u 2\n" 95 "3 u 2\n"
105 "4 d 2\n" 96 "4 d 2\n"
106 "4 c 2\n" 97 "4 c 2\n"
107 "5 l 1\n" 98 "5 l 1\n"
108 "5 o 1\n" 99 "5 o 1\n"
109 "7 t 1\n" 100 "7 t 1\n"
110 "7 n 1\n" 101 "7 n 1\n"
111 "7 a 1\n" 102 "7 a 1\n"
112 "7 r 1\n" 103 "7 r 1\n"
113 "8 s 1\n" 104 "8 s 1\n"
114 "8 i 1\n" 105 "8 i 1\n"
115 "11 e 1\n" 106 "11 e 1\n"
116 "0\n"; 107 "0\n";
117 108
118WordGame::WordGame( QWidget* parent, const char* name, WFlags fl ) : 109WordGame::WordGame( QWidget* parent, const char* name, WFlags fl ) :
119 QMainWindow(parent, name, fl) 110 QMainWindow(parent, name, fl)
120{ 111{
121 if ( qApp->desktop()->width() < 240 ) { 112 if ( qApp->desktop()->width() < 240 ) {
122 tile_smallw = 10; 113 tile_smallw = 10;
123 tile_smallh = 10; 114 tile_smallh = 10;
124 tile_bigw = 16; 115 tile_bigw = 16;
125 tile_bigh = 16; 116 tile_bigh = 16;
126 tile_stweak = 0; 117 tile_stweak = 0;
127 tile_btweak = 0; 118 tile_btweak = 0;
128 } 119 }
129 120
130 setIcon( Resource::loadPixmap( "wordgame/WordGame.png" ) ); 121 setIcon( Resource::loadPixmap( "wordgame/WordGame.png" ) );
131 setCaption( tr("Word Game") ); 122 setCaption( tr("Word Game") );
132 123
133 setToolBarsMovable( FALSE ); 124 setToolBarsMovable( FALSE );
134 vbox = new QVBox(this); 125 vbox = new QVBox(this);
135 126
136 setCentralWidget(vbox); 127 setCentralWidget(vbox);
137 toolbar = new QToolBar(this); 128 toolbar = new QToolBar(this);
138 addToolBar(toolbar, Bottom); 129 addToolBar(toolbar, Bottom);
139 reset = new QToolButton(Resource::loadPixmap("back"), tr("Back"), "", this, SLOT(resetTurn()), toolbar); 130 reset = new QToolButton(Resource::loadPixmap("back"), tr("Back"), "", this, SLOT(resetTurn()), toolbar);
140 done = new QToolButton(Resource::loadPixmap("done"), tr("Done"), "", this, SLOT(endTurn()), toolbar); 131 done = new QToolButton(Resource::loadPixmap("done"), tr("Done"), "", this, SLOT(endTurn()), toolbar);
141 scoreinfo = new ScoreInfo(toolbar); 132 scoreinfo = new ScoreInfo(toolbar);
142 scoreinfo->setFont(QFont("Helvetica",10)); 133 scoreinfo->setFont(QFont("Helvetica",10));
143 new QToolButton(Resource::loadPixmap("finish"), tr("Close"), "", this, SLOT(endGame()), toolbar); 134 new QToolButton(Resource::loadPixmap("finish"), tr("Close"), "", this, SLOT(endGame()), toolbar);
144 toolbar->setStretchableWidget(scoreinfo); 135 toolbar->setStretchableWidget(scoreinfo);
145 136
diff --git a/noncore/games/zlines/ballpainter.cpp b/noncore/games/zlines/ballpainter.cpp
index c2b34e1..622ec29 100644
--- a/noncore/games/zlines/ballpainter.cpp
+++ b/noncore/games/zlines/ballpainter.cpp
@@ -1,124 +1,121 @@
1/*************************************************************************** 1/***************************************************************************
2 ballpainter.cpp - description 2 ballpainter.cpp - description
3 ------------------- 3 -------------------
4 begin : Fri May 19 2000 4 begin : Fri May 19 2000
5 copyright : (C) 2000 by Roman Merzlyakov 5 copyright : (C) 2000 by Roman Merzlyakov
6 email : roman@sbrf.barrt.ru 6 email : roman@sbrf.barrt.ru
7 copyright : (C) 2000 by Roman Razilov 7 copyright : (C) 2000 by Roman Razilov
8 email : Roman.Razilov@gmx.de 8 email : Roman.Razilov@gmx.de
9 ***************************************************************************/ 9 ***************************************************************************/
10 10
11/*************************************************************************** 11/***************************************************************************
12 * * 12 * *
13 * This program is free software; you can redistribute it and/or modify * 13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by * 14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or * 15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. * 16 * (at your option) any later version. *
17 * * 17 * *
18 ***************************************************************************/ 18 ***************************************************************************/
19 19
20#include <qpe/resource.h> 20#include <qpe/resource.h>
21 21
22#include <qapplication.h>
23#include "ballpainter.h" 22#include "ballpainter.h"
24//#include "shotcounter.h" 23//#include "shotcounter.h"
25#include <qpainter.h> 24#include <qpainter.h>
26#include "linesboard.h"
27//#include <qcolor.h> 25//#include <qcolor.h>
28#include <qjpegio.h>
29 26
30 27
31#define PIXSIZE 21 28#define PIXSIZE 21
32 29
33int colorLinesArr[NCOLORS] = 30int colorLinesArr[NCOLORS] =
34{0x0000ff, 0x00ff00, 0xff0000, 0x00ffff, 0xff00ff, 0xffff00, 0x005080}; 31{0x0000ff, 0x00ff00, 0xff0000, 0x00ffff, 0xff00ff, 0xffff00, 0x005080};
35// 0x00bbggrr 32// 0x00bbggrr
36// red , green , blue , yellow , violet , cyan , brown 33// red , green , blue , yellow , violet , cyan , brown
37 34
38 35
39 36
40BallPainter::BallPainter() 37BallPainter::BallPainter()
41 : QObject() 38 : QObject()
42{ 39{
43 createPixmap(); 40 createPixmap();
44} 41}
45 42
46BallPainter::~BallPainter() 43BallPainter::~BallPainter()
47{ 44{
48} 45}
49 46
50QPixmap* BallPainter::pixmap( enum Pixmaps pix ) 47QPixmap* BallPainter::pixmap( enum Pixmaps pix )
51{ 48{
52 QString name; 49 QString name;
53 switch(pix) { 50 switch(pix) {
54 case Field: 51 case Field:
55 name = QString::fromLatin1("zlines/field"); 52 name = QString::fromLatin1("zlines/field");
56 break; 53 break;
57 case Balls: 54 case Balls:
58 name = QString::fromLatin1("zlines/balls"); 55 name = QString::fromLatin1("zlines/balls");
59 break; 56 break;
60 case Fire: 57 case Fire:
61 name = QString::fromLatin1("zlines/fire"); 58 name = QString::fromLatin1("zlines/fire");
62 break; 59 break;
63 } 60 }
64 61
65 return new QPixmap(Resource::loadPixmap(name) ); 62 return new QPixmap(Resource::loadPixmap(name) );
66} 63}
67 64
68void BallPainter::createPixmap() 65void BallPainter::createPixmap()
69{ 66{
70 // warning( kapp->kde_datadir() +"/klines/data/balls.bmp"); 67 // warning( kapp->kde_datadir() +"/klines/data/balls.bmp");
71 backgroundPix = pixmap(Field); 68 backgroundPix = pixmap(Field);
72 QPixmap *balls = pixmap(Balls); 69 QPixmap *balls = pixmap(Balls);
73 QPixmap *fire = pixmap(Fire); 70 QPixmap *fire = pixmap(Fire);
74 if (balls->isNull() ||backgroundPix->isNull() || fire->isNull() ) 71 if (balls->isNull() ||backgroundPix->isNull() || fire->isNull() )
75 fatal("Cannot open data files.\nHave you correctly installed klines?"); 72 fatal("Cannot open data files.\nHave you correctly installed klines?");
76 73
77 warning("Pixsize %i", PIXSIZE); 74 warning("Pixsize %i", PIXSIZE);
78 for(int c=0; c<NCOLORS; c++) 75 for(int c=0; c<NCOLORS; c++)
79 { 76 {
80 for(int t=0; t<PIXTIME + FIREBALLS + BOOMBALLS + 1 ; t++) 77 for(int t=0; t<PIXTIME + FIREBALLS + BOOMBALLS + 1 ; t++)
81 { 78 {
82 imgCash[c][t] = new QPixmap(CELLSIZE, CELLSIZE); 79 imgCash[c][t] = new QPixmap(CELLSIZE, CELLSIZE);
83 QPainter p(imgCash[c][t]); 80 QPainter p(imgCash[c][t]);
84 p.drawPixmap(0,0,(*backgroundPix),0,0,CELLSIZE,CELLSIZE); 81 p.drawPixmap(0,0,(*backgroundPix),0,0,CELLSIZE,CELLSIZE);
85 p.drawPixmap(1,1,(*balls),t*PIXSIZE,c*PIXSIZE,PIXSIZE,PIXSIZE); 82 p.drawPixmap(1,1,(*balls),t*PIXSIZE,c*PIXSIZE,PIXSIZE,PIXSIZE);
86 } 83 }
87 for(int t=0; t < FIREPIX ; t++) 84 for(int t=0; t < FIREPIX ; t++)
88 { 85 {
89 firePix[t] = new QPixmap(CELLSIZE, CELLSIZE); 86 firePix[t] = new QPixmap(CELLSIZE, CELLSIZE);
90 QPainter p(firePix[t]); 87 QPainter p(firePix[t]);
91 p.drawPixmap(0,0,(*backgroundPix),0,0,CELLSIZE,CELLSIZE); 88 p.drawPixmap(0,0,(*backgroundPix),0,0,CELLSIZE,CELLSIZE);
92 p.drawPixmap(1,1,(*fire),t*PIXSIZE,0,PIXSIZE,PIXSIZE); 89 p.drawPixmap(1,1,(*fire),t*PIXSIZE,0,PIXSIZE,PIXSIZE);
93 } 90 }
94 } 91 }
95 delete balls; 92 delete balls;
96 delete fire; 93 delete fire;
97} 94}
98 95
99 96
100QPixmap* BallPainter::GetBall(int color, int animstep, int panim) 97QPixmap* BallPainter::GetBall(int color, int animstep, int panim)
101{ 98{
102 // return backgroundPix; 99 // return backgroundPix;
103 100
104 if( (color<0) || (color>=NCOLORS) || (animstep<0) || color == NOBALL ) 101 if( (color<0) || (color>=NCOLORS) || (animstep<0) || color == NOBALL )
105 { 102 {
106 // warning("BallPainter::Background"); 103 // warning("BallPainter::Background");
107 return backgroundPix; 104 return backgroundPix;
108 } 105 }
109 if ( panim == ANIM_JUMP ) 106 if ( panim == ANIM_JUMP )
110 { 107 {
111 if ( ( animstep < 0 ) || ( animstep >= PIXTIME ) ) 108 if ( ( animstep < 0 ) || ( animstep >= PIXTIME ) )
112 return backgroundPix; 109 return backgroundPix;
113 else 110 else
114 return imgCash[color][animstep]; 111 return imgCash[color][animstep];
115 } 112 }
116 else if ( panim == ANIM_BURN ) 113 else if ( panim == ANIM_BURN )
117 { 114 {
118 if ( animstep < FIREBALLS ) 115 if ( animstep < FIREBALLS )
119 return imgCash[color][animstep + PIXTIME + BOOMBALLS + 1]; 116 return imgCash[color][animstep + PIXTIME + BOOMBALLS + 1];
120 else if ( animstep < FIREBALLS + FIREPIX ) 117 else if ( animstep < FIREBALLS + FIREPIX )
121 return firePix[animstep - FIREBALLS]; 118 return firePix[animstep - FIREBALLS];
122 } 119 }
123 else if ( panim == ANIM_BORN ) 120 else if ( panim == ANIM_BORN )
124 { 121 {
diff --git a/noncore/games/zlines/field.cpp b/noncore/games/zlines/field.cpp
index 2a87739..0adf4ac 100644
--- a/noncore/games/zlines/field.cpp
+++ b/noncore/games/zlines/field.cpp
@@ -1,116 +1,115 @@
1/*************************************************************************** 1/***************************************************************************
2 field.cpp - description 2 field.cpp - description
3 ------------------- 3 -------------------
4begin : Fri May 19 2000 4begin : Fri May 19 2000
5copyright : (C) 2000 by Roman Merzlyakov 5copyright : (C) 2000 by Roman Merzlyakov
6email : roman@sbrf.barrt.ru 6email : roman@sbrf.barrt.ru
7copyright : (C) 2000 by Roman Razilov 7copyright : (C) 2000 by Roman Razilov
8email : Roman.Razilov@gmx.de 8email : Roman.Razilov@gmx.de
9 ***************************************************************************/ 9 ***************************************************************************/
10 10
11/*************************************************************************** 11/***************************************************************************
12 * * 12 * *
13 * This program is free software; you can redistribute it and/or modify * 13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by * 14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or * 15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. * 16 * (at your option) any later version. *
17 * * 17 * *
18 ***************************************************************************/ 18 ***************************************************************************/
19#include <stdlib.h> 19#include <stdlib.h>
20#include "cfg.h"
21#include "field.h" 20#include "field.h"
22 21
23Field::Field(QWidget* parent, const char* name) 22Field::Field(QWidget* parent, const char* name)
24 : QWidget( parent, name ) 23 : QWidget( parent, name )
25{ 24{
26 clearField(); 25 clearField();
27} 26}
28 27
29Field::~Field() 28Field::~Field()
30{ 29{
31} 30}
32 31
33void Field::clearField() 32void Field::clearField()
34{ 33{
35 for(int y=0; y<NUMCELLSH; y++) 34 for(int y=0; y<NUMCELLSH; y++)
36 for(int x=0; x<NUMCELLSW; x++) 35 for(int x=0; x<NUMCELLSW; x++)
37 field[y][x].clear(); 36 field[y][x].clear();
38} 37}
39void Field::clearAnim() 38void Field::clearAnim()
40{ 39{
41 for(int y=0; y<NUMCELLSH; y++) 40 for(int y=0; y<NUMCELLSH; y++)
42 for(int x=0; x<NUMCELLSW; x++) 41 for(int x=0; x<NUMCELLSW; x++)
43 field[y][x].setAnim( ANIM_NO ); 42 field[y][x].setAnim( ANIM_NO );
44} 43}
45int Field::deleteAnimatedBalls() 44int Field::deleteAnimatedBalls()
46{ 45{
47 int deleted = 0; 46 int deleted = 0;
48 for(int y=0; y<NUMCELLSH; y++) 47 for(int y=0; y<NUMCELLSH; y++)
49 for(int x=0; x<NUMCELLSW; x++) 48 for(int x=0; x<NUMCELLSW; x++)
50 { 49 {
51 if ( field[y][x].getAnim() != ANIM_NO ) 50 if ( field[y][x].getAnim() != ANIM_NO )
52 { 51 {
53 deleted++; 52 deleted++;
54 field[y][x].clear(); 53 field[y][x].clear();
55 } 54 }
56 } 55 }
57 return deleted; 56 return deleted;
58} 57}
59 58
60bool Field::checkBounds(int x, int y) 59bool Field::checkBounds(int x, int y)
61{ 60{
62 return (x>=0) && (x<NUMCELLSW) && (y>=0) && (y<NUMCELLSH); 61 return (x>=0) && (x<NUMCELLSW) && (y>=0) && (y<NUMCELLSH);
63} 62}
64 63
65void Field::putBall(int x, int y, int color) 64void Field::putBall(int x, int y, int color)
66{ 65{
67 if( checkBounds(x,y) ) 66 if( checkBounds(x,y) )
68 field[y][x].setColor(color); 67 field[y][x].setColor(color);
69} 68}
70/* 69/*
71 void Field::putBall(int x, int y, char color) 70 void Field::putBall(int x, int y, char color)
72 { 71 {
73 if( checkBounds(x,y) ){ 72 if( checkBounds(x,y) ){
74 field[y][x].setColor(color); 73 field[y][x].setColor(color);
75 erase5Balls(); 74 erase5Balls();
76 repaint(FALSE); 75 repaint(FALSE);
77 } 76 }
78 }*/ 77 }*/
79void Field::moveBall(int xa, int ya, int xb, int yb) 78void Field::moveBall(int xa, int ya, int xb, int yb)
80{ 79{
81 if( checkBounds(xa,ya) && checkBounds(xb,yb) && 80 if( checkBounds(xa,ya) && checkBounds(xb,yb) &&
82 field[yb][xb].isFree() && ( xa != xb || ya != yb) ) { 81 field[yb][xb].isFree() && ( xa != xb || ya != yb) ) {
83 field[yb][xb].moveBall(field[ya][xa]); 82 field[yb][xb].moveBall(field[ya][xa]);
84 } 83 }
85} 84}
86 85
87int Field::getBall(int x, int y) 86int Field::getBall(int x, int y)
88{ 87{
89 if( checkBounds(x,y) ) 88 if( checkBounds(x,y) )
90 return field[y][x].getColor(); 89 return field[y][x].getColor();
91 else 90 else
92 return NOBALL; 91 return NOBALL;
93} 92}
94int Field::getAnim(int x, int y) 93int Field::getAnim(int x, int y)
95{ 94{
96 if( checkBounds(x,y) ) 95 if( checkBounds(x,y) )
97 return field[y][x].getAnim(); 96 return field[y][x].getAnim();
98 else 97 else
99 return NOBALL; 98 return NOBALL;
100} 99}
101void Field::setAnim(int x, int y, int anim) 100void Field::setAnim(int x, int y, int anim)
102{ 101{
103 if( checkBounds(x,y) ) 102 if( checkBounds(x,y) )
104 field[y][x].setAnim( anim ); 103 field[y][x].setAnim( anim );
105} 104}
106 105
107void Field::removeBall(int x, int y ) 106void Field::removeBall(int x, int y )
108{ 107{
109 if( checkBounds(x,y) ) field[y][x].clear(); 108 if( checkBounds(x,y) ) field[y][x].clear();
110} 109}
111 110
112int Field::freeSpace() 111int Field::freeSpace()
113{ 112{
114 int s = 0; 113 int s = 0;
115 for(int y=0; y<NUMCELLSH; y++) 114 for(int y=0; y<NUMCELLSH; y++)
116 for(int x=0; x<NUMCELLSW; x++) 115 for(int x=0; x<NUMCELLSW; x++)
diff --git a/noncore/games/zlines/klines.cpp b/noncore/games/zlines/klines.cpp
index 02ff0db..76c94e2 100644
--- a/noncore/games/zlines/klines.cpp
+++ b/noncore/games/zlines/klines.cpp
@@ -1,137 +1,128 @@
1/*************************************************************************** 1/***************************************************************************
2 klines.cpp - description 2 klines.cpp - description
3 ------------------- 3 -------------------
4 begin : Fri May 19 2000 4 begin : Fri May 19 2000
5 copyright : (C) 2000 by Roman Merzlyakov 5 copyright : (C) 2000 by Roman Merzlyakov
6 email : roman@sbrf.barrt.ru 6 email : roman@sbrf.barrt.ru
7 copyright : (C) 2000 by Roman Razilov 7 copyright : (C) 2000 by Roman Razilov
8 email : Roman.Razilov@gmx.de 8 email : Roman.Razilov@gmx.de
9 ***************************************************************************/ 9 ***************************************************************************/
10 10
11/*************************************************************************** 11/***************************************************************************
12 * * 12 * *
13 * This program is free software; you can redistribute it and/or modify * 13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by * 14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or * 15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. * 16 * (at your option) any later version. *
17 * * 17 * *
18 ***************************************************************************/ 18 ***************************************************************************/
19/* changes 19/* changes
2021.05.2000 Roman Razilov Menu game/Next 2021.05.2000 Roman Razilov Menu game/Next
21*/ 21*/
22// 22//
23// The implementation of the KLines widget 23// The implementation of the KLines widget
24// 24//
25 25
26#include <qkeycode.h>
27#include <qlabel.h>
28#include <qpushbutton.h>
29#include <qtooltip.h>
30#include <qstring.h>
31#include <stdlib.h> 26#include <stdlib.h>
32#include <unistd.h> 27#include <unistd.h>
33#include <time.h> 28#include <time.h>
34 29
35#include <qapplication.h> 30#include <qapplication.h>
36#include <qmenubar.h>
37#include <qpopupmenu.h>
38 31
39 32
40#include "cfg.h"
41#include <qstatusbar.h>
42#include "klines.h" 33#include "klines.h"
43 34
44 35
45/* 36/*
46 Creates the KLines widget and sets saved options (if any). 37 Creates the KLines widget and sets saved options (if any).
47 */ 38 */
48 39
49KLines::KLines(QWidget *par, const char* n, WFlags fl) : QMainWindow(par,n,fl) 40KLines::KLines(QWidget *par, const char* n, WFlags fl) : QMainWindow(par,n,fl)
50{ 41{
51 time_t t; 42 time_t t;
52 time(&t); 43 time(&t);
53 srand((unsigned int)t + getpid()); 44 srand((unsigned int)t + getpid());
54 45
55 setCaption(QString("ZLines")); 46 setCaption(QString("ZLines"));
56 47
57 mwidget = new MainWidget(this); 48 mwidget = new MainWidget(this);
58 setCentralWidget( mwidget ); 49 setCentralWidget( mwidget );
59 50
60 lsb = mwidget->GetLsb(); 51 lsb = mwidget->GetLsb();
61 lPrompt = mwidget->GetPrompt(); 52 lPrompt = mwidget->GetPrompt();
62 53
63 menu = menuBar(); 54 menu = menuBar();
64 game = new QPopupMenu; 55 game = new QPopupMenu;
65 edit = new QPopupMenu; 56 edit = new QPopupMenu;
66 57
67 game->insertItem(tr("&New game"), this, SLOT(stopGame()), CTRL+Key_N ); 58 game->insertItem(tr("&New game"), this, SLOT(stopGame()), CTRL+Key_N );
68 game->insertSeparator(); 59 game->insertSeparator();
69 game->insertItem(tr("Ne&xt"), this, SLOT(makeTurn()), Key_N ); 60 game->insertItem(tr("Ne&xt"), this, SLOT(makeTurn()), Key_N );
70 game->insertSeparator(); 61 game->insertSeparator();
71 idMenuPrompt = game->insertItem( tr("&Show next"), this, SLOT(switchPrompt()), CTRL+Key_P ); 62 idMenuPrompt = game->insertItem( tr("&Show next"), this, SLOT(switchPrompt()), CTRL+Key_P );
72 game->setCheckable(true); 63 game->setCheckable(true);
73 game->setItemChecked(idMenuPrompt, lPrompt->getState()); 64 game->setItemChecked(idMenuPrompt, lPrompt->getState());
74 game->insertSeparator(); 65 game->insertSeparator();
75 game->insertItem(tr("&Quit"), qApp, SLOT(quit()), CTRL+Key_Q ); 66 game->insertItem(tr("&Quit"), qApp, SLOT(quit()), CTRL+Key_Q );
76 67
77 idMenuUndo = edit->insertItem(tr("Und&o"), this, SLOT(undo()), CTRL+Key_Z ); 68 idMenuUndo = edit->insertItem(tr("Und&o"), this, SLOT(undo()), CTRL+Key_Z );
78 69
79 menu->insertItem( tr("&Game"), game ); 70 menu->insertItem( tr("&Game"), game );
80 menu->insertItem( tr("&Edit"), edit ); 71 menu->insertItem( tr("&Edit"), edit );
81 72
82 menu->show(); 73 menu->show();
83 74
84 score = 0; 75 score = 0;
85 prev_score = 0; 76 prev_score = 0;
86 77
87 mwidget->setMessage(tr("Points: 0")); 78 mwidget->setMessage(tr("Points: 0"));
88 79
89 startGame(); 80 startGame();
90} 81}
91 82
92/* 83/*
93 Saves the options and destroys the KLines widget. 84 Saves the options and destroys the KLines widget.
94 */ 85 */
95 86
96KLines::~KLines() 87KLines::~KLines()
97{ 88{
98} 89}
99 90
100/* 91/*
101 Resize event of the KLines widget. 92 Resize event of the KLines widget.
102 */ 93 */
103 94
104void KLines::resizeEvent( QResizeEvent *e ) 95void KLines::resizeEvent( QResizeEvent *e )
105{ 96{
106 QMainWindow::resizeEvent(e); 97 QMainWindow::resizeEvent(e);
107} 98}
108 99
109void KLines::setMinSize() 100void KLines::setMinSize()
110{ 101{
111 // setMinimumSize( gr->wHint(), gr->hHint() + menu->height() + stat->height() + 102 // setMinimumSize( gr->wHint(), gr->hHint() + menu->height() + stat->height() +
112 // tool->height() ); 103 // tool->height() );
113} 104}
114 105
115void KLines::startGame() 106void KLines::startGame()
116{ 107{
117 score = 0; 108 score = 0;
118 prev_score = 0; 109 prev_score = 0;
119 bUndo=TRUE; 110 bUndo=TRUE;
120 111
121 lsb->clearField(); 112 lsb->clearField();
122 generateRandomBalls(); 113 generateRandomBalls();
123 placeBalls(); 114 placeBalls();
124 generateRandomBalls(); 115 generateRandomBalls();
125 edit->setItemEnabled(idMenuUndo, FALSE ); 116 edit->setItemEnabled(idMenuUndo, FALSE );
126 updateStat(); 117 updateStat();
127} 118}
128void KLines::stopGame() 119void KLines::stopGame()
129{ 120{
130 debug("Klines::stopGame"); 121 debug("Klines::stopGame");
131 endGame(); 122 endGame();
132} 123}
133 124
134void KLines::searchBallsLine() 125void KLines::searchBallsLine()
135{ 126{
136} 127}
137 128
diff --git a/noncore/games/zlines/linesboard.cpp b/noncore/games/zlines/linesboard.cpp
index 0965b2c..1e59aeb 100644
--- a/noncore/games/zlines/linesboard.cpp
+++ b/noncore/games/zlines/linesboard.cpp
@@ -1,118 +1,115 @@
1/*************************************************************************** 1/***************************************************************************
2 linesboard.cpp - description 2 linesboard.cpp - description
3 ------------------- 3 -------------------
4 begin : Fri May 19 2000 4 begin : Fri May 19 2000
5 copyright : (C) 2000 by Roman Merzlyakov 5 copyright : (C) 2000 by Roman Merzlyakov
6 email : roman@sbrf.barrt.ru 6 email : roman@sbrf.barrt.ru
7 copyright : (C) 2000 by Roman Razilov 7 copyright : (C) 2000 by Roman Razilov
8 email : Roman.Razilov@gmx.de 8 email : Roman.Razilov@gmx.de
9 ***************************************************************************/ 9 ***************************************************************************/
10 10
11/*************************************************************************** 11/***************************************************************************
12 * * 12 * *
13 * This program is free software; you can redistribute it and/or modify * 13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by * 14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or * 15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. * 16 * (at your option) any later version. *
17 * * 17 * *
18 ***************************************************************************/ 18 ***************************************************************************/
19#include <qpainter.h> 19#include <qpainter.h>
20#include <qpixmap.h>
21#include <qcolor.h>
22#include <qkeycode.h>
23#include <stdlib.h> 20#include <stdlib.h>
24 21
25#include "linesboard.h" 22#include "linesboard.h"
26 23
27/* 24/*
28 Constructs a LinesBoard widget. 25 Constructs a LinesBoard widget.
29*/ 26*/
30 27
31LinesBoard::LinesBoard( BallPainter * abPainter, QWidget* parent, const char* name ) 28LinesBoard::LinesBoard( BallPainter * abPainter, QWidget* parent, const char* name )
32 : Field( parent, name ) 29 : Field( parent, name )
33{ 30{
34 anim = ANIM_NO; 31 anim = ANIM_NO;
35// waypos = 0; 32// waypos = 0;
36// waylen = 0; 33// waylen = 0;
37// jumpingRow = -1; 34// jumpingRow = -1;
38// jumpingCol = -1; 35// jumpingCol = -1;
39 painting = 0; 36 painting = 0;
40 way = new Waypoints[NUMCELLSW*NUMCELLSH]; 37 way = new Waypoints[NUMCELLSW*NUMCELLSH];
41 38
42 bPainter = abPainter; 39 bPainter = abPainter;
43 40
44 setFocusPolicy( NoFocus ); 41 setFocusPolicy( NoFocus );
45 setBackgroundColor( gray ); 42 setBackgroundColor( gray );
46 43
47 setMouseTracking( FALSE ); 44 setMouseTracking( FALSE );
48 setFixedSize(wHint(), hHint()); 45 setFixedSize(wHint(), hHint());
49 46
50 timer = new QTimer(this); 47 timer = new QTimer(this);
51 connect( timer, SIGNAL(timeout()), SLOT(timerSlot()) ); 48 connect( timer, SIGNAL(timeout()), SLOT(timerSlot()) );
52 timer->start( TIMERCLOCK, FALSE ); 49 timer->start( TIMERCLOCK, FALSE );
53 50
54} 51}
55 52
56/* 53/*
57 Destructor: deallocates memory for contents 54 Destructor: deallocates memory for contents
58*/ 55*/
59 56
60LinesBoard::~LinesBoard() 57LinesBoard::~LinesBoard()
61{ 58{
62 // debug("stop"); 59 // debug("stop");
63 timer->stop(); 60 timer->stop();
64 delete timer; 61 delete timer;
65 delete []way; 62 delete []way;
66} 63}
67 64
68 65
69void LinesBoard::placeBalls(int pnextBalls[BALLSDROP]) 66void LinesBoard::placeBalls(int pnextBalls[BALLSDROP])
70{ 67{
71 debug("LinesBoard::placeBalls( )"); 68 debug("LinesBoard::placeBalls( )");
72 for(int i=0; i < BALLSDROP; i++){ 69 for(int i=0; i < BALLSDROP; i++){
73 nextBalls[i] = pnextBalls[i]; 70 nextBalls[i] = pnextBalls[i];
74 } 71 }
75 nextBallToPlace = 0; 72 nextBallToPlace = 0;
76 placeBall(); 73 placeBall();
77 debug("LinesBoard::placeBalls End "); 74 debug("LinesBoard::placeBalls End ");
78} 75}
79void LinesBoard::placeBall( ) 76void LinesBoard::placeBall( )
80{ 77{
81 int color = nextBalls[nextBallToPlace]; 78 int color = nextBalls[nextBallToPlace];
82 debug("LinesBoard::placeBall( ) color=%i, nextBallToPlace = %i", color, nextBallToPlace); 79 debug("LinesBoard::placeBall( ) color=%i, nextBallToPlace = %i", color, nextBallToPlace);
83 char* xx = (char*)malloc( sizeof(char)*NUMCELLSW*NUMCELLSH ); 80 char* xx = (char*)malloc( sizeof(char)*NUMCELLSW*NUMCELLSH );
84 char* yy = (char*)malloc( sizeof(char)*NUMCELLSW*NUMCELLSH ); 81 char* yy = (char*)malloc( sizeof(char)*NUMCELLSW*NUMCELLSH );
85// int nb=3; 82// int nb=3;
86// if( freeSpace() < 3) nb = freeSpace(); 83// if( freeSpace() < 3) nb = freeSpace();
87 int empty=0; 84 int empty=0;
88 for(int y=0; y<NUMCELLSH; y++) 85 for(int y=0; y<NUMCELLSH; y++)
89 for(int x=0; x<NUMCELLSW; x++) 86 for(int x=0; x<NUMCELLSW; x++)
90 if( getBall(x,y) == NOBALL ) 87 if( getBall(x,y) == NOBALL )
91 { 88 {
92 xx[empty] = x; 89 xx[empty] = x;
93 yy[empty] = y; 90 yy[empty] = y;
94 empty++; 91 empty++;
95 }; 92 };
96// debug("empty = %i",empty); 93// debug("empty = %i",empty);
97 if ( empty > 0) 94 if ( empty > 0)
98 { 95 {
99 int pos = rand()%empty; 96 int pos = rand()%empty;
100 putBall( xx[pos], yy[pos], color ); 97 putBall( xx[pos], yy[pos], color );
101 clearAnim(); 98 clearAnim();
102 setAnim( xx[pos], yy[pos], ANIM_BORN ); 99 setAnim( xx[pos], yy[pos], ANIM_BORN );
103 nextBallToPlace++; 100 nextBallToPlace++;
104 AnimStart(ANIM_BORN); 101 AnimStart(ANIM_BORN);
105 free(xx); 102 free(xx);
106 free(yy); 103 free(yy);
107 } 104 }
108 else 105 else
109 { 106 {
110 free(xx); 107 free(xx);
111 free(yy); 108 free(yy);
112 emit endGame(); 109 emit endGame();
113 } 110 }
114 debug("LinesBoard::placeBall END"); 111 debug("LinesBoard::placeBall END");
115} 112}
116 113
117 114
118/*id LinesBoard::doAfterBalls() { 115/*id LinesBoard::doAfterBalls() {
diff --git a/noncore/games/zlines/main.cpp b/noncore/games/zlines/main.cpp
index ff41f95..238e7d3 100644
--- a/noncore/games/zlines/main.cpp
+++ b/noncore/games/zlines/main.cpp
@@ -1,30 +1,29 @@
1/*************************************************************************** 1/***************************************************************************
2 main.cpp - description 2 main.cpp - description
3 ------------------- 3 -------------------
4 begin : Fri May 19 2000 4 begin : Fri May 19 2000
5 copyright : (C) 2000 by Roman Merzlyakov 5 copyright : (C) 2000 by Roman Merzlyakov
6 email : roman@sbrf.barrt.ru 6 email : roman@sbrf.barrt.ru
7 copyright : (C) 2000 by Roman Razilov 7 copyright : (C) 2000 by Roman Razilov
8 email : Roman.Razilov@gmx.de 8 email : Roman.Razilov@gmx.de
9 ***************************************************************************/ 9 ***************************************************************************/
10 10
11/*************************************************************************** 11/***************************************************************************
12 * * 12 * *
13 * This program is free software; you can redistribute it and/or modify * 13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by * 14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or * 15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. * 16 * (at your option) any later version. *
17 * * 17 * *
18 ***************************************************************************/ 18 ***************************************************************************/
19 /* 19 /*
20 * Roman Razilov 2000-05-19 debug dummmy 20 * Roman Razilov 2000-05-19 debug dummmy
21 * Roman Razilov 2000-05-21 qimgio 21 * Roman Razilov 2000-05-21 qimgio
22*/ 22*/
23 23
24#include <qglobal.h>
25 24
26 25
27#include <opie/oapplicationfactory.h> 26#include <opie/oapplicationfactory.h>
28#include "klines.h" 27#include "klines.h"
29 28
30OPIE_EXPORT_APP( OApplicationFactory<KLines> ) 29OPIE_EXPORT_APP( OApplicationFactory<KLines> )
diff --git a/noncore/games/zlines/mwidget.cpp b/noncore/games/zlines/mwidget.cpp
index 6641fa2..211d3d3 100644
--- a/noncore/games/zlines/mwidget.cpp
+++ b/noncore/games/zlines/mwidget.cpp
@@ -1,84 +1,83 @@
1/*************************************************************************** 1/***************************************************************************
2 mwidget.cpp - description 2 mwidget.cpp - description
3 ------------------- 3 -------------------
4begin : Fri May 19 2000 4begin : Fri May 19 2000
5copyright : (C) 2000 by Roman Merzlyakov 5copyright : (C) 2000 by Roman Merzlyakov
6email : roman@sbrf.barrt.ru 6email : roman@sbrf.barrt.ru
7copyright : (C) 2000 by Roman Razilov 7copyright : (C) 2000 by Roman Razilov
8email : Roman.Razilov@gmx.de 8email : Roman.Razilov@gmx.de
9 ***************************************************************************/ 9 ***************************************************************************/
10 10
11/*************************************************************************** 11/***************************************************************************
12 * * 12 * *
13 * This program is free software; you can redistribute it and/or modify * 13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by * 14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or * 15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. * 16 * (at your option) any later version. *
17 * * 17 * *
18 ***************************************************************************/ 18 ***************************************************************************/
19#include "mwidget.h" 19#include "mwidget.h"
20#include <qlayout.h> 20#include <qlayout.h>
21#include "ballpainter.h"
22#include <qhbox.h> 21#include <qhbox.h>
23#include <qlabel.h> 22#include <qlabel.h>
24 23
25MainWidget::MainWidget( QWidget* parent, const char* name ) 24MainWidget::MainWidget( QWidget* parent, const char* name )
26 : QFrame( parent, name ) 25 : QFrame( parent, name )
27{ 26{
28 BallPainter *bPainter = new BallPainter(); 27 BallPainter *bPainter = new BallPainter();
29 28
30 QGridLayout *Form1Layout = new QGridLayout( this ); 29 QGridLayout *Form1Layout = new QGridLayout( this );
31 Form1Layout->setSpacing( 4 ); 30 Form1Layout->setSpacing( 4 );
32 Form1Layout->setMargin( 4 ); 31 Form1Layout->setMargin( 4 );
33 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); 32 QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
34 Form1Layout->addItem( spacer, 0, 0 ); 33 Form1Layout->addItem( spacer, 0, 0 );
35 34
36 lsb = new LinesBoard(bPainter, this); 35 lsb = new LinesBoard(bPainter, this);
37 36
38 Form1Layout->addWidget( lsb, 0, 1 ); 37 Form1Layout->addWidget( lsb, 0, 1 );
39 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); 38 QSpacerItem* spacer_2 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
40 Form1Layout->addItem( spacer_2, 0, 2 ); 39 Form1Layout->addItem( spacer_2, 0, 2 );
41 40
42 QHBox *bottom=new QHBox(this); 41 QHBox *bottom=new QHBox(this);
43 42
44 mPoints=new QLabel(bottom); 43 mPoints=new QLabel(bottom);
45 bottom->setStretchFactor(mPoints, 2); 44 bottom->setStretchFactor(mPoints, 2);
46 45
47 lPrompt = new LinesPrompt(bPainter, bottom); 46 lPrompt = new LinesPrompt(bPainter, bottom);
48 47
49 Form1Layout->addWidget( bottom, 1, 1 ); 48 Form1Layout->addWidget( bottom, 1, 1 );
50 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding ); 49 QSpacerItem* spacer_3 = new QSpacerItem( 20, 20, QSizePolicy::Minimum, QSizePolicy::Expanding );
51 Form1Layout->addItem( spacer_3, 2, 1 ); 50 Form1Layout->addItem( spacer_3, 2, 1 );
52 51
53 52
54 connect(lsb, SIGNAL(endTurn()), parent, SLOT(makeTurn())); 53 connect(lsb, SIGNAL(endTurn()), parent, SLOT(makeTurn()));
55 connect(lsb, SIGNAL(eraseLine(int)), parent, SLOT(addScore(int))); 54 connect(lsb, SIGNAL(eraseLine(int)), parent, SLOT(addScore(int)));
56 connect(lsb, SIGNAL(endGame()), parent, SLOT(stopGame())); 55 connect(lsb, SIGNAL(endGame()), parent, SLOT(stopGame()));
57 56
58 connect(lPrompt, SIGNAL(PromptPressed()), parent, SLOT(switchPrompt())); 57 connect(lPrompt, SIGNAL(PromptPressed()), parent, SLOT(switchPrompt()));
59 58
60} 59}
61 60
62void MainWidget::setMessage(const QString &message) 61void MainWidget::setMessage(const QString &message)
63{ 62{
64 mPoints->setText(message); 63 mPoints->setText(message);
65} 64}
66 65
67 66
68/* 67/*
69Destructor: deallocates memory for contents 68Destructor: deallocates memory for contents
70 */ 69 */
71 70
72MainWidget::~MainWidget() 71MainWidget::~MainWidget()
73{ 72{
74} 73}
75 74
76LinesBoard * MainWidget::GetLsb() 75LinesBoard * MainWidget::GetLsb()
77{ 76{
78 return lsb; 77 return lsb;
79} 78}
80 79
81LinesPrompt * MainWidget::GetPrompt() 80LinesPrompt * MainWidget::GetPrompt()
82{ 81{
83 return lPrompt; 82 return lPrompt;
84} 83}
diff --git a/noncore/games/zsame/StoneWidget.cpp b/noncore/games/zsame/StoneWidget.cpp
index 49fa1a4..646fc9c 100644
--- a/noncore/games/zsame/StoneWidget.cpp
+++ b/noncore/games/zsame/StoneWidget.cpp
@@ -1,124 +1,119 @@
1/* 1/*
2 * ksame 0.4 - simple Game 2 * ksame 0.4 - simple Game
3 * Copyright (C) 1997,1998 Marcus Kreutzberger 3 * Copyright (C) 1997,1998 Marcus Kreutzberger
4 * 4 *
5 * This program is free software; you can redistribute it and/or modify 5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or 7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
9 * 9 *
10 * This program is distributed in the hope that it will be useful, 10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details. 13 * GNU General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU General Public License 15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software 16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 * 18 *
19 */ 19 */
20 20
21#include <stdio.h> 21#include <stdio.h>
22#include <stdlib.h> 22#include <stdlib.h>
23 23
24#include <qpainter.h>
25#include <qpixmap.h>
26#include <qbitmap.h>
27#include <qimage.h>
28#include <qcursor.h>
29 24
30 25
31#include <qpe/resource.h> 26#include <qpe/resource.h>
32 27
33#include <time.h> 28#include <time.h>
34#include <assert.h> 29#include <assert.h>
35 30
36#include "StoneWidget.h" 31#include "StoneWidget.h"
37 32
38 33
39 34
40struct StoneSlice { 35struct StoneSlice {
41 QPixmap stone; 36 QPixmap stone;
42}; 37};
43 38
44 39
45StoneWidget::StoneWidget( QWidget *parent, int x, int y ) 40StoneWidget::StoneWidget( QWidget *parent, int x, int y )
46 : QWidget(parent,"StoneWidget"), stonefield(x,y) 41 : QWidget(parent,"StoneWidget"), stonefield(x,y)
47{ 42{
48// setBackgroundPixmap(QPixmap(locate("wallpaper", "Time-For-Lunch-2.jpg"))); 43// setBackgroundPixmap(QPixmap(locate("wallpaper", "Time-For-Lunch-2.jpg")));
49// QPixmap stonemap(locate("appdata", "stones.png")); 44// QPixmap stonemap(locate("appdata", "stones.png"));
50 45
51 QPixmap stonemap = Resource::loadPixmap("zsame/stones" ); 46 QPixmap stonemap = Resource::loadPixmap("zsame/stones" );
52 assert(!stonemap.isNull()); 47 assert(!stonemap.isNull());
53 48
54 slice=0; 49 slice=0;
55 maxslices=30; 50 maxslices=30;
56 maxcolors=4; 51 maxcolors=4;
57 52
58 sizex=x; 53 sizex=x;
59 sizey=y; 54 sizey=y;
60 55
61 stone_width=stonemap.width()/(maxslices+1); 56 stone_width=stonemap.width()/(maxslices+1);
62 stone_height=stonemap.height()/maxcolors; 57 stone_height=stonemap.height()/maxcolors;
63 58
64 map = new StoneSlice*[maxcolors]; 59 map = new StoneSlice*[maxcolors];
65 QBitmap mask; 60 QBitmap mask;
66 for (int c = 0; c < maxcolors; c++) { 61 for (int c = 0; c < maxcolors; c++) {
67 map[c] = new StoneSlice[maxslices]; 62 map[c] = new StoneSlice[maxslices];
68 63
69 for (int s = 0; s < maxslices; s++) { 64 for (int s = 0; s < maxslices; s++) {
70 map[c][s].stone.resize(stone_width, stone_height); 65 map[c][s].stone.resize(stone_width, stone_height);
71 assert(!map[c][s].stone.isNull()); 66 assert(!map[c][s].stone.isNull());
72 bitBlt(&map[c][s].stone, 0, 0, 67 bitBlt(&map[c][s].stone, 0, 0,
73 &stonemap, stone_width * s, 68 &stonemap, stone_width * s,
74 c*stone_height, 69 c*stone_height,
75 stone_width,stone_height,CopyROP,false); 70 stone_width,stone_height,CopyROP,false);
76 QImage im = map[c][s].stone.convertToImage(); 71 QImage im = map[c][s].stone.convertToImage();
77 mask = im.createHeuristicMask(); 72 mask = im.createHeuristicMask();
78 map[c][s].stone.setMask(mask); 73 map[c][s].stone.setMask(mask);
79 } 74 }
80 } 75 }
81 76
82 field_height=stone_height*sizey; 77 field_height=stone_height*sizey;
83 field_width=stone_width*sizex; 78 field_width=stone_width*sizex;
84 79
85 setMouseTracking(true); 80 setMouseTracking(true);
86 81
87 // QColor c(115,115,115); 82 // QColor c(115,115,115);
88 // setBackgroundColor(c); 83 // setBackgroundColor(c);
89 84
90 // emit s_sizechanged(); 85 // emit s_sizechanged();
91 startTimer( 100 ); 86 startTimer( 100 );
92 history.setAutoDelete(true); 87 history.setAutoDelete(true);
93} 88}
94 89
95StoneWidget::~StoneWidget() { 90StoneWidget::~StoneWidget() {
96 for (int c = 0; c < maxcolors; c++) { 91 for (int c = 0; c < maxcolors; c++) {
97 delete [] map[c]; 92 delete [] map[c];
98 } 93 }
99 delete [] map; 94 delete [] map;
100 95
101 setMouseTracking(false); 96 setMouseTracking(false);
102 killTimers(); 97 killTimers();
103} 98}
104 99
105unsigned int 100unsigned int
106StoneWidget::board() { 101StoneWidget::board() {
107 return stonefield.getBoard(); 102 return stonefield.getBoard();
108} 103}
109 104
110int 105int
111StoneWidget::score() { 106StoneWidget::score() {
112 return stonefield.getScore(); 107 return stonefield.getScore();
113} 108}
114 109
115int 110int
116StoneWidget::marked() { 111StoneWidget::marked() {
117 return stonefield.getMarked(); 112 return stonefield.getMarked();
118} 113}
119 114
120QSize 115QSize
121StoneWidget::size() { 116StoneWidget::size() {
122 return QSize(sizex,sizey); 117 return QSize(sizex,sizey);
123} 118}
124 119
diff --git a/noncore/games/zsame/ZSameWidget.cpp b/noncore/games/zsame/ZSameWidget.cpp
index 5001b55..45a877f 100644
--- a/noncore/games/zsame/ZSameWidget.cpp
+++ b/noncore/games/zsame/ZSameWidget.cpp
@@ -1,139 +1,132 @@
1/* Yo Emacs, this is -*- C++ -*- */ 1/* Yo Emacs, this is -*- C++ -*- */
2/* 2/*
3 * ksame 0.4 - simple Game 3 * ksame 0.4 - simple Game
4 * Copyright (C) 1997,1998 Marcus Kreutzberger 4 * Copyright (C) 1997,1998 Marcus Kreutzberger
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by 7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or 8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version. 9 * (at your option) any later version.
10 * 10 *
11 * This program is distributed in the hope that it will be useful, 11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details. 14 * GNU General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU General Public License 16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software 17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 * 19 *
20 */ 20 */
21 21
22#include <stdio.h> 22#include <stdio.h>
23 23
24#include <qwidget.h>
25#include <qpushbutton.h>
26#include <qpixmap.h>
27#include <qvbox.h>
28#include <qpopupmenu.h>
29#include <qtoolbar.h> 24#include <qtoolbar.h>
30#include <qmenubar.h> 25#include <qmenubar.h>
31 26
32#include <qapplication.h> 27#include <qapplication.h>
33#include <qaction.h> 28#include <qaction.h>
34#include <qmessagebox.h> 29#include <qmessagebox.h>
35 30
36#include <qpe/resource.h> 31#include <qpe/resource.h>
37#include <opie/oapplicationfactory.h> 32#include <opie/oapplicationfactory.h>
38#include <kapplication.h> 33#include <kapplication.h>
39 34
40 35
41#include "ZSameWidget.h" 36#include "ZSameWidget.h"
42#include "StoneWidget.h"
43#include "version.h"
44 37
45static int default_colors=3; 38static int default_colors=3;
46 39
47#define i18n tr 40#define i18n tr
48 41
49 42
50OPIE_EXPORT_APP( OApplicationFactory<ZSameWidget> ) 43OPIE_EXPORT_APP( OApplicationFactory<ZSameWidget> )
51 44
52 45
53 46
54ZSameWidget::ZSameWidget( QWidget* parent, const char* name, WFlags fl ) 47ZSameWidget::ZSameWidget( QWidget* parent, const char* name, WFlags fl )
55 : QMainWindow( parent, name, fl ) 48 : QMainWindow( parent, name, fl )
56{ 49{
57 setCaption(tr("ZSame")); 50 setCaption(tr("ZSame"));
58 51
59 setToolBarsMovable( false ); 52 setToolBarsMovable( false );
60 QToolBar* con = new QToolBar( this ); 53 QToolBar* con = new QToolBar( this );
61 con->setHorizontalStretchable( true ); 54 con->setHorizontalStretchable( true );
62 QMenuBar* mb = new QMenuBar( con ); 55 QMenuBar* mb = new QMenuBar( con );
63 QToolBar* tb = new QToolBar( this ); 56 QToolBar* tb = new QToolBar( this );
64 57
65 QPopupMenu* fileMenu = new QPopupMenu( this ); 58 QPopupMenu* fileMenu = new QPopupMenu( this );
66 59
67 QAction* a = new QAction(tr("New Game"), Resource::loadIconSet("new") , 60 QAction* a = new QAction(tr("New Game"), Resource::loadIconSet("new") ,
68 QString::null, 0, this, "new_icon"); 61 QString::null, 0, this, "new_icon");
69 a->addTo( fileMenu ); 62 a->addTo( fileMenu );
70 a->addTo( tb ); 63 a->addTo( tb );
71 connect(a, SIGNAL(activated()), this, SLOT(m_new())); 64 connect(a, SIGNAL(activated()), this, SLOT(m_new()));
72 65
73 a = new QAction(tr("Restart This Board"), Resource::loadIconSet("redo"), 66 a = new QAction(tr("Restart This Board"), Resource::loadIconSet("redo"),
74 QString::null, 0, this, "restart_board" ); 67 QString::null, 0, this, "restart_board" );
75 a->addTo( fileMenu ); 68 a->addTo( fileMenu );
76 connect( a, SIGNAL(activated()), this, SLOT(m_restart())); 69 connect( a, SIGNAL(activated()), this, SLOT(m_restart()));
77 restart = a; 70 restart = a;
78 71
79 a = new QAction( tr("Undo"), Resource::loadIconSet("undo"), 72 a = new QAction( tr("Undo"), Resource::loadIconSet("undo"),
80 QString::null, 0, this, "undo_action" ); 73 QString::null, 0, this, "undo_action" );
81 a->addTo( fileMenu ); 74 a->addTo( fileMenu );
82 a->addTo( tb ); 75 a->addTo( tb );
83 connect( a, SIGNAL(activated()), this, SLOT(m_undo())); 76 connect( a, SIGNAL(activated()), this, SLOT(m_undo()));
84 77
85 a = new QAction(tr("Quit"), Resource::loadIconSet("quit_icon"), 78 a = new QAction(tr("Quit"), Resource::loadIconSet("quit_icon"),
86 QString::null, 0, this, "quit_action"); 79 QString::null, 0, this, "quit_action");
87 a->addTo( fileMenu ); 80 a->addTo( fileMenu );
88 a->addTo( tb ); 81 a->addTo( tb );
89 connect(a, SIGNAL(activated()), this, SLOT(m_quit())); 82 connect(a, SIGNAL(activated()), this, SLOT(m_quit()));
90 83
91 mb->insertItem(tr("Game" ), fileMenu ); 84 mb->insertItem(tr("Game" ), fileMenu );
92 85
93 int foo[2]; 86 int foo[2];
94 desktop_widget(foo); 87 desktop_widget(foo);
95 stone = new StoneWidget(this,foo[0],foo[1]); 88 stone = new StoneWidget(this,foo[0],foo[1]);
96 89
97 connect( stone, SIGNAL(s_gameover()), this, SLOT(gameover())); 90 connect( stone, SIGNAL(s_gameover()), this, SLOT(gameover()));
98 91
99 connect( stone, SIGNAL(s_colors(int)), this, SLOT(setColors(int))); 92 connect( stone, SIGNAL(s_colors(int)), this, SLOT(setColors(int)));
100 connect( stone, SIGNAL(s_board(int)), this, SLOT(setBoard(int))); 93 connect( stone, SIGNAL(s_board(int)), this, SLOT(setBoard(int)));
101 connect( stone, SIGNAL(s_marked(int)), this, SLOT(setMarked(int))); 94 connect( stone, SIGNAL(s_marked(int)), this, SLOT(setMarked(int)));
102 connect( stone, SIGNAL(s_score(int)), this, SLOT(setScore(int))); 95 connect( stone, SIGNAL(s_score(int)), this, SLOT(setScore(int)));
103 connect( stone, SIGNAL(s_remove(int,int)), this, SLOT(stonesRemoved(int,int))); 96 connect( stone, SIGNAL(s_remove(int,int)), this, SLOT(stonesRemoved(int,int)));
104 97
105 connect(stone, SIGNAL(s_sizechanged()), this, SLOT(sizeChanged())); 98 connect(stone, SIGNAL(s_sizechanged()), this, SLOT(sizeChanged()));
106 99
107 sizeChanged(); 100 sizeChanged();
108 setCentralWidget(stone); 101 setCentralWidget(stone);
109 102
110 103
111 setScore(0); 104 setScore(0);
112} 105}
113 106
114ZSameWidget::~ZSameWidget() { 107ZSameWidget::~ZSameWidget() {
115 108
116} 109}
117 110
118void ZSameWidget::readProperties(Config *conf) { 111void ZSameWidget::readProperties(Config *conf) {
119/* 112/*
120 Q_ASSERT(conf); 113 Q_ASSERT(conf);
121 stone->readProperties(conf); 114 stone->readProperties(conf);
122*/ 115*/
123} 116}
124 117
125void ZSameWidget::saveProperties(Config *conf) { 118void ZSameWidget::saveProperties(Config *conf) {
126/* 119/*
127 Q_ASSERT(conf); 120 Q_ASSERT(conf);
128 stone->saveProperties(conf); 121 stone->saveProperties(conf);
129 conf->sync(); 122 conf->sync();
130*/ 123*/
131} 124}
132 125
133void ZSameWidget::sizeChanged() { 126void ZSameWidget::sizeChanged() {
134 //stone->setFixedSize(stone->sizeHint()); 127 //stone->setFixedSize(stone->sizeHint());
135} 128}
136 129
137void ZSameWidget::newGame(unsigned int board,int colors) { 130void ZSameWidget::newGame(unsigned int board,int colors) {
138 while (board>=1000000) board-=1000000; 131 while (board>=1000000) board-=1000000;
139 // kdDebug() << "newgame board " << board << " colors " << colors << endl; 132 // kdDebug() << "newgame board " << board << " colors " << colors << endl;