public static void DrawInspectGizmoGridFor(IEnumerable <object> selectedObjects, out Gizmo mouseoverGizmo) { mouseoverGizmo = null; try { objList.Clear(); objList.AddRange(selectedObjects); gizmoList.Clear(); for (int i = 0; i < objList.Count; i++) { ISelectable selectable = objList[i] as ISelectable; if (selectable != null) { gizmoList.AddRange(selectable.GetGizmos()); } } for (int j = 0; j < objList.Count; j++) { Thing t = objList[j] as Thing; if (t == null) { continue; } List <Designator> allDesignators = Find.ReverseDesignatorDatabase.AllDesignators; for (int k = 0; k < allDesignators.Count; k++) { Designator des = allDesignators[k]; if (!des.CanDesignateThing(t).Accepted) { continue; } Command_Action command_Action = new Command_Action(); command_Action.defaultLabel = des.LabelCapReverseDesignating(t); command_Action.icon = des.IconReverseDesignating(t, out var angle, out var offset); command_Action.iconAngle = angle; command_Action.iconOffset = offset; command_Action.defaultDesc = des.DescReverseDesignating(t); command_Action.order = ((des is Designator_Uninstall) ? (-11f) : (-20f)); command_Action.action = delegate { if (TutorSystem.AllowAction(des.TutorTagDesignate)) { des.DesignateThing(t); des.Finalize(somethingSucceeded: true); } }; command_Action.hotKey = des.hotKey; command_Action.groupKey = des.groupKey; gizmoList.Add(command_Action); } } objList.Clear(); GizmoGridDrawer.DrawGizmoGrid(gizmoList, InspectPaneUtility.PaneWidthFor(Find.WindowStack.WindowOfType <IInspectPane>()) + GizmoGridDrawer.GizmoSpacing.y, out mouseoverGizmo); gizmoList.Clear(); } catch (Exception ex) { Log.ErrorOnce(ex.ToString(), 3427734); } }
public static void DrawInspectGizmoGridFor(IEnumerable <object> selectedObjects, out Gizmo mouseoverGizmo) { mouseoverGizmo = null; try { InspectGizmoGrid.objList.Clear(); InspectGizmoGrid.objList.AddRange(selectedObjects); InspectGizmoGrid.gizmoList.Clear(); for (int i = 0; i < InspectGizmoGrid.objList.Count; i++) { ISelectable selectable = InspectGizmoGrid.objList[i] as ISelectable; if (selectable != null) { InspectGizmoGrid.gizmoList.AddRange(selectable.GetGizmos()); } } for (int j = 0; j < InspectGizmoGrid.objList.Count; j++) { Thing t = InspectGizmoGrid.objList[j] as Thing; if (t != null) { List <Designator> allDesignators = Find.ReverseDesignatorDatabase.AllDesignators; for (int k = 0; k < allDesignators.Count; k++) { Designator des = allDesignators[k]; if (des.CanDesignateThing(t).Accepted) { Command_Action command_Action = new Command_Action(); command_Action.defaultLabel = des.LabelCapReverseDesignating(t); float iconAngle; Vector2 iconOffset; command_Action.icon = des.IconReverseDesignating(t, out iconAngle, out iconOffset); command_Action.iconAngle = iconAngle; command_Action.iconOffset = iconOffset; command_Action.defaultDesc = des.DescReverseDesignating(t); command_Action.order = ((!(des is Designator_Uninstall)) ? -20f : -11f); command_Action.action = delegate() { if (TutorSystem.AllowAction(des.TutorTagDesignate)) { des.DesignateThing(t); des.Finalize(true); } }; command_Action.hotKey = des.hotKey; command_Action.groupKey = des.groupKey; InspectGizmoGrid.gizmoList.Add(command_Action); } } } } InspectGizmoGrid.objList.Clear(); GizmoGridDrawer.DrawGizmoGrid(InspectGizmoGrid.gizmoList, InspectPaneUtility.PaneWidthFor(Find.WindowStack.WindowOfType <IInspectPane>()) + 20f, out mouseoverGizmo); InspectGizmoGrid.gizmoList.Clear(); } catch (Exception ex) { Log.ErrorOnce(ex.ToString(), 3427734, false); } }
public static void DrawInspectGizmoGridFor(IEnumerable <object> selectedObjects) { try { InspectGizmoGrid.objList.Clear(); InspectGizmoGrid.objList.AddRange(selectedObjects); InspectGizmoGrid.gizmoList.Clear(); for (int i = 0; i < InspectGizmoGrid.objList.Count; i++) { ISelectable selectable = InspectGizmoGrid.objList[i] as ISelectable; if (selectable != null) { foreach (Gizmo current in selectable.GetGizmos()) { InspectGizmoGrid.gizmoList.Add(current); } } } for (int j = 0; j < InspectGizmoGrid.objList.Count; j++) { Thing t = InspectGizmoGrid.objList[j] as Thing; if (t != null) { List <Designator> allDesignators = ReverseDesignatorDatabase.AllDesignators; for (int k = 0; k < allDesignators.Count; k++) { Designator des = allDesignators[k]; if (des.CanDesignateThing(t).Accepted) { Command_Action command_Action = new Command_Action(); command_Action.defaultLabel = des.LabelCapReverseDesignating(t); command_Action.icon = des.IconReverseDesignating(t); command_Action.defaultDesc = des.DescReverseDesignating(t); command_Action.action = delegate { des.DesignateThing(t); des.Finalize(true); }; command_Action.hotKey = des.hotKey; command_Action.groupKey = des.groupKey; InspectGizmoGrid.gizmoList.Add(command_Action); } } } } Gizmo gizmo; GizmoGridDrawer.DrawGizmoGrid(InspectGizmoGrid.gizmoList, RimWorld.MainTabWindow_Inspect.PaneSize.x + 20f, out gizmo); } catch (Exception ex) { Log.ErrorOnce(ex.ToString(), 3427734); } }
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(); } }