1
0

DefaultGameScreen.xaml.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. using System.Numerics;
  2. using Content.Client.UserInterface.Systems.Chat.Widgets;
  3. using Robust.Client.AutoGenerated;
  4. using Robust.Client.UserInterface.XAML;
  5. namespace Content.Client.UserInterface.Screens;
  6. [GenerateTypedNameReferences]
  7. public sealed partial class DefaultGameScreen : InGameScreen
  8. {
  9. public DefaultGameScreen()
  10. {
  11. RobustXamlLoader.Load(this);
  12. AutoscaleMaxResolution = new Vector2i(1080, 770);
  13. SetAnchorPreset(MainViewport, LayoutPreset.Wide);
  14. SetAnchorPreset(ViewportContainer, LayoutPreset.Wide);
  15. SetAnchorAndMarginPreset(TopLeft, LayoutPreset.TopLeft, margin: 10);
  16. SetAnchorAndMarginPreset(Ghost, LayoutPreset.BottomWide, margin: 80);
  17. SetAnchorAndMarginPreset(Inventory, LayoutPreset.BottomLeft, margin: 5);
  18. SetAnchorAndMarginPreset(Hotbar, LayoutPreset.BottomWide, margin: 5);
  19. SetAnchorAndMarginPreset(Chat, LayoutPreset.TopRight, margin: 10);
  20. SetAnchorAndMarginPreset(Alerts, LayoutPreset.TopRight, margin: 10);
  21. SetAnchorAndMarginPreset(Targeting, LayoutPreset.BottomRight, margin: 5); // Shitmed Change
  22. Chat.OnResized += ChatOnResized;
  23. Chat.OnChatResizeFinish += ChatOnResizeFinish;
  24. MainViewport.OnResized += ResizeActionContainer;
  25. Inventory.OnResized += ResizeActionContainer;
  26. }
  27. private void ResizeActionContainer()
  28. {
  29. float indent = Inventory.Size.Y + TopBar.Size.Y + 40;
  30. Actions.ActionsContainer.MaxGridHeight = MainViewport.Size.Y - indent;
  31. }
  32. private void ChatOnResizeFinish(Vector2 _)
  33. {
  34. var marginBottom = Chat.GetValue<float>(MarginBottomProperty);
  35. var marginLeft = Chat.GetValue<float>(MarginLeftProperty);
  36. OnChatResized?.Invoke(new Vector2(marginBottom, marginLeft));
  37. }
  38. private void ChatOnResized()
  39. {
  40. var marginBottom = Chat.GetValue<float>(MarginBottomProperty);
  41. SetMarginTop(Alerts, marginBottom);
  42. }
  43. public override ChatBox ChatBox => Chat;
  44. //TODO: There's probably a better way to do this... but this is also the easiest way.
  45. public override void SetChatSize(Vector2 size)
  46. {
  47. SetMarginBottom(Chat, size.X);
  48. SetMarginLeft(Chat, size.Y);
  49. SetMarginTop(Alerts, size.X);
  50. }
  51. }