Skip to content
Draft
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
27 changes: 27 additions & 0 deletions Content.Client/_DEN/CartridgeLoader/Cartridges/NanoChatUi.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Content.Client.UserInterface.Fragments;
using Content.Shared._DEN.CartridgeLoader.Cartridges;
using Robust.Client.UserInterface;

namespace Content.Client._DEN.CartridgeLoader.Cartridges;

public sealed partial class NanoChatUi : UIFragment
{
private NanoChatUiFragment? _fragment;
public override Control GetUIFragmentRoot()
{
return _fragment!;
}

public override void Setup(BoundUserInterface userInterface, EntityUid? fragmentOwner)
{
_fragment = new();
}

public override void UpdateState(BoundUserInterfaceState state)
{
if (state is not NanoChatUiState castState)
return;

_fragment?.UpdateState(castState);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<BoxContainer xmlns="https://spacestation14.io"
xmlns:widgets="clr-namespace:Content.Client._DEN.CartridgeLoader.Cartridges.Widgets"
HorizontalExpand="True"
VerticalExpand="True">
<BoxContainer HorizontalExpand="True"
VerticalExpand="True"
Orientation="Vertical">
<widgets:NanoChatTopBar />
<BoxContainer HorizontalExpand="True"
VerticalExpand="True"
Margin="3">
<widgets:NanoChatChatsContainer Name="ChatsContainer" Margin="0 0 3 0" />
<widgets:NanoChatMessageBox Name="MessageBox" Visible="True" />
</BoxContainer>
</BoxContainer>
</BoxContainer>
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Content.Client._DEN.CartridgeLoader.Cartridges.Widgets;
using Content.Shared._DEN.CartridgeLoader.Cartridges;
using Content.Shared._DEN.NanoChat;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client._DEN.CartridgeLoader.Cartridges;

[GenerateTypedNameReferences]
public sealed partial class NanoChatUiFragment : BoxContainer
{
[Dependency] private readonly ILogManager _logManager = default!;

private Dictionary<Guid, NanoChatConversation> _conversations = new();
private Dictionary<Guid, NanoChatMessage> _messages = new();
private Dictionary<uint, NanoChatUser> _users = new();
private Dictionary<Guid, NanoChatMessageEntry> _messageIdToUi = new();
private ISawmill _sawmill;

public NanoChatUiFragment()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

_sawmill = _logManager.GetSawmill("nanochat.ui");
}

public void UpdateState(NanoChatUiState state)
{
_conversations = state.Conversations;
_messages = state.Messages;
_users = state.RelevantUsers;

ChatsContainer.SetConversations(state.Conversations, state.CurrentConversationId);
}

private void AddMessageEntry(Guid messageId, NanoChatMessageEntry messageEntry)
{
_messageIdToUi.Add(messageId, messageEntry);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<BoxContainer xmlns="https://spacestation14.io"
HorizontalExpand="True"
VerticalExpand="True"
Orientation="Horizontal">
<PanelContainer Name="ChatsContainer"
HorizontalExpand="True"
VerticalExpand="True">
<ScrollContainer VerticalExpand="True"
HorizontalExpand="True"
HScrollEnabled="False">
<BoxContainer Name="ChatList"
Orientation="Vertical"
VerticalExpand="True"
HorizontalExpand="True"
Margin="4">
<RichTextLabel Name="NoChatsLabel"
Text="No chats found."
HorizontalAlignment="Center"
Margin="0 35"
Visible="True" />
<!-- <widgets:NanoChatUserEntry /> -->
</BoxContainer>
</ScrollContainer>
</PanelContainer>
</BoxContainer>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Content.Shared._DEN.NanoChat;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client._DEN.CartridgeLoader.Cartridges.Widgets;

[GenerateTypedNameReferences]
public sealed partial class NanoChatChatsContainer : BoxContainer
{
[Dependency] private readonly ILogManager _logManager = default!;

private readonly ISawmill _sawmill;

public event Action<Guid?>? OnChatClicked;

public NanoChatChatsContainer()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

_sawmill = _logManager.GetSawmill("nanochat.ui.chatscontainer");
}

public void SetConversations(Dictionary<Guid, NanoChatConversation> conversations,
Guid? currentConversationId = null)
{
foreach (var pair in conversations)
{
BuildConversation(pair.Value, currentConversationId == pair.Key);
}
}

private void BuildConversation(NanoChatConversation conversation, bool pressed)
{
var userEntry = new NanoChatConversationEntry();

userEntry.SetConversationTitle(conversation.Title);
userEntry.SetConversationSubtitle(conversation.Subtitle);
userEntry.SetPressed(pressed);

userEntry.OnConversationClicked += () => OnChatClicked?.Invoke(conversation.Id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<BoxContainer xmlns="https://spacestation14.io"
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
HorizontalExpand="True"
SetHeight="50">
<PanelContainer VerticalExpand="True"
SetWidth="8">
<PanelContainer.PanelOverride>
<graphics:StyleBoxFlat BackgroundColor="#cd61ff"/>
</PanelContainer.PanelOverride>
</PanelContainer>
<Button Name="ConversationButton"
HorizontalExpand="True"
VerticalExpand="True"
StyleClasses="ButtonSquare"
Margin="1 0"
Pressed="True">
<BoxContainer HorizontalExpand="True"
VerticalExpand="True"
Orientation="Vertical">
<RichTextLabel Name="TitleLabel"
Text="[color=#d9d9d9][bold]Vincent Ledoux[/bold][/color]"
HorizontalExpand="True"
SetHeight="15" />
<Control SetHeight="5" />
<RichTextLabel Name="SubtitleLabel"
Text="[color=white][font size=10]Research Director[/font][/color]"
HorizontalExpand="True"
SetHeight="15" />
</BoxContainer>
</Button>
</BoxContainer>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client._DEN.CartridgeLoader.Cartridges.Widgets;

[GenerateTypedNameReferences]
public sealed partial class NanoChatConversationEntry : BoxContainer
{
[Dependency] private readonly ILogManager _logManager = default!;

private const string ConversationTitleColor = "#d9d9d9";
private ISawmill _sawmill = default!;

public event Action? OnConversationClicked;

public NanoChatConversationEntry()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

ConversationButton.OnPressed += _ => OnConversationClicked?.Invoke();
_sawmill = _logManager.GetSawmill("nanochat.ui.entry");
}

public void SetConversationTitle(string title)
{
TitleLabel.Text = $"[color={ConversationTitleColor}][bold]{title}[/bold][/color]";
}

public void SetConversationSubtitle(string subtitle)
{
SubtitleLabel.Text = $"[color=white][font size=10]{subtitle}[/font][/color]";
}

public void SetPressed(bool pressed)
{
ConversationButton.Pressed = pressed;
}

public void SetVisible(bool visibility)
{
Visible = visibility;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<PanelContainer xmlns="https://spacestation14.io"
HorizontalExpand="True"
VerticalExpand="True"
SizeFlagsStretchRatio="1.5">
<BoxContainer HorizontalExpand="True" VerticalExpand="True" Orientation="Vertical">
<ScrollContainer HScrollEnabled="False"
HorizontalExpand="True"
VerticalExpand="True">
<BoxContainer Name="ChatMessagesContainer" VerticalExpand="True" Orientation="Vertical">
<!-- <widgets:NanoChatMessageEntry HorizontalAlignment="Left" /> -->
</BoxContainer>
</ScrollContainer>
<BoxContainer Name="MessageInputContainer"
Orientation="Vertical"
VerticalAlignment="Bottom">
<RichTextLabel Name="CharacterCount" HorizontalAlignment="Right" Text="0/512" />
<BoxContainer Orientation="Horizontal">
<LineEdit Name="MessageInput"
PlaceHolder="Message goes here..."
HorizontalExpand="True" />
<Button Name="EmojiMenu"
SetWidth="32"
VerticalExpand="True"
HorizontalAlignment="Right"
StyleClasses="ButtonSquare"
Text="E"/>
<Button Name="SendMessage"
SetWidth="32"
VerticalExpand="True"
HorizontalAlignment="Right"
StyleClasses="ButtonSquare"
Text=">"
Margin="0 0 3 0"/>
</BoxContainer>
</BoxContainer>
</BoxContainer>
</PanelContainer>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client._DEN.CartridgeLoader.Cartridges.Widgets;

[GenerateTypedNameReferences]
public sealed partial class NanoChatMessageBox : PanelContainer
{
[Dependency] private readonly ILogManager _logManager = default!;

private ISawmill _sawmill = default!;

public NanoChatMessageBox()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

_sawmill = _logManager.GetSawmill("nanochat.ui.messagebox");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<PanelContainer xmlns="https://spacestation14.io"
VerticalExpand="True"
MinSize="30 30"
Margin="2">
<BoxContainer HorizontalExpand="True" VerticalExpand="True" Orientation="Vertical">
<PanelContainer StyleClasses="PanelLight" HorizontalAlignment="Right" MaxWidth="330">
<RichTextLabel Text="1" Margin="10"></RichTextLabel>
</PanelContainer>
</BoxContainer>
</PanelContainer>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client._DEN.CartridgeLoader.Cartridges.Widgets;

[GenerateTypedNameReferences]
public sealed partial class NanoChatMessageEntry : PanelContainer
{
[Dependency] private readonly ILogManager _logManager = default!;

private ISawmill _sawmill = default!;

public NanoChatMessageEntry()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

_sawmill = _logManager.GetSawmill("nanochat.ui.messageentry");
}
}
Loading