6 private int m_characterRotationX;
7 private int m_characterRotationY;
8 private int m_characterScaleDelta;
9 private vector m_characterOrientation;
18 void ~InspectMenuNew()
20 GetGame().GetDragQueue().RemoveCalls(
this);
23 GetGame().GetMission().GetHud().ShowHudUI(
true );
24 GetGame().GetMission().GetHud().ShowQuickbarUI(
true );
31 layoutRoot =
GetGame().GetWorkspace().CreateWidgets(
"gui/layouts/inventory_new/day_z_inventory_new_inspect.layout");
40 super.OnClick(w,
x,
y, button);
42 switch (w.GetUserID())
57 InspectMenuNew.UpdateItemInfo(layoutRoot, item);
61 Widget preview_frame = layoutRoot.FindAnyWidget(
"ItemFrameWidget");
68 m_item_widget.SetItem(item);
69 m_item_widget.SetView( item.GetViewIndex() );
70 m_item_widget.SetModelPosition(
Vector(0,0,1));
71 PPERequesterBank.GetRequester(PPERequester_InventoryBlur).Start();
78 super.OnMouseButtonDown(w,
x,
y, button);
80 if (w == m_item_widget)
82 GetGame().GetDragQueue().Call(
this,
"UpdateRotation");
83 GetMousePos(m_characterRotationX, m_characterRotationY);
90 void UpdateRotation(
int mouse_x,
int mouse_y,
bool is_dragging)
92 vector o = m_characterOrientation;
93 o[0] = o[0] + (m_characterRotationY - mouse_y);
94 o[1] = o[1] - (m_characterRotationX - mouse_x);
96 m_item_widget.SetModelOrientation( o );
100 m_characterOrientation = o;
105 override bool OnMouseWheel(
Widget w,
int x,
int y,
int wheel)
107 super.OnMouseWheel(w,
x,
y, wheel);
109 if ( w == m_item_widget )
111 m_characterScaleDelta = wheel;
121 m_item_widget.GetPos(
x,
y);
122 m_item_widget.GetSize(w,h);
123 w = w + ( m_characterScaleDelta / 4);
124 h = h + ( m_characterScaleDelta / 4 );
125 if ( w > 0.5 && w < 3 )
127 m_item_widget.SetSize( w, h );
130 int screen_w, screen_h;
132 float new_x =
x - ( m_characterScaleDelta / 8 );
133 float new_y =
y - ( m_characterScaleDelta / 8 );
134 m_item_widget.SetPos( new_x, new_y );
140 if (!root_widget || !item)
return;
142 Widget panelInfo = root_widget.FindAnyWidget(
"InventoryInfoPanelWidget");
145 if ( item.IsInherited(
ZombieBase ) || item.IsInherited( Car ) )
147 panelInfo.Show(
false );
151 panelInfo.Show(
true );
155 if ( !item.IsInherited(
ZombieBase ) && !item.IsInherited( Car ) )
158 WidgetTrySetText(root_widget,
"ItemDescWidget", iItem.GetTooltip());
161 WidgetTrySetText(root_widget,
"ItemNameWidget", item.GetDisplayName());
162 InspectMenuNew.UpdateItemInfoDamage(root_widget, item);
163 InspectMenuNew.UpdateItemInfoLiquidType(root_widget, item);
164 InspectMenuNew.UpdateItemInfoTemperature(root_widget, item);
165 InspectMenuNew.UpdateItemInfoWetness(root_widget, item);
166 InspectMenuNew.UpdateItemInfoQuantity(root_widget, item);
167 InspectMenuNew.UpdateItemInfoWeight(root_widget, item);
168 InspectMenuNew.UpdateItemInfoFoodStage(root_widget, item);
169 InspectMenuNew.UpdateItemInfoCleanness(root_widget, item);
171 Widget content = root_widget.FindAnyWidget(
"InventoryInfoPanelWidget");
175 static void UpdateSlotInfo(
Widget root_widget,
string name,
string desc =
"")
177 if (!root_widget )
return;
179 WidgetTrySetText(root_widget,
"ItemNameWidget",
name);
183 static void UpdateItemInfoDamage(
Widget root_widget,
EntityAI item)
185 if ( item.IsInherited(
ZombieBase ) || item.IsInherited( Car ) )
return;
187 int damageLevel = item.GetHealthLevel();
193 WidgetTrySetText(root_widget,
"ItemDamageWidget",
"#inv_inspect_ruined",
Colors.COLOR_RUINED);
198 WidgetTrySetText(root_widget,
"ItemDamageWidget",
"#inv_inspect_badly",
Colors.COLOR_BADLY_DAMAGED);
204 WidgetTrySetText(root_widget,
"ItemDamageWidget",
"#inv_inspect_damaged",
Colors.COLOR_DAMAGED);
210 WidgetTrySetText(root_widget,
"ItemDamageWidget",
"#inv_inspect_worn",
Colors.COLOR_WORN);
216 WidgetTrySetText(root_widget,
"ItemDamageWidget",
"#inv_inspect_pristine",
Colors.COLOR_PRISTINE);
222 WidgetTrySetText(root_widget,
"ItemDamageWidget",
"ERROR",
Colors.COLOR_PRISTINE);
230 static void UpdateItemInfoLiquidType(
Widget root_widget,
EntityAI item)
232 if ( item.IsInherited(
ZombieBase ) || item.IsInherited( Car ) )
return;
236 if( item_base && item_base.GetQuantity() > 0 && item_base.IsBloodContainer() )
240 if( blood_container.GetBloodTypeVisible() )
244 string blood_type_name =
BloodTypes.GetBloodTypeName(blood_container.GetLiquidType(), type, positive);
245 WidgetTrySetText(root_widget,
"ItemLiquidTypeWidget",
"#inv_inspect_blood: " + blood_type_name,
Colors.COLOR_LIQUID);
249 WidgetTrySetText(root_widget,
"ItemLiquidTypeWidget",
"#inv_inspect_blood",
Colors.COLOR_LIQUID);
252 else if( item_base && item_base.GetQuantity() > 0 && item_base.IsLiquidContainer() )
254 int liquid_type = item_base.GetLiquidType();
260 WidgetTrySetText(root_widget,
"ItemLiquidTypeWidget",
"#inv_inspect_water",
Colors.COLOR_LIQUID);
266 WidgetTrySetText(root_widget,
"ItemLiquidTypeWidget",
"#inv_inspect_river_water",
Colors.COLOR_LIQUID);
272 WidgetTrySetText(root_widget,
"ItemLiquidTypeWidget",
"#inv_inspect_vodka",
Colors.COLOR_LIQUID);
278 WidgetTrySetText(root_widget,
"ItemLiquidTypeWidget",
"#inv_inspect_beer",
Colors.COLOR_LIQUID);
284 WidgetTrySetText(root_widget,
"ItemLiquidTypeWidget",
"#inv_inspect_gasoline",
Colors.COLOR_LIQUID);
290 WidgetTrySetText(root_widget,
"ItemLiquidTypeWidget",
"#inv_inspect_diesel",
Colors.COLOR_LIQUID);
296 WidgetTrySetText(root_widget,
"ItemLiquidTypeWidget",
"#inv_inspect_disinfectant",
Colors.COLOR_LIQUID);
302 WidgetTrySetText(root_widget,
"ItemLiquidTypeWidget",
"#inv_inspect_saline",
Colors.COLOR_LIQUID);
308 WidgetTrySetText(root_widget,
"ItemLiquidTypeWidget",
"ERROR",
Colors.COLOR_LIQUID);
315 WidgetTrySetText(root_widget,
"ItemLiquidTypeWidget",
"");
320 static void UpdateItemInfoTemperature(
Widget root_widget,
EntityAI item)
322 if ( item.IsInherited(
ZombieBase ) || item.IsInherited( Car ) )
return;
327 temperature = item_base.GetTemperature();
330 if( temperature > 30 )
332 if ( temperature > 100 )
334 temperature = 100 *
Math.Floor( temperature / 100.0 );
338 temperature = 10 *
Math.Floor( temperature / 10.0 );
340 WidgetTrySetText(root_widget,
"ItemTemperatureWidget",
"#inv_inspect_about " + temperature.ToString() +
" " +
"#inv_inspect_celsius",
GetTemperatureColor( temperature ) );
344 WidgetTrySetText(root_widget,
"ItemTemperatureWidget",
"");
349 static void UpdateItemInfoWetness(
Widget root_widget,
EntityAI item)
351 if ( item.IsInherited(
ZombieBase ) || item.IsInherited( Car ) )
return;
357 wetness = item_IB.GetWet();
362 WidgetTrySetText(root_widget,
"ItemWetnessWidget",
"");
366 WidgetTrySetText(root_widget,
"ItemWetnessWidget",
"#inv_inspcet_damp",
Colors.COLOR_DAMP);
370 WidgetTrySetText( root_widget,
"ItemWetnessWidget",
"#inv_inspect_wet",
Colors.COLOR_WET );
374 WidgetTrySetText( root_widget,
"ItemWetnessWidget",
"#inv_inspect_soaking_wet",
Colors.COLOR_SOAKING_WET );
378 WidgetTrySetText( root_widget,
"ItemWetnessWidget",
"#inv_inspect_drenched",
Colors.COLOR_DRENCHED );
383 static void UpdateItemInfoQuantity(
Widget root_widget,
EntityAI item)
385 if ( item.IsInherited(
ZombieBase ) || item.IsInherited( Car ) )
return;
390 float item_quantity = item_base.GetQuantity();
391 int max_quantity = item.GetQuantityMax();
393 float quantity_ratio;
395 if( max_quantity > 0 && !item.IsInherited(
ClothingBase ))
398 if( item.ConfigGetString(
"stackedUnit") ==
"pc." )
400 if( item_quantity == 1 )
402 WidgetTrySetText( root_widget,
"ItemQuantityWidget", item_quantity.ToString() +
" " +
"#inv_inspect_piece",
Colors.COLOR_DEFAULT );
406 WidgetTrySetText( root_widget,
"ItemQuantityWidget", item_quantity.ToString() +
" " +
"#inv_inspect_pieces",
Colors.COLOR_DEFAULT );
409 else if( item.ConfigGetString(
"stackedUnit") ==
"percentage" )
411 quantity_ratio =
Math.Round( ( item_quantity / max_quantity ) * 100 );
413 quantity_str =
"#inv_inspect_remaining " + quantity_ratio.ToString() +
"#inv_inspect_percent";
414 WidgetTrySetText( root_widget,
"ItemQuantityWidget", quantity_str,
Colors.COLOR_DEFAULT );
416 else if( item.ConfigGetString(
"stackedUnit") ==
"g" )
418 quantity_ratio =
Math.Round( ( item_quantity / max_quantity ) * 100 );
420 quantity_str =
"#inv_inspect_remaining " + quantity_ratio.ToString() +
"#inv_inspect_percent";
421 WidgetTrySetText( root_widget,
"ItemQuantityWidget", quantity_str,
Colors.COLOR_DEFAULT );
423 else if( item.ConfigGetString(
"stackedUnit") ==
"ml" )
425 quantity_ratio =
Math.Round( ( item_quantity / max_quantity ) * 100 );
427 quantity_str =
"#inv_inspect_remaining " + quantity_ratio.ToString() +
"#inv_inspect_percent";
428 WidgetTrySetText( root_widget,
"ItemQuantityWidget", quantity_str,
Colors.COLOR_DEFAULT );
430 else if( item.IsInherited( Magazine ) )
432 Magazine magazine_item;
433 Class.CastTo(magazine_item, item);
435 if( magazine_item.GetAmmoCount() == 1 )
437 WidgetTrySetText( root_widget,
"ItemQuantityWidget", magazine_item.GetAmmoCount().ToString() +
" " +
"#inv_inspect_piece",
Colors.COLOR_DEFAULT );
441 WidgetTrySetText( root_widget,
"ItemQuantityWidget", magazine_item.GetAmmoCount().ToString() +
" " +
"#inv_inspect_pieces",
Colors.COLOR_DEFAULT );
446 WidgetTrySetText( root_widget,
"ItemQuantityWidget",
"" );
453 float heatIsolation = MiscGameplayFunctions.GetCurrentItemHeatIsolation( item_base );
456 WidgetTrySetText( root_widget,
"ItemQuantityWidget",
"#inv_inspect_iso_bad",
GetTemperatureColor( 10 ) );
458 else if ( ( heatIsolation >
GameConstants.HEATISO_THRESHOLD_BAD ) && ( heatIsolation <=
GameConstants.HEATISO_THRESHOLD_LOW ) )
460 WidgetTrySetText( root_widget,
"ItemQuantityWidget",
"#inv_inspect_iso_low",
GetTemperatureColor( 20 ) );
462 else if ( ( heatIsolation >
GameConstants.HEATISO_THRESHOLD_LOW ) && ( heatIsolation <=
GameConstants.HEATISO_THRESHOLD_MEDIUM ) )
464 WidgetTrySetText( root_widget,
"ItemQuantityWidget",
"#inv_inspect_iso_medium",
GetTemperatureColor( 30 ) );
466 else if ( ( heatIsolation >
GameConstants.HEATISO_THRESHOLD_MEDIUM ) && ( heatIsolation <=
GameConstants.HEATISO_THRESHOLD_HIGH ) )
468 WidgetTrySetText( root_widget,
"ItemQuantityWidget",
"#inv_inspect_iso_high",
GetTemperatureColor( 50 ) );
472 WidgetTrySetText( root_widget,
"ItemQuantityWidget",
"#inv_inspect_iso_excel",
GetTemperatureColor( 70 ) );
477 WidgetTrySetText( root_widget,
"ItemQuantityWidget",
"" );
484 static void UpdateItemInfoWeight(
Widget root_widget,
EntityAI item)
486 if (!item.CanDisplayWeight())
488 WidgetTrySetText(root_widget,
"ItemWeightWidget",
"",
Colors.COLOR_DEFAULT);
495 int weight = item_IB.GetWeightEx();
497 if (root_widget.GetName() !=
"BackPanelWidget")
499 weight = item_IB.GetSingleInventoryItemWeightEx();
504 int kilos =
Math.Round(weight / 1000.0);
505 WidgetTrySetText(root_widget,
"ItemWeightWidget",
"#inv_inspect_about" +
" " + kilos.ToString() +
" " +
"#inv_inspect_kg",
Colors.COLOR_DEFAULT);
507 else if (weight >= 500)
509 WidgetTrySetText(root_widget,
"ItemWeightWidget",
"#inv_inspect_under_1",
Colors.COLOR_DEFAULT);
511 else if (weight >= 250)
513 WidgetTrySetText(root_widget,
"ItemWeightWidget",
"#inv_inspect_under_05",
Colors.COLOR_DEFAULT);
517 WidgetTrySetText(root_widget,
"ItemWeightWidget",
"#inv_inspect_under_025",
Colors.COLOR_DEFAULT);
523 static void UpdateItemInfoFoodStage(
Widget root_widget,
EntityAI item)
526 if ( food_item && food_item.HasFoodStage() )
528 ref FoodStage food_stage = food_item.GetFoodStage();
529 FoodStageType food_stage_type = food_stage.GetFoodStageType();
531 switch( food_stage_type )
535 WidgetTrySetText( root_widget,
"ItemFoodStageWidget",
"#inv_inspect_raw",
Colors.COLOR_RAW );
540 WidgetTrySetText( root_widget,
"ItemFoodStageWidget",
"#inv_inspect_baked",
Colors.COLOR_BAKED );
545 WidgetTrySetText( root_widget,
"ItemFoodStageWidget",
"#inv_inspect_boiled",
Colors.COLOR_BOILED );
550 WidgetTrySetText( root_widget,
"ItemFoodStageWidget",
"#inv_inspect_dried",
Colors.COLOR_DRIED );
555 WidgetTrySetText( root_widget,
"ItemFoodStageWidget",
"#inv_inspect_burned",
Colors.COLOR_BURNED );
560 WidgetTrySetText( root_widget,
"ItemFoodStageWidget",
"#inv_inspect_rotten",
Colors.COLOR_ROTTEN );
567 WidgetTrySetText( root_widget,
"ItemFoodStageWidget",
"" );
573 static void UpdateItemInfoCleanness(
Widget root_widget,
EntityAI item)
576 if(ib && ib.m_Cleanness==1)
578 WidgetTrySetText( root_widget,
"ItemCleannessWidget",
"#inv_inspect_cleaned",
Colors.WHITEGRAY );
582 WidgetTrySetText( root_widget,
"ItemCleannessWidget",
"" );
589 static void WidgetTrySetText(
Widget root_widget,
string widget_name,
string text,
int color = 0)
595 widget.SetText(text);
596 Widget widget_background = root_widget.FindAnyWidget(widget_name+
"Background");
597 if (widget_background)
601 widget_background.Show(
true );
602 widget_background.SetColor(color | 0x7F000000);
606 widget_background.Show(
false );