DayZ 1.24
Loading...
Searching...
No Matches
InspectMenuNew.c
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2class InspectMenuNew extends UIScriptedMenu
3{
10
11
13 {
14
15 }
16
17 //--------------------------------------------------------------------------
19 {
20 GetGame().GetDragQueue().RemoveCalls(this);
21 if (GetGame().GetMission())
22 {
23 GetGame().GetMission().GetHud().ShowHudUI(true);
24 GetGame().GetMission().GetHud().ShowQuickbarUI(true);
25 }
26 }
27
28 //--------------------------------------------------------------------------
29 override Widget Init()
30 {
31 layoutRoot = GetGame().GetWorkspace().CreateWidgets("gui/layouts/inventory_new/day_z_inventory_new_inspect.layout");
32
33
34 return layoutRoot;
35 }
36
37 //--------------------------------------------------------------------------
38 override bool OnClick(Widget w, int x, int y, int button)
39 {
40 super.OnClick(w, x, y, button);
41
42 switch (w.GetUserID())
43 {
44 case IDC_CANCEL:
45 Close();
46 return true;
47 }
48
49 return false;
50 }
51
52 //--------------------------------------------------------------------------
54 {
55 if (item)
56 {
57 InspectMenuNew.UpdateItemInfo(layoutRoot, item);
58
59 if (!m_item_widget)
60 {
61 Widget preview_frame = layoutRoot.FindAnyWidget("ItemFrameWidget");
62 if (preview_frame)
63 m_item_widget = ItemPreviewWidget.Cast(preview_frame);
64 }
65
66 m_item_widget.SetItem(item);
67 m_item_widget.SetView(item.GetViewIndex());
68 m_item_widget.SetModelPosition(Vector(0, 0, 1));
69 PPERequesterBank.GetRequester(PPERequester_InventoryBlur).Start();
70 }
71 }
72
73 //--------------------------------------------------------------------------
74 override bool OnMouseButtonDown(Widget w, int x, int y, int button)
75 {
76 super.OnMouseButtonDown(w, x, y, button);
77
78 if (w == m_item_widget)
79 {
80 GetGame().GetDragQueue().Call(this, "UpdateRotation");
81 GetMousePos(m_characterRotationX, m_characterRotationY);
82 return true;
83 }
84 return false;
85 }
86
87 //--------------------------------------------------------------------------
89 {
91 o[0] = o[0] + (m_characterRotationY - mouse_y);
92 o[1] = o[1] - (m_characterRotationX - mouse_x);
93
94 m_item_widget.SetModelOrientation(o);
95
96 if (!is_dragging)
97 m_characterOrientation = o;
98 }
99
100 //--------------------------------------------------------------------------
101 override bool OnMouseWheel(Widget w, int x, int y, int wheel)
102 {
103 super.OnMouseWheel(w, x, y, wheel);
104
105 if (w == m_item_widget)
106 {
107 m_characterScaleDelta = wheel;
108 UpdateScale();
109 }
110 return false;
111 }
112
113 //--------------------------------------------------------------------------
115 {
116 float w, h, x, y;
117 m_item_widget.GetPos(x, y);
118 m_item_widget.GetSize(w, h);
119 w = w + (m_characterScaleDelta / 4);
120 h = h + (m_characterScaleDelta / 4);
121 if (w > 0.5 && w < 3)
122 {
123 m_item_widget.SetSize(w, h);
124
125 // align to center
126 int screen_w, screen_h;
128 float new_x = x - (m_characterScaleDelta / 8);
129 float new_y = y - (m_characterScaleDelta / 8);
130 m_item_widget.SetPos(new_x, new_y);
131 }
132 }
133 //--------------------------------------------------------------------------
135 {
136 if (!root_widget || !item) return;
137
138 Widget panelInfo = root_widget.FindAnyWidget("InventoryInfoPanelWidget");
139 if (panelInfo)
140 {
141 if (item.IsInherited(ZombieBase) || item.IsInherited(Car))
142 panelInfo.Show(false);
143 else
144 panelInfo.Show(true);
145 }
146
147 if (!item.IsInherited(ZombieBase) && !item.IsInherited(Car))
148 {
150 WidgetTrySetText(root_widget, "ItemDescWidget", iItem.GetTooltip());
151 }
152
153 WidgetTrySetText(root_widget, "ItemNameWidget", item.GetDisplayName());
154 InspectMenuNew.UpdateItemInfoDamage(root_widget, item);
155 InspectMenuNew.UpdateItemInfoLiquidType(root_widget, item);
156 InspectMenuNew.UpdateItemInfoTemperature(root_widget, item);
157 InspectMenuNew.UpdateItemInfoWetness(root_widget, item);
158 InspectMenuNew.UpdateItemInfoQuantity(root_widget, item);
159 InspectMenuNew.UpdateItemInfoWeight(root_widget, item);
160 InspectMenuNew.UpdateItemInfoFoodStage(root_widget, item);
161 InspectMenuNew.UpdateItemInfoCleanness(root_widget, item);
162
163 Widget content = root_widget.FindAnyWidget("InventoryInfoPanelWidget");
164 }
165
166 //--------------------------------------------------------------------------
167 static void UpdateSlotInfo(Widget root_widget, string name, string desc = "")
168 {
169 if (!root_widget) return;
170
171 WidgetTrySetText(root_widget, "ItemNameWidget", name);
172 }
173
174 //--------------------------------------------------------------------------
176 {
177 if (item.IsInherited(ZombieBase) || item.IsInherited(Car)) return;
178
179 int damageLevel = item.GetHealthLevel();
180
181 switch (damageLevel)
182 {
184 {
185 WidgetTrySetText(root_widget, "ItemDamageWidget", "#inv_inspect_ruined", Colors.COLOR_RUINED);
186 break;
187 }
189 {
190 WidgetTrySetText(root_widget, "ItemDamageWidget", "#inv_inspect_badly", Colors.COLOR_BADLY_DAMAGED);
191 break;
192 }
193
195 {
196 WidgetTrySetText(root_widget, "ItemDamageWidget", "#inv_inspect_damaged", Colors.COLOR_DAMAGED);
197 break;
198 }
199
201 {
202 WidgetTrySetText(root_widget, "ItemDamageWidget", "#inv_inspect_worn", Colors.COLOR_WORN);
203 break;
204 }
205
207 {
208 WidgetTrySetText(root_widget, "ItemDamageWidget", "#inv_inspect_pristine", Colors.COLOR_PRISTINE);
209 break;
210 }
211
212 default:
213 {
214 WidgetTrySetText(root_widget, "ItemDamageWidget", "ERROR", Colors.COLOR_PRISTINE);
215 break;
216 }
217 }
218
219 }
220
221 //--------------------------------------------------------------------------
223 {
224 if (item.IsInherited(ZombieBase) || item.IsInherited(Car)) return;
225
227
228 if (item_base && item_base.GetQuantity() > 0 && item_base.IsBloodContainer())
229 {
231
232 if (blood_container.GetBloodTypeVisible())
233 {
234 string type;
235 bool positive;
236 string blood_type_name = BloodTypes.GetBloodTypeName(blood_container.GetLiquidType(), type, positive);
237 WidgetTrySetText(root_widget, "ItemLiquidTypeWidget", "#inv_inspect_blood: " + blood_type_name, Colors.COLOR_LIQUID);
238 }
239 else
240 WidgetTrySetText(root_widget, "ItemLiquidTypeWidget", "#inv_inspect_blood", Colors.COLOR_LIQUID);
241 }
242 else if (item_base && item_base.GetQuantity() > 0 && item_base.IsLiquidContainer())
243 {
244 int liquid_type = item_base.GetLiquidType();
245
246 switch (liquid_type)
247 {
248 case LIQUID_WATER:
249 {
250 WidgetTrySetText(root_widget, "ItemLiquidTypeWidget", "#inv_inspect_water", Colors.COLOR_LIQUID);
251 break;
252 }
253
255 {
256 WidgetTrySetText(root_widget, "ItemLiquidTypeWidget", "#inv_inspect_river_water", Colors.COLOR_LIQUID);
257 break;
258 }
259
260 case LIQUID_VODKA:
261 {
262 WidgetTrySetText(root_widget, "ItemLiquidTypeWidget", "#inv_inspect_vodka", Colors.COLOR_LIQUID);
263 break;
264 }
265
266 case LIQUID_BEER:
267 {
268 WidgetTrySetText(root_widget, "ItemLiquidTypeWidget", "#inv_inspect_beer", Colors.COLOR_LIQUID);
269 break;
270 }
271
272 case LIQUID_GASOLINE:
273 {
274 WidgetTrySetText(root_widget, "ItemLiquidTypeWidget", "#inv_inspect_gasoline", Colors.COLOR_LIQUID);
275 break;
276 }
277
278 case LIQUID_DIESEL:
279 {
280 WidgetTrySetText(root_widget, "ItemLiquidTypeWidget", "#inv_inspect_diesel", Colors.COLOR_LIQUID);
281 break;
282 }
283
285 {
286 WidgetTrySetText(root_widget, "ItemLiquidTypeWidget", "#inv_inspect_disinfectant", Colors.COLOR_LIQUID);
287 break;
288 }
289
290 case LIQUID_SALINE:
291 {
292 WidgetTrySetText(root_widget, "ItemLiquidTypeWidget", "#inv_inspect_saline", Colors.COLOR_LIQUID);
293 break;
294 }
295
296 default:
297 {
298 WidgetTrySetText(root_widget, "ItemLiquidTypeWidget", "ERROR", Colors.COLOR_LIQUID);
299 break;
300 }
301 }
302 }
303 else
304 WidgetTrySetText(root_widget, "ItemLiquidTypeWidget", "");
305 }
306
307 //--------------------------------------------------------------------------
309 {
310 if (item.IsInherited(ZombieBase) || item.IsInherited(Car)) return;
311 float temperature;
313 if (item_base)
314 temperature = item_base.GetTemperature();
315
316 if (temperature > 30)
317 {
318 if (temperature > 100)
319 temperature = 100 * Math.Floor(temperature / 100.0);
320 else
321 temperature = 10 * Math.Floor(temperature / 10.0);
322 WidgetTrySetText(root_widget, "ItemTemperatureWidget", "#inv_inspect_about " + temperature.ToString() + " " + "#inv_inspect_celsius", GetTemperatureColor(temperature));
323 }
324 else
325 WidgetTrySetText(root_widget, "ItemTemperatureWidget", "");
326 }
327
328 //--------------------------------------------------------------------------
330 {
331 if (item.IsInherited(ZombieBase) || item.IsInherited(Car)) return;
332 float wetness = 0;
333
334 if (item.IsInherited(ItemBase))
335 {
337 wetness = item_IB.GetWet();
338 }
339
341 WidgetTrySetText(root_widget, "ItemWetnessWidget", "");
343 WidgetTrySetText(root_widget, "ItemWetnessWidget", "#inv_inspcet_damp", Colors.COLOR_DAMP);
345 WidgetTrySetText(root_widget, "ItemWetnessWidget", "#inv_inspect_wet", Colors.COLOR_WET);
347 WidgetTrySetText(root_widget, "ItemWetnessWidget", "#inv_inspect_soaking_wet", Colors.COLOR_SOAKING_WET);
348 else
349 WidgetTrySetText(root_widget, "ItemWetnessWidget", "#inv_inspect_drenched", Colors.COLOR_DRENCHED);
350 }
351
352 //--------------------------------------------------------------------------
354 {
355 if (item.IsInherited(ZombieBase) || item.IsInherited(Car)) return;
356
358 if (item_base)
359 {
360 float item_quantity = item_base.GetQuantity();
361 int max_quantity = item.GetQuantityMax();
362
363 float quantity_ratio;
364
365 if (max_quantity > 0 && !item.IsInherited(ClothingBase)) // Some items, like books, have max_quantity set to 0 => division by ZERO error in quantity_ratio
366 {
367 string quantity_str;
368 if (item.ConfigGetString("stackedUnit") == "pc.")
369 {
370 if (item_quantity == 1)
371 WidgetTrySetText(root_widget, "ItemQuantityWidget", item_quantity.ToString() + " " + "#inv_inspect_piece", Colors.COLOR_DEFAULT);
372 else
373 WidgetTrySetText(root_widget, "ItemQuantityWidget", item_quantity.ToString() + " " + "#inv_inspect_pieces", Colors.COLOR_DEFAULT);
374 }
375 else if (item.ConfigGetString("stackedUnit") == "percentage")
376 {
378
379 quantity_str = "#inv_inspect_remaining " + quantity_ratio.ToString() + "#inv_inspect_percent";
381 }
382 else if (item.ConfigGetString("stackedUnit") == "g")
383 {
385
386 quantity_str = "#inv_inspect_remaining " + quantity_ratio.ToString() + "#inv_inspect_percent";
388 }
389 else if (item.ConfigGetString("stackedUnit") == "ml")
390 {
392
393 quantity_str = "#inv_inspect_remaining " + quantity_ratio.ToString() + "#inv_inspect_percent";
395 }
396 else if (item.IsInherited(Magazine))
397 {
400
401 if (magazine_item.GetAmmoCount() == 1)
402 WidgetTrySetText(root_widget, "ItemQuantityWidget", magazine_item.GetAmmoCount().ToString() + " " + "#inv_inspect_piece", Colors.COLOR_DEFAULT);
403 else
404 WidgetTrySetText(root_widget, "ItemQuantityWidget", magazine_item.GetAmmoCount().ToString() + " " + "#inv_inspect_pieces", Colors.COLOR_DEFAULT);
405 }
406 else
407 WidgetTrySetText(root_widget, "ItemQuantityWidget", "");
408 }
409 else
410 {
411 if (item.IsInherited(ClothingBase))
412 {
413 float heatIsolation = MiscGameplayFunctions.GetCurrentItemHeatIsolation(item_base);
415 WidgetTrySetText(root_widget, "ItemQuantityWidget", "#inv_inspect_iso_bad", GetTemperatureColor(10));
417 WidgetTrySetText(root_widget, "ItemQuantityWidget", "#inv_inspect_iso_low", GetTemperatureColor(20));
419 WidgetTrySetText(root_widget, "ItemQuantityWidget", "#inv_inspect_iso_medium", GetTemperatureColor(30));
421 WidgetTrySetText(root_widget, "ItemQuantityWidget", "#inv_inspect_iso_high", GetTemperatureColor(50));
422 else
423 WidgetTrySetText(root_widget, "ItemQuantityWidget", "#inv_inspect_iso_excel", GetTemperatureColor(70));
424 }
425 else
426 WidgetTrySetText(root_widget, "ItemQuantityWidget", "");
427 }
428 }
429 }
430
431 //--------------------------------------------------------------------------
433 {
434 if (!item.CanDisplayWeight())
435 {
436 WidgetTrySetText(root_widget, "ItemWeightWidget", "", Colors.COLOR_DEFAULT);
437 return;
438 }
439
441 if (item_IB)
442 {
443 int weight = item_IB.GetWeightEx();
444
445 if (root_widget.GetName() != "BackPanelWidget")
446 weight = item_IB.GetSingleInventoryItemWeightEx();
447
448 if (weight >= 1000)
449 {
450 int kilos = Math.Round(weight / 1000.0);
451 WidgetTrySetText(root_widget, "ItemWeightWidget", "#inv_inspect_about" + " " + kilos.ToString() + " " + "#inv_inspect_kg", Colors.COLOR_DEFAULT);
452 }
453 else if (weight >= 500)
454 WidgetTrySetText(root_widget, "ItemWeightWidget", "#inv_inspect_under_1", Colors.COLOR_DEFAULT);
455 else if (weight >= 250)
456 WidgetTrySetText(root_widget, "ItemWeightWidget", "#inv_inspect_under_05", Colors.COLOR_DEFAULT);
457 else
458 WidgetTrySetText(root_widget, "ItemWeightWidget", "#inv_inspect_under_025", Colors.COLOR_DEFAULT);
459 }
460 }
461
462 //--------------------------------------------------------------------------
464 {
466 if (food_item && food_item.HasFoodStage())
467 {
468 ref FoodStage food_stage = food_item.GetFoodStage();
469 FoodStageType food_stage_type = food_stage.GetFoodStageType();
470
471 switch (food_stage_type)
472 {
473 case FoodStageType.RAW:
474 {
475 WidgetTrySetText(root_widget, "ItemFoodStageWidget", "#inv_inspect_raw", Colors.COLOR_RAW);
476 break;
477 }
478 case FoodStageType.BAKED:
479 {
480 WidgetTrySetText(root_widget, "ItemFoodStageWidget", "#inv_inspect_baked", Colors.COLOR_BAKED);
481 break;
482 }
483 case FoodStageType.BOILED:
484 {
485 WidgetTrySetText(root_widget, "ItemFoodStageWidget", "#inv_inspect_boiled", Colors.COLOR_BOILED);
486 break;
487 }
488 case FoodStageType.DRIED:
489 {
490 WidgetTrySetText(root_widget, "ItemFoodStageWidget", "#inv_inspect_dried", Colors.COLOR_DRIED);
491 break;
492 }
493 case FoodStageType.BURNED:
494 {
495 WidgetTrySetText(root_widget, "ItemFoodStageWidget", "#inv_inspect_burned", Colors.COLOR_BURNED);
496 break;
497 }
498 case FoodStageType.ROTTEN:
499 {
500 WidgetTrySetText(root_widget, "ItemFoodStageWidget", "#inv_inspect_rotten", Colors.COLOR_ROTTEN);
501 break;
502 }
503 }
504 }
505 else
506 WidgetTrySetText(root_widget, "ItemFoodStageWidget", "");
507 }
508
509
510 //--------------------------------------------------------------------------
512 {
513 ItemBase ib = ItemBase.Cast(item);
514 if (ib && ib.m_Cleanness == 1)
515 WidgetTrySetText(root_widget, "ItemCleannessWidget", "#inv_inspect_cleaned", Colors.WHITEGRAY);
516 else
517 WidgetTrySetText(root_widget, "ItemCleannessWidget", "");
518 }
519
520
521 //--------------------------------------------------------------------------
522 static void WidgetTrySetText(Widget root_widget, string widget_name, string text, int color = 0)
523 {
524 TextWidget widget = TextWidget.Cast(root_widget.FindAnyWidget(widget_name));
526 if (widget)
527 {
528 widget.SetText(text);
529 Widget widget_background = root_widget.FindAnyWidget(widget_name + "Background");
531 {
532 if (color != 0)
533 {
534 widget_background.Show(true);
535 widget_background.SetColor(color | 0x7F000000);
536 }
537 else
538 widget_background.Show(false);
539 }
540 }
541 if (rt_widget)
542 rt_widget.Update();
543 }
544
545};
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
FoodStageType
Definition FoodStage.c:2
Icon x
Icon y
void Close()
static string GetBloodTypeName(int bloodtype, out string type, out bool positive)
Definition BloodType.c:82
Super root of all classes in Enforce script.
Definition EnScript.c:11
Definition Colors.c:4
const int COLOR_BAKED
Definition Colors.c:34
const int COLOR_DRENCHED
Definition Colors.c:26
const int COLOR_DAMAGED
Definition Colors.c:22
const int COLOR_BADLY_DAMAGED
Definition Colors.c:21
const int COLOR_RAW
Definition Colors.c:33
const int COLOR_DAMP
Definition Colors.c:29
const int COLOR_ROTTEN
Definition Colors.c:38
const int COLOR_PRISTINE
Definition Colors.c:24
const int COLOR_BOILED
Definition Colors.c:35
const int COLOR_WET
Definition Colors.c:28
const int COLOR_SOAKING_WET
Definition Colors.c:27
const int COLOR_WORN
Definition Colors.c:23
const int COLOR_BURNED
Definition Colors.c:37
const int COLOR_DEFAULT
Definition Colors.c:18
const int WHITEGRAY
Definition Colors.c:16
const int COLOR_DRIED
Definition Colors.c:36
const int COLOR_RUINED
Definition Colors.c:20
const int COLOR_LIQUID
Definition Colors.c:31
proto native void SetView(int viewIndex)
proto native void SetModelPosition(vector vPos)
proto native void SetItem(EntityAI object)
proto native void SetModelOrientation(vector vOrientation)
Definition EnMath.c:7
static void UpdateItemInfoWetness(Widget root_widget, EntityAI item)
static void UpdateItemInfoFoodStage(Widget root_widget, EntityAI item)
static void WidgetTrySetText(Widget root_widget, string widget_name, string text, int color=0)
void UpdateRotation(int mouse_x, int mouse_y, bool is_dragging)
static void UpdateItemInfoLiquidType(Widget root_widget, EntityAI item)
override bool OnMouseWheel(Widget w, int x, int y, int wheel)
static void UpdateItemInfo(Widget root_widget, EntityAI item)
ItemPreviewWidget m_slot_widget
static void UpdateItemInfoCleanness(Widget root_widget, EntityAI item)
override bool OnMouseButtonDown(Widget w, int x, int y, int button)
static void UpdateSlotInfo(Widget root_widget, string name, string desc="")
void SetItem(EntityAI item)
override Widget Init()
static void UpdateItemInfoQuantity(Widget root_widget, EntityAI item)
override bool OnClick(Widget w, int x, int y, int button)
ItemPreviewWidget m_item_widget
static void UpdateItemInfoTemperature(Widget root_widget, EntityAI item)
vector m_characterOrientation
static void UpdateItemInfoDamage(Widget root_widget, EntityAI item)
static void UpdateItemInfoWeight(Widget root_widget, EntityAI item)
proto native CGame GetGame()
const float HEATISO_THRESHOLD_HIGH
Definition constants.c:816
const float HEATISO_THRESHOLD_MEDIUM
Definition constants.c:815
const float HEATISO_THRESHOLD_BAD
Definition constants.c:813
const float HEATISO_THRESHOLD_LOW
Definition constants.c:814
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
const int STATE_RUINED
Definition constants.c:757
const int STATE_WORN
Definition constants.c:760
const int STATE_DAMAGED
Definition constants.c:759
const int STATE_BADLY_DAMAGED
Definition constants.c:758
const int STATE_PRISTINE
Definition constants.c:761
const float STATE_DAMP
Definition constants.c:784
const float STATE_SOAKING_WET
Definition constants.c:782
const float STATE_DRENCHED
Definition constants.c:781
const float STATE_WET
Definition constants.c:783
const int LIQUID_VODKA
Definition constants.c:506
const int LIQUID_DISINFECTANT
Definition constants.c:510
const int LIQUID_BEER
Definition constants.c:507
const int LIQUID_GASOLINE
Definition constants.c:508
const int LIQUID_WATER
Definition constants.c:504
const int LIQUID_RIVERWATER
Definition constants.c:505
const int LIQUID_DIESEL
Definition constants.c:509
const int LIQUID_SALINE
Definition constants.c:502
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float Floor(float f)
Returns floor of value.
static proto float Round(float f)
Returns mathematical round of value.
proto void GetScreenSize(out int x, out int y)
proto void GetMousePos(out int x, out int y)
int GetTemperatureColor(int temperature)
Definition tools.c:929
const int IDC_CANCEL
Definition constants.c:128