Basic Playnite extension

dashboard
Pat Hartl 2023-01-04 20:31:02 -06:00
parent 640a75abdd
commit 025b45342d
15 changed files with 199 additions and 1 deletions

View File

@ -31,13 +31,45 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Playnite.SDK, Version=6.8.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\PlayniteSDK.6.8.0\lib\net462\Playnite.SDK.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="RestSharp, Version=106.15.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
<HintPath>..\packages\RestSharp.106.15.0\lib\net452\RestSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Encodings.Web.5.0.0\lib\net461\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=5.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Text.Json.5.0.1\lib\net461\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
@ -48,6 +80,7 @@
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="LANCommanderClient.cs" />
<Compile Include="PlayniteClient.cs" />
<Compile Include="PlayniteLibraryPlugin.cs" />
<Compile Include="PlayniteSettings.cs" />
@ -57,6 +90,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="extension.yaml" />
<None Include="packages.config" />
</ItemGroup>
@ -74,5 +108,11 @@
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LANCommander.SDK\LANCommander.SDK.csproj">
<Project>{4c2a71fd-a30b-4d62-888a-4ef843d8e506}</Project>
<Name>LANCommander.SDK</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -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<Game> GetGames()
{
var response = Client.Get<IEnumerable<Game>>(new RestRequest("/api/Games"));
return response.Data;
}
}
}

View File

@ -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<GameMetadata> GetGames(LibraryGetGamesArgs args)
{
// Implement LANCommander client here
return new List<GameMetadata>();
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)

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Text.Json" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.1" newVersion="5.0.0.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -1,4 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl.AsyncInterfaces" version="5.0.0" targetFramework="net462" />
<package id="PlayniteSDK" version="6.8.0" targetFramework="net462" />
<package id="RestSharp" version="106.15.0" targetFramework="net462" />
<package id="System.Buffers" version="4.5.1" targetFramework="net462" />
<package id="System.Memory" version="4.5.4" targetFramework="net462" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net462" />
<package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0" targetFramework="net462" />
<package id="System.Text.Encodings.Web" version="5.0.0" targetFramework="net462" />
<package id="System.Text.Json" version="5.0.1" targetFramework="net462" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net462" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net462" />
</packages>

View File

@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>

View File

@ -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; }
}
}

View File

@ -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; }
}
}

View File

@ -0,0 +1,11 @@
using System.Collections.Generic;
namespace LANCommander.SDK.Models
{
public class Company : BaseModel
{
public string Name { get; set; }
public virtual IEnumerable<Game> PublishedGames { get; set; }
public virtual IEnumerable<Game> DevelopedGames { get; set; }
}
}

View File

@ -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<Tag> Tags { get; set; }
public virtual Company Publisher { get; set; }
public virtual Company Developer { get; set; }
public virtual IEnumerable<Archive> Archives { get; set; }
}
}

View File

@ -0,0 +1,10 @@
using System.Collections.Generic;
namespace LANCommander.SDK.Models
{
public class Tag : BaseModel
{
public string Name { get; set; }
public virtual IEnumerable<Game> Games { get; set; }
}
}

View File

@ -0,0 +1,10 @@
using System;
namespace LANCommander.SDK.Models
{
public class User
{
public Guid Id { get; set; }
public string UserName { get; set; }
}
}

View File

@ -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

View File

@ -45,6 +45,10 @@
<Folder Include="Migrations\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LANCommander.SDK\LANCommander.SDK.csproj" />
</ItemGroup>
<ItemGroup>
<TypeScriptCompile Update="wwwroot\js\Upload.ts">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>

Binary file not shown.