mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-15 23:13:18 +00:00
Use std::string_view in MWGui::ToolTips
This commit is contained in:
parent
6150fe81c7
commit
d4a1061354
3 changed files with 15 additions and 15 deletions
|
|
@ -300,9 +300,9 @@ namespace MWGui
|
|||
ESM::Class::Specialization specialization
|
||||
= static_cast<ESM::Class::Specialization>(currentClass->mData.mSpecialization);
|
||||
|
||||
std::string specName{ MWBase::Environment::get().getWindowManager()->getGameSettingString(
|
||||
ESM::Class::sGmstSpecializationIds[specialization], ESM::Class::sGmstSpecializationIds[specialization]) };
|
||||
mSpecializationName->setCaption(specName);
|
||||
std::string_view specName = MWBase::Environment::get().getWindowManager()->getGameSettingString(
|
||||
ESM::Class::sGmstSpecializationIds[specialization], ESM::Class::sGmstSpecializationIds[specialization]);
|
||||
mSpecializationName->setCaption(MyGUI::UString(specName));
|
||||
ToolTips::createSpecializationToolTip(mSpecializationName, specName, specialization);
|
||||
|
||||
mFavoriteAttribute[0]->setAttributeId(ESM::Attribute::indexToRefId(currentClass->mData.mAttribute[0]));
|
||||
|
|
|
|||
|
|
@ -657,28 +657,28 @@ namespace MWGui
|
|||
return std::to_string(value);
|
||||
}
|
||||
|
||||
std::string ToolTips::getWeightString(const float weight, const std::string& prefix)
|
||||
std::string ToolTips::getWeightString(const float weight, std::string_view prefix)
|
||||
{
|
||||
if (weight == 0)
|
||||
return {};
|
||||
return std::format("\n{}: {}", prefix, toString(weight));
|
||||
}
|
||||
|
||||
std::string ToolTips::getPercentString(const float value, const std::string& prefix)
|
||||
std::string ToolTips::getPercentString(const float value, std::string_view prefix)
|
||||
{
|
||||
if (value == 0)
|
||||
return {};
|
||||
return std::format("\n{}: {}%", prefix, toString(value * 100));
|
||||
}
|
||||
|
||||
std::string ToolTips::getValueString(const int value, const std::string& prefix)
|
||||
std::string ToolTips::getValueString(const int value, std::string_view prefix)
|
||||
{
|
||||
if (value == 0)
|
||||
return {};
|
||||
return std::format("\n{}: {}", prefix, value);
|
||||
}
|
||||
|
||||
std::string ToolTips::getMiscString(const std::string& text, const std::string& prefix)
|
||||
std::string ToolTips::getMiscString(std::string_view text, std::string_view prefix)
|
||||
{
|
||||
if (text.empty())
|
||||
return {};
|
||||
|
|
@ -745,7 +745,7 @@ namespace MWGui
|
|||
return ret;
|
||||
}
|
||||
|
||||
std::string ToolTips::getDurationString(float duration, const std::string& prefix)
|
||||
std::string ToolTips::getDurationString(float duration, std::string_view prefix)
|
||||
{
|
||||
auto l10n = MWBase::Environment::get().getL10nManager()->getContext("Interface");
|
||||
|
||||
|
|
@ -853,7 +853,7 @@ namespace MWGui
|
|||
widget->setUserString("ImageTexture_AttributeImage", attribute->mIcon);
|
||||
}
|
||||
|
||||
void ToolTips::createSpecializationToolTip(MyGUI::Widget* widget, const std::string& name, int specId)
|
||||
void ToolTips::createSpecializationToolTip(MyGUI::Widget* widget, std::string_view name, int specId)
|
||||
{
|
||||
widget->setUserString("Caption_Caption", name);
|
||||
std::string specText;
|
||||
|
|
|
|||
|
|
@ -67,12 +67,12 @@ namespace MWGui
|
|||
void setFocusObjectScreenCoords(float x, float y);
|
||||
///< set the screen-space position of the tooltip for focused object
|
||||
|
||||
static std::string getWeightString(const float weight, const std::string& prefix);
|
||||
static std::string getPercentString(const float value, const std::string& prefix);
|
||||
static std::string getValueString(const int value, const std::string& prefix);
|
||||
static std::string getWeightString(const float weight, std::string_view prefix);
|
||||
static std::string getPercentString(const float value, std::string_view prefix);
|
||||
static std::string getValueString(const int value, std::string_view prefix);
|
||||
///< @return "prefix: value" or "" if value is 0
|
||||
|
||||
static std::string getMiscString(const std::string& text, const std::string& prefix);
|
||||
static std::string getMiscString(std::string_view text, std::string_view prefix);
|
||||
///< @return "prefix: text" or "" if text is empty
|
||||
|
||||
static std::string toString(const float value);
|
||||
|
|
@ -87,14 +87,14 @@ namespace MWGui
|
|||
static std::string getCellRefString(const MWWorld::CellRef& cellref);
|
||||
///< Returns a string containing debug tooltip information about the given cellref.
|
||||
|
||||
static std::string getDurationString(float duration, const std::string& prefix);
|
||||
static std::string getDurationString(float duration, std::string_view prefix);
|
||||
///< Returns duration as two largest time units, rounded down. Note: not localized; no line break.
|
||||
|
||||
// these do not create an actual tooltip, but they fill in the data that is required so the tooltip
|
||||
// system knows what to show in case this widget is hovered
|
||||
static void createSkillToolTip(MyGUI::Widget* widget, ESM::RefId skillId);
|
||||
static void createAttributeToolTip(MyGUI::Widget* widget, ESM::RefId attributeId);
|
||||
static void createSpecializationToolTip(MyGUI::Widget* widget, const std::string& name, int specId);
|
||||
static void createSpecializationToolTip(MyGUI::Widget* widget, std::string_view name, int specId);
|
||||
static void createBirthsignToolTip(MyGUI::Widget* widget, const ESM::RefId& birthsignId);
|
||||
static void createRaceToolTip(MyGUI::Widget* widget, const ESM::Race* playerRace);
|
||||
static void createClassToolTip(MyGUI::Widget* widget, const ESM::Class& playerClass);
|
||||
|
|
|
|||
Loading…
Reference in a new issue