Пример #1
0
		public void Add(Game[] games, CloudAction action)
		{
			for (int i = 0; i < games.Length; i++)
			{
				Add(games[i], action);
			}
		}
Пример #2
0
 ///// <summary>
 ///// Write game settings to INI file.
 ///// </summary>
 ///// <param name="game"></param>
 //public string GetIniContent(Game game)
 //{
 //    // Get game directory.
 //    var dir = new FileInfo(game.FullPath).Directory;
 //    // Get INI file.
 //    var iniFile = dir.GetFiles(IniFileName).FirstOrDefault();
 //    var ini = new Ini(iniFile.FullName);
 //    var optionKeys = new[] { SettingName.PAD1, SettingName.PAD2, SettingName.PAD3, SettingName.PAD4 };
 //    for (int i = 0; i < optionKeys.Length; i++)
 //    {
 //        var optionKey = optionKeys[i];
 //        var mapTo = (MapTo)(i + 1);
 //        // Write PADx.
 //        var mapItem = SettingsMap.FirstOrDefault(x => x.IniSection == OptionsSection && x.IniKey == optionKey);
 //        WriteSettingsToIni(mapItem);
 //        var settings = SettingManager.Settings.Items.Where(x => x.MapTo == (int)mapTo).ToArray();
 //        for (int s = 0; s < settings.Length; s++)
 //        {
 //            var setting = settings[i];
 //            var padSetting = SettingManager.GetPadSetting(setting.PadSettingChecksum);
 //            var padSectionName = string.Format("IG_{0:N}", setting.InstanceGuid);
 //            WritePadSettingsToIni(padSectionName, setting, padSetting);
 //        }
 //    }
 //    return null;
 //}
 /// <summary>
 /// Write game settings to INI file.
 /// </summary>
 /// <param name="game"></param>
 public string GetIniContent2(Game game)
 {
     // Get game directory.
     var dir = new FileInfo(game.FullPath).Directory;
     // Get INI file.
     var iniFile = dir.GetFiles(IniFileName).FirstOrDefault();
     var ini = new Ini(iniFile.FullName);
     var optionKeys = new[] { SettingName.PAD1, SettingName.PAD2, SettingName.PAD3, SettingName.PAD4 };
     for (int i = 0; i < optionKeys.Length; i++)
     {
         var optionKey = optionKeys[i];
         var mapTo = (MapTo)(i + 1);
         // Write PADx.
         var mapItem = SettingsMap.FirstOrDefault(x => x.IniSection == OptionsSection && x.IniKey == optionKey);
         WriteSettingsToIni(mapItem);
         var settings = SettingManager.Settings.Items.Where(x => x.MapTo == (int)mapTo).ToArray();
         for (int s = 0; s < settings.Length; s++)
         {
             var setting = settings[i];
             var padSetting = SettingManager.GetPadSetting(setting.PadSettingChecksum);
             var padSectionName = string.Format("IG_{0:N}", setting.InstanceGuid);
             WritePadSettingsToIni(padSectionName, setting, padSetting);
         }
     }
     return null;
 }
Пример #3
0
		public void Add(Game game, CloudAction action)
		{
			var item = new CloudItem
			{
				Action = action,
				Date = DateTime.Now,
				Item = game,
				State = CloudState.None,
			};
			data.Add(item);
		}
Пример #4
0
 /// Write game settings to INI file.
 /// </summary>
 /// <param name="game"></param>
 public string GetIniContent(Game game)
 {
     var sb = new StringBuilder();
     var optionsContent = GetIniContent(OptionsSection);
     var mappingsContent = GetIniContent(MappingsSection);
     sb.Append(optionsContent);
     sb.AppendLine();
     sb.Append(mappingsContent);
     sb.AppendLine();
     return sb.ToString();
 }
Пример #5
0
 public static Game FromDisk(string fileName)
 {
     var item = new Game();
     var fi = new FileInfo(fileName);
     var vi = System.Diagnostics.FileVersionInfo.GetVersionInfo(fi.FullName);
     item.Comment = vi.Comments;
     item.DateCreated = DateTime.Now;
     item.DateUpdated = item.DateCreated;
     item.FileName = fi.Name;
     item.FileProductName = vi.ProductName;
     item.CompanyName = vi.CompanyName;
     item.DiskDriveId = BoardInfo.GetDiskDriveIdGuid();
     item.FileVersion = new Version(vi.FileMajorPart, vi.FileMinorPart, vi.FileBuildPart, vi.FilePrivatePart).ToString();
     item.FullPath = fi.FullName;
     item.GameId = Guid.NewGuid();
     item.HookMask = 0;
     item.IsEnabled = true;
     item.XInputMask = 0;
     return item;
 }
