diff --git a/Content.Client/_DEN/CartridgeLoader/Cartridges/NanoChatUi.cs b/Content.Client/_DEN/CartridgeLoader/Cartridges/NanoChatUi.cs new file mode 100644 index 0000000000..a8e12191db --- /dev/null +++ b/Content.Client/_DEN/CartridgeLoader/Cartridges/NanoChatUi.cs @@ -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); + } +} diff --git a/Content.Client/_DEN/CartridgeLoader/Cartridges/NanoChatUiFragment.xaml b/Content.Client/_DEN/CartridgeLoader/Cartridges/NanoChatUiFragment.xaml new file mode 100644 index 0000000000..462c74c27a --- /dev/null +++ b/Content.Client/_DEN/CartridgeLoader/Cartridges/NanoChatUiFragment.xaml @@ -0,0 +1,16 @@ + + + + + + + + + diff --git a/Content.Client/_DEN/CartridgeLoader/Cartridges/NanoChatUiFragment.xaml.cs b/Content.Client/_DEN/CartridgeLoader/Cartridges/NanoChatUiFragment.xaml.cs new file mode 100644 index 0000000000..b7a3513c60 --- /dev/null +++ b/Content.Client/_DEN/CartridgeLoader/Cartridges/NanoChatUiFragment.xaml.cs @@ -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 _conversations = new(); + private Dictionary _messages = new(); + private Dictionary _users = new(); + private Dictionary _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); + } +} diff --git a/Content.Client/_DEN/CartridgeLoader/Cartridges/Widgets/NanoChatChatsContainer.xaml b/Content.Client/_DEN/CartridgeLoader/Cartridges/Widgets/NanoChatChatsContainer.xaml new file mode 100644 index 0000000000..0a331677be --- /dev/null +++ b/Content.Client/_DEN/CartridgeLoader/Cartridges/Widgets/NanoChatChatsContainer.xaml @@ -0,0 +1,25 @@ + + + + + + + + + + diff --git a/Content.Client/_DEN/CartridgeLoader/Cartridges/Widgets/NanoChatChatsContainer.xaml.cs b/Content.Client/_DEN/CartridgeLoader/Cartridges/Widgets/NanoChatChatsContainer.xaml.cs new file mode 100644 index 0000000000..fc3a85f831 --- /dev/null +++ b/Content.Client/_DEN/CartridgeLoader/Cartridges/Widgets/NanoChatChatsContainer.xaml.cs @@ -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? OnChatClicked; + + public NanoChatChatsContainer() + { + RobustXamlLoader.Load(this); + IoCManager.InjectDependencies(this); + + _sawmill = _logManager.GetSawmill("nanochat.ui.chatscontainer"); + } + + public void SetConversations(Dictionary 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); + } +} diff --git a/Content.Client/_DEN/CartridgeLoader/Cartridges/Widgets/NanoChatConversationEntry.xaml b/Content.Client/_DEN/CartridgeLoader/Cartridges/Widgets/NanoChatConversationEntry.xaml new file mode 100644 index 0000000000..c2b84f1476 --- /dev/null +++ b/Content.Client/_DEN/CartridgeLoader/Cartridges/Widgets/NanoChatConversationEntry.xaml @@ -0,0 +1,31 @@ + + + + + + + + diff --git a/Content.Client/_DEN/CartridgeLoader/Cartridges/Widgets/NanoChatConversationEntry.xaml.cs b/Content.Client/_DEN/CartridgeLoader/Cartridges/Widgets/NanoChatConversationEntry.xaml.cs new file mode 100644 index 0000000000..1ab626dbc1 --- /dev/null +++ b/Content.Client/_DEN/CartridgeLoader/Cartridges/Widgets/NanoChatConversationEntry.xaml.cs @@ -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; + } +} diff --git a/Content.Client/_DEN/CartridgeLoader/Cartridges/Widgets/NanoChatMessageBox.xaml b/Content.Client/_DEN/CartridgeLoader/Cartridges/Widgets/NanoChatMessageBox.xaml new file mode 100644 index 0000000000..d86961c5cc --- /dev/null +++ b/Content.Client/_DEN/CartridgeLoader/Cartridges/Widgets/NanoChatMessageBox.xaml @@ -0,0 +1,37 @@ + + + + + + + + + + + +