This commit is contained in:
Tyfon
2024-07-14 21:33:58 -07:00
parent 82025fee41
commit a295795198
6 changed files with 25 additions and 19 deletions

View File

@@ -15,7 +15,9 @@ global using Scheme = GClass1939;
global using ItemFilterExtensions = GClass2524;
global using QuickBindCommandMap = GClass3032;
global using DiscardResult = GClass2799;
global using BindOperation = GClass2818;
global using ItemSorter = GClass2772;
global using ItemWithLocation = GClass2521;
global using SearchableGrid = GClass2516;
// State machine states
global using FirearmReadyState = EFT.Player.FirearmController.GClass1619;
@@ -32,13 +34,17 @@ global using GridSpaceTakenError = StashGridClass.GClass3311;
global using GridModificationsUnavailableError = StashGridClass.GClass3315;
global using NoRoomError = GClass3316;
global using NoPossibleActionsError = GClass3317;
global using CannotSortError = GClass3325;
global using FailedToSortError = GClass3326;
global using MoveSameSpaceError = InteractionsHandlerClass.GClass3353;
// Operations
global using ItemOperation = GStruct413;
global using MoveOperation = GClass2802;
global using NoOpMove = GClass2795;
global using BindOperation = GClass2818;
global using SortOperation = GClass2824;
global using TargetItemOperation = TraderControllerClass.Struct775;
// Interfaces
global using IApplicable = GInterface321;
global using IApplicable = GInterface321;

View File

@@ -251,7 +251,7 @@ public class MultiSelect
if (draggedItemView != null && Count > 1)
{
GameObject textOverlay = new("MultiSelectText", [typeof(RectTransform), typeof(TextMeshProUGUI)]);
textOverlay.transform.parent = draggedItemView.transform;
textOverlay.transform.SetParent(draggedItemView.transform, false);
textOverlay.transform.SetAsLastSibling();
textOverlay.SetActive(true);

View File

@@ -117,7 +117,7 @@ public static class ContextMenuShortcutPatches
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(HideoutItemView), nameof(HideoutItemView.OnPointerEnter));
return AccessTools.DeclaredMethod(typeof(HideoutItemView), nameof(HideoutItemView.OnPointerEnter));
}
[PatchPostfix]

View File

