Custom UI Manager

This commit is contained in:
Steffen Schröder 2013-12-30 14:52:48 +01:00
parent 9bb2495756
commit 2e8a18692c
4 changed files with 325 additions and 155 deletions

View File

@ -2,6 +2,8 @@
namespace FML\Elements;
use FML\Types\Renderable;
/**
* Class representing the Custom_UI
*
@ -119,7 +121,7 @@ class CustomUI implements Renderable {
foreach ($settings as $setting => $value) {
if ($value === null) continue;
$xmlElement = $domDocument->createElement($setting);
$xmlElement->setAttribute('visible', ($value ? 1 : 0));
$xmlElement->setAttribute('visible', ($value ? 'true' : 'false'));
$xml->appendChild($xmlElement);
}
return $xml;

View File

@ -0,0 +1,174 @@
<?php
namespace ManiaControl\Manialinks;
use ManiaControl\ManiaControl;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Players\Player;
use ManiaControl\Players\PlayerManager;
use FML\ManiaLink;
use FML\Elements\CustomUI;
use FML\Controls\Quad;
use FML\ManiaLinks;
/**
* Class managing the Custom UI Settings
*
* @author steeffeen & kremsy
*/
class CustomUIManager implements CallbackListener {
/**
* Constants
*/
const CUSTOMUI_MLID = 'CustomUI.MLID';
/**
* Private Properties
*/
private $maniaControl = null;
private $manialinks = null;
private $customUI = null;
private $updateManialink = false;
/**
* Create a Custom UI Manager
*
* @param ManiaControl $maniaControl
*/
public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl;
$this->prepareManialink();
// Register for callbacks
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_SECOND, $this, 'handle1Second');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerJoined');
}
/**
* Create the ManiaLink and CustomUI instances
*/
private function prepareManialink() {
$this->customUI = new CustomUI();
}
/**
* Update the CustomUI Manialink
*
* @param Player $player
*/
private function updateManialink(Player $player = null) {
// TODO: improve rendering after FML update
$domDocument = new \DOMDocument();
$element = $this->customUI->render($domDocument);
$domDocument->appendChild($element);
$manialinkText = $domDocument->saveXML();
if ($player) {
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login);
return;
}
$this->maniaControl->manialinkManager->sendManialink($manialinkText);
}
/**
* Handle 1Second Callback
*
* @param array $callback
*/
public function handle1Second(array $callback) {
if (!$this->updateManialink) return;
$this->updateManialink = false;
$this->updateManialink();
}
/**
* Handle PlayerJoined Callback
*
* @param array $callback
*/
public function handlePlayerJoined(array $callback) {
$player = $callback[1];
$this->updateManialink($player);
}
/**
* Set Showing of Notices
*
* @param bool $visible
*/
public function setNoticeVisible($visible) {
$this->customUI->setNoticeVisible($visible);
$this->updateManialink = true;
}
/**
* Set Showing of the Challenge Info
*
* @param bool $visible
*/
public function setChallengeInfoVisible($visible) {
$this->customUI->setChallengeInfoVisible($visible);
$this->updateManialink = true;
}
/**
* Set Showing of the Net Infos
*
* @param bool $visible
*/
public function setNetInfosVisible($visible) {
$this->customUI->setNetInfosVisible($visible);
$this->updateManialink = true;
}
/**
* Set Showing of the Chat
*
* @param bool $visible
*/
public function setChatVisible($visible) {
$this->customUI->setChatVisible($visible);
$this->updateManialink = true;
}
/**
* Set Showing of the Checkpoint List
*
* @param bool $visible
*/
public function setCheckpointListVisible($visible) {
$this->customUI->setCheckpointListVisible($visible);
$this->updateManialink = true;
}
/**
* Set Showing of Round Scores
*
* @param bool $visible
*/
public function setRoundScoresVisible($visible) {
$this->customUI->setRoundScoresVisible($visible);
$this->updateManialink = true;
}
/**
* Set Showing of the Scoretable
*
* @param bool $visible
*/
public function setScoretableVisible($visible) {
$this->customUI->setScoretableVisible($visible);
$this->updateManialink = true;
}
/**
* Set Global Showing
*
* @param bool $visible
*/
public function setGlobalVisible($visible) {
$this->customUI->setGlobalVisible($visible);
$this->updateManialink = true;
}
}

