private void DataGridDifficultyRequirements_LoadingRow(object sender, DataGridRowEventArgs e) { string modName = e.Row.Item.ToString().Replace(" ", ""); SupportedMod supportedMod = App.SupportedMods.FirstOrDefault(x => x.Name == modName); if (supportedMod is null) { e.Row.Foreground = new SolidColorBrush(Color.FromRgb(255, 0, 0)); } else { if (supportedMod.Supported == 1) { e.Row.Foreground = new SolidColorBrush(Color.FromRgb(214, 143, 0)); } else if (supportedMod.Supported == 2) { e.Row.Foreground = new SolidColorBrush(Color.FromRgb(0, 200, 0)); } } }
/// <summary> /// Reads the game configuration for a particular xml node name. /// </summary> /// <param name="xmlNodeName">Name of the XML node.</param> /// <returns></returns> private IList <GameConfiguration> ReadGameConfig(string xmlNodeName) { IList <GameConfiguration> gameConfigurations = new List <GameConfiguration>(); // Read file to memory var config = XmlHelper.ReadXmlFile("Configuration.xml"); if (config == null) { return(null); } // Read the games. Most likely only one (source or target), but the code here supports multiple var foundGames = config.Descendants(xmlNodeName); // For each game, read the various properties we need, and store the result in a new GameConfiguration object foreach (var game in foundGames) { // Save game related var saveGameFolderTypeAsString = XElementHelper.ReadStringValue(game, "defaultSaveGameLocationType"); var saveGameFolderType = saveGameFolderTypeAsString.Equals(RelativeFolderLocationRoot.SteamFolder.ToString()) ? RelativeFolderLocationRoot.SteamFolder : RelativeFolderLocationRoot.WindowsUsersFolder; var saveGameExtension = XElementHelper.ReadStringValue(game, "saveGameExtension"); // Installation directory related var steamId = XElementHelper.ReadStringValue(game, "steamId"); var nonsteamRegistryName = XElementHelper.ReadStringValue(game, "nonsteamRegistryName", false); var installationFolder = this.GetSteamInstallationFolder(steamId); if (String.IsNullOrEmpty(installationFolder)) { installationFolder = this.GetNonSteamInstallationFolder(nonsteamRegistryName); } var configurationFileDirectoryTagName = XElementHelper.ReadStringValue(game, "configurationFileDirectoryTagName"); // Mod related var defaultModFolderLocationTypeAsString = XElementHelper.ReadStringValue(game, "defaultModFolderLocationType", false); var defaultModFolderLocationType = defaultModFolderLocationTypeAsString.Equals(RelativeFolderLocationRoot.SteamFolder.ToString()) ? RelativeFolderLocationRoot.SteamFolder : RelativeFolderLocationRoot.WindowsUsersFolder; var configurationFileModDirectoryTagName = XElementHelper.ReadStringValue(game, "configurationFileModDirectoryTagName", false); var currentModTagName = XElementHelper.ReadStringValue(game, "currentModTagName", false); //if (defaultModFolderLocationType == RelativeFolderLocationRoot.SteamFolder) //{ // this.options.Logger.AddLogEntry(new LogEntry("The \"defaultModFolderLocationType\" tag cannot have the value \"SteamFolder\". This value isn't supported in the frontend yet.", LogEntrySeverity.Error, LogEntrySource.UI)); //} var supportedModsAsString = game.Descendants("supportedMod"); var gameConfig = new GameConfiguration() { Name = XElementHelper.ReadStringValue(game, "name"), FriendlyName = XElementHelper.ReadStringValue(game, "friendlyName"), SaveGamePath = (saveGameFolderType == RelativeFolderLocationRoot.SteamFolder ? installationFolder : this.GetUsersFolder()) + XElementHelper.ReadStringValue(game, "defaultSaveGameSubLocation"), SteamId = steamId, ConfigurationFileDirectoryTagName = configurationFileDirectoryTagName, SaveGameExtension = saveGameExtension, ConfigurationFileModDirectoryTagName = configurationFileModDirectoryTagName, CurrentModTagName = currentModTagName, ModPath = (defaultModFolderLocationType == RelativeFolderLocationRoot.SteamFolder ? installationFolder : GetUsersFolder()) + XElementHelper.ReadStringValue(game, "defaultModFolderLocation", false), InstallationPath = installationFolder }; // Dummy item so that the user can undo selecting a mod var dummyMod = new SupportedMod() { Name = "No mod", IsDummyItem = true }; gameConfig.SupportedMods.Add(dummyMod); gameConfig.CurrentMod = dummyMod; // Add proper mods if (supportedModsAsString.Count() > 0) { supportedModsAsString.ForEach(m => gameConfig.SupportedMods.Add(new SupportedMod() { Name = XElementHelper.ReadStringValue(m, "modName") })); } gameConfigurations.Add(gameConfig); } return(gameConfigurations); }