@@ -38,7 +38,7 @@ public static class FilterOutOfStockPatches
public static void Postfix(TraderDealScreen __instance, DefaultUIButton ____updateAssort, TradingGridView ____traderGridView)
{
OutOfStockPanel = new GameObject("OutOfStockPanel", [typeof(RectTransform)]);
OutOfStockPanel.transform.parent = __instance.transform.Find("Left Person/Possessions Grid");
OutOfStockPanel.transform.SetParent(__instance.transform.Find("Left Person/Possessions Grid"), false);
OutOfStockPanel.transform.SetAsLastSibling();
OutOfStockPanel.SetActive(true);

View File

@@ -32,7 +32,7 @@ public static class SortPatches
}
[PatchPrefix]
public static bool Prefix(LootItemClass sortingItem, InventoryControllerClass controller, bool simulate, ref GStruct414<GClass2824> __result)
public static bool Prefix(LootItemClass sortingItem, InventoryControllerClass controller, bool simulate, ref GStruct414<SortOperation> __result)
{
__result = Sorter.Sort(sortingItem, controller, IncludeContainers, simulate);
return false;
@@ -86,7 +86,7 @@ public static class SortPatches
if (error == null)
{
GStruct414<GClass2824> sortOperation = InteractionsHandlerClass.Sort(lootItem, inventoryController, false);
var sortOperation = InteractionsHandlerClass.Sort(lootItem, inventoryController, false);
if (sortOperation.Succeeded)
{
IResult result = await inventoryController.TryRunNetworkTransaction(sortOperation);
@@ -109,7 +109,6 @@ public static class SortPatches
private static async Task<Error> StackAll(LootItemClass lootItem, InventoryControllerClass inventoryController)
{
Error error = null;
List<GStruct414<GInterface343>> transferOrMergeOperations = [];
var mergeableItems = lootItem.Grids.SelectMany(g => g.Items)
.OfType<Stackable>()
.Where(i => i.StackObjectsCount < i.StackMaxSize)
@@ -123,7 +122,7 @@ public static class SortPatches
continue;
}
if (InteractionsHandlerClass.smethod_0(lootItem.Grids, item, out GClass2751 targetItem, 1))
if (InteractionsHandlerClass.smethod_0(lootItem.Grids, item, out Stackable targetItem, 1))
{
var operation = InteractionsHandlerClass.TransferOrMerge(item, targetItem, inventoryController, true);
if (operation.Succeeded)

View File

@@ -1,17 +1,18 @@
using System.Collections.Generic;
using System.Linq;
using EFT.InventoryLogic;
using UnityEngine;
namespace UIFixes;
public static class Sorter
{
public static GStruct414<GClass2824> Sort(LootItemClass sortingItem, InventoryControllerClass controller, bool includingContainers, bool simulate)
public static GStruct414<SortOperation> Sort(LootItemClass sortingItem, InventoryControllerClass controller, bool includingContainers, bool simulate)
{
GClass2824 operation = new(sortingItem, controller);
SortOperation operation = new(sortingItem, controller);
if (!operation.CanExecute(controller))
{
return new GClass3325(sortingItem);
return new CannotSortError(sortingItem);
}
List<Item> itemsToSort = [];
@@ -19,7 +20,7 @@ public static class Sorter
{
operation.SetOldPositions(grid, grid.ItemCollection.ToListOfLocations());
itemsToSort.AddRange(includingContainers ? grid.Items : grid.Items.Where(i => i is not LootItemClass compoundItem || !compoundItem.Grids.Any()));
var containers = includingContainers ? [] : grid.ItemCollection.Where(kvp => kvp.Key is LootItemClass compoundItem && compoundItem.Grids.Any()).Select(kvp => new GClass2521(kvp.Key, kvp.Value)).ToArray();
var containers = includingContainers ? [] : grid.ItemCollection.Where(kvp => kvp.Key is LootItemClass compoundItem && compoundItem.Grids.Any()).Select(kvp => new ItemWithLocation(kvp.Key, kvp.Value)).ToArray();
grid.RemoveAll();
controller.RaiseEvent(new GEventArgs23(grid));
@@ -31,7 +32,7 @@ public static class Sorter
}
}
List<Item> sortedItems = GClass2772.Sort(itemsToSort);
List<Item> sortedItems = ItemSorter.Sort(itemsToSort);
int fallbackTries = 5;
InventoryError inventoryError = null;
@@ -46,7 +47,7 @@ public static class Sorter
if (grid.Add(item).Succeeded)
{
sorted = true;
operation.AddItemToGrid(grid, new GClass2521(item, ((GridItemAddress)item.CurrentAddress).LocationInGrid));
operation.AddItemToGrid(grid, new ItemWithLocation(item, ((GridItemAddress)item.CurrentAddress).LocationInGrid));
break;
}
}
@@ -64,7 +65,7 @@ public static class Sorter
if (stashGridClass3 != null && !stashGridClass3.Add(item).Failed)
{
sorted = true;
operation.AddItemToGrid(stashGridClass3, new GClass2521(item, ((ItemAddressClass)item.CurrentAddress).LocationInGrid));
operation.AddItemToGrid(stashGridClass3, new ItemWithLocation(item, ((GridItemAddress)item.CurrentAddress).LocationInGrid));
}
}
}
@@ -78,7 +79,7 @@ public static class Sorter
continue;
}
inventoryError = new GClass3326(sortingItem);
inventoryError = new FailedToSortError(sortingItem);
break;
}
}
@@ -97,9 +98,9 @@ public static class Sorter
foreach (StashGridClass grid in sortingItem.Grids)
{
if (grid.ItemCollection.Any<KeyValuePair<Item, LocationInGrid>>() && grid is GClass2516 searchable)
if (grid.ItemCollection.Any<KeyValuePair<Item, LocationInGrid>>() && grid is SearchableGrid searchableGrid)
{
searchable.FindAll(controller.Profile.ProfileId);
searchableGrid.FindAll(controller.Profile.ProfileId);
}
}