diff --git a/OpenDreamClient/InfoLabels/InfoLabel.xaml b/OpenDreamClient/InfoLabels/InfoLabel.xaml new file mode 100644 index 0000000000..b30cd30237 --- /dev/null +++ b/OpenDreamClient/InfoLabels/InfoLabel.xaml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/OpenDreamClient/InfoLabels/InfoLabel.xaml.cs b/OpenDreamClient/InfoLabels/InfoLabel.xaml.cs new file mode 100644 index 0000000000..776241f37e --- /dev/null +++ b/OpenDreamClient/InfoLabels/InfoLabel.xaml.cs @@ -0,0 +1,22 @@ +using Robust.Client.AutoGenerated; +using Robust.Client.UserInterface; +using Robust.Client.UserInterface.Controls; +using Robust.Client.UserInterface.XAML; + +namespace OpenDreamClient.InfoLabels; + +[GenerateTypedNameReferences] +public sealed partial class InfoLabel : Control { + public InfoLabel() { + RobustXamlLoader.Load(this); + + LayoutContainer.SetAnchorPreset(WipBox, LayoutContainer.LayoutPreset.TopLeft); + LayoutContainer.SetMarginTop(WipBox, 10); + LayoutContainer.SetMarginLeft(WipBox, 10); + LayoutContainer.SetGrowHorizontal(WipBox, LayoutContainer.GrowDirection.End); + +#if DEBUG + DebugWarningLabel.Visible = true; +#endif + } +} diff --git a/OpenDreamClient/Interface/DreamStylesheet.cs b/OpenDreamClient/Interface/DreamStylesheet.cs index 94438a55b5..285a863a60 100644 --- a/OpenDreamClient/Interface/DreamStylesheet.cs +++ b/OpenDreamClient/Interface/DreamStylesheet.cs @@ -4,19 +4,55 @@ using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; +using Robust.Shared.Utility; using static Robust.Client.UserInterface.StylesheetHelpers; namespace OpenDreamClient.Interface; +public static class ResCacheExtension +{ + public static Font GetFont(this IResourceCache cache, ResPath[] path, int size) + { + var fs = new Font[path.Length]; + for (var i = 0; i < path.Length; i++) + fs[i] = new VectorFont(cache.GetResource(path[i]), size); + + return new StackedFont(fs); + } + + public static Font GetFont(this IResourceCache cache, string[] path, int size) + { + var rp = new ResPath[path.Length]; + for (var i = 0; i < path.Length; i++) + rp[i] = new ResPath(path[i]); + + return cache.GetFont(rp, size); + } + + // diet notostack from ss14 + public static Font NotoStack(this IResourceCache resCache, string variation = "Regular", int size = 10, bool display = false) + { + var ds = display ? "Display" : ""; + return resCache.GetFont + ( + // Ew, but ok + [ + $"/Fonts/NotoSans{ds}-{variation}.ttf", + ], + size + ); + } +} + public static class DreamStylesheet { + public static Stylesheet Make() { var res = IoCManager.Resolve(); var textureCloseButton = res.GetResource("/cross.svg.png").Texture; - var notoSansFont = res.GetResource("/Fonts/NotoSans-Regular.ttf"); - var notoSansBoldFont = res.GetResource("/Fonts/NotoSans-Bold.ttf"); - var notoSansFont10 = new VectorFont(notoSansFont, 10); - var notoSansFont12 = new VectorFont(notoSansFont, 12); - var notoSansBoldFont14 = new VectorFont(notoSansBoldFont, 14); + var notoSansFont10 = res.NotoStack(); + var notoSansFont12 = res.NotoStack("Regular", 12); + var notoSansBold14 = res.NotoStack("Bold", 14); + var notoSansBold16 = res.NotoStack("Bold", 16); var scrollBarNormal = new StyleBoxFlat { BackgroundColor = Color.Gray.WithAlpha(0.35f), ContentMarginLeftOverride = 10, @@ -38,10 +74,10 @@ public static Stylesheet Make() { .Prop("background", Color.White), Element().Class("MapBackground") - .Prop("panel", new StyleBoxFlat { BackgroundColor = Color. Black}), + .Prop(PanelContainer.StylePropertyPanel, new StyleBoxFlat { BackgroundColor = Color. Black}), Element().Class("ContextMenuBackground") - .Prop("panel", new StyleBoxFlat() { + .Prop(PanelContainer.StylePropertyPanel, new StyleBoxFlat { BackgroundColor = Color.White, BorderColor = Color.DarkGray, BorderThickness = new Thickness(1) @@ -85,7 +121,7 @@ public static Stylesheet Make() { // Color .Prop(Label.StylePropertyFontColor, Color.FromHex("#000000")) // Font - .Prop(Label.StylePropertyFont, notoSansBoldFont14), + .Prop(Label.StylePropertyFont, notoSansBold14), // Window header color. Element().Class(DefaultWindow.StyleClassWindowHeader) @@ -181,6 +217,33 @@ public static Stylesheet Make() { .Prop(Slider.StylePropertyGrabber, new StyleBoxFlat { BackgroundColor = Color.Transparent, BorderThickness = new Thickness(1), BorderColor = Color.Black, ContentMarginLeftOverride=10, ContentMarginRightOverride=10}) .Prop(Slider.StylePropertyFill, new StyleBoxFlat { BackgroundColor = Color.Transparent, BorderThickness = new Thickness(0), BorderColor = Color.Black}), + + // main menu UI + Element diff --git a/OpenDreamClient/States/Connecting/ConnectingControl.xaml.cs b/OpenDreamClient/States/Connecting/ConnectingControl.xaml.cs index f11ec9be97..6954863477 100644 --- a/OpenDreamClient/States/Connecting/ConnectingControl.xaml.cs +++ b/OpenDreamClient/States/Connecting/ConnectingControl.xaml.cs @@ -5,34 +5,69 @@ using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; using Robust.Shared.Configuration; +using Robust.Shared.Network; +using Robust.Shared.Timing; namespace OpenDreamClient.States.Connecting; [GenerateTypedNameReferences] public sealed partial class ConnectingControl : Control { + [Dependency] private readonly IClientNetManager _netManager = default!; + [Dependency] private readonly IGameTiming _timing = default!; + + private float _tickSecond; + public ConnectingControl(IResourceCache resCache, IConfigurationManager configMan) { RobustXamlLoader.Load(this); + IoCManager.InjectDependencies(this); - Panel.PanelOverride = new StyleBoxFlat(Color.Black); + InfoTexts.PanelOverride = new StyleBoxFlat(Color.Gray); ConnectingLabel.FontOverride = new VectorFont(resCache.GetResource("/Fonts/NotoSans-Regular.ttf"), 24); - WIPLabel.FontOverride = new VectorFont(resCache.GetResource("/Fonts/NotoSans-Bold.ttf"), 32); LayoutContainer.SetAnchorPreset(this, LayoutContainer.LayoutPreset.Wide); - LayoutContainer.SetAnchorPreset(VBox, LayoutContainer.LayoutPreset.Center); - LayoutContainer.SetGrowHorizontal(VBox, LayoutContainer.GrowDirection.Both); - LayoutContainer.SetGrowVertical(VBox, LayoutContainer.GrowDirection.Both); + LayoutContainer.SetAnchorPreset(Logo, LayoutContainer.LayoutPreset.CenterTop); + LayoutContainer.SetMarginTop(Logo, 60 * UIScale); + LayoutContainer.SetGrowHorizontal(Logo, LayoutContainer.GrowDirection.Both); + LayoutContainer.SetGrowVertical(Logo, LayoutContainer.GrowDirection.End); + + LayoutContainer.SetAnchorPreset(InfoTexts, LayoutContainer.LayoutPreset.BottomWide); + LayoutContainer.SetMarginBottom(InfoTexts, -30 * UIScale); + LayoutContainer.SetGrowHorizontal(InfoTexts, LayoutContainer.GrowDirection.Both); + LayoutContainer.SetGrowVertical(InfoTexts, LayoutContainer.GrowDirection.Begin); + + Logo.Texture = resCache.GetResource("/OpenDream/Logo/logo.png"); + } - LayoutContainer.SetAnchorPreset(ConnectingLabel, LayoutContainer.LayoutPreset.Center); - LayoutContainer.SetGrowHorizontal(ConnectingLabel, LayoutContainer.GrowDirection.Both); - LayoutContainer.SetGrowVertical(ConnectingLabel, LayoutContainer.GrowDirection.Both); + protected override void FrameUpdate(FrameEventArgs args) { + base.FrameUpdate(args); + InfoText.Text = _netManager.ClientConnectState switch { + ClientConnectionState.ResolvingHost => "Resolving Host", + ClientConnectionState.EstablishingConnection => "Establishing Connection", + ClientConnectionState.Handshake => "Handshaking", + ClientConnectionState.Connected => "Connected", + _ => "Disconnected" + }; - LayoutContainer.SetAnchorPreset(WIP, LayoutContainer.LayoutPreset.VerticalCenterWide); - LayoutContainer.SetGrowHorizontal(WIP, LayoutContainer.GrowDirection.Both); - LayoutContainer.SetGrowVertical(WIP, LayoutContainer.GrowDirection.Both); + _tickSecond += args.DeltaSeconds; - var logoTexture = resCache.GetResource("/OpenDream/Logo/logo.png"); - Logo.Texture = logoTexture; + if (_tickSecond >= 1) { + _tickSecond -= 1; + switch (ConnectingLabel.Text.Length) { + case 10: + ConnectingLabel.Text = "Connecting."; + break; + case 11: + ConnectingLabel.Text = "Connecting.."; + break; + case 12: + ConnectingLabel.Text = "Connecting..."; + break; + default: + ConnectingLabel.Text = "Connecting"; + break; + } + } } } diff --git a/OpenDreamClient/States/MainMenu/MainMenuControl.xaml b/OpenDreamClient/States/MainMenu/MainMenuControl.xaml index cb29ebbac4..eb2138c32f 100644 --- a/OpenDreamClient/States/MainMenu/MainMenuControl.xaml +++ b/OpenDreamClient/States/MainMenu/MainMenuControl.xaml @@ -1,53 +1,43 @@ - - - - - - - - + + + + + + + + - - - -