Increased version number for config file. When older config files are loaded
key bindings are ignored, and a warning is displayed the first time the main menu is displayed. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@1405 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
601af042f6
commit
c3dce60b17
@ -24,6 +24,7 @@
|
||||
#include "race_manager.hpp"
|
||||
#include "menu_manager.hpp"
|
||||
#include "translation.hpp"
|
||||
#include "user_config.hpp"
|
||||
|
||||
enum WidgetTokens
|
||||
{
|
||||
@ -33,7 +34,8 @@ enum WidgetTokens
|
||||
WTOK_QUIT,
|
||||
WTOK_EMPTY,
|
||||
WTOK_HELP,
|
||||
WTOK_CREDITS
|
||||
WTOK_CREDITS,
|
||||
WTOK_WARNING
|
||||
};
|
||||
|
||||
MainMenu::MainMenu()
|
||||
@ -72,6 +74,14 @@ MainMenu::MainMenu()
|
||||
widget_manager->setWgtText( WTOK_CREDITS, _("Credits") );
|
||||
widget_manager->setWgtTextSize( WTOK_CREDITS, WGT_FNT_SML );
|
||||
|
||||
if(user_config->getWarning()!="")
|
||||
{
|
||||
widget_manager->addWgt( WTOK_WARNING, 80, 8 );
|
||||
widget_manager->setWgtText( WTOK_WARNING, user_config->getWarning().c_str() );
|
||||
widget_manager->setWgtTextSize( WTOK_WARNING, WGT_FNT_SML );
|
||||
widget_manager->hideWgtRect(WTOK_WARNING);
|
||||
}
|
||||
|
||||
widget_manager->layout(WGT_AREA_ALL);
|
||||
}
|
||||
|
||||
@ -79,6 +89,7 @@ MainMenu::MainMenu()
|
||||
MainMenu::~MainMenu()
|
||||
{
|
||||
widget_manager->reset();
|
||||
user_config->resetWarning();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -113,6 +113,7 @@ void UserConfig::setFilename()
|
||||
void UserConfig::setDefaults()
|
||||
{
|
||||
setFilename();
|
||||
m_warning = "";
|
||||
m_keyboard_debug = false;
|
||||
m_track_debug = 0;
|
||||
m_bullet_debug = false;
|
||||
@ -153,7 +154,7 @@ void UserConfig::setDefaults()
|
||||
|
||||
// Clear every entry.
|
||||
memset(inputMap, 0, sizeof(inputMap));
|
||||
|
||||
|
||||
/* general game input settings */
|
||||
set(GA_ENTER,
|
||||
Input(IT_KEYBOARD, SDLK_RETURN),
|
||||
@ -385,7 +386,7 @@ void UserConfig::loadConfig(const std::string& filename)
|
||||
}
|
||||
int configFileVersion = 0;
|
||||
lisp->get("configFileVersion", configFileVersion);
|
||||
if (configFileVersion < SUPPORTED_CONFIG_VERSION)
|
||||
if (configFileVersion < CURRENT_CONFIG_VERSION)
|
||||
{
|
||||
// Give some feedback to the user about what was changed.
|
||||
// Do NOT add a break after the case, so that all changes will be printed
|
||||
@ -403,6 +404,8 @@ void UserConfig::loadConfig(const std::string& filename)
|
||||
needToAbort=std::max(needToAbort,0);
|
||||
case 3: printf(_("Added username for all players.\n"));
|
||||
needToAbort=std::max(needToAbort,0);
|
||||
case 4: printf(_("Added jumping, which invalidates all key bindings.\n"));
|
||||
needToAbort=std::max(needToAbort,0);
|
||||
case 99: break;
|
||||
default: printf(_("Config file version '%d' is too old. Discarding your configuration. Sorry. :(\n"), configFileVersion);
|
||||
needToAbort=1;
|
||||
@ -442,10 +445,10 @@ void UserConfig::loadConfig(const std::string& filename)
|
||||
//detect if resolution change previously crashed STK
|
||||
lisp->get("crash_detected", m_crashed);
|
||||
// blacklisted resolutions
|
||||
lisp->getVector("blacklisted_resolutions", m_blacklist_res);
|
||||
|
||||
lisp->getVector("blacklisted_resolutions",
|
||||
m_blacklist_res);
|
||||
/*get number of karts*/
|
||||
lisp->get("karts", m_karts);
|
||||
lisp->get("karts", m_karts);
|
||||
|
||||
//get whether to log errors to file
|
||||
lisp->get("log-errors", m_log_errors);
|
||||
@ -482,18 +485,28 @@ void UserConfig::loadConfig(const std::string& filename)
|
||||
reader->get("lastKartId", lastKartId);
|
||||
m_player[i].setLastKartId(lastKartId);
|
||||
|
||||
// Retrieves a player's INPUT configuration
|
||||
readPlayerInput(reader, "left", KA_LEFT, i);
|
||||
readPlayerInput(reader, "right", KA_RIGHT, i);
|
||||
readPlayerInput(reader, "accel", KA_ACCEL, i);
|
||||
readPlayerInput(reader, "brake", KA_BRAKE, i);
|
||||
|
||||
readPlayerInput(reader, "wheelie", KA_WHEELIE, i);
|
||||
readPlayerInput(reader, "jump", KA_JUMP, i);
|
||||
readPlayerInput(reader, "rescue", KA_RESCUE, i);
|
||||
readPlayerInput(reader, "fire", KA_FIRE, i);
|
||||
readPlayerInput(reader, "lookBack", KA_LOOK_BACK, i);
|
||||
}
|
||||
// Don't read the key bindings from a config file earlier than
|
||||
// version 5. These config files contain (unused) keybindings for
|
||||
// jumping, so it is possible that the same key is used for
|
||||
// jumping for player 1 and something else for another player.
|
||||
// In this case jumping for player one would be disabled (see
|
||||
// unsetDuplicates). To be on the safe side, old key bindings
|
||||
// are just discarded.
|
||||
if (configFileVersion <= 4)
|
||||
{
|
||||
m_warning=_("Old config file found, check your key bindings!");
|
||||
// Retrieves a player's INPUT configuration
|
||||
readPlayerInput(reader, "left", KA_LEFT, i);
|
||||
readPlayerInput(reader, "right", KA_RIGHT, i);
|
||||
readPlayerInput(reader, "accel", KA_ACCEL, i);
|
||||
readPlayerInput(reader, "brake", KA_BRAKE, i);
|
||||
readPlayerInput(reader, "wheelie", KA_WHEELIE, i);
|
||||
readPlayerInput(reader, "jump", KA_JUMP, i);
|
||||
readPlayerInput(reader, "rescue", KA_RESCUE, i);
|
||||
readPlayerInput(reader, "fire", KA_FIRE, i);
|
||||
readPlayerInput(reader, "lookBack", KA_LOOK_BACK, i);
|
||||
} // configFileVersion <= 4
|
||||
} // for i < PLAYERS
|
||||
}
|
||||
catch(std::exception& e)
|
||||
{
|
||||
|
@ -31,10 +31,15 @@
|
||||
Version 1 can read version 0 without any problems, so
|
||||
SUPPORTED_CONFIG_VERSION is 0.
|
||||
2: Changed to SDL keyboard bindings
|
||||
3: Added username
|
||||
3: Added username (userid was used for ALL players)
|
||||
4: Added username per player
|
||||
5: Enabled jumping, which might cause a problem with old
|
||||
config files (which have an unused entry for jump defined
|
||||
--> if a kart control for (say) player 2 uses the same key as
|
||||
jump for player 1, this problem is not noticed in 0.3, but will
|
||||
cause an undefined game action now
|
||||
*/
|
||||
#define CURRENT_CONFIG_VERSION 4
|
||||
#define SUPPORTED_CONFIG_VERSION 3
|
||||
#define CURRENT_CONFIG_VERSION 5
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@ -75,6 +80,7 @@ private:
|
||||
// Attributes which have setter/getter
|
||||
int m_sfx;
|
||||
int m_music;
|
||||
std::string m_warning;
|
||||
|
||||
void readPlayerInput(const lisp::Lisp *,
|
||||
const char *,
|
||||
@ -188,6 +194,8 @@ public:
|
||||
void clearInput(int, KartAction);
|
||||
|
||||
bool isFixedInput(InputType, int, int, int);
|
||||
const std::string& getWarning() {return m_warning;}
|
||||
void resetWarning() {m_warning="";}
|
||||
|
||||
/** Creates ActionMap for use in menu mode. */
|
||||
ActionMap *newMenuActionMap();
|
||||
|
Loading…
Reference in New Issue
Block a user