X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fgame.cpp;h=d7efbeae9fbaf616d19113ee48820f5463cd79bd;hb=64996422c00ddb70cfc8aee7da7b62485b8b0416;hp=4d9b0c3f6325d044787c8c3e82bf302af60b6d86;hpb=558a133044ac638dafb7b0e9452a4d7e435177bf;p=dragonfireclient.git diff --git a/src/game.cpp b/src/game.cpp index 4d9b0c3f6..d7efbeae9 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -43,13 +43,14 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "gettext.h" #include "log.h" #include "filesys.h" - -/* - TODO: Move content-aware stuff to separate file by adding properties - and virtual interfaces -*/ +// Needed for some special cases for CONTENT_TORCH and CONTENT_SIGN_WALL +// TODO: A generic way for handling such should be created #include "content_mapnode.h" +// Needed for sign text input +// TODO: A generic way for handling such should be created #include "content_nodemeta.h" +// Needed for determining pointing to nodes +#include "mapnode_contentfeatures.h" /* Setting this to 1 enables a special camera mode that forces @@ -872,7 +873,6 @@ void the_game( L"", core::rect(5, 5+(text_height+5)*1, 795, (5+text_height)*2), false, false); - // At the middle of the screen // Object infos are shown in this gui::IGUIStaticText *guitext_info = guienv->addStaticText( @@ -889,6 +889,15 @@ void the_game( //guitext_chat->setBackgroundColor(video::SColor(96,0,0,0)); core::list chat_lines; + // Profiler text (size is updated when text is updated) + gui::IGUIStaticText *guitext_profiler = guienv->addStaticText( + L"", + core::rect(6, 4+(text_height+5)*2, 400, + (text_height+5)*2 + text_height*35), + false, false); + guitext_profiler->setBackgroundColor(video::SColor(80,0,0,0)); + guitext_profiler->setVisible(false); + /*GUIQuickInventory *quick_inventory = new GUIQuickInventory (guienv, NULL, v2s32(10, 70), 5, &local_inventory);*/ /*GUIQuickInventory *quick_inventory = new GUIQuickInventory @@ -942,6 +951,10 @@ void the_game( bool respawn_menu_active = false; + bool show_profiler = false; + bool force_fog_off = false; + bool disable_camera_update = false; + /* Main loop */ @@ -1162,14 +1175,32 @@ void the_game( */ float 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(dtime, profiler_print_interval)) { - if(m_profiler_interval.step(0.030, profiler_print_interval)) - { + if(print_to_log){ infostream<<"Profiler:"<print(infostream); - g_profiler->clear(); } + + std::ostringstream os(std::ios_base::binary); + g_profiler->print(os); + std::wstring text = narrow_to_wide(os.str()); + guitext_profiler->setText(text.c_str()); + + g_profiler->clear(); + + s32 w = font->getDimension(text.c_str()).Width; + if(w < 400) + w = 400; + core::rect rect(6, 4+(text_height+5)*2, 12+w, + 8+(text_height+5)*2 + + font->getDimension(text.c_str()).Height); + guitext_profiler->setRelativePosition(rect); } /* @@ -1299,6 +1330,31 @@ void the_game( image->drop(); } } + else if(input->wasKeyDown(getKeySetting("keymap_toggle_profiler"))) + { + show_profiler = !show_profiler; + guitext_profiler->setVisible(show_profiler); + if(show_profiler) + chat_lines.push_back(ChatLine(L"Profiler disabled")); + else + chat_lines.push_back(ChatLine(L"Profiler enabled")); + } + else if(input->wasKeyDown(getKeySetting("keymap_toggle_force_fog_off"))) + { + force_fog_off = !force_fog_off; + if(force_fog_off) + chat_lines.push_back(ChatLine(L"Fog disabled")); + else + chat_lines.push_back(ChatLine(L"Fog enabled")); + } + else if(input->wasKeyDown(getKeySetting("keymap_toggle_update_camera"))) + { + disable_camera_update = !disable_camera_update; + if(disable_camera_update) + chat_lines.push_back(ChatLine(L"Camera update disabled")); + else + chat_lines.push_back(ChatLine(L"Camera update enabled")); + } // Item selection with mouse wheel { @@ -1543,11 +1599,10 @@ void the_game( v3f camera_direction = camera.getDirection(); f32 camera_fov = camera.getFovMax(); - if(FIELD_OF_VIEW_TEST) - client.updateCamera(v3f(0,0,0), v3f(0,0,1), camera_fov); - else + if(!disable_camera_update){ client.updateCamera(camera_position, camera_direction, camera_fov); + } //timer2.stop(); //TimeTaker //timer3("//timer3"); @@ -1947,7 +2002,7 @@ void the_game( Fog */ - if(g_settings->getBool("enable_fog") == true) + if(g_settings->getBool("enable_fog") == true && !force_fog_off) { f32 range; if(farmesh) @@ -1957,10 +2012,11 @@ void the_game( else { range = draw_control.wanted_range*BS + MAP_BLOCKSIZE*BS*1.5; + range *= 0.9; if(draw_control.range_all) range = 100000*BS; - if(range < 50*BS) - range = range * 0.5 + 25*BS; + /*if(range < 50*BS) + range = range * 0.5 + 25*BS;*/ } driver->setFog( @@ -2114,7 +2170,8 @@ void the_game( 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); else guitext_chat->setVisible(true);