PDA UI refactor and cartridges (#11335)

* Work on cartridges

* Work on PDA UI

* Work on PDA UIs program list

* Work on PDA UI borders

* Add DeviceNetworkingComponent to the pda base prototype

* Fix submodule version

* Fix cartridge loader ui key

* Fix pda menu xaml

* Implement relaying ui messages

* Finish implementing the notekeeper cartridge

* Fix submodule version

* Fix errors from merging master

* Fix test failing

* Implement setting preinstalled programs

* Add some documentation to CartridgeLoaderSystem

* Add more doc comments

* Add localization to program names

* Implement review suggestions

* Fix background programs receiving events twice when active
This commit is contained in:
Julian Giebel
2022-11-08 21:00:20 +01:00
committed by GitHub
parent 1151ca42e5
commit e11cf969fa
79 changed files with 2323 additions and 94 deletions

View File

@@ -0,0 +1,39 @@
using Content.Shared.CartridgeLoader;
using Content.Shared.CartridgeLoader.Cartridges;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
namespace Content.Client.CartridgeLoader.Cartridges;
public sealed class NotekeeperUi : CartridgeUI
{
private NotekeeperUiFragment? _fragment;
public override Control GetUIFragmentRoot()
{
return _fragment!;
}
public override void Setup(BoundUserInterface userInterface)
{
_fragment = new NotekeeperUiFragment();
_fragment.OnNoteRemoved += note => SendNotekeeperMessage(NotekeeperUiAction.Remove, note, userInterface);
_fragment.OnNoteAdded += note => SendNotekeeperMessage(NotekeeperUiAction.Add, note, userInterface);
}
public override void UpdateState(BoundUserInterfaceState state)
{
if (state is not NotekeeperUiState notekeepeerState)
return;
_fragment?.UpdateState(notekeepeerState.Notes);
}
private void SendNotekeeperMessage(NotekeeperUiAction action, string note, BoundUserInterface userInterface)
{
var notekeeperMessage = new NotekeeperUiMessageEvent(action, note);
var message = new CartridgeUiMessage(notekeeperMessage);
userInterface.SendMessage(message);
}
}

View File

@@ -0,0 +1,10 @@
<cartridges:NotekeeperUiFragment xmlns:cartridges="clr-namespace:Content.Client.CartridgeLoader.Cartridges"
xmlns="https://spacestation14.io" Margin="1 0 2 0">
<PanelContainer StyleClasses="BackgroundDark"></PanelContainer>
<BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True">
<ScrollContainer HorizontalExpand="True" VerticalExpand="True" HScrollEnabled="True">
<BoxContainer Orientation="Vertical" Name="MessageContainer" HorizontalExpand="True" VerticalExpand="True"/>
</ScrollContainer>
<LineEdit Name="Input" HorizontalExpand="True" SetHeight="32"/>
</BoxContainer>
</cartridges:NotekeeperUiFragment>

View File

@@ -0,0 +1,62 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.CartridgeLoader.Cartridges;
[GenerateTypedNameReferences]
public sealed partial class NotekeeperUiFragment : BoxContainer
{
public event Action<string>? OnNoteAdded;
public event Action<string>? OnNoteRemoved;
public NotekeeperUiFragment()
{
RobustXamlLoader.Load(this);
Orientation = LayoutOrientation.Vertical;
HorizontalExpand = true;
VerticalExpand = true;
Input.OnTextEntered += _ =>
{
AddNote(Input.Text);
OnNoteAdded?.Invoke(Input.Text);
Input.Clear();
};
UpdateState(new List<string>());
}
public void UpdateState(List<string> notes)
{
MessageContainer.RemoveAllChildren();
foreach (var note in notes)
{
AddNote(note);
}
}
private void AddNote(string note)
{
var row = new BoxContainer();
row.HorizontalExpand = true;
row.Orientation = LayoutOrientation.Horizontal;
row.Margin = new Thickness(4);
var label = new Label();
label.Text = note;
label.HorizontalExpand = true;
label.ClipText = true;
var removeButton = new TextureButton();
removeButton.AddStyleClass("windowCloseButton");
removeButton.OnPressed += _ => OnNoteRemoved?.Invoke(label.Text);
row.AddChild(label);
row.AddChild(removeButton);
MessageContainer.AddChild(row);
}
}