fixes
This commit is contained in:
@ -27,13 +27,13 @@ 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';
|
||||
|
||||
|
||||
/*
|
||||
* Private Properties
|
||||
*/
|
||||
@ -49,12 +49,12 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
*/
|
||||
public function __construct(ManiaControl $maniaControl) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
|
||||
|
||||
// Init settings
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_POSX, 156.);
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_POSY, -17.);
|
||||
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MENU_ITEMSIZE, 6.);
|
||||
|
||||
|
||||
// Register for callbacks
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(CallbackManager::CB_AFTERINIT, $this, 'handleAfterInit');
|
||||
$this->maniaControl->callbackManager->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerJoined');
|
||||
@ -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,55 +165,54 @@ 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);
|
||||
$iconFrame->setPosition($posX, $posY);
|
||||
|
||||
|
||||
$backgroundQuad = new Quad();
|
||||
$iconFrame->add($backgroundQuad);
|
||||
$backgroundQuad->setSize($itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
|
||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||
|
||||
|
||||
$itemQuad = new Quad_Icons64x64_1();
|
||||
$iconFrame->add($itemQuad);
|
||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_IconServers);
|
||||
$itemQuad->setSize($itemSize, $itemSize);
|
||||
|
||||
|
||||
// Admin Menu Description Label
|
||||
$descriptionFrame = new Frame();
|
||||
$manialink->add($descriptionFrame);
|
||||
$descriptionFrame->setPosition($posX - count($this->adminMenuItems) * $itemSize * 1.15 - 6, $posY);
|
||||
|
||||
|
||||
$descriptionLabel = new Label();
|
||||
$descriptionFrame->add($descriptionLabel);
|
||||
$descriptionLabel->setAlign(Control::RIGHT, Control::TOP);
|
||||
$descriptionLabel->setSize(40, 4);
|
||||
$descriptionLabel->setTextSize(1.4);
|
||||
$descriptionLabel->setTextColor('fff');
|
||||
|
||||
|
||||
// Admin Menu
|
||||
$popoutFrame = new Frame();
|
||||
$manialink->add($popoutFrame);
|
||||
@ -219,38 +220,35 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
$popoutFrame->setHAlign(Control::RIGHT);
|
||||
$popoutFrame->setSize(4 * $itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
|
||||
$popoutFrame->setVisible(false);
|
||||
|
||||
|
||||
$backgroundQuad = new Quad();
|
||||
$popoutFrame->add($backgroundQuad);
|
||||
$backgroundQuad->setHAlign(Control::RIGHT);
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Player Menu
|
||||
*/
|
||||
@ -258,29 +256,29 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
$iconFrame = new Frame();
|
||||
$manialink->add($iconFrame);
|
||||
$iconFrame->setPosition($posX, $posY - $itemSize * $itemMarginFactorY);
|
||||
|
||||
|
||||
$backgroundQuad = new Quad();
|
||||
$iconFrame->add($backgroundQuad);
|
||||
$backgroundQuad->setSize($itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
|
||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||
|
||||
|
||||
$itemQuad = new Quad_Icons64x64_1();
|
||||
$iconFrame->add($itemQuad);
|
||||
$itemQuad->setSubStyle($itemQuad::SUBSTYLE_IconPlayers);
|
||||
$itemQuad->setSize($itemSize, $itemSize);
|
||||
|
||||
|
||||
// Player Menu Description Frame
|
||||
$descriptionFrame = new Frame();
|
||||
$manialink->add($descriptionFrame);
|
||||
$descriptionFrame->setPosition($posX - count($this->playerMenuItems) * $itemSize * 1.15 - 6, $posY - $itemSize * $itemMarginFactorY);
|
||||
|
||||
|
||||
$descriptionLabel = new Label();
|
||||
$descriptionFrame->add($descriptionLabel);
|
||||
$descriptionLabel->setAlign(Control::RIGHT, Control::TOP);
|
||||
$descriptionLabel->setSize(40, 4);
|
||||
$descriptionLabel->setTextSize(1.4);
|
||||
$descriptionLabel->setTextColor('fff');
|
||||
|
||||
|
||||
// Player Menu
|
||||
$popoutFrame = new Frame();
|
||||
$manialink->add($popoutFrame);
|
||||
@ -288,36 +286,36 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener {
|
||||
$popoutFrame->setHAlign(Control::RIGHT);
|
||||
$popoutFrame->setSize(4 * $itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
|
||||
$popoutFrame->setVisible(false);
|
||||
|
||||
|
||||
$backgroundQuad = new Quad();
|
||||
$popoutFrame->add($backgroundQuad);
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user