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);
            }
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        /// <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);
        }