Config Class Reference

#include <gameconfig.hpp>

List of all members.

Public Member Functions

 Config ()
 ~Config ()
void load ()
void save ()

Public Attributes

int profile
Size fullscreen_size
Size window_size
 the width/height of the window managers window
Size aspect_size
 the aspect ratio
float magnification
bool use_fullscreen
VideoSystem::Enum video
bool try_vsync
bool show_fps
bool sound_enabled
bool music_enabled
bool console_enabled
int random_seed
std::string start_level
 this variable is set if supertux should start in a specific level
bool enable_script_debugger
std::string start_demo
std::string record_demo
std::string locale
 force SuperTux language to this locale, e.g.


Detailed Description

Definition at line 23 of file gameconfig.hpp.


Constructor & Destructor Documentation

Config::Config (  ) 

Definition at line 28 of file gameconfig.cpp.

00028                :
00029   profile(1),
00030   fullscreen_size(800, 600),
00031   window_size(800, 600),
00032   aspect_size(0, 0), // auto detect
00033   magnification(0.0f),
00034   use_fullscreen(false),
00035   video(VideoSystem::AUTO_VIDEO),
00036   try_vsync(true),
00037   show_fps(false),
00038   sound_enabled(true),
00039   music_enabled(true),
00040   console_enabled(false),
00041   random_seed(0),          // set by time(), by default (unless in config)
00042   start_level(),
00043   enable_script_debugger(false),
00044   start_demo(),
00045   record_demo(),
00046   locale()
00047 {
00048 }

Config::~Config (  ) 

Definition at line 50 of file gameconfig.cpp.

00051 {}


Member Function Documentation

void Config::load (  ) 

Definition at line 54 of file gameconfig.cpp.

References aspect_size, console_enabled, fullscreen_size, g_jk_controller, lisp::Lisp::get(), AddonManager::get_instance(), lisp::Lisp::get_lisp(), VideoSystem::get_video_system(), Size::height, locale, magnification, music_enabled, lisp::Parser::parse(), random_seed, AddonManager::read(), JoystickKeyboardController::read(), show_fps, sound_enabled, try_vsync, use_fullscreen, video, Size::width, and window_size.

Referenced by Main::init_config().

00055 {
00056   lisp::Parser parser;
00057   const lisp::Lisp* root = parser.parse("config");
00058 
00059   const lisp::Lisp* config_lisp = root->get_lisp("supertux-config");
00060   if(!config_lisp)
00061     throw std::runtime_error("File is not a supertux-config file");
00062 
00063   config_lisp->get("show_fps", show_fps);
00064   config_lisp->get("console", console_enabled);
00065   config_lisp->get("locale", locale);
00066   config_lisp->get("random_seed", random_seed);
00067 
00068   const lisp::Lisp* config_video_lisp = config_lisp->get_lisp("video");
00069   if(config_video_lisp) {
00070     config_video_lisp->get("fullscreen", use_fullscreen);
00071     std::string video_string;
00072     config_video_lisp->get("video", video_string);
00073     video = VideoSystem::get_video_system(video_string);
00074     config_video_lisp->get("vsync", try_vsync);
00075 
00076     config_video_lisp->get("fullscreen_width",  fullscreen_size.width);
00077     config_video_lisp->get("fullscreen_height", fullscreen_size.height);
00078 
00079     config_video_lisp->get("window_width",  window_size.width);
00080     config_video_lisp->get("window_height", window_size.height);
00081 
00082     config_video_lisp->get("aspect_width",  aspect_size.width);
00083     config_video_lisp->get("aspect_height", aspect_size.height);
00084     
00085     config_video_lisp->get("magnification", magnification);
00086   }
00087 
00088   const lisp::Lisp* config_audio_lisp = config_lisp->get_lisp("audio");
00089   if(config_audio_lisp) {
00090     config_audio_lisp->get("sound_enabled", sound_enabled);
00091     config_audio_lisp->get("music_enabled", music_enabled);
00092   }
00093 
00094   const lisp::Lisp* config_control_lisp = config_lisp->get_lisp("control");
00095   if(config_control_lisp && g_jk_controller) {
00096     g_jk_controller->read(*config_control_lisp);
00097   }
00098 
00099   const lisp::Lisp* config_addons_lisp = config_lisp->get_lisp("addons");
00100   if(config_addons_lisp) {
00101     AddonManager::get_instance().read(*config_addons_lisp);
00102   }
00103 }

void Config::save (  ) 

Definition at line 106 of file gameconfig.cpp.

References aspect_size, console_enabled, lisp::Writer::end_list(), fullscreen_size, g_jk_controller, AddonManager::get_instance(), VideoSystem::get_video_string(), Size::height, locale, magnification, music_enabled, show_fps, sound_enabled, lisp::Writer::start_list(), try_vsync, use_fullscreen, video, Size::width, window_size, AddonManager::write(), JoystickKeyboardController::write(), and lisp::Writer::write().

Referenced by OptionsMenu::menu_action(), LanguageMenu::menu_action(), ScreenManager::process_events(), and Main::run().

