Various Improvements to NanoChat (#2922)

* Port improvements to NanoChat from Einstein-Engines and Goob-Station

* fix duplicate translation key

* add missing space

* Properly mark DeltaV changes

* Allow muting individual NanoChat users, NanoChat UI to put per-chat buttons next to the message box

* remove leftover from testing stuff

* cycle through inputs with tab, confirm with enter; for new and edit chat

* Add channel switching with (Shift+)Alt+Up/Down; Discord-Style

* better null check

* another better null check

* Implement changes from ImpStation PR

* Rename ContactControl -> ContactContainer

* Requested changes

* Move Loc to _DV, don't register system as manager

* I'm so smart :)

---------

Co-authored-by: Alex C <alex91905@yahoo.com>
This commit is contained in:
Tobias Berger
2025-02-23 15:59:24 +00:00
committed by GitHub
co-authored by Alex C
parent 4d81b48dd3
commit 4ecf2aaca2
21 changed files with 604 additions and 97 deletions
@@ -31,6 +31,16 @@ public abstract class SharedNanoChatSystem : EntitySystem
args.PushMarkup(Loc.GetString("nanochat-card-examine-number", ("number", $"{ent.Comp.Number:D4}")));
}
/// <summary>
/// Helper Method for truncating a string to maximum length
/// </summary>
public static string Truncate(string text, int maxLength, string overflowText = "...")
{
return text.Length > maxLength
? text[..(maxLength - overflowText.Length)] + overflowText
: text;
}
#region Public API Methods
/// <summary>
@@ -188,6 +198,19 @@ public abstract class SharedNanoChatSystem : EntitySystem
Dirty(card);
}
/// <summary>
/// Sets whether notifications are muted for a specific chat.
/// </summary>
public void ToggleChatMuted(Entity<NanoChatCardComponent?> card, uint chat)
{
if (!Resolve(card, ref card.Comp))
return;
if (!card.Comp.MutedChats.Remove(chat))
card.Comp.MutedChats.Add(chat);
Dirty(card);
}
/// <summary>
/// Gets whether NanoChat number is listed.
/// </summary>