/// <summary>
        /// Gets or creates a high score table for the current game
        /// settings.
        /// </summary>
        public HighScoreTable GetTable(Config config)
        {
            // Go through the list
            foreach (HighScoreTable table in Tables)
            {
                // See if it matches
                if (config.SelectionType == table.SelectionType &&
                    config.BoardSize == table.BoardSize &&
                    config.LanguageName == table.LanguageName)
                {
                    // This is it
                    return table;
                }
            }

            // Create a new one
            HighScoreTable hst = new HighScoreTable();
            hst.SelectionType = config.SelectionType;
            hst.BoardSize = config.BoardSize;
            hst.LanguageName = config.LanguageName;

            // Add and return it
            Tables.Add(hst);
            return hst;
        }
Exemple #2
0
        /// <summary>
        /// Loads the game configuration into memory.
        /// </summary>
        public static void LoadConfig()
        {
            // Load the high score list
            try
            {
                // Get the filename
                string filename = HighScoreFilename;
                FileInfo file = new FileInfo(filename);

                // Deserialize it
                TextReader reader = file.OpenText();
                XmlSerializer serializer = new XmlSerializer(typeof(HighScoreTableList));
                highScores = (HighScoreTableList) serializer.Deserialize(reader);
                reader.Close();
            }
            catch
            {
            }

            // Load our configuration
            try
            {
                // Get the filename
                string filename = ConfigFilename;
                FileInfo file = new FileInfo(filename);

                // Deserialize it
                TextReader reader = file.OpenText();
                XmlSerializer serializer = new XmlSerializer(typeof(Config));
                config = (Config) serializer.Deserialize(reader);
                reader.Close();

                // Set the theme
                theme = Config.Theme;
            }
            catch
            {
            }
        }