]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/client/gameui.cpp
Merge branch 'master' of https://github.com/minetest/minetest
[dragonfireclient.git] / src / client / gameui.cpp
index 01c733b4f412f678f4aa70153c984d44d5c42a35..54be24ae2ac6fd7fc65fef0a31f6bb8bbb112148 100644 (file)
@@ -53,6 +53,9 @@ GameUI::GameUI()
 }
 void GameUI::init()
 {
+       m_guitext_coords = gui::StaticText::add(guienv, L"", core::rect<s32>(0, 0, 0, 0), false,
+               false, guiroot);
+
        // First line of debug text
        m_guitext = gui::StaticText::add(guienv, utf8_to_wide(PROJECT_NAME_C).c_str(),
                core::rect<s32>(0, 0, 0, 0), false, false, guiroot);
@@ -100,8 +103,25 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_
        const CameraOrientation &cam, const PointedThing &pointed_old,
        const GUIChatConsole *chat_console, float dtime)
 {
+       LocalPlayer *player = client->getEnv().getLocalPlayer();
+       v3f player_position = player->getPosition();
+
        v2u32 screensize = RenderingEngine::getWindowSize();
 
+       bool show_coords = g_settings->getBool("coords");
+
+       if (show_coords) {
+               std::ostringstream os(std::ios_base::binary);
+               os << std::setprecision(1) << std::fixed
+                       << (player_position.X / BS)
+                       << ", " << (player_position.Y / BS)
+                       << ", " << (player_position.Z / BS);
+               setStaticText(m_guitext_coords, utf8_to_wide(os.str()).c_str());
+               m_guitext_coords->setRelativePosition(core::rect<s32>(5, screensize.Y - 5 - g_fontengine->getTextHeight(), screensize.X, screensize.Y));
+       }
+
+       m_guitext_coords->setVisible(show_coords);
+
        // Minimal debug text must only contain info that can't give a gameplay advantage
        if (m_flags.show_minimal_debug) {
                const u16 fps = 1.0 / stats.dtime_jitter.avg;
@@ -206,8 +226,7 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_
                m_guitext_status->enableOverrideColor(true);
        }
 
-       // Hide chat when console is visible
-       m_guitext_chat->setVisible(isChatVisible() && !chat_console->isVisible());
+       m_guitext_chat->setVisible(isChatVisible());
 }
 
 void GameUI::initFlags()
@@ -238,15 +257,16 @@ void GameUI::setChatText(const EnrichedString &chat_text, u32 recent_chat_count)
 void GameUI::updateChatSize()
 {
        // Update gui element size and position
-       s32 chat_y = 5;
+
+       const v2u32 &window_size = RenderingEngine::getWindowSize();
+
+       s32 chat_y = window_size.Y - 150 - m_guitext_chat->getTextHeight();
 
        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::getWindowSize();
-
        core::rect<s32> chat_size(10, chat_y, window_size.X - 20, 0);
        chat_size.LowerRightCorner.Y = std::min((s32)window_size.Y,
                        m_guitext_chat->getTextHeight() + chat_y);
@@ -294,6 +314,15 @@ void GameUI::toggleChat()
                showTranslatedStatusText("Chat hidden");
 }
 
+void GameUI::toggleCheatMenu()
+{
+       m_flags.show_cheat_menu = !m_flags.show_cheat_menu;
+       if (m_flags.show_cheat_menu)
+               showTranslatedStatusText("Cheat Menu shown");
+       else
+               showTranslatedStatusText("Cheat Menu hidden");
+}
+
 void GameUI::toggleHud()
 {
        m_flags.show_hud = !m_flags.show_hud;