Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Удобный монитор камер и портативный мониторинг для детектива. #25

Merged
merged 3 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace Content.Client.SurveillanceCamera;
[RegisterComponent]
public sealed partial class ActiveSurveillanceCameraMonitorVisualsComponent : Component
{
public float TimeLeft = 10f;
public float TimeLeft = 0.5f; // Sunrise-edit

public Action? OnFinish;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,34 @@ public sealed class SurveillanceCameraMonitorBoundUserInterface : BoundUserInter

[ViewVariables]
private EntityUid? _currentCamera;
private readonly IEntityManager _entManager; // Sunrise-edit

public SurveillanceCameraMonitorBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
_eyeLerpingSystem = EntMan.System<EyeLerpingSystem>();
_surveillanceCameraMonitorSystem = EntMan.System<SurveillanceCameraMonitorSystem>();
// Sunrise-start
IoCManager.InjectDependencies(this);
_entManager = IoCManager.Resolve<IEntityManager>();
_eyeLerpingSystem = _entManager.EntitySysManager.GetEntitySystem<EyeLerpingSystem>();
_surveillanceCameraMonitorSystem = _entManager.EntitySysManager.GetEntitySystem<SurveillanceCameraMonitorSystem>();
// Sunrise-end
}

protected override void Open()
{
base.Open();

_window = new SurveillanceCameraMonitorWindow();
// Sunrise-start
EntityUid? gridUid = null;

if (_entManager.TryGetComponent<TransformComponent>(Owner, out var xform))
{
gridUid = xform.GridUid;
}

_window = new SurveillanceCameraMonitorWindow(gridUid);
// Sunrise-end

if (State != null)
{
Expand All @@ -35,22 +51,16 @@ protected override void Open()
_window.OpenCentered();

_window.CameraSelected += OnCameraSelected;
_window.SubnetOpened += OnSubnetRequest;
_window.CameraRefresh += OnCameraRefresh;
_window.SubnetRefresh += OnSubnetRefresh;
_window.OnClose += Close;
_window.CameraSwitchTimer += OnCameraSwitchTimer;
_window.CameraDisconnect += OnCameraDisconnect;
}

private void OnCameraSelected(string address)
private void OnCameraSelected(string cameraAddress, string subnetAddress) // Sunrise-edit
{
SendMessage(new SurveillanceCameraMonitorSwitchMessage(address));
}

private void OnSubnetRequest(string subnet)
{
SendMessage(new SurveillanceCameraMonitorSubnetRequestMessage(subnet));
SendMessage(new SurveillanceCameraMonitorSwitchMessage(cameraAddress, subnetAddress)); // Sunrise-edit
}

private void OnCameraSwitchTimer()
Expand Down Expand Up @@ -82,9 +92,11 @@ protected override void UpdateState(BoundUserInterfaceState state)

var active = EntMan.GetEntity(cast.ActiveCamera);

_entManager.TryGetComponent<TransformComponent>(Owner, out var xform); // Sunrise-edit

if (active == null)
{
_window.UpdateState(null, cast.Subnets, cast.ActiveAddress, cast.ActiveSubnet, cast.Cameras);
_window.UpdateState(null, cast.ActiveAddress, cast.ActiveCamera); // Sunrise-edit

if (_currentCamera != null)
{
Expand All @@ -109,9 +121,11 @@ protected override void UpdateState(BoundUserInterfaceState state)

if (EntMan.TryGetComponent<EyeComponent>(active, out var eye))
{
_window.UpdateState(eye.Eye, cast.Subnets, cast.ActiveAddress, cast.ActiveSubnet, cast.Cameras);
_window.UpdateState(eye.Eye, cast.ActiveAddress, cast.ActiveCamera); // Sunrise-edit
}
}

_window.ShowCameras(cast.Cameras, xform?.Coordinates); // Sunrise-edit
}

protected override void Dispose(bool disposing)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:viewport="clr-namespace:Content.Client.Viewport"
Title="{Loc 'surveillance-camera-monitor-ui-window'}">
<BoxContainer Orientation="Horizontal">
<BoxContainer Orientation="Vertical" MinWidth="350" VerticalExpand="True">
<!-- lazy -->
<OptionButton Name="SubnetSelector" />
<Button Name="SubnetRefreshButton" Text="{Loc 'surveillance-camera-monitor-ui-refresh-subnets'}" />
<ScrollContainer VerticalExpand="True">
<ItemList Name="SubnetList" />
</ScrollContainer>
<Button Name="CameraRefreshButton" Text="{Loc 'surveillance-camera-monitor-ui-refresh-cameras'}" />
<Button Name="CameraDisconnectButton" Text="{Loc 'surveillance-camera-monitor-ui-disconnect'}" />
<Label Name="CameraStatus" />
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:viewport="clr-namespace:Content.Client.Viewport"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:ui="clr-namespace:Content.Client.SurveillanceCamera.UI"
xmlns:customControls="clr-namespace:Content.Client.Administration.UI.CustomControls"
Title="{Loc 'surveillance-camera-monitor-ui-window'}"
Resizable="False"
MinSize="1300 750">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Horizontal" VerticalExpand="True" HorizontalExpand="True">
<ui:SurveillanceCameraNavMapControl Name="NavMap" HorizontalExpand="True" VerticalExpand="True" MinSize="600 700" VerticalAlignment="Top"/>
<customControls:VSeparator/>
<BoxContainer Orientation="Vertical">
<Control VerticalExpand="True" HorizontalExpand="True" Margin="5 5 5 5" Name="CameraViewBox">
<viewport:ScalingViewport Name="CameraView"
VerticalExpand="True"
HorizontalExpand="True"
MinSize="700 700"
MouseFilter="Ignore" />
<TextureRect VerticalExpand="True" HorizontalExpand="True" MinSize="700 700" Name="CameraViewBackground" />
</Control>
<BoxContainer Orientation="Vertical">
<Button Name="SubnetRefreshButton" Text="{Loc 'surveillance-camera-monitor-ui-refresh-subnets'}" />
<Button Name="CameraRefreshButton" Text="{Loc 'surveillance-camera-monitor-ui-refresh-cameras'}" />
<Button Name="CameraDisconnectButton" Text="{Loc 'surveillance-camera-monitor-ui-disconnect'}" />
<Label Name="CameraStatus" />
</BoxContainer>
</BoxContainer>
</BoxContainer>
<BoxContainer Orientation="Vertical">
<PanelContainer StyleClasses="LowDivider" />
<BoxContainer Orientation="Horizontal" Margin="10 2 5 0" VerticalAlignment="Bottom">
<Label Text="{Loc 'surveillance-camera-monitor-ui-flavor-left'}" StyleClasses="WindowFooterText" />
<Label Text="{Loc 'surveillance-camera-monitor-ui-flavor-right'}" StyleClasses="WindowFooterText"
HorizontalAlignment="Right" HorizontalExpand="True" Margin="0 0 5 0" />
<TextureRect StyleClasses="NTLogoDark" Stretch="KeepAspectCentered"
VerticalAlignment="Center" HorizontalAlignment="Right" SetSize="19 19"/>
</BoxContainer>
</BoxContainer>
<Control VerticalExpand="True" HorizontalExpand="True" Margin="5 5 5 5" Name="CameraViewBox">
<viewport:ScalingViewport Name="CameraView"
VerticalExpand="True"
HorizontalExpand="True"
MinSize="500 500"
MouseFilter="Ignore" />
<TextureRect VerticalExpand="True" HorizontalExpand="True" MinSize="500 500" Name="CameraViewBackground" />
</Control>
</BoxContainer>
</DefaultWindow>
</controls:FancyWindow>
Loading
Loading