diff --git a/core/Manialinks/CustomUIManager.php b/core/Manialinks/CustomUIManager.php index 3579aafa..f4d4b2ec 100644 --- a/core/Manialinks/CustomUIManager.php +++ b/core/Manialinks/CustomUIManager.php @@ -4,8 +4,6 @@ namespace ManiaControl\Manialinks; use FML\CustomUI; use ManiaControl\Callbacks\CallbackListener; -use ManiaControl\Callbacks\Callbacks; -use ManiaControl\Callbacks\Structures\Common\UIPropertiesBaseStructure; use ManiaControl\Callbacks\TimerListener; use ManiaControl\Commands\CommandListener; use ManiaControl\General\UsageInformationAble; @@ -38,13 +36,6 @@ class CustomUIManager implements CallbackListener, TimerListener, UsageInformati private $customUI = null; private $updateManialink = false; - /** - * ShootMania UI Properties - * - * @var \ManiaControl\Callbacks\Structures\Common\UIPropertiesBaseStructure - */ - private $shootManiaUIProperties; - /** * Create a custom UI manager instance * @@ -58,35 +49,8 @@ class CustomUIManager implements CallbackListener, TimerListener, UsageInformati $this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerJoined'); $this->maniaControl->getTimerManager()->registerTimerListening($this, 'handle1Second', 1000); - - //Initilize on Init the Properties - $this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, function () { - $this->maniaControl->getModeScriptEventManager()->getShootmaniaUIProperties(); - }); - - //Update the Structure if its Changed - $this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::SM_UIPROPERTIES, $this, function (UIPropertiesBaseStructure $structure) { - $this->shootManiaUIProperties = $structure; - }); - - } - /** - * Enable the Notices - */ - public function enableNotices() { //TODO what happens if you set severall at once, than you propably mistakly use the old JSON, so there is the need to update internal json - $xml = str_replace("", "", $this->shootManiaUIProperties->getUiPropertiesXML()); - $this->maniaControl->getModeScriptEventManager()->setShootmaniaUIProperties($xml); - } - - /** - * Disables the Notices - */ - public function disableNotices() { - $xml = str_replace("", "", $this->shootManiaUIProperties->getUiPropertiesXML()); - $this->maniaControl->getModeScriptEventManager()->setShootmaniaUIProperties($xml); - } /** * Create the ManiaLink and CustomUI instances @@ -216,12 +180,4 @@ class CustomUIManager implements CallbackListener, TimerListener, UsageInformati $this->updateManialink = true; } - /** - * Get the Shootmania UI Properties - * - * @return \ManiaControl\Callbacks\Structures\Common\UIPropertiesBaseStructure - */ - public function getShootManiaUIProperties() { - return $this->shootManiaUIProperties; - } } diff --git a/core/Script/ModeScriptEventManager.php b/core/Script/ModeScriptEventManager.php index ce9583b4..056a6ab1 100644 --- a/core/Script/ModeScriptEventManager.php +++ b/core/Script/ModeScriptEventManager.php @@ -479,8 +479,8 @@ class ModeScriptEventManager implements UsageInformationAble { */ public function getTrackmaniaUIProperties() { $responseId = $this->generateResponseId(); - $this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.UI.SetProperties', array($responseId)); - return new InvokeScriptCallback($this->maniaControl, Callbacks::TM_SCORES, $responseId); + $this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.UI.GetProperties', array($responseId)); + return new InvokeScriptCallback($this->maniaControl, Callbacks::TM_UIPROPERTIES, $responseId); } /** @@ -491,7 +491,7 @@ class ModeScriptEventManager implements UsageInformationAble { * @return \ManiaControl\Script\InvokeScriptCallback You can directly set a callable on it via setCallable() to get the updated Properties */ public function setTrackmaniaUIProperties($properties) { - $this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.UI.GetProperties', array($properties)); + $this->maniaControl->getClient()->triggerModeScriptEvent('Trackmania.UI.SetProperties', array($properties)); return $this->getTrackmaniaUIProperties(); } diff --git a/plugins/MCTeam/WidgetPlugin.php b/plugins/MCTeam/WidgetPlugin.php index 6875c12c..d57a0ba7 100644 --- a/plugins/MCTeam/WidgetPlugin.php +++ b/plugins/MCTeam/WidgetPlugin.php @@ -11,6 +11,7 @@ use FML\ManiaLink; use FML\Script\Script; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\Callbacks; +use ManiaControl\Callbacks\Structures\Common\UIPropertiesBaseStructure; use ManiaControl\Callbacks\TimerListener; use ManiaControl\ManiaControl; use ManiaControl\Manialinks\IconManager; @@ -123,9 +124,6 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { public function load(ManiaControl $maniaControl) { $this->maniaControl = $maniaControl; - // Set CustomUI Setting - $this->maniaControl->getManialinkManager()->getCustomUIManager()->setChallengeInfoVisible(false); - // Callbacks $this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'handleOnBeginMap'); $this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::ENDMAP, $this, 'handleOnEndMap'); @@ -161,6 +159,16 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { $this->displayWidgets(); + + // Set CustomUI Setting + $this->maniaControl->getManialinkManager()->getCustomUIManager()->setChallengeInfoVisible(false); + + //TrackMania + $this->maniaControl->getModeScriptEventManager()->getTrackmaniaUIProperties()->setCallable(function (UIPropertiesBaseStructure $structure) { + $xml = str_replace("getUiPropertiesXML()); + $this->maniaControl->getModeScriptEventManager()->setTrackmaniaUIProperties($xml); + }); + return true; } @@ -382,6 +390,15 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin { $this->closeWidget(self::MLID_SERVERINFO_WIDGET); $this->closeWidget(self::MLID_MAP_WIDGET); $this->closeWidget(self::MLID_NEXTMAP_WIDGET); + + // Set CustomUI Setting + $this->maniaControl->getManialinkManager()->getCustomUIManager()->setChallengeInfoVisible(true); + + //TrackMania + $this->maniaControl->getModeScriptEventManager()->getTrackmaniaUIProperties()->setCallable(function (UIPropertiesBaseStructure $structure) { + $xml = str_replace("getUiPropertiesXML()); + $this->maniaControl->getModeScriptEventManager()->setTrackmaniaUIProperties($xml); + }); } /**