Merge branch 'master' into 2020-03-03-g-g-g-g-g-g-g-g-ghooooosts

This commit is contained in:
zumorica
2020-04-04 17:17:11 +02:00
49 changed files with 1131 additions and 170 deletions

View File

@@ -6,6 +6,7 @@ using Content.Client.Interfaces.Parallax;
using Content.Client.Parallax;
using Content.Client.Sandbox;
using Content.Client.UserInterface;
using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility;
using Content.Shared.Interfaces;
using Robust.Shared.IoC;
@@ -27,6 +28,7 @@ namespace Content.Client
IoCManager.Register<IModuleManager, ClientModuleManager>();
IoCManager.Register<IClientPreferencesManager, ClientPreferencesManager>();
IoCManager.Register<IItemSlotManager, ItemSlotManager>();
IoCManager.Register<IStylesheetManager, StylesheetManager>();
}
}
}

View File

@@ -8,6 +8,7 @@ using Content.Client.Parallax;
using Content.Client.Sandbox;
using Content.Client.State;
using Content.Client.UserInterface;
using Content.Client.UserInterface.Stylesheets;
using Content.Shared.GameObjects.Components;
using Content.Shared.GameObjects.Components.Cargo;
using Content.Shared.GameObjects.Components.Chemistry;
@@ -17,7 +18,7 @@ using Content.Shared.GameObjects.Components.VendingMachines;
using Robust.Client.Interfaces;
using Robust.Client.Interfaces.Graphics.Overlays;
using Robust.Client.Interfaces.Input;
using Robust.Client.Interfaces.UserInterface;
using Robust.Client.Interfaces.State;
using Robust.Client.Player;
using Robust.Shared.ContentPack;
using Robust.Shared.Interfaces.GameObjects;
@@ -35,6 +36,8 @@ namespace Content.Client
[Dependency] private readonly IPlayerManager _playerManager;
[Dependency] private readonly IBaseClient _baseClient;
[Dependency] private readonly IEscapeMenuOwner _escapeMenuOwner;
[Dependency] private readonly IGameController _gameController;
[Dependency] private readonly IStateManager _stateManager;
#pragma warning restore 649
public override void Init()
@@ -167,10 +170,7 @@ namespace Content.Client
IoCManager.Resolve<IParallaxManager>().LoadParallax();
IoCManager.Resolve<IBaseClient>().PlayerJoinedServer += SubscribePlayerAttachmentEvents;
var stylesheet = new NanoStyle();
IoCManager.Resolve<IUserInterfaceManager>().Stylesheet = stylesheet.Stylesheet;
IoCManager.Resolve<IStylesheetManager>().Initialize();
IoCManager.InjectDependencies(this);
@@ -225,6 +225,16 @@ namespace Content.Client
IoCManager.Resolve<ISandboxManager>().Initialize();
IoCManager.Resolve<IClientPreferencesManager>().Initialize();
IoCManager.Resolve<IItemSlotManager>().Initialize();
// Fire off into state dependent on launcher or not.
if (_gameController.LaunchState.FromLauncher)
{
_stateManager.RequestStateChange<LauncherConnecting>();
}
else
{
_stateManager.RequestStateChange<MainScreen>();
}
}
public override void Update(ModUpdateLevel level, FrameEventArgs frameEventArgs)

View File

@@ -5,7 +5,6 @@ using Robust.Client.Interfaces.Input;
using Robust.Client.Interfaces.Placement;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.Interfaces.State;
using Robust.Client.State.States;
using Robust.Shared.Input;
using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.Interfaces.Map;

View File

@@ -1,5 +1,6 @@
using Content.Client.GameObjects.Components.Mobs;
using Content.Client.UserInterface;
using Content.Client.UserInterface.Stylesheets;
using Robust.Client.Interfaces.GameObjects.Components;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.UserInterface;
@@ -68,7 +69,7 @@ namespace Content.Client.GameObjects.Components.Actor
(SubText = new Label
{
SizeFlagsVertical = SizeFlags.None,
StyleClasses = {NanoStyle.StyleClassLabelSubText}
StyleClasses = {StyleNano.StyleClassLabelSubText}
})
}
}

View File

