Skip to content

Commit

Permalink
Merge remote-tracking branch 'wizard/master' into upstream-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
Rxup committed Feb 11, 2024
2 parents 54d527b + cd2eb35 commit ba5f444
Show file tree
Hide file tree
Showing 286 changed files with 7,642 additions and 6,445 deletions.
2 changes: 1 addition & 1 deletion Content.Benchmarks/DeviceNetworkingBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
using Content.IntegrationTests;
using Content.IntegrationTests.Pair;
using Content.IntegrationTests.Tests.DeviceNetwork;
using Content.Server.DeviceNetwork;
using Content.Server.DeviceNetwork.Systems;
using Content.Shared.DeviceNetwork;
using Robust.Shared;
using Robust.Shared.Analyzers;
using Robust.Shared.GameObjects;
Expand Down
13 changes: 1 addition & 12 deletions Content.Client/Chat/UI/SpeechBubble.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,9 @@ protected FormattedMessage FormatSpeech(string message, Color? fontColor = null)
return msg;
}

protected string ExtractSpeechSubstring(ChatMessage message, string tag)
{
var rawmsg = message.WrappedMessage;
var tagStart = rawmsg.IndexOf($"[{tag}]");
var tagEnd = rawmsg.IndexOf($"[/{tag}]");
if (tagStart < 0 || tagEnd < 0) //the above return -1 if the tag's not found, which in turn will cause the below to throw an exception. a blank speech bubble is far more noticeably broken than the bubble not appearing at all -bhijn
return "";
tagStart += tag.Length + 2;
return rawmsg.Substring(tagStart, tagEnd - tagStart);
}

protected FormattedMessage ExtractAndFormatSpeechSubstring(ChatMessage message, string tag, Color? fontColor = null)
{
return FormatSpeech(ExtractSpeechSubstring(message, tag), fontColor);
return FormatSpeech(SharedChatSystem.GetStringInsideTag(message, tag), fontColor);
}

}
Expand Down
8 changes: 8 additions & 0 deletions Content.Client/DeviceLinking/DeviceLinkSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Content.Shared.DeviceLinking;

namespace Content.Client.DeviceLinking;

public sealed class DeviceLinkSystem : SharedDeviceLinkSystem
{

}
21 changes: 16 additions & 5 deletions Content.Client/Guidebook/Controls/GuidebookWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,33 @@ public void UpdateGuides(
}
}

private IEnumerable<GuideEntry> GetSortedRootEntries(List<string>? rootEntries)
private IEnumerable<GuideEntry> GetSortedEntries(List<string>? rootEntries)
{
if (rootEntries == null)
{
HashSet<string> entries = new(_entries.Keys);
foreach (var entry in _entries.Values)
{
if (entry.Children.Count > 0)
{
var sortedChildren = entry.Children
.Select(childId => _entries[childId])
.OrderBy(childEntry => childEntry.Priority)
.ThenBy(childEntry => Loc.GetString(childEntry.Name))
.Select(childEntry => childEntry.Id)
.ToList();

entry.Children = sortedChildren;
}
entries.ExceptWith(entry.Children);
}
rootEntries = entries.ToList();
}

return rootEntries
.Select(x => _entries[x])
.OrderBy(x => x.Priority)
.ThenBy(x => Loc.GetString(x.Name));
.Select(rootEntryId => _entries[rootEntryId])
.OrderBy(rootEntry => rootEntry.Priority)
.ThenBy(rootEntry => Loc.GetString(rootEntry.Name));
}

