Fix PlayerProfile feature for TMNEXT
This commit is contained in:
		| @@ -846,9 +846,9 @@ abstract class Control implements Identifiable, Renderable, ScriptFeatureable | |||||||
|      * @param string $eventLabel (optional) Event on which the player profile will be opened |      * @param string $eventLabel (optional) Event on which the player profile will be opened | ||||||
|      * @return static |      * @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); |         $this->addScriptFeature($playerProfile); | ||||||
|         return $this; |         return $this; | ||||||
|     } |     } | ||||||
|   | |||||||
| @@ -33,6 +33,11 @@ class PlayerProfile extends ScriptFeature | |||||||
|      */ |      */ | ||||||
|     protected $labelName = null; |     protected $labelName = null; | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * @var string $titleId Script Label name | ||||||
|  |      */ | ||||||
|  |     protected $titleId = null; | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * Construct a new Player Profile |      * Construct a new Player Profile | ||||||
|      * |      * | ||||||
| @@ -41,7 +46,7 @@ class PlayerProfile extends ScriptFeature | |||||||
|      * @param Control $control   (optional) Profile Control |      * @param Control $control   (optional) Profile Control | ||||||
|      * @param string  $labelName (optional) Script Label name |      * @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) { |         if ($login) { | ||||||
|             $this->setLogin($login); |             $this->setLogin($login); | ||||||
| @@ -52,6 +57,9 @@ class PlayerProfile extends ScriptFeature | |||||||
|         if ($labelName) { |         if ($labelName) { | ||||||
|             $this->setLabelName($labelName); |             $this->setLabelName($labelName); | ||||||
|         } |         } | ||||||
|  |         if ($titleId) { | ||||||
|  |             $this->setTitleId($titleId); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
| @@ -130,6 +138,30 @@ class PlayerProfile extends ScriptFeature | |||||||
|         return $this; |         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() |      * @see ScriptFeature::prepare() | ||||||
|      */ |      */ | ||||||
| @@ -148,18 +180,26 @@ class PlayerProfile extends ScriptFeature | |||||||
|     { |     { | ||||||
|         $login = Builder::escapeText($this->login); |         $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) { |         if ($this->control) { | ||||||
|             // Control event |             // Control event | ||||||
|             $controlId = Builder::escapeText($this->control->getId()); |             $controlId = Builder::escapeText($this->control->getId()); | ||||||
|  |  | ||||||
|             return " |             return " | ||||||
| if (Event.Control.ControlId == {$controlId}) { | if (Event.Control.ControlId == {$controlId}) { | ||||||
| 	ShowProfile({$login}); | 	{$apicall} | ||||||
| }"; | }"; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         // Other events |         // Other events | ||||||
|         return " |         return " | ||||||
| ShowProfile({$login});"; | {$apicall}"; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user