-rw-r--r-- | noncore/games/kcheckers/kcheckers.cpp | 1 | ||||
-rw-r--r-- | noncore/todayplugins/stockticker/libstocks/currency.c | 7 |
2 files changed, 4 insertions, 4 deletions
diff --git a/noncore/games/kcheckers/kcheckers.cpp b/noncore/games/kcheckers/kcheckers.cpp index a27dd18..433c68f 100644 --- a/noncore/games/kcheckers/kcheckers.cpp +++ b/noncore/games/kcheckers/kcheckers.cpp | |||
@@ -305,256 +305,257 @@ void KCheckers::setPattern(int set) | |||
305 | 305 | ||
306 | for(int i=0; i<32;i++) field[i]->setPattern(imagePat2); | 306 | for(int i=0; i<32;i++) field[i]->setPattern(imagePat2); |
307 | for(int i=32;i<64;i++) field[i]->setPattern(imagePat1); | 307 | for(int i=32;i<64;i++) field[i]->setPattern(imagePat1); |
308 | 308 | ||
309 | if(selected) field[from]->setFrame(imageFrame); | 309 | if(selected) field[from]->setFrame(imageFrame); |
310 | } | 310 | } |
311 | 311 | ||
312 | 312 | ||
313 | void KCheckers::showNumeration() | 313 | void KCheckers::showNumeration() |
314 | { | 314 | { |
315 | if(optionsMenu->isItemChecked(numID)) | 315 | if(optionsMenu->isItemChecked(numID)) |
316 | { | 316 | { |
317 | optionsMenu->setItemChecked(numID,false); | 317 | optionsMenu->setItemChecked(numID,false); |
318 | for(int i=0;i<32;i++) field[i]->setLabel(""); | 318 | for(int i=0;i<32;i++) field[i]->setLabel(""); |
319 | } | 319 | } |
320 | else | 320 | else |
321 | { | 321 | { |
322 | optionsMenu->setItemChecked(numID,true); | 322 | optionsMenu->setItemChecked(numID,true); |
323 | drawNumeration(); | 323 | drawNumeration(); |
324 | } | 324 | } |
325 | } | 325 | } |
326 | 326 | ||
327 | 327 | ||
328 | void KCheckers::drawNumeration() | 328 | void KCheckers::drawNumeration() |
329 | { | 329 | { |
330 | if(rules==ENGLISH) | 330 | if(rules==ENGLISH) |
331 | { | 331 | { |
332 | if(userFirst) | 332 | if(userFirst) |
333 | for(int i=0;i<32;i++) | 333 | for(int i=0;i<32;i++) |
334 | field[i]->setLabel(enNumeration.mid(i*2,2)); | 334 | field[i]->setLabel(enNumeration.mid(i*2,2)); |
335 | else | 335 | else |
336 | for(int i=0;i<32;i++) | 336 | for(int i=0;i<32;i++) |
337 | field[i]->setLabel(enNumeration.mid(62-i*2,2)); | 337 | field[i]->setLabel(enNumeration.mid(62-i*2,2)); |
338 | } | 338 | } |
339 | else | 339 | else |
340 | { | 340 | { |
341 | if(userFirst) | 341 | if(userFirst) |
342 | for(int i=0;i<32;i++) | 342 | for(int i=0;i<32;i++) |
343 | field[i]->setLabel(ruNumeration.mid(i*2,2)); | 343 | field[i]->setLabel(ruNumeration.mid(i*2,2)); |
344 | else | 344 | else |
345 | for(int i=0;i<32;i++) | 345 | for(int i=0;i<32;i++) |
346 | field[i]->setLabel(ruNumeration.mid(62-i*2,2)); | 346 | field[i]->setLabel(ruNumeration.mid(62-i*2,2)); |
347 | } | 347 | } |
348 | } | 348 | } |
349 | 349 | ||
350 | 350 | ||
351 | void KCheckers::drawBoard(int i) | 351 | void KCheckers::drawBoard(int i) |
352 | { | 352 | { |
353 | switch(game->board[t[i]]) | 353 | switch(game->board[t[i]]) |
354 | { | 354 | { |
355 | case MAN1: | 355 | case MAN1: |
356 | field[i]->setPicture(imageMan1); | 356 | field[i]->setPicture(imageMan1); |
357 | break; | 357 | break; |
358 | case MAN2: | 358 | case MAN2: |
359 | field[i]->setPicture(imageMan2); | 359 | field[i]->setPicture(imageMan2); |
360 | break; | 360 | break; |
361 | case KING1: | 361 | case KING1: |
362 | field[i]->setPicture(imageKing1); | 362 | field[i]->setPicture(imageKing1); |
363 | break; | 363 | break; |
364 | case KING2: | 364 | case KING2: |
365 | field[i]->setPicture(imageKing2); | 365 | field[i]->setPicture(imageKing2); |
366 | break; | 366 | break; |
367 | default: | 367 | default: |
368 | field[i]->setPicture(NULL); | 368 | field[i]->setPicture(NULL); |
369 | } | 369 | } |
370 | } | 370 | } |
371 | 371 | ||
372 | 372 | ||
373 | void KCheckers::help() | 373 | void KCheckers::help() |
374 | { | 374 | { |
375 | QMessageBox::information(this,"Rules of Play", | 375 | QMessageBox::information(this,"Rules of Play", |
376 | "In the beginning of game you have\n" | 376 | "In the beginning of game you have\n" |
377 | "12 checkers (men).\n" | 377 | "12 checkers (men).\n" |
378 | "The men move forward only.\n" | 378 | "The men move forward only.\n" |
379 | "The men can capture:\n" | 379 | "The men can capture:\n" |
380 | "- by jumping forward only (english\n" | 380 | "- by jumping forward only (english\n" |
381 | " rules);\n" | 381 | " rules);\n" |
382 | "- by jumping forward or backward\n" | 382 | "- by jumping forward or backward\n" |
383 | " (russian rules).\n" | 383 | " (russian rules).\n" |
384 | "A man which reaches the far side of\n" | 384 | "A man which reaches the far side of\n" |
385 | "the board becomes a king.\n" | 385 | "the board becomes a king.\n" |
386 | "The kings move forward or\n" | 386 | "The kings move forward or\n" |
387 | "backward:\n" | 387 | "backward:\n" |
388 | "- to one square only (english rules);\n" | 388 | "- to one square only (english rules);\n" |
389 | "- to any number of squares (russian\n" | 389 | "- to any number of squares (russian\n" |
390 | " rules).\n" | 390 | " rules).\n" |
391 | "The kings capture by jumping\n" | 391 | "The kings capture by jumping\n" |
392 | "forward or backward.\n" | 392 | "forward or backward.\n" |
393 | "Whenever a player is able to make a\n" | 393 | "Whenever a player is able to make a\n" |
394 | "capture he must do so.", | 394 | "capture he must do so.", |
395 | QMessageBox::Ok|QMessageBox::Default); | 395 | QMessageBox::Ok|QMessageBox::Default); |
396 | } | 396 | } |
397 | 397 | ||
398 | 398 | ||
399 | void KCheckers::about() | 399 | void KCheckers::about() |
400 | { | 400 | { |
401 | QMessageBox::about(this,"About KCheckers", | 401 | QMessageBox::about(this,"About KCheckers", |
402 | "KCheckers, a board game. Ver 0.3\n" | 402 | "KCheckers, a board game. Ver 0.3\n" |
403 | "(C) 2002, A. Peredri <andi@ukr.net>\n\n" | 403 | "(C) 2002, A. Peredri <andi@ukr.net>\n\n" |
404 | "http://kcheckers.tuxfamily.org\n\n" | 404 | "http://kcheckers.tuxfamily.org\n\n" |
405 | "Contributors:\n" | 405 | "Contributors:\n" |
406 | "S. Rosen <srosen@erols.com>\n\n" | 406 | "S. Rosen <srosen@erols.com>\n\n" |
407 | "Qtopia version: S.Prud'homme\n" | 407 | "Qtopia version: S.Prud'homme\n" |
408 | "<prudhomme@laposte.net>\n\n" | 408 | "<prudhomme@laposte.net>\n\n" |
409 | "This program is distributed under the\n" | 409 | "This program is distributed under the\n" |
410 | "terms of the GNU General Public\n" | 410 | "terms of the GNU General Public\n" |
411 | "License."); | 411 | "License."); |
412 | } | 412 | } |
413 | 413 | ||
414 | 414 | ||
415 | void KCheckers::aboutQt() | 415 | void KCheckers::aboutQt() |
416 | { | 416 | { |
417 | QMessageBox::aboutQt(this); | 417 | QMessageBox::aboutQt(this); |
418 | } | 418 | } |
419 | 419 | ||
420 | 420 | ||
421 | void KCheckers::newGame() | 421 | void KCheckers::newGame() |
422 | { | 422 | { |
423 | if(game) delete game; | 423 | if(game) delete game; |
424 | 424 | ||
425 | switch(rules) | 425 | switch(rules) |
426 | { | 426 | { |
427 | case ENGLISH: | 427 | case ENGLISH: |
428 | game=new ECheckers(skill); | 428 | game=new ECheckers(skill); |
429 | CHECK_PTR(game); | 429 | CHECK_PTR(game); |
430 | break; | 430 | break; |
431 | 431 | ||
432 | case RUSSIAN: | 432 | case RUSSIAN: |
433 | default: | ||
433 | game=new RCheckers(skill); | 434 | game=new RCheckers(skill); |
434 | CHECK_PTR(game); | 435 | CHECK_PTR(game); |
435 | } | 436 | } |
436 | 437 | ||
437 | unselect(); | 438 | unselect(); |
438 | gameOver=false; | 439 | gameOver=false; |
439 | 440 | ||
440 | gameMenu->setItemEnabled(undoID,false); | 441 | gameMenu->setItemEnabled(undoID,false); |
441 | undoButton->setEnabled(false); | 442 | undoButton->setEnabled(false); |
442 | 443 | ||
443 | colorChange(); | 444 | colorChange(); |
444 | 445 | ||
445 | for(int i=0;i<32;i++) drawBoard(i); | 446 | for(int i=0;i<32;i++) drawBoard(i); |
446 | if(optionsMenu->isItemChecked(numID)) drawNumeration(); | 447 | if(optionsMenu->isItemChecked(numID)) drawNumeration(); |
447 | 448 | ||
448 | if(!userFirst) compGo(); | 449 | if(!userFirst) compGo(); |
449 | 450 | ||
450 | statusLabel->setText(tr("Go!")); | 451 | statusLabel->setText(tr("Go!")); |
451 | } | 452 | } |
452 | 453 | ||
453 | 454 | ||
454 | // Undo the last computer and user moves | 455 | // Undo the last computer and user moves |
455 | 456 | ||
456 | void KCheckers::undoMove() | 457 | void KCheckers::undoMove() |
457 | { | 458 | { |
458 | for(int i=0;i<32;i++) | 459 | for(int i=0;i<32;i++) |
459 | { | 460 | { |
460 | game->board[t[i]]=undoBoard[i]; | 461 | game->board[t[i]]=undoBoard[i]; |
461 | drawBoard(i); | 462 | drawBoard(i); |
462 | } | 463 | } |
463 | 464 | ||
464 | unselect(); | 465 | unselect(); |
465 | gameOver=false; | 466 | gameOver=false; |
466 | 467 | ||
467 | gameMenu->setItemEnabled(undoID,false); | 468 | gameMenu->setItemEnabled(undoID,false); |
468 | undoButton->setEnabled(false); | 469 | undoButton->setEnabled(false); |
469 | 470 | ||
470 | statusLabel->setText(tr("Go!")); | 471 | statusLabel->setText(tr("Go!")); |
471 | } | 472 | } |
472 | 473 | ||
473 | 474 | ||
474 | void KCheckers::colorChange() | 475 | void KCheckers::colorChange() |
475 | { | 476 | { |
476 | userFirst=!userFirst; | 477 | userFirst=!userFirst; |
477 | 478 | ||
478 | QImage* image; | 479 | QImage* image; |
479 | image=imageMan1; | 480 | image=imageMan1; |
480 | imageMan1=imageMan2; | 481 | imageMan1=imageMan2; |
481 | imageMan2=image; | 482 | imageMan2=image; |
482 | image=imageKing1; | 483 | image=imageKing1; |
483 | imageKing1=imageKing2; | 484 | imageKing1=imageKing2; |
484 | imageKing2=image; | 485 | imageKing2=image; |
485 | } | 486 | } |
486 | 487 | ||
487 | 488 | ||
488 | void KCheckers::unselect() | 489 | void KCheckers::unselect() |
489 | { | 490 | { |
490 | if(selected) field[from]->setFrame(NULL); | 491 | if(selected) field[from]->setFrame(NULL); |
491 | selected=false; | 492 | selected=false; |
492 | } | 493 | } |
493 | 494 | ||
494 | 495 | ||
495 | void KCheckers::click(int fieldNumber) | 496 | void KCheckers::click(int fieldNumber) |
496 | { | 497 | { |
497 | if(gameOver) return; | 498 | if(gameOver) return; |
498 | switch(game->board[t[fieldNumber]]) | 499 | switch(game->board[t[fieldNumber]]) |
499 | { | 500 | { |
500 | case MAN1: | 501 | case MAN1: |
501 | case KING1: | 502 | case KING1: |
502 | // User selected | 503 | // User selected |
503 | if(!selected) | 504 | if(!selected) |
504 | { | 505 | { |
505 | from=fieldNumber; | 506 | from=fieldNumber; |
506 | selected=true; | 507 | selected=true; |
507 | field[fieldNumber]->setFrame(imageFrame); | 508 | field[fieldNumber]->setFrame(imageFrame); |
508 | return; | 509 | return; |
509 | } | 510 | } |
510 | // User reselected | 511 | // User reselected |
511 | else | 512 | else |
512 | { | 513 | { |
513 | field[from]->setFrame(NULL); | 514 | field[from]->setFrame(NULL); |
514 | from=fieldNumber; | 515 | from=fieldNumber; |
515 | field[fieldNumber]->setFrame(imageFrame); | 516 | field[fieldNumber]->setFrame(imageFrame); |
516 | return; | 517 | return; |
517 | } | 518 | } |
518 | case FREE: | 519 | case FREE: |
519 | if(!selected) return; | 520 | if(!selected) return; |
520 | 521 | ||
521 | if(!userGo(fieldNumber)) return; | 522 | if(!userGo(fieldNumber)) return; |
522 | 523 | ||
523 | unselect(); | 524 | unselect(); |
524 | 525 | ||
525 | if(!(game->checkMove2() || game->checkCapture2())) | 526 | if(!(game->checkMove2() || game->checkCapture2())) |
526 | { | 527 | { |
527 | gameOver=true; | 528 | gameOver=true; |
528 | statusLabel->setText(tr("Congratulation! You have won!")); | 529 | statusLabel->setText(tr("Congratulation! You have won!")); |
529 | return; | 530 | return; |
530 | } | 531 | } |
531 | 532 | ||
532 | statusLabel->setText(tr("Please wait...")); | 533 | statusLabel->setText(tr("Please wait...")); |
533 | qApp->processEvents(); | 534 | qApp->processEvents(); |
534 | 535 | ||
535 | compGo(); | 536 | compGo(); |
536 | if(!(game->checkMove1() || game->checkCapture1())) | 537 | if(!(game->checkMove1() || game->checkCapture1())) |
537 | { | 538 | { |
538 | gameOver=true; | 539 | gameOver=true; |
539 | statusLabel->setText(tr("You have lost. Game over.")); | 540 | statusLabel->setText(tr("You have lost. Game over.")); |
540 | return; | 541 | return; |
541 | } | 542 | } |
542 | statusLabel->setText(tr("Go!")); | 543 | statusLabel->setText(tr("Go!")); |
543 | } | 544 | } |
544 | } | 545 | } |
545 | 546 | ||
546 | 547 | ||
547 | void KCheckers::compGo() | 548 | void KCheckers::compGo() |
548 | { | 549 | { |
549 | int save[32]; | 550 | int save[32]; |
550 | for(int i=0;i<32;i++) save[i]=game->board[t[i]]; | 551 | for(int i=0;i<32;i++) save[i]=game->board[t[i]]; |
551 | 552 | ||
552 | game->go2(); | 553 | game->go2(); |
553 | 554 | ||
554 | for(int i=0;i<32;i++) | 555 | for(int i=0;i<32;i++) |
555 | { | 556 | { |
556 | if(game->board[t[i]]==save[i]) continue; | 557 | if(game->board[t[i]]==save[i]) continue; |
557 | drawBoard(i); | 558 | drawBoard(i); |
558 | } | 559 | } |
559 | } | 560 | } |
560 | 561 | ||
diff --git a/noncore/todayplugins/stockticker/libstocks/currency.c b/noncore/todayplugins/stockticker/libstocks/currency.c index e0090e2..82cd654 100644 --- a/noncore/todayplugins/stockticker/libstocks/currency.c +++ b/noncore/todayplugins/stockticker/libstocks/currency.c | |||
@@ -1,67 +1,66 @@ | |||
1 | /* libstocks - Library to get current stock quotes from Yahoo Finance | 1 | /* libstocks - Library to get current stock quotes from Yahoo Finance |
2 | * | 2 | * |
3 | * Copyright (C) 2000 Eric Laeuffer | 3 | * Copyright (C) 2000 Eric Laeuffer |
4 | * | 4 | * |
5 | * This library is free software; you can redistribute it and/or | 5 | * This library is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU Library General Public | 6 | * modify it under the terms of the GNU Library General Public |
7 | * License as published by the Free Software Foundation; either | 7 | * License as published by the Free Software Foundation; either |
8 | * version 2 of the License, or (at your option) any later version. | 8 | * version 2 of the License, or (at your option) any later version. |
9 | * | 9 | * |
10 | * This library is distributed in the hope that it will be useful, | 10 | * This library 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 GNU | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | * Library General Public License for more details. | 13 | * Library General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU Library General Public | 15 | * You should have received a copy of the GNU Library General Public |
16 | * License along with this library; if not, write to the | 16 | * License along with this library; if not, write to the |
17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | * Boston, MA 02111-1307, USA. | 18 | * Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #define __CURRENCY_C__ | 21 | #define __CURRENCY_C__ |
22 | 22 | ||
23 | 23 | ||
24 | #include <stdio.h> | 24 | #include <stdio.h> |
25 | #include <string.h> | 25 | #include <string.h> |
26 | #include <malloc.h> | 26 | #include <malloc.h> |
27 | #include <stdlib.h> | 27 | #include <stdlib.h> |
28 | 28 | ||
29 | #include "stocks.h" | 29 | #include "stocks.h" |
30 | 30 | ||
31 | /*****************************************************************************/ | 31 | /*****************************************************************************/ |
32 | /* returns the currency exchange rate of "from" currency into */ | 32 | /* returns the currency exchange rate of "from" currency into */ |
33 | /* "into" currency. */ | 33 | /* "into" currency. */ |
34 | /*****************************************************************************/ | 34 | /*****************************************************************************/ |
35 | libstocks_return_code get_currency_exchange(char *from, | 35 | libstocks_return_code get_currency_exchange(char *from, |
36 | char *into, | 36 | char *into, |
37 | float *exchange) | 37 | float *exchange) |
38 | { | 38 | { |
39 | char *symbol; | 39 | char *symbol; |
40 | stock *data; | 40 | stock *data; |
41 | libstocks_return_code error; | 41 | libstocks_return_code error; |
42 | 42 | ||
43 | if((symbol = (char *)malloc(strlen(from)+strlen(into)+3))==NULL) | 43 | if((symbol = (char *)malloc(strlen(from)+strlen(into)+3))==NULL) |
44 | { | 44 | { |
45 | fprintf(stderr,"Memory allocating error (%s line %d)\n" | 45 | fprintf(stderr,"Memory allocating error (%s line %d)\n" |
46 | ,__FILE__, __LINE__); | 46 | ,__FILE__, __LINE__); |
47 | exit(1); | 47 | exit(1); |
48 | } | 48 | } |
49 | 49 | ||
50 | strcpy(symbol, from); | 50 | strcpy(symbol, from); |
51 | strcat(symbol, into); | 51 | strcat(symbol, into); |
52 | strcat(symbol, "=X"); | 52 | strcat(symbol, "=X"); |
53 | 53 | ||
54 | error = get_stocks(symbol, &data); | 54 | error = get_stocks(symbol, &data); |
55 | free(symbol); | 55 | free(symbol); |
56 | if (error) | 56 | if (error) |
57 | { | 57 | { |
58 | *exchange = 0; | 58 | *exchange = 0; |
59 | return(error); | 59 | return error; |
60 | } | 60 | } |
61 | 61 | ||
62 | free_stocks(data); | ||
63 | |||
64 | *exchange = data->CurrentPrice; | 62 | *exchange = data->CurrentPrice; |
65 | return(error); | 63 | free_stocks(data); |
64 | return error; | ||
66 | 65 | ||
67 | } | 66 | } |