Snap left/right keybinds
This commit is contained in:
@@ -29,6 +29,7 @@ namespace UIFixes
|
||||
new SaveInspectWindowSizePatch().Enable();
|
||||
new AddInspectWindowButtonsPatch().Enable();
|
||||
new GrowInspectWindowDescriptionPatch().Enable();
|
||||
new LeftRightKeybindsPatch().Enable();
|
||||
}
|
||||
|
||||
public class SaveInspectWindowSizePatch : ModulePatch
|
||||
@@ -150,11 +151,7 @@ namespace UIFixes
|
||||
leftImage.overrideSprite = null;
|
||||
leftImage.SetNativeSize();
|
||||
|
||||
leftButton.onClick.AddListener(() =>
|
||||
{
|
||||
RectTransform inspectRect = (RectTransform)inspectPanel.transform;
|
||||
inspectRect.anchoredPosition = new Vector2((float)Screen.width / 4f / inspectRect.lossyScale.x, inspectRect.anchoredPosition.y);
|
||||
});
|
||||
leftButton.onClick.AddListener(() => SnapLeft(inspectPanel));
|
||||
inspectPanel.AddDisposable(() => leftButton.onClick.RemoveAllListeners());
|
||||
}
|
||||
|
||||
@@ -172,11 +169,7 @@ namespace UIFixes
|
||||
leftImage.overrideSprite = null;
|
||||
leftImage.SetNativeSize();
|
||||
|
||||
rightButton.onClick.AddListener(() =>
|
||||
{
|
||||
RectTransform inspectRect = (RectTransform)inspectPanel.transform;
|
||||
inspectRect.anchoredPosition = new Vector2((float)Screen.width * 3f/4f / inspectRect.lossyScale.x, inspectRect.anchoredPosition.y);
|
||||
});
|
||||
rightButton.onClick.AddListener(() => SnapRight(inspectPanel));
|
||||
inspectPanel.AddDisposable(() => rightButton.onClick.RemoveAllListeners());
|
||||
}
|
||||
|
||||
@@ -194,6 +187,18 @@ namespace UIFixes
|
||||
}
|
||||
}
|
||||
|
||||
private static void SnapLeft(ItemSpecificationPanel panel)
|
||||
{
|
||||
RectTransform inspectRect = (RectTransform)panel.transform;
|
||||
inspectRect.anchoredPosition = new Vector2((float)Screen.width / 4f / inspectRect.lossyScale.x, inspectRect.anchoredPosition.y);
|
||||
}
|
||||
|
||||
private static void SnapRight(ItemSpecificationPanel panel)
|
||||
{
|
||||
RectTransform inspectRect = (RectTransform)panel.transform;
|
||||
inspectRect.anchoredPosition = new Vector2((float)Screen.width * 3f / 4f / inspectRect.lossyScale.x, inspectRect.anchoredPosition.y);
|
||||
}
|
||||
|
||||
private static void StretchDescription(LayoutElement inspectLayout)
|
||||
{
|
||||
if (!Settings.ExpandDescriptionHeight.Value)
|
||||
@@ -229,5 +234,27 @@ namespace UIFixes
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class LeftRightKeybindsPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return AccessTools.Method(typeof(ItemSpecificationPanel), nameof(ItemSpecificationPanel.Update));
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
public static void Postfix(ItemSpecificationPanel __instance)
|
||||
{
|
||||
if (Settings.SnapLeftKeybind.Value.IsDown())
|
||||
{
|
||||
SnapLeft(__instance);
|
||||
}
|
||||
|
||||
if (Settings.SnapRightKeybind.Value.IsDown())
|
||||
{
|
||||
SnapRight(__instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
21
Settings.cs
21
Settings.cs
@@ -1,6 +1,7 @@
|
||||
using BepInEx.Configuration;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UIFixes
|
||||
{
|
||||
@@ -54,6 +55,8 @@ namespace UIFixes
|
||||
public static ConfigEntry<bool> RememberInspectSize { get; set; }
|
||||
public static ConfigEntry<bool> LockInspectPreviewSize { get; set; }
|
||||
public static ConfigEntry<bool> ExpandDescriptionHeight { get; set; }
|
||||
public static ConfigEntry<KeyboardShortcut> SnapLeftKeybind { get; set; }
|
||||
public static ConfigEntry<KeyboardShortcut> SnapRightKeybind { get; set; }
|
||||
public static ConfigEntry<bool> StyleItemPanel { get; set; } // Advanced
|
||||
|
||||
// In Raid
|
||||
@@ -246,6 +249,24 @@ namespace UIFixes
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
configEntries.Add(SnapLeftKeybind = config.Bind(
|
||||
InspectSection,
|
||||
"Snap Window Left shortcut",
|
||||
new KeyboardShortcut(KeyCode.LeftArrow),
|
||||
new ConfigDescription(
|
||||
"Keybind to snap the inspect panel to the left half of the screen",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
configEntries.Add(SnapRightKeybind = config.Bind(
|
||||
InspectSection,
|
||||
"Snap Window Right shortcut",
|
||||
new KeyboardShortcut(KeyCode.RightArrow),
|
||||
new ConfigDescription(
|
||||
"Keybind to snap the inspect panel to the right half of the screen",
|
||||
null,
|
||||
new ConfigurationManagerAttributes { })));
|
||||
|
||||
configEntries.Add(StyleItemPanel = config.Bind(
|
||||
InspectSection,
|
||||
"Style Attribute Panels",
|
||||
|
Reference in New Issue
Block a user