Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 170 additions & 0 deletions Stardrop/Models/Nexus/CollectionIndex.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
using System.Collections.Generic;
using System.Dynamic;
using System.Text.Json.Serialization;

namespace Stardrop.Models.Nexus
{
public class CollectionInfo
{
[JsonPropertyName("author")]
public string Author { get; set; }
[JsonPropertyName("authorUrl")]
public string AuthorUrl { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
[JsonPropertyName("description")]
public string Description { get; set; }
[JsonPropertyName("installInstructions")]
public string InstallInstructions { get; set; }
[JsonPropertyName("domainName")]
public string DomainName { get; set; }
[JsonPropertyName("gameVersions")]
public List<string> GameVersions { get; set; }
}

public class CollectionConfig
{
[JsonPropertyName("recommendNewProfile")]
public bool RecommendNewProfile { get; set; }
}


[JsonConverter(typeof(JsonStringEnumConverter))]
public enum CollectionModRuleType
{
Before,
Conflicts,
After
}

public class CollectionModRuleSource
{
[JsonPropertyName("fileExpression")]
public string FileExpression { get; set; }
[JsonPropertyName("fileMD5")]
public string? FileMD5 { get; set; }
[JsonPropertyName("tag")]
public string? Tag { get; set; }

[JsonPropertyName("versionMatch")]
public string VersionMatch { get; set; }

[JsonPropertyName("logicalFileName")]
public string LogicalFileName { get; set; }
}

public class CollectionModRuleReference
{
[JsonPropertyName("fileExpression")]
public string? FileExpression { get; set; }
[JsonPropertyName("fileMD5")]
public string? FileMD5 { get; set; }

[JsonPropertyName("versionMatch")]
public string VersionMatch { get; set; }

[JsonPropertyName("idHint")]
public string? IdHint { get; set; }
[JsonPropertyName("logicalFileName")]
public string? LogicalFileName { get; set; }
}

public class CollectionModRule
{
[JsonPropertyName("type")]
public CollectionModRuleType Type { get; set; }

[JsonPropertyName("source")]
public CollectionModRuleSource Source { get; set; }

[JsonPropertyName("reference")]
public CollectionModRuleReference Reference { get; set; }
}

public class CollectionModDetails
{
[JsonPropertyName("category")]
public string Category { get; set; }
[JsonPropertyName("type")]
public string Type { get; set; }
}

[JsonConverter(typeof(JsonStringEnumConverter))]
public enum CollectionModSourceType
{
Nexus,
Direct,
Browse, // manual download via web browser, picky suggested ignoring this one.
Bundle
}

public class CollectionModSource
{
[JsonPropertyName("updatePolicy")]
public string UpdatePolicy { get; set; }
[JsonPropertyName("type")]
public CollectionModSourceType Type { get; set; }
[JsonPropertyName("fileSize")]
public int Size { get; set; }

// "bundle" type only
[JsonPropertyName("adultContent")]
public bool? AdultContent { get; set; }
[JsonPropertyName("fileExpression")]
public string? FileExpression { get; set; }

// "bundle" or "nexus" type only
[JsonPropertyName("tag")]
public string? Tag { get; set; }

// everything except bundle only
[JsonPropertyName("md5")]
public string? MD5Checksum { get; set; }
[JsonPropertyName("logicalFilename")]
public string? LogicalFilename { get; set; }


// "nexus" type only
[JsonPropertyName("modId")]
public int? ModId { get; set; }
[JsonPropertyName("fileId")]
public int? FileId { get; set; }

// "browse" and "direct" type only
[JsonPropertyName("url")]
public string? Url { get; set; }
}

public class CollectionMods
{
[JsonPropertyName("name")]
public string Name { get; set; }
[JsonPropertyName("version")]
public string Version { get; set; }
[JsonPropertyName("optional")]
public bool Optional { get; set; }
[JsonPropertyName("domainName")]
public string DomainName { get; set; }
[JsonPropertyName("author")]
public string Author { get; set; }
[JsonPropertyName("phase")]
public int Phase { get; set; }
[JsonPropertyName("details")]
public CollectionModDetails Details { get; set; }
[JsonPropertyName("source")]
public CollectionModSource Source { get; set; }

}

public class CollectionIndex
{
[JsonPropertyName("info")]
public CollectionInfo Info { get; set; }
[JsonPropertyName("collectionConfig")]
public CollectionConfig Config { get; set; }
[JsonPropertyName("modRules")]
public List<CollectionModRule> ModRules { get; set; }
[JsonPropertyName("mods")]
public List<CollectionMods> Mods { get; set; }
}
}
36 changes: 36 additions & 0 deletions Stardrop/Models/Nexus/Web/CollectionResult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Text.Json.Serialization;

namespace Stardrop.Models.Nexus.Web
{
using System.Text.Json.Serialization;

public class CollectionResult
{
[JsonPropertyName("collection")]
public Collection Collection { get; set; }
}

public class Collection
{
[JsonPropertyName("gameId")]
public int GameId { get; set; }

[JsonPropertyName("id")]
public int Id { get; set; }

[JsonPropertyName("name")]
public string Name { get; set; }

[JsonPropertyName("summary")]
public string Summary { get; set; }

[JsonPropertyName("latestPublishedRevision")]
public LatestPublishedRevision LatestPublishedRevision { get; set; }
}

public class LatestPublishedRevision
{
[JsonPropertyName("downloadLink")]
public string DownloadLink { get; set; }
}
}
23 changes: 23 additions & 0 deletions Stardrop/Models/Nexus/Web/CollectionRevisionDownload.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace Stardrop.Models.Nexus.Web
{
public class CollectionRevisionDownloadLink
{
[JsonPropertyName("name")]
public string Name { get; set; }

[JsonPropertyName("short_name")]
public string ShortName { get; set; }

[JsonPropertyName("URI")]
public string Uri { get; set; }
}

public class CollectionRevisionDownloadResult
{
[JsonPropertyName("download_links")]
public List<CollectionRevisionDownloadLink> DownloadLinks { get; set; }
}
}
25 changes: 25 additions & 0 deletions Stardrop/Models/Nexus/Web/NXM.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
using System;
using System.Text.RegularExpressions;
using Stardrop.Utilities.External;

namespace Stardrop.Models.Nexus.Web
{
public class NXM
{
public enum NXMPurpose
{
Mod,
Collection,
Unknown
}

public static NXMPurpose CalculatePurpose(NXM nxm)
{
if (nxm.Link is null) return NXMPurpose.Unknown;

var modMatch = Regex.Match(Regex.Unescape(nxm.Link), NexusClient._nxmModPattern);
var collectionMatch = Regex.Match(Regex.Unescape(nxm.Link), NexusClient._nxmCollectionPattern);

if (modMatch.Success) return NXMPurpose.Mod;
if (collectionMatch.Success) return NXMPurpose.Collection;

return NXMPurpose.Unknown;
}


public string? Link { get; set; }
public DateTime Timestamp { get; set; }

public NXMPurpose? Purpose { get; set; }
}
}
6 changes: 5 additions & 1 deletion Stardrop/Stardrop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,16 @@
<PackageReference Include="Avalonia.Markup.Xaml.Loader" Version="0.10.17" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.17" />
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="GraphQL" Version="8.5.0" />
<PackageReference Include="GraphQL.Client" Version="6.1.0" />
<PackageReference Include="GraphQL.Client.Serializer.Newtonsoft" Version="6.1.0" />
<PackageReference Include="GraphQL.NewtonsoftJson" Version="8.5.0" />
<PackageReference Include="Json.More.Net" Version="2.0.1" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="Projektanker.Icons.Avalonia" Version="5.13.0" />
<PackageReference Include="Projektanker.Icons.Avalonia.MaterialDesign" Version="5.13.0" />
<PackageReference Include="semver" Version="2.3.0" />
<PackageReference Include="SharpCompress" Version="0.32.1" />
<PackageReference Include="SharpCompress" Version="0.40.0" />
</ItemGroup>
<ItemGroup>
<Compile Update="Views\FlexibleOptionWindow.axaml.cs">
Expand Down
Loading