@@ -1,4 +1,5 @@
using Content.Client.UserInterface;
using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility;
using Robust.Shared.Timing;
using Content.Shared.GameObjects.Components.Chemistry;
@@ -49,7 +50,7 @@ namespace Content.Client.GameObjects.Components.Chemistry
public StatusControl(InjectorComponent parent)
{
_parent = parent;
_label = new RichTextLabel { StyleClasses = { NanoStyle.StyleClassItemStatus } };
_label = new RichTextLabel { StyleClasses = { StyleNano.StyleClassItemStatus } };
AddChild(_label);
parent._uiUpdateNeeded = true;

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Content.Client.UserInterface;
using Content.Client.UserInterface.Stylesheets;
using Content.Shared.Chemistry;
using Content.Shared.GameObjects.Components.Chemistry;
using Robust.Client.Graphics.Drawing;
@@ -218,7 +219,7 @@ namespace Content.Client.GameObjects.Components.Chemistry
new Label
{
Text = $"{state.BeakerCurrentVolume}/{state.BeakerMaxVolume}",
StyleClasses = {NanoStyle.StyleClassLabelSecondaryColor}
StyleClasses = {StyleNano.StyleClassLabelSecondaryColor}
}
}
});
@@ -247,12 +248,12 @@ namespace Content.Client.GameObjects.Components.Chemistry
new Label
{
Text = $"{name}: ",
StyleClasses = {NanoStyle.StyleClassPowerStateGood}
StyleClasses = {StyleNano.StyleClassPowerStateGood}
},
new Label
{
Text = $"{reagent.Quantity}u",
StyleClasses = {NanoStyle.StyleClassPowerStateGood}
StyleClasses = {StyleNano.StyleClassPowerStateGood}
}
}
});
@@ -267,7 +268,7 @@ namespace Content.Client.GameObjects.Components.Chemistry
new Label
{
Text = $"{reagent.Quantity}u",
StyleClasses = {NanoStyle.StyleClassLabelSecondaryColor}
StyleClasses = {StyleNano.StyleClassLabelSecondaryColor}
}
}
});

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Content.Shared.GameObjects.Components.Instruments;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Client.Audio.Midi;
using Robust.Shared.Audio.Midi;
@@ -28,6 +29,7 @@ namespace Content.Client.GameObjects.Components.Instruments
[Dependency] private readonly IGameTiming _timing;
#pragma warning restore 649
[CanBeNull]
private IMidiRenderer _renderer;
private int _instrumentProgram = 1;
@@ -42,8 +44,14 @@ namespace Content.Client.GameObjects.Components.Instruments
[ViewVariables(VVAccess.ReadWrite)]
public bool LoopMidi
{
get => _renderer.LoopMidi;
set => _renderer.LoopMidi = value;
get => _renderer?.LoopMidi ?? false;
set
{
if (_renderer != null)
{
_renderer.LoopMidi = value;
}
}
}
/// <summary>
@@ -53,9 +61,13 @@ namespace Content.Client.GameObjects.Components.Instruments
public int InstrumentProgram
{
get => _instrumentProgram;
set {
set
{
_instrumentProgram = value;
_renderer.MidiProgram = _instrumentProgram;
if (_renderer != null)
{
_renderer.MidiProgram = _instrumentProgram;
}
}
}
@@ -63,22 +75,26 @@ namespace Content.Client.GameObjects.Components.Instruments
/// Whether there's a midi song being played or not.
/// </summary>
[ViewVariables]
public bool IsMidiOpen => _renderer.Status == MidiRendererStatus.File;
public bool IsMidiOpen => _renderer?.Status == MidiRendererStatus.File;
/// <summary>
/// Whether the midi renderer is listening for midi input or not.
/// </summary>
[ViewVariables]
public bool IsInputOpen => _renderer.Status == MidiRendererStatus.Input;
public bool IsInputOpen => _renderer?.Status == MidiRendererStatus.Input;
public override void Initialize()
{
base.Initialize();
IoCManager.InjectDependencies(this);
_renderer = _midiManager.GetNewRenderer();
_renderer.MidiProgram = _instrumentProgram;
_renderer.TrackingEntity = Owner;
_renderer.OnMidiPlayerFinished += () => { OnMidiPlaybackEnded?.Invoke(); };
if (_renderer != null)
{
_renderer.MidiProgram = _instrumentProgram;
_renderer.TrackingEntity = Owner;
_renderer.OnMidiPlayerFinished += () => { OnMidiPlaybackEnded?.Invoke(); };
}
}
protected override void Shutdown()
@@ -93,9 +109,16 @@ namespace Content.Client.GameObjects.Components.Instruments
serializer.DataField(ref _instrumentProgram, "program", 1);
}
public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, IComponent component = null)
public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null,
IComponent component = null)
{
base.HandleMessage(message, netChannel, component);
if (_renderer == null)
{
return;
}
switch (message)
{
case InstrumentMidiEventMessage midiEventMessage:
@@ -107,8 +130,8 @@ namespace Content.Client.GameObjects.Components.Instruments
case InstrumentStopMidiMessage _:
_renderer.StopAllNotes();
if(IsInputOpen) CloseInput();
if(IsMidiOpen) CloseMidi();
if (IsInputOpen) CloseInput();
if (IsMidiOpen) CloseMidi();
break;
}
}
@@ -116,7 +139,7 @@ namespace Content.Client.GameObjects.Components.Instruments
/// <inheritdoc cref="MidiRenderer.OpenInput"/>
public bool OpenInput()
{
if (_renderer.OpenInput())
if (_renderer != null && _renderer.OpenInput())
{
_renderer.OnMidiEvent += RendererOnMidiEvent;
return true;
@@ -128,28 +151,37 @@ namespace Content.Client.GameObjects.Components.Instruments
/// <inheritdoc cref="MidiRenderer.CloseInput"/>
public bool CloseInput()
{
if (!_renderer.CloseInput()) return false;
if (_renderer == null || !_renderer.CloseInput())
{
return false;
}
_renderer.OnMidiEvent -= RendererOnMidiEvent;
return true;
}
/// <inheritdoc cref="MidiRenderer.OpenMidi(string)"/>
public bool OpenMidi(string filename)
{
if (!_renderer.OpenMidi(filename)) return false;
if (_renderer == null || !_renderer.OpenMidi(filename))
{
return false;
}
_renderer.OnMidiEvent += RendererOnMidiEvent;
return true;
}
/// <inheritdoc cref="MidiRenderer.CloseMidi"/>
public bool CloseMidi()
{
if (!_renderer.CloseMidi()) return false;
if (_renderer == null || !_renderer.CloseMidi())
{
return false;
}
_renderer.OnMidiEvent -= RendererOnMidiEvent;
return true;
}
/// <summary>

View File

@@ -1,6 +1,7 @@
using System;
using System.Linq;
using Content.Client.UserInterface;
using Content.Client.UserInterface.Stylesheets;
using Content.Shared.Preferences.Appearance;
using JetBrains.Annotations;
using Robust.Client.GameObjects.Components.UserInterface;
@@ -126,9 +127,9 @@ namespace Content.Client.GameObjects.Components
var vBox = new VBoxContainer();
AddChild(vBox);
vBox.AddChild(_colorSliderR = new ColorSlider(NanoStyle.StyleClassSliderRed));
vBox.AddChild(_colorSliderG = new ColorSlider(NanoStyle.StyleClassSliderGreen));
vBox.AddChild(_colorSliderB = new ColorSlider(NanoStyle.StyleClassSliderBlue));
vBox.AddChild(_colorSliderR = new ColorSlider(StyleNano.StyleClassSliderRed));
vBox.AddChild(_colorSliderG = new ColorSlider(StyleNano.StyleClassSliderGreen));
vBox.AddChild(_colorSliderB = new ColorSlider(StyleNano.StyleClassSliderBlue));
Action colorValueChanged = ColorValueChanged;
_colorSliderR.OnValueChanged += colorValueChanged;

View File

@@ -1,5 +1,6 @@
using System;
using Content.Client.UserInterface;
using Content.Client.UserInterface.Stylesheets;
using Content.Shared.GameObjects.Components.Power;
using Robust.Client.GameObjects.Components.UserInterface;
using Robust.Client.Graphics.Drawing;
@@ -47,15 +48,15 @@ namespace Content.Client.GameObjects.Components.Power
{
case ApcExternalPowerState.None:
_externalPowerStateLabel.Text = "None";
_externalPowerStateLabel.SetOnlyStyleClass(NanoStyle.StyleClassPowerStateNone);
_externalPowerStateLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateNone);
break;
case ApcExternalPowerState.Low:
_externalPowerStateLabel.Text = "Low";
_externalPowerStateLabel.SetOnlyStyleClass(NanoStyle.StyleClassPowerStateLow);
_externalPowerStateLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateLow);
break;
case ApcExternalPowerState.Good:
_externalPowerStateLabel.Text = "Good";
_externalPowerStateLabel.SetOnlyStyleClass(NanoStyle.StyleClassPowerStateGood);
_externalPowerStateLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateGood);
break;
default:
throw new ArgumentOutOfRangeException();
@@ -140,7 +141,7 @@ namespace Content.Client.GameObjects.Components.Power
var externalStatus = new HBoxContainer();
var externalStatusLabel = new Label {Text = "External Power: "};
ExternalPowerStateLabel = new Label {Text = "Good"};
ExternalPowerStateLabel.SetOnlyStyleClass(NanoStyle.StyleClassPowerStateGood);
ExternalPowerStateLabel.SetOnlyStyleClass(StyleNano.StyleClassPowerStateGood);
externalStatus.AddChild(externalStatusLabel);
externalStatus.AddChild(ExternalPowerStateLabel);
rows.AddChild(externalStatus);

View File

@@ -1,4 +1,5 @@
using Content.Client.UserInterface;
using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility;
using Content.Shared.GameObjects.Components;
using Robust.Client.UserInterface;
@@ -38,7 +39,7 @@ namespace Content.Client.GameObjects.Components
public StatusControl(StackComponent parent)
{
_parent = parent;
_label = new RichTextLabel {StyleClasses = {NanoStyle.StyleClassItemStatus}};
_label = new RichTextLabel {StyleClasses = {StyleNano.StyleClassItemStatus}};
AddChild(_label);
parent._uiUpdateNeeded = true;

View File

@@ -1,6 +1,7 @@
using System;
using Content.Client.Animations;
using Content.Client.UserInterface;
using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Weapons.Ranged;
@@ -174,7 +175,7 @@ namespace Content.Client.GameObjects.Components.Weapons.Ranged
(_noMagazineLabel = new Label
{
Text = "No Magazine!",
StyleClasses = {NanoStyle.StyleClassItemStatus}
StyleClasses = {StyleNano.StyleClassItemStatus}
})
}
},

View File

