Skip to content
This repository
Browse code

Made the src/modes/boot files use spaces.

  • Loading branch information...
commit c2a0f98bcd6aacb021c2a3b536bfe2b5411cc3e7 1 parent 29d41fe
authored October 25, 2012
2,112  src/modes/boot/boot.cpp
@@ -51,11 +51,12 @@ using namespace hoa_global;
51 51
 
52 52
 using namespace hoa_boot::private_boot;
53 53
 
54  
-namespace hoa_boot {
  54
+namespace hoa_boot
  55
+{
55 56
 
56 57
 bool BOOT_DEBUG = false;
57 58
 
58  
-BootMode* BootMode::_current_instance = NULL;
  59
+BootMode *BootMode::_current_instance = NULL;
59 60
 
60 61
 const std::string _LANGUAGE_FILE = "dat/config/languages.lua";
61 62
 
@@ -64,306 +65,285 @@ const std::string _LANGUAGE_FILE = "dat/config/languages.lua";
64 65
 // ****************************************************************************
65 66
 
66 67
 BootMode::BootMode() :
67  
-	_boot_state(BOOT_STATE_INTRO),
68  
-	_exiting_to_new_game(false),
69  
-	_has_modified_settings(false),
70  
-	_key_setting_function(NULL),
71  
-	_joy_setting_function(NULL),
72  
-	_joy_axis_setting_function(NULL),
73  
-	_message_window(ustring(), 210.0f, 35.0f),
74  
-	_file_name_alert(ustring(),300.0f,35.0f),
75  
-	_file_name_window(ustring(),150.0f,35.0f)
76  
-{
77  
-	// Remove potential previous ambient overlays
78  
-	VideoManager->DisableFadeEffect();
79  
-
80  
-	IF_PRINT_DEBUG(BOOT_DEBUG) << "BootMode constructor invoked" << std::endl;
81  
-	mode_type = MODE_MANAGER_BOOT_MODE;
82  
-
83  
-	_version_text.SetStyle(TextStyle("text20"));
84  
-	std::string date_string = " - ";
85  
-	date_string.append(__DATE__);
86  
-	_version_text.SetText(UTranslate("Development Release") + MakeUnicodeString(date_string));
87  
-
88  
-	// Test the existence and validity of the boot script.
89  
-	ReadScriptDescriptor boot_script;
90  
-	if (!boot_script.OpenFile("dat/config/boot.lua")) {
91  
-		PRINT_ERROR << "Failed to load boot data file" << std::endl;
92  
-		SystemManager->ExitGame();
93  
-		return;
94  
-	}
95  
-
96  
-	// Open the boot table spacename
97  
-	if (boot_script.OpenTablespace().empty()) {
98  
-		PRINT_ERROR << "The boot script file has not set a correct tablespace" << std::endl;
99  
-		SystemManager->ExitGame();
100  
-		return;
  68
+    _boot_state(BOOT_STATE_INTRO),
  69
+    _exiting_to_new_game(false),
  70
+    _has_modified_settings(false),
  71
+    _key_setting_function(NULL),
  72
+    _joy_setting_function(NULL),
  73
+    _joy_axis_setting_function(NULL),
  74
+    _message_window(ustring(), 210.0f, 35.0f),
  75
+    _file_name_alert(ustring(), 300.0f, 35.0f),
  76
+    _file_name_window(ustring(), 150.0f, 35.0f)
  77
+{
  78
+    // Remove potential previous ambient overlays
  79
+    VideoManager->DisableFadeEffect();
  80
+
  81
+    IF_PRINT_DEBUG(BOOT_DEBUG) << "BootMode constructor invoked" << std::endl;
  82
+    mode_type = MODE_MANAGER_BOOT_MODE;
  83
+
  84
+    _version_text.SetStyle(TextStyle("text20"));
  85
+    std::string date_string = " - ";
  86
+    date_string.append(__DATE__);
  87
+    _version_text.SetText(UTranslate("Development Release") + MakeUnicodeString(date_string));
  88
+
  89
+    // Test the existence and validity of the boot script.
  90
+    ReadScriptDescriptor boot_script;
  91
+    if(!boot_script.OpenFile("dat/config/boot.lua")) {
  92
+        PRINT_ERROR << "Failed to load boot data file" << std::endl;
  93
+        SystemManager->ExitGame();
  94
+        return;
  95
+    }
  96
+
  97
+    // Open the boot table spacename
  98
+    if(boot_script.OpenTablespace().empty()) {
  99
+        PRINT_ERROR << "The boot script file has not set a correct tablespace" << std::endl;
  100
+        SystemManager->ExitGame();
  101
+        return;
101 102
     }
102  
-	boot_script.CloseTable(); // The namespace
103  
-	boot_script.CloseFile();
104  
-
105  
-	// Trigger the Initialize functions in the scene script component
106  
-	GetScriptSupervisor().AddScript("dat/config/boot.lua");
107  
-	GetScriptSupervisor().Initialize(this);
108  
-
109  
-	_options_window.Create(300.0f, 550.0f);
110  
-	_options_window.SetPosition(360.0f, 580.0f);
111  
-	_options_window.SetDisplayMode(VIDEO_MENU_INSTANT);
112  
-	_options_window.Hide();
113  
-
114  
-	// Setup all boot menu options and properties
115  
-	_SetupMainMenu();
116  
-	_SetupOptionsMenu();
117  
-	_SetupVideoOptionsMenu();
118  
-	_SetupAudioOptionsMenu();
119  
-	_SetupLanguageOptionsMenu();
120  
-	_SetupKeySettingsMenu();
121  
-	_SetupJoySettingsMenu();
122  
-	_SetupResolutionMenu();
123  
-	_active_menu = &_main_menu;
124  
-
125  
-	// make sure message window is not visible
126  
-	_message_window.Hide();
127  
-	_file_name_alert.Hide();
128  
-	_file_name_window.Hide();
  103
+    boot_script.CloseTable(); // The namespace
  104
+    boot_script.CloseFile();
  105
+
  106
+    // Trigger the Initialize functions in the scene script component
  107
+    GetScriptSupervisor().AddScript("dat/config/boot.lua");
  108
+    GetScriptSupervisor().Initialize(this);
  109
+
  110
+    _options_window.Create(300.0f, 550.0f);
  111
+    _options_window.SetPosition(360.0f, 580.0f);
  112
+    _options_window.SetDisplayMode(VIDEO_MENU_INSTANT);
  113
+    _options_window.Hide();
  114
+
  115
+    // Setup all boot menu options and properties
  116
+    _SetupMainMenu();
  117
+    _SetupOptionsMenu();
  118
+    _SetupVideoOptionsMenu();
  119
+    _SetupAudioOptionsMenu();
  120
+    _SetupLanguageOptionsMenu();
  121
+    _SetupKeySettingsMenu();
  122
+    _SetupJoySettingsMenu();
  123
+    _SetupResolutionMenu();
  124
+    _active_menu = &_main_menu;
  125
+
  126
+    // make sure message window is not visible
  127
+    _message_window.Hide();
  128
+    _file_name_alert.Hide();
  129
+    _file_name_window.Hide();
129 130
 } // BootMode::BootMode()
130 131
 
131 132
 
132 133
 
133  
-BootMode::~BootMode() {
134  
-	_options_window.Destroy();
135  
-	_SaveSettingsFile("");
  134
+BootMode::~BootMode()
  135
+{
  136
+    _options_window.Destroy();
  137
+    _SaveSettingsFile("");
136 138
 
137  
-	IF_PRINT_WARNING(BOOT_DEBUG)
138  
-		<< "BOOT: BootMode destructor invoked." << std::endl;
  139
+    IF_PRINT_WARNING(BOOT_DEBUG)
  140
+            << "BOOT: BootMode destructor invoked." << std::endl;
139 141
 
140  
-	_key_setting_function = NULL;
141  
-	_joy_setting_function = NULL;
142  
-	_joy_axis_setting_function = NULL;
  142
+    _key_setting_function = NULL;
  143
+    _joy_setting_function = NULL;
  144
+    _joy_axis_setting_function = NULL;
143 145
 }
144 146
 
145  
-void BootMode::Reset() {
146  
-	// Set the coordinate system that BootMode uses
147  
-	VideoManager->SetCoordSys(0.0f, VIDEO_STANDARD_RES_WIDTH, 0.0f, VIDEO_STANDARD_RES_HEIGHT);
148  
-	VideoManager->SetDrawFlags(VIDEO_X_CENTER, VIDEO_Y_CENTER, 0);
  147
+void BootMode::Reset()
  148
+{
  149
+    // Set the coordinate system that BootMode uses
  150
+    VideoManager->SetCoordSys(0.0f, VIDEO_STANDARD_RES_WIDTH, 0.0f, VIDEO_STANDARD_RES_HEIGHT);
  151
+    VideoManager->SetDrawFlags(VIDEO_X_CENTER, VIDEO_Y_CENTER, 0);
149 152
 
150  
-	GlobalManager->ClearAllData(); // Resets the game universe to a NULL state
151  
-	_current_instance = this;
  153
+    GlobalManager->ClearAllData(); // Resets the game universe to a NULL state
  154
+    _current_instance = this;
152 155
 
153  
-	GetScriptSupervisor().Reset();
  156
+    GetScriptSupervisor().Reset();
154 157
 }
155 158
 
156 159
 
157 160
 
158  
-void BootMode::Update() {
159  
-	_options_window.Update(SystemManager->GetUpdateTime());
  161
+void BootMode::Update()
  162
+{
  163
+    _options_window.Update(SystemManager->GetUpdateTime());
160 164
 
161  
-	// Update the game mode generic members.
162  
-	GameMode::Update();
  165
+    // Update the game mode generic members.
  166
+    GameMode::Update();
163 167
 
164  
-	if (_exiting_to_new_game) {
165  
-	    // When the dae out is done, we start a new game.
166  
-	    if (!VideoManager->IsFading())
167  
-	        GlobalManager->NewGame();
168  
-		return;
169  
-	}
  168
+    if(_exiting_to_new_game) {
  169
+        // When the dae out is done, we start a new game.
  170
+        if(!VideoManager->IsFading())
  171
+            GlobalManager->NewGame();
  172
+        return;
  173
+    }
170 174
 
171 175
     // The intro is being played
172  
-	if (_boot_state == BOOT_STATE_INTRO) {
173  
-		if (InputManager->AnyKeyPress()) {
174  
-		    ChangeState(BOOT_STATE_MENU);
175  
-			return;
176  
-		}
177  
-		else {
178  
-			return; // Otherwise skip rest of the event handling for now
179  
-		}
180  
-	}
181  
-
182  
-	HelpWindow *help_window = ModeManager->GetHelpWindow();
183  
-	if (help_window && help_window->IsActive())
184  
-	{
185  
-		// Any key, except F1
186  
-		if (!InputManager->HelpPress() && InputManager->AnyKeyPress())
187  
-		{
188  
-			AudioManager->PlaySound("snd/confirm.wav");
189  
-			help_window->Hide();
190  
-		}
191  
-
192  
-		// save the settings (automatically changes the first_start variable to 0)
193  
-		_has_modified_settings = true;
194  
-		_SaveSettingsFile("");
195  
-
196  
-		return;
197  
-	}
198  
-
199  
-	// Check for waiting keypresses or joystick button presses
200  
-	SDL_Event ev = InputManager->GetMostRecentEvent();
201  
-	if (_joy_setting_function != NULL)
202  
-	{
203  
-		if (InputManager->AnyKeyPress() && ev.type == SDL_JOYBUTTONDOWN)
204  
-		{
205  
-			(this->*_joy_setting_function)(InputManager->GetMostRecentEvent().jbutton.button);
206  
-			_joy_setting_function = NULL;
207  
-			_has_modified_settings = true;
208  
-			_RefreshJoySettings();
209  
-			_message_window.Hide();
210  
-		}
211  
-		if (InputManager->CancelPress())
212  
-		{
213  
-			_joy_setting_function = NULL;
214  
-			_message_window.Hide();
215  
-		}
216  
-		return;
217  
-	}
218  
-
219  
-	if (_joy_axis_setting_function != NULL)
220  
-	{
221  
-		int8 x = InputManager->GetLastAxisMoved();
222  
-		if (x != -1)
223  
-		{
224  
-			(this->*_joy_axis_setting_function)(x);
225  
-			_joy_axis_setting_function = NULL;
226  
-			_has_modified_settings = true;
227  
-			_RefreshJoySettings();
228  
-			_message_window.Hide();
229  
-		}
230  
-		if (InputManager->CancelPress())
231  
-		{
232  
-			_joy_axis_setting_function = NULL;
233  
-			_message_window.Hide();
234  
-		}
235  
-		return;
236  
-	}
237  
-
238  
-	if (_key_setting_function != NULL)
239  
-	{
240  
-		if (InputManager->AnyKeyPress() && ev.type == SDL_KEYDOWN)
241  
-		{
242  
-			(this->*_key_setting_function)(InputManager->GetMostRecentEvent().key.keysym.sym);
243  
-			_key_setting_function = NULL;
244  
-			_has_modified_settings = true;
245  
-			_RefreshKeySettings();
246  
-			_message_window.Hide();
247  
-		}
248  
-		if (InputManager->CancelPress())
249  
-		{
250  
-			_key_setting_function = NULL;
251  
-			_message_window.Hide();
252  
-		}
253  
-		return;
254  
-	}
255  
-
256  
-	_active_menu->Update();
257  
-
258  
-	// Only quit when we are at the main menu level
259  
-	if (_active_menu == &_main_menu && InputManager->QuitPress()) {
260  
-		SystemManager->ExitGame();
261  
-		return;
262  
-	}
263  
-
264  
-	if (InputManager->ConfirmPress()) {
265  
-		// Play 'confirm sound' if the selection isn't grayed out and it has a confirm handler
266  
-		if (_active_menu->IsOptionEnabled(_active_menu->GetSelection())) {
267  
-			// Don't play the sound on New Games as they have their own sound
268  
-			if (_active_menu != &_main_menu && _active_menu->GetSelection() != -1)
269  
-				AudioManager->PlaySound("snd/confirm.wav");
270  
-		}
271  
-		else {
272  
-			// Otherwise play a different sound
273  
-			AudioManager->PlaySound("snd/bump.wav");
274  
-		}
275  
-
276  
-		_active_menu->InputConfirm();
277  
-
278  
-	}
279  
-	else if (InputManager->LeftPress()) {
280  
-		_active_menu->InputLeft();
281  
-	}
282  
-	else if(InputManager->RightPress()) {
283  
-		_active_menu->InputRight();
284  
-	}
285  
-	else if(InputManager->UpPress()) {
286  
-		_active_menu->InputUp();
287  
-	}
288  
-	else if(InputManager->DownPress()) {
289  
-		_active_menu->InputDown();
290  
-	}
291  
-	else if(InputManager->CancelPress() || InputManager->QuitPress())
292  
-	{
293  
-		if (_active_menu == &_main_menu) {
294  
-
295  
-		}
296  
-		else if (_active_menu == &_options_menu) {
297  
-			_options_window.Hide();
298  
-			_active_menu = &_main_menu;
299  
-		}
300  
-		else if (_active_menu == &_video_options_menu) {
301  
-			_active_menu = &_options_menu;
302  
-		}
303  
-		else if (_active_menu == &_audio_options_menu) {
304  
-			_active_menu = &_options_menu;
305  
-		}
306  
-		else if (_active_menu == &_language_options_menu) {
307  
-			_active_menu = &_options_menu;
308  
-		}
309  
-		else if (_active_menu == &_key_settings_menu) {
310  
-			_active_menu = &_options_menu;
311  
-		}
312  
-		else if (_active_menu == &_joy_settings_menu) {
313  
-			_active_menu = &_options_menu;
314  
-		}
315  
-		else if (_active_menu == &_resolution_menu) {
316  
-			_active_menu = &_video_options_menu;
317  
-		}
318  
-
319  
-		// Play cancel sound
320  
-		AudioManager->PlaySound("snd/cancel.wav");
321  
-	}
322  
-} // void BootMode::Update()
  176
+    if(_boot_state == BOOT_STATE_INTRO) {
  177
+        if(InputManager->AnyKeyPress()) {
  178
+            ChangeState(BOOT_STATE_MENU);
  179
+            return;
  180
+        } else {
  181
+            return; // Otherwise skip rest of the event handling for now
  182
+        }
  183
+    }
323 184
 
  185
+    HelpWindow *help_window = ModeManager->GetHelpWindow();
  186
+    if(help_window && help_window->IsActive()) {
  187
+        // Any key, except F1
  188
+        if(!InputManager->HelpPress() && InputManager->AnyKeyPress()) {
  189
+            AudioManager->PlaySound("snd/confirm.wav");
  190
+            help_window->Hide();
  191
+        }
324 192
 
  193
+        // save the settings (automatically changes the first_start variable to 0)
  194
+        _has_modified_settings = true;
  195
+        _SaveSettingsFile("");
325 196
 
326  
-void BootMode::Draw() {
327  
-	VideoManager->PushState();
328  
-	VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_TOP, VIDEO_BLEND, 0);
329  
-	VideoManager->SetCoordSys(0.0f, VIDEO_STANDARD_RES_WIDTH, 0.0f, VIDEO_STANDARD_RES_HEIGHT);
  197
+        return;
  198
+    }
330 199
 
331  
-	GetScriptSupervisor().DrawBackground();
332  
-	GetScriptSupervisor().DrawForeground();
333  
-	VideoManager->PopState();
334  
-}
  200
+    // Check for waiting keypresses or joystick button presses
  201
+    SDL_Event ev = InputManager->GetMostRecentEvent();
  202
+    if(_joy_setting_function != NULL) {
  203
+        if(InputManager->AnyKeyPress() && ev.type == SDL_JOYBUTTONDOWN) {
  204
+            (this->*_joy_setting_function)(InputManager->GetMostRecentEvent().jbutton.button);
  205
+            _joy_setting_function = NULL;
  206
+            _has_modified_settings = true;
  207
+            _RefreshJoySettings();
  208
+            _message_window.Hide();
  209
+        }
  210
+        if(InputManager->CancelPress()) {
  211
+            _joy_setting_function = NULL;
  212
+            _message_window.Hide();
  213
+        }
  214
+        return;
  215
+    }
335 216
 
336  
-void BootMode::DrawPostEffects() {
337  
-	VideoManager->PushState();
338  
-	VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_TOP, VIDEO_BLEND, 0);
339  
-	VideoManager->SetCoordSys(0.0f, VIDEO_STANDARD_RES_WIDTH, 0.0f, VIDEO_STANDARD_RES_HEIGHT);
  217
+    if(_joy_axis_setting_function != NULL) {
  218
+        int8 x = InputManager->GetLastAxisMoved();
  219
+        if(x != -1) {
  220
+            (this->*_joy_axis_setting_function)(x);
  221
+            _joy_axis_setting_function = NULL;
  222
+            _has_modified_settings = true;
  223
+            _RefreshJoySettings();
  224
+            _message_window.Hide();
  225
+        }
  226
+        if(InputManager->CancelPress()) {
  227
+            _joy_axis_setting_function = NULL;
  228
+            _message_window.Hide();
  229
+        }
  230
+        return;
  231
+    }
340 232
 
341  
-	GetScriptSupervisor().DrawPostEffects();
  233
+    if(_key_setting_function != NULL) {
  234
+        if(InputManager->AnyKeyPress() && ev.type == SDL_KEYDOWN) {
  235
+            (this->*_key_setting_function)(InputManager->GetMostRecentEvent().key.keysym.sym);
  236
+            _key_setting_function = NULL;
  237
+            _has_modified_settings = true;
  238
+            _RefreshKeySettings();
  239
+            _message_window.Hide();
  240
+        }
  241
+        if(InputManager->CancelPress()) {
  242
+            _key_setting_function = NULL;
  243
+            _message_window.Hide();
  244
+        }
  245
+        return;
  246
+    }
  247
+
  248
+    _active_menu->Update();
  249
+
  250
+    // Only quit when we are at the main menu level
  251
+    if(_active_menu == &_main_menu && InputManager->QuitPress()) {
  252
+        SystemManager->ExitGame();
  253
+        return;
  254
+    }
  255
+
  256
+    if(InputManager->ConfirmPress()) {
  257
+        // Play 'confirm sound' if the selection isn't grayed out and it has a confirm handler
  258
+        if(_active_menu->IsOptionEnabled(_active_menu->GetSelection())) {
  259
+            // Don't play the sound on New Games as they have their own sound
  260
+            if(_active_menu != &_main_menu && _active_menu->GetSelection() != -1)
  261
+                AudioManager->PlaySound("snd/confirm.wav");
  262
+        } else {
  263
+            // Otherwise play a different sound
  264
+            AudioManager->PlaySound("snd/bump.wav");
  265
+        }
  266
+
  267
+        _active_menu->InputConfirm();
  268
+
  269
+    } else if(InputManager->LeftPress()) {
  270
+        _active_menu->InputLeft();
  271
+    } else if(InputManager->RightPress()) {
  272
+        _active_menu->InputRight();
  273
+    } else if(InputManager->UpPress()) {
  274
+        _active_menu->InputUp();
  275
+    } else if(InputManager->DownPress()) {
  276
+        _active_menu->InputDown();
  277
+    } else if(InputManager->CancelPress() || InputManager->QuitPress()) {
  278
+        if(_active_menu == &_main_menu) {
  279
+
  280
+        } else if(_active_menu == &_options_menu) {
  281
+            _options_window.Hide();
  282
+            _active_menu = &_main_menu;
  283
+        } else if(_active_menu == &_video_options_menu) {
  284
+            _active_menu = &_options_menu;
  285
+        } else if(_active_menu == &_audio_options_menu) {
  286
+            _active_menu = &_options_menu;
  287
+        } else if(_active_menu == &_language_options_menu) {
  288
+            _active_menu = &_options_menu;
  289
+        } else if(_active_menu == &_key_settings_menu) {
  290
+            _active_menu = &_options_menu;
  291
+        } else if(_active_menu == &_joy_settings_menu) {
  292
+            _active_menu = &_options_menu;
  293
+        } else if(_active_menu == &_resolution_menu) {
  294
+            _active_menu = &_video_options_menu;
  295
+        }
  296
+
  297
+        // Play cancel sound
  298
+        AudioManager->PlaySound("snd/cancel.wav");
  299
+    }
  300
+} // void BootMode::Update()
342 301
 
343  
-	if (_boot_state == BOOT_STATE_MENU) {
344  
-		_options_window.Draw();
345 302
 
346  
-		// Test whether the welcome window should be shown once
347  
-		static bool help_window_shown = false;
348  
-		if (!help_window_shown) {
349  
-			_ShowHelpWindow();
350  
-			help_window_shown = true;
351  
-		}
352 303
 
353  
-		if (_active_menu)
354  
-			_active_menu->Draw();
  304
+void BootMode::Draw()
  305
+{
  306
+    VideoManager->PushState();
  307
+    VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_TOP, VIDEO_BLEND, 0);
  308
+    VideoManager->SetCoordSys(0.0f, VIDEO_STANDARD_RES_WIDTH, 0.0f, VIDEO_STANDARD_RES_HEIGHT);
355 309
 
356  
-		VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_BOTTOM, 0);
357  
-		VideoManager->Move(10.0f, 10.0f);
358  
-		_version_text.Draw();
359  
-		VideoManager->SetDrawFlags(VIDEO_X_RIGHT, VIDEO_Y_BOTTOM, 0);
  310
+    GetScriptSupervisor().DrawBackground();
  311
+    GetScriptSupervisor().DrawForeground();
  312
+    VideoManager->PopState();
  313
+}
360 314
 
361  
-		VideoManager->Move(0.0f, 0.0f);
362  
-		_message_window.Draw();
363  
-		_file_name_alert.Draw();
364  
-		_file_name_window.Draw();
365  
-	}
366  
-	VideoManager->PopState();
  315
+void BootMode::DrawPostEffects()
  316
+{
  317
+    VideoManager->PushState();
  318
+    VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_TOP, VIDEO_BLEND, 0);
  319
+    VideoManager->SetCoordSys(0.0f, VIDEO_STANDARD_RES_WIDTH, 0.0f, VIDEO_STANDARD_RES_HEIGHT);
  320
+
  321
+    GetScriptSupervisor().DrawPostEffects();
  322
+
  323
+    if(_boot_state == BOOT_STATE_MENU) {
  324
+        _options_window.Draw();
  325
+
  326
+        // Test whether the welcome window should be shown once
  327
+        static bool help_window_shown = false;
  328
+        if(!help_window_shown) {
  329
+            _ShowHelpWindow();
  330
+            help_window_shown = true;
  331
+        }
  332
+
  333
+        if(_active_menu)
  334
+            _active_menu->Draw();
  335
+
  336
+        VideoManager->SetDrawFlags(VIDEO_X_LEFT, VIDEO_Y_BOTTOM, 0);
  337
+        VideoManager->Move(10.0f, 10.0f);
  338
+        _version_text.Draw();
  339
+        VideoManager->SetDrawFlags(VIDEO_X_RIGHT, VIDEO_Y_BOTTOM, 0);
  340
+
  341
+        VideoManager->Move(0.0f, 0.0f);
  342
+        _message_window.Draw();
  343
+        _file_name_alert.Draw();
  344
+        _file_name_window.Draw();
  345
+    }
  346
+    VideoManager->PopState();
367 347
 }
368 348
 
369 349
 // ****************************************************************************
@@ -371,23 +351,24 @@ void BootMode::DrawPostEffects() {
371 351
 // ****************************************************************************
372 352
 bool BootMode::_SavesAvailable(int32 maxId)
373 353
 {
374  
-	assert(maxId > 0);
375  
-	int32 savesAvailable = 0;
376  
-	std::string data_path = GetUserDataPath(true);
377  
-	for (int id = 0; id < maxId; ++id) {
378  
-		std::ostringstream f;
379  
-		f << data_path + "saved_game_" << id << ".lua";
380  
-		const std::string filename = f.str();
381  
-
382  
-		if (DoesFileExist(filename)) {
383  
-			++savesAvailable;
384  
-		}
385  
-	}
386  
-	return (savesAvailable > 0);
  354
+    assert(maxId > 0);
  355
+    int32 savesAvailable = 0;
  356
+    std::string data_path = GetUserDataPath(true);
  357
+    for(int id = 0; id < maxId; ++id) {
  358
+        std::ostringstream f;
  359
+        f << data_path + "saved_game_" << id << ".lua";
  360
+        const std::string filename = f.str();
  361
+
  362
+        if(DoesFileExist(filename)) {
  363
+            ++savesAvailable;
  364
+        }
  365
+    }
  366
+    return (savesAvailable > 0);
387 367
 }
388 368
 
389 369
 
390  
-void BootMode::_ReloadTranslatableMenus() {
  370
+void BootMode::_ReloadTranslatableMenus()
  371
+{
391 372
     _SetupMainMenu();
392 373
     _SetupOptionsMenu();
393 374
     _SetupVideoOptionsMenu();
@@ -398,1087 +379,1172 @@ void BootMode::_ReloadTranslatableMenus() {
398 379
 }
399 380
 
400 381
 
401  
-void BootMode::_SetupMainMenu() {
402  
-	_main_menu.ClearOptions();
403  
-	_main_menu.SetPosition(512.0f, 80.0f);
404  
-	_main_menu.SetTextStyle(TextStyle("title24"));
405  
-	_main_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
406  
-	_main_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
407  
-	_main_menu.SetSelectMode(VIDEO_SELECT_SINGLE);
408  
-	_main_menu.SetHorizontalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
409  
-	_main_menu.SetCursorOffset(-50.0f, 28.0f);
410  
-	_main_menu.SetSkipDisabled(true);
411  
-
412  
-	_main_menu.AddOption(UTranslate("New Game"), &BootMode::_OnNewGame);
413  
-	_main_menu.AddOption(UTranslate("Load Game"), &BootMode::_OnLoadGame);
414  
-	_main_menu.AddOption(UTranslate("Options"), &BootMode::_OnOptions);
415  
-
416  
-	// Insert the debug options
  382
+void BootMode::_SetupMainMenu()
  383
+{
  384
+    _main_menu.ClearOptions();
  385
+    _main_menu.SetPosition(512.0f, 80.0f);
  386
+    _main_menu.SetTextStyle(TextStyle("title24"));
  387
+    _main_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
  388
+    _main_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
  389
+    _main_menu.SetSelectMode(VIDEO_SELECT_SINGLE);
  390
+    _main_menu.SetHorizontalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
  391
+    _main_menu.SetCursorOffset(-50.0f, 28.0f);
  392
+    _main_menu.SetSkipDisabled(true);
  393
+
  394
+    _main_menu.AddOption(UTranslate("New Game"), &BootMode::_OnNewGame);
  395
+    _main_menu.AddOption(UTranslate("Load Game"), &BootMode::_OnLoadGame);
  396
+    _main_menu.AddOption(UTranslate("Options"), &BootMode::_OnOptions);
  397
+
  398
+    // Insert the debug options
417 399
 #ifdef DEBUG_MENU
418  
-	_main_menu.SetDimensions(1000.0f, 50.0f, 7, 1, 7, 1);
419  
-	_main_menu.AddOption(UTranslate("Battle"), &BootMode::_DEBUG_OnBattle);
420  
-	_main_menu.AddOption(UTranslate("Menu"), &BootMode::_DEBUG_OnMenu);
421  
-	_main_menu.AddOption(UTranslate("Shop"), &BootMode::_DEBUG_OnShop);
  400
+    _main_menu.SetDimensions(1000.0f, 50.0f, 7, 1, 7, 1);
  401
+    _main_menu.AddOption(UTranslate("Battle"), &BootMode::_DEBUG_OnBattle);
  402
+    _main_menu.AddOption(UTranslate("Menu"), &BootMode::_DEBUG_OnMenu);
  403
+    _main_menu.AddOption(UTranslate("Shop"), &BootMode::_DEBUG_OnShop);
422 404
 #else
423  
-	_main_menu.SetDimensions(800.0f, 50.0f, 4, 1, 4, 1);
  405
+    _main_menu.SetDimensions(800.0f, 50.0f, 4, 1, 4, 1);
424 406
 #endif
425  
-	_main_menu.AddOption(UTranslate("Quit"), &BootMode::_OnQuit);
426  
-
  407
+    _main_menu.AddOption(UTranslate("Quit"), &BootMode::_OnQuit);
427 408
 
428  
-	if (!_SavesAvailable()) {
429  
-		_main_menu.EnableOption(1, false);
430  
-		_main_menu.SetSelection(0);
431  
-	}
432  
-	else {
433  
-		_main_menu.SetSelection(1);
434  
-	}
435 409
 
436  
-	// Preload main sounds
437  
-	AudioManager->LoadSound("snd/confirm.wav");
438  
-	AudioManager->LoadSound("snd/cancel.wav");
439  
-	AudioManager->LoadSound("snd/bump.wav");
440  
-}
441  
-
442  
-
443  
-void BootMode::_SetupOptionsMenu() {
444  
-	_options_menu.ClearOptions();
445  
-	_options_menu.SetPosition(512.0f, 300.0f);
446  
-	_options_menu.SetDimensions(300.0f, 600.0f, 1, 5, 1, 5);
447  
-	_options_menu.SetTextStyle(TextStyle("title22"));
448  
-	_options_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
449  
-	_options_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
450  
-	_options_menu.SetSelectMode(VIDEO_SELECT_SINGLE);
451  
-	_options_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
452  
-	_options_menu.SetCursorOffset(-50.0f, 28.0f);
453  
-	_options_menu.SetSkipDisabled(true);
454  
-
455  
-	_options_menu.AddOption(UTranslate("Video"), &BootMode::_OnVideoOptions);
456  
-	_options_menu.AddOption(UTranslate("Audio"), &BootMode::_OnAudioOptions);
457  
-	_options_menu.AddOption(UTranslate("Language"), &BootMode::_OnLanguageOptions);
458  
-	_options_menu.AddOption(UTranslate("Key Settings"), &BootMode::_OnKeySettings);
459  
-	_options_menu.AddOption(UTranslate("Joystick Settings"), &BootMode::_OnJoySettings);
460  
-
461  
-	_options_menu.SetSelection(0);
462  
-}
463  
-
464  
-
465  
-void BootMode::_SetupVideoOptionsMenu() {
466  
-	_video_options_menu.ClearOptions();
467  
-	_video_options_menu.SetPosition(512.0f, 300.0f);
468  
-	_video_options_menu.SetDimensions(300.0f, 400.0f, 1, 4, 1, 4);
469  
-	_video_options_menu.SetTextStyle(TextStyle("title22"));
470  
-	_video_options_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
471  
-	_video_options_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
472  
-	_video_options_menu.SetSelectMode(VIDEO_SELECT_SINGLE);
473  
-	_video_options_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
474  
-	_video_options_menu.SetCursorOffset(-50.0f, 28.0f);
475  
-	_video_options_menu.SetSkipDisabled(true);
476  
-
477  
-	_video_options_menu.AddOption(UTranslate("Resolution:"), &BootMode::_OnResolution);
478  
-	// Left & right will change window mode as well as confirm
479  
-	_video_options_menu.AddOption(UTranslate("Window mode:"), &BootMode::_OnToggleFullscreen, NULL, NULL, &BootMode::_OnToggleFullscreen, &BootMode::_OnToggleFullscreen);
480  
-	_video_options_menu.AddOption(UTranslate("Brightness:"), NULL, NULL, NULL, &BootMode::_OnBrightnessLeft, &BootMode::_OnBrightnessRight);
481  
-	_video_options_menu.AddOption(UTranslate("Map tiles: "), &BootMode::_OnTogglePixelArtSmoothed, NULL, NULL, &BootMode::_OnTogglePixelArtSmoothed, &BootMode::_OnTogglePixelArtSmoothed);
482  
-
483  
-	_video_options_menu.SetSelection(0);
484  
-}
485  
-
486  
-
487  
-void BootMode::_SetupAudioOptionsMenu() {
488  
-	_audio_options_menu.ClearOptions();
489  
-	_audio_options_menu.SetPosition(512.0f, 300.0f);
490  
-	_audio_options_menu.SetDimensions(300.0f, 200.0f, 1, 2, 1, 2);
491  
-	_audio_options_menu.SetTextStyle(TextStyle("title22"));
492  
-	_audio_options_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
493  
-	_audio_options_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
494  
-	_audio_options_menu.SetSelectMode(VIDEO_SELECT_SINGLE);
495  
-	_audio_options_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
496  
-	_audio_options_menu.SetCursorOffset(-50.0f, 28.0f);
497  
-	_audio_options_menu.SetSkipDisabled(true);
498  
-
499  
-	_audio_options_menu.AddOption(UTranslate("Sound Volume: "), NULL, NULL, NULL, &BootMode::_OnSoundLeft, &BootMode::_OnSoundRight);
500  
-	_audio_options_menu.AddOption(UTranslate("Music Volume: "), NULL, NULL, NULL, &BootMode::_OnMusicLeft, &BootMode::_OnMusicRight);
501  
-
502  
-	_audio_options_menu.SetSelection(0);
503  
-
504  
-	// Preload test sound
505  
-	AudioManager->LoadSound("snd/volume_test.wav", this);
506  
-}
507  
-
508  
-
509  
-void BootMode::_SetupLanguageOptionsMenu() {
510  
-	_language_options_menu.SetPosition(512.0f, 300.0f);
511  
-	_language_options_menu.SetTextStyle(TextStyle("title22"));
512  
-	_language_options_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
513  
-	_language_options_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
514  
-	_language_options_menu.SetSelectMode(VIDEO_SELECT_SINGLE);
515  
-	_language_options_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
516  
-	_language_options_menu.SetCursorOffset(-50.0f, 28.0f);
517  
-	_language_options_menu.SetSkipDisabled(true);
518  
-
519  
-
520  
-	// Get the list of languages from the Lua file.
521  
-	ReadScriptDescriptor read_data;
522  
-	if (!read_data.OpenFile(_LANGUAGE_FILE)) {
523  
-		PRINT_ERROR << "Failed to load language file: " << _LANGUAGE_FILE << std::endl;
524  
-		PRINT_ERROR << "The language list will be empty." << std::endl;
525  
-		return;
526  
-	}
527  
-
528  
-	read_data.OpenTable("languages");
529  
-	uint32 table_size = read_data.GetTableSize();
530  
-
531  
-	// Set up the dimensions of the window according to how many languages are available.
532  
-	_language_options_menu.SetDimensions(300.0f, 200.0f, 1, table_size, 1, table_size);
533  
-
534  
-	_po_files.clear();
535  
-	for (uint32 i = 1; i <= table_size; i++) {
536  
-		read_data.OpenTable(i);
537  
-		_po_files.push_back(read_data.ReadString(2));
538  
-		_language_options_menu.AddOption(MakeUnicodeString(read_data.ReadString(1)),
539  
-										 &BootMode::_OnLanguageSelect);
540  
-		read_data.CloseTable();
541  
-	}
542  
-
543  
-	read_data.CloseTable();
544  
-	if (read_data.IsErrorDetected())
545  
-		PRINT_ERROR << "Error occurred while loading language list: " << read_data.GetErrorMessages() << std::endl;
546  
-	read_data.CloseFile();
547  
-}
548  
-
549  
-
550  
-void BootMode::_SetupKeySettingsMenu() {
551  
-	_key_settings_menu.ClearOptions();
552  
-	_key_settings_menu.SetPosition(512.0f, 300.0f);
553  
-	_key_settings_menu.SetDimensions(250.0f, 500.0f, 1, 12, 1, 12);
554  
-	_key_settings_menu.SetTextStyle(TextStyle("title22"));
555  
-	_key_settings_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
556  
-	_key_settings_menu.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER);
557  
-	_key_settings_menu.SetSelectMode(VIDEO_SELECT_SINGLE);
558  
-	_key_settings_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
559  
-	_key_settings_menu.SetCursorOffset(-50.0f, 28.0f);
560  
-	_key_settings_menu.SetSkipDisabled(true);
561  
-
562  
-	_key_settings_menu.AddOption(UTranslate("Up: "), &BootMode::_RedefineUpKey);
563  
-	_key_settings_menu.AddOption(UTranslate("Down: "), &BootMode::_RedefineDownKey);
564  
-	_key_settings_menu.AddOption(UTranslate("Left: "), &BootMode::_RedefineLeftKey);
565  
-	_key_settings_menu.AddOption(UTranslate("Right: "), &BootMode::_RedefineRightKey);
566  
-	_key_settings_menu.AddOption(UTranslate("Confirm: "), &BootMode::_RedefineConfirmKey);
567  
-	_key_settings_menu.AddOption(UTranslate("Cancel: "), &BootMode::_RedefineCancelKey);
568  
-	_key_settings_menu.AddOption(UTranslate("Menu: "), &BootMode::_RedefineMenuKey);
569  
-	_key_settings_menu.AddOption(UTranslate("Swap: "), &BootMode::_RedefineSwapKey);
570  
-	_key_settings_menu.AddOption(UTranslate("Left Select: "), &BootMode::_RedefineLeftSelectKey);
571  
-	_key_settings_menu.AddOption(UTranslate("Right Select: "), &BootMode::_RedefineRightSelectKey);
572  
-	_key_settings_menu.AddOption(UTranslate("Pause: "), &BootMode::_RedefinePauseKey);
573  
-	_key_settings_menu.AddOption(UTranslate("Restore defaults"), &BootMode::_OnRestoreDefaultKeys);
574  
-}
575  
-
576  
-
577  
-void BootMode::_SetupJoySettingsMenu() {
578  
-	_joy_settings_menu.ClearOptions();
579  
-	_joy_settings_menu.SetPosition(512.0f, 300.0f);
580  
-	_joy_settings_menu.SetDimensions(250.0f, 500.0f, 1, 10, 1, 10);
581  
-	_joy_settings_menu.SetTextStyle(TextStyle("title22"));
582  
-	_joy_settings_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
583  
-	_joy_settings_menu.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER);
584  
-	_joy_settings_menu.SetSelectMode(VIDEO_SELECT_SINGLE);
585  
-	_joy_settings_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
586  
-	_joy_settings_menu.SetCursorOffset(-50.0f, 28.0f);
587  
-	_joy_settings_menu.SetSkipDisabled(true);
588  
-
589  
-	ustring dummy;
590  
-	// TODO: Add missing joystick options in the GUI
591  
-//	_joy_settings_menu.AddOption(dummy, &BootMode::_ToggleJoystickEnabled);
592  
-	_joy_settings_menu.AddOption(dummy, &BootMode::_RedefineXAxisJoy);
593  
-	_joy_settings_menu.AddOption(dummy, &BootMode::_RedefineYAxisJoy);
594  
-//	_joy_settings_menu.AddOption(dummy, &BootMode::_RedefineThresholdJoy);
  410
+    if(!_SavesAvailable()) {
  411
+        _main_menu.EnableOption(1, false);
  412
+        _main_menu.SetSelection(0);
  413
+    } else {
  414
+        _main_menu.SetSelection(1);
  415
+    }
595 416
 
596  
-	_joy_settings_menu.AddOption(dummy, &BootMode::_RedefineConfirmJoy);
597  
-	_joy_settings_menu.AddOption(dummy, &BootMode::_RedefineCancelJoy);
598  
-	_joy_settings_menu.AddOption(dummy, &BootMode::_RedefineMenuJoy);
599  
-	_joy_settings_menu.AddOption(dummy, &BootMode::_RedefineSwapJoy);
600  
-	_joy_settings_menu.AddOption(dummy, &BootMode::_RedefineLeftSelectJoy);
601  
-	_joy_settings_menu.AddOption(dummy, &BootMode::_RedefineRightSelectJoy);
602  
-	_joy_settings_menu.AddOption(dummy, &BootMode::_RedefinePauseJoy);
603  
-//	_joy_settings_menu.AddOption(dummy, &BootMode::_RedefineQuitJoy);
  417
+    // Preload main sounds
  418
+    AudioManager->LoadSound("snd/confirm.wav");
  419
+    AudioManager->LoadSound("snd/cancel.wav");
  420
+    AudioManager->LoadSound("snd/bump.wav");
  421
+}
  422
+
  423
+
  424
+void BootMode::_SetupOptionsMenu()
  425
+{
  426
+    _options_menu.ClearOptions();
  427
+    _options_menu.SetPosition(512.0f, 300.0f);
  428
+    _options_menu.SetDimensions(300.0f, 600.0f, 1, 5, 1, 5);
  429
+    _options_menu.SetTextStyle(TextStyle("title22"));
  430
+    _options_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
  431
+    _options_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
  432
+    _options_menu.SetSelectMode(VIDEO_SELECT_SINGLE);
  433
+    _options_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
  434
+    _options_menu.SetCursorOffset(-50.0f, 28.0f);
  435
+    _options_menu.SetSkipDisabled(true);
  436
+
  437
+    _options_menu.AddOption(UTranslate("Video"), &BootMode::_OnVideoOptions);
  438
+    _options_menu.AddOption(UTranslate("Audio"), &BootMode::_OnAudioOptions);
  439
+    _options_menu.AddOption(UTranslate("Language"), &BootMode::_OnLanguageOptions);
  440
+    _options_menu.AddOption(UTranslate("Key Settings"), &BootMode::_OnKeySettings);
  441
+    _options_menu.AddOption(UTranslate("Joystick Settings"), &BootMode::_OnJoySettings);
604 442
 
605  
-	_joy_settings_menu.AddOption(UTranslate("Restore defaults"), &BootMode::_OnRestoreDefaultJoyButtons);
  443
+    _options_menu.SetSelection(0);
606 444
 }
607 445
 
608 446
 
609  
-void BootMode::_SetupResolutionMenu() {
610  
-	_resolution_menu.SetPosition(512.0f, 300.0f);
611  
-	_resolution_menu.SetDimensions(300.0f, 200.0f, 1, 4, 1, 4);
612  
-	_resolution_menu.SetTextStyle(TextStyle("title22"));
613  
-	_resolution_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
614  
-	_resolution_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
615  
-	_resolution_menu.SetSelectMode(VIDEO_SELECT_SINGLE);
616  
-	_resolution_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
617  
-	_resolution_menu.SetCursorOffset(-50.0f, 28.0f);
618  
-	_resolution_menu.SetSkipDisabled(true);
  447
+void BootMode::_SetupVideoOptionsMenu()
  448
+{
  449
+    _video_options_menu.ClearOptions();
  450
+    _video_options_menu.SetPosition(512.0f, 300.0f);
  451
+    _video_options_menu.SetDimensions(300.0f, 400.0f, 1, 4, 1, 4);
  452
+    _video_options_menu.SetTextStyle(TextStyle("title22"));
  453
+    _video_options_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
  454
+    _video_options_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
  455
+    _video_options_menu.SetSelectMode(VIDEO_SELECT_SINGLE);
  456
+    _video_options_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
  457
+    _video_options_menu.SetCursorOffset(-50.0f, 28.0f);
  458
+    _video_options_menu.SetSkipDisabled(true);
619 459
 
620  
-	_resolution_menu.AddOption(MakeUnicodeString("640 x 480"), &BootMode::_OnResolution640x480);
621  
-	_resolution_menu.AddOption(MakeUnicodeString("800 x 600"), &BootMode::_OnResolution800x600);
622  
-	_resolution_menu.AddOption(MakeUnicodeString("1024 x 768"), &BootMode::_OnResolution1024x768);
623  
-	_resolution_menu.AddOption(MakeUnicodeString("1280 x 1024"), &BootMode::_OnResolution1280x1024);
  460
+    _video_options_menu.AddOption(UTranslate("Resolution:"), &BootMode::_OnResolution);
  461
+    // Left & right will change window mode as well as confirm
  462
+    _video_options_menu.AddOption(UTranslate("Window mode:"), &BootMode::_OnToggleFullscreen, NULL, NULL, &BootMode::_OnToggleFullscreen, &BootMode::_OnToggleFullscreen);
  463
+    _video_options_menu.AddOption(UTranslate("Brightness:"), NULL, NULL, NULL, &BootMode::_OnBrightnessLeft, &BootMode::_OnBrightnessRight);
  464
+    _video_options_menu.AddOption(UTranslate("Map tiles: "), &BootMode::_OnTogglePixelArtSmoothed, NULL, NULL, &BootMode::_OnTogglePixelArtSmoothed, &BootMode::_OnTogglePixelArtSmoothed);
624 465
 
625  
-	if (VideoManager->GetScreenWidth() == 640)
626  
-		_resolution_menu.SetSelection(0);
627  
-	else if (VideoManager->GetScreenWidth() == 800)
628  
-		_resolution_menu.SetSelection(1);
629  
-	else if (VideoManager->GetScreenWidth() == 1024)
630  
-		_resolution_menu.SetSelection(2);
631  
-	else if(VideoManager->GetScreenWidth() == 1280)
632  
-		_resolution_menu.SetSelection(3);
  466
+    _video_options_menu.SetSelection(0);
633 467
 }
634 468
 
635  
-void BootMode::_RefreshVideoOptions() {
636  
-	// Update resolution text
637  
-	std::ostringstream resolution("");
638  
-	resolution << VideoManager->GetScreenWidth() << " x " << VideoManager->GetScreenHeight();
639  
-	_video_options_menu.SetOptionText(0, UTranslate("Resolution: ") + MakeUnicodeString(resolution.str()));
640 469
 
641  
-	// Update text on current video mode
642  
-	if (VideoManager->IsFullscreen())
643  
-		_video_options_menu.SetOptionText(1, UTranslate("Window mode: ") + UTranslate("Fullscreen"));
644  
-	else
645  
-		_video_options_menu.SetOptionText(1, UTranslate("Window mode: ") + UTranslate("Windowed"));
  470
+void BootMode::_SetupAudioOptionsMenu()
  471
+{
  472
+    _audio_options_menu.ClearOptions();
  473
+    _audio_options_menu.SetPosition(512.0f, 300.0f);
  474
+    _audio_options_menu.SetDimensions(300.0f, 200.0f, 1, 2, 1, 2);
  475
+    _audio_options_menu.SetTextStyle(TextStyle("title22"));
  476
+    _audio_options_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
  477
+    _audio_options_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
  478
+    _audio_options_menu.SetSelectMode(VIDEO_SELECT_SINGLE);
  479
+    _audio_options_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
  480
+    _audio_options_menu.SetCursorOffset(-50.0f, 28.0f);
  481
+    _audio_options_menu.SetSkipDisabled(true);
646 482
 
647  
-	// Update brightness
648  
-	_video_options_menu.SetOptionText(2, UTranslate("Brightness: ") + MakeUnicodeString(NumberToString(VideoManager->GetGamma() * 50.0f + 0.5f) + " %"));
  483
+    _audio_options_menu.AddOption(UTranslate("Sound Volume: "), NULL, NULL, NULL, &BootMode::_OnSoundLeft, &BootMode::_OnSoundRight);
  484
+    _audio_options_menu.AddOption(UTranslate("Music Volume: "), NULL, NULL, NULL, &BootMode::_OnMusicLeft, &BootMode::_OnMusicRight);
649 485
 
650  
-	// Update the image quality text
651  
-	if (VideoManager->ShouldSmoothPixelArt())
652  
-		_video_options_menu.SetOptionText(3, UTranslate("Map tiles: ") + UTranslate("Smoothed"));
653  
-	else
654  
-		_video_options_menu.SetOptionText(3, UTranslate("Map tiles: ") + UTranslate("Normal"));
  486
+    _audio_options_menu.SetSelection(0);
  487
+
  488
+    // Preload test sound
  489
+    AudioManager->LoadSound("snd/volume_test.wav", this);
655 490
 }
656 491
 
657 492
 
  493
+void BootMode::_SetupLanguageOptionsMenu()
  494
+{
  495
+    _language_options_menu.SetPosition(512.0f, 300.0f);
  496
+    _language_options_menu.SetTextStyle(TextStyle("title22"));
  497
+    _language_options_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
  498
+    _language_options_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
  499
+    _language_options_menu.SetSelectMode(VIDEO_SELECT_SINGLE);
  500
+    _language_options_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
  501
+    _language_options_menu.SetCursorOffset(-50.0f, 28.0f);
  502
+    _language_options_menu.SetSkipDisabled(true);
  503
+
  504
+
  505
+    // Get the list of languages from the Lua file.
  506
+    ReadScriptDescriptor read_data;
  507
+    if(!read_data.OpenFile(_LANGUAGE_FILE)) {
  508
+        PRINT_ERROR << "Failed to load language file: " << _LANGUAGE_FILE << std::endl;
  509
+        PRINT_ERROR << "The language list will be empty." << std::endl;
  510
+        return;
  511
+    }
658 512
 
659  
-void BootMode::_RefreshAudioOptions() {
660  
-	_audio_options_menu.SetOptionText(0, UTranslate("Sound Volume: ") + MakeUnicodeString(NumberToString(static_cast<int32>(AudioManager->GetSoundVolume() * 100.0f + 0.5f)) + " %"));
661  
-	_audio_options_menu.SetOptionText(1, UTranslate("Music Volume: ") + MakeUnicodeString(NumberToString(static_cast<int32>(AudioManager->GetMusicVolume() * 100.0f + 0.5f)) + " %"));
  513
+    read_data.OpenTable("languages");
  514
+    uint32 table_size = read_data.GetTableSize();
  515
+
  516
+    // Set up the dimensions of the window according to how many languages are available.
  517
+    _language_options_menu.SetDimensions(300.0f, 200.0f, 1, table_size, 1, table_size);
  518
+
  519
+    _po_files.clear();
  520
+    for(uint32 i = 1; i <= table_size; i++) {
  521
+        read_data.OpenTable(i);
  522
+        _po_files.push_back(read_data.ReadString(2));
  523
+        _language_options_menu.AddOption(MakeUnicodeString(read_data.ReadString(1)),
  524
+                                         &BootMode::_OnLanguageSelect);
  525
+        read_data.CloseTable();
  526
+    }
  527
+
  528
+    read_data.CloseTable();
  529
+    if(read_data.IsErrorDetected())
  530
+        PRINT_ERROR << "Error occurred while loading language list: " << read_data.GetErrorMessages() << std::endl;
  531
+    read_data.CloseFile();
662 532
 }
663 533
 
664 534
 
  535
+void BootMode::_SetupKeySettingsMenu()
  536
+{
  537
+    _key_settings_menu.ClearOptions();
  538
+    _key_settings_menu.SetPosition(512.0f, 300.0f);
  539
+    _key_settings_menu.SetDimensions(250.0f, 500.0f, 1, 12, 1, 12);
  540
+    _key_settings_menu.SetTextStyle(TextStyle("title22"));
  541
+    _key_settings_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
  542
+    _key_settings_menu.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER);
  543
+    _key_settings_menu.SetSelectMode(VIDEO_SELECT_SINGLE);
  544
+    _key_settings_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
  545
+    _key_settings_menu.SetCursorOffset(-50.0f, 28.0f);
  546
+    _key_settings_menu.SetSkipDisabled(true);
  547
+
  548
+    _key_settings_menu.AddOption(UTranslate("Up: "), &BootMode::_RedefineUpKey);
  549
+    _key_settings_menu.AddOption(UTranslate("Down: "), &BootMode::_RedefineDownKey);
  550
+    _key_settings_menu.AddOption(UTranslate("Left: "), &BootMode::_RedefineLeftKey);
  551
+    _key_settings_menu.AddOption(UTranslate("Right: "), &BootMode::_RedefineRightKey);
  552
+    _key_settings_menu.AddOption(UTranslate("Confirm: "), &BootMode::_RedefineConfirmKey);
  553
+    _key_settings_menu.AddOption(UTranslate("Cancel: "), &BootMode::_RedefineCancelKey);
  554
+    _key_settings_menu.AddOption(UTranslate("Menu: "), &BootMode::_RedefineMenuKey);
  555
+    _key_settings_menu.AddOption(UTranslate("Swap: "), &BootMode::_RedefineSwapKey);
  556
+    _key_settings_menu.AddOption(UTranslate("Left Select: "), &BootMode::_RedefineLeftSelectKey);
  557
+    _key_settings_menu.AddOption(UTranslate("Right Select: "), &BootMode::_RedefineRightSelectKey);
  558
+    _key_settings_menu.AddOption(UTranslate("Pause: "), &BootMode::_RedefinePauseKey);
  559
+    _key_settings_menu.AddOption(UTranslate("Restore defaults"), &BootMode::_OnRestoreDefaultKeys);
  560
+}
  561
+
  562
+
  563
+void BootMode::_SetupJoySettingsMenu()
  564
+{
  565
+    _joy_settings_menu.ClearOptions();
  566
+    _joy_settings_menu.SetPosition(512.0f, 300.0f);
  567
+    _joy_settings_menu.SetDimensions(250.0f, 500.0f, 1, 10, 1, 10);
  568
+    _joy_settings_menu.SetTextStyle(TextStyle("title22"));
  569
+    _joy_settings_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
  570
+    _joy_settings_menu.SetOptionAlignment(VIDEO_X_LEFT, VIDEO_Y_CENTER);
  571
+    _joy_settings_menu.SetSelectMode(VIDEO_SELECT_SINGLE);
  572
+    _joy_settings_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
  573
+    _joy_settings_menu.SetCursorOffset(-50.0f, 28.0f);
  574
+    _joy_settings_menu.SetSkipDisabled(true);
  575
+
  576
+    ustring dummy;
  577
+    // TODO: Add missing joystick options in the GUI
  578
+//	_joy_settings_menu.AddOption(dummy, &BootMode::_ToggleJoystickEnabled);
  579
+    _joy_settings_menu.AddOption(dummy, &BootMode::_RedefineXAxisJoy);
  580
+    _joy_settings_menu.AddOption(dummy, &BootMode::_RedefineYAxisJoy);
  581
+//	_joy_settings_menu.AddOption(dummy, &BootMode::_RedefineThresholdJoy);
  582
+
  583
+    _joy_settings_menu.AddOption(dummy, &BootMode::_RedefineConfirmJoy);
  584
+    _joy_settings_menu.AddOption(dummy, &BootMode::_RedefineCancelJoy);
  585
+    _joy_settings_menu.AddOption(dummy, &BootMode::_RedefineMenuJoy);
  586
+    _joy_settings_menu.AddOption(dummy, &BootMode::_RedefineSwapJoy);
  587
+    _joy_settings_menu.AddOption(dummy, &BootMode::_RedefineLeftSelectJoy);
  588
+    _joy_settings_menu.AddOption(dummy, &BootMode::_RedefineRightSelectJoy);
  589
+    _joy_settings_menu.AddOption(dummy, &BootMode::_RedefinePauseJoy);
  590
+//	_joy_settings_menu.AddOption(dummy, &BootMode::_RedefineQuitJoy);
665 591
 
666  
-void BootMode::_RefreshKeySettings() {
667  
-	// Update key names
668  
-	_key_settings_menu.SetOptionText(0, UTranslate("Move Up") + MakeUnicodeString("<r>" + InputManager->GetUpKeyName()));
669  
-	_key_settings_menu.SetOptionText(1, UTranslate("Move Down") + MakeUnicodeString("<r>" + InputManager->GetDownKeyName()));
670  
-	_key_settings_menu.SetOptionText(2, UTranslate("Move Left") + MakeUnicodeString("<r>" + InputManager->GetLeftKeyName()));
671  
-	_key_settings_menu.SetOptionText(3, UTranslate("Move Right") + MakeUnicodeString("<r>" + InputManager->GetRightKeyName()));
672  
-	_key_settings_menu.SetOptionText(4, UTranslate("Confirm") + MakeUnicodeString("<r>" + InputManager->GetConfirmKeyName()));
673  
-	_key_settings_menu.SetOptionText(5, UTranslate("Cancel") + MakeUnicodeString("<r>" + InputManager->GetCancelKeyName()));
674  
-	_key_settings_menu.SetOptionText(6, UTranslate("Menu") + MakeUnicodeString("<r>" + InputManager->GetMenuKeyName()));
675  
-	_key_settings_menu.SetOptionText(7, UTranslate("Swap") + MakeUnicodeString("<r>" + InputManager->GetSwapKeyName()));
676  
-	_key_settings_menu.SetOptionText(8, UTranslate("Left Select") + MakeUnicodeString("<r>" + InputManager->GetLeftSelectKeyName()));
677  
-	_key_settings_menu.SetOptionText(9, UTranslate("Right Select") + MakeUnicodeString("<r>" + InputManager->GetRightSelectKeyName()));
678  
-	_key_settings_menu.SetOptionText(10, UTranslate("Pause") + MakeUnicodeString("<r>" + InputManager->GetPauseKeyName()));
  592
+    _joy_settings_menu.AddOption(UTranslate("Restore defaults"), &BootMode::_OnRestoreDefaultJoyButtons);
679 593
 }
680 594
 
681 595
 
  596
+void BootMode::_SetupResolutionMenu()
  597
+{
  598
+    _resolution_menu.SetPosition(512.0f, 300.0f);
  599
+    _resolution_menu.SetDimensions(300.0f, 200.0f, 1, 4, 1, 4);
  600
+    _resolution_menu.SetTextStyle(TextStyle("title22"));
  601
+    _resolution_menu.SetAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
  602
+    _resolution_menu.SetOptionAlignment(VIDEO_X_CENTER, VIDEO_Y_CENTER);
  603
+    _resolution_menu.SetSelectMode(VIDEO_SELECT_SINGLE);
  604
+    _resolution_menu.SetVerticalWrapMode(VIDEO_WRAP_MODE_STRAIGHT);
  605
+    _resolution_menu.SetCursorOffset(-50.0f, 28.0f);
  606
+    _resolution_menu.SetSkipDisabled(true);
  607
+
  608
+    _resolution_menu.AddOption(MakeUnicodeString("640 x 480"), &BootMode::_OnResolution640x480);
  609
+    _resolution_menu.AddOption(MakeUnicodeString("800 x 600"), &BootMode::_OnResolution800x600);
  610
+    _resolution_menu.AddOption(MakeUnicodeString("1024 x 768"), &BootMode::_OnResolution1024x768);
  611
+    _resolution_menu.AddOption(MakeUnicodeString("1280 x 1024"), &BootMode::_OnResolution1280x1024);
  612
+
  613
+    if(VideoManager->GetScreenWidth() == 640)
  614
+        _resolution_menu.SetSelection(0);
  615
+    else if(VideoManager->GetScreenWidth() == 800)
  616
+        _resolution_menu.SetSelection(1);
  617
+    else if(VideoManager->GetScreenWidth() == 1024)
  618
+        _resolution_menu.SetSelection(2);
  619
+    else if(VideoManager->GetScreenWidth() == 1280)
  620
+        _resolution_menu.SetSelection(3);
  621
+}
  622
+
  623
+void BootMode::_RefreshVideoOptions()
  624
+{
  625
+    // Update resolution text
  626
+    std::ostringstream resolution("");
  627
+    resolution << VideoManager->GetScreenWidth() << " x " << VideoManager->GetScreenHeight();
  628
+    _video_options_menu.SetOptionText(0, UTranslate("Resolution: ") + MakeUnicodeString(resolution.str()));
  629
+
  630
+    // Update text on current video mode
  631
+    if(VideoManager->IsFullscreen())
  632
+        _video_options_menu.SetOptionText(1, UTranslate("Window mode: ") + UTranslate("Fullscreen"));
  633
+    else
  634
+        _video_options_menu.SetOptionText(1, UTranslate("Window mode: ") + UTranslate("Windowed"));
  635
+
  636
+    // Update brightness
  637
+    _video_options_menu.SetOptionText(2, UTranslate("Brightness: ") + MakeUnicodeString(NumberToString(VideoManager->GetGamma() * 50.0f + 0.5f) + " %"));
682 638
 
683  
-void BootMode::_RefreshJoySettings() {
684  
-	int32 i = 0;
685  
-	_joy_settings_menu.SetOptionText(i++, UTranslate("X Axis") + MakeUnicodeString("<r>" + NumberToString(InputManager->GetXAxisJoy())));
686  
-	_joy_settings_menu.SetOptionText(i++, UTranslate("Y Axis") + MakeUnicodeString("<r>" + NumberToString(InputManager->GetYAxisJoy())));
687  
-	_joy_settings_menu.SetOptionText(i++, UTranslate("Confirm: Button") + MakeUnicodeString("<r>" + NumberToString(InputManager->GetConfirmJoy())));
688  
-	_joy_settings_menu.SetOptionText(i++, UTranslate("Cancel: Button") + MakeUnicodeString("<r>" + NumberToString(InputManager->GetCancelJoy())));
689  
-	_joy_settings_menu.SetOptionText(i++, UTranslate("Menu: Button") + MakeUnicodeString("<r>" + NumberToString(InputManager->GetMenuJoy())));
690  
-	_joy_settings_menu.SetOptionText(i++, UTranslate("Swap: Button") + MakeUnicodeString("<r>" + NumberToString(InputManager->GetSwapJoy())));
691  
-	_joy_settings_menu.SetOptionText(i++, UTranslate("Left Select: Button") + MakeUnicodeString("<r>" + NumberToString(InputManager->GetLeftSelectJoy())));
692  
-	_joy_settings_menu.SetOptionText(i++, UTranslate("Right Select: Button") + MakeUnicodeString("<r>" + NumberToString(InputManager->GetRightSelectJoy())));
693  
-	_joy_settings_menu.SetOptionText(i++, UTranslate("Pause: Button") + MakeUnicodeString("<r>" + NumberToString(InputManager->GetPauseJoy())));
  639
+    // Update the image quality text
  640
+    if(VideoManager->ShouldSmoothPixelArt())
  641
+        _video_options_menu.SetOptionText(3, UTranslate("Map tiles: ") + UTranslate("Smoothed"));
  642
+    else
  643
+        _video_options_menu.SetOptionText(3, UTranslate("Map tiles: ") + UTranslate("Normal"));
  644
+}
  645
+
  646
+
  647
+
  648
+void BootMode::_RefreshAudioOptions()
  649
+{
  650
+    _audio_options_menu.SetOptionText(0, UTranslate("Sound Volume: ") + MakeUnicodeString(NumberToString(static_cast<int32>(AudioManager->GetSoundVolume() * 100.0f + 0.5f)) + " %"));
  651
+    _audio_options_menu.SetOptionText(1, UTranslate("Music Volume: ") + MakeUnicodeString(NumberToString(static_cast<int32>(AudioManager->GetMusicVolume() * 100.0f + 0.5f)) + " %"));
  652
+}
  653
+
  654
+
  655
+
  656
+void BootMode::_RefreshKeySettings()
  657
+{
  658
+    // Update key names
  659
+    _key_settings_menu.SetOptionText(0, UTranslate("Move Up") + MakeUnicodeString("<r>" + InputManager->GetUpKeyName()));