map widget map info feature
This commit is contained in:
parent
5fd8c2cf1b
commit
84b12967af
@ -15,7 +15,7 @@ use ManiaControl\Players\Player;
|
||||
use ManiaControl\Players\PlayerManager;
|
||||
use ManiaControl\Plugins\Plugin;
|
||||
use ManiaControl\Callbacks\CallbackManager;
|
||||
|
||||
use FML\Script\Script;
|
||||
|
||||
/**
|
||||
* ManiaControl Widget Plugin
|
||||
@ -67,7 +67,9 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
/**
|
||||
* Private Properties
|
||||
*/
|
||||
/** @var maniaControl $maniaControl */
|
||||
/**
|
||||
* @var maniaControl $maniaControl
|
||||
*/
|
||||
private $maniaControl = null;
|
||||
|
||||
/**
|
||||
@ -126,6 +128,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
|
||||
/**
|
||||
* Displays the Clock Widget
|
||||
*
|
||||
* @param bool $login
|
||||
*/
|
||||
public function displayClockWidget($login = false) {
|
||||
@ -198,7 +201,9 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
// Check if the Next Map is a juked Map
|
||||
$jukedMap = $this->maniaControl->mapManager->jukebox->getNextMap();
|
||||
|
||||
/** @var Player $requester */
|
||||
/**
|
||||
* @var Player $requester
|
||||
*/
|
||||
$requester = null;
|
||||
// if the nextmap is not a juked map, get it from map info
|
||||
if ($jukedMap == null) {
|
||||
@ -287,7 +292,6 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
$frame->setSize($width, $height);
|
||||
$frame->setPosition($pos_x, $pos_y);
|
||||
|
||||
|
||||
// Background Quad
|
||||
$backgroundQuad = new Quad();
|
||||
$frame->add($backgroundQuad);
|
||||
@ -300,20 +304,22 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
$this->maniaControl->client->query('GetMaxSpectators');
|
||||
$maxSpectators = $this->maniaControl->client->getResponse();
|
||||
|
||||
$serverName= $this->maniaControl->server->getName();
|
||||
$serverName = $this->maniaControl->server->getName();
|
||||
|
||||
$players = $this->maniaControl->playerManager->getPlayers();
|
||||
$playerCount = 0;
|
||||
$spectatorCount = 0;
|
||||
/** @var Player $player */
|
||||
foreach($players as $player){
|
||||
if($player->isSpectator)
|
||||
/**
|
||||
* @var Player $player
|
||||
*/
|
||||
foreach ($players as $player) {
|
||||
if ($player->isSpectator)
|
||||
$spectatorCount++;
|
||||
else
|
||||
$playerCount++;
|
||||
}
|
||||
|
||||
//Player Quad / Label
|
||||
// Player Quad / Label
|
||||
$label = new Label_Text();
|
||||
$frame->add($label);
|
||||
$label->setPosition(0, 1.5, 0.2);
|
||||
@ -331,7 +337,6 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
$label->setText($playerCount . " / " . $maxPlayers['NextValue']);
|
||||
$label->setTextColor("FFF");
|
||||
|
||||
|
||||
$quad = new Quad_Icons128x128_1();
|
||||
$frame->add($quad);
|
||||
$quad->setSubStyle($quad::SUBSTYLE_Multiplayer);
|
||||
@ -339,7 +344,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
$quad->setSize(2.5, 2.5);
|
||||
$quad->setHAlign(Control::CENTER);
|
||||
|
||||
//Spectator Quad / Label
|
||||
// Spectator Quad / Label
|
||||
$label = new Label_Text();
|
||||
$frame->add($label);
|
||||
$label->setPosition(8.5, -1.5, 0.2);
|
||||
@ -353,19 +358,19 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
$frame->add($quad);
|
||||
$quad->setSubStyle($quad::SUBSTYLE_Camera);
|
||||
$quad->setPosition(3.5, -1.6, 0.2);
|
||||
$quad->setSize(3.3,2.5);
|
||||
$quad->setSize(3.3, 2.5);
|
||||
$quad->setHAlign(Control::CENTER);
|
||||
|
||||
//Favorite quad
|
||||
//$quad = new Quad_Icons64x64_1();
|
||||
// Favorite quad
|
||||
// $quad = new Quad_Icons64x64_1();
|
||||
$quad = new Quad_Icons128x128_1();
|
||||
$frame->add($quad);
|
||||
//$quad->setSubStyle($quad::SUBSTYLE_StateFavourite);
|
||||
// $quad->setSubStyle($quad::SUBSTYLE_StateFavourite);
|
||||
$quad->setSubStyle($quad::SUBSTYLE_ServersFavorites);
|
||||
$quad->setPosition($width / 2 - 4, -1.5, -0.5);
|
||||
$quad->setSize(4,4);
|
||||
$quad->setSize(4, 4);
|
||||
$quad->setHAlign(Control::CENTER);
|
||||
//$TODO add server to favorite
|
||||
// $TODO add server to favorite
|
||||
|
||||
// Send manialink
|
||||
$manialinkText = $maniaLink->render()->saveXML();
|
||||
@ -386,6 +391,8 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
|
||||
|
||||
$maniaLink = new ManiaLink(self::MLID_MAPWIDGET);
|
||||
$script = new Script();
|
||||
$maniaLink->setScript($script);
|
||||
|
||||
// mainframe
|
||||
$frame = new Frame();
|
||||
@ -398,6 +405,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
$frame->add($backgroundQuad);
|
||||
$backgroundQuad->setSize($width, $height);
|
||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||
$script->addMapInfoButton($backgroundQuad);
|
||||
|
||||
$map = $this->maniaControl->mapManager->getCurrentMap();
|
||||
|
||||
@ -423,12 +431,13 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
$label->setText($map->authorLogin);
|
||||
$label->setTextColor("FFF");
|
||||
|
||||
if(isset($map->mx->pageurl)){
|
||||
$quad = new Quad;
|
||||
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->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->setSize(4, 4);
|
||||
$quad->setHAlign(Control::CENTER);
|
||||
$quad->setUrl($map->mx->pageurl);
|
||||
}
|
||||
@ -441,8 +450,7 @@ class WidgetPlugin implements CallbackListener, Plugin {
|
||||
/**
|
||||
* Closes a Widget
|
||||
*
|
||||
* @param
|
||||
* $widgetId
|
||||
* @param $widgetId
|
||||
*/
|
||||
public function closeWidget($widgetId) {
|
||||
$emptyManialink = new ManiaLink($widgetId);
|
||||
|
Loading…
Reference in New Issue
Block a user