Created
April 29, 2022 21:16
-
-
Save InclementDab/f797d64582c895fb5f7f90f9c7c722eb to your computer and use it in GitHub Desktop.
DoubleClickStacking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
modded class VicinitySlotsContainer | |
{ | |
override void DoubleClick(Widget w, int x, int y, int button) | |
{ | |
if (button != MouseState.LEFT) { | |
return; | |
} | |
if (!w) { | |
return; | |
} | |
ItemPreviewWidget iw = ItemPreviewWidget.Cast( w.FindAnyWidget( "Render" ) ); | |
if (!iw) { | |
string name = w.GetName(); | |
name.Replace("PanelWidget", "Render"); | |
iw = ItemPreviewWidget.Cast( w.FindAnyWidget( name ) ); | |
} | |
if (!iw) { | |
iw = ItemPreviewWidget.Cast(w); | |
} | |
ItemBase item = ItemBase.Cast( iw.GetItem() ); | |
if (!item) { | |
return; | |
} | |
if (GetGame().GetPlayer().GetInventory().HasInventoryReservation(item, null)) { | |
return; | |
} | |
if (!item.GetInventory().CanRemoveEntity()) { | |
return; | |
} | |
PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer()); | |
if (player.GetInventory().HasEntityInInventory(item) && GetGame().GetPlayer().GetHumanInventory().CanAddEntityInHands(item)) { | |
player.PredictiveTakeEntityToHands(item); | |
} else { | |
InventoryLocation dst = new InventoryLocation; | |
bool found; | |
array<EntityAI> items = {}; | |
if (player.GetInventory().EnumerateInventory(InventoryTraversalType.PREORDER, items)) { | |
foreach (EntityAI search_item: items) { | |
if (search_item.CanBeCombined(item)) { | |
search_item.CombineItemsClient(item); | |
found = true; | |
} | |
} | |
} | |
if (!found) { | |
player.GetInventory().FindFreeLocationFor( item, FindInventoryLocationType.ANY, dst ); | |
if (dst.IsValid() && player.GetInventory().LocationCanAddEntity(dst)) { | |
SplitItemUtils.TakeOrSplitToInventoryLocation(player, dst); | |
} | |
} | |
} | |
ItemManager.GetInstance().HideTooltip(); | |
InventoryMenu menu = InventoryMenu.Cast( GetGame().GetUIManager().FindMenu( MENU_INVENTORY ) ); | |
if (menu) { | |
menu.RefreshQuickbar(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not sure what RA is whoops :)
Yeah the double clicking is such such a fantastic addition, you really should get Dayz to implement into their actual code base.
The taking stacks using your interact button is borked though, has been since so long, it'll just put the exact stack quantity in your bag, no stacking.
Thought there might have been an override you could do or something :D