Same bug disabling widgets for donations and general widgets fixed

This commit is contained in:
Alexander Nell 2020-03-16 11:11:17 +01:00
parent 60a4e9760f
commit eba2b56653
2 changed files with 30 additions and 3 deletions

View File

@ -24,6 +24,8 @@ use ManiaControl\Manialinks\SidebarMenuManager;
use ManiaControl\Players\Player;
use ManiaControl\Players\PlayerManager;
use ManiaControl\Plugins\Plugin;
use ManiaControl\Settings\Setting;
use ManiaControl\Settings\SettingManager;
/**
* ManiaControl Donation Plugin
@ -37,7 +39,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin, Sideb
* Constants
*/
const ID = 3;
const VERSION = 0.1;
const VERSION = 0.11;
const AUTHOR = 'MCTeam';
const NAME = 'Donation Plugin';
const SETTING_ANNOUNCE_SERVER_DONATION = 'Enable Server-Donation Announcements';
@ -113,6 +115,7 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin, Sideb
// Register for callbacks
$this->maniaControl->getCallbackManager()->registerCallbackListener(PlayerManager::CB_PLAYERCONNECT, $this, 'handlePlayerConnect');
$this->maniaControl->getCallbackManager()->registerCallbackListener(CallbackManager::CB_MP_PLAYERMANIALINKPAGEANSWER, $this, 'handleManialinkPageAnswer');
$this->maniaControl->getCallbackManager()->registerCallbackListener(SettingManager::CB_SETTING_CHANGED, $this, 'handleSettingChanged');
// Define player stats
$this->maniaControl->getStatisticManager()->defineStatMetaData(self::STAT_PLAYER_DONATIONS);
@ -137,6 +140,8 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin, Sideb
public function displayWidget() {
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_DONATE_WIDGET_ACTIVATED)) {
$this->displayDonateWidget();
} else {
$this->maniaControl->getManialinkManager()->hideManialink(self::MLID_DONATE_WIDGET);
}
}
@ -237,6 +242,20 @@ class DonationPlugin implements CallbackListener, CommandListener, Plugin, Sideb
$this->maniaControl->getManialinkManager()->hideManialink(self::MLID_DONATE_WIDGET);
}
/**
* Handle Setting Changed Callback
*
* @internal
* @param Setting $setting
*/
public function handleSettingChanged(Setting $setting) {
if (!$setting->belongsToClass($this)) {
return;
}
$this->displayWidget();
}
/**
* Handle ManialinkPageAnswer Callback
*

View File

@ -36,7 +36,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
* Constants
*/
const PLUGIN_ID = 1;
const PLUGIN_VERSION = 0.11;
const PLUGIN_VERSION = 0.12;
const PLUGIN_NAME = 'WidgetPlugin';
const PLUGIN_AUTHOR = 'MCTeam';
@ -213,12 +213,20 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_MAP_WIDGET_ACTIVATED)) {
$this->maniaControl->getModeScriptEventManager()->setSiegeProgressionUIPosition("160.", "-67.", "0.");
$this->displayMapWidget();
} else {
$this->closeWidget(self::MLID_MAP_WIDGET);
}
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_CLOCK_WIDGET_ACTIVATED)) {
$this->displayClockWidget();
} else {
$this->closeWidget(self::MLID_CLOCK_WIDGET);
}
if ($this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_SERVERINFO_WIDGET_ACTIVATED)) {
$this->displayServerInfoWidget();
} else {
$this->closeWidget(self::MLID_SERVERINFO_WIDGET);
}
}
@ -619,7 +627,7 @@ class WidgetPlugin implements CallbackListener, TimerListener, Plugin {
*/
public function updateSettings(Setting $setting) {
if ($setting->belongsToClass($this)) {
$this->displayWIdgets();
$this->displayWidgets();
//Update Nadeo Default Widgets
if ($setting->setting == self::SETTING_TM_LIVE_INFO_WIDGET_POSX || $setting->setting == self::SETTING_TM_LIVE_INFO_WIDGET_POSY) {