Improve fps translation code.

This commit is contained in:
vlj
2014-09-08 19:51:40 +02:00
parent eaf9d796e8
commit ef89e168f8
2 changed files with 20 additions and 102 deletions

View File

@@ -1746,19 +1746,8 @@ void IrrDriver::displayFPS()
if (UserConfigParams::m_artist_debug_mode)
{
fpsString += _("FPS: ");
fpsString += core::stringw(min);
fpsString += _("/");
fpsString += core::stringw(fps);
fpsString += _("/");
fpsString += core::stringw(max);
fpsString += _(" PolyCount: ");
fpsString += _(" (Solid) ");
fpsString += core::stringw(poly_count[SOLID_NORMAL_AND_DEPTH_PASS]);
fpsString += _(" (Shadows) ");
fpsString += core::stringw(poly_count[SHADOW_PASS]);
fpsString += _(" LightDist: ");
fpsString += core::stringw(m_last_light_bucket_distance);
fpsString = StringUtils::insertValues(_("FPS: %d/%d/%d - PolyCount: %d Solid, %d Shadows - LightDist : %d"),
min, fps, max, poly_count[SOLID_NORMAL_AND_DEPTH_PASS], poly_count[SHADOW_PASS], m_last_light_bucket_distance);
poly_count[SOLID_NORMAL_AND_DEPTH_PASS] = 0;
poly_count[SHADOW_PASS] = 0;
object_count[SOLID_NORMAL_AND_DEPTH_PASS] = 0;
@@ -1766,17 +1755,7 @@ void IrrDriver::displayFPS()
object_count[TRANSPARENT_PASS] = 0;
}
else
{
fpsString += _("FPS: ");
fpsString += core::stringw(min);
fpsString += _("/");
fpsString += core::stringw(fps);
fpsString += _("/");
fpsString += core::stringw(max);
fpsString += _(" - ");
fpsString += core::stringw((int)roundf(kilotris));
fpsString += _("KTris");
}
fpsString = StringUtils::insertValues(_("FPS: %d/%d/%d - %d KTris"), min, fps, max, (int)roundf(kilotris));
static video::SColor fpsColor = video::SColor(255, 0, 0, 0);

View File

@@ -250,88 +250,27 @@ namespace StringUtils
} // insertValues(s, v1)
// ------------------------------------------------------------------------
/** Intermediate struct to fill a vector using variadic templates */
struct __FillStringwVector
{
template<typename T, typename...Args>
static void __Fill(std::vector<irr::core::stringw> &all_vals, T&& v, Args &&...args)
{
all_vals.push_back(irr::core::stringw(std::forward<T>(v)));
__Fill(all_vals, std::forward<Args>(args)...);
}
static void __Fill(std::vector<irr::core::stringw>&) {}
};
/** Like the other ones above but for wide strings */
template <class T1, class T2, class T3, class T4, class T5, class T6>
irr::core::stringw insertValues(const irr::core::stringw &s, const T1 &v1,
const T2 &v2, const T3 &v3, const T4 &v4,
const T5 &v5, const T6 &v6)
template <typename...Args>
irr::core::stringw insertValues(const irr::core::stringw &s, Args ...args)
{
std::vector<irr::core::stringw> all_vals;
all_vals.push_back( irr::core::stringw(v1) );
all_vals.push_back( irr::core::stringw(v2) );
all_vals.push_back( irr::core::stringw(v3) );
all_vals.push_back( irr::core::stringw(v4) );
all_vals.push_back( irr::core::stringw(v5) );
all_vals.push_back( irr::core::stringw(v6) );
__FillStringwVector::__Fill(all_vals, std::forward<Args>(args)...);
return insertValues(s, all_vals);
} // insertValues(s, v1, ..., v6)
// ------------------------------------------------------------------------
/** Like the other ones above but for wide strings */
template <class T1, class T2, class T3, class T4, class T5>
irr::core::stringw insertValues(const irr::core::stringw &s, const T1 &v1,
const T2 &v2, const T3 &v3, const T4 &v4,
const T5 &v5)
{
std::vector<irr::core::stringw> all_vals;
all_vals.push_back( irr::core::stringw(v1) );
all_vals.push_back( irr::core::stringw(v2) );
all_vals.push_back( irr::core::stringw(v3) );
all_vals.push_back( irr::core::stringw(v4) );
all_vals.push_back( irr::core::stringw(v5) );
return insertValues(s, all_vals);
} // insertValues(s, v1, ..., v5)
// ------------------------------------------------------------------------
/** Like the other ones above but for wide strings */
template <class T1, class T2, class T3, class T4>
irr::core::stringw insertValues(const irr::core::stringw &s, const T1 &v1,
const T2 &v2, const T3 &v3, const T4 &v4)
{
std::vector<irr::core::stringw> all_vals;
all_vals.push_back( irr::core::stringw(v1) );
all_vals.push_back( irr::core::stringw(v2) );
all_vals.push_back( irr::core::stringw(v3) );
all_vals.push_back( irr::core::stringw(v4) );
return insertValues(s, all_vals);
} // insertValues(s, v1, ..., v4)
// ------------------------------------------------------------------------
/** Like the other ones above but for wide strings */
template <class T1, class T2, class T3>
irr::core::stringw insertValues(const irr::core::stringw &s, const T1 &v1,
const T2 &v2, const T3 &v3)
{
std::vector<irr::core::stringw> all_vals;
irr::core::stringw dummy;
all_vals.push_back( irr::core::stringw(v1) );
all_vals.push_back( irr::core::stringw(v2) );
all_vals.push_back( irr::core::stringw(v3) );
return insertValues(s, all_vals);
} // insertValues(s, v1, ..., v3)
// ------------------------------------------------------------------------
/** Like the other ones above but for wide strings */
template <class T1, class T2>
irr::core::stringw insertValues(const irr::core::stringw &s, const T1 &v1,
const T2 &v2)
{
std::vector<irr::core::stringw> all_vals;
all_vals.push_back( irr::core::stringw(v1) );
all_vals.push_back( irr::core::stringw(v2) );
return insertValues(s, all_vals);
} // insertValues(s, v1, v2)
// ------------------------------------------------------------------------
/** Like the other ones above but for wide strings */
template <class T1>
irr::core::stringw insertValues(const irr::core::stringw &s, const T1 &v1)
{
std::vector<irr::core::stringw> all_vals;
all_vals.push_back( irr::core::stringw(v1) );
return insertValues(s, all_vals);
} // insertValues(s, v1)
}
// ------------------------------------------------------------------------
/** Like the other ones above but for wide strings */