]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Added Coords
authorElias Fleckenstein <eliasfleckenstein@web.de>
Sat, 1 Aug 2020 12:46:37 +0000 (14:46 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Sat, 1 Aug 2020 12:46:37 +0000 (14:46 +0200)
builtin/client/cheats.lua
src/client/gameui.cpp
src/client/gameui.h
src/defaultsettings.cpp

index 7290140dde0bd2a334a6fd9868e738ebbd9672e5..17347b8aecc84f2cf91b0c0c7a755def22d9499a 100644 (file)
@@ -20,6 +20,7 @@ core.cheats = {
                ["HUDBypass"] = "hud_flags_bypass",
                ["NoHurtCam"] = "no_hurt_cam",
                ["BrightNight"] = "no_night",
+               ["Coords"] = "coords",
        },
        ["World"] = {
                ["FastDig"] = "fastdig",
index d34f7343c6db7fbe49866752940bb3fda79d8282..8e6c82b114ba1086f6afc02d0f766e93c0061a31 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);
@@ -94,8 +97,24 @@ 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::get_instance()->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);
+
        if (m_flags.show_debug) {
                static float drawtime_avg = 0;
                drawtime_avg = drawtime_avg * 0.95 + stats.drawtime * 0.05;
@@ -125,9 +144,6 @@ void GameUI::update(const RunStats &stats, Client *client, MapDrawControl *draw_
        m_guitext->setVisible(m_flags.show_debug);
 
        if (m_flags.show_debug) {
-               LocalPlayer *player = client->getEnv().getLocalPlayer();
-               v3f player_position = player->getPosition();
-
                std::ostringstream os(std::ios_base::binary);
                os << std::setprecision(1) << std::fixed
                        << "pos: (" << (player_position.X / BS)
index 0b6298c78ce1192025fdef851096eba8c4b07580..8a1b5650dfbd570b94c319d27f622f412d4abaf2 100644 (file)
@@ -111,7 +111,8 @@ class GameUI
 
        gui::IGUIStaticText *m_guitext = nullptr;  // First line of debug text
        gui::IGUIStaticText *m_guitext2 = nullptr; // Second line of debug text
-
+       gui::IGUIStaticText *m_guitext_coords = nullptr;
+       
        gui::IGUIStaticText *m_guitext_info = nullptr; // At the middle of the screen
        std::wstring m_infotext;
 
index fe3dc3836d7c3bee0c36fc2da86906876694f30f..77592009fd03055e155d201664fea4061c65fe53 100644 (file)
@@ -87,6 +87,7 @@ void set_default_settings(Settings *settings)
        settings->setDefault("instant_break", "false");
        settings->setDefault("highway", "false");
        settings->setDefault("no_night", "false");
+       settings->setDefault("coords", "false");
        
        // Keymap
        settings->setDefault("remote_port", "30000");