diff --git a/LANCommander.Playnite.Extension/LANCommander.Playnite.Extension.csproj b/LANCommander.Playnite.Extension/LANCommander.Playnite.Extension.csproj index c909c3c..7b4d23d 100644 --- a/LANCommander.Playnite.Extension/LANCommander.Playnite.Extension.csproj +++ b/LANCommander.Playnite.Extension/LANCommander.Playnite.Extension.csproj @@ -31,13 +31,45 @@ 4 + + ..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll + ..\packages\PlayniteSDK.6.8.0\lib\net462\Playnite.SDK.dll + + ..\packages\RestSharp.106.15.0\lib\net452\RestSharp.dll + + + ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll + + + ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll + + + + ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll + + + ..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Text.Encodings.Web.5.0.0\lib\net461\System.Text.Encodings.Web.dll + + + ..\packages\System.Text.Json.5.0.1\lib\net461\System.Text.Json.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + + ..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll + + @@ -48,6 +80,7 @@ + @@ -57,6 +90,7 @@ + @@ -74,5 +108,11 @@ MSBuild:Compile + + + {4c2a71fd-a30b-4d62-888a-4ef843d8e506} + LANCommander.SDK + + \ No newline at end of file diff --git a/LANCommander.Playnite.Extension/LANCommanderClient.cs b/LANCommander.Playnite.Extension/LANCommanderClient.cs new file mode 100644 index 0000000..c15f644 --- /dev/null +++ b/LANCommander.Playnite.Extension/LANCommanderClient.cs @@ -0,0 +1,27 @@ +using LANCommander.SDK.Models; +using RestSharp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LANCommander.Playnite.Extension +{ + internal class LANCommanderClient + { + private readonly RestClient Client; + + public LANCommanderClient() + { + Client = new RestClient("https://localhost:7087"); + } + + public IEnumerable GetGames() + { + var response = Client.Get>(new RestRequest("/api/Games")); + + return response.Data; + } + } +} diff --git a/LANCommander.Playnite.Extension/PlayniteLibraryPlugin.cs b/LANCommander.Playnite.Extension/PlayniteLibraryPlugin.cs index da98550..805fc7a 100644 --- a/LANCommander.Playnite.Extension/PlayniteLibraryPlugin.cs +++ b/LANCommander.Playnite.Extension/PlayniteLibraryPlugin.cs @@ -14,6 +14,7 @@ namespace LANCommander.Playnite.Extension { public static readonly ILogger Logger = LogManager.GetLogger(); private SettingsViewModel Settings { get; set; } + private LANCommanderClient LANCommander { get; set; } public override Guid Id { get; } = Guid.Parse("48e1bac7-e0a0-45d7-ba83-36f5e9e959fc"); public override string Name => "LANCommander"; @@ -21,6 +22,7 @@ namespace LANCommander.Playnite.Extension public PlayniteLibraryPlugin(IPlayniteAPI api) : base(api) { + LANCommander = new LANCommanderClient(); Settings = new SettingsViewModel(this); Properties = new LibraryPluginProperties { @@ -31,7 +33,17 @@ namespace LANCommander.Playnite.Extension public override IEnumerable GetGames(LibraryGetGamesArgs args) { // Implement LANCommander client here - return new List(); + var games = LANCommander.GetGames().Select(g => new GameMetadata() + { + Name = g.Title, + Description = g.Description, + GameId = g.Id.ToString(), + ReleaseDate = new ReleaseDate(g.ReleasedOn), + SortingName = g.SortTitle, + Version = g.Archives != null && g.Archives.Count() > 0 ? g.Archives.OrderByDescending(a => a.CreatedOn).FirstOrDefault().Version : null, + }); + + return games; } public override ISettings GetSettings(bool firstRunSettings) diff --git a/LANCommander.Playnite.Extension/app.config b/LANCommander.Playnite.Extension/app.config new file mode 100644 index 0000000..7d2aa9e --- /dev/null +++ b/LANCommander.Playnite.Extension/app.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/LANCommander.Playnite.Extension/packages.config b/LANCommander.Playnite.Extension/packages.config index c555305..f991b70 100644 --- a/LANCommander.Playnite.Extension/packages.config +++ b/LANCommander.Playnite.Extension/packages.config @@ -1,4 +1,14 @@  + + + + + + + + + + \ No newline at end of file diff --git a/LANCommander.SDK/LANCommander.SDK.csproj b/LANCommander.SDK/LANCommander.SDK.csproj new file mode 100644 index 0000000..9f5c4f4 --- /dev/null +++ b/LANCommander.SDK/LANCommander.SDK.csproj @@ -0,0 +1,7 @@ + + + + netstandard2.0 + + + diff --git a/LANCommander.SDK/Models/Archive.cs b/LANCommander.SDK/Models/Archive.cs new file mode 100644 index 0000000..1b7c938 --- /dev/null +++ b/LANCommander.SDK/Models/Archive.cs @@ -0,0 +1,15 @@ +namespace LANCommander.SDK.Models +{ + public class Archive : BaseModel + { + public string Changelog { get; set; } + + public string ObjectKey { get; set; } + + public string Version { get; set; } + + public virtual Game Game { get; set; } + + public virtual Archive LastVersion { get; set; } + } +} diff --git a/LANCommander.SDK/Models/BaseModel.cs b/LANCommander.SDK/Models/BaseModel.cs new file mode 100644 index 0000000..5ea6d2b --- /dev/null +++ b/LANCommander.SDK/Models/BaseModel.cs @@ -0,0 +1,13 @@ +using System; + +namespace LANCommander.SDK.Models +{ + public abstract class BaseModel + { + public Guid Id { get; set; } + public DateTime CreatedOn { get; set; } + public virtual User CreatedBy { get; set; } + public DateTime UpdatedOn { get; set; } + public virtual User UpdatedBy { get; set; } + } +} diff --git a/LANCommander.SDK/Models/Company.cs b/LANCommander.SDK/Models/Company.cs new file mode 100644 index 0000000..26694de --- /dev/null +++ b/LANCommander.SDK/Models/Company.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace LANCommander.SDK.Models +{ + public class Company : BaseModel + { + public string Name { get; set; } + public virtual IEnumerable PublishedGames { get; set; } + public virtual IEnumerable DevelopedGames { get; set; } + } +} diff --git a/LANCommander.SDK/Models/Game.cs b/LANCommander.SDK/Models/Game.cs new file mode 100644 index 0000000..3a22f07 --- /dev/null +++ b/LANCommander.SDK/Models/Game.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; + +namespace LANCommander.SDK.Models +{ + public class Game : BaseModel + { + public string Title { get; set; } + public string SortTitle { get; set; } + public string DirectoryName { get; set; } + public string Description { get; set; } + public DateTime ReleasedOn { get; set; } + public virtual IEnumerable Tags { get; set; } + public virtual Company Publisher { get; set; } + public virtual Company Developer { get; set; } + public virtual IEnumerable Archives { get; set; } + } +} diff --git a/LANCommander.SDK/Models/Tag.cs b/LANCommander.SDK/Models/Tag.cs new file mode 100644 index 0000000..6bf4cf1 --- /dev/null +++ b/LANCommander.SDK/Models/Tag.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace LANCommander.SDK.Models +{ + public class Tag : BaseModel + { + public string Name { get; set; } + public virtual IEnumerable Games { get; set; } + } +} diff --git a/LANCommander.SDK/Models/User.cs b/LANCommander.SDK/Models/User.cs new file mode 100644 index 0000000..a3db433 --- /dev/null +++ b/LANCommander.SDK/Models/User.cs @@ -0,0 +1,10 @@ +using System; + +namespace LANCommander.SDK.Models +{ + public class User + { + public Guid Id { get; set; } + public string UserName { get; set; } + } +} diff --git a/LANCommander.sln b/LANCommander.sln index 6d53f3e..4f6adb2 100644 --- a/LANCommander.sln +++ b/LANCommander.sln @@ -7,6 +7,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LANCommander", "LANCommande EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LANCommander.Playnite.Extension", "LANCommander.Playnite.Extension\LANCommander.Playnite.Extension.csproj", "{F9EB13D4-8FD9-4095-B934-F7EC681E6901}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LANCommander.SDK", "LANCommander.SDK\LANCommander.SDK.csproj", "{4C2A71FD-A30B-4D62-888A-4EF843D8E506}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +23,10 @@ Global {F9EB13D4-8FD9-4095-B934-F7EC681E6901}.Debug|Any CPU.Build.0 = Debug|Any CPU {F9EB13D4-8FD9-4095-B934-F7EC681E6901}.Release|Any CPU.ActiveCfg = Release|Any CPU {F9EB13D4-8FD9-4095-B934-F7EC681E6901}.Release|Any CPU.Build.0 = Release|Any CPU + {4C2A71FD-A30B-4D62-888A-4EF843D8E506}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4C2A71FD-A30B-4D62-888A-4EF843D8E506}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4C2A71FD-A30B-4D62-888A-4EF843D8E506}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4C2A71FD-A30B-4D62-888A-4EF843D8E506}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/LANCommander/LANCommander.csproj b/LANCommander/LANCommander.csproj index e251ae8..15c9219 100644 --- a/LANCommander/LANCommander.csproj +++ b/LANCommander/LANCommander.csproj @@ -45,6 +45,10 @@ + + + + Never diff --git a/LANCommander/LANCommander.db b/LANCommander/LANCommander.db index cc632b9..0b585bd 100644 Binary files a/LANCommander/LANCommander.db and b/LANCommander/LANCommander.db differ