Node highlighting.
[oweals/minetest.git] / src / game.cpp
index 6ac320af86da2e08490812e75dc92aedc1d92d8b..bae946f28eaa70a3751901b5e25dd18bc5fc5fb2 100644 (file)
@@ -407,14 +407,16 @@ PointedThing getPointedThing(Client *client, v3f player_position,
                                mindistance = distance;
 
                                hilightboxes.clear();
-                               for(std::vector<aabb3f>::const_iterator
-                                               i2 = boxes.begin();
-                                               i2 != boxes.end(); i2++)
-                               {
-                                       aabb3f box = *i2;
-                                       box.MinEdge += npf + v3f(-d,-d,-d) - intToFloat(camera_offset, BS);
-                                       box.MaxEdge += npf + v3f(d,d,d) - intToFloat(camera_offset, BS);
-                                       hilightboxes.push_back(box);
+                               if (!g_settings->getBool("enable_node_highlighting")) {
+                                       for(std::vector<aabb3f>::const_iterator
+                                                       i2 = boxes.begin();
+                                                       i2 != boxes.end(); i2++)
+                                       {
+                                               aabb3f box = *i2;
+                                               box.MinEdge += npf + v3f(-d,-d,-d) - intToFloat(camera_offset, BS);
+                                               box.MaxEdge += npf + v3f(d,d,d) - intToFloat(camera_offset, BS);
+                                               hilightboxes.push_back(box);
+                                       }
                                }
                        }
                }
@@ -2068,31 +2070,41 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
                }
                else if(input->wasKeyDown(getKeySetting("keymap_screenshot")))
                {
-                       irr::video::IImage* const image = driver->createScreenShot(video::ECF_R8G8B8);
-                       if (image) {
-                               irr::c8 filename[256];
-                               snprintf(filename, 256, "%s" DIR_DELIM "screenshot_%u.png",
+                       irr::video::IImage* const raw_image = driver->createScreenShot();
+                       if (raw_image) {
+                               irr::video::IImage* const image = driver->createImage(video::ECF_R8G8B8, 
+                                       raw_image->getDimension());
+
+                               if (image) {
+                                       raw_image->copyTo(image);
+                                       irr::c8 filename[256];
+                                       snprintf(filename, sizeof(filename), "%s" DIR_DELIM "screenshot_%u.png",
                                                 g_settings->get("screenshot_path").c_str(),
                                                 device->getTimer()->getRealTime());
-                               if (driver->writeImageToFile(image, filename)) {
-                                       std::wstringstream sstr;
-                                       sstr<<"Saved screenshot to '"<<filename<<"'";
-                                       infostream<<"Saved screenshot to '"<<filename<<"'"<<std::endl;
-                                       statustext = sstr.str();
-                                       statustext_time = 0;
-                               } else{
-                                       infostream<<"Failed to save screenshot '"<<filename<<"'"<<std::endl;
+                                       if (driver->writeImageToFile(image, filename)) {
+                                               std::wstringstream sstr;
+                                               sstr << "Saved screenshot to '" << filename << "'";
+                                               infostream << "Saved screenshot to '" << filename << "'" << std::endl;
+                                               statustext = sstr.str();
+                                               statustext_time = 0;
+                                       } else {
+                                               infostream << "Failed to save screenshot '" << filename << "'" << std::endl;
+                                       }
+                                       image->drop();
                                }
-                               image->drop();
+                               raw_image->drop();
                        }
                }
                else if(input->wasKeyDown(getKeySetting("keymap_toggle_hud")))
                {
                        show_hud = !show_hud;
-                       if(show_hud)
+                       if(show_hud) {
                                statustext = L"HUD shown";
-                       else
+                               client.setHighlighted(client.getHighlighted(), true);
+                       } else {
                                statustext = L"HUD hidden";
+                               client.setHighlighted(client.getHighlighted(), false);
+                       }
                        statustext_time = 0;
                }
                else if(input->wasKeyDown(getKeySetting("keymap_toggle_chat")))
@@ -2789,7 +2801,8 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
                if(pointed != pointed_old)
                {
                        infostream<<"Pointing at "<<pointed.dump()<<std::endl;
-                       //dstream<<"Pointing at "<<pointed.dump()<<std::endl;
+                       if (g_settings->getBool("enable_node_highlighting"))
+                               client.setHighlighted(pointed.node_undersurface, show_hud);
                }
 
                /*