X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fgame.cpp;h=bae946f28eaa70a3751901b5e25dd18bc5fc5fb2;hb=58e6d25e033c76dc91aaac18fdeda92ac23fe0e1;hp=6c16372cc4bdc30f958b3a2c5927cfbcd3f5ee55;hpb=55c646c5c2b40931d24be8541b3056ab3322a70f;p=oweals%2Fminetest.git diff --git a/src/game.cpp b/src/game.cpp index 6c16372cc..bae946f28 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -407,14 +407,16 @@ PointedThing getPointedThing(Client *client, v3f player_position, mindistance = distance; hilightboxes.clear(); - for(std::vector::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::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); + } } } } @@ -1063,6 +1065,52 @@ static void show_pause_menu(GUIFormSpecMenu** cur_formspec, (*cur_formspec)->doPause = true; } +/******************************************************************************/ +static void updateChat(Client& client, f32 dtime, bool show_debug, + const v2u32& screensize, bool show_chat, u32 show_profiler, + ChatBackend& chat_backend, gui::IGUIStaticText* guitext_chat, + gui::IGUIFont* font) +{ + // Add chat log output for errors to be shown in chat + static LogOutputBuffer chat_log_error_buf(LMT_ERROR); + + // Get new messages from error log buffer + while(!chat_log_error_buf.empty()) { + chat_backend.addMessage(L"", narrow_to_wide(chat_log_error_buf.get())); + } + + // Get new messages from client + std::wstring message; + while (client.getChatMessage(message)) { + chat_backend.addUnparsedMessage(message); + } + + // Remove old messages + chat_backend.step(dtime); + + // Display all messages in a static text element + unsigned int recent_chat_count = chat_backend.getRecentBuffer().getLineCount(); + std::wstring recent_chat = chat_backend.getRecentChat(); + + // TODO replace by fontengine fcts + unsigned int line_height = font->getDimension(L"Ay").Height + font->getKerningHeight(); + + guitext_chat->setText(recent_chat.c_str()); + + // Update gui element size and position + s32 chat_y = 5 + line_height; + if (show_debug) + chat_y += line_height; + + core::rect rect(10, chat_y, font->getDimension(recent_chat.c_str()).Width +10, + chat_y + (recent_chat_count * line_height)); + + guitext_chat->setRelativePosition(rect); + // Don't show chat if disabled or empty or profiler is enabled + guitext_chat->setVisible( + show_chat && recent_chat_count != 0 && !show_profiler); +} + /******************************************************************************/ void the_game(bool &kill, bool random_input, InputHandler *input, IrrlichtDevice *device, gui::IGUIFont* font, std::string map_dir, @@ -1133,9 +1181,6 @@ void the_game(bool &kill, bool random_input, InputHandler *input, SoundMaker soundmaker(sound, nodedef); soundmaker.registerReceiver(&eventmgr); - // Add chat log output for errors to be shown in chat - LogOutputBuffer chat_log_error_buf(LMT_ERROR); - // Create UI for modifying quicktune values QuicktuneShortcutter quicktune; @@ -1527,24 +1572,24 @@ void the_game(bool &kill, bool random_input, InputHandler *input, gui::IGUIStaticText *guitext = guienv->addStaticText( L"Minetest", core::rect(0, 0, 0, 0), - false, false); + false, false, guiroot); // Second line of debug text gui::IGUIStaticText *guitext2 = guienv->addStaticText( L"", core::rect(0, 0, 0, 0), - false, false); + false, false, guiroot); // At the middle of the screen // Object infos are shown in this gui::IGUIStaticText *guitext_info = guienv->addStaticText( L"", core::rect(0,0,400,text_height*5+5) + v2s32(100,200), - false, true); + false, true, guiroot); // Status text (displays info when showing and hiding GUI stuff, etc.) gui::IGUIStaticText *guitext_status = guienv->addStaticText( L"", core::rect(0,0,0,0), - false, false); + false, false, guiroot); guitext_status->setVisible(false); std::wstring statustext; @@ -1555,7 +1600,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input, L"", core::rect(0,0,0,0), //false, false); // Disable word wrap as of now - false, true); + false, true, guiroot); // Remove stale "recent" chat messages from previous connections chat_backend.clearRecentChat(); // Chat backend and console @@ -1565,7 +1610,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input, gui::IGUIStaticText *guitext_profiler = guienv->addStaticText( L"", core::rect(0,0,0,0), - false, false); + false, false, guiroot); guitext_profiler->setBackgroundColor(video::SColor(120,0,0,0)); guitext_profiler->setVisible(false); guitext_profiler->setWordWrap(true); @@ -2025,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(); - 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 '"<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"))) @@ -2746,7 +2801,8 @@ void the_game(bool &kill, bool random_input, InputHandler *input, if(pointed != pointed_old) { infostream<<"Pointing at "<getBool("enable_node_highlighting")) + client.setHighlighted(pointed.node_undersurface, show_hud); } /* @@ -3311,43 +3367,8 @@ void the_game(bool &kill, bool random_input, InputHandler *input, /* Get chat messages from client */ - { - // Get new messages from error log buffer - while(!chat_log_error_buf.empty()) - { - chat_backend.addMessage(L"", narrow_to_wide( - chat_log_error_buf.get())); - } - // Get new messages from client - std::wstring message; - while(client.getChatMessage(message)) - { - chat_backend.addUnparsedMessage(message); - } - // Remove old messages - chat_backend.step(dtime); - - // Display all messages in a static text element - u32 recent_chat_count = chat_backend.getRecentBuffer().getLineCount(); - std::wstring recent_chat = chat_backend.getRecentChat(); - guitext_chat->setText(recent_chat.c_str()); - - // Update gui element size and position - s32 chat_y = 5+(text_height+5); - if(show_debug) - chat_y += (text_height+5); - core::rect rect( - 10, - chat_y, - screensize.X - 10, - chat_y + guitext_chat->getTextHeight() - ); - guitext_chat->setRelativePosition(rect); - - // Don't show chat if disabled or empty or profiler is enabled - guitext_chat->setVisible(show_chat && recent_chat_count != 0 - && !show_profiler); - } + updateChat(client, dtime, show_debug, screensize, show_chat, + show_profiler, chat_backend, guitext_chat, font); /* Inventory @@ -3388,6 +3409,13 @@ void the_game(bool &kill, bool random_input, InputHandler *input, update_draw_list_last_cam_dir = camera_direction; } + /* + make sure menu is on top + */ + if ((!noMenuActive()) && (current_formspec)) { + guiroot->bringToFront(current_formspec); + } + /* Drawing begins */