This commit is contained in:
Steffen Schröder 2014-04-27 18:59:21 +02:00
parent 7145cd267b
commit c0e2ed7370
9 changed files with 270 additions and 254 deletions

View File

@ -72,7 +72,8 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
public function addMenuItem(Control $control, $playerAction = true, $order = 0, $description = null) {
if ($playerAction) {
$this->addPlayerMenuItem($control, $order, $description);
} else {
}
else {
$this->addAdminMenuItem($control, $order, $description);
}
}
@ -86,7 +87,8 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
public function removeMenuItem($order, $playerAction = true) {
if ($playerAction) {
unset($this->playerMenuItems[$order]);
} else {
}
else {
unset($this->adminMenuItems[$order]);
}
$this->rebuildAndShowMenu();
@ -178,8 +180,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
}
$manialink = new ManiaLink(self::MLID_MENU);
$script = new Script();
$manialink->setScript($script);
$script = $manialink->getScript();
/*
* Admin Menu
@ -233,10 +234,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
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);
@ -294,6 +292,7 @@ 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);
// Add items
@ -301,10 +300,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
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);
@ -318,6 +314,8 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
}
}
//if ($player->login === 'steeffeen') var_dump((string)$manialink);
return $manialink;
}
}

View File

@ -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__;
}

View File

@ -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__;
}

View File

@ -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();

View File

@ -81,7 +81,7 @@ class Script {
else {
$scriptFunction = new ScriptFunction($name, $text);
}
array_push($this->functions, $scriptFunction);
$this->functions[$scriptFunction->getName()] = $scriptFunction;
return $this;
}

View File

@ -38,6 +38,15 @@ class ScriptFunction {
return $this;
}
/**
* Get the Name
*
* @return string
*/
public function getName() {
return $this->name;
}
/**
* Set the Text
*

View File

@ -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__;
}

View File

@ -159,12 +159,19 @@ class StyleManager {
*
* @return Frame $frame
*/
public function getDefaultListFrame(Script $script = null, $pagesId = '') {
public function getDefaultListFrame() {
$args = func_get_args();
$script = null;
$paging = null;
if ($script) {
$paging = new Paging();
$script->addFeature($paging);
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);

View File

@ -102,7 +102,6 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$this->showMapList($player);
}
/**
* Displayes a MapList on the screen
*
@ -117,21 +116,18 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
// Get Maps
if (is_null($maps) && $maps != 'redirect') {
$mapList = $this->maniaControl->mapManager->getMaps();
} else {
}
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
$maniaLink = new ManiaLink(ManialinkManager::MAIN_MLID);
$script = $maniaLink->getScript();
@ -139,7 +135,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$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
@ -193,7 +189,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$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);
$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
@ -202,6 +199,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$queuedMaps = $this->maniaControl->mapManager->mapQueue->getQueuedMapsRanking();
/**
*
* @var KarmaPlugin $karmaPlugin
*/
$karmaPlugin = $this->maniaControl->pluginManager->getPlugin(self::DEFAULT_KARMA_PLUGIN);
@ -210,6 +208,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$y = $height / 2 - 10;
$pageFrames = array();
/**
*
* @var Map $map
*/
$currentMap = $this->maniaControl->mapManager->getCurrentMap();
@ -286,14 +285,15 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$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);
$labels = $this->maniaControl->manialinkManager->labelLine($mapFrame, $array);
if (isset($labels[3])) {
/** @var Label $label */
/**
* @var Label $label
*/
$label = $labels[3];
$description = '$<' . $map->name . '$> made by $<' . $map->authorLogin . '$>';
$label->addTooltipLabelFeature($descriptionLabel, $description);
@ -318,12 +318,13 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$description = 'Remove $<' . $map->name . '$> from the Map Queue';
$label->addTooltipLabelFeature($descriptionLabel, $description);
$label->setAction(self::ACTION_UNQUEUE_MAP . '.' . $map->uid);
} else {
}
else {
$description = '$<' . $map->name . '$> is on Map-Queue Position: ' . $queuedMaps[$map->uid];
$label->addTooltipLabelFeature($descriptionLabel, $description);
}
} else {
}
else {
// Map-Queue-Map-Button
$queueLabel = new Label_Button();
$mapFrame->add($queueLabel);
@ -352,7 +353,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$confirmFrame = $this->buildConfirmFrame($maniaLink, $y, $id, $map->uid);
$eraseLabel->addToggleFeature($confirmFrame);
$description = 'Remove Map: $<' . $map->name . '$>';
$eraseLabel->addToggleFeature($descriptionLabel, $description);
$eraseLabel->addTooltipLabelFeature($descriptionLabel, $description);
}
if ($this->maniaControl->authenticationManager->checkPermission($player, MapManager::SETTING_PERMISSION_ADD_MAP)) {
@ -371,8 +372,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$description = 'Switch Directly to Map: $<' . $map->name . '$>';
$switchLabel->addTooltipLabelFeature($descriptionLabel, $description);
} else if ($this->maniaControl->pluginManager->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)) {
}
else if ($this->maniaControl->pluginManager->isPluginActive(self::DEFAULT_CUSTOM_VOTE_PLUGIN)) {
// Switch Map Voting
$switchLabel = new Label_Button();
$mapFrame->add($switchLabel);
@ -423,6 +424,7 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
}
$id++;
}
$this->maniaControl->manialinkManager->displayWidget($maniaLink, $player, 'MapList');
}
@ -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');
@ -545,7 +548,8 @@ 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;
@ -560,14 +564,18 @@ 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];
$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;
@ -578,7 +586,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
try {
$index = $self->maniaControl->mapManager->getMapIndex($map);
$self->maniaControl->client->jumpToMapIndex($index);
} catch(Exception $e) {
}
catch (Exception $e) {
// TODO temp added 19.04.2014
$self->maniaControl->errorHandler->triggerDebugNotice("Exception line 557 MapList.php" . $e->getMessage());
@ -606,7 +615,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$player = $this->maniaControl->playerManager->getPlayer($login);
if ($player) {
$this->showMapList($player);
} else {
}
else {
unset($this->mapListShown[$login]);
}
}
@ -622,7 +632,8 @@ class MapList implements ManialinkPageAnswerListener, CallbackListener {
$player = $this->maniaControl->playerManager->getPlayer($login);
if ($player) {
$this->showMapList($player, 'redirect');
} else {
}
else {
unset($this->mapListShown[$login]);
}
}