settings menus improvements
This commit is contained in:
parent
6d6189a714
commit
ef1ccd7b44
application/core/Configurators
@ -27,6 +27,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
const ACTION_PREFIX_SETTING = 'ScriptSetting.';
|
const ACTION_PREFIX_SETTING = 'ScriptSetting.';
|
||||||
const ACTION_SETTING_BOOL = 'ScriptSetting.ActionBoolSetting.';
|
const ACTION_SETTING_BOOL = 'ScriptSetting.ActionBoolSetting.';
|
||||||
const CB_SCRIPTSETTING_CHANGED = 'ScriptSettings.SettingChanged';
|
const CB_SCRIPTSETTING_CHANGED = 'ScriptSettings.SettingChanged';
|
||||||
|
const CB_SCRIPTSETTINGS_CHANGED = 'ScriptSettings.SettingsChanged';
|
||||||
const TABLE_SCRIPT_SETTINGS = 'mc_scriptsettings';
|
const TABLE_SCRIPT_SETTINGS = 'mc_scriptsettings';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -356,6 +357,7 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
*
|
*
|
||||||
* @param array $newSettings
|
* @param array $newSettings
|
||||||
* @param Player $player
|
* @param Player $player
|
||||||
|
* @param bool
|
||||||
*/
|
*/
|
||||||
private function applyNewScriptSettings(array $newSettings, Player $player) {
|
private function applyNewScriptSettings(array $newSettings, Player $player) {
|
||||||
if (!$newSettings) return true;
|
if (!$newSettings) return true;
|
||||||
@ -413,9 +415,11 @@ class ScriptSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
}
|
}
|
||||||
$statement->close();
|
$statement->close();
|
||||||
|
|
||||||
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_SCRIPTSETTINGS_CHANGED, array(self::CB_SCRIPTSETTINGS_CHANGED));
|
||||||
|
|
||||||
$chatMessage .= '!';
|
$chatMessage .= '!';
|
||||||
$this->maniaControl->chat->sendInformation($chatMessage);
|
$this->maniaControl->chat->sendInformation($chatMessage);
|
||||||
$this->maniaControl->log(Formatter::stripCodes($chatMessage));
|
$this->maniaControl->log($chatMessage, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
const ACTION_PREFIX_SETTING = 'ServerSettings.';
|
const ACTION_PREFIX_SETTING = 'ServerSettings.';
|
||||||
const ACTION_SETTING_BOOL = 'ServerSettings.ActionBoolSetting.';
|
const ACTION_SETTING_BOOL = 'ServerSettings.ActionBoolSetting.';
|
||||||
const CB_SERVERSETTING_CHANGED = 'ServerSettings.SettingChanged';
|
const CB_SERVERSETTING_CHANGED = 'ServerSettings.SettingChanged';
|
||||||
|
const CB_SERVERSETTINGS_CHANGED = 'ServerSettings.SettingsChanged';
|
||||||
const TABLE_SERVER_SETTINGS = 'mc_serversettings';
|
const TABLE_SERVER_SETTINGS = 'mc_serversettings';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -102,7 +103,7 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$serverSettings = $this->maniaControl->client->getResponse();
|
$serverSettings = $this->maniaControl->client->getResponse();
|
||||||
$loadedSettings = array();
|
$loadedSettings = array();
|
||||||
while ($row = $result->fetch_object()) {
|
while ($row = $result->fetch_object()) {
|
||||||
if (!$serverSettings[$row->settingName]) continue;
|
if (!isset($serverSettings[$row->settingName])) continue;
|
||||||
$loadedSettings[$row->settingName] = $row->settingValue;
|
$loadedSettings[$row->settingName] = $row->settingValue;
|
||||||
settype($loadedSettings[$row->settingName], gettype($serverSettings[$row->settingName]));
|
settype($loadedSettings[$row->settingName], gettype($serverSettings[$row->settingName]));
|
||||||
}
|
}
|
||||||
@ -303,9 +304,7 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
public function handleManialinkPageAnswer(array $callback) {
|
public function handleManialinkPageAnswer(array $callback) {
|
||||||
$actionId = $callback[1][2];
|
$actionId = $callback[1][2];
|
||||||
$boolSetting = (strpos($actionId, self::ACTION_SETTING_BOOL) === 0);
|
$boolSetting = (strpos($actionId, self::ACTION_SETTING_BOOL) === 0);
|
||||||
if (!$boolSetting) {
|
if (!$boolSetting) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$login = $callback[1][1];
|
$login = $callback[1][1];
|
||||||
$player = $this->maniaControl->playerManager->getPlayer($login);
|
$player = $this->maniaControl->playerManager->getPlayer($login);
|
||||||
@ -322,9 +321,7 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function applyNewScriptSettings(array $newSettings, Player $player) {
|
private function applyNewScriptSettings(array $newSettings, Player $player) {
|
||||||
if (!$newSettings) {
|
if (!$newSettings) return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
$success = $this->maniaControl->client->query('SetServerOptions', $newSettings);
|
$success = $this->maniaControl->client->query('SetServerOptions', $newSettings);
|
||||||
if (!$success) {
|
if (!$success) {
|
||||||
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
|
$this->maniaControl->chat->sendError('Error occurred: ' . $this->maniaControl->getClientErrorText(), $player->login);
|
||||||
@ -355,8 +352,8 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
$settingIndex = 0;
|
$settingIndex = 0;
|
||||||
$title = $this->maniaControl->authenticationManager->getAuthLevelName($player->authLevel);
|
$title = $this->maniaControl->authenticationManager->getAuthLevelName($player->authLevel);
|
||||||
// $chatMessage = '$ff0' . $title . ' $<' . $player->nickname . '$> set ScriptSetting' . ($settingsCount > 1 ? 's' : '') . ' ';
|
// $chatMessage = '$ff0' . $title . ' $<' . $player->nickname . '$> set ScriptSetting' . ($settingsCount > 1 ? 's' : '') . ' ';
|
||||||
|
|
||||||
foreach ($newSettings as $setting => $value) {
|
foreach ($newSettings as $setting => $value) {
|
||||||
|
|
||||||
$statement->bind_param('iss', $serverIndex, $setting, $value);
|
$statement->bind_param('iss', $serverIndex, $setting, $value);
|
||||||
$statement->execute();
|
$statement->execute();
|
||||||
if ($statement->error) {
|
if ($statement->error) {
|
||||||
@ -381,6 +378,8 @@ class ServerSettings implements ConfiguratorMenu, CallbackListener {
|
|||||||
|
|
||||||
$statement->close();
|
$statement->close();
|
||||||
|
|
||||||
|
$this->maniaControl->callbackManager->triggerCallback(self::CB_SERVERSETTINGS_CHANGED, array(self::CB_SERVERSETTINGS_CHANGED));
|
||||||
|
|
||||||
// $chatMessage .= '!';
|
// $chatMessage .= '!';
|
||||||
// $this->maniaControl->chat->sendInformation($chatMessage);
|
// $this->maniaControl->chat->sendInformation($chatMessage);
|
||||||
// $this->maniaControl->log(Formatter::stripCodes($chatMessage));
|
// $this->maniaControl->log(Formatter::stripCodes($chatMessage));
|
||||||
|
Loading…
Reference in New Issue
Block a user