X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fclient%2Fgameui.cpp;h=32396755023d3792c0d44eaf958d8544ef96d078;hb=a049e8267fabd101cb5c6528b3270214cb0647f0;hp=c216f405dc4064d908b9770bdb1b6ff54afaa1ec;hpb=a9b74f4c3966ad38c2f9a97364d3fdda0e514c93;p=dragonfireclient.git diff --git a/src/client/gameui.cpp b/src/client/gameui.cpp index c216f405d..323967550 100644 --- a/src/client/gameui.cpp +++ b/src/client/gameui.cpp @@ -61,17 +61,6 @@ void GameUI::init() m_guitext2 = gui::StaticText::add(guienv, L"", core::rect(0, 0, 0, 0), false, false, guiroot); - // At the middle of the screen - // Object infos are shown in this - m_guitext_info = gui::StaticText::add(guienv, L"", - core::rect(0, 0, 400, g_fontengine->getTextHeight() * 5 + 5) - + v2s32(100, 200), false, true, guiroot); - - // Status text (displays info when showing and hiding GUI stuff, etc.) - m_guitext_status = gui::StaticText::add(guienv, L"", - core::rect(0, 0, 0, 0), false, false, guiroot); - m_guitext_status->setVisible(false); - // Chat text m_guitext_chat = gui::StaticText::add(guienv, L"", core::rect(0, 0, 0, 0), //false, false); // Disable word wrap as of now @@ -82,6 +71,20 @@ void GameUI::init() chat_font_size, FM_Unspecified)); } + // At the middle of the screen + // Object infos are shown in this + u32 chat_font_height = m_guitext_chat->getActiveFont()->getDimension(L"Ay").Height; + m_guitext_info = gui::StaticText::add(guienv, L"", + core::rect(0, 0, 400, g_fontengine->getTextHeight() * 5 + 5) + + v2s32(100, chat_font_height * + (g_settings->getU16("recent_chat_messages") + 3)), + false, true, guiroot); + + // Status text (displays info when showing and hiding GUI stuff, etc.) + m_guitext_status = gui::StaticText::add(guienv, L"", + core::rect(0, 0, 0, 0), false, false, guiroot); + m_guitext_status->setVisible(false); + // Profiler text (size is updated when text is updated) m_guitext_profiler = gui::StaticText::add(guienv, L"", core::rect(0, 0, 0, 0), false, false, guiroot); @@ -94,9 +97,10 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_ const CameraOrientation &cam, const PointedThing &pointed_old, const GUIChatConsole *chat_console, float dtime) { - v2u32 screensize = RenderingEngine::get_instance()->getWindowSize(); + v2u32 screensize = RenderingEngine::getWindowSize(); - if (m_flags.show_debug) { + // Minimal debug text must only contain info that can't give a gameplay advantage + if (m_flags.show_minimal_debug) { static float drawtime_avg = 0; drawtime_avg = drawtime_avg * 0.95 + stats.drawtime * 0.05; u16 fps = 1.0 / stats.dtime_jitter.avg; @@ -113,8 +117,8 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_ << std::setprecision(1) << " | view range: " << (draw_control->range_all ? "All" : itos(draw_control->wanted_range)) - << std::setprecision(3) - << " | RTT: " << client->getRTT() << "s"; + << std::setprecision(2) + << " | RTT: " << (client->getRTT() * 1000.0f) << "ms"; setStaticText(m_guitext, utf8_to_wide(os.str()).c_str()); m_guitext->setRelativePosition(core::rect(5, 5, screensize.X, @@ -122,9 +126,10 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_ } // Finally set the guitext visible depending on the flag - m_guitext->setVisible(m_flags.show_debug); + m_guitext->setVisible(m_flags.show_minimal_debug); - if (m_flags.show_debug) { + // Basic debug text also shows info that might give a gameplay advantage + if (m_flags.show_basic_debug) { LocalPlayer *player = client->getEnv().getLocalPlayer(); v3f player_position = player->getPosition(); @@ -133,9 +138,9 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_ << "pos: (" << (player_position.X / BS) << ", " << (player_position.Y / BS) << ", " << (player_position.Z / BS) - << ") | yaw: " << (wrapDegrees_0_360(cam.camera_yaw)) << "\xC2\xB0 " + << ") | yaw: " << (wrapDegrees_0_360(cam.camera_yaw)) << "° " << yawToDirectionString(cam.camera_yaw) - << " | pitch: " << (-wrapDegrees_180(cam.camera_pitch)) << "\xC2\xB0" + << " | pitch: " << (-wrapDegrees_180(cam.camera_pitch)) << "°" << " | seed: " << ((u64)client->getMapSeed()); if (pointed_old.type == POINTEDTHING_NODE) { @@ -157,7 +162,7 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_ )); } - m_guitext2->setVisible(m_flags.show_debug); + m_guitext2->setVisible(m_flags.show_basic_debug); setStaticText(m_guitext_info, m_infotext.c_str()); m_guitext_info->setVisible(m_flags.show_hud && g_menumgr.menuCount() == 0); @@ -201,7 +206,8 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_ void GameUI::initFlags() { m_flags = GameUI::Flags(); - m_flags.show_debug = g_settings->getBool("show_debug"); + m_flags.show_minimal_debug = g_settings->getBool("show_debug"); + m_flags.show_basic_debug = false; } void GameUI::showMinimap(bool show) @@ -222,10 +228,12 @@ void GameUI::setChatText(const EnrichedString &chat_text, u32 recent_chat_count) // Update gui element size and position s32 chat_y = 5; - if (m_flags.show_debug) - chat_y += 2 * g_fontengine->getLineHeight(); + if (m_flags.show_minimal_debug) + chat_y += g_fontengine->getLineHeight(); + if (m_flags.show_basic_debug) + chat_y += g_fontengine->getLineHeight(); - const v2u32 &window_size = RenderingEngine::get_instance()->getWindowSize(); + const v2u32 &window_size = RenderingEngine::getWindowSize(); core::rect chat_size(10, chat_y, window_size.X - 20, 0); @@ -257,7 +265,7 @@ void GameUI::updateProfiler() core::position2di upper_left(6, 50); core::position2di lower_right = upper_left; lower_right.X += size.Width + 10; - lower_right.Y += size.Height; + lower_right.Y += size.Height; m_guitext_profiler->setRelativePosition(core::rect(upper_left, lower_right)); }