DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
ConstructionInfoIcons.c
См. документацию.
7
8class ConstructionInfoIcon: GenericIconBase
9{
13
14 override protected void InitIconWidgets(LayoutHolder parent, Widget root, int index, EntityAI slot_parent)
15 {
16 super.InitIconWidgets(parent,root,index,slot_parent);
17
18 m_OriginalGhostIconColor = m_GhostSlot.GetColor();
19 m_ImageBackdrop.Show(true);
20 }
21
23 {
24 m_Part = part;
25 }
26
27 override void ResetIconValues()
28 {
29 super.ResetIconValues();
30
31 m_Part = null;
32 }
33
34 override void Init(EntityAI obj, bool reservation = false)
35 {
36 super.Init(obj, reservation);
37
39 }
40
41 override void Clear()
42 {
43 super.Clear();
44
46 }
47
49 override void SetActive(bool active){}
50}
51
52class ConstructionToolInfoIcon: ConstructionInfoIcon
53{
54 protected bool m_ShowIcon; //set from outside (wider context), the icon just handles its own updates
55 protected ItemBase m_Tool;
56
57 override protected void InitIcon(LayoutHolder parent, Widget root, int index, EntityAI slot_parent)
58 {
59 super.InitIcon(parent,root,index,slot_parent);
60
62 }
63
64 protected void InitGhostIcon()
65 {
66 string iconPath = "set:dayz_inventory image:missing";
67 switch (m_IconIndex)
68 {
69 case EConstructionTools.TOOL_MOUNT_WIRE:
70 iconPath = "set:dayz_inventory image:plierstools";
71 break
72
73 case EConstructionTools.TOOL_NAIL:
74 iconPath = "set:dayz_inventory image:hammertools";
75 break
76
77 case EConstructionTools.TOOL_DIG_BASE:
78 iconPath = "set:dayz_inventory image:shoveltools";
79 break
80
81 case EConstructionTools.TOOL_MOUNT_LOG:
82 iconPath = "set:dayz_inventory image:hammertools";
83 break
84
85 case EConstructionTools.TOOL_HEAVY:
86 iconPath = "set:dayz_inventory image:sladgehammertools";
87 break
88
89 case EConstructionTools.TOOL_EXCAVATION:
90 iconPath = "set:dayz_inventory image:pickaxetools";
91 break
92
93 case EConstructionTools.TOOL_HANDS:
94 iconPath = "set:dayz_inventory image:hands";
95 m_GhostSlot.SetColor(0xD0FFFFFF);
96 break
97
98 case EConstructionTools.TOOL_BRICKLAYING:
99 iconPath = "set:dayz_inventory image:bricklayingtools";
100 break
101 }
102
103 m_GhostSlot.LoadImageFile(0, iconPath);
104 m_GhostSlot.SetImage(0);
105 }
106
107 override void ResetIconValues()
108 {
109 super.ResetIconValues();
110
111 m_Tool = null;
112 }
113
114 //TODO: remove!
115 void SetTool(ItemBase tool)
116 {
117 m_Tool = tool;
118 }
119
120 void SetShowIcon(bool show)
121 {
122 m_ShowIcon = show;
123 }
124
126 {
127 m_CrossedImage.Show(show);
128 }
129
130 //just visibility, all frontloaded, called on change
131 override void UpdateInterval()
132 {
133 //int actionMask = m_Part.GetBuildActionTypeMask();
134 if (m_ShowIcon)
135 {
136 //bool toolOptional = actionMask & EConstructionTools.TOOL_HANDS;
137 bool highlight = (m_IconIndex == EConstructionTools.TOOL_HANDS && !m_Tool) || (m_IconIndex != EConstructionTools.TOOL_HANDS && m_Tool != null);
138 //m_GenericWarning.Show(!toolOptional);
139
140 if (m_Tool)
141 {
142 Init(m_Tool); //render variant
143 }
144 else
145 {
146 Clear();
147 }
148 m_ColWidget.Show(highlight);
149 OnShow();
150 }
151 else
152 {
153 OnHide();
154 //m_GenericWarning.Show(false);
155 }
156
157 super.UpdateInterval();
158 }
159}
160
161class ConstructionMaterialInfoIcon: ConstructionInfoIcon
162{
163 const string QUANTITY_TEXT_COLOR_DARKER_ARGB = "0xFF7C7C7C";
164 const string QUANTITY_TEXT_COLOR_LIGHTER_ARGB = "0xFFC8C8C8";
165 protected bool m_ProcessDataChanges; //only true when a part or target entity changed //TODO: figure out something better?
167 protected EntityAI m_TargetedEntity; //owner of the construction part (and inventory)
169
170 override protected void InitIcon(LayoutHolder parent, Widget root, int index, EntityAI slot_parent)
171 {
172 super.InitIcon(parent,root,index,slot_parent);
173
174 m_ProcessDataChanges = false;
176 }
177
178 /*override protected void InitIconWidgets(LayoutHolder parent, Widget root, int index, EntityAI slot_parent)
179 {
180 super.InitIconWidgets(parent,root,index,slot_parent);
181
182 m_ImageBackdrop.Show(true);
183 }*/
184
185 protected void InitGhostIcon()
186 {
187 string iconName = "set:dayz_inventory image:missing";
188 string path = "CfgSlots" + " Slot_" + m_MaterialData.m_MaterialSlotName + " ghostIcon";
189 if (GetGame().ConfigIsExisting(path))
190 GetGame().ConfigGetText(path,iconName);
191 m_GhostSlot.LoadImageFile(0,iconName);
192 m_GhostSlot.SetImage(0);
193 }
194
195 void SetTargetEntity(EntityAI targetEnt)
196 {
197 if (m_TargetedEntity != targetEnt)
198 {
200 m_TargetedEntity = targetEnt;
201 }
202 }
203
204 override void SetConstructionPart(ConstructionPart part)
205 {
206 if (m_Part != part)
208
209 super.SetConstructionPart(part);
210 }
211
212 override void ResetIconValues()
213 {
214 super.ResetIconValues();
215
216 m_TargetedEntity = null;
217 m_MaterialData = null;
218 m_ProcessDataChanges = false;
219 }
220
221 protected void InitMaterialInfo()
222 {
223 array<ref ConstructionMaterialData> materials = m_Part.GetMaterialsData();
224 if (m_TargetedEntity && materials && materials.Count() > m_IconIndex)
225 {
226 bool show = false;
227
228 m_MaterialData = materials[m_IconIndex];
229 SetSlotID(InventorySlots.INVALID);
230
231 if (m_MaterialData.m_MaterialSlotID != InventorySlots.INVALID)
232 {
233 SetSlotID(m_MaterialData.m_MaterialSlotID);
237 }
238 else
239 {
240 ErrorEx("No valid slot index for slot named: " + m_MaterialData.m_MaterialSlotName);
241 }
242
243 if (show)
244 {
245 OnShow();
246 }
247 else
248 {
249 //ResetIconValues();
250 OnHide();
251 }
252 }
253 else
254 {
255 //ResetIconValues();
256 OnHide();
257 }
258 }
259
261 {
262 if (GetSlotID() != InventorySlots.INVALID && m_TargetedEntity.CanDisplayAttachmentSlot(m_MaterialData.m_MaterialSlotID))
263 {
264 EntityAI child = m_TargetedEntity.FindAttachmentBySlotName(m_MaterialData.m_MaterialSlotName);
265 if (child)
266 {
268 Init(child);
269 }
270 else if (m_ItemState != eConstructionIconItemState.HIDDEN)
271 {
272 Clear();
273 }
274
275 return true;
276 }
277
278 return false;
279 }
280
281 override void UpdateInterval()
282 {
284 {
285 Clear();
287 m_ProcessDataChanges = false;
288 }
289 else
290 {
291 CheckDisplayableAttachment(); //have to check periodically. TODO: link some invoker method/s to add/remove/qtyChange events on target entity?
292 }
293
294 super.UpdateInterval();
295 }
296
297 //TODO: prototype stuff, remove and address in parent classes
298 override void SetQuantity()
299 {
300 if (m_Item)
301 {
302 //m_QuantityItem.SetAlpha(1.0);
303 int quantityType = QuantityConversions.HasItemQuantity(m_Item);
304 if (quantityType != QUANTITY_HIDDEN && m_CurrQuantity != QuantityConversions.GetItemQuantity(m_Item))
305 {
306 float requiredQty;
307 float lastQuantity = m_CurrQuantity;
309 if (lastQuantity == m_CurrQuantity) //skip except quantity changed
310 return;
311
312 string color1, color2;
313
314 if (quantityType == QUANTITY_COUNT)
315 {
316 requiredQty = GetContextualSlotMax();
317 bool sufficient = m_CurrQuantity >= requiredQty;
318 if (m_LastSufficientMaterialState != sufficient)
319 {
320 m_ColWidget.Show(sufficient);
321 m_ItemPreview.Show(sufficient);
322 m_GhostSlot.Show(!sufficient);
323
324 if (!sufficient)
325 {
328
329 string iconPath = m_Item.GetInventoryItemType().GetGhostIconImagepath();
330 if (iconPath != "")
331 {
332 m_GhostSlot.LoadImageFile(1, iconPath, false);
333 m_GhostSlot.SetImage(1);
334 m_GhostSlot.SetColor(0xFFFFFFFF);
335 }
336 }
337 else
338 {
339 color1 = COLOR_WHITE.ToString();
340 color2 = COLOR_WHITE.ToString();
341 }
342
343 m_QuantityStack.Show(requiredQty != 1);
344 m_QuantityProgress.Show(false);
346
347 RichTextWidget.Cast(m_QuantityItem).SetText(string.Format("<color hex=\"%1\">%2</color><color hex=\"%3\">/%4</color>", color1, m_CurrQuantity.ToString(), color2, requiredQty.ToString()));
348 }
349 }
350 /*else if (quantityType == QUANTITY_PROGRESS)
351 {
352 requiredQty = GetContextualSlotMax();
353
354 float value = Math.Round((m_CurrQuantity / requiredQty) * 100);
355 m_QuantityProgress.SetCurrent(value);
356 m_QuantityStack.Show(false);
357 m_QuantityProgress.Show(true);
358 }*/
359 }
360 }
361 }
362
363 override void ClearRemainSelected()
364 {
365 super.ClearRemainSelected();
366
367 m_GhostSlot.SetImage(0);
368 m_GhostSlot.SetColor(m_OriginalGhostIconColor);
370
371 if (GetSlotID() != InventorySlots.INVALID)
372 {
373 int stackMax = GetContextualSlotMax();
374 if (stackMax > 0)
375 {
376 m_QuantityPanel.Show(true);
377 RichTextWidget.Cast(m_QuantityItem).SetText(string.Format("<color hex=\"%1\">%2</color><color hex=\"%3\">/%4</color>", QUANTITY_TEXT_COLOR_DARKER_ARGB, "0", QUANTITY_TEXT_COLOR_LIGHTER_ARGB, GetContextualSlotMax().ToString()));
378 //m_QuantityItem.SetAlpha(0.5019); //TODO: ffs...
379 m_QuantityItem.Show(true);
380 m_QuantityStack.Show(true);
381 m_QuantityProgress.Show(false);
382 m_PanelWidget.Show(true);
383 m_ItemPreview.Show(false);
384 }
385 }
386 }
387
388 override protected int GetContextualSlotMax()
389 {
390 return m_MaterialData.m_MaterialQuantity; //desired material quantity used as max for this purpose
391 }
392}
393
override void UpdateInterval()
Определения ActionInfoGrids.c:256
ItemBase m_Item
Определения ActionInput.c:16
void SetConstructionPart(ConstructionPart part)
Определения ActionPartInfo.c:230
ConstructionPart m_Part
Определения ActionPartInfo.c:228
eConstructionIconItemState
Определения ConstructionInfoIcons.c:2
@ SHOWN
Определения ConstructionInfoIcons.c:5
void InitGhostIcon()
Определения ConstructionInfoIcons.c:185
override void Clear()
Определения ConstructionInfoIcons.c:41
const string QUANTITY_TEXT_COLOR_LIGHTER_ARGB
Определения ConstructionInfoIcons.c:164
void InitIcon(LayoutHolder parent, Widget root, int index, EntityAI slot_parent)
Определения ConstructionInfoIcons.c:170
void SetTargetEntity(EntityAI targetEnt)
Определения ConstructionInfoIcons.c:195
EntityAI m_TargetedEntity
Определения ConstructionInfoIcons.c:167
void InitIconWidgets(LayoutHolder parent, Widget root, int index, EntityAI slot_parent)
Определения ConstructionInfoIcons.c:14
int GetContextualSlotMax()
Определения ConstructionInfoIcons.c:388
int m_LastSufficientMaterialState
Определения ConstructionInfoIcons.c:166
ConstructionMaterialData m_MaterialData
Определения ConstructionInfoIcons.c:168
override void SetQuantity()
Определения ConstructionInfoIcons.c:298
override void ClearRemainSelected()
Определения ConstructionInfoIcons.c:363
override void ResetIconValues()
Определения ConstructionInfoIcons.c:27
eConstructionIconItemState m_ItemState
Определения ConstructionInfoIcons.c:12
ConstructionToolInfoIcon QUANTITY_TEXT_COLOR_DARKER_ARGB
void InitMaterialInfo()
Определения ConstructionInfoIcons.c:221
enum eConstructionIconItemState m_OriginalGhostIconColor
bool m_ProcessDataChanges
Определения ConstructionInfoIcons.c:165
bool CheckDisplayableAttachment()
Определения ConstructionInfoIcons.c:260
void ConstructionPart(string name, string part_name, string main_part_name, int id, bool is_built, bool is_base, bool is_gate, array< string > required_parts)
Определения ConstructionPart.c:531
override void OnShow()
Определения ControlsXbox.c:362
override Widget Init()
Определения DayZGame.c:127
proto string ToString()
override void OnHide()
Определения InventoryMenu.c:141
string path
Определения OptionSelectorMultistate.c:142
void SetActive()
Определения TrapBase.c:413
instanced data holder for single construction material
Определения ConstructionMaterials.c:3
Instanced construction part data classes for dynamic data, statics now stored on EntityType level in ...
Определения ConstructionPart.c:4
void SetTool(ItemBase tool)
Определения ConstructionInfoIcons.c:115
void ToolCompatibilityWarning(bool show)
Определения ConstructionInfoIcons.c:125
void InitIcon(LayoutHolder parent, Widget root, int index, EntityAI slot_parent)
Определения ConstructionInfoIcons.c:57
override void ResetIconValues()
Определения ConstructionInfoIcons.c:107
override void UpdateInterval()
Определения ConstructionInfoIcons.c:131
void SetShowIcon(bool show)
Определения ConstructionInfoIcons.c:120
Определения GenericIcon.c:2
const int INVALID
Invalid slot (-1)
Определения InventorySlots.c:17
provides access to slot configuration
Определения InventorySlots.c:6
Определения Container.c:2
static float GetItemQuantity(InventoryItem item)
Определения QuantityConversions.c:72
static int HasItemQuantity(notnull EntityAI item)
Определения QuantityConversions.c:143
Определения gameplay.c:317
Определения EnWidgets.c:190
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto string ToString(bool simple=true)
DayZGame GetGame()
Определения gameplay.c:636
const int COLOR_WHITE
Определения 1_Core/DayZ/constants.c:63
enum ShapeType ErrorEx
const int QUANTITY_COUNT
Определения 3_Game/DayZ/constants.c:554
const int QUANTITY_HIDDEN
Определения 3_Game/DayZ/constants.c:553
@ HIDDEN
File is hidden.
Определения EnSystem.c:508
@ INVALID
Invalid file.
Определения EnSystem.c:510
static proto string ToString(void var, bool type=false, bool name=false, bool quotes=true)
Return string representation of variable.