Пример #6
0
 public static Game FromDisk(string fileName)
 {
     var item = new Game();
     var fi = new FileInfo(fileName);
     var vi = System.Diagnostics.FileVersionInfo.GetVersionInfo(fi.FullName);
     var architecture = Win32.PEReader.GetProcessorArchitecture(fi.FullName);
     var mask = GetMask(fi.FullName, architecture);
     if (mask == Engine.XInputMask.None)
     {
         mask = (architecture == System.Reflection.ProcessorArchitecture.Amd64)
         ? mask = Engine.XInputMask.XInput13_x64
         : mask = Engine.XInputMask.XInput13_x86;
     }
     item.Timeout = -1;
     item.Comment = vi.Comments ?? "";
     item.DateCreated = DateTime.Now;
     item.DateUpdated = item.DateCreated;
     item.FileName = fi.Name ?? "";
     item.FileProductName = EngineHelper.FixName(vi.ProductName, item.FileName);
     item.FileVersion = vi.FileVersion ?? "";
     item.CompanyName = vi.CompanyName ?? "";
     item.DiskDriveId = BoardInfo.GetHashedDiskId();
     item.FileVersion = new Version(vi.FileMajorPart, vi.FileMinorPart, vi.FileBuildPart, vi.FilePrivatePart).ToString();
     item.FullPath = fi.FullName ?? "";
     item.GameId = Guid.NewGuid();
     item.HookMask = 0;
     item.XInputMask = (int)mask;
     item.DInputMask = 0;
     item.DInputFile = "";
     item.FakeVID = 0;
     item.FakePID = 0;
     item.Timeout = -1;
     item.Weight = 1;
     item.IsEnabled = true;
     item.ProcessorArchitecture = (int)architecture;
     return item;
 }
Пример #7
0
 /// <summary>
 /// Create a new Game object.
 /// </summary>
 /// <param name="gameId">Initial value of the GameId property.</param>
 /// <param name="diskDriveId">Initial value of the DiskDriveId property.</param>
 /// <param name="fileName">Initial value of the FileName property.</param>
 /// <param name="fileProductName">Initial value of the FileProductName property.</param>
 /// <param name="fileVersion">Initial value of the FileVersion property.</param>
 /// <param name="fullPath">Initial value of the FullPath property.</param>
 /// <param name="companyName">Initial value of the CompanyName property.</param>
 /// <param name="hookMask">Initial value of the HookMask property.</param>
 /// <param name="xInputMask">Initial value of the XInputMask property.</param>
 /// <param name="comment">Initial value of the Comment property.</param>
 /// <param name="isEnabled">Initial value of the IsEnabled property.</param>
 /// <param name="dateCreated">Initial value of the DateCreated property.</param>
 /// <param name="processorArchitecture">Initial value of the ProcessorArchitecture property.</param>
 /// <param name="dInputMask">Initial value of the DInputMask property.</param>
 /// <param name="dInputFile">Initial value of the DInputFile property.</param>
 /// <param name="fakeVID">Initial value of the FakeVID property.</param>
 /// <param name="fakePID">Initial value of the FakePID property.</param>
 /// <param name="timeout">Initial value of the Timeout property.</param>
 /// <param name="weight">Initial value of the Weight property.</param>
 public static Game CreateGame(global::System.Guid gameId, global::System.Guid diskDriveId, global::System.String fileName, global::System.String fileProductName, global::System.String fileVersion, global::System.String fullPath, global::System.String companyName, global::System.Int32 hookMask, global::System.Int32 xInputMask, global::System.String comment, global::System.Boolean isEnabled, global::System.DateTime dateCreated, global::System.Int32 processorArchitecture, global::System.Int32 dInputMask, global::System.String dInputFile, global::System.Int32 fakeVID, global::System.Int32 fakePID, global::System.Int32 timeout, global::System.Int32 weight)
 {
     Game game = new Game();
     game.GameId = gameId;
     game.DiskDriveId = diskDriveId;
     game.FileName = fileName;
     game.FileProductName = fileProductName;
     game.FileVersion = fileVersion;
     game.FullPath = fullPath;
     game.CompanyName = companyName;
     game.HookMask = hookMask;
     game.XInputMask = xInputMask;
     game.Comment = comment;
     game.IsEnabled = isEnabled;
     game.DateCreated = dateCreated;
     game.ProcessorArchitecture = processorArchitecture;
     game.DInputMask = dInputMask;
     game.DInputFile = dInputFile;
     game.FakeVID = fakeVID;
     game.FakePID = fakePID;
     game.Timeout = timeout;
     game.Weight = weight;
     return game;
 }
