* Basic voting

* Rewrite lobby in XAML.
Working lobby voting.

* Escape menu is now XAML.

* Vote menu works, custom votes, gamemode votes.

* Vote timeouts & administration.

Basically done now.

* I will now pretend I was never planning to code voting hotkeys.

* Make vote call UI a bit... funny.

* Fix exception on round restart.

* Fix some vote command definitions.
This commit is contained in:
Pieter-Jan Briers
2021-02-16 15:07:17 +01:00
committed by GitHub
parent db290fd91e
commit cea87d6985
35 changed files with 2001 additions and 413 deletions

View File

@@ -0,0 +1,12 @@
<SS14Window xmlns="https://spacestation14.io"
xmlns:voting="clr-namespace:Content.Client.Voting"
Title="{Loc 'Esc Menu'}"
Resizable="False">
<VBoxContainer SeparationOverride="4">
<voting:VoteCallMenuButton />
<Button Name="OptionsButton" Text="{Loc 'Options'}" />
<Button Name="DisconnectButton" Text="{Loc 'Disconnect'}" />
<Button Name="QuitButton" Text="{Loc 'Quit game'}" />
</VBoxContainer>
</SS14Window>

View File

@@ -1,51 +1,29 @@
using Robust.Client.Console;
using Robust.Client.AutoGenerated;
using Robust.Client.Console;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.UserInterface
{
internal sealed class EscapeMenu : SS14Window
[GenerateTypedNameReferences]
internal partial class EscapeMenu : SS14Window
{
private readonly IClientConsoleHost _consoleHost;
private BaseButton DisconnectButton;
private BaseButton QuitButton;
private BaseButton OptionsButton;
private OptionsMenu optionsMenu;
public EscapeMenu(IClientConsoleHost consoleHost)
{
_consoleHost = consoleHost;
IoCManager.InjectDependencies(this);
RobustXamlLoader.Load(this);
PerformLayout();
}
private void PerformLayout()
{
optionsMenu = new OptionsMenu();
Resizable = false;
Title = "Esc Menu";
var vBox = new VBoxContainer {SeparationOverride = 4};
Contents.AddChild(vBox);
OptionsButton = new Button {Text = Loc.GetString("Options")};
OptionsButton.OnPressed += OnOptionsButtonClicked;
vBox.AddChild(OptionsButton);
DisconnectButton = new Button {Text = Loc.GetString("Disconnect")};
DisconnectButton.OnPressed += OnDisconnectButtonClicked;
vBox.AddChild(DisconnectButton);
QuitButton = new Button {Text = Loc.GetString("Quit Game")};
QuitButton.OnPressed += OnQuitButtonClicked;
vBox.AddChild(QuitButton);
DisconnectButton.OnPressed += OnDisconnectButtonClicked;
}
private void OnQuitButtonClicked(BaseButton.ButtonEventArgs args)

View File

@@ -15,6 +15,7 @@ using Robust.Shared.Maths;
using Robust.Shared.Utility;
using static Robust.Client.Input.Keyboard.Key;
using Control = Robust.Client.UserInterface.Control;
using LC = Robust.Client.UserInterface.Controls.LayoutContainer;
namespace Content.Client.UserInterface
{
@@ -70,6 +71,9 @@ namespace Content.Client.UserInterface
Action<bool> OnCombatModeChanged { get; set; }
Action<TargetingZone> OnTargetingZoneChanged { get; set; }
Control VoteContainer { get; }
void AddTopNotification(TopNotification notification);
// Init logic.
void Initialize();
@@ -90,6 +94,7 @@ namespace Content.Client.UserInterface
private TargetingDoll _targetingDoll;
private Button _combatModeButton;
private VBoxContainer _combatPanelContainer;
private VBoxContainer _topNotificationContainer;
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IInputManager _inputManager = default!;
@@ -120,10 +125,15 @@ namespace Content.Client.UserInterface
public Action<bool> OnCombatModeChanged { get; set; }
public Action<TargetingZone> OnTargetingZoneChanged { get; set; }
public void AddTopNotification(TopNotification notification)
{
_topNotificationContainer.AddChild(notification);
}
public void Initialize()
{
RootControl = new LayoutContainer();
LayoutContainer.SetAnchorPreset(RootControl, LayoutContainer.LayoutPreset.Wide);
RootControl = new LC();
LC.SetAnchorPreset(RootControl, LC.LayoutPreset.Wide);
var escapeTexture = _resourceCache.GetTexture("/Textures/Interface/hamburger.svg.192dpi.png");
var characterTexture = _resourceCache.GetTexture("/Textures/Interface/character.svg.192dpi.png");
@@ -141,7 +151,7 @@ namespace Content.Client.UserInterface
RootControl.AddChild(_topButtonsContainer);
LayoutContainer.SetAnchorAndMarginPreset(_topButtonsContainer, LayoutContainer.LayoutPreset.TopLeft,
LC.SetAnchorAndMarginPreset(_topButtonsContainer, LC.LayoutPreset.TopLeft,
margin: 10);
// the icon textures here should all have the same image height (32) but different widths, so in order to ensure
@@ -271,10 +281,10 @@ namespace Content.Client.UserInterface
}
};
LayoutContainer.SetGrowHorizontal(_combatPanelContainer, LayoutContainer.GrowDirection.Begin);
LayoutContainer.SetGrowVertical(_combatPanelContainer, LayoutContainer.GrowDirection.Begin);
LayoutContainer.SetAnchorAndMarginPreset(_combatPanelContainer, LayoutContainer.LayoutPreset.BottomRight);
LayoutContainer.SetMarginBottom(_combatPanelContainer, -10f);
LC.SetGrowHorizontal(_combatPanelContainer, LC.GrowDirection.Begin);
LC.SetGrowVertical(_combatPanelContainer, LC.GrowDirection.Begin);
LC.SetAnchorAndMarginPreset(_combatPanelContainer, LC.LayoutPreset.BottomRight);
LC.SetMarginBottom(_combatPanelContainer, -10f);
RootControl.AddChild(_combatPanelContainer);
_combatModeButton.OnToggled += args => OnCombatModeChanged?.Invoke(args.Pressed);
@@ -284,10 +294,10 @@ namespace Content.Client.UserInterface
{
SeparationOverride = 5
};
LayoutContainer.SetAnchorAndMarginPreset(centerBottomContainer, LayoutContainer.LayoutPreset.CenterBottom);
LayoutContainer.SetGrowHorizontal(centerBottomContainer, LayoutContainer.GrowDirection.Both);
LayoutContainer.SetGrowVertical(centerBottomContainer, LayoutContainer.GrowDirection.Begin);
LayoutContainer.SetMarginBottom(centerBottomContainer, -10f);
LC.SetAnchorAndMarginPreset(centerBottomContainer, LC.LayoutPreset.CenterBottom);
LC.SetGrowHorizontal(centerBottomContainer, LC.GrowDirection.Both);
LC.SetGrowVertical(centerBottomContainer, LC.GrowDirection.Begin);
LC.SetMarginBottom(centerBottomContainer, -10f);
RootControl.AddChild(centerBottomContainer);
HandsContainer = new MarginContainer
@@ -313,10 +323,27 @@ namespace Content.Client.UserInterface
RootControl.AddChild(SuspicionContainer);
LayoutContainer.SetAnchorAndMarginPreset(SuspicionContainer, LayoutContainer.LayoutPreset.BottomLeft,
LC.SetAnchorAndMarginPreset(SuspicionContainer, LC.LayoutPreset.BottomLeft,
margin: 10);
LayoutContainer.SetGrowHorizontal(SuspicionContainer, LayoutContainer.GrowDirection.End);
LayoutContainer.SetGrowVertical(SuspicionContainer, LayoutContainer.GrowDirection.Begin);
LC.SetGrowHorizontal(SuspicionContainer, LC.GrowDirection.End);
LC.SetGrowVertical(SuspicionContainer, LC.GrowDirection.Begin);
_topNotificationContainer = new VBoxContainer
{
CustomMinimumSize = (600, 0)
};
RootControl.AddChild(_topNotificationContainer);
LC.SetAnchorPreset(_topNotificationContainer, LC.LayoutPreset.CenterTop);
LC.SetGrowHorizontal(_topNotificationContainer, LC.GrowDirection.Both);
LC.SetGrowVertical(_topNotificationContainer, LC.GrowDirection.End);
VoteContainer = new VBoxContainer();
RootControl.AddChild(VoteContainer);
LC.SetAnchorPreset(VoteContainer, LC.LayoutPreset.TopLeft);
LC.SetMarginLeft(VoteContainer, 180);
LC.SetMarginTop(VoteContainer, 100);
LC.SetGrowHorizontal(VoteContainer, LC.GrowDirection.End);
LC.SetGrowVertical(VoteContainer, LC.GrowDirection.End);
}
private void ButtonTutorialOnOnToggled()
@@ -436,6 +463,8 @@ namespace Content.Client.UserInterface
public Action<bool> SandboxButtonToggled { get; set; }
public Control VoteContainer { get; private set; }
public sealed class TopButton : ContainerButton
{
public const string StyleClassLabelTopButton = "topButtonLabel";

View File

@@ -1,330 +0,0 @@
using Content.Client.Chat;
using Content.Client.Interfaces;
using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
namespace Content.Client.UserInterface
{
internal sealed class LobbyGui : Control
{
public Label ServerName { get; }
public Label StartTime { get; }
public Button ReadyButton { get; }
public Button ObserveButton { get; }
public Button OptionsButton { get; }
public Button LeaveButton { get; }
public ChatBox Chat { get; }
public LobbyPlayerList OnlinePlayerList { get; }
public ServerInfo ServerInfo { get; }
public LobbyCharacterPreviewPanel CharacterPreview { get; }
public LobbyGui(IEntityManager entityManager,
IResourceCache resourceCache,
IClientPreferencesManager preferencesManager)
{
var margin = new MarginContainer
{
MarginBottomOverride = 20,
MarginLeftOverride = 20,
MarginRightOverride = 20,
MarginTopOverride = 20,
};
AddChild(margin);
var panelTex = resourceCache.GetTexture("/Textures/Interface/Nano/button.svg.96dpi.png");
var back = new StyleBoxTexture
{
Texture = panelTex,
Modulate = new Color(37, 37, 42),
};
back.SetPatchMargin(StyleBox.Margin.All, 10);
var panel = new PanelContainer
{
PanelOverride = back
};
margin.AddChild(panel);
var vBox = new VBoxContainer {SeparationOverride = 0};
margin.AddChild(vBox);
var topHBox = new HBoxContainer
{
CustomMinimumSize = (0, 40),
Children =
{
new MarginContainer
{
MarginLeftOverride = 8,
Children =
{
new Label
{
Text = Loc.GetString("Lobby"),
StyleClasses = {StyleNano.StyleClassLabelHeadingBigger},
VAlign = Label.VAlignMode.Center
}
}
},
(ServerName = new Label
{
StyleClasses = {StyleNano.StyleClassLabelHeadingBigger},
VAlign = Label.VAlignMode.Center,
SizeFlagsHorizontal = SizeFlags.Expand | SizeFlags.ShrinkCenter
}),
(OptionsButton = new Button
{
SizeFlagsHorizontal = SizeFlags.ShrinkEnd,
Text = Loc.GetString("Options"),
StyleClasses = {StyleNano.StyleClassButtonBig},
}),
(LeaveButton = new Button
{
SizeFlagsHorizontal = SizeFlags.ShrinkEnd,
Text = Loc.GetString("Leave"),
StyleClasses = {StyleNano.StyleClassButtonBig},
})
}
};
vBox.AddChild(topHBox);
vBox.AddChild(new PanelContainer
{
PanelOverride = new StyleBoxFlat
{
BackgroundColor = StyleNano.NanoGold,
ContentMarginTopOverride = 2
},
});
var hBox = new HBoxContainer
{
SizeFlagsVertical = SizeFlags.FillExpand,
SeparationOverride = 0
};
vBox.AddChild(hBox);
CharacterPreview = new LobbyCharacterPreviewPanel(
entityManager,
preferencesManager)
{
SizeFlagsHorizontal = SizeFlags.None
};
hBox.AddChild(new VBoxContainer
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
SeparationOverride = 0,
Children =
{
CharacterPreview,
new StripeBack
{
Children =
{
new MarginContainer
{
MarginRightOverride = 3,
MarginLeftOverride = 3,
MarginTopOverride = 3,
MarginBottomOverride = 3,
Children =
{
new HBoxContainer
{
SeparationOverride = 6,
Children =
{
(ObserveButton = new Button
{
Text = Loc.GetString("Observe"),
StyleClasses = {StyleNano.StyleClassButtonBig}
}),
(StartTime = new Label
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
Align = Label.AlignMode.Right,
FontColorOverride = Color.DarkGray,
StyleClasses = {StyleNano.StyleClassLabelBig}
}),
(ReadyButton = new Button
{
ToggleMode = true,
Text = Loc.GetString("Ready Up"),
StyleClasses = {StyleNano.StyleClassButtonBig}
}),
}
}
}
}
}
},
new MarginContainer
{
MarginRightOverride = 3,
MarginLeftOverride = 3,
MarginTopOverride = 3,
MarginBottomOverride = 3,
SizeFlagsVertical = SizeFlags.FillExpand,
Children =
{
(Chat = new ChatBox
{
Input = {PlaceHolder = Loc.GetString("Say something!")}
})
}
},
}
});
hBox.AddChild(new PanelContainer
{
PanelOverride = new StyleBoxFlat {BackgroundColor = StyleNano.NanoGold}, CustomMinimumSize = (2, 0)
});
{
hBox.AddChild(new VBoxContainer
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
Children =
{
new NanoHeading
{
Text = Loc.GetString("Online Players"),
},
new MarginContainer
{
SizeFlagsVertical = SizeFlags.FillExpand,
MarginRightOverride = 3,
MarginLeftOverride = 3,
MarginTopOverride = 3,
MarginBottomOverride = 3,
Children =
{
new HBoxContainer
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
CustomMinimumSize = (50,50),
Children =
{
(OnlinePlayerList = new LobbyPlayerList
{
SizeFlagsVertical = SizeFlags.FillExpand,
SizeFlagsHorizontal = SizeFlags.FillExpand,
})
}
}
}
},
new NanoHeading
{
Text = Loc.GetString("Server Info"),
},
new MarginContainer
{
SizeFlagsVertical = SizeFlags.FillExpand,
MarginRightOverride = 3,
MarginLeftOverride = 3,
MarginTopOverride = 3,
MarginBottomOverride = 2,
Children =
{
(ServerInfo = new ServerInfo())
}
},
}
});
}
}
}
public class LobbyPlayerList : Control
{
private readonly ScrollContainer _scroll;
private readonly VBoxContainer _vBox;
public LobbyPlayerList()
{
var panel = new PanelContainer()
{
PanelOverride = new StyleBoxFlat { BackgroundColor = Color.FromHex("#202028") },
};
_vBox = new VBoxContainer();
_scroll = new ScrollContainer();
_scroll.AddChild(_vBox);
panel.AddChild(_scroll);
AddChild(panel);
}
// Adds a row
public void AddItem(string name, string status)
{
var hbox = new HBoxContainer
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
};
// Player Name
hbox.AddChild(new PanelContainer()
{
PanelOverride = new StyleBoxFlat
{
BackgroundColor = Color.FromHex("#373744"),
ContentMarginBottomOverride = 2,
ContentMarginLeftOverride = 4,
ContentMarginRightOverride = 4,
ContentMarginTopOverride = 2
},
Children =
{
new Label
{
Text = name
}
},
SizeFlagsHorizontal = SizeFlags.FillExpand
});
// Status
hbox.AddChild(new PanelContainer()
{
PanelOverride = new StyleBoxFlat
{
BackgroundColor = Color.FromHex("#373744"),
ContentMarginBottomOverride = 2,
ContentMarginLeftOverride = 4,
ContentMarginRightOverride = 4,
ContentMarginTopOverride = 2
},
Children =
{
new Label
{
Text = status
}
},
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 0.2f,
});
_vBox.AddChild(hbox);
}
// Deletes all rows
public void Clear()
{
_vBox.RemoveAllChildren();
}
}
}

