author | imm <imm> | 2002-09-20 21:17:49 (UTC) |
---|---|---|
committer | imm <imm> | 2002-09-20 21:17:49 (UTC) |
commit | 20c93734a4eada53d056f13558cbf60d6eff5bac (patch) (unidiff) | |
tree | 6ee73a9d1e5f9f5426ada0cb58ff60ad74bc876b | |
parent | 7027b4c29de455d457b7d62f52511216a8b76b9c (diff) | |
download | opie-20c93734a4eada53d056f13558cbf60d6eff5bac.zip opie-20c93734a4eada53d056f13558cbf60d6eff5bac.tar.gz opie-20c93734a4eada53d056f13558cbf60d6eff5bac.tar.bz2 |
changed keys
-rw-r--r-- | noncore/games/kpacman/referee.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/noncore/games/kpacman/referee.cpp b/noncore/games/kpacman/referee.cpp index 9edaabd..70916f0 100644 --- a/noncore/games/kpacman/referee.cpp +++ b/noncore/games/kpacman/referee.cpp | |||
@@ -477,729 +477,734 @@ void Referee::fillStrList(QStrList &list, QString values, int max) | |||
477 | values = ""; | 477 | values = ""; |
478 | } | 478 | } |
479 | if (values.find(',') >= 0) { | 479 | if (values.find(',') >= 0) { |
480 | value = values.left(values.find(',')); | 480 | value = values.left(values.find(',')); |
481 | values.remove(0,values.find(',')+1); | 481 | values.remove(0,values.find(',')+1); |
482 | } | 482 | } |
483 | if (!value.isEmpty()) | 483 | if (!value.isEmpty()) |
484 | last = value; | 484 | last = value; |
485 | 485 | ||
486 | list.append(last); | 486 | list.append(last); |
487 | } | 487 | } |
488 | } | 488 | } |
489 | 489 | ||
490 | void Referee::fillMapName() | 490 | void Referee::fillMapName() |
491 | { | 491 | { |
492 | QStrList list = mapName; | 492 | QStrList list = mapName; |
493 | 493 | ||
494 | if (!mapName.isEmpty()) | 494 | if (!mapName.isEmpty()) |
495 | mapName.clear(); | 495 | mapName.clear(); |
496 | 496 | ||
497 | QString map; | 497 | QString map; |
498 | 498 | ||
499 | QFileInfo fileInfo; | 499 | QFileInfo fileInfo; |
500 | 500 | ||
501 | for (uint i = 0; i < list.count(); i++) { | 501 | for (uint i = 0; i < list.count(); i++) { |
502 | map = list.at(i); | 502 | map = list.at(i); |
503 | 503 | ||
504 | if (map.left(1) != "/" && map.left(1) != "~") | 504 | if (map.left(1) != "/" && map.left(1) != "~") |
505 | map = FIND_APP_DATA( mapDirectory+map ); | 505 | map = FIND_APP_DATA( mapDirectory+map ); |
506 | 506 | ||
507 | fileInfo.setFile(map); | 507 | fileInfo.setFile(map); |
508 | if (!fileInfo.isReadable()) | 508 | if (!fileInfo.isReadable()) |
509 | map = ""; | 509 | map = ""; |
510 | 510 | ||
511 | mapName.append(map); | 511 | mapName.append(map); |
512 | } | 512 | } |
513 | } | 513 | } |
514 | 514 | ||
515 | void Referee::confLevels(bool defGroup) | 515 | void Referee::confLevels(bool defGroup) |
516 | { | 516 | { |
517 | APP_CONFIG_BEGIN( cfg ); | 517 | APP_CONFIG_BEGIN( cfg ); |
518 | if (defGroup || cfg->hasKey("Levels")) | 518 | if (defGroup || cfg->hasKey("Levels")) |
519 | maxLevel = cfg->readNumEntry("Levels", 13); | 519 | maxLevel = cfg->readNumEntry("Levels", 13); |
520 | APP_CONFIG_END( cfg ); | 520 | APP_CONFIG_END( cfg ); |
521 | } | 521 | } |
522 | 522 | ||
523 | void Referee::confMisc(bool defGroup) | 523 | void Referee::confMisc(bool defGroup) |
524 | { | 524 | { |
525 | APP_CONFIG_BEGIN( cfg ); | 525 | APP_CONFIG_BEGIN( cfg ); |
526 | if (defGroup || cfg->hasKey("PixmapDirectory")) { | 526 | if (defGroup || cfg->hasKey("PixmapDirectory")) { |
527 | pixmapDirectory = cfg->readEntry("PixmapDirectory"); | 527 | pixmapDirectory = cfg->readEntry("PixmapDirectory"); |
528 | 528 | ||
529 | if (pixmapDirectory.left(1) != "/" && pixmapDirectory.left(1) != "~") | 529 | if (pixmapDirectory.left(1) != "/" && pixmapDirectory.left(1) != "~") |
530 | pixmapDirectory.insert(0, "pics/"); | 530 | pixmapDirectory.insert(0, "pics/"); |
531 | if (pixmapDirectory.right(1) != "/") | 531 | if (pixmapDirectory.right(1) != "/") |
532 | pixmapDirectory.append("/"); | 532 | pixmapDirectory.append("/"); |
533 | } | 533 | } |
534 | 534 | ||
535 | if (defGroup || cfg->hasKey("MapDirectory")) { | 535 | if (defGroup || cfg->hasKey("MapDirectory")) { |
536 | mapDirectory = cfg->readEntry("MapDirectory"); | 536 | mapDirectory = cfg->readEntry("MapDirectory"); |
537 | 537 | ||
538 | if (mapDirectory.left(1) != "/" && mapDirectory.left(1) != "~") | 538 | if (mapDirectory.left(1) != "/" && mapDirectory.left(1) != "~") |
539 | mapDirectory.insert(0, "maps/"); | 539 | mapDirectory.insert(0, "maps/"); |
540 | if (mapDirectory.right(1) != "/") | 540 | if (mapDirectory.right(1) != "/") |
541 | mapDirectory.append("/"); | 541 | mapDirectory.append("/"); |
542 | } | 542 | } |
543 | 543 | ||
544 | if (defGroup || cfg->hasKey("MapName")) | 544 | if (defGroup || cfg->hasKey("MapName")) |
545 | fillStrList(mapName, cfg->readEntry("MapName", "map"), maxLevel+1); | 545 | fillStrList(mapName, cfg->readEntry("MapName", "map"), maxLevel+1); |
546 | 546 | ||
547 | if (defGroup || cfg->hasKey("MonsterIQ")) | 547 | if (defGroup || cfg->hasKey("MonsterIQ")) |
548 | fillArray(monsterIQ, cfg->readEntry("MonsterIQ", "0,170,180,170,180,170,180"), maxLevel+1); | 548 | fillArray(monsterIQ, cfg->readEntry("MonsterIQ", "0,170,180,170,180,170,180"), maxLevel+1); |
549 | if (defGroup || cfg->hasKey("FruitIQ")) | 549 | if (defGroup || cfg->hasKey("FruitIQ")) |
550 | fillArray(fruitIQ, cfg->readEntry("FruitIQ", "0,170,180,170,180,170,180"), maxLevel+1); | 550 | fillArray(fruitIQ, cfg->readEntry("FruitIQ", "0,170,180,170,180,170,180"), maxLevel+1); |
551 | if (defGroup || cfg->hasKey("FruitIndex")) | 551 | if (defGroup || cfg->hasKey("FruitIndex")) |
552 | fillArray(fruitIndex, cfg->readEntry("FruitIndex", "0"), maxLevel+1); | 552 | fillArray(fruitIndex, cfg->readEntry("FruitIndex", "0"), maxLevel+1); |
553 | APP_CONFIG_END( cfg ); | 553 | APP_CONFIG_END( cfg ); |
554 | } | 554 | } |
555 | 555 | ||
556 | void Referee::confTiming(bool defGroup) | 556 | void Referee::confTiming(bool defGroup) |
557 | { | 557 | { |
558 | APP_CONFIG_BEGIN( cfg ); | 558 | APP_CONFIG_BEGIN( cfg ); |
559 | if (defGroup || cfg->hasKey("SpeedMS")) | 559 | if (defGroup || cfg->hasKey("SpeedMS")) |
560 | fillArray(speed, cfg->readEntry("SpeedMS", "20"), maxLevel+1); | 560 | fillArray(speed, cfg->readEntry("SpeedMS", "20"), maxLevel+1); |
561 | if (defGroup || cfg->hasKey("PacmanTicks")) | 561 | if (defGroup || cfg->hasKey("PacmanTicks")) |
562 | fillArray(pacmanTicks,cfg->readEntry("PacmanTicks", "3"), maxLevel+1); | 562 | fillArray(pacmanTicks,cfg->readEntry("PacmanTicks", "3"), maxLevel+1); |
563 | if (defGroup || cfg->hasKey("RemTicks")) | 563 | if (defGroup || cfg->hasKey("RemTicks")) |
564 | fillArray(remTicks, cfg->readEntry("RemTicks", "1"), maxLevel+1); | 564 | fillArray(remTicks, cfg->readEntry("RemTicks", "1"), maxLevel+1); |
565 | if (defGroup || cfg->hasKey("DangerousTicks")) | 565 | if (defGroup || cfg->hasKey("DangerousTicks")) |
566 | fillArray(dangerousTicks, cfg->readEntry("DangerousTicks", "3"), maxLevel+1); | 566 | fillArray(dangerousTicks, cfg->readEntry("DangerousTicks", "3"), maxLevel+1); |
567 | if (defGroup || cfg->hasKey("HarmlessTicks")) | 567 | if (defGroup || cfg->hasKey("HarmlessTicks")) |
568 | fillArray(harmlessTicks, cfg->readEntry("HarmlessTicks", "7,6,,5,,4"), maxLevel+1); | 568 | fillArray(harmlessTicks, cfg->readEntry("HarmlessTicks", "7,6,,5,,4"), maxLevel+1); |
569 | if (defGroup || cfg->hasKey("HarmlessDurationTicks")) | 569 | if (defGroup || cfg->hasKey("HarmlessDurationTicks")) |
570 | fillArray(harmlessDurTicks, cfg->readEntry("HarmlessDurationTicks", "375,,,300,,250,200,150"), maxLevel+1); | 570 | fillArray(harmlessDurTicks, cfg->readEntry("HarmlessDurationTicks", "375,,,300,,250,200,150"), maxLevel+1); |
571 | if (defGroup || cfg->hasKey("HarmlessWarningTicks")) | 571 | if (defGroup || cfg->hasKey("HarmlessWarningTicks")) |
572 | fillArray(harmlessWarnTicks, cfg->readEntry("HarmlessWarningTicks", "135"), maxLevel+1); | 572 | fillArray(harmlessWarnTicks, cfg->readEntry("HarmlessWarningTicks", "135"), maxLevel+1); |
573 | if (defGroup || cfg->hasKey("ArrestTicks")) | 573 | if (defGroup || cfg->hasKey("ArrestTicks")) |
574 | fillArray(arrestTicks, cfg->readEntry("ArrestTicks", "6"), maxLevel+1); | 574 | fillArray(arrestTicks, cfg->readEntry("ArrestTicks", "6"), maxLevel+1); |
575 | if (defGroup || cfg->hasKey("ArrestDurationTicks")) | 575 | if (defGroup || cfg->hasKey("ArrestDurationTicks")) |
576 | fillArray(arrestDurTicks, cfg->readEntry("ArrestDurationTicks", "200,,,150"), maxLevel+1); | 576 | fillArray(arrestDurTicks, cfg->readEntry("ArrestDurationTicks", "200,,,150"), maxLevel+1); |
577 | if (defGroup || cfg->hasKey("FruitTicks")) | 577 | if (defGroup || cfg->hasKey("FruitTicks")) |
578 | fillArray(fruitTicks, cfg->readEntry("FruitTicks", "7,6,,5,,4"), maxLevel+1); | 578 | fillArray(fruitTicks, cfg->readEntry("FruitTicks", "7,6,,5,,4"), maxLevel+1); |
579 | if (defGroup || cfg->hasKey("FruitAppearsTicks")) | 579 | if (defGroup || cfg->hasKey("FruitAppearsTicks")) |
580 | fillArray(fruitAppearsTicks, cfg->readEntry("FruitAppearsTicks", "1000,,1500,2000,2500,3000,3500,4000"), maxLevel+1); | 580 | fillArray(fruitAppearsTicks, cfg->readEntry("FruitAppearsTicks", "1000,,1500,2000,2500,3000,3500,4000"), maxLevel+1); |
581 | if (defGroup || cfg->hasKey("FruitDurationTicks")) | 581 | if (defGroup || cfg->hasKey("FruitDurationTicks")) |
582 | fillArray(fruitDurTicks, cfg->readEntry("FruitDurationTicks", "500,,,400,350,300,,250,200,150"), maxLevel+1); | 582 | fillArray(fruitDurTicks, cfg->readEntry("FruitDurationTicks", "500,,,400,350,300,,250,200,150"), maxLevel+1); |
583 | if (defGroup || cfg->hasKey("FruitScoreDurationTicks")) | 583 | if (defGroup || cfg->hasKey("FruitScoreDurationTicks")) |
584 | fillArray(fruitScoreDurTicks, cfg->readEntry("FruitScoreDurationTicks", "150"), maxLevel+1); | 584 | fillArray(fruitScoreDurTicks, cfg->readEntry("FruitScoreDurationTicks", "150"), maxLevel+1); |
585 | 585 | ||
586 | if (defGroup || cfg->hasKey("MonsterScoreDurationMS")) | 586 | if (defGroup || cfg->hasKey("MonsterScoreDurationMS")) |
587 | monsterScoreDurMS = cfg->readNumEntry("MonsterScoreDurationMS", 1000); | 587 | monsterScoreDurMS = cfg->readNumEntry("MonsterScoreDurationMS", 1000); |
588 | if (defGroup || cfg->hasKey("PlayerDurationMS")) | 588 | if (defGroup || cfg->hasKey("PlayerDurationMS")) |
589 | playerDurMS = cfg->readNumEntry("PlayerDurationMS", 3000); | 589 | playerDurMS = cfg->readNumEntry("PlayerDurationMS", 3000); |
590 | if (defGroup || cfg->hasKey("ReadyDurationMS")) | 590 | if (defGroup || cfg->hasKey("ReadyDurationMS")) |
591 | readyDurMS = cfg->readNumEntry("ReadyDurationMS", 2000); | 591 | readyDurMS = cfg->readNumEntry("ReadyDurationMS", 2000); |
592 | if (defGroup || cfg->hasKey("GameOverDurationMS")) | 592 | if (defGroup || cfg->hasKey("GameOverDurationMS")) |
593 | gameOverDurMS = cfg->readNumEntry("GameOverDurationMS", 3000); | 593 | gameOverDurMS = cfg->readNumEntry("GameOverDurationMS", 3000); |
594 | if (defGroup || cfg->hasKey("AfterPauseMS")) | 594 | if (defGroup || cfg->hasKey("AfterPauseMS")) |
595 | afterPauseMS = cfg->readNumEntry("AfterPauseMS", 1000); | 595 | afterPauseMS = cfg->readNumEntry("AfterPauseMS", 1000); |
596 | if (defGroup || cfg->hasKey("DyingPreAnimationMS")) | 596 | if (defGroup || cfg->hasKey("DyingPreAnimationMS")) |
597 | dyingPreAnimationMS = cfg->readNumEntry("DyingPreAnimationMS", 1000); | 597 | dyingPreAnimationMS = cfg->readNumEntry("DyingPreAnimationMS", 1000); |
598 | if (defGroup || cfg->hasKey("DyingAnimationMS")) | 598 | if (defGroup || cfg->hasKey("DyingAnimationMS")) |
599 | dyingAnimationMS = cfg->readNumEntry("DyingAnimationMS", 100); | 599 | dyingAnimationMS = cfg->readNumEntry("DyingAnimationMS", 100); |
600 | if (defGroup || cfg->hasKey("DyingPostAnimationMS")) | 600 | if (defGroup || cfg->hasKey("DyingPostAnimationMS")) |
601 | dyingPostAnimationMS = cfg->readNumEntry("DyingPostAnimationMS", 500); | 601 | dyingPostAnimationMS = cfg->readNumEntry("DyingPostAnimationMS", 500); |
602 | if (defGroup || cfg->hasKey("IntroAnimationMS")) | 602 | if (defGroup || cfg->hasKey("IntroAnimationMS")) |
603 | introAnimationMS = cfg->readNumEntry("IntroAnimationMS", 800); | 603 | introAnimationMS = cfg->readNumEntry("IntroAnimationMS", 800); |
604 | if (defGroup || cfg->hasKey("IntroPostAnimationMS")) | 604 | if (defGroup || cfg->hasKey("IntroPostAnimationMS")) |
605 | introPostAnimationMS = cfg->readNumEntry("IntroPostAnimationMS", 1000); | 605 | introPostAnimationMS = cfg->readNumEntry("IntroPostAnimationMS", 1000); |
606 | if (defGroup || cfg->hasKey("LevelUpPreAnimationMS")) | 606 | if (defGroup || cfg->hasKey("LevelUpPreAnimationMS")) |
607 | levelUpPreAnimationMS = cfg->readNumEntry("LevelUpPreAnimationMS", 2000); | 607 | levelUpPreAnimationMS = cfg->readNumEntry("LevelUpPreAnimationMS", 2000); |
608 | if (defGroup || cfg->hasKey("LevelUpAnimationMS")) | 608 | if (defGroup || cfg->hasKey("LevelUpAnimationMS")) |
609 | levelUpAnimationMS = cfg->readNumEntry("LevelUpAnimationMS", 2000); | 609 | levelUpAnimationMS = cfg->readNumEntry("LevelUpAnimationMS", 2000); |
610 | if (defGroup || cfg->hasKey("EnergizerAnimationMS")) | 610 | if (defGroup || cfg->hasKey("EnergizerAnimationMS")) |
611 | energizerAnimationMS = cfg->readNumEntry("EnergizerAnimationMS", 200); | 611 | energizerAnimationMS = cfg->readNumEntry("EnergizerAnimationMS", 200); |
612 | APP_CONFIG_END( cfg ); | 612 | APP_CONFIG_END( cfg ); |
613 | } | 613 | } |
614 | 614 | ||
615 | void Referee::confScoring(bool defGroup) | 615 | void Referee::confScoring(bool defGroup) |
616 | { | 616 | { |
617 | APP_CONFIG_BEGIN( cfg ); | 617 | APP_CONFIG_BEGIN( cfg ); |
618 | if (defGroup || cfg->hasKey("PointScore")) | 618 | if (defGroup || cfg->hasKey("PointScore")) |
619 | pointScore = cfg->readNumEntry("PointScore", 10); | 619 | pointScore = cfg->readNumEntry("PointScore", 10); |
620 | if (defGroup || cfg->hasKey("EnergizerScore")) | 620 | if (defGroup || cfg->hasKey("EnergizerScore")) |
621 | energizerScore = cfg->readNumEntry("EnergizerScore", 50); | 621 | energizerScore = cfg->readNumEntry("EnergizerScore", 50); |
622 | if (defGroup || cfg->hasKey("FruitScore")) | 622 | if (defGroup || cfg->hasKey("FruitScore")) |
623 | fillArray(fruitScore, cfg->readEntry("FruitScore", "100,300,500,,700,,1000,,2000,,3000,,5000"), maxLevel+1); | 623 | fillArray(fruitScore, cfg->readEntry("FruitScore", "100,300,500,,700,,1000,,2000,,3000,,5000"), maxLevel+1); |
624 | if (defGroup || cfg->hasKey("MonsterScore")) | 624 | if (defGroup || cfg->hasKey("MonsterScore")) |
625 | fillArray(monsterScore, cfg->readEntry("MonsterScore", "200,400,800,1600"), 4); | 625 | fillArray(monsterScore, cfg->readEntry("MonsterScore", "200,400,800,1600"), 4); |
626 | if (defGroup || cfg->hasKey("ExtraLifeScore")) | 626 | if (defGroup || cfg->hasKey("ExtraLifeScore")) |
627 | fillArray(extraLifeScore, cfg->readEntry("ExtraLifeScore", "10000"), -1); | 627 | fillArray(extraLifeScore, cfg->readEntry("ExtraLifeScore", "10000"), -1); |
628 | APP_CONFIG_END( cfg ); | 628 | APP_CONFIG_END( cfg ); |
629 | } | 629 | } |
630 | 630 | ||
631 | void Referee::confScheme() | 631 | void Referee::confScheme() |
632 | { | 632 | { |
633 | APP_CONFIG_BEGIN( cfg ); | 633 | APP_CONFIG_BEGIN( cfg ); |
634 | SAVE_CONFIG_GROUP( cfg, oldgroup ); | 634 | SAVE_CONFIG_GROUP( cfg, oldgroup ); |
635 | QString newgroup; | 635 | QString newgroup; |
636 | 636 | ||
637 | // if not set, read mode and scheme from the configfile | 637 | // if not set, read mode and scheme from the configfile |
638 | if (mode == -1 && scheme == -1) { | 638 | if (mode == -1 && scheme == -1) { |
639 | scheme = cfg->readNumEntry("Scheme", -1); | 639 | scheme = cfg->readNumEntry("Scheme", -1); |
640 | mode = cfg->readNumEntry("Mode", -1); | 640 | mode = cfg->readNumEntry("Mode", -1); |
641 | 641 | ||
642 | // if mode is not set in the defGroup-group, lookup the scheme group | 642 | // if mode is not set in the defGroup-group, lookup the scheme group |
643 | if (scheme != -1 || mode == -1) { | 643 | if (scheme != -1 || mode == -1) { |
644 | newgroup.sprintf("Scheme %d", scheme); | 644 | newgroup.sprintf("Scheme %d", scheme); |
645 | cfg->setGroup(newgroup); | 645 | cfg->setGroup(newgroup); |
646 | 646 | ||
647 | mode = cfg->readNumEntry("Mode", -1); | 647 | mode = cfg->readNumEntry("Mode", -1); |
648 | RESTORE_CONFIG_GROUP( cfg, oldgroup ); | 648 | RESTORE_CONFIG_GROUP( cfg, oldgroup ); |
649 | } | 649 | } |
650 | } | 650 | } |
651 | 651 | ||
652 | confLevels(); | 652 | confLevels(); |
653 | 653 | ||
654 | if (mode != -1) { | 654 | if (mode != -1) { |
655 | newgroup.sprintf("Mode %d", mode); | 655 | newgroup.sprintf("Mode %d", mode); |
656 | cfg->setGroup(newgroup); | 656 | cfg->setGroup(newgroup); |
657 | 657 | ||
658 | confLevels(FALSE); | 658 | confLevels(FALSE); |
659 | } | 659 | } |
660 | 660 | ||
661 | if (scheme != -1) { | 661 | if (scheme != -1) { |
662 | newgroup.sprintf("Scheme %d", scheme); | 662 | newgroup.sprintf("Scheme %d", scheme); |
663 | cfg->setGroup(newgroup); | 663 | cfg->setGroup(newgroup); |
664 | 664 | ||
665 | confLevels(FALSE); | 665 | confLevels(FALSE); |
666 | } | 666 | } |
667 | 667 | ||
668 | RESTORE_CONFIG_GROUP( cfg, oldgroup ); | 668 | RESTORE_CONFIG_GROUP( cfg, oldgroup ); |
669 | 669 | ||
670 | confMisc(); | 670 | confMisc(); |
671 | confTiming(); | 671 | confTiming(); |
672 | confScoring(); | 672 | confScoring(); |
673 | 673 | ||
674 | if (mode != -1) { | 674 | if (mode != -1) { |
675 | newgroup.sprintf("Mode %d", mode); | 675 | newgroup.sprintf("Mode %d", mode); |
676 | cfg->setGroup(newgroup); | 676 | cfg->setGroup(newgroup); |
677 | 677 | ||
678 | confMisc(FALSE); | 678 | confMisc(FALSE); |
679 | confTiming(FALSE); | 679 | confTiming(FALSE); |
680 | confScoring(FALSE); | 680 | confScoring(FALSE); |
681 | } | 681 | } |
682 | 682 | ||
683 | if (scheme != -1) { | 683 | if (scheme != -1) { |
684 | newgroup.sprintf("Scheme %d", scheme); | 684 | newgroup.sprintf("Scheme %d", scheme); |
685 | cfg->setGroup(newgroup); | 685 | cfg->setGroup(newgroup); |
686 | 686 | ||
687 | confMisc(FALSE); | 687 | confMisc(FALSE); |
688 | confTiming(FALSE); | 688 | confTiming(FALSE); |
689 | confScoring(FALSE); | 689 | confScoring(FALSE); |
690 | } | 690 | } |
691 | 691 | ||
692 | fillMapName(); | 692 | fillMapName(); |
693 | 693 | ||
694 | RESTORE_CONFIG_GROUP( cfg, oldgroup ); | 694 | RESTORE_CONFIG_GROUP( cfg, oldgroup ); |
695 | APP_CONFIG_END( cfg ); | 695 | APP_CONFIG_END( cfg ); |
696 | } | 696 | } |
697 | 697 | ||
698 | void Referee::setScheme(int Scheme, int Mode, Bitfont *font) | 698 | void Referee::setScheme(int Scheme, int Mode, Bitfont *font) |
699 | { | 699 | { |
700 | mode = Mode; | 700 | mode = Mode; |
701 | scheme = Scheme; | 701 | scheme = Scheme; |
702 | 702 | ||
703 | confScheme(); | 703 | confScheme(); |
704 | 704 | ||
705 | pix->setScheme(scheme, mode, font); | 705 | pix->setScheme(scheme, mode, font); |
706 | 706 | ||
707 | pacman->setMaxPixmaps(pix->maxPixmaps(PacmanPix)); | 707 | pacman->setMaxPixmaps(pix->maxPixmaps(PacmanPix)); |
708 | fruit->setMaxPixmaps(pix->maxPixmaps(FruitPix)); | 708 | fruit->setMaxPixmaps(pix->maxPixmaps(FruitPix)); |
709 | 709 | ||
710 | for (Monster *m = monsters->first(); m != 0; m = monsters->next()) | 710 | for (Monster *m = monsters->first(); m != 0; m = monsters->next()) |
711 | if (m) | 711 | if (m) |
712 | m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix)); | 712 | m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix)); |
713 | 713 | ||
714 | for (Energizer *e = energizers->first(); e != 0; e = energizers->next()) | 714 | for (Energizer *e = energizers->first(); e != 0; e = energizers->next()) |
715 | if (e) | 715 | if (e) |
716 | e->setMaxPixmaps(pix->maxPixmaps(EnergizerPix)); | 716 | e->setMaxPixmaps(pix->maxPixmaps(EnergizerPix)); |
717 | 717 | ||
718 | if (gameState.testBit(Introducing)) | 718 | if (gameState.testBit(Introducing)) |
719 | for (int i = 0; i < (gameState.testBit(Init) ? timerCount : 15); i++) | 719 | for (int i = 0; i < (gameState.testBit(Init) ? timerCount : 15); i++) |
720 | introPaint(i); | 720 | introPaint(i); |
721 | 721 | ||
722 | setFixedSize(pix->levelPix().size()); | 722 | setFixedSize(pix->levelPix().size()); |
723 | repaint(); | 723 | repaint(); |
724 | } | 724 | } |
725 | 725 | ||
726 | void Referee::keyPressEvent( QKeyEvent *k ) | 726 | void Referee::keyPressEvent( QKeyEvent *k ) |
727 | { | 727 | { |
728 | uint key = k->key(); | 728 | uint key = k->key(); |
729 | #ifdef QWS | 729 | #ifdef QWS |
730 | // "OK" => new game | 730 | // "OK" => new game |
731 | if ( key == Key_F33 || key == Key_F2 || key == Key_Enter ) | 731 | if ( key == Key_F33 || key == Key_F2 || key == Key_Enter ) |
732 | play(); | 732 | play(); |
733 | else if ( !gameState.testBit(Playing) && key == Key_Space ) | 733 | else if ( !gameState.testBit(Playing) && |
734 | key == Key_Up || | ||
735 | key == Key_Down || | ||
736 | key == Key_Right || | ||
737 | key == Key_Left ) | ||
734 | play(); | 738 | play(); |
735 | // "Space" => pause | 739 | // "Space" => pause |
736 | //else if ( key == Key_Space || key == Key_F3 ) | 740 | //else if ( key == Key_Space || key == Key_F3 ) |
737 | // pause(); | 741 | // pause(); |
738 | // "Menu" => hall of fame | 742 | // "Menu" => hall of fame |
739 | //else if ( key == Key_F11 || key == Key_F4 ) | 743 | //else if ( key == Key_F11 || key == Key_F4 ) |
740 | // toggleHallOfFame(); | 744 | // toggleHallOfFame(); |
741 | #endif | 745 | #endif |
742 | 746 | ||
743 | if (gameState.testBit(Paused) || gameState.testBit(HallOfFame) || | 747 | if (gameState.testBit(Paused) || gameState.testBit(HallOfFame) || |
744 | gameState.testBit(Demonstration) || gameState.testBit(Dying) || | 748 | gameState.testBit(Demonstration) || gameState.testBit(Dying) || |
745 | gameState.testBit(Ready) || gameState.testBit(LevelDone) || | 749 | gameState.testBit(Ready) || gameState.testBit(LevelDone) || |
746 | !gameState.testBit(Playing)) | 750 | !gameState.testBit(Playing)) |
747 | return; | 751 | return; |
748 | 752 | ||
749 | if (key == UpKey) | 753 | if (key == UpKey) |
750 | pacman->setDirection(N); | 754 | pacman->setDirection(N); |
751 | else if (key == DownKey) | 755 | else if (key == DownKey) |
752 | pacman->setDirection(S); | 756 | pacman->setDirection(S); |
753 | else if (key == RightKey) | 757 | else if (key == RightKey) |
754 | pacman->setDirection(E); | 758 | pacman->setDirection(E); |
755 | else if (key == LeftKey) | 759 | else if (key == LeftKey) |
756 | pacman->setDirection(W); | 760 | pacman->setDirection(W); |
757 | 761 | ||
758 | #ifdef CHEATS | 762 | #ifdef CHEATS |
759 | else if (key == Key_L) { printf("levelUp()\n"); levelUp(); } | 763 | else if (key == Key_L) { printf("levelUp()\n"); levelUp(); } |
760 | else if (key == Key_F) { printf("fruit->move(TRUE)\n"); fruit->move(TRUE); repaint(FALSE); } | 764 | else if (key == Key_F) { printf("fruit->move(TRUE)\n"); fruit->move(TRUE); repaint(FALSE); } |
761 | else if (key == Key_E) { printf("setLifes(++lifes)\n"); emit setLifes(++lifes); } | 765 | else if (key == Key_E) { printf("setLifes(++lifes)\n"); emit setLifes(++lifes); } |
762 | #endif | 766 | #endif |
763 | 767 | ||
764 | else { | 768 | else { |
765 | k->ignore(); | 769 | k->ignore(); |
766 | return; | 770 | return; |
767 | } | 771 | } |
768 | k->accept(); | 772 | k->accept(); |
769 | } | 773 | } |
770 | 774 | ||
771 | void Referee::score(int p) | 775 | void Referee::score(int p) |
772 | { | 776 | { |
773 | if (!gameState.testBit(Playing)) | 777 | if (!gameState.testBit(Playing)) |
774 | return; | 778 | return; |
775 | 779 | ||
776 | if ((points += p) < 0) | 780 | if ((points += p) < 0) |
777 | points = 0; | 781 | points = 0; |
778 | 782 | ||
779 | emit setPoints(points); | 783 | emit setPoints(points); |
780 | 784 | ||
781 | if (points >= nextExtraLifeScore) { | 785 | if (points >= nextExtraLifeScore) { |
782 | emit setLifes(++lifes); | 786 | emit setLifes(++lifes); |
783 | if (extraLifeScoreIndex < (int) extraLifeScore.size()-1) | 787 | if (extraLifeScoreIndex < (int) extraLifeScore.size()-1) |
784 | extraLifeScoreIndex++; | 788 | extraLifeScoreIndex++; |
785 | if (extraLifeScore[extraLifeScoreIndex] < 0) | 789 | if (extraLifeScore[extraLifeScoreIndex] < 0) |
786 | nextExtraLifeScore = extraLifeScore[extraLifeScoreIndex] * -1; | 790 | nextExtraLifeScore = extraLifeScore[extraLifeScoreIndex] * -1; |
787 | else | 791 | else |
788 | nextExtraLifeScore += extraLifeScore[extraLifeScoreIndex]; | 792 | nextExtraLifeScore += extraLifeScore[extraLifeScoreIndex]; |
789 | } | 793 | } |
790 | } | 794 | } |
791 | 795 | ||
792 | void Referee::eaten() | 796 | void Referee::eaten() |
793 | { | 797 | { |
794 | if (gameState.testBit(Ready)) | 798 | if (gameState.testBit(Ready)) |
795 | return; | 799 | return; |
796 | 800 | ||
797 | stop(); | 801 | stop(); |
798 | 802 | ||
799 | if (monstersEaten < 4) | 803 | if (monstersEaten < 4) |
800 | monstersEaten++; | 804 | monstersEaten++; |
801 | 805 | ||
802 | gameState.setBit(Scoring); | 806 | gameState.setBit(Scoring); |
803 | score(monsterScore[monstersEaten-1]); | 807 | score(monsterScore[monstersEaten-1]); |
804 | 808 | ||
805 | repaint(pix->rect(pix->rect(pacman->position(), MonsterPix), | 809 | repaint(pix->rect(pix->rect(pacman->position(), MonsterPix), |
806 | pix->rect(pacman->position(), MonsterScorePix, monstersEaten-1))); | 810 | pix->rect(pacman->position(), MonsterScorePix, monstersEaten-1))); |
807 | 811 | ||
808 | if (--timerCount > 0) | 812 | if (--timerCount > 0) |
809 | QTimer::singleShot( monsterScoreDurMS, this, SLOT(eaten())); | 813 | QTimer::singleShot( monsterScoreDurMS, this, SLOT(eaten())); |
810 | else { | 814 | else { |
811 | for (Monster *m = monsters->first(); m != 0; m = monsters->next()) | 815 | for (Monster *m = monsters->first(); m != 0; m = monsters->next()) |
812 | if (m && m->direction() == X && !gameState.testBit(Introducing)) | 816 | if (m && m->direction() == X && !gameState.testBit(Introducing)) |
813 | m->setDirection(N); | 817 | m->setDirection(N); |
814 | if (monstersEaten != 4 || !gameState.testBit(Introducing)) | 818 | if (monstersEaten != 4 || !gameState.testBit(Introducing)) |
815 | QTimer::singleShot( monsterScoreDurMS, this, SLOT(start())); | 819 | QTimer::singleShot( monsterScoreDurMS, this, SLOT(start())); |
816 | } | 820 | } |
817 | } | 821 | } |
818 | 822 | ||
819 | void Referee::toggleHallOfFame() | 823 | void Referee::toggleHallOfFame() |
820 | { | 824 | { |
821 | gameState.toggleBit(HallOfFame); | 825 | gameState.toggleBit(HallOfFame); |
822 | } | 826 | } |
823 | 827 | ||
824 | void Referee::hallOfFame() | 828 | void Referee::hallOfFame() |
825 | { | 829 | { |
826 | if (gameState.testBit(HallOfFame)) // If the HallOfFame is switched on manually, toggle the | 830 | if (gameState.testBit(HallOfFame)) // If the HallOfFame is switched on manually, toggle the |
827 | toggleHallOfFame(); // bit twice. | 831 | toggleHallOfFame(); // bit twice. |
828 | 832 | ||
829 | emit setLevel(0); // Clear status display for hall of fame | 833 | emit setLevel(0); // Clear status display for hall of fame |
830 | emit setScore(level, 0); | 834 | emit setScore(level, 0); |
831 | emit forcedHallOfFame(TRUE); | 835 | emit forcedHallOfFame(TRUE); |
832 | } | 836 | } |
833 | 837 | ||
834 | void Referee::pause() | 838 | void Referee::pause() |
835 | { | 839 | { |
836 | static int pausedTimer = 0; | 840 | static int pausedTimer = 0; |
837 | 841 | ||
838 | if (!gameState.testBit(Paused)) { | 842 | if (!gameState.testBit(Paused)) { |
839 | pausedTimer = gameTimer; | 843 | pausedTimer = gameTimer; |
840 | stop(); | 844 | stop(); |
841 | stopEnergizer(); | 845 | stopEnergizer(); |
842 | gameState.setBit(Paused); | 846 | gameState.setBit(Paused); |
843 | repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED")), FALSE); | 847 | repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED")), FALSE); |
844 | } else { | 848 | } else { |
845 | gameState.clearBit(Paused); | 849 | gameState.clearBit(Paused); |
846 | repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED")), FALSE); | 850 | repaint(pix->rect((BoardWidth*BoardHeight)/2-BoardWidth, tr("PAUSED")), FALSE); |
847 | if (pausedTimer) { | 851 | if (pausedTimer) { |
848 | pausedTimer = 0; | 852 | pausedTimer = 0; |
849 | start(); | 853 | start(); |
850 | } | 854 | } |
851 | } | 855 | } |
852 | emit togglePaused(); | 856 | emit togglePaused(); |
853 | } | 857 | } |
854 | 858 | ||
855 | void Referee::intro() | 859 | void Referee::intro() |
856 | { | 860 | { |
857 | stop(); | 861 | stop(); |
858 | stopEnergizer(); | 862 | stopEnergizer(); |
859 | bool paused = gameState.testBit(Paused); | 863 | bool paused = gameState.testBit(Paused); |
860 | 864 | ||
861 | gameState.fill(FALSE); | 865 | gameState.fill(FALSE); |
862 | gameState.setBit(Introducing); | 866 | gameState.setBit(Introducing); |
863 | gameState.setBit(Init); | 867 | gameState.setBit(Init); |
864 | 868 | ||
865 | if (paused) | 869 | if (paused) |
866 | gameState.setBit(Paused); | 870 | gameState.setBit(Paused); |
867 | 871 | ||
868 | level = 0; | 872 | level = 0; |
869 | emit setLevel(level); | 873 | emit setLevel(level); |
870 | 874 | ||
871 | board->init(Intro); | 875 | board->init(Intro); |
872 | pix->setLevel(level); | 876 | pix->setLevel(level); |
873 | 877 | ||
874 | initPacman(); | 878 | initPacman(); |
875 | initFruit(); | 879 | initFruit(); |
876 | initMonsters(); | 880 | initMonsters(); |
877 | initEnergizers(); | 881 | initEnergizers(); |
878 | 882 | ||
879 | repaint(); | 883 | repaint(); |
880 | 884 | ||
881 | monstersEaten = 0; | 885 | monstersEaten = 0; |
882 | timerCount = 0; | 886 | timerCount = 0; |
883 | introPlay(); | 887 | introPlay(); |
884 | } | 888 | } |
885 | 889 | ||
886 | void Referee::introMonster(int id) | 890 | void Referee::introMonster(int id) |
887 | { | 891 | { |
888 | Monster *m = new Monster(board, id); | 892 | Monster *m = new Monster(board, id); |
889 | 893 | ||
890 | m->setPosition((10+id*6)*BoardWidth+10); | 894 | m->setPosition((10+id*6)*BoardWidth+10); |
891 | m->setDirection(E); | 895 | m->setDirection(E); |
892 | m->setDangerous(dangerousTicks[level], monsterIQ[level]); | 896 | m->setDangerous(dangerousTicks[level], monsterIQ[level]); |
893 | m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix)); | 897 | m->setMaxPixmaps(pix->maxPixmaps(MonsterPix), pix->maxPixmaps(EyesPix)); |
894 | 898 | ||
895 | if (m->body() != -1) | 899 | if (m->body() != -1) |
896 | pix->draw(m->position(), RoomPix, MonsterPix, m->body()); | 900 | pix->draw(m->position(), RoomPix, MonsterPix, m->body()); |
897 | if (m->eyes() != -1) | 901 | if (m->eyes() != -1) |
898 | pix->draw(m->position(), RoomPix, EyesPix, m->eyes()); | 902 | pix->draw(m->position(), RoomPix, EyesPix, m->eyes()); |
899 | 903 | ||
900 | repaint(pix->rect(m->position(), MonsterPix), FALSE); | 904 | repaint(pix->rect(m->position(), MonsterPix), FALSE); |
901 | m->setPosition(OUT); | 905 | m->setPosition(OUT); |
902 | } | 906 | } |
903 | 907 | ||
904 | void Referee::introPaint(int t) | 908 | void Referee::introPaint(int t) |
905 | { | 909 | { |
906 | QString pts; | 910 | QString pts; |
907 | 911 | ||
908 | switch (t) { | 912 | switch (t) { |
909 | case 0 : repaint(pix->draw(16, 6, RoomPix, tr("CHARACTER"), WHITE, QColor(), AlignLeft), FALSE); | 913 | case 0 : repaint(pix->draw(16, 6, RoomPix, tr("CHARACTER"), WHITE, QColor(), AlignLeft), FALSE); |
910 | repaint(pix->draw(36, 6, RoomPix, tr("/"), WHITE, QColor(), AlignLeft), FALSE); | 914 | repaint(pix->draw(36, 6, RoomPix, tr("/"), WHITE, QColor(), AlignLeft), FALSE); |
911 | repaint(pix->draw(40, 6, RoomPix, tr("NICKNAME"), WHITE, QColor(), AlignLeft), FALSE); | 915 | repaint(pix->draw(40, 6, RoomPix, tr("NICKNAME"), WHITE, QColor(), AlignLeft), FALSE); |
912 | break; | 916 | break; |
913 | case 1 : introMonster(0); | 917 | case 1 : introMonster(0); |
914 | break; | 918 | break; |
915 | case 2 : repaint(pix->draw(16, 10, RoomPix, tr("-SHADOW"), RED, QColor(), AlignLeft), FALSE); | 919 | case 2 : repaint(pix->draw(16, 10, RoomPix, tr("-SHADOW"), RED, QColor(), AlignLeft), FALSE); |
916 | break; | 920 | break; |
917 | case 3 : repaint(pix->draw(38, 10, RoomPix, tr("\"BLINKY\""), RED, QColor(), AlignLeft), FALSE); | 921 | case 3 : repaint(pix->draw(38, 10, RoomPix, tr("\"BLINKY\""), RED, QColor(), AlignLeft), FALSE); |
918 | break; | 922 | break; |
919 | case 4 : introMonster(1); | 923 | case 4 : introMonster(1); |
920 | break; | 924 | break; |
921 | case 5 : repaint(pix->draw(16, 16, RoomPix, tr("-SPEEDY"), PINK, QColor(), AlignLeft), FALSE); | 925 | case 5 : repaint(pix->draw(16, 16, RoomPix, tr("-SPEEDY"), PINK, QColor(), AlignLeft), FALSE); |
922 | break; | 926 | break; |
923 | case 6 : repaint(pix->draw(38, 16, RoomPix, tr("\"PINKY\""), PINK, QColor(), AlignLeft), FALSE); | 927 | case 6 : repaint(pix->draw(38, 16, RoomPix, tr("\"PINKY\""), PINK, QColor(), AlignLeft), FALSE); |
924 | break; | 928 | break; |
925 | case 7 : introMonster(2); | 929 | case 7 : introMonster(2); |
926 | break; | 930 | break; |
927 | case 8 : repaint(pix->draw(16, 22, RoomPix, tr("-BASHFUL"), CYAN, QColor(), AlignLeft), FALSE); | 931 | case 8 : repaint(pix->draw(16, 22, RoomPix, tr("-BASHFUL"), CYAN, QColor(), AlignLeft), FALSE); |
928 | break; | 932 | break; |
929 | case 9 : repaint(pix->draw(38, 22, RoomPix, tr("\"INKY\""), CYAN, QColor(), AlignLeft), FALSE); | 933 | case 9 : repaint(pix->draw(38, 22, RoomPix, tr("\"INKY\""), CYAN, QColor(), AlignLeft), FALSE); |
930 | break; | 934 | break; |
931 | case 10 : introMonster(3); | 935 | case 10 : introMonster(3); |
932 | break; | 936 | break; |
933 | case 11 : repaint(pix->draw(16, 28, RoomPix, tr("-POKEY"), ORANGE, QColor(), AlignLeft), FALSE); | 937 | case 11 : repaint(pix->draw(16, 28, RoomPix, tr("-POKEY"), ORANGE, QColor(), AlignLeft), FALSE); |
934 | break; | 938 | break; |
935 | case 12 : repaint(pix->draw(38, 28, RoomPix, tr("\"CLYDE\""), ORANGE, QColor(), AlignLeft), FALSE); | 939 | case 12 : repaint(pix->draw(38, 28, RoomPix, tr("\"CLYDE\""), ORANGE, QColor(), AlignLeft), FALSE); |
936 | break; | 940 | break; |
937 | case 13 : pts.sprintf("%d", pointScore); | 941 | case 13 : pts.sprintf("%d", pointScore); |
938 | repaint(pix->draw(28, 44, RoomPix, pts.data(), WHITE, QColor(), AlignRight), FALSE); | 942 | repaint(pix->draw(28, 44, RoomPix, pts.data(), WHITE, QColor(), AlignRight), FALSE); |
939 | repaint(pix->draw(31, 44, RoomPix, "\x1C\x1D\x1E", WHITE, QColor(), AlignLeft), FALSE); | 943 | repaint(pix->draw(31, 44, RoomPix, "\x1C\x1D\x1E", WHITE, QColor(), AlignLeft), FALSE); |
940 | pts.sprintf("%d", energizerScore); | 944 | pts.sprintf("%d", energizerScore); |
941 | repaint(pix->draw(28, 48, RoomPix, pts.data(), WHITE, QColor(), AlignRight), FALSE); | 945 | repaint(pix->draw(28, 48, RoomPix, pts.data(), WHITE, QColor(), AlignRight), FALSE); |
942 | repaint(pix->draw(31, 48, RoomPix, "\x1C\x1D\x1E", WHITE, QColor(), AlignLeft), FALSE); | 946 | repaint(pix->draw(31, 48, RoomPix, "\x1C\x1D\x1E", WHITE, QColor(), AlignLeft), FALSE); |
943 | break; | 947 | break; |
944 | case 14 : // "@ 1980 MIDWAY MFG.CO." | 948 | case 14 : // "@ 1980 MIDWAY MFG.CO." |
945 | #if defined( KDE2_PORT ) | 949 | #if defined( KDE2_PORT ) |
946 | repaint(pix->draw(30, 58, RoomPix, "© 1998-2002 J.THÖNNISSEN", PINK), FALSE); | 950 | repaint(pix->draw(30, 58, RoomPix, "© 1998-2002 J.THÖNNISSEN", PINK), FALSE); |
947 | #elif defined( QPE_PORT ) | 951 | #elif defined( QPE_PORT ) |
948 | repaint(pix->draw(30, 55, RoomPix, "© 1998-2002 J.THÖNNISSEN", PINK), FALSE); | 952 | repaint(pix->draw(30, 55, RoomPix, "© 1998-2002 J.THÖNNISSEN", PINK), FALSE); |
949 | repaint(pix->draw(29, 60, RoomPix, "Qtopia port: Catalin CLIMOV", GREEN), FALSE); | 953 | repaint(pix->draw(29, 58, RoomPix, tr("QTOPIA PORT: CATALIN CLIMOV"), GREEN), FALSE); |
954 | repaint(pix->draw(29, 61, RoomPix, tr("PRESS CURSOR TO START"), GREEN), FALSE); | ||
950 | #endif | 955 | #endif |
951 | break; | 956 | break; |
952 | } | 957 | } |
953 | } | 958 | } |
954 | 959 | ||
955 | void Referee::introPlay() | 960 | void Referee::introPlay() |
956 | { | 961 | { |
957 | if (!gameState.testBit(Introducing) || gameState.testBit(Ready)) | 962 | if (!gameState.testBit(Introducing) || gameState.testBit(Ready)) |
958 | return; | 963 | return; |
959 | if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { | 964 | if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { |
960 | QTimer::singleShot(afterPauseMS, this, SLOT(introPlay())); | 965 | QTimer::singleShot(afterPauseMS, this, SLOT(introPlay())); |
961 | return; | 966 | return; |
962 | } | 967 | } |
963 | 968 | ||
964 | if (!gameState.testBit(Init)) { | 969 | if (!gameState.testBit(Init)) { |
965 | if (monstersEaten == 4) { | 970 | if (monstersEaten == 4) { |
966 | stop(); | 971 | stop(); |
967 | QTimer::singleShot(introPostAnimationMS, this, SLOT(demo())); | 972 | QTimer::singleShot(introPostAnimationMS, this, SLOT(demo())); |
968 | } | 973 | } |
969 | if (pacman->direction() == W) { | 974 | if (pacman->direction() == W) { |
970 | int id = -1; | 975 | int id = -1; |
971 | if (pacman->position() == 37*BoardWidth-6) | 976 | if (pacman->position() == 37*BoardWidth-6) |
972 | id = 0; | 977 | id = 0; |
973 | else | 978 | else |
974 | if (board->isMonster(37*BoardWidth-6)) | 979 | if (board->isMonster(37*BoardWidth-6)) |
975 | for (Monster *m = monsters->first(); m != 0; m = monsters->next()) | 980 | for (Monster *m = monsters->first(); m != 0; m = monsters->next()) |
976 | if (m && m->position() == 37*BoardWidth-6) { | 981 | if (m && m->position() == 37*BoardWidth-6) { |
977 | id = m->id(); | 982 | id = m->id(); |
978 | id++; | 983 | id++; |
979 | break; | 984 | break; |
980 | } | 985 | } |
981 | 986 | ||
982 | if (id >= 0 && id <= 4) | 987 | if (id >= 0 && id <= 4) |
983 | for (Monster *m = monsters->first(); m != 0; m = monsters->next()) | 988 | for (Monster *m = monsters->first(); m != 0; m = monsters->next()) |
984 | if (m && m->id() == id && m->position() == OUT) { | 989 | if (m && m->id() == id && m->position() == OUT) { |
985 | m->setPosition(37*BoardWidth-1); | 990 | m->setPosition(37*BoardWidth-1); |
986 | m->setDirection(W); | 991 | m->setDirection(W); |
987 | m->setDangerous(dangerousTicks[level], monsterIQ[level]); | 992 | m->setDangerous(dangerousTicks[level], monsterIQ[level]); |
988 | board->set(37*BoardWidth-1, monsterhome, id); | 993 | board->set(37*BoardWidth-1, monsterhome, id); |
989 | repaint(pix->rect(m->position(), MonsterPix)); | 994 | repaint(pix->rect(m->position(), MonsterPix)); |
990 | break; | 995 | break; |
991 | } | 996 | } |
992 | } | 997 | } |
993 | return; | 998 | return; |
994 | } | 999 | } |
995 | 1000 | ||
996 | if (timerCount < 15) | 1001 | if (timerCount < 15) |
997 | introPaint(timerCount); | 1002 | introPaint(timerCount); |
998 | 1003 | ||
999 | switch (timerCount) { | 1004 | switch (timerCount) { |
1000 | case 13 : board->set(44*BoardWidth+22, Point); | 1005 | case 13 : board->set(44*BoardWidth+22, Point); |
1001 | pix->drawPoint(44*BoardWidth+22); | 1006 | pix->drawPoint(44*BoardWidth+22); |
1002 | repaint(pix->rect(44*BoardWidth+22, PointPix), FALSE); | 1007 | repaint(pix->rect(44*BoardWidth+22, PointPix), FALSE); |
1003 | energizers->at(0)->setPosition(48*BoardWidth+22); | 1008 | energizers->at(0)->setPosition(48*BoardWidth+22); |
1004 | energizers->at(0)->setOn(); | 1009 | energizers->at(0)->setOn(); |
1005 | repaint(pix->rect(48*BoardWidth+22, EnergizerPix), FALSE); | 1010 | repaint(pix->rect(48*BoardWidth+22, EnergizerPix), FALSE); |
1006 | break; | 1011 | break; |
1007 | case 14 : energizers->at(1)->setPosition(36*BoardWidth+10); | 1012 | case 14 : energizers->at(1)->setPosition(36*BoardWidth+10); |
1008 | energizers->at(1)->setOn(); | 1013 | energizers->at(1)->setOn(); |
1009 | repaint(pix->rect(36*BoardWidth+10, EnergizerPix), FALSE); | 1014 | repaint(pix->rect(36*BoardWidth+10, EnergizerPix), FALSE); |
1010 | for (int pos = 8; pos < BoardWidth; pos++) { | 1015 | for (int pos = 8; pos < BoardWidth; pos++) { |
1011 | board->set(34*BoardWidth+pos, out); | 1016 | board->set(34*BoardWidth+pos, out); |
1012 | board->set(38*BoardWidth+pos, out); | 1017 | board->set(38*BoardWidth+pos, out); |
1013 | } | 1018 | } |
1014 | board->set(36*BoardWidth+8, out); | 1019 | board->set(36*BoardWidth+8, out); |
1015 | break; | 1020 | break; |
1016 | case 15 : gameState.clearBit(Init); | 1021 | case 15 : gameState.clearBit(Init); |
1017 | initPacman(); | 1022 | initPacman(); |
1018 | pacman->setDemo(TRUE); | 1023 | pacman->setDemo(TRUE); |
1019 | pacman->setPosition(37*BoardWidth-1); | 1024 | pacman->setPosition(37*BoardWidth-1); |
1020 | repaintFigures(); | 1025 | repaintFigures(); |
1021 | start(); | 1026 | start(); |
1022 | return; | 1027 | return; |
1023 | } | 1028 | } |
1024 | 1029 | ||
1025 | if (timerCount++ < 15) | 1030 | if (timerCount++ < 15) |
1026 | QTimer::singleShot(introAnimationMS, this, SLOT(introPlay())); | 1031 | QTimer::singleShot(introAnimationMS, this, SLOT(introPlay())); |
1027 | } | 1032 | } |
1028 | 1033 | ||
1029 | void Referee::demo() | 1034 | void Referee::demo() |
1030 | { | 1035 | { |
1031 | if (gameState.testBit(Ready)) | 1036 | if (gameState.testBit(Ready)) |
1032 | return; | 1037 | return; |
1033 | 1038 | ||
1034 | if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { | 1039 | if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { |
1035 | QTimer::singleShot(afterPauseMS, this, SLOT(demo())); | 1040 | QTimer::singleShot(afterPauseMS, this, SLOT(demo())); |
1036 | return; | 1041 | return; |
1037 | } | 1042 | } |
1038 | 1043 | ||
1039 | stop(); | 1044 | stop(); |
1040 | stopEnergizer(); | 1045 | stopEnergizer(); |
1041 | 1046 | ||
1042 | gameState.fill(FALSE); | 1047 | gameState.fill(FALSE); |
1043 | gameState.setBit(Init); | 1048 | gameState.setBit(Init); |
1044 | gameState.setBit(Demonstration); | 1049 | gameState.setBit(Demonstration); |
1045 | 1050 | ||
1046 | level = 0; | 1051 | level = 0; |
1047 | emit setLevel(level); | 1052 | emit setLevel(level); |
1048 | 1053 | ||
1049 | board->init(Demo, mapName.at(0)); | 1054 | board->init(Demo, mapName.at(0)); |
1050 | pix->setLevel(level); | 1055 | pix->setLevel(level); |
1051 | 1056 | ||
1052 | initPacman(); | 1057 | initPacman(); |
1053 | initFruit(); | 1058 | initFruit(); |
1054 | initMonsters(); | 1059 | initMonsters(); |
1055 | initEnergizers(); | 1060 | initEnergizers(); |
1056 | 1061 | ||
1057 | gameState.clearBit(Init); | 1062 | gameState.clearBit(Init); |
1058 | 1063 | ||
1059 | repaint(); | 1064 | repaint(); |
1060 | 1065 | ||
1061 | timerCount = 0; | 1066 | timerCount = 0; |
1062 | QTimer::singleShot(playerDurMS, this, SLOT(start())); | 1067 | QTimer::singleShot(playerDurMS, this, SLOT(start())); |
1063 | } | 1068 | } |
1064 | 1069 | ||
1065 | void Referee::play() | 1070 | void Referee::play() |
1066 | { | 1071 | { |
1067 | stop(); | 1072 | stop(); |
1068 | stopEnergizer(); | 1073 | stopEnergizer(); |
1069 | 1074 | ||
1070 | gameState.fill(FALSE); | 1075 | gameState.fill(FALSE); |
1071 | gameState.setBit(Init); | 1076 | gameState.setBit(Init); |
1072 | gameState.setBit(Playing); | 1077 | gameState.setBit(Playing); |
1073 | gameState.setBit(Player); | 1078 | gameState.setBit(Player); |
1074 | gameState.setBit(Ready); | 1079 | gameState.setBit(Ready); |
1075 | 1080 | ||
1076 | lifes = 3; | 1081 | lifes = 3; |
1077 | level = 1; | 1082 | level = 1; |
1078 | points = 0; | 1083 | points = 0; |
1079 | 1084 | ||
1080 | extraLifeScoreIndex = 0; | 1085 | extraLifeScoreIndex = 0; |
1081 | nextExtraLifeScore = extraLifeScore[extraLifeScoreIndex]; | 1086 | nextExtraLifeScore = extraLifeScore[extraLifeScoreIndex]; |
1082 | if (nextExtraLifeScore < 0) | 1087 | if (nextExtraLifeScore < 0) |
1083 | nextExtraLifeScore *= -1; | 1088 | nextExtraLifeScore *= -1; |
1084 | 1089 | ||
1085 | board->init(Level, mapName.at(level)); | 1090 | board->init(Level, mapName.at(level)); |
1086 | pix->setLevel(level); | 1091 | pix->setLevel(level); |
1087 | 1092 | ||
1088 | initPacman(); | 1093 | initPacman(); |
1089 | initFruit(); | 1094 | initFruit(); |
1090 | initMonsters(); | 1095 | initMonsters(); |
1091 | initEnergizers(); | 1096 | initEnergizers(); |
1092 | 1097 | ||
1093 | repaint(); | 1098 | repaint(); |
1094 | emit toggleNew(); | 1099 | emit toggleNew(); |
1095 | emit setLifes(lifes); | 1100 | emit setLifes(lifes); |
1096 | emit setLevel(level); | 1101 | emit setLevel(level); |
1097 | emit setPoints(points); | 1102 | emit setPoints(points); |
1098 | 1103 | ||
1099 | repaint(pix->rect(board->position(monsterhome, 0), tr("PLAYER ONE")), FALSE); | 1104 | repaint(pix->rect(board->position(monsterhome, 0), tr("PLAYER ONE")), FALSE); |
1100 | repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE); | 1105 | repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE); |
1101 | 1106 | ||
1102 | timerCount = 0; | 1107 | timerCount = 0; |
1103 | QTimer::singleShot(playerDurMS, this, SLOT(ready())); | 1108 | QTimer::singleShot(playerDurMS, this, SLOT(ready())); |
1104 | } | 1109 | } |
1105 | 1110 | ||
1106 | void Referee::ready() | 1111 | void Referee::ready() |
1107 | { | 1112 | { |
1108 | if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { | 1113 | if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { |
1109 | QTimer::singleShot(afterPauseMS, this, SLOT(ready())); | 1114 | QTimer::singleShot(afterPauseMS, this, SLOT(ready())); |
1110 | return; | 1115 | return; |
1111 | } | 1116 | } |
1112 | 1117 | ||
1113 | if (gameState.testBit(Player)) { | 1118 | if (gameState.testBit(Player)) { |
1114 | emit setLifes(--lifes); | 1119 | emit setLifes(--lifes); |
1115 | gameState.clearBit(Player); | 1120 | gameState.clearBit(Player); |
1116 | gameState.clearBit(Init); | 1121 | gameState.clearBit(Init); |
1117 | repaint(pix->rect(board->position(monsterhome, 0), tr("PLAYER ONE")), FALSE); | 1122 | repaint(pix->rect(board->position(monsterhome, 0), tr("PLAYER ONE")), FALSE); |
1118 | repaintFigures(); | 1123 | repaintFigures(); |
1119 | QTimer::singleShot(playerDurMS, this, SLOT(ready())); | 1124 | QTimer::singleShot(playerDurMS, this, SLOT(ready())); |
1120 | return; | 1125 | return; |
1121 | } | 1126 | } |
1122 | 1127 | ||
1123 | if (gameState.testBit(Ready)) { | 1128 | if (gameState.testBit(Ready)) { |
1124 | gameState.clearBit(Ready); | 1129 | gameState.clearBit(Ready); |
1125 | repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE); | 1130 | repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE); |
1126 | start(); | 1131 | start(); |
1127 | } else { | 1132 | } else { |
1128 | gameState.setBit(Ready); | 1133 | gameState.setBit(Ready); |
1129 | gameState.clearBit(Init); | 1134 | gameState.clearBit(Init); |
1130 | repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE); | 1135 | repaint(pix->rect(board->position(fruithome), tr("READY!")), FALSE); |
1131 | QTimer::singleShot(readyDurMS, this, SLOT(ready())); | 1136 | QTimer::singleShot(readyDurMS, this, SLOT(ready())); |
1132 | } | 1137 | } |
1133 | } | 1138 | } |
1134 | 1139 | ||
1135 | 1140 | ||
1136 | void Referee::levelUp() | 1141 | void Referee::levelUp() |
1137 | { | 1142 | { |
1138 | stop(); | 1143 | stop(); |
1139 | stopEnergizer(); | 1144 | stopEnergizer(); |
1140 | 1145 | ||
1141 | gameState.setBit(LevelDone); | 1146 | gameState.setBit(LevelDone); |
1142 | pacman->setPosition(pacman->position()); // set mouthPosition to "0" | 1147 | pacman->setPosition(pacman->position()); // set mouthPosition to "0" |
1143 | repaint(pix->rect(pacman->position(), PacmanPix)); | 1148 | repaint(pix->rect(pacman->position(), PacmanPix)); |
1144 | 1149 | ||
1145 | timerCount = 0; | 1150 | timerCount = 0; |
1146 | QTimer::singleShot(levelUpPreAnimationMS, this, SLOT(levelUpPlay())); | 1151 | QTimer::singleShot(levelUpPreAnimationMS, this, SLOT(levelUpPlay())); |
1147 | } | 1152 | } |
1148 | 1153 | ||
1149 | void Referee::levelUpPlay() | 1154 | void Referee::levelUpPlay() |
1150 | { | 1155 | { |
1151 | if (gameState.testBit(Ready)) | 1156 | if (gameState.testBit(Ready)) |
1152 | return; | 1157 | return; |
1153 | 1158 | ||
1154 | if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { | 1159 | if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { |
1155 | QTimer::singleShot(afterPauseMS, this, SLOT(levelUpPlay())); | 1160 | QTimer::singleShot(afterPauseMS, this, SLOT(levelUpPlay())); |
1156 | return; | 1161 | return; |
1157 | } | 1162 | } |
1158 | 1163 | ||
1159 | switch (timerCount) { | 1164 | switch (timerCount) { |
1160 | case 0 : gameState.setBit(Init); | 1165 | case 0 : gameState.setBit(Init); |
1161 | setOnEnergizers(); | 1166 | setOnEnergizers(); |
1162 | repaintFigures(); | 1167 | repaintFigures(); |
1163 | break; | 1168 | break; |
1164 | case 1 : gameState.clearBit(LevelDone); | 1169 | case 1 : gameState.clearBit(LevelDone); |
1165 | repaint(pix->rect(pacman->position(), PacmanPix)); | 1170 | repaint(pix->rect(pacman->position(), PacmanPix)); |
1166 | break; | 1171 | break; |
1167 | } | 1172 | } |
1168 | 1173 | ||
1169 | if (timerCount++ < 2) { | 1174 | if (timerCount++ < 2) { |
1170 | QTimer::singleShot(levelUpAnimationMS, this, SLOT(levelUpPlay())); | 1175 | QTimer::singleShot(levelUpAnimationMS, this, SLOT(levelUpPlay())); |
1171 | return; | 1176 | return; |
1172 | } | 1177 | } |
1173 | 1178 | ||
1174 | gameState.clearBit(Init); | 1179 | gameState.clearBit(Init); |
1175 | 1180 | ||
1176 | if (gameState.testBit(Demonstration)) { | 1181 | if (gameState.testBit(Demonstration)) { |
1177 | hallOfFame(); | 1182 | hallOfFame(); |
1178 | return; | 1183 | return; |
1179 | } | 1184 | } |
1180 | 1185 | ||
1181 | if (level < maxLevel) | 1186 | if (level < maxLevel) |
1182 | level++; | 1187 | level++; |
1183 | 1188 | ||
1184 | board->init(Level, mapName.at(level)); | 1189 | board->init(Level, mapName.at(level)); |
1185 | pix->setLevel(level); | 1190 | pix->setLevel(level); |
1186 | 1191 | ||
1187 | initPacman(); | 1192 | initPacman(); |
1188 | initFruit(); | 1193 | initFruit(); |
1189 | initMonsters(); | 1194 | initMonsters(); |
1190 | initEnergizers(); | 1195 | initEnergizers(); |
1191 | 1196 | ||
1192 | repaint(); | 1197 | repaint(); |
1193 | emit setLevel(level); | 1198 | emit setLevel(level); |
1194 | 1199 | ||
1195 | ready(); | 1200 | ready(); |
1196 | } | 1201 | } |
1197 | 1202 | ||
1198 | void Referee::start() | 1203 | void Referee::start() |
1199 | { | 1204 | { |
1200 | if (gameState.testBit(Ready)) | 1205 | if (gameState.testBit(Ready)) |
1201 | return; | 1206 | return; |
1202 | 1207 | ||
1203 | if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { | 1208 | if (gameState.testBit(Paused) || gameState.testBit(HallOfFame)) { |
1204 | QTimer::singleShot(afterPauseMS, this, SLOT(start())); | 1209 | QTimer::singleShot(afterPauseMS, this, SLOT(start())); |
1205 | return; | 1210 | return; |