forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master-ru' into 'master-ru'
Upstream update & Localization (Sec hud) See merge request Workbench-Team/space-station-14!102
- Loading branch information
Showing
212 changed files
with
23,429 additions
and
18,403 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using Content.Shared.Gateway; | ||
using JetBrains.Annotations; | ||
using Robust.Client.GameObjects; | ||
|
||
namespace Content.Client.Gateway.UI; | ||
|
||
[UsedImplicitly] | ||
public sealed class GatewayBoundUserInterface : BoundUserInterface | ||
{ | ||
private GatewayWindow? _window; | ||
|
||
public GatewayBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
{ | ||
} | ||
|
||
protected override void Open() | ||
{ | ||
base.Open(); | ||
|
||
_window = new GatewayWindow(); | ||
_window.OpenPortal += destination => | ||
{ | ||
SendMessage(new GatewayOpenPortalMessage(destination)); | ||
}; | ||
_window.OnClose += Close; | ||
_window?.OpenCentered(); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
base.Dispose(disposing); | ||
_window?.Dispose(); | ||
_window = null; | ||
} | ||
|
||
protected override void UpdateState(BoundUserInterfaceState state) | ||
{ | ||
base.UpdateState(state); | ||
|
||
if (state is not GatewayBoundUserInterfaceState current) | ||
return; | ||
|
||
_window?.UpdateState(current); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<controls:FancyWindow xmlns="https://spacestation14.io" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
Title="{Loc 'gateway-window-title'}" | ||
MinSize="800 360"> | ||
<BoxContainer Orientation="Vertical"> | ||
<BoxContainer Orientation="Horizontal"> | ||
<Label Name="NextCloseLabel" | ||
Text="{Loc 'gateway-window-portal-closing'}" | ||
Margin="5"></Label> | ||
<ProgressBar Name="NextCloseBar" | ||
HorizontalExpand="True" | ||
MinValue="0" | ||
MaxValue="1" | ||
SetHeight="25"/> | ||
<Label Name="NextCloseText" Text="0" Margin="5"/> | ||
</BoxContainer> | ||
<controls:HLine Color="#404040" Thickness="2" Margin="0 5 0 5"/> | ||
<BoxContainer Name="Container" | ||
Orientation="Vertical" | ||
Margin="5 0 5 0"/> | ||
</BoxContainer> | ||
</controls:FancyWindow> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,180 @@ | ||
using Content.Client.Computer; | ||
using Content.Client.Stylesheets; | ||
using Content.Client.UserInterface.Controls; | ||
using Content.Shared.Gateway; | ||
using Content.Shared.Shuttles.BUIStates; | ||
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.Timing; | ||
|
||
namespace Content.Client.Gateway.UI; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class GatewayWindow : FancyWindow, | ||
IComputerWindow<EmergencyConsoleBoundUserInterfaceState> | ||
{ | ||
private readonly IGameTiming _timing; | ||
|
||
public event Action<EntityUid>? OpenPortal; | ||
private List<(EntityUid, string, TimeSpan, bool)> _destinations = default!; | ||
private EntityUid? _current; | ||
private TimeSpan _nextClose; | ||
private TimeSpan _lastOpen; | ||
private List<Label> _readyLabels = default!; | ||
private List<Button> _openButtons = default!; | ||
|
||
public GatewayWindow() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
_timing = IoCManager.Resolve<IGameTiming>(); | ||
} | ||
|
||
public void UpdateState(GatewayBoundUserInterfaceState state) | ||
{ | ||
_destinations = state.Destinations; | ||
_current = state.Current; | ||
_nextClose = state.NextClose; | ||
_lastOpen = state.LastOpen; | ||
|
||
Container.DisposeAllChildren(); | ||
_readyLabels = new List<Label>(_destinations.Count); | ||
_openButtons = new List<Button>(_destinations.Count); | ||
|
||
if (_destinations.Count == 0) | ||
{ | ||
Container.AddChild(new BoxContainer() | ||
{ | ||
HorizontalExpand = true, | ||
VerticalExpand = true, | ||
Children = | ||
{ | ||
new Label() | ||
{ | ||
Text = Loc.GetString("gateway-window-no-destinations"), | ||
HorizontalAlignment = HAlignment.Center | ||
} | ||
} | ||
}); | ||
return; | ||
} | ||
|
||
var now = _timing.CurTime; | ||
foreach (var dest in _destinations) | ||
{ | ||
var uid = dest.Item1; | ||
var name = dest.Item2; | ||
var nextReady = dest.Item3; | ||
var busy = dest.Item4; | ||
|
||
var box = new BoxContainer() | ||
{ | ||
Orientation = BoxContainer.LayoutOrientation.Horizontal, | ||
Margin = new Thickness(5f, 5f) | ||
}; | ||
|
||
box.AddChild(new Label() | ||
{ | ||
Text = name | ||
}); | ||
|
||
var readyLabel = new Label | ||
{ | ||
Text = ReadyText(now, nextReady), | ||
Margin = new Thickness(10f, 0f, 0f, 0f) | ||
}; | ||
_readyLabels.Add(readyLabel); | ||
box.AddChild(readyLabel); | ||
|
||
var openButton = new Button() | ||
{ | ||
Text = Loc.GetString("gateway-window-open-portal"), | ||
Pressed = uid == _current, | ||
ToggleMode = true, | ||
Disabled = _current != null || busy || now < nextReady | ||
}; | ||
|
||
openButton.OnPressed += args => | ||
{ | ||
OpenPortal?.Invoke(uid); | ||
}; | ||
|
||
if (uid == state.Current) | ||
{ | ||
openButton.AddStyleClass(StyleBase.ButtonCaution); | ||
} | ||
|
||
_openButtons.Add(openButton); | ||
box.AddChild(new BoxContainer() | ||
{ | ||
HorizontalExpand = true, | ||
Align = BoxContainer.AlignMode.End, | ||
Children = | ||
{ | ||
openButton | ||
} | ||
}); | ||
|
||
Container.AddChild(new PanelContainer() | ||
{ | ||
PanelOverride = new StyleBoxFlat(new Color(30, 30, 34)), | ||
Margin = new Thickness(10f, 5f), | ||
Children = | ||
{ | ||
box | ||
} | ||
}); | ||
} | ||
} | ||
|
||
protected override void FrameUpdate(FrameEventArgs args) | ||
{ | ||
base.FrameUpdate(args); | ||
|
||
var now = _timing.CurTime; | ||
|
||
// if its not going to close then show it as empty | ||
if (_current == null) | ||
{ | ||
NextCloseBar.Value = 0f; | ||
NextCloseText.Text = "00:00"; | ||
} | ||
else | ||
{ | ||
var remaining = _nextClose - _timing.CurTime; | ||
if (remaining < TimeSpan.Zero) | ||
{ | ||
NextCloseBar.Value = 1f; | ||
NextCloseText.Text = "00:00"; | ||
} | ||
else | ||
{ | ||
var openTime = _nextClose - _lastOpen; | ||
NextCloseBar.Value = 1f - (float) (remaining / openTime); | ||
NextCloseText.Text = $"{remaining.Minutes:00}:{remaining.Seconds:00}"; | ||
} | ||
} | ||
|
||
for (var i = 0; i < _destinations.Count; i++) | ||
{ | ||
var dest = _destinations[i]; | ||
var nextReady = dest.Item3; | ||
var busy = dest.Item4; | ||
_readyLabels[i].Text = ReadyText(now, nextReady); | ||
_openButtons[i].Disabled = _current != null || busy || now < nextReady; | ||
} | ||
} | ||
|
||
private string ReadyText(TimeSpan now, TimeSpan nextReady) | ||
{ | ||
if (now < nextReady) | ||
{ | ||
var time = nextReady - now; | ||
return Loc.GetString("gateway-window-ready-in", ("time", $"{time.Minutes:00}:{time.Seconds:00}")); | ||
} | ||
|
||
return Loc.GetString("gateway-window-ready"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.