Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update main menu #1571

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions OpenDreamClient/InfoLabels/InfoLabel.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Control xmlns="https://spacestation14.io">
<LayoutContainer>
<BoxContainer Name="WipBox" MinWidth="100" Orientation="Vertical">
<Label Text="Work In Progress"
StyleClasses="od-wip"/>
<Label Name="DebugWarningLabel"
Text="{Loc 'main-menu-debug-warning'}"
StyleClasses="od-important"
Visible="False" />
</BoxContainer>
</LayoutContainer>
</Control>
22 changes: 22 additions & 0 deletions OpenDreamClient/InfoLabels/InfoLabel.xaml.cs
Original file line number Diff line number Diff line change
@@ -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
}
}
79 changes: 71 additions & 8 deletions OpenDreamClient/Interface/DreamStylesheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<FontResource>(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<IResourceCache>();
var textureCloseButton = res.GetResource<TextureResource>("/cross.svg.png").Texture;
var notoSansFont = res.GetResource<FontResource>("/Fonts/NotoSans-Regular.ttf");
var notoSansBoldFont = res.GetResource<FontResource>("/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,
Expand All @@ -38,10 +74,10 @@ public static Stylesheet Make() {
.Prop("background", Color.White),

Element<PanelContainer>().Class("MapBackground")
.Prop("panel", new StyleBoxFlat { BackgroundColor = Color. Black}),
.Prop(PanelContainer.StylePropertyPanel, new StyleBoxFlat { BackgroundColor = Color. Black}),

Element<PanelContainer>().Class("ContextMenuBackground")
.Prop("panel", new StyleBoxFlat() {
.Prop(PanelContainer.StylePropertyPanel, new StyleBoxFlat {
BackgroundColor = Color.White,
BorderColor = Color.DarkGray,
BorderThickness = new Thickness(1)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<Label>().Class("od-important")
.Prop(Label.StylePropertyFont, notoSansBold14)
.Prop(Label.StylePropertyFontColor, Color.DarkRed),

Element<Label>().Class("od-wip")
.Prop(Label.StylePropertyFont, notoSansFont12)
.Prop(Label.StylePropertyFontColor, Color.FromHex("#aaaaaabb")),

Element<ContainerButton>().Class("od-button").Pseudo(ContainerButton.StylePseudoClassNormal)
.Prop(ContainerButton.StylePropertyStyleBox, new StyleBoxFlat {
BackgroundColor = Color.FromHex("#C0C0C0"),
}),
Element<ContainerButton>().Class("od-button").Pseudo(ContainerButton.StylePseudoClassHover)
.Prop(ContainerButton.StylePropertyStyleBox, new StyleBoxFlat {
BackgroundColor = Color.FromHex("#d9d9d9"),
}),

new StyleRule(new SelectorChild(
new SelectorElement(typeof(Button), null, "mainMenu", null),
new SelectorElement(typeof(Label), null, null, null)),
new[]
{
new StyleProperty("font", notoSansBold16),
}),

});
}
}
32 changes: 32 additions & 0 deletions OpenDreamClient/MainMenuBackground/MainMenuBg.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;

namespace OpenDreamClient.MainMenuBackground;

public class MainMenuBg : Control {
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;

public MainMenuBg() {
IoCManager.InjectDependencies(this);
}

protected override void Draw(DrawingHandleScreen handle) {
// TODO prototype of byond games bg on here instead of a const
var tex = _resourceCache.GetResource<TextureResource>("/OpenDream/layer1.png").Texture;
var texSize = new Vector2(tex.Size.X * (int) Size.X, tex.Size.Y * (int) Size.X) * 3 / tex.Size.Length;

var ourSize = PixelSize;
var currentTime = (float) _timing.RealTime.TotalSeconds * 0.5f;
var offset = new Vector2(-MathF.Cos(currentTime * 0.4f), MathF.Sin(currentTime * 0.4f)) * (ourSize * 0.5f);
var origin = ((ourSize - texSize) / 2) + offset;

// blur it "slightly"
handle.UseShader(_prototypeManager.Index<ShaderPrototype>("blur").Instance());
handle.DrawTextureRect(tex, UIBox2.FromDimensions(origin, texSize));
}
}
31 changes: 12 additions & 19 deletions OpenDreamClient/States/Connecting/ConnectingControl.xaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@

<Control xmlns="https://spacestation14.io">
<PanelContainer Name="Panel">
<Control xmlns="https://spacestation14.io"
xmlns:labels="clr-namespace:OpenDreamClient.InfoLabels"
xmlns:bg="clr-namespace:OpenDreamClient.MainMenuBackground"
MinWidth="550">
<bg:MainMenuBg />
<labels:InfoLabel />
<LayoutContainer>
<BoxContainer Name="VBox"
Orientation="Vertical">
<TextureRect Name="Logo"
Stretch="KeepCentered" />
<Control MinHeight="128"></Control>
<BoxContainer Orientation="Horizontal"
SeparationOverride="4">
<Label Name="ConnectingLabel" Text="Connecting... " FontColorOverride="#FFFFFF"/>
<TextureRect Name="Logo" Stretch="KeepCentered" />
<PanelContainer Name="InfoTexts">
<BoxContainer Orientation="Vertical">
<Label Name="ConnectingLabel" Text="Connecting" HorizontalAlignment="Center"/>
<Label Name="InfoText" Text="..." HorizontalAlignment="Center"/>
</BoxContainer>
<Control MinHeight="128"></Control>
<BoxContainer Name="WIP" Orientation="Horizontal"
SeparationOverride="4">
<Label Name="WIPLabel" Text="Work In Progress" FontColorOverride="#FFFFFF"/>
</BoxContainer>

</BoxContainer>
</PanelContainer>
</LayoutContainer>
</PanelContainer>
</Control>
61 changes: 48 additions & 13 deletions OpenDreamClient/States/Connecting/ConnectingControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<FontResource>("/Fonts/NotoSans-Regular.ttf"), 24);
WIPLabel.FontOverride = new VectorFont(resCache.GetResource<FontResource>("/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<TextureResource>("/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<TextureResource>("/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;
}
}
}
}
Loading
Loading