private void DrawPortraitArea(Rect rect)
        {
            Widgets.DrawMenuSection(rect);
            rect = rect.ContractedBy(17f);
            GUI.DrawTexture(new Rect(rect.center.x - Page_ConfigureStartingPawns.PawnPortraitSize.x / 2f, rect.yMin - 20f, Page_ConfigureStartingPawns.PawnPortraitSize.x, Page_ConfigureStartingPawns.PawnPortraitSize.y), PortraitsCache.Get(this.curPawn, Page_ConfigureStartingPawns.PawnPortraitSize, default(Vector3), 1f));
            Rect rect2 = rect;

            rect2.width = 500f;
            CharacterCardUtility.DrawCharacterCard(rect2, this.curPawn, new Action(this.RandomizeCurPawn), rect);
            Rect rect3 = rect;

            rect3.yMin  += 100f;
            rect3.xMin   = rect2.xMax + 5f;
            rect3.height = 200f;
            Text.Font    = GameFont.Medium;
            Widgets.Label(rect3, "Health".Translate());
            Text.Font   = GameFont.Small;
            rect3.yMin += 35f;
            HealthCardUtility.DrawHediffListing(rect3, this.curPawn, true);
            Rect rect4 = new Rect(rect3.x, rect3.yMax, rect3.width, 200f);

            Text.Font = GameFont.Medium;
            Widgets.Label(rect4, "Relations".Translate());
            Text.Font   = GameFont.Small;
            rect4.yMin += 35f;
            SocialCardUtility.DrawRelationsAndOpinions(rect4, this.curPawn);
        }
Пример #2
0
        private static string GetPawnRowTooltip(SocialCardUtility.CachedSocialTabEntry entry, Pawn selPawnForSocialInfo)
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (entry.otherPawn.RaceProps.Humanlike && selPawnForSocialInfo.RaceProps.Humanlike)
            {
                stringBuilder.AppendLine(selPawnForSocialInfo.relations.OpinionExplanation(entry.otherPawn));
                stringBuilder.AppendLine();
                stringBuilder.Append("SomeonesOpinionOfMe".Translate(entry.otherPawn.LabelShort, entry.otherPawn));
                stringBuilder.Append(": ");
                stringBuilder.Append(entry.opinionOfMe.ToStringWithSign());
            }
            else
            {
                stringBuilder.AppendLine(entry.otherPawn.LabelCapNoCount);
                string pawnSituationLabel = SocialCardUtility.GetPawnSituationLabel(entry.otherPawn, selPawnForSocialInfo);
                if (!pawnSituationLabel.NullOrEmpty())
                {
                    stringBuilder.AppendLine(pawnSituationLabel);
                }
                stringBuilder.AppendLine("--------------");
                stringBuilder.Append(SocialCardUtility.GetRelationsString(entry, selPawnForSocialInfo));
            }
            if (Prefs.DevMode)
            {
                stringBuilder.AppendLine();
                stringBuilder.AppendLine("(debug) Compatibility: " + selPawnForSocialInfo.relations.CompatibilityWith(entry.otherPawn).ToString("F2"));
                stringBuilder.Append("(debug) RomanceChanceFactor: " + selPawnForSocialInfo.relations.SecondaryRomanceChanceFactor(entry.otherPawn).ToString("F2"));
            }
            return(stringBuilder.ToString());
        }
Пример #3
0
        private static void DrawPawnSituationLabel(Pawn pawn, Rect rect, Pawn selPawnForSocialInfo)
        {
            GUI.color = Color.gray;
            string label = SocialCardUtility.GetPawnSituationLabel(pawn, selPawnForSocialInfo).Truncate(rect.width, null);

            Widgets.Label(rect, label);
        }
        private void DrawPortraitArea(Rect rect)
        {
            Widgets.DrawMenuSection(rect);
            rect = rect.ContractedBy(17f);
            GUI.DrawTexture(new Rect(rect.center.x - PawnPortraitSize.x / 2f, rect.yMin - 24f, PawnPortraitSize.x, PawnPortraitSize.y), PortraitsCache.Get(curPawn, PawnPortraitSize));
            Rect rect2 = rect;

            rect2.width = 500f;
            CharacterCardUtility.DrawCharacterCard(rect2, curPawn, RandomizeCurPawn, rect);
            Rect rect3 = rect;

            rect3.yMin  += 100f;
            rect3.xMin   = rect2.xMax + 5f;
            rect3.height = 200f;
            Text.Font    = GameFont.Medium;
            Widgets.Label(rect3, "Health".Translate());
            Text.Font   = GameFont.Small;
            rect3.yMin += 35f;
            HealthCardUtility.DrawHediffListing(rect3, curPawn, showBloodLoss: true);
            Rect rect4 = new Rect(rect3.x, rect3.yMax, rect3.width, 200f);

            Text.Font = GameFont.Medium;
            Widgets.Label(rect4, "Relations".Translate());
            Text.Font   = GameFont.Small;
            rect4.yMin += 35f;
            SocialCardUtility.DrawRelationsAndOpinions(rect4, curPawn);
        }
