diff --git a/.envrc b/.envrc index 5def8fd66a..7fd05db3e5 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/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 09c9e76b19..7ff9017cb0 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,7 +1,4 @@ contact_links: - name: Report a Security Vulnerability url: https://github.com/space-wizards/space-station-14/blob/master/SECURITY.md - about: Please report security vulnerabilities privately so we can fix them before they are publicly disclosed. - - name: Request a Feature - url: https://discord.gg/rGvu9hKffJ - about: Submit feature requests on our Discord server (https://discord.gg/rGvu9hKffJ). + about: Please report security vulnerabilities to the Space Wizards privately so they can fix them before they are publicly disclosed. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000000..aba549332f --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,27 @@ +--- +name: Request a Feature +about: "Template for noting future planned features. Please ask for approval in the Discord if you aren't an organization Member before posting a feature request" +title: '' +labels: '' +assignees: '' + +--- + + + +# Description + + +I want Goldfish crackers + +# Media + + +![Example Screenshot](https://example.com/thisimageisntreal.png) diff --git a/.github/ISSUE_TEMPLATE/issue_report.md b/.github/ISSUE_TEMPLATE/issue_report.md index f18221e055..ab82181197 100644 --- a/.github/ISSUE_TEMPLATE/issue_report.md +++ b/.github/ISSUE_TEMPLATE/issue_report.md @@ -1,32 +1,55 @@ --- name: Report an Issue -about: "..." +about: "Any general issues you have during play or with the codebase" title: '' labels: '' assignees: '' --- + + # Description +Description + # Reproduction -# Screenshots +1. Open game +2. Game doesn't open + +# Expected behavior +1. Open game +2. Game opens + +# Media + + +![Example Screenshot](https://example.com/thisimageisntreal.png) + # Additional context + +There's a ghost in my computer diff --git a/.github/ISSUE_TEMPLATE/toolshed-feature-request.md b/.github/ISSUE_TEMPLATE/toolshed-feature-request.md deleted file mode 100644 index dae84c3e25..0000000000 --- a/.github/ISSUE_TEMPLATE/toolshed-feature-request.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -name: Toolshed feature request -about: Suggest a feature for Toolshed (for game admins/developers) -title: "[TOOLSHED REQUEST]" -labels: Toolshed -assignees: moonheart08 - ---- - -**Is your feature request related to a problem/bug? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the command you'd like** -A clear and concise description of what you want and what it should do. -If you're a technical user (i.e. programmer) including type signatures is helpful. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index bb0ae5066a..5d3ce070bc 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,20 +1,46 @@ + + # Description + + Description. --- # TODO + + - [ ] Task - [x] Completed Task --- + +

Media

