diff --git a/data/stk_config.data b/data/stk_config.data index 4922ea50f..11686167c 100644 --- a/data/stk_config.data +++ b/data/stk_config.data @@ -10,9 +10,11 @@ ;; points 1st, 0 is least points ;; 1st (title-music "main_theme.music") - (mainmenu-background "st_title_screen.rgb") - (menu-background "menu_background.rgb") - (game-style "nitro") ;; "wheelie" or "nitro" + ;; Two lists which must have the same length, containing the list of all + ;; possible main menu and background images. + (mainmenu-background "st_title_screen.rgb" "st_title_screen2.rgb") + (menu-background "menu_background.rgb" "menu_background2.rgb") + (max-history 10000) ;; maximum number of history frames. (max-skidmarks 100) ;; max. number of skidmarks per kart. (skid-fadeout-time 60) ;; Time till skidm marks fade out diff --git a/src/gui/config_display.cpp b/src/gui/config_display.cpp index e43f6b73d..3e002a3d5 100644 --- a/src/gui/config_display.cpp +++ b/src/gui/config_display.cpp @@ -18,6 +18,8 @@ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "config_display.hpp" + +#include "main_loop.hpp" #include "widget_manager.hpp" #include "user_config.hpp" #include "menu_manager.hpp" @@ -35,6 +37,7 @@ enum WidgetTokens WTOK_TITLE, WTOK_FULLSCREEN, + WTOK_NEXT_BACKGROUND, WTOK_INCR_RES, WTOK_DECR_RES, WTOK_CURRENT_RES, @@ -78,12 +81,14 @@ ConfigDisplay::ConfigDisplay() } } + widget_manager->addTextButtonWgt(WTOK_NEXT_BACKGROUND, 60, 7, _("Next background")); widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 60, 2 ); char msg [MAX_MESSAGE_LENGTH]; //I18N: displays current resolution snprintf( msg, MAX_MESSAGE_LENGTH, _("Current: %dx%d"), m_curr_width, m_curr_height ); widget_manager->addTextWgt( WTOK_CURRENT_RES, 60, 7, msg); + widget_manager->hideWgtRect(WTOK_CURRENT_RES); widget_manager->addTextButtonWgt( WTOK_INCR_RES, 60, 7, _("Increase Resolution")); @@ -131,7 +136,10 @@ void ConfigDisplay::select() } changeApplyButton(); break; - + case WTOK_NEXT_BACKGROUND: + user_config->nextBackgroundIndex(); + main_loop->loadBackgroundImages(); + break; case WTOK_INCR_RES: { const int NUM_RES = (int)m_sizes.size(); diff --git a/src/main_loop.cpp b/src/main_loop.cpp index b2bbf33b2..9817979a5 100644 --- a/src/main_loop.cpp +++ b/src/main_loop.cpp @@ -19,15 +19,6 @@ #include "main_loop.hpp" -#ifdef __APPLE__ -# include -#else -# ifdef WIN32 -# define WIN32_LEAN_AND_MEAN -# include -# endif -# include -#endif #include #include #include "sdldrv.hpp" @@ -56,17 +47,23 @@ MainLoop::~MainLoop() { } // ~MainLoop +//----------------------------------------------------------------------------- +void MainLoop::loadBackgroundImages() +{ + int ind = user_config->getBackgroundIndex(); + const std::string &main = stk_config->getMainMenuPicture(ind); + m_title_screen_texture = material_manager->getMaterial(main)->getState()->getTextureHandle(); + + const std::string &background = stk_config->getBackgroundPicture(ind); + m_bg_texture = material_manager->getMaterial(background)->getState()->getTextureHandle(); +} // loadBackgroundImages + //----------------------------------------------------------------------------- /** Run the actual main loop. */ void MainLoop::run() { - static const GLuint TITLE_SCREEN_TEXTURE = - material_manager->getMaterial(stk_config->m_mainmenu_background)->getState()->getTextureHandle(); - - static const GLuint MENUS_BG_TEXTURE = - material_manager->getMaterial(stk_config->m_menu_background)->getState()->getTextureHandle(); - + loadBackgroundImages(); bool music_on = false; m_curr_time = SDL_GetTicks(); @@ -191,9 +188,9 @@ void MainLoop::run() //Draw the splash screen if(menu_manager->isMainMenuActive()) - glBindTexture(GL_TEXTURE_2D, TITLE_SCREEN_TEXTURE); + glBindTexture(GL_TEXTURE_2D, m_title_screen_texture); else - glBindTexture(GL_TEXTURE_2D, MENUS_BG_TEXTURE); + glBindTexture(GL_TEXTURE_2D, m_bg_texture); glBegin ( GL_QUADS ) ; glColor3f (1, 1, 1 ) ; diff --git a/src/main_loop.hpp b/src/main_loop.hpp index 302e4e4db..f72087a4c 100644 --- a/src/main_loop.hpp +++ b/src/main_loop.hpp @@ -19,6 +19,16 @@ #ifndef HEADER_MAIN_LOOP_HPP #define HEADER_MAIN_LOOP_HPP +#ifdef __APPLE__ +# include +#else +# ifdef WIN32 +# define WIN32_LEAN_AND_MEAN +# include +# endif +# include +#endif + #include /** Management class for the whole gameflow, this is where the @@ -31,12 +41,15 @@ private: int m_frame_count; Uint32 m_curr_time; Uint32 m_prev_time; + GLuint m_title_screen_texture; + GLuint m_bg_texture; public: MainLoop(); ~MainLoop(); void run(); void abort(); + void loadBackgroundImages(); }; // MainLoop extern MainLoop* main_loop; diff --git a/src/stk_config.cpp b/src/stk_config.cpp index d5e72fb11..83ba74427 100644 --- a/src/stk_config.cpp +++ b/src/stk_config.cpp @@ -147,6 +147,24 @@ void STKConfig::init_defaults() m_leader_intervals.clear(); } // init_defaults +//----------------------------------------------------------------------------- +const std::string &STKConfig::getMainMenuPicture(int n) +{ + if(n>=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. @@ -181,8 +199,8 @@ void STKConfig::getAllData(const lisp::Lisp* lisp) lisp->get("slowdown-factor", m_slowdown_factor ); lisp->get("delay-finish-time", m_delay_finish_time ); lisp->get("music-credit-time", m_music_credit_time ); - lisp->get("menu-background", m_menu_background ); - lisp->get("mainmenu-background", m_mainmenu_background ); + 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 ); diff --git a/src/stk_config.hpp b/src/stk_config.hpp index 7b1a2a372..f3c0b6d18 100644 --- a/src/stk_config.hpp +++ b/src/stk_config.hpp @@ -80,9 +80,9 @@ public: MusicInformation *m_title_music; /** m_mainmenu_background; /** m_menu_background; /** +#include "user_config.hpp" + +#include #include #include #include @@ -38,8 +40,8 @@ #define _WINSOCKAPI_ #include +#include "stk_config.hpp" #include "actionmap.hpp" -#include "user_config.hpp" #include "lisp/lisp.hpp" #include "lisp/parser.hpp" #include "lisp/writer.hpp" @@ -291,7 +293,15 @@ void UserConfig::setDefaults() } // setDefaults - +// ----------------------------------------------------------------------------- +/** Sets the next background image index. */ +void UserConfig::nextBackgroundIndex() +{ + m_background_index++; + if(m_background_index>=(int)stk_config->m_mainmenu_background.size()) + m_background_index = 0; +} + // ----------------------------------------------------------------------------- /** * load default configuration file for this platform diff --git a/src/user_config.hpp b/src/user_config.hpp index 5b65f2c66..6669c8557 100644 --- a/src/user_config.hpp +++ b/src/user_config.hpp @@ -244,8 +244,8 @@ public: /** Returns the default difficulty. */ int getDefaultDifficulty() const { return m_difficulty; } - /** Sets the index of the background image. */ - void setBackgroundIndex(int n) { m_background_index = n; } + void nextBackgroundIndex(); + /** Get the index of the background image. */ int getBackgroundIndex() const { return m_background_index; }