2014-01-03 16:24:03 +01:00
|
|
|
<?php
|
2014-01-03 16:24:35 +01:00
|
|
|
|
|
|
|
namespace ManiaControl\Players;
|
2014-01-03 21:16:20 +01:00
|
|
|
|
2014-01-03 16:24:35 +01:00
|
|
|
use FML\Controls\Frame;
|
2014-01-05 00:02:13 +01:00
|
|
|
use FML\Controls\Labels\Label_Button;
|
2014-01-03 17:09:24 +01:00
|
|
|
use FML\Controls\Labels\Label_Text;
|
2014-01-03 16:24:35 +01:00
|
|
|
use FML\Controls\Quad;
|
2014-01-03 19:41:00 +01:00
|
|
|
use FML\Controls\Quads\Quad_BgsPlayerCard;
|
2014-01-03 16:24:35 +01:00
|
|
|
use FML\ManiaLink;
|
|
|
|
use ManiaControl\ManiaControl;
|
|
|
|
use ManiaControl\Manialinks\ManialinkManager;
|
2014-01-03 19:14:07 +01:00
|
|
|
use ManiaControl\Statistics\StatisticManager;
|
2014-05-13 17:59:37 +02:00
|
|
|
use ManiaControl\Utils\Formatter;
|
2014-01-03 16:24:35 +01:00
|
|
|
|
2014-01-03 16:24:03 +01:00
|
|
|
/**
|
2014-01-03 16:24:35 +01:00
|
|
|
* Player Detailed Page
|
|
|
|
*
|
2014-05-02 17:50:30 +02:00
|
|
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
2017-02-04 11:49:23 +01:00
|
|
|
* @copyright 2014-2017 ManiaControl Team
|
2014-05-02 17:50:30 +02:00
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
2014-01-03 16:24:03 +01:00
|
|
|
*/
|
2014-01-03 16:24:35 +01:00
|
|
|
class PlayerDetailed {
|
2014-04-12 12:14:37 +02:00
|
|
|
/*
|
2014-01-28 22:27:33 +01:00
|
|
|
* Constants
|
|
|
|
*/
|
2017-04-03 20:59:28 +02:00
|
|
|
const STATS_PER_COLUMN = 14;
|
2014-01-03 16:24:03 +01:00
|
|
|
|
2014-04-12 12:14:37 +02:00
|
|
|
/*
|
2014-08-02 22:31:46 +02:00
|
|
|
* Private properties
|
2014-01-03 16:24:35 +01:00
|
|
|
*/
|
2014-08-02 22:31:46 +02:00
|
|
|
/** @var ManiaControl $maniaControl */
|
2014-01-03 16:24:35 +01:00
|
|
|
private $maniaControl = null;
|
2014-01-03 16:24:03 +01:00
|
|
|
|
2014-01-03 16:24:35 +01:00
|
|
|
/**
|
2014-05-13 17:59:37 +02:00
|
|
|
* Create a new Player Detailed Instance
|
2014-01-03 16:24:35 +01:00
|
|
|
*
|
|
|
|
* @param ManiaControl $maniaControl
|
|
|
|
*/
|
|
|
|
public function __construct(ManiaControl $maniaControl) {
|
|
|
|
$this->maniaControl = $maniaControl;
|
|
|
|
|
2014-08-03 01:34:18 +02:00
|
|
|
// Settings
|
2014-08-13 11:05:52 +02:00
|
|
|
$this->width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
|
|
|
|
$this->height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
|
|
|
|
$this->quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowStyle();
|
|
|
|
$this->quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultMainWindowSubStyle();
|
2017-04-03 20:59:28 +02:00
|
|
|
|
|
|
|
//Class variables
|
|
|
|
$this->contentY = $this->height / 2 - 15;
|
|
|
|
$this->infoColWidth = $this->width * 0.3;
|
|
|
|
$this->margin = 10;
|
|
|
|
$this->padding = 2;
|
2014-01-03 16:24:35 +01:00
|
|
|
}
|
|
|
|
|
2014-05-02 16:13:45 +02:00
|
|
|
/**
|
|
|
|
* Show a Frame with detailed Information about the Target Player
|
|
|
|
*
|
|
|
|
* @param Player $player
|
|
|
|
* @param string $targetLogin
|
|
|
|
*/
|
2014-01-03 16:24:35 +01:00
|
|
|
public function showPlayerDetailed(Player $player, $targetLogin) {
|
2014-05-02 16:13:45 +02:00
|
|
|
/** @var Player $target */
|
2014-08-13 11:05:52 +02:00
|
|
|
$target = $this->maniaControl->getPlayerManager()->getPlayer($targetLogin);
|
2014-01-28 22:27:33 +01:00
|
|
|
|
2014-08-03 01:34:18 +02:00
|
|
|
// Create ManiaLink
|
2017-03-25 19:15:50 +01:00
|
|
|
$manialink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
|
|
|
$script = $manialink->getScript();
|
2014-01-28 22:27:33 +01:00
|
|
|
|
|
|
|
// Main frame
|
2014-08-13 11:05:52 +02:00
|
|
|
$frame = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultListFrame($script);
|
2017-03-25 19:15:50 +01:00
|
|
|
$manialink->addChild($frame);
|
2014-01-03 16:24:35 +01:00
|
|
|
|
|
|
|
|
2017-04-03 20:59:28 +02:00
|
|
|
$colWidth = ($this->infoColWidth - $this->padding) / 2;
|
|
|
|
$posX = -$this->width / 2 + $this->margin;
|
2014-01-03 20:29:42 +01:00
|
|
|
|
2017-04-03 20:59:28 +02:00
|
|
|
$posY = $this->contentY + 8;
|
2014-01-03 20:29:42 +01:00
|
|
|
//Nation Quad
|
|
|
|
$countryQuad = new Quad();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($countryQuad);
|
|
|
|
$countryQuad->setImageUrl("file://ZoneFlags/Login/{$targetLogin}/country");
|
2017-04-03 20:59:28 +02:00
|
|
|
$countryQuad->setPosition($posX, $posY);
|
2014-01-03 20:29:42 +01:00
|
|
|
$countryQuad->setSize(5, 5);
|
|
|
|
$countryQuad->setZ(-0.1);
|
2017-03-25 19:15:50 +01:00
|
|
|
$countryQuad->setHorizontalAlign($countryQuad::LEFT);
|
2014-01-03 20:29:42 +01:00
|
|
|
|
2014-01-03 17:09:24 +01:00
|
|
|
//Nickname
|
|
|
|
$label = new Label_Text();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($label);
|
2017-04-03 20:59:28 +02:00
|
|
|
$label->setPosition($posX + 5 + $this->padding, $posY);
|
2014-01-03 17:09:24 +01:00
|
|
|
$label->setText($target->nickname);
|
2017-03-25 19:15:50 +01:00
|
|
|
$label->setHorizontalAlign($label::LEFT);
|
2014-01-03 17:09:24 +01:00
|
|
|
|
|
|
|
//Define MainLabel (Login)
|
2017-04-03 20:59:28 +02:00
|
|
|
$posY = $this->contentY;
|
2014-01-03 17:09:24 +01:00
|
|
|
$mainLabel = new Label_Text();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($mainLabel);
|
2017-04-03 20:59:28 +02:00
|
|
|
$mainLabel->setPosition($posX, $posY);
|
2014-01-03 17:09:24 +01:00
|
|
|
$mainLabel->setTextSize(1.2);
|
2017-03-25 19:15:50 +01:00
|
|
|
$mainLabel->setHorizontalAlign($mainLabel::LEFT);
|
2014-06-22 19:02:18 +02:00
|
|
|
$mainLabel->setText('Login: ');
|
2017-04-03 20:59:28 +02:00
|
|
|
$mainLabel->setWidth($colWidth);
|
2014-01-03 17:09:24 +01:00
|
|
|
|
2017-04-03 20:59:28 +02:00
|
|
|
$posY -= 5;
|
2014-01-03 17:09:24 +01:00
|
|
|
$label = clone $mainLabel;
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($label);
|
2014-06-14 15:48:27 +02:00
|
|
|
$label->setY($posY);
|
2014-06-22 19:02:18 +02:00
|
|
|
$label->setText('Nation: ');
|
2014-01-03 17:09:24 +01:00
|
|
|
|
2017-04-03 20:59:28 +02:00
|
|
|
$posY -= 5;
|
2014-01-03 17:09:24 +01:00
|
|
|
$label = clone $mainLabel;
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($label);
|
2014-06-14 15:48:27 +02:00
|
|
|
$label->setY($posY);
|
2014-06-22 19:02:18 +02:00
|
|
|
$label->setText('Province: ');
|
2014-01-03 17:09:24 +01:00
|
|
|
|
2017-04-03 20:59:28 +02:00
|
|
|
$posY -= 5;
|
2014-01-03 17:09:24 +01:00
|
|
|
$label = clone $mainLabel;
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($label);
|
2014-06-14 15:48:27 +02:00
|
|
|
$label->setY($posY);
|
2014-06-22 19:02:18 +02:00
|
|
|
$label->setText('Authorization: ');
|
2014-01-03 17:09:24 +01:00
|
|
|
|
2017-04-03 20:59:28 +02:00
|
|
|
$posY -= 5;
|
2014-01-03 17:09:24 +01:00
|
|
|
$label = clone $mainLabel;
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($label);
|
2014-06-14 15:48:27 +02:00
|
|
|
$label->setY($posY);
|
2014-01-03 17:09:24 +01:00
|
|
|
$label->setText("Ladder Rank:");
|
|
|
|
|
2017-04-03 20:59:28 +02:00
|
|
|
$posY -= 5;
|
2014-01-03 17:09:24 +01:00
|
|
|
$label = clone $mainLabel;
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($label);
|
2014-06-14 15:48:27 +02:00
|
|
|
$label->setY($posY);
|
2014-06-22 19:02:18 +02:00
|
|
|
$label->setText('Ladder Score: ');
|
2014-01-03 17:09:24 +01:00
|
|
|
|
2017-04-03 20:59:28 +02:00
|
|
|
$posY -= 5;
|
2014-01-03 17:09:24 +01:00
|
|
|
$label = clone $mainLabel;
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($label);
|
2014-06-14 15:48:27 +02:00
|
|
|
$label->setY($posY);
|
2014-06-22 19:02:18 +02:00
|
|
|
$label->setText('Inscribed Zone: ');
|
2014-01-28 22:27:33 +01:00
|
|
|
|
2017-04-03 20:59:28 +02:00
|
|
|
$posY -= 5;
|
2014-01-28 22:27:33 +01:00
|
|
|
$label = clone $mainLabel;
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($label);
|
2014-06-14 15:48:27 +02:00
|
|
|
$label->setY($posY);
|
2014-01-28 22:27:33 +01:00
|
|
|
$label->setText('Avatar');
|
2014-01-03 17:09:24 +01:00
|
|
|
|
|
|
|
//Login
|
2017-04-03 20:59:28 +02:00
|
|
|
$posY = $this->contentY;
|
2014-01-03 17:09:24 +01:00
|
|
|
$mainLabel = new Label_Text();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($mainLabel);
|
2017-04-03 20:59:28 +02:00
|
|
|
$mainLabel->setPosition($posX + $colWidth, $posY);
|
2014-01-03 17:09:24 +01:00
|
|
|
$mainLabel->setText($target->login);
|
|
|
|
$mainLabel->setTextSize(1.2);
|
2017-03-25 19:15:50 +01:00
|
|
|
$mainLabel->setHorizontalAlign($mainLabel::LEFT);
|
2017-04-03 20:59:28 +02:00
|
|
|
$mainLabel->setWidth($colWidth);
|
2014-01-03 17:09:24 +01:00
|
|
|
|
|
|
|
//Country
|
2017-04-03 20:59:28 +02:00
|
|
|
$posY -= 5;
|
2014-01-03 17:09:24 +01:00
|
|
|
$label = clone $mainLabel;
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($label);
|
2014-06-14 15:48:27 +02:00
|
|
|
$label->setY($posY);
|
2014-01-03 17:09:24 +01:00
|
|
|
$label->setText($target->getCountry());
|
|
|
|
|
|
|
|
//Province
|
2017-04-03 20:59:28 +02:00
|
|
|
$posY -= 5;
|
2014-01-03 17:09:24 +01:00
|
|
|
$label = clone $mainLabel;
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($label);
|
2014-06-14 15:48:27 +02:00
|
|
|
$label->setY($posY);
|
2014-01-03 17:09:24 +01:00
|
|
|
$label->setText($target->getProvince());
|
|
|
|
|
|
|
|
//AuthLevel
|
2017-04-03 20:59:28 +02:00
|
|
|
$posY -= 5;
|
2014-01-03 17:09:24 +01:00
|
|
|
$label = clone $mainLabel;
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($label);
|
2014-06-14 15:48:27 +02:00
|
|
|
$label->setY($posY);
|
2014-08-13 11:05:52 +02:00
|
|
|
$label->setText($this->maniaControl->getAuthenticationManager()->getAuthLevelName($target->authLevel));
|
2014-01-03 17:09:24 +01:00
|
|
|
|
|
|
|
//LadderRank
|
2017-04-03 20:59:28 +02:00
|
|
|
$posY -= 5;
|
2014-01-03 17:09:24 +01:00
|
|
|
$label = clone $mainLabel;
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($label);
|
2014-06-14 15:48:27 +02:00
|
|
|
$label->setY($posY);
|
2014-01-03 17:09:24 +01:00
|
|
|
$label->setText($target->ladderRank);
|
|
|
|
|
|
|
|
//LadderScore
|
2017-04-03 20:59:28 +02:00
|
|
|
$posY -= 5;
|
2014-01-03 17:09:24 +01:00
|
|
|
$label = clone $mainLabel;
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($label);
|
2014-06-14 15:48:27 +02:00
|
|
|
$label->setY($posY);
|
2014-01-03 21:16:20 +01:00
|
|
|
$label->setText(round($target->ladderScore, 2));
|
2014-01-03 17:09:24 +01:00
|
|
|
|
|
|
|
//Played Since
|
2017-04-03 20:59:28 +02:00
|
|
|
$posY -= 5;
|
2014-01-03 17:09:24 +01:00
|
|
|
$label = clone $mainLabel;
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($label);
|
2014-06-14 15:48:27 +02:00
|
|
|
$label->setY($posY);
|
2014-06-22 19:02:18 +02:00
|
|
|
$label->setText(date('d M Y', time() - 3600 * 24 * $target->daysSinceZoneInscription));
|
2014-01-03 17:09:24 +01:00
|
|
|
|
|
|
|
$quad = new Quad();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($quad);
|
|
|
|
$quad->setImageUrl('file://Avatars/' . $targetLogin . "/default");
|
2017-04-03 20:59:28 +02:00
|
|
|
$quad->setPosition($posX + $colWidth, $posY - 2.5);
|
|
|
|
$quad->setAlign($quad::LEFT, $quad::TOP);
|
2014-01-03 17:09:24 +01:00
|
|
|
$quad->setSize(20, 20);
|
|
|
|
|
2014-01-03 17:36:10 +01:00
|
|
|
//Statistics
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($this->statisticsFrame($target));
|
2014-01-03 17:09:24 +01:00
|
|
|
|
|
|
|
|
2014-01-05 00:02:13 +01:00
|
|
|
$quad = new Label_Button();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($quad);
|
2014-01-05 00:02:13 +01:00
|
|
|
$quad->setStyle($quad::STYLE_CardMain_Quit);
|
2017-03-25 19:15:50 +01:00
|
|
|
$quad->setHorizontalAlign($quad::LEFT);
|
2014-01-05 00:02:13 +01:00
|
|
|
$quad->setScale(0.75);
|
2014-06-22 19:02:18 +02:00
|
|
|
$quad->setText('Back');
|
2014-01-05 00:02:13 +01:00
|
|
|
$quad->setPosition(-$this->width / 2 + 7, -$this->height / 2 + 7);
|
|
|
|
$quad->setAction(PlayerCommands::ACTION_OPEN_PLAYERLIST);
|
|
|
|
|
2014-01-03 16:24:35 +01:00
|
|
|
// render and display xml
|
2017-03-25 19:15:50 +01:00
|
|
|
$this->maniaControl->getManialinkManager()->displayWidget($manialink, $player, 'PlayerDetailed');
|
2014-01-03 16:24:35 +01:00
|
|
|
}
|
2014-01-03 17:36:10 +01:00
|
|
|
|
2014-05-02 16:13:45 +02:00
|
|
|
/**
|
|
|
|
* Build a Frame with Statistics about the given Player
|
|
|
|
*
|
|
|
|
* @param Player $player
|
|
|
|
* @return Frame
|
|
|
|
*/
|
|
|
|
public function statisticsFrame(Player $player) {
|
2014-01-03 17:36:10 +01:00
|
|
|
$frame = new Frame();
|
2017-04-03 20:59:28 +02:00
|
|
|
$frame->setPosition(-$this->width / 2 + $this->infoColWidth + $this->margin, $this->contentY);
|
2014-01-03 17:36:10 +01:00
|
|
|
|
2014-08-13 11:05:52 +02:00
|
|
|
$playerStats = $this->maniaControl->getStatisticManager()->getAllPlayerStats($player);
|
2017-04-03 20:59:28 +02:00
|
|
|
|
|
|
|
$posY = 0;
|
|
|
|
$posX = 0;
|
|
|
|
$statisticsColWidth = $this->width - $this->infoColWidth - $this->margin;
|
|
|
|
$cols = 2;
|
|
|
|
$colWidth = $statisticsColWidth / $cols;
|
|
|
|
$index = 1;
|
2014-01-29 20:51:53 +01:00
|
|
|
|
2014-05-02 17:50:30 +02:00
|
|
|
foreach ($playerStats as $stat) {
|
2017-04-03 20:59:28 +02:00
|
|
|
$value = (float) $stat[1];
|
2014-06-14 14:32:29 +02:00
|
|
|
if (!$value) {
|
2014-01-28 22:27:33 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2014-06-14 14:32:29 +02:00
|
|
|
$statProperties = $stat[0];
|
|
|
|
if ($statProperties->type === StatisticManager::STAT_TYPE_TIME) {
|
2014-06-15 02:50:13 +02:00
|
|
|
$value = Formatter::formatTimeH($value);
|
2014-06-14 14:32:29 +02:00
|
|
|
} else if ($statProperties->type === StatisticManager::STAT_TYPE_FLOAT) {
|
|
|
|
$value = round($value, 2);
|
2014-01-03 19:14:07 +01:00
|
|
|
}
|
|
|
|
|
2014-06-14 15:48:27 +02:00
|
|
|
if ($index % 2 !== 0) {
|
2014-01-03 19:41:00 +01:00
|
|
|
$lineQuad = new Quad_BgsPlayerCard();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($lineQuad);
|
2017-04-03 20:59:28 +02:00
|
|
|
$lineQuad->setSize($colWidth, 4);
|
2014-01-03 19:41:00 +01:00
|
|
|
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
|
2017-04-03 20:59:28 +02:00
|
|
|
$lineQuad->setPosition($posX, $posY, -0.001);
|
2017-03-25 19:15:50 +01:00
|
|
|
$lineQuad->setHorizontalAlign($lineQuad::LEFT);
|
2014-01-03 19:41:00 +01:00
|
|
|
}
|
|
|
|
|
2014-01-03 18:37:51 +01:00
|
|
|
$label = new Label_Text();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($label);
|
2017-04-03 20:59:28 +02:00
|
|
|
$label->setPosition($posX + $this->padding, $posY);
|
2014-01-03 18:37:51 +01:00
|
|
|
$label->setText($statProperties->name);
|
2017-03-25 19:15:50 +01:00
|
|
|
$label->setHorizontalAlign($label::LEFT);
|
2014-01-03 18:37:51 +01:00
|
|
|
$label->setTextSize(1.5);
|
2017-04-03 20:59:28 +02:00
|
|
|
$label->setWidth($colWidth / 2 - $this->padding);
|
2014-01-03 18:37:51 +01:00
|
|
|
|
|
|
|
$label = new Label_Text();
|
2017-03-25 19:15:50 +01:00
|
|
|
$frame->addChild($label);
|
2017-04-03 20:59:28 +02:00
|
|
|
$label->setPosition($posX + $colWidth - $this->padding, $posY);
|
|
|
|
$label->setHorizontalAlign(Label_Text::RIGHT);
|
2014-01-03 18:37:51 +01:00
|
|
|
$label->setText($value);
|
|
|
|
$label->setTextSize(1.5);
|
2017-04-03 20:59:28 +02:00
|
|
|
$label->setWidth($colWidth / 2 - $this->padding);
|
2014-01-03 18:37:51 +01:00
|
|
|
|
2014-06-14 14:32:29 +02:00
|
|
|
$posY -= 4;
|
2014-06-14 15:48:27 +02:00
|
|
|
$index++;
|
2014-01-28 22:27:33 +01:00
|
|
|
|
2014-06-14 15:48:27 +02:00
|
|
|
if ($index > self::STATS_PER_COLUMN) {
|
2017-04-03 20:59:28 +02:00
|
|
|
$posY = 0;
|
|
|
|
$posX += $statisticsColWidth / 2;
|
|
|
|
$index = 1;
|
2014-01-28 22:27:33 +01:00
|
|
|
}
|
2014-01-03 18:37:51 +01:00
|
|
|
}
|
2014-01-03 17:36:10 +01:00
|
|
|
return $frame;
|
|
|
|
}
|
2014-01-03 16:24:03 +01:00
|
|
|
}
|