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 // mainframe
$frame = new Frame(); $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) //TODO remove: (just temporary fix for tm bug)
if ($this->maniaControl->getMapManager()->getCurrentMap()->getGame() === 'tm') { 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\Quad;
use FML\Controls\Quads\Quad_BgsPlayerCard; use FML\Controls\Quads\Quad_BgsPlayerCard;
use FML\ManiaLink; use FML\ManiaLink;
use FML\Script\Script;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\ManialinkManager; use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Statistics\StatisticManager; use ManiaControl\Statistics\StatisticManager;
@ -25,7 +24,7 @@ class PlayerDetailed {
/* /*
* Constants * Constants
*/ */
const STATS_PER_COLUMN = 13; const STATS_PER_COLUMN = 14;
/* /*
* Private properties * Private properties
@ -46,6 +45,12 @@ class PlayerDetailed {
$this->height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight(); $this->height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
$this->quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowStyle(); $this->quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowStyle();
$this->quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowSubStyle(); $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); $frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script);
$manialink->addChild($frame); $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 //Nation Quad
$countryQuad = new Quad(); $countryQuad = new Quad();
$frame->addChild($countryQuad); $frame->addChild($countryQuad);
$countryQuad->setImageUrl("file://ZoneFlags/Login/{$targetLogin}/country"); $countryQuad->setImageUrl("file://ZoneFlags/Login/{$targetLogin}/country");
$countryQuad->setPosition(-$this->width / 2 + 10, $posY); $countryQuad->setPosition($posX, $posY);
$countryQuad->setSize(5, 5); $countryQuad->setSize(5, 5);
$countryQuad->setZ(-0.1); $countryQuad->setZ(-0.1);
$countryQuad->setHorizontalAlign($countryQuad::LEFT); $countryQuad->setHorizontalAlign($countryQuad::LEFT);
@ -84,19 +88,19 @@ class PlayerDetailed {
//Nickname //Nickname
$label = new Label_Text(); $label = new Label_Text();
$frame->addChild($label); $frame->addChild($label);
$label->setPosition(-$this->width / 2 + 15, $posY); $label->setPosition($posX + 5 + $this->padding, $posY);
$label->setText($target->nickname); $label->setText($target->nickname);
$label->setHorizontalAlign($label::LEFT); $label->setHorizontalAlign($label::LEFT);
//Define MainLabel (Login) //Define MainLabel (Login)
$posY -= 8; $posY = $this->contentY;
$mainLabel = new Label_Text(); $mainLabel = new Label_Text();
$frame->addChild($mainLabel); $frame->addChild($mainLabel);
$mainLabel->setPosition(-$this->width / 2 + 10, $posY); $mainLabel->setPosition($posX, $posY);
$mainLabel->setTextSize(1.2); $mainLabel->setTextSize(1.2);
$mainLabel->setHorizontalAlign($mainLabel::LEFT); $mainLabel->setHorizontalAlign($mainLabel::LEFT);
$mainLabel->setText('Login: '); $mainLabel->setText('Login: ');
$mainLabel->setWidth($colWidth);
$posY -= 5; $posY -= 5;
$label = clone $mainLabel; $label = clone $mainLabel;
@ -141,13 +145,14 @@ class PlayerDetailed {
$label->setText('Avatar'); $label->setText('Avatar');
//Login //Login
$posY = $this->height / 2 - 15; $posY = $this->contentY;
$mainLabel = new Label_Text(); $mainLabel = new Label_Text();
$frame->addChild($mainLabel); $frame->addChild($mainLabel);
$mainLabel->setPosition(-$this->width / 2 + 30, $posY); $mainLabel->setPosition($posX + $colWidth, $posY);
$mainLabel->setText($target->login); $mainLabel->setText($target->login);
$mainLabel->setTextSize(1.2); $mainLabel->setTextSize(1.2);
$mainLabel->setHorizontalAlign($mainLabel::LEFT); $mainLabel->setHorizontalAlign($mainLabel::LEFT);
$mainLabel->setWidth($colWidth);
//Country //Country
$posY -= 5; $posY -= 5;
@ -194,8 +199,8 @@ class PlayerDetailed {
$quad = new Quad(); $quad = new Quad();
$frame->addChild($quad); $frame->addChild($quad);
$quad->setImageUrl('file://Avatars/' . $targetLogin . "/default"); $quad->setImageUrl('file://Avatars/' . $targetLogin . "/default");
$quad->setPosition(-$this->width / 2 + 50, -$this->height / 2 + 34); $quad->setPosition($posX + $colWidth, $posY - 2.5);
$quad->setAlign($quad::RIGHT, $quad::TOP); $quad->setAlign($quad::LEFT, $quad::TOP);
$quad->setSize(20, 20); $quad->setSize(20, 20);
//Statistics //Statistics
@ -223,14 +228,19 @@ class PlayerDetailed {
*/ */
public function statisticsFrame(Player $player) { public function statisticsFrame(Player $player) {
$frame = new Frame(); $frame = new Frame();
$frame->setPosition(-$this->width / 2 + $this->infoColWidth + $this->margin, $this->contentY);
$playerStats = $this->maniaControl->getStatisticManager()->getAllPlayerStats($player); $playerStats = $this->maniaControl->getStatisticManager()->getAllPlayerStats($player);
$posY = $this->height / 2 - 15;
$posX = -$this->width / 2 + 52; $posY = 0;
$posX = 0;
$statisticsColWidth = $this->width - $this->infoColWidth - $this->margin;
$cols = 2;
$colWidth = $statisticsColWidth / $cols;
$index = 1; $index = 1;
foreach ($playerStats as $stat) { foreach ($playerStats as $stat) {
$value = (float)$stat[1]; $value = (float) $stat[1];
if (!$value) { if (!$value) {
continue; continue;
} }
@ -245,32 +255,35 @@ class PlayerDetailed {
if ($index % 2 !== 0) { if ($index % 2 !== 0) {
$lineQuad = new Quad_BgsPlayerCard(); $lineQuad = new Quad_BgsPlayerCard();
$frame->addChild($lineQuad); $frame->addChild($lineQuad);
$lineQuad->setSize(49, 4); $lineQuad->setSize($colWidth, 4);
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig); $lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
$lineQuad->setPosition($posX, $posY, 0.001); $lineQuad->setPosition($posX, $posY, -0.001);
$lineQuad->setHorizontalAlign($lineQuad::LEFT); $lineQuad->setHorizontalAlign($lineQuad::LEFT);
} }
$label = new Label_Text(); $label = new Label_Text();
$frame->addChild($label); $frame->addChild($label);
$label->setPosition($posX + 4, $posY); $label->setPosition($posX + $this->padding, $posY);
$label->setText($statProperties->name); $label->setText($statProperties->name);
$label->setHorizontalAlign($label::LEFT); $label->setHorizontalAlign($label::LEFT);
$label->setTextSize(1.5); $label->setTextSize(1.5);
$label->setWidth($colWidth / 2 - $this->padding);
$label = new Label_Text(); $label = new Label_Text();
$frame->addChild($label); $frame->addChild($label);
$label->setPosition($posX + 40, $posY); $label->setPosition($posX + $colWidth - $this->padding, $posY);
$label->setHorizontalAlign(Label_Text::RIGHT);
$label->setText($value); $label->setText($value);
$label->setTextSize(1.5); $label->setTextSize(1.5);
$label->setWidth($colWidth / 2 - $this->padding);
$posY -= 4; $posY -= 4;
$index++; $index++;
if ($index > self::STATS_PER_COLUMN) { if ($index > self::STATS_PER_COLUMN) {
$posY = $this->height / 2 - 15; $posY = 0;
$posX += 47; $posX += $statisticsColWidth / 2;
$index = 0; $index = 1;
} }
} }
return $frame; return $frame;