Custom UI Manager
This commit is contained in:
parent
9bb2495756
commit
2e8a18692c
@ -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;
|
||||
|
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;
|
||||
|
||||
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,9 +21,9 @@ 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';
|
||||
@ -33,6 +34,8 @@ class ManialinkManager implements ManialinkPageAnswerListener,CallbackListener {
|
||||
* 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');
|
||||
}
|
||||
@ -178,19 +181,20 @@ class ManialinkManager implements ManialinkPageAnswerListener,CallbackListener {
|
||||
|
||||
/**
|
||||
* Displays a ManiaLink Widget to a certain 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
|
||||
*/
|
||||
@ -200,6 +204,7 @@ class ManialinkManager implements ManialinkPageAnswerListener,CallbackListener {
|
||||
|
||||
/**
|
||||
* Closes the Manialink Widget and enables the Alt Menu
|
||||
*
|
||||
* @param Player $player
|
||||
*/
|
||||
public function closeWidget(Player $player) {
|
||||
@ -214,22 +219,23 @@ class ManialinkManager implements ManialinkPageAnswerListener,CallbackListener {
|
||||
|
||||
/**
|
||||
* Adds a line of labels
|
||||
*
|
||||
* @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
|
||||
public function labelLine(Frame $frame, array $labelStrings, array $properties = array()) {
|
||||
// TODO overwrite standard properties with properties from array
|
||||
|
||||
//define standard properties
|
||||
// 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);
|
||||
@ -239,7 +245,7 @@ class ManialinkManager implements ManialinkPageAnswerListener,CallbackListener {
|
||||
$label->setText($text);
|
||||
$label->setTextColor($textColor);
|
||||
|
||||
$frames[] = $frame; //add Frame to the frames array
|
||||
$frames[] = $frame; // add Frame to the frames array
|
||||
}
|
||||
return $frames;
|
||||
}
|
||||
|
@ -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
|
||||
*/
|
||||
@ -29,8 +28,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
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';
|
||||
@ -38,7 +36,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
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';
|
||||
@ -46,7 +44,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
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';
|
||||
@ -54,21 +52,23 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
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');
|
||||
@ -100,13 +100,12 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
/**
|
||||
* Unload the plugin and its resources
|
||||
*/
|
||||
public function unload(){
|
||||
public function unload() {
|
||||
$this->maniaControl->callbackManager->unregisterCallbackListener($this);
|
||||
unset($this->maniaControl);
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
@ -116,16 +115,16 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
|
||||
$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());
|
||||
@ -134,24 +133,23 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
$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
|
||||
*/
|
||||
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);
|
||||
@ -162,29 +160,30 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
|
||||
$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;
|
||||
@ -195,7 +194,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
$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");
|
||||
@ -206,7 +205,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
$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);
|
||||
@ -215,22 +214,21 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
$label = new Label_Text();
|
||||
$frame->add($label);
|
||||
$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->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);
|
||||
@ -239,28 +237,18 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
$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);
|
||||
@ -270,16 +258,16 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
|
||||
$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();
|
||||
@ -288,7 +276,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
$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);
|
||||
@ -299,24 +287,25 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
$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);
|
||||
@ -328,24 +317,23 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
* @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
|
||||
*/
|
||||
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);
|
||||
@ -357,8 +345,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
* @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();
|
||||
}
|
||||
}
|
||||
@ -370,22 +358,22 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user