-rw-r--r-- | noncore/games/tictac/tictac.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/noncore/games/tictac/tictac.cpp b/noncore/games/tictac/tictac.cpp index e887b00..20cc942 100644 --- a/noncore/games/tictac/tictac.cpp +++ b/noncore/games/tictac/tictac.cpp | |||
@@ -271,106 +271,106 @@ void TicTacGameBoard::computerMove() | |||
271 | st = NobodyWon; | 271 | st = NobodyWon; |
272 | emit finished(); | 272 | emit finished(); |
273 | } | 273 | } |
274 | } | 274 | } |
275 | *btArray = a; // update model | 275 | *btArray = a; // update model |
276 | updateButtons(); // update buttons | 276 | updateButtons(); // update buttons |
277 | delete[] altv; | 277 | delete[] altv; |
278 | } | 278 | } |
279 | 279 | ||
280 | 280 | ||
281 | //*************************************************************************** | 281 | //*************************************************************************** |
282 | //* TicTacToe member functions | 282 | //* TicTacToe member functions |
283 | //*************************************************************************** | 283 | //*************************************************************************** |
284 | 284 | ||
285 | // -------------------------------------------------------------------------- | 285 | // -------------------------------------------------------------------------- |
286 | // Creates a game widget with a game board and two push buttons, and connects | 286 | // Creates a game widget with a game board and two push buttons, and connects |
287 | // signals of child widgets to slots. | 287 | // signals of child widgets to slots. |
288 | // | 288 | // |
289 | 289 | ||
290 | TicTacToe::TicTacToe( int boardSize, QWidget *parent, const char *name ) | 290 | TicTacToe::TicTacToe( int boardSize, QWidget *parent, const char *name ) |
291 | : QWidget( parent, name ) | 291 | : QWidget( parent, name ) |
292 | { | 292 | { |
293 | QVBoxLayout * l = new QVBoxLayout( this, 6 ); | 293 | QVBoxLayout * l = new QVBoxLayout( this, 6 ); |
294 | 294 | ||
295 | // Create a message label | 295 | // Create a message label |
296 | 296 | ||
297 | message = new QLabel( this ); | 297 | message = new QLabel( this ); |
298 | message->setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); | 298 | message->setFrameStyle( QFrame::WinPanel | QFrame::Sunken ); |
299 | message->setAlignment( AlignCenter ); | 299 | message->setAlignment( AlignCenter ); |
300 | l->addWidget( message ); | 300 | l->addWidget( message ); |
301 | 301 | ||
302 | // Create the game board and connect the signal finished() to this | 302 | // Create the game board and connect the signal finished() to this |
303 | // gameOver() slot | 303 | // gameOver() slot |
304 | 304 | ||
305 | board = new TicTacGameBoard( boardSize, this ); | 305 | board = new TicTacGameBoard( boardSize, this ); |
306 | connect( board, SIGNAL(finished()), SLOT(gameOver()) ); | 306 | connect( board, SIGNAL(finished()), SLOT(gameOver()) ); |
307 | l->addWidget( board ); | 307 | l->addWidget( board ); |
308 | 308 | ||
309 | // Create a horizontal frame line | 309 | // Create a horizontal frame line |
310 | 310 | ||
311 | QFrame *line = new QFrame( this ); | 311 | QFrame *line = new QFrame( this ); |
312 | line->setFrameStyle( QFrame::HLine | QFrame::Sunken ); | 312 | line->setFrameStyle( QFrame::HLine | QFrame::Sunken ); |
313 | l->addWidget( line ); | 313 | l->addWidget( line ); |
314 | 314 | ||
315 | // Create the combo box for deciding who should start, and | 315 | // Create the combo box for deciding who should start, and |
316 | // connect its clicked() signals to the buttonClicked() slot | 316 | // connect its clicked() signals to the buttonClicked() slot |
317 | 317 | ||
318 | whoStarts = new QComboBox( this ); | 318 | whoStarts = new QComboBox( this ); |
319 | whoStarts->insertItem( "Computer starts" ); | 319 | whoStarts->insertItem( tr( "Computer starts" ) ); |
320 | whoStarts->insertItem( "Human starts" ); | 320 | whoStarts->insertItem( tr( "Human starts" ) ); |
321 | l->addWidget( whoStarts ); | 321 | l->addWidget( whoStarts ); |
322 | 322 | ||
323 | // Create the push buttons and connect their clicked() signals | 323 | // Create the push buttons and connect their clicked() signals |
324 | // to this right slots. | 324 | // to this right slots. |
325 | 325 | ||
326 | newGame = new QPushButton( "Play!", this ); | 326 | newGame = new QPushButton( tr( "Play!" ), this ); |
327 | connect( newGame, SIGNAL(clicked()), SLOT(newGameClicked()) ); | 327 | connect( newGame, SIGNAL(clicked()), SLOT(newGameClicked()) ); |
328 | quit = new QPushButton( "Quit", this ); | 328 | quit = new QPushButton( tr( "Quit" ), this ); |
329 | connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) ); | 329 | connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) ); |
330 | QHBoxLayout * b = new QHBoxLayout; | 330 | QHBoxLayout * b = new QHBoxLayout; |
331 | l->addLayout( b ); | 331 | l->addLayout( b ); |
332 | b->addWidget( newGame ); | 332 | b->addWidget( newGame ); |
333 | b->addWidget( quit ); | 333 | b->addWidget( quit ); |
334 | showMaximized(); | 334 | showMaximized(); |
335 | newState(); | 335 | newState(); |
336 | } | 336 | } |
337 | 337 | ||
338 | 338 | ||
339 | // -------------------------------------------------------------------------- | 339 | // -------------------------------------------------------------------------- |
340 | // TicTacToe::newGameClicked() - SLOT | 340 | // TicTacToe::newGameClicked() - SLOT |
341 | // | 341 | // |
342 | // This slot is activated when the new game button is clicked. | 342 | // This slot is activated when the new game button is clicked. |
343 | // | 343 | // |
344 | 344 | ||
345 | void TicTacToe::newGameClicked() | 345 | void TicTacToe::newGameClicked() |
346 | { | 346 | { |
347 | board->computerStarts( whoStarts->currentItem() == 0 ); | 347 | board->computerStarts( whoStarts->currentItem() == 0 ); |
348 | board->newGame(); | 348 | board->newGame(); |
349 | newState(); | 349 | newState(); |
350 | } | 350 | } |
351 | 351 | ||
352 | 352 | ||
353 | // -------------------------------------------------------------------------- | 353 | // -------------------------------------------------------------------------- |
354 | // TicTacToe::gameOver() - SLOT | 354 | // TicTacToe::gameOver() - SLOT |
355 | // | 355 | // |
356 | // This slot is activated when the TicTacGameBoard emits the signal | 356 | // This slot is activated when the TicTacGameBoard emits the signal |
357 | // "finished()", i.e. when a player has won or when it is a draw. | 357 | // "finished()", i.e. when a player has won or when it is a draw. |
358 | // | 358 | // |
359 | 359 | ||
360 | void TicTacToe::gameOver() | 360 | void TicTacToe::gameOver() |
361 | { | 361 | { |
362 | newState(); // update text box | 362 | newState(); // update text box |
363 | } | 363 | } |
364 | 364 | ||
365 | 365 | ||
366 | // -------------------------------------------------------------------------- | 366 | // -------------------------------------------------------------------------- |
367 | // Updates the message to reflect a new state. | 367 | // Updates the message to reflect a new state. |
368 | // | 368 | // |
369 | 369 | ||
370 | void TicTacToe::newState() | 370 | void TicTacToe::newState() |
371 | { | 371 | { |
372 | static const char *msg[] = { // TicTacGameBoard::State texts | 372 | static const char *msg[] = { // TicTacGameBoard::State texts |
373 | "Click Play to start", "Make your move", | 373 | "Click Play to start", "Make your move", |
374 | "You won!", "Computer won!", "It's a draw" }; | 374 | "You won!", "Computer won!", "It's a draw" }; |
375 | message->setText( msg[board->state()] ); | 375 | message->setText( msg[board->state()] ); |
376 | return; | 376 | return; |