Ejemplo n.º 1
0
 public final function save()
 {
     $this->onDraw();
     $posX = $this->posX;
     $posY = $this->posY;
     // horizontal alignment ...
     if ($this->halign == 'right') {
         $posX -= $this->getRealSizeX();
     } else {
         if ($this->halign == 'center') {
             $posX -= $this->getRealSizeX() / 2;
         }
     }
     // vertical alignment ...
     if ($this->valign == 'bottom') {
         $posY += $this->getRealSizeY();
     } else {
         if ($this->valign == 'center') {
             $posY += $this->getRealSizeY() / 2;
         }
     }
     Manialink::beginFrame($posX, $posY, $this->posZ, $this->scale);
     Manialink::setFrameId($this->id);
     if ($this->linksDisabled) {
         Manialink::disableLinks();
     }
     // render each element contained by the control and set z values...
     $zCur = 0;
     foreach ($this->getComponents() as $component) {
         if (!$component->getPosZ()) {
             $component->setPosZ($zCur);
         }
         if ($component instanceof Control) {
             $zCur += $component->save();
         } else {
             $component->save();
             $zCur += self::Z_OFFSET;
         }
     }
     if ($this->linksDisabled) {
         Manialink::enableLinks();
     }
     Manialink::endFrame();
 }
Ejemplo n.º 2
0
 /**
  * Renders the Control and all its Subelements/Subcontrols.
  * Sets all Z-Indexes accordingly to the order of the items.
  */
 final function save()
 {
     if (!$this->visible) {
         return;
     }
     $posX = $this->posX;
     $posY = $this->posY;
     // apply any layout to the underlying elements ...
     $layout = end(Manialink::$parentLayouts);
     if ($layout instanceof AbstractLayout) {
         $layout->preFilter($this);
         $posX += $layout->xIndex;
         $posY += $layout->yIndex;
     }
     $this->onDraw();
     // horizontal alignment ...
     if ($this->halign == 'right') {
         $posX -= $this->getRealSizeX();
     } else {
         if ($this->halign == 'center') {
             $posX -= $this->getRealSizeX() / 2;
         }
     }
     // vertical alignment ...
     if ($this->valign == 'bottom') {
         $posY += $this->getRealSizeY();
     } else {
         if ($this->valign == 'center') {
             $posY += $this->getRealSizeY() / 2;
         }
     }
     // layout cloning, because manialib is used to erase objects after usage. 2 frames because of ManiaLib
     // (someday something better should be done about this)
     Manialink::beginFrame($posX, $posY, $this->posZ, $this->scale);
     if ($this->id !== null) {
         Manialink::setFrameId($this->id);
     }
     if ($this->layout) {
         Manialink::beginFrame(0, 0, 0, null, $this->layout ? clone $this->layout : null);
     }
     if ($this->linksDisabled) {
         Manialink::disableLinks();
     }
     // render each element contained by the control and set z values ...
     $zCur = 0;
     foreach ($this->getComponents() as $component) {
         if (!$component->getPosZ()) {
             $component->setPosZ($zCur);
         }
         if ($component instanceof Control) {
             $zCur += $component->save();
         } else {
             // layouts are modifying position so we need to set it back
             if ($this->layout) {
                 $oldX = $component->getPosX();
                 $oldY = $component->getPosY();
                 $component->save();
                 $component->setPosition($oldX, $oldY);
             } else {
                 $component->save();
             }
             $zCur += Window::Z_OFFSET;
         }
     }
     if ($this->linksDisabled) {
         Manialink::enableLinks();
     }
     if ($this->layout) {
         Manialink::endFrame();
     }
     Manialink::endFrame();
     // post filtering of the drawing process ...
     if ($layout instanceof AbstractLayout) {
         $layout->postFilter($this);
     }
     return $zCur;
 }