1 #ifdef PLATFORM_CONSOLE
2 enum ConsoleActionToolbarMask
5 TO_HANDS_SWAP_VICINITY = 1,
6 TO_HANDS_SWAP_INVENTORY = 2,
11 OPEN_CLOSE_CONTAINER = 64,
113 #ifdef PLATFORM_CONSOLE
115 GetGame().GetUIManager().ShowUICursor(
false);
117 GetMainWidget().FindAnyWidget(
"CursorCharacter").Show(
false);
151 for (
int i = 0; i < namesCount; i++)
162 #ifdef PLATFORM_CONSOLE
169 switch (pInputDeviceType)
195 ItemManager.GetInstance().SerializeDefaultOpenStates();
196 ItemManager.GetInstance().SerializeDefaultHeaderOpenStates();
201 ItemManager.GetInstance().DeserializeDefaultOpenStates();
202 ItemManager.GetInstance().DeserializeDefaultHeaderOpenStates();
205 static int GetPlayerAttachmentIndex(
string slot_name)
207 return m_PlayerAttachmentsIndexes[slot_name];
210 static int GetPlayerAttachmentIndex(
int slot_id)
212 return GetPlayerAttachmentIndex(
InventorySlots.GetSlotName(slot_id));
218 string data, errorMessage;
222 if (
GetGame().GetProfileString(
"INV_AttIndexes", data))
224 if (!JsonFileLoader<
map<string, int>>.LoadData(data, m_PlayerAttachmentsIndexes, errorMessage))
228 string configPathGhostSlots =
"CfgVehicles SurvivorBase InventoryEquipment playerSlots";
230 GetGame().ConfigGetTextArray(configPathGhostSlots, playerGhostSlots);
232 foreach (
string slotName : playerGhostSlots)
237 m_PlayerAttachmentsIndexes.Insert(
slotName, m_PlayerAttachmentsIndexes.Count());
241 if (!JsonFileLoader<
map<string, int>>.MakeData(m_PlayerAttachmentsIndexes, data, errorMessage))
244 GetGame().SetProfileString(
"INV_AttIndexes", data);
247 static void MoveAttachmentUp(
int slot_id)
249 int curr = GetPlayerAttachmentIndex(slot_id);
252 string next_item =
"init";
256 while(!next_ent && next_item !=
"")
258 next_item = m_PlayerAttachmentsIndexes.GetKeyByValue(curr + --next_offset);
260 next_ent =
GetGame().GetPlayer().GetInventory().FindAttachment(next_id);
261 if (next_ent && !m_Instance.m_RightArea.HasEntityContainerVisible(next_ent))
265 if (next_item !=
"" && next_ent)
267 int next = GetPlayerAttachmentIndex(next_item);
268 m_PlayerAttachmentsIndexes.Set(
InventorySlots.GetSlotName(slot_id), next);
269 m_PlayerAttachmentsIndexes.Set(next_item, curr);
271 m_Instance.m_RightArea.SwapItemsInOrder(next_id, slot_id);
275 static void MoveAttachmentDown(
int slot_id)
277 int curr = GetPlayerAttachmentIndex(slot_id);
280 string next_item =
"init";
284 while(!next_ent && next_item !=
"")
286 next_item = m_PlayerAttachmentsIndexes.GetKeyByValue(curr + ++next_offset);
288 next_ent =
GetGame().GetPlayer().GetInventory().FindAttachment(next_id);
289 if (next_ent && !m_Instance.m_RightArea.HasEntityContainerVisible(next_ent))
293 if (next_item !=
"" && next_ent)
295 int next = GetPlayerAttachmentIndex(next_item);
296 m_PlayerAttachmentsIndexes.Set(
InventorySlots.GetSlotName(slot_id), next);
297 m_PlayerAttachmentsIndexes.Set(next_item, curr);
299 m_Instance.m_RightArea.SwapItemsInOrder(next_id, slot_id);
305 int proper_angle = (360 - angle) % 360;
311 if (angle < 45 || angle > 315)
315 else if (angle < 135 && angle > 45)
319 else if (angle < 225 && angle > 135)
323 else if (angle < 315 && angle > 225)
338 #ifdef PLATFORM_CONSOLE
389 string name = w.GetName();
390 name.Replace(
"PanelWidget",
"Render");
422 string name = w.GetName();
423 name.Replace(
"PanelWidget",
"Render");
438 if (!item.GetInventory().CanRemoveEntity())
448 int index = player.GetHumanInventory().FindUserReservedLocationIndex(item);
451 player.GetHumanInventory().GetUserReservedLocation(index, inv_loc);
452 if (player.GetInventory().LocationCanAddEntity(inv_loc))
461 if (player && (player.GetInventory().CanAddAttachment(item)))
463 float stackable = item.GetTargetQuantityMax(-1);
465 if (stackable == 0 || stackable >= item.GetQuantity())
467 player.PredictiveTakeEntityAsAttachment(item);
473 ItemBase.Cast(item).SplitIntoStackMaxToInventoryLocationClient(il);
478 int slot_id = item.GetInventory().GetSlotId(0);
479 EntityAI slot_item = player.GetInventory().FindAttachment(slot_id);
480 if (slot_item && player.GetInventory().CanSwapEntitiesEx(item, slot_item))
482 player.PredictiveSwapEntities(item, slot_item);
484 else if (player.CanReceiveItemIntoCargo(item))
493 CastTo(mngr_client, player.GetActionManager());
527 string name = w.GetName();
528 name.Replace(
"PanelWidget",
"Render");
545 int slot_id = item.GetInventory().GetSlotId(0);
546 EntityAI slot_item = player.GetInventory().FindAttachment(slot_id);
551 int index = player.GetHumanInventory().FindUserReservedLocationIndex(item);
554 player.GetHumanInventory().GetUserReservedLocation(index, inv_loc);
555 if (player.GetInventory().LocationCanAddEntity(inv_loc))
565 if (inv_loc.IsValid())
568 GetMainWidget().FindAnyWidget(
"RightPanel").FindAnyWidget(
"DropzoneX").SetAlpha(1);
569 if (inv_loc.GetType() == 4)
572 GetMainWidget().FindAnyWidget(
"HandsPanel").FindAnyWidget(
"DropzoneX").SetAlpha(1);
579 ItemManager.GetInstance().ShowSourceDropzone(item);
592 #ifdef PLATFORM_CONSOLE
598 if (
GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
603 if (!
GetUApi().GetInputByID(UAUIInventoryTabRight).LocalValue())
615 if (
GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
620 if (!
GetUApi().GetInputByID(UAUIInventoryTabLeft).LocalValue())
632 if (
GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
637 if (!
GetUApi().GetInputByID(UAUIInventoryContainerUp).LocalValue())
649 if (
GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
654 if (!
GetUApi().GetInputByID(UAUIInventoryContainerDown).LocalValue())
676 if (
GetUApi().GetInputByID(UAUIRotateInventory).LocalPress())
682 GetGame().GetInventoryItemSize(item, size_x, size_y);
683 if (size_x != size_y)
685 item.GetInventory().FlipCargo();
686 item.GetOnItemFlipped().Invoke(item.GetInventory().GetFlipCargo());
691 #ifdef PLATFORM_CONSOLE
694 dpi = player.GetDayZPlayerInventory();
697 if (dpi && !dpi.IsProcessing())
699 if (
GetUApi().GetInputByID(UAUIExpandCollapseContainer).LocalPress())
711 if (
GetUApi().GetInputByID(UAUIDragNDrop).LocalHoldBegin())
716 if (
GetUApi().GetInputByID(UAUISplit).LocalPress())
739 if (
GetUApi().GetInputByID(UAUIFastEquip).LocalPress())
763 if (
ItemManager.GetInstance().IsMicromanagmentMode() &&
GetUApi().GetInputByID(UAUIDragNDrop).LocalRelease())
781 if (
GetUApi().GetInputByID(UAUIPutInHandsFromVicinity).LocalPress())
795 if (
GetUApi().GetInputByID(UAUIPutInHandsFromInventory).LocalPress())
810 if (
GetUApi().GetInputByID(UAUIFastTransferToVicinity).LocalPress())
815 if (item && item.GetInventory().CanRemoveEntity())
829 if (item && item.GetInventory().CanRemoveEntity())
841 if (
GetUApi().GetInputByID(UAUIInspectItem).LocalPress())
868 if (
GetUApi().GetInputByID(UAUIFastTransferItem).LocalPress())
871 if (
GetUApi().GetInputByID(UAUIInspectItem).LocalPress())
874 if (dpi && !dpi.IsProcessing())
881 if (item && item.GetInventory().CanRemoveEntity())
889 if (item && item.GetInventory().CanRemoveEntity())
905 if (
GetUApi().GetInputByID(UAUIInventoryContainerUp).LocalPress())
907 if (
GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
915 if (
GetUApi().GetInputByID(UAUIInventoryContainerDown).LocalPress())
917 if (
GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
925 if (
GetUApi().GetInputByID(UAUIInventoryTabLeft).LocalPress())
927 if (
GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
935 if (
GetUApi().GetInputByID(UAUIInventoryTabRight).LocalPress())
937 if (
GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
946 if (
GetUApi().GetInputByID(UAUIQuickbarRadialInventoryOpen).LocalPress())
954 item_to_assign = player.GetItemInHands();
955 m_HandsArea.AddItemToQuickbarRadial(item_to_assign);
960 m_RightArea.AddItemToQuickbarRadial(item_to_assign);
965 MissionGameplay
mission = MissionGameplay.Cast(
GetGame().GetMission());
970 #ifdef PLATFORM_CONSOLE
1001 for (
int i = 0; i < 10; i++)
1023 #ifdef PLATFORM_CONSOLE
1024 UpdateConsoleToolbarCheck();
1032 if (item && item.GetInventory().CanRemoveEntity())
1034 player.SetQuickBarEntityShortcut(item, index) ;
1040 menu.RefreshQuickbar();
1046 if (!
ItemManager.GetInstance().IsMicromanagmentMode())
1048 ItemManager.GetInstance().SetItemMicromanagmentMode(
true);
1069 if (
ItemManager.GetInstance().IsMicromanagmentMode())
1071 ItemManager.GetInstance().SetItemMicromanagmentMode(
false);
1072 ItemManager.GetInstance().SetSelectedItemEx(
null,
null,
null);
1080 #ifdef PLATFORM_CONSOLE
1115 #ifdef PLATFORM_CONSOLE
1137 if (player && player.IsPlacingLocal())
1145 IngameHud hud = IngameHud.Cast(
mission.GetHud());
1148 hud.ShowQuickbarUI(
false);
1149 hud.ShowHudInventory(
true);
1155 #ifdef PLATFORM_CONSOLE
1176 IngameHud hud = IngameHud.Cast(
mission.GetHud());
1179 hud.ShowQuickbarUI(
true);
1180 hud.ShowHudInventory(
false);
1183 ItemManager.GetInstance().SetSelectedItemEx(
null,
null,
null);
1189 if (player && player.GetSoftSkillsManager())
1191 float x = player.GetSoftSkillsManager().GetSpecialtyLevel() / 2;
1193 #ifndef PLATFORM_CONSOLE
1197 IngameHud hud = IngameHud.Cast(
mission.GetHud());
1200 hud.UpdateSpecialtyMeter(
x,
y);
1218 #ifndef PLATFORM_CONSOLE
1224 #ifndef PLATFORM_CONSOLE
1235 #ifdef PLATFORM_CONSOLE
1236 protected string GetConsoleToolbarText(
int mask)
1240 string toHandsSwapVicinity =
string.Format(
" %1",
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUIPutInHandsFromVicinity",
GetStringVariant(
"UAUIPutInHandsFromVicinity",{
"#STR_Controls_TakeInHandsSwap",
"#STR_USRACT_HoldToHandSwap",
""}), EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
1241 string toHandsSwapInv =
string.Format(
" %1",
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUIPutInHandsFromInventory",
GetStringVariant(
"UAUIPutInHandsFromInventory",{
"#STR_Controls_TakeInHandsSwap",
"#STR_USRACT_HoldToHandSwap",
""}), EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
1242 string drop =
string.Format(
" %1",
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUIFastTransferToVicinity",
"#dayz_context_menu_drop", EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
1243 string equip =
string.Format(
" %1",
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUIFastEquip",
"#dayz_context_menu_equip", EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
1244 string split =
string.Format(
" %1",
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUISplit",
GetStringVariant(
"UAUISplit",{
"#dayz_context_menu_split",
"#STR_Controls_HoldSplit",
""}), EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
1245 string toInventory =
string.Format(
" %1",
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUIFastTransferItem",
"#dayz_context_menu_to_inventory", EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
1246 string openCloseContainer =
string.Format(
" %1",
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUIExpandCollapseContainer",
"#dayz_context_menu_open_close", EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
1247 string micromanagment =
string.Format(
" %1",
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUIDragNDrop",
"#dayz_context_menu_micro", EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
1248 string quickslot =
string.Format(
" %1",
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUIQuickbarRadialInventoryOpen",
"#ps4_dayz_context_menu_quickslot", EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
1249 string combine =
string.Format(
" %1",
InputUtils.GetRichtextButtonIconFromInputAction(
"UAUICombine",
GetStringVariant(
"UAUICombine",{
"#dayz_context_menu_combine",
"#dayz_context_menu_combine_hold",
""}), EUAINPUT_DEVICE_CONTROLLER,
InputUtils.ICON_SCALE_TOOLBAR));
1251 if (mask & ConsoleActionToolbarMask.OPEN_CLOSE_CONTAINER)
1253 result += openCloseContainer;
1255 if (mask & ConsoleActionToolbarMask.TO_HANDS_SWAP_VICINITY)
1257 result += toHandsSwapVicinity;
1259 if (mask & ConsoleActionToolbarMask.TO_HANDS_SWAP_INVENTORY)
1261 result += toHandsSwapInv;
1263 if (mask & ConsoleActionToolbarMask.TO_INVENTORY)
1265 result += toInventory;
1267 if (mask & ConsoleActionToolbarMask.DROP)
1271 if (mask & ConsoleActionToolbarMask.SPLIT)
1275 if (mask & ConsoleActionToolbarMask.EQUIP)
1279 if (mask & ConsoleActionToolbarMask.COMBINE)
1283 if (mask & ConsoleActionToolbarMask.MICROMANAGMENT)
1285 result += micromanagment;
1287 if (mask & ConsoleActionToolbarMask.QUICKSLOT)
1289 result += quickslot;
1313 #ifdef PLATFORM_CONSOLE
1314 void UpdateConsoleToolbarCheck()
1319 if (player.GetInventory().GetAnyInventoryReservationCount() == 0)
1331 #ifdef PLATFORM_CONSOLE
1332 int combinationFlag = 0;
1333 string contextualText;
1342 if (!(focusedItem && focusedItem.IsSetForDeletion()))
1344 if (focusedContainer)
1349 focusedItem.GetInventory().GetCurrentInventoryLocation( il );
1352 bool canBeManipulated =
false;
1362 itemPlayerOwner =
PlayerBase.Cast(focusedItem.GetHierarchyRootPlayer());
1364 focusedItem.GetInventory().GetCurrentInventoryLocation( il );
1366 canBeManipulated = !player.GetInventory().HasInventoryReservation( focusedItem,
null ) && !player.GetInventory().IsInventoryLocked() && !player.IsItemsToDelete();
1368 canBeManipulated = canBeManipulated && focusedItem.CanPutIntoHands(
null);
1369 canBeManipulated = canBeManipulated && focusedItem.GetInventory().CanRemoveEntity();
1374 canBeManipulated = canBeManipulated &&
AttachmentsOutOfReach.IsAttachmentReachable( parent,
"", il.GetSlot() );
1375 canBeManipulated = canBeManipulated && !parent.GetInventory().GetSlotLock( il.GetSlot() );
1378 if (canBeManipulated)
1380 if (!
ItemManager.GetInstance().IsMicromanagmentMode())
1382 combinationFlag |= ConsoleActionToolbarMask.MICROMANAGMENT;
1385 if (focusedContainer.CanEquipEx(focusedItem))
1387 combinationFlag |= ConsoleActionToolbarMask.EQUIP;
1390 if (player!=
null && player == itemPlayerOwner)
1392 if (focusedContainer.CanSwapOrTakeToHandsEx(focusedItem))
1394 combinationFlag |= ConsoleActionToolbarMask.TO_HANDS_SWAP_INVENTORY;
1397 if (focusedContainer.CanDropEx(focusedItem))
1399 combinationFlag |= ConsoleActionToolbarMask.DROP;
1404 if (focusedContainer.CanSwapOrTakeToHandsEx(focusedItem))
1406 combinationFlag |= ConsoleActionToolbarMask.TO_HANDS_SWAP_VICINITY;
1410 if (focusedContainer.CanCombineEx(focusedItem))
1412 combinationFlag |= ConsoleActionToolbarMask.COMBINE;
1415 if (focusedContainer.CanSplitEx(focusedItem))
1417 combinationFlag |= ConsoleActionToolbarMask.SPLIT;
1420 if (focusedArea.CanTakeToInventoryEx(focusedItem))
1422 combinationFlag |= ConsoleActionToolbarMask.TO_INVENTORY;
1427 if (focusedContainer.CanOpenCloseContainerEx(focusedItem))
1429 combinationFlag |= ConsoleActionToolbarMask.OPEN_CLOSE_CONTAINER;
1432 if (player!=
null && focusedContainer.CanAddToQuickbarEx(focusedItem))
1434 combinationFlag |= ConsoleActionToolbarMask.QUICKSLOT;
1438 contextualText = GetConsoleToolbarText(combinationFlag);
1454 if (variants.Count() != 3)
1456 ErrorEx(
"wrong array count!");
1461 if (!inp.IsLimited() || inp.IsClickLimit())
1465 if (inp.IsHoldLimit() || inp.IsHoldBeginLimit())
1469 if (inp.IsDoubleClickLimit())
1473 ErrorEx(
"Unhandled limiter exception!");
1528 if (!
ItemManager.GetInstance().IsMicromanagmentMode())
1539 if (!
ItemManager.GetInstance().IsMicromanagmentMode())
1545 EntityAI item_in_hands = player.GetItemInHands();
1563 if (!
ItemManager.GetInstance().IsMicromanagmentMode())
1569 item_in_hands = player.GetItemInHands();
1576 if (!
ItemManager.GetInstance().IsMicromanagmentMode())
1598 float tickvalue = 0;
1620 tickvalue += timeslice;