]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
LOOC will appear on top of your head (#21514)
authorVasilis <vasilis@pikachu.systems>
Thu, 9 Nov 2023 09:18:58 +0000 (10:18 +0100)
committerGitHub <noreply@github.com>
Thu, 9 Nov 2023 09:18:58 +0000 (02:18 -0700)
* Oh well

* Minor fixing up

* HOLY BINGLE I DID IT

* TOGGLE!

Content.Client/Chat/UI/SpeechBubble.cs
Content.Client/Options/UI/Tabs/GraphicsTab.xaml
Content.Client/Options/UI/Tabs/GraphicsTab.xaml.cs
Content.Client/UserInterface/Systems/Chat/ChatUIController.cs
Content.Shared/CCVar/CCVars.cs
Resources/Locale/en-US/escape-menu/ui/options-menu.ftl

index b6b336f1dc9312dca3a12ebffa37c545e342b8e0..46a9f0539213bd2ee4516783de2d3237df265167 100644 (file)
@@ -4,6 +4,7 @@ using Robust.Client.Graphics;
 using Robust.Client.UserInterface;
 using Robust.Client.UserInterface.Controls;
 using Robust.Shared.Timing;
+using Robust.Shared.Utility;
 
 namespace Content.Client.Chat.UI
 {
@@ -13,7 +14,8 @@ namespace Content.Client.Chat.UI
         {
             Emote,
             Say,
-            Whisper
+            Whisper,
+            Looc
         }
 
         /// <summary>
@@ -60,12 +62,15 @@ namespace Content.Client.Chat.UI
                 case SpeechType.Whisper:
                     return new TextSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager, "whisperBox");
 
+                case SpeechType.Looc:
+                    return new TextSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager, "emoteBox", Color.FromHex("#48d1cc"));
+
                 default:
                     throw new ArgumentOutOfRangeException();
             }
         }
 
-        public SpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager, string speechStyleClass)
+        public SpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager, string speechStyleClass, Color? fontColor = null)
         {
             _chatManager = chatManager;
             _senderEntity = senderEntity;
@@ -75,7 +80,7 @@ namespace Content.Client.Chat.UI
             // Use text clipping so new messages don't overlap old ones being pushed up.
             RectClipContent = true;
 
-            var bubble = BuildBubble(text, speechStyleClass);
+            var bubble = BuildBubble(text, speechStyleClass, fontColor);
 
             AddChild(bubble);
 
@@ -86,7 +91,7 @@ namespace Content.Client.Chat.UI
             _verticalOffsetAchieved = -ContentSize.Y;
         }
 
-        protected abstract Control BuildBubble(string text, string speechStyleClass);
+        protected abstract Control BuildBubble(string text, string speechStyleClass, Color? fontColor = null);
 
         protected override void FrameUpdate(FrameEventArgs args)
         {
@@ -164,18 +169,29 @@ namespace Content.Client.Chat.UI
 
     public sealed class TextSpeechBubble : SpeechBubble
     {
-        public TextSpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager, string speechStyleClass)
-            : base(text, senderEntity, eyeManager, chatManager, entityManager, speechStyleClass)
+        public TextSpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager, string speechStyleClass, Color? fontColor = null)
+            : base(text, senderEntity, eyeManager, chatManager, entityManager, speechStyleClass, fontColor)
         {
         }
 