Пример #5
0
 private static void CheckRecache(Pawn selPawnForSocialInfo)
 {
     if (SocialCardUtility.cachedForPawn != selPawnForSocialInfo || Time.frameCount % 20 == 0)
     {
         SocialCardUtility.Recache(selPawnForSocialInfo);
     }
 }
Пример #6
0
 private static void CheckRecache(Pawn selPawnForSocialInfo)
 {
     if (SocialCardUtility.cachedForPawn == selPawnForSocialInfo && Time.frameCount % 20 != 0)
     {
         return;
     }
     SocialCardUtility.Recache(selPawnForSocialInfo);
 }
Пример #7
0
        private static void Recache(Pawn selPawnForSocialInfo)
        {
            SocialCardUtility.cachedForPawn = selPawnForSocialInfo;
            SocialCardUtility.tmpToCache.Clear();
            foreach (Pawn current in selPawnForSocialInfo.relations.RelatedPawns)
            {
                if (SocialCardUtility.ShouldShowPawnRelations(current, selPawnForSocialInfo))
                {
                    SocialCardUtility.tmpToCache.Add(current);
                }
            }
            List <Pawn> list = null;

            if (selPawnForSocialInfo.MapHeld != null)
            {
                list = selPawnForSocialInfo.MapHeld.mapPawns.AllPawnsSpawned;
            }
            else if (selPawnForSocialInfo.IsCaravanMember())
            {
                list = selPawnForSocialInfo.GetCaravan().PawnsListForReading;
            }
            if (list != null)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    Pawn pawn = list[i];
                    if (pawn.RaceProps.Humanlike && pawn != selPawnForSocialInfo && SocialCardUtility.ShouldShowPawnRelations(pawn, selPawnForSocialInfo) && !SocialCardUtility.tmpToCache.Contains(pawn))
                    {
                        if (selPawnForSocialInfo.relations.OpinionOf(pawn) != 0 || pawn.relations.OpinionOf(selPawnForSocialInfo) != 0)
                        {
                            SocialCardUtility.tmpToCache.Add(pawn);
                        }
                    }
                }
            }
            SocialCardUtility.cachedEntries.RemoveAll((SocialCardUtility.CachedSocialTabEntry x) => !SocialCardUtility.tmpToCache.Contains(x.otherPawn));
            SocialCardUtility.tmpCached.Clear();
            for (int j = 0; j < SocialCardUtility.cachedEntries.Count; j++)
            {
                SocialCardUtility.tmpCached.Add(SocialCardUtility.cachedEntries[j].otherPawn);
            }
            foreach (Pawn current2 in SocialCardUtility.tmpToCache)
            {
                if (!SocialCardUtility.tmpCached.Contains(current2))
                {
                    SocialCardUtility.CachedSocialTabEntry cachedSocialTabEntry = new SocialCardUtility.CachedSocialTabEntry();
                    cachedSocialTabEntry.otherPawn = current2;
                    SocialCardUtility.cachedEntries.Add(cachedSocialTabEntry);
                }
            }
            SocialCardUtility.tmpCached.Clear();
            SocialCardUtility.tmpToCache.Clear();
            for (int k = 0; k < SocialCardUtility.cachedEntries.Count; k++)
            {
                SocialCardUtility.RecacheEntry(SocialCardUtility.cachedEntries[k], selPawnForSocialInfo);
            }
            SocialCardUtility.cachedEntries.Sort(SocialCardUtility.CachedEntriesComparer);
        }
Пример #8
0
 private static void DrawMyOpinion(CachedSocialTabEntry entry, Rect rect, Pawn selPawnForSocialInfo)
 {
     if (entry.otherPawn.RaceProps.Humanlike && selPawnForSocialInfo.RaceProps.Humanlike)
     {
         int opinionOfOtherPawn = entry.opinionOfOtherPawn;
         GUI.color = SocialCardUtility.OpinionLabelColor(opinionOfOtherPawn);
         Widgets.Label(rect, opinionOfOtherPawn.ToStringWithSign());
     }
 }
