Some fiddling around with fog... not much changed
authorPerttu Ahola <celeron55@gmail.com>
Mon, 14 Feb 2011 14:13:03 +0000 (16:13 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Mon, 14 Feb 2011 14:13:03 +0000 (16:13 +0200)
src/main.cpp
src/map.cpp
src/mapnode.cpp

index 1399907730275934be46e27c91f64b32bdb4e5db..1f8091a7f9baf730af55acf8e3c7736cbb23b572 100644 (file)
@@ -277,6 +277,7 @@ Doing now (most important at the top):
   placement and transfer\r
 * only_from_disk might not work anymore - check and fix it.\r
 * Check the fixmes in the list above\r
+* FIXME: Sneaking doesn't switch sneak node when moving sideways\r
 \r
 === Making it more portable\r
 * Some MSVC: std::sto* are defined without a namespace and collide\r
@@ -398,6 +399,12 @@ extern void set_default_settings();
 IrrlichtDevice *g_device = NULL;\r
 Client *g_client = NULL;\r
 \r
+//const s16 quickinv_size = 48;\r
+//const s16 quickinv_spacing = 64;\r
+const s16 quickinv_size = 32;\r
+const s16 quickinv_spacing = 40;\r
+const s16 quickinv_itemcount = 8;\r
+\r
 /*\r
        GUI Stuff\r
 */\r
@@ -1172,7 +1179,7 @@ void updateViewingRange(f32 frametime_in, Client *client)
        frametime_old = frametime;\r
 }\r
 \r
-class GUIQuickInventory : public IEventReceiver\r
+class GUIQuickInventory\r
 {\r
 public:\r
        GUIQuickInventory(\r
@@ -1184,26 +1191,27 @@ public:
                m_itemcount(itemcount),\r
                m_inventory(inventory)\r
        {\r
-               core::rect<s32> imgsize(0,0,48,48);\r
-               core::rect<s32> textsize(0,0,48,16);\r
-               v2s32 spacing(0, 64);\r
+               core::rect<s32> imgsize(0,0,quickinv_size,quickinv_size);\r
+               core::rect<s32> textsize(0,0,quickinv_size,quickinv_size);\r
                for(s32 i=0; i<m_itemcount; i++)\r
                {\r
                        m_images.push_back(env->addImage(\r
-                               imgsize + pos + spacing*i\r
+                               imgsize\r
                        ));\r
                        m_images[i]->setScaleImage(true);\r
                        m_texts.push_back(env->addStaticText(\r
                                L"",\r
-                               textsize + pos + spacing*i,\r
+                               textsize,\r
                                false, false\r
                        ));\r
-                       m_texts[i]->setBackgroundColor(\r
-                                       video::SColor(128,0,0,0));\r
+                       /*m_texts[i]->setBackgroundColor(\r
+                                       video::SColor(128,0,0,0));*/\r
                        m_texts[i]->setTextAlignment(\r
-                                       gui::EGUIA_CENTER,\r
-                                       gui::EGUIA_UPPERLEFT);\r
+                                       gui::EGUIA_LOWERRIGHT,\r
+                                       gui::EGUIA_LOWERRIGHT);\r
                }\r
+\r
+               updatePosition(pos);\r
        }\r
 \r
        ~GUIQuickInventory()\r
@@ -1218,9 +1226,14 @@ public:
                }\r
        }\r
 \r
-       virtual bool OnEvent(const SEvent& event)\r
+       void updatePosition(v2s32 pos)\r
        {\r
-               return false;\r
+               v2s32 spacing(quickinv_spacing, 0);\r
+               for(s32 i=0; i<m_itemcount; i++)\r
+               {\r
+                       m_images[i]->setRelativePosition(pos + spacing*i);\r
+                       m_texts[i]->setRelativePosition(pos + spacing*i);\r
+               }\r
        }\r
 \r
        void setSelection(s32 i)\r
