function onDraw() { \ManiaLib\Gui\Manialink::appendXML(Dictionary::getInstance()->getManiaLink($this->message)); $this->bg->setVisibility($this->showBackground); $this->setScript($this->countdown, $this->animated, $this->hideOnF6); }
public function display() { Manialink::load(); Manialink::appendXML(Dictionary::getInstance()->getManiaLink($this->displayedText)); Manialink::appendScript(<<<MANIASCRIPT #RequireContext CMlScript #Include "MathLib" as MathLib #Include "TextLib" as TextLib main() { \tdeclare Boolean countdown = True; \tdeclare Integer countdownTime = CurrentTime; \tdeclare Integer countdownTimeLeft = 10; \tdeclare CMlFrame frame <=> (Page.MainFrame.GetFirstChild("block-quit") as CMlFrame); \tdeclare CMlLabel label <=> (Page.MainFrame.GetFirstChild("countdown-label") as CMlLabel); \tlabel.SetText(TextLib::ToText(countdownTimeLeft)); \twhile(True) \t{ \t\tif(countdown && countdownTimeLeft >= 0 && CurrentTime - countdownTime > 1000) \t\t{ \t\t\tcountdownTime = CurrentTime; \t\t\tcountdownTimeLeft = countdownTimeLeft - 1; \t\t\tlabel.SetText(TextLib::ToText(countdownTimeLeft)); \t\t} \t\telse if(countdown && countdownTimeLeft <= 0) \t\t{ \t\t\tframe.Hide(); \t\t} \t\tyield; \t} } MANIASCRIPT ); $frame = new \ManiaLib\Gui\Elements\Frame(); $frame->setPosition(0, 5, 0); $label = new Label(170); $label->setAlign('center', 'center2'); $label->setStyle(Label::TextRaceMessageBig); $label->setTextSize(5); $label->setTextColor('f00'); $label->setTextId('text'); $frame->add($label); $iconBlink = new Icons128x128_Blink(15); $iconBlink->setAlign('right', 'center'); $iconBlink->setPosition(-87, 0); $iconBlink->setSubStyle(Icons128x128_Blink::Hard); $frame->add($iconBlink); $iconBlink = new Icons128x128_Blink(15); $iconBlink->setAlign('left', 'center'); $iconBlink->setPosition(87, 0); $iconBlink->setSubStyle(Icons128x128_Blink::Hard); $frame->add($iconBlink); $frame->save(); $frame = new \ManiaLib\Gui\Elements\Frame(); $frame->setPosition(0, -6.5, 10); $frame->setScriptEvents(); $frame->setId('block-quit'); $bg = new Bgs1(180, 45); $bg->setSubStyle(Bgs1::BgDialogBlur); $bg->setAlign('center'); $bg->setScriptEvents(); $bg->setId('background'); $bg->setManialink(''); $frame->add($bg); $bg = new Quad(180, 45); $bg->setBgcolor('0008'); $bg->setAlign('center'); $bg->setScriptEvents(); $frame->add($bg); $ui = new Label(120); $ui->setAlign('center'); $ui->setPosition(0, -6, 0.1); $ui->setStyle(Label::TextRaceMessageBig); $ui->setTextSize(4); $ui->setTextid('available'); $frame->add($ui); $ui = new Label(20); $ui->setId('countdown-label'); $ui->setAlign('center'); $ui->setPosition(0, -15, 0.1); $ui->setStyle(Label::TextRaceMessageBig); $ui->setTextSize(5); $ui->setText('10'); $frame->add($ui); $frame->save(); return Manialink::render(true); }