New Plugin-Install-Filter for MC-version eligibility

This commit is contained in:
Alexander Nell 2020-05-19 14:41:35 +02:00
parent d6487953fe
commit ab3e39086c

View File

@ -31,6 +31,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
const ACTION_PREFIX_INSTALL_PLUGIN = 'PluginInstallMenu.Install.'; const ACTION_PREFIX_INSTALL_PLUGIN = 'PluginInstallMenu.Install.';
const ACTION_REFRESH_LIST = 'PluginInstallMenu.RefreshList'; const ACTION_REFRESH_LIST = 'PluginInstallMenu.RefreshList';
const SETTING_GAME_ONLY = 'Display only Plugins eligible for your game'; const SETTING_GAME_ONLY = 'Display only Plugins eligible for your game';
const SETTING_VERSION_ONLY = 'Display only Plugins eligible for your MC-version';
/* /*
* Private properties * Private properties
@ -51,6 +52,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
//Settings //Settings
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_GAME_ONLY, true); $this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_GAME_ONLY, true);
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_VERSION_ONLY, true);
// Callbacks // Callbacks
$this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_REFRESH_LIST, $this, 'handleRefreshListAction'); $this->maniaControl->getManialinkManager()->registerManialinkPageAnswerListener(self::ACTION_REFRESH_LIST, $this, 'handleRefreshListAction');
@ -67,8 +69,8 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
* @see \ManiaControl\Configurator\ConfiguratorMenu::getMenu() * @see \ManiaControl\Configurator\ConfiguratorMenu::getMenu()
*/ */
public function getMenu($width, $height, Script $script, Player $player) { public function getMenu($width, $height, Script $script, Player $player) {
$gameOnly = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_GAME_ONLY);
$gameOnly = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_GAME_ONLY); $versionOnly = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_VERSION_ONLY);
$paging = new Paging(); $paging = new Paging();
$script->addFeature($paging); $script->addFeature($paging);
@ -128,6 +130,11 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
continue; continue;
} }
$isPluginCompatible = $this->isPluginCompatible($plugin);
if ($versionOnly && !$isPluginCompatible) {
continue;
}
if ($index % 10 === 0) { if ($index % 10 === 0) {
// New page // New page
$pageFrame = new Frame(); $pageFrame = new Frame();
@ -148,7 +155,7 @@ class InstallMenu implements ConfiguratorMenu, ManialinkPageAnswerListener {
$infoTooltipLabel->setLineSpacing(1); $infoTooltipLabel->setLineSpacing(1);
$nameLabel->addTooltipLabelFeature($infoTooltipLabel, $description); $nameLabel->addTooltipLabelFeature($infoTooltipLabel, $description);
if (!$this->isPluginCompatible($plugin)) { if (!$isPluginCompatible) {
// Incompatibility label // Incompatibility label
$infoLabel = new Label_Text(); $infoLabel = new Label_Text();
$pluginFrame->addChild($infoLabel); $pluginFrame->addChild($infoLabel);