public static void Prefix(MainTabWindow_Research __instance, ref ResearchTabDef tab, ref Vector2 __result) { if (ResearchSubTabUtility.CurSubTab.IsSubTabOf(tab)) { tab = ResearchSubTabUtility.CurSubTab; } }
public static void Postfix(MainTabWindow_Research __instance, ref ResearchProjectDef ___selectedProject) { if (BlindResearch.CanSeeCurrent()) { return; } ___selectedProject = null; //__instance.selectedProject = null; SetCurTab.Invoke(__instance, new object[] { ResearchTabDefOf.Main }); //__instance.CurTab = ResearchTabDefOf.Main; }
public static bool Prefix(MainTabWindow_Research __instance, ResearchProjectDef project, Rect rect, ref float __result) { if (project.HasModExtension <AnyPrerequisiteResearchExtension>()) { AnyPrerequisiteResearchExtension ext = project.GetModExtensionFast <AnyPrerequisiteResearchExtension>(); if (project.prerequisites.NullOrEmpty <ResearchProjectDef>() && ext.RequiredResearch.NullOrEmpty()) { return(true); } float xMin = rect.xMin; float yMin = rect.yMin; Widgets.LabelCacheHeight(ref rect, "ResearchPrerequisites".Translate() + ":", true, false); rect.yMin += rect.height; rect.xMin += 6f; for (int i = 0; i < project.prerequisites.Count; i++) { SetPrerequisiteStatusColor(project.prerequisites[i].IsFinished, project); Widgets.LabelCacheHeight(ref rect, project.prerequisites[i].LabelCap, true, false); rect.yMin += rect.height; } GUI.color = Color.white; Widgets.LabelCacheHeight(ref rect, "and ONE of the following" + ":", true, false); rect.yMin += rect.height; rect.xMin += 6f; if (ext.RequiredResearch != null) { for (int j = 0; j < ext.RequiredResearch.Count; j++) { SetPrerequisiteStatusColor(ext.RequiredResearch[j].IsFinished, project); Widgets.LabelCacheHeight(ref rect, ext.RequiredResearch[j].LabelCap, true, false); rect.yMin += rect.height; } } GUI.color = Color.white; rect.xMin = xMin; __result = rect.yMin - yMin; return(false); } return(true); }
public static void Postfix(MainTabWindow_Research __instance, ResearchPrerequisitesUtility.UnlockedHeader headerProject, ref string __result) { if (headerProject.unlockedBy.NullOrEmpty() || headerProject.unlockedBy.Count == 1) { return; } StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < headerProject.unlockedBy.Count; i++) { if (i > 0) { stringBuilder.Append(", "); } ResearchProjectDef researchProjectDef = headerProject.unlockedBy[i]; string text = researchProjectDef.LabelCap; if (!researchProjectDef.IsFinished) { text = text.Colorize(MissingPrerequisiteColor); } stringBuilder.Append(text); } __result = stringBuilder.ToString(); }
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(); }