Пример #8
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Games EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToGames(Game game)
 {
     base.AddObject("Games", game);
 }
		/// <summary>
		/// Read INI file by game.
		/// </summary>
		/// <param name="game"></param>
		public SearchResult ReadIniFile(Game game)
		{
			var result = new SearchResult();
			var settings = new List<Setting>();
			var padSettings = new List<PadSetting>();
			// Get game directory.
			var dir = new FileInfo(game.FullPath).Directory;
			// Get INI file.
			var iniFile = dir.GetFiles(IniFileName).FirstOrDefault();
			if (iniFile != null)
			{
				var ini = new Ini(iniFile.FullName);
				var optionKeys = new[]
				{
					SettingName.PAD1,
					SettingName.PAD2,
					SettingName.PAD3,
					SettingName.PAD4,
				};
				for (int i = 0; i < optionKeys.Length; i++)
				{
					var optionKey = optionKeys[i];
					var mapTo = (MapTo)(i + 1);
					var value = ini.GetValue(OptionsSection, optionKey);
					var padSectionNames = value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
					foreach (var padSectionName in padSectionNames)
					{
						Setting setting;
						PadSetting padSetting;
						ReadPadSettingsFromIni(padSectionName, out setting, out padSetting);
						setting.MapTo = (int)mapTo;
						// If settings was not added already then...
						if (!settings.Any(x => x.InstanceGuid.Equals(setting.InstanceGuid)))
						{
							settings.Add(setting);
							// If PAD setting was not added already then...
							if (padSettings.Any(x => x.PadSettingChecksum.Equals(x.PadSettingChecksum)))
							{
								padSettings.Add(padSetting);
							}
						}
					}
				}
			}
			return result;
		}
Пример #10
0
 public string SetGames(CloudAction action, List<Game> games)
 {
     if (action == CloudAction.Delete)
     {
         var db = new x360ceModelContainer();
         var deleted = 0;
         for (int i = 0; i < games.Count; i++)
         {
             var game = games[i];
             var diskDriveId = game.DiskDriveId;
             var fileName = game.FileName;
             var currentGame = db.Games.FirstOrDefault(x => x.DiskDriveId == diskDriveId && x.FileName == fileName);
             if (currentGame == null) continue;
             db.Games.DeleteObject(currentGame);
             deleted++;
         }
         db.SaveChanges();
         db.Dispose();
         db = null;
         return string.Format("{0} game(s) deleted.", deleted);
     }
     else
     {
         var db = new x360ceModelContainer();
         var created = 0;
         var updated = 0;
         for (int i = 0; i < games.Count; i++)
         {
             var game = games[i];
             var diskDriveId = game.DiskDriveId;
             var fileName = game.FileName;
             var item = db.Games.FirstOrDefault(x => x.DiskDriveId == diskDriveId && x.FileName == fileName);
             if (item == null)
             {
                 created++;
                 item = new Game();
                 item.GameId = Guid.NewGuid();
                 db.Games.AddObject(item);
                 item.DateCreated = DateTime.Now;
             }
             else
             {
                 updated++;
                 item.DateUpdated = DateTime.Now;
             }
             item.Comment = game.Comment;
             item.CompanyName = game.CompanyName;
             item.DInputFile = game.DInputFile;
             item.DInputMask = game.DInputMask;
             item.FakePID = game.FakePID;
             item.FakeVID = game.FakeVID;
             item.FileName = game.FileName;
             item.FileProductName = game.FileProductName;
             item.FileVersion = game.FileVersion;
             item.FullPath = game.FullPath;
             item.HookMask = game.HookMask;
             item.IsEnabled = game.IsEnabled;
             item.Timeout = game.Timeout;
             item.Weight = 1;
             item.XInputMask = game.XInputMask;
         }
         db.SaveChanges();
         db.Dispose();
         db = null;
         return string.Format("{0} game(s) created, {1} game(s) updated.", created, updated);
     }
 }
Пример #11
0
 /// <summary>
 /// Create a new Game object.
 /// </summary>
 /// <param name="gameId">Initial value of the GameId property.</param>
 /// <param name="diskDriveId">Initial value of the DiskDriveId property.</param>
 /// <param name="fileName">Initial value of the FileName property.</param>
 /// <param name="fileProductName">Initial value of the FileProductName property.</param>
 /// <param name="fileVersion">Initial value of the FileVersion property.</param>
 /// <param name="fullPath">Initial value of the FullPath property.</param>
 /// <param name="companyName">Initial value of the CompanyName property.</param>
 /// <param name="hookMask">Initial value of the HookMask property.</param>
 /// <param name="xInputMask">Initial value of the XInputMask property.</param>
 /// <param name="comment">Initial value of the Comment property.</param>
 /// <param name="isEnabled">Initial value of the IsEnabled property.</param>
 /// <param name="dateCreated">Initial value of the DateCreated property.</param>
 public static Game CreateGame(global::System.Guid gameId, global::System.Guid diskDriveId, global::System.String fileName, global::System.String fileProductName, global::System.String fileVersion, global::System.String fullPath, global::System.String companyName, global::System.Int32 hookMask, global::System.Int32 xInputMask, global::System.String comment, global::System.Boolean isEnabled, global::System.DateTime dateCreated)
 {
     Game game = new Game();
     game.GameId = gameId;
     game.DiskDriveId = diskDriveId;
     game.FileName = fileName;
     game.FileProductName = fileProductName;
     game.FileVersion = fileVersion;
     game.FullPath = fullPath;
     game.CompanyName = companyName;
     game.HookMask = hookMask;
     game.XInputMask = xInputMask;
     game.Comment = comment;
     game.IsEnabled = isEnabled;
     game.DateCreated = dateCreated;
     return game;
 }