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

A variant of a working capsule of nuke ops #29683

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
61 changes: 61 additions & 0 deletions Content.Client/DropPod/UI/DropPodBoundUi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using Content.Shared.DropPod;
using JetBrains.Annotations;
using Robust.Client.GameObjects;

namespace Content.Client.DropPod.UI;

[UsedImplicitly]
public sealed class DropPodBoundUi : BoundUserInterface
{
[ViewVariables]
private DropPodConsoleWindow? _window;

public DropPodBoundUi(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

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

_window = new DropPodConsoleWindow();
_window.OpenCentered();

_window.PointsRefreshButtonPressed += OnPointsRefreshButtonPressed;
_window.StartLandingButtonPressed += OnStartLandingButtonPressed;
_window.PointSelected += OnPointSelected;
_window.OnClose += Close;
}

private void OnPointsRefreshButtonPressed()
{
SendMessage(new DropPodRefreshMessage());
}

private void OnStartLandingButtonPressed()
{
SendMessage(new DropPodStartMessage());
}

private void OnPointSelected(int point)
{
SendMessage(new DropPodPointSelectedMessage(point));
}

protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);

if (_window == null || state is not DropPodUiState cast)
return;

_window.UpdateState(cast);
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing)
_window?.Dispose();
}
}
13 changes: 13 additions & 0 deletions Content.Client/DropPod/UI/DropPodConsoleWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<DefaultWindow xmlns="https://spacestation14.io"
xmlns:viewport="clr-namespace:Content.Client.Viewport"
Title="{Loc 'droppod-console-ui-window'}">
<BoxContainer Orientation="Horizontal">
<BoxContainer Orientation="Vertical" MinWidth="350" MinHeight="200" VerticalExpand="True">
<Button Name="DropPodRefreshPointsButton" Text="{Loc 'droppod-console-ui-refresh-points'}" />
<ScrollContainer VerticalExpand="True">
<ItemList Name="SubnetList" />
</ScrollContainer>
<Button Name="DropPodStartLandingButton" Text="{Loc 'droppod-console-ui-start-landing'}" />
</BoxContainer>
</BoxContainer>
</DefaultWindow>
46 changes: 46 additions & 0 deletions Content.Client/DropPod/UI/DropPodConsoleWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Content.Shared.DropPod;

namespace Content.Client.DropPod.UI;

[GenerateTypedNameReferences]
public sealed partial class DropPodConsoleWindow : DefaultWindow
{
public event Action<int>? PointSelected;
public event Action? PointsRefreshButtonPressed;
public event Action? StartLandingButtonPressed;

public DropPodConsoleWindow()
{
RobustXamlLoader.Load(this);

DropPodRefreshPointsButton.OnPressed += _ => PointsRefreshButtonPressed?.Invoke();
DropPodStartLandingButton.OnPressed += _ => StartLandingButtonPressed?.Invoke();
SubnetList.OnItemSelected += OnSubnetListSelect;
}

public void UpdateState(DropPodUiState state)
{
DropPodRefreshPointsButton.Disabled = !state.CanRefreshVol;
DropPodStartLandingButton.Disabled = !state.CanStartVol;
AddPointToList(state);
}

private void AddPointToList(DropPodUiState state)
{
SubnetList.Clear(); // We clean it so that there are no duplicated buttons
foreach (var point in state.Points)
{
var item = SubnetList.AddItem($"{point.Value}");
item.Metadata = point.Key; // The key contains a unique identification number (UIN), which, according to my logic, each landing point has its own
}
}

private void OnSubnetListSelect(ItemList.ItemListSelectedEventArgs args)
{
PointSelected!((int) SubnetList[args.ItemIndex].Metadata!); // When selecting the desired object in the SubnetList, we send a unique identification number by which we will search for the desired landing point
}
}
12 changes: 12 additions & 0 deletions Content.Server/DropPod/DropPodBeaconComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They would do imports before building as these are the sourcegenned ones, I would bet.

using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why?


namespace Content.Server.DropPod
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outdated namespace format

{
[RegisterComponent]
public sealed partial class DropPodBeaconComponent : Component
{

}
}
28 changes: 28 additions & 0 deletions Content.Server/DropPod/DropPodConsoleComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outdated, remove

using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outdated

using Robust.Shared.Audio;

namespace Content.Server.DropPod
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong namespace format

{
[RegisterComponent]
public sealed partial class DropPodConsoleComponent : Component
{
public bool WarDeclared = false; // This field is needed to prevent players from flying away on a capsule before the declaration of war
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where DataField


[DataField("announcement")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[DataField("announcement")]
[DataField]

outdated

public bool Announcement = true;

[DataField("text")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[DataField("text")]
[DataField]

also rename variable, something like AnnouncementText

public string Text = "Attention! A hostile corporation is trying to move an object to your station... The travel time is 12 seconds. The approximate coordinates of the movement are as follows: ";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These kinds of announcements (e.g. Space Dragon rifts) now use the approximate location, as coordinates don't tell much to most players. Also I think such things usually go into ftl files, but I'm a dilettante in this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in this ad there will be an approximate location, because the exact coordinates will be determined later by adding a scatter radius

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this should use a LocId string.

Also, the time shouldn't be written into the string. It should be passed as a variable that can be placed in the string by the localization system.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

swap to LocId and lovalize string.


[DataField("time")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[DataField("time")]
[DataField]

public int Time = 12; // if you change the time, then change it in the text /\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, make it .ftl localization variable


[DataField("sound")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[DataField("sound")]
[DataField]

public SoundSpecifier Sound = new SoundPathSpecifier("/Audio/Announcements/war.ogg");

[DataField("color")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[DataField("color")]
[DataField]

public Color Color = Color.Red;
}
}
Loading
Loading