author | waspe <waspe> | 2003-05-16 16:34:55 (UTC) |
---|---|---|
committer | waspe <waspe> | 2003-05-16 16:34:55 (UTC) |
commit | 11b6ce5ac500dce757ccdd0a5f5b5ecd7fb866c8 (patch) (unidiff) | |
tree | 3013dbafcb4e1f919e104204d1288f0309da5641 /noncore/games | |
parent | 75f1e9815410e75a6f9ae76d8db716c0c315ea45 (diff) | |
download | opie-11b6ce5ac500dce757ccdd0a5f5b5ecd7fb866c8.zip opie-11b6ce5ac500dce757ccdd0a5f5b5ecd7fb866c8.tar.gz opie-11b6ce5ac500dce757ccdd0a5f5b5ecd7fb866c8.tar.bz2 |
*** empty log message ***
-rw-r--r-- | noncore/games/backgammon/backgammon.cpp | 131 | ||||
-rw-r--r-- | noncore/games/backgammon/backgammon.h | 32 | ||||
-rw-r--r-- | noncore/games/backgammon/backgammonview.cpp | 14 | ||||
-rw-r--r-- | noncore/games/backgammon/backgammonview.h | 10 | ||||
-rw-r--r-- | noncore/games/backgammon/definition.cpp | 1 | ||||
-rw-r--r-- | noncore/games/backgammon/displaydialog.cpp | 89 | ||||
-rw-r--r-- | noncore/games/backgammon/displaydialog.h | 30 | ||||
-rw-r--r-- | noncore/games/backgammon/moveengine.cpp | 2 | ||||
-rw-r--r-- | noncore/games/backgammon/moveengine.h | 2 | ||||
-rw-r--r-- | noncore/games/backgammon/rulesdialog.h | 1 |
10 files changed, 56 insertions, 256 deletions
diff --git a/noncore/games/backgammon/backgammon.cpp b/noncore/games/backgammon/backgammon.cpp index 38ccb49..c40f462 100644 --- a/noncore/games/backgammon/backgammon.cpp +++ b/noncore/games/backgammon/backgammon.cpp | |||
@@ -1,69 +1,49 @@ | |||
1 | #include "backgammon.h" | 1 | #include "backgammon.h" |
2 | 2 | ||
3 | #include "aidialog.h" | 3 | #include "aidialog.h" |
4 | #include "displaydialog.h" | ||
5 | #include "filedialog.h" | 4 | #include "filedialog.h" |
6 | #include "playerdialog.h" | 5 | #include "playerdialog.h" |
7 | #include "rulesdialog.h" | 6 | #include "rulesdialog.h" |
8 | #include "themedialog.h" | 7 | #include "themedialog.h" |
9 | 8 | ||
10 | #include <qdatetime.h> | 9 | #include <qdatetime.h> |
11 | #include <qfile.h> | 10 | #include <qfile.h> |
11 | #include <qlayout.h> | ||
12 | #include <qmessagebox.h> | 12 | #include <qmessagebox.h> |
13 | #include <qstring.h> | 13 | #include <qstring.h> |
14 | #include <qtimer.h> | 14 | #include <qtimer.h> |
15 | #include <qmainwindow.h> | ||
15 | #include <qpe/qpeapplication.h> | 16 | #include <qpe/qpeapplication.h> |
16 | #include <qpe/config.h> | 17 | #include <qpe/config.h> |
17 | #include <qpe/qpemenubar.h> | 18 | #include <qpe/qpemenubar.h> |
18 | #include <qpe/resource.h> | 19 | #include <qpe/resource.h> |
19 | 20 | ||
20 | #include <stdlib.h> | 21 | #include <stdlib.h> |
21 | 22 | ||
22 | BackGammonView::BackGammonView(QCanvas* canvas,QWidget* parent) | ||
23 | :QCanvasView(canvas,parent) | ||
24 | { | ||
25 | //do nothing | ||
26 | } | ||
27 | |||
28 | |||
29 | |||
30 | BackGammonView::~BackGammonView() | ||
31 | { | ||
32 | //do nothing | ||
33 | } | ||
34 | |||
35 | |||
36 | |||
37 | void BackGammonView::contentsMousePressEvent(QMouseEvent* e) | ||
38 | { | ||
39 | int x=e->x(); | ||
40 | int y=e->y(); | ||
41 | emit mouse(x,y); | ||
42 | } | ||
43 | 23 | ||
44 | BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) | 24 | BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) |
45 | : QWidget(parent, name, fl) | 25 | : QMainWindow(parent, name, fl) |
46 | { | 26 | { |
47 | if (!name) setName("BackGammon"); | 27 | if (!name) setName("BackGammon"); |
48 | setCaption("Backgammon"); | 28 | setCaption("Backgammon"); |
49 | setIcon( Resource::loadPixmap( "backgammon" ) ); | 29 | setIcon( Resource::loadPixmap( "backgammon" ) ); |
50 | //general counter varaible | 30 | //general counter varaible |
51 | int a=0; | 31 | int a=0; |
52 | //the game engine | 32 | //the game engine |
53 | move=new MoveEngine(); | 33 | move=new MoveEngine(); |
54 | 34 | ||
55 | //load the default theme | 35 | //load the default theme |
56 | Config conf("backgammon"); | 36 | Config conf("backgammon"); |
57 | if(!conf.isValid()) | 37 | if(!conf.isValid()) |
58 | { | 38 | { |
59 | qDebug("config file does not exist"); | 39 | qDebug("config file does not exist"); |
60 | conf.setGroup("general"); | 40 | conf.setGroup("general"); |
61 | conf.writeEntry("theme","default"); | 41 | conf.writeEntry("theme","default"); |
62 | conf.setGroup("rules"); | 42 | conf.setGroup("rules"); |
63 | conf.writeEntry("move_with_pieces_out",false); | 43 | conf.writeEntry("move_with_pieces_out",false); |
64 | conf.writeEntry("nice_dice",false); | 44 | conf.writeEntry("nice_dice",false); |
65 | conf.setGroup("display"); | 45 | conf.setGroup("display"); |
66 | conf.writeEntry("small",false); | 46 | conf.writeEntry("small",false); |
67 | conf.writeEntry("warning",true); | 47 | conf.writeEntry("warning",true); |
68 | conf.setGroup("ai"); | 48 | conf.setGroup("ai"); |
69 | conf.writeEntry("rescue",6); | 49 | conf.writeEntry("rescue",6); |
@@ -75,63 +55,48 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) | |||
75 | 55 | ||
76 | } | 56 | } |
77 | conf.setGroup("general"); | 57 | conf.setGroup("general"); |
78 | theme_name=conf.readEntry("theme","default"); | 58 | theme_name=conf.readEntry("theme","default"); |
79 | QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme"; | 59 | QString theme_file=QPEApplication::qpeDir()+"/backgammon/"+theme_name+".theme"; |
80 | 60 | ||
81 | //the rules | 61 | //the rules |
82 | conf.setGroup("rules"); | 62 | conf.setGroup("rules"); |
83 | rules.move_with_pieces_out=conf.readBoolEntry("move_with_pieces_out",false); | 63 | rules.move_with_pieces_out=conf.readBoolEntry("move_with_pieces_out",false); |
84 | rules.generous_dice=conf.readBoolEntry("nice_dice",false); | 64 | rules.generous_dice=conf.readBoolEntry("nice_dice",false); |
85 | 65 | ||
86 | move->setRules(rules); | 66 | move->setRules(rules); |
87 | 67 | ||
88 | //get the AI settings | 68 | //get the AI settings |
89 | AISettings ai; | 69 | AISettings ai; |
90 | conf.setGroup("ai"); | 70 | conf.setGroup("ai"); |
91 | ai.rescue=conf.readNumEntry("rescue",6); | 71 | ai.rescue=conf.readNumEntry("rescue",6); |
92 | ai.eliminate=conf.readNumEntry("eliminate",4); | 72 | ai.eliminate=conf.readNumEntry("eliminate",4); |
93 | ai.expose=conf.readNumEntry("expose",1); | 73 | ai.expose=conf.readNumEntry("expose",1); |
94 | ai.protect=conf.readNumEntry("protect",5); | 74 | ai.protect=conf.readNumEntry("protect",5); |
95 | ai.safe=conf.readNumEntry("safe",3); | 75 | ai.safe=conf.readNumEntry("safe",3); |
96 | ai.empty=conf.readNumEntry("empty",2); | 76 | ai.empty=conf.readNumEntry("empty",2); |
97 | move->setAISettings(ai); | 77 | move->setAISettings(ai); |
98 | 78 | ||
99 | //non qte styles are smaller | ||
100 | conf.setGroup("display"); | ||
101 | display.small=conf.readBoolEntry("small",false); | ||
102 | display.warning=conf.readBoolEntry("warning",true); | ||
103 | non_qte=display.small; | ||
104 | if(display.warning) | ||
105 | { | ||
106 | Config test("qpe"); | ||
107 | test.setGroup("Appearance"); | ||
108 | if(test.readEntry("Style")!="QPE") | ||
109 | { | ||
110 | displaySettings(); | ||
111 | } | ||
112 | } | ||
113 | offset=(non_qte) ? 5 : 0; | ||
114 | 79 | ||
115 | //get the theme component names | 80 | //get the theme component names |
116 | Config theme(theme_file,Config::File); | 81 | Config theme(theme_file,Config::File); |
117 | if(!theme.isValid()) | 82 | if(!theme.isValid()) |
118 | { | 83 | { |
119 | qDebug("theme file does not exist"); | 84 | qDebug("theme file does not exist"); |
120 | theme.setGroup("theme"); | 85 | theme.setGroup("theme"); |
121 | theme.writeEntry("board","casino_board_1"); | 86 | theme.writeEntry("board","casino_board_1"); |
122 | theme.writeEntry("pieces1","casino_pieces_blue"); | 87 | theme.writeEntry("pieces1","casino_pieces_blue"); |
123 | theme.writeEntry("pieces2","casino_pieces_white"); | 88 | theme.writeEntry("pieces2","casino_pieces_white"); |
124 | theme.writeEntry("dice1","casino_dice"); | 89 | theme.writeEntry("dice1","casino_dice"); |
125 | theme.writeEntry("dice2","casino_dice"); | 90 | theme.writeEntry("dice2","casino_dice"); |
126 | theme.writeEntry("table","casino_table_green"); | 91 | theme.writeEntry("table","casino_table_green"); |
127 | theme.writeEntry("odds","casino_odds"); | 92 | theme.writeEntry("odds","casino_odds"); |
128 | } | 93 | } |
129 | theme.setGroup("theme"); | 94 | theme.setGroup("theme"); |
130 | board_name=theme.readEntry("board","casino_board_1"); | 95 | board_name=theme.readEntry("board","casino_board_1"); |
131 | piecesA_name=theme.readEntry("pieces1","casino_pieces_blue"); | 96 | piecesA_name=theme.readEntry("pieces1","casino_pieces_blue"); |
132 | piecesB_name=theme.readEntry("pieces2","casino_pieces_white"); | 97 | piecesB_name=theme.readEntry("pieces2","casino_pieces_white"); |
133 | diceA_name=theme.readEntry("dice1","casino_dice"); | 98 | diceA_name=theme.readEntry("dice1","casino_dice"); |
134 | diceB_name=theme.readEntry("dice2","casino_dice"); | 99 | diceB_name=theme.readEntry("dice2","casino_dice"); |
135 | table_name=theme.readEntry("table","casino_table_green"); | 100 | table_name=theme.readEntry("table","casino_table_green"); |
136 | odds_name=theme.readEntry("odds","casino_odds"); | 101 | odds_name=theme.readEntry("odds","casino_odds"); |
137 | 102 | ||
@@ -142,68 +107,63 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) | |||
142 | QPopupMenu* gamemenu= new QPopupMenu(this); | 107 | QPopupMenu* gamemenu= new QPopupMenu(this); |
143 | gamemenu->insertItem("New",this,SLOT(newgame())); | 108 | gamemenu->insertItem("New",this,SLOT(newgame())); |
144 | gamemenu->insertSeparator(); | 109 | gamemenu->insertSeparator(); |
145 | gamemenu->insertItem("Load",this,SLOT(loadgame())); | 110 | gamemenu->insertItem("Load",this,SLOT(loadgame())); |
146 | gamemenu->insertItem("Save",this,SLOT(savegame())); | 111 | gamemenu->insertItem("Save",this,SLOT(savegame())); |
147 | gamemenu->insertSeparator(); | 112 | gamemenu->insertSeparator(); |
148 | gamemenu->insertItem("Delete",this,SLOT(deletegame())); | 113 | gamemenu->insertItem("Delete",this,SLOT(deletegame())); |
149 | menuBar->insertItem("Game",gamemenu); | 114 | menuBar->insertItem("Game",gamemenu); |
150 | 115 | ||
151 | QPopupMenu* thememenu= new QPopupMenu(this); | 116 | QPopupMenu* thememenu= new QPopupMenu(this); |
152 | thememenu->insertItem("New",this,SLOT(newtheme())); | 117 | thememenu->insertItem("New",this,SLOT(newtheme())); |
153 | thememenu->insertSeparator(); | 118 | thememenu->insertSeparator(); |
154 | thememenu->insertItem("Load",this,SLOT(loadtheme())); | 119 | thememenu->insertItem("Load",this,SLOT(loadtheme())); |
155 | thememenu->insertItem("Save",this,SLOT(savetheme())); | 120 | thememenu->insertItem("Save",this,SLOT(savetheme())); |
156 | thememenu->insertSeparator(); | 121 | thememenu->insertSeparator(); |
157 | thememenu->insertItem("Default",this,SLOT(themedefault())); | 122 | thememenu->insertItem("Default",this,SLOT(themedefault())); |
158 | thememenu->insertItem("Delete",this,SLOT(deletetheme())); | 123 | thememenu->insertItem("Delete",this,SLOT(deletetheme())); |
159 | menuBar->insertItem("Theme",thememenu); | 124 | menuBar->insertItem("Theme",thememenu); |
160 | 125 | ||
161 | QPopupMenu* optionmenu=new QPopupMenu(this); | 126 | QPopupMenu* optionmenu=new QPopupMenu(this); |
162 | optionmenu->insertItem("Player",this,SLOT(playerselect())); | 127 | optionmenu->insertItem("Player",this,SLOT(playerselect())); |
163 | optionmenu->insertSeparator(); | 128 | optionmenu->insertSeparator(); |
164 | optionmenu->insertItem("AI",this,SLOT(modify_AI())); | 129 | optionmenu->insertItem("AI",this,SLOT(modify_AI())); |
165 | optionmenu->insertItem("Rules",this,SLOT(setrules())); | 130 | optionmenu->insertItem("Rules",this,SLOT(setrules())); |
166 | optionmenu->insertItem("Display",this,SLOT(displaySettings())); | ||
167 | menuBar->insertItem("Options",optionmenu); | 131 | menuBar->insertItem("Options",optionmenu); |
168 | 132 | ||
169 | //status bar | 133 | QWidget* mainarea=new QWidget(this); |
170 | message=new QLabel("<b>Backgammon</b>",this); | 134 | setCentralWidget(mainarea); |
171 | message->setGeometry(0,260,237,20); | ||
172 | message->setAlignment(AlignHCenter); | ||
173 | |||
174 | //the main area | 135 | //the main area |
175 | area=new QCanvas(235-2*offset,235-2*offset); | 136 | QBoxLayout* layout=new QBoxLayout(mainarea,QBoxLayout::TopToBottom); |
176 | boardview=new BackGammonView(area,this); | 137 | area=new QCanvas(235,235); |
138 | boardview=new BackGammonView(area,mainarea); | ||
139 | boardview->setMaximumHeight(240); | ||
140 | layout->addWidget(boardview); | ||
177 | connect(boardview,SIGNAL(mouse(int,int)),this,SLOT(mouse(int,int))); | 141 | connect(boardview,SIGNAL(mouse(int,int)),this,SLOT(mouse(int,int))); |
178 | if(non_qte) | 142 | //status bar |
179 | { | 143 | message=new QLabel("<b>Backgammon</b>",mainarea); |
180 | boardview->setGeometry(5,20,229,229); | 144 | message->setAlignment(AlignHCenter); |
181 | } | 145 | layout->addWidget(message); |
182 | else | ||
183 | { | ||
184 | boardview->setGeometry(1,20,237,237); | ||
185 | } | ||
186 | 146 | ||
187 | //the marker | 147 | //the marker |
188 | marker_current=new QCanvasRectangle(area); | 148 | marker_current=new QCanvasRectangle(area); |
189 | marker_current->setBrush(QColor(0,0,255)); | 149 | marker_current->setBrush(QColor(0,0,255)); |
190 | marker_current->setSize(15,5); | 150 | marker_current->setSize(15,5); |
191 | marker_current->setZ(1); | 151 | marker_current->setZ(1); |
192 | 152 | ||
193 | for(a=0;a<4;a++) | 153 | for(a=0;a<4;a++) |
194 | { | 154 | { |
195 | marker_next[a]=new QCanvasRectangle(area); | 155 | marker_next[a]=new QCanvasRectangle(area); |
196 | marker_next[a]->setBrush(QColor(0,255,0)); | 156 | marker_next[a]->setBrush(QColor(0,255,0)); |
197 | marker_next[a]->setSize(15,5); | 157 | marker_next[a]->setSize(15,5); |
198 | marker_next[a]->setZ(1); | 158 | marker_next[a]->setZ(1); |
199 | } | 159 | } |
200 | 160 | ||
201 | connect(move,SIGNAL(done_dice1()),this,SLOT(done_dice1())); | 161 | connect(move,SIGNAL(done_dice1()),this,SLOT(done_dice1())); |
202 | connect(move,SIGNAL(done_dice2()),this,SLOT(done_dice2())); | 162 | connect(move,SIGNAL(done_dice2()),this,SLOT(done_dice2())); |
203 | connect(move,SIGNAL(done_dice3()),this,SLOT(done_dice3())); | 163 | connect(move,SIGNAL(done_dice3()),this,SLOT(done_dice3())); |
204 | connect(move,SIGNAL(done_dice4()),this,SLOT(done_dice4())); | 164 | connect(move,SIGNAL(done_dice4()),this,SLOT(done_dice4())); |
205 | connect(move,SIGNAL(nomove()),this,SLOT(nomove())); | 165 | connect(move,SIGNAL(nomove()),this,SLOT(nomove())); |
206 | connect(move,SIGNAL(player_finished(int)),this,SLOT(finished(int))); | 166 | connect(move,SIGNAL(player_finished(int)),this,SLOT(finished(int))); |
207 | 167 | ||
208 | //the pieces | 168 | //the pieces |
209 | p1=new CanvasImageItem*[15]; | 169 | p1=new CanvasImageItem*[15]; |
@@ -227,109 +187,101 @@ BackGammon::BackGammon(QWidget* parent, const char* name, WFlags fl) | |||
227 | p1_side[a]->setSize(15,5); | 187 | p1_side[a]->setSize(15,5); |
228 | 188 | ||
229 | p2[a]=new CanvasImageItem(piece_2_front,area); | 189 | p2[a]=new CanvasImageItem(piece_2_front,area); |
230 | p2[a]->setSize(15,15); | 190 | p2[a]->setSize(15,15); |
231 | p2_side[a]=new CanvasImageItem(piece_2_side,area); | 191 | p2_side[a]=new CanvasImageItem(piece_2_side,area); |
232 | p2_side[a]->setSize(15,5); | 192 | p2_side[a]->setSize(15,5); |
233 | } | 193 | } |
234 | draw(); | 194 | draw(); |
235 | 195 | ||
236 | //the dice | 196 | //the dice |
237 | QImage dicebgA_all(Resource::loadImage("backgammon/dice/"+diceA_name)); | 197 | QImage dicebgA_all(Resource::loadImage("backgammon/dice/"+diceA_name)); |
238 | diceA1=new CanvasImageItem*[7]; | 198 | diceA1=new CanvasImageItem*[7]; |
239 | diceA2=new CanvasImageItem*[7]; | 199 | diceA2=new CanvasImageItem*[7]; |
240 | QImage dicebgB_all(Resource::loadImage("backgammon/dice/"+diceB_name)); | 200 | QImage dicebgB_all(Resource::loadImage("backgammon/dice/"+diceB_name)); |
241 | diceB1=new CanvasImageItem*[7]; | 201 | diceB1=new CanvasImageItem*[7]; |
242 | diceB2=new CanvasImageItem*[7]; | 202 | diceB2=new CanvasImageItem*[7]; |
243 | QImage oddsbg_all=(Resource::loadImage("backgammon/odds/"+odds_name)); | 203 | QImage oddsbg_all=(Resource::loadImage("backgammon/odds/"+odds_name)); |
244 | //oddsDice=new CanvasImageItem*[6]; | 204 | //oddsDice=new CanvasImageItem*[6]; |
245 | 205 | ||
246 | 206 | ||
247 | for(a=0;a<7;a++) | 207 | for(a=0;a<7;a++) |
248 | { | 208 | { |
249 | QImage dicebgA=dicebgA_all.copy(a*25,0,25,25); | 209 | QImage dicebgA=dicebgA_all.copy(a*25,0,25,25); |
250 | diceA1[a]=new CanvasImageItem(dicebgA,area); | 210 | diceA1[a]=new CanvasImageItem(dicebgA,area); |
251 | diceA1[a]->setX(5-offset); | 211 | diceA1[a]->setX(5); |
252 | diceA1[a]->setY(205-2*offset); | 212 | diceA1[a]->setY(205-2); |
253 | diceA1[a]->setZ(1); | 213 | diceA1[a]->setZ(1); |
254 | diceA1[a]->setSize(25,25); | 214 | diceA1[a]->setSize(25,25); |
255 | diceA2[a]=new CanvasImageItem(dicebgA,area); | 215 | diceA2[a]=new CanvasImageItem(dicebgA,area); |
256 | diceA2[a]->setX(35-offset); | 216 | diceA2[a]->setX(35); |
257 | diceA2[a]->setY(205-2*offset); | 217 | diceA2[a]->setY(205-2); |
258 | diceA2[a]->setZ(1); | 218 | diceA2[a]->setZ(1); |
259 | diceA2[a]->setSize(25,25); | 219 | diceA2[a]->setSize(25,25); |
260 | 220 | ||
261 | QImage dicebgB=dicebgB_all.copy(a*25,0,25,25); | 221 | QImage dicebgB=dicebgB_all.copy(a*25,0,25,25); |
262 | diceB1[a]=new CanvasImageItem(dicebgB,area); | 222 | diceB1[a]=new CanvasImageItem(dicebgB,area); |
263 | diceB1[a]->setX(175-offset); | 223 | diceB1[a]->setX(175); |
264 | diceB1[a]->setY(205-2*offset); | 224 | diceB1[a]->setY(205-2); |
265 | diceB1[a]->setZ(1); | 225 | diceB1[a]->setZ(1); |
266 | diceB1[a]->setSize(25,25); | 226 | diceB1[a]->setSize(25,25); |
267 | diceB2[a]=new CanvasImageItem(dicebgB,area); | 227 | diceB2[a]=new CanvasImageItem(dicebgB,area); |
268 | diceB2[a]->setX(205-offset); | 228 | diceB2[a]->setX(205); |
269 | diceB2[a]->setY(205-2*offset); | 229 | diceB2[a]->setY(205-2); |
270 | diceB2[a]->setZ(1); | 230 | diceB2[a]->setZ(1); |
271 | diceB2[a]->setSize(25,25); | 231 | diceB2[a]->setSize(25,25); |
272 | 232 | ||
273 | /* | 233 | /* |
274 | if(a<6) | 234 | if(a<6) |
275 | { | 235 | { |
276 | QImage oddsbg=oddsbg_all.copy(a*15,0,15,15); | 236 | QImage oddsbg=oddsbg_all.copy(a*15,0,15,15); |
277 | oddsDice[a]=new CanvasImageItem(oddsbg,area); | 237 | oddsDice[a]=new CanvasImageItem(oddsbg,area); |
278 | oddsDice[a]->setX(110-offset); | 238 | oddsDice[a]->setX(110); |
279 | oddsDice[a]->setY(210-2*offset); | 239 | oddsDice[a]->setY(210-2); |
280 | oddsDice[a]->setZ(1); | 240 | oddsDice[a]->setZ(1); |
281 | oddsDice[a]->setSize(15,15); | 241 | oddsDice[a]->setSize(15,15); |
282 | oddsDice[a]->hide(); | 242 | oddsDice[a]->hide(); |
283 | } | 243 | } |
284 | */ | 244 | */ |
285 | } | 245 | } |
286 | //oddsDice[0]->show(); | 246 | //oddsDice[0]->show(); |
287 | 247 | ||
288 | //set the board | 248 | //set the board |
289 | QImage boardbg(Resource::loadImage("backgammon/boards/"+board_name)); | 249 | QImage boardbg(Resource::loadImage("backgammon/boards/"+board_name)); |
290 | if(non_qte) | ||
291 | { | ||
292 | boardbg=boardbg.copy(offset,offset,235-2*offset,200-2*offset); | ||
293 | } | ||
294 | board=new CanvasImageItem(boardbg,area); | 250 | board=new CanvasImageItem(boardbg,area); |
295 | board->setX(0); | 251 | board->setX(0); |
296 | board->setY(0); | 252 | board->setY(0); |
297 | board->setZ(0); | 253 | board->setZ(0); |
298 | board->setSize(235-2*offset,200-2*offset); | 254 | board->setSize(235-2,200-2); |
299 | board->show(); | 255 | board->show(); |
300 | 256 | ||
301 | //the table | 257 | //the table |
302 | QImage tablebg(Resource::loadImage("backgammon/table/"+table_name)); | 258 | QImage tablebg(Resource::loadImage("backgammon/table/"+table_name)); |
303 | if(non_qte) | ||
304 | { | ||
305 | tablebg=tablebg.copy(offset,0,235-offset,200); | ||
306 | } | ||
307 | table=new CanvasImageItem(tablebg,area); | 259 | table=new CanvasImageItem(tablebg,area); |
308 | table->setX(0); | 260 | table->setX(0); |
309 | table->setY(200-2*offset); | 261 | table->setY(200-2); |
310 | table->setZ(0); | 262 | table->setZ(0); |
311 | table->setSize(235-2*offset,20); | 263 | table->setSize(235-2,20); |
312 | table->show(); | 264 | table->show(); |
313 | 265 | ||
314 | //the no move marker | 266 | //the no move marker |
315 | QImage nomovebg(Resource::loadImage("backgammon/no_move")); | 267 | QImage nomovebg(Resource::loadImage("backgammon/no_move")); |
316 | nomove_marker=new CanvasImageItem(nomovebg,area); | 268 | nomove_marker=new CanvasImageItem(nomovebg,area); |
317 | nomove_marker->setX(0); | 269 | nomove_marker->setX(0); |
318 | nomove_marker->setY(200); | 270 | nomove_marker->setY(200); |
319 | nomove_marker->setZ(2); | 271 | nomove_marker->setZ(2); |
320 | nomove_marker->hide(); | 272 | nomove_marker->hide(); |
321 | 273 | ||
322 | //default human against computer | 274 | //default human against computer |
323 | player1_auto=false; | 275 | player1_auto=false; |
324 | player2_auto=true; | 276 | player2_auto=true; |
325 | //start new game | 277 | //start new game |
326 | newgame(); | 278 | newgame(); |
327 | } | 279 | } |
328 | 280 | ||
329 | BackGammon::~BackGammon() | 281 | BackGammon::~BackGammon() |
330 | { | 282 | { |
331 | //DESTRUCTOR | 283 | //DESTRUCTOR |
332 | } | 284 | } |
333 | 285 | ||
334 | void BackGammon::newgame() | 286 | void BackGammon::newgame() |
335 | { | 287 | { |
@@ -578,66 +530,53 @@ void BackGammon::modify_AI() | |||
578 | Config conf("backgammon"); | 530 | Config conf("backgammon"); |
579 | conf.setGroup("ai"); | 531 | conf.setGroup("ai"); |
580 | conf.writeEntry("rescue",ai.rescue); | 532 | conf.writeEntry("rescue",ai.rescue); |
581 | conf.writeEntry("eliminate",ai.eliminate); | 533 | conf.writeEntry("eliminate",ai.eliminate); |
582 | conf.writeEntry("expose",ai.expose); | 534 | conf.writeEntry("expose",ai.expose); |
583 | conf.writeEntry("protect",ai.protect); | 535 | conf.writeEntry("protect",ai.protect); |
584 | conf.writeEntry("safe",ai.safe); | 536 | conf.writeEntry("safe",ai.safe); |
585 | conf.writeEntry("empty",ai.empty); | 537 | conf.writeEntry("empty",ai.empty); |
586 | } | 538 | } |
587 | 539 | ||
588 | void BackGammon::setrules() | 540 | void BackGammon::setrules() |
589 | { | 541 | { |
590 | RulesDialog* rulesdialog=new RulesDialog(this,"Load Theme",".theme"); | 542 | RulesDialog* rulesdialog=new RulesDialog(this,"Load Theme",".theme"); |
591 | rulesdialog->setRules(rules); | 543 | rulesdialog->setRules(rules); |
592 | if(!rulesdialog->exec()) | 544 | if(!rulesdialog->exec()) |
593 | return; | 545 | return; |
594 | rules=rulesdialog->getRules(); | 546 | rules=rulesdialog->getRules(); |
595 | Config conf("backgammon"); | 547 | Config conf("backgammon"); |
596 | conf.setGroup("rules"); | 548 | conf.setGroup("rules"); |
597 | conf.writeEntry("move_with_pieces_out",rules.move_with_pieces_out); | 549 | conf.writeEntry("move_with_pieces_out",rules.move_with_pieces_out); |
598 | conf.writeEntry("nice_dice",rules.generous_dice); | 550 | conf.writeEntry("nice_dice",rules.generous_dice); |
599 | move->setRules(rules); | 551 | move->setRules(rules); |
600 | } | 552 | } |
601 | 553 | ||
602 | void BackGammon::displaySettings() | ||
603 | { | ||
604 | DisplayDialog* displaydialog=new DisplayDialog(this); | ||
605 | displaydialog->setDisplaySettings(display); | ||
606 | if(!displaydialog->exec()) | ||
607 | return; | ||
608 | display=displaydialog->getDisplaySettings(); | ||
609 | Config conf("backgammon"); | ||
610 | conf.setGroup("display"); | ||
611 | conf.writeEntry("small",display.small); | ||
612 | conf.writeEntry("warning",display.warning); | ||
613 | QMessageBox::warning(this,"Backgammon","changed display settings will\nonly take place after game has\nbeen restarted","OK"); | ||
614 | } | ||
615 | 554 | ||
616 | void BackGammon::draw() | 555 | void BackGammon::draw() |
617 | { | 556 | { |
618 | Pieces pieces; | 557 | Pieces pieces; |
619 | move->position(pieces,non_qte); | 558 | move->position(pieces); |
620 | for(int a=0;a<15;a++) | 559 | for(int a=0;a<15;a++) |
621 | { | 560 | { |
622 | if(!pieces.player1[a].side) | 561 | if(!pieces.player1[a].side) |
623 | { | 562 | { |
624 | p1[a]->setX(pieces.player1[a].x); | 563 | p1[a]->setX(pieces.player1[a].x); |
625 | p1[a]->setY(pieces.player1[a].y); | 564 | p1[a]->setY(pieces.player1[a].y); |
626 | p1[a]->setZ(pieces.player1[a].z); | 565 | p1[a]->setZ(pieces.player1[a].z); |
627 | p1[a]->show(); | 566 | p1[a]->show(); |
628 | p1_side[a]->hide(); | 567 | p1_side[a]->hide(); |
629 | } | 568 | } |
630 | else | 569 | else |
631 | { | 570 | { |
632 | p1_side[a]->setX(pieces.player1[a].x); | 571 | p1_side[a]->setX(pieces.player1[a].x); |
633 | p1_side[a]->setY(pieces.player1[a].y); | 572 | p1_side[a]->setY(pieces.player1[a].y); |
634 | p1_side[a]->setZ(pieces.player1[a].z); | 573 | p1_side[a]->setZ(pieces.player1[a].z); |
635 | p1_side[a]->show(); | 574 | p1_side[a]->show(); |
636 | p1[a]->hide(); | 575 | p1[a]->hide(); |
637 | } | 576 | } |
638 | 577 | ||
639 | if(!pieces.player2[a].side) | 578 | if(!pieces.player2[a].side) |
640 | { | 579 | { |
641 | p2[a]->setX(pieces.player2[a].x); | 580 | p2[a]->setX(pieces.player2[a].x); |
642 | p2[a]->setY(pieces.player2[a].y); | 581 | p2[a]->setY(pieces.player2[a].y); |
643 | p2[a]->setZ(pieces.player2[a].z); | 582 | p2[a]->setZ(pieces.player2[a].z); |
@@ -648,65 +587,65 @@ void BackGammon::draw() | |||
648 | { | 587 | { |
649 | p2_side[a]->setX(pieces.player2[a].x); | 588 | p2_side[a]->setX(pieces.player2[a].x); |
650 | p2_side[a]->setY(pieces.player2[a].y); | 589 | p2_side[a]->setY(pieces.player2[a].y); |
651 | p2_side[a]->setZ(pieces.player2[a].z); | 590 | p2_side[a]->setZ(pieces.player2[a].z); |
652 | p2_side[a]->show(); | 591 | p2_side[a]->show(); |
653 | p2[a]->hide(); | 592 | p2[a]->hide(); |
654 | } | 593 | } |
655 | } | 594 | } |
656 | } | 595 | } |
657 | 596 | ||
658 | void BackGammon::mouse(int x,int y) | 597 | void BackGammon::mouse(int x,int y) |
659 | { | 598 | { |
660 | if(gameFinished) | 599 | if(gameFinished) |
661 | { | 600 | { |
662 | newgame(); | 601 | newgame(); |
663 | return; | 602 | return; |
664 | } | 603 | } |
665 | if(y<=200) //move pieces | 604 | if(y<=200) //move pieces |
666 | { | 605 | { |
667 | if((player==1 && player1_auto) || (player==2 && player2_auto)) | 606 | if((player==1 && player1_auto) || (player==2 && player2_auto)) |
668 | return; | 607 | return; |
669 | 608 | ||
670 | Marker marker; | 609 | Marker marker; |
671 | 610 | ||
672 | move->boardpressed(x,y,marker,non_qte); | 611 | move->boardpressed(x,y,marker); |
673 | if(marker.visible_current) | 612 | if(marker.visible_current) |
674 | { | 613 | { |
675 | marker_current->setX(marker.x_current-offset); | 614 | marker_current->setX(marker.x_current); |
676 | marker_current->setY(marker.y_current); | 615 | marker_current->setY(marker.y_current); |
677 | marker_current->show(); | 616 | marker_current->show(); |
678 | } | 617 | } |
679 | else | 618 | else |
680 | { | 619 | { |
681 | marker_current->hide(); | 620 | marker_current->hide(); |
682 | } | 621 | } |
683 | 622 | ||
684 | for(int a=0;a<4;a++) | 623 | for(int a=0;a<4;a++) |
685 | { | 624 | { |
686 | if(marker.visible_next[a]) | 625 | if(marker.visible_next[a]) |
687 | { | 626 | { |
688 | marker_next[a]->setX(marker.x_next[a]-offset); | 627 | marker_next[a]->setX(marker.x_next[a]); |
689 | marker_next[a]->setY(marker.y_next[a]); | 628 | marker_next[a]->setY(marker.y_next[a]); |
690 | marker_next[a]->show(); | 629 | marker_next[a]->show(); |
691 | } | 630 | } |
692 | else | 631 | else |
693 | { | 632 | { |
694 | marker_next[a]->hide(); | 633 | marker_next[a]->hide(); |
695 | } | 634 | } |
696 | } | 635 | } |
697 | area->update(); | 636 | area->update(); |
698 | } | 637 | } |
699 | else //roll dice | 638 | else //roll dice |
700 | { | 639 | { |
701 | if(x>=10 && x<=65 && player==1 && !dice_rolled) | 640 | if(x>=10 && x<=65 && player==1 && !dice_rolled) |
702 | { | 641 | { |
703 | dice1_played=false; | 642 | dice1_played=false; |
704 | dice2_played=false; | 643 | dice2_played=false; |
705 | dice3_played=false; | 644 | dice3_played=false; |
706 | dice4_played=false; | 645 | dice4_played=false; |
707 | dice_rolled=true; | 646 | dice_rolled=true; |
708 | srand(QTime::currentTime().msec()); | 647 | srand(QTime::currentTime().msec()); |
709 | diceA1_value=1+(int) (6.0*rand()/(RAND_MAX+1.0)); | 648 | diceA1_value=1+(int) (6.0*rand()/(RAND_MAX+1.0)); |
710 | diceA2_value=1+(int) (6.0*rand()/(RAND_MAX+1.0)); | 649 | diceA2_value=1+(int) (6.0*rand()/(RAND_MAX+1.0)); |
711 | if(diceA1_value==diceA2_value) | 650 | if(diceA1_value==diceA2_value) |
712 | { | 651 | { |
@@ -964,59 +903,51 @@ void BackGammon::setplayer() | |||
964 | } | 903 | } |
965 | else if(dice1_played && dice2_played && dice3_played && dice4_played && player==2) | 904 | else if(dice1_played && dice2_played && dice3_played && dice4_played && player==2) |
966 | { | 905 | { |
967 | message->setText("<b>P1 turn</b>"); | 906 | message->setText("<b>P1 turn</b>"); |
968 | dice_rolled=false; | 907 | dice_rolled=false; |
969 | player=1; | 908 | player=1; |
970 | if(player1_auto) | 909 | if(player1_auto) |
971 | QTimer::singleShot(2000,this,SLOT(autoroll_dice1())); | 910 | QTimer::singleShot(2000,this,SLOT(autoroll_dice1())); |
972 | } | 911 | } |
973 | } | 912 | } |
974 | 913 | ||
975 | void BackGammon::autoroll_dice1() | 914 | void BackGammon::autoroll_dice1() |
976 | { | 915 | { |
977 | mouse(20,210); | 916 | mouse(20,210); |
978 | } | 917 | } |
979 | 918 | ||
980 | void BackGammon::autoroll_dice2() | 919 | void BackGammon::autoroll_dice2() |
981 | { | 920 | { |
982 | mouse(170,210); | 921 | mouse(170,210); |
983 | } | 922 | } |
984 | 923 | ||
985 | void BackGammon::applytheme() | 924 | void BackGammon::applytheme() |
986 | { | 925 | { |
987 | QImage boardbg(Resource::loadImage("backgammon/boards/"+board_name)); | 926 | QImage boardbg(Resource::loadImage("backgammon/boards/"+board_name)); |
988 | if(non_qte) | ||
989 | { | ||
990 | boardbg=boardbg.copy(offset,offset,235-2*offset,200-2*offset); | ||
991 | } | ||
992 | board->setImage(boardbg); | 927 | board->setImage(boardbg); |
993 | 928 | ||
994 | QImage tablebg(Resource::loadImage("backgammon/table/"+table_name)); | 929 | QImage tablebg(Resource::loadImage("backgammon/table/"+table_name)); |
995 | if(non_qte) | ||
996 | { | ||
997 | tablebg=tablebg.copy(offset,0,235-offset,200); | ||
998 | } | ||
999 | table->setImage(tablebg); | 930 | table->setImage(tablebg); |
1000 | 931 | ||
1001 | QImage piece_1_all(Resource::loadImage("backgammon/pieces/"+piecesA_name)); | 932 | QImage piece_1_all(Resource::loadImage("backgammon/pieces/"+piecesA_name)); |
1002 | QImage piece_1_front=piece_1_all.copy(0,0,15,15); | 933 | QImage piece_1_front=piece_1_all.copy(0,0,15,15); |
1003 | QImage piece_1_side=piece_1_all.copy(0,15,15,5); | 934 | QImage piece_1_side=piece_1_all.copy(0,15,15,5); |
1004 | 935 | ||
1005 | QImage piece_2_all(Resource::loadImage("backgammon/pieces/"+piecesB_name)); | 936 | QImage piece_2_all(Resource::loadImage("backgammon/pieces/"+piecesB_name)); |
1006 | QImage piece_2_front=piece_2_all.copy(0,0,15,15); | 937 | QImage piece_2_front=piece_2_all.copy(0,0,15,15); |
1007 | QImage piece_2_side=piece_2_all.copy(0,15,15,5); | 938 | QImage piece_2_side=piece_2_all.copy(0,15,15,5); |
1008 | 939 | ||
1009 | int a=0; | 940 | int a=0; |
1010 | for(a=0;a<15;a++) | 941 | for(a=0;a<15;a++) |
1011 | { | 942 | { |
1012 | p1[a]->setImage(piece_1_front); | 943 | p1[a]->setImage(piece_1_front); |
1013 | p1_side[a]->setImage(piece_1_side); | 944 | p1_side[a]->setImage(piece_1_side); |
1014 | 945 | ||
1015 | p2[a]->setImage(piece_2_front); | 946 | p2[a]->setImage(piece_2_front); |
1016 | p2_side[a]->setImage(piece_2_side); | 947 | p2_side[a]->setImage(piece_2_side); |
1017 | } | 948 | } |
1018 | draw(); | 949 | draw(); |
1019 | 950 | ||
1020 | QImage dicebgA_all(Resource::loadImage("backgammon/dice/"+diceA_name)); | 951 | QImage dicebgA_all(Resource::loadImage("backgammon/dice/"+diceA_name)); |
1021 | QImage dicebgB_all(Resource::loadImage("backgammon/dice/"+diceB_name)); | 952 | QImage dicebgB_all(Resource::loadImage("backgammon/dice/"+diceB_name)); |
1022 | QImage oddsbg_all=(Resource::loadImage("backgammon/odds/"+odds_name)); | 953 | QImage oddsbg_all=(Resource::loadImage("backgammon/odds/"+odds_name)); |
diff --git a/noncore/games/backgammon/backgammon.h b/noncore/games/backgammon/backgammon.h index 40dbaba..e3276f1 100644 --- a/noncore/games/backgammon/backgammon.h +++ b/noncore/games/backgammon/backgammon.h | |||
@@ -1,80 +1,67 @@ | |||
1 | #ifndef BACKGAMMON_H | 1 | #ifndef BACKGAMMON_H |
2 | #define BACKGAMMON_H | 2 | #define BACKGAMMON_H |
3 | 3 | ||
4 | #include "backgammonview.h" | ||
4 | #include "canvasimageitem.h" | 5 | #include "canvasimageitem.h" |
5 | #include "definition.h" | ||
6 | //#include "rulesdialog.h" | 6 | //#include "rulesdialog.h" |
7 | #include "moveengine.h" | 7 | #include "moveengine.h" |
8 | 8 | ||
9 | #include <qcanvas.h> | 9 | |
10 | #include <qlabel.h> | 10 | #include <qlabel.h> |
11 | #include <qlineedit.h> | 11 | #include <qmainwindow.h> |
12 | #include <qwidget.h> | 12 | //#include <qwidget.h> |
13 | 13 | ||
14 | 14 | ||
15 | class BackGammonView : public QCanvasView | ||
16 | { | ||
17 | Q_OBJECT | ||
18 | public: | ||
19 | BackGammonView(QCanvas* canvas,QWidget* parent); | ||
20 | ~BackGammonView(); | ||
21 | signals: | ||
22 | void mouse(int,int); | ||
23 | private: | ||
24 | void contentsMousePressEvent(QMouseEvent* e); | ||
25 | }; | ||
26 | 15 | ||
27 | class BackGammon : public QWidget | 16 | |
17 | class BackGammon : public QMainWindow | ||
28 | { | 18 | { |
29 | Q_OBJECT | 19 | Q_OBJECT |
30 | private: | 20 | private: |
31 | //GUI | 21 | //GUI |
32 | //is the style not qte ? | ||
33 | bool non_qte; | ||
34 | int offset; | ||
35 | //the "status" bar | 22 | //the "status" bar |
36 | QLineEdit* inputfield; | 23 | QLabel* message; |
37 | //the main drawing area | 24 | //the main drawing area |
38 | QCanvas* area; | 25 | QCanvas* area; |
39 | BackGammonView* boardview; | 26 | BackGammonView* boardview; |
40 | CanvasImageItem* board; | 27 | CanvasImageItem* board; |
41 | CanvasImageItem* table; | 28 | CanvasImageItem* table; |
42 | CanvasImageItem** p1; | 29 | CanvasImageItem** p1; |
43 | CanvasImageItem** p2; | 30 | CanvasImageItem** p2; |
44 | CanvasImageItem** p1_side; | 31 | CanvasImageItem** p1_side; |
45 | CanvasImageItem** p2_side; | 32 | CanvasImageItem** p2_side; |
46 | 33 | ||
47 | CanvasImageItem** diceA1; | 34 | CanvasImageItem** diceA1; |
48 | CanvasImageItem** diceA2; | 35 | CanvasImageItem** diceA2; |
49 | CanvasImageItem** diceB1; | 36 | CanvasImageItem** diceB1; |
50 | CanvasImageItem** diceB2; | 37 | CanvasImageItem** diceB2; |
51 | //CanvasImageItem** oddsDice; | 38 | //CanvasImageItem** oddsDice; |
52 | CanvasImageItem* nomove_marker; | 39 | CanvasImageItem* nomove_marker; |
53 | 40 | ||
54 | QCanvasRectangle* marker_current; | 41 | QCanvasRectangle* marker_current; |
55 | QCanvasRectangle* marker_next[4]; | 42 | QCanvasRectangle* marker_next[4]; |
56 | QLabel* message; | 43 | |
57 | //ENGINE | 44 | //ENGINE |
58 | MoveEngine* move; | 45 | MoveEngine* move; |
59 | //the dice values | 46 | //the dice values |
60 | int diceA1_value; | 47 | int diceA1_value; |
61 | int diceA2_value; | 48 | int diceA2_value; |
62 | int diceA3_value; | 49 | int diceA3_value; |
63 | int diceA4_value; | 50 | int diceA4_value; |
64 | int diceB1_value; | 51 | int diceB1_value; |
65 | int diceB2_value; | 52 | int diceB2_value; |
66 | int diceB3_value; | 53 | int diceB3_value; |
67 | int diceB4_value; | 54 | int diceB4_value; |
68 | 55 | ||
69 | int player; | 56 | int player; |
70 | bool dice1_played; | 57 | bool dice1_played; |
71 | bool dice2_played; | 58 | bool dice2_played; |
72 | bool dice3_played; | 59 | bool dice3_played; |
73 | bool dice4_played; | 60 | bool dice4_played; |
74 | bool dice_rolled; | 61 | bool dice_rolled; |
75 | //computer opponent | 62 | //computer opponent |
76 | bool player1_auto; | 63 | bool player1_auto; |
77 | bool player2_auto; | 64 | bool player2_auto; |
78 | 65 | ||
79 | //the images; | 66 | //the images; |
80 | QString theme_name; | 67 | QString theme_name; |
@@ -92,43 +79,42 @@ private: | |||
92 | //the rules | 79 | //the rules |
93 | Rules rules; | 80 | Rules rules; |
94 | 81 | ||
95 | //display settings | 82 | //display settings |
96 | Display display; | 83 | Display display; |
97 | //is the game finished ? | 84 | //is the game finished ? |
98 | bool gameFinished; | 85 | bool gameFinished; |
99 | 86 | ||
100 | public: | 87 | public: |
101 | BackGammon( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 88 | BackGammon( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
102 | ~BackGammon(); | 89 | ~BackGammon(); |
103 | private slots: | 90 | private slots: |
104 | void newgame(); | 91 | void newgame(); |
105 | void playerselect(); | 92 | void playerselect(); |
106 | void loadgame(); | 93 | void loadgame(); |
107 | void savegame(); | 94 | void savegame(); |
108 | void deletegame(); | 95 | void deletegame(); |
109 | void newtheme(); | 96 | void newtheme(); |
110 | void loadtheme(); | 97 | void loadtheme(); |
111 | void savetheme(); | 98 | void savetheme(); |
112 | void themedefault(); | 99 | void themedefault(); |
113 | void deletetheme(); | 100 | void deletetheme(); |
114 | void modify_AI(); | 101 | void modify_AI(); |
115 | void setrules(); | 102 | void setrules(); |
116 | void displaySettings(); | ||
117 | void mouse(int x,int y); | 103 | void mouse(int x,int y); |
118 | void done_dice1(); | 104 | void done_dice1(); |
119 | void done_dice2(); | 105 | void done_dice2(); |
120 | void done_dice3(); | 106 | void done_dice3(); |
121 | void done_dice4(); | 107 | void done_dice4(); |
122 | void nomove(); | 108 | void nomove(); |
123 | void nomove2(); | 109 | void nomove2(); |
124 | void finished(int theplayer); | 110 | void finished(int theplayer); |
125 | void autoroll_dice1(); | 111 | void autoroll_dice1(); |
126 | void autoroll_dice2(); | 112 | void autoroll_dice2(); |
127 | private: | 113 | private: |
128 | void draw(); | 114 | void draw(); |
129 | void showdice(); | 115 | void showdice(); |
130 | void setplayer(); | 116 | void setplayer(); |
131 | void applytheme(); | 117 | void applytheme(); |
132 | }; | 118 | }; |
133 | 119 | ||
134 | #endif //BACKGAMMON_H | 120 | #endif //BACKGAMMON_H |
diff --git a/noncore/games/backgammon/backgammonview.cpp b/noncore/games/backgammon/backgammonview.cpp index ecbc12b..6ee8f10 100644 --- a/noncore/games/backgammon/backgammonview.cpp +++ b/noncore/games/backgammon/backgammonview.cpp | |||
@@ -1,17 +1,23 @@ | |||
1 | #include "backgammonview.h" | 1 | #include "backgammonview.h" |
2 | 2 | ||
3 | BackGammonView::BackGammonView(QCanvas* canvas,QWidget* parent) | 3 | BackGammonView::BackGammonView(QCanvas* canvas,QWidget* parent) |
4 | :QCanvasView(canvas,parent) | 4 | :QCanvasView(canvas,parent) |
5 | { | 5 | { |
6 | //do nothing | ||
6 | } | 7 | } |
7 | 8 | ||
9 | |||
10 | |||
8 | BackGammonView::~BackGammonView() | 11 | BackGammonView::~BackGammonView() |
9 | { | 12 | { |
13 | //do nothing | ||
10 | } | 14 | } |
11 | 15 | ||
16 | |||
17 | |||
12 | void BackGammonView::contentsMousePressEvent(QMouseEvent* e) | 18 | void BackGammonView::contentsMousePressEvent(QMouseEvent* e) |
13 | { | 19 | { |
14 | int x=e->x(); | 20 | int x=e->x(); |
15 | int y=e->y(); | 21 | int y=e->y(); |
16 | //emit mousepressed(x,y); | 22 | emit mouse(x,y); |
17 | } \ No newline at end of file | 23 | } |
diff --git a/noncore/games/backgammon/backgammonview.h b/noncore/games/backgammon/backgammonview.h index e50f2b0..52508e2 100644 --- a/noncore/games/backgammon/backgammonview.h +++ b/noncore/games/backgammon/backgammonview.h | |||
@@ -1,18 +1,18 @@ | |||
1 | #ifndef BACKGAMMONVIEW_H | 1 | #ifndef BACKGAMMON_VIEW_H |
2 | #define BACKGAMMONVIEW_H | 2 | #define BACKGAMMON_VIEW_H |
3 | 3 | ||
4 | #include <qcanvas.h> | 4 | #include <qcanvas.h> |
5 | 5 | ||
6 | class BackGammonView : public QCanvasView | 6 | class BackGammonView : public QCanvasView |
7 | { | 7 | { |
8 | Q_OBJECT | 8 | Q_OBJECT |
9 | public: | 9 | public: |
10 | BackGammonView(QCanvas* canvas,QWidget* parent); | 10 | BackGammonView(QCanvas* canvas,QWidget* parent); |
11 | ~BackGammonView(); | 11 | ~BackGammonView(); |
12 | signals: | 12 | signals: |
13 | //void mousepressed(int,int); | 13 | void mouse(int,int); |
14 | private: | 14 | private: |
15 | void contentsMousePressEvent(QMouseEvent* e); | 15 | void contentsMousePressEvent(QMouseEvent* e); |
16 | }; | 16 | }; |
17 | 17 | ||
18 | #endif //BACKGAMMONVIEW_H \ No newline at end of file | 18 | #endif //BACKGAMMON_VIEW_H \ No newline at end of file |
diff --git a/noncore/games/backgammon/definition.cpp b/noncore/games/backgammon/definition.cpp index 9e0029d..c036319 100644 --- a/noncore/games/backgammon/definition.cpp +++ b/noncore/games/backgammon/definition.cpp | |||
@@ -1,3 +1,2 @@ | |||
1 | #include "definition.h" | 1 | #include "definition.h" |
2 | 2 | ||
3 | static bool debug=false; | ||
diff --git a/noncore/games/backgammon/displaydialog.cpp b/noncore/games/backgammon/displaydialog.cpp deleted file mode 100644 index 8b97545..0000000 --- a/noncore/games/backgammon/displaydialog.cpp +++ b/dev/null | |||
@@ -1,89 +0,0 @@ | |||
1 | #include "displaydialog.h" | ||
2 | |||
3 | #include <qgroupbox.h> | ||
4 | #include <qlabel.h> | ||
5 | |||
6 | DisplayDialog::DisplayDialog(QWidget* parent,const char* name,bool modal,WFlags f) | ||
7 | : QDialog(parent,name,modal,f) | ||
8 | { | ||
9 | setCaption("Display Configuration"); | ||
10 | QLabel* header=new QLabel("<b>Change the display settings</b>",this); | ||
11 | header->setGeometry(10,10,200,20); | ||
12 | |||
13 | // | ||
14 | QGroupBox* settings_frame=new QGroupBox("Settings",this); | ||
15 | settings_frame->setGeometry(10,10,220,120); | ||
16 | |||
17 | small_box=new QRadioButton("Big display, e.g. for QPE Style",settings_frame); | ||
18 | small_box->setGeometry(10,20,200,20); | ||
19 | connect(small_box,SIGNAL(clicked()),this,SLOT(small_clicked())); | ||
20 | |||
21 | big_box=new QRadioButton("Small display, e.g. for Windows Style",settings_frame); | ||
22 | big_box->setGeometry(10,50,200,20); | ||
23 | connect(big_box,SIGNAL(clicked()),this,SLOT(big_clicked())); | ||
24 | |||
25 | // | ||
26 | QGroupBox* warning_frame=new QGroupBox("Warning",this); | ||
27 | warning_frame->setGeometry(10,140,220,120); | ||
28 | |||
29 | warning_box=new QCheckBox("show style warning",warning_frame); | ||
30 | warning_box->setGeometry(10,20,200,20); | ||
31 | connect(warning_box,SIGNAL(clicked()),this,SLOT(warning_clicked())); | ||
32 | |||
33 | QLabel* warning_help=new QLabel("show style warning at statup if the system style is not QPE\nif not set to small you may have\nscrollbars on the palying area",warning_frame); | ||
34 | warning_help->setGeometry(10,50,200,60); | ||
35 | |||
36 | showMaximized(); | ||
37 | } | ||
38 | |||
39 | |||
40 | DisplayDialog::~DisplayDialog() | ||
41 | { | ||
42 | } | ||
43 | |||
44 | void DisplayDialog::big_clicked() | ||
45 | { | ||
46 | big_box->setChecked(true); | ||
47 | small_box->setChecked(false); | ||
48 | } | ||
49 | |||
50 | void DisplayDialog::small_clicked() | ||
51 | { | ||
52 | big_box->setChecked(false); | ||
53 | small_box->setChecked(true); | ||
54 | } | ||
55 | |||
56 | void DisplayDialog::warning_clicked() | ||
57 | { | ||
58 | } | ||
59 | |||
60 | void DisplayDialog::setDisplaySettings(const Display& display) | ||
61 | { | ||
62 | if(!display.small) | ||
63 | { | ||
64 | big_box->setChecked(false); | ||
65 | small_box->setChecked(true); | ||
66 | } | ||
67 | else | ||
68 | { | ||
69 | big_box->setChecked(true); | ||
70 | small_box->setChecked(false); | ||
71 | } | ||
72 | if(display.warning) | ||
73 | warning_box->setChecked(true); | ||
74 | else | ||
75 | warning_box->setChecked(false); | ||
76 | |||
77 | } | ||
78 | |||
79 | Display DisplayDialog::getDisplaySettings() | ||
80 | { | ||
81 | Display display; | ||
82 | display.small=!small_box->isChecked(); | ||
83 | display.warning=warning_box->isChecked(); | ||
84 | return display; | ||
85 | } | ||
86 | |||
87 | |||
88 | |||
89 | |||
diff --git a/noncore/games/backgammon/displaydialog.h b/noncore/games/backgammon/displaydialog.h deleted file mode 100644 index 26b77f0..0000000 --- a/noncore/games/backgammon/displaydialog.h +++ b/dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | #ifndef DISPLAYDLAOG_H | ||
2 | #define DISPLAYDLAOG_H | ||
3 | |||
4 | #include <qcheckbox.h> | ||
5 | #include <qdialog.h> | ||
6 | #include <qradiobutton.h> | ||
7 | |||
8 | #include "definition.h" | ||
9 | |||
10 | |||
11 | class DisplayDialog : public QDialog | ||
12 | { | ||
13 | Q_OBJECT | ||
14 | private: | ||
15 | QRadioButton* small_box; | ||
16 | QRadioButton* big_box; | ||
17 | QCheckBox* warning_box; | ||
18 | public: | ||
19 | DisplayDialog(QWidget* parent=0,const char* name=0,bool modal=TRUE,WFlags f=0); | ||
20 | ~DisplayDialog(); | ||
21 | private slots: | ||
22 | void big_clicked(); | ||
23 | void small_clicked(); | ||
24 | void warning_clicked(); | ||
25 | public: | ||
26 | void setDisplaySettings(const Display& display); | ||
27 | Display getDisplaySettings(); | ||
28 | }; | ||
29 | |||
30 | #endif //DISPLAYDLAOG_H | ||
diff --git a/noncore/games/backgammon/moveengine.cpp b/noncore/games/backgammon/moveengine.cpp index 8106b3f..009c449 100644 --- a/noncore/games/backgammon/moveengine.cpp +++ b/noncore/games/backgammon/moveengine.cpp | |||
@@ -1,32 +1,30 @@ | |||
1 | #include "moveengine.h" | 1 | #include "moveengine.h" |
2 | 2 | ||
3 | #include <qmessagebox.h> | 3 | #include <qmessagebox.h> |
4 | 4 | ||
5 | #include <qtimer.h> | 5 | #include <qtimer.h> |
6 | 6 | ||
7 | #include <stdlib.h> | ||
8 | |||
9 | MoveEngine::MoveEngine() | 7 | MoveEngine::MoveEngine() |
10 | : QObject() | 8 | : QObject() |
11 | { | 9 | { |
12 | int offset=7; | 10 | int offset=7; |
13 | int a=0; //counter variable | 11 | int a=0; //counter variable |
14 | 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}; | 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}; |
15 | for(a=0;a<26;a++) | 13 | for(a=0;a<26;a++) |
16 | { | 14 | { |
17 | x_coord[a]=xfill[a]; | 15 | x_coord[a]=xfill[a]; |
18 | } | 16 | } |
19 | 17 | ||
20 | int yfill[]={10,25,40,55,70,10+offset,25+offset,40+offset,55+offset,25,40,55, 25+offset,40+offset,40}; | 18 | int yfill[]={10,25,40,55,70,10+offset,25+offset,40+offset,55+offset,25,40,55, 25+offset,40+offset,40}; |
21 | int zfill[]={1,1,1,1,1,2,2,2,2,3,3,3,4,4,5}; | 19 | int zfill[]={1,1,1,1,1,2,2,2,2,3,3,3,4,4,5}; |
22 | for(a=0;a<15;a++) | 20 | for(a=0;a<15;a++) |
23 | { | 21 | { |
24 | yup_coord[a]=yfill[a]; | 22 | yup_coord[a]=yfill[a]; |
25 | ylow_coord[a]=185-(yfill[a]); | 23 | ylow_coord[a]=185-(yfill[a]); |
26 | z_coord[a]=zfill[a]; | 24 | z_coord[a]=zfill[a]; |
27 | } | 25 | } |
28 | for(a=0;a<5;a++) | 26 | for(a=0;a<5;a++) |
29 | { | 27 | { |
30 | if(a<3) | 28 | if(a<3) |
31 | { | 29 | { |
32 | x_fin1[a]=65+a*15; | 30 | x_fin1[a]=65+a*15; |
diff --git a/noncore/games/backgammon/moveengine.h b/noncore/games/backgammon/moveengine.h index a2d4a52..4c39a04 100644 --- a/noncore/games/backgammon/moveengine.h +++ b/noncore/games/backgammon/moveengine.h | |||
@@ -1,29 +1,29 @@ | |||
1 | #ifndef MOVEENGINE_H | 1 | #ifndef MOVEENGINE_H |
2 | #define MOVEENGINE_H | 2 | #define MOVEENGINE_H |
3 | 3 | ||
4 | #include <qobject.h> | ||
5 | #include "definition.h" | 4 | #include "definition.h" |
5 | #include <qobject.h> | ||
6 | 6 | ||
7 | class MoveEngine : public QObject | 7 | class MoveEngine : public QObject |
8 | { | 8 | { |
9 | Q_OBJECT | 9 | Q_OBJECT |
10 | private: | 10 | private: |
11 | //normal pieses | 11 | //normal pieses |
12 | int x_coord[26]; //26 posssible x-positions or piece is not on the board | 12 | int x_coord[26]; //26 posssible x-positions or piece is not on the board |
13 | int yup_coord[15]; // the 15 posssible y-positions on the upper half of the board | 13 | int yup_coord[15]; // the 15 posssible y-positions on the upper half of the board |
14 | int ylow_coord[15]; // the 15 posssible y-positions on the lower half of the board | 14 | int ylow_coord[15]; // the 15 posssible y-positions on the lower half of the board |
15 | int z_coord[15]; //the 15 possible z-positionson the board | 15 | int z_coord[15]; //the 15 possible z-positionson the board |
16 | //finshed pieces | 16 | //finshed pieces |
17 | int x_fin1[3]; | 17 | int x_fin1[3]; |
18 | int x_fin2[3]; | 18 | int x_fin2[3]; |
19 | int y_fin[5]; | 19 | int y_fin[5]; |
20 | int z_fin; | 20 | int z_fin; |
21 | //the board population | 21 | //the board population |
22 | // |12|11|10|09|08|07|06|05|04|03|02|01|00| | 22 | // |12|11|10|09|08|07|06|05|04|03|02|01|00| |
23 | // ======================================= | 23 | // ======================================= |
24 | // |13|14|15|16|17|18|19|20|21|22|23|24|25| | 24 | // |13|14|15|16|17|18|19|20|21|22|23|24|25| |
25 | // endzones 26 player1, 27 player 2 | 25 | // endzones 26 player1, 27 player 2 |
26 | Population population[28]; | 26 | Population population[28]; |
27 | AISettings ai; | 27 | AISettings ai; |
28 | //move information | 28 | //move information |
29 | int player; | 29 | int player; |
diff --git a/noncore/games/backgammon/rulesdialog.h b/noncore/games/backgammon/rulesdialog.h index 9269a0e..f11a28c 100644 --- a/noncore/games/backgammon/rulesdialog.h +++ b/noncore/games/backgammon/rulesdialog.h | |||
@@ -1,27 +1,26 @@ | |||
1 | #ifndef RULESDIALOG_H_ | 1 | #ifndef RULESDIALOG_H_ |
2 | #define RULESDIALOG_H_ | 2 | #define RULESDIALOG_H_ |
3 | 3 | ||
4 | #include <qcheckbox.h> | 4 | #include <qcheckbox.h> |
5 | #include <qdialog.h> | 5 | #include <qdialog.h> |
6 | #include "definition.h" | 6 | #include "definition.h" |
7 | 7 | ||
8 | |||
9 | class RulesDialog : public QDialog | 8 | class RulesDialog : public QDialog |
10 | { | 9 | { |
11 | Q_OBJECT | 10 | Q_OBJECT |
12 | private: | 11 | private: |
13 | QCheckBox* pieces_out; | 12 | QCheckBox* pieces_out; |
14 | QCheckBox* nice_dice; | 13 | QCheckBox* nice_dice; |
15 | Rules rules; | 14 | Rules rules; |
16 | public: | 15 | public: |
17 | RulesDialog(QWidget* parent=0,const char* name=0,bool modal=TRUE,WFlags f=0); | 16 | RulesDialog(QWidget* parent=0,const char* name=0,bool modal=TRUE,WFlags f=0); |
18 | ~RulesDialog(); | 17 | ~RulesDialog(); |
19 | private slots: | 18 | private slots: |
20 | void pieces_out_clicked(); | 19 | void pieces_out_clicked(); |
21 | void nice_dice_clicked(); | 20 | void nice_dice_clicked(); |
22 | public: | 21 | public: |
23 | void setRules(const Rules& new_rules); | 22 | void setRules(const Rules& new_rules); |
24 | Rules getRules(); | 23 | Rules getRules(); |
25 | }; | 24 | }; |
26 | 25 | ||
27 | #endif //RULESDIALOG_H | 26 | #endif //RULESDIALOG_H |