@@ -1,5 +1,6 @@
using System;
using Content.Client.UserInterface;
using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components;
@@ -46,7 +47,7 @@ namespace Content.Client.GameObjects.Components
public StatusControl(WelderComponent parent)
{
_parent = parent;
_label = new RichTextLabel {StyleClasses = {NanoStyle.StyleClassItemStatus}};
_label = new RichTextLabel {StyleClasses = {StyleNano.StyleClassItemStatus}};
AddChild(_label);
parent._uiUpdateNeeded = true;

View File

@@ -1,10 +1,13 @@
using Content.Client.GameObjects.Components.Instruments;
using Content.Client.UserInterface.Stylesheets;
using Robust.Client.Audio.Midi;
using Robust.Client.Graphics.Drawing;
using Robust.Client.Interfaces.UserInterface;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Maths;
@@ -27,7 +30,7 @@ namespace Content.Client.Instruments
public InstrumentMenu(InstrumentBoundUserInterface owner)
{
IoCManager.InjectDependencies(this);
Title = "Instrument";
Title = Loc.GetString("Instrument");
_owner = owner;
@@ -55,7 +58,7 @@ namespace Content.Client.Instruments
midiInputButton = new Button()
{
Text = "MIDI Input",
Text = Loc.GetString("MIDI Input"),
TextAlign = Label.AlignMode.Center,
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 1,
@@ -73,7 +76,7 @@ namespace Content.Client.Instruments
var midiFileButton = new Button()
{
Text = "Open File",
Text = Loc.GetString("Play MIDI File"),
TextAlign = Label.AlignMode.Center,
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 1,
@@ -91,7 +94,7 @@ namespace Content.Client.Instruments
midiLoopButton = new Button()
{
Text = "Loop",
Text = Loc.GetString("Loop"),
TextAlign = Label.AlignMode.Center,
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 1,
@@ -110,7 +113,7 @@ namespace Content.Client.Instruments
midiStopButton = new Button()
{
Text = "Stop",
Text = Loc.GetString("Stop"),
TextAlign = Label.AlignMode.Center,
SizeFlagsHorizontal = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 1,
@@ -132,6 +135,26 @@ namespace Content.Client.Instruments
margin.AddChild(vBox);
if (!_midiManager.IsAvailable)
{
margin.AddChild(new PanelContainer
{
MouseFilter = MouseFilterMode.Stop,
PanelOverride = new StyleBoxFlat {BackgroundColor = Color.Black.WithAlpha(0.90f)},
Children =
{
new Label
{
Align = Label.AlignMode.Center,
SizeFlagsVertical = SizeFlags.ShrinkCenter,
SizeFlagsHorizontal = SizeFlags.ShrinkCenter,
StyleClasses = {StyleNano.StyleClassLabelBig},
Text = Loc.GetString("MIDI support is currently\nnot available on your platform.")
}
}
});
}
Contents.AddChild(margin);
}
@@ -148,7 +171,8 @@ namespace Content.Client.Instruments
private async void MidiFileButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
{
var filename = await _fileDialogManager.OpenFile();
var filters = new FileDialogFilters(new FileDialogFilters.Group("mid", "midi"));
var filename = await _fileDialogManager.OpenFile(filters);
if (filename == null) return;
@@ -160,7 +184,7 @@ namespace Content.Client.Instruments
if (!_owner.Instrument.OpenMidi(filename)) return;
MidiPlaybackSetButtonsDisabled(false);
if(midiInputButton.Pressed)
if (midiInputButton.Pressed)
midiInputButton.Pressed = false;
}

View File

@@ -0,0 +1,230 @@
using Content.Client.UserInterface.Controls;
using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility;
using Robust.Client.Graphics.Drawing;
using Robust.Client.Interfaces;
using Robust.Client.Interfaces.UserInterface;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Maths;
using static Content.Client.StaticIoC;
namespace Content.Client.State
{
public class LauncherConnecting : Robust.Client.State.State
{
#pragma warning disable 649
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager;
[Dependency] private readonly IStylesheetManager _stylesheetManager;
[Dependency] private readonly IClientNetManager _clientNetManager;
[Dependency] private readonly IGameController _gameController;
#pragma warning restore 649
private Control _control;
private Label _connectStatus;
public override void Startup()
{
var panelTex = ResC.GetTexture("/Nano/button.svg.96dpi.png");
var back = new StyleBoxTexture
{
Texture = panelTex,
Modulate = new Color(32, 32, 48),
};
back.SetPatchMargin(StyleBox.Margin.All, 10);
Button exitButton;
Label connectFailReason;
Control connectingStatus;
var address = _gameController.LaunchState.Ss14Address ?? _gameController.LaunchState.ConnectAddress;
_control = new Control
{
Stylesheet = _stylesheetManager.SheetSpace,
Children =
{
new PanelContainer
{
PanelOverride = back
},
new VBoxContainer
{
SeparationOverride = 0,
CustomMinimumSize = (300, 200),
Children =
{
new HBoxContainer
{
Children =
{
new MarginContainer
{
MarginLeftOverride = 8,
Children =
{
new Label
{
Text = Loc.GetString("Space Station 14"),
StyleClasses = {StyleBase.StyleClassLabelHeading},
VAlign = Label.VAlignMode.Center
},
}
},
(exitButton = new Button
{
Text = Loc.GetString("Exit"),
SizeFlagsHorizontal = Control.SizeFlags.ShrinkEnd | Control.SizeFlags.Expand
}),
}
},
// Line
new HighDivider(),
new MarginContainer
{
SizeFlagsVertical = Control.SizeFlags.FillExpand,
MarginLeftOverride = 4,
MarginRightOverride = 4,
MarginTopOverride = 4,
Children =
{
new VBoxContainer
{
SeparationOverride = 0,
Children =
{
new Control
{
Children =
{
(connectingStatus = new VBoxContainer
{
SeparationOverride = 0,
Children =
{
new Label
{
Text = Loc.GetString("Connecting to server..."),
Align = Label.AlignMode.Center,
},
(_connectStatus = new Label
{
StyleClasses = {StyleBase.StyleClassLabelSubText},
Align = Label.AlignMode.Center,
}),
}
}),
(connectFailReason = new Label
{
Align = Label.AlignMode.Center
})
}
},
// Padding.
new Control {CustomMinimumSize = (0, 8)},
new Label
{
Text = address,
StyleClasses = {StyleBase.StyleClassLabelSubText},
SizeFlagsHorizontal = Control.SizeFlags.ShrinkCenter,
SizeFlagsVertical =
Control.SizeFlags.ShrinkEnd | Control.SizeFlags.Expand,
}
}
},
}
},
// Line
new PanelContainer
{
PanelOverride = new StyleBoxFlat
{
BackgroundColor = Color.FromHex("#444"),
ContentMarginTopOverride = 2
},
},
new MarginContainer
{
MarginLeftOverride = 12,
MarginRightOverride = 4,
Children =
{
new HBoxContainer
{
SizeFlagsVertical = Control.SizeFlags.ShrinkEnd,
Children =
{
new Label
{
Text = Loc.GetString("Don't die!"),
StyleClasses = {StyleBase.StyleClassLabelSubText}
},
new Label
{
Text = "ver 0.1",
SizeFlagsHorizontal =
Control.SizeFlags.Expand | Control.SizeFlags.ShrinkEnd,
StyleClasses = {StyleBase.StyleClassLabelSubText}
}
}
}
}
},
}
},
}
};
_userInterfaceManager.StateRoot.AddChild(_control);
LayoutContainer.SetAnchorPreset(_control, LayoutContainer.LayoutPreset.Center);
LayoutContainer.SetGrowHorizontal(_control, LayoutContainer.GrowDirection.Both);
LayoutContainer.SetGrowVertical(_control, LayoutContainer.GrowDirection.Both);
exitButton.OnPressed += args =>
{
_gameController.Shutdown("Exit button pressed");
};
_clientNetManager.ConnectFailed += (sender, args) =>
{
connectFailReason.Text = Loc.GetString("Failed to connect to server:\n{0}", args.Reason);
connectingStatus.Visible = false;
connectFailReason.Visible = true;
};
_clientNetManager.ClientConnectStateChanged += ConnectStateChanged;
ConnectStateChanged(_clientNetManager.ClientConnectState);
}
private void ConnectStateChanged(ClientConnectionState state)
{
_connectStatus.Text = Loc.GetString(state switch
{
ClientConnectionState.NotConnecting => "Not connecting?",
ClientConnectionState.ResolvingHost => "Resolving server address...",
ClientConnectionState.EstablishingConnection => "Establishing initial connection...",
ClientConnectionState.Handshake => "Doing handshake...",
ClientConnectionState.Connected => "Synchronizing game state...",
_ => state.ToString()
});
}
public override void Shutdown()
{
_control.Dispose();
}
}
}

View File

@@ -0,0 +1,329 @@
using System;
using System.Text.RegularExpressions;
using Robust.Client;
using Robust.Client.Interfaces;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.Interfaces.UserInterface;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Log;
using Robust.Shared.Network;
using Robust.Shared.Utility;
namespace Content.Client.State
{
/// <summary>
/// Main menu screen that is the first screen to be displayed when the game starts.
/// </summary>
// Instantiated dynamically through the StateManager, Dependencies will be resolved.
public class MainScreen : Robust.Client.State.State
{
private const string PublicServerAddress = "server.spacestation14.io";
#pragma warning disable 649
[Dependency] private readonly IBaseClient _client;
[Dependency] private readonly IClientNetManager _netManager;
[Dependency] private readonly IConfigurationManager _configurationManager;
[Dependency] private readonly IGameController _controllerProxy;
[Dependency] private readonly ILocalizationManager _loc;
[Dependency] private readonly IResourceCache _resourceCache;
[Dependency] private readonly IUserInterfaceManager userInterfaceManager;
#pragma warning restore 649
private MainMenuControl _mainMenuControl;
private OptionsMenu OptionsMenu;
private bool _isConnecting;
// ReSharper disable once InconsistentNaming
private static readonly Regex IPv6Regex = new Regex(@"\[(.*:.*:.*)](?::(\d+))?");
/// <inheritdoc />
public override void Startup()
{
_mainMenuControl = new MainMenuControl(_resourceCache, _configurationManager);
userInterfaceManager.StateRoot.AddChild(_mainMenuControl);
_mainMenuControl.QuitButton.OnPressed += QuitButtonPressed;
_mainMenuControl.OptionsButton.OnPressed += OptionsButtonPressed;
_mainMenuControl.DirectConnectButton.OnPressed += DirectConnectButtonPressed;
_mainMenuControl.JoinPublicServerButton.OnPressed += JoinPublicServerButtonPressed;
_mainMenuControl.AddressBox.OnTextEntered += AddressBoxEntered;
_client.RunLevelChanged += RunLevelChanged;
OptionsMenu = new OptionsMenu(_configurationManager);
}
/// <inheritdoc />
public override void Shutdown()
{
_client.RunLevelChanged -= RunLevelChanged;
_netManager.ConnectFailed -= _onConnectFailed;
_mainMenuControl.Dispose();
OptionsMenu.Dispose();
}
private void QuitButtonPressed(BaseButton.ButtonEventArgs args)
{
_controllerProxy.Shutdown();
}
private void OptionsButtonPressed(BaseButton.ButtonEventArgs args)
{
OptionsMenu.OpenCentered();
}
private void DirectConnectButtonPressed(BaseButton.ButtonEventArgs args)
{
var input = _mainMenuControl.AddressBox;
TryConnect(input.Text);
}
private void JoinPublicServerButtonPressed(BaseButton.ButtonEventArgs args)
{
TryConnect(PublicServerAddress);
}
private void AddressBoxEntered(LineEdit.LineEditEventArgs args)
{
if (_isConnecting)
{
return;
}
TryConnect(args.Text);
}
private void TryConnect(string address)
{
var inputName = _mainMenuControl.UserNameBox.Text.Trim();
var (nameValid, invalidReason) = UsernameHelpers.IsNameValid(inputName);
if (!nameValid)
{
invalidReason = _loc.GetString(invalidReason);
userInterfaceManager.Popup(
_loc.GetString("Invalid username:\n{0}", invalidReason),
_loc.GetString("Invalid Username"));
return;
}
var configName = _configurationManager.GetCVar<string>("player.name");
if (_mainMenuControl.UserNameBox.Text != configName)
{
_configurationManager.SetCVar("player.name", inputName);
_configurationManager.SaveToFile();
}
_setConnectingState(true);
_netManager.ConnectFailed += _onConnectFailed;
try
{
ParseAddress(address, out var ip, out var port);
_client.ConnectToServer(ip, port);
}
catch (ArgumentException e)
{
userInterfaceManager.Popup($"Unable to connect: {e.Message}", "Connection error.");
Logger.Warning(e.ToString());
_netManager.ConnectFailed -= _onConnectFailed;
}
}
private void RunLevelChanged(object obj, RunLevelChangedEventArgs args)
{
if (args.NewLevel == ClientRunLevel.Initialize)
{
_setConnectingState(false);
_netManager.ConnectFailed -= _onConnectFailed;
}
}
private void ParseAddress(string address, out string ip, out ushort port)
{
var match6 = IPv6Regex.Match(address);
if (match6 != Match.Empty)
{
ip = match6.Groups[1].Value;
if (!match6.Groups[2].Success)
{
port = _client.DefaultPort;
}
else if (!ushort.TryParse(match6.Groups[2].Value, out port))
{
throw new ArgumentException("Not a valid port.");
}
return;
}
// See if the IP includes a port.
var split = address.Split(':');
ip = address;
port = _client.DefaultPort;
if (split.Length > 2)
{
throw new ArgumentException("Not a valid Address.");
}
// IP:port format.
if (split.Length == 2)
{
ip = split[0];
if (!ushort.TryParse(split[1], out port))
{
throw new ArgumentException("Not a valid port.");
}
}
}
private void _onConnectFailed(object _, NetConnectFailArgs args)
{
userInterfaceManager.Popup($"Failed to connect:\n{args.Reason}");
_netManager.ConnectFailed -= _onConnectFailed;
_setConnectingState(false);
}
private void _setConnectingState(bool state)
{
_isConnecting = state;
_mainMenuControl.DirectConnectButton.Disabled = state;
#if FULL_RELEASE
_mainMenuControl.JoinPublicServerButton.Disabled = state;
#endif
}
private sealed class MainMenuControl : Control
{
private readonly IResourceCache _resourceCache;
private readonly IConfigurationManager _configurationManager;
public LineEdit UserNameBox { get; private set; }
public Button JoinPublicServerButton { get; private set; }
public LineEdit AddressBox { get; private set; }
public Button DirectConnectButton { get; private set; }
public Button OptionsButton { get; private set; }
public Button QuitButton { get; private set; }
public Label VersionLabel { get; private set; }
public MainMenuControl(IResourceCache resCache, IConfigurationManager configMan)
{
_resourceCache = resCache;
_configurationManager = configMan;
PerformLayout();
}
private void PerformLayout()
{
LayoutContainer.SetAnchorPreset(this, LayoutContainer.LayoutPreset.Wide);
var layout = new LayoutContainer();
AddChild(layout);
var vBox = new VBoxContainer
{
StyleIdentifier = "mainMenuVBox"
};
layout.AddChild(vBox);
LayoutContainer.SetAnchorPreset(vBox, LayoutContainer.LayoutPreset.TopRight);
LayoutContainer.SetMarginRight(vBox, -25);
LayoutContainer.SetMarginTop(vBox, 30);
LayoutContainer.SetGrowHorizontal(vBox, LayoutContainer.GrowDirection.Begin);
var logoTexture = _resourceCache.GetResource<TextureResource>("/Textures/Logo/logo.png");
var logo = new TextureRect
{
Texture = logoTexture,
Stretch = TextureRect.StretchMode.KeepCentered,
};
vBox.AddChild(logo);
var userNameHBox = new HBoxContainer {SeparationOverride = 4};
vBox.AddChild(userNameHBox);
userNameHBox.AddChild(new Label {Text = "Username:"});
var currentUserName = _configurationManager.GetCVar<string>("player.name");
UserNameBox = new LineEdit
{
Text = currentUserName, PlaceHolder = "Username",
SizeFlagsHorizontal = SizeFlags.FillExpand
};
userNameHBox.AddChild(UserNameBox);
JoinPublicServerButton = new Button
{
Text = "Join Public Server",
StyleIdentifier = "mainMenu",
TextAlign = Label.AlignMode.Center,
#if !FULL_RELEASE
Disabled = true,
ToolTip = "Cannot connect to public server with a debug build."
#endif
};
vBox.AddChild(JoinPublicServerButton);
// Separator.
vBox.AddChild(new Control {CustomMinimumSize = (0, 2)});
AddressBox = new LineEdit
{
Text = "localhost",
PlaceHolder = "server address:port",
SizeFlagsHorizontal = SizeFlags.FillExpand
};
vBox.AddChild(AddressBox);
DirectConnectButton = new Button
{
Text = "Direct Connect",
TextAlign = Label.AlignMode.Center,
StyleIdentifier = "mainMenu",
};
vBox.AddChild(DirectConnectButton);
// Separator.
vBox.AddChild(new Control {CustomMinimumSize = (0, 2)});
OptionsButton = new Button
{
Text = "Options",
TextAlign = Label.AlignMode.Center,
StyleIdentifier = "mainMenu",
};
vBox.AddChild(OptionsButton);
QuitButton = new Button
{
Text = "Quit",
TextAlign = Label.AlignMode.Center,
StyleIdentifier = "mainMenu",
};
vBox.AddChild(QuitButton);
VersionLabel = new Label
{
Text = $"v0.1"
};
LayoutContainer.SetAnchorPreset(VersionLabel, LayoutContainer.LayoutPreset.BottomRight);
LayoutContainer.SetGrowHorizontal(VersionLabel, LayoutContainer.GrowDirection.Begin);
LayoutContainer.SetGrowVertical(VersionLabel, LayoutContainer.GrowDirection.Begin);
layout.AddChild(VersionLabel);
}
}
}
}

View File

@@ -9,6 +9,7 @@ using Robust.Shared.Localization;
using Robust.Shared.Maths;
using System;
using System.Collections.Generic;
using Content.Client.UserInterface.Stylesheets;
namespace Content.Client.UserInterface.Cargo
{
@@ -57,7 +58,7 @@ namespace Content.Client.UserInterface.Cargo
var accountName = new HBoxContainer();
var accountNameLabel = new Label {
Text = _loc.GetString("Account Name: "),
StyleClasses = { NanoStyle.StyleClassLabelKeyText }
StyleClasses = { StyleNano.StyleClassLabelKeyText }
};
_accountNameLabel = new Label {
Text = "None" //Owner.Bank.Account.Name
@@ -70,7 +71,7 @@ namespace Content.Client.UserInterface.Cargo
var pointsLabel = new Label
{
Text = _loc.GetString("Points: "),
StyleClasses = { NanoStyle.StyleClassLabelKeyText }
StyleClasses = { StyleNano.StyleClassLabelKeyText }
};
_pointsLabel = new Label
{
@@ -84,7 +85,7 @@ namespace Content.Client.UserInterface.Cargo
var shuttleStatusLabel = new Label
{
Text = _loc.GetString("Shuttle Status: "),
StyleClasses = { NanoStyle.StyleClassLabelKeyText }
StyleClasses = { StyleNano.StyleClassLabelKeyText }
};
_shuttleStatusLabel = new Label
{
@@ -410,13 +411,13 @@ namespace Content.Client.UserInterface.Cargo
ProductName = new Label
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
StyleClasses = { NanoStyle.StyleClassLabelSubText },
StyleClasses = { StyleNano.StyleClassLabelSubText },
ClipText = true
};
Description = new Label
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
StyleClasses = { NanoStyle.StyleClassLabelSubText },
StyleClasses = { StyleNano.StyleClassLabelSubText },
ClipText = true
};
vBox.AddChild(ProductName);
@@ -426,14 +427,14 @@ namespace Content.Client.UserInterface.Cargo
Approve = new Button
{
Text = "Approve",
StyleClasses = { NanoStyle.StyleClassLabelSubText }
StyleClasses = { StyleNano.StyleClassLabelSubText }
};
hBox.AddChild(Approve);
Cancel = new Button
{
Text = "Cancel",
StyleClasses = { NanoStyle.StyleClassLabelSubText }
StyleClasses = { StyleNano.StyleClassLabelSubText }
};
hBox.AddChild(Cancel);

View File

@@ -1,6 +1,7 @@
using System.Linq;
using Content.Client.GameObjects.Components.Mobs;
using Content.Client.Interfaces;
using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility;
using Content.Shared.Jobs;
using Content.Shared.Preferences;
@@ -67,7 +68,7 @@ namespace Content.Client.UserInterface
{
SizeFlagsHorizontal = SizeFlags.Expand | SizeFlags.ShrinkEnd,
Text = Loc.GetString("Save and close"),
StyleClasses = {NanoStyle.StyleClassButtonBig}
StyleClasses = {StyleNano.StyleClassButtonBig}
};
var topHBox = new HBoxContainer
@@ -83,7 +84,7 @@ namespace Content.Client.UserInterface
new Label
{
Text = Loc.GetString("Character Setup"),
StyleClasses = {NanoStyle.StyleClassLabelHeadingBigger},
StyleClasses = {StyleNano.StyleClassLabelHeadingBigger},
VAlign = Label.VAlignMode.Center,
SizeFlagsHorizontal = SizeFlags.Expand | SizeFlags.ShrinkCenter
}
@@ -99,7 +100,7 @@ namespace Content.Client.UserInterface
{
PanelOverride = new StyleBoxFlat
{
BackgroundColor = NanoStyle.NanoGold,
BackgroundColor = StyleNano.NanoGold,
ContentMarginTopOverride = 2
}
});
@@ -146,7 +147,7 @@ namespace Content.Client.UserInterface
hBox.AddChild(new PanelContainer
{
PanelOverride = new StyleBoxFlat {BackgroundColor = NanoStyle.NanoGold},
PanelOverride = new StyleBoxFlat {BackgroundColor = StyleNano.NanoGold},
CustomMinimumSize = (2, 0)
});
_humanoidProfileEditor = new HumanoidProfileEditor(preferencesManager, prototypeManager);

View File

@@ -0,0 +1,14 @@
using Content.Client.UserInterface.Stylesheets;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
namespace Content.Client.UserInterface.Controls
{
public sealed class HighDivider : Control
{
public HighDivider()
{
Children.Add(new PanelContainer {StyleClasses = {StyleBase.ClassHighDivider}});
}
}
}

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Content.Client.GameObjects.Components;
using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility;
using Robust.Client.Graphics.Drawing;
using Robust.Client.UserInterface;
@@ -57,7 +58,7 @@ namespace Content.Client.UserInterface
(_itemNameLabel = new Label
{
ClipText = true,
StyleClasses = {NanoStyle.StyleClassItemStatus}
StyleClasses = {StyleNano.StyleClassItemStatus}
})
}
}

View File

@@ -1,5 +1,6 @@
using Content.Client.Chat;
using Content.Client.Interfaces;
using Content.Client.UserInterface.Stylesheets;
using Content.Client.Utility;
using Robust.Client.Graphics.Drawing;
using Robust.Client.Interfaces.ResourceManagement;
@@ -69,7 +70,7 @@ namespace Content.Client.UserInterface
new Label
{
Text = Loc.GetString("Lobby"),
StyleClasses = {NanoStyle.StyleClassLabelHeadingBigger},
StyleClasses = {StyleNano.StyleClassLabelHeadingBigger},
/*MarginBottom = 40,
MarginLeft = 8,*/
VAlign = Label.VAlignMode.Center
@@ -78,7 +79,7 @@ namespace Content.Client.UserInterface
},
(ServerName = new Label
{
StyleClasses = {NanoStyle.StyleClassLabelHeadingBigger},
StyleClasses = {StyleNano.StyleClassLabelHeadingBigger},
/*MarginBottom = 40,
GrowHorizontal = GrowDirection.Both,*/
VAlign = Label.VAlignMode.Center,
@@ -88,7 +89,7 @@ namespace Content.Client.UserInterface
{
SizeFlagsHorizontal = SizeFlags.ShrinkEnd,
Text = Loc.GetString("Leave"),
StyleClasses = {NanoStyle.StyleClassButtonBig},
StyleClasses = {StyleNano.StyleClassButtonBig},
//GrowHorizontal = GrowDirection.Begin
})
}
@@ -100,7 +101,7 @@ namespace Content.Client.UserInterface
{
PanelOverride = new StyleBoxFlat
{
BackgroundColor = NanoStyle.NanoGold,
BackgroundColor = StyleNano.NanoGold,
ContentMarginTopOverride = 2
},
});
@@ -146,20 +147,20 @@ namespace Content.Client.UserInterface
(ObserveButton = new Button
{
Text = Loc.GetString("Observe"),
StyleClasses = {NanoStyle.StyleClassButtonBig}
StyleClasses = {StyleNano.StyleClassButtonBig}
}),
(StartTime = new Label
{
SizeFlagsHorizontal = SizeFlags.FillExpand,
Align = Label.AlignMode.Right,
FontColorOverride = Color.DarkGray,
StyleClasses = {NanoStyle.StyleClassLabelBig}
StyleClasses = {StyleNano.StyleClassLabelBig}
}),
(ReadyButton = new Button
{
ToggleMode = true,
Text = Loc.GetString("Ready Up"),
StyleClasses = {NanoStyle.StyleClassButtonBig}
StyleClasses = {StyleNano.StyleClassButtonBig}
}),
}
}
@@ -188,7 +189,7 @@ namespace Content.Client.UserInterface
hBox.AddChild(new PanelContainer
{
PanelOverride = new StyleBoxFlat {BackgroundColor = NanoStyle.NanoGold}, CustomMinimumSize = (2, 0)
PanelOverride = new StyleBoxFlat {BackgroundColor = StyleNano.NanoGold}, CustomMinimumSize = (2, 0)
});
{

View File

@@ -1,3 +1,4 @@
using Content.Client.UserInterface.Stylesheets;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Maths;
@@ -14,7 +15,7 @@ namespace Content.Client.UserInterface
{
Children = {(_label = new Label
{
StyleClasses = {NanoStyle.StyleClassLabelHeading}
StyleClasses = {StyleNano.StyleClassLabelHeading}
})}
};
AddChild(_panel);

View File

@@ -0,0 +1,12 @@
using Robust.Client.UserInterface;
namespace Content.Client.UserInterface.Stylesheets
{
public interface IStylesheetManager
{
Stylesheet SheetNano { get; }
Stylesheet SheetSpace { get; }
void Initialize();
}
}

View File

@@ -0,0 +1,47 @@
using Content.Client.Utility;
using Robust.Client.Graphics.Drawing;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.UserInterface;
namespace Content.Client.UserInterface.Stylesheets
{
public abstract class StyleBase
{
public const string ClassHighDivider = "HighDivider";
public const string StyleClassLabelHeading = "LabelHeading";
public const string StyleClassLabelSubText = "LabelSubText";
public abstract Stylesheet Stylesheet { get; }
protected StyleRule[] BaseRules { get; }
protected StyleBoxTexture BaseButton { get; }
protected StyleBase(IResourceCache resCache)
{
var notoSans12 = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 12);
// Button styles.
var buttonTex = resCache.GetTexture("/Nano/button.svg.96dpi.png");
BaseButton = new StyleBoxTexture
{
Texture = buttonTex,
};
BaseButton.SetPatchMargin(StyleBox.Margin.All, 10);
BaseButton.SetPadding(StyleBox.Margin.All, 1);
BaseButton.SetContentMarginOverride(StyleBox.Margin.Vertical, 2);
BaseButton.SetContentMarginOverride(StyleBox.Margin.Horizontal, 14);
BaseRules = new[]
{
// Default font.
new StyleRule(
new SelectorElement(null, null, null, null),
new[]
{
new StyleProperty("font", notoSans12),
}),
};
}
}
}

View File

@@ -1,29 +1,29 @@
using Content.Client.GameObjects.EntitySystems;
using System.Linq;
using Content.Client.GameObjects.EntitySystems;
using Content.Client.Utility;
using Robust.Client.Graphics.Drawing;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.IoC;
using Robust.Shared.Maths;
namespace Content.Client.UserInterface
namespace Content.Client.UserInterface.Stylesheets
{
public sealed class NanoStyle
public sealed class StyleNano : StyleBase
{
public const string StyleClassSliderRed = "Red";
public const string StyleClassSliderGreen = "Green";
public const string StyleClassSliderBlue = "Blue";
public const string StyleClassLabelHeading = "LabelHeading";
public const string StyleClassLabelHeadingBigger = "LabelHeadingBigger";
public const string StyleClassLabelSubText = "LabelSubText";
public const string StyleClassLabelKeyText = "LabelKeyText";
public const string StyleClassLabelSecondaryColor = "LabelSecondaryColor";
public const string StyleClassLabelBig = "LabelBig";
public const string StyleClassButtonBig = "ButtonBig";
public static readonly Color NanoGold = Color.FromHex("#A88B5E");
public static readonly Color ButtonColorDefault = Color.FromHex("#464966");
public static readonly Color ButtonColorHovered = Color.FromHex("#575b7f");
public static readonly Color ButtonColorPressed = Color.FromHex("#3e6c45");
@@ -36,12 +36,10 @@ namespace Content.Client.UserInterface
public const string StyleClassItemStatus = "ItemStatus";
public Stylesheet Stylesheet { get; }
public override Stylesheet Stylesheet { get; }
public NanoStyle()
public StyleNano(IResourceCache resCache) : base(resCache)
{
var resCache = IoCManager.Resolve<IResourceCache>();
var notoSans8 = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 8);
var notoSans10 = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 10);
var notoSans12 = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 12);
var notoSansBold12 = resCache.GetFont("/Nano/NotoSans/NotoSans-Bold.ttf", 12);
@@ -69,16 +67,10 @@ namespace Content.Client.UserInterface
var textureInvertedTriangle = resCache.GetTexture("/Nano/inverted_triangle.svg.png");
// Button styles.
var buttonTex = resCache.GetTexture("/Nano/button.svg.96dpi.png");
var buttonNormal = new StyleBoxTexture
var buttonNormal = new StyleBoxTexture(BaseButton)
{
Texture = buttonTex,
Modulate = ButtonColorDefault
};
buttonNormal.SetPatchMargin(StyleBox.Margin.All, 10);
buttonNormal.SetPadding(StyleBox.Margin.All, 1);
buttonNormal.SetContentMarginOverride(StyleBox.Margin.Vertical, 2);
buttonNormal.SetContentMarginOverride(StyleBox.Margin.Horizontal, 14);
var buttonHover = new StyleBoxTexture(buttonNormal)
{
@@ -248,16 +240,8 @@ namespace Content.Client.UserInterface
var sliderFillRed = new StyleBoxTexture(sliderFillBox) {Modulate = Color.Red};
var sliderFillBlue = new StyleBoxTexture(sliderFillBox) {Modulate = Color.Blue};
Stylesheet = new Stylesheet(new[]
Stylesheet = new Stylesheet(BaseRules.Concat(new[]
{
// Default font.
new StyleRule(
new SelectorElement(null, null, null, null),
new[]
{
new StyleProperty("font", notoSans12),
}),
// Window title.
new StyleRule(
new SelectorElement(typeof(Label), new[] {SS14Window.StyleClassWindowTitle}, null, null),
@@ -721,7 +705,12 @@ namespace Content.Client.UserInterface
{
new StyleProperty(Label.StylePropertyAlignMode, Label.AlignMode.Center),
}),
});
new StyleRule(new SelectorElement(typeof(PanelContainer), new []{ ClassHighDivider}, null, null), new []
{
new StyleProperty(PanelContainer.StylePropertyPanel, new StyleBoxFlat { BackgroundColor = NanoGold, ContentMarginBottomOverride = 2, ContentMarginLeftOverride = 2}),
})
}).ToList());
}
}
}

