[WIP] initial game library URI refactor

This commit is contained in:
Terry MacDonald 2021-04-18 15:42:00 +12:00
parent 44b620851a
commit 1e4ed0c546
4 changed files with 70 additions and 7 deletions

View File

@ -3,6 +3,13 @@
public class Game
{
public enum GameStartMode
{
URI
}
#region Properties
public virtual string Id { get; set; }
@ -24,10 +31,17 @@
public virtual string ProcessName { get; set; }
public virtual GameStartMode StartMode { get; set; }
#endregion
#region Methods
public virtual string GetStartURI(string gameArguments = "")
{
return "";
}
public virtual bool CopyTo(SteamGame steamGame)
{
return true;

View File

@ -10,7 +10,6 @@ namespace DisplayMagician.GameLibraries
{
public class OriginGame : Game
{
private string _gameRegistryKey;
private string _originGameId;
private string _originGameName;
private string _originGameExePath;
@ -18,6 +17,7 @@ namespace DisplayMagician.GameLibraries
private string _originGameExe;
private string _originGameProcessName;
private string _originGameIconPath;
//private string _originURI;
private static readonly NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
static OriginGame()
@ -27,17 +27,17 @@ namespace DisplayMagician.GameLibraries
}
public OriginGame(string OriginGameId, string OriginGameName, string OriginGameExePath, string OriginGameIconPath)
public OriginGame(string originGameId, string originGameName, string originGameExePath, string originGameIconPath)
{
//_gameRegistryKey = $@"{OriginLibrary.registryOriginInstallsKey}\\{OriginGameId}";
_originGameId = OriginGameId;
_originGameName = OriginGameName;
_originGameExePath = OriginGameExePath;
_originGameDir = Path.GetDirectoryName(OriginGameExePath);
_originGameId = originGameId;
_originGameName = originGameName;
_originGameExePath = originGameExePath;
_originGameDir = Path.GetDirectoryName(originGameExePath);
_originGameExe = Path.GetFileName(_originGameExePath);
_originGameProcessName = Path.GetFileNameWithoutExtension(_originGameExePath);
_originGameIconPath = OriginGameIconPath;
_originGameIconPath = originGameIconPath;
}
@ -154,6 +154,21 @@ namespace DisplayMagician.GameLibraries
}
}*/
public override GameStartMode StartMode
{
get => GameStartMode.URI;
}
public override string GetStartURI(string gameArguments = "")
{
string address = $"origin2://game/launch?offerIds={_originGameId}";
if (String.IsNullOrWhiteSpace(gameArguments))
{
address += "/" + gameArguments;
}
return address;
}
public bool CopyTo(OriginGame OriginGame)
{
if (!(OriginGame is OriginGame))

View File

@ -154,6 +154,21 @@ namespace DisplayMagician.GameLibraries
}
}
public override GameStartMode StartMode
{
get => GameStartMode.URI;
}
public override string GetStartURI(string gameArguments = "")
{
string address = $"steam://rungameid/{Id}";
if (String.IsNullOrWhiteSpace(gameArguments))
{
address += "/" + gameArguments;
}
return address;
}
public bool CopyInto(SteamGame steamGame)
{
if (!(steamGame is SteamGame))

View File

@ -154,6 +154,25 @@ namespace DisplayMagician.GameLibraries
}
}*/
public override GameStartMode StartMode
{
get => GameStartMode.URI;
}
public override string GetStartURI(string gameArguments = "")
{
string address = $"uplay://launch/{Id}";
if (String.IsNullOrWhiteSpace(gameArguments))
{
address += "/" + gameArguments;
}
else
{
address += "/0";
}
return address;
}
public bool CopyTo(UplayGame uplayGame)
{
if (!(uplayGame is UplayGame))