39 #ifndef PLATFORM_CONSOLE
53 #ifdef PLATFORM_CONSOLE
67 Inventory.GetInstance().UpdateConsoleToolbar();
138 icon =
Icon.Cast(selected_icon);
204 if( serialized_types.Count() > 0 )
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 )
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 &&
GetGame().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();
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.GetHumanInventory().GetEntityInHands() || entity2 == player.GetHumanInventory().GetEntityInHands())
832 if (entity1 == player.GetHumanInventory().GetEntityInHands())
860 PluginRecipesManager plugin_recipes_manager = PluginRecipesManager.Cast(
GetPlugin( PluginRecipesManager ));
void Inventory(LayoutHolder parent)
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
FindInventoryLocationType
flags for searching locations in inventory
InventoryLocationType
types of Inventory Location
PluginBase GetPlugin(typename plugin_type)
bool CanPerformActionFromInventory(ItemBase mainItem, ItemBase targetItem)
bool CanSetActionFromInventory(ItemBase mainItem, ItemBase targetItem)
proto native void SetProfileString(string name, string value)
Sets string to profile variable.
proto native void GetProfileStringList(string name, out TStringArray values)
Gets array of strings from profile variable.
proto bool GetProfileString(string name, out string value)
Gets string from profile variable.
proto native WorkspaceWidget GetWorkspace()
proto native void SaveProfile()
Saves profile on disk.
proto native void SetProfileStringList(string name, TStringArray values)
Sets array of strings to profile variable.
Super root of all classes in Enforce script.
const int COLOR_BADLY_DAMAGED
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
script counterpart to engine's class Inventory
Widget GetMicromanagedPanel()
static const int PERFORM_ACTION
static const int ADD_AS_CARGO
static const int SWAP_MAGAZINE
static const int SET_ACTION
static const int ADD_AS_ATTACHMENT
static const int COMBINE_QUANTITY2
proto native bool IsValid()
verify current set inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
proto native int GetType()
returns type of InventoryLocation
override bool CanBeCombined(EntityAI other_item, bool reservation_check=true, bool stack_max_limit=false)
static ref ItemManager m_Instance
ref map< string, bool > m_DefautHeaderOpenStates
bool GetDefaultHeaderOpenState(string type)
static int GetItemHealthColor(EntityAI item, string zone="")
void SerializeDefaultHeaderOpenStates()
void CalculateTooltipSlotPosition(int x=0, int y=0)
const float TOOLTIP_DELAY
void SetTemperature(EntityAI item, Widget item_w)
static int GetCombinationFlags(EntityAI entity1, EntityAI entity2)
void SetItemMicromanagmentMode(bool item_micromanagment_mode)
int m_HandsDefaultOpenState
void ClearDefaultOpenStates()
ref map< string, bool > m_DefautOpenStates
ref Widget m_TooltipSlotWidget
EntityAI GetDraggedItem()
void SetSelectedItemEx(EntityAI selected_item, Container selected_container, LayoutHolder selected_icon)
static int ColorFromFloat(float fraction)
Widget GetCenterDropzone()
EntityAI GetHoveredItem()
void ClearDefaultHeaderOpenStates()
HandsPreview GetHandsPreview()
void ShowSourceDropzone(EntityAI item)
void DeserializeDefaultHeaderOpenStates()
void SetDefaultHeaderOpenState(string type, bool is_opened)
Container GetSelectedContainer()
bool EvaluateContainerDragabilityDefault(EntityAI entity)
ScrollWidget GetLeftSlotsScroller()
SlotsIcon GetSelectedIcon()
HandsPreview m_HandsPreview
ref Widget m_TooltipWidget
Widget m_TooltipSourceWidget
void SetIconTemperature(EntityAI item, Widget item_w)
void SetHandsPreview(HandsPreview hansd_preview)
void SetDraggedItem(EntityAI dragged_item)
ref Timer m_TooltipSlotTimer
void SerializeDefaultOpenStates()
ref Widget m_TooltipCategoryWidget
Widget GetSelectedWidget()
EntityAI GetSelectedItem()
Widget GetRightDropzone()
void PrepareTooltip(EntityAI item, int x=0, int y=0)
static int GetItemHealthColor(int pHealthLevel)
Container m_SelectedContainer
void DeserializeDefaultOpenStates()
bool IsMicromanagmentMode()
void SetWidgetDraggable(Widget w, bool draggable)
ItemPreviewWidget m_ItemPreviewWidget
static int GetRecipeCount(bool recipe_anywhere, EntityAI entity1, EntityAI entity2)
ScrollWidget m_LeftSlotsScroller
void SetDraggedIcon(Icon dragged_icon)
void SetIsDragging(bool is_dragging)
void SetDefaultOpenStateHands(bool is_opened)
void PrepareSlotsTooltip(string name, string desc, int x=0, int y=0)
position is currentlycalculated from the owning 'm_TooltipSourceWidget' directly
void SetTooltipWidget(Widget w)
bool m_ItemMicromanagmentMode
LayoutHolder m_SelectedBaseIcon
bool GetDefaultOpenStateHands()
void UpdateTooltipSlotPosition()
void ItemManager(Widget root)
static int GetChosenCombinationFlag(EntityAI selectedEntity, EntityAI targetEntity, int relevantFlags, out InventoryLocation dst=null)
bool GetDefaultOpenState(string type)
static ItemManager GetInstance()
void SetSelectedItem(EntityAI selected_item, Container selected_container, Widget selected_widget, SlotsIcon selected_icon)
void SetDefaultOpenState(string type, bool is_opened)
Widget GetMicromanagedPanel()
static int GetNormalWidth()
static int GetNormalHeight()
proto native CGame GetGame()
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.