366 {
367 ItemManager.GetInstance().HideDropzones();
368
369 if (w == null)
370 {
371 return;
372 }
373 string name = w.GetName();
374 name.Replace(
"PanelWidget",
"Render");
375
376 ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(receiver.FindAnyWidget( "Render" ));
378 {
379 targetIpw = ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget( "Render" ));
380 }
381
382 ItemPreviewWidget selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget(
name ));
383 if (selectedIpw == null)
384 {
385 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget( "Render" ));
386 }
387 if (selectedIpw == null)
388 {
389 return;
390 }
391
392 PlayerBase player = PlayerBase.Cast(
g_Game.GetPlayer() );
393 InventoryItem targetEntity = InventoryItem.Cast(targetIpw.
GetItem());
394 InventoryItem selectedEntity = InventoryItem.Cast(selectedIpw.
GetItem());
395 InventoryLocation ilDst;
396 if (!targetEntity || !selectedEntity)
397 {
398 return;
399 }
400
402 {
403 if (targetEntity == selectedEntity)
404 {
405 ColorManager.GetInstance().SetColor( w, ColorManager.SWAP_COLOR );
406 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
407 }
408 else
409 {
410 CargoContainer parentContainer = CargoContainer.Cast(
m_Parent);
411
412 float parentX;
413 float parentY;
414
415 parentContainer.GetRootWidget().GetScreenPos(parentX, parentY);
416
417 float iconSize = parentContainer.GetIconSize();
418 float spaceSize = parentContainer.GetSpaceSize();
419
420 int PosX = (
x - parentX) / (iconSize + spaceSize);
421 int PosY = (
y - parentY) / (iconSize + spaceSize);
422
424 CargoBase targetCargo = parent.GetInventory().GetCargo();
425
426 ilDst = new InventoryLocation();
427 ilDst.
SetCargoAuto(targetCargo, selectedEntity, PosY, PosX, selectedEntity.GetInventory().GetFlipCargo());
428
429 if (parent.GetInventory().LocationCanAddEntity(ilDst))
430 {
431 ColorManager.GetInstance().SetColor(w, ColorManager.GREEN_COLOR);
432 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
433 }
434 else
435 {
436 ColorManager.GetInstance().SetColor(w, ColorManager.RED_COLOR);
437 ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
438 }
439 }
440 }
441 else
442 {
443 static int testedFlags = InventoryCombinationFlags.COMBINE_QUANTITY2 | InventoryCombinationFlags.ADD_AS_CARGO | InventoryCombinationFlags.ADD_AS_ATTACHMENT | InventoryCombinationFlags.SWAP | InventoryCombinationFlags.FSWAP | InventoryCombinationFlags.SWAP_MAGAZINE;
444
445 int chosenInventoryAction = ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags, ilDst);
446 UpdateFrameColor(selectedEntity, targetEntity, chosenInventoryAction, w, ilDst);
447 }
448 }
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
void UpdateFrameColor(EntityAI selectedEntity, EntityAI targetEntity, int combinationFlag, Widget w, InventoryLocation il=null)
proto native void SetCargoAuto(notnull CargoBase cargo, EntityAI e, int row, int col, bool flip)
based on Cargo.IsProxyCargo uses SetProxyCargo or SetCargo respectively