Credits window to XAML UI (#4622)
This commit is contained in:
30
Content.Client/Credits/CreditsWindow.xaml
Normal file
30
Content.Client/Credits/CreditsWindow.xaml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<SS14Window xmlns="https://spacestation14.io"
|
||||||
|
Title="{Loc 'credits-window-title'}"
|
||||||
|
SetSize="650 650" >
|
||||||
|
<TabContainer>
|
||||||
|
<ScrollContainer Name="Ss14ContributorsTab"
|
||||||
|
HScrollEnabled="False">
|
||||||
|
<BoxContainer Name="Ss14ContributorsContainer"
|
||||||
|
Orientation="Vertical"
|
||||||
|
Margin="2 2 0 0">
|
||||||
|
<!-- Contributors get added here by code -->
|
||||||
|
</BoxContainer>
|
||||||
|
</ScrollContainer>
|
||||||
|
<ScrollContainer Name="PatronsTab"
|
||||||
|
HScrollEnabled="False">
|
||||||
|
<BoxContainer Name="PatronsContainer"
|
||||||
|
Orientation="Vertical"
|
||||||
|
Margin="2 2 0 0">
|
||||||
|
<!-- Patrons get added here by code -->
|
||||||
|
</BoxContainer>
|
||||||
|
</ScrollContainer>
|
||||||
|
<ScrollContainer Name="LicensesTab"
|
||||||
|
HScrollEnabled="False">
|
||||||
|
<BoxContainer Name="LicensesContainer"
|
||||||
|
Orientation="Vertical"
|
||||||
|
Margin="2 2 0 0">
|
||||||
|
<!-- Licenses get added here by code -->
|
||||||
|
</BoxContainer>
|
||||||
|
</ScrollContainer>
|
||||||
|
</TabContainer>
|
||||||
|
</SS14Window>
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Client.Links;
|
using Content.Client.Links;
|
||||||
using Content.Client.Stylesheets;
|
using Content.Client.Stylesheets;
|
||||||
using Content.Shared;
|
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
|
using Robust.Client.AutoGenerated;
|
||||||
using Robust.Client.Credits;
|
using Robust.Client.Credits;
|
||||||
using Robust.Client.ResourceManagement;
|
using Robust.Client.ResourceManagement;
|
||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.CustomControls;
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
|
using Robust.Client.UserInterface.XAML;
|
||||||
using Robust.Shared.Configuration;
|
using Robust.Shared.Configuration;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
@@ -20,7 +20,8 @@ using static Robust.Client.UserInterface.Controls.BoxContainer;
|
|||||||
|
|
||||||
namespace Content.Client.Credits
|
namespace Content.Client.Credits
|
||||||
{
|
{
|
||||||
public sealed class CreditsWindow : SS14Window
|
[GenerateTypedNameReferences]
|
||||||
|
public sealed partial class CreditsWindow : SS14Window
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IResourceCache _resourceManager = default!;
|
[Dependency] private readonly IResourceCache _resourceManager = default!;
|
||||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||||
@@ -35,71 +36,34 @@ namespace Content.Client.Credits
|
|||||||
public CreditsWindow()
|
public CreditsWindow()
|
||||||
{
|
{
|
||||||
IoCManager.InjectDependencies(this);
|
IoCManager.InjectDependencies(this);
|
||||||
|
RobustXamlLoader.Load(this);
|
||||||
|
|
||||||
Title = Loc.GetString("credits-window-title");
|
TabContainer.SetTabTitle(Ss14ContributorsTab, Loc.GetString("credits-window-ss14contributorslist-tab"));
|
||||||
|
TabContainer.SetTabTitle(PatronsTab, Loc.GetString("credits-window-patrons-tab"));
|
||||||
|
TabContainer.SetTabTitle(LicensesTab, Loc.GetString("credits-window-licenses-tab"));
|
||||||
|
|
||||||
var rootContainer = new TabContainer();
|
PopulateContributors(Ss14ContributorsContainer);
|
||||||
|
PopulatePatrons(PatronsContainer);
|
||||||
var patronsList = new ScrollContainer
|
PopulateLicenses(LicensesContainer);
|
||||||
{
|
|
||||||
HScrollEnabled = false
|
|
||||||
};
|
|
||||||
var ss14ContributorsList = new ScrollContainer
|
|
||||||
{
|
|
||||||
HScrollEnabled = false
|
|
||||||
};
|
|
||||||
var licensesList = new ScrollContainer
|
|
||||||
{
|
|
||||||
HScrollEnabled = false
|
|
||||||
};
|
|
||||||
|
|
||||||
rootContainer.AddChild(ss14ContributorsList);
|
|
||||||
rootContainer.AddChild(patronsList);
|
|
||||||
rootContainer.AddChild(licensesList);
|
|
||||||
|
|
||||||
TabContainer.SetTabTitle(patronsList, Loc.GetString("credits-window-patrons-tab"));
|
|
||||||
TabContainer.SetTabTitle(ss14ContributorsList, Loc.GetString("credits-window-ss14contributorslist-tab"));
|
|
||||||
TabContainer.SetTabTitle(licensesList, Loc.GetString("credits-window-licenses-tab"));
|
|
||||||
|
|
||||||
PopulatePatronsList(patronsList);
|
|
||||||
PopulateCredits(ss14ContributorsList);
|
|
||||||
PopulateLicenses(licensesList);
|
|
||||||
|
|
||||||
Contents.AddChild(rootContainer);
|
|
||||||
|
|
||||||
SetSize = (650, 650);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PopulateLicenses(ScrollContainer licensesList)
|
private void PopulateLicenses(BoxContainer licensesContainer)
|
||||||
{
|
{
|
||||||
var vBox = new BoxContainer
|
|
||||||
{
|
|
||||||
Orientation = LayoutOrientation.Vertical,
|
|
||||||
Margin = new Thickness(2, 2, 0, 0)
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach (var entry in CreditsManager.GetLicenses().OrderBy(p => p.Name))
|
foreach (var entry in CreditsManager.GetLicenses().OrderBy(p => p.Name))
|
||||||
{
|
{
|
||||||
vBox.AddChild(new Label {StyleClasses = {StyleBase.StyleClassLabelHeading}, Text = entry.Name});
|
licensesContainer.AddChild(new Label {StyleClasses = {StyleBase.StyleClassLabelHeading}, Text = entry.Name});
|
||||||
|
|
||||||
// We split these line by line because otherwise
|
// We split these line by line because otherwise
|
||||||
// the LGPL causes Clyde to go out of bounds in the rendering code.
|
// the LGPL causes Clyde to go out of bounds in the rendering code.
|
||||||
foreach (var line in entry.License.Split("\n"))
|
foreach (var line in entry.License.Split("\n"))
|
||||||
{
|
{
|
||||||
vBox.AddChild(new Label {Text = line, FontColorOverride = new Color(200, 200, 200)});
|
licensesContainer.AddChild(new Label {Text = line, FontColorOverride = new Color(200, 200, 200)});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
licensesList.AddChild(vBox);
|
private void PopulatePatrons(BoxContainer patronsContainer)
|
||||||
}
|
|
||||||
|
|
||||||
private void PopulatePatronsList(Control patronsList)
|
|
||||||
{
|
{
|
||||||
var vBox = new BoxContainer
|
|
||||||
{
|
|
||||||
Orientation = LayoutOrientation.Vertical,
|
|
||||||
Margin = new Thickness(2, 2, 0, 0)
|
|
||||||
};
|
|
||||||
var patrons = LoadPatrons();
|
var patrons = LoadPatrons();
|
||||||
|
|
||||||
// Do not show "become a patron" button on Steam builds
|
// Do not show "become a patron" button on Steam builds
|
||||||
@@ -107,7 +71,7 @@ namespace Content.Client.Credits
|
|||||||
if (!_cfg.GetCVar(CCVars.BrandingSteam))
|
if (!_cfg.GetCVar(CCVars.BrandingSteam))
|
||||||
{
|
{
|
||||||
Button patronButton;
|
Button patronButton;
|
||||||
vBox.AddChild(patronButton = new Button
|
patronsContainer.AddChild(patronButton = new Button
|
||||||
{
|
{
|
||||||
Text = Loc.GetString("credits-window-become-patron-button"),
|
Text = Loc.GetString("credits-window-become-patron-button"),
|
||||||
HorizontalAlignment = HAlignment.Center
|
HorizontalAlignment = HAlignment.Center
|
||||||
@@ -122,23 +86,19 @@ namespace Content.Client.Credits
|
|||||||
{
|
{
|
||||||
if (!first)
|
if (!first)
|
||||||
{
|
{
|
||||||
vBox.AddChild(new Control {MinSize = (0, 10)});
|
patronsContainer.AddChild(new Control {MinSize = (0, 10)});
|
||||||
}
|
}
|
||||||
|
|
||||||
first = false;
|
first = false;
|
||||||
vBox.AddChild(new Label {StyleClasses = {StyleBase.StyleClassLabelHeading}, Text = $"{tier.Key}"});
|
patronsContainer.AddChild(new Label {StyleClasses = {StyleBase.StyleClassLabelHeading}, Text = $"{tier.Key}"});
|
||||||
|
|
||||||
var msg = string.Join(", ", tier.OrderBy(p => p.Name).Select(p => p.Name));
|
var msg = string.Join(", ", tier.OrderBy(p => p.Name).Select(p => p.Name));
|
||||||
|
|
||||||
var label = new RichTextLabel();
|
var label = new RichTextLabel();
|
||||||
label.SetMessage(msg);
|
label.SetMessage(msg);
|
||||||
|
|
||||||
vBox.AddChild(label);
|
patronsContainer.AddChild(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
patronsList.AddChild(vBox);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<PatronEntry> LoadPatrons()
|
private IEnumerable<PatronEntry> LoadPatrons()
|
||||||
@@ -151,17 +111,11 @@ namespace Content.Client.Credits
|
|||||||
.Select(m => new PatronEntry(m["Name"].AsString(), m["Tier"].AsString()));
|
.Select(m => new PatronEntry(m["Name"].AsString(), m["Tier"].AsString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PopulateCredits(Control contributorsList)
|
private void PopulateContributors(BoxContainer ss14ContributorsContainer)
|
||||||
{
|
{
|
||||||
Button contributeButton;
|
Button contributeButton;
|
||||||
|
|
||||||
var vBox = new BoxContainer
|
ss14ContributorsContainer.AddChild(new BoxContainer
|
||||||
{
|
|
||||||
Orientation = LayoutOrientation.Vertical,
|
|
||||||
Margin = new Thickness(2, 2, 0, 0)
|
|
||||||
};
|
|
||||||
|
|
||||||
vBox.AddChild(new BoxContainer
|
|
||||||
{
|
{
|
||||||
Orientation = LayoutOrientation.Horizontal,
|
Orientation = LayoutOrientation.Horizontal,
|
||||||
HorizontalAlignment = HAlignment.Center,
|
HorizontalAlignment = HAlignment.Center,
|
||||||
@@ -179,11 +133,11 @@ namespace Content.Client.Credits
|
|||||||
{
|
{
|
||||||
if (!first)
|
if (!first)
|
||||||
{
|
{
|
||||||
vBox.AddChild(new Control {MinSize = (0, 10)});
|
ss14ContributorsContainer.AddChild(new Control {MinSize = (0, 10)});
|
||||||
}
|
}
|
||||||
|
|
||||||
first = false;
|
first = false;
|
||||||
vBox.AddChild(new Label {StyleClasses = {StyleBase.StyleClassLabelHeading}, Text = title});
|
ss14ContributorsContainer.AddChild(new Label {StyleClasses = {StyleBase.StyleClassLabelHeading}, Text = title});
|
||||||
|
|
||||||
var label = new RichTextLabel();
|
var label = new RichTextLabel();
|
||||||
var text = _resourceManager.ContentFileReadAllText($"/Credits/{path}");
|
var text = _resourceManager.ContentFileReadAllText($"/Credits/{path}");
|
||||||
@@ -196,7 +150,7 @@ namespace Content.Client.Credits
|
|||||||
label.SetMessage(text);
|
label.SetMessage(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
vBox.AddChild(label);
|
ss14ContributorsContainer.AddChild(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddSection(Loc.GetString("credits-window-contributors-section-title"), "GitHub.txt");
|
AddSection(Loc.GetString("credits-window-contributors-section-title"), "GitHub.txt");
|
||||||
@@ -204,27 +158,10 @@ namespace Content.Client.Credits
|
|||||||
AddSection(Loc.GetString("credits-window-original-remake-team-section-title"), "OriginalRemake.txt");
|
AddSection(Loc.GetString("credits-window-original-remake-team-section-title"), "OriginalRemake.txt");
|
||||||
AddSection(Loc.GetString("credits-window-special-thanks-section-title"), "SpecialThanks.txt", true);
|
AddSection(Loc.GetString("credits-window-special-thanks-section-title"), "SpecialThanks.txt", true);
|
||||||
|
|
||||||
contributorsList.AddChild(vBox);
|
|
||||||
|
|
||||||
contributeButton.OnPressed += _ =>
|
contributeButton.OnPressed += _ =>
|
||||||
IoCManager.Resolve<IUriOpener>().OpenUri(UILinks.GitHub);
|
IoCManager.Resolve<IUriOpener>().OpenUri(UILinks.GitHub);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO this doesn't looked used anywhere
|
|
||||||
private static IEnumerable<string> Lines(TextReader reader)
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
var line = reader.ReadLine();
|
|
||||||
if (line == null)
|
|
||||||
{
|
|
||||||
yield break;
|
|
||||||
}
|
|
||||||
|
|
||||||
yield return line;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private sealed class PatronEntry
|
private sealed class PatronEntry
|
||||||
{
|
{
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
Reference in New Issue
Block a user