Resolved #138 Move Nadeo Live Widget (+Added Settings for customization)

This commit is contained in:
kremsy 2017-07-02 18:05:57 +02:00
parent 22e1e24284
commit 0385276d8d

View File

@ -9,9 +9,9 @@ use FML\Controls\Quads\Quad_Icons128x128_1;
use FML\Controls\Quads\Quad_Icons64x64_1; use FML\Controls\Quads\Quad_Icons64x64_1;
use FML\ManiaLink; use FML\ManiaLink;
use FML\Script\Script; use FML\Script\Script;
use FML\XmlRpc\TMUIProperties;
use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\Callbacks; use ManiaControl\Callbacks\Callbacks;
use ManiaControl\Callbacks\Structures\Common\UIPropertiesBaseStructure;
use ManiaControl\Callbacks\TimerListener; use ManiaControl\Callbacks\TimerListener;
use ManiaControl\ManiaControl; use ManiaControl\ManiaControl;
use ManiaControl\Manialinks\IconManager; use ManiaControl\Manialinks\IconManager;
@ -71,6 +71,10 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
const SETTING_SERVERINFO_WIDGET_WIDTH = 'ServerInfo-Widget-Size: Width'; const SETTING_SERVERINFO_WIDGET_WIDTH = 'ServerInfo-Widget-Size: Width';
const SETTING_SERVERINFO_WIDGET_HEIGHT = 'ServerInfo-Widget-Size: Height'; const SETTING_SERVERINFO_WIDGET_HEIGHT = 'ServerInfo-Widget-Size: Height';
// Nadeo Widget Properties
const SETTING_TM_LIVE_INFO_WIDGET_POSX = "Nadeo LiveInfo-Widget-Position: X";
const SETTING_TM_LIVE_INFO_WIDGET_POSY = "Nadeo LiveInfo-Widget-Position: Y";
/* /*
* Private properties * Private properties
*/ */
@ -158,17 +162,24 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_WIDTH, 10); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_WIDTH, 10);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_HEIGHT, 5.5); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_CLOCK_WIDGET_HEIGHT, 5.5);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_TM_LIVE_INFO_WIDGET_POSX, -122);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_TM_LIVE_INFO_WIDGET_POSY, 84);
$this->displayWidgets(); $this->displayWidgets();
// Set CustomUI Setting // Set CustomUI Setting
$this->maniaControl->getManialinkManager()->getCustomUIManager()->setChallengeInfoVisible(false); $this->maniaControl->getManialinkManager()->getCustomUIManager()->setChallengeInfoVisible(false); //TODO verify if still needed
//TrackMania //Trackmania Nadeo Widgets
$this->maniaControl->getModeScriptEventManager()->getTrackmaniaUIProperties()->setCallable(function (UIPropertiesBaseStructure $structure) { $uiProperties = new TMUIProperties();
$xml = str_replace("<map_info visible=\"true\"", "<map_info visible=\"false\"", $structure->getUiPropertiesXML()); //Map Info Widget
$this->maniaControl->getModeScriptEventManager()->setTrackmaniaUIProperties($xml); $uiProperties->setMapInfoVisible(false);
}); $livePosX = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_TM_LIVE_INFO_WIDGET_POSX);
$livePosY = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_TM_LIVE_INFO_WIDGET_POSY);
$uiProperties->setLiveInfoPosition($livePosX, $livePosY, 5);
$this->maniaControl->getModeScriptEventManager()->setTrackmaniaUIProperties((string) $uiProperties);
return true; return true;
} }
@ -394,13 +405,12 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
$this->closeWidget(self::MLID_NEXTMAP_WIDGET); $this->closeWidget(self::MLID_NEXTMAP_WIDGET);
// Set CustomUI Setting // Set CustomUI Setting
$this->maniaControl->getManialinkManager()->getCustomUIManager()->setChallengeInfoVisible(true); $this->maniaControl->getManialinkManager()->getCustomUIManager()->setChallengeInfoVisible(true); //TODO verify if still needed
//TrackMania //TrackMania
$this->maniaControl->getModeScriptEventManager()->getTrackmaniaUIProperties()->setCallable(function (UIPropertiesBaseStructure $structure) { $uiProperties = new TMUIProperties();
$xml = str_replace("<map_info visible=\"false\"", "<map_info visible=\"true\"", $structure->getUiPropertiesXML()); $uiProperties->setMapInfoVisible(true);
$this->maniaControl->getModeScriptEventManager()->setTrackmaniaUIProperties($xml); $this->maniaControl->getModeScriptEventManager()->setTrackmaniaUIProperties((string) $uiProperties);
});
} }
/** /**
@ -549,6 +559,16 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
public function updateSettings(Setting $setting) { public function updateSettings(Setting $setting) {
if ($setting->belongsToClass($this)) { if ($setting->belongsToClass($this)) {
$this->displayWIdgets(); $this->displayWIdgets();
//Update Nadeo Live Info Widget
if ($setting->setting == self::SETTING_TM_LIVE_INFO_WIDGET_POSX || $setting->setting == self::SETTING_TM_LIVE_INFO_WIDGET_POSY) {
$uiProperties = new TMUIProperties();
$livePosX = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_TM_LIVE_INFO_WIDGET_POSX);
$livePosY = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_TM_LIVE_INFO_WIDGET_POSY);
$uiProperties->setLiveInfoPosition($livePosX, $livePosY, 5);
$this->maniaControl->getModeScriptEventManager()->setTrackmaniaUIProperties((string) $uiProperties);
}
} }
} }