39 #ifndef PLATFORM_CONSOLE
53 #ifdef PLATFORM_CONSOLE
54 m_TooltipWidget =
g_Game.GetWorkspace().CreateWidgets(
"gui/layouts/inventory_new/day_z_inventory_new_tooltip_xbox.layout", root );
55 m_TooltipSlotWidget =
g_Game.GetWorkspace().CreateWidgets(
"gui/layouts/inventory_new/day_z_inventory_new_tooltip_slot_xbox.layout", root );
57 m_TooltipWidget =
g_Game.GetWorkspace().CreateWidgets(
"gui/layouts/inventory_new/day_z_inventory_new_tooltip.layout", root );
58 m_TooltipSlotWidget =
g_Game.GetWorkspace().CreateWidgets(
"gui/layouts/inventory_new/day_z_inventory_new_tooltip_slot.layout", root );
67 Inventory.GetInstance().UpdateConsoleToolbar();
138 icon =
Icon.Cast(selected_icon);
182 g_Game.SetProfileString(
"defaultOpenStateHands", hands_default_open_state.ToString() );
189 g_Game.GetProfileString(
"defaultOpenStateHands", value );
204 if( serialized_types.Count() > 0 )
206 g_Game.SetProfileStringList(
"defaultHeaderOpenStates", serialized_types );
215 g_Game.GetProfileStringList(
"defaultHeaderOpenStates", serialized_types );
217 for(
int i = 0; i < serialized_types.Count(); i++ )
220 serialized_types.Get( i ).Split(
",", strs );
221 bool is_opened = strs.Get( 1 ).ToInt();
236 if( serialized_types.Count() > 0 )
238 g_Game.SetProfileStringList(
"defaultOpenStates", serialized_types );
247 g_Game.GetProfileStringList(
"defaultOpenStates", serialized_types );
249 for(
int i = 0; i < serialized_types.Count(); i++ )
252 serialized_types.Get( i ).Split(
",", strs );
253 bool is_opened = strs.Get( 1 ).ToInt();
293 #ifndef PLATFORM_CONSOLE
304 EntityAI owner = item.GetHierarchyParent();
311 else if (owner && owner != player)
318 item.GetInventory().GetCurrentInventoryLocation(inv_loc_src);
319 int loc_type = inv_loc_src.
GetType();
419 switch (pHealthLevel)
442 switch (item.GetHealthLevel(zone))
464 if( fraction > 1 || fraction < 0 )
466 else if( fraction > 0.80 )
468 else if( fraction > 0.6 )
470 else if( fraction > 0.4 )
472 else if( fraction > 0.2 )
483 bool colorSet =
false;
484 string name = item_w.GetName();
485 name.Replace(
"Render",
"Temperature");
486 Widget temperature_widget = item_w.GetParent().FindAnyWidget(
name);
487 if (item && item.IsInherited(
ItemBase) && item.CanHaveTemperature())
489 ObjectTemperatureState temperatureState = ObjectTemperatureState.GetStateData(item.GetTemperature());
493 temperature_widget.SetColor(temperatureState.m_Color);
494 temperature_widget.SetAlpha(0.3);
497 temperature_widget.Show(colorSet);
505 bool colorSet =
false;
506 Widget temperatureColorWidget = item_w.FindAnyWidget(
"Temperature");
508 if (item && item.IsInherited(
ItemBase) && item.CanHaveTemperature())
510 ObjectTemperatureState temperatureState = ObjectTemperatureState.GetStateData(item.GetTemperature());
514 temperatureColorWidget.SetColor(temperatureState.m_Color);
515 temperatureColorWidget.SetAlpha(0.3);
518 temperatureColorWidget.Show(colorSet);
536 int screen_w, screen_h;
543 x = screen_w/2 - w/2;
545 m_RootWidget.FindAnyWidget(
"InventoryFrameWidget").GetScreenPos(x1,y1);
548 else if (
x == 0 &&
y == 0 &&
g_Game.GetInput().IsEnabledMouseAndKeyboardEvenOnServer())
557 int rightEdge =
x + w;
558 if (rightEdge > screen_w)
563 int bottomEdge =
y + h;
564 if (bottomEdge > screen_h)
602 int screen_w, screen_h;
613#ifndef PLATFORM_CONSOLE
615 y += slot_normal_h + 5;
621 while (scrollerWidget)
623 if (ScrollWidget.Cast(scrollerWidget))
629 scrollerWidget = scrollerWidget.GetParent();
633 int rightEdge =
x + w;
634 if (rightEdge > screen_w)
639 int bottomEdge =
y + h;
642 float scrollerX, scrollerY, scrollerSizeX, scrollerSizeY;
643 scrollerWidget.GetScreenPos(scrollerX,scrollerY);
644 scrollerWidget.GetScreenSize(scrollerSizeX,scrollerSizeY);
646 int scroller_bottom = scrollerY + scrollerSizeY;
647 if (bottomEdge > scroller_bottom)
649 y = scroller_bottom - slot_normal_h;
658 if (bottomEdge > screen_h)
686 draggable = !player.GetInventory().HasInventoryReservation( entity, null ) && !player.IsItemsToDelete();
687 draggable = draggable && entity.CanPutIntoHands(
g_Game.GetPlayer() );
688 draggable = draggable && entity.GetInventory().CanRemoveEntity();
723 if (!selectedEntity || !targetEntity)
746 if (targetEntity.CanBeCombined(selectedEntity))
754 if (targetEntity.GetInventory().CanAddAttachment(selectedEntity))
762 if (!targetEntity.GetInventory().HasEntityInInventory(selectedEntity) && targetEntity.GetInventory().CanAddEntityInCargo( selectedEntity, selectedEntity.GetInventory().GetFlipCargo() ))
770 Magazine mag = Magazine.Cast(targetEntity);
774 if (player.GetWeaponManager().CanSwapMagazine(wpn, Magazine.Cast(selectedEntity)))
805 if (!entity1 || !entity2)
819 if (il.
IsValid() && !entity1.GetInventory().FindAttachment(il.
GetSlot()))
821 if (!entity1.IsInherited(
ZombieBase ) && !entity1.IsInherited(
Car ) && !entity2.IsInherited(
ZombieBase ) && !entity2.IsInherited(
Car ))
826 if (!entity1.GetInventory().HasEntityInInventory(entity2) && entity1.GetInventory().CanAddEntityInCargo( entity2, entity2.GetInventory().GetFlipCargo() )) flags = flags |
InventoryCombinationFlags.
ADD_AS_CARGO;
828 if (entity1 == player.GetEntityInHands() || entity2 == player.GetEntityInHands())
832 if (entity1 == player.GetEntityInHands())
860 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(
GetPlugin( PluginRecipesManager ));
void Inventory(LayoutHolder parent)
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
bool CanSetActionFromInventory(ItemBase mainItem, ItemBase targetItem)
bool CanPerformActionFromInventory(ItemBase mainItem, ItemBase targetItem)
Base script class for cars.
Super root of all classes in Enforce script.
const int COLOR_BADLY_DAMAGED
script counterpart to engine's class Inventory
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
Widget GetMicromanagedPanel()
static const int ADD_AS_CARGO
static const int PERFORM_ACTION
static const int ADD_AS_ATTACHMENT
static const int COMBINE_QUANTITY2
static const int SET_ACTION
static const int SWAP_MAGAZINE
proto native int GetSlot()
returns slot id if current type is Attachment
proto native bool IsValid()
verify current set inventory location
proto native int GetType()
returns type of InventoryLocation
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
Widget GetCenterDropzone()
EntityAI GetSelectedItem()
ref Widget m_TooltipSlotWidget
void SetDraggedIcon(Icon dragged_icon)
void PrepareTooltip(EntityAI item, int x=0, int y=0)
bool IsMicromanagmentMode()
HandsPreview GetHandsPreview()
void SerializeDefaultOpenStates()
Widget GetSelectedWidget()
void ShowSourceDropzone(EntityAI item)
void DeserializeDefaultOpenStates()
static ref ItemManager m_Instance
bool GetDefaultOpenStateHands()
Container GetSelectedContainer()
void UpdateTooltipSlotPosition()
static int GetCombinationFlags(EntityAI entity1, EntityAI entity2)
static int GetItemHealthColor(EntityAI item, string zone="")
Widget m_TooltipSourceWidget
void ClearDefaultOpenStates()
void SetWidgetDraggable(Widget w, bool draggable)
const float TOOLTIP_DELAY
ItemPreviewWidget m_ItemPreviewWidget
int m_HandsDefaultOpenState
bool m_ItemMicromanagmentMode
bool GetDefaultOpenState(string type)
ref Timer m_TooltipSlotTimer
static int ColorFromFloat(float fraction)
static int GetItemHealthColor(int pHealthLevel)
void SetDefaultHeaderOpenState(string type, bool is_opened)
void SetTemperature(EntityAI item, Widget item_w)
void DeserializeDefaultHeaderOpenStates()
void ClearDefaultHeaderOpenStates()
ref Widget m_TooltipCategoryWidget
LayoutHolder m_SelectedBaseIcon
ScrollWidget GetLeftSlotsScroller()
void SetItemMicromanagmentMode(bool item_micromanagment_mode)
static int GetRecipeCount(bool recipe_anywhere, EntityAI entity1, EntityAI entity2)
void SetDraggedItem(EntityAI dragged_item)
ref Widget m_TooltipWidget
void SetSelectedItemEx(EntityAI selected_item, Container selected_container, LayoutHolder selected_icon)
bool EvaluateContainerDragabilityDefault(EntityAI entity)
static int GetChosenCombinationFlag(EntityAI selectedEntity, EntityAI targetEntity, int relevantFlags, out InventoryLocation dst=null)
void SetHandsPreview(HandsPreview hansd_preview)
void PrepareSlotsTooltip(string name, string desc, int x=0, int y=0)
position is currentlycalculated from the owning 'm_TooltipSourceWidget' directly
void SetIconTemperature(EntityAI item, Widget item_w)
void SetDefaultOpenState(string type, bool is_opened)
HandsPreview m_HandsPreview
void SetSelectedItem(EntityAI selected_item, Container selected_container, Widget selected_widget, SlotsIcon selected_icon)
Widget GetRightDropzone()
void CalculateTooltipSlotPosition(int x=0, int y=0)
bool GetDefaultHeaderOpenState(string type)
EntityAI GetHoveredItem()
void SerializeDefaultHeaderOpenStates()
void ItemManager(Widget root)
ref map< string, bool > m_DefautOpenStates
void SetTooltipWidget(Widget w)
void SetDefaultOpenStateHands(bool is_opened)
ScrollWidget m_LeftSlotsScroller
void SetIsDragging(bool is_dragging)
SlotsIcon GetSelectedIcon()
Container m_SelectedContainer
static ItemManager GetInstance()
ref map< string, bool > m_DefautHeaderOpenStates
EntityAI GetDraggedItem()
static int GetNormalWidth()
static int GetNormalHeight()
Widget GetMicromanagedPanel()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
array< string > TStringArray
const int STATE_BADLY_DAMAGED
proto void GetScreenSize(out int x, out int y)
proto void GetMousePos(out int x, out int y)
proto native int ToInt()
Converts string to integer.
FindInventoryLocationType
flags for searching locations in inventory
InventoryLocationType
types of Inventory Location
PluginBase GetPlugin(typename plugin_type)