[Super-tux-commit] supertux/lib/utils configfile.cpp,1.3,1.4 configfile.h,1.3,1.4 lispreader.cpp,1.3
Brought to you by:
wkendrick
From: Tobias G. <to...@us...> - 2004-07-25 19:03:43
|
Update of /cvsroot/super-tux/supertux/lib/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31225/lib/utils Modified Files: configfile.cpp configfile.h lispreader.cpp Log Message: - Major changes in Setup-API. - Moved all sound handling into SoundManager, which became a singleton. Index: configfile.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/configfile.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- configfile.h 22 Jul 2004 19:07:51 -0000 1.3 +++ configfile.h 25 Jul 2004 19:03:35 -0000 1.4 @@ -24,6 +24,8 @@ namespace SuperTux { +FILE * opendata(const char * filename, const char * mode); + class Config { public: void load (); Index: lispreader.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/lispreader.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- lispreader.cpp 22 Jul 2004 19:07:51 -0000 1.3 +++ lispreader.cpp 25 Jul 2004 19:03:35 -0000 1.4 @@ -1132,7 +1132,7 @@ return false; if (!lisp_real_p(lisp_car(obj)) && !lisp_integer_p(lisp_car(obj))) - st_abort("LispReader expected type real at token: ", name); + Termination::abort("LispReader expected type real at token: ", name); f = lisp_real(lisp_car(obj)); return true; @@ -1149,7 +1149,7 @@ while(!lisp_nil_p(obj)) { if (!lisp_string_p(lisp_car(obj))) - st_abort("LispReader expected type string at token: ", name); + Termination::abort("LispReader expected type string at token: ", name); vec.push_back(lisp_string(lisp_car(obj))); obj = lisp_cdr(obj); } @@ -1167,7 +1167,7 @@ while(!lisp_nil_p(obj)) { if (!lisp_integer_p(lisp_car(obj))) - st_abort("LispReader expected type integer at token: ", name); + Termination::abort("LispReader expected type integer at token: ", name); vec.push_back(lisp_integer(lisp_car(obj))); obj = lisp_cdr(obj); } @@ -1185,7 +1185,7 @@ while(!lisp_nil_p(obj)) { if (!lisp_integer_p(lisp_car(obj))) - st_abort("LispReader expected type integer at token: ", name); + Termination::abort("LispReader expected type integer at token: ", name); vec.push_back(lisp_integer(lisp_car(obj))); obj = lisp_cdr(obj); } @@ -1253,7 +1253,7 @@ return false; if (!lisp_string_p(lisp_car(obj))) - st_abort("LispReader expected type string at token: ", name); + Termination::abort("LispReader expected type string at token: ", name); str = lisp_string(lisp_car(obj)); return true; } @@ -1266,7 +1266,7 @@ return false; if (!lisp_boolean_p(lisp_car(obj))) - st_abort("LispReader expected type bool at token: ", name); + Termination::abort("LispReader expected type bool at token: ", name); b = lisp_boolean(lisp_car(obj)); return true; } Index: configfile.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/configfile.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- configfile.cpp 22 Jul 2004 19:07:51 -0000 1.3 +++ configfile.cpp 25 Jul 2004 19:03:35 -0000 1.4 @@ -23,6 +23,7 @@ #include "../utils/configfile.h" #include "../app/setup.h" #include "../app/globals.h" +#include "../audio/sound_manager.h" using namespace SuperTux; @@ -38,14 +39,44 @@ { /* Set defaults: */ debug_mode = false; - audio_device = true; + SoundManager::get()->set_audio_device_available(true); use_fullscreen = false; show_fps = false; use_gl = false; - use_sound = true; - use_music = true; + SoundManager::get()->enable_sound(true); + SoundManager::get()->enable_music(true); +} + +FILE * SuperTux::opendata(const char * rel_filename, const char * mode) +{ + char * filename = NULL; + FILE * fi; + + filename = (char *) malloc(sizeof(char) * (strlen(st_dir) + + strlen(rel_filename) + 1)); + + strcpy(filename, st_dir); + /* Open the high score file: */ + + strcat(filename, rel_filename); + + /* Try opening the file: */ + fi = fopen(filename, mode); + + if (fi == NULL) + { + fprintf(stderr, "Warning: Unable to open the file \"%s\" ", filename); + + if (strcmp(mode, "r") == 0) + fprintf(stderr, "for read!!!\n"); + else if (strcmp(mode, "w") == 0) + fprintf(stderr, "for write!!!\n"); + } + free( filename ); + + return(fi); } void Config::load() @@ -78,8 +109,11 @@ LispReader reader(lisp_cdr(root_obj)); reader.read_bool("fullscreen", use_fullscreen); - reader.read_bool("sound", use_sound); - reader.read_bool("music", use_music); + bool temp; + reader.read_bool("sound", temp); + SoundManager::get()->enable_sound(temp); + reader.read_bool("music", temp); + SoundManager::get()->enable_music(temp); reader.read_bool("show_fps", show_fps); std::string video; @@ -116,8 +150,8 @@ fprintf(config, "(supertux-config\n"); fprintf(config, "\t;; the following options can be set to #t or #f:\n"); fprintf(config, "\t(fullscreen %s)\n", use_fullscreen ? "#t" : "#f"); - fprintf(config, "\t(sound %s)\n", use_sound ? "#t" : "#f"); - fprintf(config, "\t(music %s)\n", use_music ? "#t" : "#f"); + fprintf(config, "\t(sound %s)\n", SoundManager::get()->sound_enabled() ? "#t" : "#f"); + fprintf(config, "\t(music %s)\n", SoundManager::get()->music_enabled() ? "#t" : "#f"); fprintf(config, "\t(show_fps %s)\n", show_fps ? "#t" : "#f"); fprintf(config, "\n\t;; either \"opengl\" or \"sdl\"\n"); |