old sorting table button; fix auto-sorting table open on scav screen
This commit is contained in:
23
.vscode/tasks.json
vendored
Normal file
23
.vscode/tasks.json
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"type": "dotnet",
|
||||||
|
"task": "build",
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"problemMatcher": [],
|
||||||
|
"label": "dotnet: build",
|
||||||
|
"presentation": {
|
||||||
|
"echo": true,
|
||||||
|
"reveal": "always",
|
||||||
|
"focus": false,
|
||||||
|
"panel": "shared",
|
||||||
|
"showReuseMessage": false,
|
||||||
|
"clear": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
90
Patches/MoveSortingTablePatches.cs
Normal file
90
Patches/MoveSortingTablePatches.cs
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
using Comfort.Common;
|
||||||
|
using EFT.UI;
|
||||||
|
using HarmonyLib;
|
||||||
|
using SPT.Reflection.Patching;
|
||||||
|
using System.Reflection;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace UIFixes;
|
||||||
|
|
||||||
|
public static class MoveSortingTablePatches
|
||||||
|
{
|
||||||
|
private static Transform SelectedBackground;
|
||||||
|
|
||||||
|
public static void Enable()
|
||||||
|
{
|
||||||
|
new ButtonsPatch().Enable();
|
||||||
|
new ToggleBackgroundPatch().Enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ButtonsPatch : ModulePatch
|
||||||
|
{
|
||||||
|
private static Tab OldSortingTableTab;
|
||||||
|
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
return AccessTools.Method(typeof(SimpleStashPanel), nameof(SimpleStashPanel.Show));
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPostfix]
|
||||||
|
public static void Postfix(SimpleStashPanel __instance, ItemUiContext ___itemUiContext_0, Tab ____sortingTableTab, LootItemClass ___lootItemClass)
|
||||||
|
{
|
||||||
|
if (Settings.SortingTableButton.Value == SortingTableDisplay.New || ____sortingTableTab == null || ___itemUiContext_0.ContextType != EItemUiContextType.InventoryScreen)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (___lootItemClass.Parent.GetOwner() is not InventoryControllerClass inventoryController)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OldSortingTableTab == null)
|
||||||
|
{
|
||||||
|
Transform scavScreenSortingTableButton = Singleton<CommonUI>.Instance.transform.Find("Common UI/Scavenger Inventory Screen/Items Panel/Stash Panel/Simple Panel/Sorting Panel/SortTableButton");
|
||||||
|
OldSortingTableTab = UnityEngine.Object.Instantiate(scavScreenSortingTableButton.GetComponent<Tab>(), ____sortingTableTab.transform.parent, false);
|
||||||
|
OldSortingTableTab.transform.SetAsFirstSibling();
|
||||||
|
|
||||||
|
OldSortingTableTab.OnSelectionChanged += __instance.method_1;
|
||||||
|
|
||||||
|
SelectedBackground = OldSortingTableTab.transform.Find("Selected");
|
||||||
|
if (!inventoryController.SortingTableActive)
|
||||||
|
{
|
||||||
|
SelectedBackground.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
__instance.R().UI.AddDisposable(() =>
|
||||||
|
{
|
||||||
|
OldSortingTableTab.OnSelectionChanged -= __instance.method_1;
|
||||||
|
UnityEngine.Object.Destroy(OldSortingTableTab.gameObject);
|
||||||
|
OldSortingTableTab = null;
|
||||||
|
SelectedBackground = null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
OldSortingTableTab.gameObject.SetActive(____sortingTableTab.isActiveAndEnabled);
|
||||||
|
|
||||||
|
if (Settings.SortingTableButton.Value == SortingTableDisplay.Old)
|
||||||
|
{
|
||||||
|
____sortingTableTab.gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ToggleBackgroundPatch : ModulePatch
|
||||||
|
{
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
return AccessTools.Method(typeof(SimpleStashPanel), nameof(SimpleStashPanel.ChangeSortingTableTabState));
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPostfix]
|
||||||
|
public static void Postfix(bool isVisible)
|
||||||
|
{
|
||||||
|
if (SelectedBackground?.gameObject != null)
|
||||||
|
{
|
||||||
|
SelectedBackground.gameObject.SetActive(isVisible);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -323,7 +323,7 @@ namespace UIFixes
|
|||||||
if (__instance.Profile == PatchConstants.BackEndSession.Profile)
|
if (__instance.Profile == PatchConstants.BackEndSession.Profile)
|
||||||
{
|
{
|
||||||
MultiSelect.StopLoading();
|
MultiSelect.StopLoading();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,7 +35,16 @@ namespace UIFixes
|
|||||||
SortingTableClass sortingTable = __instance.R().InventoryController.Inventory.SortingTable;
|
SortingTableClass sortingTable = __instance.R().InventoryController.Inventory.SortingTable;
|
||||||
if (sortingTable != null && !sortingTable.IsVisible)
|
if (sortingTable != null && !sortingTable.IsVisible)
|
||||||
{
|
{
|
||||||
Singleton<CommonUI>.Instance.InventoryScreen.method_6();
|
if (__instance.ContextType == EItemUiContextType.InventoryScreen)
|
||||||
|
{
|
||||||
|
Singleton<CommonUI>.Instance.InventoryScreen.method_6();
|
||||||
|
Singleton<CommonUI>.Instance.InventoryScreen.R().SimpleStashPanel.ChangeSortingTableTabState(true);
|
||||||
|
}
|
||||||
|
else if (__instance.ContextType == EItemUiContextType.ScavengerInventoryScreen)
|
||||||
|
{
|
||||||
|
Singleton<CommonUI>.Instance.ScavengerInventoryScreen.method_7();
|
||||||
|
Singleton<CommonUI>.Instance.ScavengerInventoryScreen.R().SimpleStashPanel.ChangeSortingTableTabState(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -62,6 +62,7 @@ namespace UIFixes
|
|||||||
NoRandomGrenadesPatch.Init();
|
NoRandomGrenadesPatch.Init();
|
||||||
GPCoinPatches.Enable();
|
GPCoinPatches.Enable();
|
||||||
FleaSlotSearchPatches.Enable();
|
FleaSlotSearchPatches.Enable();
|
||||||
|
MoveSortingTablePatches.Enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool InRaid()
|
public static bool InRaid()
|
||||||
|
34
R.cs
34
R.cs
@@ -63,6 +63,8 @@ namespace UIFixes
|
|||||||
InventoryInteractions.InitTypes();
|
InventoryInteractions.InitTypes();
|
||||||
TradingInteractions.InitTypes();
|
TradingInteractions.InitTypes();
|
||||||
TransferInteractions.InitTypes();
|
TransferInteractions.InitTypes();
|
||||||
|
InventoryScreen.InitTypes();
|
||||||
|
ScavengerInventoryScreen.InitTypes();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract class Wrapper(object value)
|
public abstract class Wrapper(object value)
|
||||||
@@ -781,7 +783,7 @@ namespace UIFixes
|
|||||||
ItemField = AccessTools.Field(Type, "item_0");
|
ItemField = AccessTools.Field(Type, "item_0");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Item Item { get { return (Item) ItemField.GetValue(Value); } }
|
public Item Item { get { return (Item)ItemField.GetValue(Value); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TransferInteractions(object value) : Wrapper(value)
|
public class TransferInteractions(object value) : Wrapper(value)
|
||||||
@@ -817,6 +819,34 @@ namespace UIFixes
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class InventoryScreen(object value) : UIInputNode(value)
|
||||||
|
{
|
||||||
|
public static Type Type { get; private set; }
|
||||||
|
private static FieldInfo SimpleStashPanelField;
|
||||||
|
|
||||||
|
public static void InitTypes()
|
||||||
|
{
|
||||||
|
Type = typeof(EFT.UI.InventoryScreen);
|
||||||
|
SimpleStashPanelField = AccessTools.Field(Type, "_simpleStashPanel");
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleStashPanel SimpleStashPanel { get { return (SimpleStashPanel)SimpleStashPanelField.GetValue(Value); } }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ScavengerInventoryScreen(object value) : UIInputNode(value)
|
||||||
|
{
|
||||||
|
public static Type Type { get; private set; }
|
||||||
|
private static FieldInfo SimpleStashPanelField;
|
||||||
|
|
||||||
|
public static void InitTypes()
|
||||||
|
{
|
||||||
|
Type = typeof(EFT.UI.ScavengerInventoryScreen);
|
||||||
|
SimpleStashPanelField = AccessTools.Field(Type, "_simpleStashPanel");
|
||||||
|
}
|
||||||
|
|
||||||
|
public SimpleStashPanel SimpleStashPanel { get { return (SimpleStashPanel)SimpleStashPanelField.GetValue(Value); } }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RExtentensions
|
public static class RExtentensions
|
||||||
@@ -845,5 +875,7 @@ namespace UIFixes
|
|||||||
public static R.MessageWindow R(this MessageWindow value) => new(value);
|
public static R.MessageWindow R(this MessageWindow value) => new(value);
|
||||||
public static R.RagfairNewOfferItemView R(this RagfairNewOfferItemView value) => new(value);
|
public static R.RagfairNewOfferItemView R(this RagfairNewOfferItemView value) => new(value);
|
||||||
public static R.TradingTableGridView R(this TradingTableGridView value) => new(value);
|
public static R.TradingTableGridView R(this TradingTableGridView value) => new(value);
|
||||||
|
public static R.InventoryScreen R(this InventoryScreen value) => new(value);
|
||||||
|
public static R.ScavengerInventoryScreen R(this ScavengerInventoryScreen value) => new(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
19
Settings.cs
19
Settings.cs
@@ -30,6 +30,13 @@ namespace UIFixes
|
|||||||
OriginalSpacing
|
OriginalSpacing
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal enum SortingTableDisplay
|
||||||
|
{
|
||||||
|
New,
|
||||||
|
Old,
|
||||||
|
Both
|
||||||
|
}
|
||||||
|
|
||||||
internal class Settings
|
internal class Settings
|
||||||
{
|
{
|
||||||
// Categories
|
// Categories
|
||||||
@@ -85,6 +92,7 @@ namespace UIFixes
|
|||||||
public static ConfigEntry<bool> AutoOpenSortingTable { get; set; }
|
public static ConfigEntry<bool> AutoOpenSortingTable { get; set; }
|
||||||
public static ConfigEntry<bool> ContextMenuOnRight { get; set; }
|
public static ConfigEntry<bool> ContextMenuOnRight { get; set; }
|
||||||
public static ConfigEntry<bool> ShowGPCurrency { get; set; }
|
public static ConfigEntry<bool> ShowGPCurrency { get; set; }
|
||||||
|
public static ConfigEntry<SortingTableDisplay> SortingTableButton { get; set; }
|
||||||
public static ConfigEntry<bool> LoadMagPresetOnBullets { get; set; } // Advanced
|
public static ConfigEntry<bool> LoadMagPresetOnBullets { get; set; } // Advanced
|
||||||
|
|
||||||
// Inspect Panels
|
// Inspect Panels
|
||||||
@@ -479,6 +487,15 @@ namespace UIFixes
|
|||||||
null,
|
null,
|
||||||
new ConfigurationManagerAttributes { })));
|
new ConfigurationManagerAttributes { })));
|
||||||
|
|
||||||
|
configEntries.Add(SortingTableButton = config.Bind(
|
||||||
|
InventorySection,
|
||||||
|
"Sorting Table Button",
|
||||||
|
SortingTableDisplay.New,
|
||||||
|
new ConfigDescription(
|
||||||
|
"What position to show the sorting table button",
|
||||||
|
null,
|
||||||
|
new ConfigurationManagerAttributes { })));
|
||||||
|
|
||||||
configEntries.Add(LoadMagPresetOnBullets = config.Bind(
|
configEntries.Add(LoadMagPresetOnBullets = config.Bind(
|
||||||
InventorySection,
|
InventorySection,
|
||||||
"Mag Presets Context Menu on Bullets",
|
"Mag Presets Context Menu on Bullets",
|
||||||
@@ -709,7 +726,7 @@ namespace UIFixes
|
|||||||
if (allowSecondaryToDisablePrimary)
|
if (allowSecondaryToDisablePrimary)
|
||||||
{
|
{
|
||||||
priorityConfig.Value = false;
|
priorityConfig.Value = false;
|
||||||
}
|
}
|
||||||
else if (priorityConfig.Value)
|
else if (priorityConfig.Value)
|
||||||
{
|
{
|
||||||
secondaryConfig.Value = false;
|
secondaryConfig.Value = false;
|
||||||
|
Reference in New Issue
Block a user