diff --git a/Content.Client/UserInterface/Screens/DefaultGameScreen.xaml b/Content.Client/UserInterface/Screens/DefaultGameScreen.xaml index a6d489147a..703bf60e95 100644 --- a/Content.Client/UserInterface/Screens/DefaultGameScreen.xaml +++ b/Content.Client/UserInterface/Screens/DefaultGameScreen.xaml @@ -15,7 +15,14 @@ - + + + + + + + + diff --git a/Content.Client/UserInterface/Screens/DefaultGameScreen.xaml.cs b/Content.Client/UserInterface/Screens/DefaultGameScreen.xaml.cs index ea69597ce2..acaefeafa7 100644 --- a/Content.Client/UserInterface/Screens/DefaultGameScreen.xaml.cs +++ b/Content.Client/UserInterface/Screens/DefaultGameScreen.xaml.cs @@ -1,7 +1,5 @@ using Content.Client.UserInterface.Systems.Chat.Widgets; using Robust.Client.AutoGenerated; -using Robust.Client.UserInterface; -using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; namespace Content.Client.UserInterface.Screens; @@ -17,7 +15,7 @@ public sealed partial class DefaultGameScreen : InGameScreen SetAnchorPreset(MainViewport, LayoutPreset.Wide); SetAnchorPreset(ViewportContainer, LayoutPreset.Wide); - SetAnchorAndMarginPreset(TopBar, LayoutPreset.TopLeft, margin: 10); + SetAnchorAndMarginPreset(TopLeft, LayoutPreset.TopLeft, margin: 10); SetAnchorAndMarginPreset(Actions, LayoutPreset.BottomLeft, margin: 10); SetAnchorAndMarginPreset(Ghost, LayoutPreset.BottomWide, margin: 80); SetAnchorAndMarginPreset(Hotbar, LayoutPreset.BottomWide, margin: 5); diff --git a/Content.Client/UserInterface/Screens/SeparatedChatGameScreen.xaml b/Content.Client/UserInterface/Screens/SeparatedChatGameScreen.xaml index 80e56694f3..de3804edd5 100644 --- a/Content.Client/UserInterface/Screens/SeparatedChatGameScreen.xaml +++ b/Content.Client/UserInterface/Screens/SeparatedChatGameScreen.xaml @@ -16,6 +16,7 @@ + diff --git a/Content.Client/UserInterface/Screens/SeparatedChatGameScreen.xaml.cs b/Content.Client/UserInterface/Screens/SeparatedChatGameScreen.xaml.cs index da7903766f..7ee01516ff 100644 --- a/Content.Client/UserInterface/Screens/SeparatedChatGameScreen.xaml.cs +++ b/Content.Client/UserInterface/Screens/SeparatedChatGameScreen.xaml.cs @@ -1,6 +1,5 @@ using Content.Client.UserInterface.Systems.Chat.Widgets; using Robust.Client.AutoGenerated; -using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; @@ -18,6 +17,7 @@ public sealed partial class SeparatedChatGameScreen : InGameScreen SetAnchorPreset(ScreenContainer, LayoutPreset.Wide); SetAnchorPreset(ViewportContainer, LayoutPreset.Wide); SetAnchorPreset(MainViewport, LayoutPreset.Wide); + SetAnchorAndMarginPreset(VoteMenu, LayoutPreset.TopLeft, margin: 10); SetAnchorAndMarginPreset(Actions, LayoutPreset.BottomLeft, margin: 10); SetAnchorAndMarginPreset(Ghost, LayoutPreset.BottomWide, margin: 80); SetAnchorAndMarginPreset(Hotbar, LayoutPreset.BottomWide, margin: 5); diff --git a/Content.Client/UserInterface/Systems/Vote/VoteUIController.cs b/Content.Client/UserInterface/Systems/Vote/VoteUIController.cs new file mode 100644 index 0000000000..809134bbb2 --- /dev/null +++ b/Content.Client/UserInterface/Systems/Vote/VoteUIController.cs @@ -0,0 +1,37 @@ +using Content.Client.UserInterface.Screens; +using Content.Client.UserInterface.Systems.Gameplay; +using Content.Client.Voting; +using Robust.Client.UserInterface.Controllers; + +namespace Content.Client.UserInterface.Systems.Vote; + +public sealed class VoteUIController : UIController +{ + [Dependency] private readonly IVoteManager _votes = default!; + + public override void Initialize() + { + base.Initialize(); + var gameplayStateLoad = UIManager.GetUIController(); + gameplayStateLoad.OnScreenLoad += OnScreenLoad; + gameplayStateLoad.OnScreenUnload += OnScreenUnload; + } + + private void OnScreenLoad() + { + switch (UIManager.ActiveScreen) + { + case DefaultGameScreen game: + _votes.SetPopupContainer(game.VoteMenu); + break; + case SeparatedChatGameScreen separated: + _votes.SetPopupContainer(separated.VoteMenu); + break; + } + } + + private void OnScreenUnload() + { + _votes.ClearPopupContainer(); + } +} diff --git a/Content.Client/Voting/VoteManager.cs b/Content.Client/Voting/VoteManager.cs index e379ca6803..a587ec7240 100644 --- a/Content.Client/Voting/VoteManager.cs +++ b/Content.Client/Voting/VoteManager.cs @@ -95,6 +95,13 @@ namespace Content.Client.Voting } _popupContainer = container; + SetVoteData(); + } + + private void SetVoteData() + { + if (_popupContainer == null) + return; foreach (var (vId, vote) in _votes) { @@ -121,9 +128,13 @@ namespace Content.Client.Voting @new = true; IoCManager.Resolve().GetEntitySystem() .PlayGlobal("/Audio/Effects/voteding.ogg", Filter.Local(), false); - // TODO: It would be better if this used a per-state container, i.e. a container - // for the lobby and each HUD layout. - SetPopupContainer(_userInterfaceManager.WindowRoot); + + // Refresh + var container = _popupContainer; + ClearPopupContainer(); + + if (container != null) + SetPopupContainer(container); // New vote from the server. var vote = new ActiveVote(voteId) @@ -142,6 +153,7 @@ namespace Content.Client.Voting _votes.Remove(voteId); if (_votePopups.TryGetValue(voteId, out var toRemove)) { + toRemove.Orphan(); _votePopups.Remove(voteId); }