// $Id$ // // SuperTuxKart - a fun racing game with go-kart // Copyright (C) 2006 Joerg Henrichs // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 3 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stk_config.hpp" #include #include #include #include "io/file_manager.hpp" #include "lisp/parser.hpp" #include "audio/music_information.hpp" STKConfig* stk_config=0; float STKConfig::UNDEFINED = -99.9f; //----------------------------------------------------------------------------- /** Loads the stk configuration file. After loading it checks if all necessary * values are actually defined, otherwise an error message is printed and STK * is aborted. * /param filename Name of the configuration file to load. */ void STKConfig::load(const std::string &filename) { const lisp::Lisp* root = 0; try { lisp::Parser parser; root = parser.parse(filename); const lisp::Lisp* const LISP = root->getLisp("config"); if(!LISP) { std::ostringstream msg; msg<<"No 'config' node found in '"<=0 && n<(int)m_mainmenu_background.size()) return m_mainmenu_background[n]; else return m_mainmenu_background[0]; } // getMainMenuPicture //----------------------------------------------------------------------------- const std::string &STKConfig::getBackgroundPicture(int n) { if(n>=0 && n<(int)m_menu_background.size()) return m_menu_background[n]; else return m_menu_background[0]; } // getBackgroundPicture //----------------------------------------------------------------------------- /** Extracts the actual information from a lisp file. * \param lisp Pointer to the lisp data structure. */ void STKConfig::getAllData(const lisp::Lisp* lisp) { // Get the values which are not part of the default KartProperties // --------------------------------------------------------------- lisp->get("anvil-weight", m_anvil_weight ); lisp->get("final-camera-time", m_final_camera_time ); lisp->get("anvil-speed-factor", m_anvil_speed_factor ); lisp->get("parachute-friction", m_parachute_friction ); lisp->get("parachute-time", m_parachute_time ); lisp->get("parachute-time-other", m_parachute_time_other ); lisp->get("parachute-done-fraction", m_parachute_done_fraction ); lisp->get("bomb-time", m_bomb_time ); lisp->get("bomb-time-increase", m_bomb_time_increase ); lisp->getVector("leader-intervals", m_leader_intervals ); lisp->get("anvil-time", m_anvil_time ); lisp->get("zipper-time", m_zipper_time ); lisp->get("zipper-force", m_zipper_force ); lisp->get("zipper-speed-gain", m_zipper_speed_gain ); lisp->get("explosion-impulse", m_explosion_impulse ); lisp->get("explosion-impulse-objects", m_explosion_impulse_objects); lisp->get("max-karts", m_max_karts ); lisp->get("grid-order", m_grid_order ); lisp->getVector("scores", m_scores ); lisp->get("max-history", m_max_history ); lisp->get("max-skidmarks", m_max_skidmarks ); lisp->get("min-kart-version", m_min_kart_version ); lisp->get("max-kart-version", m_max_kart_version ); lisp->get("min-track-version", m_min_track_version ); lisp->get("max-track-version", m_max_track_version ); lisp->get("skid-fadeout-time", m_skid_fadeout_time ); lisp->get("slowdown-factor", m_slowdown_factor ); lisp->get("near-ground", m_near_ground ); lisp->get("delay-finish-time", m_delay_finish_time ); lisp->get("music-credit-time", m_music_credit_time ); lisp->getVector("menu-background", m_menu_background ); lisp->getVector("mainmenu-background", m_mainmenu_background ); lisp->get("enable_networking", m_enable_networking ); std::string title_music; lisp->get("title-music", title_music ); m_title_music = new MusicInformation(file_manager->getMusicFile(title_music)); // Get the default KartProperties // ------------------------------ m_kart_properties.getAllData(lisp->getLisp("kart-defaults")); } // getAllData