void IExamine.Examine(FormattedMessage.Builder message, bool inDetailsRange)
 {
     if (inDetailsRange)
     {
         message.AddMarkup(Loc.GetString("power-cell-component-examine-details", ("currentCharge", $"{CurrentCharge / MaxCharge * 100:F0}")));
     }
 }
        void IExamine.Examine(FormattedMessage.Builder message, bool inDetailsRange)
        {
            if (Appearance == null)
            {
                return;
            }

            if (inDetailsRange)
            {
                if (Appearance.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul)
                {
                    message.AddMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-body-has-soul"));
                }
                else if (Appearance.TryGetData(MorgueVisuals.HasMob, out bool hasMob) && hasMob)
                {
                    message.AddMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-body-has-no-soul"));
                }
                else if (Appearance.TryGetData(MorgueVisuals.HasContents, out bool hasContents) && hasContents)
                {
                    message.AddMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-has-contents"));
                }
                else
                {
                    message.AddMarkup(Loc.GetString("morgue-entity-storage-component-on-examine-details-empty"));
                }
            }
        }
Beispiel #3
0
        public void SetMessage(string message)
        {
            var msg = new FormattedMessage.Builder();

            msg.AddText(message);
            SetMessage(msg.Build());
        }
Beispiel #4
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());
        }
 public ExaminedEvent(FormattedMessage.Builder message, EntityUid examined, EntityUid examiner, bool isInDetailsRange, bool doNewLine)
 {
     Message          = message;
     Examined         = examined;
     Examiner         = examiner;
     IsInDetailsRange = isInDetailsRange;
     _doNewLine       = doNewLine;
 }
        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 virtual void Examine(FormattedMessage.Builder message, bool inDetailsRange)
 {
     var fireRateMessage = Loc.GetString(FireRateSelector switch
     {
         FireRateSelector.Safety => "server-ranged-barrel-component-on-examine-fire-rate-safety-description",
         FireRateSelector.Single => "server-ranged-barrel-component-on-examine-fire-rate-single-description",
         FireRateSelector.Automatic => "server-ranged-barrel-component-on-examine-fire-rate-automatic-description",
         _ => throw new IndexOutOfRangeException()
     });
 public void Examine(FormattedMessage.Builder message, bool inDetailsRange)
 {
     if (inDetailsRange && LidOpen)
     {
         if (_secretStash.HasItemInside())
         {
             message.AddMarkup(Loc.GetString("toilet-component-on-examine-found-hidden-item"));
         }
     }
 }
Beispiel #9
0
 void IExamine.Examine(FormattedMessage.Builder message, bool inDetailsRange)
 {
     if (Activated)
     {
         message.AddMarkup(Loc.GetString("handheld-light-component-on-examine-is-on-message"));
     }
     else
     {
         message.AddMarkup(Loc.GetString("handheld-light-component-on-examine-is-off-message"));
     }
 }
Beispiel #10
0
        public void Examine(FormattedMessage.Builder message, bool inDetailsRange)
        {
            if (!inDetailsRange)
            {
                return;
            }
            if (Content == "")
            {
                return;
            }

            message.AddMarkup(
                Loc.GetString(
                    "paper-component-examine-detail-has-words"
                    )
                );
        }
            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(">");
            }
        void IExamine.Examine(FormattedMessage.Builder message, bool inDetailsRange)
        {
            if (!inDetailsRange)
            {
                return;
            }
            string sizeLetter = SlotSize switch
            {
                PowerCellSize.Small => Loc.GetString("power-cell-slot-component-small-size-shorthand"),
                PowerCellSize.Medium => Loc.GetString("power-cell-slot-component-medium-size-shorthand"),
                PowerCellSize.Large => Loc.GetString("power-cell-slot-component-large-size-shorthand"),
                _ => "???"
            };

            if (DescFormatString != null)
            {
                message.AddMarkup(string.Format(DescFormatString, sizeLetter));
            }
        }
        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());
        }
 void IExamine.Examine(FormattedMessage.Builder message, bool inDetailsRange)
 {
     if (_battery == null)
     {
         return;
     }
     if (inDetailsRange)
     {
         var effectiveMax = _battery.MaxCharge;
         if (effectiveMax == 0)
         {
             effectiveMax = 1;
         }
         var chargeFraction       = _battery.CurrentCharge / effectiveMax;
         var chargePercentRounded = (int)(chargeFraction * 100);
         message.AddMarkup(
             Loc.GetString(
                 "examinable-battery-component-examine-detail",
                 ("percent", chargePercentRounded),
                 ("markupPercentColor", "green")
                 )
             );
     }
 }
