Added SidebarMenuManager Fixed https://github.com/ManiaControl/ManiaControl/issues/97
This commit is contained in:
@ -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';
|
||||
@ -69,9 +65,9 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP
|
||||
const SETTING_SPECTATOR_ALLOW_VOTE = 'Allow Spectators to vote';
|
||||
const SETTING_SPECTATOR_ALLOW_START_VOTE = 'Allow Spectators to start a vote';
|
||||
|
||||
const MLID_WIDGET = 'CustomVotesPlugin.WidgetId';
|
||||
const MLID_ICON = 'CustomVotesPlugin.IconWidgetId';
|
||||
|
||||
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();
|
||||
@ -494,9 +479,9 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
||||
|
||||
$labelLine = new LabelLine($headFrame);
|
||||
$labelLine->setPrefix('$o');
|
||||
$labelLine->addLabelEntryText('Id',$posX + 5);
|
||||
$labelLine->addLabelEntryText('Id', $posX + 5);
|
||||
$labelLine->addLabelEntryText('Nickname', $posX + 18);
|
||||
$labelLine->addLabelEntryText('Login',$posX + 70);
|
||||
$labelLine->addLabelEntryText('Login', $posX + 70);
|
||||
$labelLine->addLabelEntryText('Donated planets', $posX + 110);
|
||||
$labelLine->render();
|
||||
|
||||
@ -528,9 +513,9 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin {
|
||||
|
||||
$labelLine = new LabelLine($playerFrame);
|
||||
$labelLine->addLabelEntryText($index, $posX + 5, 13);
|
||||
$labelLine->addLabelEntryText($donatingPlayer->nickname,$posX + 18, 52);
|
||||
$labelLine->addLabelEntryText($donatingPlayer->login,$posX + 70, 40);
|
||||
$labelLine->addLabelEntryText($donations,$posX + 110, $width / 2 - ($posX + 110));
|
||||
$labelLine->addLabelEntryText($donatingPlayer->nickname, $posX + 18, 52);
|
||||
$labelLine->addLabelEntryText($donatingPlayer->login, $posX + 70, 40);
|
||||
$labelLine->addLabelEntryText($donations, $posX + 110, $width / 2 - ($posX + 110));
|
||||
$labelLine->render();
|
||||
|
||||
$posY -= 4;
|
||||
|
Reference in New Issue
Block a user