From e44ac903d36dd5fd1a9b5061b9b07fc95a770af5 Mon Sep 17 00:00:00 2001 From: auria Date: Mon, 12 Jan 2009 00:49:25 +0000 Subject: [PATCH] added support for by-menu bg pictures git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2882 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- data/stk_config.data | 3 ++- src/gui/menu_manager.cpp | 6 ++++++ src/gui/menu_manager.hpp | 3 ++- src/main_loop.cpp | 19 +++++++++++++++---- src/stk_config.cpp | 6 ++++++ src/stk_config.hpp | 6 ++++-- 6 files changed, 35 insertions(+), 8 deletions(-) diff --git a/data/stk_config.data b/data/stk_config.data index 1a2c93df7..4922ea50f 100644 --- a/data/stk_config.data +++ b/data/stk_config.data @@ -10,7 +10,8 @@ ;; points 1st, 0 is least points ;; 1st (title-music "main_theme.music") - (menu-background "st_title_screen.rgb") + (mainmenu-background "st_title_screen.rgb") + (menu-background "menu_background.rgb") (game-style "nitro") ;; "wheelie" or "nitro" (max-history 10000) ;; maximum number of history frames. (max-skidmarks 100) ;; max. number of skidmarks per kart. diff --git a/src/gui/menu_manager.cpp b/src/gui/menu_manager.cpp index 542e9ed51..04e49532e 100644 --- a/src/gui/menu_manager.cpp +++ b/src/gui/menu_manager.cpp @@ -120,6 +120,12 @@ void MenuManager::pushMenu(MenuManagerIDs id) m_change_menu = true; } +//----------------------------------------------------------------------------- +const bool MenuManager::isMainMenuActive() const +{ + return m_menu_stack[ m_menu_stack.size()-1 ].first == MENUID_MAINMENU; +} + //----------------------------------------------------------------------------- void MenuManager::popMenu() { diff --git a/src/gui/menu_manager.hpp b/src/gui/menu_manager.hpp index 0075ef7ce..7541a846a 100644 --- a/src/gui/menu_manager.hpp +++ b/src/gui/menu_manager.hpp @@ -92,7 +92,8 @@ public: BaseGUI* getCurrentMenu() const {return m_current_menu;} RaceGUI* getRaceMenu () const {return (RaceGUI*)m_RaceGUI;} void update(); - + const bool isMainMenuActive() const; + private: std::vector< std::pair > m_menu_stack; diff --git a/src/main_loop.cpp b/src/main_loop.cpp index e31353db8..b2bbf33b2 100644 --- a/src/main_loop.cpp +++ b/src/main_loop.cpp @@ -61,9 +61,13 @@ MainLoop::~MainLoop() */ void MainLoop::run() { - const GLuint TITLE_SCREEN_TEXTURE = + 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(); - + + bool music_on = false; m_curr_time = SDL_GetTicks(); float dt; @@ -181,9 +185,16 @@ void MainLoop::run() // usleep(2000); #endif + + + //Draw the splash screen - glBindTexture(GL_TEXTURE_2D,TITLE_SCREEN_TEXTURE); - + + if(menu_manager->isMainMenuActive()) + glBindTexture(GL_TEXTURE_2D, TITLE_SCREEN_TEXTURE); + else + glBindTexture(GL_TEXTURE_2D, MENUS_BG_TEXTURE); + glBegin ( GL_QUADS ) ; glColor3f (1, 1, 1 ) ; glTexCoord2f(0, 0); glVertex2i(-1, -1); diff --git a/src/stk_config.cpp b/src/stk_config.cpp index ac25191a9..d5e72fb11 100644 --- a/src/stk_config.cpp +++ b/src/stk_config.cpp @@ -89,6 +89,11 @@ void STKConfig::load(const std::string &filename) fprintf(stderr,"No menu background defined in stk_config"); exit(-1); } + if(m_mainmenu_background.size()==0) + { + fprintf(stderr,"No mainmenu background defined in stk_config"); + exit(-1); + } CHECK_NEG(m_max_karts, "max-karts" ); CHECK_NEG(m_grid_order, "grid-order" ); CHECK_NEG(m_parachute_friction, "parachute-friction" ); @@ -177,6 +182,7 @@ void STKConfig::getAllData(const lisp::Lisp* lisp) 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->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 4de778981..7b1a2a372 100644 --- a/src/stk_config.hpp +++ b/src/stk_config.hpp @@ -81,8 +81,10 @@ public: MusicInformation *m_title_music; /**