ManiaLib 1.0b1 API Reference

Source for file ChallengeCard.class.php

Documentation is available at ChallengeCard.class.php

  1. <?php
  2. /**
  3.  * @author Maxime Raoust
  4.  * @copyright 2009-2010 NADEO
  5.  * @package ManiaLib
  6.  */
  7.  
  8. /**
  9.  * Challenge card
  10.  * Just like challenge cards that can be found when you browse TrackMania's campaigns
  11.  * @package ManiaLib
  12.  * @subpackage GUIToolkit_Cards
  13.  */ 
  14. class ChallengeCard extends Quad
  15. {
  16.     /**
  17.      * @var Quad 
  18.      */
  19.     public $bgImage;
  20.     /**
  21.      * @var Label 
  22.      */
  23.     public $text;
  24.     /**
  25.      * @var Label 
  26.      */
  27.     public $points;
  28.     /**
  29.      * @var Label 
  30.      */
  31.     public $lockedMessage;
  32.     
  33.     /**#@+
  34.      * @ignore
  35.      */
  36.     protected $showArrow false;
  37.     protected $sizeX 16;
  38.     protected $sizeY 17;
  39.     protected $medal;
  40.     protected $clickable true;
  41.     protected $clickableMask;
  42.     protected $clickableLock;
  43.     /**#@-*/
  44.     
  45.     function __construct ()
  46.     {
  47.         $this->setStyle(Quad::BgsChallengeMedals);
  48.         $this->setSubStyle(BgsChallengeMedals::BgNotPlayed);
  49.         
  50.         $this->bgImage = new Quad(1513.5);
  51.         $this->bgImage->setHalign("center");
  52.         $this->bgImage->setPosition(0-0.50);
  53.         
  54.         $this->points = new Label(9);
  55.         $this->points->setPosition(-6.5-10.752);
  56.         
  57.         $this->text = new Label(15);
  58.         $this->text->setPosition(0-144);
  59.         $this->text->setHalign("center");
  60.         $this->text->setStyle(Label::TextChallengeNameSmall);
  61.         
  62.         $this->lockedMessage = new Label(13);
  63.         $this->lockedMessage->setPosition(0-1.52);
  64.         $this->lockedMessage->setHalign("center");
  65.         $this->lockedMessage->enableAutonewline();
  66.         $this->lockedMessage->setStyle(Label::TextRaceChat);
  67.         
  68.         $this->clickableMask new Quad($this->sizeX$this->sizeY);
  69.         $this->clickableMask->setHalign("center");
  70.         $this->clickableMask->setPositionZ(1);
  71.         $this->clickableMask->setStyle(Quad::BgsPlayerCard);
  72.         $this->clickableMask->setSubStyle(BgsPlayerCard::BgPlayerName);
  73.         
  74.         $this->clickableLock new Icon(7.5);
  75.         $this->clickableLock->setPosition(8-142);
  76.         $this->clickableLock->setAlign("right""bottom");
  77.         $this->clickableLock->setSubStyle(Icons128x128_1::Padlock);
  78.     }
  79.     
  80.     /**
  81.      * Whether to show the blue arrow above the challenge icon
  82.      * @param boolean 
  83.      */
  84.     function showArrow($show true)
  85.     {
  86.         $this->showArrow $show;
  87.     }
  88.     
  89.     /**
  90.      * Sets the element un-clickable, dims the challenge icon and displays a
  91.      * lock icon
  92.      */
  93.     function setUnclickable()
  94.     {
  95.         $this->clickable false;
  96.     }
  97.     
  98.     /**
  99.      * @ignore
  100.      */
  101.     protected function preFilter()
  102.     {
  103.         $this->setPositionZ($this->posZ+3);
  104.         
  105.         if($this->showArrow
  106.         {
  107.             $this->setImage("BgsChallengeRace.dds");
  108.         }
  109.     }
  110.     
  111.     /**
  112.      * @ignore
  113.      */
  114.     protected function postFilter()
  115.     {
  116.         // Algin the title and its bg at the top center of the main quad        
  117.         $arr GuiTools::getAlignedPos ($this"center""top");
  118.         $x $arr["x"];
  119.         $y $arr["y"];
  120.         
  121.         Manialink::beginFrame($x$y$this->posZ-3);
  122.             $this->bgImage->save();
  123.             $this->points->save();        
  124.             if(!$this->clickable)
  125.             {
  126.                 $this->clickableMask->save();
  127.                 $this->clickableLock->save();
  128.                 $this->lockedMessage->save();
  129.             }
  130.             $this->text->save();
  131.         Manialink::endFrame();
  132.     }
  133. }
  134.  
  135. ?>