Dont show left/right buttons on containers 2 cells wide or smaller
This commit is contained in:
@@ -18,7 +18,8 @@ namespace UIFixes
|
|||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
public static void Postfix(GridWindow __instance)
|
public static void Postfix(GridWindow __instance)
|
||||||
{
|
{
|
||||||
if (Settings.AddContainerButtons.Value)
|
var wrappedInstance = __instance.R();
|
||||||
|
if (Settings.AddContainerButtons.Value && wrappedInstance.LootItem.Int32_0 > 2) // Greater than 2 cells wide
|
||||||
{
|
{
|
||||||
Transform closeButton = __instance.transform.Find("Caption Panel/Close Button");
|
Transform closeButton = __instance.transform.Find("Caption Panel/Close Button");
|
||||||
Image sortBackground = __instance.transform.Find("Caption Panel/Sort Button")?.GetComponent<Image>();
|
Image sortBackground = __instance.transform.Find("Caption Panel/Sort Button")?.GetComponent<Image>();
|
||||||
@@ -26,13 +27,13 @@ namespace UIFixes
|
|||||||
// Left button
|
// Left button
|
||||||
Button leftButton = CreateButton(closeButton, sortBackground.sprite, EItemAttributeId.RecoilBack);
|
Button leftButton = CreateButton(closeButton, sortBackground.sprite, EItemAttributeId.RecoilBack);
|
||||||
leftButton.onClick.AddListener(() => SnapLeft(__instance));
|
leftButton.onClick.AddListener(() => SnapLeft(__instance));
|
||||||
__instance.R().UI.AddDisposable(() => leftButton.onClick.RemoveAllListeners());
|
wrappedInstance.UI.AddDisposable(() => leftButton.onClick.RemoveAllListeners());
|
||||||
|
|
||||||
// Right button
|
// Right button
|
||||||
Button rightButton = CreateButton(closeButton, sortBackground.sprite, EItemAttributeId.RecoilBack);
|
Button rightButton = CreateButton(closeButton, sortBackground.sprite, EItemAttributeId.RecoilBack);
|
||||||
rightButton.transform.Find("X").Rotate(0f, 180f, 0f);
|
rightButton.transform.Find("X").Rotate(0f, 180f, 0f);
|
||||||
rightButton.onClick.AddListener(() => SnapRight(__instance));
|
rightButton.onClick.AddListener(() => SnapRight(__instance));
|
||||||
__instance.R().UI.AddDisposable(() => rightButton.onClick.RemoveAllListeners());
|
wrappedInstance.UI.AddDisposable(() => rightButton.onClick.RemoveAllListeners());
|
||||||
|
|
||||||
// Put close back on the end
|
// Put close back on the end
|
||||||
closeButton.SetAsLastSibling();
|
closeButton.SetAsLastSibling();
|
||||||
|
|||||||
3
R.cs
3
R.cs
@@ -561,14 +561,17 @@ namespace UIFixes
|
|||||||
{
|
{
|
||||||
public static Type Type { get; private set; }
|
public static Type Type { get; private set; }
|
||||||
private static FieldInfo GridSortPanelField;
|
private static FieldInfo GridSortPanelField;
|
||||||
|
private static FieldInfo LootItemField;
|
||||||
|
|
||||||
public static void InitTypes()
|
public static void InitTypes()
|
||||||
{
|
{
|
||||||
Type = typeof(EFT.UI.GridWindow);
|
Type = typeof(EFT.UI.GridWindow);
|
||||||
GridSortPanelField = AccessTools.Field(Type, "_sortPanel");
|
GridSortPanelField = AccessTools.Field(Type, "_sortPanel");
|
||||||
|
LootItemField = AccessTools.GetDeclaredFields(Type).Single(f => f.FieldType == typeof(LootItemClass));
|
||||||
}
|
}
|
||||||
|
|
||||||
public EFT.UI.DragAndDrop.GridSortPanel GridSortPanel { get { return (EFT.UI.DragAndDrop.GridSortPanel)GridSortPanelField.GetValue(Value); } }
|
public EFT.UI.DragAndDrop.GridSortPanel GridSortPanel { get { return (EFT.UI.DragAndDrop.GridSortPanel)GridSortPanelField.GetValue(Value); } }
|
||||||
|
public LootItemClass LootItem { get { return (LootItemClass)LootItemField.GetValue(Value); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GridSortPanel(object value) : Wrapper(value)
|
public class GridSortPanel(object value) : Wrapper(value)
|
||||||
|
|||||||
Reference in New Issue
Block a user