Custom UI Manager
This commit is contained in:
parent
9bb2495756
commit
2e8a18692c
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace FML\Elements;
|
namespace FML\Elements;
|
||||||
|
|
||||||
|
use FML\Types\Renderable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing the Custom_UI
|
* Class representing the Custom_UI
|
||||||
*
|
*
|
||||||
@ -119,7 +121,7 @@ class CustomUI implements Renderable {
|
|||||||
foreach ($settings as $setting => $value) {
|
foreach ($settings as $setting => $value) {
|
||||||
if ($value === null) continue;
|
if ($value === null) continue;
|
||||||
$xmlElement = $domDocument->createElement($setting);
|
$xmlElement = $domDocument->createElement($setting);
|
||||||
$xmlElement->setAttribute('visible', ($value ? 1 : 0));
|
$xmlElement->setAttribute('visible', ($value ? 'true' : 'false'));
|
||||||
$xml->appendChild($xmlElement);
|
$xml->appendChild($xmlElement);
|
||||||
}
|
}
|
||||||
return $xml;
|
return $xml;
|
||||||
|
174
application/core/Manialinks/CustomUIManager.php
Normal file
174
application/core/Manialinks/CustomUIManager.php
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
@ -2,17 +2,18 @@
|
|||||||
|
|
||||||
namespace ManiaControl\Manialinks;
|
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\ManiaControl;
|
||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
use ManiaControl\Players\Player;
|
|
||||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
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__ . '/StyleManager.php';
|
||||||
|
require_once __DIR__ . '/CustomUIManager.php';
|
||||||
require_once __DIR__ . '/../FML/autoload.php';
|
require_once __DIR__ . '/../FML/autoload.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -20,19 +21,21 @@ require_once __DIR__ . '/../FML/autoload.php';
|
|||||||
*
|
*
|
||||||
* @author steeffeen & kremsy
|
* @author steeffeen & kremsy
|
||||||
*/
|
*/
|
||||||
class ManialinkManager implements ManialinkPageAnswerListener,CallbackListener {
|
class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener {
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const MAIN_MLID = 'Main.ManiaLinkId';
|
const MAIN_MLID = 'Main.ManiaLinkId';
|
||||||
const ACTION_CLOSEWIDGET = 'ManiaLinkManager.CloseWidget';
|
const ACTION_CLOSEWIDGET = 'ManiaLinkManager.CloseWidget';
|
||||||
const CB_MAIN_WINDOW_CLOSED = 'ManialinkManagerCallback.MainWindowClosed';
|
const CB_MAIN_WINDOW_CLOSED = 'ManialinkManagerCallback.MainWindowClosed';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public properties
|
* Public properties
|
||||||
*/
|
*/
|
||||||
public $styleManager = null;
|
public $styleManager = null;
|
||||||
|
public $customUIManager = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private properties
|
* Private properties
|
||||||
*/
|
*/
|
||||||
@ -48,10 +51,10 @@ class ManialinkManager implements ManialinkPageAnswerListener,CallbackListener {
|
|||||||
public function __construct(ManiaControl $maniaControl) {
|
public function __construct(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
$this->styleManager = new StyleManager($maniaControl);
|
$this->styleManager = new StyleManager($maniaControl);
|
||||||
|
$this->customUIManager = new CustomUIManager($maniaControl);
|
||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->registerManialinkPageAnswerListener(self::ACTION_CLOSEWIDGET , $this,
|
$this->registerManialinkPageAnswerListener(self::ACTION_CLOSEWIDGET, $this, 'closeWidgetCallback');
|
||||||
'closeWidgetCallback');
|
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
|
||||||
'handleManialinkPageAnswer');
|
'handleManialinkPageAnswer');
|
||||||
}
|
}
|
||||||
@ -178,20 +181,21 @@ class ManialinkManager implements ManialinkPageAnswerListener,CallbackListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a ManiaLink Widget to a certain Player
|
* Displays a ManiaLink Widget to a certain Player
|
||||||
|
*
|
||||||
* @param String $maniaLink
|
* @param String $maniaLink
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function displayWidget($maniaLink, Player $player) {
|
public function displayWidget($maniaLink, Player $player) {
|
||||||
//render and display xml
|
// render and display xml
|
||||||
$maniaLinkText = $maniaLink->render()->saveXML();
|
$maniaLinkText = $maniaLink->render()->saveXML();
|
||||||
$this->maniaControl->manialinkManager->sendManialink($maniaLinkText, $player->login);
|
$this->maniaControl->manialinkManager->sendManialink($maniaLinkText, $player->login);
|
||||||
$this->disableAltMenu($player);
|
$this->disableAltMenu($player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes a widget via the callback
|
* Closes a widget via the callback
|
||||||
* @param array $callback
|
*
|
||||||
|
* @param array $callback
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function closeWidgetCallback(array $callback, Player $player) {
|
public function closeWidgetCallback(array $callback, Player $player) {
|
||||||
@ -200,6 +204,7 @@ class ManialinkManager implements ManialinkPageAnswerListener,CallbackListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the Manialink Widget and enables the Alt Menu
|
* Closes the Manialink Widget and enables the Alt Menu
|
||||||
|
*
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function closeWidget(Player $player) {
|
public function closeWidget(Player $player) {
|
||||||
@ -214,22 +219,23 @@ class ManialinkManager implements ManialinkPageAnswerListener,CallbackListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a line of labels
|
* Adds a line of labels
|
||||||
|
*
|
||||||
* @param Frame $frame
|
* @param Frame $frame
|
||||||
* @param array $labelStrings
|
* @param array $labelStrings
|
||||||
* @param array $properties
|
* @param array $properties
|
||||||
* @return array Returns the frames (to add special Properties later)
|
* @return array Returns the frames (to add special Properties later)
|
||||||
*/
|
*/
|
||||||
public function labelLine(Frame $frame, array $labelStrings, array $properties = array()){
|
public function labelLine(Frame $frame, array $labelStrings, array $properties = array()) {
|
||||||
//TODO overwrite standard properties with properties from array
|
// TODO overwrite standard properties with properties from array
|
||||||
|
|
||||||
//define standard properties
|
// define standard properties
|
||||||
$hAlign = Control::LEFT;
|
$hAlign = Control::LEFT;
|
||||||
$style = Label_Text::STYLE_TextCardSmall;
|
$style = Label_Text::STYLE_TextCardSmall;
|
||||||
$textSize = 1.5;
|
$textSize = 1.5;
|
||||||
$textColor = 'FFF';
|
$textColor = 'FFF';
|
||||||
|
|
||||||
$frames = array();
|
$frames = array();
|
||||||
foreach($labelStrings as $text => $x){
|
foreach ($labelStrings as $text => $x) {
|
||||||
$label = new Label_Text();
|
$label = new Label_Text();
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setHAlign($hAlign);
|
$label->setHAlign($hAlign);
|
||||||
@ -239,7 +245,7 @@ class ManialinkManager implements ManialinkPageAnswerListener,CallbackListener {
|
|||||||
$label->setText($text);
|
$label->setText($text);
|
||||||
$label->setTextColor($textColor);
|
$label->setTextColor($textColor);
|
||||||
|
|
||||||
$frames[] = $frame; //add Frame to the frames array
|
$frames[] = $frame; // add Frame to the frames array
|
||||||
}
|
}
|
||||||
return $frames;
|
return $frames;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use FML\Controls\Control;
|
use FML\Controls\Control;
|
||||||
use FML\Controls\Frame;
|
use FML\Controls\Frame;
|
||||||
use FML\Controls\Labels\Label_Text;
|
use FML\Controls\Labels\Label_Text;
|
||||||
@ -14,13 +13,13 @@ use ManiaControl\Players\PlayerManager;
|
|||||||
use ManiaControl\Plugins\Plugin;
|
use ManiaControl\Plugins\Plugin;
|
||||||
use ManiaControl\Callbacks\CallbackManager;
|
use ManiaControl\Callbacks\CallbackManager;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ManiaControl Widget Plugin
|
* ManiaControl Widget Plugin
|
||||||
*
|
*
|
||||||
* @author kremsy
|
* @author kremsy
|
||||||
*/
|
*/
|
||||||
class WidgetPlugin implements CallbackListener, Plugin {
|
class WidgetPlugin implements CallbackListener, Plugin {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
@ -29,8 +28,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
const PLUGIN_NAME = 'WidgetPlugin';
|
const PLUGIN_NAME = 'WidgetPlugin';
|
||||||
const PLUGIN_AUTHOR = 'kremsy';
|
const PLUGIN_AUTHOR = 'kremsy';
|
||||||
|
|
||||||
|
// MapWidget Properties
|
||||||
//MapWidget Properties
|
|
||||||
const MLID_MAPWIDGET = 'WidgetPlugin.MapWidget';
|
const MLID_MAPWIDGET = 'WidgetPlugin.MapWidget';
|
||||||
const SETTING_MAP_WIDGET_ACTIVATED = 'Map-Widget Activated';
|
const SETTING_MAP_WIDGET_ACTIVATED = 'Map-Widget Activated';
|
||||||
const SETTING_MAP_WIDGET_POSX = 'Map-Widget-Position: X';
|
const SETTING_MAP_WIDGET_POSX = 'Map-Widget-Position: X';
|
||||||
@ -38,7 +36,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
const SETTING_MAP_WIDGET_WIDTH = 'Map-Widget-Size: Width';
|
const SETTING_MAP_WIDGET_WIDTH = 'Map-Widget-Size: Width';
|
||||||
const SETTING_MAP_WIDGET_HEIGHT = 'Map-Widget-Size: Height';
|
const SETTING_MAP_WIDGET_HEIGHT = 'Map-Widget-Size: Height';
|
||||||
|
|
||||||
//ClockWidget Properties
|
// ClockWidget Properties
|
||||||
const MLID_CLOCKWIDGET = 'WidgetPlugin.ClockWidget';
|
const MLID_CLOCKWIDGET = 'WidgetPlugin.ClockWidget';
|
||||||
const SETTING_CLOCK_WIDGET_ACTIVATED = 'Clock-Widget Activated';
|
const SETTING_CLOCK_WIDGET_ACTIVATED = 'Clock-Widget Activated';
|
||||||
const SETTING_CLOCK_WIDGET_POSX = 'Clock-Widget-Position: X';
|
const SETTING_CLOCK_WIDGET_POSX = 'Clock-Widget-Position: X';
|
||||||
@ -46,7 +44,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
const SETTING_CLOCK_WIDGET_WIDTH = 'Clock-Widget-Size: Width';
|
const SETTING_CLOCK_WIDGET_WIDTH = 'Clock-Widget-Size: Width';
|
||||||
const SETTING_CLOCK_WIDGET_HEIGHT = 'Clock-Widget-Size: Height';
|
const SETTING_CLOCK_WIDGET_HEIGHT = 'Clock-Widget-Size: Height';
|
||||||
|
|
||||||
//NextMapWidget Properties
|
// NextMapWidget Properties
|
||||||
const MLID_NEXTMAPWIDGET = 'WidgetPlugin.NextMapWidget';
|
const MLID_NEXTMAPWIDGET = 'WidgetPlugin.NextMapWidget';
|
||||||
const SETTING_NEXTMAP_WIDGET_ACTIVATED = 'Nextmap-Widget Activated';
|
const SETTING_NEXTMAP_WIDGET_ACTIVATED = 'Nextmap-Widget Activated';
|
||||||
const SETTING_NEXTMAP_WIDGET_POSX = 'Nextmap-Widget-Position: X';
|
const SETTING_NEXTMAP_WIDGET_POSX = 'Nextmap-Widget-Position: X';
|
||||||
@ -54,21 +52,23 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
const SETTING_NEXTMAP_WIDGET_WIDTH = 'Nextmap-Widget-Size: Width';
|
const SETTING_NEXTMAP_WIDGET_WIDTH = 'Nextmap-Widget-Size: Width';
|
||||||
const SETTING_NEXTMAP_WIDGET_HEIGHT = 'Nextmap-Widget-Size: Height';
|
const SETTING_NEXTMAP_WIDGET_HEIGHT = 'Nextmap-Widget-Size: Height';
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the plugin
|
* Load the plugin
|
||||||
*
|
*
|
||||||
* @param \ManiaControl\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
|
||||||
|
$this->maniaControl->manialinkManager->customUIManager->setChallengeInfoVisible(false);
|
||||||
|
|
||||||
// Register for callbacks
|
// Register for callbacks
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_ONINIT, $this, 'handleOnInit');
|
$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_BEGINMAP, $this, 'handleOnBeginMap');
|
||||||
@ -100,13 +100,12 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
@ -116,16 +115,16 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
|
|
||||||
$maniaLink = new ManiaLink(self::MLID_CLOCKWIDGET);
|
$maniaLink = new ManiaLink(self::MLID_CLOCKWIDGET);
|
||||||
|
|
||||||
//mainframe
|
// mainframe
|
||||||
$frame = new Frame();
|
$frame = new Frame();
|
||||||
$maniaLink->add($frame);
|
$maniaLink->add($frame);
|
||||||
$frame->setSize($width,$height);
|
$frame->setSize($width, $height);
|
||||||
$frame->setPosition($pos_x, $pos_y);
|
$frame->setPosition($pos_x, $pos_y);
|
||||||
|
|
||||||
//Background Quad
|
// Background Quad
|
||||||
$backgroundQuad = new Quad();
|
$backgroundQuad = new Quad();
|
||||||
$frame->add($backgroundQuad);
|
$frame->add($backgroundQuad);
|
||||||
$backgroundQuad->setSize($width,$height);
|
$backgroundQuad->setSize($width, $height);
|
||||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||||
|
|
||||||
$localTime = date("H:i", time());
|
$localTime = date("H:i", time());
|
||||||
@ -134,24 +133,23 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setY(1.5);
|
$label->setY(1.5);
|
||||||
$label->setX(0);
|
$label->setX(0);
|
||||||
$label->setAlign(Control::CENTER,Control::TOP);
|
$label->setAlign(Control::CENTER, Control::TOP);
|
||||||
$label->setZ(0.2);
|
$label->setZ(0.2);
|
||||||
$label->setTextSize(1);
|
$label->setTextSize(1);
|
||||||
$label->setText($localTime);
|
$label->setText($localTime);
|
||||||
$label->setTextColor("FFF");
|
$label->setTextColor("FFF");
|
||||||
|
|
||||||
//Send manialink
|
// Send manialink
|
||||||
$manialinkText = $maniaLink->render()->saveXML();
|
$manialinkText = $maniaLink->render()->saveXML();
|
||||||
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
|
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the Next Map (Only at the end of the Map)
|
* 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_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);
|
||||||
@ -162,29 +160,30 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
|
|
||||||
$maniaLink = new ManiaLink(self::MLID_NEXTMAPWIDGET);
|
$maniaLink = new ManiaLink(self::MLID_NEXTMAPWIDGET);
|
||||||
|
|
||||||
//mainframe
|
// mainframe
|
||||||
$frame = new Frame();
|
$frame = new Frame();
|
||||||
$maniaLink->add($frame);
|
$maniaLink->add($frame);
|
||||||
$frame->setSize($width,$height);
|
$frame->setSize($width, $height);
|
||||||
$frame->setPosition($pos_x, $pos_y);
|
$frame->setPosition($pos_x, $pos_y);
|
||||||
|
|
||||||
//Background Quad
|
// Background Quad
|
||||||
$backgroundQuad = new Quad();
|
$backgroundQuad = new Quad();
|
||||||
$frame->add($backgroundQuad);
|
$frame->add($backgroundQuad);
|
||||||
$backgroundQuad->setSize($width,$height);
|
$backgroundQuad->setSize($width, $height);
|
||||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
$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();
|
$jukedMap = $this->maniaControl->mapManager->jukebox->getNextMap();
|
||||||
|
|
||||||
$requester = null;
|
$requester = null;
|
||||||
//if the nextmap is not a juked map, get it from map info
|
// if the nextmap is not a juked map, get it from map info
|
||||||
if($jukedMap == null){
|
if ($jukedMap == null) {
|
||||||
$this->maniaControl->client->query("GetNextMapInfo");
|
$this->maniaControl->client->query("GetNextMapInfo");
|
||||||
$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 = $jukedMap[0];
|
$requester = $jukedMap[0];
|
||||||
$map = $jukedMap[1];
|
$map = $jukedMap[1];
|
||||||
$name = $map->name;
|
$name = $map->name;
|
||||||
@ -195,7 +194,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setY($height / 2 - 2.3);
|
$label->setY($height / 2 - 2.3);
|
||||||
$label->setX(0);
|
$label->setX(0);
|
||||||
$label->setAlign(Control::CENTER,Control::CENTER);
|
$label->setAlign(Control::CENTER, Control::CENTER);
|
||||||
$label->setZ(0.2);
|
$label->setZ(0.2);
|
||||||
$label->setTextSize(1);
|
$label->setTextSize(1);
|
||||||
$label->setText("Next Map");
|
$label->setText("Next Map");
|
||||||
@ -206,7 +205,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setY($height / 2 - 5.5);
|
$label->setY($height / 2 - 5.5);
|
||||||
$label->setX(0);
|
$label->setX(0);
|
||||||
$label->setAlign(Control::CENTER,Control::CENTER);
|
$label->setAlign(Control::CENTER, Control::CENTER);
|
||||||
$label->setZ(0.2);
|
$label->setZ(0.2);
|
||||||
$label->setTextSize(1.3);
|
$label->setTextSize(1.3);
|
||||||
$label->setText($name);
|
$label->setText($name);
|
||||||
@ -215,22 +214,21 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
$label = new Label_Text();
|
$label = new Label_Text();
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setX(0);
|
$label->setX(0);
|
||||||
$label->setY(-$height/2 + 4);
|
$label->setY(-$height / 2 + 4);
|
||||||
|
|
||||||
$label->setAlign(Control::CENTER,Control::CENTER);
|
$label->setAlign(Control::CENTER, Control::CENTER);
|
||||||
$label->setZ(0.2);
|
$label->setZ(0.2);
|
||||||
$label->setTextSize(1);
|
$label->setTextSize(1);
|
||||||
$label->setScale(0.8);
|
$label->setScale(0.8);
|
||||||
$label->setText($author);
|
$label->setText($author);
|
||||||
$label->setTextColor("FFF");
|
$label->setTextColor("FFF");
|
||||||
|
|
||||||
|
if ($requester != null) {
|
||||||
if($requester != null){
|
|
||||||
$label = new Label_Text();
|
$label = new Label_Text();
|
||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setX(0);
|
$label->setX(0);
|
||||||
$label->setY(-$height/2 + 2);
|
$label->setY(-$height / 2 + 2);
|
||||||
$label->setAlign(Control::CENTER,Control::CENTER);
|
$label->setAlign(Control::CENTER, Control::CENTER);
|
||||||
$label->setZ(0.2);
|
$label->setZ(0.2);
|
||||||
$label->setTextSize(1);
|
$label->setTextSize(1);
|
||||||
$label->setScale(0.7);
|
$label->setScale(0.7);
|
||||||
@ -239,28 +237,18 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
$label->setText("Requested by " . $requester->nickname);
|
$label->setText("Requested by " . $requester->nickname);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Send manialink
|
// Send manialink
|
||||||
$manialinkText = $maniaLink->render()->saveXML();
|
$manialinkText = $maniaLink->render()->saveXML();
|
||||||
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
|
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the Map Widget
|
* Displays the Map Widget
|
||||||
* @param $login
|
*
|
||||||
|
* @param
|
||||||
|
* $login
|
||||||
*/
|
*/
|
||||||
public function displayMapWidget($login = false){
|
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);
|
|
||||||
|
|
||||||
|
|
||||||
$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);
|
||||||
@ -270,16 +258,16 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
|
|
||||||
$maniaLink = new ManiaLink(self::MLID_MAPWIDGET);
|
$maniaLink = new ManiaLink(self::MLID_MAPWIDGET);
|
||||||
|
|
||||||
//mainframe
|
// mainframe
|
||||||
$frame = new Frame();
|
$frame = new Frame();
|
||||||
$maniaLink->add($frame);
|
$maniaLink->add($frame);
|
||||||
$frame->setSize($width,$height);
|
$frame->setSize($width, $height);
|
||||||
$frame->setPosition($pos_x, $pos_y);
|
$frame->setPosition($pos_x, $pos_y);
|
||||||
|
|
||||||
//Background Quad
|
// Background Quad
|
||||||
$backgroundQuad = new Quad();
|
$backgroundQuad = new Quad();
|
||||||
$frame->add($backgroundQuad);
|
$frame->add($backgroundQuad);
|
||||||
$backgroundQuad->setSize($width,$height);
|
$backgroundQuad->setSize($width, $height);
|
||||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||||
|
|
||||||
$map = $this->maniaControl->mapManager->getCurrentMap();
|
$map = $this->maniaControl->mapManager->getCurrentMap();
|
||||||
@ -288,7 +276,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
$frame->add($label);
|
$frame->add($label);
|
||||||
$label->setY(1.5);
|
$label->setY(1.5);
|
||||||
$label->setX(0);
|
$label->setX(0);
|
||||||
$label->setAlign(Control::CENTER,Control::CENTER);
|
$label->setAlign(Control::CENTER, Control::CENTER);
|
||||||
$label->setZ(0.2);
|
$label->setZ(0.2);
|
||||||
$label->setTextSize(1.3);
|
$label->setTextSize(1.3);
|
||||||
$label->setText($map->name);
|
$label->setText($map->name);
|
||||||
@ -299,24 +287,25 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
$label->setX(0);
|
$label->setX(0);
|
||||||
$label->setY(-1.4);
|
$label->setY(-1.4);
|
||||||
|
|
||||||
$label->setAlign(Control::CENTER,Control::CENTER);
|
$label->setAlign(Control::CENTER, Control::CENTER);
|
||||||
$label->setZ(0.2);
|
$label->setZ(0.2);
|
||||||
$label->setTextSize(1);
|
$label->setTextSize(1);
|
||||||
$label->setScale(0.8);
|
$label->setScale(0.8);
|
||||||
$label->setText($map->authorLogin);
|
$label->setText($map->authorLogin);
|
||||||
$label->setTextColor("FFF");
|
$label->setTextColor("FFF");
|
||||||
|
|
||||||
|
// Send manialink
|
||||||
//Send manialink
|
|
||||||
$manialinkText = $maniaLink->render()->saveXML();
|
$manialinkText = $maniaLink->render()->saveXML();
|
||||||
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
|
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes a Widget
|
* Closes a Widget
|
||||||
* @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);
|
||||||
@ -328,24 +317,23 @@ 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();
|
||||||
}
|
}
|
||||||
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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle on Begin Map
|
* Handle on Begin Map
|
||||||
*
|
*
|
||||||
* @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();
|
||||||
}
|
}
|
||||||
$this->closeWidget(self::MLID_NEXTMAPWIDGET);
|
$this->closeWidget(self::MLID_NEXTMAPWIDGET);
|
||||||
@ -357,8 +345,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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -370,22 +358,22 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
*/
|
*/
|
||||||
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)) {
|
||||||
$this->displayMapWidget($player->login);
|
$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();
|
$this->displayClockWidget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Aktualize the clock widget every minute
|
* Aktualize the clock widget every minute
|
||||||
|
*
|
||||||
* @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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -395,7 +383,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,7 +392,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,7 +401,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -422,7 +410,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,7 +419,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function getDescription(){
|
public static function getDescription() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user