@@ -1232,7 +1245,7 @@ public:
        {\r
                s32 start = 0;\r
 \r
-               start = m_selection - m_itemcount / 2;\r
+               //start = m_selection - m_itemcount / 2;\r
 \r
                InventoryList *mainlist = m_inventory->getList("main");\r
 \r
@@ -1766,7 +1779,7 @@ int main(int argc, char *argv[])
                        core::rect<s32>(0,0,0,0),\r
                        false, false); // Disable word wrap as of now\r
                        //false, true);\r
-       guitext_chat->setBackgroundColor(video::SColor(96,0,0,0));\r
+       //guitext_chat->setBackgroundColor(video::SColor(96,0,0,0));\r
        core::list<ChatLine> chat_lines;\r
        \r
        /*\r
@@ -2011,7 +2024,8 @@ int main(int argc, char *argv[])
                return 1;\r
        \r
        //video::SColor skycolor = video::SColor(255,90,140,200);\r
-       video::SColor skycolor = video::SColor(255,166,202,244);\r
+       //video::SColor skycolor = video::SColor(255,166,202,244);\r
+       video::SColor skycolor = video::SColor(255,120,185,244);\r
 \r
        camera->setFOV(FOV_ANGLE);\r
 \r
@@ -2031,8 +2045,10 @@ int main(int argc, char *argv[])
                Add some gui stuff\r
        */\r
 \r
+       /*GUIQuickInventory *quick_inventory = new GUIQuickInventory\r
+                       (guienv, NULL, v2s32(10, 70), 5, &local_inventory);*/\r
        GUIQuickInventory *quick_inventory = new GUIQuickInventory\r
-                       (guienv, NULL, v2s32(10, 70), 5, &local_inventory);\r
+                       (guienv, NULL, v2s32(0, 0), quickinv_itemcount, &local_inventory);\r
        \r
        // Test the text input system\r
        /*(new GUITextInputMenu(guienv, guiroot, -1, &g_menumgr,\r
@@ -2051,6 +2067,11 @@ int main(int argc, char *argv[])
        guitext2->setVisible(true);\r
        guitext_info->setVisible(true);\r
        guitext_chat->setVisible(true);\r
+\r
+       //s32 guitext_chat_pad_bottom = 70;\r
+\r
+       v2u32 screensize(0,0);\r
+       v2u32 last_screensize(0,0);\r
        \r
        /*\r
                Some statistics are collected in these\r
@@ -2097,8 +2118,10 @@ int main(int argc, char *argv[])
                /*\r
                        Random calculations\r
                */\r
-               v2u32 screensize = driver->getScreenSize();\r
-               core::vector2d<s32> displaycenter(screensize.X/2,screensize.Y/2);\r
+               last_screensize = screensize;\r
+               screensize = driver->getScreenSize();\r
+               v2s32 displaycenter(screensize.X/2,screensize.Y/2);\r
+               bool screensize_changed = screensize != last_screensize;\r
                \r
                // Hilight boxes collected during the loop and displayed\r
                core::list< core::aabbox3d<f32> > hilightboxes;\r
@@ -2106,6 +2129,13 @@ int main(int argc, char *argv[])
                // Info text\r
                std::wstring infotext;\r
 \r
+               // When screen size changes, update positions and sizes of stuff\r
+               if(screensize_changed)\r
+               {\r
+                       v2s32 pos(displaycenter.X-((quickinv_itemcount-1)*quickinv_spacing+quickinv_size)/2, screensize.Y-quickinv_spacing);\r
+                       quick_inventory->updatePosition(pos);\r
+               }\r
+\r
                //TimeTaker //timer1("//timer1");\r
                \r
                // Time of frame without fps limit\r
@@ -2767,12 +2797,6 @@ int main(int argc, char *argv[])
                camera->setAspectRatio((f32)screensize.X / (f32)screensize.Y);\r
                \r
                u32 daynight_ratio = client.getDayNightRatio();\r
