diff --git a/libs/FML/Controls/Control.php b/libs/FML/Controls/Control.php index d1fc3f07..070e2fd9 100644 --- a/libs/FML/Controls/Control.php +++ b/libs/FML/Controls/Control.php @@ -846,9 +846,9 @@ abstract class Control implements Identifiable, Renderable, ScriptFeatureable * @param string $eventLabel (optional) Event on which the player profile will be opened * @return static */ - public function addPlayerProfileFeature($login, $eventLabel = ScriptLabel::MOUSECLICK) + public function addPlayerProfileFeature($login, $eventLabel = ScriptLabel::MOUSECLICK, $titleId = "Trackmania") { - $playerProfile = new PlayerProfile($login, $this, $eventLabel); + $playerProfile = new PlayerProfile($login, $this, $eventLabel, $titleId) ; $this->addScriptFeature($playerProfile); return $this; } diff --git a/libs/FML/Script/Features/PlayerProfile.php b/libs/FML/Script/Features/PlayerProfile.php index 0ef0f50f..8951f3e9 100644 --- a/libs/FML/Script/Features/PlayerProfile.php +++ b/libs/FML/Script/Features/PlayerProfile.php @@ -33,6 +33,11 @@ class PlayerProfile extends ScriptFeature */ protected $labelName = null; + /** + * @var string $titleId Script Label name + */ + protected $titleId = null; + /** * Construct a new Player Profile * @@ -41,7 +46,7 @@ class PlayerProfile extends ScriptFeature * @param Control $control (optional) Profile Control * @param string $labelName (optional) Script Label name */ - public function __construct($login = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK) + public function __construct($login = null, Control $control = null, $labelName = ScriptLabel::MOUSECLICK, $titleId = "Trackmania") { if ($login) { $this->setLogin($login); @@ -52,6 +57,9 @@ class PlayerProfile extends ScriptFeature if ($labelName) { $this->setLabelName($labelName); } + if ($titleId) { + $this->setTitleId($titleId); + } } /** @@ -130,6 +138,30 @@ class PlayerProfile extends ScriptFeature return $this; } + /** + * Get the Script Label name + * + * @api + * @return string + */ + public function getTitleId() + { + return $this->titleId; + } + + /** + * Set the Script Label name + * + * @api + * @param string $labelName Script Label name + * @return static + */ + public function setTitleId($titleId) + { + $this->titleId = (string)$titleId; + return $this; + } + /** * @see ScriptFeature::prepare() */ @@ -148,18 +180,26 @@ class PlayerProfile extends ScriptFeature { $login = Builder::escapeText($this->login); + if ($this->titleId == "Trackmania") { + $apicall = "declare Text LibTMxSMRaceScoresTable_OpenProfileLogin for ClientUI = \"\"; + LibTMxSMRaceScoresTable_OpenProfileLogin = {$login};"; + } else { + $apicall = "ShowProfile({$login});"; + } + if ($this->control) { // Control event $controlId = Builder::escapeText($this->control->getId()); + return " if (Event.Control.ControlId == {$controlId}) { - ShowProfile({$login}); + {$apicall} }"; } // Other events return " -ShowProfile({$login});"; +{$apicall}"; } }