private string SanitizeInGameOOCMessage(string message)
    {
        var newMessage = message.Trim();

        newMessage = FormattedMessage.EscapeText(newMessage);

        return(newMessage);
    }
Esempio n. 2
0
        protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySessionEventArgs eventArgs)
        {
            base.OnBwoinkTextMessage(message, eventArgs);
            var senderSession = (IPlayerSession)eventArgs.SenderSession;

            // TODO: Sanitize text?
            // Confirm that this person is actually allowed to send a message here.
            var senderPersonalChannel = senderSession.UserId == message.ChannelId;
            var senderAdmin           = _adminManager.GetAdminData(senderSession) != null;
            var authorized            = senderPersonalChannel || senderAdmin;

            if (!authorized)
            {
                // Unauthorized bwoink (log?)
                return;
            }

            var escapedText = FormattedMessage.EscapeText(message.Text);

            var bwoinkText = senderAdmin
                ? $"[color=red]{senderSession.Name}[/color]: {escapedText}"
                : $"{senderSession.Name}: {escapedText}";
            var msg = new BwoinkTextMessage(message.ChannelId, senderSession.UserId, bwoinkText);

            LogBwoink(msg);

            // Admins
            var targets = _adminManager.ActiveAdmins.Select(p => p.ConnectedClient).ToList();

            // And involved player
            if (_playerManager.TryGetSessionById(message.ChannelId, out var session))
            {
                if (!targets.Contains(session.ConnectedClient))
                {
                    targets.Add(session.ConnectedClient);
                }
            }

            foreach (var channel in targets)
            {
                RaiseNetworkEvent(msg, channel);
            }

            if (targets.Count == 1)
            {
                var systemText = senderPersonalChannel ?
                                 Loc.GetString("bwoink-system-starmute-message-no-other-users-primary") :
                                 Loc.GetString("bwoink-system-starmute-message-no-other-users-secondary");
                var starMuteMsg = new BwoinkTextMessage(message.ChannelId, SystemUserId, systemText);
                RaiseNetworkEvent(starMuteMsg, senderSession.ConnectedClient);
            }
        }
    // ReSharper disable once InconsistentNaming
    private string SanitizeInGameICMessage(EntityUid source, string message, out string?emoteStr, bool capitalize = true)
    {
        var newMessage = message.Trim();

        if (capitalize)
        {
            newMessage = SanitizeMessageCapital(source, newMessage);
        }
        newMessage = FormattedMessage.EscapeText(newMessage);

        _sanitizer.TrySanitizeOutSmilies(newMessage, source, out newMessage, out emoteStr);

        return(newMessage);
    }
