]> git.lizzy.rs Git - minetest.git/commitdiff
Revisit F6 statistics formatting (#13126)
authorSmallJoker <SmallJoker@users.noreply.github.com>
Mon, 16 Jan 2023 19:16:23 +0000 (20:16 +0100)
committerGitHub <noreply@github.com>
Mon, 16 Jan 2023 19:16:23 +0000 (20:16 +0100)
src/client/gameui.cpp
src/collision.cpp
src/profiler.cpp

index 897cefc360627cda16640c2b5e089887333e6001..9daecc355b223afba79e5590a0b1c52ef92d9bbe 100644 (file)
@@ -276,7 +276,7 @@ void GameUI::updateProfiler()
 
                core::dimension2d<u32> size = m_guitext_profiler->getOverrideFont()->
                                getDimension(str.c_str());
-               core::position2di upper_left(6, 50);
+               core::position2di upper_left(6, m_guitext->getTextHeight() * 2.5f);
                core::position2di lower_right = upper_left;
                lower_right.X += size.Width + 10;
                lower_right.Y += size.Height;
index 575e70ff9375f263d1eab1ad6357dfd11d4acda7..0649b5ced8a270e8637e7fdd976f7abecf46f356 100644 (file)
@@ -273,7 +273,7 @@ collisionMoveResult collisionMoveSimple(Environment *env, IGameDef *gamedef,
        std::vector<NearbyCollisionInfo> cinfo;
        {
        //TimeTaker tt2("collisionMoveSimple collect boxes");
-       ScopeProfiler sp2(g_profiler, PROFILER_NAME("collisionMoveSimple(): collect boxes"), SPT_AVG);
+       ScopeProfiler sp2(g_profiler, PROFILER_NAME("collision collect boxes"), SPT_AVG);
 
        v3f minpos_f(
                MYMIN(pos_f->X, newpos_f.X),
index d05b7abfe36cafb0f5425d49c552969f7e7dec90..d13afc882ecbd3dc0f8b562a4bdfa002dcc8c4b0 100644 (file)
@@ -137,7 +137,7 @@ int Profiler::print(std::ostream &o, u32 page, u32 pagecount)
 {
        GraphValues values;
        getPage(values, page, pagecount);
-       char num_buf[50];
+       char buffer[50];
 
        for (const auto &i : values) {
                o << "  " << i.first << " ";
@@ -146,16 +146,17 @@ int Profiler::print(std::ostream &o, u32 page, u32 pagecount)
                        continue;
                }
 
-               s32 space = 44 - i.first.size();
-               for (s32 j = 0; j < space; j++) {
-                       if ((j & 1) && j < space - 1)
-                               o << ".";
-                       else
-                               o << " ";
+               {
+                       // Padding
+                       s32 space = std::max(0, 44 - (s32)i.first.size());
+                       memset(buffer, '_', space);
+                       buffer[space] = '\0';
+                       o << buffer;
                }
-               porting::mt_snprintf(num_buf, sizeof(num_buf), "% 4ix % 3g",
+
+               porting::mt_snprintf(buffer, sizeof(buffer), "% 5ix % 4.4g",
                                getAvgCount(i.first), i.second);
-               o << num_buf << std::endl;
+               o << buffer << std::endl;
        }
        return values.size();
 }