Exemplo n.º 1
0
        // Token: 0x06000032 RID: 50 RVA: 0x00003078 File Offset: 0x00001278
        public override void DoWindowContents(Rect inRect)
        {
            var crafterProperties = pawnCrafter.def.GetModExtension <PawnCrafterProperties>();

            if (newChildhoodBackstory != null)
            {
                newPawn.story.childhood = newChildhoodBackstory;
                newChildhoodBackstory   = null;
                RefreshPawn();
            }

            if (newAdulthoodBackstory != null)
            {
                newPawn.story.adulthood = newAdulthoodBackstory;
                newAdulthoodBackstory   = null;
                RefreshPawn();
            }

            if (traitsChanged)
            {
                var first  = newTrait.First;
                var second = newTrait.Second;
                if (first < newPawn.story.traits.allTraits.Count)
                {
                    newPawn.story.traits.allTraits.RemoveAt(first);
                    newPawn.story.traits.allTraits.Insert(first, second);
                    if (newPawn.workSettings != null)
                    {
                        newPawn.workSettings.Notify_DisabledWorkTypesChanged();
                    }

                    if (newPawn.skills != null)
                    {
                        newPawn.skills.Notify_SkillDisablesChanged();
                    }

                    if (!newPawn.Dead && newPawn.RaceProps.Humanlike)
                    {
                        newPawn.needs.mood.thoughts.situational.Notify_SituationalThoughtsDirty();
                    }
                }
                else
                {
                    newPawn.story.traits.GainTrait(second);
                }

                newTrait      = default;
                traitsChanged = false;
                traitPos      = -1;
                RefreshPawn();
            }

            var rect = new Rect(inRect)
            {
                width  = PawnPortraitSize.x + 16f,
                height = PawnPortraitSize.y + 16f
            };

            rect    = rect.CenteredOnXIn(inRect);
            rect    = rect.CenteredOnYIn(inRect);
            rect.x += 16f;
            rect.y += 16f;
            if (newPawn != null)
            {
                var rect2 = new Rect(rect.xMin + ((rect.width - PawnPortraitSize.x) / 2f) - 10f, rect.yMin + 20f,
                                     PawnPortraitSize.x, PawnPortraitSize.y);
                GUI.DrawTexture(rect2, PortraitsCache.Get(newPawn, PawnPortraitSize, Rot4.South));
                Widgets.InfoCardButton(rect2.xMax - 16f, rect2.y, newPawn);
                Text.Font   = GameFont.Medium;
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(new Rect(0f, 0f, inRect.width, 32f),
                              crafterProperties.crafterPawnCustomizationTitle.Translate());
                Text.Font   = GameFont.Small;
                Text.Anchor = TextAnchor.MiddleLeft;
                var num   = 32f;
                var rect3 = new Rect(32f, num, 240f, 24f);
                if (newPawn.Name is NameTriple nameTriple)
                {
                    var rect4 = new Rect(rect3);
                    rect4.width *= 0.333f;
                    var rect5 = new Rect(rect3);
                    rect5.width *= 0.333f;
                    rect5.x     += rect5.width;
                    var rect6 = new Rect(rect3);
                    rect6.width *= 0.333f;
                    rect6.x     += rect5.width * 2f;
                    var first2 = nameTriple.First;
                    var nick   = nameTriple.Nick;
                    var last   = nameTriple.Last;
                    CharacterCardUtility.DoNameInputRect(rect4, ref first2, 12);
                    if (nameTriple.Nick == nameTriple.First || nameTriple.Nick == nameTriple.Last)
                    {
                        GUI.color = new Color(1f, 1f, 1f, 0.5f);
                    }

                    CharacterCardUtility.DoNameInputRect(rect5, ref nick, 9);
                    GUI.color = Color.white;
                    CharacterCardUtility.DoNameInputRect(rect6, ref last, 12);
                    if (nameTriple.First != first2 || nameTriple.Nick != nick || nameTriple.Last != last)
                    {
                        newPawn.Name = new NameTriple(first2, nick, last);
                    }

                    TooltipHandler.TipRegion(rect4, "FirstNameDesc".Translate());
                    TooltipHandler.TipRegion(rect5, "ShortIdentifierDesc".Translate());
                    TooltipHandler.TipRegion(rect6, "LastNameDesc".Translate());
                }
                else
                {
                    rect3.width = 999f;
                    Text.Font   = GameFont.Medium;
                    Widgets.Label(rect3, newPawn.Name.ToStringFull);
                    Text.Font = GameFont.Small;
                }

                var rect7 = new Rect(rect.x + rect.width + 16f, rect.y + 32f,
                                     inRect.width - (rect.x + rect.width + 16f), 32f);
                Text.Font = GameFont.Medium;
                if (Widgets.ButtonText(rect7, crafterProperties.crafterPawnCustomizationCraftButton.Translate(), true,
                                       false))
                {
                    pawnCrafter.pawnBeingCrafted = newPawn;
                    pawnCrafter.crafterStatus    = CrafterStatus.Filling;
                    Close();
                }

                Text.Font = GameFont.Small;
                if (Widgets.ButtonText(new Rect(304f, num, 120f, 24f),
                                       crafterProperties.crafterPawnCustomizationCraftRollFemaleButton.Translate(), true, false))
                {
                    newPawn.Destroy();
                    newPawn = GetNewPawn();
                }

                if (Widgets.ButtonText(new Rect(424f, num, 120f, 24f),
                                       crafterProperties.crafterPawnCustomizationCraftRollMaleButton.Translate(), true, false))
                {
                    newPawn.Destroy();
                    newPawn = GetNewPawn(Gender.Male);
                }

                num += 26f;
                var rect8 = new Rect(32f, num, 240f, 24f);
                Widgets.DrawBox(rect8);
                Widgets.DrawHighlightIfMouseover(rect8);
                string text;
                if (newPawn.story.childhood != null)
                {
                    text = crafterProperties.crafterPawnCustomizationCraftChildhoodBackstoryButton.Translate() + " " +
                           newPawn.story.childhood.titleShort;
                }
                else
                {
                    text = crafterProperties.crafterPawnCustomizationCraftChildhoodBackstoryButton.Translate() + " " +
                           crafterProperties.crafterPawnCustomizationNone.Translate();
                }

                if (Widgets.ButtonText(rect8, text, true, false))
                {
                    FloatMenuUtility.MakeMenu(from backstory in BackstoryDatabase.allBackstories.Select(
                                                  delegate(KeyValuePair <string, Backstory> backstoryPair)
                    {
                        var keyValuePair = backstoryPair;
                        return(keyValuePair.Value);
                    })
                                              where backstory.spawnCategories.Contains(crafterProperties
                                                                                       .crafterPawnCustomizationPawnBackstoryTag) && backstory.slot == BackstorySlot.Childhood
                                              select backstory, backstory => backstory.titleShort,
                                              backstory => delegate { newChildhoodBackstory = backstory; });
                }

                if (newPawn.story.childhood != null)
                {
                    TooltipHandler.TipRegion(rect8, newPawn.story.childhood.FullDescriptionFor(newPawn));
                }

                var rect9 = new Rect(304f, num, 240f, 24f);
                Widgets.DrawBox(rect9);
                Widgets.DrawHighlightIfMouseover(rect9);
                string text2;
                if (newPawn.story.adulthood != null)
                {
                    text2 = crafterProperties.crafterPawnCustomizationCraftAdulthoodBackstoryButton.Translate() + " " +
                            newPawn.story.adulthood.titleShort;
                }
                else
                {
                    text2 = crafterProperties.crafterPawnCustomizationCraftAdulthoodBackstoryButton.Translate() + " " +
                            crafterProperties.crafterPawnCustomizationNone.Translate();
                }

                if (Widgets.ButtonText(rect9, text2, true, false))
                {
                    FloatMenuUtility.MakeMenu(from backstory in BackstoryDatabase.allBackstories.Select(
                                                  delegate(KeyValuePair <string, Backstory> backstoryPair)
                    {
                        var keyValuePair = backstoryPair;
                        return(keyValuePair.Value);
                    })
                                              where backstory.spawnCategories.Contains(crafterProperties
                                                                                       .crafterPawnCustomizationPawnBackstoryTag) && backstory.slot == BackstorySlot.Adulthood
                                              select backstory, backstory => backstory.titleShort,
                                              backstory => delegate { newAdulthoodBackstory = backstory; });
                }

                if (newPawn.story.adulthood != null)
                {
                    TooltipHandler.TipRegion(rect9, newPawn.story.adulthood.FullDescriptionFor(newPawn));
                }

                num += 48f;
                var vector = new Vector2(32f, num);
                SkillUI.DrawSkillsOf(newPawn, vector, SkillUI.SkillDrawMode.Gameplay);
                num = rect.y + rect.height;
                var num2 = rect.x + 24f;
                Text.Anchor = TextAnchor.MiddleCenter;
                foreach (var trait in newPawn.story.traits.allTraits)
                {
                    var rect10 = new Rect(num2, num, 256f, 24f);
                    Widgets.DrawBox(rect10);
                    Widgets.DrawHighlightIfMouseover(rect10);
                    Widgets.Label(rect10, trait.LabelCap);
                    TooltipHandler.TipRegion(rect10, trait.TipString(newPawn));
                    num += 26f;
                }
            }

            Text.Anchor = 0;
        }
