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

◆ GetValueString()

string ScriptedWidgetEventHandler::GetValueString ( float total_value,
bool show_decimals = false )
inlineprotected

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

106 {
107 if (total_value > 0)
108 {
109 string out_string;
110
111 int total_value_int = total_value;
112 string number_str = total_value_int.ToString();
113
114 //number
115 if ( total_value >= 1000 )
116 {
117 int count;
118 int first_length = number_str.Length() % 3; //calculate position of the first separator
119 if ( first_length > 0 )
120 {
121 count = 3 - first_length;
122 }
123
124 for ( int i = 0; i < number_str.Length(); ++i )
125 {
126 out_string += number_str.Get( i );
127 count ++;
128
129 if ( count >= 3 )
130 {
131 out_string += " "; //separator
132 count = 0;
133 }
134 }
135 }
136 else
137 {
138 out_string = number_str;
139 }
140
141 //decimals
142 if ( show_decimals )
143 {
144 string total_value_str = total_value.ToString();
145 int decimal_idx = total_value_str.IndexOf( "." );
146
147 if ( decimal_idx > -1 )
148 {
149 out_string.TrimInPlace();
150 out_string += total_value_str.Substring( decimal_idx, total_value_str.Length() - decimal_idx );
151 }
152 }
153
154 return out_string;
155 }
156
157 return "0";
158 }
proto string ToString(bool simple=true)
proto native int Length()
Returns length of string.
proto string Get(int index)
Gets n-th character from string.
proto string Substring(int start, int len)
Substring of 'str' from 'start' position 'len' number of characters.
proto int TrimInPlace()
Removes leading and trailing whitespaces in string. Returns length.
proto native int IndexOf(string sample)
Finds 'sample' in 'str'. Returns -1 when not found.

Перекрестные ссылки string::Get(), string::IndexOf(), string::Length(), string::Substring(), float::ToString() и string::TrimInPlace().

Используется в GetDistanceString() и UpdateStats().