Updated MXlist with new Labelline
This commit is contained in:
parent
cfc3694835
commit
6a703f7311
@ -18,6 +18,7 @@ use ManiaControl\Callbacks\CallbackListener;
|
|||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
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\Maps\MapCommands;
|
use ManiaControl\Maps\MapCommands;
|
||||||
@ -201,6 +202,17 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
|||||||
'$oLast Update' => $posX + 130);
|
'$oLast Update' => $posX + 130);
|
||||||
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array);
|
$this->maniaControl->getManialinkManager()->labelLine($headFrame, $array);
|
||||||
|
|
||||||
|
$labelLine = new LabelLine($headFrame);
|
||||||
|
$labelLine->addLabelEntryText('Id', $posX + 3.5, 9);
|
||||||
|
$labelLine->addLabelEntryText('Name', $posX + 12.5, 38.5);
|
||||||
|
$labelLine->addLabelEntryText('Author', $posX + 59, 44);
|
||||||
|
$labelLine->addLabelEntryText('Type', $posX + 103, 15);
|
||||||
|
$labelLine->addLabelEntryText('Mood', $posX + 118, 12);
|
||||||
|
$labelLine->addLabelEntryText('Last Update', $posX + 130, $width - ($posX + 130));
|
||||||
|
|
||||||
|
$labelLine->setPrefix('$o');
|
||||||
|
$labelLine->render();
|
||||||
|
|
||||||
$index = 0;
|
$index = 0;
|
||||||
$posY = $height / 2 - 16;
|
$posY = $height / 2 - 16;
|
||||||
$pageFrame = null;
|
$pageFrame = null;
|
||||||
@ -226,12 +238,17 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
|||||||
$lineQuad->setZ(0.001);
|
$lineQuad->setZ(0.001);
|
||||||
}
|
}
|
||||||
|
|
||||||
$time = Formatter::timeElapsedString(strtotime($map->updated));
|
$time = Formatter::timeElapsedString(strtotime($map->updated));
|
||||||
$array = array('$s' . $map->id => $posX + 3.5, '$s' . $map->name => $posX + 12.5, '$s' . $map->author => $posX + 59, '$s' . str_replace('Arena', '', $map->maptype) => $posX + 103,
|
$labelLine = new LabelLine($mapFrame);
|
||||||
'$s' . $map->mood => $posX + 118, '$s' . $time => $posX + 130);
|
$labelLine->addLabelEntryText($map->id, $posX + 3.5, 9);
|
||||||
$labels = $this->maniaControl->getManialinkManager()->labelLine($mapFrame, $array);
|
$labelLine->addLabelEntryText($map->name, $posX + 12.5, 38.5);
|
||||||
$authorLabel = $labels[2];
|
$labelLine->addLabelEntryText($map->author, $posX + 59, 44, self::ACTION_GET_MAPS_FROM_AUTHOR . '.' . $map->author);
|
||||||
$authorLabel->setAction(self::ACTION_GET_MAPS_FROM_AUTHOR . '.' . $map->author);
|
$labelLine->addLabelEntryText(str_replace('Arena', '', $map->maptype), $posX + 103, 15);
|
||||||
|
$labelLine->addLabelEntryText($map->mood, $posX + 118, 12);
|
||||||
|
$labelLine->addLabelEntryText($time, $posX + 130, $width - ($posX + 130));
|
||||||
|
|
||||||
|
$labelLine->setPrefix('$s');
|
||||||
|
$labelLine->render();
|
||||||
|
|
||||||
$mapFrame->setY($posY);
|
$mapFrame->setY($posY);
|
||||||
|
|
||||||
|
@ -8,6 +8,13 @@ use FML\Controls\Labels\Label_Text;
|
|||||||
use ManiaControl\General\UsageInformationAble;
|
use ManiaControl\General\UsageInformationAble;
|
||||||
use ManiaControl\General\UsageInformationTrait;
|
use ManiaControl\General\UsageInformationTrait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class providing easy labels in a line
|
||||||
|
*
|
||||||
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
||||||
|
* @copyright 2014-2017 ManiaControl Team
|
||||||
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||||
|
*/
|
||||||
class LabelLine implements UsageInformationAble {
|
class LabelLine implements UsageInformationAble {
|
||||||
use UsageInformationTrait;
|
use UsageInformationTrait;
|
||||||
|
|
||||||
@ -19,23 +26,30 @@ class LabelLine implements UsageInformationAble {
|
|||||||
private $textSize = 1.5;
|
private $textSize = 1.5;
|
||||||
private $textColor = 'FFF';
|
private $textColor = 'FFF';
|
||||||
private $posZ = 0;
|
private $posZ = 0;
|
||||||
|
private $prefix = '';
|
||||||
|
|
||||||
|
|
||||||
public function __construct(Frame $frame) {
|
public function __construct(Frame $frame) {
|
||||||
$this->frame = $frame;
|
$this->frame = $frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new text label
|
* Create a new text label
|
||||||
*
|
*
|
||||||
* @param $labelText
|
* @param $labelText
|
||||||
* @param $posX
|
* @param $posX
|
||||||
* @param int $width
|
* @param int $width
|
||||||
|
* @param string $action
|
||||||
*/
|
*/
|
||||||
public function addLabelEntryText($labelText, $posX, $width = 0) {
|
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) {
|
||||||
|
$label->setAction($action);
|
||||||
|
}
|
||||||
if ($width) {
|
if ($width) {
|
||||||
$label->setWidth($width);
|
$label->setWidth($width);
|
||||||
}
|
}
|
||||||
@ -54,6 +68,7 @@ class LabelLine implements UsageInformationAble {
|
|||||||
/**
|
/**
|
||||||
* Adds the labels to your frame
|
* Adds the labels to your frame
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
/** @var Label $entry */
|
/** @var Label $entry */
|
||||||
foreach ($this->entries as $entry) {
|
foreach ($this->entries as $entry) {
|
||||||
@ -62,6 +77,7 @@ class LabelLine implements UsageInformationAble {
|
|||||||
$entry->setTextSize($this->textSize);
|
$entry->setTextSize($this->textSize);
|
||||||
$entry->setTextColor($this->textColor);
|
$entry->setTextColor($this->textColor);
|
||||||
$entry->setZ($this->posZ);
|
$entry->setZ($this->posZ);
|
||||||
|
$entry->setTextPrefix($this->prefix);
|
||||||
|
|
||||||
$this->frame->addChild($entry);
|
$this->frame->addChild($entry);
|
||||||
}
|
}
|
||||||
@ -122,6 +138,7 @@ class LabelLine implements UsageInformationAble {
|
|||||||
public function setTextColor($textColor) {
|
public function setTextColor($textColor) {
|
||||||
$this->textColor = $textColor;
|
$this->textColor = $textColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
@ -142,4 +159,18 @@ class LabelLine implements UsageInformationAble {
|
|||||||
public function getEntries() {
|
public function getEntries() {
|
||||||
return $this->entries;
|
return $this->entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getPrefix() {
|
||||||
|
return $this->prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $prefix
|
||||||
|
*/
|
||||||
|
public function setPrefix($prefix) {
|
||||||
|
$this->prefix = $prefix;
|
||||||
|
}
|
||||||
}
|
}
|
@ -369,6 +369,8 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener,
|
|||||||
* @param array $labelStrings
|
* @param array $labelStrings
|
||||||
* @param array $properties
|
* @param array $properties
|
||||||
* @return Label_Text[]
|
* @return Label_Text[]
|
||||||
|
* @deprecated use \ManiaControl\Manialinks\LabelLine instead
|
||||||
|
* @see \ManiaControl\Manialinks\LabelLine
|
||||||
*/
|
*/
|
||||||
public function labelLine(Frame $frame, array $labelStrings, array $properties = array()) {
|
public function labelLine(Frame $frame, array $labelStrings, array $properties = array()) {
|
||||||
// define standard properties
|
// define standard properties
|
||||||
|
Loading…
Reference in New Issue
Block a user