View File

@@ -0,0 +1,88 @@
<Control xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:style="clr-namespace:Content.Client.UserInterface.Stylesheets"
xmlns:cui="clr-namespace:Content.Client.UserInterface"
xmlns:chat="clr-namespace:Content.Client.Chat"
xmlns:maths="clr-namespace:Robust.Shared.Maths;assembly=Robust.Shared.Maths"
xmlns:voting="clr-namespace:Content.Client.Voting">
<!-- One day I'll code a Margin property for controls. -->
<MarginContainer MarginBottomOverride="20" MarginLeftOverride="20" MarginRightOverride="20"
MarginTopOverride="20">
<PanelContainer StyleClasses="AngleRect" />
<VBoxContainer>
<!-- Top row -->
<HBoxContainer CustomMinimumSize="0 40">
<MarginContainer MarginLeftOverride="8">
<Label StyleClasses="LabelHeadingBigger" VAlign="Center" Text="{Loc 'Lobby'}" />
</MarginContainer>
<Label Name="CServerName" StyleClasses="LabelHeadingBigger" VAlign="Center" />
<voting:VoteCallMenuButton Name="CCallVoteButton" StyleClasses="ButtonBig" />
<Button Name="COptionsButton" StyleClasses="ButtonBig" Text="{Loc 'Options'}" />
<Button Name="CLeaveButton" StyleClasses="ButtonBig" Text="{Loc 'Leave'}" />
</HBoxContainer>
<!-- Gold line -->
<PanelContainer>
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="{x:Static style:StyleNano.NanoGold}"
ContentMarginTopOverride="2" />
</PanelContainer.PanelOverride>
</PanelContainer>
<!-- Middle section with the two vertical panels -->
<HBoxContainer SizeFlagsVertical="FillExpand">
<!-- Left panel -->
<VBoxContainer Name="CLeftPanelContainer" SizeFlagsHorizontal="FillExpand">
<cui:StripeBack>
<MarginContainer MarginLeftOverride="3" MarginRightOverride="3" MarginBottomOverride="3"
MarginTopOverride="3">
<HBoxContainer SeparationOverride="6">
<Button Name="CObserveButton" Text="{Loc 'Observe'}" StyleClasses="ButtonBig" />
<Label Name="CStartTime" Align="Right"
FontColorOverride="{x:Static maths:Color.DarkGray}"
StyleClasses="LabelBig" SizeFlagsHorizontal="FillExpand" />
<Button Name="CReadyButton" ToggleMode="True" Text="{Loc 'Ready Up'}"
StyleClasses="ButtonBig" />
</HBoxContainer>
</MarginContainer>
</cui:StripeBack>
<MarginContainer SizeFlagsVertical="FillExpand" MarginLeftOverride="3" MarginRightOverride="3"
MarginBottomOverride="3"
MarginTopOverride="3">
<chat:ChatBox Name="CChat" />
</MarginContainer>
</VBoxContainer>
<!-- Gold line -->
<PanelContainer CustomMinimumSize="2 0">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="{x:Static style:StyleNano.NanoGold}" />
</PanelContainer.PanelOverride>
</PanelContainer>
<!-- Right panel -->
<Control SizeFlagsHorizontal="FillExpand">
<VBoxContainer>
<!-- Player list -->
<cui:NanoHeading Text="{Loc 'Online Players'}" />
<MarginContainer SizeFlagsVertical="FillExpand"
MarginRightOverride="3" MarginLeftOverride="3"
MarginBottomOverride="3" MarginTopOverride="3">
<cui:LobbyPlayerList Name="COnlinePlayerList"
SizeFlagsHorizontal="FillExpand"
SizeFlagsVertical="FillExpand" />
</MarginContainer>
<!-- Server info -->
<cui:NanoHeading Text="{Loc 'Server Info'}" />
<MarginContainer SizeFlagsVertical="FillExpand"
MarginRightOverride="3" MarginLeftOverride="3"
MarginBottomOverride="2" MarginTopOverride="3">
<cui:ServerInfo Name="CServerInfo" />
</MarginContainer>
</VBoxContainer>
<MarginContainer SizeFlagsHorizontal="ShrinkEnd" MarginTopOverride="8" MarginRightOverride="8">
<VBoxContainer Name="CVoteContainer" />
</MarginContainer>
</Control>
</HBoxContainer>
</VBoxContainer>
</MarginContainer>
</Control>

