This commit is contained in:
kremsy 2013-12-31 15:53:06 +01:00
parent 36d75064e2
commit eeb2a89c4f

View File

@ -1,28 +1,26 @@
<?php
use FML\Controls\Control;
use FML\Controls\Frame;
use FML\Controls\Labels\Label_Button;
use FML\Controls\Labels\Label_Text;
use FML\Controls\Quad;
use FML\Controls\Quads\Quad_Bgs1;
use FML\Controls\Quads\Quad_Bgs1InRace;
use FML\Controls\Quads\Quad_Icons128x128_1;
use FML\Controls\Quads\Quad_Icons64x64_1;
use FML\ManiaLink;
use FML\Script\Script;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\ManiaControl;
use ManiaControl\Players\Player;
use ManiaControl\Players\PlayerManager;
use ManiaControl\Plugins\Plugin;
use ManiaControl\Callbacks\CallbackManager;
use FML\Script\Script;
/**
* ManiaControl Widget Plugin
*
* @author kremsy
*/
class WidgetPlugin implements CallbackListener, Plugin {
class WidgetPlugin implements CallbackListener, Plugin
{
/**
* Constants
@ -78,7 +76,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
* @param ManiaControl $maniaControl
* @return bool
*/
public function load(ManiaControl $maniaControl) {
public function load(ManiaControl $maniaControl)
{
$this->maniaControl = $maniaControl;
// Set CustomUI Setting
@ -121,7 +120,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
/**
* Unload the plugin and its resources
*/
public function unload() {
public function unload()
{
$this->maniaControl->callbackManager->unregisterCallbackListener($this);
unset($this->maniaControl);
}
@ -131,7 +131,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
*
* @param bool $login
*/
public function displayClockWidget($login = false) {
public function displayClockWidget($login = false)
{
$pos_x = $this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_POSX);
$pos_y = $this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_POSY);
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_WIDTH);
@ -175,7 +176,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
*
* @param bool $login
*/
public function displayNextMapWidget($login = false) {
public function displayNextMapWidget($login = false)
{
$pos_x = $this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_POSX);
$pos_y = $this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_POSY);
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_WIDTH);
@ -211,8 +213,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
$map = $this->maniaControl->client->getResponse();
$name = $map['Name'];
$author = $map['Author'];
}
else {
} else {
$requester = $queuedMap[0];
$map = $queuedMap[1];
$name = $map->name;
@ -276,7 +277,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
*
* @param String $login
*/
public function displayServerInfoWidget($login = false) {
public function displayServerInfoWidget($login = false)
{
$pos_x = $this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_POSX);
$pos_y = $this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_POSY);
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_WIDTH);
@ -383,7 +385,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
*
* @param String $login
*/
public function displayMapWidget($login = false) {
public function displayMapWidget($login = false)
{
$pos_x = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_POSX);
$pos_y = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_POSY);
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_WIDTH);
@ -453,7 +456,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
*
* @param $widgetId
*/
public function closeWidget($widgetId) {
public function closeWidget($widgetId)
{
$emptyManialink = new ManiaLink($widgetId);
$manialinkText = $emptyManialink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText);
@ -464,7 +468,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
*
* @param array $callback
*/
public function handleOnInit(array $callback) {
public function handleOnInit(array $callback)
{
// Display Map Widget
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
$this->displayMapWidget();
@ -482,7 +487,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
*
* @param array $callback
*/
public function handleOnBeginMap(array $callback) {
public function handleOnBeginMap(array $callback)
{
// Display Map Widget
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
$this->displayMapWidget();
@ -495,7 +501,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
*
* @param array $callback
*/
public function handleOnEndMap(array $callback) {
public function handleOnEndMap(array $callback)
{
// Display Map Widget
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED)) {
$this->displayNextMapWidget();
@ -507,7 +514,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
*
* @param array $callback
*/
public function handlePlayerConnect(array $callback) {
public function handlePlayerConnect(array $callback)
{
$player = $callback[1];
// Display Map Widget
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
@ -526,7 +534,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
*
* @param array $callback
*/
public function handleEveryMinute(array $callback) {
public function handleEveryMinute(array $callback)
{
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
$this->displayClockWidget();
}
@ -537,7 +546,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
*
* @return int
*/
public static function getId() {
public static function getId()
{
return self::PLUGIN_ID;
}
@ -546,7 +556,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
*
* @return string
*/
public static function getName() {
public static function getName()
{
return self::PLUGIN_NAME;
}
@ -555,7 +566,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
*
* @return float,,
*/
public static function getVersion() {
public static function getVersion()
{
return self::PLUGIN_VERSION;
}
@ -564,7 +576,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
*
* @return string
*/
public static function getAuthor() {
public static function getAuthor()
{
return self::PLUGIN_AUTHOR;
}
@ -573,7 +586,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
*
* @return string
*/
public static function getDescription() {
public static function getDescription()
{
return null;
}
}