fixed label line, added pos in arrays as first (note its not the best fix, but it shouldnt break everything)

This commit is contained in:
kremsy 2015-06-03 23:27:50 +02:00
parent ea33ebc47b
commit de6c57fc73

View File

@ -262,7 +262,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
} }
} catch (UnknownPlayerException $e) { } catch (UnknownPlayerException $e) {
return false; return false;
} catch (FaultException $e){ } catch (FaultException $e) {
//TODO added 17.01.2015, remove later: //TODO added 17.01.2015, remove later:
$this->maniaControl->getErrorHandler()->triggerDebugNotice("Fault Exception: ManiaLink Manager, Message: " . $e->getMessage()); $this->maniaControl->getErrorHandler()->triggerDebugNotice("Fault Exception: ManiaLink Manager, Message: " . $e->getMessage());
return false; return false;
@ -349,15 +349,18 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener
return $success; return $success;
} }
/** /**
* Adds a line of labels * Adds a line of labels
* NOTE ALWAYS SET posIsKey Manually to true
* *
* @param Frame $frame * @param Frame $frame
* @param array $labelStrings * @param array $labelStrings if(posIsKey) array($pos => $value)
* @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()) { public function labelLine(Frame $frame, array $labelStrings, array $properties = array(), $posIsKey = false) {
// 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);
@ -366,7 +369,15 @@ 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 $text => $x) { foreach ($labelStrings as $key => $value) {
if ($posIsKey) {
$x = $key;
$text = $value;
} else {
$x = $value;
$text = $key;
}
$label = new Label_Text(); $label = new Label_Text();
$frame->add($label); $frame->add($label);
$label->setHAlign($hAlign); $label->setHAlign($hAlign);