View File

@@ -0,0 +1,107 @@
using System.Linq;
using Content.Client.Utility;
using Robust.Client.Graphics.Drawing;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Maths;
namespace Content.Client.UserInterface.Stylesheets
{
public class StyleSpace : StyleBase
{
public static readonly Color SpaceRed = Color.FromHex("#9b2236");
public static readonly Color ButtonColorDefault = Color.FromHex("#464966");
public static readonly Color ButtonColorHovered = Color.FromHex("#575b7f");
public static readonly Color ButtonColorPressed = Color.FromHex("#3e6c45");
public static readonly Color ButtonColorDisabled = Color.FromHex("#30313c");
public override Stylesheet Stylesheet { get; }
public StyleSpace(IResourceCache resCache) : base(resCache)
{
var notoSans10 = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 10);
var notoSansBold16 = resCache.GetFont("/Nano/NotoSans/NotoSans-Bold.ttf", 16);
// Button styles.
var buttonNormal = new StyleBoxTexture(BaseButton)
{
Modulate = ButtonColorDefault
};
var buttonHover = new StyleBoxTexture(buttonNormal)
{
Modulate = ButtonColorHovered
};
var buttonPressed = new StyleBoxTexture(buttonNormal)
{
Modulate = ButtonColorPressed
};
var buttonDisabled = new StyleBoxTexture(buttonNormal)
{
Modulate = ButtonColorDisabled
};
Stylesheet = new Stylesheet(BaseRules.Concat(new StyleRule[]
{
// Big Label
new StyleRule(new SelectorElement(typeof(Label), new[] {StyleClassLabelHeading}, null, null), new[]
{
new StyleProperty(Label.StylePropertyFont, notoSansBold16),
new StyleProperty(Label.StylePropertyFontColor, SpaceRed),
}),
// Small Label
new StyleRule(new SelectorElement(typeof(Label), new[] {StyleClassLabelSubText}, null, null), new[]
{
new StyleProperty(Label.StylePropertyFont, notoSans10),
new StyleProperty(Label.StylePropertyFontColor, Color.DarkGray),
}),
new StyleRule(new SelectorElement(typeof(PanelContainer), new[] {ClassHighDivider}, null, null), new[]
{
new StyleProperty(PanelContainer.StylePropertyPanel,
new StyleBoxFlat
{
BackgroundColor = SpaceRed, ContentMarginBottomOverride = 2, ContentMarginLeftOverride = 2
}),
}),
// Regular buttons!
new StyleRule(new SelectorElement(typeof(ContainerButton), new[] { ContainerButton.StyleClassButton }, null, new[] {ContainerButton.StylePseudoClassNormal}), new[]
{
new StyleProperty(ContainerButton.StylePropertyStyleBox, buttonNormal),
}),
new StyleRule(new SelectorElement(typeof(ContainerButton), new[] { ContainerButton.StyleClassButton }, null, new[] {ContainerButton.StylePseudoClassHover}), new[]
{
new StyleProperty(ContainerButton.StylePropertyStyleBox, buttonHover),
}),
new StyleRule(new SelectorElement(typeof(ContainerButton), new[] { ContainerButton.StyleClassButton }, null, new[] {ContainerButton.StylePseudoClassPressed}), new[]
{
new StyleProperty(ContainerButton.StylePropertyStyleBox, buttonPressed),
}),
new StyleRule(new SelectorElement(typeof(ContainerButton), new[] { ContainerButton.StyleClassButton }, null, new[] {ContainerButton.StylePseudoClassDisabled}), new[]
{
new StyleProperty(ContainerButton.StylePropertyStyleBox, buttonDisabled),
}),
new StyleRule(new SelectorElement(typeof(Label), new[] { Button.StyleClassButton }, null, null), new[]
{
new StyleProperty(Label.StylePropertyAlignMode, Label.AlignMode.Center),
}),
new StyleRule(new SelectorChild(
new SelectorElement(typeof(Button), null, null, new[] {ContainerButton.StylePseudoClassDisabled}),
new SelectorElement(typeof(Label), null, null, null)),
new[]
{
new StyleProperty("font-color", Color.FromHex("#E5E5E581")),
}),
}).ToList());
}
}
}

