diff --git a/00-CompileModule.bat b/00-CompileModule.bat index 74ece76..d9f2d7e 100644 --- a/00-CompileModule.bat +++ b/00-CompileModule.bat @@ -2,3 +2,4 @@ call 10-CompileVanilla.bat %* call 11-CompileSmxCompat.bat %* +call 12-CompileAlCompat.bat %* diff --git a/01-CreateRelease.bat b/01-CreateRelease.bat index 264a26a..4074580 100644 --- a/01-CreateRelease.bat +++ b/01-CreateRelease.bat @@ -2,3 +2,4 @@ call 20-PackageVanilla.bat %* call 21-PackageSmxCompat.bat %* +call 22-PackageAlCompat.bat %* diff --git a/12-CompileAlCompat.bat b/12-CompileAlCompat.bat new file mode 100644 index 0000000..58543e1 --- /dev/null +++ b/12-CompileAlCompat.bat @@ -0,0 +1,13 @@ +@echo off + +call MC7D2D AlCompat\InventoryMouseWheel.dll ^ +/reference:"%PATH_7D2D_MANAGED%\NGUI.dll" ^ +/reference:"%PATH_7D2D_MANAGED%\Assembly-CSharp.dll" ^ +/reference:"%PATH_7D2D_MANAGED%\Afterlife.dll" ^ +/reference:"%PATH_7D2D_MANAGED%\Quartz.dll" ^ +Harmony\*.cs AlCompat\*.cs && ^ +echo Successfully compiled AlCompat\InventoryMouseWheel.dll + +SET RV=%ERRORLEVEL% +if "%CI%"=="" pause +exit /B %RV% diff --git a/22-PackageAlCompat.bat b/22-PackageAlCompat.bat new file mode 100644 index 0000000..b427dce --- /dev/null +++ b/22-PackageAlCompat.bat @@ -0,0 +1,40 @@ +@echo off + +SET NAME=OcbInventoryMouseWheelAL + +if not exist build\ ( + mkdir build +) + +if exist build\%NAME%\ ( + echo remove existing directory + rmdir build\%NAME% /S /Q +) + +mkdir build\%NAME% + +SET VERSION=snapshot + +if not "%1"=="" ( + SET VERSION=%1 +) + +echo create %VERSION% + +xcopy *.xml build\%NAME%\ +xcopy *.md build\%NAME%\ +xcopy AlCompat\*.dll build\%NAME%\ +xcopy Config build\%NAME%\Config\ /S +xcopy Resources build\%NAME%\Resources\ /S +xcopy UIAtlases build\%NAME%\UIAtlases\ /S + +powershell -Command "(gc -encoding UTF8 build\%NAME%\ModInfo.xml) -replace '\"OcbInventoryMouseWheel\"', '\"OcbInventoryMouseWheelAL\"' | Out-File -encoding UTF8 build\%NAME%\ModInfo.xml" + +cd build +echo Packaging %NAME%-%VERSION%.zip +powershell Compress-Archive %NAME% %NAME%-%VERSION%.zip -Force +cd .. + +SET RV=%ERRORLEVEL% +if "%CI%"=="" pause +exit /B %RV% diff --git a/AlCompat/InventoryMouseWheel.dll b/AlCompat/InventoryMouseWheel.dll new file mode 100644 index 0000000..cbbc106 Binary files /dev/null and b/AlCompat/InventoryMouseWheel.dll differ diff --git a/AlCompat/XUiC_AL_ItemStack.cs b/AlCompat/XUiC_AL_ItemStack.cs new file mode 100644 index 0000000..b411fec --- /dev/null +++ b/AlCompat/XUiC_AL_ItemStack.cs @@ -0,0 +1,84 @@ +using Audio; +using System; +using UnityEngine; + +public class XUiC_AL_WheelItemStack : AL.UI.XUiC_AL_ItemStack +{ + + protected bool IsOver = false; + + public override void Init() + { + base.Init(); + } + + private ItemStack DnDStack => xui.dragAndDrop.CurrentStack; + + private void SetSlot(ItemStack stack) => ItemStack = stack; + + private void SetDnD(ItemStack stack) => xui.dragAndDrop.CurrentStack = stack; + + static bool IsShiftPressed => Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift); + + protected virtual int TransferItems(int amount, + ItemStack src, Action setSrc, + ItemStack dst, Action setDst) + { + if (IsShiftPressed) amount *= 10; + if (WheelItemStack.TransferItems(amount, src, setSrc, dst, setDst) > 0) + { + // Copied from vanilla + ForceRefreshItemStack(); + IsDirty = true; + Selected = false; + HandleClickComplete(); + xui.calloutWindow.UpdateCalloutsForItemStack( + ViewComponent.UiTransform.gameObject, + ItemStack, IsOver); + if (placeSound != null) Manager. + PlayXUiSound(placeSound, 0.1f); + } + // Return how much was transfered + return amount; + } + + public override void OnHovered(bool _isOver) + { + IsOver = _isOver; + base.OnHovered(_isOver); + } + + public override void OnScrolled(float _delta) + { + // Process the item transfer + if (IsLocked || StackLock) + { + base.OnScrolled(_delta); + } + // Do nothing if the cursor is currently locked + // Happens when cursors stay over toolbar when backpack is closed + else if (Cursor.lockState != CursorLockMode.None) + { + base.OnScrolled(_delta); + } + else if (_delta > 0.0) + { + TransferItems( + (int)(_delta * 10), + DnDStack, SetDnD, + itemStack, SetSlot); + } + else if (_delta < 0.0) + { + TransferItems( + (int)(_delta * -10), + itemStack, SetSlot, + DnDStack, SetDnD); + } + else + { + base.OnScrolled(_delta); + } + } + +} diff --git a/AlCompat/XUiC_AL_RequiredItemStack.cs b/AlCompat/XUiC_AL_RequiredItemStack.cs new file mode 100644 index 0000000..afdd056 --- /dev/null +++ b/AlCompat/XUiC_AL_RequiredItemStack.cs @@ -0,0 +1,78 @@ +using Audio; +using System; +using UnityEngine; + +public class XUiC_AL_WheelRequiredItemStack : AL.UI.XUiC_AL_RequiredItemStack +{ + + protected bool IsOver = false; + + private ItemStack DnDStack => xui.dragAndDrop.CurrentStack; + + private void SetSlot(ItemStack stack) => ItemStack = stack; + + private void SetDnD(ItemStack stack) => xui.dragAndDrop.CurrentStack = stack; + + static bool IsShiftPressed => Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift); + + protected virtual int TransferItems(int amount, + ItemStack src, Action setSrc, + ItemStack dst, Action setDst) + { + if (IsShiftPressed) amount *= 10; + if (WheelItemStack.TransferItems(amount, src, setSrc, dst, setDst) > 0) + { + // Copied from vanilla + ForceRefreshItemStack(); + IsDirty = true; + Selected = false; + HandleClickComplete(); + xui.calloutWindow.UpdateCalloutsForItemStack( + ViewComponent.UiTransform.gameObject, + ItemStack, IsOver); + if (placeSound != null) Manager. + PlayXUiSound(placeSound, 0.1f); + } + // Return how much was transfered + return amount; + } + + public override void OnHovered(bool _isOver) + { + IsOver = _isOver; + base.OnHovered(_isOver); + } + + public override void OnScrolled(float _delta) + { + // Process the item transfer + if (IsLocked || StackLock) + { + base.OnScrolled(_delta); + } + // Do nothing if the cursor is currently locked + // Happens when cursors stay over toolbar when backpack is closed + else if (Cursor.lockState != CursorLockMode.None) + { + base.OnScrolled(_delta); + } + else if (_delta > 0.0 && !TakeOnly && CanSwap(DnDStack)) + { + TransferItems( + (int)(_delta * 10), + DnDStack, SetDnD, + itemStack, SetSlot); + } + else if (_delta < 0.0 && (DnDStack.IsEmpty() || CanSwap(DnDStack))) + { + TransferItems( + (int)(_delta * -10), + itemStack, SetSlot, + DnDStack, SetDnD); + } + else + { + base.OnScrolled(_delta); + } + } +} diff --git a/Config/XUi/controls.xml b/Config/XUi/controls.xml index 33ab6b2..0f43ca7 100644 --- a/Config/XUi/controls.xml +++ b/Config/XUi/controls.xml @@ -1,14 +1,16 @@ - - - true - WheelItemStack, InventoryMouseWheel + + + + true + AL_WheelItemStack, InventoryMouseWheel - - - true - WheelItemStack, InventoryMouseWheel + + + + true + WheelItemStack, InventoryMouseWheel diff --git a/Config/XUi/windows.xml b/Config/XUi/windows.xml index 9fed891..5e0809d 100644 --- a/Config/XUi/windows.xml +++ b/Config/XUi/windows.xml @@ -1,7 +1,12 @@ - + + + true + AL_WheelRequiredItemStack, InventoryMouseWheel + + - true - WheelRequiredItemStack, InventoryMouseWheel + true + WheelRequiredItemStack, InventoryMouseWheel diff --git a/Harmony/InventoryMouseWheel.cs b/Harmony/InventoryMouseWheel.cs index 1e62341..2ef3250 100644 --- a/Harmony/InventoryMouseWheel.cs +++ b/Harmony/InventoryMouseWheel.cs @@ -33,12 +33,14 @@ static void Postfix(ref List __result) { switch (__result[i].Name) { + case "Afterlife": case "Khaines60BBM": case "Khaines96BBM": case "Z_Ravenhearst_ResizedBackpack": depPos = Mathf.Max(depPos, i + 1); break; case "OcbInventoryMouseWheel": + case "OcbInventoryMouseWheelAL": case "OcbInventoryMouseWheelSMX": myPos = i; break; diff --git a/InventoryMouseWheel.csproj b/InventoryMouseWheel.csproj index 878aae6..eced406 100644 --- a/InventoryMouseWheel.csproj +++ b/InventoryMouseWheel.csproj @@ -11,7 +11,7 @@ Properties InventoryMouseWheel InventoryMouseWheel - v4.8 + v4.8.1 512 true @@ -78,9 +78,6 @@ $(PATH_7D2D_MANAGED)\UnityEngine.CoreModule.dll - - ..\SMXcore\Quartz.dll - diff --git a/InventoryMouseWheel.dll b/InventoryMouseWheel.dll index 6d67ded..9a7aff8 100644 Binary files a/InventoryMouseWheel.dll and b/InventoryMouseWheel.dll differ diff --git a/ModInfo.xml b/ModInfo.xml index a78f22e..8de816a 100644 --- a/ModInfo.xml +++ b/ModInfo.xml @@ -5,5 +5,5 @@ - + \ No newline at end of file diff --git a/README.md b/README.md index 91ed779..a589031 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,11 @@ Only clone or download the repo if you know what you do! ## Changelog +### Version 0.3.2 + +- Enable pressing shift to take 10 items +- Add compatibility for Afterlife Overhaul + ### Version 0.3.1 - Fix XML-Patcher for V1 compatibility diff --git a/SmxCompat/InventoryMouseWheel.dll b/SmxCompat/InventoryMouseWheel.dll index 41eb3ec..fa9c043 100644 Binary files a/SmxCompat/InventoryMouseWheel.dll and b/SmxCompat/InventoryMouseWheel.dll differ