Пример #1
0
        private static void AddMessage(ColoredText msg)
        {
            //listbox not created yet, don't attempt to add
            if (listBox == null)
            {
                return;
            }

            if (listBox.children.Count > MaxMessages)
            {
                listBox.children.RemoveRange(0, listBox.children.Count - MaxMessages);
            }

            Messages.Add(msg);
            if (Messages.Count > MaxMessages)
            {
                Messages.RemoveRange(0, Messages.Count - MaxMessages);
            }

            try
            {
                var textBlock = new GUITextBlock(new Rectangle(0, 0, listBox.Rect.Width, 0), msg.Text, "", Alignment.TopLeft, Alignment.Left, null, true, GUI.SmallFont);
                textBlock.CanBeFocused = false;
                textBlock.TextColor    = msg.Color;

                listBox.AddChild(textBlock);
                listBox.BarScroll = 1.0f;
            }
            catch (Exception e)
            {
                ThrowError("Failed to add a message to the debug console.", e);
            }

            selectedIndex = Messages.Count;
        }
Пример #2
0
        public void CreatePreviewWindow(GUIComponent frame)
        {
            new GUITextBlock(new Rectangle(0, 0, 0, 20), Name, "", Alignment.TopCenter, Alignment.TopCenter, frame, true, GUI.LargeFont);

            if (PreviewImage == null)
            {
                var txtBlock = new GUITextBlock(new Rectangle(-20, 60, 256, 128), TextManager.Get("SubPreviewImageNotFound"), Color.Black * 0.5f, null, Alignment.Center, "", frame, true);
                txtBlock.OutlineColor = txtBlock.TextColor;
            }
            else
            {
                new GUIImage(new Rectangle(-10, 60, 256, 128), PreviewImage, Alignment.TopLeft, frame);
            }

            Vector2 realWorldDimensions = Dimensions * Physics.DisplayToRealWorldRatio;
            string  dimensionsStr       = realWorldDimensions == Vector2.Zero ?
                                          TextManager.Get("Unknown") :
                                          TextManager.Get("DimensionsFormat").Replace("[width]", ((int)(realWorldDimensions.X)).ToString()).Replace("[height]", ((int)(realWorldDimensions.Y)).ToString());

            new GUITextBlock(new Rectangle(246, 60, 100, 20),
                             TextManager.Get("Dimensions") + ": " + dimensionsStr,
                             "", frame, GUI.SmallFont);

            new GUITextBlock(new Rectangle(246, 80, 100, 20),
                             TextManager.Get("RecommendedCrewSize") + ": " + (RecommendedCrewSizeMax == 0 ? TextManager.Get("Unknown") : RecommendedCrewSizeMin + " - " + RecommendedCrewSizeMax),
                             "", frame, GUI.SmallFont);

            new GUITextBlock(new Rectangle(246, 100, 100, 20),
                             TextManager.Get("RecommendedCrewExperience") + ": " + (string.IsNullOrEmpty(RecommendedCrewExperience) ? TextManager.Get("unknown") : RecommendedCrewExperience),
                             "", frame, GUI.SmallFont);

            new GUITextBlock(new Rectangle(246, 120, 0, 20),
                             TextManager.Get("CompatibleContentPackages") + ":\n" + string.Join(", ", CompatibleContentPackages),
                             "", Alignment.TopLeft, Alignment.TopLeft, frame, true, GUI.SmallFont);

            var descrBox = new GUIListBox(new Rectangle(0, 200, 0, 120), "", frame);

            var descr = new GUITextBlock(new Rectangle(0, 0, descrBox.Rect.Width - 15, 0), Description + "\n", "", Alignment.TopLeft, Alignment.TopLeft, null, true, GUI.SmallFont);

            descrBox.AddChild(descr);
            descr.CanBeFocused = false;
        }
Пример #3
0
        public static void NewMessage(string msg, Color color)
        {
            if (String.IsNullOrEmpty((msg)))
            {
                return;
            }

            Messages.Add(new ColoredText(msg, color));

            if (Messages.Count > MaxMessages)
            {
                Messages.RemoveRange(0, Messages.Count - MaxMessages);
            }

            //listbox not created yet, don't attempt to add
            if (listBox == null)
            {
                return;
            }

            if (listBox.children.Count > MaxMessages)
            {
                listBox.children.RemoveRange(0, listBox.children.Count - MaxMessages);
            }

            try
            {
                var textBlock = new GUITextBlock(new Rectangle(0, 0, listBox.Rect.Width, 0), msg, "", Alignment.TopLeft, Alignment.Left, null, true, GUI.SmallFont);
                textBlock.CanBeFocused = false;
                textBlock.TextColor    = color;

                listBox.AddChild(textBlock);
                listBox.BarScroll = 1.0f;
            }
            catch
            {
                return;
            }

            selectedIndex = listBox.children.Count;
        }
Пример #4
0
 public override void AddChild(GUIComponent child)
 {
     listBox.AddChild(child);
 }