00107 {
00108   lisp::Writer writer("config");
00109 
00110   writer.start_list("supertux-config");
00111 
00112   writer.write("show_fps", show_fps);
00113   writer.write("console", console_enabled);
00114   writer.write("locale", locale);
00115 
00116   writer.start_list("video");
00117   writer.write("fullscreen", use_fullscreen);
00118   writer.write("video", VideoSystem::get_video_string(video));
00119   writer.write("vsync", try_vsync);
00120 
00121   writer.write("fullscreen_width",  fullscreen_size.width);
00122   writer.write("fullscreen_height", fullscreen_size.height);
00123 
00124   writer.write("window_width",  window_size.width);
00125   writer.write("window_height", window_size.height);
00126 
00127   writer.write("aspect_width",  aspect_size.width);
00128   writer.write("aspect_height", aspect_size.height);
00129   
00130   writer.write("magnification", magnification);
00131 
00132   writer.end_list("video");
00133 
00134   writer.start_list("audio");
00135   writer.write("sound_enabled", sound_enabled);
00136   writer.write("music_enabled", music_enabled);
00137   writer.end_list("audio");
00138 
00139   if(g_jk_controller) {
00140     writer.start_list("control");
00141     g_jk_controller->write(writer);
00142     writer.end_list("control");
00143   }
00144 
00145   writer.start_list("addons");
00146   AddonManager::get_instance().write(writer);
00147   writer.end_list("addons");
00148 
00149   writer.end_list("supertux-config");
00150 }


Member Data Documentation

int Config::profile

Definition at line 32 of file gameconfig.hpp.

Referenced by ProfileMenu::menu_action(), and TitleScreen::start_game().

Size Config::fullscreen_size

Definition at line 35 of file gameconfig.hpp.

Referenced by GLRenderer::apply_config(), GLRenderer::GLRenderer(), Main::init_video(), load(), OptionsMenu::menu_action(), OptionsMenu::OptionsMenu(), Main::parse_commandline(), and save().

Size Config::window_size

the width/height of the window managers window

Definition at line 38 of file gameconfig.hpp.

Referenced by GLRenderer::apply_config(), GLRenderer::GLRenderer(), Main::init_video(), load(), Main::parse_commandline(), GLRenderer::resize(), and save().

Size Config::aspect_size

the aspect ratio

Definition at line 41 of file gameconfig.hpp.

Referenced by GLRenderer::apply_config(), Main::init_video(), load(), OptionsMenu::menu_action(), OptionsMenu::OptionsMenu(), Main::parse_commandline(), and save().

float Config::magnification

Definition at line 43 of file gameconfig.hpp.

Referenced by GLRenderer::apply_config(), load(), OptionsMenu::menu_action(), OptionsMenu::OptionsMenu(), and save().

bool Config::use_fullscreen

Definition at line 45 of file gameconfig.hpp.

Referenced by GLRenderer::apply_config(), GLRenderer::GLRenderer(), Main::init_video(), load(), OptionsMenu::menu_action(), OptionsMenu::OptionsMenu(), Main::parse_commandline(), ScreenManager::process_events(), save(), and SDLRenderer::SDLRenderer().

VideoSystem::Enum Config::video

Definition at line 46 of file gameconfig.hpp.

Referenced by load(), VideoSystem::new_lightmap(), VideoSystem::new_renderer(), VideoSystem::new_surface_data(), VideoSystem::new_texture(), Main::parse_commandline(), and save().

bool Config::try_vsync

Definition at line 47 of file gameconfig.hpp.

Referenced by load(), and save().

bool Config::show_fps

Definition at line 48 of file gameconfig.hpp.

Referenced by scripting::debug_show_fps(), ScreenManager::draw(), load(), Main::parse_commandline(), ScreenManager::process_events(), and save().

bool Config::sound_enabled

Definition at line 49 of file gameconfig.hpp.

Referenced by Main::init_audio(), load(), OptionsMenu::menu_action(), OptionsMenu::OptionsMenu(), Main::parse_commandline(), and save().

bool Config::music_enabled

Definition at line 50 of file gameconfig.hpp.

Referenced by Main::init_audio(), load(), OptionsMenu::menu_action(), OptionsMenu::OptionsMenu(), Main::parse_commandline(), and save().

bool Config::console_enabled

Definition at line 51 of file gameconfig.hpp.

Referenced by KeyboardMenu::KeyboardMenu(), load(), Main::parse_commandline(), ScreenManager::process_events(), save(), Console::show(), and KeyboardMenu::update().

int Config::random_seed

Definition at line 53 of file gameconfig.hpp.

Referenced by Main::init_rand(), load(), scripting::play_demo(), GameSession::record_demo(), GameSession::restart_level(), and Main::run().

std::string Config::start_level

this variable is set if supertux should start in a specific level

Definition at line 56 of file gameconfig.hpp.

Referenced by Main::parse_commandline(), and Main::run().

bool Config::enable_script_debugger

Definition at line 57 of file gameconfig.hpp.

Referenced by Main::parse_commandline(), and Main::run().

std::string Config::start_demo

Definition at line 58 of file gameconfig.hpp.

Referenced by Main::parse_commandline(), and Main::run().

std::string Config::record_demo

Definition at line 59 of file gameconfig.hpp.

Referenced by Main::parse_commandline(), and Main::run().

std::string Config::locale

force SuperTux language to this locale, e.g.

"de". A file "data/locale/xx.po" must exist for this to work. An empty string means autodetect.

Definition at line 61 of file gameconfig.hpp.

Referenced by Main::init_tinygettext(), load(), LanguageMenu::menu_action(), lisp::Parser::Parser(), and save().


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 03:38:29 2014 for SuperTux by  doxygen 1.5.1