370 {
371 ItemManager.GetInstance().HideDropzones();
372
373 if (w == null)
374 {
375 return;
376 }
377 string name = w.GetName();
378 name.Replace(
"PanelWidget",
"Render");
379
380 ItemPreviewWidget targetIpw = ItemPreviewWidget.Cast(receiver.FindAnyWidget( "Render" ));
382 {
383 targetIpw = ItemPreviewWidget.Cast(receiver.GetParent().FindAnyWidget( "Render" ));
384 }
385
386 ItemPreviewWidget selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget(
name ));
387 if (selectedIpw == null)
388 {
389 selectedIpw = ItemPreviewWidget.Cast(w.FindAnyWidget( "Render" ));
390 }
391 if (selectedIpw == null)
392 {
393 return;
394 }
395
397 InventoryItem targetEntity = InventoryItem.Cast(targetIpw.
GetItem());
398 InventoryItem selectedEntity = InventoryItem.Cast(selectedIpw.
GetItem());
399 InventoryLocation ilDst;
400 if (!targetEntity || !selectedEntity)
401 {
402 return;
403 }
404
406 {
407 if (targetEntity == selectedEntity)
408 {
409 ColorManager.GetInstance().SetColor( w, ColorManager.SWAP_COLOR );
410 ItemManager.GetInstance().GetRightDropzone().SetAlpha( 1 );
411 }
412 else
413 {
414 CargoContainer parentContainer = CargoContainer.Cast(
m_Parent);
415
416 float parentX;
417 float parentY;
418
419 parentContainer.GetRootWidget().GetScreenPos(parentX, parentY);
420
421 float iconSize = parentContainer.GetIconSize();
422 float spaceSize = parentContainer.GetSpaceSize();
423
424 int PosX = (
x - parentX) / (iconSize + spaceSize);
425 int PosY = (
y - parentY) / (iconSize + spaceSize);
426
428 CargoBase targetCargo = parent.GetInventory().GetCargo();
429
430 ilDst = new InventoryLocation();
431 ilDst.
SetCargoAuto(targetCargo, selectedEntity, PosY, PosX, selectedEntity.GetInventory().GetFlipCargo());
432
433 if (parent.GetInventory().LocationCanAddEntity(ilDst))
434 {
435 ColorManager.GetInstance().SetColor(w, ColorManager.GREEN_COLOR);
436 ItemManager.GetInstance().GetRightDropzone().SetAlpha(1);
437 }
438 else
439 {
440 ColorManager.GetInstance().SetColor(w, ColorManager.RED_COLOR);
441 ItemManager.GetInstance().ShowSourceDropzone(selectedEntity);
442 }
443 }
444 }
445 else
446 {
447 static int testedFlags = InventoryCombinationFlags.COMBINE_QUANTITY2 | InventoryCombinationFlags.ADD_AS_CARGO | InventoryCombinationFlags.ADD_AS_ATTACHMENT | InventoryCombinationFlags.SWAP | InventoryCombinationFlags.FSWAP | InventoryCombinationFlags.SWAP_MAGAZINE;
448
449 int chosenInventoryAction = ItemManager.GetChosenCombinationFlag(selectedEntity, targetEntity, testedFlags, ilDst);
450 UpdateFrameColor(selectedEntity, targetEntity, chosenInventoryAction, w, ilDst);
451 }
452 }
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
proto native CGame GetGame()