public static bool Prefix(InventoryGui __instance) { if (!__instance.m_inventoryGroup.IsActive()) { return(false); } if (ZInput.GetButtonDown("JoyTabLeft")) { __instance.SetActiveGroup(__instance.m_activeGroup - 1); } if (ZInput.GetButtonDown("JoyTabRight")) { __instance.SetActiveGroup(__instance.m_activeGroup + 1); } if (__instance.m_activeGroup == 0 && !__instance.IsContainerOpen()) { __instance.SetActiveGroup(1); } if (__instance.m_activeGroup == __instance.m_uiGroups.Length - 1) { __instance.UpdateRecipeGamepadInput(); } return(false); }
static void Postfix(InventoryGui __instance, Container ___m_currentContainer, int ___m_activeGroup) { Vector3 mousePos = Input.mousePosition; if (!modEnabled.Value) { return; } if (AedenthornUtils.CheckKeyHeld(ascModKey.Value, false) || AedenthornUtils.CheckKeyHeld(descModKey.Value, false)) { bool asc = AedenthornUtils.CheckKeyHeld(ascModKey.Value, false); if (AedenthornUtils.CheckKeyHeld(descModKey.Value, true)) { asc = false; } string name = ""; SortType type = SortType.Name; PointerEventData eventData = new PointerEventData(EventSystem.current) { position = mousePos }; List <RaycastResult> raycastResults = new List <RaycastResult>(); EventSystem.current.RaycastAll(eventData, raycastResults); foreach (RaycastResult rcr in raycastResults) { if (rcr.gameObject.layer == LayerMask.NameToLayer("UI") && rcr.gameObject.name == "Bkg" && (rcr.gameObject.transform.parent.name == "Player" || rcr.gameObject.transform.parent.name == "Container")) { if (AedenthornUtils.CheckKeyDown(sortByNameKey.Value)) { name = rcr.gameObject.transform.parent.name; type = SortType.Name; break; } else if (AedenthornUtils.CheckKeyDown(sortByWeightKey.Value)) { name = rcr.gameObject.transform.parent.name; type = SortType.Weight; break; } else if (AedenthornUtils.CheckKeyDown(sortByValueKey.Value)) { name = rcr.gameObject.transform.parent.name; type = SortType.Value; break; } return; } } if (name == "" && useGamePad.Value) { if (___m_activeGroup == 0 && !__instance.IsContainerOpen()) { return; } if (___m_activeGroup == 0 || ___m_activeGroup == 1) { if (AedenthornUtils.CheckKeyDown(sortByNameKey.Value)) { name = ___m_activeGroup == 0 ? "Container" : "Player"; type = SortType.Name; } else if (AedenthornUtils.CheckKeyDown(sortByWeightKey.Value)) { name = ___m_activeGroup == 0 ? "Container" : "Player"; type = SortType.Weight; } else if (AedenthornUtils.CheckKeyDown(sortByValueKey.Value)) { name = ___m_activeGroup == 0 ? "Container" : "Player"; type = SortType.Value; } } } if (name == "" || (name == "Player" && !allowPlayerInventorySort.Value)) { return; } Dbgl($"Sorting {name} inventory by {type} {(asc ? "asc" : "desc")}"); if (name == "Player") { playerSortType.Value = type; playerSortAsc.Value = asc; context.Config.Save(); SortByType(type, Player.m_localPlayer.GetInventory(), asc, true); } else if (name == "Container") { containerSortType.Value = type; containerSortAsc.Value = asc; context.Config.Save(); SortByType(type, ___m_currentContainer.GetInventory(), asc, false); } } }