Esempio n. 1
0
        public void Examine(FormattedMessage message, bool inDetailsRange)
        {
            if (!inDetailsRange)
            {
                return;
            }

            var gam = EntitySystem.Get <AtmosphereSystem>().GetGridAtmosphere(Owner.Transform.GridID);

            var tile = gam?.GetTile(Owner.Transform.GridPosition).Air;

            if (tile == null)
            {
                return;
            }

            message.AddText($"Pressure: {tile.Pressure}\n");
            message.AddText($"Temperature: {tile.Temperature}\n");

            for (int i = 0; i < Atmospherics.TotalNumberOfGases; i++)
            {
                var gas = Atmospherics.GetGas(i);

                if (tile.Gases[i] <= Atmospherics.GasMinMoles)
                {
                    continue;
                }

                message.AddText(gas.Name);
                message.AddText($"\n Moles: {tile.Gases[i]}\n");
            }
        }
        public void Examine(FormattedMessage message, bool inDetailsRange)
        {
            message.AddText(Loc.GetString("It is set to broadcast over the {0} frequency.", BroadcastFrequency));

            message.AddText(Loc.GetString("A small screen on the headset displays the following available frequencies:"));
            message.AddText("\n");
            message.AddText(Loc.GetString("Use {0} for the currently tuned frequency.", ";"));
        }
Esempio n. 3
0
 public void Examine(FormattedMessage message)
 {
     message.AddText("A dice with ");
     message.PushColor(new Color(1F, 0.75F, 0.75F));
     message.AddText(_sides.ToString());
     message.Pop();
     message.AddText(" sides.\nIt has landed on a ");
     message.PushColor(new Color(1F, 1F, 1F));
     message.AddText(_currentSide.ToString());
     message.Pop();
     message.AddText(".");
 }
        public void Log(LogMessage message)
        {
            var formatted = new FormattedMessage(8);

            formatted.PushColor(Color.DarkGray);
            formatted.AddText("[");
            formatted.PushColor(LogLevelToColor(message.Level));
            formatted.AddText(message.LogLevelToName());
            formatted.Pop();
            formatted.AddText($"] {message.SawmillName}: ");
            formatted.Pop();
            formatted.AddText(message.Message);
            Console.AddFormattedLine(formatted);
        }
Esempio n. 5
0
        public FormattedMessage GetExamineText(EntityUid entity, EntityUid?examiner)
        {
            var message = new FormattedMessage();

            if (examiner == null)
            {
                return(message);
            }

            var doNewline = false;

            //Add an entity description if one is declared
            if (!string.IsNullOrEmpty(EntityManager.GetComponent <MetaDataComponent>(entity).EntityDescription))
            {
                message.AddText(EntityManager.GetComponent <MetaDataComponent>(entity).EntityDescription);
                doNewline = true;
            }

            message.PushColor(Color.DarkGray);

            // Raise the event and let things that subscribe to it change the message...
            var isInDetailsRange = IsInDetailsRange(examiner.Value, entity);
            var examinedEvent    = new ExaminedEvent(message, entity, examiner.Value, isInDetailsRange, doNewline);

            RaiseLocalEvent(entity, examinedEvent);

            //Add component statuses from components that report one
            foreach (var examineComponent in EntityManager.GetComponents <IExamine>(entity))
            {
                var subMessage = new FormattedMessage();
                examineComponent.Examine(subMessage, isInDetailsRange);
                if (subMessage.Tags.Count == 0)
                {
                    continue;
                }

                if (doNewline)
                {
                    message.AddText("\n");
                }

                message.AddMessage(subMessage);
                doNewline = true;
            }

            message.Pop();

            return(message);
        }
 void IExamine.Examine(FormattedMessage message)
 {
     message.AddText(_loc.GetString("Contains:\n"));
     foreach (var reagent in ReagentList)
     {
         if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype proto))
         {
             message.AddText($"{proto.Name}: {reagent.Quantity}u\n");
         }
         else
         {
             message.AddText(_loc.GetString("Unknown reagent: {0}u\n", reagent.Quantity));
         }
     }
 }
Esempio n. 7
0
        public void SetMessage(string message)
        {
            var msg = new FormattedMessage();

            msg.AddText(message);
            SetMessage(msg);
        }
