Fixed detailed player page

This commit is contained in:
Jocy 2017-04-03 20:59:28 +02:00
parent 4285128795
commit be76e54148
2 changed files with 53 additions and 40 deletions

View File

@ -163,7 +163,7 @@ class StyleManager implements UsageInformationAble {
// mainframe
$frame = new Frame();
$frame->setSize($width, $height)->setZ(45); //TODO place before scoreboards
$frame->setSize($width, $height)->setZ(ManialinkManager::MAIN_MANIALINK_Z_VALUE); //TODO place before scoreboards
//TODO remove: (just temporary fix for tm bug)
if ($this->maniaControl->getMapManager()->getCurrentMap()->getGame() === 'tm') {

View File

@ -8,7 +8,6 @@ use FML\Controls\Labels\Label_Text;
use FML\Controls\Quad;
use FML\Controls\Quads\Quad_BgsPlayerCard;
use FML\ManiaLink;
use FML\Script\Script;
use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Statistics\StatisticManager;
@ -25,7 +24,7 @@ class PlayerDetailed {
/*
* Constants
*/
const STATS_PER_COLUMN = 13;
const STATS_PER_COLUMN = 14;
/*
* Private properties
@ -46,6 +45,12 @@ class PlayerDetailed {
$this->height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
$this->quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowStyle();
$this->quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowSubStyle();
//Class variables
$this->contentY = $this->height / 2 - 15;
$this->infoColWidth = $this->width * 0.3;
$this->margin = 10;
$this->padding = 2;
}
/**
@ -66,17 +71,16 @@ class PlayerDetailed {
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script);
$manialink->addChild($frame);
// Create script and features
$script = new Script();
$manialink->setScript($script);
$posY = $this->height / 2 - 7;
$colWidth = ($this->infoColWidth - $this->padding) / 2;
$posX = -$this->width / 2 + $this->margin;
$posY = $this->contentY + 8;
//Nation Quad
$countryQuad = new Quad();
$frame->addChild($countryQuad);
$countryQuad->setImageUrl("file://ZoneFlags/Login/{$targetLogin}/country");
$countryQuad->setPosition(-$this->width / 2 + 10, $posY);
$countryQuad->setPosition($posX, $posY);
$countryQuad->setSize(5, 5);
$countryQuad->setZ(-0.1);
$countryQuad->setHorizontalAlign($countryQuad::LEFT);
@ -84,108 +88,109 @@ class PlayerDetailed {
//Nickname
$label = new Label_Text();
$frame->addChild($label);
$label->setPosition(-$this->width / 2 + 15, $posY);
$label->setPosition($posX + 5 + $this->padding, $posY);
$label->setText($target->nickname);
$label->setHorizontalAlign($label::LEFT);
//Define MainLabel (Login)
$posY -= 8;
$posY = $this->contentY;
$mainLabel = new Label_Text();
$frame->addChild($mainLabel);
$mainLabel->setPosition(-$this->width / 2 + 10, $posY);
$mainLabel->setPosition($posX, $posY);
$mainLabel->setTextSize(1.2);
$mainLabel->setHorizontalAlign($mainLabel::LEFT);
$mainLabel->setText('Login: ');
$mainLabel->setWidth($colWidth);
$posY -= 5;
$posY -= 5;
$label = clone $mainLabel;
$frame->addChild($label);
$label->setY($posY);
$label->setText('Nation: ');
$posY -= 5;
$posY -= 5;
$label = clone $mainLabel;
$frame->addChild($label);
$label->setY($posY);
$label->setText('Province: ');
$posY -= 5;
$posY -= 5;
$label = clone $mainLabel;
$frame->addChild($label);
$label->setY($posY);
$label->setText('Authorization: ');
$posY -= 5;
$posY -= 5;
$label = clone $mainLabel;
$frame->addChild($label);
$label->setY($posY);
$label->setText("Ladder Rank:");
$posY -= 5;
$posY -= 5;
$label = clone $mainLabel;
$frame->addChild($label);
$label->setY($posY);
$label->setText('Ladder Score: ');
$posY -= 5;
$posY -= 5;
$label = clone $mainLabel;
$frame->addChild($label);
$label->setY($posY);
$label->setText('Inscribed Zone: ');
$posY -= 5;
$posY -= 5;
$label = clone $mainLabel;
$frame->addChild($label);
$label->setY($posY);
$label->setText('Avatar');
//Login
$posY = $this->height / 2 - 15;
$posY = $this->contentY;
$mainLabel = new Label_Text();
$frame->addChild($mainLabel);
$mainLabel->setPosition(-$this->width / 2 + 30, $posY);
$mainLabel->setPosition($posX + $colWidth, $posY);
$mainLabel->setText($target->login);
$mainLabel->setTextSize(1.2);
$mainLabel->setHorizontalAlign($mainLabel::LEFT);
$mainLabel->setWidth($colWidth);
//Country
$posY -= 5;
$posY -= 5;
$label = clone $mainLabel;
$frame->addChild($label);
$label->setY($posY);
$label->setText($target->getCountry());
//Province
$posY -= 5;
$posY -= 5;
$label = clone $mainLabel;
$frame->addChild($label);
$label->setY($posY);
$label->setText($target->getProvince());
//AuthLevel
$posY -= 5;
$posY -= 5;
$label = clone $mainLabel;
$frame->addChild($label);
$label->setY($posY);
$label->setText($this->maniaControl->getAuthenticationManager()->getAuthLevelName($target->authLevel));
//LadderRank
$posY -= 5;
$posY -= 5;
$label = clone $mainLabel;
$frame->addChild($label);
$label->setY($posY);
$label->setText($target->ladderRank);
//LadderScore
$posY -= 5;
$posY -= 5;
$label = clone $mainLabel;
$frame->addChild($label);
$label->setY($posY);
$label->setText(round($target->ladderScore, 2));
//Played Since
$posY -= 5;
$posY -= 5;
$label = clone $mainLabel;
$frame->addChild($label);
$label->setY($posY);
@ -194,8 +199,8 @@ class PlayerDetailed {
$quad = new Quad();
$frame->addChild($quad);
$quad->setImageUrl('file://Avatars/' . $targetLogin . "/default");
$quad->setPosition(-$this->width / 2 + 50, -$this->height / 2 + 34);
$quad->setAlign($quad::RIGHT, $quad::TOP);
$quad->setPosition($posX + $colWidth, $posY - 2.5);
$quad->setAlign($quad::LEFT, $quad::TOP);
$quad->setSize(20, 20);
//Statistics
@ -223,14 +228,19 @@ class PlayerDetailed {
*/
public function statisticsFrame(Player $player) {
$frame = new Frame();
$frame->setPosition(-$this->width / 2 + $this->infoColWidth + $this->margin, $this->contentY);
$playerStats = $this->maniaControl->getStatisticManager()->getAllPlayerStats($player);
$posY = $this->height / 2 - 15;
$posX = -$this->width / 2 + 52;
$index = 1;
$posY = 0;
$posX = 0;
$statisticsColWidth = $this->width - $this->infoColWidth - $this->margin;
$cols = 2;
$colWidth = $statisticsColWidth / $cols;
$index = 1;
foreach ($playerStats as $stat) {
$value = (float)$stat[1];
$value = (float) $stat[1];
if (!$value) {
continue;
}
@ -245,32 +255,35 @@ class PlayerDetailed {
if ($index % 2 !== 0) {
$lineQuad = new Quad_BgsPlayerCard();
$frame->addChild($lineQuad);
$lineQuad->setSize(49, 4);
$lineQuad->setSize($colWidth, 4);
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
$lineQuad->setPosition($posX, $posY, 0.001);
$lineQuad->setPosition($posX, $posY, -0.001);
$lineQuad->setHorizontalAlign($lineQuad::LEFT);
}
$label = new Label_Text();
$frame->addChild($label);
$label->setPosition($posX + 4, $posY);
$label->setPosition($posX + $this->padding, $posY);
$label->setText($statProperties->name);
$label->setHorizontalAlign($label::LEFT);
$label->setTextSize(1.5);
$label->setWidth($colWidth / 2 - $this->padding);
$label = new Label_Text();
$frame->addChild($label);
$label->setPosition($posX + 40, $posY);
$label->setPosition($posX + $colWidth - $this->padding, $posY);
$label->setHorizontalAlign(Label_Text::RIGHT);
$label->setText($value);
$label->setTextSize(1.5);
$label->setWidth($colWidth / 2 - $this->padding);
$posY -= 4;
$index++;
if ($index > self::STATS_PER_COLUMN) {
$posY = $this->height / 2 - 15;
$posX += 47;
$index = 0;
$posY = 0;
$posX += $statisticsColWidth / 2;
$index = 1;
}
}
return $frame;