Exemple #1
0
        public void SetMessage(string message)
        {
            var msg = new FormattedMessage.Builder();

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

            if (examiner == null)
            {
                return(new(new Section[] {}));
            }

            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))
            {
                examineComponent.Examine(message, isInDetailsRange);

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

                doNewline = true;
            }

            return(message.Build());
        }
Exemple #3
0
        public void Log(string sawmillName, LogEvent message)
        {
            if (sawmillName == "CON")
            {
                return;
            }

            var formatted   = new FormattedMessage.Builder();
            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.PushColor(Color.LightGray);
            formatted.AddText(message.RenderMessage());
            formatted.Pop();
            if (message.Exception != null)
            {
                formatted.AddText("\n");
                formatted.AddText(message.Exception.ToString());
            }
            Console.AddFormattedLine(formatted.Build());
        }
        void IExamine.Examine(FormattedMessage.Builder message, bool inDetailsRange)
        {
            if (!_entMan.TryGetComponent(Owner, out DamageableComponent? damageable) ||
                !_entMan.TryGetComponent(Owner, 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(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 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.Builder();

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

                OutputPanel.AddMessage(response.Response);

                OutputPanel.AddText(">");
            }
Exemple #6
0
        void IExamine.Examine(FormattedMessage.Builder message, bool inDetailsRange)
        {
            if (Appearance == null)
            {
                return;
            }

            if (inDetailsRange)
            {
                if (Appearance.TryGetData(CrematoriumVisuals.Burning, out bool isBurning) && isBurning)
                {
                    message.AddMarkup(Loc.GetString("crematorium-entity-storage-component-on-examine-details-is-burning", ("owner", Owner)) + "\n");
                }

                if (Appearance.TryGetData(MorgueVisuals.HasContents, out bool hasContents) && hasContents)
                {
                    message.AddMarkup(Loc.GetString("crematorium-entity-storage-component-on-examine-details-has-contents"));
                }
                else
                {
                    message.AddText(Loc.GetString("crematorium-entity-storage-component-on-examine-details-empty"));
                }
            }
        }
 static ExamineSystem()
 {
     _entityNotFoundMessage = new FormattedMessage.Builder();
     _entityNotFoundMessage.AddText(Loc.GetString("examine-system-entity-does-not-exist"));
 }
Exemple #8
0
            public Entry(LiteResult result)
            {
                MouseFilter = MouseFilterMode.Stop;
                Result      = result;
                var compl = new FormattedMessage.Builder();
                var dim   = Color.FromHsl((0f, 0f, 0.8f, 1f));

                // warning: ew ahead
                string basen = "default";

                if (Result.Tags.Contains("Interface"))
                {
                    basen = "interface name";
                }
                else if (Result.Tags.Contains("Class"))
                {
                    basen = "class name";
                }
                else if (Result.Tags.Contains("Struct"))
                {
                    basen = "struct name";
                }
                else if (Result.Tags.Contains("Keyword"))
                {
                    basen = "keyword";
                }
                else if (Result.Tags.Contains("Namespace"))
                {
                    basen = "namespace name";
                }
                else if (Result.Tags.Contains("Method"))
                {
                    basen = "method name";
                }
                else if (Result.Tags.Contains("Property"))
                {
                    basen = "property name";
                }
                else if (Result.Tags.Contains("Field"))
                {
                    basen = "field name";
                }

                Color basec = ScriptingColorScheme.ColorScheme[basen];

                compl.PushColor(basec * dim);
                compl.AddText(Result.DisplayTextPrefix);
                compl.PushColor(basec);
                compl.AddText(Result.DisplayText);
                compl.PushColor(basec * dim);
                compl.AddText(Result.DisplayTextSuffix);
                compl.AddText(" [" + String.Join(", ", Result.Tags) + "]");
                if (Result.InlineDescription.Length != 0)
                {
                    compl.PushNewline();
                    compl.AddText(": ");
                    compl.PushColor(Color.LightSlateGray);
                    compl.AddText(Result.InlineDescription);
                }
                SetMessage(compl.Build());
            }
Exemple #9
0
        public void Execute(IConsoleShell shell, string argStr, string[] args)
        {
            var window = new SS14Window {
                MinSize = (500, 400)
            };
            var tabContainer = new TabContainer();

            window.Contents.AddChild(tabContainer);
            var scroll = new ScrollContainer();

            tabContainer.AddChild(scroll);
            //scroll.SetAnchorAndMarginPreset(Control.LayoutPreset.Wide);
            var vBox = new BoxContainer
            {
                Orientation = LayoutOrientation.Vertical
            };

            scroll.AddChild(vBox);

            var progressBar = new ProgressBar {
                MaxValue = 10, Value = 5
            };

            vBox.AddChild(progressBar);

            var optionButton = new OptionButton();

            optionButton.AddItem("Honk");
            optionButton.AddItem("Foo");
            optionButton.AddItem("Bar");
            optionButton.AddItem("Baz");
            optionButton.OnItemSelected += eventArgs => optionButton.SelectId(eventArgs.Id);
            vBox.AddChild(optionButton);

            var tree = new Tree {
                VerticalExpand = true
            };
            var root = tree.CreateItem();

            root.Text = "Honk!";
            var child = tree.CreateItem();

            child.Text = "Foo";
            for (var i = 0; i < 20; i++)
            {
                child      = tree.CreateItem();
                child.Text = $"Bar {i}";
            }

            vBox.AddChild(tree);

            var rich    = new RichTextLabel();
            var message = new FormattedMessage.Builder();

            message.AddText("Foo\n");
            message.PushColor(Color.Red);
            message.AddText("Bar");
            message.Pop();
            rich.SetMessage(message.Build());
            vBox.AddChild(rich);

            var itemList = new ItemList();

            tabContainer.AddChild(itemList);
            for (var i = 0; i < 10; i++)
            {
                itemList.AddItem(i.ToString());
            }

            var grid = new GridContainer {
                Columns = 3
            };

            tabContainer.AddChild(grid);
            for (var y = 0; y < 3; y++)
            {
                for (var x = 0; x < 3; x++)
                {
                    grid.AddChild(new Button
                    {
                        MinSize = (50, 50),
                        Text    = $"{x}, {y}"
                    });