hack to make movingobject vs. static also call the collides function of the moving...
[supertux.git] / src / gameconfig.cpp
index 1e753b2..a1a8a3d 100644 (file)
@@ -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 <mike@georgetech.com>
+//  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
 //
 //  This program is free software; you can redistribute it and/or
 //  modify it under the terms of the GNU General Public License
 
 #include "gameconfig.hpp"
 
-#include <cstdlib>
+#include <stdlib.h>
 #include <string>
 #include <stdexcept>
-#include <sstream>
-#include <fstream>
 
 #include "lisp/parser.hpp"
 #include "lisp/lisp.hpp"
@@ -38,14 +36,18 @@ Config* config = 0;
 Config::Config()
 {
   use_fullscreen = true;
+  try_vsync = true;
   show_fps = false;
   sound_enabled = true;
   music_enabled = true;
-  cheats_enabled = false;
+  console_enabled = false;
+  random_seed = 0;          // set by time(), by default (unless in config)
 
   screenwidth = 800;
   screenheight = 600;
-  use_gl = true;
+  aspect_ratio = -1;       // autodetect
+
+  enable_script_debugger = false;
 }
 
 Config::~Config()
@@ -55,20 +57,23 @@ void
 Config::load()
 {
   lisp::Parser parser;
-  std::auto_ptr<lisp::Lisp> root (parser.parse("config"));
+  const lisp::Lisp* root = parser.parse("config");
 
   const lisp::Lisp* config_lisp = root->get_lisp("supertux-config");
   if(!config_lisp)
     throw std::runtime_error("File is not a supertux-config file");
 
   config_lisp->get("show_fps", show_fps);
-  config_lisp->get("cheats", cheats_enabled);
+  config_lisp->get("console", console_enabled);
+  config_lisp->get("random_seed", random_seed);
 
   const lisp::Lisp* config_video_lisp = config_lisp->get_lisp("video");
   if(config_video_lisp) {
     config_video_lisp->get("fullscreen", use_fullscreen);
+       config_video_lisp->get("vsync", try_vsync);
     config_video_lisp->get("width", screenwidth);
     config_video_lisp->get("height", screenheight);
+    config_video_lisp->get("aspect_ratio", aspect_ratio);
   }
 
   const lisp::Lisp* config_audio_lisp = config_lisp->get_lisp("audio");
@@ -91,12 +96,14 @@ Config::save()
   writer.start_list("supertux-config");
 
   writer.write_bool("show_fps", show_fps);
-  writer.write_bool("cheats", cheats_enabled);
+  writer.write_bool("console", console_enabled);
 
   writer.start_list("video");
   writer.write_bool("fullscreen", use_fullscreen);
+  writer.write_bool("vsync", try_vsync);
   writer.write_int("width", screenwidth);
   writer.write_int("height", screenheight);
+  writer.write_float("aspect_ratio", aspect_ratio);
   writer.end_list("video");
 
   writer.start_list("audio");
@@ -109,6 +116,6 @@ Config::save()
     main_controller->write(writer);
     writer.end_list("control");
   }
-  
+
   writer.end_list("supertux-config");
 }