X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fgameconfig.cpp;h=f4c28ca18b5bd7c44cabe51feaedb720f8c915d9;hb=69be5aee32ec5b3eb1c65f4569f92746cc8d294c;hp=2387c8cf88329d3f5b93d399daf7293cba5c8b04;hpb=60908c905544776c376421b8d3e12eeb936c068f;p=supertux.git diff --git a/src/gameconfig.cpp b/src/gameconfig.cpp index 2387c8cf8..f4c28ca18 100644 --- a/src/gameconfig.cpp +++ b/src/gameconfig.cpp @@ -1,7 +1,7 @@ -// $Id: configfile.cpp 2212 2004-11-28 14:57:45Z matzebraun $ +// $Id$ // // SuperTux - A Jump'n Run -// Copyright (C) 2004 Michael George +// Copyright (C) 2006 Matthias Braun // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -18,21 +18,18 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include -#include "gameconfig.h" +#include "gameconfig.hpp" #include #include #include -#include -#include -#include "audio/sound_manager.h" -#include "lisp/parser.h" -#include "lisp/lisp.h" -#include "lisp/writer.h" -#include "control/joystickkeyboardcontroller.h" -#include "resources.h" -#include "main.h" +#include "lisp/parser.hpp" +#include "lisp/lisp.hpp" +#include "lisp/writer.hpp" +#include "control/joystickkeyboardcontroller.hpp" +#include "resources.hpp" +#include "main.hpp" Config* config = 0; @@ -43,15 +40,12 @@ Config::Config() sound_enabled = true; music_enabled = true; cheats_enabled = false; + random_seed = 0; // set by time(), by default (unless in config) screenwidth = 800; screenheight = 600; - use_gl = true; - audio_frequency = MIX_DEFAULT_FREQUENCY; - audio_channels = MIX_DEFAULT_CHANNELS; - audio_chunksize = 2048; - audio_voices = MIX_CHANNELS; + enable_script_debugger = false; } Config::~Config() @@ -61,7 +55,7 @@ void Config::load() { lisp::Parser parser; - std::auto_ptr root (parser.parse(user_dir + "/config")); + std::auto_ptr root (parser.parse("config")); const lisp::Lisp* config_lisp = root->get_lisp("supertux-config"); if(!config_lisp) @@ -69,6 +63,7 @@ Config::load() config_lisp->get("show_fps", show_fps); config_lisp->get("cheats", cheats_enabled); + config_lisp->get("random_seed", random_seed); const lisp::Lisp* config_video_lisp = config_lisp->get_lisp("video"); if(config_video_lisp) { @@ -81,10 +76,6 @@ Config::load() if(config_audio_lisp) { config_audio_lisp->get("sound_enabled", sound_enabled); config_audio_lisp->get("music_enabled", music_enabled); - config_audio_lisp->get("frequency", audio_frequency); - config_audio_lisp->get("channels", audio_channels); - config_audio_lisp->get("voices", audio_voices); - config_audio_lisp->get("chunksize", audio_chunksize); } const lisp::Lisp* config_control_lisp = config_lisp->get_lisp("control"); @@ -96,14 +87,7 @@ Config::load() void Config::save() { - std::string configfile = user_dir + "/config"; - std::ofstream file( (user_dir + "/config").c_str() ); - if(!file.good()) { - std::stringstream msg; - msg << "Couldn't write config file '" << configfile << "'"; - throw std::runtime_error(msg.str()); - } - lisp::Writer writer(file); + lisp::Writer writer("config"); writer.start_list("supertux-config"); @@ -119,10 +103,6 @@ Config::save() writer.start_list("audio"); writer.write_bool("sound_enabled", sound_enabled); writer.write_bool("music_enabled", music_enabled); - writer.write_int("frequency", audio_frequency); - writer.write_int("channels", audio_channels); - writer.write_int("voices", audio_voices); - writer.write_int("chunksize", audio_chunksize); writer.end_list("audio"); if(main_controller) { @@ -130,6 +110,6 @@ Config::save() main_controller->write(writer); writer.end_list("control"); } - + writer.end_list("supertux-config"); }