public static Vector2 CardSize(CompToggleDef compToggleDef) { var width = InspectPaneUtility.PaneWidthFor((MainTabWindow_Inspect)MainButtonDefOf.Inspect.TabWindow); var rowCount = Math.Min(compToggleDef.Props.toggleDefs.Count, MaxRows); return(new Vector2(width, TotalRowHeight(rowCount) + CardPadding * 2 + ExtraTopPadding)); }
public static bool Prefix(ref Gizmo mouseoverGizmo) { if (!Active && !Analyzer.Settings.OptimizeDrawInspectGizmoGrid) { return(true); } if (Active) { Analyzer.Start(str); } if (Analyzer.Settings.OptimizeDrawInspectGizmoGrid) { if (Event.current.type == EventType.Repaint) { return(true); } if (Event.current.type != EventType.Layout) { GizmoGridDrawer.DrawGizmoGrid(cach, InspectPaneUtility.PaneWidthFor(Find.WindowStack.WindowOfType <IInspectPane>()) + 20f, out mouseoverGizmo); } return(false); } return(true); }
public static bool Prefix(IEnumerable <object> selectedObjects, ref Gizmo mouseoverGizmo, ref Profiler __state) { if (Active && DetourMode) { Detour(selectedObjects, ref mouseoverGizmo); return(false); } if (!Active && !Analyzer.Settings.OptimizeDrawInspectGizmoGrid) { return(true); } if (Active) { __state = Analyzer.Start(str); } if (Analyzer.Settings.OptimizeDrawInspectGizmoGrid) { if (Event.current.type == EventType.Repaint) { return(true); } if (Event.current.type != EventType.Layout) { GizmoGridDrawer.DrawGizmoGrid(cach, InspectPaneUtility.PaneWidthFor(Find.WindowStack.WindowOfType <IInspectPane>()) + 20f, out mouseoverGizmo); } return(false); } return(true); }
public override void WindowUpdate() { base.WindowUpdate(); InspectPaneUtility.UpdateTabs(this); if (this.mouseoverGizmo != null) { this.mouseoverGizmo.GizmoUpdateOnMouseover(); } }
private static bool Prefix(ref Vector2 __result, IInspectPane pane) { if (!State.AltInspectPane || !State.PawnSelected) { return(true); } __result = new Vector2(InspectPaneUtility.PaneWidthFor(pane), Theme.InspectPaneHeight.Value - 35f); return(false); }
public override void DoCell(Rect rect, Pawn pawn, PawnTable table) { if (Widgets.ButtonText(rect, "...")) { CameraJumper.TryJumpAndSelect(pawn); if (Find.Selector.IsSelected(pawn)) { InspectPaneUtility.OpenTab(typeof (ITab_Pawn_Guest)); } } }
public static bool DrawTabs(IInspectPane pane) { try { var y = pane.PaneTopY - 30f; var x = InspectPaneUtility.PaneWidthFor(pane) - Theme.InspectPaneTabWidth.Value; var width = 0f; var isSelected = false; foreach (var curTab in pane.CurTabs) { if (!curTab.IsVisible) { continue; } var rect = new Rect(x, y, Theme.InspectPaneTabWidth.Value, 30f); width = x; Text.Font = GameFont.Small; if (Widgets.ButtonText(rect, curTab.labelKey.Translate())) { InterfaceToggleTab(curTab, pane); } var isOpenTab = curTab.GetType() == pane.OpenTabType; if (!isOpenTab && !curTab.TutorHighlightTagClosed.NullOrEmpty()) { UIHighlighter.HighlightOpportunity(rect, curTab.TutorHighlightTagClosed); } if (isOpenTab) { curTab.DoTabGUI(); pane.RecentHeight = 700f; isSelected = true; } x -= Theme.InspectPaneTabWidth.Value; } if (!isSelected) { return(false); } GUI.DrawTexture(new Rect(0.0f, y, width, 30f), Textures.InspectTabButtonFillTex); } catch (Exception ex) { Log.ErrorOnce(ex.ToString(), 742783); } return(false); }
private static bool Prefix_ExtraOnGui(MainTabWindow_Inspect __instance) { if (!State.HudDockedVisible) { return(true); } InspectPaneUtility.ExtraOnGUI(__instance); if (__instance.AnythingSelected && (Find.DesignatorManager.SelectedDesignator != null)) { Find.DesignatorManager.SelectedDesignator.DoExtraGuiControls(0f, __instance.PaneTopY); } return(false); }
public static void ChooseMenuAction(InspectTabBase tab) { bool flag = tab is ITab; if (flag) { InspectPaneUtility.OpenTab(tab.GetType()); } else { bool flag2 = tab is WITab; if (flag2) { Find.MainTabsRoot.EscapeCurrentTab(false); tab.OnOpen(); Find.World.UI.inspectPane.OpenTabType = tab.GetType(); } } }
public static void Initialize() { // Make evil people immune to thoughts listed below List<ThoughtDef> nullifiedThoughts = new List<ThoughtDef>(); nullifiedThoughts.Add(ThoughtDefOf.KnowGuestExecuted); nullifiedThoughts.Add(ThoughtDefOf.KnowPrisonerDiedInnocent); nullifiedThoughts.Add(ThoughtDefOf.KnowPrisonerSold); nullifiedThoughts.Add(ThoughtDefOf.KnowGuestOrganHarvested); nullifiedThoughts.Add(ThoughtDefOf.WitnessedDeathNonAlly); foreach (var thought in nullifiedThoughts) { thought.nullifyingTraits?.Add(BPDefOf.BadPeople_Evil); thought.ResolveReferences(); } // Ensure psychopath can't be evil person var psychopathTrait = TraitDefOf.Psychopath; if (psychopathTrait.conflictingTraits == null) psychopathTrait.conflictingTraits = new List<TraitDef>(); if (!psychopathTrait.conflictingTraits.Contains(BPDefOf.BadPeople_Evil)) psychopathTrait.conflictingTraits.Add(BPDefOf.BadPeople_Evil); psychopathTrait.ResolveReferences(); KinslayerInitialize(); // Adding Debug tab to all pawns, visibility resolved internally, later. foreach (ThingDef t in DefDatabase<ThingDef>.AllDefs.Where(def => def.race != null && def.race.intelligence == Intelligence.Humanlike)) { if (t.inspectorTabsResolved == null) { t.inspectorTabsResolved = new List<InspectTabBase>(1); } t.inspectorTabsResolved.Add(InspectTabManager.GetSharedInstance(typeof(ITab_DebugActivityLog))); } InspectPaneUtility.Reset(); }
/// <summary> /// This is a rip of the DoCustomBottomButtons() function in RimWorld.Page_SelectLandingSite with a new button. /// </summary> private void DoCustomBottomButtons() { // HACK : changed the number of buttons from '5 : 4' to '6 : 5' as we add a button var num = (!TutorSystem.TutorialMode) ? 6 : 5; int num2; if (num >= 4 && UI.screenWidth < 1340f) { num2 = 2; } else { num2 = 1; } var num3 = Mathf.CeilToInt(num / (float)num2); var num4 = BottomButSize.x * num3 + 10f * (num3 + 1); var num5 = num2 * BottomButSize.y + 10f * (num2 + 1); var rect = new Rect((UI.screenWidth - num4) / 2f, UI.screenHeight - num5 - 4f, num4, num5); var worldInspectPane = Find.WindowStack.WindowOfType <WorldInspectPane>(); if (worldInspectPane != null && rect.x < InspectPaneUtility.PaneWidthFor(worldInspectPane) + 4f) { rect.x = InspectPaneUtility.PaneWidthFor(worldInspectPane) + 4f; } Widgets.DrawWindowBackground(rect); var num6 = rect.xMin + 10f; var num7 = rect.yMin + 10f; Text.Font = GameFont.Small; if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "Back".Translate())) { if (CanDoBack()) { /* ADDED CODE */ #region INSERTED_CODE // make sure the prepare landing window (or its minimized window) is closed when we go back if (Find.WindowStack.IsOpen <MainWindow>() || Find.WindowStack.IsOpen <MinimizedWindow>()) { if (PrepareLanding.Instance.MainWindow != null) { PrepareLanding.Instance.MainWindow.ForceClose(); } } #endregion /* END ADDED CODE*/ DoBack(); } } num6 += BottomButSize.x + 10f; if (!TutorSystem.TutorialMode) { if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "Advanced".Translate())) { Find.WindowStack.Add(new Dialog_AdvancedGameConfig(Find.WorldInterface.SelectedTile)); } num6 += BottomButSize.x + 10f; } if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "SelectRandomSite".Translate())) { SoundDefOf.Click.PlayOneShotOnCamera(); Find.WorldInterface.SelectedTile = TileFinder.RandomStartingTile(); Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile)); } num6 += BottomButSize.x + 10f; if (num2 == 2) { num6 = rect.xMin + 10f; num7 += BottomButSize.y + 10f; } if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "WorldFactionsTab".Translate())) { Find.WindowStack.Add(new Dialog_FactionDuringLanding()); } num6 += BottomButSize.x + 10f; #region INSERTED_CODE if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "Prepare Landing")) { Log.Message("[PrepareLanding] Page button pressed!"); // don't add a new window if the window is already there if (PrepareLanding.Instance.MainWindow == null) { PrepareLanding.Instance.MainWindow = new MainWindow(PrepareLanding.Instance.GameData); } PrepareLanding.Instance.MainWindow.Show(); } num6 += BottomButSize.x + 10f; #endregion INSERTED_CODE /* end of inserted code */ if (Widgets.ButtonText(new Rect(num6, num7, BottomButSize.x, BottomButSize.y), "Next".Translate())) { if (CanDoNext()) { /* ADDED CODE */ #region INSERTED_CODE // make sure the prepare landing window (or its minimized window) is closed when we go to the next window / game stage if (Find.WindowStack.IsOpen <MainWindow>() || Find.WindowStack.IsOpen <MinimizedWindow>()) { if (PrepareLanding.Instance.MainWindow != null) { PrepareLanding.Instance.MainWindow.ForceClose(); } } #endregion /* END ADDED CODE*/ DoNext(); } } //num6 += BottomButSize.x + 10f; GenUI.AbsorbClicksInRect(rect); }
public override void DefsLoaded() { //1. Preparing settings UpdateSettings(); //2. Adding Tech Tab to Pawns //ThingDef injection stolen from the work of notfood for Psychology var zombieThinkTree = DefDatabase <ThinkTreeDef> .GetNamedSilentFail("Zombie"); IEnumerable <ThingDef> things = (from def in DefDatabase <ThingDef> .AllDefs where def.race?.intelligence == Intelligence.Humanlike && (zombieThinkTree == null || def.race.thinkTreeMain != zombieThinkTree) select def); List <string> registered = new List <string>(); foreach (ThingDef t in things) { if (t.inspectorTabsResolved == null) { t.inspectorTabsResolved = new List <InspectTabBase>(1); } t.inspectorTabsResolved.Add(InspectTabManager.GetSharedInstance(typeof(ITab_PawnKnowledge))); if (t.comps == null) { t.comps = new List <CompProperties>(1); } t.comps.Add(new CompProperties_Knowledge()); registered.Add(t.defName); } InspectPaneUtility.Reset(); //3. Preparing knowledge support infrastructure //a. Things everyone knows UniversalWeapons.AddRange(DefDatabase <ThingDef> .AllDefs.Where(x => x.IsWeapon)); UniversalCrops.AddRange(DefDatabase <ThingDef> .AllDefs.Where(x => x.plant != null && x.plant.Sowable)); //b. Minus things unlocked on research ThingFilter lateFilter = new ThingFilter(); foreach (ResearchProjectDef tech in DefDatabase <ResearchProjectDef> .AllDefs) { tech.InferSkillBias(); tech.CreateStuff(lateFilter, unlocked); foreach (ThingDef weapon in tech.UnlockedWeapons()) { UniversalWeapons.Remove(weapon); } foreach (ThingDef plant in tech.UnlockedPlants()) { UniversalCrops.Remove(plant); } } ; //c. Also removing atipical weapons List <string> ForbiddenWeaponTags = TechDefOf.WeaponsNotBasic.weaponTags; UniversalWeapons.RemoveAll(x => SplitSimpleWeapons(x, ForbiddenWeaponTags)); List <ThingDef> garbage = new List <ThingDef>(); garbage.Add(TechDefOf.WeaponsNotBasic); //d. Classifying pawn backstories PawnBackgroundUtility.BuildCache(); //e. Telling humans what's going on ThingCategoryDef knowledgeCat = TechDefOf.Knowledge; IEnumerable <ThingDef> codifiedTech = DefDatabase <ThingDef> .AllDefs.Where(x => x.IsWithinCategory(knowledgeCat)); if (Prefs.LogVerbose || FullStartupReport) { Log.Message($"[HumanResources] Codified technologies: {codifiedTech.Select(x => x.label).ToStringSafeEnumerable()}"); Log.Message($"[HumanResources] Basic crops: {UniversalCrops.ToStringSafeEnumerable()}"); Log.Message($"[HumanResources] Basic weapons: {UniversalWeapons.ToStringSafeEnumerable()}"); Log.Message($"[HumanResources] Basic weapons that require training: {SimpleWeapons.ToStringSafeEnumerable()}"); Log.Warning($"[HumanResources] Basic weapons tags: {SimpleWeapons.Where(x => !x.weaponTags.NullOrEmpty()).SelectMany(x => x.weaponTags).Distinct().ToStringSafeEnumerable()}"); if (FullStartupReport) { Log.Warning("[HumanResources] Backstories classified by TechLevel:"); for (int i = 0; i < 8; i++) { TechLevel level = (TechLevel)i; IEnumerable <string> found = PawnBackgroundUtility.TechLevelByBackstory.Where(e => e.Value == level).Select(e => e.Key); if (!found.EnumerableNullOrEmpty()) { Log.Message($"- {level.ToString().CapitalizeFirst()} ({found.EnumerableCount()}): {found.ToStringSafeEnumerable()}"); } } Log.Warning("[HumanResources] Techs classified by associated skill:"); var skills = DefDatabase <SkillDef> .AllDefsListForReading.GetEnumerator(); while (skills.MoveNext()) { SkillDef skill = skills.Current; IEnumerable <string> found = TechTracker.FindTechs(skill).Select(x => x.Tech.label); Log.Message($"- {skill.LabelCap} ({found.EnumerableCount()}): {found.ToStringSafeEnumerable()}"); } } } else { Log.Message($"[HumanResources] This is what we know: {codifiedTech.EnumerableCount()} technologies processed, {UniversalCrops.Count()} basic crops, {UniversalWeapons.Count()} basic weapons + {SimpleWeapons.Count()} that require training."); } //4. Filling gaps on the database //a. TechBook dirty trick, but only now this is possible! TechDefOf.TechBook.stuffCategories = TechDefOf.UnfinishedTechBook.stuffCategories = TechDefOf.LowTechCategories.stuffCategories; TechDefOf.TechDrive.stuffCategories = TechDefOf.HiTechCategories.stuffCategories; garbage.Add(TechDefOf.LowTechCategories); garbage.Add(TechDefOf.HiTechCategories); //b. Filling main tech category with subcategories foreach (ThingDef t in lateFilter.AllowedThingDefs.Where(t => !t.thingCategories.NullOrEmpty())) { foreach (ThingCategoryDef c in t.thingCategories) { c.childThingDefs.Add(t); if (!knowledgeCat.childCategories.NullOrEmpty() && !knowledgeCat.childCategories.Contains(c)) { knowledgeCat.childCategories.Add(c); } } } //c. Populating knowledge recipes and book shelves foreach (RecipeDef r in DefDatabase <RecipeDef> .AllDefs.Where(x => x.ingredients.Count == 1 && x.fixedIngredientFilter.AnyAllowedDef == null)) { r.fixedIngredientFilter.ResolveReferences(); r.defaultIngredientFilter.ResolveReferences(); } foreach (ThingDef t in DefDatabase <ThingDef> .AllDefs.Where(x => x.thingClass == typeof(Building_BookStore))) { t.building.fixedStorageSettings.filter.ResolveReferences(); t.building.defaultStorageSettings.filter.ResolveReferences(); } //d. Removing temporary defs from database. foreach (ThingDef def in garbage) { AccessTools.Method(typeof(DefDatabase <ThingDef>), "Remove").Invoke(this, new object[] { def }); } }
public static void Prefix(MainTabWindow_Inspect __instance, ref Rect rect) { rect.width = InspectPaneUtility.PaneWidthFor(__instance) - 72f; }
public void DrawInspectGizmos() { GizmoGridDrawer.DrawGizmoGrid(resolvedDesignatorTypes.Cast <Gizmo>(), InspectPaneUtility.PaneWidthFor(this) + 20f, out mouseoverGizmo); }
public override void WindowUpdate() { base.WindowUpdate(); InspectPaneUtility.UpdateTabs(this); }
public override void ExtraOnGUI() { base.ExtraOnGUI(); InspectPaneUtility.ExtraOnGUI(this); }
public override void DoWindowContents(Rect inRect) { if (this.Anchor == MainTabWindowAnchor.Left) { this.currentWindowRect.x = 0f; } else { this.currentWindowRect.x = (float)Screen.width - this.currentWindowRect.width; } this.currentWindowRect.y = (float)(Screen.height - 35) - this.currentWindowRect.height; if (this.def.concept != null) { ConceptDatabase.KnowledgeDemonstrated(this.def.concept, KnowledgeAmount.GuiFrame); } this.RecentHeight = RimWorld.MainTabWindow_Inspect.PaneSize.y; if (this.NumSelected > 0) { try { Rect rect = inRect.ContractedBy(12f); rect.yMin -= 4f; GUI.BeginGroup(rect); bool flag = true; if (this.NumSelected > 1) { flag = !(from t in this.Selected where !InspectPaneUtility.CanInspectTogether(this.Selected.First <object>(), t) select t).Any <object>(); } else { Rect rect2 = new Rect(rect.width - 30f, 0f, 30f, 30f); if (Find.Selector.SelectedZone == null || Find.Selector.SelectedZone.ContainsCell(MainTabWindow_Inspect.lastSelectCell)) { if (Widgets.ImageButton(rect2, TexButton.SelectOverlappingNext)) { this.SelectNextInCell(); } TooltipHandler.TipRegion(rect2, "SelectNextInSquareTip".Translate(new object[] { KeyBindingDefOf.SelectNextInCell.MainKeyLabel })); } if (Find.Selector.SingleSelectedThing != null) { Widgets.InfoCardButton(rect.width - 60f, 0f, Find.Selector.SingleSelectedThing); } } Rect rect3 = new Rect(0f, 0f, rect.width - 60f, 50f); string label = InspectPaneUtility.AdjustedLabelFor(this.Selected, rect3); rect3.width += 300f; Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.UpperLeft; Widgets.Label(rect3, label); if (flag && this.NumSelected == 1) { Rect rect4 = rect.AtZero(); rect4.yMin += 26f; InspectPaneFiller.DoPaneContentsFor((ISelectable)Find.Selector.FirstSelectedObject, rect4); } } catch (Exception ex) { Log.Error("Exception doing inspect pane: " + ex.ToString()); } finally { GUI.EndGroup(); } } }
private static void DoPlayLoad() { GraphicDatabase.Clear(); DeepProfiler.Start("Load all active mods."); try { LoadedModManager.LoadAllActiveMods(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Load language metadata."); try { LanguageDatabase.LoadAllMetadata(); } finally { DeepProfiler.End(); } LongEventHandler.SetCurrentEventText("LoadingDefs".Translate()); DeepProfiler.Start("Copy all Defs from mods to global databases."); try { foreach (Type item in typeof(Def).AllSubclasses()) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item, "AddAllInMods"); } } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve cross-references between non-implied Defs."); try { DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.Silent); } finally { DeepProfiler.End(); } DeepProfiler.Start("Rebind defs (early)."); try { DefOfHelper.RebindAllDefOfs(true); } finally { DeepProfiler.End(); } DeepProfiler.Start("Generate implied Defs (pre-resolve)."); try { DefGenerator.GenerateImpliedDefs_PreResolve(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve cross-references between Defs made by the implied defs."); try { DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.LogErrors); } finally { DeepProfiler.End(); } DeepProfiler.Start("Rebind DefOfs (final)."); try { DefOfHelper.RebindAllDefOfs(false); } finally { DeepProfiler.End(); } DeepProfiler.Start("Other def binding, resetting and global operations."); try { PlayerKnowledgeDatabase.ReloadAndRebind(); LessonAutoActivator.Reset(); CostListCalculator.Reset(); PawnApparelGenerator.Reset(); RestUtility.Reset(); ThoughtUtility.Reset(); PawnWeaponGenerator.Reset(); ThinkTreeKeyAssigner.Reset(); ThingCategoryNodeDatabase.FinalizeInit(); TrainableUtility.Reset(); HaulAIUtility.Reset(); GenConstruct.Reset(); WorkGiver_FillFermentingBarrel.Reset(); WorkGiver_DoBill.Reset(); Pawn.Reset(); WorkGiver_InteractAnimal.Reset(); WorkGiver_Warden_DoExecution.Reset(); WorkGiver_GrowerSow.Reset(); WorkGiver_Miner.Reset(); MedicalCareUtility.Reset(); InspectPaneUtility.Reset(); GraphicDatabaseHeadRecords.Reset(); DateReadout.Reset(); ResearchProjectDef.GenerateNonOverlappingCoordinates(); WorkGiver_FixBrokenDownBuilding.CacheTranslations(); ItemCollectionGeneratorUtility.Reset(); BaseGen.Reset(); HealthUtility.Reset(); ResourceCounter.ResetDefs(); WildSpawner.Reset(); ApparelProperties.Reset(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve references."); try { foreach (Type item2 in typeof(Def).AllSubclasses()) { if (item2 != typeof(ThingDef)) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item2, "ResolveAllReferences", true); } } DefDatabase <ThingDef> .ResolveAllReferences(true); } finally { DeepProfiler.End(); } DeepProfiler.Start("Generate implied Defs (post-resolve)."); try { DefGenerator.GenerateImpliedDefs_PostResolve(); } finally { DeepProfiler.End(); } if (Prefs.DevMode) { DeepProfiler.Start("Error check all defs."); try { foreach (Type item3 in typeof(Def).AllSubclasses()) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item3, "ErrorCheckAllDefs"); } } finally { DeepProfiler.End(); } } LongEventHandler.SetCurrentEventText("Initializing".Translate()); DeepProfiler.Start("Load keyboard preferences."); try { KeyPrefs.Init(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Short hash giving."); try { ShortHashGiver.GiveAllShortHashes(); } finally { DeepProfiler.End(); } LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("Load backstories."); try { BackstoryDatabase.ReloadAllBackstories(); } finally { DeepProfiler.End(); } }); LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("Inject selected language data into game data."); try { LanguageDatabase.activeLanguage.InjectIntoData(); GenLabel.ClearCache(); } finally { DeepProfiler.End(); } }); LongEventHandler.ExecuteWhenFinished(delegate { StaticConstructorOnStartupUtility.CallAll(); if (Prefs.DevMode) { StaticConstructorOnStartupUtility.ReportProbablyMissingAttributes(); } }); }
public static void Detour(IEnumerable <object> selectedObjects, ref Gizmo mouseoverGizmo) { var DoRebuild = !(Analyzer.Settings.OptimizeDrawInspectGizmoGrid && Event.current.type != EventType.Repaint); Profiler prof = null; if (DoRebuild) { mouseoverGizmo = null; try { InspectGizmoGrid.objList.Clear(); InspectGizmoGrid.objList.AddRange(selectedObjects); InspectGizmoGrid.gizmoList.Clear(); var slam = InspectGizmoGrid.objList.Count; for (var i = 0; i < slam; i++) { if (InspectGizmoGrid.objList[i] is ISelectable selectable) { if (Active) { var me = string.Intern($"{selectable.GetType()} Gizmos"); prof = Analyzer.Start(me); InspectGizmoGrid.gizmoList.AddRange(selectable.GetGizmos()); prof.Stop(); } else { InspectGizmoGrid.gizmoList.AddRange(selectable.GetGizmos()); } } } for (var j = 0; j < InspectGizmoGrid.objList.Count; j++) { if (InspectGizmoGrid.objList[j] is Thing t) { var allDesignators = Find.ReverseDesignatorDatabase.AllDesignators; var coo = allDesignators.Count; for (var k = 0; k < coo; k++) { Designator des = allDesignators[k]; if (des.CanDesignateThing(t).Accepted) { var command_Action = new Command_Action { defaultLabel = des.LabelCapReverseDesignating(t), icon = des.IconReverseDesignating(t, out var iconAngle, out var iconOffset), iconAngle = iconAngle, iconOffset = iconOffset, defaultDesc = des.DescReverseDesignating(t), order = (!(des is Designator_Uninstall) ? -20f : -11f), action = delegate { if (!TutorSystem.AllowAction(des.TutorTagDesignate)) { return; } des.DesignateThing(t); des.Finalize(true); }, hotKey = des.hotKey, groupKey = des.groupKey }; InspectGizmoGrid.gizmoList.Add(command_Action); } } } } InspectGizmoGrid.objList.Clear(); } catch (Exception ex) { Log.ErrorOnce(ex.ToString(), 3427734); } } if (Active) { prof = Analyzer.Start(str); } GizmoGridDrawer.DrawGizmoGrid(InspectGizmoGrid.gizmoList, InspectPaneUtility.PaneWidthFor(Find.WindowStack.WindowOfType <IInspectPane>()) + 20f, out mouseoverGizmo); if (Active) { prof.Stop(); } }
private static void DoPlayLoad() { DeepProfiler.Start("GraphicDatabase.Clear()"); try { GraphicDatabase.Clear(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Load all active mods."); try { LoadedModManager.LoadAllActiveMods(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Load language metadata."); try { LanguageDatabase.InitAllMetadata(); } finally { DeepProfiler.End(); } LongEventHandler.SetCurrentEventText("LoadingDefs".Translate()); DeepProfiler.Start("Copy all Defs from mods to global databases."); try { foreach (Type item in typeof(Def).AllSubclasses()) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item, "AddAllInMods"); } } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve cross-references between non-implied Defs."); try { DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.Silent); } finally { DeepProfiler.End(); } DeepProfiler.Start("Rebind defs (early)."); try { DefOfHelper.RebindAllDefOfs(earlyTryMode: true); } finally { DeepProfiler.End(); } DeepProfiler.Start("TKeySystem.BuildMappings()"); try { TKeySystem.BuildMappings(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Inject selected language data into game data (early pass)."); try { LanguageDatabase.activeLanguage.InjectIntoData_BeforeImpliedDefs(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Generate implied Defs (pre-resolve)."); try { DefGenerator.GenerateImpliedDefs_PreResolve(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve cross-references between Defs made by the implied defs."); try { DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.LogErrors); } finally { DirectXmlCrossRefLoader.Clear(); DeepProfiler.End(); } DeepProfiler.Start("Rebind DefOfs (final)."); try { DefOfHelper.RebindAllDefOfs(earlyTryMode: false); } finally { DeepProfiler.End(); } DeepProfiler.Start("Other def binding, resetting and global operations (pre-resolve)."); try { PlayerKnowledgeDatabase.ReloadAndRebind(); LessonAutoActivator.Reset(); CostListCalculator.Reset(); Pawn.ResetStaticData(); PawnApparelGenerator.Reset(); RestUtility.Reset(); ThoughtUtility.Reset(); ThinkTreeKeyAssigner.Reset(); ThingCategoryNodeDatabase.FinalizeInit(); TrainableUtility.Reset(); HaulAIUtility.Reset(); GenConstruct.Reset(); MedicalCareUtility.Reset(); InspectPaneUtility.Reset(); GraphicDatabaseHeadRecords.Reset(); DateReadout.Reset(); ResearchProjectDef.GenerateNonOverlappingCoordinates(); BaseGen.Reset(); ResourceCounter.ResetDefs(); ApparelProperties.ResetStaticData(); WildPlantSpawner.ResetStaticData(); PawnGenerator.Reset(); TunnelHiveSpawner.ResetStaticData(); Hive.ResetStaticData(); ExpectationsUtility.Reset(); WealthWatcher.ResetStaticData(); SkillUI.Reset(); QuestNode_GetThingPlayerCanProduce.ResetStaticData(); Pawn_PsychicEntropyTracker.ResetStaticData(); ColoredText.ResetStaticData(); QuestNode_GetRandomNegativeGameCondition.ResetStaticData(); RoyalTitleUtility.ResetStaticData(); RewardsGenerator.ResetStaticData(); WorkGiver_FillFermentingBarrel.ResetStaticData(); WorkGiver_DoBill.ResetStaticData(); WorkGiver_InteractAnimal.ResetStaticData(); WorkGiver_Warden_DoExecution.ResetStaticData(); WorkGiver_GrowerSow.ResetStaticData(); WorkGiver_Miner.ResetStaticData(); WorkGiver_FixBrokenDownBuilding.ResetStaticData(); WorkGiver_ConstructDeliverResources.ResetStaticData(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Resolve references."); try { DeepProfiler.Start("ThingCategoryDef resolver"); try { DefDatabase <ThingCategoryDef> .ResolveAllReferences(); } finally { DeepProfiler.End(); } DeepProfiler.Start("RecipeDef resolver"); try { DeepProfiler.enabled = false; DefDatabase <RecipeDef> .ResolveAllReferences(onlyExactlyMyType : true, parallel : true); DeepProfiler.enabled = true; } finally { DeepProfiler.End(); } DeepProfiler.Start("Static resolver calls"); try { foreach (Type item2 in typeof(Def).AllSubclasses()) { if (!(item2 == typeof(ThingDef)) && !(item2 == typeof(ThingCategoryDef)) && !(item2 == typeof(RecipeDef))) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item2, "ResolveAllReferences", true, false); } } } finally { DeepProfiler.End(); } DeepProfiler.Start("ThingDef resolver"); try { DefDatabase <ThingDef> .ResolveAllReferences(); } finally { DeepProfiler.End(); } } finally { DeepProfiler.End(); } DeepProfiler.Start("Generate implied Defs (post-resolve)."); try { DefGenerator.GenerateImpliedDefs_PostResolve(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Other def binding, resetting and global operations (post-resolve)."); try { PawnWeaponGenerator.Reset(); BuildingProperties.FinalizeInit(); ThingSetMakerUtility.Reset(); } finally { DeepProfiler.End(); } if (Prefs.DevMode) { DeepProfiler.Start("Error check all defs."); try { foreach (Type item3 in typeof(Def).AllSubclasses()) { GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), item3, "ErrorCheckAllDefs"); } } finally { DeepProfiler.End(); } } LongEventHandler.SetCurrentEventText("Initializing".Translate()); DeepProfiler.Start("Load keyboard preferences."); try { KeyPrefs.Init(); } finally { DeepProfiler.End(); } DeepProfiler.Start("Short hash giving."); try { ShortHashGiver.GiveAllShortHashes(); } finally { DeepProfiler.End(); } LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("Load backstories."); try { BackstoryDatabase.ReloadAllBackstories(); } finally { DeepProfiler.End(); } }); LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("Inject selected language data into game data."); try { LanguageDatabase.activeLanguage.InjectIntoData_AfterImpliedDefs(); GenLabel.ClearCache(); } finally { DeepProfiler.End(); } }); LongEventHandler.ExecuteWhenFinished(delegate { DeepProfiler.Start("Static constructor calls"); try { StaticConstructorOnStartupUtility.CallAll(); if (Prefs.DevMode) { StaticConstructorOnStartupUtility.ReportProbablyMissingAttributes(); } } finally { DeepProfiler.End(); } DeepProfiler.Start("Garbage Collection"); try { AbstractFilesystem.ClearAllCache(); GC.Collect(int.MaxValue, GCCollectionMode.Forced); } finally { DeepProfiler.End(); } }); }
private void DoCustomBottomButtons() { int num = (!TutorSystem.TutorialMode) ? 5 : 4; int num2 = (num < 4 || !((float)UI.screenWidth < 1340f)) ? 1 : 2; int num3 = Mathf.CeilToInt((float)num / (float)num2); Vector2 bottomButSize = Page.BottomButSize; float num4 = bottomButSize.x * (float)num3 + 10f * (float)(num3 + 1); float num5 = num2; Vector2 bottomButSize2 = Page.BottomButSize; float num6 = num5 * bottomButSize2.y + 10f * (float)(num2 + 1); Rect rect = new Rect(((float)UI.screenWidth - num4) / 2f, (float)UI.screenHeight - num6 - 4f, num4, num6); WorldInspectPane worldInspectPane = Find.WindowStack.WindowOfType <WorldInspectPane>(); if (worldInspectPane != null && rect.x < InspectPaneUtility.PaneWidthFor(worldInspectPane) + 4f) { rect.x = InspectPaneUtility.PaneWidthFor(worldInspectPane) + 4f; } Widgets.DrawWindowBackground(rect); float num7 = rect.xMin + 10f; float num8 = rect.yMin + 10f; Text.Font = GameFont.Small; float x = num7; float y = num8; Vector2 bottomButSize3 = Page.BottomButSize; float x2 = bottomButSize3.x; Vector2 bottomButSize4 = Page.BottomButSize; float num9 = num7; Vector2 bottomButSize5 = Page.BottomButSize; num7 = num9 + (bottomButSize5.x + 10f); if (!TutorSystem.TutorialMode) { float x3 = num7; float y2 = num8; Vector2 bottomButSize6 = Page.BottomButSize; float x4 = bottomButSize6.x; Vector2 bottomButSize7 = Page.BottomButSize; if (Widgets.ButtonText(new Rect(x3, y2, x4, bottomButSize7.y), "Advanced".Translate())) { Find.WindowStack.Add(new Dialog_AdvancedGameConfig(Find.WorldInterface.SelectedTile)); } float num10 = num7; Vector2 bottomButSize8 = Page.BottomButSize; num7 = num10 + (bottomButSize8.x + 10f); } float x5 = num7; float y3 = num8; Vector2 bottomButSize9 = Page.BottomButSize; float x6 = bottomButSize9.x; Vector2 bottomButSize10 = Page.BottomButSize; if (Widgets.ButtonText(new Rect(x5, y3, x6, bottomButSize10.y), "SelectRandomSite".Translate())) { SoundDefOf.Click.PlayOneShotOnCamera(); Find.WorldInterface.SelectedTile = TileFinder.RandomStartingTile(); Find.WorldCameraDriver.JumpTo(Find.WorldGrid.GetTileCenter(Find.WorldInterface.SelectedTile)); } float num11 = num7; Vector2 bottomButSize11 = Page.BottomButSize; num7 = num11 + (bottomButSize11.x + 10f); if (num2 == 2) { num7 = rect.xMin + 10f; float num12 = num8; Vector2 bottomButSize12 = Page.BottomButSize; num8 = num12 + (bottomButSize12.y + 10f); } float x7 = num7; float y4 = num8; Vector2 bottomButSize13 = Page.BottomButSize; float x8 = bottomButSize13.x; Vector2 bottomButSize14 = Page.BottomButSize; if (Widgets.ButtonText(new Rect(x7, y4, x8, bottomButSize14.y), "WorldFactionsTab".Translate())) { Find.WindowStack.Add(new Dialog_FactionDuringLanding()); } float num13 = num7; Vector2 bottomButSize15 = Page.BottomButSize; num7 = num13 + (bottomButSize15.x + 10f); float x9 = num7; float y5 = num8; Vector2 bottomButSize16 = Page.BottomButSize; float x10 = bottomButSize16.x; Vector2 bottomButSize17 = Page.BottomButSize; if (Widgets.ButtonText(new Rect(x9, y5, x10, bottomButSize17.y), "Next".Translate())) { if (Find.WorldSelector.selectedTile < 0) { return; } StartGame(Find.WorldSelector.selectedTile); } float num14 = num7; Vector2 bottomButSize18 = Page.BottomButSize; num7 = num14 + (bottomButSize18.x + 10f); GenUI.AbsorbClicksInRect(rect); }
public override void DoWindowContents(Rect rect) { InspectPaneUtility.InspectPaneOnGUI(rect, this); }
internal void <> m__0() { CameraJumper.TryJumpAndSelect(this.target); Find.LetterStack.RemoveLetter(this.$this); InspectPaneUtility.OpenTab(typeof(ITab_Pawn_Log)); }
public static bool DrawTabs(IInspectPane pane) { if (pane.CurTabs == null) { Log.Warning("NO CURTABS"); return(false); } try { var y = pane.PaneTopY - 30f; var x = InspectPaneUtility.PaneWidthFor(pane) - Theme.InspectPaneTabWidth.Value; var width = 0f; var isSelected = false; foreach (var tab in pane.CurTabs) { if (!tab.IsVisible) { continue; } int buttonWidth; if (TabButtonWidths.ContainsKey(tab)) { buttonWidth = TabButtonWidths[tab]; } else { buttonWidth = Traverse.Create(tab).Field <int>("tabButtonWidth")?.Value ?? 0; if (buttonWidth <= 0) { buttonWidth = Theme.InspectPaneTabWidth.Value; } TabButtonWidths[tab] = buttonWidth; } var rect = new Rect(x, y, buttonWidth, 30f); width = x; Text.Font = GameFont.Small; if (Widgets.ButtonText(rect, tab.labelKey.Translate())) { InterfaceToggleTab(tab, pane); } var isOpenTab = tab.GetType() == pane.OpenTabType; if (!isOpenTab && !tab.TutorHighlightTagClosed.NullOrEmpty()) { UIHighlighter.HighlightOpportunity(rect, tab.TutorHighlightTagClosed); } if (isOpenTab) { tab.DoTabGUI(); pane.RecentHeight = 700f; isSelected = true; } x -= Theme.InspectPaneTabWidth.Value; } if (!isSelected) { return(false); } GUI.DrawTexture(new Rect(0f, y, width, 30f), Textures.InspectTabButtonFill); } catch (Exception exception) { Mod.HandleError(exception); } return(false); }