mirror of
https://github.com/terrymacdonald/DisplayMagician.git
synced 2024-08-30 18:32:20 +00:00
Partially added the Uplay Library logging
This commit is contained in:
parent
6b02e2ccbe
commit
a251962207
@ -1,16 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Linq;
|
||||
using System.Management;
|
||||
|
||||
namespace DisplayMagician.GameLibraries
|
||||
{
|
||||
class GameUtils
|
||||
{
|
||||
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
public static string GetMainModuleFilepath(int processId)
|
||||
{
|
||||
logger.Debug($"GameUtils/GetMainModuleFilepath: Using an alternative thread safe way to get the main module file path from the process with ProcessId = {processId}");
|
||||
|
||||
string wmiQueryString = "SELECT ProcessId, ExecutablePath FROM Win32_Process WHERE ProcessId = " + processId;
|
||||
using (var searcher = new ManagementObjectSearcher(wmiQueryString))
|
||||
{
|
||||
@ -19,6 +19,7 @@ namespace DisplayMagician.GameLibraries
|
||||
ManagementObject mo = results.Cast<ManagementObject>().FirstOrDefault();
|
||||
if (mo != null)
|
||||
{
|
||||
logger.Debug($"GameUtils/GetMainModuleFilepath: Process eexecutable path is {(string)mo["ExecutablePath"]}");
|
||||
return (string)mo["ExecutablePath"];
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using ValveKeyValue;
|
||||
//using DisplayMagician.GameLibraries.UplayAppInfoParser;
|
||||
using Microsoft.Win32;
|
||||
using System.IO;
|
||||
using System.Drawing.IconLib;
|
||||
using System.Security;
|
||||
using System.Diagnostics;
|
||||
using EDIDParser;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DisplayMagician.GameLibraries
|
||||
{
|
||||
@ -130,17 +123,19 @@ namespace DisplayMagician.GameLibraries
|
||||
{
|
||||
if (!(uplayGame is UplayGame))
|
||||
return false;
|
||||
|
||||
|
||||
// Doublecheck if it already exists
|
||||
// Because then we just update the one that already exists
|
||||
if (ContainsUplayGame(uplayGame))
|
||||
{
|
||||
logger.Debug($"UplayLibrary/AddUplayGame: Updating Uplay game {uplayGame.Name} in our Uplay library");
|
||||
// We update the existing Shortcut with the data over
|
||||
UplayGame uplayGameToUpdate = GetUplayGame(uplayGame.Id.ToString());
|
||||
uplayGame.CopyTo(uplayGameToUpdate);
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Debug($"UplayLibrary/AddUplayGame: Adding Uplay game {uplayGame.Name} to our Uplay library");
|
||||
// Add the uplayGame to the list of uplayGames
|
||||
_allUplayGames.Add(uplayGame);
|
||||
}
|
||||
@ -160,15 +155,22 @@ namespace DisplayMagician.GameLibraries
|
||||
if (!(uplayGame is UplayGame))
|
||||
return false;
|
||||
|
||||
logger.Debug($"UplayLibrary/RemoveUplayGame: Removing Uplay game {uplayGame.Name} from our Uplay library");
|
||||
|
||||
// Remove the uplayGame from the list.
|
||||
int numRemoved = _allUplayGames.RemoveAll(item => item.Id.Equals(uplayGame.Id));
|
||||
|
||||
if (numRemoved == 1)
|
||||
{
|
||||
logger.Debug($"UplayLibrary/RemoveUplayGame: Removed Uplay game with name {uplayGame.Name}");
|
||||
return true;
|
||||
}
|
||||
else if (numRemoved == 0)
|
||||
{
|
||||
logger.Debug($"UplayLibrary/RemoveUplayGame: Didn't remove Uplay game with ID {uplayGame.Name} from the Uplay Library");
|
||||
return false;
|
||||
}
|
||||
|
||||
else
|
||||
throw new UplayLibraryException();
|
||||
}
|
||||
@ -178,15 +180,21 @@ namespace DisplayMagician.GameLibraries
|
||||
if (uplayGameId<=0)
|
||||
return false;
|
||||
|
||||
logger.Debug($"UplayLibrary/RemoveUplayGame2: Removing Uplay game with ID {uplayGameId} from the Uplay library");
|
||||
|
||||
// Remove the uplayGame from the list.
|
||||
int numRemoved = _allUplayGames.RemoveAll(item => item.Id.Equals(uplayGameId));
|
||||
|
||||
if (numRemoved == 1)
|
||||
{
|
||||
logger.Debug($"UplayLibrary/RemoveUplayGame2: Removed Uplay game with ID {uplayGameId}");
|
||||
return true;
|
||||
}
|
||||
else if (numRemoved == 0)
|
||||
{
|
||||
logger.Debug($"UplayLibrary/RemoveUplayGame2: Didn't remove Uplay game with ID {uplayGameId} from the Uplay Library");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
throw new UplayLibraryException();
|
||||
}
|
||||
@ -196,6 +204,8 @@ namespace DisplayMagician.GameLibraries
|
||||
if (String.IsNullOrWhiteSpace(uplayGameNameOrUuid))
|
||||
return false;
|
||||
|
||||
logger.Debug($"UplayLibrary/RemoveUplayGame3: Removing Uplay game with Name or UUID {uplayGameNameOrUuid} from the Uplay library");
|
||||
|
||||
int numRemoved;
|
||||
Match match = Regex.Match(uplayGameNameOrUuid, uplayAppIdRegex, RegexOptions.IgnoreCase);
|
||||
if (match.Success)
|
||||
@ -204,9 +214,15 @@ namespace DisplayMagician.GameLibraries
|
||||
numRemoved = _allUplayGames.RemoveAll(item => uplayGameNameOrUuid.Equals(item.Name));
|
||||
|
||||
if (numRemoved == 1)
|
||||
{
|
||||
logger.Debug($"UplayLibrary/RemoveUplayGame3: Removed Uplay game with Name or UUID {uplayGameNameOrUuid} ");
|
||||
return true;
|
||||
}
|
||||
else if (numRemoved == 0)
|
||||
{
|
||||
logger.Debug($"UplayLibrary/RemoveUplayGame3: Didn't remove Uplay game with Name or UUID {uplayGameNameOrUuid} from the Uplay Library");
|
||||
return false;
|
||||
}
|
||||
else
|
||||
throw new UplayLibraryException();
|
||||
|
||||
|
@ -21,7 +21,7 @@ Different games require your displays configured in different ways. If you're a
|
||||
|
||||
There is now. DisplayMagician allows you to configure multiple different display profiles, and then use those different display profiles to create Game Shortcuts. These Game Shortcuts allow you to have your game or application start exactly the way you like it.
|
||||
|
||||
Do you like running Dirt Rally 2.0 on a single NVidia Surround window across triple screens, and yet you run Project Cars 2 across four individual screens (a triple and one above)? Do you like running SimHub when you play iRacing, yet you want to start Twitch when you play Call of Duty? Well with DisplayMagician you can do all that with a single Desktop Shortcut!
|
||||
Do you like running Dirt Rally 2.0 on a single NVidia Surround window across triple screens, and yet you like to run Project Cars 2 across four individual screens (a triple and one above)? Do you like running SimHub when you play iRacing, yet you want to start Twitch when you play Call of Duty? Well with DisplayMagician you can do all that with a single Desktop Shortcut!
|
||||
|
||||
DisplayMagician also allows you to automatically change to a different audio device just for one game, and will revert that change when you close the game. Great if you have some special audio devices you use only for certain games. No more fiddling with audio settings - just play the game!
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user