View File

@ -2,17 +2,18 @@
namespace ManiaControl\Manialinks;
use FML\Controls\Control;
use FML\Controls\Frame;
use FML\Controls\Labels\Label_Text;
use FML\ManiaLink;
use ManiaControl\ManiaControl;
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
use ManiaControl\Players\Player;
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Players\Player;
use FML\ManiaLink;
use FML\Controls\Control;
use FML\Controls\Frame;
use FML\Controls\Labels\Label_Text;
require_once __DIR__ . '/StyleManager.php';
require_once __DIR__ . '/CustomUIManager.php';
require_once __DIR__ . '/../FML/autoload.php';
/**
@ -20,19 +21,21 @@ require_once __DIR__ . '/../FML/autoload.php';
*
* @author steeffeen & kremsy
*/
class ManialinkManager implements ManialinkPageAnswerListener,CallbackListener {
/*
class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener {
/**
* Constants
*/
const MAIN_MLID = 'Main.ManiaLinkId';
const ACTION_CLOSEWIDGET = 'ManiaLinkManager.CloseWidget';
const CB_MAIN_WINDOW_CLOSED = 'ManialinkManagerCallback.MainWindowClosed';
const CB_MAIN_WINDOW_CLOSED = 'ManialinkManagerCallback.MainWindowClosed';
/**
* Public properties
*/
public $styleManager = null;
public $customUIManager = null;
/**
* Private properties
*/
@ -48,10 +51,10 @@ class ManialinkManager implements ManialinkPageAnswerListener,CallbackListener {
public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl;
$this->styleManager = new StyleManager($maniaControl);
$this->customUIManager = new CustomUIManager($maniaControl);
// Register for callbacks
$this->registerManialinkPageAnswerListener(self::ACTION_CLOSEWIDGET , $this,
'closeWidgetCallback');
$this->registerManialinkPageAnswerListener(self::ACTION_CLOSEWIDGET, $this, 'closeWidgetCallback');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
'handleManialinkPageAnswer');
}
@ -80,7 +83,7 @@ class ManialinkManager implements ManialinkPageAnswerListener,CallbackListener {
/**
* Remove a Manialink Page Answer Listener
*
*
* @param ManialinkPageAnswerListener $listener
* @return bool
*/
@ -178,21 +181,22 @@ class ManialinkManager implements ManialinkPageAnswerListener,CallbackListener {
/**
* Displays a ManiaLink Widget to a certain Player
* @param String $maniaLink
* @param Player $player
*
* @param String $maniaLink
* @param Player $player
*/
public function displayWidget($maniaLink, Player $player) {
//render and display xml
// render and display xml
$maniaLinkText = $maniaLink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($maniaLinkText, $player->login);
$this->disableAltMenu($player);
}
/**
* Closes a widget via the callback
* @param array $callback
* @param Player $player
*
* @param array $callback
* @param Player $player
*/
public function closeWidgetCallback(array $callback, Player $player) {
$this->closeWidget($player);
@ -200,36 +204,38 @@ class ManialinkManager implements ManialinkPageAnswerListener,CallbackListener {
/**
* Closes the Manialink Widget and enables the Alt Menu
* @param Player $player
*
* @param Player $player
*/
public function closeWidget(Player $player) {
$emptyManialink = new ManiaLink(self::MAIN_MLID);
$manialinkText = $emptyManialink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $player->login);
$this->enableAltMenu($player);
// Trigger callback
$this->maniaControl->callbackManager->triggerCallback(self::CB_MAIN_WINDOW_CLOSED, array(self::CB_MAIN_WINDOW_CLOSED, $player));
}
/**
* Adds a line of labels
* @param Frame $frame
* @param array $labelStrings
* @param array $properties
*
* @param Frame $frame
* @param array $labelStrings
* @param array $properties
* @return array Returns the frames (to add special Properties later)
*/
public function labelLine(Frame $frame, array $labelStrings, array $properties = array()){
//TODO overwrite standard properties with properties from array
//define standard properties
public function labelLine(Frame $frame, array $labelStrings, array $properties = array()) {
// TODO overwrite standard properties with properties from array
// define standard properties
$hAlign = Control::LEFT;
$style = Label_Text::STYLE_TextCardSmall;
$textSize = 1.5;
$textColor = 'FFF';
$frames = array();
foreach($labelStrings as $text => $x){
foreach ($labelStrings as $text => $x) {
$label = new Label_Text();
$frame->add($label);
$label->setHAlign($hAlign);
@ -238,8 +244,8 @@ class ManialinkManager implements ManialinkPageAnswerListener,CallbackListener {
$label->setTextSize($textSize);
$label->setText($text);
$label->setTextColor($textColor);
$frames[] = $frame; //add Frame to the frames array
$frames[] = $frame; // add Frame to the frames array
}
return $frames;
}

View File

@ -1,5 +1,4 @@
<?php
use FML\Controls\Control;
use FML\Controls\Frame;
use FML\Controls\Labels\Label_Text;
@ -14,13 +13,13 @@ use ManiaControl\Players\PlayerManager;
use ManiaControl\Plugins\Plugin;
use ManiaControl\Callbacks\CallbackManager;
/**
* ManiaControl Widget Plugin
*
* @author kremsy
*/
class WidgetPlugin implements CallbackListener, Plugin {
/**
* Constants
*/
@ -28,130 +27,129 @@ class WidgetPlugin implements CallbackListener, Plugin {
const PLUGIN_VERSION = 0.1;
const PLUGIN_NAME = 'WidgetPlugin';
const PLUGIN_AUTHOR = 'kremsy';
//MapWidget Properties
// MapWidget Properties
const MLID_MAPWIDGET = 'WidgetPlugin.MapWidget';
const SETTING_MAP_WIDGET_ACTIVATED = 'Map-Widget Activated';
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';
//ClockWidget Properties
// ClockWidget Properties
const MLID_CLOCKWIDGET = 'WidgetPlugin.ClockWidget';
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';
//NextMapWidget Properties
// NextMapWidget Properties
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';
/**
* Private properties
* Private Properties
*/
private $maniaControl = null;
/**
/**
* Load the plugin
*
* @param \ManiaControl\ManiaControl $maniaControl
* @param ManiaControl $maniaControl
* @return bool
*/
public function load(ManiaControl $maniaControl){
public function load(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl;
// Set CustomUI Setting
$this->maniaControl->manialinkManager->customUIManager->setChallengeInfoVisible(false);
// Register for callbacks
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'handleOnBeginMap');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ENDMAP, $this, 'handleOnEndMap');
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERJOINED, $this, 'handlePlayerConnect');
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_1_MINUTE, $this, 'handleEveryMinute');
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED, true);
$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.);
$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.);
$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);
$this->maniaControl->settingManager->initSetting($this, self::SETTING_CLOCK_WIDGET_HEIGHT, 5.5);
return true;
}
/**
* Unload the plugin and its resources
*/
public function unload(){
public function unload() {
$this->maniaControl->callbackManager->unregisterCallbackListener($this);
unset($this->maniaControl);
}
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);
$height = $this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_HEIGHT);
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
$maniaLink = new ManiaLink(self::MLID_CLOCKWIDGET);
//mainframe
// mainframe
$frame = new Frame();
$maniaLink->add($frame);
$frame->setSize($width,$height);
$frame->setSize($width, $height);
$frame->setPosition($pos_x, $pos_y);
//Background Quad
// Background Quad
$backgroundQuad = new Quad();
$frame->add($backgroundQuad);
$backgroundQuad->setSize($width,$height);
$backgroundQuad->setSize($width, $height);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
$localTime = date("H:i", time());
$label = new Label_Text();
$frame->add($label);
$label->setY(1.5);
$label->setX(0);
$label->setAlign(Control::CENTER,Control::TOP);
$label->setAlign(Control::CENTER, Control::TOP);
$label->setZ(0.2);
$label->setTextSize(1);
$label->setText($localTime);
$label->setTextColor("FFF");
//Send manialink
// Send manialink
$manialinkText = $maniaLink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
}
/**
* Displays the Next Map (Only at the end of the Map)
* @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_y = $this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_POSY);
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_WIDTH);
@ -159,78 +157,78 @@ class WidgetPlugin implements CallbackListener, Plugin {
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
$labelStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultLabelStyle();
$maniaLink = new ManiaLink(self::MLID_NEXTMAPWIDGET);
//mainframe
// mainframe
$frame = new Frame();
$maniaLink->add($frame);
$frame->setSize($width,$height);
$frame->setSize($width, $height);
$frame->setPosition($pos_x, $pos_y);
//Background Quad
// Background Quad
$backgroundQuad = new Quad();
$frame->add($backgroundQuad);
$backgroundQuad->setSize($width,$height);
$backgroundQuad->setSize($width, $height);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
//Check if the Next Map is a juked Map
// Check if the Next Map is a juked Map
$jukedMap = $this->maniaControl->mapManager->jukebox->getNextMap();
$requester = null;
//if the nextmap is not a juked map, get it from map info
if($jukedMap == null){
// if the nextmap is not a juked map, get it from map info
if ($jukedMap == null) {
$this->maniaControl->client->query("GetNextMapInfo");
$map = $this->maniaControl->client->getResponse();
$name = $map['Name'];
$author = $map['Author'];
}else{
}
else {
$requester = $jukedMap[0];
$map = $jukedMap[1];
$name = $map->name;
$author = $map->authorLogin;
}
$label = new Label_Text();
$frame->add($label);
$label->setY($height / 2 - 2.3);
$label->setX(0);
$label->setAlign(Control::CENTER,Control::CENTER);
$label->setAlign(Control::CENTER, Control::CENTER);
$label->setZ(0.2);
$label->setTextSize(1);
$label->setText("Next Map");
$label->setTextColor("FFF");
$label->setStyle($labelStyle);
$label = new Label_Text();
$frame->add($label);
$label->setY($height / 2 - 5.5);
$label->setX(0);
$label->setAlign(Control::CENTER,Control::CENTER);
$label->setAlign(Control::CENTER, Control::CENTER);
$label->setZ(0.2);
$label->setTextSize(1.3);
$label->setText($name);
$label->setTextColor("FFF");
$label = new Label_Text();
$frame->add($label);
$label->setX(0);
$label->setY(-$height/2 + 4);
$label->setAlign(Control::CENTER,Control::CENTER);
$label->setY(-$height / 2 + 4);
$label->setAlign(Control::CENTER, Control::CENTER);
$label->setZ(0.2);
$label->setTextSize(1);
$label->setScale(0.8);
$label->setText($author);
$label->setTextColor("FFF");
if($requester != null){
if ($requester != null) {
$label = new Label_Text();
$frame->add($label);
$label->setX(0);
$label->setY(-$height/2 + 2);
$label->setAlign(Control::CENTER,Control::CENTER);
$label->setY(-$height / 2 + 2);
$label->setAlign(Control::CENTER, Control::CENTER);
$label->setZ(0.2);
$label->setTextSize(1);
$label->setScale(0.7);
@ -238,85 +236,76 @@ class WidgetPlugin implements CallbackListener, Plugin {
$label->setTextColor("F80");
$label->setText("Requested by " . $requester->nickname);
}
//Send manialink
// Send manialink
$manialinkText = $maniaLink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
}
/**
* Displays the Map Widget
* @param $login
*
* @param
* $login
*/
public function displayMapWidget($login = false){
$xml = "<manialinks><manialink id='0'><quad></quad></manialink>
<custom_ui>
<challenge_info visible='false'/>
</custom_ui>
</manialinks>";
$this->maniaControl->manialinkManager->sendManialink($xml);
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);
$height = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_HEIGHT);
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
$maniaLink = new ManiaLink(self::MLID_MAPWIDGET);
//mainframe
// mainframe
$frame = new Frame();
$maniaLink->add($frame);
$frame->setSize($width,$height);
$frame->setSize($width, $height);
$frame->setPosition($pos_x, $pos_y);
//Background Quad
// Background Quad
$backgroundQuad = new Quad();
$frame->add($backgroundQuad);
$backgroundQuad->setSize($width,$height);
$backgroundQuad->setSize($width, $height);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
$map = $this->maniaControl->mapManager->getCurrentMap();
$label = new Label_Text();
$frame->add($label);
$label->setY(1.5);
$label->setX(0);
$label->setAlign(Control::CENTER,Control::CENTER);
$label->setAlign(Control::CENTER, Control::CENTER);
$label->setZ(0.2);
$label->setTextSize(1.3);
$label->setText($map->name);
$label->setTextColor("FFF");
$label = new Label_Text();
$frame->add($label);
$label->setX(0);
$label->setY(-1.4);
$label->setAlign(Control::CENTER,Control::CENTER);
$label->setAlign(Control::CENTER, Control::CENTER);
$label->setZ(0.2);
$label->setTextSize(1);
$label->setScale(0.8);
$label->setText($map->authorLogin);
$label->setTextColor("FFF");
//Send manialink
// Send manialink
$manialinkText = $maniaLink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
}
/**
* Closes a Widget
* @param $widgetId
*
* @param
* $widgetId
*/
public function closeWidget($widgetId){
public function closeWidget($widgetId) {
$emptyManialink = new ManiaLink($widgetId);
$manialinkText = $emptyManialink->render()->saveXML();
$this->maniaControl->manialinkManager->sendManialink($manialinkText);
@ -325,27 +314,26 @@ class WidgetPlugin implements CallbackListener, Plugin {
/**
* Handle ManiaControl OnInit callback
*
* @param array $callback
* @param array $callback
*/
public function handleOnInit(array $callback) {
//Display Map Widget
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)){
// Display Map Widget
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
$this->displayMapWidget();
}
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)){
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
$this->displayClockWidget();
}
}
/**
* Handle on Begin Map
*
* @param array $callback
* @param array $callback
*/
public function handleOnBeginMap(array $callback) {
//Display Map Widget
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)){
// Display Map Widget
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
$this->displayMapWidget();
}
$this->closeWidget(self::MLID_NEXTMAPWIDGET);
@ -354,11 +342,11 @@ class WidgetPlugin implements CallbackListener, Plugin {
/**
* Handle on End Map
*
* @param array $callback
* @param array $callback
*/
public function handleOnEndMap(array $callback) {
//Display Map Widget
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED)){
// Display Map Widget
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED)) {
$this->displayNextMapWidget();
}
}
@ -366,26 +354,26 @@ class WidgetPlugin implements CallbackListener, Plugin {
/**
* Handle PlayerConnect callback
*
* @param array $callback
* @param array $callback
*/
public function handlePlayerConnect(array $callback) {
$player = $callback[1];
//Display Map Widget
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)){
// Display Map Widget
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
$this->displayMapWidget($player->login);
}
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)){
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
$this->displayClockWidget();
}
}
/**
* Aktualize the clock widget every minute
* @param array $callback
*
* @param 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();
}
}
@ -395,7 +383,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
*
* @return int
*/
public static function getId(){
public static function getId() {
return self::PLUGIN_ID;
}
@ -404,7 +392,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
*
* @return string
*/
public static function getName(){
public static function getName() {
return self::PLUGIN_NAME;
}
@ -413,7 +401,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
*
* @return float,,
*/
public static function getVersion(){
public static function getVersion() {
return self::PLUGIN_VERSION;
}
@ -422,7 +410,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
*
* @return string
*/
public static function getAuthor(){
public static function getAuthor() {
return self::PLUGIN_AUTHOR;
}
@ -431,7 +419,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
*
* @return string
*/
public static function getDescription(){
public static function getDescription() {
return null;
}
}