private float InfoHeightFor(float width, MissionDef def) { Requisites req = def.requisites; float total = 0f; total += Text.CalcHeight("MissionInfoMain_SMO".Translate("'" + selectedLockedMission.label + "'"), width); total += 12f; total += ReqHeight(req.researchProjects); total += ReqHeight(req.missions); total += ReqHeight(req.objectives); total += ReqHeight(req.jobs); total += ReqHeight(req.things.AllThingDefs()); return(total); }
public void DrawLockedMissionInfo(Rect rect) { Rect InfoRect = new Rect(rect.x, rect.y, rect.width / 3f, rect.height); StoryUtils.DrawMenuSectionColor(InfoRect, 1, new ColorInt(55, 55, 55), new ColorInt(135, 135, 135)); float TotalHeight = InfoHeightFor(InfoRect.width, selectedLockedMission); Rect ViewRect = new Rect(InfoRect.x, InfoRect.y, InfoRect.width, TotalHeight); Widgets.BeginScrollView(InfoRect, ref missionInfoScrollPos, ViewRect, false); InfoRect = InfoRect.ContractedBy(5f); GUI.BeginGroup(InfoRect); //MainPart float CurY = 0f; Requisites requisites = selectedLockedMission.requisites; string MainInfo = requisites.anyList ? "MissionInfoMainAny_SMO".Translate("'" + selectedLockedMission.label + "'") : "MissionInfoMain_SMO".Translate("'" + selectedLockedMission.label + "'"); float MainInfoHeight = Text.CalcHeight(MainInfo, InfoRect.width); Rect MainInfoRect = new Rect(0, 0, InfoRect.width, MainInfoHeight); Widgets.Label(MainInfoRect, MainInfo); CurY += MainInfoRect.height; GeneralInfo(new Rect(0f, CurY, InfoRect.width, 0f), ref CurY, requisites.researchProjects, requisites.anyResearch ? "MissionInfoResearchAny_SMO".Translate() : "MissionInfoResearch_SMO".Translate(), delegate(ResearchProjectDef def) { Find.MainTabsRoot.SetCurrentTab(MainButtonDefOf.Research, true); MainTabWindow_Research window = (Find.WindowStack.Windows.Where(w => w is MainTabWindow_Research).FirstOrDefault() as MainTabWindow_Research); Traverse.Create(window).Field("selectedProject").SetValue(def); }); GeneralInfo(new Rect(0f, CurY, InfoRect.width, 0f), ref CurY, requisites.missions, requisites.anyMission ? "MissionInfoMissionsAny_SMO".Translate() : "MissionInfoMissions_SMO".Translate(), delegate(MissionDef def) { SelectedMission = StoryManager.GetMission(def); selectedLockedMission = null; }); GeneralInfo(new Rect(0f, CurY, InfoRect.width, 0f), ref CurY, requisites.objectives, requisites.anyObjective ? "MissionInfoObjectivesAny_SMO".Translate() : "MissionInfoObjectives_SMO".Translate(), delegate(ObjectiveDef def) { SelectedMission = StoryManager.GetMission(def); SelectedObjective = SelectedMission.objectives.Find(o => o.def == def); selectedLockedMission = null; }); GeneralInfo(new Rect(0f, CurY, InfoRect.width, 0f), ref CurY, requisites.things, requisites.anyThing ? "MissionInfoThingsAny_SMO".Translate() : "MissionInfoThings_SMO".Translate(), null, delegate(Rect selection, ThingValue tv) { ThingDef thingDef = tv.ThingDef; string stuffLabel = tv.Stuff != null ? tv.ResolvedStuff.LabelCap : "Any_SMO".Translate(); string qualityLabel = !thingDef.CountAsResource ? tv.CustomQuality ? " (" + tv.QualityCategory.GetLabel() + ")" : "" : ""; string fullLabel = " - " + (tv.ResolvedStuff != null ? stuffLabel + " " : "") + thingDef.LabelCap + qualityLabel + " (x" + tv.value + ")"; Vector2 labelSize = Text.CalcSize(fullLabel); bool oversized = labelSize.x > selection.width; string label = oversized ? " - " + tv.ThingDef.LabelCap + "(...)" : fullLabel; Widgets.Label(selection, label); if (oversized) { TooltipHandler.TipRegion(selection, fullLabel); } }); GeneralInfo(new Rect(0f, CurY, InfoRect.width, 0f), ref CurY, requisites.jobs, "MissionInfoJobs_SMO".Translate(), null, delegate(Rect selection, JobDef def) { string label = " ..." + def.reportString; Widgets.Label(selection, label); }); GUI.EndGroup(); Widgets.EndScrollView(); }