Skip to content
Open
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
@@ -0,0 +1,48 @@
using Content.Client.ADT.CartridgeLoader.Cartridges;
using Content.Shared.ADT.CartridgeLoader.Cartridges;
using Content.Shared.ADT.NanoChat;
using JetBrains.Annotations;
using Robust.Client.UserInterface;

namespace Content.Client.ADT.NanoChat;

[UsedImplicitly]
public sealed class StationAiNanoChatBoundUserInterface(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey)
{
private StationAiNanoChatWindow? _window;

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

_window = this.CreateWindow<StationAiNanoChatWindow>();
_window.Fragment.OnMessageSent += OnMessageSent;
}

private void OnMessageSent(NanoChatUiMessageType type, uint? number, string? content, string? job)
{
SendMessage(new StationAiNanoChatUiMessage(type, number, content, job));
}

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

if (state is not NanoChatUiState nanoChatState || _window == null)
return;

_window.UpdateState(nanoChatState);
}

protected override void Dispose(bool disposing)
{
if (_window != null)
{
_window.Fragment.OnMessageSent -= OnMessageSent;
_window.Dispose();
_window = null;
}

base.Dispose(disposing);
}
}
26 changes: 26 additions & 0 deletions Content.Client/ADT/NanoChat/StationAiNanoChatWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System.Numerics;
using Content.Client.ADT.CartridgeLoader.Cartridges;
using Content.Shared.ADT.CartridgeLoader.Cartridges;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;

namespace Content.Client.ADT.NanoChat;

public sealed class StationAiNanoChatWindow : DefaultWindow
{
public readonly NanoChatUiFragment Fragment;

public StationAiNanoChatWindow()
{
Title = Loc.GetString("station-ai-nanochat-window-title");
MinSize = new Vector2(600, 400);

Fragment = new NanoChatUiFragment();
Contents.AddChild(Fragment);
}

public void UpdateState(NanoChatUiState state)
{
Fragment.UpdateState(state);
}
}
Loading
Loading