adjust multiselect clickable detection; make modify equipped weapons not advanced

This commit is contained in:
Tyfon
2024-09-15 17:12:47 -07:00
parent f3062b2d40
commit 9295d85b13
3 changed files with 30 additions and 14 deletions

View File

@@ -188,24 +188,40 @@ public class DrawMultiSelect : MonoBehaviour
};
List<RaycastResult> results = [];
preloaderRaycaster.Raycast(eventData, results); // preload objects are on top, so check that first
localRaycaster.Raycast(eventData, results);
preloaderRaycaster.Raycast(eventData, results);
foreach (GameObject gameObject in results.Select(r => r.gameObject))
GameObject gameObject = results.FirstOrDefault().gameObject;
if (gameObject == null)
{
var draggables = gameObject.GetComponents<MonoBehaviour>()
return false;
}
var draggables = gameObject.GetComponentsInParent<MonoBehaviour>()
.Where(c => c is IDragHandler || c is IBeginDragHandler || c is TextMeshProUGUI) // tmp_inputfield is draggable, but textmesh isn't so explicitly include
.Where(c => c is not ScrollRectNoDrag) // this disables scrolling, it doesn't add it
.Where(c => c.name != "Inner"); // there's a random DragTrigger sitting in ItemInfoWindows
var clickables = gameObject.GetComponents<MonoBehaviour>()
.Where(c => c is IPointerClickHandler || c is IPointerDownHandler || c is IPointerUpHandler);
var clickables = gameObject.GetComponentsInParent<MonoBehaviour>()
.Where(c => c is IPointerClickHandler || c is IPointerDownHandler || c is IPointerUpHandler)
.Where(c => c is not EmptySlotMenuTrigger); // ignore empty slots that are right-clickable due to UIFixes
// Windows are clickable to focus them, but that shouldn't block selection
var windows = clickables
.Where(c => c is UIInputNode) // Windows<>'s parent, cheap check
.Where(c =>
{
// Most window types implement IPointerClickHandler and inherit directly from Window<>
Type baseType = c.GetType().BaseType;
return baseType != null && baseType.IsGenericType && baseType.GetGenericTypeDefinition() == typeof(Window<>);
});
clickables = clickables.Except(windows);
if (draggables.Any() || clickables.Any())
{
return true;
}
}
return false;
}

View File

@@ -146,7 +146,7 @@ public static class SwapPatches
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(ItemView), nameof(ItemView.OnDrag));
return AccessTools.Method(typeof(ItemView), nameof(ItemView.OnBeginDrag));
}
[PatchPrefix]

View File

@@ -123,7 +123,7 @@ internal class Settings
public static ConfigEntry<bool> AlwaysSwapMags { get; set; }
public static ConfigEntry<bool> UnloadAmmoBoxInPlace { get; set; } // Advanced
public static ConfigEntry<bool> SwapImpossibleContainers { get; set; }
public static ConfigEntry<bool> ModifyEquippedWeapons { get; set; } // Advanced
public static ConfigEntry<bool> ModifyEquippedWeapons { get; set; }
public static ConfigEntry<ModRaidWeapon> ModifyRaidWeapons { get; set; }
public static ConfigEntry<bool> ReorderGrids { get; set; }
public static ConfigEntry<bool> PrioritizeSmallerGrids { get; set; }
@@ -609,7 +609,7 @@ internal class Settings
new ConfigDescription(
"Enable the modification of equipped weapons, including vital parts, out of raid",
null,
new ConfigurationManagerAttributes { IsAdvanced = true })));
new ConfigurationManagerAttributes { })));
configEntries.Add(ModifyRaidWeapons = config.Bind(
InventorySection,