From 97009f1e23b948ebfaf59dfd53f579810234cfff Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Mon, 7 Aug 2023 17:40:38 +0200 Subject: [PATCH] Merge Assumeru/mystringvui --- apps/openmw/mwgui/resourceskin.cpp | 5 ++--- apps/openmw/mwgui/settingswindow.cpp | 6 +++--- apps/openmw/mwgui/windowmanagerimp.cpp | 6 +++--- apps/openmw/mwgui/windowmanagerimp.hpp | 6 +++--- components/fontloader/fontloader.cpp | 2 +- components/fontloader/fontloader.hpp | 2 +- components/myguiplatform/myguidatamanager.cpp | 11 +++-------- components/myguiplatform/myguiloglistener.cpp | 6 +++--- components/myguiplatform/myguiloglistener.hpp | 4 ++-- components/widgets/box.cpp | 12 ++++++------ components/widgets/box.hpp | 4 ++-- components/widgets/imagebutton.cpp | 2 +- components/widgets/list.cpp | 2 +- 13 files changed, 31 insertions(+), 37 deletions(-) diff --git a/apps/openmw/mwgui/resourceskin.cpp b/apps/openmw/mwgui/resourceskin.cpp index e527b15796..3d9f09952e 100644 --- a/apps/openmw/mwgui/resourceskin.cpp +++ b/apps/openmw/mwgui/resourceskin.cpp @@ -9,15 +9,14 @@ namespace MWGui void resizeSkin(MyGUI::xml::ElementPtr _node) { _node->setAttribute("type", "ResourceSkin"); - auto size = _node->findAttribute("size"); - if (!size.empty()) + if (!_node->findAttribute("size").empty()) return; auto textureName = _node->findAttribute("texture"); if (textureName.empty()) return; - MyGUI::ITexture* texture = MyGUI::RenderManager::getInstance().getTexture(std::string(textureName)); + MyGUI::ITexture* texture = MyGUI::RenderManager::getInstance().getTexture(std::string{ textureName }); if (!texture) return; diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index 3c15826eae..1a41f9bb55 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -168,7 +168,7 @@ namespace MWGui std::string_view type = getSettingType(current); if (type == checkButtonType) { - const std::string initialValue + std::string_view initialValue = Settings::get(getSettingCategory(current), getSettingName(current)) ? "#{Interface:On}" : "#{Interface:Off}"; current->castType()->setCaptionWithReplacing(initialValue); @@ -247,8 +247,8 @@ namespace MWGui { MyGUI::TextBox* textBox; getWidget(textBox, labelWidgetName); - auto labelCaption = scroller->getUserString("SettingLabelCaption"); - labelCaption = Misc::StringUtils::format(std::string(labelCaption), value); + std::string labelCaption{ scroller->getUserString("SettingLabelCaption") }; + labelCaption = Misc::StringUtils::format(labelCaption, value); textBox->setCaptionWithReplacing(labelCaption); } } diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 1da19cf64e..6f27a2cdbf 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -1227,7 +1227,7 @@ namespace MWGui MWBase::Environment::get().getStateManager()->requestQuit(); } - void WindowManager::onCursorChange(const std::string& name) + void WindowManager::onCursorChange(std::string_view name) { mCursorManager->cursorChanged(name); } @@ -2071,13 +2071,13 @@ namespace MWGui mWerewolfFader->notifyAlphaChanged(set ? 1.0f : 0.0f); } - void WindowManager::onClipboardChanged(const std::string& _type, const std::string& _data) + void WindowManager::onClipboardChanged(std::string_view _type, std::string_view _data) { if (_type == "Text") SDL_SetClipboardText(MyGUI::TextIterator::getOnlyText(MyGUI::UString(_data)).asUTF8().c_str()); } - void WindowManager::onClipboardRequested(const std::string& _type, std::string& _data) + void WindowManager::onClipboardRequested(std::string_view _type, std::string& _data) { if (_type != "Text") return; diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index fae3bb1ec9..444a6f6942 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -560,7 +560,7 @@ namespace MWGui */ void onRetrieveTag(const MyGUI::UString& _tag, MyGUI::UString& _result); - void onCursorChange(const std::string& name); + void onCursorChange(std::string_view name); void onKeyFocusChanged(MyGUI::Widget* widget); // Key pressed while playing a video @@ -568,8 +568,8 @@ namespace MWGui void sizeVideo(int screenWidth, int screenHeight); - void onClipboardChanged(const std::string& _type, const std::string& _data); - void onClipboardRequested(const std::string& _type, std::string& _data); + void onClipboardChanged(std::string_view _type, std::string_view _data); + void onClipboardRequested(std::string_view _type, std::string& _data); void createTextures(); void createCursors(); diff --git a/components/fontloader/fontloader.cpp b/components/fontloader/fontloader.cpp index da20413333..64aa32310b 100644 --- a/components/fontloader/fontloader.cpp +++ b/components/fontloader/fontloader.cpp @@ -608,7 +608,7 @@ namespace Gui MyGUI::ResourceManager::getInstance().addResource(bookFont); } - void FontLoader::overrideLineHeight(MyGUI::xml::ElementPtr _node, const std::string& _file, MyGUI::Version _version) + void FontLoader::overrideLineHeight(MyGUI::xml::ElementPtr _node, std::string_view _file, MyGUI::Version _version) { // We should adjust line height for MyGUI widgets depending on font size MyGUI::xml::ElementEnumerator resourceNode = _node->getElementEnumerator(); diff --git a/components/fontloader/fontloader.hpp b/components/fontloader/fontloader.hpp index 8c1312ff97..7e9220d58d 100644 --- a/components/fontloader/fontloader.hpp +++ b/components/fontloader/fontloader.hpp @@ -27,7 +27,7 @@ namespace Gui public: FontLoader(ToUTF8::FromType encoding, const VFS::Manager* vfs, float scalingFactor); - void overrideLineHeight(MyGUI::xml::ElementPtr _node, const std::string& _file, MyGUI::Version _version); + void overrideLineHeight(MyGUI::xml::ElementPtr _node, std::string_view _file, MyGUI::Version _version); static std::string_view getFontForFace(std::string_view face); diff --git a/components/myguiplatform/myguidatamanager.cpp b/components/myguiplatform/myguidatamanager.cpp index 76ad3ac66a..49dba3634b 100644 --- a/components/myguiplatform/myguidatamanager.cpp +++ b/components/myguiplatform/myguidatamanager.cpp @@ -60,20 +60,15 @@ namespace osgMyGUI std::string DataManager::getDataPath(const std::string& name) const { - static std::string result; - result.clear(); - if (name.empty()) { - result = Files::pathToUnicodeString(mResourcePath); - return result; + return Files::pathToUnicodeString(mResourcePath); } if (!isDataExist(name)) - return result; + return {}; - result = Files::pathToUnicodeString(mResourcePath / name); - return result; + return Files::pathToUnicodeString(mResourcePath / name); } } diff --git a/components/myguiplatform/myguiloglistener.cpp b/components/myguiplatform/myguiloglistener.cpp index 42dc9c0415..89de63c46f 100644 --- a/components/myguiplatform/myguiloglistener.cpp +++ b/components/myguiplatform/myguiloglistener.cpp @@ -25,12 +25,12 @@ namespace osgMyGUI mStream.flush(); } - void CustomLogListener::log(const std::string& _section, MyGUI::LogLevel _level, const struct tm* _time, - const std::string& _message, const char* _file, int _line) + void CustomLogListener::log(std::string_view _section, MyGUI::LogLevel _level, const struct tm* _time, + std::string_view _message, std::string_view _file, int _line) { if (mStream.is_open()) { - const char* separator = " | "; + std::string_view separator = " | "; mStream << std::setw(2) << std::setfill('0') << _time->tm_hour << ":" << std::setw(2) << std::setfill('0') << _time->tm_min << ":" << std::setw(2) << std::setfill('0') << _time->tm_sec << separator << _section << separator << _level.print() << separator << _message << separator << _file diff --git a/components/myguiplatform/myguiloglistener.hpp b/components/myguiplatform/myguiloglistener.hpp index 3aeda9747b..15cea0effd 100644 --- a/components/myguiplatform/myguiloglistener.hpp +++ b/components/myguiplatform/myguiloglistener.hpp @@ -30,8 +30,8 @@ namespace osgMyGUI void close() override; 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); + void log(std::string_view _section, MyGUI::LogLevel _level, const struct tm* _time, std::string_view _message, + std::string_view _file, int _line) override; private: std::ofstream mStream; diff --git a/components/widgets/box.cpp b/components/widgets/box.cpp index ce32939315..89f92b7bf1 100644 --- a/components/widgets/box.cpp +++ b/components/widgets/box.cpp @@ -40,7 +40,7 @@ namespace Gui notifySizeChange(this); } - void AutoSizedTextBox::setPropertyOverride(std::string_view _key, const std::string_view _value) + void AutoSizedTextBox::setPropertyOverride(std::string_view _key, std::string_view _value) { if (_key == "ExpandDirection") { @@ -103,7 +103,7 @@ namespace Gui setEditStatic(true); } - void AutoSizedEditBox::setPropertyOverride(std::string_view _key, const std::string_view _value) + void AutoSizedEditBox::setPropertyOverride(std::string_view _key, std::string_view _value) { if (_key == "ExpandDirection") { @@ -136,7 +136,7 @@ namespace Gui notifySizeChange(this); } - void AutoSizedButton::setPropertyOverride(std::string_view _key, const std::string_view _value) + void AutoSizedButton::setPropertyOverride(std::string_view _key, std::string_view _value) { if (_key == "ExpandDirection") { @@ -160,7 +160,7 @@ namespace Gui align(); } - bool Box::_setPropertyImpl(std::string_view _key, const std::string_view _value) + bool Box::_setPropertyImpl(std::string_view _key, std::string_view _value) { if (_key == "Spacing") mSpacing = MyGUI::utility::parseValue(_value); @@ -261,7 +261,7 @@ namespace Gui } } - void HBox::setPropertyOverride(std::string_view _key, const std::string_view _value) + void HBox::setPropertyOverride(std::string_view _key, std::string_view _value) { if (!Box::_setPropertyImpl(_key, _value)) MyGUI::Widget::setPropertyOverride(_key, _value); @@ -416,7 +416,7 @@ namespace Gui } } - void VBox::setPropertyOverride(std::string_view _key, const std::string_view _value) + void VBox::setPropertyOverride(std::string_view _key, 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 ac8e632767..b7543f1f05 100644 --- a/components/widgets/box.hpp +++ b/components/widgets/box.hpp @@ -51,7 +51,7 @@ namespace Gui void initialiseOverride() override; protected: - void setPropertyOverride(std::string_view _key, const std::string_view _value) override; + void setPropertyOverride(std::string_view _key, std::string_view _value) override; int getWidth(); std::string mFontSize; bool mShrink = false; @@ -68,7 +68,7 @@ namespace Gui void setCaption(const MyGUI::UString& _value) override; protected: - void setPropertyOverride(std::string_view _key, const std::string_view _value) override; + void setPropertyOverride(std::string_view _key, std::string_view _value) override; std::string mFontSize; }; diff --git a/components/widgets/imagebutton.cpp b/components/widgets/imagebutton.cpp index 79df471733..01fbd66cd5 100644 --- a/components/widgets/imagebutton.cpp +++ b/components/widgets/imagebutton.cpp @@ -34,7 +34,7 @@ namespace Gui updateImage(); } - void ImageButton::setPropertyOverride(std::string_view _key, const std::string_view _value) + void ImageButton::setPropertyOverride(std::string_view _key, std::string_view _value) { if (_key == "ImageHighlighted") mImageHighlighted = _value; diff --git a/components/widgets/list.cpp b/components/widgets/list.cpp index 7ccd3e6313..896057443c 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(std::string_view _key, const std::string_view _value) + void MWList::setPropertyOverride(std::string_view _key, std::string_view _value) { if (_key == "ListItemSkin") mListItemSkin = _value;