View File

@@ -0,0 +1,26 @@
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.Interfaces.UserInterface;
using Robust.Client.UserInterface;
using Robust.Shared.IoC;
namespace Content.Client.UserInterface.Stylesheets
{
public sealed class StylesheetManager : IStylesheetManager
{
#pragma warning disable 649
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager;
[Dependency] private readonly IResourceCache _resourceCache;
#pragma warning restore 649
public Stylesheet SheetNano { get; private set; }
public Stylesheet SheetSpace { get; private set; }
public void Initialize()
{
SheetNano = new StyleNano(_resourceCache).Stylesheet;
SheetSpace = new StyleSpace(_resourceCache).Stylesheet;
_userInterfaceManager.Stylesheet = SheetNano;
}
}
}

View File

@@ -0,0 +1,81 @@
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Robust.Shared.Log;
using Robust.Server.Interfaces.Maps;
using Robust.Server.Interfaces.Timing;
namespace Content.IntegrationTests.Tests
{
[TestFixture]
[TestOf(typeof(Robust.Shared.GameObjects.Entity))]
public class EntityTest : ContentIntegrationTest
{
[Test]
public async Task Test()
{
var server = StartServerDummyTicker();
await server.WaitIdleAsync();
var mapMan = server.ResolveDependency<IMapManager>();
var entityMan = server.ResolveDependency<IEntityManager>();
var prototypeMan = server.ResolveDependency<IPrototypeManager>();
var mapLoader = server.ResolveDependency<IMapLoader>();
var pauseMan = server.ResolveDependency<IPauseManager>();
var prototypes = new List<EntityPrototype>();
IMapGrid grid = default;
IEntity testEntity = null;
//Build up test environment
server.Post(() =>
{
var mapId = mapMan.CreateMap();
pauseMan.AddUninitializedMap(mapId);
grid = mapLoader.LoadBlueprint(mapId, "Maps/stationstation.yml");
});
server.Assert(() =>
{
var testLocation = new GridCoordinates(new Robust.Shared.Maths.Vector2(0, 0), grid);
//Generate list of non-abstract prototypes to test
foreach (var prototype in prototypeMan.EnumeratePrototypes<EntityPrototype>())
{
if (prototype.Abstract)
{
continue;
}
prototypes.Add(prototype);
}
//Iterate list of prototypes to spawn
foreach (var prototype in prototypes)
{
try
{
Logger.LogS(LogLevel.Debug, "EntityTest", "Testing: " + prototype.Name);
testEntity = entityMan.SpawnEntity(prototype.ID, testLocation);
server.RunTicks(2);
Assert.That(testEntity.Initialized);
entityMan.DeleteEntity(testEntity.Uid);
}
//Fail any exceptions thrown on spawn
catch (Exception e)
{
Logger.LogS(LogLevel.Error, "EntityTest", "Entity '" + testEntity.Name + "' threw: " + e.Message);
Assert.Fail();
}
}
});
await server.WaitIdleAsync();
}
}
}

