context: using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Text.RegularExpressions;
  using System.Xml;
  using ChinhDo.Transactions;
  using Nexus.Client.Games.WorldOfTanks.Settings;
  using Nexus.Client.Games.WorldOfTanks.Settings.UI;
  using Nexus.Client.Games.WorldOfTanks.Tools;
  using Nexus.Client.ModManagement;
  using Nexus.Client.ModManagement.InstallationLog;
  using Nexus.Client.Mods;
  using Nexus.Client.PluginManagement;
  using Nexus.Client.PluginManagement.InstallationLog;
  using Nexus.Client.PluginManagement.OrderLog;
  using Nexus.Client.Settings.UI;
  using Nexus.Client.Games.Tools;
  using Nexus.Client.Updating;
  using Nexus.Client.Util;
  using System.Diagnostics;
  
  namespace Nexus.Client.Games.WorldOfTanks
  {
  	/// <summary>
  	/// Provides information required for the program to manage World of Tanks game's plugins and mods.
  	/// </summary>
  	public class WoTGameMode : GameModeBase
  	{
  		/// <summary>
  		/// Gets the version of the installed game from the version file
  		/// found in the given directory.
  		/// </summary>
  		/// <param name="p_strGameInstallPath">The path in which the game is installed.</param>
  		/// <returns>The version of the installed game.</value>
  		public static string ReadVersion(string p_strGameInstallPath)
  		{
  			string strVersion = null;
  			if (String.IsNullOrEmpty(p_strGameInstallPath))
  				return null;
  			string strVersionFilePath = Path.Combine(p_strGameInstallPath, "version.xml");
  			if (File.Exists(strVersionFilePath))
  			{
  				XmlDocument xmlVersion = new XmlDocument();
  				xmlVersion.Load(strVersionFilePath);
  				XmlNodeList xmlGameVersion = xmlVersion.GetElementsByTagName("version");
  				strVersion = xmlGameVersion[0].InnerText;
  				if (String.IsNullOrEmpty(strVersion))
  					return null;
  				string versionPattern = @"\d+\.\d+\.\w+";
  				strVersion = Regex.Match(strVersion, versionPattern, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant).Value;
  				return strVersion;
  			}
  			return null;
  		}
  
  		private WoTGameModeDescriptor m_gmdGameModeInfo = null;
  		private WoTLauncher m_glnGameLauncher = null;
  		private WoTToolLauncher m_gtlToolLauncher = null;
  
  		#region Properties
  
  		/// <summary>
  		/// Gets the string version of the installed game.
  		/// </summary>
  		/// <value>The string version of the installed game.</value>
  		public override string NonStandardGameVersion
  		{
  			get
  			{
  				//climb up the path until we find the res_mods folder
  				string[] strPath = InstallationPath.Split(new char[] { Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar }, StringSplitOptions.RemoveEmptyEntries);
  				Int32 intModFolderIndex = strPath.Length - 1;
  				for (; intModFolderIndex >= 0; intModFolderIndex--)
  					if (strPath[intModFolderIndex].Equals("res_mods", StringComparison.OrdinalIgnoreCase))
  						break;
  				string strFullPath = String.Join(Path.DirectorySeparatorChar.ToString(), strPath, 0, intModFolderIndex);
  				return ReadVersion(strFullPath);
  			}
  		}
  
  		/// <summary>
  		/// Gets the string version of the installed game.
  		/// </summary>
  		/// <value>The string version of the installed game.</value>
  		public override Version GameVersion
  		{
  			get
  			{
  				try
  				{
  					return new Version(NonStandardGameVersion);
  				}
  				catch
  				{
  					return new Version(Regex.Match(NonStandardGameVersion, @"\d+(?:\.\d+)+").Value);
  				}
  			}
  		}
  
  		/// <summary>
  		/// Gets a list of paths to which the game mode writes.
  		/// </summary>
  		/// <value>A list of paths to which the game mode writes.</value>
  		public override IEnumerable<string> WritablePaths
  		{
  			get
  			{
  				return null;
  			}
  		}
  
  		/// <summary>
  		/// Gets the installed version of the script extender.
  		/// </summary>
  		/// <remarks>
  		/// <c>null</c> is returned if the script extender is not installed.
  		/// </remarks>
  		/// <value>The installed version of the script extender.</value>
  		public virtual Version ScriptExtenderVersion
  		{
  			get
  			{
  				return null;
  			}
  		}
  
  		/// <summary>
  		/// Gets the path to the per user World of Tanks data.
  		/// </summary>
  		/// <value>The path to the per user World of Tanks data.</value>
  		public string UserGameDataPath
  		{
  			get
  			{
  				return GameModeEnvironmentInfo.InstallationPath;
  			}
  		}
  
  		/// <summary>
  		/// Gets the game launcher for the game mode.
  		/// </summary>
  		/// <value>The game launcher for the game mode.</value>
  		public override IGameLauncher GameLauncher
  		{
  			get
  			{
  				if (m_glnGameLauncher == null)
  					m_glnGameLauncher = new WoTLauncher(this, EnvironmentInfo);
  				return m_glnGameLauncher;
  			}
  		}
  
  		/// <summary>
  		/// Gets the tool launcher for the game mode.
  		/// </summary>
  		/// <value>The tool launcher for the game mode.</value>
  		public override IToolLauncher GameToolLauncher
  		{
  			get
  			{
  				if (m_gtlToolLauncher == null)
  					m_gtlToolLauncher = new WoTToolLauncher(this, EnvironmentInfo);
  				return m_gtlToolLauncher;
  			}
  		}
  
  		/// <summary>
  		/// Gets whether the game mode uses plugins.
  		/// </summary>
  		/// <remarks>
  		/// This indicates whether the game mode used plugins that are
  		/// installed by mods, or simply used mods, without
  		/// plugins.
  		/// 
  		/// In games that use mods only, the installation of a mods package
  		/// is sufficient to add the functionality to the game. The game
  		/// will often have no concept of managable game modifications.
  		/// 
  		/// In games that use plugins, mods can install files that directly
  		/// affect the game (similar to the mod-free use case), but can also
  		/// install plugins that can be managed (for example activated/reordered)
  		/// after the mod is installed.
  		/// </remarks>
  		/// <value>Whether the game mode uses plugins.</value>
  		public override bool UsesPlugins
  		{
  			get
  			{
  				return false;
  			}
  		}
  
  		/// <summary>
  		/// Gets the default game categories.
  		/// </summary>
  		/// <value>The default game categories stored in the resource file.</value>
  		public override string GameDefaultCategories
  		{
  			get
  			{
  				return Properties.Resources.Categories;
  			}
  		}
  
  		#endregion
  
  		#region Constructors
  
  		/// <summary>
  		/// A simple constructor that initializes the object with the given values.
  		/// </summary>
  		/// <param name="p_eifEnvironmentInfo">The application's environment info.</param>
  		/// <param name="p_futFileUtility">The file utility class to be used by the game mode.</param>
  		public WoTGameMode(IEnvironmentInfo p_eifEnvironmentInfo, FileUtil p_futFileUtility)
  			: base(p_eifEnvironmentInfo)
  		{
  
gt: 			SettingsGroupViews = new List<ISettingsGroupView>();