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