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\ManiaControl;
|
||||
use ManiaControl\Manialinks\IconManager;
|
||||
use ManiaControl\Manialinks\LabelLine;
|
||||
use ManiaControl\Manialinks\ManialinkManager;
|
||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
use ManiaControl\Maps\MapCommands;
|
||||
@ -201,6 +202,17 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
'$oLast Update' => $posX + 130);
|
||||
$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;
|
||||
$posY = $height / 2 - 16;
|
||||
$pageFrame = null;
|
||||
@ -226,12 +238,17 @@ class ManiaExchangeList implements CallbackListener, ManialinkPageAnswerListener
|
||||
$lineQuad->setZ(0.001);
|
||||
}
|
||||
|
||||
$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,
|
||||
'$s' . $map->mood => $posX + 118, '$s' . $time => $posX + 130);
|
||||
$labels = $this->maniaControl->getManialinkManager()->labelLine($mapFrame, $array);
|
||||
$authorLabel = $labels[2];
|
||||
$authorLabel->setAction(self::ACTION_GET_MAPS_FROM_AUTHOR . '.' . $map->author);
|
||||
$time = Formatter::timeElapsedString(strtotime($map->updated));
|
||||
$labelLine = new LabelLine($mapFrame);
|
||||
$labelLine->addLabelEntryText($map->id, $posX + 3.5, 9);
|
||||
$labelLine->addLabelEntryText($map->name, $posX + 12.5, 38.5);
|
||||
$labelLine->addLabelEntryText($map->author, $posX + 59, 44, 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);
|
||||
|
||||
|
@ -8,6 +8,13 @@ use FML\Controls\Labels\Label_Text;
|
||||
use ManiaControl\General\UsageInformationAble;
|
||||
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 {
|
||||
use UsageInformationTrait;
|
||||
|
||||
@ -19,23 +26,30 @@ class LabelLine implements UsageInformationAble {
|
||||
private $textSize = 1.5;
|
||||
private $textColor = 'FFF';
|
||||
private $posZ = 0;
|
||||
private $prefix = '';
|
||||
|
||||
|
||||
public function __construct(Frame $frame) {
|
||||
$this->frame = $frame;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new text label
|
||||
*
|
||||
* @param $labelText
|
||||
* @param $posX
|
||||
* @param int $width
|
||||
* @param $labelText
|
||||
* @param $posX
|
||||
* @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();
|
||||
$this->frame->addChild($label);
|
||||
$label->setText($labelText);
|
||||
$label->setX($posX);
|
||||
if ($action) {
|
||||
$label->setAction($action);
|
||||
}
|
||||
if ($width) {
|
||||
$label->setWidth($width);
|
||||
}
|
||||
@ -54,6 +68,7 @@ class LabelLine implements UsageInformationAble {
|
||||
/**
|
||||
* Adds the labels to your frame
|
||||
*/
|
||||
|
||||
public function render() {
|
||||
/** @var Label $entry */
|
||||
foreach ($this->entries as $entry) {
|
||||
@ -62,6 +77,7 @@ class LabelLine implements UsageInformationAble {
|
||||
$entry->setTextSize($this->textSize);
|
||||
$entry->setTextColor($this->textColor);
|
||||
$entry->setZ($this->posZ);
|
||||
$entry->setTextPrefix($this->prefix);
|
||||
|
||||
$this->frame->addChild($entry);
|
||||
}
|
||||
@ -122,6 +138,7 @@ class LabelLine implements UsageInformationAble {
|
||||
public function setTextColor($textColor) {
|
||||
$this->textColor = $textColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
@ -142,4 +159,18 @@ class LabelLine implements UsageInformationAble {
|
||||
public function getEntries() {
|
||||
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 $properties
|
||||
* @return Label_Text[]
|
||||
* @deprecated use \ManiaControl\Manialinks\LabelLine instead
|
||||
* @see \ManiaControl\Manialinks\LabelLine
|
||||
*/
|
||||
public function labelLine(Frame $frame, array $labelStrings, array $properties = array()) {
|
||||
// define standard properties
|
||||
|
Loading…
Reference in New Issue
Block a user