Esempio n. 8
0
        /// <summary>
        /// Push another message containing raw text into this examine result, on its own line.
        /// </summary>
        /// <seealso cref="PushMarkup"/>
        /// <seealso cref="PushMessage"/>
        public void PushText(string text)
        {
            var msg = new FormattedMessage();

            msg.AddText(text);
            PushMessage(msg);
        }
        public FormattedMessage GetExamineText(EntityUid entity, EntityUid?examiner)
        {
            var message = new FormattedMessage();

            if (examiner == null)
            {
                return(message);
            }

            var doNewline = false;

            //Add an entity description if one is declared
            if (!string.IsNullOrEmpty(EntityManager.GetComponent <MetaDataComponent>(entity).EntityDescription))
            {
                message.AddText(EntityManager.GetComponent <MetaDataComponent>(entity).EntityDescription);
                doNewline = true;
            }

            message.PushColor(Color.DarkGray);

            // Raise the event and let things that subscribe to it change the message...
            var isInDetailsRange = IsInDetailsRange(examiner.Value, entity);
            var examinedEvent    = new ExaminedEvent(message, entity, examiner.Value, isInDetailsRange, doNewline);

            RaiseLocalEvent(entity, examinedEvent, true);

            message.Pop();

            return(message);
        }
        public void AddLine(string text, ChatChannel channel, Color color)
        {
            if (!ThreadUtility.IsOnMainThread())
            {
                var formatted = new FormattedMessage(3);
                formatted.PushColor(color);
                formatted.AddText(text);
                formatted.Pop();
                _messageQueue.Enqueue(formatted);
                return;
            }

            _flushQueue();
            if (!firstLine)
            {
                Contents.NewLine();
            }
            else
            {
                firstLine = false;
            }

            Contents.PushColor(color);
            Contents.AddText(text);
            Contents.Pop(); // Pop the color off.
        }
Esempio n. 11
0
        public void ReceiveLine(string text)
        {
            var formatted = new FormattedMessage(1);

            formatted.AddText(text);
            TextOutput.AddMessage(formatted);
        }
Esempio n. 12
0
 void IExamine.Examine(FormattedMessage message)
 {
     if (Activated)
     {
         message.AddText("The light is currently on.");
     }
 }
Esempio n. 13
0
        public override void Output(string value, string data)
        {
            var msg = new FormattedMessage(2);

            msg.PushColor(Color.Black);
            msg.AddText(value);
            _textBox.AddMessage(msg);
        }
Esempio n. 14
0
        public override void Examine(FormattedMessage message, bool inDetailsRange)
        {
            base.Examine(message, inDetailsRange);

            var text = Loc.GetString("\nIt uses {0} ammo.", Caliber);

            message.AddText(text);
        }
 public void Examine(FormattedMessage message)
 {
     if (_description == null)
     {
         return;
     }
     message.AddText(_description);
 }
Esempio n. 16
0
        public FormattedMessage GetExamineText(IEntity entity, IEntity?examiner)
        {
            var message = new FormattedMessage();

            if (examiner == null)
            {
                return(message);
            }

            var doNewline = false;

            //Add an entity description if one is declared
            if (!string.IsNullOrEmpty(entity.Description))
            {
                message.AddText(entity.Description);
                doNewline = true;
            }

            message.PushColor(Color.DarkGray);

            // Raise the event and let things that subscribe to it change the message...
            RaiseLocalEvent(entity.Uid, new ExaminedEvent(message, entity, examiner, IsInDetailsRange(examiner, entity)));

            //Add component statuses from components that report one
            foreach (var examineComponent in entity.GetAllComponents <IExamine>())
            {
                var subMessage = new FormattedMessage();
                examineComponent.Examine(subMessage, IsInDetailsRange(examiner, entity));
                if (subMessage.Tags.Count == 0)
                {
                    continue;
                }

                if (doNewline)
                {
                    message.AddText("\n");
                }

                message.AddMessage(subMessage);
                doNewline = true;
            }

            message.Pop();

            return(message);
        }
Esempio n. 17
0
        public void AddLine(string text, ChatChannel channel, Color color)
        {
            var formatted = new FormattedMessage(3);

            formatted.PushColor(color);
            formatted.AddText(text);
            formatted.Pop();
            AddFormattedLine(formatted);
        }
