7 ref OptionSelectorMultistate m_CharacterAliveFilter;
8 ref OptionSelectorMultistate m_SortingFilter;
9 ref OptionSelectorMultistate m_RegionFilter;
10 ref OptionSelectorMultistate m_PingFilter;
29 GetGame().GetPlayerName( player_name );
32 array<string> character_name_options ={
"#server_browser_disabled", player_name };
33 array<string> region_options = {
"#server_browser_all",
"#server_browser_americas",
"#server_browser_europe",
"#server_browser_asia" };
34 array<string> sort_options = {
"#server_browser_column_host A-Z",
"#server_browser_column_host Z-A",
"#players_title >",
"#players_title <" };
35 array<string> ping_options = {
"#server_browser_disabled",
"<30",
"<50",
"<100",
"<200",
"<300",
"<500" };
36 array<string> two_options = {
"#server_browser_disabled",
"#server_browser_show" };
38 m_SearchByName =
EditBoxWidget.Cast( root.FindAnyWidget(
"search_name_setting_option" ) );
40 m_RegionFilter =
new OptionSelectorMultistate( root.FindAnyWidget(
"region_setting_option" ), 0,
this,
false, region_options );
41 m_PingFilter =
new OptionSelectorMultistate( root.FindAnyWidget(
"ping_setting_option" ), 0,
this,
false, ping_options );
42 #ifdef PLATFORM_CONSOLE
43 m_FavoritedFilter =
new OptionSelectorMultistate( root.FindAnyWidget(
"favorites_setting_option" ), 0,
this,
false, two_options );
45 m_FavoritedFilter =
new OptionSelector( root.FindAnyWidget(
"favorites_setting_option" ), 0,
this,
false );
48 m_DLCFilter =
new OptionSelector( root.FindAnyWidget(
"dlc_setting_option" ), 0,
this,
false );
49 m_FriendsPlayingFilter =
new OptionSelector( root.FindAnyWidget(
"friends_setting_option" ), 0,
this,
false );
50 m_PreviouslyPlayedFilter =
new OptionSelector( root.FindAnyWidget(
"prev_played_setting_option" ), 0,
this,
false );
51 m_FullServerFilter =
new OptionSelector( root.FindAnyWidget(
"full_server_setting_option" ), 0,
this,
false );
52 m_ThirdPersonFilter =
new OptionSelector( root.FindAnyWidget(
"tps_setting_option" ), 0,
this,
false );
53 m_PasswordFilter =
new OptionSelector( root.FindAnyWidget(
"password_setting_option" ), 0,
this,
false );
54 m_WhitelistFilter =
new OptionSelector( root.FindAnyWidget(
"whitelist_setting_option" ), 0,
this,
false );
67 #ifdef PLATFORM_CONSOLE
68 m_SortingFilter =
new OptionSelectorMultistate( root.FindAnyWidget(
"sort_setting_option" ), 0,
this,
false, sort_options );
69 m_KeyboardFilter =
new OptionSelector( root.FindAnyWidget(
"keyboard_setting_option" ), 0,
this,
false );
71 m_SortingFilter.m_OptionChanged.Insert( OnSortChanged );
75 m_PingFilter.Disable();
76 m_FriendsPlayingFilter.Disable();
79 #ifdef PLATFORM_WINDOWS
80 #ifndef PLATFORM_CONSOLE
81 m_SearchByIP =
EditBoxWidget.Cast( root.FindAnyWidget(
"search_ip_setting_option" ) );
83 m_SearchByName.SetHandler(
this );
84 m_SearchByIP.SetHandler(
this );
86 m_CharacterAliveFilter =
new OptionSelectorMultistate( root.FindAnyWidget(
"restrict_char_setting_option" ), 0,
this,
false, character_name_options );
87 m_VersionMatchFilter =
new OptionSelector( root.FindAnyWidget(
"ver_match_setting_option" ), 0,
this,
false );
98 m_Tab.OnFilterChanged();
104 if (m_Tab.GetTabType() ==
TabType.LAN || m_Tab.GetTabType() ==
TabType.FAVORITE)
107 GetGame().GetProfileString(
"SB_Filter_" + m_Tab.GetTabType(), data);
118 if (m_Options && m_Options.Count() >= 6)
120 m_SearchByName.SetText( m_Options.Get(
"m_SearchByName" ) );
121 m_DLCFilter.SetStringOption( m_Options.Get(
"m_DLCFilter" ) );
122 m_RegionFilter.SetStringOption( m_Options.Get(
"m_RegionFilter" ),
false );
123 m_PingFilter.SetStringOption( m_Options.Get(
"m_PingFilter" ),
false );
124 m_FriendsPlayingFilter.SetStringOption( m_Options.Get(
"m_FriendsPlayingFilter" ),
false );
125 m_PreviouslyPlayedFilter.SetStringOption( m_Options.Get(
"m_PreviouslyPlayedFilter" ),
false );
126 m_FullServerFilter.SetStringOption( m_Options.Get(
"m_FullServerFilter" ),
false );
127 m_ThirdPersonFilter.SetStringOption( m_Options.Get(
"m_ThirdPersonFilter" ),
false );
128 m_PasswordFilter.SetStringOption( m_Options.Get(
"m_PasswordFilter" ),
false );
129 m_WhitelistFilter.SetStringOption( m_Options.Get(
"m_WhitelistFilter" ),
false );
131 #ifdef PLATFORM_CONSOLE
132 m_SortingFilter.SetStringOption( m_Options.Get(
"m_SortingFilter" ),
false );
133 m_KeyboardFilter.SetStringOption( m_Options.Get(
"m_KeyboardFilter" ),
false );
135 m_FavoritedFilter.SetStringOption( m_Options.Get(
"m_FavoritedFilter" ),
false );
138 if (m_Options.Count() >= 12)
140 #ifdef PLATFORM_WINDOWS
141 #ifndef PLATFORM_CONSOLE
142 m_SearchByIP.SetText( m_Options.Get(
"m_SearchByIP" ) );
143 m_CharacterAliveFilter.SetStringOption( m_Options.Get(
"m_CharacterAliveFilter" ),
false );
144 m_VersionMatchFilter.SetStringOption( m_Options.Get(
"m_VersionMatchFilter" ),
false );
155 m_Options.Insert(
"m_SearchByName", m_SearchByName.GetText() );
156 m_Options.Insert(
"m_DLCFilter", m_DLCFilter.GetStringValue() );
157 m_Options.Insert(
"m_RegionFilter", m_RegionFilter.GetStringValue() );
158 m_Options.Insert(
"m_PingFilter", m_PingFilter.GetStringValue() );
159 m_Options.Insert(
"m_FriendsPlayingFilter", m_FriendsPlayingFilter.GetStringValue() );
160 m_Options.Insert(
"m_PreviouslyPlayedFilter", m_PreviouslyPlayedFilter.GetStringValue() );
161 m_Options.Insert(
"m_FullServerFilter", m_FullServerFilter.GetStringValue() );
162 m_Options.Insert(
"m_ThirdPersonFilter", m_ThirdPersonFilter.GetStringValue() );
163 m_Options.Insert(
"m_PasswordFilter", m_PasswordFilter.GetStringValue() );
164 m_Options.Insert(
"m_WhitelistFilter", m_WhitelistFilter.GetStringValue() );
166 #ifdef PLATFORM_CONSOLE
167 m_Options.Insert(
"m_SortingFilter", m_SortingFilter.GetStringValue() );
168 m_Options.Insert(
"m_KeyboardFilter", m_KeyboardFilter.GetStringValue() );
170 m_Options.Insert(
"m_FavoritedFilter", m_FavoritedFilter.GetStringValue() );
173 #ifdef PLATFORM_WINDOWS
174 #ifndef PLATFORM_CONSOLE
175 m_Options.Insert(
"m_SearchByIP", m_SearchByIP.GetText() );
176 m_Options.Insert(
"m_CharacterAliveFilter", m_CharacterAliveFilter.GetStringValue() );
177 m_Options.Insert(
"m_VersionMatchFilter", m_VersionMatchFilter.GetStringValue() );
181 string data, errorMessage;
185 GetGame().SetProfileString(
"SB_Filter_" + m_Tab.GetTabType(), data);
190 m_SearchByName.SetText(
"" );
191 m_RegionFilter.Reset();
193 m_PingFilter.Reset();
194 m_FavoritedFilter.Reset();
195 m_FriendsPlayingFilter.Reset();
196 m_PreviouslyPlayedFilter.Reset();
197 m_FullServerFilter.Reset();
198 m_ThirdPersonFilter.Reset();
199 m_PasswordFilter.Reset();
200 m_WhitelistFilter.Reset();
202 #ifdef PLATFORM_CONSOLE
203 m_SortingFilter.Reset();
204 m_KeyboardFilter.Reset();
207 #ifdef PLATFORM_WINDOWS
208 #ifndef PLATFORM_CONSOLE
209 m_SearchByIP.SetText(
"" );
210 m_CharacterAliveFilter.Reset();
211 m_VersionMatchFilter.Reset();
219 return ( m_Options[
"m_PingFilter"] != m_PingFilter.GetOptions()[0] );
224 return ( m_Options[
"m_FavoritedFilter"] != m_FavoritedFilter.GetOptions()[0] );
227 bool PreviouslyIsSet()
229 return ( m_Options[
"m_PreviouslyPlayedFilter"] != m_PreviouslyPlayedFilter.GetOptions()[0] );
233 bool ProcessIntoIPAddress(out
string potential_ip)
235 bool was_text_changed =
false;
236 int length = potential_ip.Length();
239 for (
int i = length - 1 ; i >= 0; --i )
241 string character = potential_ip.Get(i);
243 if ( character.ToInt() == 0 && character !=
"0" && character !=
"." && character !=
":" )
245 potential_ip = potential_ip.SubstringInverted(potential_ip, i, i + 1);
246 was_text_changed =
true;
250 bool text_was_shortened = LimitTextBoxCharacterCount( potential_ip, 21 );
252 return (was_text_changed || text_was_shortened);
256 bool LimitTextBoxCharacterCount( out
string text,
int max_length )
258 int length = text.Length();
259 bool was_text_changed =
false;
261 if ( length > max_length )
263 text = text.Substring(0, max_length);
264 was_text_changed =
true;
267 return was_text_changed;
271 string GenerateValidIP(
string potential_ip)
273 string correct_ip_format;
276 potential_ip.Split(
":", array_ip_and_port );
281 if( array_ip_and_port.Count() > 0 )
283 ip_entries = array_ip_and_port.Get( 0 );
285 ip_entries.Split(
".", array_ip );
288 int ip_entries_count = array_ip.Count();
290 if (ip_entries_count <= 3 || ip_entries_count > 4)
293 for (
int i = 0; i < 4; i++ )
295 int ip_entry = array_ip.Get(i).ToInt();
298 if ( ip_entry > 255 || ip_entry < 0 )
301 ip_string = ip_string + ip_entry.ToString();
303 if ( i < ip_entries_count - 1 )
304 ip_string = ip_string +
".";
308 correct_ip_format = ip_string;
313 correct_ip_format = ip_entries;
316 if ( correct_ip_format ==
"" )
321 if( array_ip_and_port.Count() > 1 )
323 port = array_ip_and_port.Get( 1 ).ToInt();
325 if ( port > 65535 | port < 0 )
330 correct_ip_format = correct_ip_format +
":" + port.ToString();
336 correct_ip_format = correct_ip_format +
":" + port.ToString();
339 return correct_ip_format;
343 bool GenerateValidFilter(out
string potential_filter)
345 return LimitTextBoxCharacterCount( potential_filter, 16 );
348 void OnSortChanged(
int value )
393 if( w == m_SearchByName )
395 string input_name = m_SearchByName.GetText();
397 if ( GenerateValidFilter( input_name ) )
398 m_SearchByName.SetText( input_name );
405 else if( w == m_SearchByIP )
407 string input_ip = m_SearchByIP.GetText();
409 if ( ProcessIntoIPAddress( input_ip ) )
410 m_SearchByIP.SetText( input_ip );
423 m_Tab.OnFilterFocus( w );
429 return m_Tab.OnMouseEnter( w,
x,
y );
434 return m_Tab.OnMouseLeave( w, enterW,
x,
y );
442 input.m_Platform = 1;
446 string name_text = m_SearchByName.GetText();
447 if ( name_text !=
"" )
449 input.SetNameFilter( name_text);
453 if (m_DLCFilter.IsSet())
455 input.SetIsDLC( m_DLCFilter.IsEnabled());
458 if (m_FullServerFilter.IsSet())
460 input.SetFullServer( m_FullServerFilter.IsEnabled());
463 if (m_ThirdPersonFilter.IsSet())
465 input.SetThirdPerson( m_ThirdPersonFilter.IsEnabled());
468 if (m_PasswordFilter.IsSet())
470 input.SetPassworded( m_PasswordFilter.IsEnabled());
473 if (m_WhitelistFilter.IsSet())
475 input.SetWhitelistEnabled( m_WhitelistFilter.IsEnabled());
478 #ifndef PLATFORM_CONSOLE
481 string ip_text = m_SearchByIP.GetText();
484 input.SetHostIp( ip_text);
488 if (m_PingFilter.IsSet())
490 string str_ping = m_PingFilter.GetStringValue();
491 int ping = str_ping.Substring(1, str_ping.Length() - 1).ToInt();
492 input.SetPingFilter( ping);
495 if (m_FriendsPlayingFilter.IsSet())
497 input.SetFriendsPlaying( m_FriendsPlayingFilter.IsEnabled());
500 if (m_PreviouslyPlayedFilter.IsSet())
502 input.SetPreviouslyPlayed( m_PreviouslyPlayedFilter.IsEnabled());
505 if (m_VersionMatchFilter.IsSet())
507 input.SetProperVersionMatch( m_VersionMatchFilter.IsEnabled());
521 input.m_Platform = 2;
524 input.m_Platform = 3;
529 string name_text = m_SearchByName.GetText();
530 if( name_text !=
"" )
532 input.SetNameFilter(name_text);
536 if (m_RegionFilter.IsSet())
538 input.SetRegionIdFilter(m_RegionFilter.GetValue());
541 if (m_DLCFilter.IsSet())
543 input.SetIsDLC(m_DLCFilter.IsEnabled());
546 if (m_FullServerFilter.IsSet())
548 input.SetFullServer(m_FullServerFilter.IsEnabled());
549 if (m_FullServerFilter.IsEnabled())
551 input.SetFreeSlotsMax(1);
555 input.SetFreeSlotsMin(1);
559 if (m_ThirdPersonFilter.IsSet())
564 input.SetModeIdFilter(!m_ThirdPersonFilter.IsEnabled());
567 if (m_PasswordFilter.IsSet())
569 input.SetIsPasswordProtectedFilter(m_PasswordFilter.IsEnabled());
572 if (m_WhitelistFilter.IsSet())
574 input.SetWhitelistEnabled(m_WhitelistFilter.IsEnabled());
577 if (m_KeyboardFilter.IsSet())
579 input.SetMouseAndKeyboardEnabled( m_KeyboardFilter.IsEnabled());