DayZ 1.24
Loading...
Searching...
No Matches
QuantityConversions Class Reference

Static Private Member Functions

static string GetItemQuantityText (EntityAI item, bool showMax=false)
 
static float GetItemQuantity (InventoryItem item)
 
static float GetItemQuantityMax (InventoryItem item)
 
static void GetItemQuantity (InventoryItem item, out float q_cur, out float q_min, out float q_max)
 
static int HasItemQuantity (notnull EntityAI item)
 

Detailed Description

Definition at line 1 of file QuantityConversions.c.

Member Function Documentation

◆ GetItemQuantity() [1/2]

static float QuantityConversions::GetItemQuantity ( InventoryItem item)
inlinestaticprivate

Definition at line 68 of file QuantityConversions.c.

69 {
70 float quantity = 0;
71 if (item.IsInherited(InventoryItem))
72 {
75 if (item_base)
76 {
77 if (item.IsMagazine())
78 {
81 quantity = magazine_item.GetAmmoCount();
82 }
83 else
84 quantity = item_base.GetQuantity();
85 }
86 }
87 return quantity;
88 }
Super root of all classes in Enforce script.
Definition EnScript.c:11
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.

References Class::CastTo().

Referenced by InventoryGridController::GetItemQuantity(), ActionTargetsCursor::GetItemQuantity(), ScriptedWidgetEventHandler::GetItemQuantity(), Icon::SetQuantity(), SlotsIcon::SetQuantity(), and UIScriptedMenu::UpdateQuickbarItemCard().

◆ GetItemQuantity() [2/2]

static void QuantityConversions::GetItemQuantity ( InventoryItem item,
out float q_cur,
out float q_min,
out float q_max )
inlinestaticprivate

Definition at line 112 of file QuantityConversions.c.

113 {
114 if (item.IsInherited(InventoryItem))
115 {
118 if (item.IsMagazine())
119 {
122 q_cur = magazine_item.GetAmmoCount();
123 q_min = 0;
124 q_max = magazine_item.GetAmmoMax();
125 }
126 else
127 {
128 q_cur = item_base.GetQuantity();
129 q_min = item_base.GetQuantityMin();
130 q_max = item_base.GetQuantityMax();
131 }
132 }
133 }

References Class::CastTo().

◆ GetItemQuantityMax()

static float QuantityConversions::GetItemQuantityMax ( InventoryItem item)
inlinestaticprivate

Definition at line 90 of file QuantityConversions.c.

91 {
92 float quantity = 0;
93 if (item.IsInherited(InventoryItem))
94 {
97 if (item_base)
98 {
99 if (item.IsMagazine())
100 {
103 quantity = magazine_item.GetAmmoMax();
104 }
105 else
106 quantity = item_base.GetQuantityMax();
107 }
108 }
109 return quantity;
110 }

References Class::CastTo().

Referenced by Icon::SetQuantity(), and SlotsIcon::SetQuantity().

◆ GetItemQuantityText()

static string QuantityConversions::GetItemQuantityText ( EntityAI item,
bool showMax = false )
inlinestaticprivate

Definition at line 3 of file QuantityConversions.c.

4 {
5 string quantity_text = "";
6 if (item.IsInherited(InventoryItem))
7 {
10 float quantity = item_base.GetQuantity();
11 int ammo;
12 if (item.IsMagazine())
13 {
16 ammo = magazine_item.GetAmmoCount();
17
18 return ammo.ToString();
19 }
20 else if (item.IsInherited(ItemBook))
21 return "";
22 int stack_max = item.GetQuantityMax();
23
24 //int max = item.ConfigGetInt("varQuantityMax");
25 //string unit = item.ConfigGetString("stackedUnit");
26
27 if (stack_max > 0)
28 {
29 if (stack_max == 1)
30 {
31 if (quantity > 1)
32 {
33 if (showMax)
34 quantity_text = string.Format("%1/%2", quantity.ToString(), stack_max.ToString());
35 //quantity_text = string.Format("%i/%i", quantity, stack_max );
36 else
37 quantity_text = quantity.ToString();
38 }
39 else
40 quantity_text = "";
41 }
42 else
43 {
44 if (showMax)
45 quantity_text = string.Format("%1/%2", quantity.ToString(), stack_max.ToString());
46 //quantity_text = string.Format("%i/%i", quantity, stack_max );
47 else
48 quantity_text = quantity.ToString();
49 // if (unit == "ml")
50 // {
51 // float liters = round(quantity / 1000.0);
52 // if ( quantity < 2000 )
53 // {
54 // liters = ( round( (quantity / 100.0) ) ) / 10;
55 // }
56 // quantity_text = ftoa(liters) + "l";
57 // }
58 // else
59 // {
60 // quantity_text = itoa(quantity) + unit;
61 // }
62 }
63 }
64 }
65 return quantity_text;
66 }

References Class::CastTo().

Referenced by InventoryGridController::GetItemQuantityText(), Icon::SetQuantity(), SlotsIcon::SetQuantity(), and UIScriptedMenu::UpdateQuickbarItemCard().

◆ HasItemQuantity()

static int QuantityConversions::HasItemQuantity ( notnull EntityAI item)
inlinestaticprivate

The documentation for this class was generated from the following file: