map/-list improvements
This commit is contained in:
parent
f46d50fee0
commit
be0f0e409b
@ -6,14 +6,13 @@ use ManiaControl\Formatter;
|
|||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map class
|
* Map Class
|
||||||
*
|
*
|
||||||
* @author kremsy & steeffeen
|
* @author kremsy & steeffeen
|
||||||
*/
|
*/
|
||||||
class Map {
|
class Map {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Public properties
|
* Public Properties
|
||||||
*/
|
*/
|
||||||
public $index = -1;
|
public $index = -1;
|
||||||
public $name = 'undefined';
|
public $name = 'undefined';
|
||||||
@ -33,15 +32,14 @@ class Map {
|
|||||||
public $comment = '';
|
public $comment = '';
|
||||||
public $titleUid = '';
|
public $titleUid = '';
|
||||||
public $startTime = -1;
|
public $startTime = -1;
|
||||||
public $mapFetcher = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new map object from rpc data
|
* Create a new Map Object from Rpc Data
|
||||||
*
|
*
|
||||||
* @param \ManiaControl\ManiaControl $maniaControl
|
* @param \ManiaControl\ManiaControl $maniaControl
|
||||||
* @param array $rpc_infos
|
* @param array $rpc_infos
|
||||||
@ -68,17 +66,17 @@ class Map {
|
|||||||
|
|
||||||
$mapsDirectory = $this->maniaControl->server->getMapsDirectory();
|
$mapsDirectory = $this->maniaControl->server->getMapsDirectory();
|
||||||
if ($this->maniaControl->server->checkAccess($mapsDirectory)) {
|
if ($this->maniaControl->server->checkAccess($mapsDirectory)) {
|
||||||
$this->mapFetcher = new \GBXChallMapFetcher(true);
|
$mapFetcher = new \GBXChallMapFetcher(true);
|
||||||
try {
|
try {
|
||||||
$this->mapFetcher->processFile($mapsDirectory . $this->fileName);
|
$mapFetcher->processFile($mapsDirectory . $this->fileName);
|
||||||
|
$this->authorNick = FORMATTER::stripDirtyCodes($mapFetcher->authorNick);
|
||||||
|
$this->authorEInfo = $mapFetcher->authorEInfo;
|
||||||
|
$this->authorZone = $mapFetcher->authorZone;
|
||||||
|
$this->comment = $mapFetcher->comment;
|
||||||
}
|
}
|
||||||
catch (\Exception $e) {
|
catch (\Exception $e) {
|
||||||
trigger_error($e->getMessage(), E_USER_WARNING);
|
trigger_error($e->getMessage());
|
||||||
}
|
}
|
||||||
$this->authorNick = FORMATTER::stripDirtyCodes($this->mapFetcher->authorNick);
|
|
||||||
$this->authorEInfo = $this->mapFetcher->authorEInfo;
|
|
||||||
$this->authorZone = $this->mapFetcher->authorZone;
|
|
||||||
$this->comment = $this->mapFetcher->comment;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: define timeout if mx is down,todo fetch all map infos at once (maybe way faster)
|
// TODO: define timeout if mx is down,todo fetch all map infos at once (maybe way faster)
|
||||||
|
@ -30,9 +30,7 @@ use MXInfoSearcher;
|
|||||||
*
|
*
|
||||||
* @author steeffeen & kremsy
|
* @author steeffeen & kremsy
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
@ -40,50 +38,38 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
const ACTION_ERASE_MAP = 'MapList.EraseMap';
|
const ACTION_ERASE_MAP = 'MapList.EraseMap';
|
||||||
const ACTION_SWITCH_MAP = 'MapList.SwitchMap';
|
const ACTION_SWITCH_MAP = 'MapList.SwitchMap';
|
||||||
const ACTION_QUEUED_MAP = 'MapList.QueueMap';
|
const ACTION_QUEUED_MAP = 'MapList.QueueMap';
|
||||||
|
|
||||||
const MAX_MAPS_PER_PAGE = 15;
|
const MAX_MAPS_PER_PAGE = 15;
|
||||||
const SHOW_MX_LIST = 1;
|
const SHOW_MX_LIST = 1;
|
||||||
const SHOW_MAP_LIST = 2;
|
const SHOW_MAP_LIST = 2;
|
||||||
|
|
||||||
const DEFAULT_KARMA_PLUGIN = 'KarmaPlugin';
|
const DEFAULT_KARMA_PLUGIN = 'KarmaPlugin';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private properties
|
* Private Properties
|
||||||
*/
|
*/
|
||||||
private $maniaControl = null;
|
private $maniaControl = null;
|
||||||
private $mapListShown = array();
|
private $mapListShown = array();
|
||||||
private $width;
|
|
||||||
private $height;
|
|
||||||
private $quadStyle;
|
|
||||||
private $quadSubstyle;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new server commands instance
|
* Create a new MapList Instance
|
||||||
*
|
*
|
||||||
* @param ManiaControl $maniaControl
|
* @param ManiaControl $maniaControl
|
||||||
*/
|
*/
|
||||||
public function __construct(ManiaControl $maniaControl) {
|
public function __construct(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
|
// Register for Callbacks
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
|
$this->maniaControl->callbackManager->registerCallbackListener(ManialinkManager::CB_MAIN_WINDOW_CLOSED, $this, 'closeWidget');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this,
|
||||||
|
'handleManialinkPageAnswer');
|
||||||
//Update Widget actions
|
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(MapQueue::CB_MAPQUEUE_CHANGED, $this, 'updateWidget');
|
$this->maniaControl->callbackManager->registerCallbackListener(MapQueue::CB_MAPQUEUE_CHANGED, $this, 'updateWidget');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_MAPLIST_UPDATED, $this, 'updateWidget');
|
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_MAPLIST_UPDATED, $this, 'updateWidget');
|
||||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'updateWidget'); //TODO not working yet
|
$this->maniaControl->callbackManager->registerCallbackListener(MapManager::CB_KARMA_UPDATED, $this, 'updateWidget');
|
||||||
//TODO update on Karma Update
|
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_MC_BEGINMAP, $this, 'updateWidget');
|
||||||
|
// TODO not working yet
|
||||||
//settings
|
|
||||||
$this->width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
|
||||||
$this->height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
|
||||||
$this->quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
|
||||||
$this->quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays the Mania Exchange List
|
* Display the Mania Exchange List
|
||||||
*
|
*
|
||||||
* @param array $chatCallback
|
* @param array $chatCallback
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
@ -98,7 +84,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
|
|
||||||
$mapName = '';
|
$mapName = '';
|
||||||
$author = '';
|
$author = '';
|
||||||
$environment = ''; //TODO also get actual environment
|
$environment = '';
|
||||||
|
// TODO also get actual environment
|
||||||
$recent = true;
|
$recent = true;
|
||||||
|
|
||||||
if (count($params) > 1) {
|
if (count($params) > 1) {
|
||||||
@ -108,13 +95,15 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
}
|
}
|
||||||
if (strtolower(substr($param, 0, 5)) == 'auth:') {
|
if (strtolower(substr($param, 0, 5)) == 'auth:') {
|
||||||
$author = substr($param, 5);
|
$author = substr($param, 5);
|
||||||
} elseif(strtolower(substr($param, 0, 4)) == 'env:') {
|
}
|
||||||
|
elseif (strtolower(substr($param, 0, 4)) == 'env:') {
|
||||||
$environment = substr($param, 4);
|
$environment = substr($param, 4);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
if ($mapName == '') {
|
if ($mapName == '') {
|
||||||
$mapName = $param;
|
$mapName = $param;
|
||||||
} else // concatenate words in name
|
}
|
||||||
{
|
else { // concatenate words in name
|
||||||
$mapName .= '%20' . $param;
|
$mapName .= '%20' . $param;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,7 +124,6 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||||
$frame = $this->buildMainFrame();
|
$frame = $this->buildMainFrame();
|
||||||
$maniaLink->add($frame);
|
$maniaLink->add($frame);
|
||||||
@ -145,14 +133,16 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$maniaLink->setScript($script);
|
$maniaLink->setScript($script);
|
||||||
|
|
||||||
// Start offsets
|
// Start offsets
|
||||||
$x = -$this->width / 2;
|
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||||
$y = $this->height / 2;
|
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
||||||
|
$x = -$width / 2;
|
||||||
|
$y = $height / 2;
|
||||||
|
|
||||||
// Headline
|
// Headline
|
||||||
$headFrame = new Frame();
|
$headFrame = new Frame();
|
||||||
$frame->add($headFrame);
|
$frame->add($headFrame);
|
||||||
$headFrame->setY($y - 5);
|
$headFrame->setY($y - 5);
|
||||||
$array = array("Id" => $x + 5, "Name" => $x + 17, "Author" => $x + 65, "Mood" => $x + 100, "Type" => $x + 115);
|
$array = array('Id' => $x + 5, 'Name' => $x + 17, 'Author' => $x + 65, 'Mood' => $x + 100, 'Type' => $x + 115);
|
||||||
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
@ -164,27 +154,26 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$this->maniaControl->manialinkManager->labelLine($mapFrame, $array);
|
$this->maniaControl->manialinkManager->labelLine($mapFrame, $array);
|
||||||
$mapFrame->setY($y);
|
$mapFrame->setY($y);
|
||||||
|
|
||||||
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) { //todoSET as setting who can add maps
|
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||||
//Add-Map-Button
|
// TODO: SET as setting who can add maps Add-Map-Button
|
||||||
$addQuad = new Quad_Icons64x64_1();
|
$addQuad = new Quad_Icons64x64_1();
|
||||||
$mapFrame->add($addQuad);
|
$mapFrame->add($addQuad);
|
||||||
$addQuad->setX($x + 15);
|
$addQuad->setX($x + 15);
|
||||||
$addQuad->setZ(-0.1);
|
$addQuad->setZ(-0.1);
|
||||||
$addQuad->setSubStyle($addQuad::SUBSTYLE_Add);
|
$addQuad->setSubStyle($addQuad::SUBSTYLE_Add);
|
||||||
$addQuad->setSize(4, 4);
|
$addQuad->setSize(4, 4);
|
||||||
$addQuad->setAction(self::ACTION_ADD_MAP . "." . $map->id);
|
$addQuad->setAction(self::ACTION_ADD_MAP . '.' . $map->id);
|
||||||
|
|
||||||
// Description Label
|
// Description Label
|
||||||
$descriptionLabel = new Label();
|
$descriptionLabel = new Label();
|
||||||
$frame->add($descriptionLabel);
|
$frame->add($descriptionLabel);
|
||||||
$descriptionLabel->setAlign(Control::LEFT, Control::TOP);
|
$descriptionLabel->setAlign(Control::LEFT, Control::TOP);
|
||||||
$descriptionLabel->setPosition($x + 10, -$this->height / 2 + 5);
|
$descriptionLabel->setPosition($x + 10, -$height / 2 + 5);
|
||||||
$descriptionLabel->setSize($this->width * 0.7, 4);
|
$descriptionLabel->setSize($width * 0.7, 4);
|
||||||
$descriptionLabel->setTextSize(2);
|
$descriptionLabel->setTextSize(2);
|
||||||
$descriptionLabel->setVisible(false);
|
$descriptionLabel->setVisible(false);
|
||||||
$descriptionLabel->setText("Add-Map: {$map->name}");
|
$descriptionLabel->setText('Add-Map: $<' . $map->name . '$>');
|
||||||
$script->addTooltip($addQuad, $descriptionLabel);
|
$script->addTooltip($addQuad, $descriptionLabel);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$y -= 4;
|
$y -= 4;
|
||||||
@ -206,26 +195,30 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
* @return Frame $frame
|
* @return Frame $frame
|
||||||
*/
|
*/
|
||||||
public function buildMainFrame() {
|
public function buildMainFrame() {
|
||||||
|
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||||
|
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
||||||
|
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
||||||
|
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
||||||
|
|
||||||
// mainframe
|
// mainframe
|
||||||
$frame = new Frame();
|
$frame = new Frame();
|
||||||
$frame->setSize($this->width, $this->height);
|
$frame->setSize($width, $height);
|
||||||
$frame->setPosition(0, 0);
|
$frame->setPosition(0, 0);
|
||||||
|
|
||||||
// Background Quad
|
// Background Quad
|
||||||
$backgroundQuad = new Quad();
|
$backgroundQuad = new Quad();
|
||||||
$frame->add($backgroundQuad);
|
$frame->add($backgroundQuad);
|
||||||
$backgroundQuad->setSize($this->width, $this->height);
|
$backgroundQuad->setSize($width, $height);
|
||||||
$backgroundQuad->setStyles($this->quadStyle, $this->quadSubstyle);
|
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||||
|
|
||||||
// Add Close Quad (X)
|
// Add Close Quad (X)
|
||||||
$closeQuad = new Quad_Icons64x64_1();
|
$closeQuad = new Quad_Icons64x64_1();
|
||||||
$frame->add($closeQuad);
|
$frame->add($closeQuad);
|
||||||
$closeQuad->setPosition($this->width * 0.483, $this->height * 0.467, 3);
|
$closeQuad->setPosition($width * 0.483, $height * 0.467, 3);
|
||||||
$closeQuad->setSize(6, 6);
|
$closeQuad->setSize(6, 6);
|
||||||
$closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace);
|
$closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace);
|
||||||
$closeQuad->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
|
$closeQuad->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
|
||||||
|
|
||||||
|
|
||||||
return $frame;
|
return $frame;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,6 +228,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
*/
|
*/
|
||||||
public function showMapList(Player $player) {
|
public function showMapList(Player $player) {
|
||||||
|
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||||
|
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
||||||
|
|
||||||
// Get Maplist
|
// Get Maplist
|
||||||
$mapList = $this->maniaControl->mapManager->getMapList();
|
$mapList = $this->maniaControl->mapManager->getMapList();
|
||||||
@ -249,7 +244,6 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$script = new Script();
|
$script = new Script();
|
||||||
$maniaLink->setScript($script);
|
$maniaLink->setScript($script);
|
||||||
|
|
||||||
|
|
||||||
// Pagers
|
// Pagers
|
||||||
|
|
||||||
// Config
|
// Config
|
||||||
@ -259,24 +253,24 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
if (count($mapList) > self::MAX_MAPS_PER_PAGE) {
|
if (count($mapList) > self::MAX_MAPS_PER_PAGE) {
|
||||||
$pagerPrev = new Quad_Icons64x64_1();
|
$pagerPrev = new Quad_Icons64x64_1();
|
||||||
$frame->add($pagerPrev);
|
$frame->add($pagerPrev);
|
||||||
$pagerPrev->setPosition($this->width * 0.42, $this->height * -0.44, 2);
|
$pagerPrev->setPosition($width * 0.42, $height * -0.44, 2);
|
||||||
$pagerPrev->setSize($pagerSize, $pagerSize);
|
$pagerPrev->setSize($pagerSize, $pagerSize);
|
||||||
$pagerPrev->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowPrev);
|
$pagerPrev->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowPrev);
|
||||||
|
|
||||||
$pagerNext = new Quad_Icons64x64_1();
|
$pagerNext = new Quad_Icons64x64_1();
|
||||||
$frame->add($pagerNext);
|
$frame->add($pagerNext);
|
||||||
$pagerNext->setPosition($this->width * 0.45, $this->height * -0.44, 2);
|
$pagerNext->setPosition($width * 0.45, $height * -0.44, 2);
|
||||||
$pagerNext->setSize($pagerSize, $pagerSize);
|
$pagerNext->setSize($pagerSize, $pagerSize);
|
||||||
$pagerNext->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowNext);
|
$pagerNext->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_ArrowNext);
|
||||||
|
|
||||||
$script->addPager($pagerPrev, -1, $pagesId);
|
$script->addPager($pagerPrev, -1, $pagesId);
|
||||||
$script->addPager($pagerNext, 1, $pagesId);
|
$script->addPager($pagerNext, 1, $pagesId);
|
||||||
|
|
||||||
$pageCountLabel = new Label();
|
$pageCountLabel = new Label_Text();
|
||||||
$frame->add($pageCountLabel);
|
$frame->add($pageCountLabel);
|
||||||
$pageCountLabel->setHAlign(Control::RIGHT);
|
$pageCountLabel->setHAlign(Control::RIGHT);
|
||||||
$pageCountLabel->setPosition($this->width * 0.40, $this->height * -0.44, 1);
|
$pageCountLabel->setPosition($width * 0.40, $height * -0.44, 1);
|
||||||
$pageCountLabel->setStyle('TextTitle1');
|
$pageCountLabel->setStyle($pageCountLabel::STYLE_TextTitle1);
|
||||||
$pageCountLabel->setTextSize(1.3);
|
$pageCountLabel->setTextSize(1.3);
|
||||||
$script->addPageLabel($pageCountLabel, $pagesId);
|
$script->addPageLabel($pageCountLabel, $pagesId);
|
||||||
}
|
}
|
||||||
@ -284,27 +278,34 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
// Headline
|
// Headline
|
||||||
$headFrame = new Frame();
|
$headFrame = new Frame();
|
||||||
$frame->add($headFrame);
|
$frame->add($headFrame);
|
||||||
$headFrame->setY($this->height / 2 - 5);
|
$headFrame->setY($height / 2 - 5);
|
||||||
$x = -$this->width / 2;
|
$x = -$width / 2;
|
||||||
$array = array("Id" => $x + 5, "Mx ID" => $x + 10, "MapName" => $x + 20, "Author" => $x + 68, "Karma" => $x + 115, "Actions" => $this->width / 2 - 15);
|
$array = array('Id' => $x + 5, 'Mx Id' => $x + 10, 'Map Name' => $x + 20, 'Author' => $x + 68, 'Karma' => $x + 115,
|
||||||
|
'Actions' => $width / 2 - 15);
|
||||||
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
||||||
|
|
||||||
// Predefine Description Label
|
// Predefine Description Label
|
||||||
$preDefinedDescriptionLabel = new Label();
|
$preDefinedDescriptionLabel = new Label();
|
||||||
$preDefinedDescriptionLabel->setAlign(Control::LEFT, Control::TOP);
|
$preDefinedDescriptionLabel->setAlign(Control::LEFT, Control::TOP);
|
||||||
$preDefinedDescriptionLabel->setPosition($x + 10, -$this->height / 2 + 5);
|
$preDefinedDescriptionLabel->setPosition($x + 10, -$height / 2 + 5);
|
||||||
$preDefinedDescriptionLabel->setSize($this->width * 0.7, 4);
|
$preDefinedDescriptionLabel->setSize($width * 0.7, 4);
|
||||||
$preDefinedDescriptionLabel->setTextSize(2);
|
$preDefinedDescriptionLabel->setTextSize(2);
|
||||||
$preDefinedDescriptionLabel->setVisible(false);
|
$preDefinedDescriptionLabel->setVisible(false);
|
||||||
|
|
||||||
$queuedMaps = $this->maniaControl->mapManager->mapQueue->getQueuedMapsRanking();
|
$queuedMaps = $this->maniaControl->mapManager->mapQueue->getQueuedMapsRanking();
|
||||||
/** @var KarmaPlugin $karmaPlugin */
|
/**
|
||||||
|
*
|
||||||
|
* @var KarmaPlugin $karmaPlugin
|
||||||
|
*/
|
||||||
$karmaPlugin = $this->maniaControl->pluginManager->getPlugin(self::DEFAULT_KARMA_PLUGIN);
|
$karmaPlugin = $this->maniaControl->pluginManager->getPlugin(self::DEFAULT_KARMA_PLUGIN);
|
||||||
|
|
||||||
$id = 1;
|
$id = 1;
|
||||||
$y = $this->height / 2 - 10;
|
$y = $height / 2 - 10;
|
||||||
$pageFrames = array();
|
$pageFrames = array();
|
||||||
/** @var Map $map */
|
/**
|
||||||
|
*
|
||||||
|
* @var Map $map
|
||||||
|
*/
|
||||||
foreach ($mapList as $map) {
|
foreach ($mapList as $map) {
|
||||||
|
|
||||||
if (!isset($pageFrame)) {
|
if (!isset($pageFrame)) {
|
||||||
@ -314,11 +315,10 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$pageFrame->setVisible(false);
|
$pageFrame->setVisible(false);
|
||||||
}
|
}
|
||||||
array_push($pageFrames, $pageFrame);
|
array_push($pageFrames, $pageFrame);
|
||||||
$y = $this->height / 2 - 10;
|
$y = $height / 2 - 10;
|
||||||
$script->addPage($pageFrame, count($pageFrames), $pagesId);
|
$script->addPage($pageFrame, count($pageFrames), $pagesId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Map Frame
|
// Map Frame
|
||||||
$mapFrame = new Frame();
|
$mapFrame = new Frame();
|
||||||
$pageFrame->add($mapFrame);
|
$pageFrame->add($mapFrame);
|
||||||
@ -328,12 +328,11 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
if ($id % 2 != 0) {
|
if ($id % 2 != 0) {
|
||||||
$lineQuad = new Quad_BgsPlayerCard();
|
$lineQuad = new Quad_BgsPlayerCard();
|
||||||
$mapFrame->add($lineQuad);
|
$mapFrame->add($lineQuad);
|
||||||
$lineQuad->setSize($this->width, 4);
|
$lineQuad->setSize($width, 4);
|
||||||
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
|
$lineQuad->setSubStyle($lineQuad::SUBSTYLE_BgPlayerCardBig);
|
||||||
$lineQuad->setZ(0.001);
|
$lineQuad->setZ(0.001);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($this->maniaControl->mapManager->getCurrentMap() === $map) {
|
if ($this->maniaControl->mapManager->getCurrentMap() === $map) {
|
||||||
$currentQuad = new Quad_Icons64x64_1();
|
$currentQuad = new Quad_Icons64x64_1();
|
||||||
$mapFrame->add($currentQuad);
|
$mapFrame->add($currentQuad);
|
||||||
@ -362,26 +361,27 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
if (isset($queuedMaps[$map->uid])) {
|
if (isset($queuedMaps[$map->uid])) {
|
||||||
$label = new Label_Text();
|
$label = new Label_Text();
|
||||||
$mapFrame->add($label);
|
$mapFrame->add($label);
|
||||||
$label->setX($this->width / 2 - 15);
|
$label->setX($width / 2 - 15);
|
||||||
$label->setAlign(Control::CENTER, Control::CENTER);
|
$label->setAlign(Control::CENTER, Control::CENTER);
|
||||||
$label->setZ(0.2);
|
$label->setZ(0.2);
|
||||||
$label->setTextSize(1.5);
|
$label->setTextSize(1.5);
|
||||||
$label->setText($queuedMaps[$map->uid]);
|
$label->setText($queuedMaps[$map->uid]);
|
||||||
$label->setTextColor("FFF");
|
$label->setTextColor('fff');
|
||||||
$descriptionLabel->setText("{$map->name} \$zis on Map-Queue Position: {$queuedMaps[$map->uid]}");
|
$descriptionLabel->setText('$<' . $map->name . '$> is on Map-Queue Position: ' . $queuedMaps[$map->uid]);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
// Map-Queue-Map-Button
|
// Map-Queue-Map-Button
|
||||||
$buttLabel = new Label_Button();
|
$queueLabel = new Label_Button();
|
||||||
$mapFrame->add($buttLabel);
|
$mapFrame->add($queueLabel);
|
||||||
$buttLabel->setX($this->width / 2 - 15);
|
$queueLabel->setX($width / 2 - 15);
|
||||||
$buttLabel->setZ(0.2);
|
$queueLabel->setZ(0.2);
|
||||||
$buttLabel->setSize(3, 3);
|
$queueLabel->setSize(3, 3);
|
||||||
$buttLabel->setAction(self::ACTION_QUEUED_MAP . "." . $map->uid);
|
$queueLabel->setAction(self::ACTION_QUEUED_MAP . '.' . $map->uid);
|
||||||
$buttLabel->setText("+");
|
$queueLabel->setText('+');
|
||||||
$buttLabel->setTextColor("09F");
|
$queueLabel->setTextColor('09f');
|
||||||
|
|
||||||
$descriptionLabel->setText("Add Map to the Map Queue: {$map->name}");
|
$descriptionLabel->setText('Add Map to the Map Queue: $<' . $map->name . '$>');
|
||||||
$script->addTooltip($buttLabel, $descriptionLabel);
|
$script->addTooltip($queueLabel, $descriptionLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_ADMIN)) {
|
||||||
@ -389,12 +389,12 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
// erase map quad
|
// erase map quad
|
||||||
$eraseLabel = new Label_Button();
|
$eraseLabel = new Label_Button();
|
||||||
$mapFrame->add($eraseLabel);
|
$mapFrame->add($eraseLabel);
|
||||||
$eraseLabel->setX($this->width / 2 - 5);
|
$eraseLabel->setX($width / 2 - 5);
|
||||||
$eraseLabel->setZ(0.2);
|
$eraseLabel->setZ(0.2);
|
||||||
$eraseLabel->setSize(3, 3);
|
$eraseLabel->setSize(3, 3);
|
||||||
$eraseLabel->setTextSize(1);
|
$eraseLabel->setTextSize(1);
|
||||||
$eraseLabel->setText("x");
|
$eraseLabel->setText('x');
|
||||||
$eraseLabel->setTextColor("A00");
|
$eraseLabel->setTextColor('a00');
|
||||||
|
|
||||||
$confirmFrame = $this->buildConfirmFrame($maniaLink, $y, $id, $map->uid);
|
$confirmFrame = $this->buildConfirmFrame($maniaLink, $y, $id, $map->uid);
|
||||||
$script->addToggle($eraseLabel, $confirmFrame);
|
$script->addToggle($eraseLabel, $confirmFrame);
|
||||||
@ -402,33 +402,33 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
// Description Label
|
// Description Label
|
||||||
$descriptionLabel = clone $preDefinedDescriptionLabel;
|
$descriptionLabel = clone $preDefinedDescriptionLabel;
|
||||||
$frame->add($descriptionLabel);
|
$frame->add($descriptionLabel);
|
||||||
$descriptionLabel->setText("Remove Map: {$map->name}");
|
$descriptionLabel->setText('Remove Map: $<' . $map->name . '$>');
|
||||||
$script->addTooltip($eraseLabel, $descriptionLabel);
|
$script->addTooltip($eraseLabel, $descriptionLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||||
// TODO SET as setting who can add maps
|
// TODO SET as setting who can add maps
|
||||||
//switch to map quad
|
// Switch to map
|
||||||
$switchToQuad = new Label_Button();
|
$switchLabel = new Label_Button();
|
||||||
$mapFrame->add($switchToQuad);
|
$mapFrame->add($switchLabel);
|
||||||
$switchToQuad->setX($this->width / 2 - 10);
|
$switchLabel->setX($width / 2 - 10);
|
||||||
$switchToQuad->setZ(0.2);
|
$switchLabel->setZ(0.2);
|
||||||
$switchToQuad->setSize(3, 3);
|
$switchLabel->setSize(3, 3);
|
||||||
$switchToQuad->setTextSize(2);
|
$switchLabel->setTextSize(2);
|
||||||
$switchToQuad->setText("»");
|
$switchLabel->setText('»');
|
||||||
$switchToQuad->setTextColor("0F0");
|
$switchLabel->setTextColor('0f0');
|
||||||
|
|
||||||
$confirmFrame = $this->buildConfirmFrame($maniaLink, $y, $id);
|
$confirmFrame = $this->buildConfirmFrame($maniaLink, $y, $id);
|
||||||
$script->addToggle($switchToQuad, $confirmFrame);
|
$script->addToggle($switchLabel, $confirmFrame);
|
||||||
|
|
||||||
$descriptionLabel = clone $preDefinedDescriptionLabel;
|
$descriptionLabel = clone $preDefinedDescriptionLabel;
|
||||||
$frame->add($descriptionLabel);
|
$frame->add($descriptionLabel);
|
||||||
$descriptionLabel->setText("Switch Directly to Map: {$map->name}");
|
$descriptionLabel->setText('Switch Directly to Map: $<' . $map->name . '$>');
|
||||||
$script->addTooltip($switchToQuad, $descriptionLabel);
|
$script->addTooltip($switchLabel, $descriptionLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Display Karma bar
|
// Display Karma bar
|
||||||
if($karmaPlugin != null) {
|
if ($karmaPlugin) {
|
||||||
$karma = $karmaPlugin->getMapKarma($map);
|
$karma = $karmaPlugin->getMapKarma($map);
|
||||||
$votes = $karmaPlugin->getMapVotes($map);
|
$votes = $karmaPlugin->getMapVotes($map);
|
||||||
if (is_numeric($karma)) {
|
if (is_numeric($karma)) {
|
||||||
@ -449,27 +449,22 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$karmaLabel->setX($x + 120);
|
$karmaLabel->setX($x + 120);
|
||||||
$karmaLabel->setSize(20 * 0.9, 5);
|
$karmaLabel->setSize(20 * 0.9, 5);
|
||||||
$karmaLabel->setTextSize(0.9);
|
$karmaLabel->setTextSize(0.9);
|
||||||
$karmaLabel->setTextColor("000");
|
$karmaLabel->setTextColor('000');
|
||||||
$karmaLabel->setAlign(Control::CENTER, Control::CENTER);
|
$karmaLabel->setAlign(Control::CENTER, Control::CENTER);
|
||||||
$karmaLabel->setText(' ' . round($karma * 100.) . '% (' . $votes['count'] . ')');
|
$karmaLabel->setText(' ' . round($karma * 100.) . '% (' . $votes['count'] . ')');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$y -= 4;
|
$y -= 4;
|
||||||
|
|
||||||
if ($id % self::MAX_MAPS_PER_PAGE == 0) {
|
if ($id % self::MAX_MAPS_PER_PAGE == 0) {
|
||||||
unset($pageFrame);
|
unset($pageFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
$id++;
|
$id++;
|
||||||
}
|
}
|
||||||
// TODO page 0 bug?
|
// TODO page 0 bug?
|
||||||
//render and display xml
|
|
||||||
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player);
|
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds the confirmation frame
|
* Builds the confirmation frame
|
||||||
*
|
*
|
||||||
@ -480,17 +475,19 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
* @return Frame
|
* @return Frame
|
||||||
*/
|
*/
|
||||||
public function buildConfirmFrame(Manialink $maniaLink, $y, $id, $mapUid = false) {
|
public function buildConfirmFrame(Manialink $maniaLink, $y, $id, $mapUid = false) {
|
||||||
|
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||||
|
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
||||||
|
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
||||||
|
|
||||||
$confirmFrame = new Frame();
|
$confirmFrame = new Frame();
|
||||||
$maniaLink->add($confirmFrame);
|
$maniaLink->add($confirmFrame);
|
||||||
$confirmFrame->setPosition($this->width / 2 + 6, $y);
|
$confirmFrame->setPosition($width / 2 + 6, $y);
|
||||||
|
|
||||||
$quad = new Quad();
|
$quad = new Quad();
|
||||||
$confirmFrame->add($quad);
|
$confirmFrame->add($quad);
|
||||||
$quad->setStyles($this->quadStyle, $this->quadSubstyle);
|
$quad->setStyles($quadStyle, $quadSubstyle);
|
||||||
$quad->setSize(12, 4);
|
$quad->setSize(12, 4);
|
||||||
|
|
||||||
|
|
||||||
$quad = new Quad_BgsPlayerCard();
|
$quad = new Quad_BgsPlayerCard();
|
||||||
$confirmFrame->add($quad);
|
$confirmFrame->add($quad);
|
||||||
$quad->setSubStyle($quad::SUBSTYLE_BgCardSystem);
|
$quad->setSubStyle($quad::SUBSTYLE_BgCardSystem);
|
||||||
@ -499,7 +496,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$label = new Label_Button();
|
$label = new Label_Button();
|
||||||
$confirmFrame->add($label);
|
$confirmFrame->add($label);
|
||||||
$label->setAlign(Control::CENTER, Control::CENTER);
|
$label->setAlign(Control::CENTER, Control::CENTER);
|
||||||
$label->setText("Sure");
|
$label->setText('Sure?');
|
||||||
$label->setTextSize(1);
|
$label->setTextSize(1);
|
||||||
$label->setScale(0.90);
|
$label->setScale(0.90);
|
||||||
$label->setX(-1.3);
|
$label->setX(-1.3);
|
||||||
@ -512,15 +509,16 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$buttLabel->setAlign(Control::CENTER, Control::CENTER);
|
$buttLabel->setAlign(Control::CENTER, Control::CENTER);
|
||||||
|
|
||||||
if (!$mapUid) {
|
if (!$mapUid) {
|
||||||
$quad->setAction(self::ACTION_SWITCH_MAP . "." . ($id - 1));
|
$quad->setAction(self::ACTION_SWITCH_MAP . '.' . ($id - 1));
|
||||||
$buttLabel->setText("»");
|
$buttLabel->setText('»');
|
||||||
$buttLabel->setTextColor("0F0");
|
$buttLabel->setTextColor('0f0');
|
||||||
$buttLabel->setTextSize(2);
|
$buttLabel->setTextSize(2);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$buttLabel->setTextSize(1);
|
$buttLabel->setTextSize(1);
|
||||||
$buttLabel->setText("x");
|
$buttLabel->setText('x');
|
||||||
$buttLabel->setTextColor("A00");
|
$buttLabel->setTextColor('a00');
|
||||||
$quad->setAction(self::ACTION_ERASE_MAP . "." . ($id - 1) . "." . $mapUid);
|
$quad->setAction(self::ACTION_ERASE_MAP . '.' . ($id - 1) . '.' . $mapUid);
|
||||||
}
|
}
|
||||||
return $confirmFrame;
|
return $confirmFrame;
|
||||||
}
|
}
|
||||||
@ -538,8 +536,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
/**
|
/**
|
||||||
* Closes the widget
|
* Closes the widget
|
||||||
*
|
*
|
||||||
* @param \ManiaControl\Players\Player $player
|
* @param Player $player
|
||||||
* @internal param $login
|
|
||||||
*/
|
*/
|
||||||
public function playerCloseWidget(Player $player) {
|
public function playerCloseWidget(Player $player) {
|
||||||
unset($this->mapListShown[$player->login]);
|
unset($this->mapListShown[$player->login]);
|
||||||
@ -547,32 +544,36 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Handle ManialinkPageAnswer Callback
|
||||||
|
*
|
||||||
* @param array $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
public function handleManialinkPageAnswer(array $callback) {
|
public function handleManialinkPageAnswer(array $callback) {
|
||||||
$actionId = $callback[1][2];
|
$actionId = $callback[1][2];
|
||||||
$actionArray = explode(".", $actionId);
|
$actionArray = explode('.', $actionId);
|
||||||
if(count($actionArray) <= 2) {
|
if (count($actionArray) <= 2) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$action = $actionArray[0] . "." . $actionArray[1];
|
$action = $actionArray[0] . '.' . $actionArray[1];
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($callback[1][1]);
|
$login = $callback[1][1];
|
||||||
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
|
$mapId = (int) $actionArray[2];
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case self::ACTION_ADD_MAP:
|
case self::ACTION_ADD_MAP:
|
||||||
$this->maniaControl->mapManager->addMapFromMx(intval($actionArray[2]), $callback[1][1]);
|
$this->maniaControl->mapManager->addMapFromMx($mapId, $player->login);
|
||||||
break;
|
break;
|
||||||
case self::ACTION_ERASE_MAP:
|
case self::ACTION_ERASE_MAP:
|
||||||
$this->maniaControl->mapManager->eraseMap(intval($actionArray[2]), $actionArray[3]);
|
$this->maniaControl->mapManager->eraseMap($mapId, $actionArray[3]);
|
||||||
$this->showMapList($player);
|
$this->showMapList($player);
|
||||||
break;
|
break;
|
||||||
case self::ACTION_SWITCH_MAP:
|
case self::ACTION_SWITCH_MAP:
|
||||||
$this->maniaControl->client->query('JumpToMapIndex', intval($actionArray[2]));
|
$this->maniaControl->client->query('JumpToMapIndex', $mapId);
|
||||||
$mapList = $this->maniaControl->mapManager->getMapList();
|
$mapList = $this->maniaControl->mapManager->getMapList();
|
||||||
|
$map = $mapList[$mapId];
|
||||||
|
|
||||||
$this->maniaControl->chat->sendSuccess('Map switched to $z$<' . $mapList[$actionArray[2]]->name . '$>!'); //TODO specified message, who done it?
|
$message = '$<' . $player->nickname . '$> skipped to Map $z$<' . $map->name . '$>!';
|
||||||
$this->maniaControl->log(Formatter::stripCodes('Skipped to $z$<' . $mapList[$actionArray[2]]->name . '$>!'));
|
$this->maniaControl->chat->sendSuccess($message);
|
||||||
|
$this->maniaControl->log($message, true);
|
||||||
|
|
||||||
$this->playerCloseWidget($player);
|
$this->playerCloseWidget($player);
|
||||||
break;
|
break;
|
||||||
@ -580,11 +581,10 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
$this->maniaControl->mapManager->mapQueue->addMapToMapQueue($callback[1][1], $actionArray[2]);
|
$this->maniaControl->mapManager->mapQueue->addMapToMapQueue($callback[1][1], $actionArray[2]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reopen the widget on Map Begin, MapListChanged
|
* Reopen the widget on Map Begin, MapListChanged, etc.
|
||||||
*
|
*
|
||||||
* @param array $callback
|
* @param array $callback
|
||||||
*/
|
*/
|
||||||
@ -595,10 +595,12 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
|||||||
if ($player != null) {
|
if ($player != null) {
|
||||||
if ($shown == self::SHOW_MX_LIST) {
|
if ($shown == self::SHOW_MX_LIST) {
|
||||||
// TODO
|
// TODO
|
||||||
} else if($shown == self::SHOW_MAP_LIST) {
|
}
|
||||||
|
else if ($shown == self::SHOW_MAP_LIST) {
|
||||||
$this->showMapList($player);
|
$this->showMapList($player);
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
unset($this->mapListShown[$login]);
|
unset($this->mapListShown[$login]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ class MapManager implements CallbackListener {
|
|||||||
*/
|
*/
|
||||||
const TABLE_MAPS = 'mc_maps';
|
const TABLE_MAPS = 'mc_maps';
|
||||||
const CB_MAPLIST_UPDATED = 'MapManager.MapListUpdated';
|
const CB_MAPLIST_UPDATED = 'MapManager.MapListUpdated';
|
||||||
|
const CB_KARMA_UPDATED = 'MapManager.KarmaUpdated';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private Properties
|
* Private Properties
|
||||||
|
Loading…
Reference in New Issue
Block a user