View File

@@ -0,0 +1,124 @@
using Content.Client.Chat;
using Content.Client.Interfaces;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
namespace Content.Client.UserInterface
{
[GenerateTypedNameReferences]
internal sealed partial class LobbyGui : Control
{
public Label ServerName => CServerName;
public Label StartTime => CStartTime;
public Button ReadyButton => CReadyButton;
public Button ObserveButton => CObserveButton;
public Button OptionsButton => COptionsButton;
public Button LeaveButton => CLeaveButton;
public ChatBox Chat => CChat;
public VBoxContainer VoteContainer => CVoteContainer;
public LobbyPlayerList OnlinePlayerList => COnlinePlayerList;
public ServerInfo ServerInfo => CServerInfo;
public LobbyCharacterPreviewPanel CharacterPreview { get; }
public LobbyGui(IEntityManager entityManager,
IClientPreferencesManager preferencesManager)
{
RobustXamlLoader.Load(this);
ServerName.SizeFlagsHorizontal = SizeFlags.Expand | SizeFlags.ShrinkCenter;
CharacterPreview = new LobbyCharacterPreviewPanel(
entityManager,
preferencesManager)
{
SizeFlagsHorizontal = SizeFlags.None
};
CLeftPanelContainer.AddChild(CharacterPreview);
CharacterPreview.SetPositionFirst();
}
}
public class LobbyPlayerList : Control
{
private readonly ScrollContainer _scroll;
private readonly VBoxContainer _vBox;
public LobbyPlayerList()
{
var panel = new PanelContainer()
{
PanelOverride = new StyleBoxFlat {BackgroundColor = Color.FromHex("#202028")},
};
_vBox = new VBoxContainer();
_scroll = new ScrollContainer();
_scroll.AddChild(_vBox);
panel.AddChild(_scroll);
AddChild(panel);
}
// Adds a row
public void AddItem(string name, string status)
{
var hbox = new HBoxContainer
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
};
// Player Name
hbox.AddChild(new PanelContainer()
{
PanelOverride = new StyleBoxFlat
{
BackgroundColor = Color.FromHex("#373744"),
ContentMarginBottomOverride = 2,
ContentMarginLeftOverride = 4,
ContentMarginRightOverride = 4,
ContentMarginTopOverride = 2
},
Children =
{
new Label
{
Text = name
}
},
SizeFlagsHorizontal = SizeFlags.FillExpand
});
// Status
hbox.AddChild(new PanelContainer()
{
PanelOverride = new StyleBoxFlat
{
BackgroundColor = Color.FromHex("#373744"),
ContentMarginBottomOverride = 2,
ContentMarginLeftOverride = 4,
ContentMarginRightOverride = 4,
ContentMarginTopOverride = 2
},
Children =
{
new Label
{
Text = status
}
},
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 0.2f,
});
_vBox.AddChild(hbox);
}
// Deletes all rows
public void Clear()
{
_vBox.RemoveAllChildren();
}
}
}

