Adapt the pause menu in benchmark mode
* Use explicit activation and desactivation functions for the profiler to improve code clarity and robustness * In the pause dialog, only display the 'back to race' and 'exit' buttons in benchmark mode * Relabel the buttons in the pause menu in benchmark mode * Use 'Performance test' in user-facing texts to ensure better translations * Fix parts of the UI disappearing when leaving the pause menu in benchmark mode Additional known issue introduced in the previous benchmark commit: * With big text sizes, the performance test button overflows in the graphics settings.
This commit is contained in:
parent
db2cc69d89
commit
171ac3c0b0
@ -133,7 +133,7 @@
|
||||
|
||||
<div width="100%" height="fit" layout="horizontal-row" id="outer_box" >
|
||||
<spacer width="5%" height="100%" />
|
||||
<button id="benchmarkCurrent" text="Benchmark current settings" I18N="In the video settings" align="center"/>
|
||||
<button id="benchmarkCurrent" text="Performance test of the current settings" I18N="In the video settings" align="center"/>
|
||||
</div>
|
||||
<!--
|
||||
<spacer width="5" height="1%"/>
|
||||
|
@ -356,8 +356,8 @@ void WorldStatus::updateTime(int ticks)
|
||||
if(RaceManager::get()->isBenchmarking())
|
||||
{
|
||||
// The profiler drawings cost performance
|
||||
profiler.setDrawing(false);
|
||||
profiler.toggleStatus();
|
||||
//profiler.setDrawing(false);
|
||||
profiler.activate();
|
||||
}
|
||||
|
||||
// event
|
||||
@ -441,7 +441,7 @@ void WorldStatus::updateTime(int ticks)
|
||||
if(RaceManager::get()->isBenchmarking())
|
||||
{
|
||||
// End profiling
|
||||
profiler.toggleStatus();
|
||||
profiler.desactivate();
|
||||
profiler.writeToFile();
|
||||
profiler.setDrawing(true);
|
||||
}
|
||||
|
@ -60,6 +60,7 @@
|
||||
#include "states_screens/main_menu_screen.hpp"
|
||||
#include "states_screens/state_manager.hpp"
|
||||
#include "tracks/track_manager.hpp"
|
||||
#include "utils/profiler.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
#include "utils/stk_process.hpp"
|
||||
#include "utils/string_utils.hpp"
|
||||
@ -1323,3 +1324,18 @@ core::stringw RaceManager::getDifficultyName(Difficulty diff) const
|
||||
}
|
||||
return "";
|
||||
} // getDifficultyName
|
||||
|
||||
//---------------------------------------------------------------------------------------------
|
||||
/** Set the benchmarking mode as requested, and turn off the profiler if needed. */
|
||||
void RaceManager::setBenchmarking(bool benchmark)
|
||||
{
|
||||
m_benchmarking = benchmark;
|
||||
|
||||
// If the benchmark mode is turned off and the profiler is still activated,
|
||||
// turn the profiler off and reset the drawing mode to default.
|
||||
if (!m_benchmarking && UserConfigParams::m_profiler_enabled)
|
||||
{
|
||||
profiler.desactivate();
|
||||
profiler.setDrawing(true);
|
||||
}
|
||||
} // setBenchmarking
|
||||
|
@ -437,6 +437,7 @@ public:
|
||||
void setNumPlayers(int players, int local_players=-1);
|
||||
void setDefaultAIKartList(const std::vector<std::string> &ai_list);
|
||||
void computeRandomKartList();
|
||||
void setBenchmarking(bool benchmark);
|
||||
|
||||
// ----------------------------------------------------------------------------------------
|
||||
bool hasTimeTarget() const { return m_time_target > 0.0f; }
|
||||
@ -854,11 +855,6 @@ public:
|
||||
m_watching_replay = watch;
|
||||
} // setWatchingReplay
|
||||
// ----------------------------------------------------------------------------------------
|
||||
void setBenchmarking(bool benchmark)
|
||||
{
|
||||
m_benchmarking = benchmark;
|
||||
} // setBenchmarking
|
||||
// ----------------------------------------------------------------------------------------
|
||||
bool isRecordingRace() const
|
||||
{
|
||||
return m_is_recording_race;
|
||||
|
@ -109,7 +109,7 @@ RacePausedDialog::RacePausedDialog(const float percentWidth,
|
||||
if (m_target_team != KART_TEAM_NONE)
|
||||
getWidget("team")->setActive(false);
|
||||
}
|
||||
}
|
||||
} // if race chat is enabled
|
||||
else
|
||||
{
|
||||
m_text_box->setActive(false);
|
||||
@ -119,15 +119,22 @@ RacePausedDialog::RacePausedDialog(const float percentWidth,
|
||||
getWidget("emoji")->setVisible(false);
|
||||
if (m_target_team != KART_TEAM_NONE)
|
||||
getWidget("team")->setVisible(false);
|
||||
}
|
||||
}
|
||||
} // else (race chat disabled)
|
||||
} // if isNetworking
|
||||
else if (!RaceManager::get()->isBenchmarking())
|
||||
{
|
||||
World::getWorld()->schedulePause(WorldStatus::IN_GAME_MENU_PHASE);
|
||||
}
|
||||
|
||||
if (dynamic_cast<OverWorld*>(World::getWorld()) == NULL)
|
||||
{
|
||||
if (RaceManager::get()->isBattleMode() || RaceManager::get()->isCTFMode())
|
||||
if (RaceManager::get()->isBenchmarking())
|
||||
{
|
||||
// Other buttons of the pause menu are removed in benchmark mode
|
||||
getWidget<IconButtonWidget>("backbtn")->setLabel(_("Back to the Performance Test"));
|
||||
getWidget<IconButtonWidget>("exit")->setLabel(_("Exit the Performance Test"));
|
||||
}
|
||||
else if (RaceManager::get()->isBattleMode() || RaceManager::get()->isCTFMode())
|
||||
{
|
||||
getWidget<IconButtonWidget>("backbtn")->setLabel(_("Back to Battle"));
|
||||
if (!NetworkConfig::get()->isNetworking())
|
||||
@ -165,7 +172,7 @@ RacePausedDialog::~RacePausedDialog()
|
||||
music_manager->resumeMusic();
|
||||
SFXManager::get()->resumeAll();
|
||||
}
|
||||
else
|
||||
else if (!RaceManager::get()->isBenchmarking())
|
||||
{
|
||||
World::getWorld()->scheduleUnpause();
|
||||
}
|
||||
@ -216,6 +223,18 @@ void RacePausedDialog::loadedFromFile()
|
||||
choice_ribbon->deleteChild("restart");
|
||||
}
|
||||
}
|
||||
|
||||
// Remove all extraneous buttons in benchmark mode
|
||||
if (RaceManager::get()->isBenchmarking())
|
||||
{
|
||||
GUIEngine::RibbonWidget* choice_ribbon =
|
||||
getWidget<GUIEngine::RibbonWidget>("choiceribbon");
|
||||
choice_ribbon->deleteChild("newrace");
|
||||
choice_ribbon->deleteChild("restart");
|
||||
choice_ribbon->deleteChild("endrace");
|
||||
choice_ribbon->deleteChild("options");
|
||||
choice_ribbon->deleteChild("help");
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -316,6 +335,10 @@ GUIEngine::EventPropagation
|
||||
RaceManager::get()->exitRace();
|
||||
RaceManager::get()->setAIKartOverride("");
|
||||
|
||||
// If a benchmark is exited early through the pause menu, disable benchmarking mode
|
||||
if (RaceManager::get()->isBenchmarking())
|
||||
RaceManager::get()->setBenchmarking(false);
|
||||
|
||||
if (NetworkConfig::get()->isNetworking())
|
||||
{
|
||||
StateManager::get()->resetAndSetStack(
|
||||
|
@ -509,7 +509,10 @@ bool handleContextMenuAction(s32 cmd_id)
|
||||
break;
|
||||
}
|
||||
case DEBUG_PROFILER:
|
||||
profiler.toggleStatus();
|
||||
if (UserConfigParams::m_profiler_enabled)
|
||||
profiler.desactivate();
|
||||
else
|
||||
profiler.activate();
|
||||
break;
|
||||
case DEBUG_PROFILER_WRITE_REPORT:
|
||||
profiler.writeToFile();
|
||||
|
@ -223,24 +223,33 @@ void Profiler::popCPUMarker()
|
||||
} // popCPUMarker
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Switches the profiler either on or off.
|
||||
/** Switches the profiler on
|
||||
*/
|
||||
void Profiler::toggleStatus()
|
||||
void Profiler::activate()
|
||||
{
|
||||
UserConfigParams::m_profiler_enabled = !UserConfigParams::m_profiler_enabled;
|
||||
|
||||
// Avoid data from multiple profiling sessions from merging in one report
|
||||
if (UserConfigParams::m_profiler_enabled)
|
||||
// If the profiler is not already turned on, reset to avoid data
|
||||
// from multiple profiling sessions from merging in one report
|
||||
if (!UserConfigParams::m_profiler_enabled)
|
||||
reset();
|
||||
|
||||
// If the profiler would immediately enabled, calls that have started but
|
||||
UserConfigParams::m_profiler_enabled = true;
|
||||
|
||||
// Would the profiler be enabled immediately, calls that have started but
|
||||
// not finished would not be registered correctly. So set the state to
|
||||
// waiting, so the unfreeze started at the next sync frame (which is
|
||||
// outside of the main loop, i.e. all profiling events inside of the main
|
||||
// loop will work as expected.
|
||||
if (m_freeze_state == UNFROZEN)
|
||||
m_freeze_state = WAITING_FOR_UNFREEZE;
|
||||
} // toggleStatus
|
||||
} // activate
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Switches the profiler off.
|
||||
*/
|
||||
void Profiler::desactivate()
|
||||
{
|
||||
UserConfigParams::m_profiler_enabled = false;
|
||||
} // desactivate
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Saves all data for the current frame, and starts the next frame in the
|
||||
|
@ -286,7 +286,8 @@ public:
|
||||
void pushCPUMarker(const char* name="N/A",
|
||||
const video::SColor& color=video::SColor());
|
||||
void popCPUMarker();
|
||||
void toggleStatus();
|
||||
void activate();
|
||||
void desactivate();
|
||||
void synchronizeFrame();
|
||||
void draw();
|
||||
void onClick(const core::vector2di& mouse_pos);
|
||||
|
Loading…
Reference in New Issue
Block a user