private void RepopulateTree(List<string>? roots = null, string? forcedRoot = null)
Expand All @@ -123,7 +134,7 @@ private void RepopulateTree(List<string>? roots = null, string? forcedRoot = nul
HashSet<string> addedEntries = new();

TreeItem? parent = forcedRoot == null ? null : AddEntry(forcedRoot, null, addedEntries);
foreach (var entry in GetSortedRootEntries(roots))
foreach (var entry in GetSortedEntries(roots))
{
AddEntry(entry.Id, parent, addedEntries);
}
Expand Down
16 changes: 14 additions & 2 deletions Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<DefaultWindow xmlns="https://spacestation14.io"
<controls:FancyWindow
xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
SetSize="250 100">
<ScrollContainer
VerticalExpand="True">
Expand All @@ -12,6 +14,16 @@
Name="PatientDataContainer"
Orientation="Vertical"
Margin="0 0 5 10">
<BoxContainer Name="ScanModePanel" HorizontalExpand="True" Visible="False" Margin="0 5 0 0">
<Label
Name="ScanMode"
Align="Left"
Text="{Loc health-analyzer-window-scan-mode-text}"/>
<Label
Name="ScanModeText"
Align="Right"
HorizontalExpand="True"/>
</BoxContainer>
<Label
Name="PatientName"/>
<Label
Expand All @@ -30,4 +42,4 @@
</BoxContainer>
</BoxContainer>
</ScrollContainer>
</DefaultWindow>
</controls:FancyWindow>
15 changes: 13 additions & 2 deletions Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System.Linq;
using System.Numerics;
using Content.Client.UserInterface.Controls;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint;
using Content.Shared.IdentityManagement;
using Content.Shared.MedicalScanner;
using Content.Shared.Nutrition.Components;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
Expand All @@ -20,7 +20,7 @@
namespace Content.Client.HealthAnalyzer.UI
{
[GenerateTypedNameReferences]
public sealed partial class HealthAnalyzerWindow : DefaultWindow
public sealed partial class HealthAnalyzerWindow : FancyWindow
{
private readonly IEntityManager _entityManager;
private readonly SpriteSystem _spriteSystem;
Expand Down Expand Up @@ -62,6 +62,17 @@ public void Populate(HealthAnalyzerScannedUserMessage msg)
entityName = Identity.Name(target.Value, _entityManager);
}

if (msg.ScanMode.HasValue)
{
ScanModePanel.Visible = true;
ScanModeText.Text = Loc.GetString(msg.ScanMode.Value ? "health-analyzer-window-scan-mode-active" : "health-analyzer-window-scan-mode-inactive");
ScanModeText.FontColorOverride = msg.ScanMode.Value ? Color.Green : Color.Red;
}
else
{
ScanModePanel.Visible = false;
}

PatientName.Text = Loc.GetString(
"health-analyzer-window-entity-health-text",
("entityName", entityName)
Expand Down
1 change: 1 addition & 0 deletions Content.Client/Options/UI/Tabs/MiscTab.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
FontColorOverride="{xNamespace:Static s:StyleNano.NanoGold}"
StyleClasses="LabelKeyText"/>
<CheckBox Name="ReducedMotionCheckBox" Text="{Loc 'ui-options-reduced-motion'}" />
<CheckBox Name="EnableColorNameCheckBox" Text="{Loc 'ui-options-enable-color-name'}" />
<BoxContainer Orientation="Horizontal">
<Label Text="{Loc 'ui-options-screen-shake-intensity'}" Margin="8 0" />
<Slider Name="ScreenShakeIntensitySlider"
Expand Down
5 changes: 5 additions & 0 deletions Content.Client/Options/UI/Tabs/MiscTab.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public MiscTab()
OpaqueStorageWindowCheckBox.OnToggled += OnCheckBoxToggled;
FancySpeechBubblesCheckBox.OnToggled += OnCheckBoxToggled;
FancyNameBackgroundsCheckBox.OnToggled += OnCheckBoxToggled;
EnableColorNameCheckBox.OnToggled += OnCheckBoxToggled;
ReducedMotionCheckBox.OnToggled += OnCheckBoxToggled;
ScreenShakeIntensitySlider.OnValueChanged += OnScreenShakeIntensitySliderChanged;
// ToggleWalk.OnToggled += OnCheckBoxToggled;
Expand All @@ -76,6 +77,7 @@ public MiscTab()
OpaqueStorageWindowCheckBox.Pressed = _cfg.GetCVar(CCVars.OpaqueStorageWindow);
FancySpeechBubblesCheckBox.Pressed = _cfg.GetCVar(CCVars.ChatEnableFancyBubbles);
FancyNameBackgroundsCheckBox.Pressed = _cfg.GetCVar(CCVars.ChatFancyNameBackground);
EnableColorNameCheckBox.Pressed = _cfg.GetCVar(CCVars.ChatEnableColorName);
ReducedMotionCheckBox.Pressed = _cfg.GetCVar(CCVars.ReducedMotion);
ScreenShakeIntensitySlider.Value = _cfg.GetCVar(CCVars.ScreenShakeIntensity) * 100f;
// ToggleWalk.Pressed = _cfg.GetCVar(CCVars.ToggleWalk);
Expand Down Expand Up @@ -120,6 +122,7 @@ private void OnApplyButtonPressed(BaseButton.ButtonEventArgs args)
_cfg.SetCVar(CCVars.LoocAboveHeadShow, ShowLoocAboveHeadCheckBox.Pressed);
_cfg.SetCVar(CCVars.ChatEnableFancyBubbles, FancySpeechBubblesCheckBox.Pressed);
_cfg.SetCVar(CCVars.ChatFancyNameBackground, FancyNameBackgroundsCheckBox.Pressed);
_cfg.SetCVar(CCVars.ChatEnableColorName, EnableColorNameCheckBox.Pressed);
_cfg.SetCVar(CCVars.ReducedMotion, ReducedMotionCheckBox.Pressed);
_cfg.SetCVar(CCVars.ScreenShakeIntensity, ScreenShakeIntensitySlider.Value / 100f);
// _cfg.SetCVar(CCVars.ToggleWalk, ToggleWalk.Pressed);
Expand All @@ -145,6 +148,7 @@ private void UpdateApplyButton()
var isLoocShowSame = ShowLoocAboveHeadCheckBox.Pressed == _cfg.GetCVar(CCVars.LoocAboveHeadShow);
var isFancyChatSame = FancySpeechBubblesCheckBox.Pressed == _cfg.GetCVar(CCVars.ChatEnableFancyBubbles);
var isFancyBackgroundSame = FancyNameBackgroundsCheckBox.Pressed == _cfg.GetCVar(CCVars.ChatFancyNameBackground);
var isEnableColorNameSame = EnableColorNameCheckBox.Pressed == _cfg.GetCVar(CCVars.ChatEnableColorName);
var isReducedMotionSame = ReducedMotionCheckBox.Pressed == _cfg.GetCVar(CCVars.ReducedMotion);
var isScreenShakeIntensitySame = Math.Abs(ScreenShakeIntensitySlider.Value / 100f - _cfg.GetCVar(CCVars.ScreenShakeIntensity)) < 0.01f;
// var isToggleWalkSame = ToggleWalk.Pressed == _cfg.GetCVar(CCVars.ToggleWalk);
Expand All @@ -159,6 +163,7 @@ private void UpdateApplyButton()
isLoocShowSame &&
isFancyChatSame &&
isFancyBackgroundSame &&
isEnableColorNameSame &&
isReducedMotionSame &&
isScreenShakeIntensitySame &&
// isToggleWalkSame &&
Expand Down
81 changes: 8 additions & 73 deletions Content.Client/Popups/PopupOverlay.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using System.Numerics;
using Content.Client.Examine;
using Content.Shared.CCVar;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Content.Shared.Popups;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Shared;
using Robust.Shared.Configuration;
Expand All @@ -26,11 +20,9 @@ public sealed class PopupOverlay : Overlay
private readonly IPlayerManager _playerMgr;
private readonly IUserInterfaceManager _uiManager;
private readonly PopupSystem _popup;
private readonly PopupUIController _controller;

private readonly ShaderInstance _shader;
private readonly Font _smallFont;
private readonly Font _mediumFont;
private readonly Font _largeFont;

public override OverlaySpace Space => OverlaySpace.ScreenSpace;

Expand All @@ -39,20 +31,18 @@ public PopupOverlay(
IEntityManager entManager,
IPlayerManager playerMgr,
IPrototypeManager protoManager,
IResourceCache cache,
IUserInterfaceManager uiManager,
PopupUIController controller,
PopupSystem popup)
{
_configManager = configManager;
_entManager = entManager;
_playerMgr = playerMgr;
_uiManager = uiManager;
_popup = popup;
_controller = controller;

_shader = protoManager.Index<ShaderPrototype>("unshaded").Instance();
_smallFont = new VectorFont(cache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Italic.ttf"), 10);
_mediumFont = new VectorFont(cache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Italic.ttf"), 12);
_largeFont = new VectorFont(cache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-BoldItalic.ttf"), 14);
}

protected override void Draw(in OverlayDrawArgs args)
Expand All @@ -68,19 +58,18 @@ protected override void Draw(in OverlayDrawArgs args)
scale = _uiManager.DefaultUIScale;

DrawWorld(args.ScreenHandle, args, scale);
DrawScreen(args.ScreenHandle, args, scale);

args.DrawingHandle.UseShader(null);
}

private void DrawWorld(DrawingHandleScreen worldHandle, OverlayDrawArgs args, float scale)
{
if (_popup.WorldLabels.Count == 0)
if (_popup.WorldLabels.Count == 0 || args.ViewportControl == null)
return;

var matrix = args.ViewportControl!.GetWorldToScreenMatrix();
var matrix = args.ViewportControl.GetWorldToScreenMatrix();
var viewPos = new MapCoordinates(args.WorldAABB.Center, args.MapId);
var ourEntity = _playerMgr.LocalPlayer?.ControlledEntity;
var ourEntity = _playerMgr.LocalEntity;

foreach (var popup in _popup.WorldLabels)
{
Expand All @@ -92,66 +81,12 @@ private void DrawWorld(DrawingHandleScreen worldHandle, OverlayDrawArgs args, fl
var distance = (mapPos.Position - args.WorldBounds.Center).Length();

// Should handle fade here too wyci.
if (!args.WorldAABB.Contains(mapPos.Position) || !ExamineSystemShared.InRangeUnOccluded(viewPos, mapPos, distance,
if (!args.WorldBounds.Contains(mapPos.Position) || !ExamineSystemShared.InRangeUnOccluded(viewPos, mapPos, distance,
e => e == popup.InitialPos.EntityId || e == ourEntity, entMan: _entManager))
continue;

var pos = matrix.Transform(mapPos.Position);
DrawPopup(popup, worldHandle, pos, scale);
_controller.DrawPopup(popup, worldHandle, pos, scale);
}
}

private void DrawScreen(DrawingHandleScreen screenHandle, OverlayDrawArgs args, float scale)
{
foreach (var popup in _popup.CursorLabels)
{
// Different window
if (popup.InitialPos.Window != args.ViewportControl?.Window?.Id)
continue;

DrawPopup(popup, screenHandle, popup.InitialPos.Position, scale);
}
}

private void DrawPopup(PopupSystem.PopupLabel popup, DrawingHandleScreen handle, Vector2 position, float scale)
{
var lifetime = PopupSystem.GetPopupLifetime(popup);

// Keep alpha at 1 until TotalTime passes half its lifetime, then gradually decrease to 0.
var alpha = MathF.Min(1f, 1f - MathF.Max(0f, popup.TotalTime - lifetime / 2) * 2 / lifetime);

var updatedPosition = position - new Vector2(0f, MathF.Min(8f, 12f * (popup.TotalTime * popup.TotalTime + popup.TotalTime)));
var font = _smallFont;
var color = Color.White.WithAlpha(alpha);

switch (popup.Type)
{
case PopupType.SmallCaution:
color = Color.Red;
break;
case PopupType.Medium:
font = _mediumFont;
color = Color.LightGray;
break;
case PopupType.MediumCaution:
font = _mediumFont;
color = Color.Red;
break;
case PopupType.Large:
font = _largeFont;
color = Color.LightGray;
break;
case PopupType.LargeCaution:
font = _largeFont;
color = Color.Red;
break;
case PopupType.LargeGreen:
font = _largeFont;
color = Color.LightGreen;
break;
}

var dimensions = handle.GetDimensions(font, popup.Text, scale);
handle.DrawString(font, updatedPosition - dimensions / 2f, popup.Text, scale, color.WithAlpha(alpha));
}
}
10 changes: 8 additions & 2 deletions Content.Client/Popups/PopupSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public sealed class PopupSystem : SharedPopupSystem
[Dependency] private readonly IOverlayManager _overlay = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
[Dependency] private readonly IResourceCache _resource = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IUserInterfaceManager _uiManager = default!;
[Dependency] private readonly IReplayRecordingManager _replayRecording = default!;
Expand All @@ -45,7 +44,14 @@ public override void Initialize()
SubscribeNetworkEvent<PopupEntityEvent>(OnPopupEntityEvent);
SubscribeNetworkEvent<RoundRestartCleanupEvent>(OnRoundRestart);
_overlay
.AddOverlay(new PopupOverlay(_configManager, EntityManager, _playerManager, _prototype, _resource, _uiManager, this));
.AddOverlay(new PopupOverlay(
_configManager,
EntityManager,
_playerManager,
_prototype,
_uiManager,
_uiManager.GetUIController<PopupUIController>(),
this));
}

public override void Shutdown()
Expand Down
Loading

0 comments on commit ba5f444

Please sign in to comment.