test
This commit is contained in:
parent
6349c3447f
commit
0be745e042
@ -19,8 +19,7 @@ use ManiaControl\Plugins\Plugin;
|
|||||||
*
|
*
|
||||||
* @author kremsy
|
* @author kremsy
|
||||||
*/
|
*/
|
||||||
class WidgetPlugin implements CallbackListener, Plugin
|
class WidgetPlugin implements CallbackListener, Plugin {
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
@ -70,14 +69,58 @@ class WidgetPlugin implements CallbackListener, Plugin
|
|||||||
*/
|
*/
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get plugin id
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public static function getId() {
|
||||||
|
return self::PLUGIN_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Plugin Name
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getName() {
|
||||||
|
return self::PLUGIN_NAME;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Plugin Version
|
||||||
|
*
|
||||||
|
* @return float,,
|
||||||
|
*/
|
||||||
|
public static function getVersion() {
|
||||||
|
return self::PLUGIN_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Plugin Author
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getAuthor() {
|
||||||
|
return self::PLUGIN_AUTHOR;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Plugin Description
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function getDescription() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the plugin
|
* Load the plugin
|
||||||
*
|
*
|
||||||
* @param ManiaControl $maniaControl
|
* @param ManiaControl $maniaControl
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function load(ManiaControl $maniaControl)
|
public function load(ManiaControl $maniaControl) {
|
||||||
{
|
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
// Set CustomUI Setting
|
// Set CustomUI Setting
|
||||||
@ -120,19 +163,105 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle ManiaControl OnInit callback
|
||||||
|
*
|
||||||
|
* @param array $callback
|
||||||
|
*/
|
||||||
|
public function handleOnInit(array $callback) {
|
||||||
|
// 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)) {
|
||||||
|
$this->displayClockWidget();
|
||||||
|
}
|
||||||
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
|
||||||
|
$this->displayServerInfoWidget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays the Map Widget
|
||||||
|
*
|
||||||
|
* @param String $login
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
$script = new Script();
|
||||||
|
$maniaLink->setScript($script);
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
$script->addMapInfoButton($backgroundQuad);
|
||||||
|
|
||||||
|
$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->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->setZ(0.2);
|
||||||
|
$label->setTextSize(1);
|
||||||
|
$label->setScale(0.8);
|
||||||
|
$label->setText($map->authorLogin);
|
||||||
|
$label->setTextColor("FFF");
|
||||||
|
|
||||||
|
if(isset($map->mx->pageurl)) {
|
||||||
|
$quad = new Quad();
|
||||||
|
$frame->add($quad);
|
||||||
|
$quad->setImage("http://wiki.maniaplanet.com/pool/images/b/bf/ManiaExchange_logo.png"); // TODO include image into
|
||||||
|
// maniacontrol
|
||||||
|
$quad->setPosition(-$width / 2 + 4, -1.5, -0.5);
|
||||||
|
$quad->setSize(4, 4);
|
||||||
|
$quad->setHAlign(Control::CENTER);
|
||||||
|
$quad->setUrl($map->mx->pageurl);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send manialink
|
||||||
|
$manialinkText = $maniaLink->render()->saveXML();
|
||||||
|
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the Clock Widget
|
* Displays the Clock Widget
|
||||||
*
|
*
|
||||||
* @param bool $login
|
* @param bool $login
|
||||||
*/
|
*/
|
||||||
public function displayClockWidget($login = false)
|
public function displayClockWidget($login = false) {
|
||||||
{
|
|
||||||
$pos_x = $this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_POSX);
|
$pos_x = $this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_POSX);
|
||||||
$pos_y = $this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_POSY);
|
$pos_y = $this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_POSY);
|
||||||
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_WIDTH);
|
$width = $this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_WIDTH);
|
||||||
@ -171,13 +300,156 @@ class WidgetPlugin implements CallbackListener, Plugin
|
|||||||
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
|
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Displays the Server Info 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);
|
||||||
|
|
||||||
|
$this->maniaControl->client->query('GetMaxPlayers');
|
||||||
|
$maxPlayers = $this->maniaControl->client->getResponse();
|
||||||
|
|
||||||
|
$this->maniaControl->client->query('GetMaxSpectators');
|
||||||
|
$maxSpectators = $this->maniaControl->client->getResponse();
|
||||||
|
|
||||||
|
$serverName = $this->maniaControl->server->getName();
|
||||||
|
|
||||||
|
$players = $this->maniaControl->playerManager->getPlayers();
|
||||||
|
$playerCount = 0;
|
||||||
|
$spectatorCount = 0;
|
||||||
|
/**
|
||||||
|
* @var Player $player
|
||||||
|
*/
|
||||||
|
foreach ($players as $player) {
|
||||||
|
if($player->isSpectator) {
|
||||||
|
$spectatorCount++;
|
||||||
|
} else {
|
||||||
|
$playerCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$label = new Label_Text();
|
||||||
|
$frame->add($label);
|
||||||
|
$label->setPosition(0, 1.5, 0.2);
|
||||||
|
$label->setAlign(Control::CENTER, Control::CENTER);
|
||||||
|
$label->setTextSize(1.3);
|
||||||
|
$label->setText($serverName);
|
||||||
|
$label->setTextColor("FFF");
|
||||||
|
|
||||||
|
// Player Quad / Label
|
||||||
|
$label = new Label_Text();
|
||||||
|
$frame->add($label);
|
||||||
|
$label->setPosition(-$width / 2 + 9, -1.5, 0.2);
|
||||||
|
$label->setAlign(Control::LEFT, Control::CENTER);
|
||||||
|
$label->setTextSize(1);
|
||||||
|
$label->setScale(0.8);
|
||||||
|
$label->setText($playerCount . " / " . $maxPlayers['NextValue']);
|
||||||
|
$label->setTextColor("FFF");
|
||||||
|
|
||||||
|
$quad = new Quad_Icons128x128_1();
|
||||||
|
$frame->add($quad);
|
||||||
|
$quad->setSubStyle($quad::SUBSTYLE_Multiplayer);
|
||||||
|
$quad->setPosition(-$width / 2 + 7, -1.6, 0.2);
|
||||||
|
$quad->setSize(2.5, 2.5);
|
||||||
|
$quad->setHAlign(Control::CENTER);
|
||||||
|
|
||||||
|
// Spectator Quad / Label
|
||||||
|
$label = new Label_Text();
|
||||||
|
$frame->add($label);
|
||||||
|
$label->setPosition(2, -1.5, 0.2);
|
||||||
|
$label->setAlign(Control::LEFT, Control::CENTER);
|
||||||
|
$label->setTextSize(1);
|
||||||
|
$label->setScale(0.8);
|
||||||
|
$label->setText($spectatorCount . " / " . $maxSpectators['NextValue']);
|
||||||
|
$label->setTextColor("FFF");
|
||||||
|
|
||||||
|
$quad = new Quad_Icons64x64_1();
|
||||||
|
$frame->add($quad);
|
||||||
|
$quad->setSubStyle($quad::SUBSTYLE_Camera);
|
||||||
|
$quad->setPosition(0, -1.6, 0.2);
|
||||||
|
$quad->setSize(3.3, 2.5);
|
||||||
|
$quad->setHAlign(Control::CENTER);
|
||||||
|
|
||||||
|
// Favorite quad
|
||||||
|
$quad = new Quad_Icons64x64_1();
|
||||||
|
$quad = new Quad_Icons128x128_1();
|
||||||
|
$frame->add($quad);
|
||||||
|
// $quad->setSubStyle($quad::SUBSTYLE_StateFavourite);
|
||||||
|
$quad->setSubStyle($quad::SUBSTYLE_ServersFavorites);
|
||||||
|
$quad->setPosition($width / 2 - 4, -1.5, -0.5);
|
||||||
|
$quad->setSize(4, 4);
|
||||||
|
$quad->setHAlign(Control::CENTER);
|
||||||
|
// $TODO add server to favorite
|
||||||
|
|
||||||
|
// Send manialink
|
||||||
|
$manialinkText = $maniaLink->render()->saveXML();
|
||||||
|
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)) {
|
||||||
|
$this->displayMapWidget();
|
||||||
|
}
|
||||||
|
$this->closeWidget(self::MLID_NEXTMAPWIDGET);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes a Widget
|
||||||
|
*
|
||||||
|
* @param $widgetId
|
||||||
|
*/
|
||||||
|
public function closeWidget($widgetId) {
|
||||||
|
$emptyManialink = new ManiaLink($widgetId);
|
||||||
|
$manialinkText = $emptyManialink->render()->saveXML();
|
||||||
|
$this->maniaControl->manialinkManager->sendManialink($manialinkText);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle on End Map
|
||||||
|
*
|
||||||
|
* @param array $callback
|
||||||
|
*/
|
||||||
|
public function handleOnEndMap(array $callback) {
|
||||||
|
// Display Map Widget
|
||||||
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED)) {
|
||||||
|
$this->displayNextMapWidget();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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);
|
||||||
@ -272,250 +544,12 @@ class WidgetPlugin implements CallbackListener, Plugin
|
|||||||
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
|
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays the Server Info 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);
|
|
||||||
|
|
||||||
$this->maniaControl->client->query('GetMaxPlayers');
|
|
||||||
$maxPlayers = $this->maniaControl->client->getResponse();
|
|
||||||
|
|
||||||
$this->maniaControl->client->query('GetMaxSpectators');
|
|
||||||
$maxSpectators = $this->maniaControl->client->getResponse();
|
|
||||||
|
|
||||||
$serverName = $this->maniaControl->server->getName();
|
|
||||||
|
|
||||||
$players = $this->maniaControl->playerManager->getPlayers();
|
|
||||||
$playerCount = 0;
|
|
||||||
$spectatorCount = 0;
|
|
||||||
/**
|
|
||||||
* @var Player $player
|
|
||||||
*/
|
|
||||||
foreach ($players as $player) {
|
|
||||||
if ($player->isSpectator)
|
|
||||||
$spectatorCount++;
|
|
||||||
else
|
|
||||||
$playerCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$label = new Label_Text();
|
|
||||||
$frame->add($label);
|
|
||||||
$label->setPosition(0, 1.5, 0.2);
|
|
||||||
$label->setAlign(Control::CENTER, Control::CENTER);
|
|
||||||
$label->setTextSize(1.3);
|
|
||||||
$label->setText($serverName);
|
|
||||||
$label->setTextColor("FFF");
|
|
||||||
|
|
||||||
// Player Quad / Label
|
|
||||||
$label = new Label_Text();
|
|
||||||
$frame->add($label);
|
|
||||||
$label->setPosition(-$width / 2 + 9, -1.5, 0.2);
|
|
||||||
$label->setAlign(Control::LEFT, Control::CENTER);
|
|
||||||
$label->setTextSize(1);
|
|
||||||
$label->setScale(0.8);
|
|
||||||
$label->setText($playerCount . " / " . $maxPlayers['NextValue']);
|
|
||||||
$label->setTextColor("FFF");
|
|
||||||
|
|
||||||
$quad = new Quad_Icons128x128_1();
|
|
||||||
$frame->add($quad);
|
|
||||||
$quad->setSubStyle($quad::SUBSTYLE_Multiplayer);
|
|
||||||
$quad->setPosition(-$width / 2 + 7, -1.6, 0.2);
|
|
||||||
$quad->setSize(2.5, 2.5);
|
|
||||||
$quad->setHAlign(Control::CENTER);
|
|
||||||
|
|
||||||
// Spectator Quad / Label
|
|
||||||
$label = new Label_Text();
|
|
||||||
$frame->add($label);
|
|
||||||
$label->setPosition(2, -1.5, 0.2);
|
|
||||||
$label->setAlign(Control::LEFT, Control::CENTER);
|
|
||||||
$label->setTextSize(1);
|
|
||||||
$label->setScale(0.8);
|
|
||||||
$label->setText($spectatorCount . " / " . $maxSpectators['NextValue']);
|
|
||||||
$label->setTextColor("FFF");
|
|
||||||
|
|
||||||
$quad = new Quad_Icons64x64_1();
|
|
||||||
$frame->add($quad);
|
|
||||||
$quad->setSubStyle($quad::SUBSTYLE_Camera);
|
|
||||||
$quad->setPosition(0, -1.6, 0.2);
|
|
||||||
$quad->setSize(3.3, 2.5);
|
|
||||||
$quad->setHAlign(Control::CENTER);
|
|
||||||
|
|
||||||
// Favorite quad
|
|
||||||
$quad = new Quad_Icons64x64_1();
|
|
||||||
$quad = new Quad_Icons128x128_1();
|
|
||||||
$frame->add($quad);
|
|
||||||
// $quad->setSubStyle($quad::SUBSTYLE_StateFavourite);
|
|
||||||
$quad->setSubStyle($quad::SUBSTYLE_ServersFavorites);
|
|
||||||
$quad->setPosition($width / 2 - 4, -1.5, -0.5);
|
|
||||||
$quad->setSize(4, 4);
|
|
||||||
$quad->setHAlign(Control::CENTER);
|
|
||||||
// $TODO add server to favorite
|
|
||||||
|
|
||||||
// Send manialink
|
|
||||||
$manialinkText = $maniaLink->render()->saveXML();
|
|
||||||
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Displays the Map Widget
|
|
||||||
*
|
|
||||||
* @param String $login
|
|
||||||
*/
|
|
||||||
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);
|
|
||||||
$script = new Script();
|
|
||||||
$maniaLink->setScript($script);
|
|
||||||
|
|
||||||
// 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);
|
|
||||||
$script->addMapInfoButton($backgroundQuad);
|
|
||||||
|
|
||||||
$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->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->setZ(0.2);
|
|
||||||
$label->setTextSize(1);
|
|
||||||
$label->setScale(0.8);
|
|
||||||
$label->setText($map->authorLogin);
|
|
||||||
$label->setTextColor("FFF");
|
|
||||||
|
|
||||||
if (isset($map->mx->pageurl)) {
|
|
||||||
$quad = new Quad();
|
|
||||||
$frame->add($quad);
|
|
||||||
$quad->setImage("http://wiki.maniaplanet.com/pool/images/b/bf/ManiaExchange_logo.png"); // TODO include image into
|
|
||||||
// maniacontrol
|
|
||||||
$quad->setPosition(-$width / 2 + 4, -1.5, -0.5);
|
|
||||||
$quad->setSize(4, 4);
|
|
||||||
$quad->setHAlign(Control::CENTER);
|
|
||||||
$quad->setUrl($map->mx->pageurl);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send manialink
|
|
||||||
$manialinkText = $maniaLink->render()->saveXML();
|
|
||||||
$this->maniaControl->manialinkManager->sendManialink($manialinkText, $login);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Closes a Widget
|
|
||||||
*
|
|
||||||
* @param $widgetId
|
|
||||||
*/
|
|
||||||
public function closeWidget($widgetId)
|
|
||||||
{
|
|
||||||
$emptyManialink = new ManiaLink($widgetId);
|
|
||||||
$manialinkText = $emptyManialink->render()->saveXML();
|
|
||||||
$this->maniaControl->manialinkManager->sendManialink($manialinkText);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle ManiaControl OnInit callback
|
|
||||||
*
|
|
||||||
* @param array $callback
|
|
||||||
*/
|
|
||||||
public function handleOnInit(array $callback)
|
|
||||||
{
|
|
||||||
// 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)) {
|
|
||||||
$this->displayClockWidget();
|
|
||||||
}
|
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
|
|
||||||
$this->displayServerInfoWidget();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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)) {
|
|
||||||
$this->displayMapWidget();
|
|
||||||
}
|
|
||||||
$this->closeWidget(self::MLID_NEXTMAPWIDGET);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handle on End Map
|
|
||||||
*
|
|
||||||
* @param array $callback
|
|
||||||
*/
|
|
||||||
public function handleOnEndMap(array $callback)
|
|
||||||
{
|
|
||||||
// Display Map Widget
|
|
||||||
if ($this->maniaControl->settingManager->getSetting($this, self::SETTING_NEXTMAP_WIDGET_ACTIVATED)) {
|
|
||||||
$this->displayNextMapWidget();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle PlayerConnect callback
|
* Handle PlayerConnect callback
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function handlePlayerConnect(array $callback)
|
public function handlePlayerConnect(array $callback) {
|
||||||
{
|
|
||||||
$player = $callback[1];
|
$player = $callback[1];
|
||||||
// Display Map Widget
|
// Display Map Widget
|
||||||
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
|
||||||
@ -534,60 +568,9 @@ class WidgetPlugin implements CallbackListener, Plugin
|
|||||||
*
|
*
|
||||||
* @param array $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function handleEveryMinute(array $callback)
|
public function handleEveryMinute(array $callback) {
|
||||||
{
|
|
||||||
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
|
||||||
$this->displayClockWidget();
|
$this->displayClockWidget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get plugin id
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public static function getId()
|
|
||||||
{
|
|
||||||
return self::PLUGIN_ID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Plugin Name
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function getName()
|
|
||||||
{
|
|
||||||
return self::PLUGIN_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Plugin Version
|
|
||||||
*
|
|
||||||
* @return float,,
|
|
||||||
*/
|
|
||||||
public static function getVersion()
|
|
||||||
{
|
|
||||||
return self::PLUGIN_VERSION;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Plugin Author
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function getAuthor()
|
|
||||||
{
|
|
||||||
return self::PLUGIN_AUTHOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get Plugin Description
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function getDescription()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user