diff --git a/.envrc b/.envrc index 5def8fd66a2752..7fd05db3e5ee2c 100644 --- a/.envrc +++ b/.envrc @@ -1,4 +1,4 @@ -if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then - source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8=" +if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4=" fi use flake diff --git a/Content.Benchmarks/ColorInterpolateBenchmark.cs b/Content.Benchmarks/ColorInterpolateBenchmark.cs index 2243bb4819ed3b..eb182328d466b5 100644 --- a/Content.Benchmarks/ColorInterpolateBenchmark.cs +++ b/Content.Benchmarks/ColorInterpolateBenchmark.cs @@ -131,8 +131,8 @@ public static Color InterpolateSysVector4(Color a, Color b, public static Color InterpolateSysVector4In(in Color endPoint1, in Color endPoint2, float lambda) { - ref var sva = ref Unsafe.As(ref Unsafe.AsRef(endPoint1)); - ref var svb = ref Unsafe.As(ref Unsafe.AsRef(endPoint2)); + ref var sva = ref Unsafe.As(ref Unsafe.AsRef(in endPoint1)); + ref var svb = ref Unsafe.As(ref Unsafe.AsRef(in endPoint2)); var res = SysVector4.Lerp(svb, sva, lambda); @@ -156,8 +156,8 @@ public static Color InterpolateSimd(Color a, Color b, public static Color InterpolateSimdIn(in Color a, in Color b, float lambda) { - var vecA = Unsafe.As>(ref Unsafe.AsRef(a)); - var vecB = Unsafe.As>(ref Unsafe.AsRef(b)); + var vecA = Unsafe.As>(ref Unsafe.AsRef(in a)); + var vecB = Unsafe.As>(ref Unsafe.AsRef(in b)); vecB = Fma.MultiplyAdd(Sse.Subtract(vecB, vecA), Vector128.Create(lambda), vecA); diff --git a/Content.Benchmarks/DeviceNetworkingBenchmark.cs b/Content.Benchmarks/DeviceNetworkingBenchmark.cs index 16805c2684f25e..bb2a22312ea82c 100644 --- a/Content.Benchmarks/DeviceNetworkingBenchmark.cs +++ b/Content.Benchmarks/DeviceNetworkingBenchmark.cs @@ -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; diff --git a/Content.Benchmarks/Program.cs b/Content.Benchmarks/Program.cs index 0beb0a613d5ed3..42a436597d5259 100644 --- a/Content.Benchmarks/Program.cs +++ b/Content.Benchmarks/Program.cs @@ -18,11 +18,6 @@ internal static class Program public static void Main(string[] args) { - MainAsync(args).GetAwaiter().GetResult(); - } - - public static async Task MainAsync(string[] args) - { #if DEBUG Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("\nWARNING: YOU ARE RUNNING A DEBUG BUILD, USE A RELEASE BUILD FOR AN ACCURATE BENCHMARK"); diff --git a/Content.Client/Actions/ActionsSystem.cs b/Content.Client/Actions/ActionsSystem.cs index 508f3404bac626..4eaf06b691e135 100644 --- a/Content.Client/Actions/ActionsSystem.cs +++ b/Content.Client/Actions/ActionsSystem.cs @@ -78,10 +78,12 @@ private void OnWorldTargetHandleState(EntityUid uid, WorldTargetActionComponent private void BaseHandleState(EntityUid uid, BaseActionComponent component, BaseActionComponentState state) where T : BaseActionComponent { + // TODO ACTIONS use auto comp states component.Icon = state.Icon; component.IconOn = state.IconOn; component.IconColor = state.IconColor; - component.Keywords = new HashSet(state.Keywords); + component.Keywords.Clear(); + component.Keywords.UnionWith(state.Keywords); component.Enabled = state.Enabled; component.Toggled = state.Toggled; component.Cooldown = state.Cooldown; @@ -101,8 +103,7 @@ private void BaseHandleState(EntityUid uid, BaseActionComponent component, Ba component.ItemIconStyle = state.ItemIconStyle; component.Sound = state.Sound; - if (_playerManager.LocalPlayer?.ControlledEntity == component.AttachedEntity) - ActionsUpdated?.Invoke(); + UpdateAction(uid, component); } protected override void UpdateAction(EntityUid? actionId, BaseActionComponent? action = null) @@ -111,7 +112,7 @@ protected override void UpdateAction(EntityUid? actionId, BaseActionComponent? a return; base.UpdateAction(actionId, action); - if (_playerManager.LocalPlayer?.ControlledEntity != action.AttachedEntity) + if (_playerManager.LocalEntity != action.AttachedEntity) return; ActionsUpdated?.Invoke(); @@ -144,7 +145,7 @@ private void HandleComponentState(EntityUid uid, ActionsComponent component, ref _added.Add((actionId, action)); } - if (_playerManager.LocalPlayer?.ControlledEntity != uid) + if (_playerManager.LocalEntity != uid) return; foreach (var action in _removed) @@ -177,7 +178,7 @@ public static int ActionComparer((EntityUid, BaseActionComponent?) a, (EntityUid protected override void ActionAdded(EntityUid performer, EntityUid actionId, ActionsComponent comp, BaseActionComponent action) { - if (_playerManager.LocalPlayer?.ControlledEntity != performer) + if (_playerManager.LocalEntity != performer) return; OnActionAdded?.Invoke(actionId); @@ -185,7 +186,7 @@ protected override void ActionAdded(EntityUid performer, EntityUid actionId, Act protected override void ActionRemoved(EntityUid performer, EntityUid actionId, ActionsComponent comp, BaseActionComponent action) { - if (_playerManager.LocalPlayer?.ControlledEntity != performer) + if (_playerManager.LocalEntity != performer) return; OnActionRemoved?.Invoke(actionId); @@ -193,7 +194,7 @@ protected override void ActionRemoved(EntityUid performer, EntityUid actionId, A public IEnumerable<(EntityUid Id, BaseActionComponent Comp)> GetClientActions() { - if (_playerManager.LocalPlayer?.ControlledEntity is not { } user) + if (_playerManager.LocalEntity is not { } user) return Enumerable.Empty<(EntityUid, BaseActionComponent)>(); return GetActions(user); @@ -216,7 +217,7 @@ public void UnlinkAllActions() public void LinkAllActions(ActionsComponent? actions = null) { - if (_playerManager.LocalPlayer?.ControlledEntity is not { } user || + if (_playerManager.LocalEntity is not { } user || !Resolve(user, ref actions, false)) { return; @@ -233,7 +234,7 @@ public override void Shutdown() public void TriggerAction(EntityUid actionId, BaseActionComponent action) { - if (_playerManager.LocalPlayer?.ControlledEntity is not { } user || + if (_playerManager.LocalEntity is not { } user || !TryComp(user, out ActionsComponent? actions)) { return; @@ -261,7 +262,7 @@ public void TriggerAction(EntityUid actionId, BaseActionComponent action) /// public void LoadActionAssignments(string path, bool userData) { - if (_playerManager.LocalPlayer?.ControlledEntity is not { } user) + if (_playerManager.LocalEntity is not { } user) return; var file = new ResPath(path).ToRootedPath(); diff --git a/Content.Client/Administration/Managers/ClientAdminManager.cs b/Content.Client/Administration/Managers/ClientAdminManager.cs index 1a1366c6f2ebad..d33761be8f237d 100644 --- a/Content.Client/Administration/Managers/ClientAdminManager.cs +++ b/Content.Client/Administration/Managers/ClientAdminManager.cs @@ -15,11 +15,13 @@ public sealed class ClientAdminManager : IClientAdminManager, IClientConGroupImp [Dependency] private readonly IClientNetManager _netMgr = default!; [Dependency] private readonly IClientConGroupController _conGroup = default!; [Dependency] private readonly IResourceManager _res = default!; + [Dependency] private readonly ILogManager _logManager = default!; private AdminData? _adminData; private readonly HashSet _availableCommands = new(); private readonly AdminCommandPermissions _localCommandPermissions = new(); + private ISawmill _sawmill = default!; public event Action? AdminStatusUpdated; @@ -92,17 +94,17 @@ private void UpdateMessageRx(MsgUpdateAdminStatus message) } _availableCommands.UnionWith(message.AvailableCommands); - Logger.DebugS("admin", $"Have {message.AvailableCommands.Length} commands available"); + _sawmill.Debug($"Have {message.AvailableCommands.Length} commands available"); _adminData = message.Admin; if (_adminData != null) { var flagsText = string.Join("|", AdminFlagsHelper.FlagsToNames(_adminData.Flags)); - Logger.InfoS("admin", $"Updated admin status: {_adminData.Active}/{_adminData.Title}/{flagsText}"); + _sawmill.Info($"Updated admin status: {_adminData.Active}/{_adminData.Title}/{flagsText}"); } else { - Logger.InfoS("admin", "Updated admin status: Not admin"); + _sawmill.Info("Updated admin status: Not admin"); } AdminStatusUpdated?.Invoke(); @@ -114,18 +116,17 @@ private void UpdateMessageRx(MsgUpdateAdminStatus message) void IPostInjectInit.PostInject() { _conGroup.Implementation = this; + _sawmill = _logManager.GetSawmill("admin"); } public AdminData? GetAdminData(EntityUid uid, bool includeDeAdmin = false) { - return uid == _player.LocalPlayer?.ControlledEntity - ? _adminData - : null; + return uid == _player.LocalEntity ? _adminData : null; } public AdminData? GetAdminData(ICommonSession session, bool includeDeAdmin = false) { - if (_player.LocalPlayer?.UserId == session.UserId) + if (_player.LocalUser == session.UserId) return _adminData; return null; @@ -133,7 +134,7 @@ void IPostInjectInit.PostInject() public AdminData? GetAdminData(bool includeDeAdmin = false) { - if (_player.LocalPlayer is { Session: { } session }) + if (_player.LocalSession is { } session) return GetAdminData(session, includeDeAdmin); return null; diff --git a/Content.Client/Administration/Systems/BwoinkSystem.cs b/Content.Client/Administration/Systems/BwoinkSystem.cs index eafd40cc9c317a..5166dc8416babe 100644 --- a/Content.Client/Administration/Systems/BwoinkSystem.cs +++ b/Content.Client/Administration/Systems/BwoinkSystem.cs @@ -19,11 +19,11 @@ protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySes OnBwoinkTextMessageRecieved?.Invoke(this, message); } - public void Send(NetUserId channelId, string text) + public void Send(NetUserId channelId, string text, bool playSound) { // Reuse the channel ID as the 'true sender'. // Server will ignore this and if someone makes it not ignore this (which is bad, allows impersonation!!!), that will help. - RaiseNetworkEvent(new BwoinkTextMessage(channelId, channelId, text)); + RaiseNetworkEvent(new BwoinkTextMessage(channelId, channelId, text, playSound: playSound)); SendInputTextUpdated(channelId, false); } diff --git a/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml b/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml index e5269c027a9dce..39ea50edbef02f 100644 --- a/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml +++ b/Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml @@ -7,6 +7,8 @@ + + - - - diff --git a/Content.Client/MassMedia/Ui/NewsWriteMenu.xaml.cs b/Content.Client/MassMedia/Ui/NewsWriteMenu.xaml.cs deleted file mode 100644 index b3cbf0cf2c2d0f..00000000000000 --- a/Content.Client/MassMedia/Ui/NewsWriteMenu.xaml.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Robust.Client.AutoGenerated; -using Robust.Client.UserInterface.CustomControls; -using Robust.Client.UserInterface.XAML; -using Robust.Shared.Prototypes; -using Content.Shared.MassMedia.Systems; - -namespace Content.Client.MassMedia.Ui; - -[GenerateTypedNameReferences] -public sealed partial class NewsWriteMenu : DefaultWindow -{ - public event Action? ShareButtonPressed; - public event Action? DeleteButtonPressed; - - public NewsWriteMenu(string name) - { - RobustXamlLoader.Load(this); - IoCManager.InjectDependencies(this); - - if (Window != null) - Window.Title = name; - - Share.OnPressed += _ => ShareButtonPressed?.Invoke(); - } - - public void UpdateUI(NewsArticle[] articles, bool shareAvalible) - { - ArticleCardsContainer.Children.Clear(); - - for (int i = 0; i < articles.Length; i++) - { - var article = articles[i]; - var mini = new MiniArticleCardControl(article.Name, (article.Author != null ? article.Author : Loc.GetString("news-read-ui-no-author"))); - mini.ArtcileNum = i; - mini.OnDeletePressed += () => DeleteButtonPressed?.Invoke(mini.ArtcileNum); - - ArticleCardsContainer.AddChild(mini); - } - - Share.Disabled = !shareAvalible; - } -} diff --git a/Content.Client/MassMedia/Ui/NewsWriterBoundUserInterface.cs b/Content.Client/MassMedia/Ui/NewsWriterBoundUserInterface.cs new file mode 100644 index 00000000000000..80eca82e324c5d --- /dev/null +++ b/Content.Client/MassMedia/Ui/NewsWriterBoundUserInterface.cs @@ -0,0 +1,84 @@ +using JetBrains.Annotations; +using Content.Shared.MassMedia.Systems; +using Content.Shared.MassMedia.Components; +using Robust.Shared.Timing; +using Robust.Shared.Utility; + +namespace Content.Client.MassMedia.Ui; + +[UsedImplicitly] +public sealed class NewsWriterBoundUserInterface : BoundUserInterface +{ + [Dependency] private readonly IGameTiming _gameTiming = default!; + + [ViewVariables] + private NewsWriterMenu? _menu; + + public NewsWriterBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) + { + + } + + protected override void Open() + { + _menu = new NewsWriterMenu(_gameTiming); + + _menu.OpenCentered(); + _menu.OnClose += Close; + + _menu.ArticleEditorPanel.PublishButtonPressed += OnPublishButtonPressed; + _menu.DeleteButtonPressed += OnDeleteButtonPressed; + + SendMessage(new NewsWriterArticlesRequestMessage()); + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + if (!disposing) + return; + + _menu?.Close(); + _menu?.Dispose(); + } + + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + if (state is not NewsWriterBoundUserInterfaceState cast) + return; + + _menu?.UpdateUI(cast.Articles, cast.PublishEnabled, cast.NextPublish); + } + + private void OnPublishButtonPressed() + { + var title = _menu?.ArticleEditorPanel.TitleField.Text.Trim() ?? ""; + if (_menu == null || title.Length == 0) + return; + + var stringContent = Rope.Collapse(_menu.ArticleEditorPanel.ContentField.TextRope).Trim(); + + if (stringContent.Length == 0) + return; + + var name = title.Length <= SharedNewsSystem.MaxTitleLength + ? title + : $"{title[..(SharedNewsSystem.MaxTitleLength - 3)]}..."; + + var content = stringContent.Length <= SharedNewsSystem.MaxContentLength + ? stringContent + : $"{stringContent[..(SharedNewsSystem.MaxContentLength - 3)]}..."; + + + SendMessage(new NewsWriterPublishMessage(name, content)); + } + + private void OnDeleteButtonPressed(int articleNum) + { + if (_menu == null) + return; + + SendMessage(new NewsWriterDeleteMessage(articleNum)); + } +} diff --git a/Content.Client/MassMedia/Ui/NewsWriterMenu.xaml b/Content.Client/MassMedia/Ui/NewsWriterMenu.xaml new file mode 100644 index 00000000000000..64932bc6cfeebb --- /dev/null +++ b/Content.Client/MassMedia/Ui/NewsWriterMenu.xaml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + +