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