diff --git a/core/Admin/ActionsMenu.php b/core/Admin/ActionsMenu.php index aff5e45e..97c69c3b 100644 --- a/core/Admin/ActionsMenu.php +++ b/core/Admin/ActionsMenu.php @@ -17,6 +17,8 @@ use ManiaControl\Manialinks\ManialinkManager; use ManiaControl\Manialinks\ManialinkPageAnswerListener; use ManiaControl\Players\Player; use ManiaControl\Players\PlayerManager; +use ManiaControl\Settings\Setting; +use ManiaControl\Settings\SettingManager; /** * Class managing Actions Menus @@ -65,6 +67,8 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, Usag $this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::AFTERINIT, $this, 'handleAfterInit'); $this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerJoined'); $this->maniaControl->getCallbackManager()->registerCallbackListener(AuthenticationManager::CB_AUTH_LEVEL_CHANGED, $this, 'handlePlayerJoined'); + $this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'handleSettingChanged'); + } /** @@ -329,4 +333,17 @@ class ActionsMenu implements CallbackListener, ManialinkPageAnswerListener, Usag $maniaLink = $this->buildMenuIconsManialink($player); $this->maniaControl->getManialinkManager()->sendManialink($maniaLink, $player); } + + /** + * Handle Setting Changed Callback + * + * @param Setting $setting + */ + public function handleSettingChanged(Setting $setting) { + if (!$setting->belongsToClass($this)) { + return; + } + + $this->rebuildAndShowMenu(); + } } diff --git a/plugins/MCTeam/CustomVotesPlugin.php b/plugins/MCTeam/CustomVotesPlugin.php index 2bd25f44..cc9521fb 100644 --- a/plugins/MCTeam/CustomVotesPlugin.php +++ b/plugins/MCTeam/CustomVotesPlugin.php @@ -15,6 +15,7 @@ use FML\Controls\Quads\Quad_Icons64x64_1; use FML\Controls\Quads\Quad_UIConstruction_Buttons; use FML\ManiaLink; use FML\Script\Features\KeyAction; +use ManiaControl\Admin\ActionsMenu; use ManiaControl\Callbacks\CallbackListener; use ManiaControl\Callbacks\CallbackManager; use ManiaControl\Callbacks\Callbacks; @@ -29,6 +30,8 @@ use ManiaControl\Plugins\Plugin; use ManiaControl\Script\ScriptManager; use ManiaControl\Server\Commands; use ManiaControl\Server\Server; +use ManiaControl\Settings\Setting; +use ManiaControl\Settings\SettingManager; use ManiaControl\Utils\ColorUtil; use Maniaplanet\DedicatedServer\Structures\VoteRatio; use Maniaplanet\DedicatedServer\Xmlrpc\ChangeInProgressException; @@ -47,7 +50,7 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP * Constants */ const PLUGIN_ID = 5; - const PLUGIN_VERSION = 0.1; + const PLUGIN_VERSION = 0.2; const PLUGIN_NAME = 'CustomVotesPlugin'; const PLUGIN_AUTHOR = 'kremsy'; @@ -148,10 +151,18 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP $this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect'); $this->maniaControl->getCallbackManager()->registerCallbackListener(Server::CB_TEAM_MODE_CHANGED, $this, 'constructMenu'); $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->getSettingManager()->getSettingValue($this->maniaControl->getActionsMenu(), ActionsMenu::SETTING_MENU_POSY); + $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, 156.); - $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_VOTE_ICON_POSY, -38.6); + $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); @@ -794,6 +805,19 @@ class CustomVotesPlugin implements CommandListener, CallbackListener, ManialinkP // Send manialink $this->maniaControl->getManialinkManager()->sendManialink($maniaLink); } + + /** + * Handle Setting Changed Callback + * + * @param Setting $setting + */ + public function handleSettingChanged(Setting $setting) { + if (!$setting->belongsToClass($this)) { + return; + } + + $this->constructMenu(); + } } /** diff --git a/plugins/MCTeam/DonationPlugin.php b/plugins/MCTeam/DonationPlugin.php index f4e388bd..1842bee9 100644 --- a/plugins/MCTeam/DonationPlugin.php +++ b/plugins/MCTeam/DonationPlugin.php @@ -10,6 +10,7 @@ use FML\Controls\Quads\Quad_BgRaceScore2; use FML\Controls\Quads\Quad_BgsPlayerCard; use FML\ManiaLink; use FML\Script\Features\Paging; +use ManiaControl\Admin\ActionsMenu; use ManiaControl\Admin\AuthenticationManager; use ManiaControl\Bills\BillManager; use ManiaControl\Callbacks\CallbackListener; @@ -116,9 +117,16 @@ 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->getSettingManager()->getSettingValue($this->maniaControl->getActionsMenu(), ActionsMenu::SETTING_MENU_POSY); + $iconSize = $this->maniaControl->getSettingManager()->getSettingValue($this->maniaControl->getActionsMenu(), ActionsMenu::SETTING_MENU_ITEMSIZE); + + $itemMarginFactorY = 1.2; + $posY = $actionsPosY - 3 * ($iconSize * $itemMarginFactorY); + $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DONATE_WIDGET_ACTIVATED, true); - $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DONATE_WIDGET_POSX, 156.); - $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_DONATE_WIDGET_POSY, -31.4); + $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"); @@ -191,7 +199,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { // Values Menu $popoutFrame = new Frame(); $frame->addChild($popoutFrame); - $popoutFrame->setPosition(- $itemSize * 0.5, 0); + $popoutFrame->setPosition(-$itemSize * 0.5, 0); $popoutFrame->setHorizontalAlign($popoutFrame::RIGHT); $popoutFrame->setVisible(false); @@ -210,7 +218,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { $descriptionLabel->setVisible(true); // Add items - $posX = -2; + $posX = -2; foreach (array_reverse($valueArray) as $value) { $label = new Label_Text(); $popoutFrame->addChild($label); @@ -226,7 +234,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin { $posX -= strlen($value) * 1.6 + 2.5; } - $descriptionFrame->setPosition( $posX - $width + $itemMarginFactorX, 0); + $descriptionFrame->setPosition($posX - $width + $itemMarginFactorX, 0); //Popout background $quad = new Quad(); diff --git a/plugins/MCTeam/LocalRecordsPlugin.php b/plugins/MCTeam/LocalRecordsPlugin.php index 4a10f3a8..4b519e25 100644 --- a/plugins/MCTeam/LocalRecordsPlugin.php +++ b/plugins/MCTeam/LocalRecordsPlugin.php @@ -38,7 +38,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList * Constants */ const ID = 7; - const VERSION = 0.2; + const VERSION = 0.3; const NAME = 'Local Records Plugin'; const AUTHOR = 'MCTeam'; const MLID_RECORDS = 'ml_local_records'; @@ -352,6 +352,9 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList } break; } + default: + $this->updateManialink = true; + break; } } @@ -592,7 +595,7 @@ class LocalRecordsPlugin implements CallbackListener, CommandListener, TimerList $pageFrame = new Frame(); $frame->addChild($pageFrame); $posY = $height / 2 - 10; - $paging->addPage($pageFrame); + $paging->addPageControl($pageFrame); } $recordFrame = new Frame();