Пример #5
0
        public GUIFrame CreateSummaryFrame(string endMessage)
        {
            bool singleplayer = GameMain.NetworkMember == null;

            bool gameOver = gameSession.CrewManager.GetCharacters().All(c => c.IsDead || c.IsUnconscious);
            bool progress = Submarine.MainSub.AtEndPosition;

            GUIFrame frame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.8f, null);

            int      width = 760, height = 400;
            GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, width, height), null, Alignment.Center, "", frame);

            GUIListBox listBox = new GUIListBox(new Rectangle(0, 0, 0, height - (int)(30 + innerFrame.Padding.Y + innerFrame.Padding.W)), "", innerFrame);

            if (!singleplayer)
            {
                SoundPlayer.OverrideMusicType = gameOver ? "crewdead" : "endround";
            }

            string summaryText = TextManager.Get(gameOver ? "RoundSummaryGameOver" :
                                                 (progress ? "RoundSummaryProgress" : "RoundSummaryReturn"));

            summaryText = summaryText
                          .Replace("[sub]", Submarine.MainSub.Name)
                          .Replace("[location]", progress ? GameMain.GameSession.EndLocation.Name : GameMain.GameSession.StartLocation.Name);

            var infoText = new GUITextBlock(new Rectangle(0, 0, listBox.Rect.Width - 20, 0), summaryText, "", null, true);

            infoText.Rect = new Rectangle(0, 0, infoText.Rect.Width, infoText.Rect.Height + 20);
            listBox.AddChild(infoText);

            if (!string.IsNullOrWhiteSpace(endMessage))
            {
                var endText = new GUITextBlock(new Rectangle(0, 0, listBox.Rect.Width - 20, 0), endMessage, "", null, true);
                endText.Rect = new Rectangle(0, 0, endText.Rect.Width, endText.Rect.Height + 20);
                listBox.AddChild(endText);
            }

            if (GameMain.GameSession.Mission != null)
            {
                new GUITextBlock(new Rectangle(0, 0, 0, 40), TextManager.Get("Mission") + ": " + GameMain.GameSession.Mission.Name, "", listBox, GUI.LargeFont);

                var missionInfo = new GUITextBlock(new Rectangle(0, 0, listBox.Rect.Width - 20, 0),
                                                   (GameMain.GameSession.Mission.Completed) ? GameMain.GameSession.Mission.SuccessMessage : GameMain.GameSession.Mission.FailureMessage,
                                                   "", null, true);
                missionInfo.Rect = new Rectangle(0, 0, missionInfo.Rect.Width, missionInfo.Rect.Height + 20);
                listBox.AddChild(missionInfo);

                if (GameMain.GameSession.Mission.Completed)
                {
                    GameMain.Server?.ConnectedClients.ForEach(c => c.Karma += 0.1f);
                }

                if (GameMain.GameSession.Mission.Completed && singleplayer)
                {
                    var missionReward = new GUITextBlock(new Rectangle(0, 0, listBox.Rect.Width - 20, 0), TextManager.Get("Reward") + ": " + GameMain.GameSession.Mission.Reward, "", Alignment.BottomLeft, Alignment.BottomLeft, null);
                    missionReward.Rect = new Rectangle(0, 0, missionReward.Rect.Width, missionReward.Rect.Height + 20);
                    listBox.AddChild(missionReward);
                }
            }
            else
            {
                GameMain.Server?.ConnectedClients.ForEach(c => c.Karma += 0.1f);
            }


            new GUITextBlock(new Rectangle(0, 0, 0, 40), TextManager.Get("RoundSummaryCrewStatus"), "", listBox, GUI.LargeFont);

            GUIListBox characterListBox = new GUIListBox(new Rectangle(0, 0, listBox.Rect.Width - 20, 90), null, Alignment.TopLeft, "", null, true);

            listBox.AddChild(characterListBox);

            int x = 0;

            foreach (CharacterInfo characterInfo in gameSession.CrewManager.GetCharacterInfos())
            {
                if (GameMain.GameSession.Mission is CombatMission &&
                    characterInfo.TeamID != GameMain.GameSession.CrewManager.WinningTeam)
                {
                    continue;
                }

                var characterFrame = new GUIFrame(new Rectangle(x, 0, 170, 70), Color.Transparent, "", characterListBox);
                characterFrame.OutlineColor = Color.Transparent;
                characterFrame.Padding      = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
                characterFrame.CanBeFocused = false;

                characterInfo.CreateCharacterFrame(characterFrame,
                                                   characterInfo.Job != null ? (characterInfo.Name + '\n' + "(" + characterInfo.Job.Name + ")") : characterInfo.Name, null);

                string statusText  = TextManager.Get("StatusOK");
                Color  statusColor = Color.DarkGreen;

                Character character = characterInfo.Character;
                if (character == null || character.IsDead)
                {
                    statusText  = TextManager.Get("CauseOfDeathDescription." + characterInfo.CauseOfDeath.ToString());
                    statusColor = Color.DarkRed;
                }
                else
                {
                    if (character.IsUnconscious)
                    {
                        statusText  = TextManager.Get("Unconscious");
                        statusColor = Color.DarkOrange;
                    }
                    else if (character.Health / character.MaxHealth < 0.8f)
                    {
                        statusText  = TextManager.Get("Injured");
                        statusColor = Color.DarkOrange;
                    }
                }

                new GUITextBlock(
                    new Rectangle(0, 0, 0, 20), statusText, statusColor * 0.8f, Color.White,
                    Alignment.BottomLeft, Alignment.Center,
                    null, characterFrame, true, GUI.SmallFont);

                x += characterFrame.Rect.Width + 10;
            }


            return(frame);
        }