View File

@@ -1,6 +1,7 @@
using Content.Server.Cargo;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects.Components.Cargo;
using Content.Server.GameObjects.Components.Power;
using Content.Shared.Prototypes.Cargo;
using Robust.Server.GameObjects.Components.UserInterface;
using Robust.Server.Interfaces.GameObjects;
@@ -40,6 +41,9 @@ namespace Content.Server.GameObjects.Components.Cargo
private bool _requestOnly = false;
private PowerDeviceComponent _powerDevice;
private bool Powered => _powerDevice.Powered;
public override void Initialize()
{
base.Initialize();
@@ -47,6 +51,7 @@ namespace Content.Server.GameObjects.Components.Cargo
Orders = Owner.GetComponent<CargoOrderDatabaseComponent>();
_userInterface = Owner.GetComponent<ServerUserInterfaceComponent>().GetBoundUserInterface(CargoConsoleUiKey.Key);
_userInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage;
_powerDevice = Owner.GetComponent<PowerDeviceComponent>();
_galacticBankManager.AddComponent(this);
BankId = 0;
}
@@ -66,6 +71,8 @@ namespace Content.Server.GameObjects.Components.Cargo
var message = serverMsg.Message;
if (!Orders.ConnectedToDatabase)
return;
if (!Powered)
return;
switch (message)
{
case CargoConsoleAddOrderMessage msg:
@@ -119,6 +126,8 @@ namespace Content.Server.GameObjects.Components.Cargo
{
return;
}
if (!Powered)
return;
_userInterface.Open(actor.playerSession);
}

