diff --git a/src/config/user_config.hpp b/src/config/user_config.hpp index 398afc456..7a1bde74b 100644 --- a/src/config/user_config.hpp +++ b/src/config/user_config.hpp @@ -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.") ); diff --git a/src/input/device_manager.cpp b/src/input/device_manager.cpp index 6c374161c..49d616d5d 100644 --- a/src/input/device_manager.cpp +++ b/src/input/device_manager.cpp @@ -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 << "\n"; configfile.close(); - printf("Serialization complete.\n\n"); + if(UserConfigParams::m_verbosity>=5) printf("Serialization complete.\n\n"); } // ----------------------------------------------------------------------------- diff --git a/src/karts/kart_properties_manager.cpp b/src/karts/kart_properties_manager.cpp index 2ccaf5443..395ff313c 100644 --- a/src/karts/kart_properties_manager.cpp +++ b/src/karts/kart_properties_manager.cpp @@ -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(); } diff --git a/src/main.cpp b/src/main.cpp index 6389bb564..98f0d9558 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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=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) { diff --git a/src/states_screens/arenas_screen.cpp b/src/states_screens/arenas_screen.cpp index 482b2dfcb..d42a35af2 100644 --- a/src/states_screens/arenas_screen.cpp +++ b/src/states_screens/arenas_screen.cpp @@ -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(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(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 // ------------------------------------------------------------------------------------------------------ diff --git a/src/states_screens/dialogs/race_paused_dialog.cpp b/src/states_screens/dialogs/race_paused_dialog.cpp index 58fa7eaf4..37b8b315d 100644 --- a/src/states_screens/dialogs/race_paused_dialog.cpp +++ b/src/states_screens/dialogs/race_paused_dialog.cpp @@ -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") { diff --git a/src/states_screens/kart_selection.cpp b/src/states_screens/kart_selection.cpp index 1d0833477..c3f8857d7 100644 --- a/src/states_screens/kart_selection.cpp +++ b/src/states_screens/kart_selection.cpp @@ -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=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; ngetName() + << " 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(); diff --git a/src/states_screens/tracks_screen.cpp b/src/states_screens/tracks_screen.cpp index 1696e76d5..ae833dfe0 100644 --- a/src/states_screens/tracks_screen.cpp +++ b/src/states_screens/tracks_screen.cpp @@ -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") {