Fix PlayerProfile feature for TMNEXT
This commit is contained in:
parent
424ff646ad
commit
0416a650a0
@ -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;
|
||||
}
|
||||
|
@ -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}";
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user