public function preFilterSize()
 {
     parent::preFilterSize();
     if (!$this->label->getSizenX() && !$this->label->getSizenY()) {
         $this->label->setSizen($this->getSizenX(), $this->getSizenY());
     }
 }
Example #2
0
 static function getTree()
 {
     $manialink = Manialink::create()->setVersion(1)->setBackground('stations')->setNavigable3d(0);
     Timeout::create()->setNodeValue(0)->appendTo($manialink);
     $cellCountX = 4;
     $cellCountY = 3;
     $frame = Frame::create()->setSizen(300, 160)->setPosn(-150, 80, 0)->setLayout(new Flow())->appendTo($manialink);
     $cases = array();
     for ($y = 0; $y < $cellCountY; $y++) {
         for ($x = 0; $x < $cellCountX; $x++) {
             $cases[] = Frame::create()->setSizen(300 / $cellCountX, 160 / $cellCountY)->appendTo($frame)->appendChild(Quad::create()->setSizen(300 / $cellCountX, 160 / $cellCountY)->setBgcolor(($x + $y) % 2 ? 'ccc' : '666'));
         }
     }
     $title = Label::create()->setSizen(300 / $cellCountX - 4, 10)->setPosn(0, -1, 1)->setBothAlign('center', 'top')->setAutonewline(1)->setStyle(LabelStyles::TextValueSmallSm)->setTextSize(2)->setTextcolor('ff0')->appendTo($cases[0]);
     $quad = Quad::create()->setSizen(11, 11)->setBgcolor('f00');
     $frame = Frame::create()->setPosn(15, -15, 1)->appendChild(Quad::create()->setSizen(10, 10)->setPosn(0, 0, 5)->setAlign('center', 'center')->setStyle(Icons64x64_1::QuitRace));
     $frameSize = $frame->getClone()->setSizen(30, 30)->appendChild(Quad::create()->setSizen(30, 30)->setBgcolor('fff5'));
     $frameSizeAlign = $frameSize->getClone()->setAlign('center', 'center')->setPosn(30, -30);
     $elt = $frameSizeAlign->getChildren();
     $elt = reset($elt);
     $elt->setRelativeAlign('center', 'center');
     $frameSizeSmall = $frame->getClone()->setPosn(0, 0, 1)->setSizen(13, 13)->appendChild(Quad::create()->setSizen(13, 13)->setBgcolor('fff5'));
     $quadSmall = $quad->getClone()->setSizen(7, 7);
     $cases[0]->appendChild($title->getClone()->setText('1. Frame + Quad'));
     $cases[0]->appendChild($frame->getClone()->appendChild($quad->getClone()));
     $cases[1]->appendChild($title->getClone()->setText('2. Frame + Quad + Align'));
     $cases[1]->appendChild($frame->getClone()->appendChild($quad->getClone()->setAlign('center', 'center')));
     $cases[2]->appendChild($title->getClone()->setText('3. Frame + Size + Quad'));
     $cases[2]->appendChild($frameSize->getClone()->appendChild($quad->getClone()));
     $cases[3]->appendChild($title->getClone()->setText('4. Frame + Size + Quad + Align'));
     $cases[3]->appendChild($frameSize->getClone()->appendChild($quad->getClone()->setAlign('center', 'center')));
     $cases[4]->appendChild($title->getClone()->setText('5. Frame + Size + Quad + Relative Align'));
     $cases[4]->appendChild($frameSize->getClone()->setPosn(10, -10)->appendChild($quad->getClone()->setRelativeAlign('right', 'bottom')));
     $cases[5]->appendChild($title->getClone()->setText('6. Frame + Size + Quad + Relative Align + Align'));
     $cases[5]->appendChild($frameSize->getClone()->appendChild($quad->getClone()->setRelativeAlign('right', 'bottom')->setAlign('right', 'bottom')));
     $cases[6]->appendChild($title->getClone()->setText('7. Frame + Size + Align + Quad'));
     $cases[6]->appendChild($frameSizeAlign->getClone()->appendChild($quad->getClone()));
     $cases[7]->appendChild($title->getClone()->setText('8. Frame + Size + Align + Quad + Relative Align + Align'));
     $cases[7]->appendChild($frameSizeAlign->getClone()->appendChild($quad->getClone()->setRelativeAlign('right', 'bottom')->setAlign('right', 'bottom')));
     $cases[8]->appendChild($title->getClone()->setText('9. Frame + Size + Align + Frame + Size'));
     $cases[8]->appendChild($frameSizeAlign->getClone()->appendChild($frameSizeSmall->getClone()));
     $cases[9]->appendChild($title->getClone()->setText('10. Frame + Size + Align + Frame + Size + Both Align'));
     $cases[9]->appendChild($frameSizeAlign->getClone()->appendChild($frameSizeSmall->getClone()->setBothAlign('right', 'bottom')));
     $cases[10]->appendChild($title->getClone()->setText('11. Frame + Size + Align + Frame + Size + Both Align + Quad'));
     $cases[10]->appendChild($frameSizeAlign->getClone()->appendChild($frameSizeSmall->getClone()->setBothAlign('right', 'bottom')->appendChild($quadSmall->getClone())));
     $cases[11]->appendChild($title->getClone()->setText('9. Frame + Size + Align + Frame + Size + Both Align + Quad + Both Align'));
     $cases[11]->appendChild($frameSizeAlign->getClone()->appendChild($frameSizeSmall->getClone()->setBothAlign('right', 'bottom')->appendChild($quadSmall->getClone()->setBothAlign('right', 'bottom'))));
     return $manialink;
 }
