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);
        }
 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);
        }
        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.
        }
Example #6
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);
        }
Example #7
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);
        }
Example #8
0
        public void AddLine(FormattedMessage message, Color color)
        {
            if (Disposed)
            {
                return;
            }

            var formatted = new FormattedMessage(3);

            formatted.PushColor(color);
            formatted.AddMessage(message);
            formatted.Pop();
            Contents.AddMessage(formatted);
        }
Example #9
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);
        }
Example #10
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);
        }
        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);
        }
Example #12
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);
        }
Example #13
0
        public void Execute(IConsoleShell shell, string argStr, string[] args)
        {
            var window = new DefaultWindow {
                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();

            message.AddText("Foo\n");
            message.PushColor(Color.Red);
            message.AddText("Bar");
            message.Pop();
            rich.SetMessage(message);
            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}"
                    });
Example #14
0
        public bool Execute(IDebugConsole console, params string[] args)
        {
            var window = new SS14Window("UITest");

            window.AddToScreen();
            var tabContainer = new TabContainer();

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

            tabContainer.AddChild(scroll);
            scroll.SetAnchorAndMarginPreset(Control.LayoutPreset.Wide);
            var vBox = new VBoxContainer();

            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 {
                SizeFlagsVertical = Control.SizeFlags.FillExpand
            };
            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();

            message.AddText("Foo\n");
            message.PushColor(Color.Red);
            message.AddText("Bar");
            message.Pop();
            rich.SetMessage(message);
            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
                    {
                        CustomMinimumSize = (50, 50),
                        Text = $"{x}, {y}"
                    });