Added support (incl. gui) to change the menu background
pictures. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2888 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
cc79071ae0
commit
d1eea398a1
@ -10,9 +10,11 @@
|
|||||||
;; points 1st, 0 is least points
|
;; points 1st, 0 is least points
|
||||||
;; 1st
|
;; 1st
|
||||||
(title-music "main_theme.music")
|
(title-music "main_theme.music")
|
||||||
(mainmenu-background "st_title_screen.rgb")
|
;; Two lists which must have the same length, containing the list of all
|
||||||
(menu-background "menu_background.rgb")
|
;; possible main menu and background images.
|
||||||
(game-style "nitro") ;; "wheelie" or "nitro"
|
(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-history 10000) ;; maximum number of history frames.
|
||||||
(max-skidmarks 100) ;; max. number of skidmarks per kart.
|
(max-skidmarks 100) ;; max. number of skidmarks per kart.
|
||||||
(skid-fadeout-time 60) ;; Time till skidm marks fade out
|
(skid-fadeout-time 60) ;; Time till skidm marks fade out
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "config_display.hpp"
|
#include "config_display.hpp"
|
||||||
|
|
||||||
|
#include "main_loop.hpp"
|
||||||
#include "widget_manager.hpp"
|
#include "widget_manager.hpp"
|
||||||
#include "user_config.hpp"
|
#include "user_config.hpp"
|
||||||
#include "menu_manager.hpp"
|
#include "menu_manager.hpp"
|
||||||
@ -35,6 +37,7 @@ enum WidgetTokens
|
|||||||
WTOK_TITLE,
|
WTOK_TITLE,
|
||||||
|
|
||||||
WTOK_FULLSCREEN,
|
WTOK_FULLSCREEN,
|
||||||
|
WTOK_NEXT_BACKGROUND,
|
||||||
WTOK_INCR_RES,
|
WTOK_INCR_RES,
|
||||||
WTOK_DECR_RES,
|
WTOK_DECR_RES,
|
||||||
WTOK_CURRENT_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 );
|
widget_manager->addEmptyWgt( WidgetManager::WGT_NONE, 60, 2 );
|
||||||
|
|
||||||
char msg [MAX_MESSAGE_LENGTH];
|
char msg [MAX_MESSAGE_LENGTH];
|
||||||
//I18N: displays current resolution
|
//I18N: displays current resolution
|
||||||
snprintf( msg, MAX_MESSAGE_LENGTH, _("Current: %dx%d"), m_curr_width, m_curr_height );
|
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->addTextWgt( WTOK_CURRENT_RES, 60, 7, msg);
|
||||||
|
widget_manager->hideWgtRect(WTOK_CURRENT_RES);
|
||||||
|
|
||||||
widget_manager->addTextButtonWgt( WTOK_INCR_RES, 60, 7,
|
widget_manager->addTextButtonWgt( WTOK_INCR_RES, 60, 7,
|
||||||
_("Increase Resolution"));
|
_("Increase Resolution"));
|
||||||
@ -131,7 +136,10 @@ void ConfigDisplay::select()
|
|||||||
}
|
}
|
||||||
changeApplyButton();
|
changeApplyButton();
|
||||||
break;
|
break;
|
||||||
|
case WTOK_NEXT_BACKGROUND:
|
||||||
|
user_config->nextBackgroundIndex();
|
||||||
|
main_loop->loadBackgroundImages();
|
||||||
|
break;
|
||||||
case WTOK_INCR_RES:
|
case WTOK_INCR_RES:
|
||||||
{
|
{
|
||||||
const int NUM_RES = (int)m_sizes.size();
|
const int NUM_RES = (int)m_sizes.size();
|
||||||
|
@ -19,15 +19,6 @@
|
|||||||
|
|
||||||
#include "main_loop.hpp"
|
#include "main_loop.hpp"
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
# include <OpenGL/gl.h>
|
|
||||||
#else
|
|
||||||
# ifdef WIN32
|
|
||||||
# define WIN32_LEAN_AND_MEAN
|
|
||||||
# include <windows.h>
|
|
||||||
# endif
|
|
||||||
# include <GL/gl.h>
|
|
||||||
#endif
|
|
||||||
#include <SDL/SDL.h>
|
#include <SDL/SDL.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include "sdldrv.hpp"
|
#include "sdldrv.hpp"
|
||||||
@ -56,17 +47,23 @@ MainLoop::~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.
|
/** Run the actual main loop.
|
||||||
*/
|
*/
|
||||||
void MainLoop::run()
|
void MainLoop::run()
|
||||||
{
|
{
|
||||||
static const GLuint TITLE_SCREEN_TEXTURE =
|
loadBackgroundImages();
|
||||||
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;
|
bool music_on = false;
|
||||||
m_curr_time = SDL_GetTicks();
|
m_curr_time = SDL_GetTicks();
|
||||||
@ -191,9 +188,9 @@ void MainLoop::run()
|
|||||||
//Draw the splash screen
|
//Draw the splash screen
|
||||||
|
|
||||||
if(menu_manager->isMainMenuActive())
|
if(menu_manager->isMainMenuActive())
|
||||||
glBindTexture(GL_TEXTURE_2D, TITLE_SCREEN_TEXTURE);
|
glBindTexture(GL_TEXTURE_2D, m_title_screen_texture);
|
||||||
else
|
else
|
||||||
glBindTexture(GL_TEXTURE_2D, MENUS_BG_TEXTURE);
|
glBindTexture(GL_TEXTURE_2D, m_bg_texture);
|
||||||
|
|
||||||
glBegin ( GL_QUADS ) ;
|
glBegin ( GL_QUADS ) ;
|
||||||
glColor3f (1, 1, 1 ) ;
|
glColor3f (1, 1, 1 ) ;
|
||||||
|
@ -19,6 +19,16 @@
|
|||||||
|
|
||||||
#ifndef HEADER_MAIN_LOOP_HPP
|
#ifndef HEADER_MAIN_LOOP_HPP
|
||||||
#define HEADER_MAIN_LOOP_HPP
|
#define HEADER_MAIN_LOOP_HPP
|
||||||
|
#ifdef __APPLE__
|
||||||
|
# include <OpenGL/gl.h>
|
||||||
|
#else
|
||||||
|
# ifdef WIN32
|
||||||
|
# define WIN32_LEAN_AND_MEAN
|
||||||
|
# include <windows.h>
|
||||||
|
# endif
|
||||||
|
# include <GL/gl.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <SDL/SDL_types.h>
|
#include <SDL/SDL_types.h>
|
||||||
|
|
||||||
/** Management class for the whole gameflow, this is where the
|
/** Management class for the whole gameflow, this is where the
|
||||||
@ -31,12 +41,15 @@ private:
|
|||||||
int m_frame_count;
|
int m_frame_count;
|
||||||
Uint32 m_curr_time;
|
Uint32 m_curr_time;
|
||||||
Uint32 m_prev_time;
|
Uint32 m_prev_time;
|
||||||
|
GLuint m_title_screen_texture;
|
||||||
|
GLuint m_bg_texture;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainLoop();
|
MainLoop();
|
||||||
~MainLoop();
|
~MainLoop();
|
||||||
void run();
|
void run();
|
||||||
void abort();
|
void abort();
|
||||||
|
void loadBackgroundImages();
|
||||||
}; // MainLoop
|
}; // MainLoop
|
||||||
|
|
||||||
extern MainLoop* main_loop;
|
extern MainLoop* main_loop;
|
||||||
|
@ -147,6 +147,24 @@ void STKConfig::init_defaults()
|
|||||||
m_leader_intervals.clear();
|
m_leader_intervals.clear();
|
||||||
} // init_defaults
|
} // 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.
|
/** Extracts the actual information from a lisp file.
|
||||||
* \param lisp Pointer to the lisp data structure.
|
* \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("slowdown-factor", m_slowdown_factor );
|
||||||
lisp->get("delay-finish-time", m_delay_finish_time );
|
lisp->get("delay-finish-time", m_delay_finish_time );
|
||||||
lisp->get("music-credit-time", m_music_credit_time );
|
lisp->get("music-credit-time", m_music_credit_time );
|
||||||
lisp->get("menu-background", m_menu_background );
|
lisp->getVector("menu-background", m_menu_background );
|
||||||
lisp->get("mainmenu-background", m_mainmenu_background );
|
lisp->getVector("mainmenu-background", m_mainmenu_background );
|
||||||
lisp->get("enable_networking", m_enable_networking );
|
lisp->get("enable_networking", m_enable_networking );
|
||||||
std::string title_music;
|
std::string title_music;
|
||||||
lisp->get("title-music", title_music );
|
lisp->get("title-music", title_music );
|
||||||
|
@ -80,9 +80,9 @@ public:
|
|||||||
|
|
||||||
MusicInformation
|
MusicInformation
|
||||||
*m_title_music; /**<Filename of the title music to play.*/
|
*m_title_music; /**<Filename of the title music to play.*/
|
||||||
std::string
|
std::vector<std::string>
|
||||||
m_mainmenu_background; /**<Picture used as menu background. */
|
m_mainmenu_background; /**<Picture used as menu background. */
|
||||||
std::string
|
std::vector<std::string>
|
||||||
m_menu_background; /**<Picture used as background for other menus. */
|
m_menu_background; /**<Picture used as background for other menus. */
|
||||||
|
|
||||||
/** Empty constructor. The actual work is done in load. */
|
/** Empty constructor. The actual work is done in load. */
|
||||||
@ -93,6 +93,8 @@ public:
|
|||||||
/** Returns the default kart properties for each kart. */
|
/** Returns the default kart properties for each kart. */
|
||||||
const KartProperties &
|
const KartProperties &
|
||||||
getDefaultKartProperties() const {return m_kart_properties; }
|
getDefaultKartProperties() const {return m_kart_properties; }
|
||||||
|
const std::string &getMainMenuPicture(int n);
|
||||||
|
const std::string &getBackgroundPicture(int n);
|
||||||
}
|
}
|
||||||
; // STKConfig
|
; // STKConfig
|
||||||
|
|
||||||
|
@ -17,8 +17,10 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program; if not, write to the Free Software
|
// along with this program; if not, write to the Free Software
|
||||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
|
#include "user_config.hpp"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -38,8 +40,8 @@
|
|||||||
#define _WINSOCKAPI_
|
#define _WINSOCKAPI_
|
||||||
#include <plib/ul.h>
|
#include <plib/ul.h>
|
||||||
|
|
||||||
|
#include "stk_config.hpp"
|
||||||
#include "actionmap.hpp"
|
#include "actionmap.hpp"
|
||||||
#include "user_config.hpp"
|
|
||||||
#include "lisp/lisp.hpp"
|
#include "lisp/lisp.hpp"
|
||||||
#include "lisp/parser.hpp"
|
#include "lisp/parser.hpp"
|
||||||
#include "lisp/writer.hpp"
|
#include "lisp/writer.hpp"
|
||||||
@ -291,6 +293,14 @@ void UserConfig::setDefaults()
|
|||||||
|
|
||||||
} // 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;
|
||||||
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
|
@ -244,8 +244,8 @@ public:
|
|||||||
/** Returns the default difficulty. */
|
/** Returns the default difficulty. */
|
||||||
int getDefaultDifficulty() const { return m_difficulty; }
|
int getDefaultDifficulty() const { return m_difficulty; }
|
||||||
|
|
||||||
/** Sets the index of the background image. */
|
void nextBackgroundIndex();
|
||||||
void setBackgroundIndex(int n) { m_background_index = n; }
|
|
||||||
/** Get the index of the background image. */
|
/** Get the index of the background image. */
|
||||||
int getBackgroundIndex() const { return m_background_index; }
|
int getBackgroundIndex() const { return m_background_index; }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user