Diffstat (limited to 'noncore/games/backgammon/backgammon.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/backgammon/backgammon.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/noncore/games/backgammon/backgammon.cpp b/noncore/games/backgammon/backgammon.cpp index 51020a0..bdb1c78 100644 --- a/noncore/games/backgammon/backgammon.cpp +++ b/noncore/games/backgammon/backgammon.cpp | |||
@@ -1,105 +1,109 @@ | |||
1 | #include "backgammon.h" | 1 | #include "backgammon.h" |
2 | |||
3 | #include "aidialog.h" | 2 | #include "aidialog.h" |
4 | #include "filedialog.h" | 3 | #include "filedialog.h" |
5 | #include "playerdialog.h" | 4 | #include "playerdialog.h" |
6 | #include "rulesdialog.h" | 5 | #include "rulesdialog.h" |
7 | #include "themedialog.h" | 6 | #include "themedialog.h" |
8 | 7 | ||
8 | /* OPIE */ | ||
9 | #include <opie2/odebug.h> | ||
10 | #include <qpe/qpeapplication.h> | ||
11 | #include <qpe/config.h> | ||
12 | #include <qpe/resource.h> | ||
13 | using namespace Opie::Core; | ||
14 | |||
15 | /* QT */ | ||
9 | #include <qfile.h> | 16 | #include <qfile.h> |
10 | #include <qlayout.h> | 17 | #include <qlayout.h> |
11 | #include <qmessagebox.h> | 18 | #include <qmessagebox.h> |
12 | #include <qtimer.h> | 19 | #include <qtimer.h> |
13 | #include <qpe/qpeapplication.h> | ||
14 | #include <qpe/config.h> | ||
15 | #include <qmenubar.h> | 20 | #include <qmenubar.h> |
16 | #include <qpe/resource.h> | ||
17 | 21 | ||
18 | #include <stdlib.h> | 22 | #include <stdlib.h> |
19 | 23 | ||
20 | 24 | ||
21 | BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) | 25 | BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) |
22 | : QMainWindow(parent, name, fl) | 26 | : QMainWindow(parent, name, fl) |
23 | { | 27 | { |
24 | if (!name) setName("BackGammon"); | 28 | if (!name) setName("BackGammon"); |
25 | setCaption(tr( "Backgammon") ); | 29 | setCaption(tr( "Backgammon") ); |
26 | setIcon( Resource::loadPixmap( "backgammon" ) ); | 30 | setIcon( Resource::loadPixmap( "backgammon" ) ); |
27 | //general counter varaible | 31 | //general counter varaible |
28 | int a=0; | 32 | int a=0; |
29 | //the game engine | 33 | //the game engine |
30 | move=new MoveEngine(); | 34 | move=new MoveEngine(); |
31 | 35 | ||
32 | //load the default theme | 36 | //load the default theme |
33 | Config conf("backgammon"); | 37 | Config conf("backgammon"); |
34 | if(!conf.isValid()) | 38 | if(!conf.isValid()) |
35 | { | 39 | { |
36 | qDebug("config file does not exist"); | 40 | odebug << "config file does not exist" << oendl; |
37 | conf.setGroup("general"); | 41 | conf.setGroup("general"); |
38 | conf.writeEntry("theme","default"); | 42 | conf.writeEntry("theme","default"); |
39 | conf.setGroup("rules"); | 43 | conf.setGroup("rules"); |
40 | conf.writeEntry("move_with_pieces_out",false); | 44 | conf.writeEntry("move_with_pieces_out",false); |
41 | conf.writeEntry("nice_dice",false); | 45 | conf.writeEntry("nice_dice",false); |
42 | conf.setGroup("display"); | 46 | conf.setGroup("display"); |
43 | conf.writeEntry("small",false); | 47 | conf.writeEntry("small",false); |
44 | conf.writeEntry("warning",true); | 48 | conf.writeEntry("warning",true); |
45 | conf.setGroup("ai"); | 49 | conf.setGroup("ai"); |
46 | conf.writeEntry("rescue",6); | 50 | conf.writeEntry("rescue",6); |
47 | conf.writeEntry("eliminate",4); | 51 | conf.writeEntry("eliminate",4); |
48 | conf.writeEntry("expose",1); | 52 | conf.writeEntry("expose",1); |
49 | conf.writeEntry("protect",5); | 53 | conf.writeEntry("protect",5); |
50 | conf.writeEntry("safe",3); | 54 | conf.writeEntry("safe",3); |
51 | conf.writeEntry("empty",2); | 55 | conf.writeEntry("empty",2); |
52 | 56 | ||
53 | } | 57 | } |
54 | conf.setGroup("general"); | 58 | conf.setGroup("general"); |
55 | theme_name=conf.readEntry("theme","default"); | 59 | theme_name=conf.readEntry("theme","default"); |
56 | QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme"; | 60 | QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme"; |
57 | 61 | ||
58 | //the rules | 62 | //the rules |
59 | conf.setGroup("rules"); | 63 | conf.setGroup("rules"); |
60 | rules.move_with_pieces_out=conf.readBoolEntry("move_with_pieces_out",false); | 64 | rules.move_with_pieces_out=conf.readBoolEntry("move_with_pieces_out",false); |
61 | rules.generous_dice=conf.readBoolEntry("nice_dice",false); | 65 | rules.generous_dice=conf.readBoolEntry("nice_dice",false); |
62 | 66 | ||
63 | move->setRules(rules); | 67 | move->setRules(rules); |
64 | 68 | ||
65 | //get the AI settings | 69 | //get the AI settings |
66 | AISettings ai; | 70 | AISettings ai; |
67 | conf.setGroup("ai"); | 71 | conf.setGroup("ai"); |
68 | ai.rescue=conf.readNumEntry("rescue",6); | 72 | ai.rescue=conf.readNumEntry("rescue",6); |
69 | ai.eliminate=conf.readNumEntry("eliminate",4); | 73 | ai.eliminate=conf.readNumEntry("eliminate",4); |
70 | ai.expose=conf.readNumEntry("expose",1); | 74 | ai.expose=conf.readNumEntry("expose",1); |
71 | ai.protect=conf.readNumEntry("protect",5); | 75 | ai.protect=conf.readNumEntry("protect",5); |
72 | ai.safe=conf.readNumEntry("safe",3); | 76 | ai.safe=conf.readNumEntry("safe",3); |
73 | ai.empty=conf.readNumEntry("empty",2); | 77 | ai.empty=conf.readNumEntry("empty",2); |
74 | move->setAISettings(ai); | 78 | move->setAISettings(ai); |
75 | 79 | ||
76 | 80 | ||
77 | //get the theme component names | 81 | //get the theme component names |
78 | Config theme(theme_file,Config::File); | 82 | Config theme(theme_file,Config::File); |
79 | if(!theme.isValid()) | 83 | if(!theme.isValid()) |
80 | { | 84 | { |
81 | qDebug("theme file does not exist"); | 85 | odebug << "theme file does not exist" << oendl; |
82 | theme.setGroup("theme"); | 86 | theme.setGroup("theme"); |
83 | theme.writeEntry("board","casino_board_1"); | 87 | theme.writeEntry("board","casino_board_1"); |
84 | theme.writeEntry("pieces1","casino_pieces_blue"); | 88 | theme.writeEntry("pieces1","casino_pieces_blue"); |
85 | theme.writeEntry("pieces2","casino_pieces_white"); | 89 | theme.writeEntry("pieces2","casino_pieces_white"); |
86 | theme.writeEntry("dice1","casino_dice"); | 90 | theme.writeEntry("dice1","casino_dice"); |
87 | theme.writeEntry("dice2","casino_dice"); | 91 | theme.writeEntry("dice2","casino_dice"); |
88 | theme.writeEntry("table","casino_table_green"); | 92 | theme.writeEntry("table","casino_table_green"); |
89 | theme.writeEntry("odds","casino_odds"); | 93 | theme.writeEntry("odds","casino_odds"); |
90 | } | 94 | } |
91 | theme.setGroup("theme"); | 95 | theme.setGroup("theme"); |
92 | board_name=theme.readEntry("board","casino_board_1"); | 96 | board_name=theme.readEntry("board","casino_board_1"); |
93 | piecesA_name=theme.readEntry("pieces1","casino_pieces_blue"); | 97 | piecesA_name=theme.readEntry("pieces1","casino_pieces_blue"); |
94 | piecesB_name=theme.readEntry("pieces2","casino_pieces_white"); | 98 | piecesB_name=theme.readEntry("pieces2","casino_pieces_white"); |
95 | diceA_name=theme.readEntry("dice1","casino_dice"); | 99 | diceA_name=theme.readEntry("dice1","casino_dice"); |
96 | diceB_name=theme.readEntry("dice2","casino_dice"); | 100 | diceB_name=theme.readEntry("dice2","casino_dice"); |
97 | table_name=theme.readEntry("table","casino_table_green"); | 101 | table_name=theme.readEntry("table","casino_table_green"); |
98 | odds_name=theme.readEntry("odds","casino_odds"); | 102 | odds_name=theme.readEntry("odds","casino_odds"); |
99 | 103 | ||
100 | 104 | ||
101 | //the menu | 105 | //the menu |
102 | QMenuBar* menuBar = new QMenuBar(this); | 106 | QMenuBar* menuBar = new QMenuBar(this); |
103 | 107 | ||
104 | QPopupMenu* gamemenu= new QPopupMenu(this); | 108 | QPopupMenu* gamemenu= new QPopupMenu(this); |
105 | gamemenu->insertItem(tr( "New" ),this,SLOT(newgame())); | 109 | gamemenu->insertItem(tr( "New" ),this,SLOT(newgame())); |