ModList list from GitHub will display the description of a game instead of toString if available

This commit is contained in:
erri120 2019-11-18 16:46:55 +01:00
parent 50bbd0eb1f
commit 2fde106b92
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135
2 changed files with 14 additions and 3 deletions

View File

@ -6,6 +6,7 @@ using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
using CommonMark.Syntax;
using Newtonsoft.Json;
using Wabbajack.Common;
using Wabbajack.Lib.Downloaders;
@ -31,6 +32,9 @@ namespace Wabbajack.Lib.ModListRegistry
[JsonProperty("game")]
public Game Game { get; set; }
[JsonIgnore]
public string GameName { get; set; }
[JsonProperty("official")]
public bool Official { get; set; }
@ -75,9 +79,16 @@ namespace Wabbajack.Lib.ModListRegistry
public static List<ModlistMetadata> LoadFromGithub()
{
var client = new HttpClient();
Utils.Log("Loading Modlists from Github");
Utils.Log("Loading ModLists from Github");
var result = client.GetStringSync(Consts.ModlistMetadataURL);
return result.FromJSONString<List<ModlistMetadata>>();
var list = result.FromJSONString<List<ModlistMetadata>>();
list.Do(m =>
{
m.GameName = m.Game.ToDescriptionString();
if (string.IsNullOrWhiteSpace(m.GameName))
m.GameName = m.Game.ToString();
});
return list;
}
public bool NeedsDownload(string modlistPath)

View File

@ -97,7 +97,7 @@
Grid.Row="1"
Grid.Column="4"
HorizontalAlignment="Right"
Text="{Binding Game}"
Text="{Binding GameName}"
TextAlignment="Right" />
<TextBlock
Grid.Row="2"