mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-13 08:41:27 +00:00
* Implement basic RPC information endpoint with test data * Implement configuration options for RPC * Rename RpcConfiguration to RpcResponse * Rider insists on modifying dataSources.xml * Implement documentation and fix code quality/gitignore issues * Use SerializableAttribute instead of UsedImplicitlyAttribute * Add warning regarding nullable assets * Prevent precision issues with application ID * Check asset properties for null/whitespace and return null
33 lines
No EOL
1.4 KiB
C#
33 lines
No EOL
1.4 KiB
C#
#nullable disable
|
|
|
|
using LBPUnion.ProjectLighthouse.Configuration.ConfigurationCategories;
|
|
|
|
namespace LBPUnion.ProjectLighthouse.Servers.API.Responses;
|
|
|
|
public class RpcResponse
|
|
{
|
|
public string ApplicationId { get; set; }
|
|
public string PartyIdPrefix { get; set; }
|
|
public UsernameType UsernameType { get; set; }
|
|
public RpcAssets Assets { get; set; }
|
|
|
|
public static RpcResponse CreateFromConfiguration(RichPresenceConfiguration configuration) =>
|
|
new()
|
|
{
|
|
ApplicationId = configuration.ApplicationId,
|
|
PartyIdPrefix = configuration.PartyIdPrefix,
|
|
UsernameType = configuration.UsernameType,
|
|
Assets = new RpcAssets
|
|
{
|
|
PodAsset = AssetConvertNull(configuration.Assets.PodAsset),
|
|
MoonAsset = AssetConvertNull(configuration.Assets.MoonAsset),
|
|
RemoteMoonAsset = AssetConvertNull(configuration.Assets.RemoteMoonAsset),
|
|
DeveloperAsset = AssetConvertNull(configuration.Assets.DeveloperAsset),
|
|
DeveloperAdventureAsset = AssetConvertNull(configuration.Assets.DeveloperAdventureAsset),
|
|
DlcAsset = AssetConvertNull(configuration.Assets.DlcAsset),
|
|
FallbackAsset = AssetConvertNull(configuration.Assets.FallbackAsset),
|
|
},
|
|
};
|
|
|
|
private static string AssetConvertNull(string asset) => string.IsNullOrWhiteSpace(asset) ? null : asset;
|
|
} |