Esempio n. 18
0
 void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
 {
     if (inDetailsRange)
     {
         if (LabelContainer?.ContainedEntity != null && LabelContainer.ContainedEntity.TryGetComponent <PaperComponent>(out var paper))
         {
             message.AddText(Loc.GetString("The label reads: {0}", paper.Content));
         }
     }
 }
        public static FormattedMessage GetExamineText(IEntity entity, IEntity examiner)
        {
            var message = new FormattedMessage();

            var doNewline = false;

            //Add an entity description if one is declared
            if (!string.IsNullOrEmpty(entity.Description))
            {
                message.AddText(entity.Description);
                doNewline = true;
            }

            message.PushColor(Color.DarkGray);

            var inDetailsRange = Get <SharedInteractionSystem>()
                                 .InRangeUnobstructed(examiner.Transform.MapPosition, entity.Transform.MapPosition,
                                                      ExamineDetailsRange, predicate: entity0 => entity0 == examiner || entity0 == entity, ignoreInsideBlocker: true);

            //Add component statuses from components that report one
            foreach (var examineComponent in entity.GetAllComponents <IExamine>())
            {
                var subMessage = new FormattedMessage();
                examineComponent.Examine(subMessage, inDetailsRange);
                if (subMessage.Tags.Count == 0)
                {
                    continue;
                }

                if (doNewline)
                {
                    message.AddText("\n");
                }

                message.AddMessage(subMessage);
                doNewline = true;
            }

            message.Pop();

            return(message);
        }
        public void Log(string sawmillName, LogEvent message)
        {
            if (sawmillName == "CON")
            {
                return;
            }

            var formatted   = new FormattedMessage(8);
            var robustLevel = message.Level.ToRobust();

            formatted.PushColor(Color.DarkGray);
            formatted.AddText("[");
            formatted.PushColor(LogLevelToColor(robustLevel));
            formatted.AddText(LogMessage.LogLevelToName(robustLevel));
            formatted.Pop();
            formatted.AddText($"] {sawmillName}: ");
            formatted.Pop();
            formatted.AddText(message.RenderMessage());
            if (message.Exception != null)
            {
                formatted.AddText("\n");
                formatted.AddText(message.Exception.ToString());
            }
            Console.AddFormattedLine(formatted);
        }
Esempio n. 21
0
        public static FormattedMessage GetExamineText(IEntity entity, IEntity examiner)
        {
            var message = new FormattedMessage();

            var doNewline = false;

            //Add an entity description if one is declared
            if (!string.IsNullOrEmpty(entity.Description))
            {
                message.AddText(entity.Description);
                doNewline = true;
            }

            message.PushColor(Color.DarkGray);

            //Add component statuses from components that report one
            foreach (var examineComponent in entity.GetAllComponents <IExamine>())
            {
                var subMessage = new FormattedMessage();
                examineComponent.Examine(subMessage, IsInDetailsRange(examiner, entity));
                if (subMessage.Tags.Count == 0)
                {
                    continue;
                }

                if (doNewline)
                {
                    message.AddText("\n");
                }

                message.AddMessage(subMessage);
                doNewline = true;
            }

            message.Pop();

            return(message);
        }
Esempio n. 22
0
        void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
        {
            if (!Owner.TryGetComponent(out IDamageableComponent? damageable) ||
                !Owner.TryGetComponent(out DestructibleComponent? destructible))
            {
                return;
            }

            var           damage  = damageable.TotalDamage;
            DamageTrigger?trigger = null;

            // TODO: Pretend this does not exist until https://github.com/space-wizards/space-station-14/pull/2783 is merged
            foreach (var threshold in destructible.Thresholds)
            {
                if ((trigger = threshold.Trigger as DamageTrigger) != null)
                {
                    break;
                }
            }

            if (trigger == null)
            {
                return;
            }

            var damageThreshold = trigger.Damage;
            var fraction        = damage == 0 || damageThreshold == 0
                ? 0f
                : (float)damage / damageThreshold;
            var level = Math.Min(ContentHelpers.RoundToLevels((double)fraction, 1, 7), 5);

            switch (level)
            {
            case 0:
                message.AddText(Loc.GetString("It looks fully intact."));
                break;

            case 1:
                message.AddText(Loc.GetString("It has a few scratches."));
                break;

            case 2:
                message.AddText(Loc.GetString("It has a few small cracks."));
                break;

            case 3:
                message.AddText(Loc.GetString("It has several big cracks running along its surface."));
                break;

            case 4:
                message.AddText(Loc.GetString("It has deep cracks across multiple layers."));
                break;

            case 5:
                message.AddText(Loc.GetString("It is extremely badly cracked and on the verge of shattering."));
                break;
            }
        }