Exemplo n.º 2
0
            public static bool DrawCharacterCardP(ref Rect rect, ref Pawn pawn, ref Action randomizeCallback, ref Rect creationRect)
            {
                rect.position = new Vector2(17f, 17f);
                rect.size     = new Vector2(cardX, cardY);
                bool flag = randomizeCallback != null;

                GUI.BeginGroup((!flag) ? rect : creationRect);
                Rect       rectLabel  = new Rect(0f, 0f, 300f, 30f);
                NameTriple nameTriple = pawn.Name as NameTriple;

                if (flag && nameTriple != null)
                {
                    Rect rect3 = new Rect(rectLabel);
                    rect3.width *= 0.333f;
                    Rect rect4 = new Rect(rectLabel);
                    rect4.width *= 0.333f;
                    rect4.x     += rect4.width;
                    Rect rect5 = new Rect(rectLabel);
                    rect5.width *= 0.333f;
                    rect5.x     += rect4.width * 2f;
                    string first = nameTriple.First;
                    string nick  = nameTriple.Nick;
                    string last  = nameTriple.Last;
                    CharacterCardUtility.DoNameInputRect(rect3, ref first, 12);
                    if (nameTriple.Nick == nameTriple.First || nameTriple.Nick == nameTriple.Last)
                    {
                        GUI.color = new Color(1f, 1f, 1f, 0.5f);
                    }
                    CharacterCardUtility.DoNameInputRect(rect4, ref nick, 9);
                    GUI.color = Color.white;
                    CharacterCardUtility.DoNameInputRect(rect5, ref last, 12);
                    if (nameTriple.First != first || nameTriple.Nick != nick || nameTriple.Last != last)
                    {
                        pawn.Name = new NameTriple(first, nick, last);
                    }
                    TooltipHandler.TipRegion(rect3, "FirstNameDesc".Translate());
                    TooltipHandler.TipRegion(rect4, "ShortIdentifierDesc".Translate());
                    TooltipHandler.TipRegion(rect5, "LastNameDesc".Translate());
                }
                else
                {
                    rectLabel.width = 999f;
                    Text.Font       = GameFont.Medium;
                    Widgets.Label(rectLabel, pawn.Name.ToStringFull);
                    Text.Font = GameFont.Small;
                }
                if (randomizeCallback != null)
                {
                    Rect rectRandomise = new Rect(creationRect.width - 24f - 100f, 0f, 100f, rectLabel.height);
                    if (Widgets.ButtonText(rectRandomise, "Randomize".Translate(), true, false, true))
                    {
                        SoundDefOf.TickTiny.PlayOneShotOnCamera(null);
                        randomizeCallback();
                    }
                    UIHighlighter.HighlightOpportunity(rectRandomise, "RandomizePawn");
                }
                if (flag)
                {
                    Widgets.InfoCardButton(creationRect.width - 24f, 0f, pawn);
                }
                else if (!pawn.health.Dead)
                {
                    float num = CharacterCardUtility.PawnCardSize.x - 85f;
                    if ((pawn.Faction == Faction.OfPlayer || pawn.IsPrisonerOfColony) && pawn.Spawned)
                    {
                        Rect rectBanish = new Rect(num, 0f, 30f, 30f);
                        TooltipHandler.TipRegion(rectBanish, PawnBanishUtility.GetBanishButtonTip(pawn));
                        if (Widgets.ButtonImage(rectBanish, ContentFinder <Texture2D> .Get("UI/Buttons/Banish", true)))
                        {
                            if (pawn.Downed)
                            {
                                Messages.Message("MessageCantBanishDownedPawn".Translate(new object[]
                                {
                                    pawn.LabelShort
                                }).AdjustedFor(pawn), pawn, MessageTypeDefOf.RejectInput);
                            }
                            else
                            {
                                PawnBanishUtility.ShowBanishPawnConfirmationDialog(pawn);
                            }
                        }
                        num -= 40f;
                    }
                    if (pawn.IsColonist)
                    {
                        Rect rect8 = new Rect(num, 0f, 30f, 30f);
                        TooltipHandler.TipRegion(rect8, "RenameColonist".Translate());
                        if (Widgets.ButtonImage(rect8, ContentFinder <Texture2D> .Get("UI/Buttons/Rename", true)))
                        {
                            Find.WindowStack.Add(new Dialog_ChangeNameTriple(pawn));
                        }
                        num -= 40f;
                    }
                }
                string label        = pawn.MainDesc(true);
                Rect   rectMainDesc = new Rect(0f, 45f, rect.width, 60f);

                Widgets.Label(rectMainDesc, label);
                Pawn p = pawn;

                TooltipHandler.TipRegion(rectMainDesc, () => p.ageTracker.AgeTooltipString, 6873641);
                Rect positionLeftHalf  = new Rect(0f, 100f, 250f, cardY);
                Rect positionRightHalf = new Rect(positionLeftHalf.xMax, 100f, 258f, cardY);

                GUI.BeginGroup(positionLeftHalf);
                float currentY = 0f;

                Text.Font = GameFont.Medium;
                Widgets.Label(new Rect(0f, 0f, 200f, 30f), "Backstory".Translate());
                currentY += 30f;
                Text.Font = GameFont.Small;
                foreach (BackstorySlot backstorySlot in Enum.GetValues(typeof(BackstorySlot)))
                {
                    Backstory backstory = pawn.story.GetBackstory(backstorySlot);
                    if (backstory != null)
                    {
                        Rect rect10 = new Rect(0f, currentY, positionLeftHalf.width, 24f);
                        if (Mouse.IsOver(rect10))
                        {
                            Widgets.DrawHighlight(rect10);
                        }
                        TooltipHandler.TipRegion(rect10, backstory.FullDescriptionFor(pawn));
                        Text.Anchor = TextAnchor.MiddleLeft;
                        string str = (backstorySlot != BackstorySlot.Adulthood) ? "Childhood".Translate() : "Adulthood".Translate();
                        Widgets.Label(rect10, str + ":");
                        Text.Anchor = TextAnchor.UpperLeft;
                        Rect rect11 = new Rect(rect10);
                        rect11.x     += 90f;
                        rect11.width -= 90f;
                        string title = backstory.Title;
                        Widgets.Label(rect11, title);
                        currentY += rect10.height + 2f;
                    }
                }
                currentY += 25f;
                Text.Font = GameFont.Small;
                Widgets.Label(new Rect(0f, currentY, 200f, 30f), "IncapableOf".Translate());
                currentY += 30f;
                Text.Font = GameFont.Small;
                StringBuilder stringBuilder            = new StringBuilder();
                WorkTags      combinedDisabledWorkTags = pawn.story.CombinedDisabledWorkTags;

                if (combinedDisabledWorkTags == WorkTags.None)
                {
                    stringBuilder.Append("(" + "NoneLower".Translate() + "), ");
                }
                else
                {
                    List <WorkTags> list  = WorkTagsFrom(combinedDisabledWorkTags).ToList <WorkTags>();
                    bool            flag2 = true;
                    foreach (WorkTags current in list)
                    {
                        if (flag2)
                        {
                            stringBuilder.Append(current.LabelTranslated().CapitalizeFirst());
                        }
                        else
                        {
                            stringBuilder.Append(current.LabelTranslated());
                        }
                        stringBuilder.Append(", ");
                        flag2 = false;
                    }
                }
                string text = stringBuilder.ToString();

                text = text.Substring(0, text.Length - 2);
                Rect rect12 = new Rect(0f, currentY, positionLeftHalf.width, 999f);

                Widgets.Label(rect12, text);
                currentY += 100f;
                Text.Font = GameFont.Medium;
                Widgets.Label(new Rect(0f, currentY, 200f, 30f), "Traits".Translate());
                currentY += 30f;
                Text.Font = GameFont.Small;
                for (int i = 0; i < pawn.story.traits.allTraits.Count; i++)
                {
                    Trait trait            = pawn.story.traits.allTraits[i];
                    Rect  rectCurrentTrait = new Rect(0f, currentY, positionLeftHalf.width, 24f);
                    if (Mouse.IsOver(rectCurrentTrait))
                    {
                        Widgets.DrawHighlight(rectCurrentTrait);
                    }
                    Widgets.Label(rectCurrentTrait, trait.LabelCap);
                    currentY += rectCurrentTrait.height + 2f;
                    Trait     trLocal = trait;
                    TipSignal tip     = new TipSignal(() => trLocal.TipString(p), (int)currentY * 37);
                    TooltipHandler.TipRegion(rectCurrentTrait, tip);
                }
                GUI.EndGroup();
                GUI.BeginGroup(positionRightHalf);
                Text.Font = GameFont.Medium;
                Widgets.Label(new Rect(0f, 0f, 200f, 30f), "Skills".Translate());
                SkillUI.SkillDrawMode mode;
                if (Current.ProgramState == ProgramState.Playing)
                {
                    mode = SkillUI.SkillDrawMode.Gameplay;
                }
                else
                {
                    mode = SkillUI.SkillDrawMode.Menu;
                }
                SkillUI.DrawSkillsOf(pawn, new Vector2(0f, 35f), mode);
                GUI.EndGroup();
                GUI.EndGroup();

                return(false);
            }