Skip to content

Commit

Permalink
StyleSpace is no more
Browse files Browse the repository at this point in the history
Signed-off-by: Brandon Li <sirbrandonthenerd@gmail.com>
  • Loading branch information
aspiringLich committed Jul 21, 2024
1 parent 05917be commit 5206ba3
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<Control xmlns="https://spacestation14.io"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client">
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
Stylesheet="System">
<PanelContainer MouseFilter="Stop">
<PanelContainer.PanelOverride>
<!-- semi-transparent background -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ public AdminMessagePopupWindow()
{
RobustXamlLoader.Load(this);

Stylesheet = IoCManager.Resolve<IStylesheetManager>().SheetSpace;

AcceptButton.OnPressed += OnAcceptButtonPressed;
DismissButton.OnPressed += OnDismissButtonPressed;
}
Expand All @@ -49,7 +47,8 @@ public void SetState(AdminMessageEuiState state)
MessageContainer.AddChild(new AdminMessagePopupMessage(message));
}

Description.SetMessage(FormattedMessage.FromMarkup(Loc.GetString("admin-notes-message-desc", ("count", state.Messages.Length))));
Description.SetMessage(
FormattedMessage.FromMarkup(Loc.GetString("admin-notes-message-desc", ("count", state.Messages.Length))));
}

private void OnDismissButtonPressed(BaseButton.ButtonEventArgs obj)
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/Changelog/ChangelogWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
xmlns:ui="clr-namespace:Content.Client.Changelog"
Title="{Loc 'changelog-window-title'}"
MinSize="500 400"
SetSize="500 400">
SetSize="500 400"
Stylesheet="Interface">
<PanelContainer StyleClasses="AngleRect" />
<BoxContainer Orientation="Vertical">
<TabContainer Name="Tabs" Access="Public" HorizontalExpand="True" VerticalExpand="True" />
Expand Down
1 change: 0 additions & 1 deletion Content.Client/Changelog/ChangelogWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public ChangelogWindow()
{
RobustXamlLoader.Load(this);
WindowTitle.AddStyleClass(StyleClass.LabelHeading);
Stylesheet = IoCManager.Resolve<IStylesheetManager>().SheetSpace;
}

