Пример #1
0
 function display()
 {
     $manialink = $this->request->createLink('/');
     $ui = new \ManiaLib\Gui\Cards\Navigation\Menu();
     $ui->title->setText(\ManiaHost\Config::getInstance()->appName);
     $ui->quitButton->setManialink($manialink);
     $ui->subTitle->setText('Powered by ManiaHost');
     $manialink = $this->request->createLink('../select-duration/');
     if ($this->response->isAvailable) {
         $ui->addItem();
         $ui->lastItem->text->setText('Rent a server');
         $ui->lastItem->setManialink($manialink);
     }
     if ($this->response->isAdmin) {
         $manialink = $this->request->createLinkArgList('/admin/');
         $ui->addItem(Menu::BUTTONS_BOTTOM);
         $ui->lastItem->text->setText('Admin panel');
         $ui->lastItem->icon->setSubStyle(Icons128x128_1::Options);
         $ui->lastItem->setManialink($manialink);
     }
     $ui->save();
     $ui = new \ManiaLib\Gui\Cards\Panel(206, 10);
     $ui->setHalign('center');
     $ui->setPosition(40, 80, 0.1);
     $ui->title->setText('Current rents');
     $ui->save();
     if (!count($this->response->rents)) {
         $ui = new \ManiaLib\Gui\Elements\Label(60);
         $ui->setStyle(\ManiaLib\Gui\Elements\Label::TextInfoMedium);
         $ui->setText('$000You have no rents in progress');
         $ui->setPosition(-60, 55, 0.1);
         $ui->save();
     } else {
         $layout = new \ManiaLib\Gui\Layouts\Column();
         $layout->setMarginHeight(4);
         Manialink::beginFrame(-60, 60, 0.1, 1, $layout);
         foreach ($this->response->rents as $rent) {
             $remaining = $rent->rentDate + $rent->duration * 3600 - time();
             $remaining = round((double) $remaining / 3600, 2);
             $card = new \ManiaHost\Cards\Rent();
             $card->name->setText(sprintf('%s', $rent->serverOptions['Name']));
             if ($rent->login) {
                 $card->login->setText(sprintf('$oserver login$o: %s', $rent->login));
                 $card->setManialink('maniaplanet://#join=' . $rent->login);
             } else {
                 $card->login->setText('Your server will start soon. Refresh the page to see it. If it does not start contact the admin.');
             }
             $card->remainingTime->setText(sprintf('$oRemaining time$o: %s hours', $remaining));
             $this->request->set('idRent', $rent->id);
             $manialink = $this->request->createLink('/rent/renew/');
             $this->request->restore('idRent');
             $card->renew->setText('Renew');
             $card->renew->setManialink($manialink);
             $card->save();
         }
         Manialink::endFrame();
         $this->response->multipage->pageNavigator->setPosition(40, -60);
         $this->response->multipage->savePageNavigator();
     }
 }
Пример #2
0
 function display()
 {
     $ui = new \ManiaLib\Gui\Cards\Navigation\Menu();
     $ui->title->setText(\ManiaHost\Config::getInstance()->appName);
     $ui->subTitle->setText('Select maps');
     $manialink = $this->request->createLinkArgList('../my-maps/');
     $ui->addItem();
     $ui->lastItem->text->setText('My maps');
     $ui->lastItem->icon->setSubStyle(\ManiaLib\Gui\Elements\Icons128x128_1::Browse);
     $ui->lastItem->setManialink($manialink);
     $manialink = $this->request->createLinkArgList('../default-maps/');
     $ui->addItem();
     $ui->lastItem->text->setText('Default maps');
     $ui->lastItem->icon->setSubStyle(\ManiaLib\Gui\Elements\Icons128x128_1::Browse);
     $ui->lastItem->setManialink($manialink);
     $manialink = $this->request->createLinkArgList('../select-map/');
     $ui->quitButton->text->setText('Back');
     $ui->quitButton->setManialink($manialink);
     $ui->save();
     Manialink::beginFrame(40, 65, 0.1);
     $ui = new \ManiaLib\Gui\Cards\Panel(123, 65);
     $ui->setHalign('center');
     $ui->title->setText('Upload');
     $ui->save();
     $ui = new \ManiaLib\Gui\Elements\Label(115);
     $ui->setHalign('center');
     $ui->setPosition(0, -25, 0.1);
     $ui->setText('Your maps will be stored until the end of your rentals');
     $ui->setStyle(\ManiaLib\Gui\Elements\Label::TextTips);
     $ui->save();
     $ui = new \ManiaLib\Gui\Elements\FileEntry(100, 6);
     $ui->setHalign('center');
     $ui->setPosition(0, -35, 0.9);
     $ui->setFolder('Maps');
     $ui->setName('file');
     $ui->save();
     $this->request->set('file', 'file');
     $manialink = $this->request->createLink('../do-upload/');
     $ui = new \ManiaLib\Gui\Elements\Button();
     $ui->setHalign('center');
     $ui->setPosition(0, -45, 0.1);
     $ui->setText('Send');
     $ui->setManialink(sprintf('POST(%s,file)', $manialink));
     $ui->save();
     if ($this->response->message) {
         $ui = new \ManiaLib\Gui\Elements\Label(110);
         $ui->setHalign('center');
         $ui->setPosition(0, -56, 0.1);
         $ui->setStyle(\ManiaLib\Gui\Elements\Label::TextTitleError);
         $ui->setText($this->response->message);
         $ui->save();
     }
     Manialink::endFrame();
     Manialink::beginFrame(40, -10, 0.1);
     $ui = new \ManiaLib\Gui\Cards\Panel(123, 50);
     $ui->setHalign('center');
     $ui->title->setText('Available space');
     $ui->titleBg->setSubStyle(Bgs1::BgTitle3_2);
     $ui->save();
     $ui = new \ManiaLib\Gui\Elements\Label(80);
     $ui->setHalign('center');
     $ui->setPosition(0, -25, 0.1);
     $ui->setText(sprintf('%.2fMo / 20Mo', $this->response->availableSpace / pow(2, 20)));
     $ui->save();
     $ui = new Bgs1(100, 6);
     $ui->setAlign('center', 'center');
     $ui->setPosition(0, -35, 0.1);
     $ui->setSubStyle(Bgs1::BgProgressBar);
     $ui->save();
     $ui = new Bgs1($this->response->hRatioProgressBar * 100, 5);
     $ui->setValign('center');
     $ui->setPosition(-50, -35, 0.2);
     $ui->setSubStyle(Bgs1::ProgressBar);
     $ui->save();
     Manialink::endFrame();
 }