View File

@@ -2,6 +2,8 @@ using Content.Client.Utility;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Maths;
namespace Content.Client.UserInterface.Stylesheets
@@ -9,10 +11,13 @@ namespace Content.Client.UserInterface.Stylesheets
public abstract class StyleBase
{
public const string ClassHighDivider = "HighDivider";
public const string ClassLowDivider = "LowDivider";
public const string StyleClassLabelHeading = "LabelHeading";
public const string StyleClassLabelSubText = "LabelSubText";
public const string StyleClassItalic = "Italic";
public const string ClassAngleRect = "AngleRect";
public const string ButtonOpenRight = "OpenRight";
public const string ButtonOpenLeft = "OpenLeft";
public const string ButtonOpenBoth = "OpenBoth";
@@ -30,10 +35,13 @@ namespace Content.Client.UserInterface.Stylesheets
protected StyleBoxTexture BaseButtonOpenBoth { get; }
protected StyleBoxTexture BaseButtonSquare { get; }
protected StyleBoxTexture BaseAngleRect { get; }
protected StyleBase(IResourceCache resCache)
{
var notoSans12 = resCache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 12);
var notoSans12Italic = resCache.GetFont("/Fonts/NotoSans/NotoSans-Italic.ttf", 12);
var textureCloseButton = resCache.GetTexture("/Textures/Interface/Nano/cross.svg.png");
// Button styles.
var buttonTex = resCache.GetTexture("/Textures/Interface/Nano/button.svg.96dpi.png");
@@ -80,6 +88,12 @@ namespace Content.Client.UserInterface.Stylesheets
BaseButtonSquare.SetPadding(StyleBox.Margin.Right, 2);
BaseButtonSquare.SetPadding(StyleBox.Margin.Left, 1);
BaseAngleRect = new StyleBoxTexture
{
Texture = buttonTex,
};
BaseAngleRect.SetPatchMargin(StyleBox.Margin.All, 10);
BaseRules = new[]
{
// Default font.
@@ -97,6 +111,33 @@ namespace Content.Client.UserInterface.Stylesheets
{
new StyleProperty("font", notoSans12Italic),
}),
// Window close button base texture.
new StyleRule(
new SelectorElement(typeof(TextureButton), new[] {SS14Window.StyleClassWindowCloseButton}, null,
null),
new[]
{
new StyleProperty(TextureButton.StylePropertyTexture, textureCloseButton),
new StyleProperty(Control.StylePropertyModulateSelf, Color.FromHex("#4B596A")),
}),
// Window close button hover.
new StyleRule(
new SelectorElement(typeof(TextureButton), new[] {SS14Window.StyleClassWindowCloseButton}, null,
new[] {TextureButton.StylePseudoClassHover}),
new[]
{
new StyleProperty(Control.StylePropertyModulateSelf, Color.FromHex("#7F3636")),
}),
// Window close button pressed.
new StyleRule(
new SelectorElement(typeof(TextureButton), new[] {SS14Window.StyleClassWindowCloseButton}, null,
new[] {TextureButton.StylePseudoClassPressed}),
new[]
{
new StyleProperty(Control.StylePropertyModulateSelf, Color.FromHex("#753131")),
}),
};
}
}

