started converting user config to XML. Implementation is not 100% complete yet; saving works, not lodading. Implementation is not the prettiest but designed for minimal maintenance.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3625 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
d9f999dff8
commit
2f6b05bace
@ -58,7 +58,7 @@ SFXManager::SFXManager()
|
||||
if(!m_initialized) return;
|
||||
|
||||
loadSfx();
|
||||
setMasterSFXVolume( user_config->m_sfx_volume );
|
||||
setMasterSFXVolume( UserConfigParams::m_sfx_volume );
|
||||
|
||||
} // SoundManager
|
||||
|
||||
@ -82,7 +82,7 @@ SFXManager::~SFXManager()
|
||||
//----------------------------------------------------------------------------
|
||||
bool SFXManager::sfxAllowed()
|
||||
{
|
||||
if(!user_config->doSFX() || !m_initialized)
|
||||
if(!UserConfigParams::m_sfx || !m_initialized)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
|
@ -41,7 +41,7 @@ SoundManager* sound_manager= NULL;
|
||||
SoundManager::SoundManager()
|
||||
{
|
||||
m_current_music= NULL;
|
||||
setMasterMusicVolume(user_config->m_music_volume);
|
||||
setMasterMusicVolume(UserConfigParams::m_music_volume);
|
||||
|
||||
ALCdevice* device = alcOpenDevice ( NULL ); //The default sound device
|
||||
if( device == NULL )
|
||||
@ -138,7 +138,7 @@ void SoundManager::startMusic(MusicInformation* mi)
|
||||
stopMusic();
|
||||
m_current_music = mi;
|
||||
|
||||
if(!mi || !user_config->doMusic() || !m_initialized) return;
|
||||
if(!mi || !UserConfigParams::m_music || !m_initialized) return;
|
||||
|
||||
mi->volumeMusic(m_masterGain);
|
||||
mi->startMusic();
|
||||
@ -161,7 +161,7 @@ void SoundManager::setMasterMusicVolume(float gain)
|
||||
m_masterGain = gain;
|
||||
if(m_current_music) m_current_music->volumeMusic(m_masterGain);
|
||||
|
||||
user_config->m_music_volume = m_masterGain;
|
||||
UserConfigParams::m_music_volume = m_masterGain;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -185,7 +185,7 @@ MusicInformation* SoundManager::getMusicInformation(const std::string& filename)
|
||||
//----------------------------------------------------------------------------
|
||||
void SoundManager::positionListener(const Vec3 &position, const Vec3 &front)
|
||||
{
|
||||
if(!user_config->doSFX() || !m_initialized) return;
|
||||
if(!UserConfigParams::m_sfx || !m_initialized) return;
|
||||
|
||||
//forward vector
|
||||
m_listenerVec[0] = front.getX();
|
||||
|
@ -18,14 +18,15 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "config/user_config.hpp"
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <fstream>
|
||||
|
||||
// for mkdir:
|
||||
#if !defined(WIN32) || defined(__CYGWIN__)
|
||||
# include <sys/stat.h>
|
||||
@ -37,12 +38,116 @@
|
||||
#include "challenges/unlock_manager.hpp"
|
||||
#include "config/stk_config.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "io/xml_node.hpp"
|
||||
#include "lisp/lisp.hpp"
|
||||
#include "lisp/parser.hpp"
|
||||
#include "lisp/writer.hpp"
|
||||
#include "race/race_manager.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
|
||||
class UserConfigParam;
|
||||
static std::vector<UserConfigParam*> all_params;
|
||||
|
||||
|
||||
// X-macros
|
||||
#define PARAM_PREFIX
|
||||
#define PARAM_DEFAULT(X) = X
|
||||
#include "config/user_config.hpp"
|
||||
|
||||
IntUserConfigParam::IntUserConfigParam(int defaultValue, const char* paramName)
|
||||
{
|
||||
this->value = defaultValue;
|
||||
this->paramName = paramName;
|
||||
all_params.push_back(this);
|
||||
}
|
||||
|
||||
void IntUserConfigParam::write(std::ofstream& stream) const
|
||||
{
|
||||
stream << " <" << paramName << " value=\"" << value << "\" />\n";
|
||||
}
|
||||
|
||||
void IntUserConfigParam::read(const XMLNode* node)
|
||||
{
|
||||
const XMLNode* child = node->getNode( paramName );
|
||||
if(child == NULL) return;
|
||||
|
||||
child->get( "value", &value );
|
||||
}
|
||||
|
||||
StringUserConfigParam::StringUserConfigParam(const char* defaultValue, const char* paramName)
|
||||
{
|
||||
this->value = defaultValue;
|
||||
this->paramName = paramName;
|
||||
all_params.push_back(this);
|
||||
}
|
||||
void StringUserConfigParam::write(std::ofstream& stream) const
|
||||
{
|
||||
stream << " <" << paramName << " value=\"" << value << "\" />\n";
|
||||
}
|
||||
void StringUserConfigParam::read(const XMLNode* node)
|
||||
{
|
||||
const XMLNode* child = node->getNode( paramName );
|
||||
if(child == NULL) return;
|
||||
|
||||
child->get( "value", &value );
|
||||
}
|
||||
|
||||
BoolUserConfigParam::BoolUserConfigParam(bool defaultValue, const char* paramName)
|
||||
{
|
||||
this->value = defaultValue;
|
||||
this->paramName = paramName;
|
||||
all_params.push_back(this);
|
||||
|
||||
}
|
||||
void BoolUserConfigParam::write(std::ofstream& stream) const
|
||||
{
|
||||
stream << " <" << paramName << " value=\"" << (value ? "true" : "false" )<< "\" />\n";
|
||||
}
|
||||
void BoolUserConfigParam::read(const XMLNode* node)
|
||||
{
|
||||
const XMLNode* child = node->getNode( paramName );
|
||||
if(child == NULL) return;
|
||||
|
||||
std::string textValue = "";
|
||||
child->get( "value", &textValue );
|
||||
|
||||
if(textValue == "true")
|
||||
{
|
||||
value = true;
|
||||
}
|
||||
else if(textValue == "false")
|
||||
{
|
||||
value = false;
|
||||
}
|
||||
else
|
||||
std::cerr << "Unknown value for " << paramName << "; expected true or false\n";
|
||||
}
|
||||
|
||||
|
||||
FloatUserConfigParam::FloatUserConfigParam(bool defaultValue, const char* paramName)
|
||||
{
|
||||
this->value = defaultValue;
|
||||
this->paramName = paramName;
|
||||
all_params.push_back(this);
|
||||
|
||||
}
|
||||
void FloatUserConfigParam::write(std::ofstream& stream) const
|
||||
{
|
||||
stream << " <" << paramName << " value=\"" << value << "\" />\n";
|
||||
}
|
||||
void FloatUserConfigParam::read(const XMLNode* node)
|
||||
{
|
||||
const XMLNode* child = node->getNode( paramName );
|
||||
if(child == NULL) return;
|
||||
|
||||
child->get( "value", &value );
|
||||
}
|
||||
|
||||
// =====================================================================================
|
||||
// =====================================================================================
|
||||
|
||||
UserConfig *user_config;
|
||||
|
||||
@ -86,68 +191,29 @@ void UserConfig::setDefaults()
|
||||
{
|
||||
setFilename();
|
||||
m_warning = "";
|
||||
m_gamepad_debug = false;
|
||||
m_track_debug = 0;
|
||||
m_bullet_debug = false;
|
||||
m_fullscreen = false;
|
||||
m_no_start_screen = false;
|
||||
m_sfx = UC_ENABLE;
|
||||
m_music = UC_ENABLE;
|
||||
m_graphical_effects = true;
|
||||
m_display_fps = false;
|
||||
m_item_style = "items";
|
||||
m_background_music = "";
|
||||
m_profile = 0;
|
||||
m_print_kart_sizes = false;
|
||||
m_max_fps = 120;
|
||||
m_sfx_volume = 1.0f;
|
||||
m_music_volume = 0.7f;
|
||||
m_width = 800;
|
||||
m_height = 600;
|
||||
m_prev_width = m_width;
|
||||
m_prev_height = m_height;
|
||||
m_prev_windowed = false;
|
||||
m_crashed = false;
|
||||
m_blacklist_res.clear();
|
||||
m_num_karts = 4;
|
||||
m_num_laps = 4;
|
||||
m_difficulty = 0;
|
||||
m_background_index = 0;
|
||||
m_log_errors = false;
|
||||
m_kart_group = "standard";
|
||||
m_track_group = "standard";
|
||||
m_last_track = "jungle";
|
||||
m_server_address = "localhost";
|
||||
m_server_port = 2305;
|
||||
//m_blacklist_res.clear();
|
||||
|
||||
std::string username = "unnamed player";
|
||||
|
||||
if(getenv("USERNAME")!=NULL) // for windows
|
||||
m_username=getenv("USERNAME");
|
||||
username = getenv("USERNAME");
|
||||
else if(getenv("USER")!=NULL) // Linux, Macs
|
||||
m_username=getenv("USER");
|
||||
username = getenv("USER");
|
||||
else if(getenv("LOGNAME")!=NULL) // Linux, Macs
|
||||
m_username=getenv("LOGNAME");
|
||||
else m_username="nouser";
|
||||
username = getenv("LOGNAME");
|
||||
|
||||
|
||||
std::cout << "creating Players with name " << username.c_str() << std::endl;
|
||||
|
||||
// Set the name as the default name for all players.
|
||||
for(int i=0; i<4; i++)
|
||||
{
|
||||
m_player[i].setName(m_username);
|
||||
m_player[i].setLastKartId(0);
|
||||
}
|
||||
|
||||
// Clear every entry.
|
||||
//memset(m_input_map, 0, sizeof(m_input_map));
|
||||
// TODO : create only one by default and let users add more?
|
||||
UserConfigParams::m_player.push_back( Player(username + " 1") );
|
||||
UserConfigParams::m_player.push_back( Player(username + " 2") );
|
||||
UserConfigParams::m_player.push_back( Player(username + " 3") );
|
||||
UserConfigParams::m_player.push_back( Player(username + " 4") );
|
||||
|
||||
|
||||
} // 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;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/**
|
||||
@ -238,8 +304,79 @@ int UserConfig::CheckAndCreateDir()
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/** Load configuration values from file. */
|
||||
// TODO : implement
|
||||
void UserConfig::loadConfig(const std::string& filename)
|
||||
{
|
||||
|
||||
XMLNode* root = file_manager->createXMLTree(filename);
|
||||
if(!root)
|
||||
{
|
||||
std::cerr << "Could not read user config file file " << filename.c_str() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
const XMLNode* node = root;
|
||||
//const XMLNode* node = root->getNode("stkconfig");
|
||||
//if(node == NULL)
|
||||
//{
|
||||
// std::cerr << "Error, malformed user config file! Contains no <stkconfig> tag!\n";
|
||||
// return;
|
||||
//}
|
||||
|
||||
|
||||
int configFileVersion = CURRENT_CONFIG_VERSION;
|
||||
if(!root->get("version", &configFileVersion) < 1)
|
||||
{
|
||||
std::cerr << "Warning, malformed user config file! Contains no version\n";
|
||||
}
|
||||
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
|
||||
printf("\nConfig file version '%d' is too old.\n"
|
||||
"The following changes have been applied in the current SuperTuxKart version:\n",
|
||||
configFileVersion);
|
||||
int needToAbort=0;
|
||||
switch(configFileVersion)
|
||||
{
|
||||
case 0: printf("- Single window menu, old status display,new keyboard style settings were removed\n");
|
||||
needToAbort=std::max(needToAbort,0);
|
||||
case 1: printf("- Key bindings were changed, please check the settings. All existing values were discarded.\n");
|
||||
needToAbort=std::max(needToAbort,1);// old keybinds wouldn't make any sense
|
||||
case 2: printf("Added username.\n");
|
||||
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 6: printf("Added nitro and drifting, removed jumping and wheelie.\n");
|
||||
//nitro_name="wheelie";
|
||||
//drift_name="jump";
|
||||
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;
|
||||
break;
|
||||
}
|
||||
if(needToAbort)
|
||||
{
|
||||
printf("The old config file is deleted, a new one will be created.\n");
|
||||
delete root;
|
||||
return;
|
||||
}
|
||||
printf("This warning can be ignored, the config file will be automatically updated.\n");
|
||||
// Keep on reading the config files as far as possible
|
||||
} // if configFileVersion<SUPPORTED_CONFIG_VERSION
|
||||
|
||||
|
||||
const int paramAmount = all_params.size();
|
||||
for(int i=0; i<paramAmount; i++)
|
||||
{
|
||||
all_params[i]->read(node);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
std::string temp;
|
||||
const lisp::Lisp* root = 0;
|
||||
int i = 0;
|
||||
@ -294,7 +431,7 @@ void UserConfig::loadConfig(const std::string& filename)
|
||||
needToAbort=std::max(needToAbort,0);
|
||||
case 1: printf("- Key bindings were changed, please check the settings. All existing values were discarded.\n");
|
||||
needToAbort=std::max(needToAbort,1);// old keybinds wouldn't make any sense
|
||||
case 2: printf("Added username, using: '%s'.\n", m_username.c_str());
|
||||
case 2: printf("Added username, using: '%s'.\n", UserConfigParams::m_username.c_str());
|
||||
needToAbort=std::max(needToAbort,0);
|
||||
case 3: printf("Added username for all players.\n");
|
||||
needToAbort=std::max(needToAbort,0);
|
||||
@ -371,6 +508,8 @@ void UserConfig::loadConfig(const std::string& filename)
|
||||
if(unlock_info) unlock_manager->load(unlock_info);
|
||||
|
||||
/*get player configurations*/
|
||||
// TODO : save/load players to/from file
|
||||
/*
|
||||
for(i=0; i<PLAYERS; ++i)
|
||||
{
|
||||
temp = "player-";
|
||||
@ -416,19 +555,19 @@ void UserConfig::loadConfig(const std::string& filename)
|
||||
|
||||
// Retrieves a player's INPUT configuration
|
||||
// TODO - input config I/O
|
||||
/*
|
||||
for(int ka=PA_FIRST+1; ka<PA_COUNT; ka++)
|
||||
{
|
||||
readPlayerInput(reader, KartActionStrings[ka],
|
||||
(KartAction)ka, i);
|
||||
}
|
||||
*/
|
||||
//for(int ka=PA_FIRST+1; ka<PA_COUNT; ka++)
|
||||
//{
|
||||
// readPlayerInput(reader, KartActionStrings[ka],
|
||||
// (KartAction)ka, i);
|
||||
//}
|
||||
|
||||
// Leave those in for backwards compatibility (i.e. config files
|
||||
// with jump/wheelie). If jump/wheelie are not defined, nothing
|
||||
// happens (the same input is read again).
|
||||
//readPlayerInput(reader, nitro_name, KA_NITRO, i);
|
||||
//readPlayerInput(reader, drift_name, KA_DRIFT, i);
|
||||
} // for i < PLAYERS
|
||||
*/
|
||||
|
||||
// Read the last input device configurations. It is important that this
|
||||
// happens after reading the player config, since if no last config
|
||||
@ -445,290 +584,43 @@ void UserConfig::loadConfig(const std::string& filename)
|
||||
}
|
||||
|
||||
delete root;
|
||||
#endif
|
||||
} // loadConfig
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/*
|
||||
void UserConfig::readStickConfigs(const lisp::Lisp *r)
|
||||
{
|
||||
std::string temp;
|
||||
int count = 0;
|
||||
|
||||
const lisp::Lisp *scsreader = r->getLisp("stick-configs");
|
||||
if (scsreader)
|
||||
{
|
||||
scsreader->get("count", count);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
temp = "stick-";
|
||||
temp += (i + '1');
|
||||
const lisp::Lisp *screader = scsreader->getLisp(temp);
|
||||
if (screader)
|
||||
{
|
||||
std::string id;
|
||||
screader->get("id", id);
|
||||
|
||||
StickConfig *sc = new StickConfig(id);
|
||||
|
||||
screader->get("preferredIndex", sc->m_preferredIndex);
|
||||
screader->get("deadzone", sc->m_deadzone);
|
||||
|
||||
m_stickconfigs.push_back(sc);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // readStickConfigs
|
||||
*/
|
||||
// -----------------------------------------------------------------------------
|
||||
/** Write settings to config file. */
|
||||
void UserConfig::saveConfig(const std::string& filename)
|
||||
void UserConfig::saveConfig(const std::string& filepath)
|
||||
{
|
||||
std::string temp;
|
||||
int i;
|
||||
|
||||
const int DIR_EXIST = CheckAndCreateDir();
|
||||
// Check if the config directory exists (again, since it was already checked
|
||||
// when reading the config file - this is done in case that the problem was
|
||||
// fixed while tuxkart is running). If the directory does not exist and
|
||||
// can not be created, an error message was already printed to stderr,
|
||||
// and we can exit here without any further messages.
|
||||
if (DIR_EXIST == 0) return;
|
||||
|
||||
lisp::Writer *writer = new lisp::Writer(filename);
|
||||
try
|
||||
if (DIR_EXIST == 0)
|
||||
{
|
||||
writer->beginList("tuxkart-config");
|
||||
writer->writeComment("If the game's supported config file version is higher than this number the configuration is discarded.");
|
||||
writer->write("configFileVersion\t", CURRENT_CONFIG_VERSION);
|
||||
|
||||
writer->writeComment("the following options can be set to #t or #f:");
|
||||
writer->write("sfx\t", !(m_sfx==UC_DISABLE));
|
||||
writer->write("music\t", !(m_music==UC_DISABLE));
|
||||
writer->write("graphical-effects\t", m_graphical_effects);
|
||||
writer->writeComment("Display frame per seconds");
|
||||
writer->write("displayFPS\t", m_display_fps);
|
||||
writer->writeComment("Name of the .items file to use.");
|
||||
writer->write("itemStyle\t", m_item_style);
|
||||
writer->writeComment("Background music file to use,");
|
||||
writer->write("background-music\t", m_background_music);
|
||||
writer->writeComment("maximum fps, should be at least 60");
|
||||
writer->write("max-fps\t", m_max_fps);
|
||||
writer->writeComment("Volume for sound effects, see openal AL_GAIN for interpretation");
|
||||
writer->write("sfx-volume", m_sfx_volume);
|
||||
writer->write("music-volume", m_music_volume);
|
||||
|
||||
writer->writeComment("screen resolution and windowing mode");
|
||||
writer->write("width\t", m_width);
|
||||
writer->write("height\t", m_height);
|
||||
writer->write("prev_width\t", m_prev_width);
|
||||
writer->write("prev_height\t", m_prev_height);
|
||||
writer->write("prev_windowed\t", m_prev_windowed);
|
||||
writer->write("crash_detected\t", m_crashed);
|
||||
writer->write("blacklisted_resolutions\t",
|
||||
m_blacklist_res);
|
||||
writer->write("fullscreen\t", m_fullscreen);
|
||||
|
||||
writer->writeComment("Number of karts. -1 means use all");
|
||||
writer->write("karts\t", m_num_karts);
|
||||
writer->writeComment("Number of laps.");
|
||||
writer->write("laps\t", m_num_laps);
|
||||
writer->writeComment("Difficulty: 0=easy, 1=medium, 2=hard");
|
||||
writer->write("difficulty\t", m_difficulty);
|
||||
writer->writeComment("Last selected kart group");
|
||||
writer->write("kart-group", m_kart_group);
|
||||
writer->writeComment("Last selected track group");
|
||||
writer->write("track-group", m_track_group);
|
||||
writer->writeComment("Last track played");
|
||||
writer->write("last-track", m_last_track);
|
||||
writer->writeComment("Menu background image to use");
|
||||
writer->write("background", m_background_index);
|
||||
writer->writeComment("Information about last server used");
|
||||
writer->write("server-address", m_server_address);
|
||||
writer->write("server-port", m_server_port);
|
||||
|
||||
//writeStickConfigs(writer);
|
||||
|
||||
// Write unlock information back
|
||||
writer->beginList("unlock-info");
|
||||
unlock_manager->save(writer);
|
||||
writer->endList("unlock-info");
|
||||
|
||||
/* write player configurations */
|
||||
for(i=0; i<PLAYERS; ++i)
|
||||
{
|
||||
temp = "player ";
|
||||
temp += i+'1';
|
||||
temp += " settings";
|
||||
writer->writeComment(temp);
|
||||
temp = "player-";
|
||||
temp += i+'1';
|
||||
writer->beginList(temp);
|
||||
|
||||
writer->write("name\t", m_player[i].getName());
|
||||
|
||||
writer->writeComment("optional");
|
||||
writer->write("lastKartId", m_player[i].getLastKartId());
|
||||
|
||||
writer->endList(temp);
|
||||
} // for i
|
||||
|
||||
writer->endList("tuxkart-config");
|
||||
}
|
||||
catch(std::exception& e)
|
||||
{
|
||||
fprintf(stderr, "Couldn't write config: ");
|
||||
fprintf(stderr, "%s",e.what());
|
||||
fprintf(stderr, "\n");
|
||||
std::cerr << "User config firectory does not exist, cannot save config file!\n";
|
||||
return;
|
||||
}
|
||||
|
||||
delete writer;
|
||||
std::ofstream configfile;
|
||||
configfile.open (filepath.c_str());
|
||||
|
||||
if(!configfile.is_open())
|
||||
{
|
||||
std::cerr << "Failed to open " << filepath.c_str() << " for writing, user config won't be saved\n";
|
||||
return;
|
||||
}
|
||||
|
||||
configfile << "<stkconfig version=\"" << CURRENT_CONFIG_VERSION << "\" >\n";
|
||||
|
||||
const int paramAmount = all_params.size();
|
||||
for(int i=0; i<paramAmount; i++)
|
||||
{
|
||||
//std::cout << "saving parameter " << i << " to file\n";
|
||||
all_params[i]->write(configfile);
|
||||
}
|
||||
configfile << "</stkconfig>\n";
|
||||
configfile.close();
|
||||
|
||||
} // saveConfig
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/*
|
||||
void UserConfig::writeStickConfigs(lisp::Writer *writer)
|
||||
{
|
||||
int count = 0;
|
||||
std::string temp;
|
||||
|
||||
writer->beginList("stick-configs");
|
||||
|
||||
count = (int)m_stickconfigs.size();
|
||||
writer->write("count", count);
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
StickConfig *sc = m_stickconfigs[i];
|
||||
temp = "stick-";
|
||||
temp += i + '1';
|
||||
|
||||
writer->beginList(temp);
|
||||
|
||||
writer->write("id", sc->m_id);
|
||||
writer->write("preferredIndex", sc->m_preferredIndex);
|
||||
writer->writeComment("0 means that the default deadzone value is used.");
|
||||
writer->write("deadzone", sc->m_deadzone);
|
||||
|
||||
writer->endList(temp);
|
||||
}
|
||||
|
||||
writer->endList("stick-configs");
|
||||
} // writeStickConfigs
|
||||
*/
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
#if 0
|
||||
std::string UserConfig::getMappingAsString(StaticAction ga)
|
||||
{
|
||||
if (m_input_map[ga].count &&
|
||||
m_input_map[ga].inputs[0].type)
|
||||
{
|
||||
std::stringstream s;
|
||||
s << getInputAsString(m_input_map[ga].inputs[0]);
|
||||
|
||||
return s.str();
|
||||
}
|
||||
else
|
||||
{
|
||||
return std::string(_("not set"));
|
||||
}
|
||||
} // getMappingAsString
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
std::string UserConfig::getMappingAsString(int playerIndex, StaticAction ka)
|
||||
{
|
||||
return getMappingAsString((GameAction) (GA_FIRST_KARTACTION
|
||||
+ playerIndex * KC_COUNT + ka) );
|
||||
} // getMappingAsString
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
void UserConfig::unsetDuplicates(GameAction ga, const Input &i)
|
||||
{
|
||||
for (int cga = GA_FIRST_KARTACTION; cga <= GA_LAST_KARTACTION; cga++)
|
||||
{
|
||||
if (cga != ga)
|
||||
{
|
||||
// If the input occurs in any other mapping
|
||||
// delete it properly from there.
|
||||
|
||||
if (m_input_map[cga].count
|
||||
&& m_input_map[cga].inputs[0].type == i.type
|
||||
&& m_input_map[cga].inputs[0].id0 == i.id0
|
||||
&& m_input_map[cga].inputs[0].id1 == i.id1
|
||||
&& m_input_map[cga].inputs[0].id2 == i.id2)
|
||||
{
|
||||
// Delete it.
|
||||
m_input_map[cga].inputs[0].type = Input::IT_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} // unsetDuplicates
|
||||
#endif
|
||||
// -----------------------------------------------------------------------------
|
||||
/*
|
||||
void UserConfig::setStaticAction(StaticAction ga, const Input &i)
|
||||
{
|
||||
m_input_map[ga].count = 1;
|
||||
m_input_map[ga].inputs[0] = i;
|
||||
} // set(1 input)
|
||||
// -----------------------------------------------------------------------------
|
||||
void UserConfig::setStaticAction(StaticAction ga, const Input &i0, const Input &i1)
|
||||
{
|
||||
m_input_map[ga].count = 2;
|
||||
m_input_map[ga].inputs[0] = i0;
|
||||
m_input_map[ga].inputs[1] = i1;
|
||||
} // set(2 inputs)
|
||||
// -----------------------------------------------------------------------------
|
||||
void UserConfig::setStaticAction(StaticAction ga, const Input &i0, const Input &i1, const Input &i2)
|
||||
{
|
||||
m_input_map[ga].count = 3;
|
||||
m_input_map[ga].inputs[0] = i0;
|
||||
m_input_map[ga].inputs[1] = i1;
|
||||
m_input_map[ga].inputs[2] = i2;
|
||||
} //set(3 inputs)
|
||||
// -----------------------------------------------------------------------------
|
||||
void UserConfig::setStaticAction(StaticAction ga, const Input &i0, const Input &i1,
|
||||
const Input &i2, const Input &i3)
|
||||
{
|
||||
m_input_map[ga].count = 4;
|
||||
m_input_map[ga].inputs[0] = i0;
|
||||
m_input_map[ga].inputs[1] = i1;
|
||||
m_input_map[ga].inputs[2] = i2;
|
||||
m_input_map[ga].inputs[3] = i3;
|
||||
} // set(4 inputs)
|
||||
*/
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
/** Determines a name for a 'input configuration' (i.e. which input action
|
||||
* triggers what kart action like left, right, ...). The result is the
|
||||
* name of the gamepad, "keyboard-"+keycode for left, or "mouse" (or "" if
|
||||
* something else).
|
||||
* \param player_index Player index 0, ..., max
|
||||
*/
|
||||
#if 0
|
||||
std::string UserConfig::getInputDeviceName(int player_index) const
|
||||
{
|
||||
std::string config_name;
|
||||
const Input &left_input = getInput(player_index, PA_LEFT);
|
||||
switch(left_input.type)
|
||||
{
|
||||
case Input::IT_KEYBOARD : { // config name: keyboard+player_index
|
||||
std::ostringstream s;
|
||||
s<<"keyboard-"<<left_input.id0;
|
||||
config_name = s.str();
|
||||
break;
|
||||
}
|
||||
case Input::IT_STICKBUTTON :
|
||||
case Input::IT_STICKHAT :
|
||||
case Input::IT_STICKMOTION : config_name=m_stickconfigs[left_input.id0]->m_id;
|
||||
break;
|
||||
case Input::IT_MOUSEBUTTON :
|
||||
case Input::IT_MOUSEMOTION : config_name="mouse"; break;
|
||||
default : config_name=""; break;
|
||||
} // switch left_input.type
|
||||
return config_name;
|
||||
} // getInputDeviceName
|
||||
#endif
|
||||
|
@ -21,8 +21,6 @@
|
||||
#ifndef HEADER_USER_CONFIG_HPP
|
||||
#define HEADER_USER_CONFIG_HPP
|
||||
|
||||
#define PLAYERS 4
|
||||
|
||||
/* The following config versions are currently used:
|
||||
0: the 0.2 release config file, without config-version number
|
||||
(so that defaults to 0)
|
||||
@ -40,11 +38,12 @@
|
||||
cause an undefined game action now
|
||||
6: Added stick configurations.
|
||||
*/
|
||||
#define CURRENT_CONFIG_VERSION 7
|
||||
const int CURRENT_CONFIG_VERSION = 7;
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
|
||||
#include "config/player.hpp"
|
||||
#include "input/input.hpp"
|
||||
@ -52,195 +51,179 @@
|
||||
#include "lisp/parser.hpp"
|
||||
#include "lisp/writer.hpp"
|
||||
|
||||
//class ActionMap;
|
||||
struct Input;
|
||||
class XMLNode;
|
||||
|
||||
/**
|
||||
* The base of a set of small utilities to enable quickly adding/removing stuff to/from config painlessly.
|
||||
*/
|
||||
class UserConfigParam
|
||||
{
|
||||
protected:
|
||||
std::string paramName;
|
||||
public:
|
||||
virtual ~UserConfigParam() {}
|
||||
virtual void write(std::ofstream& stream) const = 0;
|
||||
virtual void read(const XMLNode* node) = 0;
|
||||
|
||||
};
|
||||
|
||||
class IntUserConfigParam : public UserConfigParam
|
||||
{
|
||||
int value;
|
||||
public:
|
||||
IntUserConfigParam(int defaultValue, const char* paramName);
|
||||
void write(std::ofstream& stream) const;
|
||||
void read(const XMLNode* node);
|
||||
|
||||
operator int() const { return value; }
|
||||
int& operator=(const int& v) { value = v; return value; }
|
||||
};
|
||||
|
||||
class StringUserConfigParam : public UserConfigParam
|
||||
{
|
||||
std::string value;
|
||||
public:
|
||||
StringUserConfigParam(const char* defaultValue, const char* paramName);
|
||||
void write(std::ofstream& stream) const;
|
||||
void read(const XMLNode* node);
|
||||
|
||||
operator std::string() const { return value; }
|
||||
std::string& operator=(const std::string& v) { value = v; return value; }
|
||||
const char* c_str() const { return value.c_str(); }
|
||||
};
|
||||
|
||||
class BoolUserConfigParam : public UserConfigParam
|
||||
{
|
||||
bool value;
|
||||
public:
|
||||
BoolUserConfigParam(bool defaultValue, const char* paramName);
|
||||
void write(std::ofstream& stream) const;
|
||||
void read(const XMLNode* node);
|
||||
|
||||
operator bool() const { return value; }
|
||||
bool& operator=(const bool& v) { value = v; return value; }
|
||||
};
|
||||
|
||||
class FloatUserConfigParam : public UserConfigParam
|
||||
{
|
||||
float value;
|
||||
public:
|
||||
FloatUserConfigParam(bool defaultValue, const char* paramName);
|
||||
void write(std::ofstream& stream) const;
|
||||
void read(const XMLNode* node);
|
||||
|
||||
operator float() const { return value; }
|
||||
float& operator=(const float& v) { value = v; return value; }
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Using X-macros for setting-possible values is not very pretty, but it's a no-maintenance case :
|
||||
* when you want to add a new parameter, just add one signle line below and everything else automagically works
|
||||
* (including default value, saving to file, loading from file)
|
||||
*/
|
||||
|
||||
#ifndef PARAM_PREFIX
|
||||
#define PARAM_PREFIX extern
|
||||
#endif
|
||||
|
||||
#ifndef PARAM_DEFAULT
|
||||
#define PARAM_DEFAULT(X)
|
||||
#endif
|
||||
|
||||
namespace UserConfigParams
|
||||
{
|
||||
PARAM_PREFIX BoolUserConfigParam m_sfx PARAM_DEFAULT( BoolUserConfigParam(true, "sfx_on") );
|
||||
PARAM_PREFIX BoolUserConfigParam m_music PARAM_DEFAULT( BoolUserConfigParam(true, "music_on") );
|
||||
|
||||
/** Default number of karts. */
|
||||
PARAM_PREFIX IntUserConfigParam m_num_karts PARAM_DEFAULT( IntUserConfigParam(4, "numkarts") );
|
||||
|
||||
/** Default number of laps. */
|
||||
PARAM_PREFIX IntUserConfigParam m_num_laps PARAM_DEFAULT( IntUserConfigParam(4, "numlaps") );
|
||||
|
||||
/** Default difficulty. */
|
||||
PARAM_PREFIX IntUserConfigParam m_difficulty PARAM_DEFAULT( IntUserConfigParam(0, "difficulty") );
|
||||
|
||||
/** Index of current background image. */ // TODO : make this a skin choice instead
|
||||
PARAM_PREFIX IntUserConfigParam m_background_index PARAM_DEFAULT( IntUserConfigParam(0, "background_index") );
|
||||
|
||||
// Attributes that are accessed directly.
|
||||
PARAM_PREFIX BoolUserConfigParam m_gamepad_debug PARAM_DEFAULT( BoolUserConfigParam(false, "gamepad_debug") );
|
||||
PARAM_PREFIX BoolUserConfigParam m_track_debug PARAM_DEFAULT( BoolUserConfigParam(false, "track_debug") );
|
||||
PARAM_PREFIX BoolUserConfigParam m_bullet_debug PARAM_DEFAULT( BoolUserConfigParam(false, "bullet_debug") );
|
||||
PARAM_PREFIX BoolUserConfigParam m_fullscreen PARAM_DEFAULT( BoolUserConfigParam(false, "fullscreen") );
|
||||
PARAM_PREFIX BoolUserConfigParam m_no_start_screen PARAM_DEFAULT( BoolUserConfigParam(false, "no_start_screen") );
|
||||
|
||||
// TODO : adapt to be more powerful with irrlicht
|
||||
PARAM_PREFIX BoolUserConfigParam m_graphical_effects PARAM_DEFAULT( BoolUserConfigParam(true, "gfx") );
|
||||
|
||||
PARAM_PREFIX BoolUserConfigParam m_display_fps PARAM_DEFAULT( BoolUserConfigParam(false, "show_fps") );
|
||||
|
||||
// Positive number: time in seconds, neg: # laps. (used to profile AI)
|
||||
// 0 if no profiling. Never saved in config file!
|
||||
PARAM_PREFIX IntUserConfigParam m_profile PARAM_DEFAULT( IntUserConfigParam(0, "profile") );
|
||||
|
||||
PARAM_PREFIX BoolUserConfigParam m_print_kart_sizes PARAM_DEFAULT( BoolUserConfigParam(false, "print_kart_sizes") ); // print all kart sizes
|
||||
|
||||
PARAM_PREFIX FloatUserConfigParam m_sfx_volume PARAM_DEFAULT( FloatUserConfigParam(1.0, "sfx_volume") );
|
||||
PARAM_PREFIX FloatUserConfigParam m_music_volume PARAM_DEFAULT( FloatUserConfigParam(0.7f, "music_volume") );
|
||||
|
||||
PARAM_PREFIX IntUserConfigParam m_max_fps PARAM_DEFAULT( IntUserConfigParam(120, "max_fps") );
|
||||
|
||||
PARAM_PREFIX StringUserConfigParam m_item_style PARAM_DEFAULT( StringUserConfigParam("items", "item_style") );
|
||||
|
||||
PARAM_PREFIX StringUserConfigParam m_kart_group PARAM_DEFAULT( StringUserConfigParam("standard", "kart_group") ); /**< Kart group used last. */
|
||||
PARAM_PREFIX StringUserConfigParam m_track_group PARAM_DEFAULT( StringUserConfigParam("standard", "track_group") ); /**< Track group used last. */
|
||||
PARAM_PREFIX StringUserConfigParam m_last_track PARAM_DEFAULT( StringUserConfigParam("jungle", "last_track") ); /**< name of the last track used. */
|
||||
|
||||
PARAM_PREFIX StringUserConfigParam m_server_address PARAM_DEFAULT( StringUserConfigParam("localhost", "server_adress") );
|
||||
PARAM_PREFIX IntUserConfigParam m_server_port PARAM_DEFAULT( IntUserConfigParam(2305, "server_port") );
|
||||
|
||||
PARAM_PREFIX IntUserConfigParam m_width PARAM_DEFAULT( IntUserConfigParam(800, "width") );
|
||||
PARAM_PREFIX IntUserConfigParam m_height PARAM_DEFAULT( IntUserConfigParam(600, "height") );
|
||||
PARAM_PREFIX IntUserConfigParam m_prev_width PARAM_DEFAULT( IntUserConfigParam(800, "prev_width") );
|
||||
PARAM_PREFIX IntUserConfigParam m_prev_height PARAM_DEFAULT( IntUserConfigParam(600, "prev_height") );
|
||||
|
||||
PARAM_PREFIX BoolUserConfigParam m_prev_windowed PARAM_DEFAULT( BoolUserConfigParam(true, "prev_windowed") );
|
||||
PARAM_PREFIX BoolUserConfigParam m_crashed PARAM_DEFAULT( BoolUserConfigParam(false, "crashed") ); // TODO : is this used with new code? does it still work?
|
||||
PARAM_PREFIX BoolUserConfigParam m_log_errors PARAM_DEFAULT( BoolUserConfigParam(false, "log_errors") );
|
||||
|
||||
// TODO? implement blacklist for new irrlicht device and GUI
|
||||
PARAM_PREFIX std::vector<std::string> m_blacklist_res;
|
||||
|
||||
// TODO : implement saving to config file
|
||||
PARAM_PREFIX std::vector<Player> m_player;
|
||||
|
||||
}
|
||||
#undef PARAM_PREFIX
|
||||
#undef PARAM_SUFFIX
|
||||
|
||||
/** Class for managing general STK user configuration data. */
|
||||
class UserConfig
|
||||
{
|
||||
public:
|
||||
/** Stores information about joystick and gamepads. */
|
||||
/*
|
||||
class StickConfig
|
||||
{
|
||||
public:
|
||||
std::string m_id;
|
||||
int m_preferredIndex;
|
||||
int m_deadzone;
|
||||
StickConfig(const std::string &id) : m_id(id) {}
|
||||
};
|
||||
*/
|
||||
|
||||
private:
|
||||
// This class stores the last used input configuration (i.e. which action
|
||||
// is used for left, right, ..., look back) for a certain input
|
||||
// device (i.e. keyboard, joystick, ...)
|
||||
/*
|
||||
struct InputConfiguration
|
||||
{
|
||||
Input m_input[PA_COUNT];
|
||||
};
|
||||
*/
|
||||
// The mapping of input device name to the last used configuration.
|
||||
// Note that std::map can not be used with Input[KC_COUNT] as 2nd
|
||||
// parameter
|
||||
// std::map<std::string, InputConfiguration> m_last_input_configuration;
|
||||
|
||||
//std::string getInputDeviceName(int player_index) const;
|
||||
|
||||
//std::vector <StickConfig *> m_stickconfigs;
|
||||
/*
|
||||
typedef struct
|
||||
{
|
||||
int count;
|
||||
Input inputs[4];
|
||||
} InputMapEntry;
|
||||
*/
|
||||
|
||||
|
||||
/** Filename of the user config file. */
|
||||
std::string m_filename;
|
||||
|
||||
/** Stores the GameAction->Input mappings in a way that is suitable for
|
||||
* quick modification of the mappings. Internally this allows multiple
|
||||
* Input instances per GameAction but the public methods allow only one
|
||||
* mapping.
|
||||
*
|
||||
* It is named after what is put in as values.
|
||||
*/
|
||||
//InputMapEntry m_input_map[GA_COUNT];
|
||||
|
||||
void setFilename ();
|
||||
|
||||
// Attributes which have setter/getter
|
||||
int m_sfx;
|
||||
int m_music;
|
||||
std::string m_warning;
|
||||
/** Default number of karts. */
|
||||
int m_num_karts;
|
||||
/** Default number of laps. */
|
||||
int m_num_laps;
|
||||
/** Default difficulty. */
|
||||
int m_difficulty;
|
||||
|
||||
/** Index of current background image. */
|
||||
int m_background_index;
|
||||
|
||||
//void readStickConfigs(const lisp::Lisp *);
|
||||
|
||||
//void writeStickConfigs(lisp::Writer *);
|
||||
|
||||
/** Iterates through the input mapping and unsets all
|
||||
* where the given input occurs.
|
||||
*
|
||||
* This makes sure an input is not bound multiple times.
|
||||
*/
|
||||
void unsetDuplicates(PlayerAction, const Input &);
|
||||
|
||||
/** Creates an GameAction->Input mapping with one Input */
|
||||
//void setStaticAction(StaticAction, const Input &);
|
||||
|
||||
/** Creates an GameAction->Input mapping with two Inputs */
|
||||
//void setStaticAction(StaticAction, const Input &, const Input &);
|
||||
|
||||
/** Creates an GameAction->Input mapping with three Inputs */
|
||||
//void setStaticAction(StaticAction, const Input &, const Input &, const Input &);
|
||||
|
||||
/** Creates an GameAction->Input mapping with four Inputs */
|
||||
//void setStaticAction(StaticAction, const Input &, const Input &, const Input &, const Input &);
|
||||
|
||||
//std::string getInputAsString(const Input &);
|
||||
|
||||
/** Creates an ActionMap for the GameAction values of the specified
|
||||
* range.
|
||||
*/
|
||||
// ActionMap *newActionMap(const int, const int);
|
||||
|
||||
/** Sets the Input for the given GameAction. Includes a check for
|
||||
* duplicates and automatic removing of the other candidate(s).
|
||||
*
|
||||
* For use when reading from file.
|
||||
*/
|
||||
void setInput(PlayerAction, const Input &);
|
||||
|
||||
public:
|
||||
enum UC_Mode {UC_ENABLE, UC_DISABLE, UC_TEMPORARY_DISABLE};
|
||||
|
||||
std::string m_warning;
|
||||
int CheckAndCreateDir();
|
||||
|
||||
// Attributes that are accessed directly.
|
||||
bool m_gamepad_debug;
|
||||
int m_track_debug;
|
||||
bool m_bullet_debug;
|
||||
bool m_fullscreen;
|
||||
bool m_no_start_screen;
|
||||
bool m_graphical_effects;
|
||||
bool m_display_fps;
|
||||
int m_profile; // Positive number: time in seconds, neg: # laps. (used to profile AI)
|
||||
bool m_print_kart_sizes; // print all kart sizes
|
||||
// 0 if no profiling. Never saved in config file!
|
||||
float m_sfx_volume;
|
||||
float m_music_volume;
|
||||
|
||||
int m_max_fps;
|
||||
std::string m_item_style;
|
||||
std::string m_username;
|
||||
std::string m_background_music;
|
||||
std::string m_kart_group; /**< Kart group used last. */
|
||||
std::string m_track_group; /**< Track group used last. */
|
||||
std::string m_last_track; /**< name of the last track used. */
|
||||
std::string m_server_address;
|
||||
int m_server_port;
|
||||
int m_width;
|
||||
int m_height;
|
||||
int m_prev_width;
|
||||
int m_prev_height;
|
||||
bool m_prev_windowed;
|
||||
bool m_crashed;
|
||||
std::vector<std::string>
|
||||
m_blacklist_res;
|
||||
Player m_player[PLAYERS];
|
||||
bool m_log_errors;
|
||||
|
||||
UserConfig();
|
||||
UserConfig(const std::string& filename);
|
||||
~UserConfig();
|
||||
void setDefaults();
|
||||
void setMusic(int m) { m_music = m; }
|
||||
void setSFX(int m) { m_sfx = m; }
|
||||
bool doMusic() const { return m_music == UC_ENABLE;}
|
||||
bool doSFX() const { return m_sfx == UC_ENABLE;}
|
||||
/** Sets the default number of karts. This is only used to store
|
||||
* this number in the user config file as a default next time. */
|
||||
void setDefaultNumKarts(int n) { m_num_karts = n; }
|
||||
/** Returns the default number of karts. */
|
||||
int getDefaultNumKarts() const { return m_num_karts; }
|
||||
|
||||
/** Sets the default number of laps. This is only used to store
|
||||
* this number in the user config file as a default next time. */
|
||||
void setDefaultNumLaps(int n) { m_num_laps = n; }
|
||||
/** Returns the default number of laps. */
|
||||
int getDefaultNumLaps() const { return m_num_laps; }
|
||||
|
||||
/** Sets the default difficulty. This is only used to store
|
||||
* this number in the user config file as a default next time. */
|
||||
void setDefaultNumDifficulty(int n) { m_difficulty = n; }
|
||||
/** Returns the default difficulty. */
|
||||
int getDefaultDifficulty() const { return m_difficulty; }
|
||||
void nextBackgroundIndex();
|
||||
|
||||
/** Get the index of the background image. */
|
||||
int getBackgroundIndex() const { return m_background_index; }
|
||||
|
||||
void loadConfig();
|
||||
void loadConfig(const std::string& filename);
|
||||
void saveConfig() { saveConfig(m_filename); }
|
||||
void saveConfig(const std::string& filename);
|
||||
/*
|
||||
void addStickConfig(UserConfig::StickConfig *sc)
|
||||
{m_stickconfigs.push_back(sc);}
|
||||
const std::vector<StickConfig *>
|
||||
*getStickConfigs() const { return &m_stickconfigs; }
|
||||
*/
|
||||
|
||||
const std::string
|
||||
&getWarning() { return m_warning; }
|
||||
void resetWarning() { m_warning=""; }
|
||||
|
@ -106,10 +106,10 @@ void IrrDriver::initDevice()
|
||||
for(int bits=32; bits>15; bits -=8)
|
||||
{
|
||||
m_device = createDevice(type,
|
||||
core::dimension2d<s32>(user_config->m_width,
|
||||
user_config->m_height ),
|
||||
core::dimension2d<s32>(UserConfigParams::m_width,
|
||||
UserConfigParams::m_height ),
|
||||
bits, //bits per pixel
|
||||
user_config->m_fullscreen,
|
||||
UserConfigParams::m_fullscreen,
|
||||
false, // stencil buffers
|
||||
false, // vsync
|
||||
this // event receiver
|
||||
@ -154,8 +154,8 @@ void IrrDriver::changeResolution()
|
||||
m_device->getVideoDriver()->beginScene(true, true, video::SColor(255,100,101,140));
|
||||
m_device->getVideoDriver()->draw2DRectangle( SColor(255, 0, 0, 0),
|
||||
core::rect<s32>(0, 0,
|
||||
user_config->m_prev_width,
|
||||
user_config->m_prev_height) );
|
||||
UserConfigParams::m_prev_width,
|
||||
UserConfigParams::m_prev_height) );
|
||||
m_device->getVideoDriver()->endScene();
|
||||
|
||||
// startScreen -> removeTextures();
|
||||
@ -426,7 +426,7 @@ void IrrDriver::update(float dt)
|
||||
if(!m_device->run()) return;
|
||||
m_device->getVideoDriver()->beginScene(true, true, video::SColor(255,100,101,140));
|
||||
#ifdef HAVE_GLUT
|
||||
if(user_config->m_bullet_debug && race_manager->raceIsActive())
|
||||
if(UserConfigParams::m_bullet_debug && race_manager->raceIsActive())
|
||||
{
|
||||
// Use bullets debug drawer
|
||||
GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 };
|
||||
|
@ -86,5 +86,5 @@ void Scene::draw(float dt)
|
||||
glDisable ( GL_FOG ) ;
|
||||
}
|
||||
|
||||
glViewport ( 0, 0, user_config->m_width, user_config->m_height ) ;
|
||||
glViewport ( 0, 0, UserConfigParams::m_width, UserConfigParams::m_height ) ;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ void Font::Print(const char *text, int size,
|
||||
#ifdef HAVE_IRRLICHT
|
||||
#else
|
||||
// Only scale for lower resolution
|
||||
float fontScaling = user_config->m_width<800 ? ((float)user_config->m_width/800.0f)
|
||||
float fontScaling = UserConfigParams::m_width<800 ? ((float)UserConfigParams::m_width/800.0f)
|
||||
: 1.0f;
|
||||
int sz = (int)(size*std::max(scale_x,scale_y)*fontScaling);
|
||||
|
||||
@ -87,14 +87,14 @@ void Font::Print(const char *text, int size,
|
||||
if(x==CENTER_OF_SCREEN)
|
||||
{
|
||||
if(left ==-1) left = 0;
|
||||
if(right==-1) right = user_config->m_width-1;
|
||||
if(right==-1) right = UserConfigParams::m_width-1;
|
||||
int width = right-left+1;
|
||||
x = (width - W)/2 + left;
|
||||
}
|
||||
|
||||
if(y==CENTER_OF_SCREEN)
|
||||
{
|
||||
if(top == -1) top = user_config->m_height-1;
|
||||
if(top == -1) top = UserConfigParams::m_height-1;
|
||||
if(bottom == -1) bottom = 0;
|
||||
int height = top-bottom+1;
|
||||
y = (height - H)/2 + bottom;
|
||||
@ -128,7 +128,7 @@ void Font::PrintBold(const std::string &text, int size, int x, int y,
|
||||
int left, int right, int top, int bottom )
|
||||
{
|
||||
// Only scale for lower resolution
|
||||
float fontScaling = user_config->m_width<800 ? ((float)user_config->m_width/800.0f)
|
||||
float fontScaling = UserConfigParams::m_width<800 ? ((float)UserConfigParams::m_width/800.0f)
|
||||
: 1.0f;
|
||||
int sz = (int)(size*std::max(scale_x,scale_y)*fontScaling);
|
||||
|
||||
@ -140,14 +140,14 @@ void Font::PrintBold(const std::string &text, int size, int x, int y,
|
||||
if(x==CENTER_OF_SCREEN)
|
||||
{
|
||||
if(left ==-1) left = 0;
|
||||
if(right==-1) right = user_config->m_width-1;
|
||||
if(right==-1) right = UserConfigParams::m_width-1;
|
||||
int width = right-left+1;
|
||||
x = (width - W)/2 + left;
|
||||
}
|
||||
|
||||
if(y==CENTER_OF_SCREEN)
|
||||
{
|
||||
if(top == -1) top = user_config->m_height-1;
|
||||
if(top == -1) top = UserConfigParams::m_height-1;
|
||||
if(bottom == -1) bottom = 0;
|
||||
int height = top-bottom+1;
|
||||
y = (height - H)/2 + bottom;
|
||||
@ -199,8 +199,8 @@ void Font::getBBox(const std::string &text, int size, bool italic,
|
||||
{
|
||||
#ifndef HAVE_IRRLICHT
|
||||
m_fnt->getBBox(text.c_str(), (float)size, italic, left, right, bot, top);
|
||||
if(user_config->m_width<800) {
|
||||
float fract=(float)user_config->m_width/800.0f;
|
||||
if(UserConfigParams::m_width<800) {
|
||||
float fract=(float)UserConfigParams::m_width/800.0f;
|
||||
*left *= fract;
|
||||
*right *= fract;
|
||||
if(bot) *bot *= fract;
|
||||
@ -228,8 +228,8 @@ void Font::getBBoxMultiLine(const std::string &text, int size, bool italic,
|
||||
if(right)*right = std::max(*right, r);
|
||||
if(top) *top = std::max(*top, t);
|
||||
}
|
||||
if(user_config->m_width<800) {
|
||||
float fract=(float)user_config->m_width/800.0f;
|
||||
if(UserConfigParams::m_width<800) {
|
||||
float fract=(float)UserConfigParams::m_width/800.0f;
|
||||
*left *= fract;
|
||||
*right *= fract;
|
||||
if(bot) *bot *= fract;
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "gui/engine.hpp"
|
||||
#include "gui/modaldialog.hpp"
|
||||
#include "gui/options_screen.hpp"
|
||||
#include "utils/translation.hpp"
|
||||
|
||||
using namespace irr;
|
||||
@ -37,6 +38,15 @@ void ModalDialog::dismiss()
|
||||
modalWindow = NULL;
|
||||
}
|
||||
|
||||
void ModalDialog::onEnterPressed()
|
||||
{
|
||||
if(modalWindow != NULL) modalWindow->onEnterPressedInternal();
|
||||
}
|
||||
|
||||
void ModalDialog::onEnterPressedInternal()
|
||||
{
|
||||
}
|
||||
|
||||
ModalDialog::ModalDialog(const float percentWidth, const float percentHeight)
|
||||
{
|
||||
const core::dimension2d<s32>& frame_size = GUIEngine::getDriver()->getCurrentRenderTargetSize();
|
||||
@ -82,6 +92,13 @@ EnterPlayerNameDialog::EnterPlayerNameDialog(const float w, const float h) :
|
||||
const int textAreaYFrom = bottomYFrom + bottomHeight/2 - textHeight/2;
|
||||
|
||||
core::rect< s32 > area_bottom(50, textAreaYFrom - 10, m_area.getWidth()-50, textAreaYFrom + textHeight + 10);
|
||||
IGUIEditBox* textCtrl = GUIEngine::getGUIEnv()->addEditBox (L"", area_bottom, true /* border */, m_irrlicht_window);
|
||||
textCtrl = GUIEngine::getGUIEnv()->addEditBox (L"", area_bottom, true /* border */, m_irrlicht_window);
|
||||
GUIEngine::getGUIEnv()->setFocus(textCtrl);
|
||||
}
|
||||
|
||||
void EnterPlayerNameDialog::onEnterPressedInternal()
|
||||
{
|
||||
stringw playerName = textCtrl->getText();
|
||||
StateManager::gotNewPlayerName( playerName );
|
||||
ModalDialog::dismiss();
|
||||
}
|
||||
|
@ -34,10 +34,13 @@ protected:
|
||||
*/
|
||||
ModalDialog(const float percentWidth, const float percentHeight);
|
||||
|
||||
virtual void onEnterPressedInternal();
|
||||
|
||||
public:
|
||||
virtual ~ModalDialog();
|
||||
|
||||
static void dismiss();
|
||||
static void onEnterPressed();
|
||||
};
|
||||
|
||||
class PressAKeyDialog : public ModalDialog
|
||||
@ -51,9 +54,11 @@ public:
|
||||
|
||||
class EnterPlayerNameDialog : public ModalDialog
|
||||
{
|
||||
IGUIEditBox* textCtrl;
|
||||
public:
|
||||
/**
|
||||
* Creates a modal dialog with given percentage of screen width and height
|
||||
*/
|
||||
EnterPlayerNameDialog(const float percentWidth, const float percentHeight);
|
||||
void onEnterPressedInternal();
|
||||
};
|
||||
|
@ -60,8 +60,8 @@ namespace StateManager
|
||||
CheckBoxWidget* music = getCurrentScreen()->getWidget<CheckBoxWidget>("music_enabled");
|
||||
|
||||
// ---- audio enables/disables
|
||||
sfx->setState( user_config->doSFX() );
|
||||
music->setState( user_config->doMusic() );
|
||||
sfx->setState( UserConfigParams::m_sfx );
|
||||
music->setState( UserConfigParams::m_music );
|
||||
|
||||
// ---- video modes
|
||||
{
|
||||
@ -71,7 +71,7 @@ namespace StateManager
|
||||
|
||||
CheckBoxWidget* full = getCurrentScreen()->getWidget<CheckBoxWidget>("fullscreen");
|
||||
assert( full != NULL );
|
||||
full->setState( user_config->m_fullscreen );
|
||||
full->setState( UserConfigParams::m_fullscreen );
|
||||
|
||||
// --- get resolution list from irrlicht the first time
|
||||
if(!getCurrentScreen()->m_inited)
|
||||
@ -123,7 +123,7 @@ namespace StateManager
|
||||
char name[32];
|
||||
sprintf( name, "%ix%i", w, h );
|
||||
|
||||
if(w == user_config->m_width && h == user_config->m_height)
|
||||
if(w == UserConfigParams::m_width && h == UserConfigParams::m_height)
|
||||
{
|
||||
//std::cout << "************* Detected right resolution!!! " << n << "\n";
|
||||
// that's the current one
|
||||
@ -157,7 +157,7 @@ namespace StateManager
|
||||
sample_sound->volume(1);
|
||||
|
||||
sfx_manager->setMasterSFXVolume( w->getValue()/10.0f );
|
||||
user_config->m_sfx_volume = w->getValue()/10.0f;
|
||||
UserConfigParams::m_sfx_volume = w->getValue()/10.0f;
|
||||
|
||||
// play a sample sound to show the user what this volume is like
|
||||
sample_sound->position ( Vec3(0,0,0) );
|
||||
@ -172,8 +172,9 @@ namespace StateManager
|
||||
{
|
||||
CheckBoxWidget* w = dynamic_cast<CheckBoxWidget*>(widget);
|
||||
|
||||
user_config->setMusic(w->getState() ? UserConfig::UC_ENABLE : UserConfig::UC_DISABLE);
|
||||
|
||||
UserConfigParams::m_music = w->getState();
|
||||
std::cout << "music state is now " << (bool)UserConfigParams::m_music << std::endl;
|
||||
|
||||
if(w->getState() == false)
|
||||
sound_manager->stopMusic();
|
||||
else
|
||||
@ -183,14 +184,14 @@ namespace StateManager
|
||||
{
|
||||
CheckBoxWidget* w = dynamic_cast<CheckBoxWidget*>(widget);
|
||||
|
||||
user_config->setSFX(w->getState() ? UserConfig::UC_ENABLE : UserConfig::UC_DISABLE);
|
||||
UserConfigParams::m_sfx = w->getState();
|
||||
}
|
||||
else if(name == "apply_resolution")
|
||||
{
|
||||
using namespace GUIEngine;
|
||||
|
||||
user_config->m_prev_width = user_config->m_width;
|
||||
user_config->m_prev_height = user_config->m_height;
|
||||
UserConfigParams::m_prev_width = UserConfigParams::m_width;
|
||||
UserConfigParams::m_prev_height = UserConfigParams::m_height;
|
||||
|
||||
RibbonGridWidget* w1 = getCurrentScreen()->getWidget<RibbonGridWidget>("resolutions");
|
||||
assert(w1 != NULL);
|
||||
@ -207,9 +208,9 @@ namespace StateManager
|
||||
CheckBoxWidget* w2 = getCurrentScreen()->getWidget<CheckBoxWidget>("fullscreen");
|
||||
assert(w2 != NULL);
|
||||
|
||||
user_config->m_width = w;
|
||||
user_config->m_height = h;
|
||||
user_config->m_fullscreen = w2->getState();
|
||||
UserConfigParams::m_width = w;
|
||||
UserConfigParams::m_height = h;
|
||||
UserConfigParams::m_fullscreen = w2->getState();
|
||||
irr_driver->changeResolution();
|
||||
}
|
||||
|
||||
@ -480,6 +481,12 @@ namespace StateManager
|
||||
input_manager->getDeviceList()->serialize();
|
||||
}
|
||||
|
||||
void gotNewPlayerName(const stringw& newName)
|
||||
{
|
||||
std::cout << "got player name : " << stringc( newName ).c_str() << std::endl;
|
||||
// TODO
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// main call (from StateManager); dispatches the call to a specialissed function as needed
|
||||
void menuEventOptions(Widget* widget, const std::string& name)
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define __HEADER_OPTIONS_SCREEN_HPP__
|
||||
|
||||
#include <string>
|
||||
#include "irrlicht.h"
|
||||
|
||||
namespace GUIEngine
|
||||
{
|
||||
@ -33,6 +34,7 @@ namespace StateManager
|
||||
|
||||
void menuEventOptions(GUIEngine::Widget* widget, const std::string& name);
|
||||
void gotSensedInput(Input* sensedInput);
|
||||
void gotNewPlayerName(const irr::core::stringw& newName);
|
||||
|
||||
}
|
||||
|
||||
|
@ -65,14 +65,14 @@ RaceGUI::RaceGUI()
|
||||
|
||||
#ifdef HAVE_IRRLICHT
|
||||
gui::IGUIEnvironment *gui_env = irr_driver->getGUI();
|
||||
core::rect<s32> pos(user_config->m_width-60, 10,
|
||||
user_config->m_width, 50);
|
||||
core::rect<s32> pos(UserConfigParams::m_width-60, 10,
|
||||
UserConfigParams::m_width, 50);
|
||||
m_time = gui_env->addStaticText(L"", pos);
|
||||
m_time->setOverrideFont(irr_driver->getRaceFont());
|
||||
|
||||
int icon_width=40;
|
||||
int icon_player_width=50;
|
||||
if(user_config->m_height<600)
|
||||
if(UserConfigParams::m_height<600)
|
||||
{
|
||||
icon_width = 27;
|
||||
icon_player_width = 35;
|
||||
@ -87,8 +87,8 @@ RaceGUI::RaceGUI()
|
||||
// FIXME: The icons needs to be resized.
|
||||
m_icons[i] = irr_driver->getGUI()->addImage(m->getTexture(), p);
|
||||
}
|
||||
core::rect<s32> p(user_config->m_width-10, 0,
|
||||
user_config->m_width+10, 10);
|
||||
core::rect<s32> p(UserConfigParams::m_width-10, 0,
|
||||
UserConfigParams::m_width+10, 10);
|
||||
m_attachment_icon = irr_driver->getGUI()->addImage(p);
|
||||
#else
|
||||
m_speed_back_icon = material_manager->getMaterial("speedback.rgb");
|
||||
@ -145,7 +145,7 @@ void RaceGUI::drawFPS ()
|
||||
m_fps_counter = 0;
|
||||
m_fps_timer.setMaxDelta(1000);
|
||||
}
|
||||
font_race->PrintShadow(m_fps_string,48, 0, user_config->m_height-50);
|
||||
font_race->PrintShadow(m_fps_string,48, 0, UserConfigParams::m_height-50);
|
||||
*/
|
||||
} // drawFPS
|
||||
|
||||
@ -163,8 +163,8 @@ void RaceGUI::drawTimer ()
|
||||
#ifdef HAVE_IRRLICHT
|
||||
m_time->setText(core::stringw(str).c_str());
|
||||
#else
|
||||
font_race->PrintShadow(str, 60, user_config->m_width-260,
|
||||
user_config->m_height-64);
|
||||
font_race->PrintShadow(str, 60, UserConfigParams::m_width-260,
|
||||
UserConfigParams::m_height-64);
|
||||
#endif
|
||||
} // drawTimer
|
||||
|
||||
@ -226,7 +226,7 @@ void RaceGUI::drawPlayerIcons (const KartIconDisplayInfo* info)
|
||||
int y;
|
||||
int ICON_WIDTH=40;
|
||||
int ICON_PLAYER_WIDTH=50;
|
||||
if(user_config->m_height<600)
|
||||
if(UserConfigParams::m_height<600)
|
||||
{
|
||||
ICON_WIDTH = 27;
|
||||
ICON_PLAYER_WIDTH = 35;
|
||||
@ -245,7 +245,7 @@ void RaceGUI::drawPlayerIcons (const KartIconDisplayInfo* info)
|
||||
if(kart->isEliminated()) continue;
|
||||
const int position = kart->getPosition();
|
||||
|
||||
y = user_config->m_height*7/8-20 - ( (position == -1 ? i : position-1)*(ICON_PLAYER_WIDTH+2));
|
||||
y = UserConfigParams::m_height*7/8-20 - ( (position == -1 ? i : position-1)*(ICON_PLAYER_WIDTH+2));
|
||||
|
||||
GLfloat COLOR[] = {info[i].r, info[i].g, info[i].b, 1.0f};
|
||||
font_race->PrintShadow(info[i].time.c_str(), 30, ICON_PLAYER_WIDTH+x, y+5, COLOR);
|
||||
@ -330,8 +330,8 @@ void RaceGUI::drawPowerupIcons ( Kart* player_kart, int offset_x,
|
||||
if(powerup->getType() == POWERUP_NOTHING) return;
|
||||
|
||||
// Originally the hardcoded sizes were 320-32 and 400
|
||||
int x1 = (int)((user_config->m_width/2-32) * ratio_x) + offset_x ;
|
||||
int y1 = (int)(user_config->m_height*5/6 * ratio_y) + offset_y;
|
||||
int x1 = (int)((UserConfigParams::m_width/2-32) * ratio_x) + offset_x ;
|
||||
int y1 = (int)(UserConfigParams::m_height*5/6 * ratio_y) + offset_y;
|
||||
|
||||
int nSize=(int)(64.0f*std::min(ratio_x, ratio_y));
|
||||
#ifdef HAVE_IRRLICHT
|
||||
@ -375,10 +375,10 @@ void RaceGUI::drawEnergyMeter ( Kart *player_kart, int offset_x, int offset_y,
|
||||
{
|
||||
float state = (float)(player_kart->getEnergy()) /
|
||||
MAX_ITEMS_COLLECTED;
|
||||
int x = (int)((user_config->m_width-24) * ratio_x) + offset_x;
|
||||
int x = (int)((UserConfigParams::m_width-24) * ratio_x) + offset_x;
|
||||
int y = (int)(250 * ratio_y) + offset_y;
|
||||
int w = (int)(16 * ratio_x);
|
||||
int h = (int)(user_config->m_height/4 * ratio_y);
|
||||
int h = (int)(UserConfigParams::m_height/4 * ratio_y);
|
||||
int wl = (int)(ratio_x);
|
||||
if(wl < 1)
|
||||
wl = 1;
|
||||
@ -514,7 +514,7 @@ void RaceGUI::drawSpeed(Kart* kart, int offset_x, int offset_y,
|
||||
#define SPEEDWIDTH 128
|
||||
int width = (int)(SPEEDWIDTH*minRatio);
|
||||
int height = (int)(SPEEDWIDTH*minRatio);
|
||||
offset_x += (int)((user_config->m_width-10)*ratio_x) - width;
|
||||
offset_x += (int)((UserConfigParams::m_width-10)*ratio_x) - width;
|
||||
offset_y += (int)(10*ratio_y);
|
||||
|
||||
#ifdef HAVE_IRRLICHT
|
||||
@ -634,7 +634,7 @@ void RaceGUI::drawAllMessages(Kart* player_kart, int offset_x, int offset_y,
|
||||
int y;
|
||||
// First line of text somewhat under the top of the screen. For now
|
||||
// start just under the timer display
|
||||
y = (int)(ratio_y*(user_config->m_height -164)+offset_y);
|
||||
y = (int)(ratio_y*(UserConfigParams::m_height -164)+offset_y);
|
||||
// The message are displayed in reverse order, so that a multi-line
|
||||
// message (addMessage("1", ...); addMessage("2",...) is displayed
|
||||
// in the right order: "1" on top of "2"
|
||||
@ -651,7 +651,7 @@ void RaceGUI::drawAllMessages(Kart* player_kart, int offset_x, int offset_y,
|
||||
Font::CENTER_OF_SCREEN, y,
|
||||
COLORS,
|
||||
ratio_x, ratio_y,
|
||||
offset_x, offset_x+(int)(user_config->m_width*ratio_x));
|
||||
offset_x, offset_x+(int)(UserConfigParams::m_width*ratio_x));
|
||||
// Add 20% of font size as space between the lines
|
||||
y-=msg.m_font_size*12/10;
|
||||
|
||||
@ -712,7 +712,7 @@ void RaceGUI::drawStatusText(const float dt)
|
||||
glAlphaFunc ( GL_GREATER, 0.1f);
|
||||
glEnable ( GL_BLEND );
|
||||
|
||||
glOrtho ( 0, user_config->m_width, 0, user_config->m_height, 0, 100 ) ;
|
||||
glOrtho ( 0, UserConfigParams::m_width, 0, UserConfigParams::m_height, 0, 100 ) ;
|
||||
switch (RaceManager::getWorld()->getPhase())
|
||||
{
|
||||
case READY_PHASE:
|
||||
@ -797,12 +797,12 @@ void RaceGUI::drawStatusText(const float dt)
|
||||
|
||||
if(numPlayers == 2)
|
||||
{
|
||||
if(pla == 0) offset_y = user_config->m_height/2;
|
||||
if(pla == 0) offset_y = UserConfigParams::m_height/2;
|
||||
}
|
||||
else if (numPlayers == 3)
|
||||
{
|
||||
if (pla == 0 || pla == 1)
|
||||
offset_y = user_config->m_height/2;
|
||||
offset_y = UserConfigParams::m_height/2;
|
||||
else
|
||||
{
|
||||
// Fixes width for player 3
|
||||
@ -810,16 +810,16 @@ void RaceGUI::drawStatusText(const float dt)
|
||||
}
|
||||
|
||||
if (pla == 1)
|
||||
offset_x = user_config->m_width/2;
|
||||
offset_x = UserConfigParams::m_width/2;
|
||||
|
||||
}
|
||||
else if(numPlayers == 4)
|
||||
{
|
||||
if(pla == 0 || pla == 1)
|
||||
offset_y = user_config->m_height/2;
|
||||
offset_y = UserConfigParams::m_height/2;
|
||||
|
||||
if((pla == 1) || pla == 3)
|
||||
offset_x = user_config->m_width/2;
|
||||
offset_x = UserConfigParams::m_width/2;
|
||||
}
|
||||
|
||||
Kart* player_kart = RaceManager::getWorld()->getLocalPlayerKart(pla);
|
||||
@ -836,12 +836,12 @@ void RaceGUI::drawStatusText(const float dt)
|
||||
|
||||
if(player_kart->hasViewBlockedByPlunger())
|
||||
{
|
||||
const int screen_width = (numPlayers > 2) ? user_config->m_width/2 : user_config->m_width;
|
||||
const int plunger_size = (numPlayers > 1) ? user_config->m_height/2 : user_config->m_height;
|
||||
const int screen_width = (numPlayers > 2) ? UserConfigParams::m_width/2 : UserConfigParams::m_width;
|
||||
const int plunger_size = (numPlayers > 1) ? UserConfigParams::m_height/2 : UserConfigParams::m_height;
|
||||
int plunger_x = offset_x + screen_width/2 - plunger_size/2;
|
||||
|
||||
if (numPlayers == 3 && pla > 1)
|
||||
plunger_x = offset_x + user_config->m_width/2 - plunger_size/2;
|
||||
plunger_x = offset_x + UserConfigParams::m_width/2 - plunger_size/2;
|
||||
|
||||
#ifndef HAVE_IRRLICHT
|
||||
m_plunger_face->getState()->force();
|
||||
@ -865,7 +865,7 @@ void RaceGUI::drawStatusText(const float dt)
|
||||
|
||||
|
||||
drawMap();
|
||||
if ( user_config->m_display_fps ) drawFPS();
|
||||
if ( UserConfigParams::m_display_fps ) drawFPS();
|
||||
|
||||
drawPlayerIcons(info);
|
||||
|
||||
|
@ -687,6 +687,13 @@ bool Screen::OnEvent(const SEvent& event)
|
||||
|
||||
break;
|
||||
}
|
||||
case EGET_EDITBOX_ENTER:
|
||||
{
|
||||
// currently, enter pressed in text ctrl events can only happen in dialogs.
|
||||
// FIXME : find a cleaner way to route the event to its proper location
|
||||
ModalDialog::onEnterPressed();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
} // end switch
|
||||
|
@ -143,6 +143,8 @@ namespace SkinConfig
|
||||
std::cerr << "Unknown node in XML file : " << node->getName().c_str() << std::endl;
|
||||
}
|
||||
}// nend for
|
||||
|
||||
delete root;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -157,9 +157,9 @@ namespace StateManager
|
||||
{
|
||||
RibbonWidget* w = getCurrentScreen()->getWidget<RibbonWidget>("difficulty");
|
||||
assert( w != NULL );
|
||||
w->setSelection(user_config->getDefaultDifficulty());
|
||||
w->setSelection(UserConfigParams::m_difficulty);
|
||||
|
||||
race_manager->setDifficulty( (RaceManager::Difficulty)user_config->getDefaultDifficulty() );
|
||||
race_manager->setDifficulty( (RaceManager::Difficulty)(int)UserConfigParams::m_difficulty );
|
||||
|
||||
SpinnerWidget* kartamount = getCurrentScreen()->getWidget<SpinnerWidget>("aikartamount");
|
||||
race_manager->setNumKarts( kartamount->getValue() + 1 );
|
||||
@ -216,7 +216,7 @@ namespace StateManager
|
||||
}
|
||||
/*
|
||||
289 race_manager->setDifficulty((RaceManager::Difficulty)m_difficulty);
|
||||
290 user_config->setDefaultNumDifficulty(m_difficulty);
|
||||
290 UserConfigParams::setDefaultNumDifficulty(m_difficulty);
|
||||
|
||||
// if there is no AI, there's no point asking the player for the amount of karts.
|
||||
299 // It will always be the same as the number of human players
|
||||
@ -228,14 +228,14 @@ namespace StateManager
|
||||
305 else
|
||||
306 {
|
||||
307 race_manager->setNumKarts(m_num_karts);
|
||||
308 user_config->setDefaultNumKarts(race_manager->getNumKarts());
|
||||
308 UserConfigParams::setDefaultNumKarts(race_manager->getNumKarts());
|
||||
309 }
|
||||
|
||||
311 if( race_manager->getMajorMode() != RaceManager::MAJOR_MODE_GRAND_PRIX &&
|
||||
312 RaceManager::modeHasLaps( race_manager->getMinorMode() ) )
|
||||
313 {
|
||||
314 race_manager->setNumLaps( m_num_laps );
|
||||
315 user_config->setDefaultNumLaps(m_num_laps);
|
||||
315 UserConfigParams::setDefaultNumLaps(m_num_laps);
|
||||
316 }
|
||||
317 // Might still be set from a previous challenge
|
||||
318 race_manager->setCoinTarget(0);
|
||||
@ -250,10 +250,10 @@ namespace StateManager
|
||||
|
||||
race_manager->setTrack(argv[i+1]);
|
||||
|
||||
user_config->setDefaultNumKarts(stk_config->m_max_karts);
|
||||
race_manager->setNumKarts(user_config->getDefaultNumKarts() );
|
||||
UserConfigParams::setDefaultNumKarts(stk_config->m_max_karts);
|
||||
race_manager->setNumKarts(UserConfigParams::getDefaultNumKarts() );
|
||||
|
||||
user_config->getDefaultNumKarts()
|
||||
UserConfigParams::getDefaultNumKarts()
|
||||
|
||||
StateManager::enterGameState();
|
||||
race_manager->startNew();
|
||||
|
@ -993,6 +993,7 @@
|
||||
951C35BD0FC066ED00A48379 /* credits.hpp */,
|
||||
9505577A0F696A900056E88C /* engine.cpp */,
|
||||
9505577B0F696A900056E88C /* engine.hpp */,
|
||||
95C2AE370F296541000D3E5D /* enet */,
|
||||
95C1E3FF0F699427005D33E6 /* font.cpp */,
|
||||
95C1E4020F69943D005D33E6 /* font.hpp */,
|
||||
954A57DB0FEC5AE40073C16C /* modaldialog.cpp */,
|
||||
@ -1108,7 +1109,6 @@
|
||||
95C2AC360F296540000D3E5D /* bullet */,
|
||||
95D950CC0FE473CA002E10AD /* config */,
|
||||
95C2AE250F296541000D3E5D /* challenges */,
|
||||
95C2AE370F296541000D3E5D /* enet */,
|
||||
950557790F696A900056E88C /* gui */,
|
||||
95C2AE870F296542000D3E5D /* graphics */,
|
||||
95C65D750F532F7D00BE7BA7 /* io */,
|
||||
@ -1512,8 +1512,8 @@
|
||||
95C2AE720F296542000D3E5D /* win32.c */,
|
||||
);
|
||||
name = enet;
|
||||
path = ../../enet;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
path = games/supertuxkart/src/enet;
|
||||
sourceTree = SYSTEM_DEVELOPER_DIR;
|
||||
};
|
||||
95C2AE540F296541000D3E5D /* include */ = {
|
||||
isa = PBXGroup;
|
||||
|
@ -130,8 +130,8 @@ void InputManager::handleStaticAction(int key, int value)
|
||||
break;
|
||||
#endif
|
||||
case KEY_F12:
|
||||
user_config->m_display_fps = !user_config->m_display_fps;
|
||||
if(user_config->m_display_fps)
|
||||
UserConfigParams::m_display_fps = !UserConfigParams::m_display_fps;
|
||||
if(UserConfigParams::m_display_fps)
|
||||
{
|
||||
getRaceGUI()->resetFPSCounter();
|
||||
}
|
||||
@ -222,7 +222,7 @@ void InputManager::input(Input::InputType type, int deviceID, int btnID, int axi
|
||||
// Stores the sensed input when the button/key/axes/<whatever> is
|
||||
// released only and is not used in a fixed mapping.
|
||||
//else
|
||||
//if (!user_config->isFixedInput(type, id0, id1, id2) ) // ignore static actions (TODO)
|
||||
//if (!UserConfigParams::isFixedInput(type, id0, id1, id2) ) // ignore static actions (TODO)
|
||||
{
|
||||
// See if the new input should be stored. This happens if:
|
||||
// 1) the value is larger
|
||||
@ -332,7 +332,7 @@ bool InputManager::input(const SEvent& event)
|
||||
if(value == -32768) continue; // ignore bogus values given by irrlicht
|
||||
#endif
|
||||
|
||||
if(user_config->m_gamepad_debug)
|
||||
if(UserConfigParams::m_gamepad_debug)
|
||||
{
|
||||
printf("axis motion: gamepad_id=%d axis=%d value=%d\n",
|
||||
event.JoystickEvent.Joystick, axis_id, value);
|
||||
@ -502,7 +502,7 @@ void InputManager::setMode(InputDriverMode new_mode)
|
||||
// Leaving boot strap mode.
|
||||
|
||||
// Installs the action map for the menu.
|
||||
// m_action_map = user_config->newMenuActionMap();
|
||||
// m_action_map = UserConfigParams::newMenuActionMap();
|
||||
|
||||
m_mode = MENU;
|
||||
|
||||
@ -544,7 +544,7 @@ void InputManager::setMode(InputDriverMode new_mode)
|
||||
// delete m_action_map;
|
||||
|
||||
// Installs the action map for the ingame mode.
|
||||
// m_action_map = user_config->newIngameActionMap();
|
||||
// m_action_map = UserConfigParams::newIngameActionMap();
|
||||
|
||||
irr_driver->hidePointer();
|
||||
|
||||
|
@ -89,7 +89,7 @@ void Attachment::clear()
|
||||
// -----------------------------------------------------------------------------
|
||||
void Attachment::hitBanana(const Item &item, int new_attachment)
|
||||
{
|
||||
if(user_config->m_profile) return;
|
||||
if(UserConfigParams::m_profile) return;
|
||||
float leftover_time = 0.0f;
|
||||
|
||||
switch(getType()) // If there already is an attachment, make it worse :)
|
||||
|
@ -217,13 +217,13 @@ void ItemManager::cleanup()
|
||||
// FIXME: This should go in a system-wide configuration file,
|
||||
// and only one of this and the hard-coded settings in
|
||||
// setDefaultItemStyle are necessary!!!
|
||||
loadItemStyle(user_config->m_item_style);
|
||||
loadItemStyle(UserConfigParams::m_item_style);
|
||||
}
|
||||
catch(std::runtime_error)
|
||||
{
|
||||
fprintf(stderr,"The item style '%s' in your configuration file does not exist.\nIt is ignored.\n",
|
||||
user_config->m_item_style.c_str());
|
||||
user_config->m_item_style="";
|
||||
UserConfigParams::m_item_style.c_str());
|
||||
UserConfigParams::m_item_style="";
|
||||
}
|
||||
|
||||
try
|
||||
|
@ -555,12 +555,12 @@ void Kart::update(float dt)
|
||||
m_attachment.update(dt);
|
||||
|
||||
//smoke drawing control point
|
||||
if ( user_config->m_graphical_effects )
|
||||
if ( UserConfigParams::m_graphical_effects )
|
||||
{
|
||||
m_smoke_system->update(dt);
|
||||
m_water_splash_system->update(dt);
|
||||
m_nitro->update(dt);
|
||||
} // user_config->m_graphical_effects
|
||||
} // UserConfigParams::m_graphical_effects
|
||||
updatePhysics(dt);
|
||||
|
||||
//kart_info.m_last_track_coords = kart_info.m_curr_track_coords;
|
||||
|
@ -161,7 +161,7 @@ void KartProperties::load(const std::string &filename, const std::string &node,
|
||||
|
||||
|
||||
// Useful when tweaking kart parameters
|
||||
if(user_config->m_print_kart_sizes)
|
||||
if(UserConfigParams::m_print_kart_sizes)
|
||||
printf("%s:\twidth: %f\tlength: %f\theight: %f\n",getIdent().c_str(),
|
||||
m_kart_model.getWidth(), m_kart_model.getLength(),
|
||||
m_kart_model.getHeight());
|
||||
|
@ -274,7 +274,7 @@ std::vector<std::string> KartPropertiesManager::getRandomKartList(int count,
|
||||
|
||||
// Add karts from the current group
|
||||
// --------------------------------
|
||||
std::vector<int> karts = getKartsInGroup(user_config->m_kart_group);
|
||||
std::vector<int> karts = getKartsInGroup(UserConfigParams::m_kart_group);
|
||||
std::vector<int>::iterator k;
|
||||
// Remove karts that are already used or generally not available
|
||||
// (i.e. locked or not available on all clients)
|
||||
|
@ -170,7 +170,7 @@ void PlayerKart::action(PlayerAction action, int value)
|
||||
//-----------------------------------------------------------------------------
|
||||
void PlayerKart::steer(float dt, int steer_val)
|
||||
{
|
||||
if(user_config->m_gamepad_debug)
|
||||
if(UserConfigParams::m_gamepad_debug)
|
||||
{
|
||||
printf("steering: steer_val %d ", steer_val);
|
||||
}
|
||||
@ -204,7 +204,7 @@ void PlayerKart::steer(float dt, int steer_val)
|
||||
if(m_controls.m_steer>0.0f) m_controls.m_steer=0.0f;
|
||||
} // if m_controls.m_steer<=0.0f
|
||||
} // no key is pressed
|
||||
if(user_config->m_gamepad_debug)
|
||||
if(UserConfigParams::m_gamepad_debug)
|
||||
{
|
||||
printf(" set to: %f\n", m_controls.m_steer);
|
||||
}
|
||||
|
80
src/main.cpp
80
src/main.cpp
@ -143,17 +143,17 @@ int handleCmdLinePreliminary(int argc, char **argv)
|
||||
{
|
||||
// Check that current res is not blacklisted
|
||||
std::ostringstream o;
|
||||
o << user_config->m_width << "x" << user_config->m_height;
|
||||
o << UserConfigParams::m_width << "x" << UserConfigParams::m_height;
|
||||
std::string res = o.str();
|
||||
if (std::find(user_config->m_blacklist_res.begin(),
|
||||
user_config->m_blacklist_res.end(),res) == user_config->m_blacklist_res.end())
|
||||
user_config->m_fullscreen = true;
|
||||
if (std::find(UserConfigParams::m_blacklist_res.begin(),
|
||||
UserConfigParams::m_blacklist_res.end(),res) == UserConfigParams::m_blacklist_res.end())
|
||||
UserConfigParams::m_fullscreen = true;
|
||||
else
|
||||
fprintf ( stdout, "Resolution %s has been blacklisted, so it is not available!\n", res.c_str());
|
||||
}
|
||||
else if ( !strcmp(argv[i], "--windowed") || !strcmp(argv[i], "-w"))
|
||||
{
|
||||
user_config->m_fullscreen = false;
|
||||
UserConfigParams::m_fullscreen = false;
|
||||
}
|
||||
#endif
|
||||
else if ( !strcmp(argv[i], "--screensize") || !strcmp(argv[i], "-s") )
|
||||
@ -165,13 +165,13 @@ int handleCmdLinePreliminary(int argc, char **argv)
|
||||
std::ostringstream o;
|
||||
o << width << "x" << height;
|
||||
std::string res = o.str();
|
||||
if (!user_config->m_fullscreen || std::find(user_config->m_blacklist_res.begin(),
|
||||
user_config->m_blacklist_res.end(),res) == user_config->m_blacklist_res.end())
|
||||
if (!UserConfigParams::m_fullscreen || std::find(UserConfigParams::m_blacklist_res.begin(),
|
||||
UserConfigParams::m_blacklist_res.end(),res) == UserConfigParams::m_blacklist_res.end())
|
||||
{
|
||||
user_config->m_prev_width = user_config->m_width = width;
|
||||
user_config->m_prev_height = user_config->m_height = height;
|
||||
fprintf ( stdout, "You choose to be in %dx%d.\n", user_config->m_width,
|
||||
user_config->m_height );
|
||||
UserConfigParams::m_prev_width = UserConfigParams::m_width = width;
|
||||
UserConfigParams::m_prev_height = UserConfigParams::m_height = height;
|
||||
fprintf ( stdout, "You choose to be in %dx%d.\n", (int)UserConfigParams::m_width,
|
||||
(int)UserConfigParams::m_height );
|
||||
}
|
||||
else
|
||||
fprintf ( stdout, "Resolution %s has been blacklisted, so it is not available!\n", res.c_str());
|
||||
@ -210,30 +210,30 @@ int handleCmdLine(int argc, char **argv)
|
||||
if(argv[i][0] != '-') continue;
|
||||
if(!strcmp(argv[i], "--gamepad-debug"))
|
||||
{
|
||||
user_config->m_gamepad_debug=true;
|
||||
UserConfigParams::m_gamepad_debug=true;
|
||||
}
|
||||
else if(sscanf(argv[i], "--track-debug=%d",&n)==1)
|
||||
{
|
||||
user_config->m_track_debug=n;
|
||||
UserConfigParams::m_track_debug=n;
|
||||
}
|
||||
else if(!strcmp(argv[i], "--track-debug"))
|
||||
{
|
||||
user_config->m_track_debug=1;
|
||||
UserConfigParams::m_track_debug=1;
|
||||
}
|
||||
#ifdef HAVE_GLUT
|
||||
else if(!strcmp(argv[i], "--bullet-debug"))
|
||||
{
|
||||
user_config->m_bullet_debug=1;
|
||||
UserConfigParams::m_bullet_debug=1;
|
||||
}
|
||||
#endif
|
||||
else if(!strcmp(argv[i], "--kartsize-debug"))
|
||||
{
|
||||
user_config->m_print_kart_sizes=true;
|
||||
UserConfigParams::m_print_kart_sizes=true;
|
||||
}
|
||||
else if(sscanf(argv[i], "--server=%d",&n)==1)
|
||||
{
|
||||
network_manager->setMode(NetworkManager::NW_SERVER);
|
||||
user_config->m_server_port = n;
|
||||
UserConfigParams::m_server_port = n;
|
||||
}
|
||||
else if( !strcmp(argv[i], "--server") )
|
||||
{
|
||||
@ -241,12 +241,12 @@ int handleCmdLine(int argc, char **argv)
|
||||
}
|
||||
else if( sscanf(argv[i], "--port=%d", &n) )
|
||||
{
|
||||
user_config->m_server_port=n;
|
||||
UserConfigParams::m_server_port=n;
|
||||
}
|
||||
else if( sscanf(argv[i], "--client=%s", s) )
|
||||
{
|
||||
network_manager->setMode(NetworkManager::NW_CLIENT);
|
||||
user_config->m_server_address=s;
|
||||
UserConfigParams::m_server_address=s;
|
||||
}
|
||||
else if( (!strcmp(argv[i], "--kart") && i+1<argc ))
|
||||
{
|
||||
@ -301,15 +301,15 @@ int handleCmdLine(int argc, char **argv)
|
||||
else if( (!strcmp(argv[i], "--numkarts") || !strcmp(argv[i], "-k")) &&
|
||||
i+1<argc )
|
||||
{
|
||||
user_config->setDefaultNumKarts(atoi(argv[i+1]));
|
||||
if(user_config->getDefaultNumKarts()>stk_config->m_max_karts) {
|
||||
UserConfigParams::m_num_karts = atoi(argv[i+1]);
|
||||
if(UserConfigParams::m_num_karts > stk_config->m_max_karts)
|
||||
{
|
||||
fprintf(stdout, "Number of karts reset to maximum number %d\n",
|
||||
stk_config->m_max_karts);
|
||||
user_config->setDefaultNumKarts(stk_config->m_max_karts);
|
||||
UserConfigParams::m_num_karts = stk_config->m_max_karts;
|
||||
}
|
||||
race_manager->setNumKarts(user_config->getDefaultNumKarts() );
|
||||
fprintf(stdout, "%d karts will be used.\n",
|
||||
user_config->getDefaultNumKarts());
|
||||
race_manager->setNumKarts( UserConfigParams::m_num_karts );
|
||||
fprintf(stdout, "%d karts will be used.\n", (int)UserConfigParams::m_num_karts);
|
||||
i++;
|
||||
}
|
||||
else if( !strcmp(argv[i], "--list-tracks") || !strcmp(argv[i], "-l") )
|
||||
@ -351,7 +351,7 @@ int handleCmdLine(int argc, char **argv)
|
||||
else if ( !strcmp(argv[i], "--no-start-screen")
|
||||
|| !strcmp(argv[i], "-N") )
|
||||
{
|
||||
user_config->m_no_start_screen = true;
|
||||
UserConfigParams::m_no_start_screen = true;
|
||||
//FIXME} else if ( !strcmp(argv[i], "--reverse") ) {
|
||||
//FIXME:fprintf ( stdout, "Enabling reverse mode.\n" ) ;
|
||||
//FIXME:raceSetup.reverse = 1;
|
||||
@ -387,14 +387,14 @@ int handleCmdLine(int argc, char **argv)
|
||||
*/
|
||||
else if( !strcmp(argv[i], "--log=terminal"))
|
||||
{
|
||||
user_config->m_log_errors=false;
|
||||
UserConfigParams::m_log_errors=false;
|
||||
}
|
||||
else if( !strcmp(argv[i], "--log=file"))
|
||||
{
|
||||
user_config->m_log_errors=true;
|
||||
UserConfigParams::m_log_errors=true;
|
||||
} else if( sscanf(argv[i], "--profile=%d", &n)==1)
|
||||
{
|
||||
user_config->m_profile=n;
|
||||
UserConfigParams::m_profile=n;
|
||||
if(n<0)
|
||||
{
|
||||
fprintf(stdout,"Profiling %d laps\n",-n);
|
||||
@ -402,13 +402,13 @@ int handleCmdLine(int argc, char **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Profiling: %d seconds.\n",user_config->m_profile);
|
||||
printf("Profiling: %d seconds.\n", (int)UserConfigParams::m_profile);
|
||||
race_manager->setNumLaps(999999); // profile end depends on time
|
||||
}
|
||||
}
|
||||
else if( !strcmp(argv[i], "--profile") )
|
||||
{
|
||||
user_config->m_profile=20;
|
||||
UserConfigParams::m_profile=20;
|
||||
}
|
||||
else if( sscanf(argv[i], "--history=%d", &n)==1)
|
||||
{
|
||||
@ -443,10 +443,10 @@ int handleCmdLine(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
} // for i <argc
|
||||
if(user_config->m_profile)
|
||||
if(UserConfigParams::m_profile)
|
||||
{
|
||||
user_config->setSFX(UserConfig::UC_DISABLE); // Disable sound effects
|
||||
user_config->setMusic(UserConfig::UC_DISABLE);// and music when profiling
|
||||
UserConfigParams::m_sfx = false; // Disable sound effects
|
||||
UserConfigParams::m_music = false;// and music when profiling
|
||||
}
|
||||
|
||||
return 1;
|
||||
@ -550,7 +550,7 @@ int main(int argc, char *argv[] )
|
||||
//handleCmdLine() needs InitTuxkart() so it can't be called first
|
||||
if(!handleCmdLine(argc, argv)) exit(0);
|
||||
|
||||
if (user_config->m_log_errors) //Enable logging of stdout and stderr to logfile
|
||||
if (UserConfigParams::m_log_errors) //Enable logging of stdout and stderr to logfile
|
||||
{
|
||||
std::string logoutfile = file_manager->getLogFile("stdout.log");
|
||||
std::string logerrfile = file_manager->getLogFile("stderr.log");
|
||||
@ -595,7 +595,7 @@ int main(int argc, char *argv[] )
|
||||
// prepare main menu
|
||||
StateManager::initGUI();
|
||||
|
||||
if(!user_config->m_no_start_screen) StateManager::pushMenu("main.stkgui");
|
||||
if(!UserConfigParams::m_no_start_screen) StateManager::pushMenu("main.stkgui");
|
||||
else StateManager::enterGameState();
|
||||
|
||||
// Replay a race
|
||||
@ -629,9 +629,9 @@ int main(int argc, char *argv[] )
|
||||
}
|
||||
// Not replaying
|
||||
// =============
|
||||
if(!user_config->m_profile)
|
||||
if(!UserConfigParams::m_profile)
|
||||
{
|
||||
if(user_config->m_no_start_screen)
|
||||
if(UserConfigParams::m_no_start_screen)
|
||||
{
|
||||
// Quickstart (-N)
|
||||
// ===============
|
||||
@ -664,12 +664,12 @@ int main(int argc, char *argv[] )
|
||||
if(user_config)
|
||||
{
|
||||
// In case that abort is triggered before user_config exists
|
||||
if (user_config->m_crashed) user_config->m_crashed = false;
|
||||
if (UserConfigParams::m_crashed) UserConfigParams::m_crashed = false;
|
||||
user_config->saveConfig();
|
||||
}
|
||||
if(input_manager) delete input_manager; // if early crash avoid delete NULL
|
||||
|
||||
if (user_config && user_config->m_log_errors) //close logfiles
|
||||
if (user_config && UserConfigParams::m_log_errors) //close logfiles
|
||||
{
|
||||
fclose(stderr);
|
||||
fclose(stdout);
|
||||
|
@ -82,7 +82,7 @@ void MainLoop::run()
|
||||
|
||||
// Throttle fps if more than maximum, which can reduce
|
||||
// the noise the fan on a graphics card makes
|
||||
if( dt*user_config->m_max_fps < 1000.0f)
|
||||
if( dt*UserConfigParams::m_max_fps < 1000.0f)
|
||||
{
|
||||
//SDL_Delay has a granularity of 10ms on most platforms, so
|
||||
//most likely when frames go faster than 125 frames, at times
|
||||
@ -118,7 +118,7 @@ void MainLoop::run()
|
||||
if(!race_manager->getWorld()->isFinishPhase())
|
||||
network_manager->sendUpdates();
|
||||
music_on = false;
|
||||
if(user_config->m_profile) dt=1.0f/60.0f;
|
||||
if(UserConfigParams::m_profile) dt=1.0f/60.0f;
|
||||
// In the first call dt might be large (includes loading time),
|
||||
// which can cause the camera to significantly tilt
|
||||
stk_scene->draw(RaceManager::getWorld()->getPhase()==SETUP_PHASE ? 0.0f : dt);
|
||||
@ -135,10 +135,10 @@ void MainLoop::run()
|
||||
history->update(dt);
|
||||
RaceManager::getWorld()->update(dt);
|
||||
|
||||
if(user_config->m_profile>0)
|
||||
if(UserConfigParams::m_profile>0)
|
||||
{
|
||||
m_frame_count++;
|
||||
if (RaceManager::getWorld()->getTime()>user_config->m_profile)
|
||||
if (RaceManager::getWorld()->getTime()>UserConfigParams::m_profile)
|
||||
{
|
||||
//FIXME: SDL_GetTicks() includes the loading time,
|
||||
//so the FPS will be skewed for now.
|
||||
|
@ -32,7 +32,7 @@ TimedRace::TimedRace()
|
||||
m_previous_phase = SETUP_PHASE; // initialise it just in case
|
||||
|
||||
// for profiling AI
|
||||
m_phase = user_config->m_profile ? RACE_PHASE : SETUP_PHASE;
|
||||
m_phase = UserConfigParams::m_profile ? RACE_PHASE : SETUP_PHASE;
|
||||
|
||||
// FIXME - is it a really good idea to reload and delete the sound every race??
|
||||
m_prestart_sound = sfx_manager->newSFX(SFXManager::SOUND_PRESTART);
|
||||
|
@ -74,7 +74,7 @@ void StandardRace::update(float delta)
|
||||
if(race_manager->getFinishedKarts() >= race_manager->getNumKarts() )
|
||||
{
|
||||
TimedRace::enterRaceOverState();
|
||||
if(user_config->m_profile<0) printProfileResultAndExit();
|
||||
if(UserConfigParams::m_profile<0) printProfileResultAndExit();
|
||||
unlock_manager->raceFinished();
|
||||
} // if all karts are finished
|
||||
|
||||
|
@ -103,7 +103,7 @@ void World::init()
|
||||
const std::string& kart_name = race_manager->getKartName(i);
|
||||
int local_player_id = race_manager->getKartLocalPlayerId(i);
|
||||
int global_player_id = race_manager->getKartGlobalPlayerId(i);
|
||||
if(user_config->m_profile)
|
||||
if(UserConfigParams::m_profile)
|
||||
{
|
||||
// In profile mode, load only the old kart
|
||||
newkart = new DefaultRobot(kart_name, position, init_pos, m_track);
|
||||
@ -121,7 +121,7 @@ void World::init()
|
||||
{
|
||||
case RaceManager::KT_PLAYER:
|
||||
newkart = new PlayerKart(kart_name, position,
|
||||
&(user_config->m_player[local_player_id]),
|
||||
&(UserConfigParams::m_player[local_player_id]),
|
||||
init_pos, local_player_id);
|
||||
m_player_karts[global_player_id] = (PlayerKart*)newkart;
|
||||
m_local_player_karts[local_player_id] = static_cast<PlayerKart*>(newkart);
|
||||
@ -140,7 +140,7 @@ void World::init()
|
||||
case RaceManager::KT_LEADER:
|
||||
break;
|
||||
}
|
||||
} // if !user_config->m_profile
|
||||
} // if !UserConfigParams::m_profile
|
||||
#ifdef HAVE_IRRLICHT
|
||||
#else
|
||||
newkart -> getModelTransform() -> clrTraversalMaskBits(SSGTRAV_ISECT|SSGTRAV_HOT);
|
||||
|
@ -70,7 +70,7 @@ void ConnectMessage::setId()
|
||||
{
|
||||
char hostname[256];
|
||||
gethostname(hostname, 255);
|
||||
const std::string& id=user_config->m_player[0].getName();
|
||||
const std::string& id=UserConfigParams::m_player[0].getName();
|
||||
std::ostringstream o;
|
||||
o << id << '@' << hostname;
|
||||
m_id = o.str();
|
||||
|
@ -78,7 +78,7 @@ bool NetworkManager::initServer()
|
||||
{
|
||||
ENetAddress address;
|
||||
address.host = ENET_HOST_ANY;
|
||||
address.port = user_config->m_server_port;
|
||||
address.port = UserConfigParams::m_server_port;
|
||||
|
||||
m_host = enet_host_create (& address /* the address to bind the server host to */,
|
||||
stk_config->m_max_karts /* number of connections */,
|
||||
@ -121,8 +121,8 @@ bool NetworkManager::initClient()
|
||||
ENetEvent event;
|
||||
ENetPeer *peer;
|
||||
|
||||
enet_address_set_host (& address, user_config->m_server_address.c_str());
|
||||
address.port = user_config->m_server_port;
|
||||
enet_address_set_host (& address, UserConfigParams::m_server_address.c_str());
|
||||
address.port = UserConfigParams::m_server_port;
|
||||
|
||||
/* Initiate the connection, allocating the two channels 0 and 1. */
|
||||
peer = enet_host_connect (m_host, &address, 2);
|
||||
@ -144,7 +144,7 @@ bool NetworkManager::initClient()
|
||||
enet_peer_reset (peer);
|
||||
|
||||
fprintf(stderr, "Connection to '%s:%d' failed.\n",
|
||||
user_config->m_server_address.c_str(), user_config->m_server_port);
|
||||
UserConfigParams::m_server_address.c_str(), (int)UserConfigParams::m_server_port);
|
||||
return false;
|
||||
}
|
||||
m_server = peer;
|
||||
|
@ -50,7 +50,7 @@ void Physics::init(const Vec3 &world_min, const Vec3 &world_max)
|
||||
m_dynamics_world->setGravity(btVector3(0.0f, 0.0f,
|
||||
-RaceManager::getTrack()->getGravity()));
|
||||
#ifdef HAVE_GLUT
|
||||
if(user_config->m_bullet_debug)
|
||||
if(UserConfigParams::m_bullet_debug)
|
||||
{
|
||||
m_debug_drawer = new GLDebugDrawer();
|
||||
m_debug_drawer->setDebugMode(btIDebugDraw::DBG_DrawWireframe);
|
||||
@ -63,7 +63,7 @@ void Physics::init(const Vec3 &world_min, const Vec3 &world_max)
|
||||
Physics::~Physics()
|
||||
{
|
||||
#ifdef HAVE_GLUT
|
||||
if(user_config->m_bullet_debug) delete m_debug_drawer;
|
||||
if(UserConfigParams::m_bullet_debug) delete m_debug_drawer;
|
||||
#endif
|
||||
delete m_dynamics_world;
|
||||
delete m_axis_sweep;
|
||||
|
@ -66,7 +66,7 @@ Kart* RaceManager::getKart(const unsigned int n)
|
||||
*/
|
||||
RaceManager::RaceManager()
|
||||
{
|
||||
m_num_karts = user_config->getDefaultNumKarts();
|
||||
m_num_karts = UserConfigParams::m_num_karts;
|
||||
m_difficulty = RD_HARD;
|
||||
m_major_mode = MAJOR_MODE_SINGLE;
|
||||
m_minor_mode = MINOR_MODE_QUICK_RACE;
|
||||
@ -115,7 +115,7 @@ void RaceManager::setLocalKartInfo(unsigned int player_id, const std::string& ka
|
||||
assert(0<=player_id && player_id <m_local_kart_info.size());
|
||||
|
||||
m_local_kart_info[player_id]=RemoteKartInfo(player_id, kart,
|
||||
user_config->m_player[player_id].getName(),
|
||||
UserConfigParams::m_player[player_id].getName(),
|
||||
network_manager->getMyHostId());
|
||||
} // setLocalKartInfo
|
||||
|
||||
|
@ -1275,7 +1275,7 @@ void Track::loadTrackModel()
|
||||
m_light->setLightData(light);
|
||||
// Note: the physics world for irrlicht is created in loadMainTrack
|
||||
createPhysicsModel();
|
||||
if(user_config->m_track_debug)
|
||||
if(UserConfigParams::m_track_debug)
|
||||
m_quad_graph->createDebugMesh();
|
||||
|
||||
} // loadTrack
|
||||
|
Loading…
Reference in New Issue
Block a user