TrackManiaControl/application/plugins/WidgetPlugin.php

494 lines
16 KiB
PHP
Raw Normal View History

2013-12-29 22:52:07 +01:00
<?php
use FML\Controls\Control;
use FML\Controls\Frame;
use FML\Controls\Labels\Label_Text;
use FML\Controls\Quad;
use FML\ManiaLink;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\ManiaControl;
2013-12-30 16:45:26 +01:00
use ManiaControl\Players\Player;
2013-12-29 22:52:07 +01:00
use ManiaControl\Players\PlayerManager;
use ManiaControl\Plugins\Plugin;
use ManiaControl\Callbacks\CallbackManager;
2013-12-30 16:45:26 +01:00
2013-12-30 13:10:26 +01:00
/**
* ManiaControl Widget Plugin
*
* @author kremsy
*/
2013-12-29 22:52:07 +01:00
class WidgetPlugin implements CallbackListener, Plugin {
2013-12-30 14:52:48 +01:00
2013-12-29 22:52:07 +01:00
/**
* Constants
*/
const PLUGIN_ID = 8;
const PLUGIN_VERSION = 0.1;
const PLUGIN_NAME = 'WidgetPlugin';
const PLUGIN_AUTHOR = 'kremsy';
2013-12-30 14:52:48 +01:00
// MapWidget Properties
2013-12-30 11:23:00 +01:00
const MLID_MAPWIDGET = 'WidgetPlugin.MapWidget';
2013-12-29 23:39:30 +01:00
const SETTING_MAP_WIDGET_ACTIVATED = 'Map-Widget Activated';
2013-12-29 22:52:07 +01:00
const SETTING_MAP_WIDGET_POSX = 'Map-Widget-Position: X';
const SETTING_MAP_WIDGET_POSY = 'Map-Widget-Position: Y';
const SETTING_MAP_WIDGET_WIDTH = 'Map-Widget-Size: Width';
const SETTING_MAP_WIDGET_HEIGHT = 'Map-Widget-Size: Height';
2013-12-30 14:52:48 +01:00
// ClockWidget Properties
2013-12-30 11:23:00 +01:00
const MLID_CLOCKWIDGET = 'WidgetPlugin.ClockWidget';
2013-12-29 23:39:30 +01:00
const SETTING_CLOCK_WIDGET_ACTIVATED = 'Clock-Widget Activated';
const SETTING_CLOCK_WIDGET_POSX = 'Clock-Widget-Position: X';
const SETTING_CLOCK_WIDGET_POSY = 'Clock-Widget-Position: Y';
const SETTING_CLOCK_WIDGET_WIDTH = 'Clock-Widget-Size: Width';
const SETTING_CLOCK_WIDGET_HEIGHT = 'Clock-Widget-Size: Height';
2013-12-30 14:52:48 +01:00
// NextMapWidget Properties
2013-12-30 11:23:00 +01:00
const MLID_NEXTMAPWIDGET = 'WidgetPlugin.NextMapWidget';
const SETTING_NEXTMAP_WIDGET_ACTIVATED = 'Nextmap-Widget Activated';
const SETTING_NEXTMAP_WIDGET_POSX = 'Nextmap-Widget-Position: X';
const SETTING_NEXTMAP_WIDGET_POSY = 'Nextmap-Widget-Position: Y';
const SETTING_NEXTMAP_WIDGET_WIDTH = 'Nextmap-Widget-Size: Width';
const SETTING_NEXTMAP_WIDGET_HEIGHT = 'Nextmap-Widget-Size: Height';
2013-12-30 23:04:38 +01:00
// ServerInfoWidget Properties
const MLID_SERVERINFOWIDGET = 'WidgetPlugin.ServerInfoWidget';
const SETTING_SERVERINFO_WIDGET_ACTIVATED = 'ServerInfo-Widget Activated';
const SETTING_SERVERINFO_WIDGET_POSX = 'ServerInfo-Widget-Position: X';
const SETTING_SERVERINFO_WIDGET_POSY = 'ServerInfo-Widget-Position: Y';
const SETTING_SERVERINFO_WIDGET_WIDTH = 'ServerInfo-Widget-Size: Width';
const SETTING_SERVERINFO_WIDGET_HEIGHT = 'ServerInfo-Widget-Size: Height';
2013-12-29 22:52:07 +01:00
/**
2013-12-30 14:52:48 +01:00
* Private Properties
2013-12-29 22:52:07 +01:00
*/
2013-12-30 16:52:26 +01:00
/** @var maniaControl $maniaControl */
2013-12-29 22:52:07 +01:00
private $maniaControl = null;
2013-12-30 14:52:48 +01:00
/**
2013-12-29 22:52:07 +01:00
* Load the plugin
*
2013-12-30 14:52:48 +01:00
* @param ManiaControl $maniaControl
2013-12-29 22:52:07 +01:00
* @return bool
*/
2013-12-30 14:52:48 +01:00
public function load(ManiaControl $maniaControl) {
2013-12-29 22:52:07 +01:00
$this->maniaControl = $maniaControl;
2013-12-30 14:52:48 +01:00
// Set CustomUI Setting
$this->maniaControl->manialinkManager->customUIManager->setChallengeInfoVisible(false);
2013-12-29 22:52:07 +01:00
// Register for callbacks
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit');
2013-12-30 11:23:00 +01:00
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'handleOnBeginMap');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ENDMAP, $this, 'handleOnEndMap');
2013-12-29 22:52:07 +01:00
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerConnect');
2013-12-29 23:39:30 +01:00
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_MINUTE, $this, 'handleEveryMinute');
2013-12-30 14:52:48 +01:00
2013-12-29 23:01:51 +01:00
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED, true);
2013-12-29 22:52:07 +01:00
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_POSX, 160 - 20);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_POSY, 90 - 4.5);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_WIDTH, 40);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_HEIGHT, 9.);
2013-12-30 23:04:38 +01:00
$this->maniaControl->settingManager->initSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED, true);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_SERVERINFO_WIDGET_POSX, -160 + 20);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_SERVERINFO_WIDGET_POSY, 90 - 4.5);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_SERVERINFO_WIDGET_WIDTH, 40);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_SERVERINFO_WIDGET_HEIGHT, 9.);
2013-12-30 11:23:00 +01:00
$this->maniaControl->settingManager->initSetting($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED, true);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_NEXTMAP_WIDGET_POSX, 160 - 20);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_NEXTMAP_WIDGET_POSY, 90 - 25.5);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_NEXTMAP_WIDGET_WIDTH, 40);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_NEXTMAP_WIDGET_HEIGHT, 12.);
2013-12-30 14:52:48 +01:00
2013-12-29 23:39:30 +01:00
$this->maniaControl->settingManager->initSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED, true);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_CLOCK_WIDGET_POSX, 160 - 5);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_CLOCK_WIDGET_POSY, 90 - 11);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_CLOCK_WIDGET_WIDTH, 10);
2013-12-29 23:42:50 +01:00
$this->maniaControl->settingManager->initSetting($this, self::SETTING_CLOCK_WIDGET_HEIGHT, 5.5);
2013-12-30 14:52:48 +01:00
2013-12-29 22:52:07 +01:00
return true;
}
/**
* Unload the plugin and its resources
*/
2013-12-30 14:52:48 +01:00
public function unload() {
2013-12-29 22:52:07 +01:00
$this->maniaControl->callbackManager->unregisterCallbackListener($this);
unset($this->maniaControl);
}
2013-12-30 23:04:38 +01:00
/**
* Displays the Clock Widget
* @param bool $login
*/
2013-12-30 14:52:48 +01:00
public function displayClockWidget($login = false) {
2013-12-29 23:39:30 +01:00
$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);
$height = $this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_HEIGHT);
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
2013-12-30 14:52:48 +01:00
2013-12-29 23:39:30 +01:00
$maniaLink = new ManiaLink(self::MLID_CLOCKWIDGET);
2013-12-30 14:52:48 +01:00
// mainframe
2013-12-29 23:39:30 +01:00
$frame = new Frame();
$maniaLink->add($frame);
2013-12-30 14:52:48 +01:00
$frame->setSize($width, $height);
2013-12-29 23:39:30 +01:00
$frame->setPosition($pos_x, $pos_y);
2013-12-30 14:52:48 +01:00
// Background Quad
2013-12-29 23:39:30 +01:00
$backgroundQuad = new Quad();
$frame->add($backgroundQuad);
2013-12-30 14:52:48 +01:00
$backgroundQuad->setSize($width, $height);
2013-12-29 23:39:30 +01:00
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
2013-12-30 14:52:48 +01:00
2013-12-29 23:39:30 +01:00
$localTime = date("H:i", time());
2013-12-30 14:52:48 +01:00
2013-12-29 23:39:30 +01:00
$label = new Label_Text();
$frame->add($label);
$label->setY(1.5);
$label->setX(0);
2013-12-30 14:52:48 +01:00
$label->setAlign(Control::CENTER, Control::TOP);
2013-12-29 23:39:30 +01:00
$label->setZ(0.2);
2013-12-29 23:42:50 +01:00
$label->setTextSize(1);
2013-12-29 23:39:30 +01:00
$label->setText($localTime);
$label->setTextColor("FFF");
2013-12-30 14:52:48 +01:00
// Send manialink
2013-12-29 23:39:30 +01:00
$manialinkText = $maniaLink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
}
2013-12-30 11:23:00 +01:00
/**
* Displays the Next Map (Only at the end of the Map)
2013-12-30 14:52:48 +01:00
*
* @param bool $login
2013-12-30 11:23:00 +01:00
*/
2013-12-30 14:52:48 +01:00
public function displayNextMapWidget($login = false) {
2013-12-30 11:23:00 +01:00
$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);
$height = $this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_HEIGHT);
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
$labelStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultLabelStyle();
2013-12-30 14:52:48 +01:00
2013-12-30 11:23:00 +01:00
$maniaLink = new ManiaLink(self::MLID_NEXTMAPWIDGET);
2013-12-30 16:45:26 +01:00
2013-12-30 14:52:48 +01:00
// mainframe
2013-12-30 11:23:00 +01:00
$frame = new Frame();
$maniaLink->add($frame);
2013-12-30 14:52:48 +01:00
$frame->setSize($width, $height);
2013-12-30 11:23:00 +01:00
$frame->setPosition($pos_x, $pos_y);
2013-12-30 14:52:48 +01:00
// Background Quad
2013-12-30 11:23:00 +01:00
$backgroundQuad = new Quad();
$frame->add($backgroundQuad);
2013-12-30 14:52:48 +01:00
$backgroundQuad->setSize($width, $height);
2013-12-30 11:23:00 +01:00
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
2013-12-30 14:52:48 +01:00
// Check if the Next Map is a juked Map
2013-12-30 11:23:00 +01:00
$jukedMap = $this->maniaControl->mapManager->jukebox->getNextMap();
2013-12-30 16:45:26 +01:00
/** @var Player $requester */
2013-12-30 11:23:00 +01:00
$requester = null;
2013-12-30 14:52:48 +01:00
// if the nextmap is not a juked map, get it from map info
if ($jukedMap == null) {
2013-12-30 11:23:00 +01:00
$this->maniaControl->client->query("GetNextMapInfo");
$map = $this->maniaControl->client->getResponse();
$name = $map['Name'];
$author = $map['Author'];
2013-12-30 14:52:48 +01:00
}
else {
2013-12-30 11:23:00 +01:00
$requester = $jukedMap[0];
$map = $jukedMap[1];
$name = $map->name;
$author = $map->authorLogin;
}
2013-12-30 16:45:26 +01:00
2013-12-30 11:23:00 +01:00
$label = new Label_Text();
$frame->add($label);
$label->setY($height / 2 - 2.3);
$label->setX(0);
2013-12-30 14:52:48 +01:00
$label->setAlign(Control::CENTER, Control::CENTER);
2013-12-30 11:23:00 +01:00
$label->setZ(0.2);
$label->setTextSize(1);
$label->setText("Next Map");
$label->setTextColor("FFF");
$label->setStyle($labelStyle);
2013-12-30 14:52:48 +01:00
2013-12-30 11:23:00 +01:00
$label = new Label_Text();
$frame->add($label);
$label->setY($height / 2 - 5.5);
$label->setX(0);
2013-12-30 14:52:48 +01:00
$label->setAlign(Control::CENTER, Control::CENTER);
2013-12-30 11:23:00 +01:00
$label->setZ(0.2);
$label->setTextSize(1.3);
$label->setText($name);
$label->setTextColor("FFF");
2013-12-30 14:52:48 +01:00
2013-12-30 11:23:00 +01:00
$label = new Label_Text();
$frame->add($label);
$label->setX(0);
2013-12-30 14:52:48 +01:00
$label->setY(-$height / 2 + 4);
$label->setAlign(Control::CENTER, Control::CENTER);
2013-12-30 11:23:00 +01:00
$label->setZ(0.2);
$label->setTextSize(1);
$label->setScale(0.8);
$label->setText($author);
$label->setTextColor("FFF");
2013-12-30 14:52:48 +01:00
if ($requester != null) {
2013-12-30 11:23:00 +01:00
$label = new Label_Text();
$frame->add($label);
$label->setX(0);
2013-12-30 14:52:48 +01:00
$label->setY(-$height / 2 + 2);
$label->setAlign(Control::CENTER, Control::CENTER);
2013-12-30 11:23:00 +01:00
$label->setZ(0.2);
$label->setTextSize(1);
$label->setScale(0.7);
$label->setText($author);
$label->setTextColor("F80");
$label->setText("Requested by " . $requester->nickname);
}
2013-12-30 14:52:48 +01:00
// Send manialink
2013-12-30 11:23:00 +01:00
$manialinkText = $maniaLink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
}
2013-12-29 23:39:30 +01:00
2013-12-30 23:04:38 +01:00
/**
* Displays the Map Widget
*
* @param String $login
*/
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);
$height = $this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_HEIGHT);
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
$maniaLink = new ManiaLink(self::MLID_SERVERINFOWIDGET);
// mainframe
$frame = new Frame();
$maniaLink->add($frame);
$frame->setSize($width, $height);
$frame->setPosition($pos_x, $pos_y);
// Background Quad
$backgroundQuad = new Quad();
$frame->add($backgroundQuad);
$backgroundQuad->setSize($width, $height);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
#
$serverName= $this->maniaControl->server->getName();
$label = new Label_Text();
$frame->add($label);
$label->setY(1.5);
$label->setX(0);
$label->setAlign(Control::CENTER, Control::CENTER);
$label->setZ(0.2);
$label->setTextSize(1.3);
$label->setText($serverName);
$label->setTextColor("FFF");
// Send manialink
$manialinkText = $maniaLink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
}
2013-12-29 22:52:07 +01:00
/**
* Displays the Map Widget
2013-12-30 14:52:48 +01:00
*
2013-12-30 16:45:26 +01:00
* @param String $login
2013-12-29 22:52:07 +01:00
*/
2013-12-30 14:52:48 +01:00
public function displayMapWidget($login = false) {
2013-12-29 22:52:07 +01:00
$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);
$height = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_HEIGHT);
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
2013-12-30 14:52:48 +01:00
2013-12-29 22:52:07 +01:00
$maniaLink = new ManiaLink(self::MLID_MAPWIDGET);
2013-12-30 14:52:48 +01:00
// mainframe
2013-12-29 22:52:07 +01:00
$frame = new Frame();
$maniaLink->add($frame);
2013-12-30 14:52:48 +01:00
$frame->setSize($width, $height);
2013-12-29 22:52:07 +01:00
$frame->setPosition($pos_x, $pos_y);
2013-12-30 14:52:48 +01:00
// Background Quad
2013-12-29 22:52:07 +01:00
$backgroundQuad = new Quad();
$frame->add($backgroundQuad);
2013-12-30 14:52:48 +01:00
$backgroundQuad->setSize($width, $height);
2013-12-29 22:52:07 +01:00
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
2013-12-30 16:45:26 +01:00
2013-12-29 22:52:07 +01:00
$map = $this->maniaControl->mapManager->getCurrentMap();
2013-12-30 14:52:48 +01:00
2013-12-29 22:52:07 +01:00
$label = new Label_Text();
$frame->add($label);
2013-12-29 23:01:51 +01:00
$label->setY(1.5);
2013-12-29 22:52:07 +01:00
$label->setX(0);
2013-12-30 14:52:48 +01:00
$label->setAlign(Control::CENTER, Control::CENTER);
2013-12-29 22:52:07 +01:00
$label->setZ(0.2);
$label->setTextSize(1.3);
$label->setText($map->name);
$label->setTextColor("FFF");
2013-12-30 14:52:48 +01:00
2013-12-29 22:52:07 +01:00
$label = new Label_Text();
$frame->add($label);
$label->setX(0);
2013-12-29 23:01:51 +01:00
$label->setY(-1.4);
2013-12-30 14:52:48 +01:00
$label->setAlign(Control::CENTER, Control::CENTER);
2013-12-29 22:52:07 +01:00
$label->setZ(0.2);
$label->setTextSize(1);
2013-12-29 23:01:51 +01:00
$label->setScale(0.8);
2013-12-29 22:52:07 +01:00
$label->setText($map->authorLogin);
$label->setTextColor("FFF");
2013-12-30 16:45:26 +01:00
2013-12-30 14:52:48 +01:00
// Send manialink
2013-12-29 22:52:07 +01:00
$manialinkText = $maniaLink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
}
2013-12-30 11:23:00 +01:00
/**
* Closes a Widget
2013-12-30 14:52:48 +01:00
*
* @param
* $widgetId
2013-12-30 11:23:00 +01:00
*/
2013-12-30 14:52:48 +01:00
public function closeWidget($widgetId) {
2013-12-30 11:23:00 +01:00
$emptyManialink = new ManiaLink($widgetId);
$manialinkText = $emptyManialink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText);
}
2013-12-29 22:52:07 +01:00
/**
* Handle ManiaControl OnInit callback
*
2013-12-30 14:52:48 +01:00
* @param array $callback
2013-12-29 22:52:07 +01:00
*/
public function handleOnInit(array $callback) {
2013-12-30 14:52:48 +01:00
// Display Map Widget
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
2013-12-29 23:01:51 +01:00
$this->displayMapWidget();
}
2013-12-30 14:52:48 +01:00
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
2013-12-29 23:39:30 +01:00
$this->displayClockWidget();
}
2013-12-30 23:04:38 +01:00
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
$this->displayServerInfoWidget();
}
2013-12-29 22:52:07 +01:00
}
2013-12-30 11:23:00 +01:00
/**
* Handle on Begin Map
*
2013-12-30 14:52:48 +01:00
* @param array $callback
2013-12-30 11:23:00 +01:00
*/
public function handleOnBeginMap(array $callback) {
2013-12-30 14:52:48 +01:00
// Display Map Widget
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
2013-12-30 11:23:00 +01:00
$this->displayMapWidget();
}
$this->closeWidget(self::MLID_NEXTMAPWIDGET);
}
/**
* Handle on End Map
*
2013-12-30 14:52:48 +01:00
* @param array $callback
2013-12-30 11:23:00 +01:00
*/
public function handleOnEndMap(array $callback) {
2013-12-30 14:52:48 +01:00
// Display Map Widget
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED)) {
2013-12-30 11:23:00 +01:00
$this->displayNextMapWidget();
}
}
2013-12-29 22:52:07 +01:00
/**
* Handle PlayerConnect callback
*
2013-12-30 14:52:48 +01:00
* @param array $callback
2013-12-29 22:52:07 +01:00
*/
public function handlePlayerConnect(array $callback) {
2013-12-29 23:01:51 +01:00
$player = $callback[1];
2013-12-30 14:52:48 +01:00
// Display Map Widget
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
2013-12-29 23:01:51 +01:00
$this->displayMapWidget($player->login);
}
2013-12-30 14:52:48 +01:00
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
2013-12-30 23:04:38 +01:00
$this->displayClockWidget($player->login);
}
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
$this->displayServerInfoWidget($player->login);
2013-12-29 23:39:30 +01:00
}
2013-12-29 22:52:07 +01:00
}
2013-12-29 23:39:30 +01:00
/**
* Aktualize the clock widget every minute
2013-12-30 14:52:48 +01:00
*
* @param array $callback
2013-12-29 23:39:30 +01:00
*/
public function handleEveryMinute(array $callback) {
2013-12-30 14:52:48 +01:00
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
2013-12-29 23:39:30 +01:00
$this->displayClockWidget();
}
}
2013-12-29 22:52:07 +01:00
/**
* Get plugin id
*
* @return int
*/
2013-12-30 14:52:48 +01:00
public static function getId() {
2013-12-29 22:52:07 +01:00
return self::PLUGIN_ID;
}
/**
* Get Plugin Name
*
* @return string
*/
2013-12-30 14:52:48 +01:00
public static function getName() {
2013-12-29 22:52:07 +01:00
return self::PLUGIN_NAME;
}
/**
* Get Plugin Version
*
* @return float,,
*/
2013-12-30 14:52:48 +01:00
public static function getVersion() {
2013-12-29 22:52:07 +01:00
return self::PLUGIN_VERSION;
}
/**
* Get Plugin Author
*
* @return string
*/
2013-12-30 14:52:48 +01:00
public static function getAuthor() {
2013-12-29 22:52:07 +01:00
return self::PLUGIN_AUTHOR;
}
/**
* Get Plugin Description
*
* @return string
*/
2013-12-30 14:52:48 +01:00
public static function getDescription() {
2013-12-29 22:52:07 +01:00
return null;
}
}