/// <summary> /// Shows the mod actions popup. /// </summary> /// <param name="button">The options button which invoked this popup.</param> /// <param name="index">The mod index in the list that is showing the popup.</param> private void ShowPopup(KButton button, int index) { var mods = Global.Instance.modManager?.mods; int n; if (mods != null && index >= 0 && index < (n = mods.Count)) { var mod = mods[index]; bool isSteam = mod.label.distribution_platform == Label.DistributionPlatform. Steam; RectTransform rt = actionsScreen.rectTransform(), crt = button.rectTransform(); actionsScreen.Index = index; actionsScreen.Mod = mod; // Update usability of each button if (buttonFirst != null) { buttonFirst.isInteractable = index > 0; } if (buttonUp != null) { buttonUp.isInteractable = index > 0; } if (buttonDown != null) { buttonDown.isInteractable = index < n - 1; } if (buttonLast != null) { buttonLast.isInteractable = index < n - 1; } if (buttonUnsub != null) { buttonUnsub.isInteractable = isSteam; } if (buttonManage != null) { PUIElements.SetToolTip(buttonManage, isSteam ? UI.MODSSCREEN. BUTTON_SUBSCRIPTION : UI.MODSSCREEN.BUTTON_LOCAL); PUIElements.SetToolTip(buttonManage, mod.manage_tooltip); } if (buttonModify != null) { buttonModify.isInteractable = isSteam; } actionsScreen.SetActive(true); // Resize to the proper size LayoutRebuilder.ForceRebuildLayoutImmediate(rt); float w = LayoutUtility.GetPreferredWidth(rt), h = LayoutUtility. GetPreferredHeight(rt) * 0.5f, end = crt.offsetMin.x - 1.0f; rt.SetParent(crt.parent, false); rt.SetAsLastSibling(); // Move it to the correct place rt.anchoredPosition = Vector2.zero; rt.anchorMin = DebugUtils.ANCHOR_MID_LEFT; rt.anchorMax = DebugUtils.ANCHOR_MID_LEFT; rt.offsetMin = new Vector2(end - w, -h); rt.offsetMax = new Vector2(end, h); callingButton = button; } }