-
Notifications
You must be signed in to change notification settings - Fork 348
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into merge-master-08/10
- Loading branch information
Showing
266 changed files
with
6,508 additions
and
142 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
39 changes: 39 additions & 0 deletions
39
Content.Client/Nyanotrasen/CartridgeLoader/Cartridges/GlimmerMonitorUi.cs
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,39 @@ | ||
using Robust.Client.GameObjects; | ||
using Robust.Client.UserInterface; | ||
using Content.Client.UserInterface.Fragments; | ||
using Content.Shared.CartridgeLoader.Cartridges; | ||
using Content.Shared.CartridgeLoader; | ||
|
||
namespace Content.Client.Nyanotrasen.CartridgeLoader.Cartridges; | ||
|
||
public sealed partial class GlimmerMonitorUi : UIFragment | ||
{ | ||
private GlimmerMonitorUiFragment? _fragment; | ||
|
||
public override Control GetUIFragmentRoot() | ||
{ | ||
return _fragment!; | ||
} | ||
|
||
public override void Setup(BoundUserInterface userInterface, EntityUid? fragmentOwner) | ||
{ | ||
_fragment = new GlimmerMonitorUiFragment(); | ||
|
||
_fragment.OnSync += _ => SendSyncMessage(userInterface); | ||
} | ||
|
||
public override void UpdateState(BoundUserInterfaceState state) | ||
{ | ||
if (state is not GlimmerMonitorUiState monitorState) | ||
return; | ||
|
||
_fragment?.UpdateState(monitorState.GlimmerValues); | ||
} | ||
|
||
private void SendSyncMessage(BoundUserInterface userInterface) | ||
{ | ||
var syncMessage = new GlimmerMonitorSyncMessageEvent(); | ||
var message = new CartridgeUiMessage(syncMessage); | ||
userInterface.SendMessage(message); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Content.Client/Nyanotrasen/CartridgeLoader/Cartridges/GlimmerMonitorUiFragment.xaml
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,13 @@ | ||
<cartridges:GlimmerMonitorUiFragment xmlns:cartridges="clr-namespace:Content.Client.Nyanotrasen.CartridgeLoader.Cartridges" | ||
xmlns="https://spacestation14.io" Margin="1 0 2 0"> | ||
<PanelContainer StyleClasses="BackgroundDark"></PanelContainer> | ||
<BoxContainer Name="SettingsBox" Orientation="Horizontal" HorizontalExpand="True" VerticalExpand="False"> | ||
<Label Text="{Loc 'glimmer-monitor-interval'}"/> | ||
<Button Name="IntervalButton1" Access="Public" Text="1m" StyleClasses="OpenRight"/> | ||
<Button Name="IntervalButton5" Access="Public" Text="5m" StyleClasses="OpenBoth"/> | ||
<Button Name="IntervalButton10" Access="Public" Text="10m" StyleClasses="OpenLeft"/> | ||
<Button Name="SyncButton" Access="Public" Text="{Loc 'glimmer-monitor-sync'}" Margin="200 0 0 0" /> | ||
</BoxContainer> | ||
<BoxContainer Name="MonitorBox" Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True"> | ||
</BoxContainer> | ||
</cartridges:GlimmerMonitorUiFragment> |
116 changes: 116 additions & 0 deletions
116
Content.Client/Nyanotrasen/CartridgeLoader/Cartridges/GlimmerMonitorUiFragment.xaml.cs
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,116 @@ | ||
using System.Linq; | ||
using System.Numerics; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.ResourceManagement; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Content.Client.Nyanotrasen.UserInterface.CustomControls; | ||
|
||
namespace Content.Client.Nyanotrasen.CartridgeLoader.Cartridges; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class GlimmerMonitorUiFragment : BoxContainer | ||
{ | ||
[Dependency] private readonly IResourceCache _resourceCache = default!; | ||
|
||
public event Action<bool>? OnSync; | ||
private List<int> _cachedValues = new(); | ||
|
||
public GlimmerMonitorUiFragment() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
IoCManager.InjectDependencies(this); | ||
|
||
Orientation = LayoutOrientation.Vertical; | ||
HorizontalExpand = true; | ||
VerticalExpand = true; | ||
|
||
var intervalGroup = new ButtonGroup(); | ||
IntervalButton1.Group = intervalGroup; | ||
IntervalButton5.Group = intervalGroup; | ||
IntervalButton10.Group = intervalGroup; | ||
|
||
IntervalButton1.Pressed = true; | ||
|
||
IntervalButton1.OnPressed += _ => UpdateState(_cachedValues); | ||
IntervalButton5.OnPressed += _ => UpdateState(_cachedValues); | ||
IntervalButton10.OnPressed += _ => UpdateState(_cachedValues); | ||
|
||
SyncButton.OnPressed += _ => OnSync?.Invoke(true); | ||
} | ||
|
||
public void UpdateState(List<int> glimmerValues) | ||
{ | ||
_cachedValues = glimmerValues; | ||
if (glimmerValues.Count < 1) | ||
return; | ||
|
||
MonitorBox.RemoveAllChildren(); | ||
|
||
var glimmerLabel = new Label(); | ||
glimmerLabel.Text = Loc.GetString("glimmer-monitor-current-glimmer", ("glimmer", glimmerValues[^1])); | ||
MonitorBox.AddChild(glimmerLabel); | ||
|
||
var formattedValues = FormatGlimmerValues(glimmerValues); | ||
var graph = new GlimmerGraph(_resourceCache, formattedValues); | ||
graph.SetSize = new Vector2(450, 250); | ||
MonitorBox.AddChild(graph); | ||
} | ||
|
||
|
||
private List<int> FormatGlimmerValues(List<int> glimmerValues) | ||
{ | ||
var returnList = glimmerValues; | ||
|
||
if (IntervalButton5.Pressed) | ||
{ | ||
returnList = GetAveragedList(glimmerValues, 5); | ||
} | ||
else if (IntervalButton10.Pressed) | ||
{ | ||
returnList = GetAveragedList(glimmerValues, 10); | ||
} | ||
|
||
return ClipToFifteen(returnList); | ||
} | ||
|
||
/// <summary> | ||
/// Format glimmer values to get <=15 data points correctly. | ||
/// </summary> | ||
private List<int> ClipToFifteen(List<int> glimmerValues) | ||
{ | ||
List<int> returnList; | ||
|
||
if (glimmerValues.Count <= 15) | ||
{ | ||
returnList = glimmerValues; | ||
} | ||
else | ||
{ | ||
returnList = glimmerValues.Skip(glimmerValues.Count - 15).ToList(); | ||
} | ||
|
||
return returnList; | ||
} | ||
|
||
private List<int> GetAveragedList(IEnumerable<int> glimmerValues, int interval) | ||
{ | ||
var returnList = new List<int>(); | ||
var subtotal = 0; | ||
var elementsPassed = 0; | ||
for (int i = 0; i < glimmerValues.Count(); ++i) | ||
{ | ||
subtotal += glimmerValues.ElementAt(i); | ||
++elementsPassed; | ||
if (elementsPassed == interval) | ||
{ | ||
returnList.Add(subtotal / interval); | ||
subtotal = 0; | ||
elementsPassed = 0; | ||
} | ||
} | ||
if (elementsPassed != 0) | ||
returnList.Add(subtotal / elementsPassed); | ||
return returnList; | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
Content.Client/Nyanotrasen/Chat/PsionicChatUpdateSystem.cs
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,32 @@ | ||
using Content.Shared.Abilities.Psionics; | ||
using Content.Client.Chat.Managers; | ||
using Robust.Client.Player; | ||
|
||
namespace Content.Client.Nyanotrasen.Chat | ||
{ | ||
public sealed class PsionicChatUpdateSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly IChatManager _chatManager = default!; | ||
[Dependency] private readonly IPlayerManager _playerManager = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
SubscribeLocalEvent<PsionicComponent, ComponentInit>(OnInit); | ||
SubscribeLocalEvent<PsionicComponent, ComponentRemove>(OnRemove); | ||
} | ||
|
||
public PsionicComponent? Player => CompOrNull<PsionicComponent>(_playerManager.LocalPlayer?.ControlledEntity); | ||
public bool IsPsionic => Player != null; | ||
|
||
private void OnInit(EntityUid uid, PsionicComponent component, ComponentInit args) | ||
{ | ||
_chatManager.UpdatePermissions(); | ||
} | ||
|
||
private void OnRemove(EntityUid uid, PsionicComponent component, ComponentRemove args) | ||
{ | ||
_chatManager.UpdatePermissions(); | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
Content.Client/Nyanotrasen/Psionics/Glimmer/GlimmerReactiveVisuals.cs
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,6 @@ | ||
namespace Content.Client.Psionics.Glimmer; | ||
|
||
public enum GlimmerReactiveVisualLayers : byte | ||
{ | ||
GlimmerEffect, | ||
} |
42 changes: 42 additions & 0 deletions
42
Content.Client/Nyanotrasen/Psionics/UI/AcceptPsionicsEUI.cs
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,42 @@ | ||
using Content.Client.Eui; | ||
using Content.Shared.Psionics; | ||
using JetBrains.Annotations; | ||
using Robust.Client.Graphics; | ||
|
||
namespace Content.Client.Psionics.UI | ||
{ | ||
[UsedImplicitly] | ||
public sealed class AcceptPsionicsEui : BaseEui | ||
{ | ||
private readonly AcceptPsionicsWindow _window; | ||
|
||
public AcceptPsionicsEui() | ||
{ | ||
_window = new AcceptPsionicsWindow(); | ||
|
||
_window.DenyButton.OnPressed += _ => | ||
{ | ||
SendMessage(new AcceptPsionicsChoiceMessage(AcceptPsionicsUiButton.Deny)); | ||
_window.Close(); | ||
}; | ||
|
||
_window.AcceptButton.OnPressed += _ => | ||
{ | ||
SendMessage(new AcceptPsionicsChoiceMessage(AcceptPsionicsUiButton.Accept)); | ||
_window.Close(); | ||
}; | ||
} | ||
|
||
public override void Opened() | ||
{ | ||
IoCManager.Resolve<IClyde>().RequestWindowAttention(); | ||
_window.OpenCentered(); | ||
} | ||
|
||
public override void Closed() | ||
{ | ||
_window.Close(); | ||
} | ||
|
||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
Content.Client/Nyanotrasen/Psionics/UI/AcceptPsionicsWindow.cs
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,62 @@ | ||
using System.Numerics; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.CustomControls; | ||
using Robust.Shared.Localization; | ||
using static Robust.Client.UserInterface.Controls.BoxContainer; | ||
|
||
namespace Content.Client.Psionics.UI | ||
{ | ||
public sealed class AcceptPsionicsWindow : DefaultWindow | ||
{ | ||
public readonly Button DenyButton; | ||
public readonly Button AcceptButton; | ||
|
||
public AcceptPsionicsWindow() | ||
{ | ||
|
||
Title = Loc.GetString("accept-psionics-window-title"); | ||
|
||
Contents.AddChild(new BoxContainer | ||
{ | ||
Orientation = LayoutOrientation.Vertical, | ||
Children = | ||
{ | ||
new BoxContainer | ||
{ | ||
Orientation = LayoutOrientation.Vertical, | ||
Children = | ||
{ | ||
(new Label() | ||
{ | ||
Text = Loc.GetString("accept-psionics-window-prompt-text-part") | ||
}), | ||
new BoxContainer | ||
{ | ||
Orientation = LayoutOrientation.Horizontal, | ||
Align = AlignMode.Center, | ||
Children = | ||
{ | ||
(AcceptButton = new Button | ||
{ | ||
Text = Loc.GetString("accept-cloning-window-accept-button"), | ||
}), | ||
|
||
(new Control() | ||
{ | ||
MinSize = new Vector2(20, 0) | ||
}), | ||
|
||
(DenyButton = new Button | ||
{ | ||
Text = Loc.GetString("accept-cloning-window-deny-button"), | ||
}) | ||
} | ||
}, | ||
} | ||
}, | ||
} | ||
}); | ||
} | ||
} | ||
} |
Oops, something went wrong.