View File

@@ -80,7 +80,6 @@ namespace Content.Client.UserInterface.Stylesheets
var notoSansBold16 = resCache.GetFont("/Fonts/NotoSans/NotoSans-Bold.ttf", 16);
var notoSansBold18 = resCache.GetFont("/Fonts/NotoSans/NotoSans-Bold.ttf", 18);
var notoSansBold20 = resCache.GetFont("/Fonts/NotoSans/NotoSans-Bold.ttf", 20);
var textureCloseButton = resCache.GetTexture("/Textures/Interface/Nano/cross.svg.png");
var windowHeaderTex = resCache.GetTexture("/Textures/Interface/Nano/window_header.png");
var windowHeader = new StyleBoxTexture
{
@@ -428,31 +427,6 @@ namespace Content.Client.UserInterface.Stylesheets
{
new StyleProperty(PanelContainer.StylePropertyPanel, windowHeader),
}),
// Window close button base texture.
new StyleRule(
new SelectorElement(typeof(TextureButton), new[] {SS14Window.StyleClassWindowCloseButton}, null,
null),
new[]
{
new StyleProperty(TextureButton.StylePropertyTexture, textureCloseButton),
new StyleProperty(Control.StylePropertyModulateSelf, Color.FromHex("#4B596A")),
}),
// Window close button hover.
new StyleRule(
new SelectorElement(typeof(TextureButton), new[] {SS14Window.StyleClassWindowCloseButton}, null,
new[] {TextureButton.StylePseudoClassHover}),
new[]
{
new StyleProperty(Control.StylePropertyModulateSelf, Color.FromHex("#7F3636")),
}),
// Window close button pressed.
new StyleRule(
new SelectorElement(typeof(TextureButton), new[] {SS14Window.StyleClassWindowCloseButton}, null,
new[] {TextureButton.StylePseudoClassPressed}),
new[]
{
new StyleProperty(Control.StylePropertyModulateSelf, Color.FromHex("#753131")),
}),
// Shapes for the buttons.
Element<ContainerButton>().Class(ContainerButton.StyleClassButton)
@@ -1061,7 +1035,12 @@ namespace Content.Client.UserInterface.Stylesheets
new StyleRule(new SelectorElement(typeof(PanelContainer), new []{ ClassHighDivider}, null, null), new []
{
new StyleProperty(PanelContainer.StylePropertyPanel, new StyleBoxFlat { BackgroundColor = NanoGold, ContentMarginBottomOverride = 2, ContentMarginLeftOverride = 2}),
})
}),
Element<PanelContainer>().Class(ClassAngleRect)
.Prop(PanelContainer.StylePropertyPanel, BaseAngleRect)
.Prop(Control.StylePropertyModulateSelf, Color.FromHex("#25252A")),
}).ToList());
}
}

