Replaced old with new LabelLine

This commit is contained in:
Jocy 2017-04-01 18:48:36 +02:00
parent a9f462ea8f
commit 2e94928539
8 changed files with 126 additions and 121 deletions

View File

@ -16,6 +16,7 @@ use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\General\UsageInformationAble; use ManiaControl\General\UsageInformationAble;
use ManiaControl\General\UsageInformationTrait; use ManiaControl\General\UsageInformationTrait;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\LabelLine;
use ManiaControl\Manialinks\ManialinkManager; use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
@ -94,7 +95,7 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener, Usage
//Create ManiaLink //Create ManiaLink
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID); $maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
$paging = new Paging(); $paging = new Paging();
$script = new Script(); $script = new Script();
$script->addFeature($paging); $script->addFeature($paging);
$maniaLink->setScript($script); $maniaLink->setScript($script);
@ -114,11 +115,16 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener, Usage
$headFrame = new Frame(); $headFrame = new Frame();
$frame->addChild($headFrame); $frame->addChild($headFrame);
$headFrame->setY($posY - 5); $headFrame->setY($posY - 5);
$array = array('Id' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Actions' => $posX + 120);
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array);
$index = 1; $labelLine = new LabelLine($headFrame);
$posY -= 10; $labelLine->addLabelEntryText('Id', $posX + 5);
$labelLine->addLabelEntryText('Nickname', $posX + 18);
$labelLine->addLabelEntryText('Login', $posX + 70);
$labelLine->addLabelEntryText('Actions', $posX + 120);
$labelLine->render();
$index = 1;
$posY -= 10;
$pageFrame = null; $pageFrame = null;
foreach ($admins as $admin) { foreach ($admins as $admin) {
@ -142,9 +148,11 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener, Usage
$lineQuad->setZ(0.001); $lineQuad->setZ(0.001);
} }
$positions = array($posX + 5, $posX + 18, $posX + 70); $labelLine = new LabelLine($playerFrame);
$texts = array($index, $admin->nickname, $admin->login); $labelLine->addLabelEntryText($index, $posX + 5, 13);
$this->maniaControl->getManialinkManager()->labelLine($playerFrame, array($positions, $texts)); $labelLine->addLabelEntryText($admin->nickname, $posX + 18, 52);
$labelLine->addLabelEntryText($admin->login, $posX + 70, 48);
$labelLine->render();
// Level Quad // Level Quad
$rightQuad = new Quad_BgRaceScore2(); $rightQuad = new Quad_BgRaceScore2();

View File

