/// <summary> /// Adds buttons to a mod entry to move the mod around. /// </summary> /// <param name="displayedMod">The mod entry to modify.</param> /// <param name="instance">The Mods screen that is the parent of these entries.</param> internal static void ConfigureRowInstance(object displayedMod, ModsScreen instance) { if (displayedMod == null) { throw new ArgumentNullException(nameof(displayedMod)); } var type = displayedMod.GetType(); if (!PPatchTools.TryGetFieldValue(displayedMod, "mod_index", out int index)) { throw new ArgumentException("Unable to get mod index"); } if (!PPatchTools.TryGetFieldValue(displayedMod, "rect_transform", out Transform transform)) { throw new ArgumentException("Unable to get rect transform"); } var refs = transform.gameObject.GetComponentSafe <HierarchyReferences>(); KButton button; // "More mod actions" if (refs != null && (button = refs.GetReference <KButton>(REF_MORE)) != null) { var onAction = new ModActionDelegates(button, index, instance.gameObject); button.onClick += onAction.TogglePopup; button.gameObject.AddOrGet <ToolTip>().OnToolTip = onAction.GetDescription; } }