projects
/
supertux.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Initial integration, lots of broken stuff
[supertux.git]
/
src
/
gameconfig.cpp
diff --git
a/src/gameconfig.cpp
b/src/gameconfig.cpp
index
18c2dd2
..
4972804
100644
(file)
--- 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
//
// SuperTux - A Jump'n Run
-// Copyright (C) 200
4 Michael George <mike@georgetech.com
>
+// Copyright (C) 200
6 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
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@
-18,43
+18,40
@@
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <config.h>
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <config.h>
-#include "gameconfig.h"
+#include "gameconfig.h
pp
"
-#include <
cstdlib
>
+#include <
stdlib.h
>
#include <string>
#include <stdexcept>
#include <string>
#include <stdexcept>
-#include <sstream>
-#include <fstream>
-#include "app/setup.h"
-#include "app/globals.h"
-#include "audio/sound_manager.h"
-#include "lisp/parser.h"
-#include "lisp/lisp.h"
-#include "lisp/writer.h"
-#include "control/joystickkeyboardcontroller.h"
-#include "main.h"
-
-using namespace SuperTux;
+#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;
Config::Config()
{
use_fullscreen = true;
Config* config = 0;
Config::Config()
{
use_fullscreen = true;
+ //video = AUTO_VIDEO;
+ video = "auto";
+ try_vsync = true;
show_fps = false;
sound_enabled = true;
music_enabled = 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;
screenwidth = 800;
screenheight = 600;
- use_gl = true;
+ aspect_ratio = -1; // autodetect
+
+ enable_script_debugger = false;
- audio_frequency = MIX_DEFAULT_FREQUENCY;
- audio_channels = MIX_DEFAULT_CHANNELS;
- audio_chunksize = 2048;
- audio_voices = MIX_CHANNELS;
+ locale = ""; // autodetect
}
Config::~Config()
}
Config::~Config()
@@
-64,30
+61,34
@@
void
Config::load()
{
lisp::Parser parser;
Config::load()
{
lisp::Parser parser;
-
std::auto_ptr<lisp::Lisp> root (parser.parse(user_dir + "/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);
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("locale", locale);
+ 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);
const lisp::Lisp* config_video_lisp = config_lisp->get_lisp("video");
if(config_video_lisp) {
config_video_lisp->get("fullscreen", use_fullscreen);
+ //std::string video_string;
+ //config_video_lisp->get("video", video_string);
+ //video = get_video_system(video_string);
+ config_video_lisp->get("video", video);
+ config_video_lisp->get("vsync", try_vsync);
config_video_lisp->get("width", screenwidth);
config_video_lisp->get("height", screenheight);
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");
if(config_audio_lisp) {
config_audio_lisp->get("sound_enabled", sound_enabled);
config_audio_lisp->get("music_enabled", music_enabled);
}
const lisp::Lisp* config_audio_lisp = config_lisp->get_lisp("audio");
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");
}
const lisp::Lisp* config_control_lisp = config_lisp->get_lisp("control");
@@
-99,33
+100,27
@@
Config::load()
void
Config::save()
{
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");
writer.write_bool("show_fps", show_fps);
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.write_string("locale", locale);
writer.start_list("video");
writer.write_bool("fullscreen", use_fullscreen);
writer.start_list("video");
writer.write_bool("fullscreen", use_fullscreen);
+ //writer.write_string("video", get_video_string(video));
+ writer.write_string("video", video);
+ writer.write_bool("vsync", try_vsync);
writer.write_int("width", screenwidth);
writer.write_int("height", screenheight);
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");
writer.write_bool("sound_enabled", sound_enabled);
writer.write_bool("music_enabled", music_enabled);
writer.end_list("video");
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) {
writer.end_list("audio");
if(main_controller) {
@@
-133,6
+128,6
@@
Config::save()
main_controller->write(writer);
writer.end_list("control");
}
main_controller->write(writer);
writer.end_list("control");
}
-
+
writer.end_list("supertux-config");
}
writer.end_list("supertux-config");
}