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 17:09:24 +01:00
|
|
|
use FML\Controls\Control;
|
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 FML\Script\Script;
|
2014-01-03 19:14:07 +01:00
|
|
|
use ManiaControl\Formatter;
|
2014-01-03 16:24:35 +01:00
|
|
|
use ManiaControl\ManiaControl;
|
|
|
|
use ManiaControl\Manialinks\ManialinkManager;
|
2014-01-03 19:14:07 +01:00
|
|
|
use ManiaControl\Statistics\StatisticManager;
|
2014-05-02 16:13:45 +02:00
|
|
|
use Maniaplanet\DedicatedServer\Structures\Player;
|
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>
|
|
|
|
* @copyright 2014 ManiaControl Team
|
|
|
|
* @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
|
|
|
|
*/
|
|
|
|
const STATS_PER_COLUMN = 13;
|
2014-01-03 16:24:03 +01:00
|
|
|
|
2014-04-12 12:14:37 +02:00
|
|
|
/*
|
|
|
|
* Private Properties
|
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
|
|
|
/**
|
|
|
|
* Create a new Player Detailed instance
|
|
|
|
*
|
|
|
|
* @param ManiaControl $maniaControl
|
|
|
|
*/
|
|
|
|
public function __construct(ManiaControl $maniaControl) {
|
|
|
|
$this->maniaControl = $maniaControl;
|
|
|
|
|
|
|
|
// settings
|
|
|
|
$this->width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
|
|
|
$this->height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
|
|
|
$this->quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
|
|
|
$this->quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
|
|
|
}
|
|
|
|
|
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-01-28 22:27:33 +01:00
|
|
|
$target = $this->maniaControl->playerManager->getPlayer($targetLogin);
|
|
|
|
|
|
|
|
//Create ManiaLink
|
2014-01-03 16:24:35 +01:00
|
|
|
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
2014-01-28 22:27:33 +01:00
|
|
|
$script = $maniaLink->getScript();
|
|
|
|
|
|
|
|
// Main frame
|
2014-01-31 13:40:07 +01:00
|
|
|
$frame = $this->maniaControl->manialinkManager->styleManager->getDefaultListFrame($script);
|
2014-01-28 22:27:33 +01:00
|
|
|
$maniaLink->add($frame);
|
2014-01-03 16:24:35 +01:00
|
|
|
|
|
|
|
// Create script and features
|
|
|
|
$script = new Script();
|
|
|
|
$maniaLink->setScript($script);
|
|
|
|
|
2014-01-28 22:27:33 +01:00
|
|
|
$y = $this->height / 2 - 7;
|
2014-01-03 20:29:42 +01:00
|
|
|
|
|
|
|
//Nation Quad
|
|
|
|
$countryQuad = new Quad();
|
|
|
|
$frame->add($countryQuad);
|
2014-04-13 11:50:07 +02:00
|
|
|
$countryQuad->setImage("file://ZoneFlags/Login/{$targetLogin}/country");
|
2014-01-03 20:29:42 +01:00
|
|
|
$countryQuad->setPosition(-$this->width / 2 + 10, $y);
|
|
|
|
$countryQuad->setSize(5, 5);
|
|
|
|
$countryQuad->setZ(-0.1);
|
|
|
|
$countryQuad->setHAlign(Control::LEFT);
|
|
|
|
|
2014-01-03 17:09:24 +01:00
|
|
|
//Nickname
|
|
|
|
$label = new Label_Text();
|
|
|
|
$frame->add($label);
|
2014-01-03 20:29:42 +01:00
|
|
|
$label->setPosition(-$this->width / 2 + 15, $y);
|
2014-01-03 17:09:24 +01:00
|
|
|
$label->setText($target->nickname);
|
|
|
|
$label->setHAlign(Control::LEFT);
|
|
|
|
|
|
|
|
|
|
|
|
//Define MainLabel (Login)
|
2014-01-28 22:27:33 +01:00
|
|
|
$y -= 8;
|
2014-01-03 17:09:24 +01:00
|
|
|
$mainLabel = new Label_Text();
|
|
|
|
$frame->add($mainLabel);
|
|
|
|
$mainLabel->setPosition(-$this->width / 2 + 10, $y);
|
|
|
|
$mainLabel->setTextSize(1.2);
|
|
|
|
$mainLabel->setHAlign(Control::LEFT);
|
|
|
|
$mainLabel->setText("Login:");
|
|
|
|
|
|
|
|
$y -= 5;
|
|
|
|
$label = clone $mainLabel;
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setY($y);
|
|
|
|
$label->setText("Nation: ");
|
|
|
|
|
|
|
|
$y -= 5;
|
|
|
|
$label = clone $mainLabel;
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setY($y);
|
|
|
|
$label->setText("Province:");
|
|
|
|
|
|
|
|
$y -= 5;
|
|
|
|
$label = clone $mainLabel;
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setY($y);
|
|
|
|
$label->setText("Authorization:");
|
|
|
|
|
|
|
|
$y -= 5;
|
|
|
|
$label = clone $mainLabel;
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setY($y);
|
|
|
|
$label->setText("Ladder Rank:");
|
|
|
|
|
|
|
|
$y -= 5;
|
|
|
|
$label = clone $mainLabel;
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setY($y);
|
|
|
|
$label->setText("Ladder Score:");
|
|
|
|
|
|
|
|
$y -= 5;
|
|
|
|
$label = clone $mainLabel;
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setY($y);
|
2014-01-28 22:27:33 +01:00
|
|
|
$label->setText("Inscribed Zone:");
|
|
|
|
|
|
|
|
$y -= 5;
|
|
|
|
$label = clone $mainLabel;
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setY($y);
|
|
|
|
$label->setText('Avatar');
|
2014-01-03 17:09:24 +01:00
|
|
|
|
|
|
|
//Login
|
2014-01-03 21:16:20 +01:00
|
|
|
$y = $this->height / 2 - 15;
|
2014-01-03 17:09:24 +01:00
|
|
|
$mainLabel = new Label_Text();
|
|
|
|
$frame->add($mainLabel);
|
|
|
|
$mainLabel->setPosition(-$this->width / 2 + 30, $y);
|
|
|
|
$mainLabel->setText($target->login);
|
|
|
|
$mainLabel->setTextSize(1.2);
|
|
|
|
$mainLabel->setHAlign(Control::LEFT);
|
|
|
|
|
|
|
|
//Country
|
|
|
|
$y -= 5;
|
|
|
|
$label = clone $mainLabel;
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setY($y);
|
|
|
|
$label->setText($target->getCountry());
|
|
|
|
|
|
|
|
//Province
|
|
|
|
$y -= 5;
|
|
|
|
$label = clone $mainLabel;
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setY($y);
|
|
|
|
$label->setText($target->getProvince());
|
|
|
|
|
|
|
|
//AuthLevel
|
|
|
|
$y -= 5;
|
|
|
|
$label = clone $mainLabel;
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setY($y);
|
|
|
|
$label->setText($this->maniaControl->authenticationManager->getAuthLevelName($target->authLevel));
|
|
|
|
|
|
|
|
//LadderRank
|
|
|
|
$y -= 5;
|
|
|
|
$label = clone $mainLabel;
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setY($y);
|
|
|
|
$label->setText($target->ladderRank);
|
|
|
|
|
|
|
|
//LadderScore
|
|
|
|
$y -= 5;
|
|
|
|
$label = clone $mainLabel;
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setY($y);
|
2014-01-03 21:16:20 +01:00
|
|
|
$label->setText(round($target->ladderScore, 2));
|
2014-01-03 17:09:24 +01:00
|
|
|
|
|
|
|
//Played Since
|
|
|
|
$y -= 5;
|
|
|
|
$label = clone $mainLabel;
|
|
|
|
$frame->add($label);
|
|
|
|
$label->setY($y);
|
2014-01-29 09:29:02 +01:00
|
|
|
$label->setText(date("d M Y", time() - 3600 * 24 * $target->daysSinceZoneInscription));
|
2014-01-03 17:09:24 +01:00
|
|
|
|
|
|
|
$quad = new Quad();
|
|
|
|
$frame->add($quad);
|
2014-04-13 11:50:07 +02:00
|
|
|
$quad->setImage('file://Avatars/' . $targetLogin . "/default");
|
2014-01-28 22:27:33 +01:00
|
|
|
$quad->setPosition(-$this->width / 2 + 50, -$this->height / 2 + 34);
|
2014-01-03 17:09:24 +01:00
|
|
|
$quad->setAlign(Control::RIGHT, Control::TOP);
|
|
|
|
$quad->setSize(20, 20);
|
|
|
|
|
2014-01-03 17:36:10 +01:00
|
|
|
//Statistics
|
|
|
|
$frame->add($this->statisticsFrame($target));
|
2014-01-03 17:09:24 +01:00
|
|
|
|
|
|
|
|
2014-01-05 00:02:13 +01:00
|
|
|
$quad = new Label_Button();
|
|
|
|
$frame->add($quad);
|
|
|
|
$quad->setStyle($quad::STYLE_CardMain_Quit);
|
|
|
|
$quad->setHAlign(Control::LEFT);
|
|
|
|
$quad->setScale(0.75);
|
2014-01-28 22:27:33 +01: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
|
2014-01-11 17:38:46 +01:00
|
|
|
$this->maniaControl->manialinkManager->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();
|
|
|
|
|
2014-01-03 18:37:51 +01:00
|
|
|
$playerStats = $this->maniaControl->statisticManager->getAllPlayerStats($player);
|
2014-01-29 22:50:04 +01:00
|
|
|
$y = $this->height / 2 - 15;
|
|
|
|
$x = -$this->width / 2 + 52;
|
|
|
|
$id = 1;
|
2014-01-29 20:51:53 +01:00
|
|
|
|
2014-05-02 17:50:30 +02:00
|
|
|
foreach ($playerStats as $stat) {
|
2014-01-03 18:37:51 +01:00
|
|
|
$statProperties = $stat[0];
|
2014-01-03 21:16:20 +01:00
|
|
|
$value = $stat[1];
|
2014-01-03 18:37:51 +01:00
|
|
|
|
2014-01-29 22:50:04 +01:00
|
|
|
if (floatval($value) == 0) {
|
2014-01-28 22:27:33 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($statProperties->type == StatisticManager::STAT_TYPE_TIME) {
|
2014-02-01 17:47:05 +01:00
|
|
|
$value = Formatter::formatTimeHMS($value);
|
2014-01-29 20:51:53 +01:00
|
|
|
} else if ($statProperties->type == StatisticManager::STAT_TYPE_FLOAT) {
|
|
|
|
$value = round(floatval($value), 2);
|
2014-01-03 19:14:07 +01:00
|
|
|
}
|
|
|
|
|
2014-01-28 22:27:33 +01:00
|
|
|
if ($id % 2 != 0) {
|
2014-01-03 19:41:00 +01:00
|
|
|
$lineQuad = new Quad_BgsPlayerCard();
|
|
|
|
$frame->add($lineQuad);
|
|
|
|
$lineQuad->setSize(49, 4);
|
|
|
|
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
|
2014-01-28 22:27:33 +01:00
|
|
|
$lineQuad->setPosition($x, $y, 0.001);
|
2014-01-03 19:41:00 +01:00
|
|
|
$lineQuad->setHAlign(Control::LEFT);
|
|
|
|
}
|
|
|
|
|
2014-01-03 18:37:51 +01:00
|
|
|
$label = new Label_Text();
|
|
|
|
$frame->add($label);
|
2014-01-28 22:27:33 +01:00
|
|
|
$label->setPosition($x + 4, $y);
|
2014-01-03 18:37:51 +01:00
|
|
|
$label->setText($statProperties->name);
|
|
|
|
$label->setHAlign(Control::LEFT);
|
|
|
|
$label->setTextSize(1.5);
|
|
|
|
|
|
|
|
$label = new Label_Text();
|
|
|
|
$frame->add($label);
|
2014-01-28 22:27:33 +01:00
|
|
|
$label->setPosition($x + 40, $y);
|
2014-01-03 18:37:51 +01:00
|
|
|
$label->setText($value);
|
2014-01-28 22:27:33 +01:00
|
|
|
$label->setVAlign(Control::CENTER2);
|
2014-01-03 18:37:51 +01:00
|
|
|
$label->setTextSize(1.5);
|
|
|
|
|
|
|
|
$y -= 4;
|
2014-01-03 19:41:00 +01:00
|
|
|
$id++;
|
2014-01-28 22:27:33 +01:00
|
|
|
|
|
|
|
if ($id > self::STATS_PER_COLUMN) {
|
|
|
|
$y = $this->height / 2 - 15;
|
|
|
|
$x += 47;
|
|
|
|
$id = 0;
|
|
|
|
}
|
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
|
|
|
}
|