fixes
This commit is contained in:
parent
7145cd267b
commit
c0e2ed7370
@ -27,11 +27,11 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const MLID_MENU = 'ActionsMenu.MLID';
|
||||
const SETTING_MENU_POSX = 'Menu Position: X';
|
||||
const SETTING_MENU_POSY = 'Menu Position: Y';
|
||||
const SETTING_MENU_ITEMSIZE = 'Menu Item Size';
|
||||
const ACTION_OPEN_ADMIN_MENU = 'ActionsMenu.OpenAdminMenu';
|
||||
const MLID_MENU = 'ActionsMenu.MLID';
|
||||
const SETTING_MENU_POSX = 'Menu Position: X';
|
||||
const SETTING_MENU_POSY = 'Menu Position: Y';
|
||||
const SETTING_MENU_ITEMSIZE = 'Menu Item Size';
|
||||
const ACTION_OPEN_ADMIN_MENU = 'ActionsMenu.OpenAdminMenu';
|
||||
const ACTION_OPEN_PLAYER_MENU = 'ActionsMenu.OpenPlayerMenu';
|
||||
|
||||
/*
|
||||
@ -65,14 +65,15 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
* Add a new Menu Item
|
||||
*
|
||||
* @param Control $control
|
||||
* @param bool $playerAction
|
||||
* @param int $order
|
||||
* @param string $description
|
||||
* @param bool $playerAction
|
||||
* @param int $order
|
||||
* @param string $description
|
||||
*/
|
||||
public function addMenuItem(Control $control, $playerAction = true, $order = 0, $description = null) {
|
||||
if($playerAction) {
|
||||
if ($playerAction) {
|
||||
$this->addPlayerMenuItem($control, $order, $description);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$this->addAdminMenuItem($control, $order, $description);
|
||||
}
|
||||
}
|
||||
@ -80,13 +81,14 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
/**
|
||||
* Removes a Menu Item
|
||||
*
|
||||
* @param $order
|
||||
* @param $order
|
||||
* @param bool $playerAction
|
||||
*/
|
||||
public function removeMenuItem($order, $playerAction = true) {
|
||||
if($playerAction) {
|
||||
if ($playerAction) {
|
||||
unset($this->playerMenuItems[$order]);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
unset($this->adminMenuItems[$order]);
|
||||
}
|
||||
$this->rebuildAndShowMenu();
|
||||
@ -96,11 +98,11 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
* Add a new Player Menu Item
|
||||
*
|
||||
* @param Control $control
|
||||
* @param int $order
|
||||
* @param string $description
|
||||
* @param int $order
|
||||
* @param string $description
|
||||
*/
|
||||
public function addPlayerMenuItem(Control $control, $order = 0, $description = null) {
|
||||
if(!isset($this->playerMenuItems[$order])) {
|
||||
if (!isset($this->playerMenuItems[$order])) {
|
||||
$this->playerMenuItems[$order] = array();
|
||||
}
|
||||
array_push($this->playerMenuItems[$order], array($control, $description));
|
||||
@ -112,11 +114,11 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
* Add a new Admin Menu Item
|
||||
*
|
||||
* @param Control $control
|
||||
* @param int $order
|
||||
* @param string $description
|
||||
* @param int $order
|
||||
* @param string $description
|
||||
*/
|
||||
public function addAdminMenuItem(Control $control, $order = 0, $description = null) {
|
||||
if(!isset($this->adminMenuItems[$order])) {
|
||||
if (!isset($this->adminMenuItems[$order])) {
|
||||
$this->adminMenuItems[$order] = array();
|
||||
}
|
||||
array_push($this->adminMenuItems[$order], array($control, $description));
|
||||
@ -136,12 +138,12 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
* Build and show the menus to everyone (if a menu get made after the init)
|
||||
*/
|
||||
public function rebuildAndShowMenu() {
|
||||
if(!$this->initCompleted) {
|
||||
if (!$this->initCompleted) {
|
||||
return;
|
||||
}
|
||||
$players = $this->maniaControl->playerManager->getPlayers();
|
||||
foreach($players as $player) {
|
||||
$manialink = $this->buildMenuIconsManialink($player);
|
||||
foreach ($players as $player) {
|
||||
$manialink = $this->buildMenuIconsManialink($player);
|
||||
$this->maniaControl->manialinkManager->sendManialink($manialink, $player->login);
|
||||
}
|
||||
}
|
||||
@ -163,28 +165,27 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
* @return ManiaLink
|
||||
*/
|
||||
private function buildMenuIconsManialink(Player $player) {
|
||||
$posX = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_POSX);
|
||||
$posY = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_POSY);
|
||||
$itemSize = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_ITEMSIZE);
|
||||
$shootManiaOffset = $this->maniaControl->manialinkManager->styleManager->getDefaultIconOffsetSM();
|
||||
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
|
||||
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
|
||||
$posX = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_POSX);
|
||||
$posY = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_POSY);
|
||||
$itemSize = $this->maniaControl->settingManager->getSetting($this, self::SETTING_MENU_ITEMSIZE);
|
||||
$shootManiaOffset = $this->maniaControl->manialinkManager->styleManager->getDefaultIconOffsetSM();
|
||||
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadStyle();
|
||||
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultQuadSubstyle();
|
||||
$itemMarginFactorX = 1.3;
|
||||
$itemMarginFactorY = 1.2;
|
||||
|
||||
//If game is shootmania lower the icons position by 20
|
||||
// If game is shootmania lower the icons position by 20
|
||||
if ($this->maniaControl->mapManager->getCurrentMap()->getGame() == 'sm') {
|
||||
$posY -= $shootManiaOffset;
|
||||
}
|
||||
|
||||
$manialink = new ManiaLink(self::MLID_MENU);
|
||||
$script = new Script();
|
||||
$manialink->setScript($script);
|
||||
$script = $manialink->getScript();
|
||||
|
||||
/*
|
||||
* Admin Menu
|
||||
*/
|
||||
if($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||
if ($this->maniaControl->authenticationManager->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||
// Admin Menu Icon Frame
|
||||
$iconFrame = new Frame();
|
||||
$manialink->add($iconFrame);
|
||||
@ -226,26 +227,23 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||
$backgroundQuad->setSize(count($this->adminMenuItems) * $itemSize * 1.15 + 2, $itemSize * $itemMarginFactorY);
|
||||
|
||||
$itemQuad->addToggleFeature($popoutFrame);
|
||||
$itemQuad->addToggleFeature($popoutFrame);
|
||||
|
||||
// Add items
|
||||
$x = -1;
|
||||
foreach($this->adminMenuItems as $menuItems) {
|
||||
foreach($menuItems as $menuItem) {
|
||||
foreach ($this->adminMenuItems as $menuItems) {
|
||||
foreach ($menuItems as $menuItem) {
|
||||
$menuQuad = $menuItem[0];
|
||||
/**
|
||||
*
|
||||
* @var Quad $menuQuad
|
||||
*/
|
||||
/** @var Quad $menuQuad */
|
||||
$popoutFrame->add($menuQuad);
|
||||
$menuQuad->setSize($itemSize, $itemSize);
|
||||
$menuQuad->setX($x);
|
||||
$menuQuad->setHAlign(Control::RIGHT);
|
||||
$x -= $itemSize * 1.05;
|
||||
|
||||
if($menuItem[1]) {
|
||||
if ($menuItem[1]) {
|
||||
$description = '$s' . $menuItem[1];
|
||||
$menuQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
$menuQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -294,30 +292,30 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
$backgroundQuad->setHAlign(Control::RIGHT);
|
||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||
$backgroundQuad->setSize(count($this->playerMenuItems) * $itemSize * 1.15 + 2, $itemSize * $itemMarginFactorY);
|
||||
$itemQuad->addToggleFeature($popoutFrame);
|
||||
|
||||
$itemQuad->addToggleFeature($popoutFrame);
|
||||
|
||||
// Add items
|
||||
$x = -1;
|
||||
foreach($this->playerMenuItems as $menuItems) {
|
||||
foreach($menuItems as $menuItem) {
|
||||
foreach ($this->playerMenuItems as $menuItems) {
|
||||
foreach ($menuItems as $menuItem) {
|
||||
$menuQuad = $menuItem[0];
|
||||
/**
|
||||
*
|
||||
* @var Quad $menuQuad
|
||||
*/
|
||||
/** @var Quad $menuQuad */
|
||||
$popoutFrame->add($menuQuad);
|
||||
$menuQuad->setSize($itemSize, $itemSize);
|
||||
$menuQuad->setX($x);
|
||||
$menuQuad->setHAlign(Control::RIGHT);
|
||||
$x -= $itemSize * 1.05;
|
||||
|
||||
if($menuItem[1]) {
|
||||
if ($menuItem[1]) {
|
||||
$description = '$s' . $menuItem[1];
|
||||
$menuQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
$menuQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if ($player->login === 'steeffeen') var_dump((string)$manialink);
|
||||
|
||||
return $manialink;
|
||||
}
|
||||
}
|
||||
|
@ -10,8 +10,4 @@ namespace ManiaControl\Callbacks;
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
interface CallbackListener {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const CALLBACKLISTENER_INTERFACE = __CLASS__;
|
||||
}
|
||||
|
@ -10,8 +10,4 @@ namespace ManiaControl\Callbacks;
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
interface TimerListener {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const TIMERLISTENER_INTERFACE = __CLASS__;
|
||||
}
|
||||
|
@ -323,6 +323,9 @@ Void {$updatePageFunction}(Text _PagingId, Text _PageLabelId, Integer _BrowseAct
|
||||
* @return string
|
||||
*/
|
||||
protected function getPageButtonsArrayText() {
|
||||
if (!$this->buttons) {
|
||||
return Builder::getArray(array("" => 0), true);
|
||||
}
|
||||
$pageButtons = array();
|
||||
foreach ($this->buttons as $pageButton) {
|
||||
$pageButtons[$pageButton->getControl()->getId()] = $pageButton->getBrowseAction();
|
||||
|
@ -81,7 +81,7 @@ class Script {
|
||||
else {
|
||||
$scriptFunction = new ScriptFunction($name, $text);
|
||||
}
|
||||
array_push($this->functions, $scriptFunction);
|
||||
$this->functions[$scriptFunction->getName()] = $scriptFunction;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,15 @@ class ScriptFunction {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Text
|
||||
*
|
||||
|
@ -10,8 +10,4 @@ namespace ManiaControl\Manialinks;
|
||||
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
||||
*/
|
||||
interface ManialinkPageAnswerListener {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const MANIALINKPAGEANSWERLISTENER_INTERFACE = __CLASS__;
|
||||
}
|
||||
|
@ -159,12 +159,19 @@ class StyleManager {
|
||||
*
|
||||
* @return Frame $frame
|
||||
*/
|
||||
public function getDefaultListFrame(Script $script = null, $pagesId = '') {
|
||||
$paging = null;
|
||||
if ($script) {
|
||||
$paging = new Paging();
|
||||
$script->addFeature($paging);
|
||||
}
|
||||
public function getDefaultListFrame() {
|
||||
$args = func_get_args();
|
||||
$script = null;
|
||||
$paging = null;
|
||||
foreach ($args as $arg) {
|
||||
if ($arg instanceof Script) {
|
||||
$script = $arg;
|
||||
}
|
||||
if ($arg instanceof Paging) {
|
||||
$paging = $arg;
|
||||
}
|
||||
}
|
||||
|
||||
$width = $this->getListWidgetsWidth();
|
||||
$height = $this->getListWidgetsHeight();
|
||||
$quadStyle = $this->getDefaultMainWindowStyle();
|
||||
@ -189,7 +196,7 @@ class StyleManager {
|
||||
$closeQuad->setSubStyle(Quad_Icons64x64_1::SUBSTYLE_QuitRace);
|
||||
$closeQuad->setAction(ManialinkManager::ACTION_CLOSEWIDGET);
|
||||
|
||||
if ($pagesId && isset($script)) {
|
||||
if ($script) {
|
||||
$pagerSize = 6.;
|
||||
$pagerPrev = new Quad_Icons64x64_1();
|
||||
$frame->add($pagerPrev);
|
||||
|
@ -37,23 +37,23 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
/*
|
||||
* Constants
|
||||
*/
|
||||
const ACTION_UPDATE_MAP = 'MapList.UpdateMap';
|
||||
const ACTION_ERASE_MAP = 'MapList.EraseMap';
|
||||
const ACTION_SWITCH_MAP = 'MapList.SwitchMap';
|
||||
const ACTION_START_SWITCH_VOTE = 'MapList.StartMapSwitchVote';
|
||||
const ACTION_QUEUED_MAP = 'MapList.QueueMap';
|
||||
const ACTION_UNQUEUE_MAP = 'MapList.UnQueueMap';
|
||||
const ACTION_CHECK_UPDATE = 'MapList.CheckUpdate';
|
||||
const ACTION_CLEAR_MAPQUEUE = 'MapList.ClearMapQueue';
|
||||
const MAX_MAPS_PER_PAGE = 15;
|
||||
const DEFAULT_KARMA_PLUGIN = 'KarmaPlugin';
|
||||
const ACTION_UPDATE_MAP = 'MapList.UpdateMap';
|
||||
const ACTION_ERASE_MAP = 'MapList.EraseMap';
|
||||
const ACTION_SWITCH_MAP = 'MapList.SwitchMap';
|
||||
const ACTION_START_SWITCH_VOTE = 'MapList.StartMapSwitchVote';
|
||||
const ACTION_QUEUED_MAP = 'MapList.QueueMap';
|
||||
const ACTION_UNQUEUE_MAP = 'MapList.UnQueueMap';
|
||||
const ACTION_CHECK_UPDATE = 'MapList.CheckUpdate';
|
||||
const ACTION_CLEAR_MAPQUEUE = 'MapList.ClearMapQueue';
|
||||
const MAX_MAPS_PER_PAGE = 15;
|
||||
const DEFAULT_KARMA_PLUGIN = 'KarmaPlugin';
|
||||
const DEFAULT_CUSTOM_VOTE_PLUGIN = 'CustomVotesPlugin';
|
||||
|
||||
/*
|
||||
* Private Properties
|
||||
*/
|
||||
private $maniaControl = null;
|
||||
private $mapListShown = array();
|
||||
private $maniaControl = null;
|
||||
private $mapListShown = array();
|
||||
private $mapsInListShown = array();
|
||||
|
||||
/**
|
||||
@ -80,71 +80,67 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
/**
|
||||
* Clears the Map Queue
|
||||
*
|
||||
* @param array $chatCallback
|
||||
* @param array $chatCallback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function clearMapQueue(array $chatCallback, Player $player) {
|
||||
//Clears the Map Queue
|
||||
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 array $chatCallback
|
||||
* @param Player $player
|
||||
*/
|
||||
public function checkUpdates(array $chatCallback, Player $player) {
|
||||
//Update Mx Infos
|
||||
// Update Mx Infos
|
||||
$this->maniaControl->mapManager->mxManager->fetchManiaExchangeMapInformations();
|
||||
|
||||
//Reshow the Maplist
|
||||
// Reshow the Maplist
|
||||
$this->showMapList($player);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Displayes a MapList on the screen
|
||||
*
|
||||
* @param Player $player
|
||||
*/
|
||||
public function showMapList(Player $player, $maps = null) {
|
||||
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||
$height = $this->maniaControl->manialinkManager->styleManager->getListWidgetsHeight();
|
||||
|
||||
$this->mapListShown[$player->login] = true;
|
||||
|
||||
// Get Maps
|
||||
if(is_null($maps) && $maps != 'redirect') {
|
||||
if (is_null($maps) && $maps != 'redirect') {
|
||||
$mapList = $this->maniaControl->mapManager->getMaps();
|
||||
} else {
|
||||
if(array_key_exists($player->login, $this->mapsInListShown) && $maps == 'redirect') {
|
||||
}
|
||||
else {
|
||||
if (array_key_exists($player->login, $this->mapsInListShown) && $maps == 'redirect') {
|
||||
$mapList = $this->mapsInListShown[$player->login];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$mapList = $maps;
|
||||
}
|
||||
}
|
||||
|
||||
$this->mapsInListShown[$player->login] = $mapList;
|
||||
|
||||
$pagesId = '';
|
||||
if (count($mapList) > self::MAX_MAPS_PER_PAGE) {
|
||||
$pagesId = 'MapListPages';
|
||||
}
|
||||
|
||||
//Create ManiaLink
|
||||
// Create ManiaLink
|
||||
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
|
||||
$script = $maniaLink->getScript();
|
||||
$paging = new Paging();
|
||||
$script->addFeature($paging);
|
||||
$script = $maniaLink->getScript();
|
||||
$paging = new Paging();
|
||||
$script->addFeature($paging);
|
||||
|
||||
// Main frame
|
||||
$frame = $this->maniaControl->manialinkManager->styleManager->getDefaultListFrame($script, $pagesId);
|
||||
$frame = $this->maniaControl->manialinkManager->styleManager->getDefaultListFrame($script, $paging);
|
||||
$maniaLink->add($frame);
|
||||
|
||||
//Admin Buttons
|
||||
// Admin Buttons
|
||||
if ($this->maniaControl->authenticationManager->checkPermission($player, MapQueue::SETTING_PERMISSION_CLEAR_MAPQUEUE)) {
|
||||
//Clear Map-Queue
|
||||
// Clear Map-Queue
|
||||
$label = new Label_Button();
|
||||
$frame->add($label);
|
||||
$label->setText("Clear Map-Queue");
|
||||
@ -162,7 +158,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
}
|
||||
|
||||
if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_CHECK_UPDATE)) {
|
||||
//Check Update
|
||||
// Check Update
|
||||
$label = new Label_Button();
|
||||
$frame->add($label);
|
||||
$label->setText("Check MX Updates");
|
||||
@ -192,24 +188,27 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$headFrame = new Frame();
|
||||
$frame->add($headFrame);
|
||||
$headFrame->setY($height / 2 - 5);
|
||||
$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);
|
||||
$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);
|
||||
$this->maniaControl->manialinkManager->labelLine($headFrame, $array);
|
||||
|
||||
//Predefine description Label
|
||||
// Predefine description Label
|
||||
$descriptionLabel = $this->maniaControl->manialinkManager->styleManager->getDefaultDescriptionLabel();
|
||||
$frame->add($descriptionLabel);
|
||||
|
||||
$queuedMaps = $this->maniaControl->mapManager->mapQueue->getQueuedMapsRanking();
|
||||
/**
|
||||
*
|
||||
* @var KarmaPlugin $karmaPlugin
|
||||
*/
|
||||
$karmaPlugin = $this->maniaControl->pluginManager->getPlugin(self::DEFAULT_KARMA_PLUGIN);
|
||||
|
||||
$id = 1;
|
||||
$y = $height / 2 - 10;
|
||||
$id = 1;
|
||||
$y = $height / 2 - 10;
|
||||
$pageFrames = array();
|
||||
/**
|
||||
*
|
||||
* @var Map $map
|
||||
*/
|
||||
$currentMap = $this->maniaControl->mapManager->getCurrentMap();
|
||||
@ -218,7 +217,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$mxIconGreen = $this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_GREEN);
|
||||
$mxIconGreenHover = $this->maniaControl->manialinkManager->iconManager->getIcon(IconManager::MX_ICON_GREEN_MOVER);
|
||||
|
||||
foreach($mapList as $map) {
|
||||
foreach ($mapList as $map) {
|
||||
if (!isset($pageFrame)) {
|
||||
$pageFrame = new Frame();
|
||||
$frame->add($pageFrame);
|
||||
@ -228,7 +227,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
array_push($pageFrames, $pageFrame);
|
||||
$y = $height / 2 - 10;
|
||||
|
||||
$paging->addPage($pageFrame);
|
||||
$paging->addPage($pageFrame);
|
||||
}
|
||||
|
||||
// Map Frame
|
||||
@ -266,8 +265,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$mxQuad->setX($x + 65);
|
||||
$mxQuad->setUrl($map->mx->pageurl);
|
||||
$mxQuad->setZ(0.01);
|
||||
$description = 'View $<' . $map->name . '$> on Mania-Exchange';
|
||||
$mxQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
$description = 'View $<' . $map->name . '$> on Mania-Exchange';
|
||||
$mxQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
|
||||
if ($map->updateAvailable()) {
|
||||
$mxQuad = new Quad();
|
||||
@ -278,25 +277,26 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$mxQuad->setX($x + 62);
|
||||
$mxQuad->setUrl($map->mx->pageurl);
|
||||
$mxQuad->setZ(0.01);
|
||||
$description = 'Update for $<' . $map->name . '$> available on Mania-Exchange!';
|
||||
$mxQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
$description = 'Update for $<' . $map->name . '$> available on Mania-Exchange!';
|
||||
$mxQuad->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
|
||||
//Update Button
|
||||
// Update Button
|
||||
if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
|
||||
$mxQuad->setAction(self::ACTION_UPDATE_MAP . '.' . $map->uid);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Display Maps
|
||||
$array = array($id => $x + 5, $mxId => $x + 10, Formatter::stripDirtyCodes($map->name) => $x + 20, $map->authorNick => $x + 68);
|
||||
$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);
|
||||
if (isset($labels[3])) {
|
||||
/** @var Label $label */
|
||||
$label = $labels[3];
|
||||
$description = '$<' . $map->name . '$> made by $<' . $map->authorLogin . '$>';
|
||||
$label->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
/**
|
||||
* @var Label $label
|
||||
*/
|
||||
$label = $labels[3];
|
||||
$description = '$<' . $map->name . '$> made by $<' . $map->authorLogin . '$>';
|
||||
$label->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
}
|
||||
|
||||
// TODO action detailed map info including mx info
|
||||
@ -312,18 +312,19 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$label->setText($queuedMaps[$map->uid]);
|
||||
$label->setTextColor('fff');
|
||||
|
||||
//Checks if the Player who openend the Widget has queued the map
|
||||
// Checks if the Player who openend the Widget has queued the map
|
||||
$queuer = $this->maniaControl->mapManager->mapQueue->getQueuer($map->uid);
|
||||
if ($queuer->login == $player->login) {
|
||||
$description = 'Remove $<' . $map->name . '$> from the Map Queue';
|
||||
$label->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
$description = 'Remove $<' . $map->name . '$> from the Map Queue';
|
||||
$label->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
$label->setAction(self::ACTION_UNQUEUE_MAP . '.' . $map->uid);
|
||||
} else {
|
||||
$description = '$<' . $map->name . '$> is on Map-Queue Position: ' . $queuedMaps[$map->uid];
|
||||
$label->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
}
|
||||
|
||||
} else {
|
||||
else {
|
||||
$description = '$<' . $map->name . '$> is on Map-Queue Position: ' . $queuedMaps[$map->uid];
|
||||
$label->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Map-Queue-Map-Button
|
||||
$queueLabel = new Label_Button();
|
||||
$mapFrame->add($queueLabel);
|
||||
@ -334,8 +335,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$queueLabel->setText('+');
|
||||
$queueLabel->setTextColor('09f');
|
||||
|
||||
$description = 'Add $<' . $map->name . '$> to the Map Queue';
|
||||
$queueLabel->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
$description = 'Add $<' . $map->name . '$> to the Map Queue';
|
||||
$queueLabel->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
}
|
||||
|
||||
if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_REMOVE_MAP)) {
|
||||
@ -350,9 +351,9 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$eraseLabel->setTextColor('a00');
|
||||
|
||||
$confirmFrame = $this->buildConfirmFrame($maniaLink, $y, $id, $map->uid);
|
||||
$eraseLabel->addToggleFeature($confirmFrame);
|
||||
$description = 'Remove Map: $<' . $map->name . '$>';
|
||||
$eraseLabel->addToggleFeature($descriptionLabel, $description);
|
||||
$eraseLabel->addToggleFeature($confirmFrame);
|
||||
$description = 'Remove Map: $<' . $map->name . '$>';
|
||||
$eraseLabel->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
}
|
||||
|
||||
if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
|
||||
@ -367,13 +368,13 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$switchLabel->setTextColor('0f0');
|
||||
|
||||
$confirmFrame = $this->buildConfirmFrame($maniaLink, $y, $id);
|
||||
$switchLabel->addToggleFeature($confirmFrame);
|
||||
$switchLabel->addToggleFeature($confirmFrame);
|
||||
|
||||
$description = 'Switch Directly to Map: $<' . $map->name . '$>';
|
||||
$switchLabel->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
|
||||
} else if ($this->maniaControl->pluginManager->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)) {
|
||||
//Switch Map Voting
|
||||
$description = 'Switch Directly to Map: $<' . $map->name . '$>';
|
||||
$switchLabel->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
}
|
||||
else if ($this->maniaControl->pluginManager->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)) {
|
||||
// Switch Map Voting
|
||||
$switchLabel = new Label_Button();
|
||||
$mapFrame->add($switchLabel);
|
||||
$switchLabel->setX($width / 2 - 10);
|
||||
@ -385,8 +386,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
|
||||
$switchLabel->setAction(self::ACTION_START_SWITCH_VOTE . '.' . ($id - 1));
|
||||
|
||||
$description = 'Start Map-Switch Vote: $<' . $map->name . '$>';
|
||||
$switchLabel->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
$description = 'Start Map-Switch Vote: $<' . $map->name . '$>';
|
||||
$switchLabel->addTooltipLabelFeature($descriptionLabel, $description);
|
||||
}
|
||||
|
||||
// Display Karma bar
|
||||
@ -423,6 +424,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
}
|
||||
$id++;
|
||||
}
|
||||
|
||||
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player, 'MapList');
|
||||
}
|
||||
|
||||
@ -430,14 +432,14 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
* Builds the confirmation frame
|
||||
*
|
||||
* @param ManiaLink $maniaLink
|
||||
* @param $y
|
||||
* @param $id
|
||||
* @param bool $mapUid
|
||||
* @param $y
|
||||
* @param $id
|
||||
* @param bool $mapUid
|
||||
* @return Frame
|
||||
*/
|
||||
public function buildConfirmFrame(Manialink $maniaLink, $y, $id, $mapUid = false) {
|
||||
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
||||
$width = $this->maniaControl->manialinkManager->styleManager->getListWidgetsWidth();
|
||||
$quadStyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowStyle();
|
||||
$quadSubstyle = $this->maniaControl->manialinkManager->styleManager->getDefaultMainWindowSubStyle();
|
||||
|
||||
$confirmFrame = new Frame();
|
||||
@ -474,7 +476,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$buttLabel->setText('»');
|
||||
$buttLabel->setTextColor('0f0');
|
||||
$buttLabel->setTextSize(2);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$buttLabel->setTextSize(1);
|
||||
$buttLabel->setText('x');
|
||||
$buttLabel->setTextColor('a00');
|
||||
@ -487,10 +490,10 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
* Unset the player if he opened another Main Widget
|
||||
*
|
||||
* @param Player $player
|
||||
* @param $openedWidget
|
||||
* @param $openedWidget
|
||||
*/
|
||||
public function handleWidgetOpened(Player $player, $openedWidget) {
|
||||
//unset when another main widget got opened
|
||||
// unset when another main widget got opened
|
||||
if ($openedWidget != 'MapList') {
|
||||
unset($this->mapListShown[$player->login]);
|
||||
}
|
||||
@ -521,18 +524,18 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
* @param array $callback
|
||||
*/
|
||||
public function handleManialinkPageAnswer(array $callback) {
|
||||
$actionId = $callback[1][2];
|
||||
$actionId = $callback[1][2];
|
||||
$actionArray = explode('.', $actionId);
|
||||
if (count($actionArray) <= 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
$action = $actionArray[0] . '.' . $actionArray[1];
|
||||
$login = $callback[1][1];
|
||||
$login = $callback[1][1];
|
||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||
$mapId = (int)$actionArray[2];
|
||||
$mapId = (int) $actionArray[2];
|
||||
|
||||
switch($action) {
|
||||
switch ($action) {
|
||||
case self::ACTION_UPDATE_MAP:
|
||||
$mapUid = $actionArray[2];
|
||||
$this->maniaControl->mapManager->updateMap($player, $mapUid);
|
||||
@ -545,13 +548,14 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
case self::ACTION_SWITCH_MAP:
|
||||
try {
|
||||
$this->maniaControl->client->jumpToMapIndex($mapId);
|
||||
} catch(Exception $e) {
|
||||
}
|
||||
catch (Exception $e) {
|
||||
// TODO: is it even possible that an exception other than connection errors will be thrown? - remove try-catch?
|
||||
$this->maniaControl->chat->sendError("Error while Jumping to Map Index");
|
||||
break;
|
||||
}
|
||||
$mapList = $this->maniaControl->mapManager->getMaps();
|
||||
$map = $mapList[$mapId];
|
||||
$map = $mapList[$mapId];
|
||||
|
||||
$message = '$<' . $player->nickname . '$> skipped to Map $z$<' . $map->name . '$>!';
|
||||
$this->maniaControl->chat->sendSuccess($message);
|
||||
@ -560,26 +564,31 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
$this->playerCloseWidget($player);
|
||||
break;
|
||||
case self::ACTION_START_SWITCH_VOTE:
|
||||
/** @var $votesPlugin CustomVotesPlugin */
|
||||
/**
|
||||
* @var $votesPlugin CustomVotesPlugin
|
||||
*/
|
||||
$votesPlugin = $this->maniaControl->pluginManager->getPlugin(self::DEFAULT_CUSTOM_VOTE_PLUGIN);
|
||||
$mapList = $this->maniaControl->mapManager->getMaps();
|
||||
$map = $mapList[$mapId];
|
||||
$mapList = $this->maniaControl->mapManager->getMaps();
|
||||
$map = $mapList[$mapId];
|
||||
|
||||
$message = '$<' . $player->nickname . '$>$s started a vote to switch to $<' . $map->name . '$>!';
|
||||
|
||||
/** @var Map $map */
|
||||
/**
|
||||
* @var Map $map
|
||||
*/
|
||||
$votesPlugin->defineVote('switchmap', "Goto " . $map->name, true, $message);
|
||||
|
||||
$self = $this;
|
||||
$votesPlugin->startVote($player, 'switchmap', function ($result) use (&$self, &$votesPlugin, &$map) {
|
||||
$votesPlugin->startVote($player, 'switchmap', function ($result) use(&$self, &$votesPlugin, &$map) {
|
||||
$self->maniaControl->chat->sendInformation('$sVote Successfully -> Map switched!');
|
||||
$votesPlugin->undefineVote('switchmap');
|
||||
|
||||
try {
|
||||
$index = $self->maniaControl->mapManager->getMapIndex($map);
|
||||
$self->maniaControl->client->jumpToMapIndex($index);
|
||||
} catch(Exception $e) {
|
||||
//TODO temp added 19.04.2014
|
||||
}
|
||||
catch (Exception $e) {
|
||||
// TODO temp added 19.04.2014
|
||||
$self->maniaControl->errorHandler->triggerDebugNotice("Exception line 557 MapList.php" . $e->getMessage());
|
||||
|
||||
$self->maniaControl->chat->sendError("Error while Switching Map");
|
||||
@ -601,12 +610,13 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
* Reopen the widget on Map Begin, MapListChanged, etc.
|
||||
*/
|
||||
public function updateWidget() {
|
||||
foreach($this->mapListShown as $login => $shown) {
|
||||
foreach ($this->mapListShown as $login => $shown) {
|
||||
if ($shown) {
|
||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||
if ($player) {
|
||||
$this->showMapList($player);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
unset($this->mapListShown[$login]);
|
||||
}
|
||||
}
|
||||
@ -617,12 +627,13 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
|
||||
* Reopen the widget on MapQueue changed
|
||||
*/
|
||||
public function updateWidgetQueue() {
|
||||
foreach($this->mapListShown as $login => $shown) {
|
||||
foreach ($this->mapListShown as $login => $shown) {
|
||||
if ($shown) {
|
||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||
if ($player) {
|
||||
$this->showMapList($player, 'redirect');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
unset($this->mapListShown[$login]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user