private static string CustomMoodNeedTooltip(Need_Mood mood) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(mood.GetTipString()); PawnNeedsUIUtility.GetThoughtGroupsInDisplayOrder(mood, thoughtGroupsPresent); bool flag = false; for (int i = 0; i < thoughtGroupsPresent.Count; i++) { Thought group = thoughtGroupsPresent[i]; mood.thoughts.GetMoodThoughts(group, thoughtGroup); Thought leadingThoughtInGroup = PawnNeedsUIUtility.GetLeadingThoughtInGroup(thoughtGroup); if (leadingThoughtInGroup.VisibleInNeedsTab) { if (!flag) { flag = true; stringBuilder.AppendLine(); } stringBuilder.Append(leadingThoughtInGroup.LabelCap); if (thoughtGroup.Count > 1) { stringBuilder.Append(" x"); stringBuilder.Append(thoughtGroup.Count); } stringBuilder.Append(": "); stringBuilder.AppendLine(mood.thoughts.MoodOffsetOfGroup(group).ToString("##0")); } } return(stringBuilder.ToString()); }
private static void DoRow(Rect rect, Pawn pawn, ref Pawn specificNeedsTabForPawn) { GUI.BeginGroup(rect); Rect rect2 = rect.AtZero(); Widgets.InfoCardButton(rect2.width - 24f, (rect.height - 24f) / 2f, pawn); rect2.width -= 24f; if (!pawn.Dead) { OpenSpecificTabButton(rect2, pawn, ref specificNeedsTabForPawn); rect2.width -= 24f; } Widgets.DrawHighlightIfMouseover(rect2); Rect rect3 = new Rect(4f, (rect.height - 27f) / 2f, 27f, 27f); Widgets.ThingIcon(rect3, pawn, 1f); Rect bgRect = new Rect(rect3.xMax + 4f, 16f, 100f, 18f); GenMapUI.DrawPawnLabel(pawn, bgRect, 1f, 100f, null, GameFont.Small, false, false); tmpNeeds.Clear(); List <Need> allNeeds = pawn.needs.AllNeeds; foreach (Need n in allNeeds) { if (n.def.showForCaravanMembers) // Change for all needs? { tmpNeeds.Add(n); } } PawnNeedsUIUtility.SortInDisplayOrder(tmpNeeds); float xMax = bgRect.xMax; foreach (Need need in tmpNeeds) { int maxThresholdMarkers = 0; bool doTooltip = true; Rect rect4 = new Rect(xMax, 0f, 100f, 50f); Need_Mood mood = need as Need_Mood; if (mood != null) { maxThresholdMarkers = 1; doTooltip = false; //TooltipHandler.TipRegion(rect4, new TipSignal(() => CaravanNeedsTabUtility.CustomMoodNeed)) //Add better way to make stringbuilder } need.DrawOnGUI(rect4, maxThresholdMarkers, 10f, false, doTooltip); xMax = rect4.xMax; } if (pawn.Downed) { GUI.color = new Color(1f, 0f, 0f, 0.5f); Widgets.DrawLineHorizontal(0f, rect.height / 2f, rect.width); GUI.color = Color.white; } GUI.EndGroup(); }
private static void GetNeedsToDisplay(Pawn p, List <Need> outNeeds) { outNeeds.Clear(); List <Need> allNeeds = p.needs.AllNeeds; for (int i = 0; i < allNeeds.Count; i++) { Need need = allNeeds[i]; if (need.def.showForCaravanMembers) { outNeeds.Add(need); } } PawnNeedsUIUtility.SortInDisplayOrder(outNeeds); }
private static void UpdateDisplayNeeds(Pawn pawn) { displayNeeds.Clear(); List <Need> allNeeds = pawn.needs.AllNeeds; for (int i = 0; i < allNeeds.Count; i++) { if (allNeeds[i].def == NeedDefOf.Joy || allNeeds[i].def == DefDatabase <NeedDef> .GetNamed("Beauty") || allNeeds[i].def == DefDatabase <NeedDef> .GetNamed("Comfort") || allNeeds[i].def == DefDatabase <NeedDef> .GetNamed("Outdoors")) { displayNeeds.Add(allNeeds[i]); } } PawnNeedsUIUtility.SortInDisplayOrder(displayNeeds); }
private static void DrawThoughtListing(Rect listingRect, Pawn pawn, ref Vector2 thoughtScrollPosition) { if (Event.current.type == EventType.Layout) { return; } Text.Font = GameFont.Small; PawnNeedsUIUtility.GetThoughtGroupsInDisplayOrder(pawn.needs.mood, thoughtGroupsPresent); float height = (float)thoughtGroupsPresent.Count * 24f; Widgets.BeginScrollView(listingRect, ref thoughtScrollPosition, new Rect(0f, 0f, listingRect.width - 16f, height)); Text.Anchor = TextAnchor.MiddleLeft; float num = 0f; for (int i = 0; i < thoughtGroupsPresent.Count; i++) { if (DrawThoughtGroup(new Rect(0f, num, listingRect.width - 16f, 20f), thoughtGroupsPresent[i], pawn)) { num += 24f; } } Widgets.EndScrollView(); Text.Anchor = TextAnchor.UpperLeft; }
private static bool DrawThoughtGroup(Rect rect, Thought group, Pawn pawn) { try { pawn.needs.mood.thoughts.GetMoodThoughts(group, thoughtGroup); Thought leadingThoughtInGroup = PawnNeedsUIUtility.GetLeadingThoughtInGroup(thoughtGroup); if (!leadingThoughtInGroup.VisibleInNeedsTab) { thoughtGroup.Clear(); return(false); } if (leadingThoughtInGroup != thoughtGroup[0]) { thoughtGroup.Remove(leadingThoughtInGroup); thoughtGroup.Insert(0, leadingThoughtInGroup); } if (Mouse.IsOver(rect)) { Widgets.DrawHighlight(rect); } if (Mouse.IsOver(rect)) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(leadingThoughtInGroup.Description); if (group.def.DurationTicks > 5) { stringBuilder.AppendLine(); stringBuilder.AppendLine(); Thought_Memory thought_Memory = leadingThoughtInGroup as Thought_Memory; if (thought_Memory != null) { if (thoughtGroup.Count == 1) { stringBuilder.Append("ThoughtExpiresIn".Translate((group.def.DurationTicks - thought_Memory.age).ToStringTicksToPeriod())); } else { int num = int.MaxValue; int num2 = int.MinValue; foreach (Thought_Memory item in thoughtGroup) { num = Mathf.Min(num, item.age); num2 = Mathf.Max(num2, item.age); } stringBuilder.Append("ThoughtStartsExpiringIn".Translate((group.def.DurationTicks - num2).ToStringTicksToPeriod())); stringBuilder.AppendLine(); stringBuilder.Append("ThoughtFinishesExpiringIn".Translate((group.def.DurationTicks - num).ToStringTicksToPeriod())); } } } if (thoughtGroup.Count > 1) { bool flag = false; for (int i = 1; i < thoughtGroup.Count; i++) { bool flag2 = false; for (int j = 0; j < i; j++) { if (thoughtGroup[i].LabelCap == thoughtGroup[j].LabelCap) { flag2 = true; break; } } if (!flag2) { if (!flag) { stringBuilder.AppendLine(); stringBuilder.AppendLine(); flag = true; } stringBuilder.AppendLine("+ " + thoughtGroup[i].LabelCap); } } } TooltipHandler.TipRegion(rect, new TipSignal(stringBuilder.ToString(), 7291)); } Text.WordWrap = false; Text.Anchor = TextAnchor.MiddleLeft; Rect rect2 = new Rect(rect.x + 10f, rect.y, 225f, rect.height); rect2.yMin -= 3f; rect2.yMax += 3f; string text = leadingThoughtInGroup.LabelCap; if (thoughtGroup.Count > 1) { text = text + " x" + thoughtGroup.Count; } Widgets.Label(rect2, text); Text.Anchor = TextAnchor.MiddleCenter; float num3 = pawn.needs.mood.thoughts.MoodOffsetOfGroup(group); if (num3 == 0f) { GUI.color = NoEffectColor; } else if (num3 > 0f) { GUI.color = MoodColor; } else { GUI.color = MoodColorNegative; } Widgets.Label(new Rect(rect.x + 235f, rect.y, 32f, rect.height), num3.ToString("##0")); Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.white; Text.WordWrap = true; } catch (Exception ex) { Log.ErrorOnce(string.Concat("Exception in DrawThoughtGroup for ", group.def, " on ", pawn, ": ", ex.ToString()), 3452698); } return(true); }
private Func <string> GetTooltip() => () => { if (Model.Base.needs?.mood?.thoughts == null) { return(""); } var thoughts = new List <Thought>(); try { PawnNeedsUIUtility.GetThoughtGroupsInDisplayOrder(Model.Base.needs.mood, thoughts); } catch (Exception exception) { Mod.HandleWarning(exception); } var builder = new StringBuilder(); foreach (var thought in thoughts) { float offset; try { offset = thought.MoodOffset(); } catch (Exception exception) { Mod.HandleWarning(exception); offset = 0; } Color color; if (offset <= -10) { color = Theme.CriticalColor.Value; } else if (offset < 0) { color = Theme.WarningColor.Value; } else if (offset >= 10) { color = Theme.ExcellentColor.Value; } else if (offset > 0) { color = Theme.GoodColor.Value; } else { color = Theme.InfoColor.Value; } try { var similar = new List <Thought>(); Model.Base.needs.mood.thoughts.GetMoodThoughts(thought, similar); var thoughtLabel = thought.LabelCap; if (similar.Count > 1) { thoughtLabel += " x" + similar.Count; } var line = $"{thoughtLabel}: {offset * similar.Count}".Color(color); builder.AppendLine(line); } catch (Exception exception) { Mod.HandleWarning(exception); } } builder.AppendLine(); if (Model.Base.Inspired) { builder.AppendLine(Model.Base.Inspiration.InspectLine.Color(Theme.ExcellentColor.Value)); } return(builder.Length > 0 ? builder.ToStringTrimmed().Size(Theme.RegularTextStyle.ActualSize) : ""); };