Beispiel #15
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"));
                }
            }
        }
Beispiel #16
0
        public void Examine(FormattedMessage.Builder message, bool inDetailsRange)
        {
            var text = Loc.GetString("ammo-component-on-examine", ("caliber", Caliber));

            message.AddMarkup(text);
        }
        public void Examine(FormattedMessage.Builder message, bool inDetailsRange)
        {
            var loc = Location == null ? "<null>" : $"'{Location}'";

            message.AddText(Loc.GetString("warp-point-component-on-examine-success", ("location", loc)));
        }
 static ExamineSystem()
 {
     _entityNotFoundMessage = new FormattedMessage.Builder();
     _entityNotFoundMessage.AddText(Loc.GetString("examine-system-entity-does-not-exist"));
 }
 public void Examine(FormattedMessage.Builder message, bool inDetailsRange)
 {
     message.AddMarkup(Loc.GetString("machine-part-component-on-examine-rating-text", ("rating", Rating)) + "\n");
     message.AddMarkup(Loc.GetString("machine-part-component-on-examine-type-text", ("type", PartType)) + "\n");
 }
        public void Examine(FormattedMessage.Builder message, bool inDetailsRange)
        {
            if (!inDetailsRange)
            {
                return;
            }

            if (Seed == null)
            {
                message.AddMarkup(Loc.GetString("plant-holder-component-nothing-planted-message") + "\n");
            }
            else if (!Dead)
            {
                message.AddMarkup(Loc.GetString("plant-holder-component-something-already-growing-message",
                                                ("seedName", Seed.DisplayName),
                                                ("toBeForm", Seed.DisplayName.EndsWith('s') ? "are" : "is"))
                                  + "\n");

                if (Health <= Seed.Endurance / 2)
                {
                    message.AddMarkup(Loc.GetString(
                                          "plant-holder-component-something-already-growing-low-health-message",
                                          ("healthState",
                                           Loc.GetString(Age > Seed.Lifespan
                                                  ? "plant-holder-component-plant-old-adjective"
                                                  : "plant-holder-component-plant-unhealthy-adjective")))
                                      + "\n");
                }
            }
            else
            {
                message.AddMarkup(Loc.GetString("plant-holder-component-dead-plant-matter-message") + "\n");
            }

            if (WeedLevel >= 5)
            {
                message.AddMarkup(Loc.GetString("plant-holder-component-weed-high-level-message") + "\n");
            }

            if (PestLevel >= 5)
            {
                message.AddMarkup(Loc.GetString("plant-holder-component-pest-high-level-message") + "\n");
            }

            message.AddMarkup(Loc.GetString($"plant-holder-component-water-level-message",
                                            ("waterLevel", (int)WaterLevel)) + "\n");
            message.AddMarkup(Loc.GetString($"plant-holder-component-nutrient-level-message",
                                            ("nutritionLevel", (int)NutritionLevel)) + "\n");

            if (DrawWarnings)
            {
                if (Toxins > 40f)
                {
                    message.AddMarkup(Loc.GetString("plant-holder-component-toxins-high-warning") + "\n");
                }

                if (ImproperLight)
                {
                    message.AddMarkup(Loc.GetString("plant-holder-component-light-improper-warning") + "\n");
                }

                if (ImproperHeat)
                {
                    message.AddMarkup(Loc.GetString("plant-holder-component-heat-improper-warning") + "\n");
                }

                if (ImproperPressure)
                {
                    message.AddMarkup(Loc.GetString("plant-holder-component-pressure-improper-warning") + "\n");
                }

                if (_missingGas > 0)
                {
                    message.AddMarkup(Loc.GetString("plant-holder-component-gas-missing-warning") + "\n");
                }
            }
        }
Beispiel #21
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}"
                    });
Beispiel #22
0
 public static void AddMarkup(this FormattedMessage.Builder bld, string text) => bld.AddMessage(Basic.BuildMarkup(text));
Beispiel #23
0
 public static void EscapeText(this FormattedMessage.Builder _, string text) => Basic.EscapeText(text);
Beispiel #24
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());
            }