new good solution for labelline issues
This commit is contained in:
		| @@ -133,9 +133,9 @@ class AdminLists implements ManialinkPageAnswerListener, CallbackListener { | |||||||
| 				$lineQuad->setZ(0.001); | 				$lineQuad->setZ(0.001); | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			$array = array($index => $posX + 5, $admin->nickname => $posX + 18, $admin->login => $posX + 70); | 			$positions = array($posX + 5, $posX + 18, $posX + 70); | ||||||
| 			$this->maniaControl->getManialinkManager()->labelLine($playerFrame, $array); | 			$texts     = array($index, $admin->nickname, $admin->login); | ||||||
|  | 			$this->maniaControl->getManialinkManager()->labelLine($playerFrame, array($positions, $texts)); | ||||||
|  |  | ||||||
| 			// Level Quad | 			// Level Quad | ||||||
| 			$rightQuad = new Quad_BgRaceScore2(); | 			$rightQuad = new Quad_BgRaceScore2(); | ||||||
|   | |||||||
| @@ -352,15 +352,15 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener | |||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * Adds a line of labels | 	 * 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 Frame $frame | ||||||
| 	 * @param array   $labelStrings if(posIsKey) array($pos => $value) | 	 * @param array $labelStrings | ||||||
| 	 * @param array   $properties | 	 * @param array $properties | ||||||
| 	 * @param boolean $posIsKey |  | ||||||
| 	 * @return Label_Text[] | 	 * @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 | 		// define standard properties | ||||||
| 		$hAlign    = (isset($properties['hAlign']) ? $properties['hAlign'] : Control::LEFT); | 		$hAlign    = (isset($properties['hAlign']) ? $properties['hAlign'] : Control::LEFT); | ||||||
| 		$style     = (isset($properties['style']) ? $properties['style'] : Label_Text::STYLE_TextCardSmall); | 		$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); | 		$profile   = (isset($properties['profile']) ? $properties['profile'] : false); | ||||||
|  |  | ||||||
| 		$labels = array(); | 		$labels = array(); | ||||||
| 		foreach ($labelStrings as $key => $value) { |  | ||||||
| 			if ($posIsKey) { | 		//If you call LabelLine with array(array(positions), array(texts)) | ||||||
| 				$x    = $key; | 		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])) { | ||||||
| 				$text = $value; | 			$positions = $labelStrings[0]; | ||||||
| 			} else { | 			$texts     = $labelStrings[1]; | ||||||
| 				$x    = $value; |  | ||||||
| 				$text = $key; | 			if (count($positions) != count($texts)) { | ||||||
|  | 				trigger_error("LabelLine Position length is not equal to Text Length", E_USER_ERROR); | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			$label = new Label_Text(); | 			foreach ($positions as $key => $x) { | ||||||
| 			$frame->add($label); | 				$label = new Label_Text(); | ||||||
| 			$label->setHAlign($hAlign); | 				$frame->add($label); | ||||||
| 			$label->setX($x); | 				$label->setHAlign($hAlign); | ||||||
| 			$label->setStyle($style); | 				$label->setX($x); | ||||||
| 			$label->setTextSize($textSize); | 				$label->setStyle($style); | ||||||
| 			$label->setText($text); | 				$label->setTextSize($textSize); | ||||||
| 			$label->setTextColor($textColor); | 				$label->setText($texts[$key]); | ||||||
|  | 				$label->setTextColor($textColor); | ||||||
|  |  | ||||||
| 			if ($profile) { | 				if ($profile) { | ||||||
| 				$label->addPlayerProfileFeature($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; | 		return $labels; | ||||||
|   | |||||||
| @@ -62,7 +62,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer | |||||||
| 	 * Private properties | 	 * Private properties | ||||||
| 	 */ | 	 */ | ||||||
| 	/** @var ManiaControl $maniaControl */ | 	/** @var ManiaControl $maniaControl */ | ||||||
| 	private $maniaControl = null; | 	private $maniaControl     = null; | ||||||
| 	private $playersListShown = array(); | 	private $playersListShown = array(); | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| @@ -163,6 +163,7 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer | |||||||
| 		$headFrame = new Frame(); | 		$headFrame = new Frame(); | ||||||
| 		$frame->add($headFrame); | 		$frame->add($headFrame); | ||||||
| 		$headFrame->setY($posY - 5); | 		$headFrame->setY($posY - 5); | ||||||
|  |  | ||||||
| 		$labelLineArray = array('Id' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Location' => $posX + 101); | 		$labelLineArray = array('Id' => $posX + 5, 'Nickname' => $posX + 18, 'Login' => $posX + 70, 'Location' => $posX + 101); | ||||||
| 		if ($this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR) | 		if ($this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR) | ||||||
| 		) { | 		) { | ||||||
| @@ -195,8 +196,9 @@ class PlayerList implements ManialinkPageAnswerListener, CallbackListener, Timer | |||||||
| 				$lineQuad->setZ(0.001); | 				$lineQuad->setZ(0.001); | ||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			$array = array($index => $posX + 5, $listPlayer->nickname => $posX + 18, $listPlayer->login => $posX + 70, $path => $posX + 101); | 			$positions = array($posX + 5, $posX + 18, $posX + 70, $posX + 101); | ||||||
| 			$this->maniaControl->getManialinkManager()->labelLine($playerFrame, $array); | 			$texts     = array($index, $listPlayer->nickname, $listPlayer->login, $path); | ||||||
|  | 			$this->maniaControl->getManialinkManager()->labelLine($playerFrame, array($positions, $texts)); | ||||||
|  |  | ||||||
| 			$playerFrame->setY($posY); | 			$playerFrame->setY($posY); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -281,6 +281,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 			return; | 			return; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|  | 		//FIXME if you write "/donate 50 hallo" than comes Message: Donate to Hallo | ||||||
| 		if (!$receiverName) { | 		if (!$receiverName) { | ||||||
| 			$serverName = $this->maniaControl->getClient()->getServerName(); | 			$serverName = $this->maniaControl->getClient()->getServerName(); | ||||||
| 			$message    = 'Donate ' . $amount . ' Planets to $<' . $serverName . '$>?'; | 			$message    = 'Donate ' . $amount . ' Planets to $<' . $serverName . '$>?'; | ||||||
| @@ -519,8 +520,10 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { | |||||||
| 			} | 			} | ||||||
|  |  | ||||||
| 			$donatingPlayer = $this->maniaControl->getPlayerManager()->getPlayerByIndex($playerIndex); | 			$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; | 			$posY -= 4; | ||||||
| 			$index++; | 			$index++; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user