-        protected override Control BuildBubble(string text, string speechStyleClass)
+        protected override Control BuildBubble(string text, string speechStyleClass, Color? fontColor = null)
         {
             var label = new RichTextLabel
             {
                 MaxWidth = 256,
             };
-            label.SetMessage(text);
+
+            if (fontColor != null)
+            {
+                var msg = new FormattedMessage();
+                msg.PushColor(fontColor.Value);
+                msg.AddMarkup(text);
+                label.SetMessage(msg);
+            }
+            else
+            {
+                label.SetMessage(text);
+            }
 
             var panel = new PanelContainer
             {
index 41b304417a2a24e29ad86f5bcbffba390d61321d..f759c78eca89017df10d83ab581a62aee24b6b6a 100644 (file)
@@ -22,6 +22,7 @@
             </BoxContainer>
             <CheckBox Name="ShowHeldItemCheckBox" Text="{Loc 'ui-options-show-held-item'}" />
             <CheckBox Name="ShowCombatModeIndicatorsCheckBox" Text="{Loc 'ui-options-show-combat-mode-indicators'}" />
+            <CheckBox Name="ShowLoocAboveHeadCheckBox" Text="{Loc 'ui-options-show-looc-on-head'}" />
             <BoxContainer Orientation="Horizontal">
                 <CheckBox Name="ViewportStretchCheckBox" Text="{Loc 'ui-options-vp-stretch'}" />
                 <BoxContainer Name="ViewportScaleBox" Orientation="Horizontal">
index 852a3c28661a87956bbe83851d8ef66c0a6f992e..e64838ba752e1a7f6c4293b52dc1aa4bcd121a34 100644 (file)
@@ -103,6 +103,7 @@ namespace Content.Client.Options.UI.Tabs
 
             ShowHeldItemCheckBox.OnToggled += OnCheckBoxToggled;
             ShowCombatModeIndicatorsCheckBox.OnToggled += OnCheckBoxToggled;
+            ShowLoocAboveHeadCheckBox.OnToggled += OnCheckBoxToggled;
             IntegerScalingCheckBox.OnToggled += OnCheckBoxToggled;
             ViewportLowResCheckBox.OnToggled += OnCheckBoxToggled;
             ParallaxLowQualityCheckBox.OnToggled += OnCheckBoxToggled;
@@ -121,6 +122,7 @@ namespace Content.Client.Options.UI.Tabs
             FpsCounterCheckBox.Pressed = _cfg.GetCVar(CCVars.HudFpsCounterVisible);
             ShowHeldItemCheckBox.Pressed = _cfg.GetCVar(CCVars.HudHeldItemShow);
             ShowCombatModeIndicatorsCheckBox.Pressed = _cfg.GetCVar(CCVars.CombatModeIndicatorsPointShow);
+            ShowLoocAboveHeadCheckBox.Pressed = _cfg.GetCVar(CCVars.LoocAboveHeadShow);
             ViewportWidthSlider.Value = _cfg.GetCVar(CCVars.ViewportWidth);
 
             _cfg.OnValueChanged(CCVars.ViewportMinimumWidth, _ => UpdateViewportWidthRange());
@@ -168,6 +170,7 @@ namespace Content.Client.Options.UI.Tabs
             _cfg.SetCVar(CCVars.ParallaxLowQuality, ParallaxLowQualityCheckBox.Pressed);
             _cfg.SetCVar(CCVars.HudHeldItemShow, ShowHeldItemCheckBox.Pressed);
             _cfg.SetCVar(CCVars.CombatModeIndicatorsPointShow, ShowCombatModeIndicatorsCheckBox.Pressed);
+            _cfg.SetCVar(CCVars.LoocAboveHeadShow, ShowLoocAboveHeadCheckBox.Pressed);
             _cfg.SetCVar(CCVars.HudFpsCounterVisible, FpsCounterCheckBox.Pressed);
             _cfg.SetCVar(CCVars.ViewportWidth, (int) ViewportWidthSlider.Value);
 
@@ -205,6 +208,7 @@ namespace Content.Client.Options.UI.Tabs
             var isPLQSame = ParallaxLowQualityCheckBox.Pressed == _cfg.GetCVar(CCVars.ParallaxLowQuality);
             var isShowHeldItemSame = ShowHeldItemCheckBox.Pressed == _cfg.GetCVar(CCVars.HudHeldItemShow);
             var isCombatModeIndicatorsSame = ShowCombatModeIndicatorsCheckBox.Pressed == _cfg.GetCVar(CCVars.CombatModeIndicatorsPointShow);
+            var isLoocShowSame = ShowLoocAboveHeadCheckBox.Pressed == _cfg.GetCVar(CCVars.LoocAboveHeadShow);
             var isFpsCounterVisibleSame = FpsCounterCheckBox.Pressed == _cfg.GetCVar(CCVars.HudFpsCounterVisible);
             var isWidthSame = (int) ViewportWidthSlider.Value == _cfg.GetCVar(CCVars.ViewportWidth);
             var isLayoutSame = HudLayoutOption.SelectedMetadata is string opt && opt == _cfg.GetCVar(CCVars.UILayout);
@@ -221,6 +225,7 @@ namespace Content.Client.Options.UI.Tabs
                                    isHudThemeSame &&
                                    isShowHeldItemSame &&
                                    isCombatModeIndicatorsSame &&
+                                   isLoocShowSame &&
                                    isFpsCounterVisibleSame &&
                                    isWidthSame &&
                                    isLayoutSame;
index 9334f85c00697e211703759b71b8782ba15a9381..2d90b371c3c69fa8544cb1fdaf7e2f7279232517 100644 (file)
@@ -369,7 +369,7 @@ public sealed class ChatUIController : UIController
         UpdateChannelPermissions();
     }
 
-    private void AddSpeechBubble(ChatMessage msg, SpeechBubble.SpeechType speechType)
+    private void AddSpeechBubble(ChatMessage msg, SpeechBubble.SpeechType speechType, string? prefixText = null, string? prefixEndText = null)
     {
         var ent = EntityManager.GetEntity(msg.SenderEntity);
 
@@ -379,8 +379,11 @@ public sealed class ChatUIController : UIController
             return;
         }
 
+        // Kind of shitty way to add prefixes but hey it works!
+        string Message = prefixText + msg.Message + prefixEndText;
+
         // msg.Message should be the string that a user sent over text, without any added markup.
-        var messages = SplitMessage(msg.Message);
+        var messages = SplitMessage(Message);
 
         foreach (var message in messages)
         {
@@ -843,6 +846,15 @@ public sealed class ChatUIController : UIController
             case ChatChannel.Emotes:
                 AddSpeechBubble(msg, SpeechBubble.SpeechType.Emote);
                 break;
+
+            case ChatChannel.LOOC:
+                if (_cfg.GetCVar(CCVars.LoocAboveHeadShow))
+                {
+                    const string prefixText = "(LOOC: ";
+                    const string prefixEndText = ")";
+                    AddSpeechBubble(msg, SpeechBubble.SpeechType.Looc, prefixText, prefixEndText);
+                }
+                break;
         }
     }
 