protected override void Opened()
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Launcher/LauncherConnectingGui.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public LauncherConnectingGui(LauncherConnecting state, IRobustRandom random,

LayoutContainer.SetAnchorPreset(this, LayoutContainer.LayoutPreset.Wide);

Stylesheet = IoCManager.Resolve<IStylesheetManager>().SheetSpace;
Stylesheet = IoCManager.Resolve<IStylesheetManager>().SheetSystem;

ChangeLoginTip();
ReconnectButton.OnPressed += ReconnectButtonPressed;
Expand Down
5 changes: 3 additions & 2 deletions Content.Client/Stylesheets/IStylesheetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ namespace Content.Client.Stylesheets;

public interface IStylesheetManager
{
Stylesheet SheetNano { get; }
Stylesheet SheetSpace { get; }
Stylesheet SheetNanotransen { get; }
Stylesheet SheetSystem { get; }

public Dictionary<string, Stylesheet> Stylesheets { get; }

void Initialize();
}
10 changes: 8 additions & 2 deletions Content.Client/Stylesheets/Redux/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,17 @@
- `ColorPalette` / `Palettes` but same thing
- [x] tooltips being part of another stylesheet is kinda bad
- [x] rename `InterfaceStylesheet` to `SystemStylesheet`
- [ ] rename `FancyWindow` to `NanoWindow`
- [ ] ~~rename `FancyWindow` to `NanoWindow`~~
- doesnt work with other stylesheets so `FancyWindow` stays!
- [x] add a `Stylesheet` property, so you can like, set the styles of a window
- [x] Get rid of `NTSheetlets` & `InterfaceSheetlets`
- Eh, most of it anyway
- [x] Make all `StyleClass` conform to naming conventions
- [x] Separate out `FontKind` maybe
- [x] change `ButtonHovered` and friends to `PseudoHovered`
- [x] `IPanelPalette` is unnecessary now
- [ ] What the fuck is `StyleSpace` get rid of it
- [x] What the fuck is `StyleSpace` get rid of it
- Switched to `SystemStylesheet`
- [x] Fix the codepen
- [ ] figure out `BaseStylesheet.Fonts`

Expand All @@ -59,6 +62,7 @@ TL;DR port all of `StyleNano` into sheetlets

### Another PR:

- [ ] Style classes for window sizes (and yayyy refactor all the windows maybe?)
- [ ] Admin Message window exit button is basically indistinguishable from the red header
- [ ] Button text colors / change text color when pressed / disabled?
- [ ] Resizing windows is like, too precise
Expand Down Expand Up @@ -152,13 +156,15 @@ that, ideally, every theme should have a unique implementation of, then you woul

#### `StyleNano` is gone!!

- Well it's not gone, but it is obsolete. If you have messed with it at all, your changes will need to be redone.
- Style classes defined in `StyleNano` have been moved either to `Content.Client.Stylesheets.Redux.StyleClass` or their
associated `Control`.
- Any `StyleRule` additions to `StyleNano` must be rewritten to conform to the new format (See guide (TODO: LINK GUIDE))
- Some unused / redundant style classes were removed. If you hapenned to be relying on them, either substitute in the
appropriate style classes defined in `Content.Client.Stylesheets.Redux.StyleClass` or create a new Sheetlet (Again,
see guide)
- If you are planning on creating a new UI, there are new conventions you should follow (Yet again, see guide)
- `StyleSpace` is gone too but that probably doesn't affect you

#### `Content.Client/Stylesheets/Redux`

Expand Down
21 changes: 11 additions & 10 deletions Content.Client/Stylesheets/StylesheetManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Diagnostics;
using Content.Client.Stylesheets.Redux;
using Content.Client.Stylesheets.Redux.Stylesheets;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;

namespace Content.Client.Stylesheets
Expand All @@ -10,31 +9,33 @@ public sealed class StylesheetManager : IStylesheetManager
{
[Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;

public Stylesheet SheetNano { get; private set; } = default!;
public Stylesheet SheetNanotransen { get; private set; } = default!;
public Stylesheet SheetSystem { get; private set; } = default!;
public Stylesheet SheetSpace { get; private set; } = default!;

public Dictionary<string, Stylesheet> Stylesheets { get; private set; } = default!;

public void Initialize()
{
var sawmill = _logManager.GetSawmill("style");
sawmill.Debug("Initializing Stylesheets...");
var sw = Stopwatch.StartNew();

SheetNano = Init(new NanotrasenStylesheet(new PalettedStylesheet.NoConfig()));
SheetSystem = Init(new SystemStylesheet(new PalettedStylesheet.NoConfig()));
SheetSpace = new StyleSpace(_resourceCache).Stylesheet; // TODO: REMOVE
Stylesheets = new Dictionary<string, Stylesheet>();

SheetNanotransen = Init("Nanotransen", new NanotrasenStylesheet(new PalettedStylesheet.NoConfig()));
SheetSystem = Init("Interface", new SystemStylesheet(new PalettedStylesheet.NoConfig()));

_userInterfaceManager.Stylesheet = SheetNano;
_userInterfaceManager.Stylesheet = SheetNanotransen;

sawmill.Debug($"Initialized {_styleRuleCount} style rules in {sw.Elapsed}");
}

private int _styleRuleCount = 0;
private int _styleRuleCount;

public Stylesheet Init(BaseStylesheet baseSheet)
public Stylesheet Init(string name, BaseStylesheet baseSheet)
{
Stylesheets.Add(name, baseSheet.Stylesheet);
_styleRuleCount += baseSheet.Stylesheet.Rules.Count;
return baseSheet.Stylesheet;
}
Expand Down
17 changes: 17 additions & 0 deletions Content.Client/UserInterface/Controls/FancyWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Numerics;
using Content.Client.Guidebook;
using Content.Client.Guidebook.Components;
using Content.Client.Stylesheets;
using Content.Shared.Guidebook;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
Expand All @@ -14,6 +15,7 @@ namespace Content.Client.UserInterface.Controls
public partial class FancyWindow : BaseWindow
{
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
[Dependency] private readonly IStylesheetManager _styleMan = default!;
private GuidebookSystem? _guidebookSystem;
private const int DRAG_MARGIN_SIZE = 7;

Expand All @@ -23,6 +25,7 @@ public partial class FancyWindow : BaseWindow
public FancyWindow()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

CloseButton.OnPressed += _ => Close();
HelpButton.OnPressed += _ => Help();
Expand All @@ -35,7 +38,21 @@ public string? Title
set => WindowTitle.Text = value;
}

private string? _stylesheet;

public new string? Stylesheet
{
get => _stylesheet;
set
{
_stylesheet = value;
if (value is not null && _styleMan.Stylesheets.TryGetValue(value, out var stylesheet))
base.Stylesheet = stylesheet;
}
}

private List<ProtoId<GuideEntryPrototype>>? _helpGuidebookIds;

public List<ProtoId<GuideEntryPrototype>>? HelpGuidebookIds
{
get => _helpGuidebookIds;
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Voting/UI/VoteCallMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public VoteCallMenu()
IoCManager.InjectDependencies(this);
RobustXamlLoader.Load(this);

Stylesheet = IoCManager.Resolve<IStylesheetManager>().SheetSpace;
Stylesheet = IoCManager.Resolve<IStylesheetManager>().SheetSystem;
CloseButton.OnPressed += _ => Close();

for (var i = 0; i < AvailableVoteTypes.Length; i++)
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Voting/UI/VotePopup.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public VotePopup(VoteManager.ActiveVote vote)
IoCManager.InjectDependencies(this);
RobustXamlLoader.Load(this);

Stylesheet = IoCManager.Resolve<IStylesheetManager>().SheetSpace;
Stylesheet = IoCManager.Resolve<IStylesheetManager>().SheetSystem;

Modulate = Color.White.WithAlpha(0.75f);
_voteButtons = new Button[vote.Entries.Length];
Expand Down

0 comments on commit 5206ba3

Please sign in to comment.