View File

@@ -2,6 +2,7 @@
using System.Linq;
using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.GameObjects.Components.Power;
using Content.Server.Interfaces;
using Content.Server.Interfaces.GameObjects;
using Content.Shared.Chemistry;
@@ -46,6 +47,11 @@ namespace Content.Server.GameObjects.Components.Chemistry
[ViewVariables]
private SolutionComponent Solution => _beakerContainer.ContainedEntity.GetComponent<SolutionComponent>();
///implementing PowerDeviceComponent
private PowerDeviceComponent _powerDevice;
private bool Powered => _powerDevice.Powered;
/// <summary>
/// Shows the serializer how to save/load this components yaml prototype.
/// </summary>
@@ -70,6 +76,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
_beakerContainer =
ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-reagentContainerContainer", Owner);
_powerDevice = Owner.GetComponent<PowerDeviceComponent>();
InitializeFromPrototype();
UpdateUserInterface();
@@ -159,6 +166,9 @@ namespace Content.Server.GameObjects.Components.Chemistry
//Check if player can interact in their current state
if (!ActionBlockerSystem.CanInteract(playerEntity) || !ActionBlockerSystem.CanUse(playerEntity))
return false;
//Check if device is powered
if (!Powered)
return false;
return true;
}
@@ -251,6 +261,9 @@ namespace Content.Server.GameObjects.Components.Chemistry
return;
}
if (!Powered)
return;
var activeHandEntity = hands.GetActiveHand?.Owner;
if (activeHandEntity == null)
{

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Medical;
using Content.Server.GameObjects.Components.Power;
using Robust.Server.GameObjects;
using Robust.Server.GameObjects.Components.Container;
using Robust.Server.GameObjects.Components.UserInterface;
@@ -24,6 +25,10 @@ namespace Content.Server.GameObjects.Components.Medical
private readonly Vector2 _ejectOffset = new Vector2(-0.5f, 0f);
public bool IsOccupied => _bodyContainer.ContainedEntity != null;
///implementing PowerDeviceComponent
private PowerDeviceComponent _powerDevice;
private bool Powered => _powerDevice.Powered;
public override void Initialize()
{
base.Initialize();
@@ -31,6 +36,7 @@ namespace Content.Server.GameObjects.Components.Medical
_userInterface = Owner.GetComponent<ServerUserInterfaceComponent>()
.GetBoundUserInterface(MedicalScannerUiKey.Key);
_bodyContainer = ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-bodyContainer", Owner);
_powerDevice = Owner.GetComponent<PowerDeviceComponent>();
UpdateUserInterface();
}
@@ -79,6 +85,8 @@ namespace Content.Server.GameObjects.Components.Medical
private void UpdateUserInterface()
{
if (!Powered)
return;
var newState = GetUserInterfaceState();
_userInterface.SetState(newState);
}
@@ -112,6 +120,8 @@ namespace Content.Server.GameObjects.Components.Medical
{
return;
}
if (!Powered)
return;
_userInterface.Open(actor.playerSession);
}

