1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651 |
- #ifdef PLATFORM_CONSOLE
- enum ConsoleActionToolbarMask
- {
- EMPTY = 0,
- TO_HANDS_SWAP_VICINITY = 1,
- TO_HANDS_SWAP_INVENTORY = 2,
- DROP = 4,
- EQUIP = 8,
- SPLIT = 16,
- TO_INVENTORY = 32,
- OPEN_CLOSE_CONTAINER = 64,
- MICROMANAGMENT = 128,
- QUICKSLOT = 256,
- COMBINE = 512,
- }
- #endif
- enum Direction
- {
- RIGHT,
- LEFT,
- UP,
- DOWN
- }
- class Inventory: LayoutHolder
- {
- protected ref LeftArea m_LeftArea;
- protected ref RightArea m_RightArea;
- protected ref HandsArea m_HandsArea;
- protected ref PlayerPreview m_PlayerPreview;
- protected ref InventoryQuickbar m_Quickbar;
-
- protected Widget m_QuickbarWidget;
- protected Widget m_SpecializationPanel;
- protected Widget m_SpecializationIcon;
- protected Widget m_TopConsoleToolbarVicinity;
- protected Widget m_TopConsoleToolbarHands;
- protected Widget m_TopConsoleToolbarEquipment;
- protected Widget m_BottomConsoleToolbar;
- protected RichTextWidget m_BottomConsoleToolbarRichText;
- protected ref ContextMenu m_ContextMenu;
- protected static ref map<string, int> m_PlayerAttachmentsIndexes;
-
- protected bool m_HadFastTransferred;
- protected bool m_HadInspected;
- protected bool m_NeedUpdateConsoleToolbar;
-
- protected static Inventory m_Instance;
-
- protected int m_ControllerAngle;
- protected int m_ControllerTilt;
- protected bool m_ControllerRightStickTimerEnd = true;
- protected ref Timer m_ControllerRightStickTimer;
-
- protected bool m_HoldingQB;
- protected InventoryItem m_QBHoveredItems;
-
- ////////////////////
- const float BT_REPEAT_DELAY = 0.35; //delay from first press to begin tick repeat state
- const float BT_REPEAT_TIME = 0.09; //tick repeat frequency time
- const float BT_THRESHOLD_VALUE = 0.8; //threshold values for analog inputs
- const int INV_MOV_LEFT = 0;
- const int INV_MOV_RIGHT = 1;
- const int INV_MOV_UP = 2;
- const int INV_MOV_DOWN = 3;
- protected ref array<string> m_InvInputNames = {"UAUILeftInventory","UAUIRightInventory","UAUIUpInventory","UAUIDownInventory"};
- protected ref array<UAIDWrapper> m_InvInputWrappers;
- protected ref array<float> m_InvInputTimes;
- protected int m_InvInputWrappersCount;
- protected float m_SensitivityThreshold = 0.0;
- UAInput m_InvUAInput;
- int m_InvInputActive = 0;
-
- void Inventory(LayoutHolder parent)
- {
- m_Instance = this;
- LoadPlayerAttachmentIndexes();
-
- m_ControllerRightStickTimer = new Timer();
- new ItemManager(GetMainWidget());
- new ColorManager();
-
- m_LeftArea = new LeftArea(this);
- m_RightArea = new RightArea(this);
- m_HandsArea = new HandsArea(this);
- m_PlayerPreview = new PlayerPreview(this);
- m_QuickbarWidget = GetMainWidget().FindAnyWidget("QuickbarGrid");
- m_Quickbar = new InventoryQuickbar(m_QuickbarWidget);
- m_Quickbar.UpdateItems(m_QuickbarWidget);
-
- m_SpecializationPanel = GetMainWidget().FindAnyWidget("SpecializationPanelPanel");
- m_SpecializationIcon = GetMainWidget().FindAnyWidget("SpecializationIcon");
-
- WidgetEventHandler.GetInstance().RegisterOnDropReceived(GetMainWidget().FindAnyWidget("LeftBackground"), this, "OnLeftPanelDropReceived");
- WidgetEventHandler.GetInstance().RegisterOnDraggingOver(GetMainWidget().FindAnyWidget("LeftBackground"), this, "DraggingOverLeftPanel");
- WidgetEventHandler.GetInstance().RegisterOnDropReceived(GetMainWidget().FindAnyWidget("LeftPanel").FindAnyWidget("Scroller"), this, "OnLeftPanelDropReceived");
- WidgetEventHandler.GetInstance().RegisterOnDraggingOver(GetMainWidget().FindAnyWidget("LeftPanel").FindAnyWidget("Scroller"), this, "DraggingOverLeftPanel");
-
- WidgetEventHandler.GetInstance().RegisterOnDropReceived(GetMainWidget().FindAnyWidget("RightBackground"), this, "OnRightPanelDropReceived");
- WidgetEventHandler.GetInstance().RegisterOnDraggingOver(GetMainWidget().FindAnyWidget("RightBackground"), this, "DraggingOverRightPanel");
- WidgetEventHandler.GetInstance().RegisterOnDropReceived(GetMainWidget().FindAnyWidget("RightPanel").FindAnyWidget("Scroller"), this, "OnRightPanelDropReceived");
- WidgetEventHandler.GetInstance().RegisterOnDraggingOver(GetMainWidget().FindAnyWidget("RightPanel").FindAnyWidget("Scroller"), this, "DraggingOverRightPanel");
-
- WidgetEventHandler.GetInstance().RegisterOnDropReceived(GetMainWidget().FindAnyWidget("CharacterPanel"), this, "OnCenterPanelDropReceived");
- WidgetEventHandler.GetInstance().RegisterOnDraggingOver(GetMainWidget().FindAnyWidget("CharacterPanel"), this, "DraggingOverCenterPanel");
-
- WidgetEventHandler.GetInstance().RegisterOnDropReceived(GetMainWidget().FindAnyWidget("HandsPanel"), this, "OnHandsPanelDropReceived");
- WidgetEventHandler.GetInstance().RegisterOnDraggingOver(GetMainWidget().FindAnyWidget("HandsPanel"), this, "DraggingOverHandsPanel");
-
- #ifdef PLATFORM_CONSOLE
- PluginDiagMenu plugin_diag_menu = PluginDiagMenu.Cast(GetPlugin(PluginDiagMenu));
- GetGame().GetUIManager().ShowUICursor(false);
- ResetFocusedContainers();
- GetMainWidget().FindAnyWidget("CursorCharacter").Show(false);
- //console inventory toolbar
- m_TopConsoleToolbarVicinity = GetRootWidget().FindAnyWidget("LBRB_Vicinity");
- m_TopConsoleToolbarHands = GetRootWidget().FindAnyWidget("LBRB_Hands");
- m_TopConsoleToolbarEquipment = GetRootWidget().FindAnyWidget("LBRB_Equipment");
- RichTextWidget.Cast(m_TopConsoleToolbarVicinity.FindAnyWidget("LBRB_Vicinity_LBIcon")).SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIInventoryTabLeft", "", EUAINPUT_DEVICE_CONTROLLER));
- RichTextWidget.Cast(m_TopConsoleToolbarVicinity.FindAnyWidget("LBRB_Vicinity_RBIcon")).SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIInventoryTabRight", "", EUAINPUT_DEVICE_CONTROLLER));
- RichTextWidget.Cast(m_TopConsoleToolbarHands.FindAnyWidget("LBRB_Hands_LBIcon")).SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIInventoryTabLeft", "", EUAINPUT_DEVICE_CONTROLLER));
- RichTextWidget.Cast(m_TopConsoleToolbarHands.FindAnyWidget("LBRB_Hands_RBIcon")).SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIInventoryTabRight", "", EUAINPUT_DEVICE_CONTROLLER));
- RichTextWidget.Cast(m_TopConsoleToolbarEquipment.FindAnyWidget("LBRB_Equipment_LBIcon")).SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIInventoryTabLeft", "", EUAINPUT_DEVICE_CONTROLLER));
- RichTextWidget.Cast(m_TopConsoleToolbarEquipment.FindAnyWidget("LBRB_Equipment_RBIcon")).SetText(InputUtils.GetRichtextButtonIconFromInputAction("UAUIInventoryTabRight", "", EUAINPUT_DEVICE_CONTROLLER));
-
- m_BottomConsoleToolbar = GetRootWidget().FindAnyWidget("BottomConsoleToolbar");
- m_BottomConsoleToolbarRichText = RichTextWidget.Cast(GetRootWidget().FindAnyWidget("ContextToolbarText"));
-
- m_NeedUpdateConsoleToolbar = false;
-
- GetGame().GetMission().GetOnInputPresetChanged().Insert(OnInputPresetChanged);
- GetGame().GetMission().GetOnInputDeviceChanged().Insert(OnInputDeviceChanged);
-
- m_SpecializationPanel.Show(false);
- UpdateConsoleToolbar();
- InitInputWrapperData();
- #endif
- }
-
- void InitInputWrapperData()
- {
- int namesCount = m_InvInputNames.Count();
- m_InvInputWrappers = new array<UAIDWrapper>;
- m_InvInputTimes = new array<float>;
-
- for (int i = 0; i < namesCount; i++)
- {
- m_InvInputWrappers.Insert(GetUApi().GetInputByName(m_InvInputNames[i]).GetPersistentWrapper());
- m_InvInputTimes.Insert(0);
- }
-
- m_InvInputWrappersCount = m_InvInputWrappers.Count();
- }
-
- protected void OnInputPresetChanged()
- {
- #ifdef PLATFORM_CONSOLE
- UpdateConsoleToolbar();
- #endif
- }
-
- protected void OnInputDeviceChanged(EInputDeviceType pInputDeviceType)
- {
- switch (pInputDeviceType)
- {
- case EInputDeviceType.CONTROLLER:
- m_BottomConsoleToolbar.Show(true);
- UpdateConsoleToolbar();
- break;
-
- default:
- if (GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer())
- {
- m_BottomConsoleToolbar.Show(false);
- m_TopConsoleToolbarVicinity.Show(false);
- m_TopConsoleToolbarHands.Show(false);
- m_TopConsoleToolbarEquipment.Show(false);
- }
- break;
- }
- }
-
- static Inventory GetInstance()
- {
- return m_Instance;
- }
-
- void Serialize()
- {
- ItemManager.GetInstance().SerializeDefaultOpenStates();
- ItemManager.GetInstance().SerializeDefaultHeaderOpenStates();
- }
- void Deserialize()
- {
- ItemManager.GetInstance().DeserializeDefaultOpenStates();
- ItemManager.GetInstance().DeserializeDefaultHeaderOpenStates();
- }
- static int GetPlayerAttachmentIndex(string slot_name)
- {
- return m_PlayerAttachmentsIndexes[slot_name];
- }
-
- static int GetPlayerAttachmentIndex(int slot_id)
- {
- return GetPlayerAttachmentIndex(InventorySlots.GetSlotName(slot_id));
- }
-
- protected void LoadPlayerAttachmentIndexes()
- {
- int i;
- string data, errorMessage;
-
- m_PlayerAttachmentsIndexes = new map<string, int>();
- if (GetGame().GetProfileString("INV_AttIndexes", data))
- {
- if (!JsonFileLoader<map<string, int>>.LoadData(data, m_PlayerAttachmentsIndexes, errorMessage))
- ErrorEx(errorMessage);
- }
-
- string configPathGhostSlots = "CfgVehicles SurvivorBase InventoryEquipment playerSlots";
- array<string> playerGhostSlots = new array<string>();
- GetGame().ConfigGetTextArray(configPathGhostSlots, playerGhostSlots);
-
- foreach (string slotName : playerGhostSlots)
- {
- slotName.Replace("Slot_", "");
- if (!m_PlayerAttachmentsIndexes.Contains(slotName) && InventorySlots.GetSlotIdFromString(slotName) != -1)
- {
- m_PlayerAttachmentsIndexes.Insert(slotName, m_PlayerAttachmentsIndexes.Count());
- }
- }
-
- if (!JsonFileLoader<map<string, int>>.MakeData(m_PlayerAttachmentsIndexes, data, errorMessage))
- ErrorEx(errorMessage);
- GetGame().SetProfileString("INV_AttIndexes", data);
- }
-
- static void MoveAttachmentUp(int slot_id)
- {
- int curr = GetPlayerAttachmentIndex(slot_id);
-
- int next_offset = 0;
- string next_item = "init";
- int next_id;
- EntityAI next_ent;
-
- while(!next_ent && next_item != "")
- {
- next_item = m_PlayerAttachmentsIndexes.GetKeyByValue(curr + --next_offset);
- next_id = InventorySlots.GetSlotIdFromString(next_item);
- next_ent = GetGame().GetPlayer().GetInventory().FindAttachment(next_id);
- if (next_ent && !m_Instance.m_RightArea.HasEntityContainerVisible(next_ent))
- next_ent = null;
- }
-
- if (next_item != "" && next_ent)
- {
- int next = GetPlayerAttachmentIndex(next_item);
- m_PlayerAttachmentsIndexes.Set(InventorySlots.GetSlotName(slot_id), next);
- m_PlayerAttachmentsIndexes.Set(next_item, curr);
- if (m_Instance)
- m_Instance.m_RightArea.SwapItemsInOrder(next_id, slot_id);
- }
- }
-
- static void MoveAttachmentDown(int slot_id)
- {
- int curr = GetPlayerAttachmentIndex(slot_id);
-
- int next_offset = 0;
- string next_item = "init";
- int next_id;
- EntityAI next_ent;
-
- while(!next_ent && next_item != "")
- {
- next_item = m_PlayerAttachmentsIndexes.GetKeyByValue(curr + ++next_offset);
- next_id = InventorySlots.GetSlotIdFromString(next_item);
- next_ent = GetGame().GetPlayer().GetInventory().FindAttachment(next_id);
- if (next_ent && !m_Instance.m_RightArea.HasEntityContainerVisible(next_ent))
- next_ent = null;
- }
-
- if (next_item != "" && next_ent)
- {
- int next = GetPlayerAttachmentIndex(next_item);
- m_PlayerAttachmentsIndexes.Set(InventorySlots.GetSlotName(slot_id), next);
- m_PlayerAttachmentsIndexes.Set(next_item, curr);
- if (m_Instance)
- m_Instance.m_RightArea.SwapItemsInOrder(next_id, slot_id);
- }
- }
- protected int GetProperControllerStickAngle(int angle)
- {
- int proper_angle = (360 - angle) % 360;
- return proper_angle;
- }
- protected int AngleToDirection(int angle)
- {
- if (angle < 45 || angle > 315)
- {
- return Direction.RIGHT;
- }
- else if (angle < 135 && angle > 45)
- {
- return Direction.DOWN;
- }
- else if (angle < 225 && angle > 135)
- {
- return Direction.LEFT;
- }
- else if (angle < 315 && angle > 225)
- {
- return Direction.UP;
- }
- return -1;
- }
- void TimerEnd()
- {
- m_ControllerRightStickTimerEnd = true;
- m_ControllerRightStickTimer.Stop();
- }
- bool Controller(Widget w, int control, int value)
- {
- #ifdef PLATFORM_CONSOLE
-
- //Right stick
- if (control == ControlID.CID_RADIALMENU)
- {
- m_ControllerAngle = value >> 4; // <0,360>
- m_ControllerTilt = value & 0xF; // <0,10>
- m_ControllerAngle = GetProperControllerStickAngle(m_ControllerAngle);
- m_ControllerAngle = AngleToDirection(m_ControllerAngle);
- if (m_ControllerTilt>5)
- {
- if (m_ControllerRightStickTimerEnd)
- {
- m_ControllerRightStickTimerEnd = false;
- m_ControllerRightStickTimer.Run(0.1, this, "TimerEnd");
- }
- }
- return true;
- }
-
- UpdateConsoleToolbar();
- #endif
- return false;
- }
- void DraggingOverHandsPanel(Widget w, int x, int y, Widget receiver)
- {
- ItemManager.GetInstance().HideDropzones();
- m_HandsArea.DraggingOverHandsPanel(w, x, y, receiver);
- }
-
- void OnHandsPanelDropReceived(Widget w, int x, int y, Widget receiver)
- {
- m_HandsArea.OnHandsPanelDropReceived(w, x, y, receiver);
- }
- void OnLeftPanelDropReceived(Widget w, int x, int y, Widget receiver)
- {
- m_LeftArea.OnLeftPanelDropReceived(w, x, y, receiver);
- }
- void OnRightPanelDropReceived(Widget w, int x, int y, Widget receiver)
- {
- if (w)
- {
- ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
- if (!ipw)
- {
- string name = w.GetName();
- name.Replace("PanelWidget", "Render");
- ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
- if (!ipw)
- {
- ipw = ItemPreviewWidget.Cast(w);
- if (!ipw)
- {
- return;
- }
- }
- }
-
- EntityAI item = ipw.GetItem();
- if (item)
- {
- PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
- InventoryLocation il = new InventoryLocation;
- if (player && player.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.CARGO | FindInventoryLocationType.ATTACHMENT, il))
- {
- SplitItemUtils.TakeOrSplitToInventory(player, player, item);
- }
- }
- }
- }
-
- void OnCenterPanelDropReceived(Widget w, int x, int y, Widget receiver)
- {
- if (w)
- {
- ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
- if (!ipw)
- {
- string name = w.GetName();
- name.Replace("PanelWidget", "Render");
- ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
- if (!ipw)
- {
- ipw = ItemPreviewWidget.Cast(w);
- if (!ipw)
- {
- return;
- }
- }
- }
-
- EntityAI item = ipw.GetItem();
- if (item)
- {
- if (!item.GetInventory().CanRemoveEntity())
- return;
- PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
-
- bool found = false;
-
- InventoryLocation inv_loc = new InventoryLocation;
-
- if (player)
- {
- int index = player.GetHumanInventory().FindUserReservedLocationIndex(item);
- if (index>=0)
- {
- player.GetHumanInventory().GetUserReservedLocation(index, inv_loc);
- if (player.GetInventory().LocationCanAddEntity(inv_loc))
- {
- SplitItemUtils.TakeOrSplitToInventoryLocation(player, inv_loc);
- }
- return;
- }
-
- }
-
- if (player && (player.GetInventory().CanAddAttachment(item)))
- {
- float stackable = item.GetTargetQuantityMax(-1);
-
- if (stackable == 0 || stackable >= item.GetQuantity())
- {
- player.PredictiveTakeEntityAsAttachment(item);
- }
- else
- {
- InventoryLocation il = new InventoryLocation;
- player.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.ATTACHMENT, il);
- ItemBase.Cast(item).SplitIntoStackMaxToInventoryLocationClient(il);
- }
- }
- else
- {
- int slot_id = item.GetInventory().GetSlotId(0);
- EntityAI slot_item = player.GetInventory().FindAttachment(slot_id);
- if (slot_item && player.GetInventory().CanSwapEntitiesEx(item, slot_item))
- {
- player.PredictiveSwapEntities(item, slot_item);
- }
- else if (player.CanReceiveItemIntoCargo(item))
- {
- InventoryLocation dst = new InventoryLocation;
- player.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.ANY, dst);
- if (dst.IsValid())
- {
- if (dst.GetType() == InventoryLocationType.HANDS && item.IsHeavyBehaviour())
- {
- ActionManagerClient mngr_client;
- CastTo(mngr_client, player.GetActionManager());
-
- ActionTarget atrg = new ActionTarget(item, null, -1, vector.Zero, -1.0);
- if (mngr_client.GetAction(ActionTakeItemToHands).Can(player, atrg, null))
- mngr_client.PerformActionStart(mngr_client.GetAction(ActionTakeItemToHands), atrg, null);
-
- return;
- }
-
- SplitItemUtils.TakeOrSplitToInventoryLocation(player, dst);
- }
- }
- }
- }
- }
- }
- void DraggingOverLeftPanel(Widget w, int x, int y, Widget receiver)
- {
- m_LeftArea.DraggingOverHeader(w, x, y, receiver);
- }
- void DraggingOverRightPanel(Widget w, int x, int y, Widget receiver)
- {
- m_RightArea.DraggingOverHeader(w, x, y, receiver);
- }
-
- void DraggingOverCenterPanel(Widget w, int x, int y, Widget receiver)
- {
- if (w)
- {
- ItemPreviewWidget ipw = ItemPreviewWidget.Cast(w.FindAnyWidget("Render"));
- if (!ipw)
- {
- string name = w.GetName();
- name.Replace("PanelWidget", "Render");
- ipw = ItemPreviewWidget.Cast(w.FindAnyWidget(name));
- if (!ipw)
- {
- ipw = ItemPreviewWidget.Cast(w);
- if (!ipw)
- {
- return;
- }
- }
- }
-
- EntityAI item = ipw.GetItem();
- PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
-
- if (player && item)
- {
- int slot_id = item.GetInventory().GetSlotId(0);
- EntityAI slot_item = player.GetInventory().FindAttachment(slot_id);
- bool found = false;
-
- InventoryLocation inv_loc = new InventoryLocation;
-
- int index = player.GetHumanInventory().FindUserReservedLocationIndex(item);
- if (index>=0)
- {
- player.GetHumanInventory().GetUserReservedLocation(index, inv_loc);
- if (player.GetInventory().LocationCanAddEntity(inv_loc))
- found = true;
- }
-
- if (!found)
- {
- player.GetInventory().FindFreeLocationFor(item, FindInventoryLocationType.ANY, inv_loc);
- }
-
-
- if (inv_loc.IsValid())
- {
- ItemManager.GetInstance().HideDropzones();
- GetMainWidget().FindAnyWidget("RightPanel").FindAnyWidget("DropzoneX").SetAlpha(1);
- if (inv_loc.GetType() == 4)
- {
- ItemManager.GetInstance().HideDropzones();
- GetMainWidget().FindAnyWidget("HandsPanel").FindAnyWidget("DropzoneX").SetAlpha(1);
- }
-
- ColorManager.GetInstance().SetColor(w, ColorManager.GREEN_COLOR);
- }
- else
- {
- ItemManager.GetInstance().ShowSourceDropzone(item);
- ColorManager.GetInstance().SetColor(w, ColorManager.RED_COLOR);
- }
- }
- else
- {
- ColorManager.GetInstance().SetColor(w, ColorManager.RED_COLOR);
- }
- }
- }
- void Update(float timeslice)
- {
- #ifdef PLATFORM_CONSOLE
- //inventory grid movement
- InventoryMovementButtonTickHandler(timeslice);
-
- if (m_InvInputActive & (1 << INV_MOV_RIGHT))
- {
- if (GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
- {
- EnableMicromanagement();
- }
-
- if (!GetUApi().GetInputByID(UAUIInventoryTabRight).LocalValue())
- {
- if (m_RightArea.IsActive())
- m_RightArea.MoveGridCursor(Direction.RIGHT);
- if (m_LeftArea.IsActive())
- m_LeftArea.MoveGridCursor(Direction.RIGHT);
- if (m_HandsArea.IsActive())
- m_HandsArea.MoveGridCursor(Direction.RIGHT);
- }
- }
- else if (m_InvInputActive & (1 << INV_MOV_LEFT))
- {
- if (GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
- {
- EnableMicromanagement();
- }
-
- if (!GetUApi().GetInputByID(UAUIInventoryTabLeft).LocalValue())
- {
- if (m_RightArea.IsActive())
- m_RightArea.MoveGridCursor(Direction.LEFT);
- if (m_LeftArea.IsActive())
- m_LeftArea.MoveGridCursor(Direction.LEFT);
- if (m_HandsArea.IsActive())
- m_HandsArea.MoveGridCursor(Direction.LEFT);
- }
- }
- else if (m_InvInputActive & (1 << INV_MOV_UP))
- {
- if (GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
- {
- EnableMicromanagement();
- }
-
- if (!GetUApi().GetInputByID(UAUIInventoryContainerUp).LocalValue())
- {
- if (m_RightArea.IsActive())
- m_RightArea.MoveGridCursor(Direction.UP);
- if (m_LeftArea.IsActive())
- m_LeftArea.MoveGridCursor(Direction.UP);
- if (m_HandsArea.IsActive())
- m_HandsArea.MoveGridCursor(Direction.UP);
- }
- }
- else if (m_InvInputActive & (1 << INV_MOV_DOWN))
- {
- if (GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
- {
- EnableMicromanagement();
- }
-
- if (!GetUApi().GetInputByID(UAUIInventoryContainerDown).LocalValue())
- {
- if (m_RightArea.IsActive())
- m_RightArea.MoveGridCursor(Direction.DOWN);
- if (m_LeftArea.IsActive())
- m_LeftArea.MoveGridCursor(Direction.DOWN);
- if (m_HandsArea.IsActive())
- m_HandsArea.MoveGridCursor(Direction.DOWN);
- }
- }
-
- m_InvInputActive = 0;
- #endif
-
- UpdateInterval();
- }
-
- UAInput m_InpInp = null;
- override void UpdateInterval()
- {
- PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
- InventoryItem item;
- if (GetUApi().GetInputByID(UAUIRotateInventory).LocalPress())
- {
- item = InventoryItem.Cast(ItemManager.GetInstance().GetDraggedItem());
- if (item)
- {
- int size_x, size_y;
- GetGame().GetInventoryItemSize(item, size_x, size_y);
- if (size_x != size_y)
- {
- item.GetInventory().FlipCargo();
- item.GetOnItemFlipped().Invoke(item.GetInventory().GetFlipCargo());
- }
- }
- }
-
- #ifdef PLATFORM_CONSOLE
- DayZPlayerInventory dpi;
- if (player)
- dpi = player.GetDayZPlayerInventory();
-
- // There's a second one a bit below
- if (dpi && !dpi.IsProcessing())
- {
- if (GetUApi().GetInputByID(UAUIExpandCollapseContainer).LocalPress())
- {
- if (m_RightArea.IsActive())
- {
- m_RightArea.ExpandCollapseContainer();
- }
- else if (m_LeftArea.IsActive())
- {
- m_LeftArea.ExpandCollapseContainer();
- }
- }
-
- if (GetUApi().GetInputByID(UAUIDragNDrop).LocalHoldBegin())
- {
- EnableMicromanagement();
- }
-
- if (GetUApi().GetInputByID(UAUISplit).LocalPress())
- {
- if (m_HandsArea.IsActive())
- {
- if (m_HandsArea.SplitItem())
- {
- m_HandsArea.SetActive(false);
- m_HandsArea.UnfocusGrid();
- m_RightArea.SetActive(true);
- }
- }
- else if (m_RightArea.IsActive())
- {
- m_RightArea.SplitItem();
- }
- else if (m_LeftArea.IsActive())
- {
- m_LeftArea.SplitItem();
- }
-
- HideOwnedTooltip();
- }
-
- if (GetUApi().GetInputByID(UAUIFastEquip).LocalPress())
- {
- if (m_HandsArea.IsActive())
- {
- if (m_HandsArea.EquipItem())
- {
- m_HandsArea.SetActive(false);
- m_HandsArea.UnfocusGrid();
- m_RightArea.SetActive(true);
- }
- }
- else if (m_RightArea.IsActive())
- {
- m_RightArea.EquipItem();
- }
- else if (m_LeftArea.IsActive())
- {
- m_LeftArea.EquipItem();
- }
-
- UpdateConsoleToolbar();
- HideOwnedTooltip();
- }
-
- if (ItemManager.GetInstance().IsMicromanagmentMode() && GetUApi().GetInputByID(UAUIDragNDrop).LocalRelease())
- {
- if (m_RightArea.IsActive())
- {
- m_RightArea.Select();
- }
- else if (m_LeftArea.IsActive())
- {
- m_LeftArea.Select();
- }
- else if (m_HandsArea.IsActive())
- {
- m_HandsArea.Select();
- }
-
- DisableMicromanagement();
- UpdateConsoleToolbar();
- }
- if (GetUApi().GetInputByID(UAUIPutInHandsFromVicinity).LocalPress())
- {
- if (m_LeftArea.IsActive())
- {
- if (m_LeftArea.Select())
- {
- m_LeftArea.SetActive(false);
- m_LeftArea.UnfocusGrid();
- m_HandsArea.SetActive(true);
-
- UpdateConsoleToolbar();
- }
- }
- }
- if (GetUApi().GetInputByID(UAUIPutInHandsFromInventory).LocalPress())
- {
- if (m_RightArea.IsActive())
- {
- if (m_RightArea.Select())
- {
- m_RightArea.SetActive(false);
- m_RightArea.UnfocusGrid();
- m_HandsArea.SetActive(true);
-
- UpdateConsoleToolbar();
- }
- }
- }
-
- if (GetUApi().GetInputByID(UAUIFastTransferToVicinity).LocalPress()) //item drop
- {
- if (m_HandsArea.IsActive())
- {
- item = InventoryItem.Cast(m_HandsArea.GetFocusedItem());
- if (item && item.GetInventory().CanRemoveEntity())
- {
- if (m_HandsArea.TransferItemToVicinity())
- {
- m_HandsArea.SetActive(false);
- m_HandsArea.UnfocusGrid();
- m_LeftArea.SetActive(true);
- m_HadFastTransferred = true;
- }
- }
- }
- else if (m_RightArea.IsActive())
- {
- item = InventoryItem.Cast(m_RightArea.GetFocusedItem());
- if (item && item.GetInventory().CanRemoveEntity())
- {
- if (m_RightArea.TransferItemToVicinity())
- m_HadFastTransferred = true;
- }
- }
-
- UpdateConsoleToolbar();
- HideOwnedTooltip();
- }
- }
-
- if (GetUApi().GetInputByID(UAUIInspectItem).LocalPress())
- {
- if (m_HandsArea.IsActive())
- {
- if (m_HandsArea.InspectItem())
- {
- m_HadInspected = true;
- }
- }
- else if (m_RightArea.IsActive())
- {
- if (m_RightArea.InspectItem())
- {
- m_HadInspected = true;
- }
- }
- else if (m_LeftArea.IsActive())
- {
- if (m_LeftArea.InspectItem())
- {
- m_HadInspected = true;
- }
- }
-
- UpdateConsoleToolbar();
- }
-
- if (GetUApi().GetInputByID(UAUIFastTransferItem).LocalPress())
- m_HadFastTransferred = false;
-
- if (GetUApi().GetInputByID(UAUIInspectItem).LocalPress())
- m_HadInspected = false;
-
- if (dpi && !dpi.IsProcessing())
- {
- if (!m_HadFastTransferred && GetUApi().GetInputByID(UAUIFastTransferItem).LocalPress()) //transfers item to inventory (not hands, or hands last?)
- {
- if (m_LeftArea.IsActive())
- {
- item = InventoryItem.Cast(m_LeftArea.GetFocusedItem());
- if (item && item.GetInventory().CanRemoveEntity())
- {
- m_LeftArea.TransferItem();
- }
- }
- else if (m_HandsArea.IsActive())
- {
- item = InventoryItem.Cast(m_HandsArea.GetFocusedItem());
- if (item && item.GetInventory().CanRemoveEntity())
- {
- if (m_HandsArea.TransferItem())
- {
- m_HandsArea.SetActive(false);
- m_HandsArea.UnfocusGrid();
- m_RightArea.SetActive(true);
- }
- }
- }
-
- UpdateConsoleToolbar();
- HideOwnedTooltip();
- }
- }
-
- if (GetUApi().GetInputByID(UAUIInventoryContainerUp).LocalPress())
- {
- if (GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
- {
- EnableMicromanagement();
- }
-
- MoveFocusByContainer(Direction.UP);
- }
- if (GetUApi().GetInputByID(UAUIInventoryContainerDown).LocalPress())
- {
- if (GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
- {
- EnableMicromanagement();
- }
-
- MoveFocusByContainer(Direction.DOWN);
- }
- if (GetUApi().GetInputByID(UAUIInventoryTabLeft).LocalPress())
- {
- if (GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
- {
- EnableMicromanagement();
- }
-
- MoveFocusByArea(Direction.LEFT);
- }
- if (GetUApi().GetInputByID(UAUIInventoryTabRight).LocalPress())
- {
- if (GetUApi().GetInputByID(UAUIDragNDrop).LocalValue())
- {
- EnableMicromanagement();
- }
-
- MoveFocusByArea(Direction.RIGHT);
- }
-
- //Open Quickbar radial menu
- if (GetUApi().GetInputByID(UAUIQuickbarRadialInventoryOpen).LocalPress())
- {
- //assign item
- EntityAI item_to_assign;
-
- if (m_HandsArea.IsActive())
- {
- player = PlayerBase.Cast(GetGame().GetPlayer());
- item_to_assign = m_HandsArea.GetFocusedItem();
- m_HandsArea.AddItemToQuickbarRadial(item_to_assign);
- }
- else if (m_RightArea.IsActive())
- {
- item_to_assign = m_RightArea.GetFocusedItem();
- m_RightArea.AddItemToQuickbarRadial(item_to_assign);
- }
- }
- #endif
-
- MissionGameplay mission = MissionGameplay.Cast(GetGame().GetMission());
- if (!m_HadInspected && GetUApi().GetInputByID(UAUICombine).LocalPress())
- {
- if (GetMainWidget().IsVisible())
- {
- #ifdef PLATFORM_CONSOLE
- //DisableMicromanagement();
- if (m_RightArea.IsActive())
- {
- if (m_RightArea.CanCombine())
- {
- if (m_RightArea.Combine())
- {
- mission.HideInventory();
- }
- }
- }
- else if (m_LeftArea.IsActive())
- {
- if (m_LeftArea.CanCombine())
- {
- if (m_LeftArea.Combine())
- {
- mission.HideInventory();
- }
- }
- }
- #endif
- }
- }
-
- // controller close inventory using back action
- if (!m_HadInspected && GetUApi().GetInputByID(UAUIBack).LocalPress() && GetGame().GetInput().GetCurrentInputDevice() == EInputDeviceType.CONTROLLER)
- {
- mission.HideInventory();
- }
-
- for (int i = 0; i < 10; i++)
- {
- if (!m_HoldingQB && GetUApi().GetInputByName("UAItem" + i).LocalPress())
- {
- m_QBHoveredItems = InventoryItem.Cast(ItemManager.GetInstance().GetHoveredItem());
- m_HoldingQB = true;
- }
-
- if (m_HoldingQB && GetUApi().GetInputByName("UAItem" + i).LocalHold())
- {
-
- AddQuickbarItem(m_QBHoveredItems, i);
- m_QBHoveredItems = null;
- m_HoldingQB = false;
- }
- }
- m_LeftArea.UpdateInterval();
- m_RightArea.UpdateInterval();
- m_HandsArea.UpdateInterval();
- m_PlayerPreview.UpdateInterval();
-
- #ifdef PLATFORM_CONSOLE
- UpdateConsoleToolbarCheck();
- #endif
- }
-
- void AddQuickbarItem(InventoryItem item, int index)
- {
- PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
-
- if (item && item.GetInventory().CanRemoveEntity())
- {
- player.SetQuickBarEntityShortcut(item, index) ;
- }
-
- InventoryMenu menu = InventoryMenu.Cast(GetGame().GetUIManager().FindMenu(MENU_INVENTORY));
- if (menu)
- {
- menu.RefreshQuickbar();
- }
- }
-
- void EnableMicromanagement()
- {
- if (!ItemManager.GetInstance().IsMicromanagmentMode())
- {
- ItemManager.GetInstance().SetItemMicromanagmentMode(true);
- if (m_RightArea.IsActive())
- {
- m_RightArea.SelectItem();
- }
- else if (m_LeftArea.IsActive())
- {
- m_LeftArea.SelectItem();
- }
- else if (m_HandsArea.IsActive())
- {
- m_HandsArea.SelectItem();
- }
-
- UpdateConsoleToolbar();
- HideOwnedTooltip();
- }
- }
-
- void DisableMicromanagement()
- {
- if (ItemManager.GetInstance().IsMicromanagmentMode())
- {
- ItemManager.GetInstance().SetItemMicromanagmentMode(false);
- ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
- UpdateConsoleToolbar();
- HideOwnedTooltip();
- }
- }
- override void SetLayoutName()
- {
- #ifdef PLATFORM_CONSOLE
- m_LayoutName = WidgetLayoutName.InventoryXbox;
- #else
- switch (InventoryMenu.GetWidthType())
- {
- case ScreenWidthType.NARROW:
- {
- m_LayoutName = WidgetLayoutName.InventoryNarrow;
- break;
- }
- case ScreenWidthType.MEDIUM:
- {
- m_LayoutName = WidgetLayoutName.InventoryMedium;
- break;
- }
- case ScreenWidthType.WIDE:
- {
- m_LayoutName = WidgetLayoutName.InventoryWide;
- break;
- }
- }
- #endif
- }
- void Init() {}
- void Reset()
- {
- m_LeftArea.Refresh();
- m_RightArea.Refresh();
- m_HandsArea.Refresh();
- }
-
- void ResetFocusedContainers()
- {
- #ifdef PLATFORM_CONSOLE
- m_RightArea.UnfocusGrid();
- m_LeftArea.UnfocusGrid();
- m_HandsArea.UnfocusGrid();
-
- m_LeftArea.SetActive(false);
- m_HandsArea.SetActive(false);
- m_RightArea.SetActive(false);
-
- m_RightArea.ResetFocusedContainer();
- m_LeftArea.ResetFocusedContainer();
-
- m_RightArea.SetActive(true);
- #endif
- }
- override void OnShow()
- {
- SetFocus(GetMainWidget());
- Deserialize();
-
- PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
- if (player && player.IsPlacingLocal())
- {
- GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).Call(player.TogglePlacingLocal);
- }
- Mission mission = GetGame().GetMission();
- if (mission)
- {
- IngameHud hud = IngameHud.Cast(mission.GetHud());
- if (hud)
- {
- hud.ShowQuickbarUI(false);
- hud.ShowHudInventory(true);
- }
- }
-
- m_SpecializationPanel.Show(false);
-
- #ifdef PLATFORM_CONSOLE
- ResetFocusedContainers();
- #endif
-
- RefreshQuickbar();
- UpdateInterval();
- UpdateConsoleToolbar();
-
- m_HadFastTransferred = false;
- m_HadInspected = false;
-
- m_PlayerPreview.RefreshPlayerPreview();
- }
- override void OnHide()
- {
- Serialize();
- HideOwnedTooltip();
- Mission mission = GetGame().GetMission();
- if (mission)
- {
- IngameHud hud = IngameHud.Cast(mission.GetHud());
- if (hud)
- {
- hud.ShowQuickbarUI(true);
- hud.ShowHudInventory(false);
- }
- }
- ItemManager.GetInstance().SetSelectedItemEx(null, null, null);
- }
-
- void UpdateSpecialtyMeter()
- {
- PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
- if (player && player.GetSoftSkillsManager())
- {
- float x = player.GetSoftSkillsManager().GetSpecialtyLevel() / 2;
- float y = -0.75;
- #ifndef PLATFORM_CONSOLE
- m_SpecializationIcon.SetPos(x, y, true);
- #else
- Mission mission = GetGame().GetMission();
- IngameHud hud = IngameHud.Cast(mission.GetHud());
- if (hud)
- {
- hud.UpdateSpecialtyMeter(x,y);
- }
- #endif
- }
- }
-
- override void Refresh()
- {
- m_LeftArea.Refresh();
- m_HandsArea.Refresh();
- m_RightArea.Refresh();
-
- RefreshQuickbar();
- UpdateConsoleToolbar();
- }
-
- void RefreshQuickbar()
- {
- #ifndef PLATFORM_CONSOLE
- m_QuickbarWidget.Show(true);
- #else
- m_QuickbarWidget.Show(GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer());
- #endif
-
- #ifndef PLATFORM_CONSOLE
- if (m_Quickbar)
- #else
- if (m_Quickbar && GetGame().GetInput().IsEnabledMouseAndKeyboardEvenOnServer())
- #endif
- {
- m_Quickbar.UpdateItems(m_QuickbarWidget);
- }
- }
-
- #ifdef PLATFORM_CONSOLE
- protected string GetConsoleToolbarText(int mask)
- {
- string result = "";
-
- string toHandsSwapVicinity = string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUIPutInHandsFromVicinity", GetStringVariant("UAUIPutInHandsFromVicinity",{"#STR_Controls_TakeInHandsSwap","#STR_USRACT_HoldToHandSwap",""}), EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
- string toHandsSwapInv = string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUIPutInHandsFromInventory", GetStringVariant("UAUIPutInHandsFromInventory",{"#STR_Controls_TakeInHandsSwap","#STR_USRACT_HoldToHandSwap",""}), EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
- string drop = string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUIFastTransferToVicinity", "#dayz_context_menu_drop", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
- string equip = string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUIFastEquip", "#dayz_context_menu_equip", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
- string split = string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUISplit", GetStringVariant("UAUISplit",{"#dayz_context_menu_split","#STR_Controls_HoldSplit",""}), EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
- string toInventory = string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUIFastTransferItem", "#dayz_context_menu_to_inventory", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
- string openCloseContainer = string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUIExpandCollapseContainer", "#dayz_context_menu_open_close", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
- string micromanagment = string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUIDragNDrop", "#dayz_context_menu_micro", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
- string quickslot = string.Format(" %1", InputUtils.GetRichtextButtonIconFromInputAction("UAUIQuickbarRadialInventoryOpen", "#ps4_dayz_context_menu_quickslot", EUAINPUT_DEVICE_CONTROLLER, InputUtils.ICON_SCALE_TOOLBAR));
- 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));
-
- if (mask & ConsoleActionToolbarMask.OPEN_CLOSE_CONTAINER)
- {
- result += openCloseContainer;
- }
- if (mask & ConsoleActionToolbarMask.TO_HANDS_SWAP_VICINITY)
- {
- result += toHandsSwapVicinity;
- }
- if (mask & ConsoleActionToolbarMask.TO_HANDS_SWAP_INVENTORY)
- {
- result += toHandsSwapInv;
- }
- if (mask & ConsoleActionToolbarMask.TO_INVENTORY)
- {
- result += toInventory;
- }
- if (mask & ConsoleActionToolbarMask.DROP)
- {
- result += drop;
- }
- if (mask & ConsoleActionToolbarMask.SPLIT)
- {
- result += split;
- }
- if (mask & ConsoleActionToolbarMask.EQUIP)
- {
- result += equip;
- }
- if (mask & ConsoleActionToolbarMask.COMBINE)
- {
- result += combine;
- }
- if (mask & ConsoleActionToolbarMask.MICROMANAGMENT)
- {
- result += micromanagment;
- }
- if (mask & ConsoleActionToolbarMask.QUICKSLOT)
- {
- result += quickslot;
- }
- return result;
- }
- #endif
- Container GetFocusedArea()
- {
- if (m_LeftArea && m_LeftArea.IsActive())
- {
- return m_LeftArea;
- }
- else if (m_RightArea && m_RightArea.IsActive())
- {
- return m_RightArea;
- }
- else if (m_HandsArea && m_HandsArea.IsActive())
- {
- return m_HandsArea;
- }
- return null;
- }
-
- #ifdef PLATFORM_CONSOLE
- void UpdateConsoleToolbarCheck()
- {
- if ( m_NeedUpdateConsoleToolbar )
- {
- PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
- if (player.GetInventory().GetAnyInventoryReservationCount() == 0)
- {
- m_NeedUpdateConsoleToolbar = false;
- UpdateConsoleToolbar();
- }
- }
- }
- #endif
-
- //Console toolbar
- void UpdateConsoleToolbar()
- {
- #ifdef PLATFORM_CONSOLE
- int combinationFlag = 0;
- string contextualText;
- InventoryLocation il;
-
- Container focusedArea = GetFocusedArea();
- if (focusedArea)
- {
- Container focusedContainer = GetFocusedArea().GetFocusedContainer();
- EntityAI focusedItem = GetFocusedArea().GetFocusedItem();
-
- if (!(focusedItem && focusedItem.IsSetForDeletion()))
- {
- if (focusedContainer)
- {
- if (focusedItem)
- {
- il = new InventoryLocation;
- focusedItem.GetInventory().GetCurrentInventoryLocation( il );
- }
-
- bool canBeManipulated = false;
- PlayerBase player;
- PlayerBase itemPlayerOwner;
-
- player = PlayerBase.Cast(GetGame().GetPlayer());
-
- m_NeedUpdateConsoleToolbar = player.GetInventory().GetAnyInventoryReservationCount() > 0;
-
- if (focusedItem)
- {
- itemPlayerOwner = PlayerBase.Cast(focusedItem.GetHierarchyRootPlayer());
- il = new InventoryLocation;
- focusedItem.GetInventory().GetCurrentInventoryLocation( il );
-
- canBeManipulated = !player.GetInventory().HasInventoryReservation( focusedItem, null ) && !player.GetInventory().IsInventoryLocked() && !player.IsItemsToDelete();
- m_NeedUpdateConsoleToolbar |= !canBeManipulated;
- canBeManipulated = canBeManipulated && focusedItem.CanPutIntoHands(null);
- canBeManipulated = canBeManipulated && focusedItem.GetInventory().CanRemoveEntity();
-
- EntityAI parent = il.GetParent();
- if ( parent && il.GetType() == InventoryLocationType.ATTACHMENT )
- {
- canBeManipulated = canBeManipulated && AttachmentsOutOfReach.IsAttachmentReachable( parent, "", il.GetSlot() );
- canBeManipulated = canBeManipulated && !parent.GetInventory().GetSlotLock( il.GetSlot() );
- }
-
- if (canBeManipulated)
- {
- if (!ItemManager.GetInstance().IsMicromanagmentMode())
- {
- combinationFlag |= ConsoleActionToolbarMask.MICROMANAGMENT;
- }
-
- if (focusedContainer.CanEquipEx(focusedItem))
- {
- combinationFlag |= ConsoleActionToolbarMask.EQUIP;
- }
-
- if (player!= null && player == itemPlayerOwner)
- {
- if (focusedContainer.CanSwapOrTakeToHandsEx(focusedItem))
- {
- combinationFlag |= ConsoleActionToolbarMask.TO_HANDS_SWAP_INVENTORY;
- }
-
- if (focusedContainer.CanDropEx(focusedItem))
- {
- combinationFlag |= ConsoleActionToolbarMask.DROP;
- }
- }
- else
- {
- if (focusedContainer.CanSwapOrTakeToHandsEx(focusedItem))
- {
- combinationFlag |= ConsoleActionToolbarMask.TO_HANDS_SWAP_VICINITY;
- }
- }
-
- if (focusedContainer.CanCombineEx(focusedItem))
- {
- combinationFlag |= ConsoleActionToolbarMask.COMBINE;
- }
-
- if (focusedContainer.CanSplitEx(focusedItem))
- {
- combinationFlag |= ConsoleActionToolbarMask.SPLIT;
- }
-
- if (focusedArea.CanTakeToInventoryEx(focusedItem))
- {
- combinationFlag |= ConsoleActionToolbarMask.TO_INVENTORY;
- }
- }
- }
-
- if (focusedContainer.CanOpenCloseContainerEx(focusedItem))
- {
- combinationFlag |= ConsoleActionToolbarMask.OPEN_CLOSE_CONTAINER;
- }
-
- if (player!= null && focusedContainer.CanAddToQuickbarEx(focusedItem))
- {
- combinationFlag |= ConsoleActionToolbarMask.QUICKSLOT;
- }
- }
- }
- contextualText = GetConsoleToolbarText(combinationFlag);
- if (m_TopConsoleToolbarVicinity)
- m_TopConsoleToolbarVicinity.Show(m_LeftArea.IsActive());
- if (m_TopConsoleToolbarHands)
- m_TopConsoleToolbarHands.Show(m_HandsArea.IsActive());
- if (m_TopConsoleToolbarEquipment)
- m_TopConsoleToolbarEquipment.Show(m_RightArea.IsActive());
- if (m_BottomConsoleToolbarRichText)
- m_BottomConsoleToolbarRichText.SetText(contextualText + " ");
- }
- #endif
- }
-
- //! Picks from the strings by active input limiter variant in order: {click,hold,doubleclick}. Intended for inputs that check 'LocalPress' exclusively!!
- string GetStringVariant(string pInputAction, notnull array<string> variants)
- {
- if (variants.Count() != 3)
- {
- ErrorEx("wrong array count!");
- return "";
- }
-
- UAInput inp = GetUApi().GetInputByName(pInputAction);
- if (!inp.IsLimited() || inp.IsClickLimit()) //returns 'click' (no extension) variant as default
- {
- return variants[0];
- }
- if (inp.IsHoldLimit() || inp.IsHoldBeginLimit())
- {
- return variants[1];
- }
- if (inp.IsDoubleClickLimit())
- {
- return variants[2];
- }
- ErrorEx("Unhandled limiter exception!");
- return "";
- }
-
- //! Shifts between containers vertically
- void MoveFocusByContainer(int direction)
- {
- HideOwnedTooltip();
-
- if (direction == Direction.UP)
- {
- if ( m_LeftArea.IsActive() )
- {
- m_LeftArea.SetSameLevelPreviousActive();
- }
- else if ( m_RightArea.IsActive() )
- {
- m_RightArea.SetSameLevelPreviousActive();
- }
- else if ( m_HandsArea.IsActive() )
- {
- m_HandsArea.SetSameLevelPreviousActive();
- }
-
- UpdateConsoleToolbar();
- }
- else if (direction == Direction.DOWN)
- {
- if ( m_LeftArea.IsActive() )
- {
- m_LeftArea.SetSameLevelNextActive();
- }
- else if ( m_RightArea.IsActive() )
- {
- m_RightArea.SetSameLevelNextActive();
- }
- else if ( m_HandsArea.IsActive() )
- {
- m_HandsArea.SetSameLevelNextActive();
- }
-
- UpdateConsoleToolbar();
- }
- }
-
- //! Shifts between vicinity-hands-player
- void MoveFocusByArea(int direction)
- {
- HideOwnedTooltip();
- PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
-
- if (direction == Direction.LEFT)
- {
- if (m_LeftArea.IsActive())
- {
- if (!ItemManager.GetInstance().IsMicromanagmentMode())
- {
- m_LeftArea.UnfocusGrid();
- }
- m_LeftArea.SetActive(false);
- m_RightArea.SetActive(true);
-
- UpdateConsoleToolbar();
- }
- else if (m_RightArea.IsActive())
- {
- if (!ItemManager.GetInstance().IsMicromanagmentMode())
- {
- m_RightArea.UnfocusGrid();
- }
- m_RightArea.SetActive(false);
- player = PlayerBase.Cast(GetGame().GetPlayer());
- EntityAI item_in_hands = player.GetItemInHands();
- m_HandsArea.SetActive(true);
- UpdateConsoleToolbar();
- }
- else if (m_HandsArea.IsActive())
- {
- m_HandsArea.UnfocusGrid();
- m_HandsArea.SetActive(false);
- m_LeftArea.SetActive(true);
-
- UpdateConsoleToolbar();
- }
- }
- else if (direction == Direction.RIGHT)
- {
- if (m_LeftArea.IsActive())
- {
- if (!ItemManager.GetInstance().IsMicromanagmentMode())
- {
- m_LeftArea.UnfocusGrid();
- }
- m_LeftArea.SetActive(false);
- player = PlayerBase.Cast(GetGame().GetPlayer());
- item_in_hands = player.GetItemInHands();
- m_HandsArea.SetActive(true);
-
- UpdateConsoleToolbar();
- }
- else if (m_RightArea.IsActive())
- {
- if (!ItemManager.GetInstance().IsMicromanagmentMode())
- {
- m_RightArea.UnfocusGrid();
- }
- m_RightArea.SetActive(false);
- m_LeftArea.SetActive(true);
-
- UpdateConsoleToolbar();
- }
- else if (m_HandsArea.IsActive())
- {
- m_HandsArea.UnfocusGrid();
- m_HandsArea.SetActive(false);
- m_RightArea.SetActive(true);
-
- UpdateConsoleToolbar();
- }
- }
- }
-
- void InventoryMovementButtonTickHandler(float timeslice)
- {
- float tickvalue = 0;
-
- if (m_SensitivityThreshold > 0.0)
- {
- if (m_SensitivityThreshold < BT_REPEAT_TIME) //sensitivity solution...
- {
- m_SensitivityThreshold += timeslice;
- return;
- }
- else
- {
- m_SensitivityThreshold = 0.0;
- }
- }
-
- for (int i = 0; i < m_InvInputWrappersCount; i++)
- {
- m_InvUAInput = m_InvInputWrappers[i].InputP();
-
- if (m_InvUAInput.LocalValue() > BT_THRESHOLD_VALUE)
- {
- tickvalue = m_InvInputTimes[i];
- tickvalue += timeslice;
- }
- else
- {
- tickvalue = 0.0;
- }
-
- if (tickvalue < BT_REPEAT_DELAY && m_InvUAInput.LocalPress())
- {
- m_InvInputActive |= (1 << i);
- m_SensitivityThreshold += timeslice;
- }
- else if (tickvalue > (BT_REPEAT_DELAY + BT_REPEAT_TIME))
- {
- while (tickvalue > (BT_REPEAT_DELAY + BT_REPEAT_TIME))
- {
- tickvalue -= BT_REPEAT_TIME;
- }
-
- m_InvInputActive |= (1 << i);
- m_SensitivityThreshold += timeslice;
- }
- else
- {
- m_InvInputActive &= ~(1 << i);
- }
-
- m_InvInputTimes[i] = tickvalue;
- }
- }
- }
|