Viewport improvements (#3765)
This commit is contained in:
committed by
GitHub
parent
8e2fc49357
commit
147a54c642
@@ -6,6 +6,7 @@ using Content.Client.UserInterface;
|
||||
using Content.Client.Voting;
|
||||
using Content.Shared;
|
||||
using Content.Shared.Input;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Input;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
@@ -13,12 +14,16 @@ using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Client.State
|
||||
{
|
||||
public class GameScreen : GameScreenBase
|
||||
public class GameScreen : GameScreenBase, IMainViewportState
|
||||
{
|
||||
public static readonly Vector2i ViewportSize = (EyeManager.PixelsPerMeter * 21, EyeManager.PixelsPerMeter * 15);
|
||||
|
||||
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
|
||||
[Dependency] private readonly IGameHud _gameHud = default!;
|
||||
[Dependency] private readonly IInputManager _inputManager = default!;
|
||||
@@ -26,6 +31,8 @@ namespace Content.Client.State
|
||||
[Dependency] private readonly IVoteManager _voteManager = default!;
|
||||
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
|
||||
[Dependency] private readonly IClientAdminManager _adminManager = default!;
|
||||
[Dependency] private readonly IClyde _clyde = default!;
|
||||
[Dependency] private readonly IEyeManager _eyeManager = default!;
|
||||
|
||||
[ViewVariables] private ChatBox? _gameChat;
|
||||
private ConstructionMenuPresenter? _constructionMenu;
|
||||
@@ -33,15 +40,27 @@ namespace Content.Client.State
|
||||
private bool _oocEnabled;
|
||||
private bool _adminOocEnabled;
|
||||
|
||||
public MainViewport Viewport { get; private set; } = default!;
|
||||
|
||||
public override void Startup()
|
||||
{
|
||||
base.Startup();
|
||||
|
||||
_gameChat = new ChatBox();
|
||||
Viewport = new MainViewport
|
||||
{
|
||||
Viewport =
|
||||
{
|
||||
ViewportSize = ViewportSize
|
||||
}
|
||||
};
|
||||
|
||||
_userInterfaceManager.StateRoot.AddChild(Viewport);
|
||||
LayoutContainer.SetAnchorPreset(Viewport, LayoutContainer.LayoutPreset.Wide);
|
||||
Viewport.SetPositionFirst();
|
||||
|
||||
_userInterfaceManager.StateRoot.AddChild(_gameChat);
|
||||
LayoutContainer.SetAnchorAndMarginPreset(_gameChat, LayoutContainer.LayoutPreset.TopRight, margin: 10);
|
||||
LayoutContainer.SetAnchorAndMarginPreset(_gameChat, LayoutContainer.LayoutPreset.TopRight, margin: 10);
|
||||
LayoutContainer.SetMarginLeft(_gameChat, -475);
|
||||
LayoutContainer.SetMarginBottom(_gameChat, 235);
|
||||
|
||||
@@ -65,6 +84,8 @@ namespace Content.Client.State
|
||||
_adminManager.AdminStatusUpdated += OnAdminStatusUpdated;
|
||||
|
||||
SetupPresenters();
|
||||
|
||||
_eyeManager.MainViewport = Viewport.Viewport;
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
@@ -74,7 +95,10 @@ namespace Content.Client.State
|
||||
base.Shutdown();
|
||||
|
||||
_gameChat?.Dispose();
|
||||
Viewport.Dispose();
|
||||
_gameHud.RootControl.Orphan();
|
||||
// Clear viewport to some fallback, whatever.
|
||||
_eyeManager.MainViewport = _userInterfaceManager.MainViewport;
|
||||
|
||||
}
|
||||
|
||||
@@ -168,5 +192,12 @@ namespace Content.Client.State
|
||||
chat.Input.GrabKeyboardFocus();
|
||||
chat.Input.InsertAtCursor("]");
|
||||
}
|
||||
|
||||
public override void FrameUpdate(FrameEventArgs e)
|
||||
{
|
||||
base.FrameUpdate(e);
|
||||
|
||||
Viewport.Viewport.Eye = _eyeManager.CurrentEye;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user