5 protected Widget m_TimeSurvived;
8 protected Widget m_PlayersKilled;
11 protected Widget m_InfectedKilled;
14 protected Widget m_DistanceTraveled;
17 protected Widget m_LongRangeShot;
22 void MainMenuStats(
Widget root)
28 m_TimeSurvived =
m_Root.FindAnyWidget(
"TimeSurvived");
29 m_TimeSurvivedValue =
TextWidget.Cast(
m_Root.FindAnyWidget(
"TimeSurvivedValue"));
31 m_PlayersKilled =
m_Root.FindAnyWidget(
"PlayersKilled");
32 m_PlayersKilledValue =
TextWidget.Cast(
m_Root.FindAnyWidget(
"PlayersKilledValue"));
34 m_InfectedKilled =
m_Root.FindAnyWidget(
"InfectedKilled");
35 m_InfectedKilledValue =
TextWidget.Cast(
m_Root.FindAnyWidget(
"InfectedKilledValue"));
37 m_DistanceTraveled =
m_Root.FindAnyWidget(
"DistanceTraveled");
38 m_DistanceTraveledValue =
TextWidget.Cast(
m_Root.FindAnyWidget(
"DistanceTraveledValue"));
40 m_LongRangeShot =
m_Root.FindAnyWidget(
"LongRangeShot");
41 m_LongRangeShotValue =
TextWidget.Cast(
m_Root.FindAnyWidget(
"LongRangeShotValue"));
58 MissionMainMenu missionMainMenu = MissionMainMenu.Cast(
GetGame().GetMission());
60 if (missionMainMenu && missionMainMenu.GetIntroScenePC())
62 #ifdef PLATFORM_WINDOWS
63 player = missionMainMenu.GetIntroScenePC().GetIntroCharacter().GetCharacterObj();
65 #ifdef PLATFORM_CONSOLE
66 player = missionMainMenu.GetIntroScenePC().GetIntroCharacter().GetCharacterObj();
71 TimeConversions.ConvertSecondsToFullTime(player.StatGet(
AnalyticsManagerServer.STAT_PLAYTIME), m_TimeSurvivedFull);
72 m_TimeSurvivedValue.SetText(m_TimeSurvivedFull.FormatedNonZero());
75 m_InfectedKilledValue.SetText(GetValueString(player.StatGet(
AnalyticsManagerServer.STAT_INFECTED_KILLED)));
77 m_LongRangeShotValue.SetText(GetDistanceString(player.StatGet(
AnalyticsManagerServer.STAT_LONGEST_SURVIVOR_HIT),
true));
82 protected string GetDistanceString(
float total_distance,
bool meters_only =
false )
84 if (total_distance > 0)
86 string distanceString;
88 float kilometers = total_distance * 0.001;
89 kilometers =
Math.Round(kilometers);
90 if ( kilometers >= 10 && !meters_only )
92 distanceString = GetValueString(kilometers,
true) +
" #STR_distance_unit_abbrev_kilometer_0";
96 distanceString = GetValueString(total_distance) +
" #STR_distance_unit_abbrev_meter_0";
99 return distanceString;
102 return "0" +
" #STR_distance_unit_abbrev_meter_0";
105 protected string GetValueString(
float total_value,
bool show_decimals =
false)
111 int total_value_int = total_value;
112 string number_str = total_value_int.ToString();
115 if ( total_value >= 1000 )
118 int first_length = number_str.Length() % 3;
119 if ( first_length > 0 )
121 count = 3 - first_length;
124 for (
int i = 0; i < number_str.Length(); ++i )
126 out_string += number_str.Get( i );
138 out_string = number_str;
144 string total_value_str = total_value.ToString();
145 int decimal_idx = total_value_str.IndexOf(
"." );
147 if ( decimal_idx > -1 )
149 out_string.TrimInPlace();
150 out_string += total_value_str.Substring( decimal_idx, total_value_str.Length() - decimal_idx );
163 protected string GetTimeString(
float total_time);