@ -9,6 +9,7 @@ use FML\Script\Features\Paging;
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\Callbacks; use ManiaControl\Callbacks\Callbacks;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\LabelLine;
use ManiaControl\Manialinks\ManialinkManager; use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
@ -109,7 +110,7 @@ class HelpManager implements CommandListener, CallbackListener {
foreach (array_reverse($commands) as $command) { foreach (array_reverse($commands) as $command) {
if (array_key_exists($command['Method'], $registeredMethods)) { if (array_key_exists($command['Method'], $registeredMethods)) {
if ($showCommands[$registeredMethods[$command['Method']]]['Description'] === $command['Description']) { if ($showCommands[$registeredMethods[$command['Method']]]['Description'] === $command['Description']) {
$name = $registeredMethods[$command['Method']]; $name = $registeredMethods[$command['Method']];
$showCommands[$name]['Name'] .= '|' . $command['Name']; $showCommands[$name]['Name'] .= '|' . $command['Name'];
} else { } else {
$showCommands[$command['Name']] = $command; $showCommands[$command['Name']] = $command;
@ -170,11 +171,14 @@ class HelpManager implements CommandListener, CallbackListener {
$headFrame = new Frame(); $headFrame = new Frame();
$frame->addChild($headFrame); $frame->addChild($headFrame);
$headFrame->setY($posY - 5); $headFrame->setY($posY - 5);
$array = array('Command' => $posX + 5, 'Description' => $posX + 50);
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array);
$index = 1; $labelLine = new LabelLine($headFrame);
$posY -= 10; $labelLine->addLabelEntryText('Command', $posX + 5);
$labelLine->addLabelEntryText('Description', $posX + 50);
$labelLine->render();
$index = 1;
$posY -= 10;
$pageFrame = null; $pageFrame = null;
foreach ($commands as $command) { foreach ($commands as $command) {
@ -197,11 +201,10 @@ class HelpManager implements CommandListener, CallbackListener {
$lineQuad->setZ(0.001); $lineQuad->setZ(0.001);
} }
$array = array($command['Name'] => $posX + 5, $command['Description'] => $posX + 50); $labelLine = new LabelLine($playerFrame);
$labels = $this->maniaControl->getManialinkManager()->labelLine($playerFrame, $array); $labelLine->addLabelEntryText($command['Name'], $posX + 5, 45);
$labelLine->addLabelEntryText($command['Description'], $posX + 50, $width / 2 - $posX + 50);
$label = $labels[0]; $labelLine->render();
$label->setWidth(40);
$posY -= 4; $posY -= 4;
$index++; $index++;

View File

@ -198,9 +198,6 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
$headFrame = new Frame(); $headFrame = new Frame();
$frame->addChild($headFrame); $frame->addChild($headFrame);
$headFrame->setY($posY - 12); $headFrame->setY($posY - 12);
$array = array('$oId' => $posX + 3.5, '$oName' => $posX + 12.5, '$oAuthor' => $posX + 59, '$oKarma' => $posX + 85, '$oType' => $posX + 103, '$oMood' => $posX + 118,
'$oLast Update' => $posX + 130);
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array);
$labelLine = new LabelLine($headFrame); $labelLine = new LabelLine($headFrame);
$labelLine->addLabelEntryText('Id', $posX + 3.5, 9); $labelLine->addLabelEntryText('Id', $posX + 3.5, 9);
@ -210,7 +207,6 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
$labelLine->addLabelEntryText('Mood', $posX + 118, 12); $labelLine->addLabelEntryText('Mood', $posX + 118, 12);
$labelLine->addLabelEntryText('Last Update', $posX + 130, $width - ($posX + 130)); $labelLine->addLabelEntryText('Last Update', $posX + 130, $width - ($posX + 130));
$labelLine->setPrefix('$o');
$labelLine->render(); $labelLine->render();
$index = 0; $index = 0;

View File

@ -44,15 +44,15 @@ class LabelLine implements UsageInformationAble {
*/ */
public function addLabelEntryText($labelText, $posX, $width = 0, $action = '') { public function addLabelEntryText($labelText, $posX, $width = 0, $action = '') {
$label = new Label_Text(); $label = new Label_Text();
$this->frame->addChild($label);
$label->setText($labelText); $label->setText($labelText);
$label->setX($posX); $label->setX($posX);
if ($action) { if ($action) {
$label->setAction($action); $label->setAction($action);
} }
if ($width) { if ($width) {
$label->setWidth($width); $label->setWidth($width);
$label->setHeight(0); //TODO verify if 5 is ok for everywhere $label->setHeight(0);
} }
$this->addLabel($label); $this->addLabel($label);
} }
@ -62,7 +62,7 @@ class LabelLine implements UsageInformationAble {
* *
* @param \FML\Controls\Labels\Label_Text $label * @param \FML\Controls\Labels\Label_Text $label
*/ */
private function addLabel(Label_Text $label) { public function addLabel(Label_Text $label) {
array_push($this->entries, $label); array_push($this->entries, $label);
} }

View File

@ -113,7 +113,7 @@ class StyleManager implements UsageInformationAble {
// Predefine Description Label // Predefine Description Label
$descriptionLabel = new Label(); $descriptionLabel = new Label();
$descriptionLabel->setAlign($descriptionLabel::LEFT, $descriptionLabel::TOP)->setPosition($width * -0.5 + 10, $height * -0.5 + 5)->setSize($width * 0.7, 4)->setTextSize(2)->setVisible(false); $descriptionLabel->setAlign($descriptionLabel::LEFT, $descriptionLabel::TOP)->setPosition($width * -0.5 + 10, $height * -0.5 + 5)->setZ(1)->setSize($width * 0.7, 4)->setTextSize(2)->setVisible(false);
return $descriptionLabel; return $descriptionLabel;
} }

View File

@ -19,6 +19,7 @@ use ManiaControl\Callbacks\Callbacks;
use ManiaControl\Logger; use ManiaControl\Logger;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\IconManager; use ManiaControl\Manialinks\IconManager;
use ManiaControl\Manialinks\LabelLine;
use ManiaControl\Manialinks\ManialinkManager; use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
@ -118,8 +119,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
* @param int $pageIndex * @param int $pageIndex
*/ */
public function showMapList(Player $player, $mapList = null, $pageIndex = -1) { public function showMapList(Player $player, $mapList = null, $pageIndex = -1) {
$width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth(); $width = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsWidth();
$height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight(); $height = $this->maniaControl->getManialinkManager()->getStyleManager()->getListWidgetsHeight();
$buttonY = -$height / 2 + 9; $buttonY = -$height / 2 + 9;
if ($pageIndex < 0) { if ($pageIndex < 0) {
@ -154,8 +155,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$maniaLink->addChild($frame); $maniaLink->addChild($frame);
// Admin Buttons // Admin Buttons
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapQueue::SETTING_PERMISSION_CLEAR_MAPQUEUE) if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapQueue::SETTING_PERMISSION_CLEAR_MAPQUEUE)) {
) {
// Clear Map-Queue // Clear Map-Queue
$label = new Label_Button(); $label = new Label_Button();
$frame->addChild($label); $frame->addChild($label);
@ -173,11 +173,10 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$quad->setAction(self::ACTION_CLEAR_MAPQUEUE); $quad->setAction(self::ACTION_CLEAR_MAPQUEUE);
} }
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_CHECK_UPDATE) if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_CHECK_UPDATE)) {
) {
$mxCheckForUpdatesX = $width / 2 - 37; $mxCheckForUpdatesX = $width / 2 - 37;
$buttonWidth = 35; $buttonWidth = 35;
$iconSize = 3; $iconSize = 3;
// Check Update // Check Update
$label = new Label_Button(); $label = new Label_Button();
$frame->addChild($label); $frame->addChild($label);
@ -206,8 +205,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$mxQuad->setAction(self::ACTION_CHECK_UPDATE); $mxQuad->setAction(self::ACTION_CHECK_UPDATE);
} }
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP) if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
) {
// Directory browser // Directory browser
$browserButton = new Label_Button(); $browserButton = new Label_Button();
$frame->addChild($browserButton); $frame->addChild($browserButton);
@ -227,9 +225,15 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$headFrame = new Frame(); $headFrame = new Frame();
$frame->addChild($headFrame); $frame->addChild($headFrame);
$headFrame->setY($height / 2 - 5); $headFrame->setY($height / 2 - 5);
$posX = -$width / 2; $posX = -$width / 2;
$array = array('Id' => $posX + 5, 'Mx Id' => $posX + 10, 'Map Name' => $posX + 20, 'Author' => $posX + 68, 'Karma' => $posX + 115, 'Actions' => $width / 2 - 16);
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array); $labelLine = new LabelLine($headFrame);
$labelLine->addLabelEntryText('Id', $posX + 5);
$labelLine->addLabelEntryText('Mx Id', $posX + 10);
$labelLine->addLabelEntryText('Map Name', $posX + 20);
$labelLine->addLabelEntryText('Author', $posX + 68);
$labelLine->addLabelEntryText('Actions', $width / 2 - 16);
$labelLine->render();
// Predefine description Label // Predefine description Label
$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel(); $descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel();
@ -314,23 +318,29 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$mxQuad->addTooltipLabelFeature($descriptionLabel, $description); $mxQuad->addTooltipLabelFeature($descriptionLabel, $description);
// Update Button // Update Button
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP) if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
) {
$mxQuad->setAction(self::ACTION_UPDATE_MAP . '.' . $map->uid); $mxQuad->setAction(self::ACTION_UPDATE_MAP . '.' . $map->uid);
} }
} }
} }
// Display Maps // Display Maps
$array = array($mapListId => $posX + 5, $mxId => $posX + 10, Formatter::stripDirtyCodes($map->name) => $posX + 20, $map->authorNick => $posX + 68); $labelLine = new LabelLine($mapFrame);
$labels = $this->maniaControl->getManialinkManager()->labelLine($mapFrame, $array); $labelLine->addLabelEntryText($mapListId, $posX + 5, 5);
if (isset($labels[3])) { $labelLine->addLabelEntryText($mxId, $posX + 10, 10);
/** @var Label $label */ $labelLine->addLabelEntryText(Formatter::stripDirtyCodes($map->name), $posX + 20, 42);
$label = $labels[3];
$description = 'Click to checkout all maps by $<' . $map->authorLogin . '$>!'; $label = new Label_Text();
$label->setAction(MapCommands::ACTION_SHOW_AUTHOR . $map->authorLogin); $mapFrame->addChild($label);
$label->addTooltipLabelFeature($descriptionLabel, $description); $label->setText($map->authorNick);
} $label->setX($posX + 68);
$label->setSize(47, 0);
$label->setAction(MapCommands::ACTION_SHOW_AUTHOR . $map->authorLogin);
$description = 'Click to checkout all maps by $<' . $map->authorLogin . '$>!';
$label->addTooltipLabelFeature($descriptionLabel, $description);
$labelLine->addLabel($label);
$labelLine->render();
// TODO action detailed map info including mx info // TODO action detailed map info including mx info
@ -364,8 +374,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$queueLabel->setText('+'); $queueLabel->setText('+');
if (in_array($map->uid, $queueBuffer)) { if (in_array($map->uid, $queueBuffer)) {
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapQueue::SETTING_PERMISSION_CLEAR_MAPQUEUE) if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapQueue::SETTING_PERMISSION_CLEAR_MAPQUEUE)) {
) {
$queueLabel->setAction(self::ACTION_QUEUED_MAP . '.' . $map->uid); $queueLabel->setAction(self::ACTION_QUEUED_MAP . '.' . $map->uid);
} }
$queueLabel->setTextColor('f00'); $queueLabel->setTextColor('f00');
@ -379,8 +388,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
} }
} }
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_REMOVE_MAP) if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_REMOVE_MAP)) {
) {
// remove map button // remove map button
$removeButton = new Label_Button(); $removeButton = new Label_Button();
$mapFrame->addChild($removeButton); $mapFrame->addChild($removeButton);
@ -397,8 +405,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$removeButton->addTooltipLabelFeature($descriptionLabel, $description); $removeButton->addTooltipLabelFeature($descriptionLabel, $description);
} }
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP) if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
) {
// Switch to button // Switch to button
$switchLabel = new Label_Button(); $switchLabel = new Label_Button();
$mapFrame->addChild($switchLabel); $mapFrame->addChild($switchLabel);
@ -415,10 +422,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$description = 'Switch Directly to Map: ' . $map->getEscapedName(); $description = 'Switch Directly to Map: ' . $map->getEscapedName();
$switchLabel->addTooltipLabelFeature($descriptionLabel, $description); $switchLabel->addTooltipLabelFeature($descriptionLabel, $description);
} }
if ($this->maniaControl->getPluginManager()->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN) if ($this->maniaControl->getPluginManager()->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)) {
) { if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)
) {
// Switch Map Voting for Admins // Switch Map Voting for Admins
$switchQuad = new Quad_UIConstruction_Buttons(); $switchQuad = new Quad_UIConstruction_Buttons();
$mapFrame->addChild($switchQuad); $mapFrame->addChild($switchQuad);
@ -461,8 +466,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
} }
if (is_numeric($karma) && $votes['count'] > 0) { if (is_numeric($karma) && $votes['count'] > 0) {
if ($this->maniaControl->getSettingManager()->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA) if ($this->maniaControl->getSettingManager()->getSettingValue($karmaPlugin, $karmaPlugin::SETTING_NEWKARMA)) {
) {
$karmaText = ' ' . round($karma * 100.) . '% (' . $votes['count'] . ')'; $karmaText = ' ' . round($karma * 100.) . '% (' . $votes['count'] . ')';
} else { } else {
$min = 0; $min = 0;

View File

@ -17,6 +17,7 @@ use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Callbacks\TimerListener; use ManiaControl\Callbacks\TimerListener;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\LabelLine;
use ManiaControl\Manialinks\ManialinkManager; use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Utils\Formatter; use ManiaControl\Utils\Formatter;
@ -168,11 +169,16 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
$frame->addChild($headFrame); $frame->addChild($headFrame);
$headFrame->setY($posY - 5); $headFrame->setY($posY - 5);
$labelLineArray = array('Id' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Location' => $posX + 101); $labelLine = new LabelLine($headFrame);
$labelLine->addLabelEntryText('Id', $posX + 5);
$labelLine->addLabelEntryText('Nickname', $posX + 18);
$labelLine->addLabelEntryText('Login', $posX + 70);
$labelLine->addLabelEntryText('Location', $posX + 101);
if ($this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) { if ($this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
$labelLineArray['Actions'] = $posX + 135; $labelLine->addLabelEntryText('Actions', $posX + 135);
} }
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $labelLineArray); $labelLine->render();
$index = 1; $index = 1;
$posY = $height / 2 - 10; $posY = $height / 2 - 10;
@ -198,10 +204,15 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig); $lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
$lineQuad->setZ($backgroundZ); $lineQuad->setZ($backgroundZ);
} }
$labelLine = new LabelLine($playerFrame);
$positions = array($posX + 5, $posX + 18, $posX + 70, $posX + 101); $labelLine->addLabelEntryText($index, $posX + 5, 13);
$texts = array($index, $listPlayer->nickname, $listPlayer->login, $path); $labelLine->addLabelEntryText($listPlayer->nickname, $posX + 18, 43);
$this->maniaControl->getManialinkManager()->labelLine($playerFrame, array($positions, $texts), array('posZ' => $foregroundZ)); $labelLine->addLabelEntryText($listPlayer->login, $posX + 70, 26);
$labelLine->addLabelEntryText($path, $posX + 101, 27);
$labelLine->setPosZ($foregroundZ);
$labelLine->render();
$playerFrame->setY($posY); $playerFrame->setY($posY);

