Added SidebarMenuManager Fixed https://github.com/ManiaControl/ManiaControl/issues/97
This commit is contained in:
parent
d7348fd412
commit
b90a769723
@ -15,6 +15,7 @@ use ManiaControl\General\UsageInformationTrait;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\ManialinkManager;
|
||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
use ManiaControl\Manialinks\SidebarMenuManager;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Players\PlayerManager;
|
||||
use ManiaControl\Settings\Setting;
|
||||
@ -41,6 +42,8 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, Usag
|
||||
const SETTING_MENU_ITEMSIZE = 'Menu Item Size';
|
||||
const ACTION_OPEN_ADMIN_MENU = 'ActionsMenu.OpenAdminMenu';
|
||||
const ACTION_OPEN_PLAYER_MENU = 'ActionsMenu.OpenPlayerMenu';
|
||||
const ADMIN_MENU_ID = 'ActionsMenu.AdminMenu';
|
||||
const PLAYER_MENU_ID = 'ActionsMenu.PlayerMenu';
|
||||
|
||||
/*
|
||||
* Private properties
|
||||
@ -71,6 +74,8 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, Usag
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'handlePlayerJoined');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'handleSettingChanged');
|
||||
|
||||
$this->maniaControl->getManialinkManager()->getSidebarMenuManager()->addMenuEntry(SidebarMenuManager::ORDER_ADMIN_MENU, self::ADMIN_MENU_ID);
|
||||
$this->maniaControl->getManialinkManager()->getSidebarMenuManager()->addMenuEntry(SidebarMenuManager::ORDER_PLAYER_MENU, self::PLAYER_MENU_ID);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,19 +140,18 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, Usag
|
||||
/**
|
||||
* Builds the Manialink
|
||||
*
|
||||
* @param $admin
|
||||
* @param Player $player
|
||||
* @return ManiaLink
|
||||
*/
|
||||
private function buildMenuIconsManialink($admin = false) {
|
||||
$posX = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_POSX);
|
||||
$adminPos = $this->maniaControl->getManialinkManager()->getSidebarMenuManager()->getEntryPosition(self::ADMIN_MENU_ID);
|
||||
$playerPos = $this->maniaControl->getManialinkManager()->getSidebarMenuManager()->getEntryPosition(self::PLAYER_MENU_ID);
|
||||
$itemSize = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_ITEMSIZE);
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle();
|
||||
$itemMarginFactorX = 1.3;
|
||||
$itemMarginFactorY = 1.2;
|
||||
|
||||
$posY = $this->getActionsMenuY();
|
||||
|
||||
$maniaLink = new ManiaLink(self::MLID_MENU);
|
||||
$frame = new Frame();
|
||||
$maniaLink->addChild($frame);
|
||||
@ -160,7 +164,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, Usag
|
||||
// Admin Menu Icon Frame
|
||||
$iconFrame = new Frame();
|
||||
$frame->addChild($iconFrame);
|
||||
$iconFrame->setPosition($posX, $posY);
|
||||
$iconFrame->setPosition($adminPos['x'], $adminPos['y']);
|
||||
|
||||
$backgroundQuad = new Quad();
|
||||
$iconFrame->addChild($backgroundQuad);
|
||||
@ -175,7 +179,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, Usag
|
||||
// Admin Menu Description
|
||||
$descriptionLabel = new Label();
|
||||
$frame->addChild($descriptionLabel);
|
||||
$descriptionLabel->setPosition($posX - count($this->adminMenuItems) * $itemSize * 1.05 - 5, $posY);
|
||||
$descriptionLabel->setPosition($adminPos['x'] - count($this->adminMenuItems) * $itemSize * 1.05 - 5, $adminPos['y']);
|
||||
$descriptionLabel->setAlign($descriptionLabel::RIGHT, $descriptionLabel::TOP);
|
||||
$descriptionLabel->setSize(40, 4);
|
||||
$descriptionLabel->setTextSize(1.4);
|
||||
@ -184,7 +188,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, Usag
|
||||
// Admin Menu
|
||||
$popoutFrame = new Frame();
|
||||
$frame->addChild($popoutFrame);
|
||||
$popoutFrame->setPosition($posX - $itemSize * 0.5, $posY);
|
||||
$popoutFrame->setPosition($adminPos['x'] - $itemSize * 0.5, $adminPos['y']);
|
||||
$popoutFrame->setHorizontalAlign($popoutFrame::RIGHT);
|
||||
$popoutFrame->setVisible(false);
|
||||
|
||||
@ -223,7 +227,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, Usag
|
||||
// Player Menu Icon Frame
|
||||
$iconFrame = new Frame();
|
||||
$frame->addChild($iconFrame);
|
||||
$iconFrame->setPosition($posX, $posY - $itemSize * $itemMarginFactorY);
|
||||
$iconFrame->setPosition($playerPos['x'], $playerPos['y']);
|
||||
|
||||
$backgroundQuad = new Quad();
|
||||
$iconFrame->addChild($backgroundQuad);
|
||||
@ -238,7 +242,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, Usag
|
||||
// Player Menu Description
|
||||
$descriptionLabel = new Label();
|
||||
$frame->addChild($descriptionLabel);
|
||||
$descriptionLabel->setPosition($posX - count($this->playerMenuItems) * $itemSize * 1.05 - 5, $posY - $itemSize * $itemMarginFactorY);
|
||||
$descriptionLabel->setPosition($playerPos['x'] - count($this->playerMenuItems) * $itemSize * 1.05 - 5, $playerPos['y']);
|
||||
$descriptionLabel->setAlign($descriptionLabel::RIGHT, $descriptionLabel::TOP);
|
||||
$descriptionLabel->setSize(40, 4);
|
||||
$descriptionLabel->setTextSize(1.4);
|
||||
@ -247,7 +251,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, Usag
|
||||
// Player Menu
|
||||
$popoutFrame = new Frame();
|
||||
$frame->addChild($popoutFrame);
|
||||
$popoutFrame->setPosition($posX - $itemSize * 0.5, $posY - $itemSize * $itemMarginFactorY);
|
||||
$popoutFrame->setPosition($playerPos['x'] - $itemSize * 0.5, $playerPos['y']);
|
||||
$popoutFrame->setHorizontalAlign($popoutFrame::RIGHT);
|
||||
$popoutFrame->setVisible(false);
|
||||
|
||||
@ -336,12 +340,7 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, Usag
|
||||
* @param Player $player
|
||||
*/
|
||||
public function handlePlayerJoined(Player $player) {
|
||||
if ($this->maniaControl->getAuthenticationManager()->checkRight($player, AuthenticationManager::AUTH_LEVEL_MODERATOR)) {
|
||||
$maniaLink = $this->buildMenuIconsManialink(true);
|
||||
} else {
|
||||
$maniaLink = $this->buildMenuIconsManialink(false);
|
||||
}
|
||||
|
||||
$maniaLink = $this->buildMenuIconsManialink($player);
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($maniaLink, $player);
|
||||
}
|
||||
|
||||
@ -357,18 +356,4 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, Usag
|
||||
|
||||
$this->rebuildAndShowMenu();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Y value of the Actionsmenu (dependent on game)
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getActionsMenuY() {
|
||||
if ($this->maniaControl->getMapManager()->getCurrentMap()->getGame() === 'sm') {
|
||||
$posY = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_POSY_SHOOTMANIA);
|
||||
} else {
|
||||
$posY = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_POSY_TRACKMANIA);
|
||||
}
|
||||
return $posY;
|
||||
}
|
||||
}
|
||||
|
@ -235,7 +235,6 @@ class CallbackManager implements UsageInformationAble {
|
||||
$startTime = microtime(true);
|
||||
$callbacks = $this->maniaControl->getClient()->executeCallbacks();
|
||||
$timings["executeCallbacks"] = microtime(true) - $startTime;
|
||||
|
||||
foreach ($callbacks as $key => $callback) {
|
||||
$time1 = microtime(true);
|
||||
$this->handleCallback($callback);
|
||||
|
@ -52,6 +52,9 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener,
|
||||
/** @var IconManager $iconManager */
|
||||
private $iconManager = null;
|
||||
|
||||
/** @var SidebarMenuManager $sidebarMenuManager */
|
||||
private $sidebarMenuManager = null;
|
||||
|
||||
// TODO: use listening class
|
||||
private $pageAnswerListeners = array();
|
||||
private $pageAnswerRegexListener = array();
|
||||
@ -68,6 +71,7 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener,
|
||||
$this->styleManager = new StyleManager($maniaControl);
|
||||
$this->customUIManager = new CustomUIManager($maniaControl);
|
||||
$this->iconManager = new IconManager($maniaControl);
|
||||
$this->sidebarMenuManager = new SidebarMenuManager($maniaControl);
|
||||
|
||||
// Callbacks
|
||||
$this->registerManialinkPageAnswerListener(self::ACTION_CLOSEWIDGET, $this, 'closeWidgetCallback');
|
||||
@ -212,7 +216,6 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener,
|
||||
$this->sendManialink($maniaLink, $player);
|
||||
|
||||
if ($widgetName) {
|
||||
// TODO make check by manialinkId, getter is needed to avoid uses on non main widgets
|
||||
$this->disableAltMenu($player);
|
||||
// Trigger callback
|
||||
$player = $this->maniaControl->getPlayerManager()->getPlayer($player);
|
||||
@ -388,4 +391,11 @@ class ManialinkManager implements ManialinkPageAnswerListener, CallbackListener,
|
||||
|
||||
return $labelLine->getEntries();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SidebarMenuManager
|
||||
*/
|
||||
public function getSidebarMenuManager() {
|
||||
return $this->sidebarMenuManager;
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace ManiaControl\Manialinks\SidebarMenu;
|
||||
namespace ManiaControl\Manialinks;
|
||||
|
||||
use FML\Controls\Frame;
|
||||
use FML\Controls\Quad;
|
||||
use FML\Controls\Quads\Quad_UIConstruction_Buttons;
|
||||
use FML\ManiaLink;
|
||||
use ManiaControl\Callbacks\CallbackListener;
|
||||
use ManiaControl\General\UsageInformationAble;
|
||||
use ManiaControl\General\UsageInformationTrait;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\ManialinkManager;
|
||||
|
||||
|
||||
class SidebarMenuManager implements UsageInformationAble {
|
||||
class SidebarMenuManager implements UsageInformationAble, CallbackListener {
|
||||
use UsageInformationTrait;
|
||||
|
||||
const SIDEBAR_MANIALINK_ID = 'SidebarMenuManager.SidebarMenu';
|
||||
const ADMIN_MENU_ORDER = 10;
|
||||
const PLAYER_MENU_ORDER = 20;
|
||||
|
||||
/* Settings */
|
||||
const SETTING_SIDEBAR_POSX = 'Sidebar X Position';
|
||||
const SETTING_SIDEBAR_POSY_SHOOTMANIA = 'Sidebar Y Position (Shootmania)';
|
||||
const SETTING_SIDEBAR_POSY_TRACKMANIA = 'Sidebar Y Position (Trackmania)';
|
||||
const SETTING_MENU_ITEMSIZE = 'Size of menu items';
|
||||
|
||||
const ORDER_ADMIN_MENU = 10;
|
||||
const ORDER_PLAYER_MENU = 20;
|
||||
|
||||
/* @var $maniaControl ManiaControl */
|
||||
private $maniaControl;
|
||||
private $menuEntries = array();
|
||||
private $yPositions = array();
|
||||
|
||||
function __construct(ManiaControl $maniaControl) {
|
||||
$this->maniaControl = $maniaControl;
|
||||
@ -35,72 +31,86 @@ class SidebarMenuManager implements UsageInformationAble {
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SIDEBAR_POSY_SHOOTMANIA, -37);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SIDEBAR_POSY_TRACKMANIA, 17);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MENU_ITEMSIZE, 6);
|
||||
|
||||
}
|
||||
|
||||
public function addMenuEntry(SidebarMenuEntry $entry, $order) {
|
||||
if (isset($this->menuEntries[$order])) {
|
||||
$this->addMenuEntry($entry, $order + 1);
|
||||
}
|
||||
array_push($menuEntries, $entry);
|
||||
ksort($this->menuEntries);
|
||||
$this->updateManiaLink();
|
||||
}
|
||||
|
||||
private function itemsBeforeAdmin() {
|
||||
$count = 0;
|
||||
foreach ($this->menuEntries as $key => $entry) {
|
||||
if ($key < self::ADMIN_MENU_ORDER) {
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
return $count;
|
||||
}
|
||||
|
||||
|
||||
private function updateManiaLink() {
|
||||
$itemSize = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_ITEMSIZE);
|
||||
/**
|
||||
* Returns array('x' => xPosition, 'y' => yPosition) of the Sidebar
|
||||
*
|
||||
* @return array
|
||||
* @api
|
||||
*/
|
||||
public function getSidebarPosition() {
|
||||
$posX = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SIDEBAR_POSX);
|
||||
|
||||
if ($this->maniaControl->getMapManager()->getCurrentMap()->getGame() === 'sm') {
|
||||
$posY = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SIDEBAR_POSY_SHOOTMANIA);
|
||||
} else {
|
||||
$posY = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SIDEBAR_POSY_TRACKMANIA);
|
||||
}
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle();
|
||||
$itemMarginFactorX = 1.3;
|
||||
$itemMarginFactorY = 1.2;
|
||||
|
||||
//Calculate X relative to AdminMenu
|
||||
$posX -= $itemSize * 1.05 * $this->itemsBeforeAdmin();
|
||||
return array('x' => $posX, 'y' => $posY);
|
||||
}
|
||||
|
||||
$maniaLink = new ManiaLink(self::SIDEBAR_MANIALINK_ID);
|
||||
$frame = new Frame();
|
||||
$maniaLink->addChild($frame);
|
||||
$frame->setZ(ManialinkManager::MAIN_MANIALINK_Z_VALUE);
|
||||
$frame->setPosition($posX, $posY);
|
||||
/**
|
||||
* Returns array('x' => xPosition, 'y' => yPosition) of a menu item of the sidebar
|
||||
*
|
||||
* @param string $id
|
||||
* @return array|null
|
||||
*/
|
||||
public function getEntryPosition($id) {
|
||||
$itemSize = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MENU_ITEMSIZE);
|
||||
$pos = $this->getSidebarPosition();
|
||||
$posX = $pos['x'];
|
||||
$posY = $pos['y'];
|
||||
|
||||
if (isset($this->yPositions[$id])) {
|
||||
return array('x' => $posX, 'y' => $this->yPositions[$id]);
|
||||
}
|
||||
|
||||
$posX = 0;
|
||||
/** @var SidebarMenuEntry $entry */
|
||||
foreach ($this->menuEntries as $entry) {
|
||||
$iconFrame = new Frame();
|
||||
$frame->addChild($iconFrame);
|
||||
$iconFrame->setX($posX);
|
||||
|
||||
$background = new Quad();
|
||||
$frame->addChild($background);
|
||||
$background->setStyles($quadStyle, $quadSubstyle);
|
||||
$background->setSize($itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
|
||||
|
||||
$icon = $entry->getIcon();
|
||||
$frame->addChild($icon);
|
||||
if($entry->getDescription()){
|
||||
|
||||
if ($entry == $id) {
|
||||
$this->yPositions[$id] = $posY;
|
||||
return array('x' => $posX, 'y' => $posY);
|
||||
}
|
||||
$posY -= $itemSize * 1.05;
|
||||
}
|
||||
|
||||
$this->maniaControl->getErrorHandler()->triggerDebugNotice('SidebarMenuEntry id:' . $id . ' not found');
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an Entry to the SidebarMenu
|
||||
* Get the associated position with getEntryPosition($id)
|
||||
*
|
||||
* @param int $order
|
||||
* @param string $id
|
||||
* @api
|
||||
*/
|
||||
public function addMenuEntry($order, $id) {
|
||||
if (isset($this->menuEntries[$order])) {
|
||||
if ($this->menuEntries[$order] != $id) {
|
||||
$this->addMenuEntry($order + 1, $id);
|
||||
}
|
||||
}
|
||||
$this->menuEntries[$order] = $id;
|
||||
ksort($this->menuEntries);
|
||||
$this->yPositions = array();
|
||||
}
|
||||
|
||||
|
||||
$this->maniaControl->getManialinkManager()->sendManialink($maniaLink);
|
||||
/**
|
||||
* Deletes an Entry from the SidebarMenu
|
||||
*
|
||||
* @param string $id
|
||||
*/
|
||||
public function deleteMenuEntry($id) {
|
||||
foreach ($this->menuEntries as $k => $entry) {
|
||||
if ($entry == $id) {
|
||||
array_splice($this->menuEntries, $k, 1);
|
||||
$this->yPositions = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -24,6 +24,7 @@ use ManiaControl\Commands\CommandListener;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\ManialinkManager;
|
||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||
use ManiaControl\Manialinks\SidebarMenuManager;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Players\PlayerManager;
|
||||
use ManiaControl\Plugins\Plugin;
|
||||
@ -54,11 +55,6 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
const PLUGIN_NAME = 'CustomVotesPlugin';
|
||||
const PLUGIN_AUTHOR = 'kremsy';
|
||||
|
||||
const SETTING_VOTE_ICON_POSX = 'Vote-Icon-Position: X';
|
||||
const SETTING_VOTE_ICON_POSY = 'Vote-Icon-Position: Y';
|
||||
const SETTING_VOTE_ICON_WIDTH = 'Vote-Icon-Size: Width';
|
||||
const SETTING_VOTE_ICON_HEIGHT = 'Vote-Icon-Size: Height';
|
||||
|
||||
const SETTING_WIDGET_POSX = 'Widget-Position: X';
|
||||
const SETTING_WIDGET_POSY = 'Widget-Position: Y';
|
||||
const SETTING_WIDGET_WIDTH = 'Widget-Size: Width';
|
||||
@ -71,7 +67,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
|
||||
const MLID_WIDGET = 'CustomVotesPlugin.WidgetId';
|
||||
const MLID_ICON = 'CustomVotesPlugin.IconWidgetId';
|
||||
|
||||
const CUSTOMVOTES_MENU_ID = 'CustomVotesPlugin.MenuId';
|
||||
|
||||
const ACTION_POSITIVE_VOTE = 'CustomVotesPlugin.PositiveVote';
|
||||
const ACTION_NEGATIVE_VOTE = 'CustomVotesPlugin.NegativeVote';
|
||||
@ -153,19 +149,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(ScriptManager::CB_PAUSE_STATUS_CHANGED, $this, 'constructMenu');
|
||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'handleSettingChanged');
|
||||
|
||||
$actionsPosX = $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getActionsMenu(), ActionsMenu::SETTING_MENU_POSX);
|
||||
$actionsPosY = $this->maniaControl->getActionsMenu()->getActionsMenuY();
|
||||
$iconSize = $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getActionsMenu(), ActionsMenu::SETTING_MENU_ITEMSIZE);
|
||||
|
||||
$itemMarginFactorY = 1.2;
|
||||
$posY = $actionsPosY - 2 * ($iconSize * $itemMarginFactorY);
|
||||
|
||||
// Settings
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_VOTE_ICON_POSX, $actionsPosX);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_VOTE_ICON_POSY, $posY);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_VOTE_ICON_WIDTH, 6);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_VOTE_ICON_HEIGHT, 6);
|
||||
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_POSX, -80); //160 -15
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_POSY, 80); //-15
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_WIDGET_WIDTH, 50); //30
|
||||
@ -177,6 +161,8 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SPECTATOR_ALLOW_START_VOTE, true);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_VOTE_TIME, 40);
|
||||
|
||||
$this->maniaControl->getManialinkManager()->getSidebarMenuManager()->addMenuEntry(SidebarMenuManager::ORDER_PLAYER_MENU + 5, self::CUSTOMVOTES_MENU_ID);
|
||||
|
||||
//Define Votes
|
||||
$this->defineVote("teambalance", "Vote for Team Balance");
|
||||
$this->defineVote("skipmap", "Vote for Skip Map")->setStopCallback(Callbacks::ENDMAP);
|
||||
@ -282,10 +268,8 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
* @param bool $login
|
||||
*/
|
||||
private function showIcon($login = false) {
|
||||
$posX = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_VOTE_ICON_POSX);
|
||||
$posY = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_VOTE_ICON_POSY);
|
||||
$width = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_VOTE_ICON_WIDTH);
|
||||
$height = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_VOTE_ICON_HEIGHT);
|
||||
$pos = $this->maniaControl->getManialinkManager()->getSidebarMenuManager()->getEntryPosition(self::CUSTOMVOTES_MENU_ID);
|
||||
$width = $this->maniaControl->getSettingManager()->getSettingValue(SidebarMenuManager::class, SidebarMenuManager::SETTING_MENU_ITEMSIZE);
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle();
|
||||
$itemMarginFactorX = 1.3;
|
||||
@ -298,12 +282,12 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
//Custom Vote Menu Iconsframe
|
||||
$frame = new Frame();
|
||||
$maniaLink->addChild($frame);
|
||||
$frame->setPosition($posX, $posY);
|
||||
$frame->setPosition($pos['x'], $pos['y']);
|
||||
$frame->setZ(ManialinkManager::MAIN_MANIALINK_Z_VALUE);
|
||||
|
||||
$backgroundQuad = new Quad();
|
||||
$frame->addChild($backgroundQuad);
|
||||
$backgroundQuad->setSize($width * $itemMarginFactorX, $height * $itemMarginFactorY);
|
||||
$backgroundQuad->setSize($width * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
|
||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||
|
||||
$iconFrame = new Frame();
|
||||
@ -319,7 +303,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
$menuEntries = count($this->voteMenuItems);
|
||||
$descriptionFrame = new Frame();
|
||||
$maniaLink->addChild($descriptionFrame);
|
||||
$descriptionFrame->setPosition($posX - $menuEntries * $itemSize * 1.05 - 5, $posY);
|
||||
$descriptionFrame->setPosition($pos['x'] - $menuEntries * $itemSize * 1.05 - 5, $pos['y']);
|
||||
|
||||
$descriptionLabel = new Label();
|
||||
$descriptionFrame->addChild($descriptionLabel);
|
||||
@ -331,7 +315,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
//Popout Frame
|
||||
$popoutFrame = new Frame();
|
||||
$maniaLink->addChild($popoutFrame);
|
||||
$popoutFrame->setPosition($posX - $itemSize * 0.5, $posY);
|
||||
$popoutFrame->setPosition($pos['x'] - $itemSize * 0.5, $pos['y']);
|
||||
$popoutFrame->setHorizontalAlign($popoutFrame::RIGHT);
|
||||
$popoutFrame->setSize(4 * $itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
|
||||
$popoutFrame->setVisible(false);
|
||||
|
@ -19,6 +19,7 @@ use ManiaControl\Commands\CommandListener;
|
||||
use ManiaControl\ManiaControl;
|
||||
use ManiaControl\Manialinks\LabelLine;
|
||||
use ManiaControl\Manialinks\ManialinkManager;
|
||||
use ManiaControl\Manialinks\SidebarMenuManager;
|
||||
use ManiaControl\Players\Player;
|
||||
use ManiaControl\Players\PlayerManager;
|
||||
use ManiaControl\Plugins\Plugin;
|
||||
@ -41,14 +42,11 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
||||
const SETTING_ANNOUNCE_SERVER_DONATION = 'Enable Server-Donation Announcements';
|
||||
const STAT_PLAYER_DONATIONS = 'Donated Planets';
|
||||
const ACTION_DONATE_VALUE = 'Donate.DonateValue';
|
||||
const DONATIONPLUGIN_MENU_ID = 'DonationPlugin.MenuId';
|
||||
|
||||
// DonateWidget Properties
|
||||
const MLID_DONATE_WIDGET = 'DonationPlugin.DonateWidget';
|
||||
const SETTING_DONATE_WIDGET_ACTIVATED = 'Donate-Widget Activated';
|
||||
const SETTING_DONATE_WIDGET_POSX = 'Donate-Widget-Position: X';
|
||||
const SETTING_DONATE_WIDGET_POSY = 'Donate-Widget-Position: Y';
|
||||
const SETTING_DONATE_WIDGET_WIDTH = 'Donate-Widget-Size: Width';
|
||||
const SETTING_DONATE_WIDGET_HEIGHT = 'Donate-Widget-Size: Height';
|
||||
const SETTING_DONATION_VALUES = 'Donation Values';
|
||||
const SETTING_MIN_AMOUNT_SHOWN = 'Minimum Donation amount to get shown';
|
||||
|
||||
@ -118,18 +116,9 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
||||
// Define player stats
|
||||
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_PLAYER_DONATIONS);
|
||||
|
||||
$actionsPosX = $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getActionsMenu(), ActionsMenu::SETTING_MENU_POSX);
|
||||
$actionsPosY = $this->maniaControl->getActionsMenu()->getActionsMenuY();
|
||||
$iconSize = $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getActionsMenu(), ActionsMenu::SETTING_MENU_ITEMSIZE);
|
||||
|
||||
$itemMarginFactorY = 1.2;
|
||||
$posY = $actionsPosY - 3 * ($iconSize * $itemMarginFactorY);
|
||||
$this->maniaControl->getManialinkManager()->getSidebarMenuManager()->addMenuEntry(SidebarMenuManager::ORDER_PLAYER_MENU + 10, self::DONATIONPLUGIN_MENU_ID);
|
||||
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DONATE_WIDGET_ACTIVATED, true);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DONATE_WIDGET_POSX, $actionsPosX);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DONATE_WIDGET_POSY, $posY);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DONATE_WIDGET_WIDTH, 6);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DONATE_WIDGET_HEIGHT, 6);
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DONATION_VALUES, "20,50,100,500,1000,2000");
|
||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_MIN_AMOUNT_SHOWN, 100);
|
||||
|
||||
@ -155,10 +144,8 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
||||
* @param string $login
|
||||
*/
|
||||
public function displayDonateWidget($login = null) {
|
||||
$posX = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATE_WIDGET_POSX);
|
||||
$posY = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATE_WIDGET_POSY);
|
||||
$width = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATE_WIDGET_WIDTH);
|
||||
$height = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATE_WIDGET_HEIGHT);
|
||||
$pos = $this->maniaControl->getManialinkManager()->getSidebarMenuManager()->getEntryPosition(self::DONATIONPLUGIN_MENU_ID);
|
||||
$itemSize = $this->maniaControl->getSettingManager()->getSettingValue(SidebarMenuManager::class, SidebarMenuManager::SETTING_MENU_ITEMSIZE);
|
||||
$values = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATION_VALUES);
|
||||
$quadStyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadStyle();
|
||||
$quadSubstyle = $this->maniaControl->getManialinkManager()->getStyleManager()->getDefaultQuadSubstyle();
|
||||
@ -166,19 +153,17 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
||||
$itemMarginFactorY = 1.2;
|
||||
|
||||
|
||||
$itemSize = $width;
|
||||
|
||||
$maniaLink = new ManiaLink(self::MLID_DONATE_WIDGET);
|
||||
|
||||
// Donate Menu Icon Frame
|
||||
$frame = new Frame();
|
||||
$maniaLink->addChild($frame);
|
||||
$frame->setPosition($posX, $posY);
|
||||
$frame->setPosition($pos['x'], $pos['y']);
|
||||
$frame->setZ(ManialinkManager::MAIN_MANIALINK_Z_VALUE);
|
||||
|
||||
$backgroundQuad = new Quad();
|
||||
$frame->addChild($backgroundQuad);
|
||||
$backgroundQuad->setSize($width * $itemMarginFactorX, $height * $itemMarginFactorY);
|
||||
$backgroundQuad->setSize($itemSize * $itemMarginFactorX, $itemSize * $itemMarginFactorY);
|
||||
$backgroundQuad->setStyles($quadStyle, $quadSubstyle);
|
||||
|
||||
$iconFrame = new Frame();
|
||||
@ -230,7 +215,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
||||
$posX -= strlen($value) * 1.6 + 2.5;
|
||||
}
|
||||
|
||||
$descriptionFrame->setPosition($posX - $width + $itemMarginFactorX, 0);
|
||||
$descriptionFrame->setPosition($posX - $itemSize + $itemMarginFactorX, 0);
|
||||
|
||||
//Popout background
|
||||
$quad = new Quad();
|
||||
|
Loading…
Reference in New Issue
Block a user