Exemple #1
0
 /// <summary>
 /// Changes the current game version to the desired game version.
 /// </summary>
 /// <param name="newVersion"></param>
 public void ChangeGameVersion(GameVersion newVersion)
 {
     foreach (GameVersionSettings gameVersionSetting in GameVersionSettings)
     {
         if (newVersion.Equals(gameVersionSetting.Game_Version))
         {
             current_GameVersionSettings = gameVersionSetting;
             return;
         }
     }
 }
Exemple #2
0
        /// <summary>
        /// Creates a new game version settings list.
        /// </summary>
        private void New_GameVersionSettingsList()
        {
            GameVersionSettings = new List <GameVersionSettings>();

            var enumListString = Enum.GetNames(typeof(GameVersion));

            for (int i = 0; i < enumListString.Length; i++)
            {
                GameVersionSettings new_gameVersionSettings = new GameVersionSettings();
                new_gameVersionSettings.Game_Version = (GameVersion)Enum.Parse(typeof(GameVersion), enumListString[i]);

                GameVersionSettings.Add(new_gameVersionSettings);
            }
        }
Exemple #3
0
 public void Set_Current_GameVersionSettings(int selectedIndex)
 {
     current_GameVersionSettings = GameVersionSettings[selectedIndex];
 }
Exemple #4
0
        /// <summary>
        /// Reads and parses the data from the app config file.
        /// </summary>
        public void ReadConfigFile()
        {
            appSettingsFile     = new AppSettingsFile();
            GameVersionSettings = new List <GameVersionSettings>();

            //read the data from the config file
            string jsonText = File.ReadAllText(configFile_file_location);

            //parse the data into a json array
            JArray array;

            try
            {
                array = JArray.Parse(jsonText);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString(), e.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            JObject AppSettingsFile_fromJson     = array[0] as JObject;
            JArray  GameVersionSettings_fromJson = array[1] as JArray;

            //loop through each property to get the data
            foreach (JProperty property in AppSettingsFile_fromJson.Properties())
            {
                string name = property.Name;

                if (name.Equals(nameof(appSettingsFile.Default_Game_Version)))
                {
                    appSettingsFile.Default_Game_Version = (GameVersion)(int)property.Value;
                }

                if (name.Equals(nameof(appSettingsFile.UI_LightMode)))
                {
                    appSettingsFile.UI_LightMode = (bool)property.Value;
                }

                if (name.Equals(nameof(appSettingsFile.UI_WindowDefocusing)))
                {
                    appSettingsFile.UI_WindowDefocusing = (bool)property.Value;
                }
            }

            //loop through each property to get the data
            foreach (JObject obj in GameVersionSettings_fromJson.Children <JObject>())
            {
                GameVersionSettings new_gameVersionSettings = new GameVersionSettings();

                //loop through each property to get the data
                foreach (JProperty property in obj.Properties())
                {
                    string name = property.Name;

                    if (name.Equals(nameof(current_GameVersionSettings.Game_Location)))
                    {
                        new_gameVersionSettings.Game_Location = (string)property.Value;
                    }

                    if (name.Equals(nameof(current_GameVersionSettings.Game_LocationExe)))
                    {
                        new_gameVersionSettings.Game_LocationExe = (string)property.Value;
                    }

                    if (name.Equals(nameof(current_GameVersionSettings.Game_Version)))
                    {
                        new_gameVersionSettings.Game_Version = (GameVersion)(int)property.Value;
                    }
                }

                GameVersionSettings.Add(new_gameVersionSettings);
            }

            foreach (GameVersionSettings version in GameVersionSettings)
            {
                if (appSettingsFile.Default_Game_Version.Equals(version.Game_Version))
                {
                    current_GameVersionSettings = version;
                }
            }
        }