new good solution for labelline issues

This commit is contained in:
kremsy 2015-06-04 00:23:29 +02:00
parent de6c57fc73
commit 9f809ec9d3
4 changed files with 57 additions and 32 deletions

View File

@ -133,9 +133,9 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener {
$lineQuad->setZ(0.001);
}
$array = array($index => $posX + 5, $admin->nickname => $posX + 18, $admin->login => $posX + 70);
$this->maniaControl->getManialinkManager()->labelLine($playerFrame, $array);
$positions = array($posX + 5, $posX + 18, $posX + 70);
$texts = array($index, $admin->nickname, $admin->login);
$this->maniaControl->getManialinkManager()->labelLine($playerFrame, array($positions, $texts));
// Level Quad
$rightQuad = new Quad_BgRaceScore2();

View File

@ -352,15 +352,15 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
/**
* Adds a line of labels
* NOTE ALWAYS SET posIsKey Manually to true
* LabelLine should be an array with the following structure: array(array(positions), array(texts))
* or array($text1 => $pos1, $text2 => $pos2 ...)
*
* @param Frame $frame
* @param array $labelStrings if(posIsKey) array($pos => $value)
* @param array $properties
* @param boolean $posIsKey
* @param Frame $frame
* @param array $labelStrings
* @param array $properties
* @return Label_Text[]
*/
public function labelLine(Frame $frame, array $labelStrings, array $properties = array(), $posIsKey = false) {
public function labelLine(Frame $frame, array $labelStrings, array $properties = array()) {
// define standard properties
$hAlign = (isset($properties['hAlign']) ? $properties['hAlign'] : Control::LEFT);
$style = (isset($properties['style']) ? $properties['style'] : Label_Text::STYLE_TextCardSmall);
@ -369,29 +369,49 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
$profile = (isset($properties['profile']) ? $properties['profile'] : false);
$labels = array();
foreach ($labelStrings as $key => $value) {
if ($posIsKey) {
$x = $key;
$text = $value;
} else {
$x = $value;
$text = $key;
//If you call LabelLine with array(array(positions), array(texts))
if (count($labelStrings) == 2 && array_key_exists(0, $labelStrings) && array_key_exists(1, $labelStrings) && array_key_exists(0, $labelStrings[0]) && array_key_exists(0, $labelStrings[1])) {
$positions = $labelStrings[0];
$texts = $labelStrings[1];
if (count($positions) != count($texts)) {
trigger_error("LabelLine Position length is not equal to Text Length", E_USER_ERROR);
}
$label = new Label_Text();
$frame->add($label);
$label->setHAlign($hAlign);
$label->setX($x);
$label->setStyle($style);
$label->setTextSize($textSize);
$label->setText($text);
$label->setTextColor($textColor);
foreach ($positions as $key => $x) {
$label = new Label_Text();
$frame->add($label);
$label->setHAlign($hAlign);
$label->setX($x);
$label->setStyle($style);
$label->setTextSize($textSize);
$label->setText($texts[$key]);
$label->setTextColor($textColor);
if ($profile) {
$label->addPlayerProfileFeature($profile);
if ($profile) {
$label->addPlayerProfileFeature($profile);
}
array_push($labels, $label);
}
} else {
foreach ($labelStrings as $text => $x) {
$label = new Label_Text();
$frame->add($label);
$label->setHAlign($hAlign);
$label->setX($x);
$label->setStyle($style);
$label->setTextSize($textSize);
$label->setText($text);
$label->setTextColor($textColor);
array_push($labels, $label);
if ($profile) {
$label->addPlayerProfileFeature($profile);
}
array_push($labels, $label);
}
}
return $labels;

View File

@ -62,7 +62,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
* Private properties
*/
/** @var ManiaControl $maniaControl */
private $maniaControl = null;
private $maniaControl = null;
private $playersListShown = array();
/**
@ -163,6 +163,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
$headFrame = new Frame();
$frame->add($headFrame);
$headFrame->setY($posY - 5);
$labelLineArray = array('Id' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Location' => $posX + 101);
if ($this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)
) {
@ -195,8 +196,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer
$lineQuad->setZ(0.001);
}
$array = array($index => $posX + 5, $listPlayer->nickname => $posX + 18, $listPlayer->login => $posX + 70, $path => $posX + 101);
$this->maniaControl->getManialinkManager()->labelLine($playerFrame, $array);
$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));
$playerFrame->setY($posY);

View File

@ -281,6 +281,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
return;
}
//FIXME if you write "/donate 50 hallo" than comes Message: Donate to Hallo
if (!$receiverName) {
$serverName = $this->maniaControl->getClient()->getServerName();
$message = 'Donate ' . $amount . ' Planets to $<' . $serverName . '$>?';
@ -519,8 +520,10 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
}
$donatingPlayer = $this->maniaControl->getPlayerManager()->getPlayerByIndex($playerIndex);
$array = array($index => $posX + 5, $donatingPlayer->nickname => $posX + 18, $donatingPlayer->login => $posX + 70, $donations => $posX + 110);
$this->maniaControl->getManialinkManager()->labelLine($playerFrame, $array);
$positions = array($posX + 5, $posX + 18, $posX + 70, $posX + 110);
$texts = array($index, $donatingPlayer->nickname, $donatingPlayer->login, $donations);
$this->maniaControl->getManialinkManager()->labelLine($playerFrame, array($positions, $texts));
$posY -= 4;
$index++;