Exemple #1
0
        protected override void FillTab()
        {
            Pawn selPawnForCombatInfo = SelPawnForCombatInfo;
            Rect rect  = new Rect(0f, 0f, size.x, size.y);
            Rect rect2 = new Rect(ShowAllX, ToolbarHeight, ShowAllWidth, 24f);
            bool flag  = showAll;

            Widgets.CheckboxLabeled(rect2, "ShowAll".Translate(), ref showAll);
            if (flag != showAll)
            {
                cachedLogDisplay = null;
            }
            Rect rect3 = new Rect(ShowCombatX, ToolbarHeight, ShowCombatWidth, 24f);
            bool flag2 = showCombat;

            Widgets.CheckboxLabeled(rect3, "ShowCombat".Translate(), ref showCombat);
            if (flag2 != showCombat)
            {
                cachedLogDisplay = null;
            }
            Rect rect4 = new Rect(ShowSocialX, ToolbarHeight, ShowSocialWidth, 24f);
            bool flag3 = showSocial;

            Widgets.CheckboxLabeled(rect4, "ShowSocial".Translate(), ref showSocial);
            if (flag3 != showSocial)
            {
                cachedLogDisplay = null;
            }
            if (cachedLogDisplay == null || cachedLogDisplayLastTick != selPawnForCombatInfo.records.LastBattleTick || cachedLogPlayLastTick != Find.PlayLog.LastTick || cachedLogForPawn != selPawnForCombatInfo)
            {
                cachedLogDisplay         = ITab_Pawn_Log_Utility.GenerateLogLinesFor(selPawnForCombatInfo, showAll, showCombat, showSocial).ToList();
                cachedLogDisplayLastTick = selPawnForCombatInfo.records.LastBattleTick;
                cachedLogPlayLastTick    = Find.PlayLog.LastTick;
                cachedLogForPawn         = selPawnForCombatInfo;
            }
            Rect rect5 = new Rect(rect.width - ButtonOffset, 0f, 18f, 24f);

            if (Widgets.ButtonImage(rect5, TexButton.Copy))
            {
                StringBuilder stringBuilder = new StringBuilder();
                foreach (ITab_Pawn_Log_Utility.LogLineDisplayable item in cachedLogDisplay)
                {
                    item.AppendTo(stringBuilder);
                }
                GUIUtility.systemCopyBuffer = stringBuilder.ToString();
            }
            TooltipHandler.TipRegion(rect5, "CopyLogTip".Translate());
            rect.yMin = 24f;
            rect      = rect.ContractedBy(10f);
            float width = rect.width - 16f - 10f;
            float num   = 0f;

            foreach (ITab_Pawn_Log_Utility.LogLineDisplayable item2 in cachedLogDisplay)
            {
                if (item2.Matches(logSeek))
                {
                    scrollPosition.y = num - (item2.GetHeight(width) + rect.height) / 2f;
                }
                num += item2.GetHeight(width);
            }
            logSeek = null;
            if (num > 0f)
            {
                Rect viewRect = new Rect(0f, 0f, rect.width - 16f, num);
                data.StartNewDraw();
                Widgets.BeginScrollView(rect, ref scrollPosition, viewRect);
                float num2 = 0f;
                foreach (ITab_Pawn_Log_Utility.LogLineDisplayable item3 in cachedLogDisplay)
                {
                    item3.Draw(num2, width, data);
                    num2 += item3.GetHeight(width);
                }
                Widgets.EndScrollView();
            }
            else
            {
                Text.Anchor = TextAnchor.MiddleCenter;
                GUI.color   = Color.grey;
                Widgets.Label(new Rect(0f, 0f, size.x, size.y), "(" + "NoRecentEntries".Translate() + ")");
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
        }