1) Added -v X verbosity command line option, so that debug output is only printed

if an appropriat ehigh verbosity is selected. For now most debug statements 
   that are always printed (i.e. independent of user actions) is only printed
   if verbosity is >=5,  debug statement which are a reaction of a user action
   with verbosity >=4.
2) track- and gamepad-debug flags are not saved in config files anymore, made
   disabled reverse_look_threshold as default.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@5063 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2010-03-24 23:52:41 +00:00
parent 8a91d2a09b
commit 939caf1981
9 changed files with 125 additions and 73 deletions

View File

@ -229,11 +229,20 @@ namespace UserConfigParams
PARAM_DEFAULT( IntUserConfigParam(0, "renderer", &m_video_group,
"Type of the renderer.") );
// ---- Debug
PARAM_PREFIX BoolUserConfigParam m_gamepad_debug PARAM_DEFAULT( BoolUserConfigParam(false, "gamepad_debug") );
PARAM_PREFIX IntUserConfigParam m_track_debug PARAM_DEFAULT( IntUserConfigParam(false, "track_debug") );
// ---- Debug - not saved to config file
// If gamepad debugging is enabled.
PARAM_PREFIX bool m_gamepad_debug PARAM_DEFAULT( false );
// If track debugging is enabled
PARAM_PREFIX int m_track_debug PARAM_DEFAULT( false );
// If the kart sizes should be printed at startup
PARAM_PREFIX bool m_print_kart_sizes PARAM_DEFAULT( false );
/** Verbosity level for debug messages. Note that error and important warnings
* must always be printed. */
PARAM_PREFIX int m_verbosity PARAM_DEFAULT( 0 );
// ---- Networking
PARAM_PREFIX StringUserConfigParam m_server_address
PARAM_DEFAULT( StringUserConfigParam("localhost", "server_adress", "Information about last server used") );
@ -259,7 +268,9 @@ namespace UserConfigParams
PARAM_DEFAULT( BoolUserConfigParam(false, "log_errors", "Enable logging of stdout and stderr to logfile") );
PARAM_PREFIX IntUserConfigParam m_reverse_look_threshold
PARAM_DEFAULT( IntUserConfigParam(9, "reverse_look_threshold") );
PARAM_DEFAULT( IntUserConfigParam(0, "reverse_look_threshold",
"If the kart is driving backwards faster than this value,\n"
"switch automatically to reverse camera (set to 0 to disable).") );
PARAM_PREFIX StringUserConfigParam m_item_style
PARAM_DEFAULT( StringUserConfigParam("items", "item_style", "Name of the .items file to use.") );

View File