Пример #9
0
        private static void DrawRelationLabel(SocialCardUtility.CachedSocialTabEntry entry, Rect rect, Pawn selPawnForSocialInfo)
        {
            string relationsString = SocialCardUtility.GetRelationsString(entry, selPawnForSocialInfo);

            if (!relationsString.NullOrEmpty())
            {
                GUI.color = SocialCardUtility.RelationLabelColor;
                Widgets.Label(rect, relationsString);
            }
        }
Пример #10
0
 private static void DrawHisOpinion(CachedSocialTabEntry entry, Rect rect, Pawn selPawnForSocialInfo)
 {
     if (entry.otherPawn.RaceProps.Humanlike && selPawnForSocialInfo.RaceProps.Humanlike)
     {
         int   opinionOfMe = entry.opinionOfMe;
         Color color       = SocialCardUtility.OpinionLabelColor(opinionOfMe);
         GUI.color = new Color(color.r, color.g, color.b, 0.4f);
         Widgets.Label(rect, "(" + opinionOfMe.ToStringWithSign() + ")");
     }
 }
Пример #11
0
        private static float GetRowHeight(SocialCardUtility.CachedSocialTabEntry entry, float rowWidth, Pawn selPawnForSocialInfo)
        {
            float width;
            float width2;
            float num;
            float num2;
            float num3;

            SocialCardUtility.CalculateColumnsWidths(rowWidth, out width, out width2, out num, out num2, out num3);
            float num4 = 0f;

            num4 = Mathf.Max(num4, Text.CalcHeight(SocialCardUtility.GetRelationsString(entry, selPawnForSocialInfo), width));
            num4 = Mathf.Max(num4, Text.CalcHeight(SocialCardUtility.GetPawnLabel(entry.otherPawn), width2));
            return(num4 + 3f);
        }
Пример #12
0
        private static float GetRowHeight(CachedSocialTabEntry entry, float rowWidth, Pawn selPawnForSocialInfo)
        {
            float width  = default(float);
            float width2 = default(float);
            float num    = default(float);
            float num2   = default(float);
            float num3   = default(float);

            SocialCardUtility.CalculateColumnsWidths(rowWidth, out width, out width2, out num, out num2, out num3);
            float a = 0f;

            a = Mathf.Max(a, Text.CalcHeight(SocialCardUtility.GetRelationsString(entry, selPawnForSocialInfo), width));
            a = Mathf.Max(a, Text.CalcHeight(SocialCardUtility.GetPawnLabel(entry.otherPawn), width2));
            return((float)(a + 3.0));
        }
Пример #13
0
        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;
        }
Пример #14
0
        public static void DrawSocialCard(Rect rect, Pawn pawn)
        {
            GUI.BeginGroup(rect);
            Text.Font = GameFont.Small;
            Rect rect2 = new Rect(0f, 20f, rect.width, rect.height - 20f);
            Rect rect3 = rect2.ContractedBy(10f);
            Rect rect4 = rect3;
            Rect rect5 = rect3;

            rect4.height *= 0.63f;
            rect5.y       = rect4.yMax + 17f;
            rect5.yMax    = rect3.yMax;
            GUI.color     = new Color(1f, 1f, 1f, 0.5f);
            Widgets.DrawLineHorizontal(0f, (rect4.yMax + rect5.y) / 2f, rect.width);
            GUI.color = Color.white;
            if (Prefs.DevMode)
            {
                Rect rect6 = new Rect(5f, 5f, rect.width, 22f);
                SocialCardUtility.DrawDebugOptions(rect6, pawn);
            }
            SocialCardUtility.DrawRelationsAndOpinions(rect4, pawn);
            InteractionCardUtility.DrawInteractionsLog(rect5, pawn, Find.PlayLog.AllEntries, 12);
            GUI.EndGroup();
        }
Пример #15
0
        private void DrawPortraitArea(Rect rect)
        {
            Widgets.DrawMenuSection(rect);
            rect = rect.ContractedBy(17f);
            Vector2 center            = rect.center;
            float   x                 = center.x;
            Vector2 pawnPortraitSize  = Page_ConfigureStartingPawns.PawnPortraitSize;
            double  x2                = x - pawnPortraitSize.x / 2.0;
            double  y                 = rect.yMin - 20.0;
            Vector2 pawnPortraitSize2 = Page_ConfigureStartingPawns.PawnPortraitSize;
            float   x3                = pawnPortraitSize2.x;
            Vector2 pawnPortraitSize3 = Page_ConfigureStartingPawns.PawnPortraitSize;

            GUI.DrawTexture(new Rect((float)x2, (float)y, x3, pawnPortraitSize3.y), PortraitsCache.Get(this.curPawn, Page_ConfigureStartingPawns.PawnPortraitSize, default(Vector3), 1f));
            Rect rect2 = rect;

            rect2.width = 500f;
            CharacterCardUtility.DrawCharacterCard(rect2, this.curPawn, this.RandomizeCurPawn, rect);
            Rect rect3 = rect;

            rect3.yMin  += 100f;
            rect3.xMin   = (float)(rect2.xMax + 5.0);
            rect3.height = 200f;
            Text.Font    = GameFont.Medium;
            Widgets.Label(rect3, "Health".Translate());
            Text.Font   = GameFont.Small;
            rect3.yMin += 35f;
            HealthCardUtility.DrawHediffListing(rect3, this.curPawn, true);
            Rect rect4 = new Rect(rect3.x, rect3.yMax, rect3.width, 200f);

            Text.Font = GameFont.Medium;
            Widgets.Label(rect4, "Relations".Translate());
            Text.Font   = GameFont.Small;
            rect4.yMin += 35f;
            SocialCardUtility.DrawRelationsAndOpinions(rect4, this.curPawn);
        }