index eb74a4994f5836f6ad69dddff5fa7fa79300ba19..82430ea78170f53d063268cbd0255ab37b193f12 100644 (file)
@@ -645,6 +645,9 @@ namespace Content.Shared.CCVar
         public static readonly CVarDef<bool> CombatModeIndicatorsPointShow =
             CVarDef.Create("hud.combat_mode_indicators_point_show", true, CVar.ARCHIVE | CVar.CLIENTONLY);
 
+        public static readonly CVarDef<bool> LoocAboveHeadShow =
+            CVarDef.Create("hud.show_looc_above_head", true, CVar.ARCHIVE | CVar.CLIENTONLY);
+
         public static readonly CVarDef<float> HudHeldItemOffset =
             CVarDef.Create("hud.held_item_offset", 28f, CVar.ARCHIVE | CVar.CLIENTONLY);
 
index 5540b6609b57101b9aed4efdb331b0e30540d14d..ddf76ebb1a6b2c873f099cfe333787451ecd15b8 100644 (file)
@@ -29,6 +29,7 @@ ui-options-volume-percent = { TOSTRING($volume, "P0") }
 
 ui-options-show-held-item = Show held item next to cursor?
 ui-options-show-combat-mode-indicators = Show combat mode indicators with cursor?
+ui-options-show-looc-on-head = Show LOOC chat above characters head?
 ui-options-vsync = VSync
 ui-options-fullscreen = Fullscreen
 ui-options-lighting-label = Lighting Quality: