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\UsageInformationTrait;
use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\LabelLine;
use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Players\Player;
@ -114,8 +115,13 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener, Usage
$headFrame = new Frame();
$frame->addChild($headFrame);
$headFrame->setY($posY - 5);
$array = array('Id' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Actions' => $posX + 120);
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array);
$labelLine = new LabelLine($headFrame);
$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;
@ -142,9 +148,11 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener, Usage
$lineQuad->setZ(0.001);
}
$positions = array($posX + 5, $posX + 18, $posX + 70);
$texts = array($index, $admin->nickname, $admin->login);
$this->maniaControl->getManialinkManager()->labelLine($playerFrame, array($positions, $texts));
$labelLine = new LabelLine($playerFrame);
$labelLine->addLabelEntryText($index, $posX + 5, 13);
$labelLine->addLabelEntryText($admin->nickname, $posX + 18, 52);
$labelLine->addLabelEntryText($admin->login, $posX + 70, 48);
$labelLine->render();
// Level Quad
$rightQuad = new Quad_BgRaceScore2();

View File

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

View File

@ -198,9 +198,6 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
$headFrame = new Frame();
$frame->addChild($headFrame);
$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->addLabelEntryText('Id', $posX + 3.5, 9);
@ -210,7 +207,6 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
$labelLine->addLabelEntryText('Mood', $posX + 118, 12);
$labelLine->addLabelEntryText('Last Update', $posX + 130, $width - ($posX + 130));
$labelLine->setPrefix('$o');
$labelLine->render();
$index = 0;

View File

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

View File

@ -113,7 +113,7 @@ class StyleManager implements UsageInformationAble {
// Predefine Description 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;
}

View File

@ -19,6 +19,7 @@ use ManiaControl\Callbacks\Callbacks;
use ManiaControl\Logger;
use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\IconManager;
use ManiaControl\Manialinks\LabelLine;
use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Players\Player;
@ -154,8 +155,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$maniaLink->addChild($frame);
// 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
$label = new Label_Button();
$frame->addChild($label);
@ -173,8 +173,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$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;
$buttonWidth = 35;
$iconSize = 3;
@ -206,8 +205,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$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
$browserButton = new Label_Button();
$frame->addChild($browserButton);
@ -228,8 +226,14 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$frame->addChild($headFrame);
$headFrame->setY($height / 2 - 5);
$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
$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel();
@ -314,23 +318,29 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$mxQuad->addTooltipLabelFeature($descriptionLabel, $description);
// 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);
}
}
}
// Display Maps
$array = array($mapListId => $posX + 5, $mxId => $posX + 10, Formatter::stripDirtyCodes($map->name) => $posX + 20, $map->authorNick => $posX + 68);
$labels = $this->maniaControl->getManialinkManager()->labelLine($mapFrame, $array);
if (isset($labels[3])) {
/** @var Label $label */
$label = $labels[3];
$description = 'Click to checkout all maps by $<' . $map->authorLogin . '$>!';
$labelLine = new LabelLine($mapFrame);
$labelLine->addLabelEntryText($mapListId, $posX + 5, 5);
$labelLine->addLabelEntryText($mxId, $posX + 10, 10);
$labelLine->addLabelEntryText(Formatter::stripDirtyCodes($map->name), $posX + 20, 42);
$label = new Label_Text();
$mapFrame->addChild($label);
$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
@ -364,8 +374,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$queueLabel->setText('+');
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->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
$removeButton = new Label_Button();
$mapFrame->addChild($removeButton);
@ -397,8 +405,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$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
$switchLabel = new Label_Button();
$mapFrame->addChild($switchLabel);
@ -415,10 +422,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$description = 'Switch Directly to Map: ' . $map->getEscapedName();
$switchLabel->addTooltipLabelFeature($descriptionLabel, $description);
}
if ($this->maniaControl->getPluginManager()->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)
) {
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)
) {
if ($this->maniaControl->getPluginManager()->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)) {
if ($this->maniaControl->getAuthenticationManager()->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
// Switch Map Voting for Admins
$switchQuad = new Quad_UIConstruction_Buttons();
$mapFrame->addChild($switchQuad);
@ -461,8 +466,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
}
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'] . ')';
} else {
$min = 0;

View File

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

View File

@ -15,6 +15,7 @@ use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Callbacks\Callbacks;
use ManiaControl\Commands\CommandListener;
use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\LabelLine;
use ManiaControl\Manialinks\ManialinkManager;
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Players\Player;
@ -153,13 +154,8 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
$posY = $height / 2;
// Predefine Description Label
$descriptionLabel = new Label();
$descriptionLabel = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultDescriptionLabel();
$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
$headFrame = new Frame();
@ -167,9 +163,11 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
$headFrame->setY($posY - 5);
$headFrame->setZ(1);
$labelLine = new LabelLine($headFrame);
$posX = $xStart;
$array['$oId'] = $posX + 5;
$array['$oNickname'] = $posX + 14;
$labelLine->addLabelEntryText('Id', $posX + 5);
$labelLine->addLabelEntryText('Nickname', $posX + 14);
// Headline
$posX = $xStart + 55;
@ -178,33 +176,24 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
$ranking = $this->maniaControl->getStatisticManager()->getStatsRanking($stat["Name"]);
if (!empty($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"];
} else {
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
$textSize = 1.5;
$textColor = 'fff';
$index = 1;
$posY -= 10;
@ -234,8 +223,8 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
$currentQuad->setSubStyle($currentQuad::SUBSTYLE_ArrowBlue);
}
$displayArray = array();
$labelLine = new LabelLine($playerFrame);
$posX = $xStart + 55;
foreach ($this->statArray as $stat) {
$statValue = 0;
if (isset($statRankings[$stat['Name']][$playerId])) {
@ -246,26 +235,20 @@ class SimpleStatsList implements ManialinkPageAnswerListener, CallbackListener,
$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();
$playerFrame->addChild($label);
$label->setHorizontalAlign($label::LEFT);
$label->setX($posX);
$label->setStyle($label::STYLE_TextCardSmall);
$label->setTextSize($textSize);
$label->setText($array['Value']);
$label->setTextColor($textColor);
$label->addTooltipLabelFeature($descriptionLabel, '$o ' . $key);
$posX += $array['Width'];
$label->setText(strval($statValue));
$label->addTooltipLabelFeature($descriptionLabel, '$o ' . $stat['Name']);
$labelLine->addLabel($label);
$posX += $stat['Width'];
}
$labelLine->addLabelEntryText($index, $xStart + 5, 9);
$labelLine->addLabelEntryText($listPlayer->nickname, $xStart + 14, 41);
$labelLine->render();
$playerFrame->setY($posY);
if ($index % 2 !== 0) {