mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-29 04:20:29 +00:00
Use more string_view
This commit is contained in:
parent
bedfbfd594
commit
dfcd34372d
@ -163,7 +163,7 @@ namespace MWClass
|
||||
text += "\n#{sType} ";
|
||||
|
||||
int skill = MWMechanics::getWeaponType(ref->mBase->mData.mType)->mSkill;
|
||||
const std::string type = ESM::Skill::sSkillNameIds[skill];
|
||||
const std::string& type = ESM::Skill::sSkillNameIds[skill];
|
||||
std::string_view oneOrTwoHanded;
|
||||
if (weaponType->mWeaponClass == ESM::WeaponType::Melee)
|
||||
{
|
||||
|
@ -393,7 +393,7 @@ namespace MWGui
|
||||
const ESM::Spell* spell =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
|
||||
|
||||
std::string spellName = spell->mName;
|
||||
const std::string& spellName = spell->mName;
|
||||
if (spellName != mSpellName && mSpellVisible)
|
||||
{
|
||||
mWeaponSpellTimer = 5.0f;
|
||||
@ -463,7 +463,7 @@ namespace MWGui
|
||||
|
||||
void HUD::unsetSelectedSpell()
|
||||
{
|
||||
std::string spellName = "#{sNone}";
|
||||
std::string_view spellName = "#{sNone}";
|
||||
if (spellName != mSpellName && mSpellVisible)
|
||||
{
|
||||
mWeaponSpellTimer = 5.0f;
|
||||
|
@ -791,7 +791,7 @@ namespace MWGui
|
||||
|
||||
int incr = next ? 1 : -1;
|
||||
bool found = false;
|
||||
std::string lastId;
|
||||
std::string_view lastId;
|
||||
if (selected != -1)
|
||||
lastId = model.getItem(selected).mBase.getCellRef().getRefId();
|
||||
ItemModel::ModelIndex cycled = selected;
|
||||
|
@ -93,7 +93,7 @@ namespace MWGui
|
||||
{
|
||||
MWBase::WindowManager *winMgr = MWBase::Environment::get().getWindowManager();
|
||||
|
||||
std::string name = *sender->getUserData<std::string>();
|
||||
const std::string& name = *sender->getUserData<std::string>();
|
||||
winMgr->playSound("Menu Click");
|
||||
if (name == "return")
|
||||
{
|
||||
|
@ -287,16 +287,16 @@ namespace MWGui
|
||||
while (mConfigArea->getChildCount() > 0)
|
||||
MyGUI::Gui::getInstance().destroyWidget(mConfigArea->getChildAt(0));
|
||||
|
||||
mShaderInfo->setCaption("");
|
||||
mShaderInfo->setCaption({});
|
||||
|
||||
std::ostringstream ss;
|
||||
|
||||
const std::string NA = "#{Interface:NotAvailableShort}";
|
||||
const std::string endl = "\n";
|
||||
const std::string_view NA = "#{Interface:NotAvailableShort}";
|
||||
const char endl = '\n';
|
||||
|
||||
std::string author = technique->getAuthor().empty() ? NA : std::string(technique->getAuthor());
|
||||
std::string version = technique->getVersion().empty() ? NA : std::string(technique->getVersion());
|
||||
std::string description = technique->getDescription().empty() ? NA : std::string(technique->getDescription());
|
||||
std::string_view author = technique->getAuthor().empty() ? NA : technique->getAuthor();
|
||||
std::string_view version = technique->getVersion().empty() ? NA : technique->getVersion();
|
||||
std::string_view description = technique->getDescription().empty() ? NA : technique->getDescription();
|
||||
|
||||
auto serializeBool = [](bool value) {
|
||||
return value ? "#{sYes}" : "#{sNo}";
|
||||
|
@ -68,7 +68,7 @@ void Recharge::updateView()
|
||||
{
|
||||
MWWorld::Ptr gem = *mGemIcon->getUserData<MWWorld::Ptr>();
|
||||
|
||||
std::string soul = gem.getCellRef().getSoul();
|
||||
const std::string& soul = gem.getCellRef().getSoul();
|
||||
const ESM::Creature *creature = MWBase::Environment::get().getWorld()->getStore().get<ESM::Creature>().find(soul);
|
||||
|
||||
mChargeLabel->setCaptionWithReplacing("#{sCharges} " + MyGUI::utility::toString(creature->mData.mSoul));
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "../mwstate/character.hpp"
|
||||
|
||||
#include "confirmationdialog.hpp"
|
||||
#include "ustring.hpp"
|
||||
|
||||
namespace MWGui
|
||||
{
|
||||
@ -177,7 +178,7 @@ namespace MWGui
|
||||
|
||||
// For a custom class, we will not find it in the store (unless we loaded the savegame first).
|
||||
// Fall back to name stored in savegame header in that case.
|
||||
std::string className;
|
||||
std::string_view className;
|
||||
if (it->getSignature().mPlayerClassId.empty())
|
||||
className = it->getSignature().mPlayerClassName;
|
||||
else
|
||||
@ -191,7 +192,7 @@ namespace MWGui
|
||||
className = "?"; // From an older savegame format that did not support custom classes properly.
|
||||
}
|
||||
|
||||
title << " (#{sLevel} " << it->getSignature().mPlayerLevel << " " << MyGUI::TextIterator::toTagsString(className) << ")";
|
||||
title << " (#{sLevel} " << it->getSignature().mPlayerLevel << " " << MyGUI::TextIterator::toTagsString(toUString(className)) << ")";
|
||||
|
||||
mCharacterSelection->addItem (MyGUI::LanguageManager::getInstance().replaceTags(title.str()));
|
||||
|
||||
|
@ -238,7 +238,7 @@ namespace MWGui
|
||||
, mCurrentPage(-1)
|
||||
{
|
||||
bool terrain = Settings::Manager::getBool("distant terrain", "Terrain");
|
||||
const std::string widgetName = terrain ? "RenderingDistanceSlider" : "LargeRenderingDistanceSlider";
|
||||
const std::string_view widgetName = terrain ? "RenderingDistanceSlider" : "LargeRenderingDistanceSlider";
|
||||
MyGUI::Widget* unusedSlider;
|
||||
getWidget(unusedSlider, widgetName);
|
||||
unusedSlider->setVisible(false);
|
||||
|
@ -34,10 +34,7 @@ namespace MWGui
|
||||
|
||||
bool SpellBuyingWindow::sortSpells (const ESM::Spell* left, const ESM::Spell* right)
|
||||
{
|
||||
std::string leftName = Misc::StringUtils::lowerCase(left->mName);
|
||||
std::string rightName = Misc::StringUtils::lowerCase(right->mName);
|
||||
|
||||
return leftName.compare(rightName) < 0;
|
||||
return Misc::StringUtils::ciLess(left->mName, right->mName);
|
||||
}
|
||||
|
||||
void SpellBuyingWindow::addSpell(const ESM::Spell& spell)
|
||||
|
@ -555,7 +555,7 @@ namespace MWGui
|
||||
|
||||
for (const short effectId : knownEffects)
|
||||
{
|
||||
std::string name = MWBase::Environment::get().getWorld ()->getStore ().get<ESM::GameSetting>().find(
|
||||
const std::string& name = MWBase::Environment::get().getWorld ()->getStore ().get<ESM::GameSetting>().find(
|
||||
ESM::MagicEffect::effectIdToString(effectId))->mValue.getString();
|
||||
MyGUI::Widget* w = mAvailableEffectsList->getItemWidget(name);
|
||||
|
||||
|
@ -149,7 +149,7 @@ namespace MWGui
|
||||
image->setImageTexture(Misc::ResourceHelpers::correctIconPath(effect->mIcon,
|
||||
MWBase::Environment::get().getResourceSystem()->getVFS()));
|
||||
|
||||
std::string name = ESM::MagicEffect::effectIdToString (effectId);
|
||||
const std::string& name = ESM::MagicEffect::effectIdToString(effectId);
|
||||
|
||||
ToolTipInfo tooltipInfo;
|
||||
tooltipInfo.caption = "#{" + name + "}";
|
||||
|
@ -147,7 +147,7 @@ namespace MWGui
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Spell>().find(spellId);
|
||||
|
||||
MWWorld::Ptr player = MWMechanics::getPlayer();
|
||||
std::string raceId = player.get<ESM::NPC>()->mBase->mRace;
|
||||
const std::string& raceId = player.get<ESM::NPC>()->mBase->mRace;
|
||||
const ESM::Race* race = MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(raceId);
|
||||
// can't delete racial spells, birthsign spells or powers
|
||||
bool isInherent = race->mPowers.exists(spell->mId) || spell->mData.mType == ESM::Spell::ST_Power;
|
||||
|
@ -400,9 +400,9 @@ namespace MWGui
|
||||
else
|
||||
mDynamicToolTipBox->changeWidgetSkin(MWBase::Environment::get().getWindowManager()->isGuiMode() ? "HUD_Box_NoTransp" : "HUD_Box");
|
||||
|
||||
std::string caption = info.caption;
|
||||
std::string image = info.icon;
|
||||
int imageSize = (image != "") ? info.imageSize : 0;
|
||||
const std::string& caption = info.caption;
|
||||
const std::string& image = info.icon;
|
||||
int imageSize = (!image.empty()) ? info.imageSize : 0;
|
||||
std::string text = info.text;
|
||||
|
||||
// remove the first newline (easier this way)
|
||||
@ -411,7 +411,7 @@ namespace MWGui
|
||||
|
||||
const ESM::Enchantment* enchant = nullptr;
|
||||
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
||||
if (info.enchant != "")
|
||||
if (!info.enchant.empty())
|
||||
{
|
||||
enchant = store.get<ESM::Enchantment>().search(info.enchant);
|
||||
if (enchant)
|
||||
@ -432,8 +432,8 @@ namespace MWGui
|
||||
|
||||
const MyGUI::IntPoint padding(8, 8);
|
||||
|
||||
const int imageCaptionHPadding = (caption != "" ? 8 : 0);
|
||||
const int imageCaptionVPadding = (caption != "" ? 4 : 0);
|
||||
const int imageCaptionHPadding = !caption.empty() ? 8 : 0;
|
||||
const int imageCaptionVPadding = !caption.empty() ? 4 : 0;
|
||||
|
||||
const int maximumWidth = MyGUI::RenderManager::getInstance().getViewSize().width - imageCaptionHPadding * 2;
|
||||
|
||||
@ -446,7 +446,7 @@ namespace MWGui
|
||||
captionWidget->setCaptionWithReplacing(caption);
|
||||
MyGUI::IntSize captionSize = captionWidget->getTextSize();
|
||||
|
||||
int captionHeight = std::max(caption != "" ? captionSize.height : 0, imageSize);
|
||||
int captionHeight = std::max(!caption.empty() ? captionSize.height : 0, imageSize);
|
||||
|
||||
Gui::EditBox* textWidget = mDynamicToolTipBox->createWidget<Gui::EditBox>("SandText", MyGUI::IntCoord(0, captionHeight+imageCaptionVPadding, 300, 300-captionHeight-imageCaptionVPadding), MyGUI::Align::Stretch, "ToolTipText");
|
||||
textWidget->setEditStatic(true);
|
||||
@ -458,8 +458,8 @@ namespace MWGui
|
||||
MyGUI::IntSize textSize = textWidget->getTextSize();
|
||||
|
||||
captionSize += MyGUI::IntSize(imageSize, 0); // adjust for image
|
||||
MyGUI::IntSize totalSize = MyGUI::IntSize( std::min(std::max(textSize.width,captionSize.width + ((image != "") ? imageCaptionHPadding : 0)),maximumWidth),
|
||||
((text != "") ? textSize.height + imageCaptionVPadding : 0) + captionHeight );
|
||||
MyGUI::IntSize totalSize = MyGUI::IntSize( std::min(std::max(textSize.width,captionSize.width + ((!image.empty()) ? imageCaptionHPadding : 0)),maximumWidth),
|
||||
(!text.empty() ? textSize.height + imageCaptionVPadding : 0) + captionHeight );
|
||||
|
||||
for (const std::string& note : info.notes)
|
||||
{
|
||||
@ -578,7 +578,7 @@ namespace MWGui
|
||||
|
||||
textWidget->setPosition (textWidget->getPosition() + MyGUI::IntPoint(0, padding.top)); // only apply vertical padding, the horizontal works automatically due to Align::HCenter
|
||||
|
||||
if (image != "")
|
||||
if (!image.empty())
|
||||
{
|
||||
MyGUI::ImageBox* imageWidget = mDynamicToolTipBox->createWidget<MyGUI::ImageBox>("ImageBox",
|
||||
MyGUI::IntCoord((totalSize.width - captionSize.width - imageCaptionHPadding)/2, 0, imageSize, imageSize),
|
||||
@ -611,7 +611,7 @@ namespace MWGui
|
||||
std::string ToolTips::getWeightString(const float weight, const std::string& prefix)
|
||||
{
|
||||
if (weight == 0)
|
||||
return "";
|
||||
return {};
|
||||
else
|
||||
return "\n" + prefix + ": " + toString(weight);
|
||||
}
|
||||
@ -619,7 +619,7 @@ namespace MWGui
|
||||
std::string ToolTips::getPercentString(const float value, const std::string& prefix)
|
||||
{
|
||||
if (value == 0)
|
||||
return "";
|
||||
return {};
|
||||
else
|
||||
return "\n" + prefix + ": " + toString(value*100) +"%";
|
||||
}
|
||||
@ -627,15 +627,15 @@ namespace MWGui
|
||||
std::string ToolTips::getValueString(const int value, const std::string& prefix)
|
||||
{
|
||||
if (value == 0)
|
||||
return "";
|
||||
return {};
|
||||
else
|
||||
return "\n" + prefix + ": " + toString(value);
|
||||
}
|
||||
|
||||
std::string ToolTips::getMiscString(const std::string& text, const std::string& prefix)
|
||||
{
|
||||
if (text == "")
|
||||
return "";
|
||||
if (text.empty())
|
||||
return {};
|
||||
else
|
||||
return "\n" + prefix + ": " + text;
|
||||
}
|
||||
@ -643,7 +643,7 @@ namespace MWGui
|
||||
std::string ToolTips::getCountString(const int value)
|
||||
{
|
||||
if (value == 1)
|
||||
return "";
|
||||
return {};
|
||||
else
|
||||
return " (" + MyGUI::utility::toString(value) + ")";
|
||||
}
|
||||
@ -652,11 +652,11 @@ namespace MWGui
|
||||
{
|
||||
const std::string& soul = cellref.getSoul();
|
||||
if (soul.empty())
|
||||
return std::string();
|
||||
return {};
|
||||
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
||||
const ESM::Creature *creature = store.get<ESM::Creature>().search(soul);
|
||||
if (!creature)
|
||||
return std::string();
|
||||
return {};
|
||||
if (creature->mName.empty())
|
||||
return " (" + creature->mId + ")";
|
||||
return " (" + creature->mName + ")";
|
||||
@ -677,7 +677,7 @@ namespace MWGui
|
||||
if (cellref.getFactionRank() >= 0)
|
||||
{
|
||||
int rank = cellref.getFactionRank();
|
||||
const std::string rankName = fact->mRanks[rank];
|
||||
const std::string& rankName = fact->mRanks[rank];
|
||||
if (rankName.empty())
|
||||
ret += getValueString(cellref.getFactionRank(), "Rank");
|
||||
else
|
||||
@ -802,9 +802,9 @@ namespace MWGui
|
||||
if (attributeId == -1)
|
||||
return;
|
||||
|
||||
std::string icon = ESM::Attribute::sAttributeIcons[attributeId];
|
||||
std::string name = ESM::Attribute::sGmstAttributeIds[attributeId];
|
||||
std::string desc = ESM::Attribute::sGmstAttributeDescIds[attributeId];
|
||||
const std::string& icon = ESM::Attribute::sAttributeIcons[attributeId];
|
||||
const std::string& name = ESM::Attribute::sGmstAttributeIds[attributeId];
|
||||
const std::string& desc = ESM::Attribute::sGmstAttributeDescIds[attributeId];
|
||||
|
||||
widget->setUserString("ToolTipType", "Layout");
|
||||
widget->setUserString("ToolTipLayout", "AttributeToolTip");
|
||||
@ -850,12 +850,9 @@ namespace MWGui
|
||||
widget->setUserString("ToolTipType", "Layout");
|
||||
widget->setUserString("ToolTipLayout", "BirthSignToolTip");
|
||||
widget->setUserString("ImageTexture_BirthSignImage", Misc::ResourceHelpers::correctTexturePath(sign->mTexture, vfs));
|
||||
std::string text;
|
||||
std::string text = sign->mName + "\n#{fontcolourhtml=normal}" + sign->mDescription;
|
||||
|
||||
text += sign->mName;
|
||||
text += "\n#{fontcolourhtml=normal}" + sign->mDescription;
|
||||
|
||||
std::vector<std::string> abilities, powers, spells;
|
||||
std::vector<const ESM::Spell*> abilities, powers, spells;
|
||||
|
||||
for (const std::string& spellId : sign->mPowers.mList)
|
||||
{
|
||||
@ -867,35 +864,27 @@ namespace MWGui
|
||||
continue; // We only want spell, ability and powers.
|
||||
|
||||
if (type == ESM::Spell::ST_Ability)
|
||||
abilities.push_back(spellId);
|
||||
abilities.push_back(spell);
|
||||
else if (type == ESM::Spell::ST_Power)
|
||||
powers.push_back(spellId);
|
||||
powers.push_back(spell);
|
||||
else if (type == ESM::Spell::ST_Spell)
|
||||
spells.push_back(spellId);
|
||||
spells.push_back(spell);
|
||||
}
|
||||
|
||||
struct {
|
||||
const std::vector<std::string> &spells;
|
||||
std::string label;
|
||||
}
|
||||
categories[3] = {
|
||||
{abilities, "sBirthsignmenu1"},
|
||||
{powers, "sPowers"},
|
||||
{spells, "sBirthsignmenu2"}
|
||||
};
|
||||
|
||||
for (int category = 0; category < 3; ++category)
|
||||
using Category = std::pair<const std::vector<const ESM::Spell*>&, std::string_view>;
|
||||
for (const auto&[category, label] : std::initializer_list<Category>{{abilities, "sBirthsignmenu1"}, {powers, "sPowers"}, {spells, "sBirthsignmenu2"}})
|
||||
{
|
||||
bool addHeader = true;
|
||||
for (const std::string& spellId : categories[category].spells)
|
||||
for (const ESM::Spell* spell : category)
|
||||
{
|
||||
if (addHeader)
|
||||
{
|
||||
text += std::string("\n\n#{fontcolourhtml=header}") + std::string("#{") + categories[category].label + "}";
|
||||
text += "\n\n#{fontcolourhtml=header}#{";
|
||||
text += label;
|
||||
text += '}';
|
||||
addHeader = false;
|
||||
}
|
||||
|
||||
const ESM::Spell *spell = store.get<ESM::Spell>().find(spellId);
|
||||
text += "\n#{fontcolourhtml=normal}" + spell->mName;
|
||||
}
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ void MWMechanics::AiPackage::openDoors(const MWWorld::Ptr& actor)
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string keyId = door.getCellRef().getKey();
|
||||
const std::string& keyId = door.getCellRef().getKey();
|
||||
if (keyId.empty())
|
||||
return;
|
||||
|
||||
|
@ -60,8 +60,7 @@ namespace MWMechanics
|
||||
actor.getClass().getCreatureStats(actor).getSpells().add(spell);
|
||||
MWBase::Environment::get().getWorld()->applyLoopingParticles(actor);
|
||||
|
||||
std::string msg = "sMagicContractDisease";
|
||||
msg = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find(msg)->mValue.getString();
|
||||
std::string msg = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("sMagicContractDisease")->mValue.getString();
|
||||
msg = Misc::StringUtils::format(msg, spell->mName);
|
||||
MWBase::Environment::get().getWindowManager()->messageBox(msg);
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace MWWorld
|
||||
}
|
||||
|
||||
const auto& target = getTarget();
|
||||
const std::string targetSoul = target.getCellRef().getSoul();
|
||||
const std::string& targetSoul = target.getCellRef().getSoul();
|
||||
|
||||
if (targetSoul.empty())
|
||||
{
|
||||
|
@ -137,7 +137,7 @@ void MWWorld::ContainerStore::storeStates (const CellRefList<T>& collection,
|
||||
}
|
||||
}
|
||||
|
||||
const std::string MWWorld::ContainerStore::sGoldId = "gold_001";
|
||||
const std::string_view MWWorld::ContainerStore::sGoldId = "gold_001";
|
||||
|
||||
MWWorld::ContainerStore::ContainerStore()
|
||||
: mListener(nullptr)
|
||||
|
@ -90,7 +90,7 @@ namespace MWWorld
|
||||
|
||||
static constexpr int Type_All = 0xffff;
|
||||
|
||||
static const std::string sGoldId;
|
||||
static const std::string_view sGoldId;
|
||||
|
||||
protected:
|
||||
ContainerStoreListener* mListener;
|
||||
|
Loading…
x
Reference in New Issue
Block a user