use ManiaLib\Manialink\Styles\Icons64x64_1;
use ManiaLib\Manialink\Styles\LabelStyles;
use ManiaLib\XML\Rendering\Renderer;
error_reporting(E_ALL);
$manialink = Manialink::create()->setVersion(1)->setBackground('stations')->setNavigable3d(0);
Timeout::create()->setNodeValue(0)->appendTo($manialink);
define('CELL_COUNT_X', 4);
define('CELL_COUNT_Y', 3);
$frame = Frame::create()->setSizen(300, 160)->setPosn(-150, 80, 0)->setLayout(new Flow())->appendTo($manialink);
$cases = array();
for ($y = 0; $y < CELL_COUNT_Y; $y++) {
    for ($x = 0; $x < CELL_COUNT_X; $x++) {
        $cases[] = Frame::create()->setSizen(300 / CELL_COUNT_X, 160 / CELL_COUNT_Y)->appendTo($frame)->appendChild(Quad::create()->setSizen(300 / CELL_COUNT_X, 160 / CELL_COUNT_Y)->setBgcolor(($x + $y) % 2 ? 'ccc' : '666'));
    }
}
$title = Label::create()->setSizen(300 / CELL_COUNT_X - 4, 10)->setPosn(0, -1, 1)->setBothAlign('center', 'top')->setAutonewline(1)->setStyle(LabelStyles::TextValueSmallSm)->setTextSize(2)->setTextcolor('ff0')->appendTo($cases[0]);
$quad = Quad::create()->setSizen(11, 11)->setBgcolor('f00');
$frame = Frame::create()->setPosn(15, -15, 1)->appendChild(Quad::create()->setSizen(10, 10)->setPosn(0, 0, 5)->setAlign('center', 'center')->setStyle(Icons64x64_1::QuitRace));
$frameSize = $frame->getClone()->setSizen(30, 30)->appendChild(Quad::create()->setSizen(30, 30)->setBgcolor('fff5'));
$frameSizeAlign = $frameSize->getClone()->setAlign('center', 'center')->setPosn(30, -30);
$elt = $frameSizeAlign->getChildren();
$elt = reset($elt);
$elt->setRelativeAlign('center', 'center');
$frameSizeSmall = $frame->getClone()->setPosn(0, 0, 1)->setSizen(13, 13)->appendChild(Quad::create()->setSizen(13, 13)->setBgcolor('fff5'));
$quadSmall = $quad->getClone()->setSizen(7, 7);
$cases[0]->appendChild($title->getClone()->setText('1. Frame + Quad'));
$cases[0]->appendChild($frame->getClone()->appendChild($quad->getClone()));
$cases[1]->appendChild($title->getClone()->setText('2. Frame + Quad + Align'));
$cases[1]->appendChild($frame->getClone()->appendChild($quad->getClone()->setAlign('center', 'center')));
$cases[2]->appendChild($title->getClone()->setText('3. Frame + Size + Quad'));
$cases[2]->appendChild($frameSize->getClone()->appendChild($quad->getClone()));
Example #4
0
use Manialib\Manialink\Elements\Frame;
use Manialib\Manialink\Elements\Label;
use Manialib\Manialink\Elements\Manialink;
use Manialib\Manialink\Elements\Quad;
use Manialib\Manialink\Elements\Script;
use Manialib\Manialink\Elements\Timeout;
use Manialib\XML\Fragment;
use Manialib\Manialink\Layouts\Line;
use Manialib\XML\Rendering\Renderer;
use Manialib\Manialink\Styles\Bgs1;
error_reporting(E_ALL);
$ml = new Manialink();
Timeout::create()->setNodeValue(0)->appendTo($ml);
$frame = Frame::create()->setPosn(-150, 80)->appendTo($ml);
Quad::create()->setSizen(50, 10)->setPosn(2, 0, 0.1)->setStyle(Bgs1::BgWindow1)->appendTo($frame);
Label::create()->setSizen(50, 5)->setPosn(0, -15, 0.1)->setText('hello world')->appendTo($frame);
$frame2 = Frame::create()->setPosn(0, -25, 0.1)->setLayout(Line::create()->setMarginWidth(1))->appendTo($frame);
for ($i = 0; $i < 5; $i++) {
    Quad::create()->setSizen(5, 5)->setBgcolor('ccc')->appendTo($frame2);
}
$ui = LabelBox::create()->setPosn(0, -35)->setSizen(100, 10)->appendTo($frame);
$ui->getBg()->setStyle(Bgs1::BgTitle3);
$ui->getLabel()->setText('Much foobar')->setTextSize(4);
$frame2 = Frame::create()->setPosn(0, -50)->setSizen(50, 50)->setAlign('left', 'top')->appendTo($frame);
Quad::create()->setSizen(50, 50)->setBgcolor('eee')->appendTo($frame2);
Quad::create()->setSizen(10, 10)->setPosnZ(0.1)->setAlign('right', 'bottom')->setRelativeAlign('right', 'bottom')->setBgcolor('ccc')->appendTo($frame2);
Script::create()->setNodeValue('main(){ log("Hello world"); } // < &')->appendTo($ml);
Fragment::create()->setNodeValue('<label text="This label is written directly in XML" />')->appendTo($ml);
return $ml;
//This will output:
//<manialink version="1">
use ManiaLib\Manialink\Elements\Frame;
use ManiaLib\Manialink\Elements\Label;
use ManiaLib\Manialink\Elements\Manialink;
use ManiaLib\Manialink\Elements\Quad;
use ManiaLib\Manialink\Elements\Timeout;
use ManiaLib\Manialink\Layouts\Line;
use ManiaLib\Manialink\Styles\Icons64x64_1;
use ManiaLib\Manialink\Styles\LabelStyles;
error_reporting(E_ALL);
$ml = new Manialink();
Timeout::create()->setNodeValue(0)->appendTo($ml);
$alignements = array('left', 'center', 'right');
Label::create()->setText('Line layout examples')->setAlign('center')->setStyle(LabelStyles::TextRaceMessageBig)->setPosn(0, 80)->appendTo($ml);
$contentFrame = Frame::create()->setPosn(-150, 60)->setLayout(Line::create())->appendTo($ml);
foreach ($alignements as $key => $aligmenement) {
    $testFrame = Frame::create()->setSizen(90, 35)->appendTo($contentFrame);
    Label::create()->setBothAlign('center')->setText(sprintf('%s align', ucfirst($aligmenement)))->setStyle(LabelStyles::TextTitle3)->setPosn(0, -3)->appendTo($testFrame);
    Quad::create()->setSizen(6, 6)->setRelativeValign('center')->setAlign('center', 'center')->setPosn(25, -3, 2)->setStyle(Icons64x64_1::QuitRace)->appendTo($testFrame);
    $frame = Frame::create()->setRelativeValign('center')->setPosn(25, -3)->setLayout(Line::create()->setMarginWidth(1))->appendTo($testFrame);
    for ($i = 0; $i < 3; $i++) {
        Quad::create()->setSizen(20, 20)->setAlign($aligmenement, 'center')->setBgcolor('F00')->setOpacity(0.5)->appendTo($frame);
    }
}
$testFrame = Frame::create()->setPosn(-45, 20)->setSizen(90, 35)->appendTo($ml);
Label::create()->setBothAlign('center')->setText('left and right align')->setStyle(LabelStyles::TextTitle3)->setPosn(0, -3)->appendTo($testFrame);
Quad::create()->setSizen(6, 6)->setRelativeValign('center')->setAlign('center', 'center')->setPosn(25, -3, 2)->setStyle(Icons64x64_1::QuitRace)->appendTo($testFrame);
$frame = Frame::create()->setRelativeValign('center')->setPosn(25, -3)->setLayout(Line::create()->setMarginWidth(1))->appendTo($testFrame);
for ($i = 0; $i < 3; $i++) {
    Quad::create()->setSizen(20, 20)->setHalign($i % 2 == 0 ? 'left' : 'right')->setBgcolor('F00')->setOpacity(0.5)->appendTo($frame);
}
return $ml;
Example #6
0
 function preFilter()
 {
     // Set styles
     $this->arrowFastNext->setStyle($this->arrowNoneStyle);
     $this->arrowFastPrev->setStyle($this->arrowNoneStyle);
     $this->arrowFirst->setStyle($this->arrowNoneStyle);
     $this->arrowLast->setStyle($this->arrowNoneStyle);
     $this->arrowPrev->setStyle($this->arrowNoneStyle);
     $this->arrowNext->setStyle($this->arrowNoneStyle);
     // Arrow styles
     if ($this->arrowNext->hasLink()) {
         $this->arrowNext->setStyle($this->arrowNextStyle);
     }
     if ($this->arrowPrev->hasLink()) {
         $this->arrowPrev->setStyle($this->arrowPrevStyle);
     }
     if ($this->arrowNext->hasLink() && $this->arrowFastNext->hasLink()) {
         $this->arrowFastNext->setStyle($this->arrowFastNextStyle);
     } else {
         $this->arrowFastNext->setManialink(null);
     }
     if ($this->arrowPrev->hasLink() && $this->arrowFastPrev->hasLink()) {
         $this->arrowFastPrev->setStyle($this->arrowFastPrevStyle);
     } else {
         $this->arrowFastPrev->setManialink(null);
     }
     if ($this->arrowNext->hasLink() && $this->arrowLast->hasLink()) {
         $this->arrowLast->setStyle($this->arrowLastStyle);
     } else {
         $this->arrowLast->setManialink(null);
     }
     if ($this->arrowPrev->hasLink() && $this->arrowFirst->hasLink()) {
         $this->arrowFirst->setStyle($this->arrowFirstStyle);
     } else {
         $this->arrowFirst->setManialink(null);
     }
     $this->text->setText($this->currentPage . ' / ' . $this->pageNumber);
     $this->text->setAlign('center', 'center2');
     $this->text->setRelativeAlign('center', 'center');
     $this->text->setPosnZ(0.1);
     $this->textBg->setBothAlign('center', 'center');
     $this->arrowNext->setRelativeAlign('center', 'center')->setValign("center");
     $this->arrowFastNext->setRelativeAlign('center', 'center')->setValign("center");
     $this->arrowLast->setRelativeAlign('center', 'center')->setValign("center");
     $this->arrowNext->setPosn((int) $this->showText * $this->text->getSizenX() / 2, 0, 1);
     $this->arrowFastNext->setPosn($this->arrowNext->getPosnX() + $this->arrowNext->getSizenX(), 0, 1);
     $this->arrowLast->setPosn($this->arrowNext->getPosnX() + (int) $this->showFastNext * $this->arrowFastNext->getSizenX() + $this->arrowNext->getSizenX(), 0, 1);
     $this->arrowPrev->setRelativeAlign('center', 'center')->setAlign("right", "center");
     $this->arrowFastPrev->setRelativeAlign('center', 'center')->setAlign("right", "center");
     $this->arrowFirst->setRelativeAlign('center', 'center')->setAlign("right", "center");
     $this->arrowPrev->setPosn(-((int) $this->showText * $this->text->getSizenX() / 2), 0, 1);
     $this->arrowFastPrev->setPosn($this->arrowPrev->getPosnX() - $this->arrowPrev->getSizenX(), 0, 1);
     $this->arrowFirst->setPosn($this->arrowPrev->getPosnX() - (int) $this->showFastNext * $this->arrowFastPrev->getSizenX() - $this->arrowPrev->getSizenX(), 0, 1);
     if ($this->showText) {
         $this->appendChild($this->text);
         $this->appendChild($this->textBg);
     }
     if ($this->showFastNext) {
         $this->appendChild($this->arrowFastNext);
         $this->appendChild($this->arrowFastPrev);
     }
     if ($this->showLast) {
         $this->appendChild($this->arrowFirst);
         $this->appendChild($this->arrowLast);
     }
     $this->appendChild($this->arrowPrev);
     $this->appendChild($this->arrowNext);
 }