1 // ------------------------------------------------------------------
3 // ------------------------------------------------------------------
4 // This has the menu of the Kball game
5 // ------------------------------------------------------------------
6 // Developed By Kronoman - Copyright (c) 2004
7 // In loving memory of my father
8 // ------------------------------------------------------------------
10 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
11 // DEBUG -- THIS FILE IS A MESS, DO SOMETHING ABOUT IT (SPANK IT?)
12 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14 // Dig up her bones!!!
16 #include "gamemenu.h" // I need my prototypes
17 #include "sound.h" // I need the sound system
19 #include <stdlib.h> // getenv
20 #include <stdio.h> // snprintf
22 // some globals needed by callback
23 CParticleManager menu_particle_manager
; // our own particle managar :^D -- REMEMBER TO CALL NUKE PARTICLES BEFORE LEAVING!
24 BITMAP
*bmp_real_background
= NULL
; // menu real background
25 CSoundWrapper
*sound_menu
= NULL
; // sound manager of game menu object
27 // ------------------------------------------------------------------
28 // This callback function produces the background animation in the menus
29 // also, polls the music
30 // ------------------------------------------------------------------
31 void menu_callback_animation(CQMenu
&d
, bool do_logic
)
35 if (sound_menu
) // poll music
36 sound_menu
->music_poll();
38 time_t t_now
= time(NULL
); // get current time, for displaying it, and also, for little surprise :O
40 struct tm
*time_now_local
= localtime (&t_now
); // get finally the time in appropiate format
42 bmp
= d
.get_back_bitmap();
45 return ; // can't draw :(
47 // DEBUG -- improve this animation
48 if (do_logic
) // update logic
50 menu_particle_manager
.update_logic();
51 // add particles at random
52 if (rand() % 100 > 95)
54 int c
, x
, y
; // color, pos of explosion
56 switch (rand() % 4) // pick color scheme
60 c
= makecol(255, rand() % 256, 0);
64 c
= makecol(0, rand() % 256, 255);
68 c
= makecol(rand() % 256, 0, 255);
72 c
= makecol(rand() % 256, 255, 0);
76 c
= makecol(rand() % 256, rand() % 256, rand() % 256);
80 x
= (rand() % (int)(SCREEN_W
* 0.8)) + (int)(SCREEN_W
* 0.1); // use 80% of screen width
81 y
= (rand() % (int)(SCREEN_H
* 0.8)) + (int)(SCREEN_H
* 0.1); // use 80% of screen height
82 for (int i
= 0; i
< rand() % 50 + 100; i
++) // add particles
84 if (rand() % 100 < 85)
85 menu_particle_manager
.add_particle(new CCircleParticle(x
, y
, (float)((rand() % 800) - 400) / 100.0, (float)((rand() % 800) - 400) / 100.0, c
, rand() % 60 + 5, rand() % 4 + 1));
87 menu_particle_manager
.add_particle(new CSparkParticle(x
, y
, (float)((rand() % 800) - 400) / 100.0, (float)((rand() % 800) - 400) / 100.0, c
, rand() % 60 + 5, rand() % 3 + 1));
90 // a little text message
91 if (time_now_local
->tm_mday
== 30 && time_now_local
->tm_mon
== 3 && rand() % 100 < 75)
92 menu_particle_manager
.add_particle(new CTextParticle(x
, y
, (float)((rand() % 800) - 400) / 100.0, (float)(rand() % 400 + 150) / -100.0, c
, rand() % 60 + 35, (rand() % 1000 < 990 ? string("Kronoman Rulez!") : string("Send me lots of $$$! ;)")) ) );
94 if (time_now_local
->tm_year
+ 1900 >= 2010 && rand() % 100 < 75)
97 usprintf(tmpstr
, "Yeah! My game still runs in %d", 1900 + time_now_local
->tm_year
);
99 if (time_now_local
->tm_year
+ 1900 > 2082 && rand() % 100 < 75)
100 menu_particle_manager
.add_particle(new CTextParticle(x
, y
, (float)((rand() % 800) - 400) / 100.0, (float)(rand() % 400 + 150) / -100.0, c
, rand() % 60 + 35, string("I must be over 100 years by now... send me dead flowers to my grave :'(") ) );
102 menu_particle_manager
.add_particle(new CTextParticle(x
, y
, (float)((rand() % 800) - 400) / 100.0, (float)(rand() % 400 + 150) / -100.0, c
, rand() % 60 + 35, string(tmpstr
) ) );
110 if (bmp_real_background
!= NULL
)
111 blit (bmp_real_background
, bmp
, 0, 0, 0, 0, bmp_real_background
->w
, bmp_real_background
->h
);
115 //set_trans_blender(128,128,128,128);
116 //drawing_mode(DRAW_MODE_TRANS, NULL,0,0);
117 menu_particle_manager
.render(bmp
, 0, 0);
122 char tbufstr
[256]; // time string buffer
124 strftime(tbufstr
, 255, "%b %d %Y %H:%M:%S", time_now_local
); // This function formats the time data
128 textout(bmp
, font
, tbufstr
, 0, bmp
->h
- text_height(font
), makecol(128, 0, 255));
133 CGameMenu::CGameMenu()
135 mtracer
.add("CGameMenu::CGameMenu()");
137 menu_back
= NULL
; // doble buffer bitmap for menu
140 CGameMenu::~CGameMenu()
142 mtracer
.add("CGameMenu::~CGameMenu()");
144 // here we should release RAM used, etc (we should wrap init code and end code in a nice place... not the shit that is right now!)
147 // ------------------------------------------------------------------
148 // This shows the main menu to the user
149 // This is the menu that let the user choose the main options
150 // ------------------------------------------------------------------
151 void CGameMenu::do_main_menu()
153 CQMenu menu
; // menu to use/show
154 char tmp_file_buf
[2048];
156 mtracer
.add("CGameMenu::do_main_menu() started");
158 // I set this so the callback 'knows' the sound manager
159 sound_menu
= &this->soundw
;
160 //soundw.set_enabled(true);
164 clear_bitmap(screen
);
165 textout_centre_ex(screen
, font
, "[ Please wait... loading... ]", SCREEN_W
/ 2, SCREEN_H
/ 2, makecol(255, 255, 255), makecol(0, 0, 64));
167 menu_datafile
.load_datafile(where_is_the_filename(tmp_file_buf
, "gui.dat")); // load datafile
170 soundw
.music_load((DUH
*)menu_datafile
.get_resource_dat("MENU_MUSIC_XM"));
172 bmp_real_background
= (BITMAP
*)menu_datafile
.get_resource_dat("MENU_BMP_BACKGROUND"); // get back bmp image
174 // set some gravity to particles
175 menu_particle_manager
.add_dy
= 0.08;
177 menu_back
= create_bitmap(SCREEN_W
, SCREEN_H
); // DEBUG -- HERE I SHOULD LOAD THE BACKGROUND FROM DATAFILE!
178 if (menu_back
== NULL
)
179 raise_error("do_main_menu()\nERROR: can't create menu_back bitmap!");
183 menu
.set_to_bitmap(screen
);
185 menu
.set_back_bitmap(menu_back
);
187 menu
.set_callback_drawer(menu_callback_animation
);
189 menu
.set_font_s((FONT
*)menu_datafile
.get_resource_dat("MENU_FONT_BIG"));
191 menu
.set_fg_color_s(makecol(255, 255, 255));
193 menu
.set_bg_color_s(makecol(0, 0, 200));
195 menu
.set_font_ns((FONT
*)menu_datafile
.get_resource_dat("MENU_FONT_BIG"));
197 menu
.set_fg_color_ns(makecol(128, 128, 128));
199 menu
.set_bg_color_ns( -1);
201 menu
.set_xywh(320, 100, SCREEN_W
, SCREEN_H
);
203 menu
.text_align
= 2; // center align
205 menu
.item_y_separation
= 25;
208 menu
.add_item_to_menu(string("Start new game")); // 0
210 menu
.add_item_to_menu(string("Options")); // 1
212 menu
.add_item_to_menu(string("Credits")); // 2
214 menu
.add_item_to_menu(string("Map editor")); // 3
216 menu
.add_item_to_menu(string("Quit")); // 4
218 while (ret
!= 4) // 4 = quit
220 char str
[4096], *home
= getenv("HOME");
223 snprintf(str
, sizeof(str
), "%s/.kball", home
);
224 mkdir(str
, S_IRWXU
| S_IRWXG
| S_IROTH
| S_IXOTH
);
225 snprintf(str
, sizeof(str
), "%s/.kball/kball.cfg", home
);
226 set_config_file(str
);
230 set_config_file("kball.cfg");
233 menu
.control
.load_configuration_of_controller("KBALL_CONTROLLER");
235 soundw
.music_resume();
237 ret
= menu
.do_the_menu(); // show the menu
239 soundw
.music_pause();
245 do_file_level_selector();
256 case 3: // map editor (from hell they came...)
257 map_editor
.start_map_editor();
261 for (int yi
= 0; yi
< SCREEN_H
; yi
+= 2)
262 hline(screen
, 0, yi
, SCREEN_W
, makecol(0, 0, 20));
264 textout_centre(screen
, (FONT
*)menu_datafile
.get_resource_dat("MENU_FONT_BIG"), "QUIT GAME? Y/N", SCREEN_W
/ 2 + 2, SCREEN_H
/ 2 + 2, makecol(0, 0, 0));
266 textout_centre(screen
, (FONT
*)menu_datafile
.get_resource_dat("MENU_FONT_BIG"), "QUIT GAME? Y/N", SCREEN_W
/ 2, SCREEN_H
/ 2, makecol(0, 255, 255));
274 if ((readkey() >> 8) != KEY_Y
)
276 ret
= -1; // abort exit
286 // DEBUG -- REMEMBER HERE TO FREE THE MEMORY/OBJECTS USED!
287 destroy_bitmap(menu_back
);
289 menu_particle_manager
.nuke_particle_list(); // destroy particles
291 menu_datafile
.nuke_datafile(); // free RAM of datafile
293 bmp_real_background
= NULL
;
296 // ------------------------------------------------------------------
297 // This lets the user choose a level to start it, or a full campaign
298 // It WILL start a game
299 // For this, it list on a menu the files of the current directory
300 // This should *ONLY* be called from main menu, otherwise data needed
301 // for menu will be absent on RAM (have a nice SEG FAULT!)
302 // ------------------------------------------------------------------
303 void CGameMenu::do_file_level_selector()
305 // the level path is defined as [install dir]/levels
308 char path_str
[2048]; // path to level to play
309 char level_path
[2048]; // full path to levels in general (dir/kball/bin/levels, etc)
312 bool full_campaign
= false; // we are going to play full campaing, or single map?
314 mtracer
.add("CGameMenu::do_file_level_selector() started\n");
316 char str
[4096], *home
= getenv("HOME");
319 snprintf(str
, sizeof(str
), "%s/.kball", home
);
320 mkdir(str
, S_IRWXU
| S_IRWXG
| S_IROTH
| S_IXOTH
);
321 snprintf(str
, sizeof(str
), "%s/.kball/kball.cfg", home
);
322 set_config_file(str
);
326 set_config_file("kball.cfg");
328 menu
.control
.load_configuration_of_controller("KBALL_CONTROLLER");
330 menu
.set_to_bitmap(screen
);
331 menu
.set_back_bitmap(menu_back
);
332 menu
.set_callback_drawer(menu_callback_animation
);
334 menu
.item_y_separation
= 25;
336 // let choose single level, or campaign
337 menu
.set_font_s((FONT
*)menu_datafile
.get_resource_dat("MENU_FONT_BIG"));
338 menu
.set_fg_color_s(makecol(255, 255, 255));
339 menu
.set_bg_color_s(makecol(0, 0, 200));
341 menu
.set_font_ns((FONT
*)menu_datafile
.get_resource_dat("MENU_FONT_BIG"));
342 menu
.set_fg_color_ns(makecol(128, 128, 128));
343 menu
.set_bg_color_ns( -1);
344 menu
.set_xywh(320, 100, SCREEN_W
, SCREEN_H
);
346 menu
.clear_menu_list();
347 menu
.add_item_to_menu("Full campaign");
348 menu
.add_item_to_menu("Single level");
355 usprintf(t
, "%s/.kball/levels", home
);
356 if (file_exists(t
, (FA_RDONLY
| FA_HIDDEN
| FA_SYSTEM
| FA_LABEL
| FA_DIREC
), NULL
))
358 menu
.add_item_to_menu("Personal levels");
364 if (file_exists("levels", (FA_RDONLY
| FA_HIDDEN
| FA_SYSTEM
| FA_LABEL
| FA_DIREC
), NULL
))
366 menu
.add_item_to_menu("Personal levels");
370 menu
.add_item_to_menu("< Cancel and return >");
373 //get_executable_name(level_path, 2048);
374 //replace_filename(level_path, level_path, "", 2048);
375 //append_filename(level_path, level_path, "levels", 2048);
376 usprintf(level_path
, "/usr/share/games/kball/levels");
378 fix_filename_slashes(level_path
);
379 mtracer
.add("--> \t Level path == %s", level_path
);
381 soundw
.music_resume();
383 switch (menu
.do_the_menu()) // show the menu and act in consecuence)
388 soundw
.music_pause();
389 usprintf(path_str
, "%s/*.fmp", level_path
);
390 full_campaign
= true;
394 soundw
.music_pause();
395 usprintf(path_str
, "%s/*.map", level_path
);
396 full_campaign
= false;
400 if (personal_levels
== 0)
402 soundw
.music_pause();
405 soundw
.music_pause();
408 usprintf(path_str
, "%s/.kball/levels/*", home
);
409 usprintf(level_path
, "%s/.kball/levels", home
);
413 usprintf(path_str
, "levels/*");
414 usprintf(level_path
, "levels");
416 full_campaign
= false;
420 soundw
.music_pause();
425 fix_filename_slashes(path_str
);
428 // --- Now, list files to use ---
429 menu
.set_font_s((FONT
*)menu_datafile
.get_resource_dat("MENU_FONT_MEDIUM"));
430 menu
.set_fg_color_s(makecol(255, 255, 255));
431 menu
.set_bg_color_s(makecol(0, 0, 200));
433 menu
.set_font_ns((FONT
*)menu_datafile
.get_resource_dat("MENU_FONT_MEDIUM"));
434 menu
.set_fg_color_ns(makecol(128, 128, 128));
435 menu
.set_bg_color_ns( -1);
437 menu
.set_xywh(320, 100, SCREEN_W
, SCREEN_H
);
438 menu
.item_y_separation
= 5;
440 menu
.clear_menu_list();
442 // read files and populate menu with them
443 //ret = al_findfirst(path_str, &dir_reader, FA_ARCH);
444 mtracer
.add("--> \t Path string to search for levels == '%s'", path_str
);
445 ret
= al_findfirst(path_str
, &dir_reader
,(FA_RDONLY
| FA_HIDDEN
| FA_SYSTEM
| FA_LABEL
| FA_ARCH
));
449 menu
.add_item_to_menu(dir_reader
.name
);
450 ret
= al_findnext(&dir_reader
);
453 al_findclose(&dir_reader
);
455 // if we don't have items, we must return with a message
456 if (menu
.get_menu_item_count() < 1)
458 menu
.clear_menu_list();
459 menu
.add_item_to_menu("ERROR: NO FILE AVAILABLE!");
461 soundw
.music_resume();
465 soundw
.music_pause();
466 return ; // abort the mission :^P
469 menu
.add_item_to_menu("< Cancel and return >");
471 soundw
.music_resume();
473 ret
= menu
.do_the_menu(); // show the menu
475 soundw
.music_pause();
477 if (ret
== menu
.get_menu_item_count() - 1)
478 return ; // last item == cancel, then, cancel
481 usprintf(path_str
, "%s/%s", level_path
, menu
.get_menu_item_text(ret
).c_str());
483 fix_filename_slashes(path_str
);
485 // play the game - rock 'n roll!
486 home
= getenv("HOME");
489 snprintf(str
, sizeof(str
), "%s/.kball", home
);
490 mkdir(str
, S_IRWXU
| S_IRWXG
| S_IROTH
| S_IXOTH
);
491 snprintf(str
, sizeof(str
), "%s/.kball/kball.cfg", home
);
492 set_config_file(str
);
496 set_config_file("kball.cfg");
499 game_kernel
.player_ball
.control
.load_configuration_of_controller("KBALL_CONTROLLER");
501 text_mode(makecol(0, 0, 0));
505 mtracer
.add("CGameMenu::do_file_level_selector()\n\tStarting campaign game\n");
507 game_kernel
.player_ball
.lives
= BALL_LIVES_CAMPAIGN
; // ball of the player lives
508 game_kernel
.player_ball
.score
= 0;
509 game_kernel
.stats
.reset();
510 game_kernel
.play_a_full_campaign(path_str
);
512 mtracer
.add("CGameMenu::do_file_level_selector()\n\tEnd of campaign game\n");
516 // start single level game play
517 mtracer
.add("CGameMenu::do_file_level_selector()\n\tStarting single level game\n");
519 game_kernel
.player_ball
.lives
= BALL_LIVES
; // ball of the player lives
520 game_kernel
.player_ball
.score
= 0;
521 game_kernel
.stats
.reset();
522 game_kernel
.play_a_single_level(path_str
);
524 mtracer
.add("CGameMenu::do_file_level_selector()\n\tEnd of single level game\n");
529 // ------------------------------------------------------------------
530 // This shows the 'About' stuff
531 // ------------------------------------------------------------------
532 void CGameMenu::do_about_stuff()
534 mtracer
.add("CGameMenu::do_about_stuff();");
536 BITMAP
*back
= (BITMAP
*)menu_datafile
.get_resource_dat("ABOUT_BACKGROUND"); // get back bmp image
537 BITMAP
*dbuf
= create_bitmap(SCREEN_W
, SCREEN_H
);
538 FONT
*font_about
= (FONT
*)menu_datafile
.get_resource_dat("MENU_FONT_SMALL");
539 SAMPLE
*snd_loop_sample
= (SAMPLE
*)menu_datafile
.get_resource_dat("ABOUT_BACK_SOUND"); // back sound
542 mtracer
.add("CGameMenu::do_about_stuff() -- ERROR!!! Can't create dbuf bitmap!");
546 #define LINES_SIZE 30
547 string about_txt
[LINES_SIZE
]; // current lines of about text
549 DATAFILE
*datastream
; // data stream for reading about text
551 char *readstream
; // stream for reading about text
553 int xstream
= 0; // where I'm reading the stream?
555 datastream
= menu_datafile
.get_resource("ABOUT_TEXT"); // get about text
557 readstream
= (char *)datastream
->dat
;
559 int text_shift_y
= 0; // y displacement for smooth text movement
562 if (snd_loop_sample
!= NULL
)
563 play_sample(snd_loop_sample
, 255, 128, 1000, TRUE
);
567 while (!keypressed())
569 blit(back
, dbuf
, 0, 0, 0, 0, back
->w
, back
->h
);
571 if (text_shift_y
> text_height(font_about
))
575 // shift 1 up all text in string array
576 for (int i
= 0; i
< LINES_SIZE
- 1; i
++)
578 about_txt
[i
] = about_txt
[i
+ 1];
581 // take input from user
582 about_txt
[LINES_SIZE
- 1] = "";
584 while (xstream
< datastream
->size
&& readstream
[xstream
] > 13)
586 // read current line from stream
587 about_txt
[LINES_SIZE
- 1] = about_txt
[LINES_SIZE
- 1] + readstream
[xstream
];
591 while (xstream
< datastream
->size
&& readstream
[xstream
] <= 13)
592 xstream
++; // skip bad chars (CR, LF, etc)
594 if (xstream
>= datastream
->size
)
595 xstream
++; // if we reached end, keep counting, so the thing starts again
597 if (xstream
> datastream
->size
+ LINES_SIZE
)
598 xstream
= 0; // start again after a whole clear screen
603 int ytext
= -5 - (text_height(font_about
) / 2) - text_shift_y
; // starting (a little above screen top, to make the effect OK)
605 for (int i
= 0; i
< LINES_SIZE
; i
++)
608 // the text is rendered in a way so the text is outlined, thats why is rendered many times
610 //textout_centre(dbuf, font_about, about_txt[i].c_str(), SCREEN_W/2+2, ytext-2, makecol(0,0,200));
611 //textout_centre(dbuf, font_about, about_txt[i].c_str(), SCREEN_W/2+2, ytext+2, makecol(0,0,200));
612 //textout_centre(dbuf, font_about, about_txt[i].c_str(), SCREEN_W/2-2, ytext-2, makecol(0,0,200));
613 //textout_centre(dbuf, font_about, about_txt[i].c_str(),SCREEN_W/2-2, ytext+2, makecol(0,0,200));
615 textout_centre(dbuf
, font_about
, about_txt
[i
].c_str(), SCREEN_W
/ 2 + 3, ytext
+ 3, makecol(0, 0, 0));
617 textout_centre(dbuf
, font_about
, about_txt
[i
].c_str(), SCREEN_W
/ 2, ytext
, makecol(255, 255, 255));
618 ytext
+= text_height(font_about
);
621 text_shift_y
++; // this makes the 'smooth' scrolling possible :^O (/me pats himself on the back... good job boy...)
623 blit(dbuf
, screen
, 0, 0, 0, 0, back
->w
, back
->h
);
625 rest(7); // do a little pause (time in ms)
628 if (snd_loop_sample
!= NULL
)
629 stop_sample(snd_loop_sample
);
636 // ------------------------------------------------------------------
638 // ------------------------------------------------------------------
639 void CGameMenu::do_options_menu()
643 mtracer
.add("CGameMenu::do_options_menu() started\n");
645 char str
[4096], *home
= getenv("HOME");
648 snprintf(str
, sizeof(str
), "%s/.kball", home
);
649 mkdir(str
, S_IRWXU
| S_IRWXG
| S_IROTH
| S_IXOTH
);
650 snprintf(str
, sizeof(str
), "%s/.kball/kball.cfg", home
);
651 set_config_file(str
);
655 set_config_file("kball.cfg");
658 menu
.control
.load_configuration_of_controller("KBALL_CONTROLLER");
659 game_kernel
.player_ball
.control
.load_configuration_of_controller("KBALL_CONTROLLER");
661 menu
.set_to_bitmap(screen
);
662 menu
.set_back_bitmap(menu_back
);
663 menu
.set_callback_drawer(menu_callback_animation
);
665 menu
.set_xywh(SCREEN_W
/ 2, 100, SCREEN_W
, SCREEN_H
);
666 menu
.item_y_separation
= 5;
668 menu
.set_font_s((FONT
*)menu_datafile
.get_resource_dat("MENU_FONT_MEDIUM"));
669 menu
.set_fg_color_s(makecol(255, 255, 255));
670 menu
.set_bg_color_s(makecol(0, 0, 200));
672 menu
.set_font_ns((FONT
*)menu_datafile
.get_resource_dat("MENU_FONT_MEDIUM"));
673 menu
.set_fg_color_ns(makecol(128, 128, 128));
674 menu
.set_bg_color_ns( -1);
678 menu
.clear_menu_list();
680 if (game_kernel
.player_ball
.control
.use_keyboard
)
681 menu
.add_item_to_menu("Keyboard is ON");
683 menu
.add_item_to_menu("Keyboard is OFF");
685 menu
.add_item_to_menu("Configure Keyboard");
687 if (game_kernel
.player_ball
.control
.use_mouse
)
688 menu
.add_item_to_menu("Mouse is ON");
690 menu
.add_item_to_menu("Mouse is OFF");
692 menu
.add_item_to_menu("Configure Mouse");
694 if (game_kernel
.player_ball
.control
.use_joystick
)
695 menu
.add_item_to_menu("Joystick is ON");
697 menu
.add_item_to_menu("Joystick is OFF");
699 menu
.add_item_to_menu("Configure Joystick");
701 if (CSoundWrapper::global_is_enabled())
702 menu
.add_item_to_menu("Sound is ON");
704 menu
.add_item_to_menu("Sound is OFF");
708 usprintf(tmpstrvol
, "Sound volume %3d%%", CSoundWrapper::global_get_volume()*100/255);
709 menu
.add_item_to_menu(tmpstrvol
);
711 menu
.add_item_to_menu("< Return >");
713 char str
[4096], *home
= getenv("HOME");
716 snprintf(str
, sizeof(str
), "%s/.kball", home
);
717 mkdir(str
, S_IRWXU
| S_IRWXG
| S_IROTH
| S_IXOTH
);
718 snprintf(str
, sizeof(str
), "%s/.kball/kball.cfg", home
);
719 set_config_file(str
);
723 set_config_file("kball.cfg");
726 menu
.control
.load_configuration_of_controller("KBALL_CONTROLLER");
728 soundw
.music_resume();
730 ret
= menu
.do_the_menu(ret
);
732 soundw
.music_pause();
737 case 0: // toggle keyboard
738 game_kernel
.player_ball
.control
.use_keyboard
= !game_kernel
.player_ball
.control
.use_keyboard
;
741 case 1: // configure keyb
742 blit (bmp_real_background
, screen
, 0, 0, 0, 0, bmp_real_background
->w
, bmp_real_background
->h
);
743 game_kernel
.player_ball
.control
.interactive_configuration_keyboard((FONT
*)menu_datafile
.get_resource_dat("MENU_FONT_SMALL"), makecol(0, 255, 255));
746 case 2: // toggle mouse
747 game_kernel
.player_ball
.control
.use_mouse
= !game_kernel
.player_ball
.control
.use_mouse
;
750 case 3: // configure mouse
751 blit (bmp_real_background
, screen
, 0, 0, 0, 0, bmp_real_background
->w
, bmp_real_background
->h
);
752 game_kernel
.player_ball
.control
.interactive_configuration_mouse((FONT
*)menu_datafile
.get_resource_dat("MENU_FONT_SMALL"), makecol(0, 255, 255));
755 case 4: // toggle joystick
756 game_kernel
.player_ball
.control
.use_joystick
= !game_kernel
.player_ball
.control
.use_joystick
;
759 case 5: // configure joy
760 blit (bmp_real_background
, screen
, 0, 0, 0, 0, bmp_real_background
->w
, bmp_real_background
->h
);
761 game_kernel
.player_ball
.control
.interactive_configuration_joystick((FONT
*)menu_datafile
.get_resource_dat("MENU_FONT_SMALL"), makecol(0, 255, 255));
765 CSoundWrapper::global_set_enabled(!CSoundWrapper::global_is_enabled());
768 case 7: // toggle sound volume
771 int v
= CSoundWrapper::global_get_volume();
777 CSoundWrapper::global_set_volume(v
);
779 soundw
.music_stop(); // DEBUG - MUSIC GLITCH TO AJUST MUSIC ; THIS IS ALMOST A BUG
780 soundw
.music_start();
786 home
= getenv("HOME");
789 snprintf(str
, sizeof(str
), "%s/.kball", home
);
790 mkdir(str
, S_IRWXU
| S_IRWXG
| S_IROTH
| S_IXOTH
);
791 snprintf(str
, sizeof(str
), "%s/.kball/kball.cfg", home
);
792 set_config_file(str
);
796 set_config_file("kball.cfg");
799 game_kernel
.player_ball
.control
.save_configuration_of_controller("KBALL_CONTROLLER");