diff --git a/.editorconfig b/.editorconfig index 58d0d332bb..3e44d1a281 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,9 +9,10 @@ indent_style = space tab_width = 4 # New line preferences -end_of_line = crlf:suggestion +#end_of_line = crlf insert_final_newline = true trim_trailing_whitespace = true +max_line_length = 120 #### .NET Coding Conventions #### @@ -104,7 +105,6 @@ csharp_preferred_modifier_order = public, private, protected, internal, new, abs # 'using' directive preferences csharp_using_directive_placement = outside_namespace:silent -csharp_style_namespace_declarations = file_scoped:suggestion #### C# Formatting Rules #### @@ -337,7 +337,11 @@ dotnet_naming_symbols.type_parameters_symbols.applicable_kinds = type_parameter # ReSharper properties resharper_braces_for_ifelse = required_for_multiline +resharper_csharp_wrap_arguments_style = chop_if_long +resharper_csharp_wrap_parameters_style = chop_if_long resharper_keep_existing_attribute_arrangement = true +resharper_wrap_chained_binary_patterns = chop_if_long +resharper_wrap_chained_method_calls = chop_if_long [*.{csproj,xml,yml,yaml,dll.config,msbuildproj,targets,props}] indent_size = 2 diff --git a/.github/labeler.yml b/.github/labeler.yml index eb01eeecc4..6b87aa2655 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -1,39 +1,56 @@ "Changes: Audio": - - "**/*.ogg" - + - changed-files: + - any-glob-to-any-file: "**/*.ogg" + "Changes: C#": - - "**/*.cs" + - changed-files: + - any-glob-to-any-file: "**/*.cs" "Changes: Config": - - "**/*.toml" - - "**/*.config" - - "*.json" - - ".github/*.yml" - - ".github/*.json" - - ".vscode/*.json" - - ".editorconfig" +- changed-files: + - any-glob-to-any-file: + - "**/*.toml" + - "**/*.config" + - "*.json" + - ".github/*.yml" + - ".github/*.json" + - ".vscode/*.json" + - ".editorconfig" "Changes: Documentation": - - "**/*.xml" - - "**/*.md" + - changed-files: + - any-glob-to-any-file: + - "**/*.xml" + - "**/*.md" "Changes: Localization": -- 'Resources/Locale/**/*.ftl' + - changed-files: + - any-glob-to-any-file: 'Resources/Locale/**/*.ftl' "Changes: Map": - - "Resources/Maps/**/*.yml" - - "Resources/Prototypes/Maps/**/*.yml" + - changed-files: + - any-glob-to-any-file: + - "Resources/Maps/**/*.yml" + - "Resources/Prototypes/Maps/**/*.yml" "Changes: Sprite": - - "**/*.rsi/*.png" - - "**/*.rsi/*.json" + - changed-files: + - any-glob-to-any-file: + - "**/*.rsi/*.png" + - "**/*.rsi/*.json" "Changes: UI": - - "**/*.xaml*" + - changed-files: + - any-glob-to-any-file: "**/*.xaml*" "Changes: YML": - - any: ["**/*.yml"] - all: ["!Resources/Maps/**/*.yml", "!Resources/Prototypes/Maps/**/*.yml"] + - changed-files: + - any-glob-to-any-file: + - "**/*.yml" + - all-globs-to-all-files: + - "!Resources/Maps/**/*.yml", + - "!Resources/Prototypes/Maps/**/*.yml" "Changes: Workflow": - - ".github/workflows/*.yml" + - changed-files: + - any-glob-to-any-file: ".github/workflows/*.yml" diff --git a/.github/workflows/conflict-labeler.yml b/.github/workflows/conflict-labeler.yml index 152d3a9f3c..1bba677022 100644 --- a/.github/workflows/conflict-labeler.yml +++ b/.github/workflows/conflict-labeler.yml @@ -1,18 +1,20 @@ name: Check Merge Conflicts on: - push: - branches: - - master pull_request_target: + types: + - opened + - synchronize + - reopened + - ready_for_review jobs: Label: - if: github.actor != 'PJBot' && github.actor != 'DeltaV-Bot' && github.actor != 'SimpleStation14' + if: ( github.event.pull_request.draft == false ) && ( github.actor != 'PJBot' && github.actor != 'DeltaV-Bot' && github.actor != 'SimpleStation14' ) runs-on: ubuntu-latest steps: - name: Check for Merge Conflicts - uses: ike709/actions-label-merge-conflict@9eefdd17e10566023c46d2dc6dc04fcb8ec76142 + uses: eps1lon/actions-label-merge-conflict@v3.0.0 with: dirtyLabel: "Status: Merge Conflict" repoToken: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/labeler-pr.yml b/.github/workflows/labeler-pr.yml index efb051f4cc..2fd754b15e 100644 --- a/.github/workflows/labeler-pr.yml +++ b/.github/workflows/labeler-pr.yml @@ -6,8 +6,9 @@ on: jobs: labeler: if: github.actor != 'PJBot' && github.actor != 'DeltaV-Bot' && github.actor != 'SimpleStation14' + permissions: + contents: read + pull-requests: write runs-on: ubuntu-latest steps: - - uses: actions/labeler@v3 - with: - repo-token: "${{ secrets.GITHUB_TOKEN }}" + - uses: actions/labeler@v5 diff --git a/Content.Client/Access/IdCardSystem.cs b/Content.Client/Access/IdCardSystem.cs index fcf2bf57de..e0c02976f7 100644 --- a/Content.Client/Access/IdCardSystem.cs +++ b/Content.Client/Access/IdCardSystem.cs @@ -2,6 +2,4 @@ namespace Content.Client.Access; -public sealed class IdCardSystem : SharedIdCardSystem -{ -} +public sealed class IdCardSystem : SharedIdCardSystem; diff --git a/Content.Client/Access/UI/AgentIDCardBoundUserInterface.cs b/Content.Client/Access/UI/AgentIDCardBoundUserInterface.cs index 73f18aec8d..c3fac8cb92 100644 --- a/Content.Client/Access/UI/AgentIDCardBoundUserInterface.cs +++ b/Content.Client/Access/UI/AgentIDCardBoundUserInterface.cs @@ -40,9 +40,9 @@ private void OnJobChanged(string newJob) SendMessage(new AgentIDCardJobChangedMessage(newJob)); } - public void OnJobIconChanged(string newJobIcon) + public void OnJobIconChanged(string newJobIconId) { - SendMessage(new AgentIDCardJobIconChangedMessage(newJobIcon)); + SendMessage(new AgentIDCardJobIconChangedMessage(newJobIconId)); } /// @@ -57,7 +57,7 @@ protected override void UpdateState(BoundUserInterfaceState state) _window.SetCurrentName(cast.CurrentName); _window.SetCurrentJob(cast.CurrentJob); - _window.SetAllowedIcons(cast.Icons); + _window.SetAllowedIcons(cast.Icons, cast.CurrentJobIconId); } protected override void Dispose(bool disposing) diff --git a/Content.Client/Access/UI/AgentIDCardWindow.xaml.cs b/Content.Client/Access/UI/AgentIDCardWindow.xaml.cs index beca0c41ba..9a38c0c485 100644 --- a/Content.Client/Access/UI/AgentIDCardWindow.xaml.cs +++ b/Content.Client/Access/UI/AgentIDCardWindow.xaml.cs @@ -38,7 +38,7 @@ public AgentIDCardWindow(AgentIDCardBoundUserInterface bui) JobLineEdit.OnFocusExit += e => OnJobChanged?.Invoke(e.Text); } - public void SetAllowedIcons(HashSet icons) + public void SetAllowedIcons(HashSet icons, string currentJobIconId) { IconGrid.DisposeAllChildren(); @@ -79,6 +79,10 @@ public void SetAllowedIcons(HashSet icons) jobIconButton.AddChild(jobIconTexture); jobIconButton.OnPressed += _ => _bui.OnJobIconChanged(jobIcon.ID); IconGrid.AddChild(jobIconButton); + + if (jobIconId.Equals(currentJobIconId)) + jobIconButton.Pressed = true; + i++; } } diff --git a/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs b/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs index 5b7011c195..a321b4121e 100644 --- a/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs +++ b/Content.Client/Access/UI/IdCardConsoleBoundUserInterface.cs @@ -1,6 +1,5 @@ using Content.Shared.Access; using Content.Shared.Access.Components; -using Content.Shared.Access; using Content.Shared.Access.Systems; using Content.Shared.Containers.ItemSlots; using Content.Shared.CrewManifest; diff --git a/Content.Client/Actions/ActionsSystem.cs b/Content.Client/Actions/ActionsSystem.cs index 90158ba81e..0bc65eb935 100644 --- a/Content.Client/Actions/ActionsSystem.cs +++ b/Content.Client/Actions/ActionsSystem.cs @@ -249,7 +249,10 @@ public void TriggerAction(EntityUid actionId, BaseActionComponent action) if (action.ClientExclusive) { if (instantAction.Event != null) + { instantAction.Event.Performer = user; + instantAction.Event.Action = actionId; + } PerformAction(user, actions, actionId, instantAction, instantAction.Event, GameTiming.CurTime); } diff --git a/Content.Client/Administration/Components/HeadstandComponent.cs b/Content.Client/Administration/Components/HeadstandComponent.cs index d95e74576b..a4e3bfc5aa 100644 --- a/Content.Client/Administration/Components/HeadstandComponent.cs +++ b/Content.Client/Administration/Components/HeadstandComponent.cs @@ -3,7 +3,7 @@ namespace Content.Client.Administration.Components; -[RegisterComponent, NetworkedComponent] +[RegisterComponent] public sealed partial class HeadstandComponent : SharedHeadstandComponent { diff --git a/Content.Client/Administration/Components/KillSignComponent.cs b/Content.Client/Administration/Components/KillSignComponent.cs index 1cf47b93ff..91c44ef3f2 100644 --- a/Content.Client/Administration/Components/KillSignComponent.cs +++ b/Content.Client/Administration/Components/KillSignComponent.cs @@ -3,6 +3,5 @@ namespace Content.Client.Administration.Components; -[NetworkedComponent, RegisterComponent] -public sealed partial class KillSignComponent : SharedKillSignComponent -{ } +[RegisterComponent] +public sealed partial class KillSignComponent : SharedKillSignComponent; diff --git a/Content.Client/Administration/Managers/ClientAdminManager.cs b/Content.Client/Administration/Managers/ClientAdminManager.cs index fdd62fb6a2..0f740c8104 100644 --- a/Content.Client/Administration/Managers/ClientAdminManager.cs +++ b/Content.Client/Administration/Managers/ClientAdminManager.cs @@ -126,12 +126,15 @@ void IPostInjectInit.PostInject() public AdminData? GetAdminData(EntityUid uid, bool includeDeAdmin = false) { - return uid == _player.LocalEntity ? _adminData : null; + if (uid == _player.LocalEntity && (_adminData?.Active ?? includeDeAdmin)) + return _adminData; + + return null; } public AdminData? GetAdminData(ICommonSession session, bool includeDeAdmin = false) { - if (_player.LocalUser == session.UserId) + if (_player.LocalUser == session.UserId && (_adminData?.Active ?? includeDeAdmin)) return _adminData; return null; diff --git a/Content.Client/Administration/Systems/AdminVerbSystem.cs b/Content.Client/Administration/Systems/AdminVerbSystem.cs index e0f84bc4f0..dced59bbf2 100644 --- a/Content.Client/Administration/Systems/AdminVerbSystem.cs +++ b/Content.Client/Administration/Systems/AdminVerbSystem.cs @@ -1,3 +1,6 @@ +using Content.Shared.Administration; +using Content.Shared.Administration.Managers; +using Content.Shared.Mind.Components; using Content.Shared.Verbs; using Robust.Client.Console; using Robust.Shared.Utility; @@ -11,10 +14,12 @@ sealed class AdminVerbSystem : EntitySystem { [Dependency] private readonly IClientConGroupController _clientConGroupController = default!; [Dependency] private readonly IClientConsoleHost _clientConsoleHost = default!; + [Dependency] private readonly ISharedAdminManager _admin = default!; public override void Initialize() { SubscribeLocalEvent>(AddAdminVerbs); + } private void AddAdminVerbs(GetVerbsEvent args) @@ -33,6 +38,24 @@ private void AddAdminVerbs(GetVerbsEvent args) }; args.Verbs.Add(verb); } + + if (!_admin.IsAdmin(args.User)) + return; + + if (_admin.HasAdminFlag(args.User, AdminFlags.Admin)) + args.ExtraCategories.Add(VerbCategory.Admin); + + if (_admin.HasAdminFlag(args.User, AdminFlags.Fun) && HasComp(args.Target)) + args.ExtraCategories.Add(VerbCategory.Antag); + + if (_admin.HasAdminFlag(args.User, AdminFlags.Debug)) + args.ExtraCategories.Add(VerbCategory.Debug); + + if (_admin.HasAdminFlag(args.User, AdminFlags.Fun)) + args.ExtraCategories.Add(VerbCategory.Smite); + + if (_admin.HasAdminFlag(args.User, AdminFlags.Admin)) + args.ExtraCategories.Add(VerbCategory.Tricks); } } } diff --git a/Content.Client/Administration/UI/BanPanel/BanPanel.xaml.cs b/Content.Client/Administration/UI/BanPanel/BanPanel.xaml.cs index 1f32640f7d..dc263d6055 100644 --- a/Content.Client/Administration/UI/BanPanel/BanPanel.xaml.cs +++ b/Content.Client/Administration/UI/BanPanel/BanPanel.xaml.cs @@ -3,6 +3,7 @@ using System.Net.Sockets; using Content.Client.Administration.UI.CustomControls; using Content.Shared.Administration; +using Content.Shared.CCVar; using Content.Shared.Database; using Content.Shared.Roles; using Robust.Client.AutoGenerated; @@ -11,6 +12,7 @@ using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.XAML; +using Robust.Shared.Configuration; using Robust.Shared.Prototypes; using Robust.Shared.Timing; using Robust.Shared.Utility; @@ -32,8 +34,11 @@ public sealed partial class BanPanel : DefaultWindow // This is less efficient than just holding a reference to the root control and enumerating children, but you // have to know how the controls are nested, which makes the code more complicated. private readonly List _roleCheckboxes = new(); + private readonly ISawmill _banpanelSawmill; [Dependency] private readonly IGameTiming _gameTiming = default!; + [Dependency] private readonly IConfigurationManager _cfg = default!; + [Dependency] private readonly ILogManager _logManager = default!; private enum TabNumbers { @@ -65,6 +70,7 @@ public BanPanel() { RobustXamlLoader.Load(this); IoCManager.InjectDependencies(this); + _banpanelSawmill = _logManager.GetSawmill("admin.banpanel"); PlayerList.OnSelectionChanged += OnPlayerSelectionChanged; PlayerNameLine.OnFocusExit += _ => OnPlayerNameChanged(); PlayerCheckbox.OnPressed += _ => @@ -104,6 +110,11 @@ public BanPanel() }; SubmitButton.OnPressed += SubmitButtonOnOnPressed; + IpCheckbox.Pressed = _cfg.GetCVar(CCVars.ServerBanIpBanDefault); + HwidCheckbox.Pressed = _cfg.GetCVar(CCVars.ServerBanHwidBanDefault); + LastConnCheckbox.Pressed = _cfg.GetCVar(CCVars.ServerBanUseLastDetails); + EraseCheckbox.Pressed = _cfg.GetCVar(CCVars.ServerBanErasePlayer); + SeverityOption.AddItem(Loc.GetString("admin-note-editor-severity-none"), (int) NoteSeverity.None); SeverityOption.AddItem(Loc.GetString("admin-note-editor-severity-low"), (int) NoteSeverity.Minor); SeverityOption.AddItem(Loc.GetString("admin-note-editor-severity-medium"), (int) NoteSeverity.Medium); @@ -175,6 +186,39 @@ private void CreateRoleGroup(string roleName, IEnumerable roleList, Colo c.Pressed = args.Pressed; } } + + if (args.Pressed) + { + if (!Enum.TryParse(_cfg.GetCVar(CCVars.DepartmentBanDefaultSeverity), true, out NoteSeverity newSeverity)) + { + _banpanelSawmill + .Warning("Departmental role ban severity could not be parsed from config!"); + return; + } + SeverityOption.SelectId((int) newSeverity); + } + else + { + foreach (var childContainer in RolesContainer.Children) + { + if (childContainer is Container) + { + foreach (var child in childContainer.Children) + { + if (child is CheckBox { Pressed: true }) + return; + } + } + } + + if (!Enum.TryParse(_cfg.GetCVar(CCVars.RoleBanDefaultSeverity), true, out NoteSeverity newSeverity)) + { + _banpanelSawmill + .Warning("Role ban severity could not be parsed from config!"); + return; + } + SeverityOption.SelectId((int) newSeverity); + } }; outerContainer.AddChild(innerContainer); foreach (var role in roleList) @@ -353,6 +397,35 @@ private void OnTypeChanged() { TypeOption.ModulateSelfOverride = null; Tabs.SetTabVisible((int) TabNumbers.Roles, TypeOption.SelectedId == (int) Types.Role); + NoteSeverity? newSeverity = null; + switch (TypeOption.SelectedId) + { + case (int)Types.Server: + if (Enum.TryParse(_cfg.GetCVar(CCVars.ServerBanDefaultSeverity), true, out NoteSeverity serverSeverity)) + newSeverity = serverSeverity; + else + { + _banpanelSawmill + .Warning("Server ban severity could not be parsed from config!"); + } + + break; + case (int) Types.Role: + + if (Enum.TryParse(_cfg.GetCVar(CCVars.RoleBanDefaultSeverity), true, out NoteSeverity roleSeverity)) + { + newSeverity = roleSeverity; + } + else + { + _banpanelSawmill + .Warning("Role ban severity could not be parsed from config!"); + } + break; + } + + if (newSeverity != null) + SeverityOption.SelectId((int) newSeverity.Value); } private void UpdateSubmitEnabled() diff --git a/Content.Client/Animations/TrackUserComponent.cs b/Content.Client/Animations/TrackUserComponent.cs new file mode 100644 index 0000000000..374c187398 --- /dev/null +++ b/Content.Client/Animations/TrackUserComponent.cs @@ -0,0 +1,17 @@ +using System.Numerics; + +namespace Content.Client.Animations; + +/// +/// Entities with this component tracks the user's world position every frame. +/// +[RegisterComponent] +public sealed partial class TrackUserComponent : Component +{ + public EntityUid? User; + + /// + /// Offset in the direction of the entity's rotation. + /// + public Vector2 Offset = Vector2.Zero; +} diff --git a/Content.Client/Atmos/UI/GasAnalyzerWindow.xaml.cs b/Content.Client/Atmos/UI/GasAnalyzerWindow.xaml.cs index b105e629cf..b54af3a587 100644 --- a/Content.Client/Atmos/UI/GasAnalyzerWindow.xaml.cs +++ b/Content.Client/Atmos/UI/GasAnalyzerWindow.xaml.cs @@ -163,6 +163,26 @@ private void GenerateGasDisplay(GasMixEntry gasMix, Control parent) parent.AddChild(panel); panel.AddChild(dataContainer); + // Volume label + var volBox = new BoxContainer { Orientation = BoxContainer.LayoutOrientation.Horizontal }; + + volBox.AddChild(new Label + { + Text = Loc.GetString("gas-analyzer-window-volume-text") + }); + volBox.AddChild(new Control + { + MinSize = new Vector2(10, 0), + HorizontalExpand = true + }); + volBox.AddChild(new Label + { + Text = Loc.GetString("gas-analyzer-window-volume-val-text", ("volume", $"{gasMix.Volume:0.##}")), + Align = Label.AlignMode.Right, + HorizontalExpand = true + }); + dataContainer.AddChild(volBox); + // Pressure label var presBox = new BoxContainer { Orientation = BoxContainer.LayoutOrientation.Horizontal }; diff --git a/Content.Client/Audio/Jukebox/JukeboxBoundUserInterface.cs b/Content.Client/Audio/Jukebox/JukeboxBoundUserInterface.cs index 072730d65d..60fe339069 100644 --- a/Content.Client/Audio/Jukebox/JukeboxBoundUserInterface.cs +++ b/Content.Client/Audio/Jukebox/JukeboxBoundUserInterface.cs @@ -9,7 +9,6 @@ namespace Content.Client.Audio.Jukebox; public sealed class JukeboxBoundUserInterface : BoundUserInterface { - [Dependency] private readonly IPlayerManager _player = default!; [Dependency] private readonly IPrototypeManager _protoManager = default!; [ViewVariables] diff --git a/Content.Client/Audio/Jukebox/JukeboxSystem.cs b/Content.Client/Audio/Jukebox/JukeboxSystem.cs index 53bde82a78..dd4a5bbb9b 100644 --- a/Content.Client/Audio/Jukebox/JukeboxSystem.cs +++ b/Content.Client/Audio/Jukebox/JukeboxSystem.cs @@ -11,6 +11,7 @@ public sealed class JukeboxSystem : SharedJukeboxSystem [Dependency] private readonly IPrototypeManager _protoManager = default!; [Dependency] private readonly AnimationPlayerSystem _animationPlayer = default!; [Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!; + [Dependency] private readonly SharedUserInterfaceSystem _uiSystem = default!; public override void Initialize() { @@ -35,13 +36,10 @@ private void OnProtoReload(PrototypesReloadedEventArgs obj) var query = AllEntityQuery(); - while (query.MoveNext(out _, out var ui)) + while (query.MoveNext(out var uid, out _, out var ui)) { - if (!ui.OpenInterfaces.TryGetValue(JukeboxUiKey.Key, out var baseBui) || - baseBui is not JukeboxBoundUserInterface bui) - { + if (!_uiSystem.TryGetOpenUi((uid, ui), JukeboxUiKey.Key, out var bui)) continue; - } bui.PopulateMusic(); } @@ -49,15 +47,9 @@ private void OnProtoReload(PrototypesReloadedEventArgs obj) private void OnJukeboxAfterState(Entity ent, ref AfterAutoHandleStateEvent args) { - if (!TryComp(ent, out UserInterfaceComponent? ui)) + if (!_uiSystem.TryGetOpenUi(ent.Owner, JukeboxUiKey.Key, out var bui)) return; - if (!ui.OpenInterfaces.TryGetValue(JukeboxUiKey.Key, out var baseBui) || - baseBui is not JukeboxBoundUserInterface bui) - { - return; - } - bui.Reload(); } diff --git a/Content.Client/CardboardBox/CardboardBoxSystem.cs b/Content.Client/CardboardBox/CardboardBoxSystem.cs index 90a21d8e41..925013db10 100644 --- a/Content.Client/CardboardBox/CardboardBoxSystem.cs +++ b/Content.Client/CardboardBox/CardboardBoxSystem.cs @@ -1,4 +1,5 @@ using System.Numerics; +using Content.Shared.Body.Components; using Content.Shared.CardboardBox; using Content.Shared.CardboardBox.Components; using Content.Shared.Examine; @@ -13,9 +14,14 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem [Dependency] private readonly TransformSystem _transform = default!; [Dependency] private readonly ExamineSystemShared _examine = default!; + private EntityQuery _bodyQuery; + public override void Initialize() { base.Initialize(); + + _bodyQuery = GetEntityQuery(); + SubscribeNetworkEvent(OnBoxEffect); } @@ -59,6 +65,10 @@ private void OnBoxEffect(PlayBoxEffectMessage msg) if (!_examine.InRangeUnOccluded(sourcePos, mapPos, box.Distance, null)) continue; + // no effect for anything too exotic + if (!_bodyQuery.HasComp(mob)) + continue; + var ent = Spawn(box.Effect, mapPos); if (!xformQuery.TryGetComponent(ent, out var entTransform) || !TryComp(ent, out var sprite)) diff --git a/Content.Client/Cargo/UI/BountyEntry.xaml.cs b/Content.Client/Cargo/UI/BountyEntry.xaml.cs index 027d7b3e80..31c417117a 100644 --- a/Content.Client/Cargo/UI/BountyEntry.xaml.cs +++ b/Content.Client/Cargo/UI/BountyEntry.xaml.cs @@ -7,7 +7,6 @@ using Robust.Client.UserInterface.XAML; using Robust.Shared.Prototypes; using Robust.Shared.Timing; -using Serilog; namespace Content.Client.Cargo.UI; diff --git a/Content.Client/Changelog/ChangelogWindow.xaml.cs b/Content.Client/Changelog/ChangelogWindow.xaml.cs index e5f492900c..9b7fd75436 100644 --- a/Content.Client/Changelog/ChangelogWindow.xaml.cs +++ b/Content.Client/Changelog/ChangelogWindow.xaml.cs @@ -87,14 +87,12 @@ private void TabsUpdated() if (!tab.AdminOnly || isAdmin) { Tabs.SetTabVisible(i, true); - tab.Visible = true; visibleTabs++; firstVisible ??= i; } else { Tabs.SetTabVisible(i, false); - tab.Visible = false; } } diff --git a/Content.Client/Chat/UI/EmotesMenu.xaml b/Content.Client/Chat/UI/EmotesMenu.xaml new file mode 100644 index 0000000000..cc4d5bb77e --- /dev/null +++ b/Content.Client/Chat/UI/EmotesMenu.xaml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Content.Client/Chat/UI/EmotesMenu.xaml.cs b/Content.Client/Chat/UI/EmotesMenu.xaml.cs new file mode 100644 index 0000000000..a26d319920 --- /dev/null +++ b/Content.Client/Chat/UI/EmotesMenu.xaml.cs @@ -0,0 +1,112 @@ +using System.Numerics; +using Content.Client.UserInterface.Controls; +using Content.Shared.Chat.Prototypes; +using Content.Shared.Speech; +using Robust.Client.AutoGenerated; +using Robust.Client.GameObjects; +using Robust.Client.UserInterface.Controls; +using Robust.Client.UserInterface.XAML; +using Robust.Shared.Player; +using Robust.Shared.Prototypes; + +namespace Content.Client.Chat.UI; + +[GenerateTypedNameReferences] +public sealed partial class EmotesMenu : RadialMenu +{ + [Dependency] private readonly EntityManager _entManager = default!; + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly ISharedPlayerManager _playerManager = default!; + + private readonly SpriteSystem _spriteSystem; + + public event Action>? OnPlayEmote; + + public EmotesMenu() + { + IoCManager.InjectDependencies(this); + RobustXamlLoader.Load(this); + + _spriteSystem = _entManager.System(); + + var main = FindControl("Main"); + + var emotes = _prototypeManager.EnumeratePrototypes(); + foreach (var emote in emotes) + { + var player = _playerManager.LocalSession?.AttachedEntity; + if (emote.Category == EmoteCategory.Invalid || + emote.ChatTriggers.Count == 0 || + !(player.HasValue && (emote.Whitelist?.IsValid(player.Value, _entManager) ?? true)) || + (emote.Blacklist?.IsValid(player.Value, _entManager) ?? false)) + continue; + + if (!emote.Available && + _entManager.TryGetComponent(player.Value, out var speech) && + !speech.AllowedEmotes.Contains(emote.ID)) + continue; + + var parent = FindControl(emote.Category.ToString()); + + var button = new EmoteMenuButton + { + StyleClasses = { "RadialMenuButton" }, + SetSize = new Vector2(64f, 64f), + ToolTip = Loc.GetString(emote.Name), + ProtoId = emote.ID, + }; + + var tex = new TextureRect + { + VerticalAlignment = VAlignment.Center, + HorizontalAlignment = HAlignment.Center, + Texture = _spriteSystem.Frame0(emote.Icon), + TextureScale = new Vector2(2f, 2f), + }; + + button.AddChild(tex); + parent.AddChild(button); + foreach (var child in main.Children) + { + if (child is not RadialMenuTextureButton castChild) + continue; + + if (castChild.TargetLayer == emote.Category.ToString()) + { + castChild.Visible = true; + break; + } + } + } + + + // Set up menu actions + foreach (var child in Children) + { + if (child is not RadialContainer container) + continue; + AddEmoteClickAction(container); + } + } + + private void AddEmoteClickAction(RadialContainer container) + { + foreach (var child in container.Children) + { + if (child is not EmoteMenuButton castChild) + continue; + + castChild.OnButtonUp += _ => + { + OnPlayEmote?.Invoke(castChild.ProtoId); + Close(); + }; + } + } +} + + +public sealed class EmoteMenuButton : RadialMenuTextureButton +{ + public ProtoId ProtoId { get; set; } +} diff --git a/Content.Client/Chemistry/Components/SolutionItemStatusComponent.cs b/Content.Client/Chemistry/Components/SolutionItemStatusComponent.cs new file mode 100644 index 0000000000..58c5a05894 --- /dev/null +++ b/Content.Client/Chemistry/Components/SolutionItemStatusComponent.cs @@ -0,0 +1,22 @@ +using Content.Client.Chemistry.EntitySystems; +using Content.Client.Chemistry.UI; + +namespace Content.Client.Chemistry.Components; + +/// +/// Exposes a solution container's contents via a basic item status control. +/// +/// +/// Shows the solution volume, max volume, and transfer amount. +/// +/// +/// +[RegisterComponent] +public sealed partial class SolutionItemStatusComponent : Component +{ + /// + /// The ID of the solution that will be shown on the item status control. + /// + [DataField, ViewVariables(VVAccess.ReadWrite)] + public string Solution = "default"; +} diff --git a/Content.Client/Chemistry/EntitySystems/SolutionItemStatusSystem.cs b/Content.Client/Chemistry/EntitySystems/SolutionItemStatusSystem.cs new file mode 100644 index 0000000000..76aab516a7 --- /dev/null +++ b/Content.Client/Chemistry/EntitySystems/SolutionItemStatusSystem.cs @@ -0,0 +1,22 @@ +using Content.Client.Chemistry.Components; +using Content.Client.Chemistry.UI; +using Content.Client.Items; +using Content.Shared.Chemistry.EntitySystems; + +namespace Content.Client.Chemistry.EntitySystems; + +/// +/// Wires up item status logic for . +/// +/// +public sealed class SolutionItemStatusSystem : EntitySystem +{ + [Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!; + + public override void Initialize() + { + base.Initialize(); + Subs.ItemStatus( + entity => new SolutionStatusControl(entity, EntityManager, _solutionContainerSystem)); + } +} diff --git a/Content.Client/Chemistry/UI/ButtonGrid.cs b/Content.Client/Chemistry/UI/ButtonGrid.cs new file mode 100644 index 0000000000..0abd9ef8a4 --- /dev/null +++ b/Content.Client/Chemistry/UI/ButtonGrid.cs @@ -0,0 +1,119 @@ +using System; +using Robust.Client.Graphics; +using Robust.Client.UserInterface.Controls; + +namespace Content.Client.Chemistry.UI; + +/// +/// Creates a grid of buttons given a comma-seperated list of Text +/// +public sealed class ButtonGrid : GridContainer +{ + private string _buttonList = ""; + + /// + /// A comma-seperated list of text to use for each button. These will be inserted sequentially. + /// + public string ButtonList + { + get => _buttonList; + set + { + _buttonList = value; + Update(); + } + } + + public bool RadioGroup { get; set; } = false; + + private string? _selected; + + /// + /// Which button is currently selected. Only matters when is true. + /// + public string? Selected + { + get => _selected; + set + { + _selected = value; + Update(); + } + } + + public Action? OnButtonPressed; + + /// + /// + /// + public new int Columns + { + get => base.Columns; + set + { + base.Columns = value; + Update(); + } + } + + /// + /// + /// + public new int Rows + { + get => base.Rows; + set + { + base.Rows = value; + Update(); + } + } + + private void Update() + { + if (ButtonList == "") + return; + + this.Children.Clear(); + var i = 0; + var list = ButtonList.Split(","); + + var group = new ButtonGroup(); + + foreach (var button in list) + { + var btn = new Button(); + btn.Text = button; + btn.OnPressed += _ => + { + if (RadioGroup) + btn.Pressed = true; + Selected = button; + OnButtonPressed?.Invoke(button); + }; + if (button == Selected) + btn.Pressed = true; + var sep = HSeparationOverride ?? 0; + // ReSharper disable once PossibleLossOfFraction + // btn.SetWidth = (this.PixelWidth - sep * (Columns - 1)) / 3; + btn.Group = group; + + var row = i / Columns; + var col = i % Columns; + var last = i == list.Length - 1; + var lastCol = i == Columns - 1; + var lastRow = row == list.Length / Columns - 1; + + if (row == 0 && (lastCol || last)) + btn.AddStyleClass("OpenLeft"); + else if (col == 0 && lastRow) + btn.AddStyleClass("OpenRight"); + else + btn.AddStyleClass("OpenBoth"); + + this.Children.Add(btn); + + i++; + } + } +} diff --git a/Content.Client/Chemistry/UI/InjectorStatusControl.cs b/Content.Client/Chemistry/UI/InjectorStatusControl.cs index ba1f97cd1e..f9b0d90e20 100644 --- a/Content.Client/Chemistry/UI/InjectorStatusControl.cs +++ b/Content.Client/Chemistry/UI/InjectorStatusControl.cs @@ -32,7 +32,7 @@ protected override void FrameUpdate(FrameEventArgs args) { base.FrameUpdate(args); - if (!_solutionContainers.TryGetSolution(_parent.Owner, InjectorComponent.SolutionName, out _, out var solution)) + if (!_solutionContainers.TryGetSolution(_parent.Owner, _parent.Comp.SolutionName, out _, out var solution)) return; // only updates the UI if any of the details are different than they previously were diff --git a/Content.Client/Chemistry/UI/ReagentCardControl.xaml b/Content.Client/Chemistry/UI/ReagentCardControl.xaml new file mode 100644 index 0000000000..966c730140 --- /dev/null +++ b/Content.Client/Chemistry/UI/ReagentCardControl.xaml @@ -0,0 +1,37 @@ + + + + + + + diff --git a/Content.Client/Chemistry/UI/ReagentCardControl.xaml.cs b/Content.Client/Chemistry/UI/ReagentCardControl.xaml.cs new file mode 100644 index 0000000000..60336143fc --- /dev/null +++ b/Content.Client/Chemistry/UI/ReagentCardControl.xaml.cs @@ -0,0 +1,30 @@ +using Content.Shared.Chemistry; +using Robust.Client.AutoGenerated; +using Robust.Client.Graphics; +using Robust.Client.UserInterface; +using Robust.Client.UserInterface.XAML; + +namespace Content.Client.Chemistry.UI; + +[GenerateTypedNameReferences] +public sealed partial class ReagentCardControl : Control +{ + public string StorageSlotId { get; } + public Action? OnPressed; + public Action? OnEjectButtonPressed; + + public ReagentCardControl(ReagentInventoryItem item) + { + RobustXamlLoader.Load(this); + + StorageSlotId = item.StorageSlotId; + ColorPanel.PanelOverride = new StyleBoxFlat { BackgroundColor = item.ReagentColor }; + ReagentNameLabel.Text = item.ReagentLabel; + ReagentNameLabel.FontColorOverride = Color.White; + FillLabel.Text = item.StoredAmount; + EjectButtonIcon.Text = Loc.GetString("reagent-dispenser-window-eject-container-button"); + + MainButton.OnPressed += args => OnPressed?.Invoke(StorageSlotId); + EjectButton.OnPressed += args => OnEjectButtonPressed?.Invoke(StorageSlotId); + } +} diff --git a/Content.Client/Chemistry/UI/ReagentDispenserBoundUserInterface.cs b/Content.Client/Chemistry/UI/ReagentDispenserBoundUserInterface.cs index 8244e3e6ed..99e5a3d395 100644 --- a/Content.Client/Chemistry/UI/ReagentDispenserBoundUserInterface.cs +++ b/Content.Client/Chemistry/UI/ReagentDispenserBoundUserInterface.cs @@ -1,3 +1,4 @@ +using Content.Client.Guidebook.Components; using Content.Shared.Chemistry; using Content.Shared.Containers.ItemSlots; using JetBrains.Annotations; @@ -34,6 +35,7 @@ protected override void Open() _window = new() { Title = EntMan.GetComponent(Owner).EntityName, + HelpGuidebookIds = EntMan.GetComponent(Owner).Guides }; _window.OpenCentered(); @@ -42,38 +44,11 @@ protected override void Open() // Setup static button actions. _window.EjectButton.OnPressed += _ => SendMessage(new ItemSlotButtonPressedEvent(SharedReagentDispenser.OutputSlotName)); _window.ClearButton.OnPressed += _ => SendMessage(new ReagentDispenserClearContainerSolutionMessage()); - _window.DispenseButton1.OnPressed += _ => SendMessage(new ReagentDispenserSetDispenseAmountMessage(ReagentDispenserDispenseAmount.U1)); - _window.DispenseButton5.OnPressed += _ => SendMessage(new ReagentDispenserSetDispenseAmountMessage(ReagentDispenserDispenseAmount.U5)); - _window.DispenseButton10.OnPressed += _ => SendMessage(new ReagentDispenserSetDispenseAmountMessage(ReagentDispenserDispenseAmount.U10)); - _window.DispenseButton15.OnPressed += _ => SendMessage(new ReagentDispenserSetDispenseAmountMessage(ReagentDispenserDispenseAmount.U15)); - _window.DispenseButton20.OnPressed += _ => SendMessage(new ReagentDispenserSetDispenseAmountMessage(ReagentDispenserDispenseAmount.U20)); - _window.DispenseButton25.OnPressed += _ => SendMessage(new ReagentDispenserSetDispenseAmountMessage(ReagentDispenserDispenseAmount.U25)); - _window.DispenseButton30.OnPressed += _ => SendMessage(new ReagentDispenserSetDispenseAmountMessage(ReagentDispenserDispenseAmount.U30)); - _window.DispenseButton50.OnPressed += _ => SendMessage(new ReagentDispenserSetDispenseAmountMessage(ReagentDispenserDispenseAmount.U50)); - _window.DispenseButton100.OnPressed += _ => SendMessage(new ReagentDispenserSetDispenseAmountMessage(ReagentDispenserDispenseAmount.U100)); - // Setup reagent button actions. - _window.OnDispenseReagentButtonPressed += (args, button) => SendMessage(new ReagentDispenserDispenseReagentMessage(button.ReagentId)); - _window.OnDispenseReagentButtonMouseEntered += (args, button) => - { - if (_lastState is not null) - _window.UpdateContainerInfo(_lastState); - }; - _window.OnDispenseReagentButtonMouseExited += (args, button) => - { - if (_lastState is not null) - _window.UpdateContainerInfo(_lastState); - }; + _window.AmountGrid.OnButtonPressed += s => SendMessage(new ReagentDispenserSetDispenseAmountMessage(s)); - _window.OnEjectJugButtonPressed += (args, button) => SendMessage(new ItemSlotButtonPressedEvent(button.ReagentId)); - _window.OnEjectJugButtonMouseEntered += (args, button) => { - if (_lastState is not null) - _window.UpdateContainerInfo(_lastState); - }; - _window.OnEjectJugButtonMouseExited += (args, button) => { - if (_lastState is not null) - _window.UpdateContainerInfo(_lastState); - }; + _window.OnDispenseReagentButtonPressed += (id) => SendMessage(new ReagentDispenserDispenseReagentMessage(id)); + _window.OnEjectJugButtonPressed += (id) => SendMessage(new ItemSlotButtonPressedEvent(id)); } /// diff --git a/Content.Client/Chemistry/UI/ReagentDispenserWindow.xaml b/Content.Client/Chemistry/UI/ReagentDispenserWindow.xaml index 3b812ba56b..c900d7ecf2 100644 --- a/Content.Client/Chemistry/UI/ReagentDispenserWindow.xaml +++ b/Content.Client/Chemistry/UI/ReagentDispenserWindow.xaml @@ -1,53 +1,77 @@ - - - - [GenerateTypedNameReferences] - public sealed partial class ReagentDispenserWindow : DefaultWindow + public sealed partial class ReagentDispenserWindow : FancyWindow { [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IEntityManager _entityManager = default!; - public event Action? OnDispenseReagentButtonPressed; - public event Action? OnDispenseReagentButtonMouseEntered; - public event Action? OnDispenseReagentButtonMouseExited; - - public event Action? OnEjectJugButtonPressed; - public event Action? OnEjectJugButtonMouseEntered; - public event Action? OnEjectJugButtonMouseExited; + public event Action? OnDispenseReagentButtonPressed; + public event Action? OnEjectJugButtonPressed; /// /// Create and initialize the dispenser UI client-side. Creates the basic layout, @@ -35,44 +29,27 @@ public ReagentDispenserWindow() { RobustXamlLoader.Load(this); IoCManager.InjectDependencies(this); - - var dispenseAmountGroup = new ButtonGroup(); - DispenseButton1.Group = dispenseAmountGroup; - DispenseButton5.Group = dispenseAmountGroup; - DispenseButton10.Group = dispenseAmountGroup; - DispenseButton15.Group = dispenseAmountGroup; - DispenseButton20.Group = dispenseAmountGroup; - DispenseButton25.Group = dispenseAmountGroup; - DispenseButton30.Group = dispenseAmountGroup; - DispenseButton50.Group = dispenseAmountGroup; - DispenseButton100.Group = dispenseAmountGroup; } /// /// Update the button grid of reagents which can be dispensed. /// /// Reagents which can be dispensed by this dispenser - public void UpdateReagentsList(List>> inventory) + public void UpdateReagentsList(List inventory) { - if (ChemicalList == null) + if (ReagentList == null) return; - ChemicalList.Children.Clear(); + ReagentList.Children.Clear(); //Sort inventory by reagentLabel - inventory.Sort((x, y) => x.Value.Key.CompareTo(y.Value.Key)); + inventory.Sort((x, y) => x.ReagentLabel.CompareTo(y.ReagentLabel)); - foreach (KeyValuePair> entry in inventory) + foreach (var item in inventory) { - var button = new DispenseReagentButton(entry.Key, entry.Value.Key, entry.Value.Value); - button.OnPressed += args => OnDispenseReagentButtonPressed?.Invoke(args, button); - button.OnMouseEntered += args => OnDispenseReagentButtonMouseEntered?.Invoke(args, button); - button.OnMouseExited += args => OnDispenseReagentButtonMouseExited?.Invoke(args, button); - ChemicalList.AddChild(button); - var ejectButton = new EjectJugButton(entry.Key); - ejectButton.OnPressed += args => OnEjectJugButtonPressed?.Invoke(args, ejectButton); - ejectButton.OnMouseEntered += args => OnEjectJugButtonMouseEntered?.Invoke(args, ejectButton); - ejectButton.OnMouseExited += args => OnEjectJugButtonMouseExited?.Invoke(args, ejectButton); - ChemicalList.AddChild(ejectButton); + var card = new ReagentCardControl(item); + card.OnPressed += OnDispenseReagentButtonPressed; + card.OnEjectButtonPressed += OnEjectJugButtonPressed; + ReagentList.Children.Add(card); } } @@ -93,36 +70,7 @@ public void UpdateState(BoundUserInterfaceState state) ClearButton.Disabled = castState.OutputContainer is null; EjectButton.Disabled = castState.OutputContainer is null; - switch (castState.SelectedDispenseAmount) - { - case ReagentDispenserDispenseAmount.U1: - DispenseButton1.Pressed = true; - break; - case ReagentDispenserDispenseAmount.U5: - DispenseButton5.Pressed = true; - break; - case ReagentDispenserDispenseAmount.U10: - DispenseButton10.Pressed = true; - break; - case ReagentDispenserDispenseAmount.U15: - DispenseButton15.Pressed = true; - break; - case ReagentDispenserDispenseAmount.U20: - DispenseButton20.Pressed = true; - break; - case ReagentDispenserDispenseAmount.U25: - DispenseButton25.Pressed = true; - break; - case ReagentDispenserDispenseAmount.U30: - DispenseButton30.Pressed = true; - break; - case ReagentDispenserDispenseAmount.U50: - DispenseButton50.Pressed = true; - break; - case ReagentDispenserDispenseAmount.U100: - DispenseButton100.Pressed = true; - break; - } + AmountGrid.Selected = ((int)castState.SelectedDispenseAmount).ToString(); } /// @@ -137,23 +85,15 @@ public void UpdateContainerInfo(ReagentDispenserBoundUserInterfaceState state) if (state.OutputContainer is null) { + ContainerInfoName.Text = ""; + ContainerInfoFill.Text = ""; ContainerInfo.Children.Add(new Label { Text = Loc.GetString("reagent-dispenser-window-no-container-loaded-text") }); return; } - ContainerInfo.Children.Add(new BoxContainer // Name of the container and its fill status (Ex: 44/100u) - { - Orientation = LayoutOrientation.Horizontal, - Children = - { - new Label {Text = $"{state.OutputContainer.DisplayName}: "}, - new Label - { - Text = $"{state.OutputContainer.CurrentVolume}/{state.OutputContainer.MaxVolume}", - StyleClasses = {StyleNano.StyleClassLabelSecondaryColor} - } - } - }); + // Set Name of the container and its fill status (Ex: 44/100u) + ContainerInfoName.Text = state.OutputContainer.DisplayName; + ContainerInfoFill.Text = state.OutputContainer.CurrentVolume + "/" + state.OutputContainer.MaxVolume; foreach (var (reagent, quantity) in state.OutputContainer.Reagents!) { diff --git a/Content.Client/Chemistry/UI/SolutionStatusControl.cs b/Content.Client/Chemistry/UI/SolutionStatusControl.cs new file mode 100644 index 0000000000..1a33ffb0e1 --- /dev/null +++ b/Content.Client/Chemistry/UI/SolutionStatusControl.cs @@ -0,0 +1,59 @@ +using Content.Client.Chemistry.Components; +using Content.Client.Chemistry.EntitySystems; +using Content.Client.Items.UI; +using Content.Client.Message; +using Content.Client.Stylesheets; +using Content.Shared.Chemistry.Components; +using Content.Shared.Chemistry.EntitySystems; +using Content.Shared.FixedPoint; +using Robust.Client.UserInterface.Controls; + +namespace Content.Client.Chemistry.UI; + +/// +/// Displays basic solution information for . +/// +/// +public sealed class SolutionStatusControl : PollingItemStatusControl +{ + private readonly Entity _parent; + private readonly IEntityManager _entityManager; + private readonly SharedSolutionContainerSystem _solutionContainers; + private readonly RichTextLabel _label; + + public SolutionStatusControl( + Entity parent, + IEntityManager entityManager, + SharedSolutionContainerSystem solutionContainers) + { + _parent = parent; + _entityManager = entityManager; + _solutionContainers = solutionContainers; + _label = new RichTextLabel { StyleClasses = { StyleNano.StyleClassItemStatus } }; + AddChild(_label); + } + + protected override Data PollData() + { + if (!_solutionContainers.TryGetSolution(_parent.Owner, _parent.Comp.Solution, out _, out var solution)) + return default; + + FixedPoint2? transferAmount = null; + if (_entityManager.TryGetComponent(_parent.Owner, out SolutionTransferComponent? transfer)) + transferAmount = transfer.TransferAmount; + + return new Data(solution.Volume, solution.MaxVolume, transferAmount); + } + + protected override void Update(in Data data) + { + var markup = Loc.GetString("solution-status-volume", + ("currentVolume", data.Volume), + ("maxVolume", data.MaxVolume)); + if (data.TransferVolume is { } transferVolume) + markup += "\n" + Loc.GetString("solution-status-transfer", ("volume", transferVolume)); + _label.SetMarkup(markup); + } + + public readonly record struct Data(FixedPoint2 Volume, FixedPoint2 MaxVolume, FixedPoint2? TransferVolume); +} diff --git a/Content.Client/Clothing/ClientClothingSystem.cs b/Content.Client/Clothing/ClientClothingSystem.cs index 7e78ac7d70..dd69521f48 100644 --- a/Content.Client/Clothing/ClientClothingSystem.cs +++ b/Content.Client/Clothing/ClientClothingSystem.cs @@ -11,6 +11,7 @@ using Robust.Client.GameObjects; using Robust.Client.Graphics; using Robust.Client.ResourceManagement; +using Robust.Shared.Serialization.Manager; using Robust.Shared.Serialization.TypeSerializers.Implementations; using Robust.Shared.Utility; using static Robust.Client.GameObjects.SpriteComponent; @@ -46,6 +47,7 @@ public sealed class ClientClothingSystem : ClothingSystem }; [Dependency] private readonly IResourceCache _cache = default!; + [Dependency] private readonly ISerializationManager _serialization = default!; [Dependency] private readonly InventorySystem _inventorySystem = default!; public override void Initialize() @@ -265,6 +267,7 @@ private void RenderEquipment(EntityUid equipee, EntityUid equipment, string slot // temporary, until layer draw depths get added. Basically: a layer with the key "slot" is being used as a // bookmark to determine where in the list of layers we should insert the clothing layers. bool slotLayerExists = sprite.LayerMapTryGet(slot, out var index); + var displacementData = inventory.Displacements.GetValueOrDefault(slot); // add the new layers foreach (var (key, layerData) in ev.Layers) @@ -308,6 +311,28 @@ private void RenderEquipment(EntityUid equipee, EntityUid equipment, string slot sprite.LayerSetData(index, layerData); layer.Offset += slotDef.Offset; + + if (displacementData != null) + { + if (displacementData.ShaderOverride != null) + sprite.LayerSetShader(index, displacementData.ShaderOverride); + + var displacementKey = $"{key}-displacement"; + if (!revealedLayers.Add(displacementKey)) + { + Log.Warning($"Duplicate key for clothing visuals DISPLACEMENT: {displacementKey}."); + continue; + } + + var displacementLayer = _serialization.CreateCopy(displacementData.Layer, notNullableOverride: true); + displacementLayer.CopyToShaderParameters!.LayerKey = key; + + // Add before main layer for this item. + sprite.AddLayer(displacementLayer, index); + sprite.LayerMapSet(displacementKey, index); + + revealedLayers.Add(displacementKey); + } } RaiseLocalEvent(equipment, new EquipmentVisualsUpdatedEvent(equipee, slot, revealedLayers), true); diff --git a/Content.Client/Communications/UI/CommunicationsConsoleMenu.xaml.cs b/Content.Client/Communications/UI/CommunicationsConsoleMenu.xaml.cs index 90643e45cf..4d8dd86a4d 100644 --- a/Content.Client/Communications/UI/CommunicationsConsoleMenu.xaml.cs +++ b/Content.Client/Communications/UI/CommunicationsConsoleMenu.xaml.cs @@ -1,7 +1,9 @@ using Content.Client.UserInterface.Controls; using System.Threading; +using Content.Shared.CCVar; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface.XAML; +using Robust.Shared.Configuration; using Robust.Shared.Utility; using Timer = Robust.Shared.Timing.Timer; @@ -13,6 +15,8 @@ public sealed partial class CommunicationsConsoleMenu : FancyWindow private CommunicationsConsoleBoundUserInterface Owner { get; set; } private readonly CancellationTokenSource _timerCancelTokenSource = new(); + [Dependency] private readonly IConfigurationManager _cfg = default!; + public CommunicationsConsoleMenu(CommunicationsConsoleBoundUserInterface owner) { IoCManager.InjectDependencies(this); @@ -23,6 +27,22 @@ public CommunicationsConsoleMenu(CommunicationsConsoleBoundUserInterface owner) var loc = IoCManager.Resolve(); MessageInput.Placeholder = new Rope.Leaf(loc.GetString("comms-console-menu-announcement-placeholder")); + var maxAnnounceLength = _cfg.GetCVar(CCVars.ChatMaxAnnouncementLength); + MessageInput.OnTextChanged += (args) => + { + if (args.Control.TextLength > maxAnnounceLength) + { + AnnounceButton.Disabled = true; + AnnounceButton.ToolTip = Loc.GetString("comms-console-message-too-long"); + } + else + { + AnnounceButton.Disabled = !owner.CanAnnounce; + AnnounceButton.ToolTip = null; + + } + }; + AnnounceButton.OnPressed += (_) => Owner.AnnounceButtonPressed(Rope.Collapse(MessageInput.TextRope)); AnnounceButton.Disabled = !owner.CanAnnounce; diff --git a/Content.Client/CriminalRecords/Systems/CriminalRecordsHackerSystem.cs b/Content.Client/CriminalRecords/Systems/CriminalRecordsHackerSystem.cs new file mode 100644 index 0000000000..21fccc880d --- /dev/null +++ b/Content.Client/CriminalRecords/Systems/CriminalRecordsHackerSystem.cs @@ -0,0 +1,7 @@ +using Content.Shared.CriminalRecords.Systems; + +namespace Content.Client.CriminalRecords.Systems; + +public sealed class CriminalRecordsHackerSystem : SharedCriminalRecordsHackerSystem +{ +} diff --git a/Content.Client/DeviceNetwork/JammerSystem.cs b/Content.Client/DeviceNetwork/JammerSystem.cs new file mode 100644 index 0000000000..c7dbf8c8fe --- /dev/null +++ b/Content.Client/DeviceNetwork/JammerSystem.cs @@ -0,0 +1,8 @@ +using Content.Shared.Radio.EntitySystems; + +namespace Content.Client.DeviceNetwork; + +public sealed class JammerSystem : SharedJammerSystem +{ + +} diff --git a/Content.Client/DoAfter/DoAfterOverlay.cs b/Content.Client/DoAfter/DoAfterOverlay.cs index 2e23dd44ca..45981159f0 100644 --- a/Content.Client/DoAfter/DoAfterOverlay.cs +++ b/Content.Client/DoAfter/DoAfterOverlay.cs @@ -21,7 +21,7 @@ public sealed class DoAfterOverlay : Overlay private readonly ProgressColorSystem _progressColor; private readonly Texture _barTexture; - private readonly ShaderInstance _shader; + private readonly ShaderInstance _unshadedShader; /// /// Flash time for cancelled DoAfters @@ -45,7 +45,7 @@ public DoAfterOverlay(IEntityManager entManager, IPrototypeManager protoManager, var sprite = new SpriteSpecifier.Rsi(new("/Textures/Interface/Misc/progress_bar.rsi"), "icon"); _barTexture = _entManager.EntitySysManager.GetEntitySystem().Frame0(sprite); - _shader = protoManager.Index("unshaded").Instance(); + _unshadedShader = protoManager.Index("unshaded").Instance(); } protected override void Draw(in OverlayDrawArgs args) @@ -58,7 +58,6 @@ protected override void Draw(in OverlayDrawArgs args) const float scale = 1f; var scaleMatrix = Matrix3.CreateScale(new Vector2(scale, scale)); var rotationMatrix = Matrix3.CreateRotation(-rotation); - handle.UseShader(_shader); var curTime = _timing.CurTime; @@ -79,6 +78,13 @@ protected override void Draw(in OverlayDrawArgs args) if (!bounds.Contains(worldPosition)) continue; + // shades the do-after bar if the do-after bar belongs to other players + // does not shade do-afters belonging to the local player + if (uid != localEnt) + handle.UseShader(null); + else + handle.UseShader(_unshadedShader); + // If the entity is paused, we will draw the do-after as it was when the entity got paused. var meta = metaQuery.GetComponent(uid); var time = meta.EntityPaused diff --git a/Content.Client/Entry/EntryPoint.cs b/Content.Client/Entry/EntryPoint.cs index 7f921fc1a6..1ab213ae0a 100644 --- a/Content.Client/Entry/EntryPoint.cs +++ b/Content.Client/Entry/EntryPoint.cs @@ -12,10 +12,10 @@ using Content.Client.Input; using Content.Client.IoC; using Content.Client.Launcher; +using Content.Client.Lobby; using Content.Client.MainMenu; using Content.Client.Parallax.Managers; using Content.Client.Players.PlayTimeTracking; -using Content.Client.Preferences; using Content.Client.Radiation.Overlays; using Content.Client.Replay; using Content.Client.Screenshot; @@ -124,6 +124,7 @@ public override void Init() _prototypeManager.RegisterIgnore("alertLevels"); _prototypeManager.RegisterIgnore("nukeopsRole"); _prototypeManager.RegisterIgnore("stationGoal"); + _prototypeManager.RegisterIgnore("ghostRoleRaffleDecider"); _componentFactory.GenerateNetIds(); _adminManager.Initialize(); diff --git a/Content.Client/Extinguisher/FireExtinguisherComponent.cs b/Content.Client/Extinguisher/FireExtinguisherComponent.cs index 126c172924..324b05a93d 100644 --- a/Content.Client/Extinguisher/FireExtinguisherComponent.cs +++ b/Content.Client/Extinguisher/FireExtinguisherComponent.cs @@ -3,7 +3,5 @@ namespace Content.Client.Extinguisher; -[NetworkedComponent, RegisterComponent] -public sealed partial class FireExtinguisherComponent : SharedFireExtinguisherComponent -{ -} +[RegisterComponent] +public sealed partial class FireExtinguisherComponent : SharedFireExtinguisherComponent; diff --git a/Content.Client/Eye/EyeLerpingSystem.cs b/Content.Client/Eye/EyeLerpingSystem.cs index 78e1b851fc..ac32299dca 100644 --- a/Content.Client/Eye/EyeLerpingSystem.cs +++ b/Content.Client/Eye/EyeLerpingSystem.cs @@ -86,7 +86,7 @@ public void RemoveEye(EntityUid uid) private void HandleMapChange(EntityUid uid, LerpingEyeComponent component, ref EntParentChangedMessage args) { // Is this actually a map change? If yes, stop any lerps - if (args.OldMapId != args.Transform.MapID) + if (args.OldMapId != args.Transform.MapUid) component.LastRotation = GetRotation(uid, args.Transform); } diff --git a/Content.Client/Fax/System/FaxVisualsSystem.cs b/Content.Client/Fax/System/FaxVisualsSystem.cs new file mode 100644 index 0000000000..892aec1d95 --- /dev/null +++ b/Content.Client/Fax/System/FaxVisualsSystem.cs @@ -0,0 +1,48 @@ +using Robust.Client.GameObjects; +using Content.Shared.Fax.Components; +using Content.Shared.Fax; +using Robust.Client.Animations; + +namespace Content.Client.Fax.System; + +/// +/// Visualizer for the fax machine which displays the correct sprite based on the inserted entity. +/// +public sealed class FaxVisualsSystem : EntitySystem +{ + [Dependency] private readonly AnimationPlayerSystem _player = default!; + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnAppearanceChanged); + } + + private void OnAppearanceChanged(EntityUid uid, FaxMachineComponent component, ref AppearanceChangeEvent args) + { + if (args.Sprite == null) + return; + + if (_appearance.TryGetData(uid, FaxMachineVisuals.VisualState, out FaxMachineVisualState visuals) && visuals == FaxMachineVisualState.Inserting) + { + _player.Play(uid, new Animation() + { + Length = TimeSpan.FromSeconds(2.4), + AnimationTracks = + { + new AnimationTrackSpriteFlick() + { + LayerKey = FaxMachineVisuals.VisualState, + KeyFrames = + { + new AnimationTrackSpriteFlick.KeyFrame(component.InsertingState, 0f), + new AnimationTrackSpriteFlick.KeyFrame("icon", 2.4f), + } + } + } + }, "faxecute"); + } + } +} diff --git a/Content.Client/Fax/UI/FaxBoundUi.cs b/Content.Client/Fax/UI/FaxBoundUi.cs index 9b57595d7b..a95066a3b5 100644 --- a/Content.Client/Fax/UI/FaxBoundUi.cs +++ b/Content.Client/Fax/UI/FaxBoundUi.cs @@ -40,7 +40,7 @@ private async void OnFileButtonPressed() { if (_dialogIsOpen) return; - + _dialogIsOpen = true; var filters = new FileDialogFilters(new FileDialogFilters.Group("txt")); await using var file = await _fileDialogManager.OpenFile(filters); @@ -52,8 +52,27 @@ private async void OnFileButtonPressed() } using var reader = new StreamReader(file); + + var firstLine = await reader.ReadLineAsync(); + string? label = null; var content = await reader.ReadToEndAsync(); - SendMessage(new FaxFileMessage(content[..Math.Min(content.Length, FaxFileMessageValidation.MaxContentSize)], _window.OfficePaper)); + + if (firstLine is { }) + { + if (firstLine.StartsWith('#')) + { + label = firstLine[1..].Trim(); + } + else + { + content = firstLine + "\n" + content; + } + } + + SendMessage(new FaxFileMessage( + label?[..Math.Min(label.Length, FaxFileMessageValidation.MaxLabelSize)], + content[..Math.Min(content.Length, FaxFileMessageValidation.MaxContentSize)], + _window.OfficePaper)); } private void OnSendButtonPressed() diff --git a/Content.Client/GameTicking/Managers/ClientGameTicker.cs b/Content.Client/GameTicking/Managers/ClientGameTicker.cs index df709e9444..309db2eb4e 100644 --- a/Content.Client/GameTicking/Managers/ClientGameTicker.cs +++ b/Content.Client/GameTicking/Managers/ClientGameTicker.cs @@ -1,3 +1,4 @@ +using Content.Client.Administration.Managers; using Content.Client.Gameplay; using Content.Client.Lobby; using Content.Client.RoundEnd; @@ -6,7 +7,7 @@ using JetBrains.Annotations; using Robust.Client.Graphics; using Robust.Client.State; -using Robust.Shared.Utility; +using Robust.Client.UserInterface; namespace Content.Client.GameTicking.Managers { @@ -14,17 +15,14 @@ namespace Content.Client.GameTicking.Managers public sealed class ClientGameTicker : SharedGameTicker { [Dependency] private readonly IStateManager _stateManager = default!; - [Dependency] private readonly IEntityManager _entityManager = default!; + [Dependency] private readonly IClientAdminManager _admin = default!; + [Dependency] private readonly IClyde _clyde = default!; + [Dependency] private readonly SharedMapSystem _map = default!; + [Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!; - [ViewVariables] private bool _initialized; private Dictionary> _jobsAvailable = new(); private Dictionary _stationNames = new(); - /// - /// The current round-end window. Could be used to support re-opening the window after closing it. - /// - private RoundEndSummaryWindow? _window; - [ViewVariables] public bool AreWeReady { get; private set; } [ViewVariables] public bool IsGameStarted { get; private set; } [ViewVariables] public string? RestartSound { get; private set; } @@ -44,8 +42,6 @@ public sealed class ClientGameTicker : SharedGameTicker public override void Initialize() { - DebugTools.Assert(!_initialized); - SubscribeNetworkEvent(JoinLobby); SubscribeNetworkEvent(JoinGame); SubscribeNetworkEvent(ConnectionStatus); @@ -53,14 +49,33 @@ public override void Initialize() SubscribeNetworkEvent(LobbyInfo); SubscribeNetworkEvent(LobbyCountdown); SubscribeNetworkEvent(RoundEnd); - SubscribeNetworkEvent(msg => - { - IoCManager.Resolve().RequestWindowAttention(); - }); + SubscribeNetworkEvent(OnAttentionRequest); SubscribeNetworkEvent(LateJoinStatus); SubscribeNetworkEvent(UpdateJobsAvailable); - _initialized = true; + _admin.AdminStatusUpdated += OnAdminUpdated; + OnAdminUpdated(); + } + + public override void Shutdown() + { + _admin.AdminStatusUpdated -= OnAdminUpdated; + base.Shutdown(); + } + + private void OnAdminUpdated() + { + // Hide some map/grid related logs from clients. This is to try prevent some easy metagaming by just + // reading the console. E.g., logs like this one could leak the nuke station/grid: + // > Grid NT-Arrivals 1101 (122/n25896) changed parent. Old parent: map 10 (121/n25895). New parent: FTL (123/n26470) +#if !DEBUG + _map.Log.Level = _admin.IsAdmin() ? LogLevel.Info : LogLevel.Warning; +#endif + } + + private void OnAttentionRequest(RequestWindowAttentionEvent ev) + { + _clyde.RequestWindowAttention(); } private void LateJoinStatus(TickerLateJoinStatusEvent message) @@ -132,12 +147,7 @@ private void RoundEnd(RoundEndMessageEvent message) // Force an update in the event of this song being the same as the last. RestartSound = message.RestartSound; - // Don't open duplicate windows (mainly for replays). - if (_window?.RoundId == message.RoundId) - return; - - //This is not ideal at all, but I don't see an immediately better fit anywhere else. - _window = new RoundEndSummaryWindow(message.GamemodeTitle, message.RoundEndText, message.RoundDuration, message.RoundId, message.AllPlayersEndInfo, _entityManager); + _userInterfaceManager.GetUIController().OpenRoundEndSummaryWindow(message); } } } diff --git a/Content.Client/Ghost/Commands/ToggleGhostVisibilityCommand.cs b/Content.Client/Ghost/Commands/ToggleGhostVisibilityCommand.cs new file mode 100644 index 0000000000..480da6ad8d --- /dev/null +++ b/Content.Client/Ghost/Commands/ToggleGhostVisibilityCommand.cs @@ -0,0 +1,26 @@ +using Robust.Shared.Console; + +namespace Content.Client.Ghost.Commands; + +public sealed class ToggleGhostVisibilityCommand : IConsoleCommand +{ + [Dependency] private readonly IEntitySystemManager _entSysMan = default!; + + public string Command => "toggleghostvisibility"; + public string Description => "Toggles ghost visibility on the client."; + public string Help => "toggleghostvisibility [bool]"; + + public void Execute(IConsoleShell shell, string argStr, string[] args) + { + var ghostSystem = _entSysMan.GetEntitySystem(); + + if (args.Length != 0 && bool.TryParse(args[0], out var visibility)) + { + ghostSystem.ToggleGhostVisibility(visibility); + } + else + { + ghostSystem.ToggleGhostVisibility(); + } + } +} diff --git a/Content.Client/Ghost/GhostSystem.cs b/Content.Client/Ghost/GhostSystem.cs index 774eae3f02..906a2312be 100644 --- a/Content.Client/Ghost/GhostSystem.cs +++ b/Content.Client/Ghost/GhostSystem.cs @@ -3,7 +3,6 @@ using Content.Shared.Ghost; using Robust.Client.Console; using Robust.Client.GameObjects; -using Robust.Client.Graphics; using Robust.Client.Player; using Robust.Shared.Player; @@ -177,9 +176,9 @@ public void OpenGhostRoles() _console.RemoteExecuteCommand(null, "ghostroles"); } - public void ToggleGhostVisibility() + public void ToggleGhostVisibility(bool? visibility = null) { - GhostVisibility = !GhostVisibility; + GhostVisibility = visibility ?? !GhostVisibility; } public void ReturnToRound() diff --git a/Content.Client/Guidebook/Controls/GuideReagentEmbed.xaml.cs b/Content.Client/Guidebook/Controls/GuideReagentEmbed.xaml.cs index e2b09386df..537494933b 100644 --- a/Content.Client/Guidebook/Controls/GuideReagentEmbed.xaml.cs +++ b/Content.Client/Guidebook/Controls/GuideReagentEmbed.xaml.cs @@ -4,6 +4,7 @@ using Content.Client.Guidebook.Richtext; using Content.Client.Message; using Content.Client.UserInterface.ControlExtensions; +using Content.Shared.Body.Prototypes; using Content.Shared.Chemistry.Reaction; using Content.Shared.Chemistry.Reagent; using JetBrains.Annotations; @@ -128,7 +129,7 @@ private void GenerateControl(ReagentPrototype reagent) var groupLabel = new RichTextLabel(); groupLabel.SetMarkup(Loc.GetString("guidebook-reagent-effects-metabolism-group-rate", - ("group", group), ("rate", effect.MetabolismRate))); + ("group", _prototype.Index(group).LocalizedName), ("rate", effect.MetabolismRate))); var descriptionLabel = new RichTextLabel { Margin = new Thickness(25, 0, 10, 0) diff --git a/Content.Client/Guidebook/GuideEntry.cs b/Content.Client/Guidebook/GuideEntry.cs index b3c004267d..b7b3b3309e 100644 --- a/Content.Client/Guidebook/GuideEntry.cs +++ b/Content.Client/Guidebook/GuideEntry.cs @@ -42,7 +42,7 @@ public class GuideEntry } [Prototype("guideEntry")] -public sealed class GuideEntryPrototype : GuideEntry, IPrototype +public sealed partial class GuideEntryPrototype : GuideEntry, IPrototype { public string ID => Id; } diff --git a/Content.Client/Guidebook/GuidebookSystem.cs b/Content.Client/Guidebook/GuidebookSystem.cs index cb13d4ca6e..0aa2c85142 100644 --- a/Content.Client/Guidebook/GuidebookSystem.cs +++ b/Content.Client/Guidebook/GuidebookSystem.cs @@ -80,6 +80,11 @@ private void OnGetVerbs(EntityUid uid, GuideHelpComponent component, GetVerbsEve }); } + public void OpenHelp(List guides) + { + OnGuidebookOpen?.Invoke(guides, null, null, true, guides[0]); + } + private void OnInteract(EntityUid uid, GuideHelpComponent component, ActivateInWorldEvent args) { if (!_timing.IsFirstTimePredicted) diff --git a/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs b/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs index 0cb3ad144d..fcf6d4551f 100644 --- a/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs +++ b/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml.cs @@ -139,7 +139,7 @@ private void DrawDiagnosticGroups( var groupTitleText = $"{Loc.GetString( "health-analyzer-window-damage-group-text", - ("damageGroup", Loc.GetString("health-analyzer-window-damage-group-" + damageGroupId)), + ("damageGroup", _prototypes.Index(damageGroupId).LocalizedName), ("amount", damageAmount) )}"; @@ -170,7 +170,7 @@ private void DrawDiagnosticGroups( var damageString = Loc.GetString( "health-analyzer-window-damage-type-text", - ("damageType", Loc.GetString("health-analyzer-window-damage-type-" + type)), + ("damageType", _prototypes.Index(type).LocalizedName), ("amount", typeAmount) ); diff --git a/Content.Client/Implants/UI/ImplanterStatusControl.cs b/Content.Client/Implants/UI/ImplanterStatusControl.cs index f3f0cdea7d..e2ffabd17d 100644 --- a/Content.Client/Implants/UI/ImplanterStatusControl.cs +++ b/Content.Client/Implants/UI/ImplanterStatusControl.cs @@ -1,5 +1,6 @@ using Content.Client.Message; using Content.Client.Stylesheets; +using Content.Client.UserInterface.Controls; using Content.Shared.Implants.Components; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; @@ -17,7 +18,7 @@ public ImplanterStatusControl(ImplanterComponent parent) _parent = parent; _label = new RichTextLabel { StyleClasses = { StyleNano.StyleClassItemStatus } }; _label.MaxWidth = 350; - AddChild(_label); + AddChild(new ClipControl { Children = { _label } }); Update(); } @@ -42,17 +43,12 @@ private void Update() _ => Loc.GetString("injector-invalid-injector-toggle-mode") }; - var (implantName, implantDescription) = _parent.ImplanterSlot.HasItem switch - { - false => (Loc.GetString("implanter-empty-text"), ""), - true => (_parent.ImplantData.Item1, _parent.ImplantData.Item2), - }; - + var implantName = _parent.ImplanterSlot.HasItem + ? _parent.ImplantData.Item1 + : Loc.GetString("implanter-empty-text"); _label.SetMarkup(Loc.GetString("implanter-label", ("implantName", implantName), - ("implantDescription", implantDescription), - ("modeString", modeStringLocalized), - ("lineBreak", "\n"))); + ("modeString", modeStringLocalized))); } } diff --git a/Content.Client/Input/ContentContexts.cs b/Content.Client/Input/ContentContexts.cs index c54f5002ec..2b1361208d 100644 --- a/Content.Client/Input/ContentContexts.cs +++ b/Content.Client/Input/ContentContexts.cs @@ -38,6 +38,7 @@ public static void SetupContexts(IInputContextContainer contexts) common.AddFunction(ContentKeyFunctions.ZoomIn); common.AddFunction(ContentKeyFunctions.ResetZoom); common.AddFunction(ContentKeyFunctions.InspectEntity); + common.AddFunction(ContentKeyFunctions.ToggleRoundEndSummaryWindow); // Not in engine, because engine cannot check for sanbox/admin status before starting placement. common.AddFunction(ContentKeyFunctions.EditorCopyObject); @@ -59,6 +60,7 @@ public static void SetupContexts(IInputContextContainer contexts) human.AddFunction(ContentKeyFunctions.UseItemInHand); human.AddFunction(ContentKeyFunctions.AltUseItemInHand); human.AddFunction(ContentKeyFunctions.OpenCharacterMenu); + human.AddFunction(ContentKeyFunctions.OpenEmotesMenu); human.AddFunction(ContentKeyFunctions.OpenLanguageMenu); human.AddFunction(ContentKeyFunctions.ActivateItemInWorld); human.AddFunction(ContentKeyFunctions.ThrowItemInHand); diff --git a/Content.Client/Inventory/ClientInventorySystem.cs b/Content.Client/Inventory/ClientInventorySystem.cs index 7b98513a92..87cea4e3d2 100644 --- a/Content.Client/Inventory/ClientInventorySystem.cs +++ b/Content.Client/Inventory/ClientInventorySystem.cs @@ -199,7 +199,7 @@ public void UIInventoryActivate(string slot) public void UIInventoryStorageActivate(string slot) { - EntityManager.EntityNetManager?.SendSystemNetworkMessage(new OpenSlotStorageNetworkMessage(slot)); + EntityManager.RaisePredictiveEvent(new OpenSlotStorageNetworkMessage(slot)); } public void UIInventoryExamine(string slot, EntityUid uid) @@ -251,6 +251,7 @@ public sealed class SlotData public string SlotGroup => SlotDef.SlotGroup; public string SlotDisplayName => SlotDef.DisplayName; public string TextureName => "Slots/" + SlotDef.TextureName; + public string FullTextureName => SlotDef.FullTextureName; public SlotData(SlotDefinition slotDef, ContainerSlot? container = null, bool highlighted = false, bool blocked = false) diff --git a/Content.Client/Inventory/StrippableBoundUserInterface.cs b/Content.Client/Inventory/StrippableBoundUserInterface.cs index 4bb49fecc1..4ccede7f5d 100644 --- a/Content.Client/Inventory/StrippableBoundUserInterface.cs +++ b/Content.Client/Inventory/StrippableBoundUserInterface.cs @@ -222,7 +222,7 @@ private void UpdateEntityIcon(SlotControl button, EntityUid? entity) if (entity == null) { - button.SpriteView.SetEntity(null); + button.SetEntity(null); return; } @@ -234,7 +234,7 @@ private void UpdateEntityIcon(SlotControl button, EntityUid? entity) else return; - button.SpriteView.SetEntity(viewEnt); + button.SetEntity(viewEnt); } } } diff --git a/Content.Client/IoC/ClientContentIoC.cs b/Content.Client/IoC/ClientContentIoC.cs index 01c8f38281..8c2b676c2e 100644 --- a/Content.Client/IoC/ClientContentIoC.cs +++ b/Content.Client/IoC/ClientContentIoC.cs @@ -4,23 +4,20 @@ using Content.Client.Clickable; using Content.Client.DiscordAuth; using Content.Client.JoinQueue; -using Content.Client.Options; using Content.Client.Eui; using Content.Client.GhostKick; using Content.Client.Info; using Content.Client.Launcher; using Content.Client.Parallax.Managers; using Content.Client.Players.PlayTimeTracking; -using Content.Client.Preferences; using Content.Client.Screenshot; using Content.Client.Fullscreen; using Content.Client.Stylesheets; using Content.Client.Viewport; using Content.Client.Voting; -using Content.Shared.Administration; using Content.Shared.Administration.Logs; -using Content.Shared.Module; using Content.Client.Guidebook; +using Content.Client.Lobby; using Content.Client.Replay; using Content.Shared.Administration.Managers; using Content.Shared.Players.PlayTimeTracking; diff --git a/Content.Client/Items/UI/PollingItemStatusControl.cs b/Content.Client/Items/UI/PollingItemStatusControl.cs new file mode 100644 index 0000000000..39cffb06f6 --- /dev/null +++ b/Content.Client/Items/UI/PollingItemStatusControl.cs @@ -0,0 +1,28 @@ +using Robust.Client.UserInterface; +using Robust.Shared.Timing; + +namespace Content.Client.Items.UI; + +/// +/// A base for item status controls that poll data every frame. Avoids UI updates if data didn't change. +/// +/// The full status control data that is polled every frame. +public abstract class PollingItemStatusControl : Control where TData : struct, IEquatable +{ + private TData _lastData; + + protected override void FrameUpdate(FrameEventArgs args) + { + base.FrameUpdate(args); + + var newData = PollData(); + if (newData.Equals(_lastData)) + return; + + _lastData = newData; + Update(newData); + } + + protected abstract TData PollData(); + protected abstract void Update(in TData data); +} diff --git a/Content.Client/Labels/EntitySystems/HandLabelerSystem.cs b/Content.Client/Labels/EntitySystems/HandLabelerSystem.cs new file mode 100644 index 0000000000..e956014b2e --- /dev/null +++ b/Content.Client/Labels/EntitySystems/HandLabelerSystem.cs @@ -0,0 +1,18 @@ +using Content.Client.Labels.UI; +using Content.Shared.Labels; +using Content.Shared.Labels.Components; +using Content.Shared.Labels.EntitySystems; + +namespace Content.Client.Labels.EntitySystems; + +public sealed class HandLabelerSystem : SharedHandLabelerSystem +{ + protected override void UpdateUI(Entity ent) + { + if (UserInterfaceSystem.TryGetOpenUi(ent.Owner, HandLabelerUiKey.Key, out var bui) + && bui is HandLabelerBoundUserInterface cBui) + { + cBui.Reload(); + } + } +} diff --git a/Content.Client/Labels/UI/HandLabelerBoundUserInterface.cs b/Content.Client/Labels/UI/HandLabelerBoundUserInterface.cs index d393c43f93..555f1ff09e 100644 --- a/Content.Client/Labels/UI/HandLabelerBoundUserInterface.cs +++ b/Content.Client/Labels/UI/HandLabelerBoundUserInterface.cs @@ -1,4 +1,5 @@ using Content.Shared.Labels; +using Content.Shared.Labels.Components; using Robust.Client.GameObjects; namespace Content.Client.Labels.UI @@ -8,11 +9,14 @@ namespace Content.Client.Labels.UI /// public sealed class HandLabelerBoundUserInterface : BoundUserInterface { + [Dependency] private readonly IEntityManager _entManager = default!; + [ViewVariables] private HandLabelerWindow? _window; public HandLabelerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) { + IoCManager.InjectDependencies(this); } protected override void Open() @@ -27,24 +31,25 @@ protected override void Open() _window.OnClose += Close; _window.OnLabelChanged += OnLabelChanged; + Reload(); } private void OnLabelChanged(string newLabel) { - SendMessage(new HandLabelerLabelChangedMessage(newLabel)); + // Focus moment + if (_entManager.TryGetComponent(Owner, out HandLabelerComponent? labeler) && + labeler.AssignedLabel.Equals(newLabel)) + return; + + SendPredictedMessage(new HandLabelerLabelChangedMessage(newLabel)); } - /// - /// Update the UI state based on server-sent info - /// - /// - protected override void UpdateState(BoundUserInterfaceState state) + public void Reload() { - base.UpdateState(state); - if (_window == null || state is not HandLabelerBoundUserInterfaceState cast) + if (_window == null || !_entManager.TryGetComponent(Owner, out HandLabelerComponent? component)) return; - _window.SetCurrentLabel(cast.CurrentLabel); + _window.SetCurrentLabel(component.AssignedLabel); } protected override void Dispose(bool disposing) diff --git a/Content.Client/Labels/UI/HandLabelerWindow.xaml.cs b/Content.Client/Labels/UI/HandLabelerWindow.xaml.cs index 7706c31f85..6482cdc1cc 100644 --- a/Content.Client/Labels/UI/HandLabelerWindow.xaml.cs +++ b/Content.Client/Labels/UI/HandLabelerWindow.xaml.cs @@ -9,17 +9,40 @@ public sealed partial class HandLabelerWindow : DefaultWindow { public event Action? OnLabelChanged; + /// + /// Is the user currently entering text into the control? + /// + private bool _focused; + // TODO LineEdit Make this a bool on the LineEdit control + + private string _label = string.Empty; + public HandLabelerWindow() { RobustXamlLoader.Load(this); - LabelLineEdit.OnTextEntered += e => OnLabelChanged?.Invoke(e.Text); - LabelLineEdit.OnFocusExit += e => OnLabelChanged?.Invoke(e.Text); + LabelLineEdit.OnTextEntered += e => + { + _label = e.Text; + OnLabelChanged?.Invoke(_label); + }; + + LabelLineEdit.OnFocusEnter += _ => _focused = true; + LabelLineEdit.OnFocusExit += _ => + { + _focused = false; + LabelLineEdit.Text = _label; + }; } public void SetCurrentLabel(string label) { - LabelLineEdit.Text = label; + if (label == _label) + return; + + _label = label; + if (!_focused) + LabelLineEdit.Text = label; } } } diff --git a/Content.Client/LateJoin/LateJoinGui.cs b/Content.Client/LateJoin/LateJoinGui.cs index 1351aa9e86..1b2a87be72 100644 --- a/Content.Client/LateJoin/LateJoinGui.cs +++ b/Content.Client/LateJoin/LateJoinGui.cs @@ -2,15 +2,14 @@ using System.Numerics; using Content.Client.CrewManifest; using Content.Client.GameTicking.Managers; +using Content.Client.Lobby; using Content.Client.UserInterface.Controls; using Content.Client.Players.PlayTimeTracking; -using Content.Client.Preferences; using Content.Shared.CCVar; using Content.Shared.Customization.Systems; using Content.Shared.Preferences; using Content.Shared.Roles; using Content.Shared.StatusIcon; -using Microsoft.Win32.SafeHandles; using Robust.Client.Console; using Robust.Client.GameObjects; using Robust.Client.UserInterface; diff --git a/Content.Client/Lathe/UI/LatheMenu.xaml.cs b/Content.Client/Lathe/UI/LatheMenu.xaml.cs index ca8d256127..9e15f8239e 100644 --- a/Content.Client/Lathe/UI/LatheMenu.xaml.cs +++ b/Content.Client/Lathe/UI/LatheMenu.xaml.cs @@ -10,6 +10,8 @@ using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.XAML; +using Robust.Client.ResourceManagement; +using Robust.Client.Graphics; using Robust.Shared.Prototypes; namespace Content.Client.Lathe.UI; @@ -19,6 +21,8 @@ public sealed partial class LatheMenu : DefaultWindow { [Dependency] private readonly IEntityManager _entityManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly IResourceCache _resources = default!; + private EntityUid _owner; private readonly SpriteSystem _spriteSystem; private readonly LatheSystem _lathe; @@ -104,12 +108,21 @@ public void PopulateRecipes() RecipeList.Children.Clear(); foreach (var prototype in sortedRecipesToShow) { - var icon = prototype.Icon == null - ? _spriteSystem.GetPrototypeIcon(prototype.Result).Default - : _spriteSystem.Frame0(prototype.Icon); + List textures; + if (_prototypeManager.TryIndex(prototype.Result, out EntityPrototype? entityProto) && entityProto != null) + { + textures = SpriteComponent.GetPrototypeTextures(entityProto, _resources).Select(o => o.Default).ToList(); + } + else + { + textures = prototype.Icon == null + ? new List { _spriteSystem.GetPrototypeIcon(prototype.Result).Default } + : new List { _spriteSystem.Frame0(prototype.Icon) }; + } + var canProduce = _lathe.CanProduce(_owner, prototype, quantity); - var control = new RecipeControl(prototype, () => GenerateTooltipText(prototype), canProduce, icon); + var control = new RecipeControl(prototype, () => GenerateTooltipText(prototype), canProduce, textures); control.OnButtonPressed += s => { if (!int.TryParse(AmountLineEdit.Text, out var amount) || amount <= 0) diff --git a/Content.Client/Lathe/UI/RecipeControl.xaml b/Content.Client/Lathe/UI/RecipeControl.xaml index 2e02c8a614..d1371a026a 100644 --- a/Content.Client/Lathe/UI/RecipeControl.xaml +++ b/Content.Client/Lathe/UI/RecipeControl.xaml @@ -5,11 +5,15 @@ Margin="0" StyleClasses="ButtonSquare"> - + CanShrink="true" + /> diff --git a/Content.Client/Lathe/UI/RecipeControl.xaml.cs b/Content.Client/Lathe/UI/RecipeControl.xaml.cs index bf85ff7d93..47b6b5932c 100644 --- a/Content.Client/Lathe/UI/RecipeControl.xaml.cs +++ b/Content.Client/Lathe/UI/RecipeControl.xaml.cs @@ -2,8 +2,8 @@ using Robust.Client.AutoGenerated; using Robust.Client.Graphics; using Robust.Client.UserInterface; +using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; -using Robust.Shared.Graphics; namespace Content.Client.Lathe.UI; @@ -13,12 +13,12 @@ public sealed partial class RecipeControl : Control public Action? OnButtonPressed; public Func TooltipTextSupplier; - public RecipeControl(LatheRecipePrototype recipe, Func tooltipTextSupplier, bool canProduce, Texture? texture = null) + public RecipeControl(LatheRecipePrototype recipe, Func tooltipTextSupplier, bool canProduce, List textures) { RobustXamlLoader.Load(this); RecipeName.Text = recipe.Name; - RecipeTexture.Texture = texture; + RecipeTextures.Textures = textures; Button.Disabled = !canProduce; TooltipTextSupplier = tooltipTextSupplier; Button.TooltipSupplier = SupplyTooltip; diff --git a/Content.Client/Light/EntitySystems/ExpendableLightSystem.cs b/Content.Client/Light/EntitySystems/ExpendableLightSystem.cs index a2a7fb2531..8077406730 100644 --- a/Content.Client/Light/EntitySystems/ExpendableLightSystem.cs +++ b/Content.Client/Light/EntitySystems/ExpendableLightSystem.cs @@ -52,7 +52,7 @@ protected override void OnAppearanceChange(EntityUid uid, ExpendableLightCompone case ExpendableLightState.Lit: _audioSystem.Stop(comp.PlayingStream); comp.PlayingStream = _audioSystem.PlayPvs( - comp.LoopedSound, uid, SharedExpendableLightComponent.LoopedSoundParams)?.Entity; + comp.LoopedSound, uid)?.Entity; if (args.Sprite.LayerMapTryGet(ExpendableLightVisualLayers.Overlay, out var layerIdx, true)) { diff --git a/Content.Client/Preferences/ClientPreferencesManager.cs b/Content.Client/Lobby/ClientPreferencesManager.cs similarity index 99% rename from Content.Client/Preferences/ClientPreferencesManager.cs rename to Content.Client/Lobby/ClientPreferencesManager.cs index aca7159504..2926968657 100644 --- a/Content.Client/Preferences/ClientPreferencesManager.cs +++ b/Content.Client/Lobby/ClientPreferencesManager.cs @@ -10,7 +10,7 @@ using Robust.Shared.Prototypes; using Robust.Shared.Utility; -namespace Content.Client.Preferences +namespace Content.Client.Lobby { /// /// Receives and from the server during the initial diff --git a/Content.Client/Preferences/IClientPreferencesManager.cs b/Content.Client/Lobby/IClientPreferencesManager.cs similarity index 94% rename from Content.Client/Preferences/IClientPreferencesManager.cs rename to Content.Client/Lobby/IClientPreferencesManager.cs index e55d6b600c..1b72593ad0 100644 --- a/Content.Client/Preferences/IClientPreferencesManager.cs +++ b/Content.Client/Lobby/IClientPreferencesManager.cs @@ -1,7 +1,7 @@ using System; using Content.Shared.Preferences; -namespace Content.Client.Preferences +namespace Content.Client.Lobby { public interface IClientPreferencesManager { diff --git a/Content.Client/Lobby/LobbyState.cs b/Content.Client/Lobby/LobbyState.cs index bed52217a9..2e728f552a 100644 --- a/Content.Client/Lobby/LobbyState.cs +++ b/Content.Client/Lobby/LobbyState.cs @@ -3,8 +3,6 @@ using Content.Client.LateJoin; using Content.Client.Lobby.UI; using Content.Client.Message; -using Content.Client.Preferences; -using Content.Client.Preferences.UI; using Content.Client.UserInterface.Systems.Chat; using Content.Client.Voting; using Robust.Client; @@ -12,8 +10,6 @@ using Robust.Client.ResourceManagement; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; -using Robust.Shared.Configuration; -using Robust.Shared.Prototypes; using Robust.Shared.Timing; @@ -25,59 +21,39 @@ public sealed class LobbyState : Robust.Client.State.State [Dependency] private readonly IClientConsoleHost _consoleHost = default!; [Dependency] private readonly IEntityManager _entityManager = default!; [Dependency] private readonly IResourceCache _resourceCache = default!; - [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!; - [Dependency] private readonly IClientPreferencesManager _preferencesManager = default!; [Dependency] private readonly IGameTiming _gameTiming = default!; [Dependency] private readonly IVoteManager _voteManager = default!; - [Dependency] private readonly IConfigurationManager _configurationManager = default!; - - [ViewVariables] private CharacterSetupGui? _characterSetup; private ClientGameTicker _gameTicker = default!; private ContentAudioSystem _contentAudioSystem = default!; protected override Type? LinkedScreenType { get; } = typeof(LobbyGui); - private LobbyGui? _lobby; + public LobbyGui? Lobby; protected override void Startup() { if (_userInterfaceManager.ActiveScreen == null) return; - _lobby = (LobbyGui) _userInterfaceManager.ActiveScreen; + Lobby = (LobbyGui) _userInterfaceManager.ActiveScreen; var chatController = _userInterfaceManager.GetUIController(); _gameTicker = _entityManager.System(); _contentAudioSystem = _entityManager.System(); _contentAudioSystem.LobbySoundtrackChanged += UpdateLobbySoundtrackInfo; - _characterSetup = new CharacterSetupGui(_entityManager, _resourceCache, _preferencesManager, - _prototypeManager, _configurationManager); - LayoutContainer.SetAnchorPreset(_characterSetup, LayoutContainer.LayoutPreset.Wide); - _lobby.CharacterSetupState.AddChild(_characterSetup); chatController.SetMainChat(true); - _voteManager.SetPopupContainer(_lobby.VoteContainer); - - _characterSetup.CloseButton.OnPressed += _ => - { - _lobby.SwitchState(LobbyGui.LobbyGuiState.Default); - }; + _voteManager.SetPopupContainer(Lobby.VoteContainer); + LayoutContainer.SetAnchorPreset(Lobby, LayoutContainer.LayoutPreset.Wide); + Lobby.ServerName.Text = _baseClient.GameInfo?.ServerName; // The eye of refactor gazes upon you... - _characterSetup.SaveButton.OnPressed += _ => - { - _characterSetup.Save(); - _userInterfaceManager.GetUIController().UpdateCharacterUI(); - }; - - LayoutContainer.SetAnchorPreset(_lobby, LayoutContainer.LayoutPreset.Wide); - _lobby.ServerName.Text = _baseClient.GameInfo?.ServerName; //The eye of refactor gazes upon you... UpdateLobbyUi(); - _lobby.CharacterPreview.CharacterSetupButton.OnPressed += OnSetupPressed; - _lobby.ReadyButton.OnPressed += OnReadyPressed; - _lobby.ReadyButton.OnToggled += OnReadyToggled; + Lobby.CharacterPreview.CharacterSetupButton.OnPressed += OnSetupPressed; + Lobby.ReadyButton.OnPressed += OnReadyPressed; + Lobby.ReadyButton.OnToggled += OnReadyToggled; _gameTicker.InfoBlobUpdated += UpdateLobbyUi; _gameTicker.LobbyStatusUpdated += LobbyStatusUpdated; @@ -95,20 +71,23 @@ protected override void Shutdown() _voteManager.ClearPopupContainer(); - _lobby!.CharacterPreview.CharacterSetupButton.OnPressed -= OnSetupPressed; - _lobby!.ReadyButton.OnPressed -= OnReadyPressed; - _lobby!.ReadyButton.OnToggled -= OnReadyToggled; + Lobby!.CharacterPreview.CharacterSetupButton.OnPressed -= OnSetupPressed; + Lobby!.ReadyButton.OnPressed -= OnReadyPressed; + Lobby!.ReadyButton.OnToggled -= OnReadyToggled; - _lobby = null; + Lobby = null; + } - _characterSetup?.Dispose(); - _characterSetup = null; + public void SwitchState(LobbyGui.LobbyGuiState state) + { + // Yeah I hate this but LobbyState contains all the badness for now + Lobby?.SwitchState(state); } private void OnSetupPressed(BaseButton.ButtonEventArgs args) { SetReady(false); - _lobby!.SwitchState(LobbyGui.LobbyGuiState.CharacterSetup); + Lobby?.SwitchState(LobbyGui.LobbyGuiState.CharacterSetup); } private void OnReadyPressed(BaseButton.ButtonEventArgs args) @@ -128,20 +107,20 @@ public override void FrameUpdate(FrameEventArgs e) { if (_gameTicker.IsGameStarted) { - _lobby!.StartTime.Text = string.Empty; + Lobby!.StartTime.Text = string.Empty; var roundTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan); - _lobby!.StationTime.Text = Loc.GetString("lobby-state-player-status-round-time", ("hours", roundTime.Hours), ("minutes", roundTime.Minutes)); + Lobby!.StationTime.Text = Loc.GetString("lobby-state-player-status-round-time", ("hours", roundTime.Hours), ("minutes", roundTime.Minutes)); return; } - _lobby!.StationTime.Text = Loc.GetString("lobby-state-player-status-round-not-started"); + Lobby!.StationTime.Text = Loc.GetString("lobby-state-player-status-round-not-started"); string text; if (_gameTicker.Paused) text = Loc.GetString("lobby-state-paused"); else if (_gameTicker.StartTime < _gameTiming.CurTime) { - _lobby!.StartTime.Text = Loc.GetString("lobby-state-soon"); + Lobby!.StartTime.Text = Loc.GetString("lobby-state-soon"); return; } else @@ -156,7 +135,7 @@ public override void FrameUpdate(FrameEventArgs e) text = $"{difference.Minutes}:{difference.Seconds:D2}"; } - _lobby!.StartTime.Text = Loc.GetString("lobby-state-round-start-countdown-text", ("timeLeft", text)); + Lobby!.StartTime.Text = Loc.GetString("lobby-state-round-start-countdown-text", ("timeLeft", text)); } private void LobbyStatusUpdated() @@ -167,36 +146,36 @@ private void LobbyStatusUpdated() private void LobbyLateJoinStatusUpdated() { - _lobby!.ReadyButton.Disabled = _gameTicker.DisallowedLateJoin; + Lobby!.ReadyButton.Disabled = _gameTicker.DisallowedLateJoin; } private void UpdateLobbyUi() { if (_gameTicker.IsGameStarted) { - _lobby!.ReadyButton.Text = Loc.GetString("lobby-state-ready-button-join-state"); - _lobby!.ReadyButton.ToggleMode = false; - _lobby!.ReadyButton.Pressed = false; - _lobby!.ObserveButton.Disabled = false; + Lobby!.ReadyButton.Text = Loc.GetString("lobby-state-ready-button-join-state"); + Lobby!.ReadyButton.ToggleMode = false; + Lobby!.ReadyButton.Pressed = false; + Lobby!.ObserveButton.Disabled = false; } else { - _lobby!.StartTime.Text = string.Empty; - _lobby!.ReadyButton.Text = Loc.GetString(_lobby!.ReadyButton.Pressed ? "lobby-state-player-status-ready": "lobby-state-player-status-not-ready"); - _lobby!.ReadyButton.ToggleMode = true; - _lobby!.ReadyButton.Disabled = false; - _lobby!.ReadyButton.Pressed = _gameTicker.AreWeReady; - _lobby!.ObserveButton.Disabled = true; + Lobby!.StartTime.Text = string.Empty; + Lobby!.ReadyButton.Text = Loc.GetString(Lobby!.ReadyButton.Pressed ? "lobby-state-player-status-ready": "lobby-state-player-status-not-ready"); + Lobby!.ReadyButton.ToggleMode = true; + Lobby!.ReadyButton.Disabled = false; + Lobby!.ReadyButton.Pressed = _gameTicker.AreWeReady; + Lobby!.ObserveButton.Disabled = true; } if (_gameTicker.ServerInfoBlob != null) - _lobby!.ServerInfo.SetInfoBlob(_gameTicker.ServerInfoBlob); + Lobby!.ServerInfo.SetInfoBlob(_gameTicker.ServerInfoBlob); } private void UpdateLobbySoundtrackInfo(LobbySoundtrackChangedEvent ev) { if (ev.SoundtrackFilename == null) - _lobby!.LobbySong.SetMarkup(Loc.GetString("lobby-state-song-no-song-text")); + Lobby!.LobbySong.SetMarkup(Loc.GetString("lobby-state-song-no-song-text")); else if (ev.SoundtrackFilename != null && _resourceCache.TryGetResource(ev.SoundtrackFilename, out var lobbySongResource)) { @@ -214,16 +193,16 @@ private void UpdateLobbySoundtrackInfo(LobbySoundtrackChangedEvent ev) ("songTitle", title), ("songArtist", artist)); - _lobby!.LobbySong.SetMarkup(markup); + Lobby!.LobbySong.SetMarkup(markup); } } private void UpdateLobbyBackground() { if (_gameTicker.LobbyBackground != null) - _lobby!.Background.Texture = _resourceCache.GetResource(_gameTicker.LobbyBackground); + Lobby!.Background.Texture = _resourceCache.GetResource(_gameTicker.LobbyBackground); else - _lobby!.Background.Texture = null; + Lobby!.Background.Texture = null; } diff --git a/Content.Client/Lobby/LobbyUIController.cs b/Content.Client/Lobby/LobbyUIController.cs index 47ab651c10..ccefbb0aa4 100644 --- a/Content.Client/Lobby/LobbyUIController.cs +++ b/Content.Client/Lobby/LobbyUIController.cs @@ -3,156 +3,250 @@ using Content.Client.Inventory; using Content.Client.Lobby.UI; using Content.Client.Players.PlayTimeTracking; -using Content.Client.Preferences; -using Content.Client.Preferences.UI; +using Content.Shared.CCVar; +using Content.Shared.Clothing.Loadouts.Prototypes; using Content.Shared.Clothing.Loadouts.Systems; using Content.Shared.GameTicking; -using Content.Shared.Humanoid; +using Content.Shared.Humanoid.Markings; using Content.Shared.Humanoid.Prototypes; using Content.Shared.Preferences; using Content.Shared.Roles; +using Content.Shared.Traits; +using Robust.Client.Player; +using Robust.Client.ResourceManagement; using Robust.Client.State; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controllers; +using Robust.Shared.Configuration; using Robust.Shared.Map; using Robust.Shared.Prototypes; +using Robust.Shared.Utility; +using static Content.Shared.Humanoid.SharedHumanoidAppearanceSystem; +using CharacterSetupGui = Content.Client.Lobby.UI.CharacterSetupGui; +using HumanoidProfileEditor = Content.Client.Lobby.UI.HumanoidProfileEditor; namespace Content.Client.Lobby; public sealed class LobbyUIController : UIController, IOnStateEntered, IOnStateExited { [Dependency] private readonly IClientPreferencesManager _preferencesManager = default!; - [Dependency] private readonly IStateManager _stateManager = default!; + [Dependency] private readonly IConfigurationManager _configurationManager = default!; + [Dependency] private readonly IFileDialogManager _dialogManager = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly IResourceCache _resourceCache = default!; + [Dependency] private readonly IStateManager _stateManager = default!; + [Dependency] private readonly JobRequirementsManager _requirements = default!; + [Dependency] private readonly MarkingManager _markings = default!; [Dependency] private readonly JobRequirementsManager _jobRequirements = default!; [UISystemDependency] private readonly HumanoidAppearanceSystem _humanoid = default!; [UISystemDependency] private readonly ClientInventorySystem _inventory = default!; [UISystemDependency] private readonly LoadoutSystem _loadouts = default!; - private LobbyCharacterPanel? _previewPanel; + private CharacterSetupGui? _characterSetup; private HumanoidProfileEditor? _profileEditor; - /* - * Each character profile has its own dummy. There is also a dummy for the lobby screen + character editor - * that is shared too. - */ + /// This is the character preview panel in the chat. This should only update if their character updates + private LobbyCharacterPreviewPanel? PreviewPanel => GetLobbyPreview(); - /// - /// Preview dummy for role gear. - /// - private EntityUid? _previewDummy; + /// This is the modified profile currently being edited + private HumanoidCharacterProfile? EditedProfile => _profileEditor?.Profile; + private int? EditedSlot => _profileEditor?.CharacterSlot; - [Access(typeof(HumanoidProfileEditor))] - public bool UpdateClothes = true; - [Access(typeof(HumanoidProfileEditor))] - public bool ShowClothes = true; - [Access(typeof(HumanoidProfileEditor))] - public bool ShowLoadouts = true; - - // TODO: Load the species directly and don't update entity ever. - public event Action? PreviewDummyUpdated; public override void Initialize() { base.Initialize(); + _prototypeManager.PrototypesReloaded += OnPrototypesReloaded; _preferencesManager.OnServerDataLoaded += PreferencesDataLoaded; - } + _requirements.Updated += OnRequirementsUpdated; - private void PreferencesDataLoaded() - { - if (_previewDummy != null) - EntityManager.DeleteEntity(_previewDummy); + _configurationManager.OnValueChanged(CCVars.FlavorText, _ => _profileEditor?.RefreshFlavorText()); + _configurationManager.OnValueChanged(CCVars.GameRoleTimers, + _ => + { + _profileEditor?.RefreshAntags(); + _profileEditor?.RefreshJobs(); + }); - UpdateCharacterUI(); + _preferencesManager.OnServerDataLoaded += PreferencesDataLoaded; } public void OnStateEntered(LobbyState state) { + PreviewPanel?.SetLoaded(_preferencesManager.ServerDataLoaded); + ReloadCharacterSetup(); } public void OnStateExited(LobbyState state) { - EntityManager.DeleteEntity(_previewDummy); - _previewDummy = null; + PreviewPanel?.SetLoaded(false); + _characterSetup?.Dispose(); + _profileEditor?.Dispose(); + _characterSetup = null; + _profileEditor = null; } - public void SetPreviewPanel(LobbyCharacterPanel? panel) + + private void PreferencesDataLoaded() { - _previewPanel = panel; - UpdateCharacterUI(); + PreviewPanel?.SetLoaded(true); + + if (_stateManager.CurrentState is not LobbyState) + return; + + ReloadCharacterSetup(); } - public void SetProfileEditor(HumanoidProfileEditor? editor) + private LobbyCharacterPreviewPanel? GetLobbyPreview() { - _profileEditor = editor; - UpdateCharacterUI(); + return _stateManager.CurrentState is LobbyState lobby ? lobby.Lobby?.CharacterPreview : null; } - public void UpdateCharacterUI() + private void OnRequirementsUpdated() { - // Test moment - if (_stateManager.CurrentState is not LobbyState) + if (_profileEditor == null) return; - if (!_preferencesManager.ServerDataLoaded) - { - _previewPanel?.SetLoaded(false); + _profileEditor.RefreshAntags(); + _profileEditor.RefreshJobs(); + } + + private void OnPrototypesReloaded(PrototypesReloadedEventArgs obj) + { + if (_profileEditor == null) return; - } - var maybeProfile = _profileEditor?.Profile ?? (HumanoidCharacterProfile) _preferencesManager.Preferences!.SelectedCharacter; + if (obj.WasModified()) + _profileEditor.RefreshSpecies(); + + if (obj.WasModified()) + _profileEditor.RefreshAntags(); + + if (obj.WasModified() + || obj.WasModified()) + _profileEditor.RefreshJobs(); + + if (obj.WasModified()) + _profileEditor.UpdateTraits(null, true); + + if (obj.WasModified()) + _profileEditor.UpdateLoadouts(null, true); + } + + + /// Reloads every single character setup control + public void ReloadCharacterSetup() + { + RefreshLobbyPreview(); + var (characterGui, profileEditor) = EnsureGui(); + characterGui.ReloadCharacterPickers(); + profileEditor.SetProfile( + (HumanoidCharacterProfile?) _preferencesManager.Preferences?.SelectedCharacter, + _preferencesManager.Preferences?.SelectedCharacterIndex); + } + + /// Refreshes the character preview in the lobby chat + private void RefreshLobbyPreview() + { + if (PreviewPanel == null) + return; - if (_previewDummy == null - || maybeProfile.Species != EntityManager.GetComponent(_previewDummy.Value).Species) + // Get selected character, load it, then set it + var character = _preferencesManager.Preferences?.SelectedCharacter; + + if (character is not HumanoidCharacterProfile humanoid) { - RespawnDummy(maybeProfile); - _previewPanel?.SetSprite(_previewDummy!.Value); + PreviewPanel.SetSprite(EntityUid.Invalid); + PreviewPanel.SetSummaryText(string.Empty); + return; } - _previewPanel?.SetLoaded(true); + var dummy = LoadProfileEntity(humanoid, true); + PreviewPanel.SetSprite(dummy); + PreviewPanel.SetSummaryText(humanoid.Summary); + } + + private void SaveProfile() + { + DebugTools.Assert(EditedProfile != null); - if (_previewDummy == null) + if (EditedProfile == null || EditedSlot == null) return; - _previewPanel?.SetSummaryText(maybeProfile.Summary); - _humanoid.LoadProfile(_previewDummy.Value, maybeProfile); + var selected = _preferencesManager.Preferences?.SelectedCharacterIndex; + if (selected == null) + return; + _preferencesManager.UpdateCharacter(EditedProfile, EditedSlot.Value); + ReloadCharacterSetup(); + } - if (UpdateClothes) + private (CharacterSetupGui, HumanoidProfileEditor) EnsureGui() + { + if (_characterSetup != null && _profileEditor != null) { - RemoveDummyClothes(_previewDummy.Value); - if (ShowClothes) - GiveDummyJobClothes(_previewDummy.Value, GetPreferredJob(maybeProfile), maybeProfile); - if (ShowLoadouts) - _loadouts.ApplyCharacterLoadout(_previewDummy.Value, GetPreferredJob(maybeProfile), maybeProfile, - _jobRequirements.GetRawPlayTimeTrackers(), _jobRequirements.IsWhitelisted()); - UpdateClothes = false; + _characterSetup.Visible = true; + _profileEditor.Visible = true; + return (_characterSetup, _profileEditor); } - PreviewDummyUpdated?.Invoke(_previewDummy.Value); - } + _profileEditor = new HumanoidProfileEditor( + _preferencesManager, + _configurationManager, + EntityManager, + _dialogManager, + _playerManager, + _prototypeManager, + _requirements, + _markings); + _characterSetup = new CharacterSetupGui(EntityManager, _prototypeManager, _resourceCache, _preferencesManager, _profileEditor); - public void RespawnDummy(HumanoidCharacterProfile profile) - { - if (_previewDummy != null) - RemoveDummyClothes(_previewDummy.Value); + _characterSetup.CloseButton.OnPressed += _ => + { + // Reset sliders etc. + _profileEditor.SetProfile(null, null); + _profileEditor.Visible = false; + if (_stateManager.CurrentState is LobbyState lobbyGui) + { + lobbyGui.SwitchState(LobbyGui.LobbyGuiState.Default); + } + }; + + _profileEditor.Save += SaveProfile; + + _characterSetup.SelectCharacter += args => + { + _preferencesManager.SelectCharacter(args); + ReloadCharacterSetup(); + }; + + _characterSetup.DeleteCharacter += args => + { + _preferencesManager.DeleteCharacter(args); - EntityManager.DeleteEntity(_previewDummy); - _previewDummy = EntityManager.SpawnEntity( - _prototypeManager.Index(profile.Species).DollPrototype, MapCoordinates.Nullspace); + if (EditedSlot == args) + // Reload everything + ReloadCharacterSetup(); + else + // Only need to reload character pickers + _characterSetup?.ReloadCharacterPickers(); + }; - UpdateClothes = true; + if (_stateManager.CurrentState is LobbyState lobby) + lobby.Lobby?.CharacterSetupState.AddChild(_characterSetup); + + return (_characterSetup, _profileEditor); } - /// - /// Gets the highest priority job for the profile. - /// + #region Helpers + + /// Gets the highest priority job for the profile. public JobPrototype GetPreferredJob(HumanoidCharacterProfile profile) { var highPriorityJob = profile.JobPriorities.FirstOrDefault(p => p.Value == JobPriority.High).Key; - // ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract (what is ReSharper smoking?) return _prototypeManager.Index(highPriorityJob ?? SharedGameTicker.FallbackOverflowJob); } @@ -166,9 +260,7 @@ public void RemoveDummyClothes(EntityUid dummy) EntityManager.DeleteEntity(unequippedItem.Value); } - /// - /// Applies the highest priority job's clothes and loadouts to the dummy. - /// + /// Applies the highest priority job's clothes and loadouts to the dummy. public void GiveDummyJobClothesLoadout(EntityUid dummy, HumanoidCharacterProfile profile) { var job = GetPreferredJob(profile); @@ -176,9 +268,7 @@ public void GiveDummyJobClothesLoadout(EntityUid dummy, HumanoidCharacterProfile _loadouts.ApplyCharacterLoadout(dummy, job, profile, _jobRequirements.GetRawPlayTimeTrackers(), _jobRequirements.IsWhitelisted()); } - /// - /// Applies the specified job's clothes to the dummy. - /// + /// Applies the specified job's clothes to the dummy. public void GiveDummyJobClothes(EntityUid dummy, JobPrototype job, HumanoidCharacterProfile profile) { if (!_inventory.TryGetSlots(dummy, out var slots) @@ -202,8 +292,28 @@ public void GiveDummyJobClothes(EntityUid dummy, JobPrototype job, HumanoidChara } } - public EntityUid? GetPreviewDummy() + /// Loads the profile onto a dummy entity + public EntityUid LoadProfileEntity(HumanoidCharacterProfile? humanoid, bool jobClothes) { - return _previewDummy; + EntityUid dummyEnt; + + if (humanoid is not null) + { + var dummy = _prototypeManager.Index(humanoid.Species).DollPrototype; + dummyEnt = EntityManager.SpawnEntity(dummy, MapCoordinates.Nullspace); + } + else + dummyEnt = EntityManager.SpawnEntity( + _prototypeManager.Index(DefaultSpecies).DollPrototype, + MapCoordinates.Nullspace); + + _humanoid.LoadProfile(dummyEnt, humanoid); + + if (humanoid != null && jobClothes) + GiveDummyJobClothesLoadout(dummyEnt, humanoid); + + return dummyEnt; } + + #endregion } diff --git a/Content.Client/Lobby/UI/CharacterPickerButton.xaml b/Content.Client/Lobby/UI/CharacterPickerButton.xaml new file mode 100644 index 0000000000..fa428b9b61 --- /dev/null +++ b/Content.Client/Lobby/UI/CharacterPickerButton.xaml @@ -0,0 +1,11 @@ + + + + + [GenerateTypedNameReferences] + public sealed partial class CharacterSetupGui : Control + { + private readonly IClientPreferencesManager _preferencesManager; + private readonly IEntityManager _entManager; + private readonly IPrototypeManager _protomanager; + + private readonly Button _createNewCharacterButton; + + public event Action? SelectCharacter; + public event Action? DeleteCharacter; + + public CharacterSetupGui( + IEntityManager entManager, + IPrototypeManager protoManager, + IResourceCache resourceCache, + IClientPreferencesManager preferencesManager, + HumanoidProfileEditor profileEditor) + { + RobustXamlLoader.Load(this); + _preferencesManager = preferencesManager; + _entManager = entManager; + _protomanager = protoManager; + + var panelTex = resourceCache.GetTexture("/Textures/Interface/Nano/button.svg.96dpi.png"); + var back = new StyleBoxTexture + { + Texture = panelTex, + Modulate = new Color(37, 37, 42) + }; + back.SetPatchMargin(StyleBox.Margin.All, 10); + + BackgroundPanel.PanelOverride = back; + + _createNewCharacterButton = new Button + { + Text = Loc.GetString("character-setup-gui-create-new-character-button"), + }; + + _createNewCharacterButton.OnPressed += args => + { + preferencesManager.CreateCharacter(HumanoidCharacterProfile.Random()); + ReloadCharacterPickers(); + args.Event.Handle(); + }; + + CharEditor.AddChild(profileEditor); + RulesButton.OnPressed += _ => new RulesAndInfoWindow().Open(); + + StatsButton.OnPressed += _ => new PlaytimeStatsWindow().OpenCentered(); + } + + /// + /// Disposes and reloads all character picker buttons from the preferences data. + /// + public void ReloadCharacterPickers() + { + _createNewCharacterButton.Orphan(); + Characters.DisposeAllChildren(); + + var numberOfFullSlots = 0; + var characterButtonsGroup = new ButtonGroup(); + + if (!_preferencesManager.ServerDataLoaded) + { + return; + } + + _createNewCharacterButton.ToolTip = + Loc.GetString("character-setup-gui-create-new-character-button-tooltip", + ("maxCharacters", _preferencesManager.Settings!.MaxCharacterSlots)); + + var selectedSlot = _preferencesManager.Preferences?.SelectedCharacterIndex; + + foreach (var (slot, character) in _preferencesManager.Preferences!.Characters) + { + numberOfFullSlots++; + var characterPickerButton = new CharacterPickerButton(_entManager, + _protomanager, + characterButtonsGroup, + character, + slot == selectedSlot); + + Characters.AddChild(characterPickerButton); + + characterPickerButton.OnPressed += args => + { + SelectCharacter?.Invoke(slot); + }; + + characterPickerButton.OnDeletePressed += () => + { + DeleteCharacter?.Invoke(slot); + }; + } + + _createNewCharacterButton.Disabled = numberOfFullSlots >= _preferencesManager.Settings.MaxCharacterSlots; + Characters.AddChild(_createNewCharacterButton); + } + } +} diff --git a/Content.Client/Preferences/UI/HighlightedContainer.xaml b/Content.Client/Lobby/UI/HighlightedContainer.xaml similarity index 100% rename from Content.Client/Preferences/UI/HighlightedContainer.xaml rename to Content.Client/Lobby/UI/HighlightedContainer.xaml diff --git a/Content.Client/Preferences/UI/HighlightedContainer.xaml.cs b/Content.Client/Lobby/UI/HighlightedContainer.xaml.cs similarity index 88% rename from Content.Client/Preferences/UI/HighlightedContainer.xaml.cs rename to Content.Client/Lobby/UI/HighlightedContainer.xaml.cs index 68294d0f05..084c1c3709 100644 --- a/Content.Client/Preferences/UI/HighlightedContainer.xaml.cs +++ b/Content.Client/Lobby/UI/HighlightedContainer.xaml.cs @@ -2,7 +2,7 @@ using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; -namespace Content.Client.Preferences.UI; +namespace Content.Client.Lobby.UI; [GenerateTypedNameReferences] public sealed partial class HighlightedContainer : PanelContainer diff --git a/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml b/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml new file mode 100644 index 0000000000..df364546ba --- /dev/null +++ b/Content.Client/Lobby/UI/HumanoidProfileEditor.xaml @@ -0,0 +1,220 @@ + + + + + + + + + + + + + public AlignRCDConstruction(PlacementManager pMan) : base(pMan) { - var dependencies = IoCManager.Instance!; - _entityManager = dependencies.Resolve(); - _mapManager = dependencies.Resolve(); - _playerManager = dependencies.Resolve(); - _stateManager = dependencies.Resolve(); - + IoCManager.InjectDependencies(this); _mapSystem = _entityManager.System(); _rcdSystem = _entityManager.System(); _transformSystem = _entityManager.System(); diff --git a/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Position.cs b/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Position.cs index 2ee7e30ec9..d00e319eed 100644 --- a/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Position.cs +++ b/Content.Client/Replay/Spectator/ReplaySpectatorSystem.Position.cs @@ -195,9 +195,16 @@ private void OnParentChanged(EntityUid uid, ReplaySpectatorComponent component, if (uid != _player.LocalEntity) return; - if (args.Transform.MapUid != null || args.OldMapId == MapId.Nullspace) + if (args.Transform.MapUid != null || args.OldMapId == null) return; + if (_spectatorData != null) + { + // Currently scrubbing/setting the replay tick + // the observer will get respawned once the state was applied + return; + } + // The entity being spectated from was moved to null-space. // This was probably because they were spectating some entity in a client-side replay that left PVS range. // Simple respawn the ghost. diff --git a/Content.Client/Robotics/Systems/RoboticsConsoleSystem.cs b/Content.Client/Robotics/Systems/RoboticsConsoleSystem.cs new file mode 100644 index 0000000000..0219c965cd --- /dev/null +++ b/Content.Client/Robotics/Systems/RoboticsConsoleSystem.cs @@ -0,0 +1,7 @@ +using Content.Shared.Robotics.Systems; + +namespace Content.Client.Robotics.Systems; + +public sealed class RoboticsConsoleSystem : SharedRoboticsConsoleSystem +{ +} diff --git a/Content.Client/Robotics/UI/RoboticsConsoleBoundUserInterface.cs b/Content.Client/Robotics/UI/RoboticsConsoleBoundUserInterface.cs new file mode 100644 index 0000000000..6185979eee --- /dev/null +++ b/Content.Client/Robotics/UI/RoboticsConsoleBoundUserInterface.cs @@ -0,0 +1,50 @@ +using Content.Shared.Robotics; +using Robust.Client.GameObjects; + +namespace Content.Client.Robotics.UI; + +public sealed class RoboticsConsoleBoundUserInterface : BoundUserInterface +{ + [ViewVariables] + public RoboticsConsoleWindow _window = default!; + + public RoboticsConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) + { + } + + protected override void Open() + { + base.Open(); + + _window = new RoboticsConsoleWindow(Owner); + _window.OnDisablePressed += address => + { + SendMessage(new RoboticsConsoleDisableMessage(address)); + }; + _window.OnDestroyPressed += address => + { + SendMessage(new RoboticsConsoleDestroyMessage(address)); + }; + _window.OnClose += Close; + + _window.OpenCentered(); + } + + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + + if (state is not RoboticsConsoleState cast) + return; + + _window?.UpdateState(cast); + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + + if (disposing) + _window?.Dispose(); + } +} diff --git a/Content.Client/Robotics/UI/RoboticsConsoleWindow.xaml b/Content.Client/Robotics/UI/RoboticsConsoleWindow.xaml new file mode 100644 index 0000000000..a3b3978790 --- /dev/null +++ b/Content.Client/Robotics/UI/RoboticsConsoleWindow.xaml @@ -0,0 +1,40 @@ + + + + + + + + + +