]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/game.cpp
Move ContentFeatures to mapnode_contentfeatures.{h,cpp} and clean stuff
[dragonfireclient.git] / src / game.cpp
index 92d4a2ae490601d1b101e729763a75e21a311786..d7efbeae9fbaf616d19113ee48820f5463cd79bd 100644 (file)
@@ -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
@@ -888,11 +889,11 @@ void the_game(
        //guitext_chat->setBackgroundColor(video::SColor(96,0,0,0));
        core::list<ChatLine> chat_lines;
        
-       // Profiler text
+       // Profiler text (size is updated when text is updated)
        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),
+                       core::rect<s32>(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);
@@ -951,6 +952,8 @@ void the_game(
        bool respawn_menu_active = false;
 
        bool show_profiler = false;
+       bool force_fog_off = false;
+       bool disable_camera_update = false;
 
        /*
                Main loop
@@ -1177,7 +1180,7 @@ void the_game(
                        print_to_log = false;
                        profiler_print_interval = 5;
                }
-               if(m_profiler_interval.step(0.030, profiler_print_interval))
+               if(m_profiler_interval.step(dtime, profiler_print_interval))
                {
                        if(print_to_log){
                                infostream<<"Profiler:"<<std::endl;
@@ -1186,9 +1189,18 @@ void the_game(
 
                        std::ostringstream os(std::ios_base::binary);
                        g_profiler->print(os);
-                       guitext_profiler->setText(narrow_to_wide(os.str()).c_str());
+                       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<s32> rect(6, 4+(text_height+5)*2, 12+w,
+                                       8+(text_height+5)*2 +
+                                       font->getDimension(text.c_str()).Height);
+                       guitext_profiler->setRelativePosition(rect);
                }
 
                /*
@@ -1322,6 +1334,26 @@ void the_game(
                {
                        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
@@ -1567,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");
@@ -1971,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)
@@ -1981,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(