Esempio n. 23
0
        void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
        {
            if (!Owner.TryGetComponent(out IDamageableComponent? damageable) ||
                !Owner.TryGetComponent(out DestructibleComponent? destructible))
            {
                return;
            }

            var           damage  = damageable.TotalDamage;
            DamageTrigger?trigger = null;

            // TODO: Pretend this does not exist until https://github.com/space-wizards/space-station-14/pull/2783 is merged
            foreach (var threshold in destructible.Thresholds)
            {
                if ((trigger = threshold.Trigger as DamageTrigger) != null)
                {
                    break;
                }
            }

            if (trigger == null)
            {
                return;
            }

            var damageThreshold = trigger.Damage;
            var fraction        = damage == 0 || damageThreshold == 0
                ? 0f
                : (float)damage / damageThreshold;
            var level = Math.Min(ContentHelpers.RoundToLevels((double)fraction, 1, 7), 5);

            switch (level)
            {
            case 0:
                message.AddText(Loc.GetString("comp-window-damaged-1"));
                break;

            case 1:
                message.AddText(Loc.GetString("comp-window-damaged-2"));
                break;

            case 2:
                message.AddText(Loc.GetString("comp-window-damaged-3"));
                break;

            case 3:
                message.AddText(Loc.GetString("comp-window-damaged-4"));
                break;

            case 4:
                message.AddText(Loc.GetString("comp-window-damaged-5"));
                break;

            case 5:
                message.AddText(Loc.GetString("comp-window-damaged-6"));
                break;
            }
        }
        public void DoExamine(FormattedMessage message, ConstructionPrototype prototype, int stage, bool inDetailRange)
        {
            var stages = prototype.Stages;

            if (stage >= 0 && stage < stages.Count)
            {
                var curStage = stages[stage];
                if (curStage.Backward != null && curStage.Backward is ConstructionStepTool)
                {
                    var backward = (ConstructionStepTool)curStage.Backward;
                    message.AddText(Loc.GetString("To deconstruct: {0}x {1} Tool", backward.Amount, backward.ToolQuality));
                }
                if (curStage.Forward != null && curStage.Forward is ConstructionStepMaterial)
                {
                    if (curStage.Backward != null)
                    {
                        message.AddText("\n");
                    }
                    var forward = (ConstructionStepMaterial)curStage.Forward;
                    message.AddText(Loc.GetString("To construct: {0}x {1}", forward.Amount, forward.Material));
                }
            }
        }
Esempio n. 25
0
        public void AddLine(string message, ChatChannel channel, Color color)
        {
            if (Disposed)
            {
                return;
            }

            var formatted = new FormattedMessage(3);

            formatted.PushColor(color);
            formatted.AddText(message);
            formatted.Pop();
            contents.AddMessage(formatted);
        }
