Skip to content

Commit

Permalink
Changed: GameBanana Item Type is now a dropdown.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed Nov 2, 2022
1 parent c7f0051 commit 171f627
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
6 changes: 5 additions & 1 deletion source/Reloaded.Mod.Loader.IO/Config/IConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ namespace Reloaded.Mod.Loader.IO.Config;
/// </summary>
public interface IConfig<TType> : IConfig where TType : IConfig<TType>, new()
{
private static JsonSerializerOptions _options = new JsonSerializerOptions() { WriteIndented = true };
private static JsonSerializerOptions _options = new JsonSerializerOptions()
{
WriteIndented = true
};

private static Encoding _encoding = new UTF8Encoding(false);

#if NET7_0_OR_GREATER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public async Task<ModDependencyResolveResult> ResolveAsync(string packageId, Dic
var resolver = new GameBananaUpdateResolver(new GameBananaResolverConfiguration()
{
ItemId = (int)gbConfig.Config.ItemId,
ModType = gbConfig.Config.ItemType
ModType = gbConfig.Config.ItemType.ToString()
}, new CommonPackageResolverSettings() { MetadataFileName = gbConfig.ReleaseMetadataName });

await resolver.InitializeAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void Migrate(PathTuple<ModConfig> mod, PathTuple<ModUserConfig>? userConf
return new GameBananaUpdateResolver(new GameBananaResolverConfiguration()
{
ItemId = (int) gbConfig!.ItemId,
ModType = gbConfig.ItemType
ModType = gbConfig.ItemType.ToString()
}, data.CommonPackageResolverSettings);
}

Expand Down Expand Up @@ -82,8 +82,9 @@ public class GameBananaConfig : IConfig<GameBananaConfig>
/// Type of the item on GameBanana, typically 'Mod'
/// </summary>
[Category(DefaultCategory)]
[Description("Type of the item on GameBanana, typically 'Mod'.")]
public string ItemType { get; set; } = "Mod";
[Description("Type of the item on GameBanana.")]
[JsonConverter(typeof(JsonStringEnumConverter))]
public GBItemType ItemType { get; set; } = GBItemType.Mod;

/// <summary>
/// Id of the item on GameBanana, this is the last number in the URL to your mod page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class GameBananaMod
{
public const string CategoryMod = "Mod";
public const string CategorySound = "Sound";
public const string CategoryWip = "Wip";

[JsonPropertyName("_idRow")]
public long Id { get; set; }
Expand Down Expand Up @@ -61,9 +62,10 @@ public class GameBananaMod
/// <param name="take">Number of items to take.</param>
public static async Task<List<GameBananaMod>> GetByNameAllCategoriesAsync(string? searchText, int gameId, int page, int take)
{
var tasks = new Task<List<GameBananaMod>>[2];
var tasks = new Task<List<GameBananaMod>>[3];
tasks[0] = GetByNameAsync(searchText, gameId, page, take, CategoryMod);
tasks[1] = GetByNameAsync(searchText, gameId, page, take, CategorySound);
tasks[2] = GetByNameAsync(searchText, gameId, page, take, CategoryWip);
await Task.WhenAll(tasks);

var result = tasks[1].Result;
Expand Down Expand Up @@ -453,4 +455,26 @@ public override void Write(Utf8JsonWriter writer, Dictionary<string, GameBananaM
{
JsonSerializer.Serialize(writer, value, _options);
}
}

// DO NOT RENAME, THESE ARE SAME STRINGS AS USED IN API
/// <summary>
/// Type of GameBanana item.
/// </summary>
public enum GBItemType
{
/// <summary>
/// For all mods.
/// </summary>
Mod,

/// <summary>
/// Because site staff is funny.
/// </summary>
Sound,

/// <summary>
/// You can upload files here? Damn.
/// </summary>
Wip,
}

0 comments on commit 171f627

Please sign in to comment.