diff --git a/apps/openmw/mwgui/cursor.cpp b/apps/openmw/mwgui/cursor.cpp index 7c95e2fd11..1b6431f0fb 100644 --- a/apps/openmw/mwgui/cursor.cpp +++ b/apps/openmw/mwgui/cursor.cpp @@ -23,8 +23,8 @@ namespace MWGui MyGUI::xml::ElementEnumerator info = _node->getElementEnumerator(); while (info.next("Property")) { - const std::string& key = info->findAttribute("key"); - const std::string& value = info->findAttribute("value"); + auto key = info->findAttribute("key"); + auto value = info->findAttribute("value"); if (key == "Point") mPoint = MyGUI::IntPoint::parse(value); diff --git a/apps/openmw/mwgui/resourceskin.cpp b/apps/openmw/mwgui/resourceskin.cpp index ea081dd17a..e527b15796 100644 --- a/apps/openmw/mwgui/resourceskin.cpp +++ b/apps/openmw/mwgui/resourceskin.cpp @@ -9,15 +9,15 @@ namespace MWGui void resizeSkin(MyGUI::xml::ElementPtr _node) { _node->setAttribute("type", "ResourceSkin"); - const std::string size = _node->findAttribute("size"); + auto size = _node->findAttribute("size"); if (!size.empty()) return; - const std::string textureName = _node->findAttribute("texture"); + auto textureName = _node->findAttribute("texture"); if (textureName.empty()) return; - MyGUI::ITexture* texture = MyGUI::RenderManager::getInstance().getTexture(textureName); + MyGUI::ITexture* texture = MyGUI::RenderManager::getInstance().getTexture(std::string(textureName)); if (!texture) return; @@ -30,7 +30,7 @@ namespace MWGui if (basis->getName() != "BasisSkin") continue; - const std::string basisSkinType = basis->findAttribute("type"); + auto basisSkinType = basis->findAttribute("type"); if (Misc::StringUtils::ciEqual(basisSkinType, "SimpleText")) continue; bool isTileRect = Misc::StringUtils::ciEqual(basisSkinType, "TileRect"); diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index 2c405dcbd3..3c15826eae 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -242,13 +242,13 @@ namespace MWGui void SettingsWindow::updateSliderLabel(MyGUI::ScrollBar* scroller, const std::string& value) { - std::string labelWidgetName = scroller->getUserString("SettingLabelWidget"); + auto labelWidgetName = scroller->getUserString("SettingLabelWidget"); if (!labelWidgetName.empty()) { MyGUI::TextBox* textBox; getWidget(textBox, labelWidgetName); - std::string labelCaption = scroller->getUserString("SettingLabelCaption"); - labelCaption = Misc::StringUtils::format(labelCaption, value); + auto labelCaption = scroller->getUserString("SettingLabelCaption"); + labelCaption = Misc::StringUtils::format(std::string(labelCaption), value); textBox->setCaptionWithReplacing(labelCaption); } } diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 6beee8d07b..323579317a 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -244,7 +244,7 @@ namespace MWGui = store->get().find(MWMechanics::getSpellSchool(spell, player))->mSchool; info.text = "#{sSchool}: " + MyGUI::TextIterator::toTagsString(school->mName).asUTF8(); } - const std::string& cost = focus->getUserString("SpellCost"); + auto cost = focus->getUserString("SpellCost"); if (!cost.empty() && cost != "0") info.text += MWGui::ToolTips::getValueString(MWMechanics::calcSpellCost(*spell), "#{sCastCost}"); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 9bcfb3e158..1da19cf64e 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -2186,7 +2186,7 @@ namespace MWGui ResourceImageSetPointerFix* imgSetPointer = resource->castType(false); if (!imgSetPointer) continue; - std::string tex_name = imgSetPointer->getImageSet()->getIndexInfo(0, 0).texture; + auto tex_name = imgSetPointer->getImageSet()->getIndexInfo(0, 0).texture; osg::ref_ptr image = mResourceSystem->getImageManager()->getImage(tex_name); diff --git a/components/fontloader/fontloader.cpp b/components/fontloader/fontloader.cpp index 9434578220..da20413333 100644 --- a/components/fontloader/fontloader.cpp +++ b/components/fontloader/fontloader.cpp @@ -58,7 +58,7 @@ namespace MyGUI::xml::ElementPtr sizeProperty = getProperty(layersIterator.current(), "Size"); if (sizeProperty != nullptr) { - std::string sizeValue = sizeProperty->findAttribute("value"); + auto sizeValue = sizeProperty->findAttribute("value"); if (!sizeValue.empty()) return MyGUI::IntSize::parse(sizeValue); } @@ -614,7 +614,7 @@ namespace Gui MyGUI::xml::ElementEnumerator resourceNode = _node->getElementEnumerator(); while (resourceNode.next("Resource")) { - std::string type = resourceNode->findAttribute("type"); + auto type = resourceNode->findAttribute("type"); if (Misc::StringUtils::ciEqual(type, "ResourceLayout")) { diff --git a/components/myguiplatform/myguidatamanager.cpp b/components/myguiplatform/myguidatamanager.cpp index 8e34e0c2fe..76ad3ac66a 100644 --- a/components/myguiplatform/myguidatamanager.cpp +++ b/components/myguiplatform/myguidatamanager.cpp @@ -58,7 +58,7 @@ namespace osgMyGUI throw std::runtime_error("DataManager::getDataListNames is not implemented - VFS is used"); } - const std::string& DataManager::getDataPath(const std::string& name) const + std::string DataManager::getDataPath(const std::string& name) const { static std::string result; result.clear(); diff --git a/components/myguiplatform/myguidatamanager.hpp b/components/myguiplatform/myguidatamanager.hpp index 40dc6c3705..5b392177b7 100644 --- a/components/myguiplatform/myguidatamanager.hpp +++ b/components/myguiplatform/myguidatamanager.hpp @@ -45,7 +45,7 @@ namespace osgMyGUI @param _name Resource name. @return Return full path to specified data. */ - const std::string& getDataPath(const std::string& _name) const override; + std::string getDataPath(const std::string& _name) const override; private: std::filesystem::path mResourcePath; diff --git a/components/myguiplatform/myguiloglistener.hpp b/components/myguiplatform/myguiloglistener.hpp index 1af63a397f..3aeda9747b 100644 --- a/components/myguiplatform/myguiloglistener.hpp +++ b/components/myguiplatform/myguiloglistener.hpp @@ -31,7 +31,7 @@ namespace osgMyGUI void flush() override; void log(const std::string& _section, MyGUI::LogLevel _level, const struct tm* _time, - const std::string& _message, const char* _file, int _line) override; + const std::string& _message, const char* _file, int _line); private: std::ofstream mStream; diff --git a/components/myguiplatform/scalinglayer.cpp b/components/myguiplatform/scalinglayer.cpp index fbd2f594c7..c04134bfad 100644 --- a/components/myguiplatform/scalinglayer.cpp +++ b/components/myguiplatform/scalinglayer.cpp @@ -123,8 +123,8 @@ namespace osgMyGUI { if (info->getName() == "Property") { - const std::string& key = info->findAttribute("key"); - const std::string& value = info->findAttribute("value"); + auto key = info->findAttribute("key"); + auto value = info->findAttribute("value"); if (key == "Size") { diff --git a/components/widgets/box.cpp b/components/widgets/box.cpp index 642721b807..2d81152b3a 100644 --- a/components/widgets/box.cpp +++ b/components/widgets/box.cpp @@ -40,7 +40,7 @@ namespace Gui notifySizeChange(this); } - void AutoSizedTextBox::setPropertyOverride(const std::string& _key, const std::string& _value) + void AutoSizedTextBox::setPropertyOverride(std::string_view _key, const std::string_view _value) { if (_key == "ExpandDirection") { @@ -103,7 +103,7 @@ namespace Gui setEditStatic(true); } - void AutoSizedEditBox::setPropertyOverride(const std::string& _key, const std::string& _value) + void AutoSizedEditBox::setPropertyOverride(std::string_view _key, const std::string_view _value) { if (_key == "ExpandDirection") { @@ -136,7 +136,7 @@ namespace Gui notifySizeChange(this); } - void AutoSizedButton::setPropertyOverride(const std::string& _key, const std::string& _value) + void AutoSizedButton::setPropertyOverride(std::string_view _key, const std::string_view _value) { if (_key == "ExpandDirection") { @@ -147,6 +147,7 @@ namespace Gui Gui::Button::setPropertyOverride(_key, _value); } } + Box::Box() : mSpacing(4) , mPadding(0) @@ -159,7 +160,7 @@ namespace Gui align(); } - bool Box::_setPropertyImpl(const std::string& _key, const std::string& _value) + bool Box::_setPropertyImpl(std::string_view _key, const std::string_view _value) { if (_key == "Spacing") mSpacing = MyGUI::utility::parseValue(_value); @@ -260,7 +261,7 @@ namespace Gui } } - void HBox::setPropertyOverride(const std::string& _key, const std::string& _value) + void HBox::setPropertyOverride(std::string_view _key, const std::string_view _value) { if (!Box::_setPropertyImpl(_key, _value)) MyGUI::Widget::setPropertyOverride(_key, _value); @@ -415,7 +416,7 @@ namespace Gui } } - void VBox::setPropertyOverride(const std::string& _key, const std::string& _value) + void VBox::setPropertyOverride(std::string_view _key, const std::string_view _value) { if (!Box::_setPropertyImpl(_key, _value)) MyGUI::Widget::setPropertyOverride(_key, _value); diff --git a/components/widgets/box.hpp b/components/widgets/box.hpp index b5fcc8e9b6..699009c21f 100644 --- a/components/widgets/box.hpp +++ b/components/widgets/box.hpp @@ -53,7 +53,7 @@ namespace Gui void setCaption(const MyGUI::UString& _value) override; protected: - void setPropertyOverride(const std::string& _key, const std::string& _value) override; + void setPropertyOverride(std::string_view _key, std::string_view _value) override; std::string mFontSize; }; @@ -68,7 +68,7 @@ namespace Gui void initialiseOverride() override; protected: - void setPropertyOverride(const std::string& _key, const std::string& _value) override; + void setPropertyOverride(std::string_view _key, const std::string_view _value) override; int getWidth(); std::string mFontSize; bool mShrink = false; @@ -85,7 +85,7 @@ namespace Gui void setCaption(const MyGUI::UString& _value) override; protected: - void setPropertyOverride(const std::string& _key, const std::string& _value) override; + void setPropertyOverride(std::string_view _key, const std::string_view _value) override; std::string mFontSize; }; @@ -105,7 +105,7 @@ namespace Gui protected: virtual void align() = 0; - virtual bool _setPropertyImpl(const std::string& _key, const std::string& _value); + virtual bool _setPropertyImpl(std::string_view _key, std::string_view _value); int mSpacing; // how much space to put between elements @@ -137,7 +137,7 @@ namespace Gui void align() override; MyGUI::IntSize getRequestedSize() override; - void setPropertyOverride(const std::string& _key, const std::string& _value) override; + void setPropertyOverride(std::string_view _key, std::string_view _value) override; void onWidgetCreated(MyGUI::Widget* _widget) override; }; @@ -156,7 +156,7 @@ namespace Gui void align() override; MyGUI::IntSize getRequestedSize() override; - void setPropertyOverride(const std::string& _key, const std::string& _value) override; + void setPropertyOverride(std::string_view _key, std::string_view _value); void onWidgetCreated(MyGUI::Widget* _widget) override; }; diff --git a/components/widgets/imagebutton.cpp b/components/widgets/imagebutton.cpp index 0eb193aea3..79df471733 100644 --- a/components/widgets/imagebutton.cpp +++ b/components/widgets/imagebutton.cpp @@ -34,7 +34,7 @@ namespace Gui updateImage(); } - void ImageButton::setPropertyOverride(const std::string& _key, const std::string& _value) + void ImageButton::setPropertyOverride(std::string_view _key, const std::string_view _value) { if (_key == "ImageHighlighted") mImageHighlighted = _value; @@ -56,6 +56,7 @@ namespace Gui else ImageBox::setPropertyOverride(_key, _value); } + void ImageButton::onMouseSetFocus(Widget* _old) { mMouseFocus = true; diff --git a/components/widgets/imagebutton.hpp b/components/widgets/imagebutton.hpp index 923f168ba4..90b5e6339e 100644 --- a/components/widgets/imagebutton.hpp +++ b/components/widgets/imagebutton.hpp @@ -32,7 +32,7 @@ namespace Gui static bool sDefaultNeedKeyFocus; protected: - void setPropertyOverride(const std::string& _key, const std::string& _value) override; + void setPropertyOverride(std::string_view _key, std::string_view _value) override; void onMouseLostFocus(MyGUI::Widget* _new) override; void onMouseSetFocus(MyGUI::Widget* _old) override; void onMouseButtonPressed(int _left, int _top, MyGUI::MouseButton _id) override; diff --git a/components/widgets/list.cpp b/components/widgets/list.cpp index b4784299a5..7ccd3e6313 100644 --- a/components/widgets/list.cpp +++ b/components/widgets/list.cpp @@ -107,7 +107,7 @@ namespace Gui mScrollView->setViewOffset(MyGUI::IntPoint(0, -viewPosition)); } - void MWList::setPropertyOverride(const std::string& _key, const std::string& _value) + void MWList::setPropertyOverride(std::string_view _key, const std::string_view _value) { if (_key == "ListItemSkin") mListItemSkin = _value; diff --git a/components/widgets/list.hpp b/components/widgets/list.hpp index 88368e0794..3d5e320cf7 100644 --- a/components/widgets/list.hpp +++ b/components/widgets/list.hpp @@ -49,7 +49,7 @@ namespace Gui void scrollToTop(); - void setPropertyOverride(const std::string& _key, const std::string& _value) override; + void setPropertyOverride(std::string_view _key, std::string_view _value) override; protected: void initialiseOverride() override;