F2 toggles profiler display in client

This commit is contained in:
Perttu Ahola 2011-10-17 20:40:55 +03:00
parent 6661d9be1a
commit 64c4d00693
2 changed files with 33 additions and 7 deletions

@ -36,6 +36,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("keymap_jump", "KEY_SPACE"); settings->setDefault("keymap_jump", "KEY_SPACE");
settings->setDefault("keymap_sneak", "KEY_LSHIFT"); settings->setDefault("keymap_sneak", "KEY_LSHIFT");
settings->setDefault("keymap_inventory", "KEY_KEY_I"); settings->setDefault("keymap_inventory", "KEY_KEY_I");
settings->setDefault("keymap_special1", "KEY_KEY_E");
settings->setDefault("keymap_chat", "KEY_KEY_T"); settings->setDefault("keymap_chat", "KEY_KEY_T");
settings->setDefault("keymap_cmd", "/"); settings->setDefault("keymap_cmd", "/");
settings->setDefault("keymap_rangeselect", "KEY_KEY_R"); settings->setDefault("keymap_rangeselect", "KEY_KEY_R");
@ -43,8 +44,8 @@ void set_default_settings(Settings *settings)
settings->setDefault("keymap_fastmove", "KEY_KEY_J"); settings->setDefault("keymap_fastmove", "KEY_KEY_J");
settings->setDefault("keymap_frametime_graph", "KEY_F1"); settings->setDefault("keymap_frametime_graph", "KEY_F1");
settings->setDefault("keymap_screenshot", "KEY_F12"); settings->setDefault("keymap_screenshot", "KEY_F12");
settings->setDefault("keymap_toggle_profiler", "KEY_F2");
// Some (temporary) keys for debugging // Some (temporary) keys for debugging
settings->setDefault("keymap_special1", "KEY_KEY_E");
settings->setDefault("keymap_print_debug_stacks", "KEY_KEY_P"); settings->setDefault("keymap_print_debug_stacks", "KEY_KEY_P");
settings->setDefault("wanted_fps", "30"); settings->setDefault("wanted_fps", "30");

@ -872,7 +872,6 @@ void the_game(
L"", L"",
core::rect<s32>(5, 5+(text_height+5)*1, 795, (5+text_height)*2), core::rect<s32>(5, 5+(text_height+5)*1, 795, (5+text_height)*2),
false, false); false, false);
// At the middle of the screen // At the middle of the screen
// Object infos are shown in this // Object infos are shown in this
gui::IGUIStaticText *guitext_info = guienv->addStaticText( gui::IGUIStaticText *guitext_info = guienv->addStaticText(
@ -889,6 +888,15 @@ void the_game(
//guitext_chat->setBackgroundColor(video::SColor(96,0,0,0)); //guitext_chat->setBackgroundColor(video::SColor(96,0,0,0));
core::list<ChatLine> chat_lines; core::list<ChatLine> chat_lines;
// Profiler text
gui::IGUIStaticText *guitext_profiler = guienv->addStaticText(
L"<Profiler>",
core::rect<s32>(6, 4+(text_height+5)*3, 400,
(text_height+5)*3 + text_height*35),
false, false);
guitext_profiler->setBackgroundColor(video::SColor(80,0,0,0));
guitext_profiler->setVisible(false);
/*GUIQuickInventory *quick_inventory = new GUIQuickInventory /*GUIQuickInventory *quick_inventory = new GUIQuickInventory
(guienv, NULL, v2s32(10, 70), 5, &local_inventory);*/ (guienv, NULL, v2s32(10, 70), 5, &local_inventory);*/
/*GUIQuickInventory *quick_inventory = new GUIQuickInventory /*GUIQuickInventory *quick_inventory = new GUIQuickInventory
@ -942,6 +950,8 @@ void the_game(
bool respawn_menu_active = false; bool respawn_menu_active = false;
bool show_profiler = false;
/* /*
Main loop Main loop
*/ */
@ -1162,14 +1172,23 @@ void the_game(
*/ */
float profiler_print_interval = float profiler_print_interval =
g_settings->getFloat("profiler_print_interval"); g_settings->getFloat("profiler_print_interval");
if(profiler_print_interval != 0) bool print_to_log = true;
if(profiler_print_interval == 0){
print_to_log = false;
profiler_print_interval = 5;
}
if(m_profiler_interval.step(0.030, profiler_print_interval))
{ {
if(m_profiler_interval.step(0.030, profiler_print_interval)) if(print_to_log){
{
infostream<<"Profiler:"<<std::endl; infostream<<"Profiler:"<<std::endl;
g_profiler->print(infostream); g_profiler->print(infostream);
g_profiler->clear();
} }
std::ostringstream os(std::ios_base::binary);
g_profiler->print(os);
guitext_profiler->setText(narrow_to_wide(os.str()).c_str());
g_profiler->clear();
} }
/* /*
@ -1299,6 +1318,11 @@ void the_game(
image->drop(); image->drop();
} }
} }
else if(input->wasKeyDown(getKeySetting("keymap_toggle_profiler")))
{
show_profiler = !show_profiler;
guitext_profiler->setVisible(show_profiler);
}
// Item selection with mouse wheel // Item selection with mouse wheel
{ {
@ -2114,7 +2138,8 @@ void the_game(
guitext_chat->setRelativePosition(rect); guitext_chat->setRelativePosition(rect);
if(chat_lines.size() == 0) // Don't show chat if empty or profiler is enabled
if(chat_lines.size() == 0 || show_profiler)
guitext_chat->setVisible(false); guitext_chat->setVisible(false);
else else
guitext_chat->setVisible(true); guitext_chat->setVisible(true);