View File

@@ -30,6 +30,20 @@ namespace Content.Client.UserInterface.Stylesheets
var notoSans10 = resCache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 10);
var notoSansBold16 = resCache.GetFont("/Fonts/NotoSans/NotoSans-Bold.ttf", 16);
var progressBarBackground = new StyleBoxFlat
{
BackgroundColor = new Color(0.25f, 0.25f, 0.25f)
};
progressBarBackground.SetContentMarginOverride(StyleBox.Margin.Vertical, 5);
var progressBarForeground = new StyleBoxFlat
{
BackgroundColor = new Color(0.25f, 0.50f, 0.25f)
};
progressBarForeground.SetContentMarginOverride(StyleBox.Margin.Vertical, 5);
var textureInvertedTriangle = resCache.GetTexture("/Textures/Interface/Nano/inverted_triangle.svg.png");
Stylesheet = new Stylesheet(BaseRules.Concat(new StyleRule[]
{
Element<Label>().Class(StyleClassLabelHeading)
@@ -45,6 +59,15 @@ namespace Content.Client.UserInterface.Stylesheets
{
BackgroundColor = SpaceRed, ContentMarginBottomOverride = 2, ContentMarginLeftOverride = 2
}),
Element<PanelContainer>().Class(ClassLowDivider)
.Prop(PanelContainer.StylePropertyPanel, new StyleBoxFlat
{
BackgroundColor = Color.FromHex("#444"),
ContentMarginLeftOverride = 2,
ContentMarginBottomOverride = 2
}),
// Shapes for the buttons.
Element<ContainerButton>().Class(ContainerButton.StyleClassButton)
.Prop(ContainerButton.StylePropertyStyleBox, BaseButton),
@@ -103,11 +126,42 @@ namespace Content.Client.UserInterface.Stylesheets
Element<Label>().Class(ContainerButton.StyleClassButton)
.Prop(Label.StylePropertyAlignMode, Label.AlignMode.Center),
Element<PanelContainer>().Class(ClassAngleRect)
.Prop(PanelContainer.StylePropertyPanel, BaseAngleRect)
.Prop(Control.StylePropertyModulateSelf, Color.FromHex("#202030")),
Child()
.Parent(Element<Button>().Class(ContainerButton.StylePseudoClassDisabled))
.Child(Element<Label>())
.Prop("font-color", Color.FromHex("#E5E5E581")),
Element<ProgressBar>()
.Prop(ProgressBar.StylePropertyBackground, progressBarBackground)
.Prop(ProgressBar.StylePropertyForeground, progressBarForeground),
// OptionButton
Element<OptionButton>()
.Prop(ContainerButton.StylePropertyStyleBox, BaseButton),
Element<OptionButton>().Pseudo(ContainerButton.StylePseudoClassNormal)
.Prop(Control.StylePropertyModulateSelf, ButtonColorDefault),
Element<OptionButton>().Pseudo(ContainerButton.StylePseudoClassHover)
.Prop(Control.StylePropertyModulateSelf, ButtonColorHovered),
Element<OptionButton>().Pseudo(ContainerButton.StylePseudoClassPressed)
.Prop(Control.StylePropertyModulateSelf, ButtonColorPressed),
Element<OptionButton>().Pseudo(ContainerButton.StylePseudoClassDisabled)
.Prop(Control.StylePropertyModulateSelf, ButtonColorDisabled),
Element<TextureRect>().Class(OptionButton.StyleClassOptionTriangle)
.Prop(TextureRect.StylePropertyTexture, textureInvertedTriangle),
Element<Label>().Class(OptionButton.StyleClassOptionButton)
.Prop(Label.StylePropertyAlignMode, Label.AlignMode.Center),
}).ToList());
}
}

View File

@@ -0,0 +1,9 @@
using Robust.Client.UserInterface;
namespace Content.Client.UserInterface
{
public class TopNotification : Control
{
}
}