Esempio n. 4
0
        public TutorialWindow()
        {
            Title = "The Tutorial!";

            //Get section header font
            var  cache        = IoCManager.Resolve <IResourceCache>();
            var  inputManager = IoCManager.Resolve <IInputManager>();
            Font headerFont   = new VectorFont(cache.GetResource <FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), _headerFontSize);

            var scrollContainer = new ScrollContainer();

            scrollContainer.AddChild(VBox = new VBoxContainer());
            Contents.AddChild(scrollContainer);

            //Intro
            VBox.AddChild(new Label {
                FontOverride = headerFont, Text = "Intro"
            });
            AddFormattedText(IntroContents);

            string Key(BoundKeyFunction func)
            {
                return(FormattedMessage.EscapeText(inputManager.GetKeyFunctionButtonString(func)));
            }

            //Controls
            VBox.AddChild(new Label {
                FontOverride = headerFont, Text = "\nControls"
            });

            // Moved this down here so that Rider shows which args correspond to which format spot.
            AddFormattedText(Loc.GetString(@"Movement: [color=#a4885c]{0} {1} {2} {3}[/color]
Switch hands: [color=#a4885c]{4}[/color]
Use held item: [color=#a4885c]{5}[/color]
Drop held item: [color=#a4885c]{6}[/color]
Smart equip from backpack: [color=#a4885c]{24}[/color]
Smart equip from belt: [color=#a4885c]{25}[/color]
Open inventory: [color=#a4885c]{7}[/color]
Open character window: [color=#a4885c]{8}[/color]
Open crafting window: [color=#a4885c]{9}[/color]
Open action menu: [color=#a4885c]{33}[/color]
Focus chat: [color=#a4885c]{10}[/color]
Focus OOC: [color=#a4885c]{26}[/color]
Focus Admin Chat: [color=#a4885c]{27}[/color]
Use hand/object in hand: [color=#a4885c]{22}[/color]
Do wide attack: [color=#a4885c]{23}[/color]
Use targeted entity: [color=#a4885c]{11}[/color]
Throw held item: [color=#a4885c]{12}[/color]
Pull entity: [color=#a4885c]{30}[/color]
Move pulled entity: [color=#a4885c]{29}[/color]
Stop pulling: [color=#a4885c]{32}[/color]
Examine entity: [color=#a4885c]{13}[/color]
Point somewhere: [color=#a4885c]{28}[/color]
Open entity context menu: [color=#a4885c]{14}[/color]
Toggle combat mode: [color=#a4885c]{15}[/color]
Toggle console: [color=#a4885c]{16}[/color]
Toggle UI: [color=#a4885c]{17}[/color]
Toggle debug overlay: [color=#a4885c]{18}[/color]
Toggle entity spawner: [color=#a4885c]{19}[/color]
Toggle tile spawner: [color=#a4885c]{20}[/color]
Toggle sandbox window: [color=#a4885c]{21}[/color]
Toggle admin menu [color=#a4885c]{31}[/color]
Hotbar slot 1: [color=#a4885c]{34}[/color]
Hotbar slot 2: [color=#a4885c]{35}[/color]
Hotbar slot 3: [color=#a4885c]{36}[/color]
Hotbar slot 4: [color=#a4885c]{37}[/color]
Hotbar slot 5: [color=#a4885c]{38}[/color]
Hotbar slot 6: [color=#a4885c]{39}[/color]
Hotbar slot 7: [color=#a4885c]{40}[/color]
Hotbar slot 8: [color=#a4885c]{41}[/color]
Hotbar slot 9: [color=#a4885c]{42}[/color]
Hotbar slot 0: [color=#a4885c]{43}[/color]
                ",
                                           Key(MoveUp), Key(MoveLeft), Key(MoveDown), Key(MoveRight),
                                           Key(SwapHands),
                                           Key(ActivateItemInHand),
                                           Key(Drop),
                                           Key(OpenInventoryMenu),
                                           Key(OpenCharacterMenu),
                                           Key(OpenCraftingMenu),
                                           Key(FocusChat),
                                           Key(ActivateItemInWorld),
                                           Key(ThrowItemInHand),
                                           Key(ExamineEntity),
                                           Key(OpenContextMenu),
                                           Key(ToggleCombatMode),
                                           Key(ShowDebugConsole),
                                           Key(HideUI),
                                           Key(ShowDebugMonitors),
                                           Key(OpenEntitySpawnWindow),
                                           Key(OpenTileSpawnWindow),
                                           Key(OpenSandboxWindow),
                                           Key(Use),
                                           Key(WideAttack),
                                           Key(SmartEquipBackpack),
                                           Key(SmartEquipBelt),
                                           Key(FocusOOC),
                                           Key(FocusAdminChat),
                                           Key(Point),
                                           Key(TryPullObject),
                                           Key(MovePulledObject),
                                           Key(OpenAdminMenu),
                                           Key(ReleasePulledObject),
                                           Key(OpenActionsMenu),
                                           Key(Hotbar1),
                                           Key(Hotbar2),
                                           Key(Hotbar3),
                                           Key(Hotbar4),
                                           Key(Hotbar5),
                                           Key(Hotbar6),
                                           Key(Hotbar7),
                                           Key(Hotbar8),
                                           Key(Hotbar9),
                                           Key(Hotbar0)));

            //Gameplay
            VBox.AddChild(new Label {
                FontOverride = headerFont, Text = "\nGameplay"
            });
            AddFormattedText(GameplayContents);

            //Gameplay
            VBox.AddChild(new Label {
                FontOverride = headerFont, Text = Loc.GetString("\nSandbox spawner", Key(OpenSandboxWindow))
            });
            AddFormattedText(SandboxSpawnerContents);

            //Feedback
            VBox.AddChild(new Label {
                FontOverride = headerFont, Text = "\nFeedback"
            });
            AddFormattedText(FeedbackContents);
        }
        public TutorialWindow()
        {
            Title = "The Tutorial!";

            //Get section header font
            var  cache        = IoCManager.Resolve <IResourceCache>();
            var  inputManager = IoCManager.Resolve <IInputManager>();
            Font headerFont   = new VectorFont(cache.GetResource <FontResource>("/Nano/NotoSans/NotoSans-Regular.ttf"), _headerFontSize);

            var scrollContainer = new ScrollContainer();

            scrollContainer.AddChild(VBox = new VBoxContainer());
            Contents.AddChild(scrollContainer);

            //Intro
            VBox.AddChild(new Label {
                FontOverride = headerFont, Text = "Intro"
            });
            AddFormattedText(IntroContents);

            string Key(BoundKeyFunction func)
            {
                return(FormattedMessage.EscapeText(inputManager.GetKeyFunctionButtonString(func)));
            }

            //Controls
            VBox.AddChild(new Label {
                FontOverride = headerFont, Text = "\nControls"
            });

            // Moved this down here so that Rider shows which args correspond to which format spot.
            AddFormattedText(Loc.GetString(@"Movement: [color=#a4885c]{0} {1} {2} {3}[/color]
Switch hands: [color=#a4885c]{4}[/color]
Use held item: [color=#a4885c]{5}[/color]
Drop held item: [color=#a4885c]{6}[/color]
Open inventory: [color=#a4885c]{7}[/color]
Open character window: [color=#a4885c]{8}[/color]
Open crafting window: [color=#a4885c]{9}[/color]
Focus chat: [color=#a4885c]{10}[/color]
Use targeted entity: [color=#a4885c]{11}[/color]
Throw held item: [color=#a4885c]{12}[/color]
Examine entity: [color=#a4885c]{13}[/color]
Open entity context menu: [color=#a4885c]{14}[/color]
Toggle combat mode: [color=#a4885c]{15}[/color]
Toggle console: [color=#a4885c]{16}[/color]
Toggle UI: [color=#a4885c]{17}[/color]
Toggle debug overlay: [color=#a4885c]{18}[/color]
Toggle entity spawner: [color=#a4885c]{19}[/color]
Toggle tile spawner: [color=#a4885c]{20}[/color]
Toggle sandbox window: [color=#a4885c]{21}[/color]",
                                           Key(MoveUp), Key(MoveLeft), Key(MoveDown), Key(MoveRight),
                                           Key(SwapHands),
                                           Key(ActivateItemInHand),
                                           Key(Drop),
                                           Key(OpenInventoryMenu),
                                           Key(OpenCharacterMenu),
                                           Key(OpenCraftingMenu),
                                           Key(FocusChat),
                                           Key(ActivateItemInWorld),
                                           Key(ThrowItemInHand),
                                           Key(ExamineEntity),
                                           Key(OpenContextMenu),
                                           Key(ToggleCombatMode),
                                           Key(ShowDebugConsole),
                                           Key(HideUI),
                                           Key(ShowDebugMonitors),
                                           Key(OpenEntitySpawnWindow),
                                           Key(OpenTileSpawnWindow),
                                           Key(OpenSandboxWindow)));

            //Gameplay
            VBox.AddChild(new Label {
                FontOverride = headerFont, Text = Loc.GetString("\nSandbox spawner", Key(OpenSandboxWindow))
            });
            AddFormattedText(SandboxSpawnerContents);

            //Gameplay
            VBox.AddChild(new Label {
                FontOverride = headerFont, Text = "\nGameplay"
            });
            AddFormattedText(GameplayContents);

            //Feedback
            VBox.AddChild(new Label {
                FontOverride = headerFont, Text = "\nFeedback"
            });
            AddFormattedText(FeedbackContents);
        }