Пример #16
0
 protected override void FillTab()
 {
     SocialCardUtility.DrawSocialCard(new Rect(0f, 0f, base.size.x, base.size.y), this.SelPawnForSocialInfo);
 }
Пример #17
0
 private static void DrawPawnLabel(Pawn pawn, Rect rect)
 {
     GUI.color = SocialCardUtility.PawnLabelColor;
     Widgets.Label(rect, SocialCardUtility.GetPawnLabel(pawn));
 }
Пример #18
0
        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);
        }
 public string OpinionExplanation(Pawn other)
 {
     if (other.RaceProps.Humanlike && this.pawn != other)
     {
         StringBuilder stringBuilder = new StringBuilder();
         stringBuilder.AppendLine("OpinionOf".Translate(other.LabelShort) + ": " + this.OpinionOf(other).ToStringWithSign());
         string pawnSituationLabel = SocialCardUtility.GetPawnSituationLabel(other, this.pawn);
         if (!pawnSituationLabel.NullOrEmpty())
         {
             stringBuilder.AppendLine(pawnSituationLabel);
         }
         stringBuilder.AppendLine("--------------");
         bool flag = false;
         if (this.pawn.Dead)
         {
             stringBuilder.AppendLine("IAmDead".Translate());
             flag = true;
         }
         else
         {
             IEnumerable <PawnRelationDef> relations = this.pawn.GetRelations(other);
             foreach (PawnRelationDef item in relations)
             {
                 stringBuilder.AppendLine(item.GetGenderSpecificLabelCap(other) + ": " + item.opinionOffset.ToStringWithSign());
                 flag = true;
             }
             if (this.pawn.RaceProps.Humanlike)
             {
                 ThoughtHandler thoughts = this.pawn.needs.mood.thoughts;
                 thoughts.GetDistinctSocialThoughtGroups(other, Pawn_RelationsTracker.tmpSocialThoughts);
                 for (int i = 0; i < Pawn_RelationsTracker.tmpSocialThoughts.Count; i++)
                 {
                     ISocialThought socialThought = Pawn_RelationsTracker.tmpSocialThoughts[i];
                     int            num           = 1;
                     Thought        thought       = (Thought)socialThought;
                     if (thought.def.IsMemory)
                     {
                         num = thoughts.memories.NumMemoriesInGroup((Thought_MemorySocial)socialThought);
                     }
                     stringBuilder.Append(thought.LabelCapSocial);
                     if (num != 1)
                     {
                         stringBuilder.Append(" x" + num);
                     }
                     stringBuilder.AppendLine(": " + thoughts.OpinionOffsetOfGroup(socialThought, other).ToStringWithSign());
                     flag = true;
                 }
             }
             List <Hediff> hediffs = this.pawn.health.hediffSet.hediffs;
             for (int j = 0; j < hediffs.Count; j++)
             {
                 HediffStage curStage = hediffs[j].CurStage;
                 if (curStage != null && curStage.opinionOfOthersFactor != 1.0)
                 {
                     stringBuilder.Append(hediffs[j].LabelBase.CapitalizeFirst());
                     if (curStage.opinionOfOthersFactor != 0.0)
                     {
                         stringBuilder.AppendLine(": x" + curStage.opinionOfOthersFactor.ToStringPercent());
                     }
                     else
                     {
                         stringBuilder.AppendLine();
                     }
                     flag = true;
                 }
             }
             if (this.pawn.HostileTo(other))
             {
                 stringBuilder.AppendLine("Hostile".Translate());
                 flag = true;
             }
         }
         if (!flag)
         {
             stringBuilder.AppendLine("NoneBrackets".Translate());
         }
         return(stringBuilder.ToString().TrimEndNewlines());
     }
     return(string.Empty);
 }