View File

@ -15,6 +15,7 @@ use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Callbacks\Callbacks; use ManiaControl\Callbacks\Callbacks;
use ManiaControl\Commands\CommandListener; use ManiaControl\Commands\CommandListener;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\LabelLine;
use ManiaControl\Manialinks\ManialinkManager; use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Players\Player; use ManiaControl\Players\Player;
@ -40,8 +41,8 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
*/ */
/** @var ManiaControl $maniaControl */ /** @var ManiaControl $maniaControl */
private $maniaControl = null; private $maniaControl = null;
private $statArray = array(); private $statArray = array();
private $statsWidth = 0; private $statsWidth = 0;
/** /**
* Construct a new simple stats list instance * Construct a new simple stats list instance
@ -99,7 +100,7 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
$this->statArray[$order]["HeadShortCut"] = '$o' . $headShortCut; $this->statArray[$order]["HeadShortCut"] = '$o' . $headShortCut;
$this->statArray[$order]["Width"] = $width; $this->statArray[$order]["Width"] = $width;
$this->statArray[$order]["Format"] = $format; $this->statArray[$order]["Format"] = $format;
$this->statsWidth += $width; $this->statsWidth += $width;
} }
/** /**
@ -153,13 +154,8 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
$posY = $height / 2; $posY = $height / 2;
// Predefine Description Label // Predefine Description Label
$descriptionLabel = new Label(); $descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel();
$frame->addChild($descriptionLabel); $frame->addChild($descriptionLabel);
$descriptionLabel->setAlign($descriptionLabel::LEFT, $descriptionLabel::TOP);
$descriptionLabel->setPosition($xStart + 10, -$height / 2 + 5);
$descriptionLabel->setSize($width * 0.7, 4);
$descriptionLabel->setTextSize(2);
$descriptionLabel->setVisible(false);
// Headline // Headline
$headFrame = new Frame(); $headFrame = new Frame();
@ -167,9 +163,11 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
$headFrame->setY($posY - 5); $headFrame->setY($posY - 5);
$headFrame->setZ(1); $headFrame->setZ(1);
$posX = $xStart; $labelLine = new LabelLine($headFrame);
$array['$oId'] = $posX + 5;
$array['$oNickname'] = $posX + 14; $posX = $xStart;
$labelLine->addLabelEntryText('Id', $posX + 5);
$labelLine->addLabelEntryText('Nickname', $posX + 14);
// Headline // Headline
$posX = $xStart + 55; $posX = $xStart + 55;
@ -177,36 +175,27 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
foreach ($this->statArray as $key => $stat) { foreach ($this->statArray as $key => $stat) {
$ranking = $this->maniaControl->getStatisticManager()->getStatsRanking($stat["Name"]); $ranking = $this->maniaControl->getStatisticManager()->getStatsRanking($stat["Name"]);
if (!empty($ranking)) { if (!empty($ranking)) {
$statRankings[$stat["Name"]] = $ranking; $statRankings[$stat["Name"]] = $ranking;
$array[$stat['HeadShortCut']] = $posX;
$label = new Label_Text();
$label->setText($stat['HeadShortCut']);
$label->setX($posX);
$label->setSize($stat['Width'], 0);
$label->setAction(self::ACTION_SORT_STATS . '.' . $stat["Name"]);
$label->addTooltipLabelFeature($descriptionLabel, '$o ' . $stat["Name"]);
$labelLine->addLabel($label);
$posX += $stat["Width"]; $posX += $stat["Width"];
} else { } else {
unset($this->statArray[$key]); unset($this->statArray[$key]);
} }
} }
$labelLine->render();
$labels = $this->maniaControl->getManialinkManager()->labelLine($headFrame, $array);
// Description Label
$index = 2;
foreach ($this->statArray as $statArray) {
if (!isset($labels[$index])) {
break;
}
/** @var Label_Text $label */
$label = $labels[$index];
$label->setAction(self::ACTION_SORT_STATS . '.' . $statArray["Name"]);
$label->addTooltipLabelFeature($descriptionLabel, '$o ' . $statArray["Name"]);
$index++;
}
// define standard properties // define standard properties
$textSize = 1.5; $index = 1;
$textColor = 'fff'; $posY -= 10;
$index = 1;
$posY -= 10;
if (!isset($statRankings[$order])) { if (!isset($statRankings[$order])) {
return; return;
@ -234,8 +223,8 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
$currentQuad->setSubStyle($currentQuad::SUBSTYLE_ArrowBlue); $currentQuad->setSubStyle($currentQuad::SUBSTYLE_ArrowBlue);
} }
$displayArray = array(); $labelLine = new LabelLine($playerFrame);
$posX = $xStart + 55;
foreach ($this->statArray as $stat) { foreach ($this->statArray as $stat) {
$statValue = 0; $statValue = 0;
if (isset($statRankings[$stat['Name']][$playerId])) { if (isset($statRankings[$stat['Name']][$playerId])) {
@ -246,26 +235,20 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
$statValue = round(floatval($statValue), 2); $statValue = round(floatval($statValue), 2);
} }
} }
$displayArray[$stat['Name']] = array('Value' => strval($statValue), 'Width' => $stat['Width']);
}
$array = array($index => $xStart + 5, $listPlayer->nickname => $xStart + 14);
$this->maniaControl->getManialinkManager()->labelLine($playerFrame, $array);
$posX = $xStart + 55;
foreach ($displayArray as $key => $array) {
$label = new Label_Text(); $label = new Label_Text();
$playerFrame->addChild($label);
$label->setHorizontalAlign($label::LEFT);
$label->setX($posX); $label->setX($posX);
$label->setStyle($label::STYLE_TextCardSmall); $label->setText(strval($statValue));
$label->setTextSize($textSize); $label->addTooltipLabelFeature($descriptionLabel, '$o ' . $stat['Name']);
$label->setText($array['Value']); $labelLine->addLabel($label);
$label->setTextColor($textColor);
$label->addTooltipLabelFeature($descriptionLabel, '$o ' . $key); $posX += $stat['Width'];
$posX += $array['Width'];
} }
$labelLine->addLabelEntryText($index, $xStart + 5, 9);
$labelLine->addLabelEntryText($listPlayer->nickname, $xStart + 14, 41);
$labelLine->render();
$playerFrame->setY($posY); $playerFrame->setY($posY);
if ($index % 2 !== 0) { if ($index % 2 !== 0) {