-               /*video::SColor bgcolor = video::SColor(\r
-                               255,\r
-                               skycolor.getRed() * daynight_ratio / 1000,\r
-                               skycolor.getGreen() * daynight_ratio / 1000,\r
-                               skycolor.getBlue() * daynight_ratio / 1000);*/\r
-\r
                u8 l = decode_light((daynight_ratio * LIGHT_SUN) / 1000);\r
                video::SColor bgcolor = video::SColor(\r
                                255,\r
@@ -2787,7 +2811,8 @@ int main(int argc, char *argv[])
                if(g_settings.getBool("enable_fog") == true)\r
                {\r
                        //f32 range = draw_control.wanted_range * BS + MAP_BLOCKSIZE/2*BS;\r
-                       f32 range = draw_control.wanted_range * BS + MAP_BLOCKSIZE/3*BS;\r
+                       f32 range = draw_control.wanted_range * BS + 0.8*MAP_BLOCKSIZE*BS;\r
+                       //f32 range = draw_control.wanted_range * BS + 0.0*MAP_BLOCKSIZE*BS;\r
                        if(draw_control.range_all)\r
                                range = 100000*BS;\r
 \r
@@ -2795,11 +2820,23 @@ int main(int argc, char *argv[])
                                bgcolor,\r
                                video::EFT_FOG_LINEAR,\r
                                range*0.6,\r
-                               range*1.1,\r
+                               range*1.0,\r
+                               0.01,\r
+                               false, // pixel fog\r
+                               false // range fog\r
+                       );\r
+               }\r
+               else\r
+               {\r
+                       driver->setFog(\r
+                               bgcolor,\r
+                               video::EFT_FOG_LINEAR,\r
+                               100000*BS,\r
+                               110000*BS,\r
                                0.01,\r
                                false, // pixel fog\r
                                false // range fog\r
-                               );\r
+                       );\r
                }\r
 \r
 \r
@@ -2912,13 +2949,23 @@ int main(int argc, char *argv[])
                                chat_lines.erase(it);\r
                        }\r
                        guitext_chat->setText(whole.c_str());\r
+\r
                        // Update gui element size and position\r
+\r
+                       /*core::rect<s32> rect(\r
+                                       10,\r
+                                       screensize.Y - guitext_chat_pad_bottom\r
+                                                       - text_height*chat_lines.size(),\r
+                                       screensize.X - 10,\r
+                                       screensize.Y - guitext_chat_pad_bottom\r
+                       );*/\r
                        core::rect<s32> rect(\r
                                        10,\r
-                                       screensize.Y - 10 - text_height*chat_lines.size(),\r
+                                       50,\r
                                        screensize.X - 10,\r
-                                       screensize.Y - 10\r
+                                       50 + text_height*chat_lines.size()\r
                        );\r
+\r
                        guitext_chat->setRelativePosition(rect);\r
 \r
                        if(chat_lines.size() == 0)\r
index fe10565781713b20cc1f18b89917acd689b3ec35..184d89b9c7f9af4c23a0d6d8b84671b1fb134798 100644 (file)
@@ -5428,10 +5428,15 @@ void ClientMap::renderMap(video::IVideoDriver* driver, s32 pass)
                        {
                                continue;
                        }
+                       
+                       // This is ugly
+                       /*if(m_control.range_all == false &&
+                                       d - 0.5*BS*MAP_BLOCKSIZE > range)
+                               continue;*/
 
 #if 1
                        /*
-                               Update expired mesh
+                               Update expired mesh (used for day/night change)
                        */
 
                        bool mesh_expired = false;
index 1e0381d03ef2e8a77c7fd70b589410b97da7b2e2..2ca4ade7a75e889f33e0b25ce7fb8e18b444c876 100644 (file)
@@ -163,6 +163,7 @@ void init_mapnode()
        i = CONTENT_MUD;
        f = &g_content_features[i];
        f->setAllTextures("mud.png");
+       f->setInventoryTextureCube("mud.png", "mud.png", "mud.png");
        f->param_type = CPT_MINERAL;
        f->is_ground_content = true;
        f->dug_item = std::string("MaterialItem ")+itos(i)+" 1";