Merge remote-tracking branch 'upstream/master' into 20-10-30-admins

This commit is contained in:
Pieter-Jan Briers
2020-11-10 16:59:17 +01:00
473 changed files with 5588 additions and 3584 deletions

View File

@@ -0,0 +1,73 @@
using System;
using Content.Client.UserInterface.Stylesheets;
using Robust.Client.Graphics.Drawing;
using Robust.Client.Interfaces.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Maths;
namespace Content.Client.UserInterface
{
/// <summary>
/// The status effects display on the right side of the screen.
/// </summary>
public sealed class AlertsUI : Control
{
public GridContainer Grid { get; }
private readonly IClyde _clyde;
public AlertsUI(IClyde clyde)
{
_clyde = clyde;
var panelContainer = new PanelContainer
{
StyleClasses = {StyleNano.StyleClassTransparentBorderedWindowPanel},
SizeFlagsVertical = SizeFlags.FillExpand,
};
AddChild(panelContainer);
Grid = new GridContainer
{
MaxHeight = CalcMaxHeight(clyde.ScreenSize),
ExpandBackwards = true
};
panelContainer.AddChild(Grid);
clyde.OnWindowResized += ClydeOnOnWindowResized;
LayoutContainer.SetGrowHorizontal(this, LayoutContainer.GrowDirection.Begin);
LayoutContainer.SetAnchorAndMarginPreset(this, LayoutContainer.LayoutPreset.TopRight, margin: 10);
LayoutContainer.SetMarginTop(this, 250);
}
protected override void UIScaleChanged()
{
Grid.MaxHeight = CalcMaxHeight(_clyde.ScreenSize);
base.UIScaleChanged();
}
private void ClydeOnOnWindowResized(WindowResizedEventArgs obj)
{
// TODO: Can rework this once https://github.com/space-wizards/RobustToolbox/issues/1392 is done,
// this is here because there isn't currently a good way to allow the grid to adjust its height based
// on constraints, otherwise we would use anchors to lay it out
Grid.MaxHeight = CalcMaxHeight(obj.NewSize);;
}
private float CalcMaxHeight(Vector2i screenSize)
{
return Math.Max(((screenSize.Y) / UIScale) - 420, 1);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
{
_clyde.OnWindowResized -= ClydeOnOnWindowResized;
}
}
}
}

View File

@@ -149,7 +149,7 @@ namespace Content.Client.UserInterface
PanelOverride = new StyleBoxFlat {BackgroundColor = StyleNano.NanoGold},
CustomMinimumSize = (2, 0)
});
_humanoidProfileEditor = new HumanoidProfileEditor(preferencesManager, prototypeManager);
_humanoidProfileEditor = new HumanoidProfileEditor(preferencesManager, prototypeManager, entityManager);
_humanoidProfileEditor.OnProfileChanged += newProfile => { UpdateUI(); };
hBox.AddChild(_humanoidProfileEditor);
@@ -158,6 +158,15 @@ namespace Content.Client.UserInterface
preferencesManager.OnServerDataLoaded += UpdateUI;
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;
_preferencesManager.OnServerDataLoaded -= UpdateUI;
}
public void Save() => _humanoidProfileEditor.Save();
private void UpdateUI()
@@ -283,7 +292,9 @@ namespace Content.Client.UserInterface
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing) return;
if (!disposing)
return;
_previewDummy.Delete();
_previewDummy = null;
}

View File

