mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-22 19:39:32 -04:00
Use std::format in MWGui::ToolTips
This commit is contained in:
parent
9610be7c8a
commit
6150fe81c7
@ -1,5 +1,6 @@
|
|||||||
#include "tooltips.hpp"
|
#include "tooltips.hpp"
|
||||||
|
|
||||||
|
#include <format>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
|
||||||
#include <MyGUI_Gui.h>
|
#include <MyGUI_Gui.h>
|
||||||
@ -52,7 +53,7 @@ namespace MWGui
|
|||||||
mDynamicToolTipBox->setNeedMouseFocus(false);
|
mDynamicToolTipBox->setNeedMouseFocus(false);
|
||||||
mMainWidget->setNeedMouseFocus(false);
|
mMainWidget->setNeedMouseFocus(false);
|
||||||
|
|
||||||
for (unsigned int i = 0; i < mMainWidget->getChildCount(); ++i)
|
for (size_t i = 0; i < mMainWidget->getChildCount(); ++i)
|
||||||
{
|
{
|
||||||
mMainWidget->getChildAt(i)->setVisible(false);
|
mMainWidget->getChildAt(i)->setVisible(false);
|
||||||
}
|
}
|
||||||
@ -77,7 +78,7 @@ namespace MWGui
|
|||||||
}
|
}
|
||||||
|
|
||||||
// start by hiding everything
|
// start by hiding everything
|
||||||
for (unsigned int i = 0; i < mMainWidget->getChildCount(); ++i)
|
for (size_t i = 0; i < mMainWidget->getChildCount(); ++i)
|
||||||
{
|
{
|
||||||
mMainWidget->getChildAt(i)->setVisible(false);
|
mMainWidget->getChildAt(i)->setVisible(false);
|
||||||
}
|
}
|
||||||
@ -343,7 +344,7 @@ namespace MWGui
|
|||||||
MyGUI::Gui::getInstance().destroyWidget(mDynamicToolTipBox->getChildAt(0));
|
MyGUI::Gui::getInstance().destroyWidget(mDynamicToolTipBox->getChildAt(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < mMainWidget->getChildCount(); ++i)
|
for (size_t i = 0; i < mMainWidget->getChildCount(); ++i)
|
||||||
{
|
{
|
||||||
mMainWidget->getChildAt(i)->setVisible(false);
|
mMainWidget->getChildAt(i)->setVisible(false);
|
||||||
}
|
}
|
||||||
@ -660,40 +661,35 @@ namespace MWGui
|
|||||||
{
|
{
|
||||||
if (weight == 0)
|
if (weight == 0)
|
||||||
return {};
|
return {};
|
||||||
else
|
return std::format("\n{}: {}", prefix, toString(weight));
|
||||||
return "\n" + prefix + ": " + toString(weight);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ToolTips::getPercentString(const float value, const std::string& prefix)
|
std::string ToolTips::getPercentString(const float value, const std::string& prefix)
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
return {};
|
return {};
|
||||||
else
|
return std::format("\n{}: {}%", prefix, toString(value * 100));
|
||||||
return "\n" + prefix + ": " + toString(value * 100) + "%";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ToolTips::getValueString(const int value, const std::string& prefix)
|
std::string ToolTips::getValueString(const int value, const std::string& prefix)
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
return {};
|
return {};
|
||||||
else
|
return std::format("\n{}: {}", prefix, value);
|
||||||
return "\n" + prefix + ": " + toString(value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ToolTips::getMiscString(const std::string& text, const std::string& prefix)
|
std::string ToolTips::getMiscString(const std::string& text, const std::string& prefix)
|
||||||
{
|
{
|
||||||
if (text.empty())
|
if (text.empty())
|
||||||
return {};
|
return {};
|
||||||
else
|
return std::format("\n{}: {}", prefix, text);
|
||||||
return "\n" + prefix + ": " + text;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ToolTips::getCountString(const int value)
|
std::string ToolTips::getCountString(const int value)
|
||||||
{
|
{
|
||||||
if (value == 1)
|
if (value == 1)
|
||||||
return {};
|
return {};
|
||||||
else
|
return std::format(" ({})", value);
|
||||||
return " (" + MyGUI::utility::toString(value) + ")";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ToolTips::getSoulString(const MWWorld::CellRef& cellref)
|
std::string ToolTips::getSoulString(const MWWorld::CellRef& cellref)
|
||||||
@ -706,8 +702,8 @@ namespace MWGui
|
|||||||
if (!creature)
|
if (!creature)
|
||||||
return {};
|
return {};
|
||||||
if (creature->mName.empty())
|
if (creature->mName.empty())
|
||||||
return " (" + creature->mId.toDebugString() + ")";
|
return std::format(" ({})", creature->mId.toDebugString());
|
||||||
return " (" + creature->mName + ")";
|
return std::format(" ({})", creature->mName);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ToolTips::getCellRefString(const MWWorld::CellRef& cellref)
|
std::string ToolTips::getCellRefString(const MWWorld::CellRef& cellref)
|
||||||
@ -740,10 +736,9 @@ namespace MWGui
|
|||||||
for (std::pair<ESM::RefId, int>& owner : itemOwners)
|
for (std::pair<ESM::RefId, int>& owner : itemOwners)
|
||||||
{
|
{
|
||||||
if (owner.second == std::numeric_limits<int>::max())
|
if (owner.second == std::numeric_limits<int>::max())
|
||||||
ret += std::string("\nStolen from ") + owner.first.toDebugString(); // for legacy (ESS) savegames
|
ret += std::format("\nStolen from {}", owner.first.toDebugString()); // for legacy (ESS) savegames
|
||||||
else
|
else
|
||||||
ret += std::string("\nStolen ") + MyGUI::utility::toString(owner.second) + " from "
|
ret += std::format("\nStolen {} from {}", owner.second, owner.first.toDebugString());
|
||||||
+ owner.first.toDebugString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret += getMiscString(cellref.getGlobalVariable(), "Global");
|
ret += getMiscString(cellref.getGlobalVariable(), "Global");
|
||||||
@ -754,8 +749,8 @@ namespace MWGui
|
|||||||
{
|
{
|
||||||
auto l10n = MWBase::Environment::get().getL10nManager()->getContext("Interface");
|
auto l10n = MWBase::Environment::get().getL10nManager()->getContext("Interface");
|
||||||
|
|
||||||
std::string ret;
|
std::string ret(prefix);
|
||||||
ret = prefix + ": ";
|
ret += ": ";
|
||||||
|
|
||||||
if (duration < 1.f)
|
if (duration < 1.f)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user