using System; using System.Collections.Generic; public class GetGamePrefs : ConsoleCommand { private string[] forbiddenPrefs = new string[] { "telnet", "adminfilename", "controlpanel", "password", "savegamefolder", "options", "last" }; private bool prefAccessAllowed (EnumGamePrefs gp) { string gpName = gp.ToString ().ToLower (); foreach (string s in forbiddenPrefs) { if (gpName.Contains (s)) { return false; } } return true; } public GetGamePrefs (ConsoleSdtd cons) : base(cons) { } public override string Description () { return "gets a game pref"; } public override string[] Names () { return new string[] { "getgamepref", "gg" }; } public override void Run (string[] _params) { if (_params.Length <= 0) { SortedList sortedList = new SortedList (); foreach (EnumGamePrefs gp in Enum.GetValues(typeof(EnumGamePrefs))) { if (prefAccessAllowed (gp)) sortedList.Add (gp.ToString (), string.Format ("{0} = {1}", gp.ToString (), GamePrefs.GetObject (gp))); } foreach (string s in sortedList.Keys) { m_Console.md000a (sortedList [s]); } return; } EnumGamePrefs enumGamePrefs; try { enumGamePrefs = (EnumGamePrefs)((int)Enum.Parse (typeof(EnumGamePrefs), _params [0])); } catch (Exception) { m_Console.md000a ("Error parsing parameter: " + _params [0]); return; } if (prefAccessAllowed (enumGamePrefs)) m_Console.md000a (string.Format ("{0} = {1}", enumGamePrefs, GamePrefs.GetObject (enumGamePrefs))); else m_Console.md000a ("Access to requested preference is forbidden"); } }