function onNewMemoryValue($newValue) { $lastValue = end($this->memoryStats); $this->memoryStats[] = $newValue; if (count($this->memoryStats) > 10) { array_shift($this->memoryStats); $bar = array_shift($this->bars); $this->barsFrame->removeComponent($bar); } else { $bar = new Quad(); $bar->setSizeX(($this->sizeX - 2) / 10); $bar->setValign('bottom'); } if ($lastValue === false || $lastValue == $newValue) { $bar->setBgcolor('999'); } else { if ($lastValue < $newValue) { $bar->setBgcolor('a00'); } else { $bar->setBgcolor('0a0'); } } $this->barsFrame->addComponent($bar); $this->bars[] = $bar; $heightFactor = 2 * ($this->sizeY - 6) / ceil(3 * max($this->memoryStats)); foreach ($this->bars as $i => $bar) { $bar->setSizeY($this->memoryStats[$i] * $heightFactor); } $i = 1; $step = round(37.5 * max($this->memoryStats) / $this->memoryLimit, 2); foreach ($this->lines as $line) { $line[1]->setText('$fff' . $i++ * $step . '% of total'); } $this->redraw(); }
function __construct($sizeX = 125, $sizeY = 16) { parent::__construct($sizeX, $sizeY); $this->cardElementsValign = 'center'; $this->bg = new \ManiaLib\Gui\Elements\Quad($sizeX, 8); $this->bg->setValign('center'); $this->bg->setSubStyle(\ManiaLib\Gui\Elements\Bgs1::BgList); $this->addCardElement($this->bg); $this->bullet = new \ManiaLib\Gui\Elements\Quad(15, 15); $this->bullet->setValign('center'); $this->bullet->setPosition(0.5, -0.1, 1); $this->addCardElement($this->bullet); $this->title = new \ManiaLib\Gui\Elements\Label(); $this->title->setValign('center'); $this->title->setPosition(10, 0.1, 1); $this->title->setStyle(\ManiaLib\Gui\Elements\Label::TextTitle3); $this->addCardElement($this->title); }
function __construct() { $this->setSize(80, 20); $ui = new Elements\Quad(80, 20); $ui->setImage('http://static.maniaplanet.com/manialinks/elite/PlayerCardBg.dds', true); $this->addComponent($ui); $this->icon = new Elements\Icons64x64_1(18.5, 18.5); $this->icon->setBgcolor('F00'); $this->icon->setAlign('left', 'center'); $this->addComponent($this->icon); $this->label = new Elements\Label(38); $this->label->setPosition(22, -2.5); $this->label->setTextSize(3); $this->label->setStyle(Elements\Label::TextRaceMessage); $this->addComponent($this->label); $this->teamLabel = new Elements\Label(25); $this->teamLabel->setPosition(27, -11.5); $this->teamLabel->setValign('center2'); $this->teamLabel->setStyle(Elements\Label::TextRaceMessage); $this->teamLabel->setTextSize(2); $this->teamLabel->setText('$o$09FLorem$z Ipsum Team'); // $this->addComponent($this->teamLabel); $this->teamIcon = new Elements\Quad(4, 4); $this->teamIcon->setValign('center'); $this->teamIcon->setPosition(22, -11.5); $this->teamIcon->setBgcolor('FF0a'); // $this->addComponent($this->teamIcon); $this->rankLabel = new Elements\Label(30); $this->rankLabel->setAlign('left', 'center2'); $this->rankLabel->setPosition(27, -17.5); $this->rankLabel->setText('-'); $this->rankLabel->setStyle(Elements\Label::TextRaceMessage); $this->rankLabel->setTextSize(1); $this->addComponent($this->rankLabel); $this->countryFlag = new Elements\Quad(4, 4); $this->countryFlag->setAlign('left', 'center'); $this->countryFlag->setPosition(22, -17.5); $this->addComponent($this->countryFlag); $frame = new \ManiaLive\Gui\Controls\Frame(72, 0); $frame->setScale(1.13); $frame->setPosZ(0.1); $this->addComponent($frame); $this->echelonQuad = new Elements\Quad(14.1551, 17.6938); $this->echelonQuad->setAlign('center', 'top'); $frame->addComponent($this->echelonQuad); $ui = new Elements\Label(15); $ui->setAlign('center', 'top'); $ui->setStyle(Elements\Label::TextRaceMessage); $ui->setPosition(-0.25, -3.6); $ui->setTextSize(0.5); $ui->setText('Echelon'); $frame->addComponent($ui); $this->echelonLabel = new Elements\Label(10, 10); $this->echelonLabel->setAlign('center', 'center'); $this->echelonLabel->setPosition(-0.25, -10.6); $this->echelonLabel->setStyle(Elements\Label::TextRaceMessageBig); $frame->addComponent($this->echelonLabel); $this->disableQuad = new Elements\Quad(80, 20); $this->disableQuad->setBgcolor('333A'); $this->disableQuad->setVisibility(false); $this->disableQuad->setPosZ(3); $this->addComponent($this->disableQuad); }
function onNewNetworkValue($newValue) { $this->networkSums[] = $newValue[0] + $newValue[1]; $this->networkStats[] = $newValue; if (count($this->networkSums) > 10) { array_shift($this->networkSums); array_shift($this->networkStats); $bars = array_shift($this->bars); $this->barsFrame->removeComponent($bars[2]); } else { $frame = new Frame(); $frame->setSizeX(($this->sizeX - 2) / 10); $sentBar = new Quad(); $sentBar->setSizeX(($this->sizeX - 2) / 10); $sentBar->setBgcolor('a00'); $sentBar->setValign('bottom'); $frame->addComponent($sentBar); $receivedBar = new Quad(); $receivedBar->setSizeX(($this->sizeX - 2) / 10); $receivedBar->setBgcolor('0a0'); $receivedBar->setValign('bottom'); $frame->addComponent($receivedBar); $bars = array($sentBar, $receivedBar, $frame); } $this->barsFrame->addComponent($bars[2]); $this->bars[] = $bars; $heightFactor = ($this->sizeY - 6) / max(51200, 1.2 * max($this->networkSums)); foreach ($this->bars as $i => $bars) { $bars[0]->setSizeY($this->networkStats[$i][1] * $heightFactor); $bars[1]->setSizeY($this->networkStats[$i][0] * $heightFactor); $bars[1]->setPosY($bars[0]->getRealSizeY()); } $i = 1; $step = max(51200, 1.2 * max($this->networkSums)) / 4096; foreach ($this->lines as $line) { $line[1]->setText('$fff' . round($i++ * $step) . ' kb/s'); } $this->redraw(); }
function onNewCpuValue($newValue) { $this->cpuStats[] = $newValue; if (count($this->cpuStats) > 10) { array_shift($this->cpuStats); $bar = array_shift($this->bars); $this->barsFrame->removeComponent($bar); } else { $bar = new Quad(); $bar->setSizeX(($this->sizeX - 2) / 10); $bar->setValign('bottom'); } $this->barsFrame->addComponent($bar); $this->bars[] = $bar; $iColor = 0; $heightFactor = ($this->sizeY - 6) / max(self::RESPONSE_OPTIMAL, max($this->cpuStats)); foreach ($this->bars as $i => $bar) { $color = dechex($iColor++); $bar->setBgcolor($color . $color . $color); $bar->setSizeY($this->cpuStats[$i] * $heightFactor); } $this->redraw(); }