protected override void SetInitialSizeAndPosition() { strName = pawn.Name.ToStringFull; strChildhoodLabel = "Childhood"; strAdulthoodLabel = "Adulthood"; Text.Font = GameFont.Medium; rectNameLabel.width = Text.CalcSize(strName).x; rectNameLabel.height = Text.CalcSize(strName).y; Text.Font = GameFont.Small; for (int i = 1; i < PBS.intChildStoriesAmount; i++) { PBS.GetNeoChildStory(ref tempChildStory, i); if (Text.CalcSize(tempChildStory.Title).x >= rectChildStoriesOut.width + 16f) { rectChildStoriesOut.width = Text.CalcSize(tempChildStory.Title).x + 16f; } rectChildStoriesIn.height += Text.CalcSize("00000").y; } for (int i = 1; i < PBS.intAdultStoriesAmount; i++) { PBS.GetNeoAdultStory(ref tempAdultStory, i); if (Text.CalcSize(tempAdultStory.Title).x >= rectAdultStoriesOut.width + 16f) { rectAdultStoriesOut.width = Text.CalcSize(tempAdultStory.Title).x + 16f; } rectAdultStoriesIn.height += Text.CalcSize("00000").y; } if (rectChildStoriesOut.width > rectAdultStoriesOut.width) { rectAdultStoriesOut.width = rectChildStoriesOut.width; } else if (rectAdultStoriesOut.width > rectChildStoriesOut.width) { rectChildStoriesOut.width = rectAdultStoriesOut.width; } rectChildStoriesIn.width = rectChildStoriesOut.width - 16f; rectAdultStoriesIn.width = rectAdultStoriesOut.width - 16f; rectChildStoriesOut.height = Text.CalcSize("00000").y * 5f; rectAdultStoriesOut.height = Text.CalcSize("00000").y * 5f; rectChildEquip.width = rectChildStoriesOut.width; rectAdultEquip.width = rectAdultStoriesOut.width; rectChildEquip.height = Text.CalcHeight("Equip Childhood", rectChildEquip.width); rectAdultEquip.height = Text.CalcHeight("Equip Adulthood", rectAdultEquip.width); rectStoryViewerOut.width = rectChildStoriesOut.width * 1.5f; rectStoryViewerOut.height = rectChildStoriesOut.height + rectAdultStoriesOut.height + rectChildEquip.height + rectAdultEquip.height + floSpacing; rectStoryViewerIn.width = rectStoryViewerOut.width - 16f; rectAdultLabel.size = Text.CalcSize(strAdulthoodLabel); rectChildLabel.size = Text.CalcSize(strChildhoodLabel); rectEquippedChildLabel.width = rectChildStoriesIn.width; rectEquippedAdultLabel.width = rectAdultStoriesIn.width; rectEquippedChildLabel.height = Text.CalcSize("00000").y; rectEquippedAdultLabel.height = Text.CalcSize("00000").y; rectPortrait.size = PawnPortraitSize; float floRightWidth = 0f; if (rectNameLabel.width > rectEquippedChildLabel.width) { floRightWidth = rectNameLabel.width; } else if (rectEquippedChildLabel.width > rectNameLabel.width) { floRightWidth = rectEquippedChildLabel.width; } vecInitialSize.x += (StandardMargin * 2f) + rectChildStoriesOut.width + rectStoryViewerOut.width + floRightWidth + (floSpacing * 2f); vecInitialSize.y += CloseButSize.y + (StandardMargin * 2f) + rectChildStoriesOut.height + rectAdultStoriesOut.height + rectChildEquip.height + rectAdultEquip.height + (floSpacing * 2f); windowRect = new Rect(((float)UI.screenWidth - InitialSize.x) / 2f, ((float)UI.screenHeight - InitialSize.y) / 2f, InitialSize.x, InitialSize.y); rectChildEquip.y = rectChildStoriesOut.height; rectAdultStoriesOut.y = rectChildEquip.y + rectChildEquip.height + floSpacing; rectAdultEquip.y = rectAdultStoriesOut.y + rectAdultStoriesOut.height; rectStoryViewerOut.x = rectChildStoriesOut.x + rectChildStoriesOut.width + floSpacing; rectNameLabel.x = rectStoryViewerOut.x + rectStoryViewerOut.width + floSpacing; rectPortrait.x = rectNameLabel.x + (rectNameLabel.width * .5f) - (rectPortrait.width * .5f); rectPortrait.y = rectNameLabel.y + rectNameLabel.height; rectChildLabel.x = rectNameLabel.x; rectChildLabel.y = rectPortrait.y + rectPortrait.height; rectEquippedChildLabel.x = rectNameLabel.x; rectEquippedChildLabel.y = rectChildLabel.y + rectChildLabel.height; rectAdultLabel.x = rectNameLabel.x; rectAdultLabel.y = rectEquippedChildLabel.y + rectEquippedChildLabel.height + floSpacing; rectEquippedAdultLabel.x = rectNameLabel.x; rectEquippedAdultLabel.y = rectAdultLabel.y + rectAdultLabel.height; }
private static void SetBackstoryInSlot(Pawn pawn, BackstorySlot slot, ref Backstory backstory, FactionDef factionType) { try { if (slot == BackstorySlot.Childhood && factionType == FactionDefOf.PlayerTribe) { //if (!(from bs in ProBackstories.aBSChildNeo where bs.shuffleable && bs.spawnCategories.Contains(factionType.backstoryCategory) && // bs.slot == slot select bs).TryRandomElement(out backstory)) //{ //} try { ProBS.GetNeoChildStory(ref backstory); } catch (Exception e) { Log.Message(string.Format("EXCEPTION! {0}.{1} \n\tMESSAGE: {2} \n\tException occurred calling {3} method", e.TargetSite.ReflectedType.Name, e.TargetSite.Name, e.Message, Prophecy.Meta.KrozzyUtilities.GetCallForExceptionThisMethod(System.Reflection.MethodBase.GetCurrentMethod(), e))); } } else if (slot == BackstorySlot.Adulthood && factionType == FactionDefOf.PlayerTribe) { //if (!(from bs in ProBackstories.aBSAdultNeo where bs.shuffleable && bs.spawnCategories.Contains(factionType.backstoryCategory) && // bs.slot == slot && !bs.requiredWorkTags.OverlapsWithOnAnyWorkType(pawn.story.childhood.workDisables) select bs).TryRandomElement(out backstory)) //{ //} try { ProBS.GetNeoAdultStory(ref backstory); } catch (Exception e) { Log.Message(string.Format("EXCEPTION! {0}.{1} \n\tMESSAGE: {2} \n\tException occurred calling {3} method", e.TargetSite.ReflectedType.Name, e.TargetSite.Name, e.Message, Prophecy.Meta.KrozzyUtilities.GetCallForExceptionThisMethod(System.Reflection.MethodBase.GetCurrentMethod(), e))); } } } catch (Exception e) { Log.Message("ProPawnBioAndNameGenerator.SetBackstoryInSlot failed. Using Vanilla. \n " + e.Message + " \n" + e.InnerException.Message + " \n" + e.TargetSite.Name); if (!(from kvp in BackstoryDatabase.allBackstories where kvp.Value.shuffleable && kvp.Value.spawnCategories.Contains(factionType.backstoryCategory) && kvp.Value.slot == slot && (slot != BackstorySlot.Adulthood || !kvp.Value.requiredWorkTags.OverlapsWithOnAnyWorkType(pawn.story.childhood.workDisables)) select kvp.Value).TryRandomElement(out backstory)) { Log.Error(string.Concat(new object[] { "No shuffled ", slot, " found for ", pawn, " of ", factionType, ". Defaulting." })); backstory = (from kvp in BackstoryDatabase.allBackstories where kvp.Value.slot == slot select kvp).RandomElement <KeyValuePair <string, Backstory> >().Value; } } }