public static void DrawRelationsAndOpinions(Rect rect, Pawn selPawnForSocialInfo) { SocialCardUtility.CheckRecache(selPawnForSocialInfo); if (Current.ProgramState != ProgramState.Playing) { SocialCardUtility.showAllRelations = false; } GUI.BeginGroup(rect); Text.Font = GameFont.Small; GUI.color = Color.white; Rect outRect = new Rect(0f, 0f, rect.width, rect.height); Rect viewRect = new Rect(0f, 0f, rect.width - 16f, SocialCardUtility.listScrollViewHeight); Rect rect2 = rect; if (viewRect.height > outRect.height) { rect2.width -= 16f; } Widgets.BeginScrollView(outRect, ref SocialCardUtility.listScrollPosition, viewRect, true); float num = 0f; float y = SocialCardUtility.listScrollPosition.y; float num2 = SocialCardUtility.listScrollPosition.y + outRect.height; for (int i = 0; i < SocialCardUtility.cachedEntries.Count; i++) { float rowHeight = SocialCardUtility.GetRowHeight(SocialCardUtility.cachedEntries[i], rect2.width, selPawnForSocialInfo); if (num > y - rowHeight && num < num2) { SocialCardUtility.DrawPawnRow(num, rect2.width, SocialCardUtility.cachedEntries[i], selPawnForSocialInfo); } num += rowHeight; } if (!SocialCardUtility.cachedEntries.Any <SocialCardUtility.CachedSocialTabEntry>()) { GUI.color = Color.gray; Text.Anchor = TextAnchor.UpperCenter; Rect rect3 = new Rect(0f, 0f, rect2.width, 30f); Widgets.Label(rect3, "NoRelationships".Translate()); Text.Anchor = TextAnchor.UpperLeft; } if (Event.current.type == EventType.Layout) { SocialCardUtility.listScrollViewHeight = num + 30f; } Widgets.EndScrollView(); GUI.EndGroup(); GUI.color = Color.white; }
private static void DrawPawnRow(float y, float width, SocialCardUtility.CachedSocialTabEntry entry, Pawn selPawnForSocialInfo) { float rowHeight = SocialCardUtility.GetRowHeight(entry, width, selPawnForSocialInfo); Rect rect = new Rect(0f, y, width, rowHeight); Pawn otherPawn = entry.otherPawn; if (Mouse.IsOver(rect)) { GUI.color = SocialCardUtility.HighlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } TooltipHandler.TipRegion(rect, () => SocialCardUtility.GetPawnRowTooltip(entry, selPawnForSocialInfo), entry.otherPawn.thingIDNumber * 13 + selPawnForSocialInfo.thingIDNumber); if (Widgets.ButtonInvisible(rect, false)) { if (Current.ProgramState == ProgramState.Playing) { if (otherPawn.Dead) { Messages.Message("MessageCantSelectDeadPawn".Translate(new object[] { otherPawn.LabelShort }).CapitalizeFirst(), MessageTypeDefOf.RejectInput, false); } else if (otherPawn.SpawnedOrAnyParentSpawned || otherPawn.IsCaravanMember()) { CameraJumper.TryJumpAndSelect(otherPawn); } else { Messages.Message("MessageCantSelectOffMapPawn".Translate(new object[] { otherPawn.LabelShort }).CapitalizeFirst(), MessageTypeDefOf.RejectInput, false); } } else if (Find.GameInitData.startingAndOptionalPawns.Contains(otherPawn)) { Page_ConfigureStartingPawns page_ConfigureStartingPawns = Find.WindowStack.WindowOfType <Page_ConfigureStartingPawns>(); if (page_ConfigureStartingPawns != null) { page_ConfigureStartingPawns.SelectPawn(otherPawn); SoundDefOf.RowTabSelect.PlayOneShotOnCamera(null); } } } float width2; float width3; float width4; float width5; float width6; SocialCardUtility.CalculateColumnsWidths(width, out width2, out width3, out width4, out width5, out width6); Rect rect2 = new Rect(5f, y + 3f, width2, rowHeight - 3f); SocialCardUtility.DrawRelationLabel(entry, rect2, selPawnForSocialInfo); Rect rect3 = new Rect(rect2.xMax, y + 3f, width3, rowHeight - 3f); SocialCardUtility.DrawPawnLabel(otherPawn, rect3); Rect rect4 = new Rect(rect3.xMax, y + 3f, width4, rowHeight - 3f); SocialCardUtility.DrawMyOpinion(entry, rect4, selPawnForSocialInfo); Rect rect5 = new Rect(rect4.xMax, y + 3f, width5, rowHeight - 3f); SocialCardUtility.DrawHisOpinion(entry, rect5, selPawnForSocialInfo); Rect rect6 = new Rect(rect5.xMax, y + 3f, width6, rowHeight - 3f); SocialCardUtility.DrawPawnSituationLabel(entry.otherPawn, rect6, selPawnForSocialInfo); }