@ -32,16 +32,20 @@ bool DeviceManager::initialize()
// Shutdown in case the device manager is being re-initialized
shutdown();
printf("Initializing Device Manager\n");
printf("---------------------------\n");
if(UserConfigParams::m_verbosity>=5)
{
printf("Initializing Device Manager\n");
printf("---------------------------\n");
}
deserialize();
// Assign a configuration to the keyboard, or create one if we haven't yet
printf("Initializing keyboard support.\n");
if(UserConfigParams::m_verbosity>=5) printf("Initializing keyboard support.\n");
if (m_keyboard_configs.size() == 0)
{
printf("No keyboard configuration exists, creating one.\n");
if(UserConfigParams::m_verbosity>=5)
printf("No keyboard configuration exists, creating one.\n");
m_keyboard_configs.push_back(new KeyboardConfig());
created = true;
}
@ -54,25 +58,36 @@ bool DeviceManager::initialize()
m_keyboard_configs.get(n)->setInUse(n == 0);
}
printf("Initializing gamepad support.\n");
if(UserConfigParams::m_verbosity>=5)
printf("Initializing gamepad support.\n");
irr_driver->getDevice()->activateJoysticks(m_irrlicht_gamepads);
numGamepads = m_irrlicht_gamepads.size();
printf("Irrlicht reports %d gamepads are attached to the system.\n", numGamepads);
if(UserConfigParams::m_verbosity>=4)
{
printf("Irrlicht reports %d gamepads are attached to the system.\n",
numGamepads);
}
// Create GamePadDevice for each physical gamepad and find a GamepadConfig to match
for (int id = 0; id < numGamepads; id++)
{
printf("#%d: %s detected...", id, m_irrlicht_gamepads[id].Name.c_str());
if(UserConfigParams::m_verbosity>=4)
{
printf("#%d: %s detected...", id,
m_irrlicht_gamepads[id].Name.c_str());
}
// Returns true if new configuration was created
if (getConfigForGamepad(id, &gamepadConfig) == true)
{
printf("creating new configuration.\n");
if(UserConfigParams::m_verbosity>=4)
printf("creating new configuration.\n");
created = true;
}
else
{
printf("using existing configuration.\n");
if(UserConfigParams::m_verbosity>=4)
printf("using existing configuration.\n");
}
gamepadConfig->setInUse(true);
@ -303,11 +318,13 @@ bool DeviceManager::deserialize()
{
static std::string filepath = file_manager->getConfigDir() + "/" + INPUT_FILE_NAME;
printf("Deserializing input.xml...\n");
if(UserConfigParams::m_verbosity>=5)
printf("Deserializing input.xml...\n");
if(!file_manager->fileExists(filepath))
{
printf("Warning: no configuration file exists.\n");
if(UserConfigParams::m_verbosity>=4)
printf("Warning: no configuration file exists.\n");
}
else
{
@ -381,8 +398,11 @@ bool DeviceManager::deserialize()
} // end switch
} // end while
printf("Found %d keyboard and %d gamepad configurations.\n", m_keyboard_configs.size(), m_gamepad_configs.size());
if(UserConfigParams::m_verbosity>=4)
{
printf("Found %d keyboard and %d gamepad configurations.\n",
m_keyboard_configs.size(), m_gamepad_configs.size());
}
// For Debugging....
/*
for (int n = 0; n < m_keyboard_configs.size(); n++)
@ -399,7 +419,7 @@ bool DeviceManager::deserialize()
void DeviceManager::serialize()
{
static std::string filepath = file_manager->getConfigDir() + "/" + INPUT_FILE_NAME;
printf("Serializing input.xml...\n");
if(UserConfigParams::m_verbosity>=5) printf("Serializing input.xml...\n");
std::ofstream configfile;
@ -425,7 +445,7 @@ void DeviceManager::serialize()
configfile << "</input>\n";
configfile.close();
printf("Serialization complete.\n\n");
if(UserConfigParams::m_verbosity>=5) printf("Serialization complete.\n\n");
}
// -----------------------------------------------------------------------------

View File

@ -149,14 +149,12 @@ bool KartPropertiesManager::loadKart(const std::string &dir)
//-----------------------------------------------------------------------------
const int KartPropertiesManager::getKartId(const std::string &ident) const
{
//std::cout << "======\n";
//std::cout << "Searching for kart " << ident.c_str() << std::endl;
{
for(KartPropertiesVector::const_iterator i = m_karts_properties.begin();
i != m_karts_properties.end(); ++i)
{
std::cout << " -- " << (*i)->getIdent().c_str() << std::endl;
if(UserConfigParams::m_verbosity>=5)
std::cout << " -- " << (*i)->getIdent().c_str() << std::endl;
if ((*i)->getIdent() == ident)
return i-m_karts_properties.begin();
}

View File

@ -432,9 +432,14 @@ int handleCmdLine(int argc, char **argv)
}
else if( !strcmp(argv[i], "--profile") )
{
printf("Profiling: %d seconds.\n", n);
ProfileWorld::setProfileModeTime(20);
race_manager->setNumLaps(999999); // profile end depends on time
printf("Profiling: %d seconds.\n", n);
ProfileWorld::setProfileModeTime(20);
race_manager->setNumLaps(999999); // profile end depends on time
}
else if ( !strcmp(argv[i], "-v") && i+1<argc )
{
UserConfigParams::m_verbosity = atoi(argv[i+1]);
i++;
}
else if( sscanf(argv[i], "--history=%d", &n)==1)
{

View File

@ -156,7 +156,11 @@ void RaceManager::setTrack(const std::string& track)
void RaceManager::computeRandomKartList()
{
int n = m_num_karts - m_player_karts.size();
std::cout << "AI karts count = " << n << " for m_num_karts=" << m_num_karts << " and m_player_karts.size()=" << m_player_karts.size() << std::endl;
if(UserConfigParams::m_verbosity>=5)
std::cout << "AI karts count = " << n << " for m_num_karts="
<< m_num_karts << " and m_player_karts.size()="
<< m_player_karts.size() << std::endl;
// If less kart selected than there are player karts, adjust the number of
// karts to the minimum
if(n<0)
@ -398,7 +402,10 @@ void RaceManager::exitRace()
std::string winners[3];
for (unsigned int i=0; i < m_kart_status.size(); ++i)
{
std::cout << m_kart_status[i].m_ident << " has GP final rank " << m_kart_status[i].m_gp_rank << std::endl;
if(UserConfigParams::m_verbosity>=5)
std::cout << m_kart_status[i].m_ident << " has GP final rank "
<< m_kart_status[i].m_gp_rank << std::endl;
const int rank = m_kart_status[i].m_gp_rank;
if (rank >= 0 && rank < 3)
{

View File

@ -35,39 +35,37 @@ DEFINE_SCREEN_SINGLETON( ArenasScreen );
ArenasScreen::ArenasScreen() : Screen("arenas.stkgui")
{
}
} // ArenasScreen
// ------------------------------------------------------------------------------------------------------
void ArenasScreen::eventCallback(Widget* widget, const std::string& name, const int playerID)
{
if (name == "tracks")
if(name!="tracks") return;
DynamicRibbonWidget* w2 = dynamic_cast<DynamicRibbonWidget*>(widget);
if(w2==NULL) return;
const std::string selection = w2->getSelectionIDString(GUI_PLAYER_ID);
if(UserConfigParams::m_verbosity>=5)
std::cout << "Clicked on arena " << selection.c_str() << std::endl;
if (selection == "random_track")
{
DynamicRibbonWidget* w2 = dynamic_cast<DynamicRibbonWidget*>(widget);
if (w2 != NULL)
{
const std::string selection = w2->getSelectionIDString(GUI_PLAYER_ID);
std::cout << "Clicked on arena " << selection.c_str() << std::endl;
if (selection == "random_track")
{
// TODO
}
else
{
Track* clickedTrack = track_manager->getTrack(selection);
if (clickedTrack != NULL)
{
ITexture* screenshot = irr_driver->getTexture( clickedTrack->getScreenshotFile().c_str() );
new TrackInfoDialog( clickedTrack->getIdent(), clickedTrack->getName().c_str(),
screenshot, 0.8f, 0.7f);
}
}
}
// TODO
}
}
else
{
Track* clickedTrack = track_manager->getTrack(selection);
if (clickedTrack != NULL)
{
ITexture* screenshot = irr_driver->getTexture( clickedTrack->getScreenshotFile().c_str() );
new TrackInfoDialog( clickedTrack->getIdent(), clickedTrack->getName().c_str(),
screenshot, 0.8f, 0.7f);
} // clickedTrack != NULL
} // if random_track
} // eventCallback
// ------------------------------------------------------------------------------------------------------
@ -104,13 +102,13 @@ void ArenasScreen::init()
// FIXME: don't hardcode player 0?
w->setSelection(w->getItems()[0].m_code_name, 0, true);
}
} // init
// ------------------------------------------------------------------------------------------------------
void ArenasScreen::tearDown()
{
}
} // tearDown
// ------------------------------------------------------------------------------------------------------
@ -121,7 +119,7 @@ void ArenasScreen::setFocusOnTrack(const std::string& trackName)
// FIXME: don't hardcode player 0?
w->setSelection(trackName, 0, true);
}
} // setFOxuOnTrack
// ------------------------------------------------------------------------------------------------------

View File

@ -145,7 +145,6 @@ RacePausedDialog::RacePausedDialog(const float percentWidth, const float percent
m_children.push_back(m_choice_ribbon);
m_choice_ribbon->add();
}
// ------------------------------------------------------------------------------------------------------
void RacePausedDialog::onEnterPressedInternal()
@ -156,7 +155,9 @@ void RacePausedDialog::onEnterPressedInternal()
GUIEngine::EventPropagation RacePausedDialog::processEvent(const std::string& eventSource)
{
std::cout << "RacePausedDialog::processEvent(" << eventSource.c_str() << ")\n";
if(UserConfigParams::m_verbosity>=5)
std::cout << "RacePausedDialog::processEvent("
<< eventSource.c_str() << ")\n";
if (eventSource == "backbtn")
{
@ -168,8 +169,9 @@ GUIEngine::EventPropagation RacePausedDialog::processEvent(const std::string& ev
{
const std::string& selection = m_choice_ribbon->getSelectionIDString(GUI_PLAYER_ID);
std::cout << "RacePausedDialog::processEvent(" << eventSource.c_str()
<< " : " << selection << ")\n";
if(UserConfigParams::m_verbosity>=5)
std::cout << "RacePausedDialog::processEvent("
<< eventSource.c_str() << " : " << selection << ")\n";
if (selection == "exit")
{

View File

@ -537,8 +537,12 @@ public:
// update player profile when spinner changed
if (originator == spinnerID)
{
std::cout << "Identity changed for player " << m_playerID
<< " : " << irr::core::stringc(playerName->getStringValue().c_str()).c_str() << std::endl;
if(UserConfigParams::m_verbosity>=5)
{
std::cout << "Identity changed for player " << m_playerID
<< " : " << irr::core::stringc(playerName->getStringValue().c_str()).c_str()
<< std::endl;
}
m_associatedPlayer->setPlayerProfile( UserConfigParams::m_all_players.get(playerName->getValue()) );
}
@ -811,7 +815,7 @@ void KartSelectionScreen::forgetWhatWasLoaded()
// Return true if event was handled successfully
bool KartSelectionScreen::playerJoin(InputDevice* device, bool firstPlayer)
{
std::cout << "playerJoin() ==========\n";
if(UserConfigParams::m_verbosity>=5) std::cout << "playerJoin() ==========\n";
if (g_dispatcher == NULL)
{
@ -928,7 +932,8 @@ bool KartSelectionScreen::playerQuit(StateManager::ActivePlayer* player)
std::cout << "void playerQuit(ActivePlayer* player) : cannot find passed player\n";
return false;
}
std::cout << "playerQuit( " << playerID << " )\n";
if(UserConfigParams::m_verbosity>=5)
std::cout << "playerQuit( " << playerID << " )\n";
// Just a cheap way to check if there is any discrepancy
// between g_player_karts and the active player array
@ -1131,13 +1136,16 @@ void KartSelectionScreen::allPlayersDone()
const ptr_vector< StateManager::ActivePlayer, HOLD >& players = StateManager::get()->getActivePlayers();
// ---- Print selection (for debugging purposes)
std::cout << "==========\n" << players.size() << " players :\n";
for (int n=0; n<players.size(); n++)
if(UserConfigParams::m_verbosity>=4)
{
std::cout << " Player " << n << " is " << players[n].getConstProfile()->getName()
<< " on " << players[n].getDevice()->m_name << std::endl;
std::cout << "==========\n" << players.size() << " players :\n";
for (int n=0; n<players.size(); n++)
{
std::cout << " Player " << n << " is " << players[n].getConstProfile()->getName()
<< " on " << players[n].getDevice()->m_name << std::endl;
}
std::cout << "==========\n";
}
std::cout << "==========\n";
// ---- Give player info to race manager
race_manager->setNumPlayers( players.size() );
@ -1413,7 +1421,8 @@ void KartSelectionScreen::setKartsFromCurrentGroup()
// FIXME : clean this mess, this file should not contain so many classes spread all over the place
EventPropagation FocusDispatcher::focused(const int playerID)
{
std::cout << "FocusDispatcher focused by player " << playerID << std::endl;
if(UserConfigParams::m_verbosity>=5)
std::cout << "FocusDispatcher focused by player " << playerID << std::endl;
// since this screen is multiplayer, redirect focus to the right widget
const int amount = m_parent->m_kart_widgets.size();

View File

@ -79,7 +79,9 @@ void TracksScreen::eventCallback(Widget* widget, const std::string& name, const
if (w2 != NULL)
{
const std::string selection = w2->getSelectionIDString(GUI_PLAYER_ID);
std::cout << "Clicked on track " << selection.c_str() << std::endl;
if(UserConfigParams::m_verbosity>=5)
std::cout << "Clicked on track " << selection.c_str()
<< std::endl;
if (selection == "random_track")
{