Added filter and sort settings to GameMode-Settings
This commit is contained in:
parent
01efa96f83
commit
0148923268
@ -42,13 +42,19 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
|
|||||||
const CB_SCRIPTSETTING_CHANGED = 'GameModeSettings.SettingChanged';
|
const CB_SCRIPTSETTING_CHANGED = 'GameModeSettings.SettingChanged';
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
const CB_SCRIPTSETTINGS_CHANGED = 'GameModeSettings.SettingsChanged';
|
const CB_SCRIPTSETTINGS_CHANGED = 'GameModeSettings.SettingsChanged';
|
||||||
|
|
||||||
const TABLE_GAMEMODE_SETTINGS = 'mc_gamemodesettings';
|
const TABLE_GAMEMODE_SETTINGS = 'mc_gamemodesettings';
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
const TABLE_SCRIPT_SETTINGS = 'mc_scriptsettings';
|
const TABLE_SCRIPT_SETTINGS = 'mc_scriptsettings';
|
||||||
|
|
||||||
|
const DESCRIPTION_HIDDEN = '<hidden>';
|
||||||
|
|
||||||
|
const SETTING_HIDE_SETTINGS_WITH_DESCRIPTION_HIDDEN = 'Hide Settings with Description "' . self::DESCRIPTION_HIDDEN . '"';
|
||||||
const SETTING_LOAD_DEFAULT_SETTINGS_MAP_BEGIN = 'Load Stored GameMode-Settings on Map-Begin';
|
const SETTING_LOAD_DEFAULT_SETTINGS_MAP_BEGIN = 'Load Stored GameMode-Settings on Map-Begin';
|
||||||
const SETTING_PERMISSION_CHANGE_MODE_SETTINGS = 'Change GameMode-Settings';
|
const SETTING_PERMISSION_CHANGE_MODE_SETTINGS = 'Change GameMode-Settings';
|
||||||
/** @deprecated */
|
/** @deprecated */
|
||||||
const SETTING_PERMISSION_CHANGE_SCRIPT_SETTINGS = 'Change Script-Settings';
|
const SETTING_PERMISSION_CHANGE_SCRIPT_SETTINGS = 'Change Script-Settings';
|
||||||
|
const SETTING_SORT_SETTINGS = 'Sort Settings';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Private properties
|
* Private properties
|
||||||
@ -70,7 +76,9 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
|
|||||||
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'onBeginMap');
|
$this->maniaControl->getCallbackManager()->registerCallbackListener(Callbacks::BEGINMAP, $this, 'onBeginMap');
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_HIDE_SETTINGS_WITH_DESCRIPTION_HIDDEN, true);
|
||||||
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_LOAD_DEFAULT_SETTINGS_MAP_BEGIN, false);
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_LOAD_DEFAULT_SETTINGS_MAP_BEGIN, false);
|
||||||
|
$this->maniaControl->getSettingManager()->initSetting($this, self::SETTING_SORT_SETTINGS, true);
|
||||||
|
|
||||||
// Permissions
|
// Permissions
|
||||||
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_CHANGE_MODE_SETTINGS, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
$this->maniaControl->getAuthenticationManager()->definePermissionLevel(self::SETTING_PERMISSION_CHANGE_MODE_SETTINGS, AuthenticationManager::AUTH_LEVEL_ADMIN);
|
||||||
@ -270,6 +278,8 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
|
|||||||
* @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) {
|
||||||
|
$isScriptMode = $this->maniaControl->getServer()->getScriptManager()->isScriptMode();
|
||||||
|
|
||||||
$paging = new Paging();
|
$paging = new Paging();
|
||||||
$script->addFeature($paging);
|
$script->addFeature($paging);
|
||||||
$frame = new Frame();
|
$frame = new Frame();
|
||||||
@ -280,11 +290,22 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
|
|||||||
try {
|
try {
|
||||||
$gameModeSettings = $this->getGameModeSettingsArray();
|
$gameModeSettings = $this->getGameModeSettingsArray();
|
||||||
|
|
||||||
if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) {
|
if ($isScriptMode) {
|
||||||
$scriptInfo = $this->maniaControl->getClient()->getModeScriptInfo();
|
$scriptInfo = $this->maniaControl->getClient()->getModeScriptInfo();
|
||||||
$scriptParams = $scriptInfo->paramDescs;
|
$scriptParams = $scriptInfo->paramDescs;
|
||||||
|
|
||||||
|
$hideSettingsWithDescriptionHidden = $this->maniaControl->getSettingManager()->getSettingValue($this, self::SETTING_HIDE_SETTINGS_WITH_DESCRIPTION_HIDDEN);
|
||||||
|
if ($hideSettingsWithDescriptionHidden) {
|
||||||
|
$scriptParams = array_filter($scriptParams, function ($scriptParam) {
|
||||||
|
return $scriptParam->desc !== self::DESCRIPTION_HIDDEN;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
usort($scriptParams, function ($a, $b) {
|
||||||
|
return $a->name === $b->name ? 0 : ($a->name < $b->name ? -1 : 1);
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
$scriptParams = $gameModeSettings[0];
|
$scriptParams = $gameModeSettings[0];
|
||||||
|
ksort($scriptParams);
|
||||||
}
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$label = new Label();
|
$label = new Label();
|
||||||
@ -323,7 +344,7 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
|
|||||||
|
|
||||||
$paging->setLabel($pageCountLabel);
|
$paging->setLabel($pageCountLabel);
|
||||||
|
|
||||||
if (!$this->maniaControl->getServer()->getScriptManager()->isScriptMode()) {
|
if (!$isScriptMode) {
|
||||||
$descriptionLabel = new Label();
|
$descriptionLabel = new Label();
|
||||||
$frame->addChild($descriptionLabel);
|
$frame->addChild($descriptionLabel);
|
||||||
$descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT);
|
$descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT);
|
||||||
@ -343,7 +364,7 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
|
|||||||
foreach ($scriptParams as $key => $scriptParam) {
|
foreach ($scriptParams as $key => $scriptParam) {
|
||||||
$settingName = null;
|
$settingName = null;
|
||||||
$settingValue = null;
|
$settingValue = null;
|
||||||
if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) {
|
if ($isScriptMode) {
|
||||||
$settingName = $scriptParam->name;
|
$settingName = $scriptParam->name;
|
||||||
if (!isset($gameModeSettings[$settingName])) {
|
if (!isset($gameModeSettings[$settingName])) {
|
||||||
continue;
|
continue;
|
||||||
@ -380,7 +401,7 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
|
|||||||
$nameLabel->setTextSize($labelTextSize);
|
$nameLabel->setTextSize($labelTextSize);
|
||||||
$nameLabel->setX(-0.46 * $width);
|
$nameLabel->setX(-0.46 * $width);
|
||||||
|
|
||||||
if (!$this->maniaControl->getServer()->getScriptManager()->isScriptMode()) {
|
if (!$isScriptMode) {
|
||||||
if (is_bool($settingValue[0])) {
|
if (is_bool($settingValue[0])) {
|
||||||
$activeQuad = new Quad_Icons64x64_1();
|
$activeQuad = new Quad_Icons64x64_1();
|
||||||
$settingFrame->addChild($activeQuad);
|
$settingFrame->addChild($activeQuad);
|
||||||
@ -426,7 +447,7 @@ class GameModeSettings implements ConfiguratorMenu, CallbackListener, Communicat
|
|||||||
$entry->setX(0.275 * $width);
|
$entry->setX(0.275 * $width);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->maniaControl->getServer()->getScriptManager()->isScriptMode()) {
|
if ($isScriptMode) {
|
||||||
$descriptionLabel = new Label();
|
$descriptionLabel = new Label();
|
||||||
$pageFrame->addChild($descriptionLabel);
|
$pageFrame->addChild($descriptionLabel);
|
||||||
$descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT);
|
$descriptionLabel->setHorizontalAlign($descriptionLabel::LEFT);
|
||||||
|
Loading…
Reference in New Issue
Block a user