- +![Example Media Embed](https://example.com/thisimageisntreal.png)

@@ -23,10 +49,14 @@ Description. # Changelog - + :cl: -- add: Added fun! -- tweak: Tweaked fun! +- add: Added fun :D +- tweak: Tweaked fun - fix: Fixed fun! -- remove: Removed fun! +- remove: Removed fun :( diff --git a/.github/workflows/build-map-renderer.yml b/.github/workflows/build-map-renderer.yml index 01575f64b9..45c807b362 100644 --- a/.github/workflows/build-map-renderer.yml +++ b/.github/workflows/build-map-renderer.yml @@ -10,7 +10,7 @@ on: jobs: build: - if: github.actor != 'PJBot' && github.event.pull_request.draft == false && github.actor != 'DeltaV-Bot' + if: github.actor != 'PJBot' && github.event.pull_request.draft == false && github.actor != 'DeltaV-Bot' && github.actor != 'SimpleStation14' strategy: matrix: os: [ubuntu-latest] diff --git a/.github/workflows/build-test-debug.yml b/.github/workflows/build-test-debug.yml index 519f5af6f4..c3b766f8de 100644 --- a/.github/workflows/build-test-debug.yml +++ b/.github/workflows/build-test-debug.yml @@ -10,7 +10,7 @@ on: jobs: build: - if: github.actor != 'PJBot' && github.event.pull_request.draft == false && github.actor != 'DeltaV-Bot' + if: github.actor != 'PJBot' && github.event.pull_request.draft == false && github.actor != 'DeltaV-Bot' && github.actor != 'SimpleStation14' strategy: matrix: os: [ubuntu-latest] diff --git a/.github/workflows/conflict-labeler.yml b/.github/workflows/conflict-labeler.yml index a47965334c..152d3a9f3c 100644 --- a/.github/workflows/conflict-labeler.yml +++ b/.github/workflows/conflict-labeler.yml @@ -8,7 +8,7 @@ on: jobs: Label: - if: github.actor != 'PJBot' && github.actor != 'DeltaV-Bot' + if: github.actor != 'PJBot' && github.actor != 'DeltaV-Bot' && github.actor != 'SimpleStation14' runs-on: ubuntu-latest steps: - name: Check for Merge Conflicts diff --git a/.github/workflows/labeler-pr.yml b/.github/workflows/labeler-pr.yml index e1755aa26e..efb051f4cc 100644 --- a/.github/workflows/labeler-pr.yml +++ b/.github/workflows/labeler-pr.yml @@ -5,7 +5,7 @@ on: jobs: labeler: - if: github.actor != 'PJBot' && github.actor != 'DeltaV-Bot' + if: github.actor != 'PJBot' && github.actor != 'DeltaV-Bot' && github.actor != 'SimpleStation14' runs-on: ubuntu-latest steps: - uses: actions/labeler@v3 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 4ba70f3504..74a975be5c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -67,7 +67,7 @@ jobs: username: ${{ secrets.PUBLISH_USER }} key: ${{ secrets.PUBLISH_KEY }} port: ${{ secrets.PUBLISH_PORT }} - script: /home/${{ secrets.PUBLISH_USER }}/publish/push.ps1 ${{ github.sha }} + script: /home/deltav/publish/push.ps1 ${{ github.sha }} - name: Publish changelog (Discord) run: Tools/actions_changelogs_since_last_run.py diff --git a/.github/workflows/test-packaging.yml b/.github/workflows/test-packaging.yml index ccece69adb..b35a609220 100644 --- a/.github/workflows/test-packaging.yml +++ b/.github/workflows/test-packaging.yml @@ -29,7 +29,7 @@ on: jobs: build: name: Test Packaging - if: github.actor != 'PJBot' && github.event.pull_request.draft == false && github.actor != 'DeltaV-Bot' + if: github.actor != 'PJBot' && github.event.pull_request.draft == false && github.actor != 'DeltaV-Bot' && github.actor != 'SimpleStation14' runs-on: ubuntu-latest steps: diff --git a/.github/workflows/update-credits.yml b/.github/workflows/update-credits.yml index fb3508385e..69a8bc1988 100644 --- a/.github/workflows/update-credits.yml +++ b/.github/workflows/update-credits.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest # Hey there fork dev! If you like to include your own contributors in this then you can probably just change this to your own repo # Do this in dump_github_contributors.ps1 too into your own repo - if: github.repository == 'DeltaV-Station/Delta-v' + if: github.repository == 'Simple-Station/Einstein-Engines' steps: - uses: actions/checkout@v3.6.0 @@ -47,6 +47,6 @@ jobs: with: commit-message: Update Credits title: Update Credits - body: This is an automated Pull Request. This PR updates the github contributors in the credits section. - author: DeltaV-Bot + body: This is an automated Pull Request. This PR updates the GitHub contributors in the credits section. + author: ${{ vars.CHANGELOG_USER }} <${{ vars.CHANGELOG_EMAIL }}> branch: automated/credits-${{env.NOW}} diff --git a/.github/workflows/validate-rgas.yml b/.github/workflows/validate-rgas.yml index 0ed04021eb..72ce39ceff 100644 --- a/.github/workflows/validate-rgas.yml +++ b/.github/workflows/validate-rgas.yml @@ -9,7 +9,7 @@ on: jobs: yaml-schema-validation: name: YAML RGA schema validator - if: github.actor != 'PJBot' && github.event.pull_request.draft == false && github.actor != 'DeltaV-Bot' + if: github.actor != 'PJBot' && github.event.pull_request.draft == false && github.actor != 'DeltaV-Bot' && github.actor != 'SimpleStation14' runs-on: ubuntu-latest steps: - uses: actions/checkout@v3.6.0 diff --git a/.github/workflows/validate_mapfiles.yml b/.github/workflows/validate_mapfiles.yml index 43d77841a8..190ee97d8f 100644 --- a/.github/workflows/validate_mapfiles.yml +++ b/.github/workflows/validate_mapfiles.yml @@ -9,7 +9,7 @@ on: jobs: yaml-schema-validation: name: YAML map schema validator - if: github.actor != 'PJBot' && github.event.pull_request.draft == false && github.actor != 'DeltaV-Bot' + if: github.actor != 'PJBot' && github.event.pull_request.draft == false && github.actor != 'DeltaV-Bot' && github.actor != 'SimpleStation14' runs-on: ubuntu-latest steps: - uses: actions/checkout@v3.6.0 diff --git a/.github/workflows/yaml-linter.yml b/.github/workflows/yaml-linter.yml index 796795b234..f60945ae7c 100644 --- a/.github/workflows/yaml-linter.yml +++ b/.github/workflows/yaml-linter.yml @@ -10,7 +10,7 @@ on: jobs: build: name: YAML Linter - if: github.actor != 'PJBot' && github.event.pull_request.draft == false && github.actor != 'DeltaV-Bot' + if: github.actor != 'PJBot' && github.event.pull_request.draft == false && github.actor != 'DeltaV-Bot' && github.actor != 'SimpleStation14' runs-on: ubuntu-latest steps: - uses: actions/checkout@v3.6.0 diff --git a/Content.Benchmarks/ColorInterpolateBenchmark.cs b/Content.Benchmarks/ColorInterpolateBenchmark.cs index 2243bb4819..eb182328d4 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 16805c2684..bb2a22312e 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 0beb0a613d..42a436597d 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 508f3404ba..31d092b25d 100644 --- a/Content.Client/Actions/ActionsSystem.cs +++ b/Content.Client/Actions/ActionsSystem.cs @@ -1,6 +1,7 @@ using System.IO; using System.Linq; using Content.Shared.Actions; +using Content.Shared.Mapping; using JetBrains.Annotations; using Robust.Client.Player; using Robust.Shared.ContentPack; @@ -78,10 +79,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 +104,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 +113,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 +146,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 +179,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 +187,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 +195,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 +218,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 +235,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 +263,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(); @@ -310,6 +312,70 @@ public void LoadActionAssignments(string path, bool userData) AssignSlot?.Invoke(assignments); } + /// + /// Load actions and their toolbar assignments from a file. + /// DeltaV - Load from an existing yaml stream instead + /// + public void LoadActionAssignments(YamlStream stream) + { + if (_playerManager.LocalEntity is not { } user) + return; + + if (stream.Documents[0].RootNode.ToDataNode() is not SequenceDataNode sequence) + return; + + ClearAssignments?.Invoke(); + + var assignments = new List(); + var existingActions = GetClientActions(); + var existingActionsList = existingActions.ToList(); + + foreach (var entry in sequence.Sequence) + { + if (entry is not MappingDataNode map) + continue; + + if (!map.TryGet("action", out var actionNode)) + continue; + + if (!map.TryGet("name", out var nameNode)) + continue; + + var action = _serialization.Read(actionNode, notNullableOverride: true); + + // Prevent spawning actions multiple times + var existing = existingActionsList.FirstOrNull(a => + Name(a.Id) == nameNode.Value); + + EntityUid actionId; + if (existing == null) + { + actionId = Spawn(null); + AddComp(actionId, action); + _metaData.SetEntityName(actionId, nameNode.Value); + DirtyEntity(actionId); + AddActionDirect(user, actionId); + } + else + { + actionId = existing.Value.Id; + } + + if (!map.TryGet("assignments", out var assignmentNode)) + continue; + + var nodeAssignments = _serialization.Read>(assignmentNode, notNullableOverride: true); + + foreach (var index in nodeAssignments) + { + var assignment = new SlotAssignment(index.Hotbar, index.Slot, actionId); + assignments.Add(assignment); + } + } + + AssignSlot?.Invoke(assignments); + } + public record struct SlotAssignment(byte Hotbar, byte Slot, EntityUid ActionId); } } diff --git a/Content.Client/Administration/Managers/ClientAdminManager.cs b/Content.Client/Administration/Managers/ClientAdminManager.cs index 1a1366c6f2..fdd62fb6a2 100644 --- a/Content.Client/Administration/Managers/ClientAdminManager.cs +++ b/Content.Client/Administration/Managers/ClientAdminManager.cs @@ -2,6 +2,7 @@ using Content.Shared.Administration.Managers; using Robust.Client.Console; using Robust.Client.Player; +using Robust.Client.UserInterface; using Robust.Shared.ContentPack; using Robust.Shared.Network; using Robust.Shared.Player; @@ -15,11 +16,14 @@ 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!; + [Dependency] private readonly IUserInterfaceManager _userInterface = default!; private AdminData? _adminData; private readonly HashSet _availableCommands = new(); private readonly AdminCommandPermissions _localCommandPermissions = new(); + private ISawmill _sawmill = default!; public event Action? AdminStatusUpdated; @@ -92,17 +96,20 @@ 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}"); + + if (_adminData.Active) + _userInterface.DebugMonitors.SetMonitor(DebugMonitor.Coords, true); } else { - Logger.InfoS("admin", "Updated admin status: Not admin"); + _sawmill.Info("Updated admin status: Not admin"); } AdminStatusUpdated?.Invoke(); @@ -114,18 +121,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 +139,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 eafd40cc9c..5166dc8416 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 e5269c027a..39ea50edbe 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 b3cbf0cf2c..0000000000 --- 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 0000000000..80eca82e32 --- /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 0000000000..64932bc6cf --- /dev/null +++ b/Content.Client/MassMedia/Ui/NewsWriterMenu.xaml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + +