diff --git a/Content.Client/UserInterface/CreditsWindow.cs b/Content.Client/UserInterface/CreditsWindow.cs index 1bdd4c7a76..c43271c270 100644 --- a/Content.Client/UserInterface/CreditsWindow.cs +++ b/Content.Client/UserInterface/CreditsWindow.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.IO; using System.Linq; using Content.Client.UserInterface.Stylesheets; -using Newtonsoft.Json; using Robust.Client.Credits; using Robust.Client.Interfaces.ResourceManagement; using Robust.Client.UserInterface; @@ -13,6 +12,7 @@ using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Maths; using Robust.Shared.Utility; +using YamlDotNet.RepresentationModel; namespace Content.Client.UserInterface { @@ -82,7 +82,7 @@ namespace Content.Client.UserInterface var margin = new MarginContainer {MarginLeftOverride = 2, MarginTopOverride = 2}; var vBox = new VBoxContainer(); margin.AddChild(vBox); - var patrons = ReadJson("/Credits/Patrons.json"); + var patrons = LoadPatrons(); Button patronButton; vBox.AddChild(patronButton = new Button @@ -117,6 +117,16 @@ namespace Content.Client.UserInterface patronsList.AddChild(margin); } + private IEnumerable LoadPatrons() + { + var yamlStream = _resourceManager.ContentFileReadYaml(new ResourcePath("/Credits/Patrons.json")); + var sequence = (YamlSequenceNode) yamlStream.Documents[0].RootNode; + + return sequence + .Cast() + .Select(m => new PatronEntry(m["Name"].AsString(), m["Tier"].AsString())); + } + private void PopulateCredits(Control contributorsList) { Button contributeButton; @@ -141,6 +151,7 @@ namespace Content.Client.UserInterface }); var first = true; + void AddSection(string title, string path, bool markup = false) { if (!first) @@ -190,29 +201,16 @@ namespace Content.Client.UserInterface } } - private T ReadJson(string path) - { - var serializer = new JsonSerializer(); - - using var stream = _resourceManager.ContentFileRead(path); - using var streamReader = new StreamReader(stream); - using var jsonTextReader = new JsonTextReader(streamReader); - - return serializer.Deserialize(jsonTextReader)!; - } - - [JsonObject(ItemRequired = Required.Always)] private sealed class PatronEntry { - public string Name { get; set; } = default!; - public string Tier { get; set; } = default!; - } + public string Name { get; } + public string Tier { get; } - [JsonObject(ItemRequired = Required.Always)] - private sealed class OpenSourceLicense - { - public string Name { get; set; } = default!; - public string License { get; set; } = default!; + public PatronEntry(string name, string tier) + { + Name = name; + Tier = tier; + } } } }