View File

@@ -62,6 +62,9 @@ namespace Content.Server.GameObjects.Components.Research
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage message)
{
if (!Powered)
return;
switch (message.Message)
{
case LatheQueueRecipeMessage msg:
@@ -87,13 +90,15 @@ namespace Content.Server.GameObjects.Components.Research
case LatheServerSyncMessage msg:
if (!Owner.TryGetComponent(out TechnologyDatabaseComponent database)
|| !Owner.TryGetComponent(out ProtolatheDatabaseComponent protoDatabase)) return;
|| !Owner.TryGetComponent(out ProtolatheDatabaseComponent protoDatabase)) return;
if(database.SyncWithServer())
if (database.SyncWithServer())
protoDatabase.Sync();
break;
}
}
internal bool Produce(LatheRecipePrototype recipe)

View File

@@ -46,6 +46,8 @@ namespace Content.Server.GameObjects.Components.Research
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage message)
{
if (!Owner.TryGetComponent(out TechnologyDatabaseComponent database)) return;
if (!Powered)
return;
switch (message.Message)
{

View File

@@ -47,6 +47,8 @@ namespace Content.Server.GameObjects.Components.VendingMachines
{
return;
}
if (!Powered)
return;
var wires = Owner.GetComponent<WiresComponent>();
if (wires.IsPanelOpen)
@@ -121,6 +123,9 @@ namespace Content.Server.GameObjects.Components.VendingMachines
private void UserInterfaceOnOnReceiveMessage(ServerBoundUserInterfaceMessage serverMsg)
{
if (!Powered)
return;
var message = serverMsg.Message;
switch (message)
{

View File

@@ -10,6 +10,7 @@
texture: Buildings/chemicals.rsi/industrial_dispenser.png
- type: ReagentDispenser
pack: ChemDispenserStandardInventory
- type: PowerDevice
- type: reagentDispenserInventory
id: ChemDispenserStandardInventory

View File

@@ -1,70 +1,70 @@
# - type: entity
# name: BaseInstrument
# id: BaseInstrument
# abstract: true
# components:
# - type: Instrument
# handheld: false
#
# - type: Clickable
# - type: InteractionOutline
#
# - type: Collidable
# shapes:
# - !type:PhysShapeAabb
# layer: 31
#
# - type: SnapGrid
# offset: Center
#
# - type: Damageable
# - type: Destructible
# thresholdvalue: 50
#
# - type: UserInterface
# interfaces:
# - key: enum.InstrumentUiKey.Key
# type: InstrumentBoundUserInterface
#
# - type: entity
# name: Piano
# parent: BaseInstrument
# id: PianoInstrument
# description: Play Needles Piano Now.
# components:
# - type: Instrument
# program: 1
# - type: Sprite
# sprite: Objects/Instruments/musician.rsi
# state: piano
# - type: Icon
# sprite: Objects/Instruments/musician.rsi
# state: piano
#
# - type: entity
# name: Minimoog
# parent: BaseInstrument
# id: MinimoogInstrument
# components:
# - type: Instrument
# program: 7
# - type: Sprite
# sprite: Objects/Instruments/musician.rsi
# state: minimoog
# - type: Icon
# sprite: Objects/Instruments/musician.rsi
# state: minimoog
#
# - type: entity
# name: Xylophone
# parent: BaseInstrument
# id: XylophoneInstrument
# components:
# - type: Instrument
# program: 13
# - type: Sprite
# sprite: Objects/Instruments/musician.rsi
# state: xylophone
# - type: Icon
# sprite: Objects/Instruments/musician.rsi
# state: xylophone
- type: entity
name: BaseInstrument
id: BaseInstrument
abstract: true
components:
- type: Instrument
handheld: false
- type: Clickable
- type: InteractionOutline
- type: Collidable
shapes:
- !type:PhysShapeAabb
layer: 31
- type: SnapGrid
offset: Center
- type: Damageable
- type: Destructible
thresholdvalue: 50
- type: UserInterface
interfaces:
- key: enum.InstrumentUiKey.Key
type: InstrumentBoundUserInterface
- type: entity
name: Piano
parent: BaseInstrument
id: PianoInstrument
description: Play Needles Piano Now.
components:
- type: Instrument
program: 1
- type: Sprite
sprite: Objects/Instruments/musician.rsi
state: piano
- type: Icon
sprite: Objects/Instruments/musician.rsi
state: piano
- type: entity
name: Minimoog
parent: BaseInstrument
id: MinimoogInstrument
components:
- type: Instrument
program: 7
- type: Sprite
sprite: Objects/Instruments/musician.rsi
state: minimoog
- type: Icon
sprite: Objects/Instruments/musician.rsi
state: minimoog
- type: entity
name: Xylophone
parent: BaseInstrument
id: XylophoneInstrument
components:
- type: Instrument
program: 13
- type: Sprite
sprite: Objects/Instruments/musician.rsi
state: xylophone
- type: Icon
sprite: Objects/Instruments/musician.rsi
state: xylophone

View File

@@ -11,7 +11,7 @@
map: ["enum.MedicalScannerVisualLayers.Machine"]
- state: scanner_terminal_blue
map: ["enum.MedicalScannerVisualLayers.Terminal"]
- type: PowerDevice
- type: Icon
sprite: Buildings/medical_scanner.rsi
state: scanner_open

Binary file not shown.

Before

Width:  |  Height:  |  Size: 162 B

After

Width:  |  Height:  |  Size: 127 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 B

After

Width:  |  Height:  |  Size: 134 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 171 B

After

Width:  |  Height:  |  Size: 134 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 B

After

Width:  |  Height:  |  Size: 120 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 B

After

Width:  |  Height:  |  Size: 157 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 198 B

After

Width:  |  Height:  |  Size: 179 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 B

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 B

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 B

After

Width:  |  Height:  |  Size: 115 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 B

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 146 B

After

Width:  |  Height:  |  Size: 127 B

View File

@@ -52,5 +52,6 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=Occluders/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=preemptively/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=prefs/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Soundfont/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=soundfonts/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=swsl/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>