Skip to content
This repository
Browse code

Don't crash on broken config file

  • Loading branch information...
commit 04aeb29684b4492df09691533cb82995cf745243 1 parent e26649a
Igor Paliychuk authored September 17, 2012

Showing 1 changed file with 101 additions and 124 deletions. Show diff stats Hide diff stats

  1. 225  src/GameStateConfig.cpp
225  src/GameStateConfig.cpp
@@ -70,14 +70,92 @@ GameStateConfig::GameStateConfig ()
70 70
 
71 71
 void GameStateConfig::init() {
72 72
 
73  
-	// Initialize Widgets
  73
+	ok_button = new WidgetButton(mods->locate("images/menus/buttons/button_default.png"));
  74
+	defaults_button = new WidgetButton(mods->locate("images/menus/buttons/button_default.png"));
  75
+	cancel_button = new WidgetButton(mods->locate("images/menus/buttons/button_default.png"));
  76
+
  77
+	ok_button->label = msg->get("Ok");
  78
+	ok_button->pos.x = VIEW_W_HALF - ok_button->pos.w/2;
  79
+	ok_button->pos.y = VIEW_H - (cancel_button->pos.h*3);
  80
+	ok_button->refresh();
  81
+
  82
+	defaults_button->label = msg->get("Defaults");
  83
+	defaults_button->pos.x = VIEW_W_HALF - defaults_button->pos.w/2;
  84
+	defaults_button->pos.y = VIEW_H - (cancel_button->pos.h*2);
  85
+	defaults_button->refresh();
  86
+
  87
+	cancel_button->label = msg->get("Cancel");
  88
+	cancel_button->pos.x = VIEW_W_HALF - cancel_button->pos.w/2;
  89
+	cancel_button->pos.y = VIEW_H - (cancel_button->pos.h);
  90
+	cancel_button->refresh();
  91
+
  92
+	vector<string> mod_dirs;
  93
+	getDirList(PATH_DATA + "mods", mod_dirs);
  94
+	mods_total = mod_dirs.size();
  95
+	// Remove active mods from the available mods list
  96
+	for (unsigned int i = 0; i<mods->mod_list.size(); i++) {
  97
+		for (unsigned int j = 0; j<mod_dirs.size(); j++) {
  98
+			if (mods->mod_list[i] == mod_dirs[j] || FALLBACK_MOD == mod_dirs[j]) mod_dirs[j].erase();
  99
+		}
  100
+	}
  101
+
  102
+	fullscreen_cb = new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
  103
+	fullscreen_lb = new WidgetLabel();
  104
+	mouse_move_cb = new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
  105
+	mouse_move_lb = new WidgetLabel();
  106
+	combat_text_cb = new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
  107
+	combat_text_lb = new WidgetLabel();
  108
+	hwsurface_cb = new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
  109
+	hwsurface_lb = new WidgetLabel();
  110
+	doublebuf_cb = new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
  111
+	doublebuf_lb = new WidgetLabel();
  112
+	enable_joystick_cb = new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
  113
+	enable_joystick_lb = new WidgetLabel();
  114
+	texture_quality_cb = new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
  115
+	texture_quality_lb = new WidgetLabel();
  116
+	change_gamma_cb = new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
  117
+	change_gamma_lb = new WidgetLabel();
  118
+	animated_tiles_cb = new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
  119
+	animated_tiles_lb = new WidgetLabel();
  120
+	mouse_aim_cb = new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
  121
+	mouse_aim_lb = new WidgetLabel();
  122
+	show_fps_cb = new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
  123
+	show_fps_lb = new WidgetLabel();
  124
+	music_volume_sl = new WidgetSlider(mods->locate("images/menus/buttons/slider_default.png"));
  125
+	music_volume_lb = new WidgetLabel();
  126
+	sound_volume_sl = new WidgetSlider(mods->locate("images/menus/buttons/slider_default.png"));
  127
+	sound_volume_lb = new WidgetLabel();
  128
+	gamma_sl = new WidgetSlider(mods->locate("images/menus/buttons/slider_default.png"));
  129
+	gamma_lb = new WidgetLabel();
  130
+	resolution_lb = new WidgetLabel();
  131
+	activemods_lstb = new WidgetListBox(mods_total, 10, mods->locate("images/menus/buttons/listbox_default.png"));
  132
+	activemods_lb = new WidgetLabel();
  133
+	inactivemods_lstb = new WidgetListBox(mods_total, 10, mods->locate("images/menus/buttons/listbox_default.png"));
  134
+	inactivemods_lb = new WidgetLabel();
  135
+	joystick_device_lstb = new WidgetListBox(SDL_NumJoysticks(), 10, mods->locate("images/menus/buttons/listbox_default.png"));
  136
+	joystick_device_lb = new WidgetLabel();
  137
+	language_lb = new WidgetLabel();
  138
+	hws_note_lb = new WidgetLabel();
  139
+	dbuf_note_lb = new WidgetLabel();
  140
+	anim_tiles_note_lb = new WidgetLabel();
  141
+	test_note_lb = new WidgetLabel();
  142
+	activemods_shiftup_btn = new WidgetButton(mods->locate("images/menus/buttons/up.png"));
  143
+	activemods_shiftdown_btn = new WidgetButton(mods->locate("images/menus/buttons/down.png"));
  144
+	activemods_deactivate_btn = new WidgetButton(mods->locate("images/menus/buttons/button_default.png"));
  145
+	inactivemods_activate_btn = new WidgetButton(mods->locate("images/menus/buttons/button_default.png"));
  146
+
74 147
 	tabControl = new WidgetTabControl(6);
75 148
 	tabControl->setMainArea(((VIEW_W - FRAME_W)/2)+3, (VIEW_H - FRAME_H)/2, FRAME_W, FRAME_H);
76 149
 	frame = tabControl->getContentArea();
77 150
 
78  
-	ok_button = new WidgetButton(mods->locate("images/menus/buttons/button_default.png"));
79  
-	defaults_button = new WidgetButton(mods->locate("images/menus/buttons/button_default.png"));
80  
-	cancel_button = new WidgetButton(mods->locate("images/menus/buttons/button_default.png"));
  151
+	// Define the header.
  152
+	tabControl->setTabTitle(0, msg->get("Video"));
  153
+	tabControl->setTabTitle(1, msg->get("Audio"));
  154
+	tabControl->setTabTitle(2, msg->get("Interface"));
  155
+	tabControl->setTabTitle(3, msg->get("Input"));
  156
+	tabControl->setTabTitle(4, msg->get("Keybindings"));
  157
+	tabControl->setTabTitle(5, msg->get("Mods"));
  158
+	tabControl->updateHeader();
81 159
 
82 160
 	input_confirm = new MenuConfirm("",msg->get("Assign: "));
83 161
 	defaults_confirm = new MenuConfirm(msg->get("Defaults"),msg->get("Reset ALL settings?"));
@@ -85,6 +163,8 @@ void GameStateConfig::init() {
85 163
 	// Allocate KeyBindings
86 164
 	for (unsigned int i = 0; i < 25; i++) {
87 165
 		 settings_lb[i] = new WidgetLabel();
  166
+		 settings_lb[i]->set(msg->get(binding_name[i]));
  167
+		 settings_lb[i]->setJustify(JUSTIFY_RIGHT);
88 168
 	}
89 169
 	for (unsigned int i = 0; i < 50; i++) {
90 170
 		 settings_key[i] = new WidgetButton(mods->locate("images/menus/buttons/button_default.png"));
@@ -107,51 +187,24 @@ void GameStateConfig::init() {
107 187
 
108 188
 	readConfig();
109 189
 
110  
-	// Define the header.
111  
-	tabControl->setTabTitle(0, msg->get("Video"));
112  
-	tabControl->setTabTitle(1, msg->get("Audio"));
113  
-	tabControl->setTabTitle(2, msg->get("Interface"));
114  
-	tabControl->setTabTitle(3, msg->get("Input"));
115  
-	tabControl->setTabTitle(4, msg->get("Keybindings"));
116  
-	tabControl->setTabTitle(5, msg->get("Mods"));
117  
-	tabControl->updateHeader();
118  
-
119  
-	// Define widgets
120  
-	ok_button->label = msg->get("Ok");
121  
-	ok_button->pos.x = VIEW_W_HALF - ok_button->pos.w/2;
122  
-	ok_button->pos.y = VIEW_H - (cancel_button->pos.h*3);
123  
-	ok_button->refresh();
124  
-
125  
-	defaults_button->label = msg->get("Defaults");
126  
-	defaults_button->pos.x = VIEW_W_HALF - defaults_button->pos.w/2;
127  
-	defaults_button->pos.y = VIEW_H - (cancel_button->pos.h*2);
128  
-	defaults_button->refresh();
129  
-
130  
-	cancel_button->label = msg->get("Cancel");
131  
-	cancel_button->pos.x = VIEW_W_HALF - cancel_button->pos.w/2;
132  
-	cancel_button->pos.y = VIEW_H - (cancel_button->pos.h);
133  
-	cancel_button->refresh();
  190
+	// Finish Mods ListBoxes setup
  191
+	activemods_lstb->multi_select = true;
  192
+	for (unsigned int i = 0; i < mods->mod_list.size() ; i++) {
  193
+		if (mods->mod_list[i] != FALLBACK_MOD)
  194
+			activemods_lstb->append(mods->mod_list[i],"");
  195
+	}
  196
+	child_widget.push_back(activemods_lstb);
  197
+	optiontab[child_widget.size()-1] = 5;
134 198
 
135  
-	// Add Key Binding objects
136  
-	for (unsigned int i = 0; i < 25; i++) {
137  
-		 settings_lb[i]->set(msg->get(binding_name[i]));
138  
-		 settings_lb[i]->setJustify(JUSTIFY_RIGHT);
  199
+	inactivemods_lstb->multi_select = true;
  200
+	for (unsigned int i = 0; i < mod_dirs.size(); i++) {
  201
+		inactivemods_lstb->append(mod_dirs[i],"");
139 202
 	}
  203
+	child_widget.push_back(inactivemods_lstb);
  204
+	optiontab[child_widget.size()-1] = 5;
140 205
 }
141 206
 
142 207
 void GameStateConfig::readConfig () {
143  
-	
144  
-	// Allocate Mods ListBoxes
145  
-	vector<string> mod_dirs;
146  
-	getDirList(PATH_DATA + "mods", mod_dirs);
147  
-	mods_total = mod_dirs.size();
148  
-	// Remove active mods from the available mods list
149  
-	for (unsigned int i = 0; i<mods->mod_list.size(); i++) {
150  
-		for (unsigned int j = 0; j<mod_dirs.size(); j++) {
151  
-			if (mods->mod_list[i] == mod_dirs[j] || FALLBACK_MOD == mod_dirs[j]) mod_dirs[j].erase();
152  
-		}
153  
-	}
154  
-
155 208
 	//Load the menu configuration from file
156 209
 	int x1 = 0;
157 210
 	int y1 = 0;
@@ -175,14 +228,11 @@ void GameStateConfig::readConfig () {
175 228
 			
176 229
 			//checkboxes
177 230
 			if (infile.key == "fullscreen") {
178  
-				fullscreen_cb =
179  
-					new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
180 231
 				fullscreen_cb->pos.x = frame.x + x2;
181 232
 				fullscreen_cb->pos.y = frame.y + y2;
182 233
 				child_widget.push_back(fullscreen_cb);
183 234
 				optiontab[child_widget.size()-1] = 0;
184 235
 
185  
-				fullscreen_lb = new WidgetLabel();
186 236
 				fullscreen_lb->setX(frame.x + x1);
187 237
 				fullscreen_lb->setY(frame.y + y1);
188 238
 				fullscreen_lb->set(msg->get("Full Screen Mode"));
@@ -191,14 +241,11 @@ void GameStateConfig::readConfig () {
191 241
 				optiontab[child_widget.size()-1] = 0;
192 242
 			}
193 243
 			else if (infile.key == "mouse_move") {
194  
-				mouse_move_cb =
195  
-					new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
196 244
 				mouse_move_cb->pos.x = frame.x + x2;
197 245
 				mouse_move_cb->pos.y = frame.y + y2;
198 246
 				child_widget.push_back(mouse_move_cb);
199 247
 				optiontab[child_widget.size()-1] = 3;
200 248
 
201  
-				mouse_move_lb = new WidgetLabel();
202 249
 				mouse_move_lb->setX(frame.x + x1);
203 250
 				mouse_move_lb->setY(frame.y + y1);			
204 251
 				mouse_move_lb->set(msg->get("Move hero using mouse"));
@@ -207,14 +254,11 @@ void GameStateConfig::readConfig () {
207 254
 				optiontab[child_widget.size()-1] = 3;
208 255
 			}
209 256
 			else if (infile.key == "combat_text") {
210  
-				combat_text_cb =
211  
-					new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
212 257
 				combat_text_cb->pos.x = frame.x + x2;
213 258
 				combat_text_cb->pos.y = frame.y + y2;
214 259
 				child_widget.push_back(combat_text_cb);
215 260
 				optiontab[child_widget.size()-1] = 2;
216 261
 
217  
-				combat_text_lb = new WidgetLabel();
218 262
 				combat_text_lb->setX(frame.x + x1);
219 263
 				combat_text_lb->setY(frame.y + y1);
220 264
 				combat_text_lb->set(msg->get("Show combat text"));
@@ -224,14 +268,11 @@ void GameStateConfig::readConfig () {
224 268
 
225 269
 			}
226 270
 			else if (infile.key == "hwsurface") {
227  
-				hwsurface_cb =
228  
-					new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
229 271
 				hwsurface_cb->pos.x = frame.x + x2;
230 272
 				hwsurface_cb->pos.y = frame.y + y2;
231 273
 				child_widget.push_back(hwsurface_cb);
232 274
 				optiontab[child_widget.size()-1] = 0;
233 275
 
234  
-				hwsurface_lb = new WidgetLabel();
235 276
 				hwsurface_lb->setX(frame.x + x1);
236 277
 				hwsurface_lb->setY(frame.y + y1);
237 278
 				hwsurface_lb->set(msg->get("Hardware surfaces"));
@@ -240,14 +281,11 @@ void GameStateConfig::readConfig () {
240 281
 				optiontab[child_widget.size()-1] = 0;
241 282
 			}
242 283
 			else if (infile.key == "doublebuf") {
243  
-				doublebuf_cb =
244  
-					new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
245 284
 				doublebuf_cb->pos.x = frame.x + x2;
246 285
 				doublebuf_cb->pos.y = frame.y + y2;
247 286
 				child_widget.push_back(doublebuf_cb);
248 287
 				optiontab[child_widget.size()-1] = 0;
249 288
 
250  
-				doublebuf_lb = new WidgetLabel();
251 289
 				doublebuf_lb->setX(frame.x + x1);
252 290
 				doublebuf_lb->setY(frame.y + y1);
253 291
 				doublebuf_lb->set(msg->get("Double buffering"));
@@ -257,14 +295,11 @@ void GameStateConfig::readConfig () {
257 295
 
258 296
 			}
259 297
 			else if (infile.key == "enable_joystick") {
260  
-				enable_joystick_cb =
261  
-					new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
262 298
 				enable_joystick_cb->pos.x = frame.x + x2;
263 299
 				enable_joystick_cb->pos.y = frame.y + y2;
264 300
 				child_widget.push_back(enable_joystick_cb);
265 301
 				optiontab[child_widget.size()-1] = 3;
266 302
 
267  
-				enable_joystick_lb = new WidgetLabel();
268 303
 				enable_joystick_lb->setX(frame.x + x1);
269 304
 				enable_joystick_lb->setY(frame.y + y1);
270 305
 				enable_joystick_lb->set(msg->get("Use joystick"));
@@ -273,14 +308,11 @@ void GameStateConfig::readConfig () {
273 308
 				optiontab[child_widget.size()-1] = 3;
274 309
 			}
275 310
 			else if (infile.key == "texture_quality") {
276  
-				texture_quality_cb =
277  
-					new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
278 311
 				texture_quality_cb->pos.x = frame.x + x2;
279 312
 				texture_quality_cb->pos.y = frame.y + y2;	
280 313
 				child_widget.push_back(texture_quality_cb);
281 314
 				optiontab[child_widget.size()-1] = 0;
282 315
 
283  
-				texture_quality_lb = new WidgetLabel();
284 316
 				texture_quality_lb->setX(frame.x + x1);
285 317
 				texture_quality_lb->setY(frame.y + y1);
286 318
 				texture_quality_lb->set(msg->get("High Quality Textures"));
@@ -289,14 +321,11 @@ void GameStateConfig::readConfig () {
289 321
 				optiontab[child_widget.size()-1] = 0;
290 322
 			}
291 323
 			else if (infile.key == "change_gamma") {
292  
-				change_gamma_cb =
293  
-					new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
294 324
 				change_gamma_cb->pos.x = frame.x + x2;
295 325
 				change_gamma_cb->pos.y = frame.y + y2;
296 326
 				child_widget.push_back(change_gamma_cb);
297 327
 				optiontab[child_widget.size()-1] = 0;
298 328
 
299  
-				change_gamma_lb = new WidgetLabel();
300 329
 				change_gamma_lb->setX(frame.x + x1);
301 330
 				change_gamma_lb->setY(frame.y + y1);				
302 331
 				change_gamma_lb->set(msg->get("Allow changing gamma"));
@@ -305,14 +334,11 @@ void GameStateConfig::readConfig () {
305 334
 				optiontab[child_widget.size()-1] = 0;
306 335
 			}
307 336
 			else if (infile.key == "animated_tiles") {
308  
-				animated_tiles_cb =
309  
-					new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
310 337
 				animated_tiles_cb->pos.x = frame.x + x2;
311 338
 				animated_tiles_cb->pos.y = frame.y + y2;
312 339
 				child_widget.push_back(animated_tiles_cb);
313 340
 				optiontab[child_widget.size()-1] = 0;
314 341
 
315  
-				animated_tiles_lb = new WidgetLabel();
316 342
 				animated_tiles_lb->setX(frame.x + x1);
317 343
 				animated_tiles_lb->setY(frame.y + y1);				
318 344
 				animated_tiles_lb->set(msg->get("Animated tiles"));
@@ -321,14 +347,11 @@ void GameStateConfig::readConfig () {
321 347
 				optiontab[child_widget.size()-1] = 0;
322 348
 			}
323 349
 			else if (infile.key == "mouse_aim") {
324  
-				mouse_aim_cb =
325  
-					new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
326 350
 				mouse_aim_cb->pos.x = frame.x + x2;
327 351
 				mouse_aim_cb->pos.y = frame.y + y2;
328 352
 				child_widget.push_back(mouse_aim_cb);
329 353
 				optiontab[child_widget.size()-1] = 3;
330 354
 
331  
-				mouse_aim_lb = new WidgetLabel();
332 355
 				mouse_aim_lb->setX(frame.x + x1);
333 356
 				mouse_aim_lb->setY(frame.y + y1);				
334 357
 				mouse_aim_lb->set(msg->get("Mouse aim"));
@@ -337,14 +360,11 @@ void GameStateConfig::readConfig () {
337 360
 				optiontab[child_widget.size()-1] = 3;
338 361
 			}
339 362
 			else if (infile.key == "show_fps") {
340  
-				show_fps_cb =
341  
-					new WidgetCheckBox(mods->locate("images/menus/buttons/checkbox_default.png"));
342 363
 				show_fps_cb->pos.x = frame.x + x2;
343 364
 				show_fps_cb->pos.y = frame.y + y2;
344 365
 				child_widget.push_back(show_fps_cb);
345 366
 				optiontab[child_widget.size()-1] = 2;
346 367
 
347  
-				show_fps_lb = new WidgetLabel();
348 368
 				show_fps_lb->setX(frame.x + x1);
349 369
 				show_fps_lb->setY(frame.y + y1);					
350 370
 				show_fps_lb->set(msg->get("Show FPS"));
@@ -354,14 +374,11 @@ void GameStateConfig::readConfig () {
354 374
 			}
355 375
 			//sliders
356 376
 			else if (infile.key == "music_volume") {
357  
-				music_volume_sl =
358  
-					new WidgetSlider(mods->locate("images/menus/buttons/slider_default.png"));
359 377
 				music_volume_sl->pos.x = frame.x + x2;
360 378
 				music_volume_sl->pos.y = frame.y + y2;
361 379
 				child_widget.push_back(music_volume_sl);
362 380
 				optiontab[child_widget.size()-1] = 1;
363 381
 
364  
-				music_volume_lb = new WidgetLabel();
365 382
 				music_volume_lb->setX(frame.x + x1);
366 383
 				music_volume_lb->setY(frame.y + y1);				
367 384
 				music_volume_lb->set(msg->get("Music Volume"));
@@ -370,14 +387,11 @@ void GameStateConfig::readConfig () {
370 387
 				optiontab[child_widget.size()-1] = 1;
371 388
 			}
372 389
 			else if (infile.key == "sound_volume") {
373  
-				sound_volume_sl =
374  
-					new WidgetSlider(mods->locate("images/menus/buttons/slider_default.png"));
375 390
 				sound_volume_sl->pos.x = frame.x + x2;
376 391
 				sound_volume_sl->pos.y = frame.y + y2;	
377 392
 				child_widget.push_back(sound_volume_sl);
378 393
 				optiontab[child_widget.size()-1] = 1;
379 394
 
380  
-				sound_volume_lb = new WidgetLabel();
381 395
 				sound_volume_lb->setX(frame.x + x1);
382 396
 				sound_volume_lb->setY(frame.y + y1);
383 397
 				sound_volume_lb->set(msg->get("Sound Volume"));
@@ -386,14 +400,11 @@ void GameStateConfig::readConfig () {
386 400
 				optiontab[child_widget.size()-1] = 1;
387 401
 			}
388 402
 			else if (infile.key == "gamma") {
389  
-				gamma_sl =
390  
-					new WidgetSlider(mods->locate("images/menus/buttons/slider_default.png"));
391 403
 				gamma_sl->pos.x = frame.x + x2;
392 404
 				gamma_sl->pos.y = frame.y + y2;
393 405
 				child_widget.push_back(gamma_sl);
394 406
 				optiontab[child_widget.size()-1] = 0;
395 407
 
396  
-				gamma_lb = new WidgetLabel();
397 408
 				gamma_lb->setX(frame.x + x1);
398 409
 				gamma_lb->setY(frame.y + y1);
399 410
 				gamma_lb->set(msg->get("Gamma"));
@@ -403,13 +414,11 @@ void GameStateConfig::readConfig () {
403 414
 			}
404 415
 			//listboxes
405 416
 			else if (infile.key == "resolution") {
406  
-
407 417
 				resolution_lstb->pos.x = frame.x + x2;
408 418
 				resolution_lstb->pos.y = frame.y + y2;				
409 419
 				child_widget.push_back(resolution_lstb);
410 420
 				optiontab[child_widget.size()-1] = 0;
411 421
 
412  
-				resolution_lb = new WidgetLabel();
413 422
 				resolution_lb->setX(frame.x + x1);
414 423
 				resolution_lb->setY(frame.y + y1);
415 424
 				resolution_lb->set(msg->get("Resolution"));
@@ -418,19 +427,9 @@ void GameStateConfig::readConfig () {
418 427
 
419 428
 			}
420 429
 			else if (infile.key == "activemods") {
421  
-				activemods_lstb =
422  
-					new WidgetListBox(mods_total, 10, mods->locate("images/menus/buttons/listbox_default.png"));
423 430
 				activemods_lstb->pos.x = frame.x + x2;
424 431
 				activemods_lstb->pos.y = frame.y + y2;
425  
-				activemods_lstb->multi_select = true;
426  
-				for (unsigned int i = 0; i < mods->mod_list.size() ; i++) {
427  
-					if (mods->mod_list[i] != FALLBACK_MOD)
428  
-						activemods_lstb->append(mods->mod_list[i],"");
429  
-				}
430  
-				child_widget.push_back(activemods_lstb);
431  
-				optiontab[child_widget.size()-1] = 5;
432 432
 
433  
-				activemods_lb = new WidgetLabel();
434 433
 				activemods_lb->setX(frame.x + x1);
435 434
 				activemods_lb->setY(frame.y + y1);
436 435
 				activemods_lb->set(msg->get("Active Mods"));
@@ -438,18 +437,9 @@ void GameStateConfig::readConfig () {
438 437
 				optiontab[child_widget.size()-1] = 5;
439 438
 			}
440 439
 			else if (infile.key == "inactivemods") {
441  
-				inactivemods_lstb =
442  
-					new WidgetListBox(mods_total, 10, mods->locate("images/menus/buttons/listbox_default.png"));
443 440
 				inactivemods_lstb->pos.x = frame.x + x2;
444 441
 				inactivemods_lstb->pos.y = frame.y + y2;
445  
-				inactivemods_lstb->multi_select = true;
446  
-				for (unsigned int i = 0; i < mod_dirs.size(); i++) {
447  
-					inactivemods_lstb->append(mod_dirs[i],"");
448  
-				}
449  
-				child_widget.push_back(inactivemods_lstb);
450  
-				optiontab[child_widget.size()-1] = 5;
451 442
 
452  
-				inactivemods_lb = new WidgetLabel();
453 443
 				inactivemods_lb->setX(frame.x + x1);
454 444
 				inactivemods_lb->setY(frame.y + y1);
455 445
 				inactivemods_lb->set(msg->get("Available Mods"));
@@ -457,8 +447,6 @@ void GameStateConfig::readConfig () {
457 447
 				optiontab[child_widget.size()-1] = 5;
458 448
 			}
459 449
 			else if (infile.key == "joystick_device") {
460  
-				joystick_device_lstb =
461  
-					new WidgetListBox(SDL_NumJoysticks(), 10, mods->locate("images/menus/buttons/listbox_default.png"));
462 450
 				joystick_device_lstb->pos.x = frame.x + x2;
463 451
 				joystick_device_lstb->pos.y = frame.y + y2;
464 452
 				for(int i = 0; i < SDL_NumJoysticks(); i++) {
@@ -468,7 +456,6 @@ void GameStateConfig::readConfig () {
468 456
 				child_widget.push_back(joystick_device_lstb);
469 457
 				optiontab[child_widget.size()-1] = 3;
470 458
 
471  
-				joystick_device_lb = new WidgetLabel();
472 459
 				joystick_device_lb->setX(frame.x + x1);
473 460
 				joystick_device_lb->setY(frame.y + y1);
474 461
 				joystick_device_lb->set(msg->get("Joystick"));
@@ -481,7 +468,6 @@ void GameStateConfig::readConfig () {
481 468
 				child_widget.push_back(language_lstb);
482 469
 				optiontab[child_widget.size()-1] = 2;
483 470
 
484  
-				language_lb = new WidgetLabel();
485 471
 				language_lb->setX(frame.x + x1);
486 472
 				language_lb->setY(frame.y + y1);
487 473
 				language_lb->set(msg->get("Language"));
@@ -517,7 +503,6 @@ void GameStateConfig::readConfig () {
517 503
 			// buttons end
518 504
 
519 505
 			else if (infile.key == "hws_note") {
520  
-				hws_note_lb = new WidgetLabel();
521 506
 				hws_note_lb->setX(frame.x + x1);
522 507
 				hws_note_lb->setY(frame.y + y1);
523 508
 				hws_note_lb->set(msg->get("Disable for performance"));
@@ -525,7 +510,6 @@ void GameStateConfig::readConfig () {
525 510
 				optiontab[child_widget.size()-1] = 0;
526 511
 			}
527 512
 			else if (infile.key == "dbuf_note") {
528  
-				dbuf_note_lb = new WidgetLabel();
529 513
 				dbuf_note_lb->setX(frame.x + x1);
530 514
 				dbuf_note_lb->setY(frame.y + y1);
531 515
 				dbuf_note_lb->set(msg->get("Disable for performance"));
@@ -533,7 +517,6 @@ void GameStateConfig::readConfig () {
533 517
 				optiontab[child_widget.size()-1] = 0;
534 518
 			}
535 519
 			else if (infile.key == "anim_tiles_note") {
536  
-				anim_tiles_note_lb = new WidgetLabel();
537 520
 				anim_tiles_note_lb->setX(frame.x + x1);
538 521
 				anim_tiles_note_lb->setY(frame.y + y1);
539 522
 				anim_tiles_note_lb->set(msg->get("Disable for performance"));
@@ -541,7 +524,6 @@ void GameStateConfig::readConfig () {
541 524
 				optiontab[child_widget.size()-1] = 0;
542 525
 			}
543 526
 			else if (infile.key == "test_note") {
544  
-				test_note_lb = new WidgetLabel();
545 527
 				test_note_lb->setX(frame.x + x1);
546 528
 				test_note_lb->setY(frame.y + y1);
547 529
 				test_note_lb->set(msg->get("Experimental"));
@@ -550,8 +532,6 @@ void GameStateConfig::readConfig () {
550 532
 			}
551 533
 			//buttons
552 534
 			else if (infile.key == "activemods_shiftup") {
553  
-				activemods_shiftup_btn =
554  
-					new WidgetButton(mods->locate("images/menus/buttons/up.png"));
555 535
 				activemods_shiftup_btn->pos.x = frame.x + x1;
556 536
 				activemods_shiftup_btn->pos.y = frame.y + y1;
557 537
 				activemods_shiftup_btn->refresh();
@@ -559,8 +539,6 @@ void GameStateConfig::readConfig () {
559 539
 				optiontab[child_widget.size()-1] = 5;
560 540
 			}
561 541
 			else if (infile.key == "activemods_shiftdown") {
562  
-				activemods_shiftdown_btn =
563  
-					new WidgetButton(mods->locate("images/menus/buttons/down.png"));
564 542
 				activemods_shiftdown_btn->pos.x = frame.x + x1;
565 543
 				activemods_shiftdown_btn->pos.y = frame.y + y1;
566 544
 				activemods_shiftdown_btn->refresh();
@@ -568,8 +546,6 @@ void GameStateConfig::readConfig () {
568 546
 				optiontab[child_widget.size()-1] = 5;
569 547
 			}
570 548
 			else if (infile.key == "activemods_deactivate") {
571  
-				activemods_deactivate_btn =
572  
-					new WidgetButton(mods->locate("images/menus/buttons/button_default.png"));
573 549
 				activemods_deactivate_btn->label = msg->get("<< Disable");
574 550
 				activemods_deactivate_btn->pos.x = frame.x + x1;
575 551
 				activemods_deactivate_btn->pos.y = frame.y + y1;
@@ -578,8 +554,6 @@ void GameStateConfig::readConfig () {
578 554
 				optiontab[child_widget.size()-1] = 5;
579 555
 			}
580 556
 			else if (infile.key == "inactivemods_activate") {
581  
-				inactivemods_activate_btn =
582  
-					new WidgetButton(mods->locate("images/menus/buttons/button_default.png"));
583 557
 				inactivemods_activate_btn->label = msg->get("Enable >>");
584 558
 				inactivemods_activate_btn->pos.x = frame.x + x1;
585 559
 				inactivemods_activate_btn->pos.y = frame.y + y1;
@@ -1281,7 +1255,10 @@ GameStateConfig::~GameStateConfig()
1281 1255
 		delete (*iter);
1282 1256
 	}
1283 1257
 	child_widget.clear();
1284  
-	
  1258
+
  1259
+	for (unsigned int i = 0; i < 25; i++) {
  1260
+		 delete settings_lb[i];
  1261
+	}
1285 1262
 	for (unsigned int i = 0; i < 50; i++) {
1286 1263
 		 delete settings_key[i];
1287 1264
 	}

0 notes on commit 04aeb29

Please sign in to comment.
Something went wrong with that request. Please try again.