Esempio n. 26
0
        private BoxContainer MakeRoundEndSummaryTab(string gamemode, string roundEnd, TimeSpan roundDuration, int roundId)
        {
            var roundEndSummaryTab = new BoxContainer
            {
                Orientation = LayoutOrientation.Vertical,
                Name        = Loc.GetString("round-end-summary-window-round-end-summary-tab-title")
            };

            var roundEndSummaryContainerScrollbox = new ScrollContainer
            {
                VerticalExpand = true
            };
            var roundEndSummaryContainer = new BoxContainer
            {
                Orientation = LayoutOrientation.Vertical
            };

            //Gamemode Name
            var gamemodeLabel   = new RichTextLabel();
            var gamemodeMessage = new FormattedMessage();

            gamemodeMessage.AddMarkup(Loc.GetString("round-end-summary-window-round-id-label", ("roundId", roundId)));
            gamemodeMessage.AddText(" ");
            gamemodeMessage.AddMarkup(Loc.GetString("round-end-summary-window-gamemode-name-label", ("gamemode", gamemode)));
            gamemodeLabel.SetMessage(gamemodeMessage);
            roundEndSummaryContainer.AddChild(gamemodeLabel);

            //Duration
            var roundTimeLabel = new RichTextLabel();

            roundTimeLabel.SetMarkup(Loc.GetString("round-end-summary-window-duration-label",
                                                   ("hours", roundDuration.Hours),
                                                   ("minutes", roundDuration.Minutes),
                                                   ("seconds", roundDuration.Seconds)));
            roundEndSummaryContainer.AddChild(roundTimeLabel);

            //Round end text
            if (!string.IsNullOrEmpty(roundEnd))
            {
                var roundEndLabel = new RichTextLabel();
                roundEndLabel.SetMarkup(roundEnd);
                roundEndSummaryContainer.AddChild(roundEndLabel);
            }

            roundEndSummaryContainerScrollbox.AddChild(roundEndSummaryContainer);
            roundEndSummaryTab.AddChild(roundEndSummaryContainerScrollbox);

            return(roundEndSummaryTab);
        }
        void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
        {
            if (!CanExamineContents)
            {
                return;
            }

            if (ReagentList.Count == 0)
            {
                message.AddText(Loc.GetString("It's empty."));
            }
            else if (ReagentList.Count == 1)
            {
                var reagent = ReagentList[0];

                if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype proto))
                {
                    var colorStr = $" [color={proto.GetSubstanceTextColor().ToHexNoAlpha()}]";
                    message.AddText(Loc.GetString("It contains a"));
                    message.AddMarkup(colorStr + Loc.GetString(proto.PhysicalDescription) + "[/color] ");
                    message.AddText(Loc.GetString("substance."));
                }
            }
            else
            {
                var reagent = ReagentList.Max();

                if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype proto))
                {
                    var colorStr = $" [color={SubstanceColor.ToHexNoAlpha()}]";
                    message.AddText(Loc.GetString("It contains a"));
                    message.AddMarkup(colorStr + Loc.GetString(proto.PhysicalDescription) + "[/color] ");
                    message.AddText(Loc.GetString("mixture of substances."));
                }
            }
        }
        public TutorialWindow()
        {
            Title = "The Tutorial!";

            var scrollContainer = new ScrollContainer();

            Contents.AddChild(scrollContainer);

            var label = new RichTextLabel();

            scrollContainer.AddChild(label);

            var message = new FormattedMessage();

            message.AddText(TutorialContents);
            label.SetMessage(message);
        }
            public void ReceiveResponse(MsgScriptResponse response)
            {
                RunButton.Disabled = false;

                // Remove > or . at the end of the output panel.
                OutputPanel.RemoveEntry(^ 1);
                _linesEntered += 1;

                if (!response.WasComplete)
                {
                    if (_linesEntered == 1)
                    {
                        OutputPanel.AddText($"> {_lastEnteredText}");
                    }
                    else
                    {
                        OutputPanel.AddText($". {_lastEnteredText}");
                    }

                    OutputPanel.AddText(".");
                    return;
                }

                // Remove echo of partial submission from the output panel.
                for (var i = 1; i < _linesEntered; i++)
                {
                    OutputPanel.RemoveEntry(^ 1);
                }

                _linesEntered = 0;

                // Echo entered script.
                var echoMessage = new FormattedMessage();

                echoMessage.PushColor(Color.FromHex("#D4D4D4"));
                echoMessage.AddText("> ");
                echoMessage.AddMessage(response.Echo);
                OutputPanel.AddMessage(echoMessage);

                OutputPanel.AddMessage(response.Response);

                OutputPanel.AddText(">");
            }
Esempio n. 30
0
        private void _openTutorialWindow()
        {
            var window = new SS14Window {
                Title = "Tutorial"
            };

            var scrollContainer = new ScrollContainer();

            window.Contents.AddChild(scrollContainer);

            var label = new RichTextLabel();

            scrollContainer.AddChild(label);

            var message = new FormattedMessage();

            message.AddText(TutorialContents);
            label.SetMessage(message);

            window.AddToScreen();
        }