Snap left/right keybinds
This commit is contained in:
@@ -29,6 +29,7 @@ namespace UIFixes
|
|||||||
new SaveInspectWindowSizePatch().Enable();
|
new SaveInspectWindowSizePatch().Enable();
|
||||||
new AddInspectWindowButtonsPatch().Enable();
|
new AddInspectWindowButtonsPatch().Enable();
|
||||||
new GrowInspectWindowDescriptionPatch().Enable();
|
new GrowInspectWindowDescriptionPatch().Enable();
|
||||||
|
new LeftRightKeybindsPatch().Enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SaveInspectWindowSizePatch : ModulePatch
|
public class SaveInspectWindowSizePatch : ModulePatch
|
||||||
@@ -150,11 +151,7 @@ namespace UIFixes
|
|||||||
leftImage.overrideSprite = null;
|
leftImage.overrideSprite = null;
|
||||||
leftImage.SetNativeSize();
|
leftImage.SetNativeSize();
|
||||||
|
|
||||||
leftButton.onClick.AddListener(() =>
|
leftButton.onClick.AddListener(() => SnapLeft(inspectPanel));
|
||||||
{
|
|
||||||
RectTransform inspectRect = (RectTransform)inspectPanel.transform;
|
|
||||||
inspectRect.anchoredPosition = new Vector2((float)Screen.width / 4f / inspectRect.lossyScale.x, inspectRect.anchoredPosition.y);
|
|
||||||
});
|
|
||||||
inspectPanel.AddDisposable(() => leftButton.onClick.RemoveAllListeners());
|
inspectPanel.AddDisposable(() => leftButton.onClick.RemoveAllListeners());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -172,11 +169,7 @@ namespace UIFixes
|
|||||||
leftImage.overrideSprite = null;
|
leftImage.overrideSprite = null;
|
||||||
leftImage.SetNativeSize();
|
leftImage.SetNativeSize();
|
||||||
|
|
||||||
rightButton.onClick.AddListener(() =>
|
rightButton.onClick.AddListener(() => SnapRight(inspectPanel));
|
||||||
{
|
|
||||||
RectTransform inspectRect = (RectTransform)inspectPanel.transform;
|
|
||||||
inspectRect.anchoredPosition = new Vector2((float)Screen.width * 3f/4f / inspectRect.lossyScale.x, inspectRect.anchoredPosition.y);
|
|
||||||
});
|
|
||||||
inspectPanel.AddDisposable(() => rightButton.onClick.RemoveAllListeners());
|
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)
|
private static void StretchDescription(LayoutElement inspectLayout)
|
||||||
{
|
{
|
||||||
if (!Settings.ExpandDescriptionHeight.Value)
|
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 BepInEx.Configuration;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace UIFixes
|
namespace UIFixes
|
||||||
{
|
{
|
||||||
@@ -54,6 +55,8 @@ namespace UIFixes
|
|||||||
public static ConfigEntry<bool> RememberInspectSize { get; set; }
|
public static ConfigEntry<bool> RememberInspectSize { get; set; }
|
||||||
public static ConfigEntry<bool> LockInspectPreviewSize { get; set; }
|
public static ConfigEntry<bool> LockInspectPreviewSize { get; set; }
|
||||||
public static ConfigEntry<bool> ExpandDescriptionHeight { 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
|
public static ConfigEntry<bool> StyleItemPanel { get; set; } // Advanced
|
||||||
|
|
||||||
// In Raid
|
// In Raid
|
||||||
@@ -246,6 +249,24 @@ namespace UIFixes
|
|||||||
null,
|
null,
|
||||||
new ConfigurationManagerAttributes { })));
|
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(
|
configEntries.Add(StyleItemPanel = config.Bind(
|
||||||
InspectSection,
|
InspectSection,
|
||||||
"Style Attribute Panels",
|
"Style Attribute Panels",
|
||||||
|
|||||||
Reference in New Issue
Block a user