@@ -27,29 +27,23 @@ namespace Content.Client.UserInterface
/// Possible values range from 1 to -1, where 1 to 0 is a depleting circle animation and 0 to -1 is a blink animation.
/// </summary>
public float Progress { get; set; }
private static readonly Color StartColor = new Color(0.8f, 0.0f, 0.2f); // red
private static readonly Color EndColor = new Color(0.92f, 0.77f, 0.34f); // yellow
private static readonly Color CompletedColor = new Color(0.0f, 0.8f, 0.27f); // green
protected override void Draw(DrawingHandleScreen handle)
{
Span<float> x = stackalloc float[10];
Span<float> x = new float[10];
Color color;
var lerp = 1f - MathF.Abs(Progress); // for future bikeshedding purposes
if (Progress >= 0f)
{
color = new Color(
EndColor.R + (StartColor.R - EndColor.R) * Progress,
EndColor.G + (StartColor.G - EndColor.G) * Progress,
EndColor.B + (StartColor.B - EndColor.B) * Progress,
EndColor.A);
var hue = (5f / 18f) * lerp;
color = Color.FromHsv((hue, 0.75f, 0.75f, 0.50f));
}
else
{
var alpha = MathHelper.Clamp(0.5f * lerp, 0f, 0.5f);
color = CompletedColor.WithAlpha(alpha);
color = new Color(1f, 1f, 1f, alpha);
}
_shader.SetParameter("progress", Progress);

View File

@@ -1,22 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Content.Client.GameObjects.Components;
using Content.Client.GameObjects.Components;
using Content.Client.GameObjects.Components.Mobs;
using Content.Client.Interfaces;
using Content.Shared;
using Content.Shared.GameTicking;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using Robust.Client.GameObjects;
using Robust.Client.Graphics.Drawing;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.Utility;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Content.Client.UserInterface
{
@@ -43,17 +46,25 @@ namespace Content.Client.UserInterface
private readonly OptionButton _preferenceUnavailableButton;
private readonly List<AntagPreferenceSelector> _antagPreferences;
private readonly IEntity _previewDummy;
private readonly SpriteView _previewSprite;
private readonly SpriteView _previewSpriteSide;
private bool _isDirty;
public int CharacterSlot;
public HumanoidCharacterProfile Profile;
public event Action<HumanoidCharacterProfile> OnProfileChanged;
public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IPrototypeManager prototypeManager)
public HumanoidProfileEditor(IClientPreferencesManager preferencesManager, IPrototypeManager prototypeManager, IEntityManager entityManager)
{
_random = IoCManager.Resolve<IRobustRandom>();
_preferencesManager = preferencesManager;
var hbox = new HBoxContainer();
AddChild(hbox);
#region Left
var margin = new MarginContainer
{
MarginTopOverride = 10,
@@ -61,7 +72,7 @@ namespace Content.Client.UserInterface
MarginLeftOverride = 10,
MarginRightOverride = 10
};
AddChild(margin);
hbox.AddChild(margin);
var vBox = new VBoxContainer();
margin.AddChild(vBox);
@@ -98,7 +109,7 @@ namespace Content.Client.UserInterface
{
SizeFlagsVertical = SizeFlags.FillExpand
};
var nameLabel = new Label {Text = Loc.GetString("Name:")};
var nameLabel = new Label { Text = Loc.GetString("Name:") };
_nameEdit = new LineEdit
{
CustomMinimumSize = (270, 0),
@@ -119,7 +130,7 @@ namespace Content.Client.UserInterface
#endregion Name
var tabContainer = new TabContainer {SizeFlagsVertical = SizeFlags.FillExpand};
var tabContainer = new TabContainer { SizeFlagsVertical = SizeFlags.FillExpand };
vBox.AddChild(tabContainer);
#region Appearance
@@ -141,7 +152,7 @@ namespace Content.Client.UserInterface
{
var panel = HighlightedContainer();
var hBox = new HBoxContainer();
var sexLabel = new Label {Text = Loc.GetString("Sex:")};
var sexLabel = new Label { Text = Loc.GetString("Sex:") };
var sexButtonGroup = new ButtonGroup();
@@ -171,8 +182,8 @@ namespace Content.Client.UserInterface
{
var panel = HighlightedContainer();
var hBox = new HBoxContainer();
var ageLabel = new Label {Text = Loc.GetString("Age:")};
_ageEdit = new LineEdit {CustomMinimumSize = (40, 0)};
var ageLabel = new Label { Text = Loc.GetString("Age:") };
_ageEdit = new LineEdit { CustomMinimumSize = (40, 0) };
_ageEdit.OnTextChanged += args =>
{
if (!int.TryParse(args.Text, out var newAge))
@@ -348,7 +359,7 @@ namespace Content.Client.UserInterface
foreach (var antag in prototypeManager.EnumeratePrototypes<AntagPrototype>().OrderBy(a => a.Name))
{
if(!antag.SetPreference)
if (!antag.SetPreference)
{
continue;
}
@@ -410,6 +421,71 @@ namespace Content.Client.UserInterface
#endregion Save
#endregion
#region Right
margin = new MarginContainer
{
MarginTopOverride = 10,
MarginBottomOverride = 10,
MarginLeftOverride = 10,
MarginRightOverride = 10
};
hbox.AddChild(margin);
vBox = new VBoxContainer()
{
SizeFlagsVertical = SizeFlags.FillExpand,
SizeFlagsHorizontal = SizeFlags.FillExpand,
};
hbox.AddChild(vBox);
#region Preview
_previewDummy = entityManager.SpawnEntity("HumanMob_Dummy", MapCoordinates.Nullspace);
var sprite = _previewDummy.GetComponent<SpriteComponent>();
// Front
var box = new Control()
{
SizeFlagsHorizontal = SizeFlags.Fill,
SizeFlagsVertical = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 1f,
};
vBox.AddChild(box);
_previewSprite = new SpriteView
{
Sprite = sprite,
Scale = (6, 6),
OverrideDirection = Direction.South,
SizeFlagsVertical = SizeFlags.ShrinkCenter,
SizeFlagsStretchRatio = 1
};
box.AddChild(_previewSprite);
// Side
box = new Control()
{
SizeFlagsHorizontal = SizeFlags.Fill,
SizeFlagsVertical = SizeFlags.FillExpand,
SizeFlagsStretchRatio = 1f,
};
vBox.AddChild(box);
_previewSpriteSide = new SpriteView
{
Sprite = sprite,
Scale = (6, 6),
OverrideDirection = Direction.East,
SizeFlagsVertical = SizeFlags.ShrinkCenter,
SizeFlagsStretchRatio = 1
};
box.AddChild(_previewSpriteSide);
#endregion
#endregion
if (preferencesManager.ServerDataLoaded)
{
LoadServerData();
@@ -420,6 +496,16 @@ namespace Content.Client.UserInterface
IsDirty = false;
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;
_previewDummy.Delete();
_preferencesManager.OnServerDataLoaded -= LoadServerData;
}
private void LoadServerData()
{
Profile = (HumanoidCharacterProfile) _preferencesManager.Preferences.SelectedCharacter;
@@ -458,6 +544,7 @@ namespace Content.Client.UserInterface
set
{
_isDirty = value;
UpdatePreview();
UpdateSaveButton();
}
}
@@ -503,6 +590,15 @@ namespace Content.Client.UserInterface
_saveButton.Disabled = Profile is null || !IsDirty;
}
private void UpdatePreview()
{
if (Profile is null)
return;
_previewDummy.GetComponent<HumanoidAppearanceComponent>().UpdateFromProfile(Profile);
LobbyCharacterPreviewPanel.GiveDummyJobClothes(_previewDummy, Profile);
}
public void UpdateControls()
{
if (Profile is null) return;
@@ -514,6 +610,8 @@ namespace Content.Client.UserInterface
UpdateJobPriorities();
UpdateAntagPreferences();
UpdatePreview();
_preferenceUnavailableButton.SelectId((int) Profile.PreferenceUnavailable);
}

View File

@@ -1,7 +1,9 @@
using Robust.Client.Graphics;
using Content.Shared;
using Robust.Client.Graphics;
using Robust.Client.Interfaces.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared;
using Robust.Shared.Interfaces.Configuration;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
@@ -121,7 +123,7 @@ namespace Content.Client.UserInterface
});
ApplyButton.OnPressed += OnApplyButtonPressed;
VSyncCheckBox.Pressed = _cfg.GetCVar<bool>("display.vsync");
VSyncCheckBox.Pressed = _cfg.GetCVar(CVars.DisplayVSync);
FullscreenCheckBox.Pressed = ConfigIsFullscreen;
LightingPresetOption.SelectId(GetConfigLightingQuality());
_uiScaleOption.SelectId(GetConfigUIScalePreset(ConfigUIScale));
@@ -137,11 +139,11 @@ namespace Content.Client.UserInterface
private void OnApplyButtonPressed(BaseButton.ButtonEventArgs args)
{
_cfg.SetCVar("display.vsync", VSyncCheckBox.Pressed);
_cfg.SetCVar(CVars.DisplayVSync, VSyncCheckBox.Pressed);
SetConfigLightingQuality(LightingPresetOption.SelectedId);
_cfg.SetCVar("display.windowmode",
_cfg.SetCVar(CVars.DisplayWindowMode,
(int) (FullscreenCheckBox.Pressed ? WindowMode.Fullscreen : WindowMode.Windowed));
_cfg.SetCVar("display.uiScale", UIScaleOptions[_uiScaleOption.SelectedId]);
_cfg.SetCVar(CVars.DisplayUIScale, UIScaleOptions[_uiScaleOption.SelectedId]);
_cfg.SaveToFile();
UpdateApplyButton();
}
@@ -159,7 +161,7 @@ namespace Content.Client.UserInterface
private void UpdateApplyButton()
{
var isVSyncSame = VSyncCheckBox.Pressed == _cfg.GetCVar<bool>("display.vsync");
var isVSyncSame = VSyncCheckBox.Pressed == _cfg.GetCVar(CVars.DisplayVSync);
var isFullscreenSame = FullscreenCheckBox.Pressed == ConfigIsFullscreen;
var isLightingQualitySame = LightingPresetOption.SelectedId == GetConfigLightingQuality();
var isUIScaleSame = MathHelper.CloseTo(UIScaleOptions[_uiScaleOption.SelectedId], ConfigUIScale);
@@ -167,14 +169,14 @@ namespace Content.Client.UserInterface
}
private bool ConfigIsFullscreen =>
_cfg.GetCVar<int>("display.windowmode") == (int) WindowMode.Fullscreen;
_cfg.GetCVar(CVars.DisplayWindowMode) == (int) WindowMode.Fullscreen;
private float ConfigUIScale => _cfg.GetCVar<float>("display.uiScale");
private float ConfigUIScale => _cfg.GetCVar(CVars.DisplayUIScale);
private int GetConfigLightingQuality()
{
var val = _cfg.GetCVar<int>("display.lightmapdivider");
var soft = _cfg.GetCVar<bool>("display.softshadows");
var val = _cfg.GetCVar(CVars.DisplayLightMapDivider);
var soft = _cfg.GetCVar(CVars.DisplaySoftShadows);
if (val >= 8)
{
return 0;
@@ -198,20 +200,20 @@ namespace Content.Client.UserInterface
switch (value)
{
case 0:
_cfg.SetCVar("display.lightmapdivider", 8);
_cfg.SetCVar("display.softshadows", false);
_cfg.SetCVar(CVars.DisplayLightMapDivider, 8);
_cfg.SetCVar(CVars.DisplaySoftShadows, false);
break;
case 1:
_cfg.SetCVar("display.lightmapdivider", 2);
_cfg.SetCVar("display.softshadows", false);
_cfg.SetCVar(CVars.DisplayLightMapDivider, 2);
_cfg.SetCVar(CVars.DisplaySoftShadows, false);
break;
case 2:
_cfg.SetCVar("display.lightmapdivider", 2);
_cfg.SetCVar("display.softshadows", true);
_cfg.SetCVar(CVars.DisplayLightMapDivider, 2);
_cfg.SetCVar(CVars.DisplaySoftShadows, true);
break;
case 3:
_cfg.SetCVar("display.lightmapdivider", 1);
_cfg.SetCVar("display.softshadows", true);
_cfg.SetCVar(CVars.DisplayLightMapDivider, 1);
_cfg.SetCVar(CVars.DisplaySoftShadows, true);
break;
}
}

View File

@@ -1,23 +0,0 @@
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
namespace Content.Client.UserInterface
{
/// <summary>
/// The status effects display on the right side of the screen.
/// </summary>
public sealed class StatusEffectsUI : Control
{
public VBoxContainer VBox { get; }
public StatusEffectsUI()
{
VBox = new VBoxContainer();
AddChild(VBox);
LayoutContainer.SetGrowHorizontal(this, LayoutContainer.GrowDirection.Begin);
LayoutContainer.SetAnchorAndMarginPreset(this, LayoutContainer.LayoutPreset.TopRight, margin: 10);
LayoutContainer.SetMarginTop(this, 250);
}
}
}

View File

@@ -13,6 +13,13 @@ namespace Content.Client.UserInterface.Stylesheets
{
public sealed class StyleNano : StyleBase
{
public const string StyleClassBorderedWindowPanel = "BorderedWindowPanel";
public const string StyleClassTransparentBorderedWindowPanel = "TransparentBorderedWindowPanel";
public const string StyleClassTooltipPanel = "tooltipBox";
public const string StyleClassTooltipAlertTitle = "tooltipAlertTitle";
public const string StyleClassTooltipAlertDescription = "tooltipAlertDesc";
public const string StyleClassTooltipAlertCooldown = "tooltipAlertCooldown";
public const string StyleClassSliderRed = "Red";
public const string StyleClassSliderGreen = "Green";
public const string StyleClassSliderBlue = "Blue";
@@ -55,6 +62,7 @@ namespace Content.Client.UserInterface.Stylesheets
var notoSansDisplayBold14 = resCache.GetFont("/Fonts/NotoSansDisplay/NotoSansDisplay-Bold.ttf", 14);
var notoSans16 = resCache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 16);
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");
@@ -73,6 +81,20 @@ namespace Content.Client.UserInterface.Stylesheets
windowBackground.SetPatchMargin(StyleBox.Margin.Horizontal | StyleBox.Margin.Bottom, 2);
windowBackground.SetExpandMargin(StyleBox.Margin.Horizontal | StyleBox.Margin.Bottom, 2);
var borderedWindowBackgroundTex = resCache.GetTexture("/Textures/Interface/Nano/window_background_bordered.png");
var borderedWindowBackground = new StyleBoxTexture
{
Texture = borderedWindowBackgroundTex,
};
borderedWindowBackground.SetPatchMargin(StyleBox.Margin.All, 2);
var borderedTransparentWindowBackgroundTex = resCache.GetTexture("/Textures/Interface/Nano/transparent_window_background_bordered.png");
var borderedTransparentWindowBackground = new StyleBoxTexture
{
Texture = borderedTransparentWindowBackgroundTex,
};
borderedTransparentWindowBackground.SetPatchMargin(StyleBox.Margin.All, 2);
var textureInvertedTriangle = resCache.GetTexture("/Textures/Interface/Nano/inverted_triangle.svg.png");
var lineEditTex = resCache.GetTexture("/Textures/Interface/Nano/lineedit.png");
@@ -147,7 +169,7 @@ namespace Content.Client.UserInterface.Stylesheets
Texture = tooltipTexture,
};
tooltipBox.SetPatchMargin(StyleBox.Margin.All, 2);
tooltipBox.SetContentMarginOverride(StyleBox.Margin.Horizontal, 5);
tooltipBox.SetContentMarginOverride(StyleBox.Margin.Horizontal, 7);
// Placeholder
var placeholderTexture = resCache.GetTexture("/Textures/Interface/Nano/placeholder.png");
@@ -245,6 +267,19 @@ namespace Content.Client.UserInterface.Stylesheets
{
new StyleProperty(PanelContainer.StylePropertyPanel, windowBackground),
}),
// bordered window background
new StyleRule(
new SelectorElement(null, new[] {StyleClassBorderedWindowPanel}, null, null),
new[]
{
new StyleProperty(PanelContainer.StylePropertyPanel, borderedWindowBackground),
}),
new StyleRule(
new SelectorElement(null, new[] {StyleClassTransparentBorderedWindowPanel}, null, null),
new[]
{
new StyleProperty(PanelContainer.StylePropertyPanel, borderedTransparentWindowBackground),
}),
// Window header.
new StyleRule(
new SelectorElement(typeof(PanelContainer), new[] {SS14Window.StyleClassWindowHeader}, null, null),
@@ -464,7 +499,7 @@ namespace Content.Client.UserInterface.Stylesheets
new StyleProperty(PanelContainer.StylePropertyPanel, tooltipBox)
}),
new StyleRule(new SelectorElement(typeof(PanelContainer), new[] {"tooltipBox"}, null, null), new[]
new StyleRule(new SelectorElement(typeof(PanelContainer), new [] { StyleClassTooltipPanel }, null, null), new[]
{
new StyleProperty(PanelContainer.StylePropertyPanel, tooltipBox)
}),
@@ -482,6 +517,20 @@ namespace Content.Client.UserInterface.Stylesheets
new StyleProperty("font", notoSansItalic12),
}),
// alert tooltip
new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] {StyleClassTooltipAlertTitle}, null, null), new[]
{
new StyleProperty("font", notoSansBold18)
}),
new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] {StyleClassTooltipAlertDescription}, null, null), new[]
{
new StyleProperty("font", notoSans16)
}),
new StyleRule(new SelectorElement(typeof(RichTextLabel), new[] {StyleClassTooltipAlertCooldown}, null, null), new[]
{
new StyleProperty("font", notoSans16)
}),
// Entity tooltip
new StyleRule(
new SelectorElement(typeof(PanelContainer), new[] {ExamineSystem.StyleClassEntityTooltip}, null,