DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ UpdateItemInfoQuantity()

static void UIScriptedMenu::UpdateItemInfoQuantity ( Widget root_widget,
EntityAI item )
inlinestaticprivate

См. определение в файле InspectMenuNew.c строка 386

387 {
388 if ( item.IsInherited( ZombieBase ) || item.IsInherited( Car ) ) return;
389
390 ItemBase item_base = ItemBase.Cast( item );
391 if( item_base )
392 {
393 float item_quantity = item_base.GetQuantity();
394 int max_quantity = item.GetQuantityMax();
395
396 float quantity_ratio;
397
398 if( max_quantity > 0 && !item.IsInherited( ClothingBase )) // Some items, like books, have max_quantity set to 0 => division by ZERO error in quantity_ratio
399 {
400 string quantity_str;
401 if( item.ConfigGetString("stackedUnit") == "pc." )
402 {
403 if( item_quantity == 1 )
404 {
405 WidgetTrySetText( root_widget, "ItemQuantityWidget", item_quantity.ToString() + " " + "#inv_inspect_piece", Colors.COLOR_DEFAULT );
406 }
407 else
408 {
409 WidgetTrySetText( root_widget, "ItemQuantityWidget", item_quantity.ToString() + " " + "#inv_inspect_pieces", Colors.COLOR_DEFAULT );
410 }
411 }
412 else if( item.ConfigGetString("stackedUnit") == "percentage" )
413 {
414 quantity_ratio = Math.Round( ( item_quantity / max_quantity ) * 100 );
415
416 quantity_str = "#inv_inspect_remaining " + quantity_ratio.ToString() + "#inv_inspect_percent";
417 WidgetTrySetText( root_widget, "ItemQuantityWidget", quantity_str, Colors.COLOR_DEFAULT );
418 }
419 else if( item.ConfigGetString("stackedUnit") == "g" )
420 {
421 quantity_ratio = Math.Round( ( item_quantity / max_quantity ) * 100 );
422
423 quantity_str = "#inv_inspect_remaining " + quantity_ratio.ToString() + "#inv_inspect_percent";
424 WidgetTrySetText( root_widget, "ItemQuantityWidget", quantity_str, Colors.COLOR_DEFAULT );
425 }
426 else if( item.ConfigGetString("stackedUnit") == "ml" )
427 {
428 quantity_ratio = Math.Round( ( item_quantity / max_quantity ) * 100 );
429
430 quantity_str = "#inv_inspect_remaining " + quantity_ratio.ToString() + "#inv_inspect_percent";
431 WidgetTrySetText( root_widget, "ItemQuantityWidget", quantity_str, Colors.COLOR_DEFAULT );
432 }
433 else if( item.IsInherited( Magazine ) )
434 {
435 Magazine magazine_item;
436 Class.CastTo(magazine_item, item);
437
438 if( magazine_item.GetAmmoCount() == 1 )
439 {
440 WidgetTrySetText( root_widget, "ItemQuantityWidget", magazine_item.GetAmmoCount().ToString() + " " + "#inv_inspect_piece", Colors.COLOR_DEFAULT );
441 }
442 else
443 {
444 WidgetTrySetText( root_widget, "ItemQuantityWidget", magazine_item.GetAmmoCount().ToString() + " " + "#inv_inspect_pieces", Colors.COLOR_DEFAULT );
445 }
446 }
447 else
448 {
449 WidgetTrySetText( root_widget, "ItemQuantityWidget", "" );
450 }
451 }
452 else
453 {
454 if ( item.IsInherited( ClothingBase ) )
455 {
456 float heatIsolation = MiscGameplayFunctions.GetCurrentItemHeatIsolation( item_base );
457 if ( heatIsolation <= GameConstants.HEATISO_THRESHOLD_BAD )
458 {
459 WidgetTrySetText( root_widget, "ItemQuantityWidget", "#inv_inspect_iso_worst", GetTemperatureColor( 10 ) );
460 }
461 else if ( ( heatIsolation > GameConstants.HEATISO_THRESHOLD_BAD ) && ( heatIsolation <= GameConstants.HEATISO_THRESHOLD_LOW ) )
462 {
463 WidgetTrySetText( root_widget, "ItemQuantityWidget", "#inv_inspect_iso_low", GetTemperatureColor( 20 ) );
464 }
465 else if ( ( heatIsolation > GameConstants.HEATISO_THRESHOLD_LOW ) && ( heatIsolation <= GameConstants.HEATISO_THRESHOLD_MEDIUM ) )
466 {
467 WidgetTrySetText( root_widget, "ItemQuantityWidget", "#inv_inspect_iso_medium", GetTemperatureColor( 30 ) );
468 }
469 else if ( ( heatIsolation > GameConstants.HEATISO_THRESHOLD_MEDIUM ) && ( heatIsolation <= GameConstants.HEATISO_THRESHOLD_HIGH ) )
470 {
471 WidgetTrySetText( root_widget, "ItemQuantityWidget", "#inv_inspect_iso_high", GetTemperatureColor( 50 ) );
472 }
473 else
474 {
475 WidgetTrySetText( root_widget, "ItemQuantityWidget", "#inv_inspect_iso_excel", GetTemperatureColor( 70 ) );
476 }
477 }
478 else
479 {
480 WidgetTrySetText( root_widget, "ItemQuantityWidget", "" );
481 }
482 }
483 }
484 }
Clothing ClothingBase
Определения Clothing_Base.c:194
class GP5GasMask extends MaskBase ItemBase
static void WidgetTrySetText(Widget root_widget, string widget_name, string text, int color=0)
Определения InspectMenuNew.c:592
proto string ToString(bool simple=true)
@ Colors
Определения EnWorld.c:88
int GetTemperatureColor(int temperature)
Определения tools.c:992

Перекрестные ссылки Class::CastTo(), Colors::COLOR_DEFAULT, GetTemperatureColor(), GameConstants::HEATISO_THRESHOLD_BAD, GameConstants::HEATISO_THRESHOLD_HIGH, GameConstants::HEATISO_THRESHOLD_LOW, GameConstants::HEATISO_THRESHOLD_MEDIUM, Math::Round(), float::ToString() и WidgetTrySetText().