TrackManiaControl/application/core/Maps/MapList.php

845 lines
28 KiB
PHP
Raw Normal View History

2013-12-14 22:00:59 +01:00
<?php
namespace ManiaControl\Maps;
2014-01-02 10:38:46 +01:00
2013-12-14 22:00:59 +01:00
use FML\Controls\Control;
2014-01-09 16:41:17 +01:00
use FML\Controls\Entry;
2014-01-02 10:38:46 +01:00
use FML\Controls\Frame;
2013-12-29 19:21:29 +01:00
use FML\Controls\Gauge;
2013-12-14 22:00:59 +01:00
use FML\Controls\Label;
2013-12-31 02:27:40 +01:00
use FML\Controls\Labels\Label_Button;
use FML\Controls\Labels\Label_Text;
2014-01-02 10:38:46 +01:00
use FML\Controls\Quad;
2013-12-31 02:27:40 +01:00
use FML\Controls\Quads\Quad_BgsPlayerCard;
2013-12-14 22:00:59 +01:00
use FML\Controls\Quads\Quad_Icons64x64_1;
2014-01-02 10:38:46 +01:00
use FML\ManiaLink;
2013-12-15 15:13:56 +01:00
use FML\Script\Script;
2013-12-30 16:58:35 +01:00
use KarmaPlugin;
2013-12-15 15:13:56 +01:00
use ManiaControl\Callbacks\CallbackListener;
use ManiaControl\Callbacks\CallbackManager;
2013-12-29 19:21:29 +01:00
use ManiaControl\ColorUtil;
2013-12-31 11:39:54 +01:00
use ManiaControl\Formatter;
2014-01-02 10:38:46 +01:00
use ManiaControl\ManiaControl;
2014-01-09 18:19:37 +01:00
use ManiaControl\Manialinks\IconManager;
use ManiaControl\Manialinks\ManialinkManager;
2013-12-14 22:00:59 +01:00
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
use ManiaControl\Players\Player;
2013-12-24 13:09:39 +01:00
/**
* MapList Widget Class
*
* @author steeffeen & kremsy
*/
2013-12-15 15:13:56 +01:00
class MapList implements ManialinkPageAnswerListener, CallbackListener {
2013-12-18 15:48:33 +01:00
/**
* Constants
*/
2014-01-09 17:26:59 +01:00
const ACTION_ADD_MAP = 'MapList.AddMap';
2014-01-12 21:39:27 +01:00
const ACTION_UPDATE_MAP = 'MapList.UpdateMap';
2014-01-09 17:26:59 +01:00
const ACTION_SEARCH_MAPNAME = 'MapList.SearchMapName';
const ACTION_SEARCH_AUTHOR = 'MapList.SearchAuthor';
const ACTION_GET_MAPS_FROM_AUTHOR = 'MapList.GetMapsFromAuthor';
const ACTION_ERASE_MAP = 'MapList.EraseMap';
const ACTION_SWITCH_MAP = 'MapList.SwitchMap';
const ACTION_QUEUED_MAP = 'MapList.QueueMap';
2014-01-17 22:35:14 +01:00
const ACTION_CHECK_UPDATE = 'MapList.CheckUpdate';
const ACTION_CLEAR_MAPQUEUE = 'MapList.ClearMapQueue';
2014-01-09 17:26:59 +01:00
const MAX_MAPS_PER_PAGE = 15;
const MAX_MX_MAPS_PER_PAGE = 14;
const SHOW_MX_LIST = 1;
const SHOW_MAP_LIST = 2;
const DEFAULT_KARMA_PLUGIN = 'KarmaPlugin';
2014-01-08 18:07:09 +01:00
2013-12-14 22:00:59 +01:00
/**
2014-01-06 15:54:22 +01:00
* Private Properties
2013-12-14 22:00:59 +01:00
*/
private $maniaControl = null;
2013-12-28 23:24:54 +01:00
private $mapListShown = array();
2013-12-14 22:00:59 +01:00
/**
2014-01-06 15:54:22 +01:00
* Create a new MapList Instance
2013-12-14 22:00:59 +01:00
*
* @param ManiaControl $maniaControl
*/
public function __construct(ManiaControl $maniaControl) {
$this->maniaControl = $maniaControl;
2014-01-08 18:07:09 +01:00
2014-01-06 15:54:22 +01:00
// Register for Callbacks
2014-01-02 10:38:46 +01:00
$this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
$this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_OPENED, $this, 'handleWidgetOpened');
2014-01-08 18:07:09 +01:00
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
2013-12-31 12:25:03 +01:00
$this->maniaControl->callbackManager->registerCallbackListener(MapQueue::CB_MAPQUEUE_CHANGED, $this, 'updateWidget');
2014-01-06 18:50:26 +01:00
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_MAPS_UPDATED, $this, 'updateWidget');
2014-01-06 15:54:22 +01:00
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_KARMA_UPDATED, $this, 'updateWidget');
2014-01-09 19:00:37 +01:00
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_BEGINMAP, $this, 'updateWidget');
2014-01-09 16:41:17 +01:00
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_SEARCH_MAPNAME, $this, 'showManiaExchangeList');
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_SEARCH_AUTHOR, $this, 'showManiaExchangeList');
2014-01-17 22:35:14 +01:00
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CHECK_UPDATE, $this, 'checkUpdates');
$this->maniaControl->manialinkManager->registerManialinkPageAnswerListener(self::ACTION_CLEAR_MAPQUEUE, $this, 'clearMapQueue');
2013-12-14 22:00:59 +01:00
}
2014-01-17 22:35:14 +01:00
/**
* Clears the Map Queue
*
* @param array $chatCallback
* @param Player $player
*/
public function clearMapQueue(array $chatCallback, Player $player) {
//Clears the Map Queue
$this->maniaControl->mapManager->mapQueue->clearMapQueue($player);
}
/**
* Check for Map Updates
*
* @param array $chatCallback
* @param Player $player
*/
public function checkUpdates(array $chatCallback, Player $player) {
//Update Mx Infos
$this->maniaControl->mapManager->mxManager->fetchManiaExchangeMapInformations();
//Reshow the Maplist
$this->showMapList($player);
}
2014-01-09 16:41:17 +01:00
2013-12-15 12:34:35 +01:00
/**
2014-01-06 15:54:22 +01:00
* Display the Mania Exchange List
2014-01-02 10:38:46 +01:00
*
2014-01-08 18:07:09 +01:00
* @param array $chatCallback
2013-12-15 12:34:35 +01:00
* @param Player $player
*/
2014-01-02 10:38:46 +01:00
public function showManiaExchangeList(array $chatCallback, Player $player) {
2013-12-28 23:24:54 +01:00
$this->mapListShown[$player->login] = self::SHOW_MX_LIST;
2014-01-08 18:07:09 +01:00
$params = explode(' ', $chatCallback[1][2]);
2014-01-08 18:07:09 +01:00
2014-01-08 20:11:48 +01:00
$searchString = '';
$author = '';
$environment = '';
2014-01-27 21:27:31 +01:00
if (count($params) >= 1) {
2014-01-08 18:07:09 +01:00
foreach($params as $param) {
2014-01-27 21:27:31 +01:00
if ($param == '/xlist' || $param == MapCommands::ACTION_OPEN_XLIST) {
continue;
2014-01-02 10:38:46 +01:00
}
2014-01-27 21:27:31 +01:00
if ($param == self::ACTION_SEARCH_MAPNAME) {
2014-01-09 16:41:17 +01:00
$searchString = $chatCallback[1][3][0]['Value'];
2014-01-27 21:27:31 +01:00
} else if ($param == self::ACTION_SEARCH_AUTHOR) {
2014-01-09 16:41:17 +01:00
$author = $chatCallback[1][3][0]['Value'];
2014-01-27 21:27:31 +01:00
} else if (strtolower(substr($param, 0, 5)) == 'auth:') {
$author = substr($param, 5);
2014-01-27 21:27:31 +01:00
} else if (strtolower(substr($param, 0, 4)) == 'env:') {
$environment = substr($param, 4);
2014-01-08 18:07:09 +01:00
} else {
2014-01-27 21:27:31 +01:00
if ($searchString == '') {
2014-01-08 20:11:48 +01:00
$searchString = $param;
2014-01-08 18:07:09 +01:00
} else { // concatenate words in name
2014-01-08 20:11:48 +01:00
$searchString .= '%20' . $param;
2014-01-02 10:38:46 +01:00
}
}
}
}
2014-01-08 18:07:09 +01:00
// search for matching maps
2014-01-14 15:15:13 +01:00
$maps = $this->maniaControl->mapManager->mxManager->getMaps($searchString, $author, $environment);
2014-01-08 18:07:09 +01:00
2014-01-06 15:54:22 +01:00
// check if there are any results
2014-01-27 21:27:31 +01:00
if ($maps == null) {
$this->maniaControl->chat->sendError('No maps found, or MX is down!', $player->login);
return;
}
2014-01-08 18:07:09 +01:00
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
2014-01-08 18:07:09 +01:00
$frame = $this->buildMainFrame();
2013-12-15 12:34:35 +01:00
$maniaLink->add($frame);
2014-01-09 18:19:37 +01:00
$frame->setZ(10);
2014-01-08 18:07:09 +01:00
2013-12-15 15:13:56 +01:00
// Create script and features
$script = new Script();
$maniaLink->setScript($script);
2014-01-08 18:07:09 +01:00
2014-01-06 15:54:22 +01:00
// Start offsets
2014-01-08 18:07:09 +01:00
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
2014-01-06 15:54:22 +01:00
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
2014-01-08 18:07:09 +01:00
$x = -$width / 2;
$y = $height / 2;
2014-01-09 18:19:37 +01:00
// Pagers
// Config
$pagerSize = 6.;
2014-01-09 18:45:39 +01:00
$pagesId = 'MxListPages';
2014-01-09 18:19:37 +01:00
$pagerPrev = new Quad_Icons64x64_1();
$frame->add($pagerPrev);
$pagerPrev->setPosition($width * 0.42, $height * -0.44, 2);
$pagerPrev->setSize($pagerSize, $pagerSize);
$pagerPrev->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowPrev);
$pagerNext = new Quad_Icons64x64_1();
$frame->add($pagerNext);
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2);
$pagerNext->setSize($pagerSize, $pagerSize);
$pagerNext->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowNext);
$script->addPager($pagerPrev, -1, $pagesId);
$script->addPager($pagerNext, 1, $pagesId);
$pageCountLabel = new Label_Text();
$frame->add($pageCountLabel);
$pageCountLabel->setHAlign(Control::RIGHT);
$pageCountLabel->setPosition($width * 0.40, $height * -0.44, 1);
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
$pageCountLabel->setTextSize(1.3);
$script->addPageLabel($pageCountLabel, $pagesId);
// Predefine Description Label
$descriptionLabel = new Label();
$frame->add($descriptionLabel);
$descriptionLabel->setAlign(Control::LEFT, Control::TOP);
$descriptionLabel->setPosition($x + 10, -$height / 2 + 5);
$descriptionLabel->setSize($width * 0.7, 4);
$descriptionLabel->setTextSize(2);
$descriptionLabel->setVisible(false);
2014-01-06 15:54:22 +01:00
// Headline
2013-12-15 12:34:35 +01:00
$headFrame = new Frame();
$frame->add($headFrame);
2014-01-18 21:21:29 +01:00
$headFrame->setY($y - 12);
$array = array('$oMx Id' => $x + 5, '$oName' => $x + 17, '$oAuthor' => $x + 65, '$oType' => $x + 100, '$oMood' => $x + 115, '$oLast Update' => $x + 130);
2014-01-02 10:38:46 +01:00
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
2014-01-08 18:07:09 +01:00
2014-01-18 21:21:29 +01:00
$i = 0;
$y = $height / 2 - 16;
2014-01-09 18:19:37 +01:00
$pageFrames = array();
2014-01-09 18:45:39 +01:00
foreach($maps as $map) { //TODO order possabilities
2014-01-27 21:27:31 +01:00
if (!isset($pageFrame)) {
2014-01-09 18:19:37 +01:00
$pageFrame = new Frame();
$frame->add($pageFrame);
2014-01-27 21:27:31 +01:00
if (!empty($pageFrames)) {
2014-01-09 18:19:37 +01:00
$pageFrame->setVisible(false);
}
array_push($pageFrames, $pageFrame);
2014-01-18 21:21:29 +01:00
$y = $height / 2 - 16;
2014-01-09 18:19:37 +01:00
$script->addPage($pageFrame, count($pageFrames), $pagesId);
}
2014-01-09 16:41:17 +01:00
2014-01-09 18:19:37 +01:00
// Map Frame
2013-12-15 12:34:35 +01:00
$mapFrame = new Frame();
2014-01-09 18:19:37 +01:00
$pageFrame->add($mapFrame);
2014-01-27 21:27:31 +01:00
if ($i % 2 == 0) {
2014-01-09 18:19:37 +01:00
$lineQuad = new Quad_BgsPlayerCard();
$mapFrame->add($lineQuad);
$lineQuad->setSize($width, 4);
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
$lineQuad->setZ(0.001);
}
/** @var MxMapInfo $map */
2014-01-09 19:00:37 +01:00
$time = Formatter::time_elapsed_string(strtotime($map->updated));
2014-01-09 17:26:59 +01:00
$array = array($map->id => $x + 5, $map->name => $x + 17, $map->author => $x + 65, str_replace("Arena", "", $map->maptype) => $x + 100, $map->mood => $x + 115, $time => $x + 130);
$labels = $this->maniaControl->manialinkManager->labelLine($mapFrame, $array);
/** @var Label_Text $authorLabel */
$authorLabel = $labels[2];
$authorLabel->setAction(self::ACTION_GET_MAPS_FROM_AUTHOR . '.' . $map->author);
2013-12-15 12:34:35 +01:00
$mapFrame->setY($y);
2014-01-08 18:07:09 +01:00
2014-01-09 18:19:37 +01:00
$mxQuad = new Quad();
$mapFrame->add($mxQuad);
$mxQuad->setSize(3, 3);
$mxQuad->setImage($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON));
$mxQuad->setImageFocus($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_MOVER));
$mxQuad->setX($x + 62);
$mxQuad->setUrl($map->pageurl);
$mxQuad->setZ(0.01);
$script->addTooltip($mxQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "View " . $map->name . " on Mania-Exchange"));
2014-01-17 22:35:14 +01:00
//TODO permission Clear Jukebox
2014-01-27 21:27:31 +01:00
if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
2014-01-09 18:19:37 +01:00
$addQuad = new Quad_Icons64x64_1();
$mapFrame->add($addQuad);
$addQuad->setX($x + 59);
$addQuad->setZ(-0.1);
$addQuad->setSubStyle($addQuad::SUBSTYLE_Add);
$addQuad->setSize(4, 4);
$addQuad->setAction(self::ACTION_ADD_MAP . '.' . $map->id);
$addQuad->setZ(0.01);
$script->addTooltip($addQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => 'Add-Map: $<' . $map->name . '$>'));
}
2014-01-09 19:29:25 +01:00
//Award Quad
2014-01-27 21:27:31 +01:00
if ($map->awards > 0) {
2014-01-09 17:26:59 +01:00
$awardQuad = new Quad_Icons64x64_1();
$mapFrame->add($awardQuad);
$awardQuad->setSize(3, 3);
$awardQuad->setSubStyle($awardQuad::SUBSTYLE_OfficialRace);
$awardQuad->setX($x + 93);
2014-01-09 19:29:25 +01:00
$awardQuad->setZ(0.01);
2014-01-09 17:26:59 +01:00
$awardLabel = new Label_Text();
$mapFrame->add($awardLabel);
$awardLabel->setX($x + 94.5);
$awardLabel->setHAlign(Control::LEFT);
$awardLabel->setText($map->awards);
$awardLabel->setTextSize(1.3);
}
2013-12-15 15:13:56 +01:00
$y -= 4;
2013-12-15 12:34:35 +01:00
$i++;
2014-01-27 21:27:31 +01:00
if ($i % self::MAX_MX_MAPS_PER_PAGE == 0) {
2014-01-09 18:19:37 +01:00
unset($pageFrame);
2014-01-02 10:38:46 +01:00
}
2013-12-15 12:34:35 +01:00
}
2014-01-08 18:07:09 +01:00
2014-01-09 16:41:17 +01:00
$label = new Label_Text();
$frame->add($label);
2014-01-18 21:21:29 +01:00
$label->setPosition(-$width / 2 + 5, $height / 2 - 5);
2014-01-09 16:41:17 +01:00
$label->setHAlign(Control::LEFT);
$label->setTextSize(1.3);
$label->setText("Search:");
$entry = new Entry();
$frame->add($entry);
$entry->setStyle(Label_Text::STYLE_TextValueSmall);
$entry->setHAlign(Control::LEFT);
2014-01-18 21:21:29 +01:00
$entry->setPosition(-$width / 2 + 15, $height / 2 - 5);
2014-01-09 16:41:17 +01:00
$entry->setTextSize(1);
$entry->setSize($width * 0.25, 4);
$entry->setName('SearchString');
//Search for Map-Name
$label = new Label_Button();
$frame->add($label);
2014-01-18 21:21:29 +01:00
$label->setPosition(-$width / 2 + 63, $height / 2 - 5);
2014-01-09 16:41:17 +01:00
$label->setText("MapName");
$label->setTextSize(1.3);
$quad = new Quad_BgsPlayerCard();
$frame->add($quad);
2014-01-18 21:21:29 +01:00
$quad->setPosition(-$width / 2 + 63, $height / 2 - 5, 0.01);
2014-01-09 16:41:17 +01:00
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
$quad->setSize(18, 5);
$quad->setAction(self::ACTION_SEARCH_MAPNAME);
//Search for Author
$label = new Label_Button();
$frame->add($label);
2014-01-18 21:21:29 +01:00
$label->setPosition(-$width / 2 + 82, $height / 2 - 5);
2014-01-09 16:41:17 +01:00
$label->setText("Author");
$label->setTextSize(1.3);
$quad = new Quad_BgsPlayerCard();
$frame->add($quad);
2014-01-18 21:21:29 +01:00
$quad->setPosition(-$width / 2 + 82, $height / 2 - 5, 0.01);
2014-01-09 16:41:17 +01:00
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
$quad->setSize(18, 5);
$quad->setAction(self::ACTION_SEARCH_AUTHOR);
2014-01-06 15:54:22 +01:00
// render and display xml
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player, 'MxList');
}
/**
* Builds the mainFrame
2014-01-02 10:38:46 +01:00
*
* @return Frame $frame
*/
2014-01-02 10:38:46 +01:00
public function buildMainFrame() {
2014-01-08 18:07:09 +01:00
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
2014-01-06 15:54:22 +01:00
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
2014-01-08 18:07:09 +01:00
2014-01-06 15:54:22 +01:00
// mainframe
2013-12-14 22:00:59 +01:00
$frame = new Frame();
2014-01-06 15:54:22 +01:00
$frame->setSize($width, $height);
2013-12-14 22:00:59 +01:00
$frame->setPosition(0, 0);
2014-01-08 18:07:09 +01:00
2014-01-06 15:54:22 +01:00
// Background Quad
2013-12-14 22:00:59 +01:00
$backgroundQuad = new Quad();
$frame->add($backgroundQuad);
2014-01-06 15:54:22 +01:00
$backgroundQuad->setSize($width, $height);
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
2014-01-08 18:07:09 +01:00
// Add Close Quad (X)
$closeQuad = new Quad_Icons64x64_1();
$frame->add($closeQuad);
2014-01-06 15:54:22 +01:00
$closeQuad->setPosition($width * 0.483, $height * 0.467, 3);
$closeQuad->setSize(6, 6);
$closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace);
2013-12-24 13:09:39 +01:00
$closeQuad->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
2014-01-08 18:07:09 +01:00
return $frame;
}
2014-01-02 10:38:46 +01:00
/**
* Displayes a MapList on the screen
2014-01-02 10:38:46 +01:00
*
* @param Player $player
*/
2014-01-03 18:04:46 +01:00
public function showMapList(Player $player) {
2014-01-08 18:07:09 +01:00
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
2014-01-06 15:54:22 +01:00
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
2014-01-08 18:07:09 +01:00
2014-01-06 15:54:22 +01:00
// Get Maplist
2014-01-06 18:50:26 +01:00
$mapList = $this->maniaControl->mapManager->getMaps();
2014-01-08 18:07:09 +01:00
2013-12-28 23:24:54 +01:00
$this->mapListShown[$player->login] = self::SHOW_MAP_LIST;
2014-01-08 18:07:09 +01:00
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
2014-01-08 18:07:09 +01:00
$frame = $this->buildMainFrame();
$maniaLink->add($frame);
2014-01-09 18:19:37 +01:00
$frame->setZ(10);
2014-01-08 18:07:09 +01:00
2013-12-16 12:16:33 +01:00
// Create script and features
$script = new Script();
$maniaLink->setScript($script);
2014-01-08 18:07:09 +01:00
2014-01-02 20:50:09 +01:00
// Pagers
// Config
$pagerSize = 6.;
2014-01-08 18:07:09 +01:00
$pagesId = 'MapListPages';
2014-01-27 21:27:31 +01:00
if (count($mapList) > self::MAX_MAPS_PER_PAGE) {
2014-01-02 20:50:09 +01:00
$pagerPrev = new Quad_Icons64x64_1();
$frame->add($pagerPrev);
2014-01-06 15:54:22 +01:00
$pagerPrev->setPosition($width * 0.42, $height * -0.44, 2);
2014-01-02 20:50:09 +01:00
$pagerPrev->setSize($pagerSize, $pagerSize);
$pagerPrev->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowPrev);
2014-01-08 18:07:09 +01:00
2014-01-02 20:50:09 +01:00
$pagerNext = new Quad_Icons64x64_1();
$frame->add($pagerNext);
2014-01-06 15:54:22 +01:00
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2);
2014-01-02 20:50:09 +01:00
$pagerNext->setSize($pagerSize, $pagerSize);
$pagerNext->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowNext);
2014-01-08 18:07:09 +01:00
2014-01-02 20:50:09 +01:00
$script->addPager($pagerPrev, -1, $pagesId);
$script->addPager($pagerNext, 1, $pagesId);
2014-01-08 18:07:09 +01:00
2014-01-06 15:54:22 +01:00
$pageCountLabel = new Label_Text();
2014-01-02 20:50:09 +01:00
$frame->add($pageCountLabel);
$pageCountLabel->setHAlign(Control::RIGHT);
2014-01-06 15:54:22 +01:00
$pageCountLabel->setPosition($width * 0.40, $height * -0.44, 1);
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
2014-01-02 20:50:09 +01:00
$pageCountLabel->setTextSize(1.3);
$script->addPageLabel($pageCountLabel, $pagesId);
}
2014-01-08 18:07:09 +01:00
2014-01-17 22:35:14 +01:00
//Admin Buttons
2014-01-27 21:27:31 +01:00
if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
2014-01-17 22:35:14 +01:00
//Clear Jukebox
$label = new Label_Button();
$frame->add($label);
$label->setText("Clear Map-Queue");
$label->setTextSize(1);
$label->setPosition($width / 2 - 8, -$height / 2 + 9);
$label->setHAlign(Control::RIGHT);
$quad = new Quad_BgsPlayerCard();
$frame->add($quad);
$quad->setPosition($width / 2 - 5, -$height / 2 + 9, 0.01);
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
$quad->setHAlign(Control::RIGHT);
$quad->setSize(29, 4);
$quad->setAction(self::ACTION_CLEAR_MAPQUEUE);
//Check Update
$label = new Label_Button();
$frame->add($label);
$label->setText("Check MX Updates");
$label->setTextSize(1);
$label->setPosition($width / 2 - 41, -$height / 2 + 9, 0.01);
$label->setHAlign(Control::RIGHT);
$quad = new Quad_BgsPlayerCard();
$frame->add($quad);
$quad->setPosition($width / 2 - 37, -$height / 2 + 9, 0.01);
$quad->setSubStyle($quad::SUBSTYLE_BgPlayerCardBig);
$quad->setHAlign(Control::RIGHT);
$quad->setSize(35, 4);
$quad->setAction(self::ACTION_CHECK_UPDATE);
$mxQuad = new Quad();
$frame->add($mxQuad);
$mxQuad->setSize(3, 3);
$mxQuad->setImage($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_GREEN));
$mxQuad->setImageFocus($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_GREEN_MOVER));
$mxQuad->setPosition($width / 2 - 67, -$height / 2 + 9);
$mxQuad->setZ(0.01);
$mxQuad->setAction(self::ACTION_CHECK_UPDATE);
}
2014-01-06 15:54:22 +01:00
// Headline
2013-12-15 11:55:44 +01:00
$headFrame = new Frame();
$frame->add($headFrame);
2014-01-06 15:54:22 +01:00
$headFrame->setY($height / 2 - 5);
2014-01-08 18:07:09 +01:00
$x = -$width / 2;
$array = array('Id' => $x + 5, 'Mx Id' => $x + 10, 'Map Name' => $x + 20, 'Author' => $x + 68, 'Karma' => $x + 115, 'Actions' => $width / 2 - 15);
2014-01-02 10:38:46 +01:00
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
2014-01-08 18:07:09 +01:00
2014-01-06 15:54:22 +01:00
// Predefine Description Label
2014-01-12 00:28:06 +01:00
$descriptionLabel = new Label();
$frame->add($descriptionLabel);
$descriptionLabel->setAlign(Control::LEFT, Control::TOP);
$descriptionLabel->setPosition($x + 10, -$height / 2 + 5);
$descriptionLabel->setSize($width * 0.7, 4);
$descriptionLabel->setTextSize(2);
$descriptionLabel->setVisible(false);
2014-01-08 18:07:09 +01:00
2013-12-31 12:36:49 +01:00
$queuedMaps = $this->maniaControl->mapManager->mapQueue->getQueuedMapsRanking();
2014-01-06 15:54:22 +01:00
/**
* @var KarmaPlugin $karmaPlugin
*/
2013-12-29 19:21:29 +01:00
$karmaPlugin = $this->maniaControl->pluginManager->getPlugin(self::DEFAULT_KARMA_PLUGIN);
2014-01-08 18:07:09 +01:00
$id = 1;
$y = $height / 2 - 10;
2014-01-02 20:50:09 +01:00
$pageFrames = array();
2014-01-06 15:54:22 +01:00
/**
* @var Map $map
*/
2014-01-08 18:07:09 +01:00
foreach($mapList as $map) {
2014-01-27 21:27:31 +01:00
if (!isset($pageFrame)) {
2014-01-02 20:50:09 +01:00
$pageFrame = new Frame();
$frame->add($pageFrame);
2014-01-27 21:27:31 +01:00
if (!empty($pageFrames)) {
2014-01-02 20:50:09 +01:00
$pageFrame->setVisible(false);
}
array_push($pageFrames, $pageFrame);
2014-01-06 15:54:22 +01:00
$y = $height / 2 - 10;
2014-01-02 20:50:09 +01:00
$script->addPage($pageFrame, count($pageFrames), $pagesId);
}
2014-01-08 18:07:09 +01:00
2014-01-06 15:54:22 +01:00
// Map Frame
2013-12-14 22:00:59 +01:00
$mapFrame = new Frame();
2014-01-02 20:50:09 +01:00
$pageFrame->add($mapFrame);
2013-12-30 16:58:35 +01:00
$mapFrame->setZ(0.1);
2013-12-14 22:00:59 +01:00
$mapFrame->setY($y);
2014-01-08 18:07:09 +01:00
2014-01-27 21:27:31 +01:00
if ($id % 2 != 0) {
2013-12-31 02:27:40 +01:00
$lineQuad = new Quad_BgsPlayerCard();
$mapFrame->add($lineQuad);
2014-01-06 15:54:22 +01:00
$lineQuad->setSize($width, 4);
2013-12-31 02:27:40 +01:00
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
$lineQuad->setZ(0.001);
}
2014-01-08 18:07:09 +01:00
2014-01-27 21:27:31 +01:00
if ($this->maniaControl->mapManager->getCurrentMap() === $map) {
2013-12-30 16:58:35 +01:00
$currentQuad = new Quad_Icons64x64_1();
2013-12-30 20:15:38 +01:00
$mapFrame->add($currentQuad);
2013-12-30 16:58:35 +01:00
$currentQuad->setX($x + 3.5);
$currentQuad->setZ(0.2);
$currentQuad->setSize(4, 4);
$currentQuad->setSubStyle($currentQuad::SUBSTYLE_ArrowBlue);
}
2014-01-08 18:07:09 +01:00
2013-12-30 16:58:35 +01:00
$mxId = '-';
2014-01-27 21:27:31 +01:00
if (isset($map->mx->id)) {
2013-12-30 16:58:35 +01:00
$mxId = $map->mx->id;
2014-01-12 00:28:06 +01:00
$mxQuad = new Quad();
$mapFrame->add($mxQuad);
$mxQuad->setSize(3, 3);
$mxQuad->setImage($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON));
$mxQuad->setImageFocus($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_MOVER));
$mxQuad->setX($x + 65);
$mxQuad->setUrl($map->mx->pageurl);
$mxQuad->setZ(0.01);
$script->addTooltip($mxQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "View $<" . $map->name . "$> on Mania-Exchange"));
2014-01-27 21:27:31 +01:00
if ($map->updateAvailable()) {
2014-01-12 00:28:06 +01:00
$mxQuad = new Quad();
$mapFrame->add($mxQuad);
$mxQuad->setSize(3, 3);
$mxQuad->setImage($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_GREEN));
$mxQuad->setImageFocus($this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_GREEN_MOVER));
$mxQuad->setX($x + 62);
$mxQuad->setUrl($map->mx->pageurl);
$mxQuad->setZ(0.01);
$script->addTooltip($mxQuad, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => "Update of $<" . $map->name . "$> available on Mania-Exchange"));
2014-01-15 20:49:01 +01:00
//Update Button
2014-01-27 21:27:31 +01:00
if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
2014-01-15 20:49:01 +01:00
$mxQuad->setAction(self::ACTION_UPDATE_MAP . '.' . $map->uid);
}
2014-01-12 00:28:06 +01:00
}
2014-01-02 10:38:46 +01:00
}
2014-01-08 18:07:09 +01:00
2014-01-06 15:54:22 +01:00
// Display Maps
2014-01-27 21:27:31 +01:00
$array = array($id => $x + 5, $mxId => $x + 10, Formatter::stripDirtyCodes($map->name) => $x + 20, $map->authorNick => $x + 68);
$labels = $this->maniaControl->manialinkManager->labelLine($mapFrame, $array);
$script->addTooltip($labels[3], $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => '$<' . $map->name . '$> made by $<' . $map->authorLogin . '$>'));
2014-01-09 19:00:37 +01:00
// TODO action detailed map info including mx info
2014-01-08 18:07:09 +01:00
2014-01-06 15:54:22 +01:00
// Map-Queue-Map-Label
2014-01-27 21:27:31 +01:00
if (isset($queuedMaps[$map->uid])) {
2013-12-31 12:36:49 +01:00
$label = new Label_Text();
$mapFrame->add($label);
2014-01-06 15:54:22 +01:00
$label->setX($width / 2 - 15);
2014-01-02 10:38:46 +01:00
$label->setAlign(Control::CENTER, Control::CENTER);
2013-12-31 12:36:49 +01:00
$label->setZ(0.2);
$label->setTextSize(1.5);
$label->setText($queuedMaps[$map->uid]);
2014-01-06 15:54:22 +01:00
$label->setTextColor('fff');
2014-01-12 00:28:06 +01:00
$script->addTooltip($label, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => '$<' . $map->name . '$> is on Map-Queue Position: ' . $queuedMaps[$map->uid]));
2014-01-08 18:07:09 +01:00
} else {
2014-01-06 15:54:22 +01:00
// Map-Queue-Map-Button
$queueLabel = new Label_Button();
$mapFrame->add($queueLabel);
$queueLabel->setX($width / 2 - 15);
$queueLabel->setZ(0.2);
$queueLabel->setSize(3, 3);
$queueLabel->setAction(self::ACTION_QUEUED_MAP . '.' . $map->uid);
$queueLabel->setText('+');
$queueLabel->setTextColor('09f');
2014-01-08 18:07:09 +01:00
2014-01-12 00:28:06 +01:00
$script->addTooltip($queueLabel, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => 'Add Map to the Map Queue: $<' . $map->name . '$>'));
2014-01-06 15:54:22 +01:00
}
2014-01-08 18:07:09 +01:00
2014-01-27 21:27:31 +01:00
if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_REMOVE_MAP)) {
2014-01-06 15:54:22 +01:00
// erase map quad
2014-01-06 14:43:26 +01:00
$eraseLabel = new Label_Button();
$mapFrame->add($eraseLabel);
2014-01-06 15:54:22 +01:00
$eraseLabel->setX($width / 2 - 5);
2014-01-06 14:43:26 +01:00
$eraseLabel->setZ(0.2);
$eraseLabel->setSize(3, 3);
$eraseLabel->setTextSize(1);
2014-01-06 15:54:22 +01:00
$eraseLabel->setText('x');
$eraseLabel->setTextColor('a00');
2014-01-08 18:07:09 +01:00
2014-01-03 18:04:46 +01:00
$confirmFrame = $this->buildConfirmFrame($maniaLink, $y, $id, $map->uid);
2014-01-12 01:59:23 +01:00
$script->addToggle($eraseLabel, $confirmFrame);
2014-01-12 00:28:06 +01:00
$script->addTooltip($eraseLabel, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => 'Remove Map: $<' . $map->name . '$>'));
2013-12-16 12:41:14 +01:00
}
2014-01-08 18:07:09 +01:00
2014-01-27 21:27:31 +01:00
if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
2014-01-06 15:54:22 +01:00
// Switch to map
$switchLabel = new Label_Button();
$mapFrame->add($switchLabel);
$switchLabel->setX($width / 2 - 10);
$switchLabel->setZ(0.2);
$switchLabel->setSize(3, 3);
$switchLabel->setTextSize(2);
$switchLabel->setText('»');
$switchLabel->setTextColor('0f0');
2014-01-08 18:07:09 +01:00
2014-01-03 18:04:46 +01:00
$confirmFrame = $this->buildConfirmFrame($maniaLink, $y, $id);
2014-01-12 01:59:23 +01:00
$script->addToggle($switchLabel, $confirmFrame);
2014-01-08 18:07:09 +01:00
2014-01-12 00:28:06 +01:00
$script->addTooltip($switchLabel, $descriptionLabel, array(Script::OPTION_TOOLTIP_TEXT => 'Switch Directly to Map: $<' . $map->name . '$>'));
2013-12-16 12:41:14 +01:00
}
2014-01-08 18:07:09 +01:00
2014-01-06 15:54:22 +01:00
// Display Karma bar
2014-01-27 21:27:31 +01:00
if ($karmaPlugin) {
2013-12-29 19:21:29 +01:00
$karma = $karmaPlugin->getMapKarma($map);
$votes = $karmaPlugin->getMapVotes($map);
2014-01-27 21:27:31 +01:00
if (is_numeric($karma)) {
2013-12-29 19:21:29 +01:00
$karmaGauge = new Gauge();
$mapFrame->add($karmaGauge);
2013-12-31 02:27:40 +01:00
$karmaGauge->setZ(2);
2013-12-30 23:53:42 +01:00
$karmaGauge->setX($x + 120);
2013-12-29 19:21:29 +01:00
$karmaGauge->setSize(20, 9);
$karmaGauge->setDrawBg(false);
$karma = floatval($karma);
$karmaGauge->setRatio($karma + 0.15 - $karma * 0.15);
$karmaColor = ColorUtil::floatToStatusColor($karma);
$karmaGauge->setColor($karmaColor . '9');
2014-01-08 18:07:09 +01:00
2013-12-29 19:21:29 +01:00
$karmaLabel = new Label();
$mapFrame->add($karmaLabel);
2013-12-31 02:27:40 +01:00
$karmaLabel->setZ(2);
2013-12-30 23:53:42 +01:00
$karmaLabel->setX($x + 120);
2013-12-29 19:21:29 +01:00
$karmaLabel->setSize(20 * 0.9, 5);
$karmaLabel->setTextSize(0.9);
2014-01-06 15:54:22 +01:00
$karmaLabel->setTextColor('000');
2013-12-29 19:21:29 +01:00
$karmaLabel->setAlign(Control::CENTER, Control::CENTER);
$karmaLabel->setText(' ' . round($karma * 100.) . '% (' . $votes['count'] . ')');
}
}
2014-01-08 18:07:09 +01:00
2013-12-14 22:00:59 +01:00
$y -= 4;
2014-01-27 21:27:31 +01:00
if ($id % self::MAX_MAPS_PER_PAGE == 0) {
2014-01-02 20:50:09 +01:00
unset($pageFrame);
}
$id++;
}
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player, 'MapList');
2013-12-14 22:00:59 +01:00
}
2014-01-03 18:04:46 +01:00
/**
* Builds the confirmation frame
*
* @param ManiaLink $maniaLink
2014-01-08 18:07:09 +01:00
* @param $y
* @param $id
* @param bool $mapUid
2014-01-03 18:04:46 +01:00
* @return Frame
*/
public function buildConfirmFrame(Manialink $maniaLink, $y, $id, $mapUid = false) {
2014-01-08 18:07:09 +01:00
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
2014-01-06 15:54:22 +01:00
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
2014-01-08 18:07:09 +01:00
2014-01-03 18:04:46 +01:00
$confirmFrame = new Frame();
$maniaLink->add($confirmFrame);
2014-01-06 15:54:22 +01:00
$confirmFrame->setPosition($width / 2 + 6, $y);
2014-01-12 01:59:23 +01:00
$confirmFrame->setVisible(false);
2014-01-08 18:07:09 +01:00
2014-01-03 18:04:46 +01:00
$quad = new Quad();
$confirmFrame->add($quad);
2014-01-06 15:54:22 +01:00
$quad->setStyles($quadStyle, $quadSubstyle);
2014-01-03 18:04:46 +01:00
$quad->setSize(12, 4);
2014-01-08 18:07:09 +01:00
2014-01-03 18:04:46 +01:00
$quad = new Quad_BgsPlayerCard();
$confirmFrame->add($quad);
$quad->setSubStyle($quad::SUBSTYLE_BgCardSystem);
$quad->setSize(11, 3.5);
2014-01-08 18:07:09 +01:00
2014-01-03 18:04:46 +01:00
$label = new Label_Button();
$confirmFrame->add($label);
$label->setAlign(Control::CENTER, Control::CENTER);
2014-01-06 15:54:22 +01:00
$label->setText('Sure?');
2014-01-03 18:04:46 +01:00
$label->setTextSize(1);
$label->setScale(0.90);
$label->setX(-1.3);
2014-01-08 18:07:09 +01:00
2014-01-03 18:04:46 +01:00
$buttLabel = new Label_Button();
$confirmFrame->add($buttLabel);
$buttLabel->setPosition(3.2, 0.4, 0.2);
$buttLabel->setSize(3, 3);
$buttLabel->setAlign(Control::CENTER, Control::CENTER);
2014-01-08 18:07:09 +01:00
2014-01-27 21:27:31 +01:00
if (!$mapUid) {
2014-01-06 15:54:22 +01:00
$quad->setAction(self::ACTION_SWITCH_MAP . '.' . ($id - 1));
$buttLabel->setText('»');
$buttLabel->setTextColor('0f0');
2014-01-03 18:04:46 +01:00
$buttLabel->setTextSize(2);
2014-01-08 18:07:09 +01:00
} else {
2014-01-03 18:04:46 +01:00
$buttLabel->setTextSize(1);
2014-01-06 15:54:22 +01:00
$buttLabel->setText('x');
$buttLabel->setTextColor('a00');
$quad->setAction(self::ACTION_ERASE_MAP . '.' . ($id - 1) . '.' . $mapUid);
2014-01-03 18:04:46 +01:00
}
return $confirmFrame;
}
/**
* Unset the player if he opened another Main Widget
2014-01-12 00:28:06 +01:00
*
* @param array $callback
*/
2014-01-12 00:28:06 +01:00
public function handleWidgetOpened(array $callback) {
$player = $callback[1];
$openedWidget = $callback[2];
//unset when another main widget got opened
2014-01-27 21:27:31 +01:00
if ($openedWidget != 'MapList' && $openedWidget != 'MxList') {
unset($this->mapListShown[$player->login]);
}
}
2014-01-12 00:28:06 +01:00
/**
* Closes the widget
2014-01-02 10:38:46 +01:00
*
* @param array $callback
*/
2013-12-29 22:52:07 +01:00
public function closeWidget(array $callback) {
$player = $callback[1];
2014-01-03 18:57:08 +01:00
unset($this->mapListShown[$player->login]);
2014-01-03 18:04:46 +01:00
}
/**
* Closes the widget
*
2014-01-06 15:54:22 +01:00
* @param Player $player
2014-01-03 18:04:46 +01:00
*/
public function playerCloseWidget(Player $player) {
2013-12-28 23:24:54 +01:00
unset($this->mapListShown[$player->login]);
2014-01-03 18:04:46 +01:00
$this->maniaControl->manialinkManager->closeWidget($player);
2013-12-14 22:00:59 +01:00
}
2013-12-15 15:13:56 +01:00
/**
2014-01-06 15:54:22 +01:00
* Handle ManialinkPageAnswer Callback
*
2013-12-15 15:13:56 +01:00
* @param array $callback
*/
2014-01-02 10:38:46 +01:00
public function handleManialinkPageAnswer(array $callback) {
2014-01-08 18:07:09 +01:00
$actionId = $callback[1][2];
2014-01-06 15:54:22 +01:00
$actionArray = explode('.', $actionId);
2014-01-27 21:27:31 +01:00
if (count($actionArray) <= 2) {
2014-01-08 18:07:09 +01:00
return;
}
2014-01-06 15:54:22 +01:00
$action = $actionArray[0] . '.' . $actionArray[1];
2014-01-08 18:07:09 +01:00
$login = $callback[1][1];
2014-01-06 15:54:22 +01:00
$player = $this->maniaControl->playerManager->getPlayer($login);
2014-01-08 18:07:09 +01:00
$mapId = (int)$actionArray[2];
switch($action) {
2014-01-09 17:26:59 +01:00
case self::ACTION_GET_MAPS_FROM_AUTHOR:
$callback[1][2] = 'auth:' . $actionArray[2];
$this->showManiaExchangeList($callback, $player);
break;
2014-01-02 10:38:46 +01:00
case self::ACTION_ADD_MAP:
2014-01-06 15:54:22 +01:00
$this->maniaControl->mapManager->addMapFromMx($mapId, $player->login);
2014-01-02 10:38:46 +01:00
break;
2014-01-12 21:39:27 +01:00
case self::ACTION_UPDATE_MAP:
$mapUid = $actionArray[2];
$this->maniaControl->mapManager->updateMap($player, $mapUid);
break;
2014-01-02 10:38:46 +01:00
case self::ACTION_ERASE_MAP:
2014-01-10 15:58:27 +01:00
$mapUid = $actionArray[3];
$this->maniaControl->mapManager->removeMap($player, $mapUid);
2014-01-02 10:38:46 +01:00
$this->showMapList($player);
break;
case self::ACTION_SWITCH_MAP:
2014-01-25 23:33:39 +01:00
try {
$this->maniaControl->client->jumpToMapIndex($mapId);
} catch(\Exception $e) {
$this->maniaControl->chat->sendError("Error while Jumping to Map Index");
break;
}
2014-01-08 18:07:09 +01:00
$mapList = $this->maniaControl->mapManager->getMaps();
$map = $mapList[$mapId];
2014-01-06 15:54:22 +01:00
$message = '$<' . $player->nickname . '$> skipped to Map $z$<' . $map->name . '$>!';
$this->maniaControl->chat->sendSuccess($message);
$this->maniaControl->log($message, true);
2014-01-08 18:07:09 +01:00
2014-01-03 18:04:46 +01:00
$this->playerCloseWidget($player);
2014-01-02 10:38:46 +01:00
break;
case self::ACTION_QUEUED_MAP:
$this->maniaControl->mapManager->mapQueue->addMapToMapQueue($callback[1][1], $actionArray[2]);
break;
}
2013-12-15 15:13:56 +01:00
}
2013-12-28 23:24:54 +01:00
/**
2014-01-06 15:54:22 +01:00
* Reopen the widget on Map Begin, MapListChanged, etc.
2014-01-02 10:38:46 +01:00
*
2013-12-28 23:24:54 +01:00
* @param array $callback
*/
2014-01-02 10:38:46 +01:00
public function updateWidget(array $callback) {
2014-01-08 18:07:09 +01:00
foreach($this->mapListShown as $login => $shown) {
2014-01-27 21:27:31 +01:00
if ($shown) {
2013-12-28 23:24:54 +01:00
$player = $this->maniaControl->playerManager->getPlayer($login);
2014-01-27 21:27:31 +01:00
if ($player != null) {
if ($shown == self::SHOW_MX_LIST) {
2014-01-14 18:27:54 +01:00
//nothing to update yet
2014-01-27 21:27:31 +01:00
} else if ($shown == self::SHOW_MAP_LIST) {
2013-12-28 23:24:54 +01:00
$this->showMapList($player);
}
2014-01-08 18:07:09 +01:00
} else {
2013-12-28 23:24:54 +01:00
unset($this->mapListShown[$login]);
}
}
}
}
2013-12-14 22:00:59 +01:00
}