コード例 #1
0
        private string extraTooltip(KerbalTrait k)
        {
            StringBuilder sb = StringBuilderCache.Acquire();

            if (k.ProtoCrew.experienceTrait.Config.Name == "Tourist")
            {
                sb.AppendLine();
                sb.AppendLine();
                sb.AppendFormat("<b>{0}</b>", Localizer.Format("#PORTRAIT_STATS_UI_ITINERARY", k.ProtoCrew.name));
                if (k.TouristParams.Count > 0)
                {
                    for (int i = 0; i < k.TouristParams.Count; i++)
                    {
                        sb.AppendLine();
                        sb.Append(k.TouristParams[i]);
                    }
                }
                else
                {
                    sb.AppendLine();
                    sb.Append(go_home);
                }
                sb.AppendLine();
                sb.AppendLine();
                sb.Append(k.Crew.InPart.partInfo.title);
            }
            else
            {
                sb.AppendLine();
                sb.AppendLine();
                sb.AppendFormat("<b>{0}</b> {1:P0} <b>{2}</b> {3:P0}", courage, k.ProtoCrew.courage, stupidity, k.ProtoCrew.stupidity);

                bool vet = k.ProtoCrew.veteran;
                bool bad = k.ProtoCrew.isBadass;

                if (vet || bad)
                {
                    sb.AppendLine();

                    if (vet)
                    {
                        sb.Append(veteran);
                    }

                    if (bad)
                    {
                        if (vet)
                        {
                            sb.AppendFormat(" - {0}", badass);
                        }
                        else
                        {
                            sb.Append(badass);
                        }
                    }
                }

                sb.AppendLine();
                sb.AppendLine();
                sb.Append(k.Crew.InPart.partInfo.title);
                sb.AppendLine();
                sb.AppendLine();
                if (PortraitStats.Instance.careerMode)
                {
                    sb.AppendFormat("<b>{0}</b> {1:F2}/{2}", experience, k.ProtoCrew.experience, KerbalRoster.GetExperienceLevelRequirement(k.ProtoCrew.experienceLevel));
                }

                string log = KerbalRoster.GenerateExperienceLog(k.ProtoCrew.flightLog);
                if (!string.IsNullOrEmpty(log))
                {
                    sb.AppendLine();
                    sb.AppendLine();
                    sb.AppendFormat("<b>{0}</b>", current_flight);
                    sb.AppendLine();
                    sb.Append(log);
                }
            }

            return(sb.ToStringAndRelease());
        }
コード例 #2
0
        private void DrawToolTip(int index, bool drawTraitTip)
        {
            if (tipStyle == null)
            {
                tipStyle                  = new GUIStyle(GUI.skin.box);
                tipStyle.wordWrap         = true;
                tipStyle.stretchHeight    = true;
                tipStyle.normal.textColor = Color.white;
                tipStyle.richText         = true;
                tipStyle.alignment        = TextAnchor.UpperLeft;
            }

            GUI.depth = 0;
            if (Time.fixedTime > toolTipTime + 0.4)
            {
                ProtoCrewMember pcm = activeCrew[index].ProtoCrew;

                if (pcm == null)
                {
                    return;
                }

                string text = "";

                if (drawTraitTip)
                {
                    text = "<b>" + pcm.name + "</b>";
                    if (pcm.isBadass)
                    {
                        text += " - Badass";
                    }
                    text += "\nCourage: " + pcm.courage.ToString("P0") + " Stupidity: " + pcm.stupidity.ToString("P0");
                    text += "\n<b>" + pcm.experienceTrait.Title + "</b>";
                    if (!string.IsNullOrEmpty(pcm.experienceTrait.Description))
                    {
                        text += "\n" + pcm.experienceTrait.Description;
                    }
                    if (!string.IsNullOrEmpty(pcm.experienceTrait.DescriptionEffects))
                    {
                        text += "\n<b>Effects</b>\n";
                        text += pcm.experienceTrait.DescriptionEffects;
                    }
                }
                else
                {
                    text = "<b>" + pcm.name + "</b>";
                    if (careerMode)
                    {
                        text += "\n<b>Experience:</b> " + pcm.experience.ToString("F2") + "/" + KerbalRoster.GetExperienceLevelRequirement(pcm.experienceLevel);
                    }
                    string log = KerbalRoster.GenerateExperienceLog(pcm.careerLog);
                    if (!string.IsNullOrEmpty(log))
                    {
                        text += "\n<b>Career Log:</b>\n";
                        text += log;
                    }
                    log = KerbalRoster.GenerateExperienceLog(pcm.flightLog);
                    if (!string.IsNullOrEmpty(log))
                    {
                        text += "\n<b>Current Flight:</b>\n";
                        text += log;
                    }
                }

                GUIContent tip = new GUIContent(text);

                Vector2 textDimensions = tipStyle.CalcSize(tip);
                if (textDimensions.x > 320)
                {
                    textDimensions.x = 320;
                    textDimensions.y = tipStyle.CalcHeight(tip, 320);
                }
                tooltipPosition.width  = textDimensions.x;
                tooltipPosition.height = textDimensions.y;
                tooltipPosition.x      = Event.current.mousePosition.x + tooltipPosition.width > Screen.width ?
                                         Screen.width - tooltipPosition.width : Event.current.mousePosition.x;
                tooltipPosition.y = Event.current.mousePosition.y - tooltipPosition.height - 8;

                GUI.Label(tooltipPosition, tip, tipStyle);
            }
        }