public static string[] arrayGames() { List <string> lg; try { lg = SPConfig.listGameNames(); if (lg.Count < 1) { MessageBox.Show("Error! Invalid number of Games on Settings File! The file might be corrupted!", "**Error**", MessageBoxButtons.OK, MessageBoxIcon.Error); string[] arrayError = { "SETTINGS ERROR!" }; return(arrayError); } string[] arrayGames = lg.ToArray(); return(arrayGames); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); string[] arrayError = { "SETTINGS ERROR!" }; return(arrayError); } }
/// <summary> /// Get PathsHelper object /// </summary> /// <param name="gameName"></param> /// <returns></returns> public static PathsHelper getPathsHelper(string gameName) { SPConfig config = SPConfig.loadConfig(); SPGame gameSettings = SettingsFactory.getGameSettings(gameName); SPSettings settings = SettingsFactory.getSettings(); PathsHelper paths = new PathsHelper(settings, gameSettings); return(paths); }
/// <summary> /// Tells if a game name exists on the list of configured games. /// </summary> /// <param name="gameName"></param> /// <returns></returns> public static bool gameExist(string gameName) { List <string> listGames = SPConfig.listGameNames(); if (!listGames.Contains(gameName)) { return(false); } return(true); }
/// <summary> /// Return a list of configured games /// </summary> /// <returns></returns> public static List <string> listGameNames() { SPConfig config = SPConfig.loadConfig(); List <string> listGamesStr = new List <string>(); List <SPGame> listGames = config.listGames; if (listGames != null) { foreach (var item in listGames) { string gamaStr = item.game.Trim(); listGamesStr.Add(gamaStr); } } return(listGamesStr); }
/// <summary> /// Returns a valid profile name. /// </summary> /// <param name="name"></param> /// <param name="inUse"></param> /// <returns></returns> public string safeNewProfileName(string name, List <string> inUse) { // check if name is empty if (name == null) { name = ""; } if (name.Trim().Equals("")) { name = "NO_NAME"; } // make sure is alphanumeric CSharp.alphaNumeric(name); //append to list of inUse Values List <string> lg = SPConfig.listGameNames(); if (lg != null) { foreach (var item in lg) { inUse.Add(item); } } inUse.Add(this._gameFolder); inUse.Add(this._backupFolder); // if value already exist, create a counter int sufix = 0; string cleanName = name; while (inUse.Contains(name)) { sufix++; name = cleanName + "_" + sufix.ToString(); } return(name); }
/// <summary> /// returns SPGame object. /// </summary> /// <param name="gameName"></param> /// <returns></returns> public static SPGame getGameSettings(string gameName) { SPConfig config = SPConfig.loadConfig(); return(config.selectGame(gameName)); }
/// <summary> /// returns SPSettings object /// </summary> /// <returns></returns> public static SPSettings getSettings() { SPConfig config = SPConfig.loadConfig(); return(config.settings);; }