]> icculus.org git repositories - taylor/freespace2.git/blob - src/launcher/launchersetup.cpp
remaining launchersetup functionality
[taylor/freespace2.git] / src / launcher / launchersetup.cpp
1
2 #include "SDL.h"
3
4 #include "launcher.h"
5 #include "launchersetup.h"
6 #include "osregistry.h"
7
8 #include "wx/valnum.h"
9
10
11 wxBEGIN_EVENT_TABLE(LauncherSetup, wxDialog)
12         EVT_BUTTON(wxID_OK, LauncherSetup::onOk)
13         EVT_CHECKBOX(ID_CB_MSAA, LauncherSetup::onToggleMSAA)
14 wxEND_EVENT_TABLE()
15
16
17 LauncherSetup::LauncherSetup( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
18 {
19         this->SetSizeHints( wxSize(370, -1), wxDefaultSize );
20
21
22         wxNotebook *nbook = new wxNotebook( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
23
24         initTab_Video(nbook);
25         initTab_Audio(nbook);
26         initTab_Joystick(nbook);
27         initTab_Speed(nbook);
28         initTab_Network(nbook);
29         initTab_PXO(nbook);
30
31         wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL );
32         bSizer->Add( nbook, 0, wxALL|wxEXPAND, 5 );
33
34
35         wxStdDialogButtonSizer* sdbSizer = new wxStdDialogButtonSizer();
36         sdbSizer->AddButton( new wxButton(this, wxID_OK) );
37         sdbSizer->AddButton( new wxButton(this, wxID_CANCEL) );
38         sdbSizer->Realize();
39
40         bSizer->Add( sdbSizer, 0, wxALL|wxEXPAND, 5 );
41
42
43         this->SetSizer( bSizer );
44         this->Layout();
45         bSizer->Fit( this );
46
47
48         this->Centre( wxBOTH );
49 }
50
51 LauncherSetup::~LauncherSetup()
52 {
53 }
54
55 void LauncherSetup::initTab_Video(wxNotebook *parent)
56 {
57         unsigned int checked = 0;
58
59         wxPanel* panel = new wxPanel( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
60
61         wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL );
62
63
64         // 'renderer'
65         wxStaticBoxSizer* sbSizer = new wxStaticBoxSizer( new wxStaticBox( panel, wxID_ANY, wxT("Renderer") ), wxVERTICAL );
66
67         m_Video_Renderer = new wxComboBox( panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_DROPDOWN|wxCB_READONLY );
68         sbSizer->Add( m_Video_Renderer, 1, wxALL|wxEXPAND, 5 );
69
70         bSizer->Add( sbSizer, 0, wxALL|wxEXPAND, 5 );
71
72         m_Video_Renderer->Append( wxT("OpenGL") );
73         m_Video_Renderer->SetSelection( 0 );
74
75         // 'fullscreen'
76         m_Video_Fullscreen = new wxCheckBox( panel, wxID_ANY, wxT("Fullscreen"), wxDefaultPosition, wxDefaultSize, 0 );
77         bSizer->Add( m_Video_Fullscreen, 0, wxALL, 5 );
78
79         checked = os_config_read_uint("Video", "Fullscreen", 1);
80
81         m_Video_Fullscreen->SetValue( (checked == 1) );
82
83         // 'show fps'
84         m_Video_ShowFPS = new wxCheckBox( panel, wxID_ANY, wxT("Show FPS"), wxDefaultPosition, wxDefaultSize, 0 );
85         bSizer->Add( m_Video_ShowFPS, 0, wxALL, 5 );
86
87         checked = os_config_read_uint("Video", "ShowFPS", 0);
88
89         m_Video_ShowFPS->SetValue( (checked == 1) );
90
91         // 'anti-alias'
92         wxBoxSizer* bSizer_aa = new wxBoxSizer( wxHORIZONTAL );
93
94         m_Video_MSAA = new wxCheckBox( panel, ID_CB_MSAA, wxT("Anti-Alias"), wxDefaultPosition, wxDefaultSize, 0 );
95         bSizer_aa->Add( m_Video_MSAA, 0, wxALIGN_CENTER_VERTICAL, 5 );
96
97         const wxString msaa_samples[] = { wxT("2x"), wxT("4x"), wxT("8x"), wxT("16x") };
98         const int num_msaa_samples = sizeof( msaa_samples ) / sizeof( wxString );
99         m_Video_MSAASamples = new wxChoice( panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, num_msaa_samples, msaa_samples, 0 );
100         bSizer_aa->Add( m_Video_MSAASamples, 0, wxLEFT, 15 );
101
102         bSizer->Add( bSizer_aa, 0, wxALL, 5 );
103
104         checked = os_config_read_uint("Video", "AntiAlias", 0);
105
106         if (checked) {
107                 m_Video_MSAA->SetValue(true);
108
109                 if (checked < 4) {
110                         m_Video_MSAASamples->SetSelection(0);
111                 } else if (checked < 8) {
112                         m_Video_MSAASamples->SetSelection(1);
113                 } else if (checked < 16) {
114                         m_Video_MSAASamples->SetSelection(2);
115                 } else {
116                         m_Video_MSAASamples->SetSelection(3);
117                 }
118         } else {
119                 m_Video_MSAA->SetValue(false);
120                 m_Video_MSAASamples->SetSelection(wxNOT_FOUND);
121                 m_Video_MSAASamples->Disable();
122         }
123
124
125         panel->SetSizer( bSizer );
126         panel->Layout();
127
128         bSizer->Fit( panel );
129
130         parent->AddPage( panel, wxT("Video"), true );
131 }
132
133 void LauncherSetup::saveTab_Video()
134 {
135         wxString value;
136         unsigned int msaa = 0;
137
138         value = m_Video_Renderer->GetValue();
139
140         os_config_write_string("Video", "Renderer", value.c_str());
141
142         if ( m_Video_MSAA->IsChecked() ) {
143                 int sel = m_Video_MSAASamples->GetSelection();
144                 wxASSERT( sel != wxNOT_FOUND );
145
146                 msaa = 2 << sel;
147         }
148
149         os_config_write_uint("Video", "AntiAlias", msaa);
150
151         os_config_write_uint("Video", "Fullscreen", m_Video_Fullscreen->IsChecked() ? 1 : 0);
152         os_config_write_uint("Video", "ShowFPS", m_Video_ShowFPS->IsChecked() ? 1 : 0);
153 }
154
155 void LauncherSetup::initTab_Audio(wxNotebook *parent)
156 {
157         unsigned int checked = 0;
158         ALint ver_major = 0, ver_minor = 0;
159         const ALCchar *ptr = NULL;
160         const char *conf_ptr = NULL;
161         bool audio_enabled = false;
162
163         alcGetIntegerv(NULL, ALC_MAJOR_VERSION, 1, &ver_major);
164         alcGetIntegerv(NULL, ALC_MINOR_VERSION, 1, &ver_minor);
165
166         if ( (ver_major >= 1) && (ver_minor >= 1) ) {
167                 audio_enabled = true;
168         }
169
170         wxPanel* panel = new wxPanel( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
171
172         wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL );
173
174
175         // 'playback device'
176         wxStaticBoxSizer* sbSizer_playback = new wxStaticBoxSizer( new wxStaticBox( panel, wxID_ANY, wxT("Playback Device") ), wxVERTICAL );
177
178         m_Audio_PlaybackDevice = new wxComboBox( panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_DROPDOWN|wxCB_READONLY );
179         sbSizer_playback->Add( m_Audio_PlaybackDevice, 0, wxALL|wxEXPAND, 5 );
180
181         bSizer->Add( sbSizer_playback, 0, wxALL|wxEXPAND, 5 );
182
183         m_Audio_PlaybackDevice->Append("<Default>");
184         m_Audio_PlaybackDevice->SetSelection(0);
185
186         conf_ptr = os_config_read_string("Audio", "PlaybackDevice", NULL);
187
188         if (audio_enabled) {
189                 if ( alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE ) {
190                         ptr = alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER);
191                 } else {
192                         ptr = alcGetString(NULL, ALC_DEVICE_SPECIFIER);
193                 }
194
195                 if (ptr) {
196                         while (*ptr) {
197                                 m_Audio_PlaybackDevice->Append(ptr);
198
199                                 if ( conf_ptr && !SDL_strcasecmp(conf_ptr, ptr) ) {
200                                         unsigned int sel = m_Audio_PlaybackDevice->GetCount() - 1;
201
202                                         m_Audio_PlaybackDevice->SetSelection(sel);
203
204                                         conf_ptr = NULL;
205                                 }
206
207                                 ptr += strlen(ptr) + 1;
208                         }
209                 }
210         }
211
212         // 'capture device'
213         wxStaticBoxSizer* sbSizer_capture = new wxStaticBoxSizer( new wxStaticBox( panel, wxID_ANY, wxT("Capture Device") ), wxVERTICAL );
214
215         m_Audio_CaptureDevice = new wxComboBox( panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_DROPDOWN|wxCB_READONLY );
216         sbSizer_capture->Add( m_Audio_CaptureDevice, 0, wxALL|wxEXPAND, 5 );
217
218         bSizer->Add( sbSizer_capture, 0, wxALL|wxEXPAND, 5 );
219
220         m_Audio_CaptureDevice->Append("<Default>");
221         m_Audio_CaptureDevice->SetSelection(0);
222
223         conf_ptr = os_config_read_string("Audio", "CaptureDevice", NULL);
224
225         if (audio_enabled) {
226                 ptr = alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER);
227
228                 if (ptr) {
229                         while (*ptr) {
230                                 m_Audio_CaptureDevice->Append(ptr);
231
232                                 if ( conf_ptr && !SDL_strcasecmp(conf_ptr, ptr) ) {
233                                         unsigned int sel = m_Audio_CaptureDevice->GetCount() - 1;
234
235                                         m_Audio_CaptureDevice->SetSelection(sel);
236
237                                         conf_ptr = NULL;
238                                 }
239
240                                 ptr += strlen(ptr) + 1;
241                         }
242                 }
243         }
244
245         // 'efx'
246         m_Audio_EFX = new wxCheckBox( panel, wxID_ANY, wxT("EFX / EAX Reverb"), wxDefaultPosition, wxDefaultSize, 0 );
247         bSizer->Add( m_Audio_EFX, 0, wxALL, 5 );
248
249         checked = os_config_read_uint("Audio", "EFX", 0);
250
251         m_Audio_EFX->SetValue( (checked == 1) );
252
253         // 'launcher sounds'
254 #ifndef MAKE_FS1
255         m_Audio_LauncherSounds = new wxCheckBox( panel, wxID_ANY, wxT("Enable Launcher Sounds"), wxDefaultPosition, wxDefaultSize, 0 );
256         bSizer->Add( m_Audio_LauncherSounds, 0, wxALL, 5 );
257
258         checked = os_config_read_uint("Audio", "LauncherSoundEnabled", 1);
259
260         m_Audio_LauncherSounds->SetValue( (checked == 1) );
261 #endif
262
263
264         panel->SetSizer( bSizer );
265         panel->Layout();
266
267         bSizer->Fit( panel );
268
269         parent->AddPage( panel, wxT("Audio"), false );
270 }
271
272 void LauncherSetup::saveTab_Audio()
273 {
274         wxString value;
275
276         value = m_Audio_PlaybackDevice->GetValue();
277
278         if ( value.IsSameAs( wxT("<Default>") ) ) {
279                 os_config_write_string("Audio", "PlaybackDevice", "");
280         } else {
281                 os_config_write_string("Audio", "PlaybackDevice", value.c_str());
282         }
283
284         value = m_Audio_CaptureDevice->GetValue();
285
286         if ( value.IsSameAs( wxT("<Default>") ) ) {
287                 os_config_write_string("Audio", "CaptureDevice", "");
288         } else {
289                 os_config_write_string("Audio", "CaptureDevice", value.c_str());
290         }
291
292         os_config_write_uint("Audio", "EFX", m_Audio_EFX->IsChecked() ? 1 : 0);
293 #ifndef MAKE_FS1
294         os_config_write_uint("Audio", "LauncherSoundEnabled", m_Audio_LauncherSounds->IsChecked() ? 1 : 0);
295
296         Launcher* parent = (Launcher*)GetParent();
297         parent->SndEnable( m_Audio_LauncherSounds->IsChecked() );
298 #endif
299 }
300
301 void LauncherSetup::initTab_Joystick(wxNotebook *parent)
302 {
303         unsigned int checked = 0;
304         const char *conf_ptr = NULL;
305         bool joystick_enabled = false;
306
307         if ( !SDL_InitSubSystem(SDL_INIT_JOYSTICK) ) {
308                 joystick_enabled = true;
309         }
310
311         wxPanel* panel = new wxPanel( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
312
313         wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL );
314
315         wxStaticBoxSizer* sbSizer = new wxStaticBoxSizer( new wxStaticBox( panel, wxID_ANY, wxT("Joystick") ), wxVERTICAL );
316
317
318         // 'current joystick'
319         m_Joystick_Device = new wxComboBox( panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
320         sbSizer->Add( m_Joystick_Device, 0, wxALL|wxEXPAND, 5 );
321
322         m_Joystick_Device->Append( wxT("<Default>") );
323         m_Joystick_Device->SetSelection( 0 );
324
325         conf_ptr = os_config_read_string("Controls", "CurrentJoystick", NULL);
326
327         if (joystick_enabled) {
328                 int num_sticks = SDL_NumJoysticks();
329
330                 for (int i = 0; i < num_sticks; i++) {
331                         const char *jname = SDL_JoystickNameForIndex(i);
332
333                         if (jname) {
334                                 m_Joystick_Device->Append(jname);
335
336                                 if ( conf_ptr && !SDL_strcasecmp(conf_ptr, jname) ) {
337                                         unsigned int sel = m_Joystick_Device->GetCount() - 1;
338
339                                         m_Joystick_Device->SetSelection(sel);
340
341                                         conf_ptr = NULL;
342                                 }
343                         }
344                 }
345
346                 SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
347         }
348
349         bSizer->Add( sbSizer, 0, wxALL|wxEXPAND, 5 );
350
351         // 'force feedback'
352         m_Joystick_FF = new wxCheckBox( panel, wxID_ANY, wxT("Enable Force Feedback"), wxDefaultPosition, wxDefaultSize, 0 );
353         bSizer->Add( m_Joystick_FF, 0, wxALL|wxEXPAND, 5 );
354
355         checked = os_config_read_uint("Controls", "EnableJoystickFF", 0);
356
357         m_Joystick_FF->SetValue( (checked == 1) );
358
359         // 'directional hit'
360         m_Joystick_Directional = new wxCheckBox( panel, wxID_ANY, wxT("Enable directional hit effect (Force Feedback)"), wxDefaultPosition, wxDefaultSize, 0 );
361         bSizer->Add( m_Joystick_Directional, 0, wxALL|wxEXPAND, 5 );
362
363         checked = os_config_read_uint("Controls", "EnableHitEffect", 0);
364
365         m_Joystick_Directional->SetValue( (checked == 1) );
366
367
368         panel->SetSizer( bSizer );
369         panel->Layout();
370
371         bSizer->Fit( panel );
372
373         parent->AddPage( panel, wxT("Joystick"), false );
374 }
375
376 void LauncherSetup::saveTab_Joystick()
377 {
378         wxString value;
379
380         value = m_Joystick_Device->GetValue();
381
382         if ( value.IsSameAs( wxT("<Default>") ) ) {
383                 os_config_write_string("Controls", "CurrentJoystick", "");
384         } else {
385                 os_config_write_string("Controls", "CurrentJoystick", value.c_str());
386         }
387
388         os_config_write_uint("Controls", "EnableJoystickFF", m_Joystick_FF->IsChecked() ? 1 : 0);
389         os_config_write_uint("Controls", "EnableHitEffect", m_Joystick_Directional->IsChecked() ? 1 : 0);
390 }
391
392 void LauncherSetup::initTab_Speed(wxNotebook *parent)
393 {
394         unsigned int detail_lvl = 0;
395
396         wxPanel* panel = new wxPanel( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
397
398         wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL );
399
400         // 'computer speed'
401         wxStaticBoxSizer* sbSizer = new wxStaticBoxSizer( new wxStaticBox( panel, wxID_ANY, wxT("Default Detail Level") ), wxVERTICAL );
402
403         m_Speed_DefaultDetail = new wxComboBox( panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, NULL, wxCB_DROPDOWN );
404         sbSizer->Add( m_Speed_DefaultDetail, 0, wxALL|wxEXPAND, 5 );
405
406         m_Speed_DefaultDetail->Append( wxT("Low") );
407         m_Speed_DefaultDetail->Append( wxT("Medium") );
408         m_Speed_DefaultDetail->Append( wxT("High") );
409         m_Speed_DefaultDetail->Append( wxT("Very High") );
410
411         detail_lvl = os_config_read_uint(NULL, "ComputerSpeed", 2);
412
413         if (detail_lvl > 3) {
414                 detail_lvl = 0;
415         }
416
417         m_Speed_DefaultDetail->SetSelection(detail_lvl);
418
419
420         bSizer->Add( sbSizer, 0, wxALL|wxEXPAND, 5 );
421
422         panel->SetSizer( bSizer );
423         panel->Layout();
424
425         bSizer->Fit( panel );
426
427         parent->AddPage( panel, wxT("Speed"), false );
428 }
429
430 void LauncherSetup::saveTab_Speed()
431 {
432         int sel;
433
434         sel = m_Speed_DefaultDetail->GetSelection();
435
436         if ( (sel < 0) || (sel > 3) ) {
437                 sel = 0;
438         }
439
440         os_config_write_uint(NULL, "ComputerSpeed", sel);
441 }
442
443 void LauncherSetup::initTab_Network(wxNotebook* parent)
444 {
445         const char *conf_ptr = NULL;
446         unsigned int val = 0;
447
448         wxPanel* panel = new wxPanel( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
449
450         wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL );
451
452         // 'connection type'
453         const wxString conn_types[] = { wxT("None"), wxT("Dialup Networking"), wxT("LAN/Direct Connection") };
454         const int num_conn_types = sizeof( conn_types ) / sizeof( wxString );
455         m_Network_Connection = new wxRadioBox( panel, wxID_ANY, wxT("Internet Connection"), wxDefaultPosition, wxDefaultSize, num_conn_types, conn_types, 1, wxRA_SPECIFY_COLS|wxSTATIC_BORDER );
456         bSizer->Add( m_Network_Connection, 0, wxALL|wxEXPAND, 5 );
457
458         conf_ptr = os_config_read_string("Network", "NetworkConnection", NULL);
459         val = 0;
460
461         if (conf_ptr) {
462                 if ( !SDL_strcasecmp(conf_ptr, "dialup") ) {
463                         val = 1;
464                 } else if ( !SDL_strcasecmp(conf_ptr, "lan") ) {
465                         val = 2;
466                 }
467         }
468
469         m_Network_Connection->SetSelection(val);
470
471         // 'connection speed'
472         const wxString speed_types[] = { wxT("None Specified"), wxT("Slower than 56K Modem"), wxT("56K Modem"), wxT("Single Channel ISDN"), wxT("Dual Channel ISDN, Cable Modems"), wxT("T1, ADSL, T3, etc.") };
473         const int num_speed_types = sizeof( speed_types ) / sizeof( wxString );
474         m_Network_Speed = new wxRadioBox( panel, wxID_ANY, wxT("Connection Speed"), wxDefaultPosition, wxDefaultSize, num_speed_types, speed_types, 1, wxRA_SPECIFY_COLS );
475         bSizer->Add( m_Network_Speed, 0, wxALL|wxEXPAND, 5 );
476
477         conf_ptr = os_config_read_string("Network", "ConnectionSpeed", NULL);
478         val = 0;
479
480         if (conf_ptr) {
481                 if ( !SDL_strcasecmp(conf_ptr, "Slow") ) {
482                         val = 1;
483                 } else if ( !SDL_strcasecmp(conf_ptr, "56K") ) {
484                         val = 2;
485                 } else if ( !SDL_strcasecmp(conf_ptr, "ISDN") ) {
486                         val = 3;
487                 } else if ( !SDL_strcasecmp(conf_ptr, "Cable") ) {
488                         val = 4;
489                 } else if ( !SDL_strcasecmp(conf_ptr, "Fast") ) {
490                         val = 5;
491                 }
492         }
493
494         m_Network_Speed->SetSelection(val);
495
496
497         wxStaticBoxSizer* sbSizer = new wxStaticBoxSizer( new wxStaticBox( panel, wxID_ANY, wxT("Misc") ), wxVERTICAL );
498
499         wxFlexGridSizer* fgSizer_port = new wxFlexGridSizer( 0, 2, 0, 0 );
500         fgSizer_port->SetFlexibleDirection( wxBOTH );
501         fgSizer_port->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
502
503         // 'port'
504         wxStaticText* txt_port = new wxStaticText( panel, wxID_ANY, wxT("Force local port"), wxDefaultPosition, wxDefaultSize, 0 );
505         txt_port->Wrap( -1 );
506         fgSizer_port->Add( txt_port, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
507
508         m_Network_Port = new wxTextCtrl( panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
509         fgSizer_port->Add( m_Network_Port, 0, wxALL|wxEXPAND, 5 );
510
511         wxIntegerValidator<unsigned short> vald( &m_port_validate );
512
513         m_Network_Port->SetValidator(vald);
514
515         sbSizer->Add( fgSizer_port, 1, wxEXPAND, 5 );
516
517         val = os_config_read_uint("Network", "ForcePort", 0);
518
519         if (val) {
520                 wxString sval = wxString::Format( wxT("%u"), val );
521
522                 m_Network_Port->SetValue(sval);
523         }
524
525
526         bSizer->Add( sbSizer, 0, wxALL|wxEXPAND, 5 );
527
528         panel->SetSizer( bSizer );
529         panel->Layout();
530
531         bSizer->Fit( panel );
532
533         parent->AddPage( panel, wxT("Network"), false );
534 }
535
536 void LauncherSetup::saveTab_Network()
537 {
538         const char *conn_types[] = { "none", "dialup", "lan" };
539         const char *conn_speed[] = { "none", "Slow", "56K", "ISDN", "Cable", "Fast" };
540         int sel = 0;
541         long port = 0;
542
543         sel = m_Network_Connection->GetSelection();
544
545         if ( (sel < 0) || (sel > 2) ) {
546                 sel = 0;
547         }
548
549         os_config_write_string("Network", "NetworkConnection", conn_types[sel]);
550
551         sel = m_Network_Speed->GetSelection();
552
553         if ( (sel < 0) || (sel > 5) ) {
554                 sel = 0;
555         }
556
557         os_config_write_string("Network", "ConnectionSpeed", conn_speed[sel]);
558
559         if ( !m_Network_Port->GetValue().IsEmpty() ) {
560                 m_Network_Port->GetValue().ToLong(&port);
561                 wxASSERT( port <= USHRT_MAX );
562         }
563
564         os_config_write_uint("Network", "ForcePort", (unsigned int)port);
565 }
566
567 void LauncherSetup::initTab_PXO(wxNotebook* parent)
568 {
569         const char *conf_ptr = NULL;
570         unsigned int checked = 0;
571
572         wxPanel* panel = new wxPanel( parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
573
574         wxBoxSizer* bSizer = new wxBoxSizer( wxVERTICAL );
575
576         wxStaticBoxSizer* sbSizer = new wxStaticBoxSizer( new wxStaticBox( panel, wxID_ANY, wxT("PXO Account") ), wxVERTICAL );
577
578         wxFlexGridSizer* fgSizer = new wxFlexGridSizer( 0, 2, 0, 0 );
579         fgSizer->SetFlexibleDirection( wxBOTH );
580         fgSizer->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_ALL );
581
582         // 'pxo login'
583         wxStaticText* pxo_login = new wxStaticText( panel, wxID_ANY, wxT("Login"), wxDefaultPosition, wxDefaultSize, 0 );
584         pxo_login->Wrap( -1 );
585         fgSizer->Add( pxo_login, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
586
587         m_PXO_Username = new wxTextCtrl( panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
588         fgSizer->Add( m_PXO_Username, 0, wxALL|wxEXPAND, 5 );
589
590         m_PXO_Username->SetMaxLength(32);
591
592         conf_ptr = os_config_read_string("PXO", "Login", NULL);
593
594         if (conf_ptr) {
595                 m_PXO_Username->SetValue(conf_ptr);
596         }
597
598         // 'pxo password'
599         wxStaticText* pxo_pass = new wxStaticText( panel, wxID_ANY, wxT("Password"), wxDefaultPosition, wxDefaultSize, 0 );
600         pxo_pass->Wrap( -1 );
601         fgSizer->Add( pxo_pass, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
602
603         m_PXO_Password = new wxTextCtrl( panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PASSWORD );
604         fgSizer->Add( m_PXO_Password, 0, wxALL|wxEXPAND, 5 );
605
606         m_PXO_Password->SetMaxLength(32);
607
608         conf_ptr = os_config_read_string("PXO", "Password", NULL);
609
610         if (conf_ptr) {
611                 m_PXO_Password->SetValue(conf_ptr);
612         }
613
614         sbSizer->Add( fgSizer, 1, wxEXPAND, 5 );
615
616         bSizer->Add( sbSizer, 0, wxALL|wxEXPAND, 5 );
617
618         // 'multi version check'
619         m_PXO_SkipVerify = new wxCheckBox( panel, wxID_ANY, wxT("Skip version check in PXO"), wxDefaultPosition, wxDefaultSize, 0 );
620         bSizer->Add( m_PXO_SkipVerify, 0, wxALL, 5 );
621
622         checked = os_config_read_uint("PXO", "SkipVerify", 0);
623
624         m_PXO_SkipVerify->SetValue( (checked == 1) );
625
626         // 'banners'
627         m_PXO_Banners = new wxCheckBox( panel, wxID_ANY, wxT("PXO Banners"), wxDefaultPosition, wxDefaultSize, 0 );
628         bSizer->Add( m_PXO_Banners, 0, wxALL, 5 );
629
630         checked = os_config_read_uint("PXO", "Banners", 1);
631
632         m_PXO_Banners->SetValue( (checked == 1) );
633
634
635         panel->SetSizer( bSizer );
636         panel->Layout();
637
638         bSizer->Fit( panel );
639
640         parent->AddPage( panel, wxT("PXO"), false );
641 }
642
643 void LauncherSetup::saveTab_PXO()
644 {
645
646 }
647
648 void LauncherSetup::save_settings()
649 {
650         const char *ptr = NULL;
651
652         // 'Default' section
653         ptr = os_config_read_string(NULL, "Language", NULL);
654
655         if (ptr) {
656                 os_config_write_string(NULL, "Language", ptr);
657         } else {
658                 os_config_write_string(NULL, "Language", "");
659         }
660
661         ptr = os_config_read_string(NULL, "LastPlayer", NULL);
662
663         if (ptr) {
664                 os_config_write_string(NULL, "LastPlayer", ptr);
665         } else {
666                 os_config_write_string(NULL, "LastPlayer", "");
667         }
668
669         ptr = os_config_read_string(NULL, "ExtrasPath", NULL);
670
671         if (ptr) {
672                 os_config_write_string(NULL, "ExtrasPath", ptr);
673         } else {
674                 os_config_write_string(NULL, "ExtrasPath", "");
675         }
676
677         os_config_write_uint(NULL, "StraightToSetup", 0);
678
679         saveTab_Speed();
680
681         // 'Video' section
682         saveTab_Video();
683
684         // 'Audio' section
685         saveTab_Audio();
686
687         // 'Controls' section
688         saveTab_Joystick();
689
690         // 'Network' section
691         saveTab_Network();
692
693         // 'PXO' section
694         saveTab_PXO();
695 }
696
697 void LauncherSetup::onOk(wxCommandEvent& WXUNUSED(event))
698 {
699         if ( Validate() && TransferDataFromWindow() ) {
700                 save_settings();
701
702                 if ( IsModal() ) {
703                         EndModal(wxID_OK);
704                 } else {
705                         SetReturnCode(wxID_OK);
706                         Show(false);
707                 }
708         }
709 }
710
711 void LauncherSetup::onToggleMSAA(wxCommandEvent& event)
712 {
713         if ( event.IsChecked() ) {
714                 m_Video_MSAASamples->Enable();
715
716                 if (m_Video_MSAASamples->GetSelection() == wxNOT_FOUND) {
717                         m_Video_MSAASamples->SetSelection(0);
718                 }
719         } else {
720                 m_Video_MSAASamples->Disable();
721         }
722 }