From 43a931d3c43ab147d32bd4b453c656915edd10fe Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Mon, 7 Aug 2023 12:43:30 +0200 Subject: [PATCH 01/31] [#7528] Fix MyGUI 3.4.3 issues --- apps/openmw/mwgui/cursor.cpp | 4 ++-- apps/openmw/mwgui/resourceskin.cpp | 8 ++++---- apps/openmw/mwgui/settingswindow.cpp | 6 +++--- apps/openmw/mwgui/tooltips.cpp | 2 +- apps/openmw/mwgui/windowmanagerimp.cpp | 2 +- components/fontloader/fontloader.cpp | 4 ++-- components/myguiplatform/myguidatamanager.cpp | 2 +- components/myguiplatform/myguidatamanager.hpp | 2 +- components/myguiplatform/myguiloglistener.hpp | 2 +- components/myguiplatform/scalinglayer.cpp | 4 ++-- components/widgets/box.cpp | 13 +++++++------ components/widgets/box.hpp | 12 ++++++------ components/widgets/imagebutton.cpp | 3 ++- components/widgets/imagebutton.hpp | 2 +- components/widgets/list.cpp | 2 +- components/widgets/list.hpp | 2 +- 16 files changed, 36 insertions(+), 34 deletions(-) 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; From 8885519953a59e59e087b756784ff0af3d53d34a Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Mon, 7 Aug 2023 13:36:24 +0200 Subject: [PATCH 02/31] bump macos deps for arm64 --- CI/before_install.osx.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CI/before_install.osx.sh b/CI/before_install.osx.sh index 5b305d66b6..41e6707c45 100755 --- a/CI/before_install.osx.sh +++ b/CI/before_install.osx.sh @@ -34,7 +34,7 @@ qmake --version if [[ "${MACOS_AMD64}" ]]; then curl -fSL -R -J https://gitlab.com/OpenMW/openmw-deps/-/raw/main/macos/openmw-deps-20221113.zip -o ~/openmw-deps.zip else - curl -fSL -R -J https://gitlab.com/OpenMW/openmw-deps/-/raw/main/macos/openmw-deps-20230920_arm64.zip -o ~/openmw-deps.zip + curl -fSL -R -J https://gitlab.com/OpenMW/openmw-deps/-/raw/main/macos/openmw-deps-20231017_arm64.zip -o ~/openmw-deps.zip fi unzip -o ~/openmw-deps.zip -d /tmp > /dev/null From 2a8976d4e9072d7ba3ac99fe6a27b82c3cb898eb Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Mon, 7 Aug 2023 13:39:53 +0200 Subject: [PATCH 03/31] bump windows mygui to 3.4.3 --- CI/before_script.msvc.sh | 20 ++++++++++---------- CI/org.openmw.OpenMW.devel.yaml | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CI/before_script.msvc.sh b/CI/before_script.msvc.sh index abedc7f965..338ca1ee9e 100644 --- a/CI/before_script.msvc.sh +++ b/CI/before_script.msvc.sh @@ -597,14 +597,14 @@ if [ -z $SKIP_DOWNLOAD ]; then "ffmpeg-${FFMPEG_VER}-dev-win${BITS}.zip" # MyGUI - download "MyGUI 3.4.2" \ - "https://gitlab.com/OpenMW/openmw-deps/-/raw/main/windows/MyGUI-3.4.2-msvc${MYGUI_MSVC_YEAR}-win${BITS}.7z" \ - "MyGUI-3.4.2-msvc${MYGUI_MSVC_YEAR}-win${BITS}.7z" + download "MyGUI 3.4.3" \ + "https://gitlab.com/OpenMW/openmw-deps/-/raw/main/windows/MyGUI-3.4.3-msvc${MYGUI_MSVC_YEAR}-win${BITS}.7z" \ + "MyGUI-3.4.3-msvc${MYGUI_MSVC_YEAR}-win${BITS}.7z" if [ -n "$PDBS" ]; then download "MyGUI symbols" \ - "https://gitlab.com/OpenMW/openmw-deps/-/raw/main/windows/MyGUI-3.4.2-msvc${MYGUI_MSVC_YEAR}-win${BITS}-sym.7z" \ - "MyGUI-3.4.2-msvc${MYGUI_MSVC_YEAR}-win${BITS}-sym.7z" + "https://gitlab.com/OpenMW/openmw-deps/-/raw/main/windows/MyGUI-3.4.3-msvc${MYGUI_MSVC_YEAR}-win${BITS}-sym.7z" \ + "MyGUI-3.4.3-msvc${MYGUI_MSVC_YEAR}-win${BITS}-sym.7z" fi # OpenAL @@ -768,20 +768,20 @@ printf "FFmpeg ${FFMPEG_VER}... " } cd $DEPS echo -printf "MyGUI 3.4.2... " +printf "MyGUI 3.4.3... " { cd $DEPS_INSTALL if [ -d MyGUI ] && \ grep "MYGUI_VERSION_MAJOR 3" MyGUI/include/MYGUI/MyGUI_Prerequest.h > /dev/null && \ grep "MYGUI_VERSION_MINOR 4" MyGUI/include/MYGUI/MyGUI_Prerequest.h > /dev/null && \ - grep "MYGUI_VERSION_PATCH 2" MyGUI/include/MYGUI/MyGUI_Prerequest.h > /dev/null + grep "MYGUI_VERSION_PATCH 3" MyGUI/include/MYGUI/MyGUI_Prerequest.h > /dev/null then printf "Exists. " elif [ -z $SKIP_EXTRACT ]; then rm -rf MyGUI - eval 7z x -y "${DEPS}/MyGUI-3.4.2-msvc${MYGUI_MSVC_YEAR}-win${BITS}.7z" $STRIP - [ -n "$PDBS" ] && eval 7z x -y "${DEPS}/MyGUI-3.4.2-msvc${MYGUI_MSVC_YEAR}-win${BITS}-sym.7z" $STRIP - mv "MyGUI-3.4.2-msvc${MYGUI_MSVC_YEAR}-win${BITS}" MyGUI + eval 7z x -y "${DEPS}/MyGUI-3.4.3-msvc${MYGUI_MSVC_YEAR}-win${BITS}.7z" $STRIP + [ -n "$PDBS" ] && eval 7z x -y "${DEPS}/MyGUI-3.4.3-msvc${MYGUI_MSVC_YEAR}-win${BITS}-sym.7z" $STRIP + mv "MyGUI-3.4.3-msvc${MYGUI_MSVC_YEAR}-win${BITS}" MyGUI fi export MYGUI_HOME="$(real_pwd)/MyGUI" for CONFIGURATION in ${CONFIGURATIONS[@]}; do diff --git a/CI/org.openmw.OpenMW.devel.yaml b/CI/org.openmw.OpenMW.devel.yaml index 9e8fb9eeb9..9f4d921cf1 100644 --- a/CI/org.openmw.OpenMW.devel.yaml +++ b/CI/org.openmw.OpenMW.devel.yaml @@ -125,8 +125,8 @@ modules: - "-DMYGUI_BUILD_PLUGINS=0" sources: - type: archive - url: https://github.com/MyGUI/mygui/archive/refs/tags/MyGUI3.4.2.tar.gz - sha256: 1cc45fb96c9438e3476778449af0378443d84794a458978a29c75306e45dd45a + url: https://github.com/MyGUI/mygui/archive/refs/tags/MyGUI3.4.3.tar.gz + sha256: 33c91b531993047e77cace36d6fea73634b8c17bd0ed193d4cd12ac7c6328abd - name: libunshield buildsystem: cmake-ninja From 1df448f59b8b2b4bbe7eca77adc72b082bd80960 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Mon, 7 Aug 2023 13:44:41 +0200 Subject: [PATCH 04/31] remove hack from 3.4.2 --- components/myguiplatform/myguirendermanager.hpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/components/myguiplatform/myguirendermanager.hpp b/components/myguiplatform/myguirendermanager.hpp index 9a53b06c06..a940b31050 100644 --- a/components/myguiplatform/myguirendermanager.hpp +++ b/components/myguiplatform/myguirendermanager.hpp @@ -74,11 +74,7 @@ namespace osgMyGUI return static_cast(MyGUI::RenderManager::getInstancePtr()); } - bool checkTexture(MyGUI::ITexture* _texture) -#if MYGUI_DEBUG_MODE == 1 /* needed workaround for MyGUI 3.4.2 */ - override -#endif - ; + bool checkTexture(MyGUI::ITexture* _texture) override; /** @see RenderManager::getViewSize */ const MyGUI::IntSize& getViewSize() const override From e97b07b6a495aca1ee46492fdf42e1a227a41c30 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Mon, 7 Aug 2023 14:02:37 +0200 Subject: [PATCH 05/31] additional cleanup --- CMakeLists.txt | 2 +- apps/openmw/mwgui/formatting.cpp | 2 +- apps/openmw/mwgui/formatting.hpp | 2 +- apps/openmw/mwgui/spellview.cpp | 4 +-- apps/openmw/mwgui/tooltips.cpp | 6 ++-- components/lua_ui/widget.cpp | 4 --- components/lua_ui/window.cpp | 4 --- components/widgets/box.cpp | 6 ++-- components/widgets/box.hpp | 24 +++----------- components/widgets/fontwrapper.hpp | 40 ------------------------ components/widgets/numericeditbox.hpp | 3 +- components/widgets/sharedstatebutton.hpp | 4 +-- components/widgets/widgets.cpp | 3 -- extern/CMakeLists.txt | 4 +-- 14 files changed, 19 insertions(+), 89 deletions(-) delete mode 100644 components/widgets/fontwrapper.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ba0cd672cd..cad6290274 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -454,7 +454,7 @@ set(Boost_NO_WARN_NEW_VERSIONS ON) # ignore warnings about new releases of boos find_package(Boost 1.6.2 REQUIRED COMPONENTS ${BOOST_COMPONENTS} OPTIONAL_COMPONENTS ${BOOST_OPTIONAL_COMPONENTS}) if(OPENMW_USE_SYSTEM_MYGUI) - find_package(MyGUI 3.4.2 REQUIRED) + find_package(MyGUI 3.4.3 REQUIRED) endif() find_package(SDL2 2.0.9 REQUIRED) find_package(OpenAL REQUIRED) diff --git a/apps/openmw/mwgui/formatting.cpp b/apps/openmw/mwgui/formatting.cpp index 7f62bbf49c..c4f0f804a6 100644 --- a/apps/openmw/mwgui/formatting.cpp +++ b/apps/openmw/mwgui/formatting.cpp @@ -475,7 +475,7 @@ namespace MWGui::Formatting : GraphicElement(parent, pag, blockStyle) , mTextStyle(textStyle) { - Gui::EditBox* box = parent->createWidget("NormalText", + MyGUI::EditBox* box = parent->createWidget("NormalText", MyGUI::IntCoord(0, pag.getCurrentTop(), pag.getPageWidth(), 0), MyGUI::Align::Left | MyGUI::Align::Top, parent->getName() + MyGUI::utility::toString(parent->getChildCount())); box->setEditStatic(true); diff --git a/apps/openmw/mwgui/formatting.hpp b/apps/openmw/mwgui/formatting.hpp index 9a215b200b..f093a36dfe 100644 --- a/apps/openmw/mwgui/formatting.hpp +++ b/apps/openmw/mwgui/formatting.hpp @@ -161,7 +161,7 @@ namespace MWGui private: int currentFontHeight() const; TextStyle mTextStyle; - Gui::EditBox* mEditBox; + MyGUI::EditBox* mEditBox; }; class ImageElement : public GraphicElement diff --git a/apps/openmw/mwgui/spellview.cpp b/apps/openmw/mwgui/spellview.cpp index 678f6ffe1f..97de7dbc06 100644 --- a/apps/openmw/mwgui/spellview.cpp +++ b/apps/openmw/mwgui/spellview.cpp @@ -238,7 +238,7 @@ namespace MWGui mLines.emplace_back(separator, (MyGUI::Widget*)nullptr, NoSpellIndex); } - MyGUI::TextBox* groupWidget = mScrollView->createWidget("SandBrightText", + MyGUI::TextBox* groupWidget = mScrollView->createWidget("SandBrightText", MyGUI::IntCoord(0, 0, mScrollView->getWidth(), 24), MyGUI::Align::Left | MyGUI::Align::Top); groupWidget->setCaptionWithReplacing(label); groupWidget->setTextAlign(MyGUI::Align::Left); @@ -246,7 +246,7 @@ namespace MWGui if (!label2.empty()) { - MyGUI::TextBox* groupWidget2 = mScrollView->createWidget("SandBrightText", + MyGUI::TextBox* groupWidget2 = mScrollView->createWidget("SandBrightText", MyGUI::IntCoord(0, 0, mScrollView->getWidth(), 24), MyGUI::Align::Left | MyGUI::Align::Top); groupWidget2->setCaptionWithReplacing(label2); groupWidget2->setTextAlign(MyGUI::Align::Right); diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index 323579317a..929d78f3b1 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -443,7 +443,7 @@ namespace MWGui const std::string realImage = Misc::ResourceHelpers::correctIconPath(image, MWBase::Environment::get().getResourceSystem()->getVFS()); - Gui::EditBox* captionWidget = mDynamicToolTipBox->createWidget( + MyGUI::EditBox* captionWidget = mDynamicToolTipBox->createWidget( "NormalText", MyGUI::IntCoord(0, 0, 300, 300), MyGUI::Align::Left | MyGUI::Align::Top, "ToolTipCaption"); captionWidget->setEditStatic(true); captionWidget->setNeedKeyFocus(false); @@ -452,7 +452,7 @@ namespace MWGui int captionHeight = std::max(!caption.empty() ? captionSize.height : 0, imageSize); - Gui::EditBox* textWidget = mDynamicToolTipBox->createWidget("SandText", + MyGUI::EditBox* textWidget = mDynamicToolTipBox->createWidget("SandText", MyGUI::IntCoord(0, captionHeight + imageCaptionVPadding, 300, 300 - captionHeight - imageCaptionVPadding), MyGUI::Align::Stretch, "ToolTipText"); textWidget->setEditStatic(true); @@ -474,7 +474,7 @@ namespace MWGui MyGUI::ImageBox* icon = mDynamicToolTipBox->createWidget("MarkerButton", MyGUI::IntCoord(padding.left, totalSize.height + padding.top, 8, 8), MyGUI::Align::Default); icon->setColour(MyGUI::Colour(1.0f, 0.3f, 0.3f)); - Gui::EditBox* edit = mDynamicToolTipBox->createWidget("SandText", + MyGUI::EditBox* edit = mDynamicToolTipBox->createWidget("SandText", MyGUI::IntCoord(padding.left + 8 + 4, totalSize.height + padding.top, 300 - padding.left - 8 - 4, 300 - totalSize.height), MyGUI::Align::Default); diff --git a/components/lua_ui/widget.cpp b/components/lua_ui/widget.cpp index ff9f4d90a2..eacaec37bd 100644 --- a/components/lua_ui/widget.cpp +++ b/components/lua_ui/widget.cpp @@ -73,11 +73,7 @@ namespace LuaUi w->eventMouseButtonPressed.clear(); w->eventMouseButtonReleased.clear(); w->eventMouseMove.clear(); -#if MYGUI_VERSION <= MYGUI_DEFINE_VERSION(3, 4, 2) - w->eventMouseDrag.m_event.clear(); -#else w->eventMouseDrag.clear(); -#endif w->eventMouseSetFocus.clear(); w->eventMouseLostFocus.clear(); diff --git a/components/lua_ui/window.cpp b/components/lua_ui/window.cpp index 3ee7336a78..5da2ae4ca4 100644 --- a/components/lua_ui/window.cpp +++ b/components/lua_ui/window.cpp @@ -16,11 +16,7 @@ namespace LuaUi for (auto& [w, _] : mActionWidgets) { w->eventMouseButtonPressed.clear(); -#if MYGUI_VERSION <= MYGUI_DEFINE_VERSION(3, 4, 2) - w->eventMouseDrag.m_event.clear(); -#else w->eventMouseDrag.clear(); -#endif } mActionWidgets.clear(); diff --git a/components/widgets/box.cpp b/components/widgets/box.cpp index 2d81152b3a..ce32939315 100644 --- a/components/widgets/box.cpp +++ b/components/widgets/box.cpp @@ -48,7 +48,7 @@ namespace Gui } else { - Gui::TextBox::setPropertyOverride(_key, _value); + TextBox::setPropertyOverride(_key, _value); } } @@ -115,7 +115,7 @@ namespace Gui } else { - Gui::EditBox::setPropertyOverride(_key, _value); + EditBox::setPropertyOverride(_key, _value); } } @@ -144,7 +144,7 @@ namespace Gui } else { - Gui::Button::setPropertyOverride(_key, _value); + Button::setPropertyOverride(_key, _value); } } diff --git a/components/widgets/box.hpp b/components/widgets/box.hpp index 699009c21f..0029bc938a 100644 --- a/components/widgets/box.hpp +++ b/components/widgets/box.hpp @@ -7,25 +7,9 @@ #include #include -#include "fontwrapper.hpp" namespace Gui { - class Button : public FontWrapper - { - MYGUI_RTTI_DERIVED(Button) - }; - - class TextBox : public FontWrapper - { - MYGUI_RTTI_DERIVED(TextBox) - }; - - class EditBox : public FontWrapper - { - MYGUI_RTTI_DERIVED(EditBox) - }; - class AutoSizedWidget { public: @@ -44,7 +28,7 @@ namespace Gui MyGUI::Align mExpandDirection; }; - class AutoSizedTextBox : public AutoSizedWidget, public TextBox + class AutoSizedTextBox : public AutoSizedWidget, public MyGUI::TextBox { MYGUI_RTTI_DERIVED(AutoSizedTextBox) @@ -57,7 +41,7 @@ namespace Gui std::string mFontSize; }; - class AutoSizedEditBox : public AutoSizedWidget, public EditBox + class AutoSizedEditBox : public AutoSizedWidget, public MyGUI::EditBox { MYGUI_RTTI_DERIVED(AutoSizedEditBox) @@ -76,7 +60,7 @@ namespace Gui int mMaxWidth = 0; }; - class AutoSizedButton : public AutoSizedWidget, public Button + class AutoSizedButton : public AutoSizedWidget, public MyGUI::Button { MYGUI_RTTI_DERIVED(AutoSizedButton) @@ -156,7 +140,7 @@ namespace Gui void align() override; MyGUI::IntSize getRequestedSize() override; - void setPropertyOverride(std::string_view _key, std::string_view _value); + void setPropertyOverride(std::string_view _key, std::string_view _value) override; void onWidgetCreated(MyGUI::Widget* _widget) override; }; diff --git a/components/widgets/fontwrapper.hpp b/components/widgets/fontwrapper.hpp deleted file mode 100644 index f2c30376b9..0000000000 --- a/components/widgets/fontwrapper.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef OPENMW_WIDGETS_WRAPPER_H -#define OPENMW_WIDGETS_WRAPPER_H - -#include - -#include "components/settings/values.hpp" - -#include - -namespace Gui -{ - template - class FontWrapper : public T - { -#if MYGUI_VERSION <= MYGUI_DEFINE_VERSION(3, 4, 2) - public: - void setFontName(const std::string& name) override - { - T::setFontName(name); - T::setPropertyOverride("FontHeight", std::to_string(Settings::gui().mFontSize)); - } - - protected: - void setPropertyOverride(const std::string& _key, const std::string& _value) override - { - T::setPropertyOverride(_key, _value); - - // https://github.com/MyGUI/mygui/issues/113 - // There is a bug in MyGUI: when it initializes the FontName property, it reset the font height. - // We should restore it. - if (_key == "FontName") - { - T::setPropertyOverride("FontHeight", std::to_string(Settings::gui().mFontSize)); - } - } -#endif - }; -} - -#endif diff --git a/components/widgets/numericeditbox.hpp b/components/widgets/numericeditbox.hpp index ee8ef39a59..8e5de984c8 100644 --- a/components/widgets/numericeditbox.hpp +++ b/components/widgets/numericeditbox.hpp @@ -3,7 +3,6 @@ #include -#include "fontwrapper.hpp" namespace Gui { @@ -11,7 +10,7 @@ namespace Gui /** * @brief A variant of the EditBox that only allows integer inputs */ - class NumericEditBox final : public FontWrapper + class NumericEditBox final : public MyGUI::EditBox { MYGUI_RTTI_DERIVED(NumericEditBox) diff --git a/components/widgets/sharedstatebutton.hpp b/components/widgets/sharedstatebutton.hpp index 688d949f6e..99f597360c 100644 --- a/components/widgets/sharedstatebutton.hpp +++ b/components/widgets/sharedstatebutton.hpp @@ -3,8 +3,6 @@ #include -#include "fontwrapper.hpp" - namespace Gui { @@ -14,7 +12,7 @@ namespace Gui /// @brief A button that applies its own state changes to other widgets, to do this you define it as part of a /// ButtonGroup. - class SharedStateButton final : public FontWrapper + class SharedStateButton final : public MyGUI::Button { MYGUI_RTTI_DERIVED(SharedStateButton) diff --git a/components/widgets/widgets.cpp b/components/widgets/widgets.cpp index d27d7e5fc9..097f84c62f 100644 --- a/components/widgets/widgets.cpp +++ b/components/widgets/widgets.cpp @@ -18,12 +18,9 @@ namespace Gui MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); - MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); MyGUI::FactoryManager::getInstance().registerFactory("Widget"); diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index 9a536069e6..cf7a3bcf70 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -77,8 +77,8 @@ if(NOT OPENMW_USE_SYSTEM_MYGUI) include(FetchContent) FetchContent_Declare(mygui - URL https://github.com/MyGUI/mygui/archive/refs/tags/MyGUI3.4.2.zip - URL_HASH SHA512=d15de716102237ca55b952c2ab52f84b91766332a0357a50b17c20cf2f168666ddaab52d088d7bb8f713ad0fc27e19d74e6ae2673f310a8f60a3b5754f0a0ba7 + URL https://github.com/MyGUI/mygui/archive/refs/tags/MyGUI3.4.3.zip + URL_HASH SHA512=c804ef665e786076582367f171082cd2181fdbd214300ddcca4a4245c5a0f45e62e72778ee2d96ec46b393e22477dd729f9bb3006e6eecbf536674e34a057721 SOURCE_DIR fetched/mygui ) FetchContent_MakeAvailableExcludeFromAll(mygui) From 589a27d09cb51cfaa75292c18e93e4a060b2f3e5 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Mon, 7 Aug 2023 14:09:32 +0200 Subject: [PATCH 06/31] additional clean up for clang --- components/myguiplatform/myguirendermanager.hpp | 17 +++-------------- components/widgets/box.hpp | 1 - components/widgets/numericeditbox.hpp | 1 - 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/components/myguiplatform/myguirendermanager.hpp b/components/myguiplatform/myguirendermanager.hpp index a940b31050..7f1582203a 100644 --- a/components/myguiplatform/myguirendermanager.hpp +++ b/components/myguiplatform/myguirendermanager.hpp @@ -66,8 +66,6 @@ namespace osgMyGUI void enableShaders(Shader::ShaderManager& shaderManager); - void setScalingFactor(float factor); - static RenderManager& getInstance() { return *getInstancePtr(); } static RenderManager* getInstancePtr() { @@ -77,16 +75,10 @@ namespace osgMyGUI bool checkTexture(MyGUI::ITexture* _texture) override; /** @see RenderManager::getViewSize */ - const MyGUI::IntSize& getViewSize() const override - { - return mViewSize; - } + const MyGUI::IntSize& getViewSize() const override { return mViewSize; } /** @see RenderManager::getVertexFormat */ - MyGUI::VertexColourType getVertexFormat() const override - { - return mVertexFormat; - } + MyGUI::VertexColourType getVertexFormat() const override { return mVertexFormat; } /** @see RenderManager::isFormatSupported */ bool isFormatSupported(MyGUI::PixelFormat format, MyGUI::TextureUsage usage) override; @@ -119,10 +111,7 @@ namespace osgMyGUI void setInjectState(osg::StateSet* stateSet); /** @see IRenderTarget::getInfo */ - const MyGUI::RenderTargetInfo& getInfo() const override - { - return mInfo; - } + const MyGUI::RenderTargetInfo& getInfo() const override { return mInfo; } void setViewSize(int width, int height) override; diff --git a/components/widgets/box.hpp b/components/widgets/box.hpp index 0029bc938a..ac8e632767 100644 --- a/components/widgets/box.hpp +++ b/components/widgets/box.hpp @@ -7,7 +7,6 @@ #include #include - namespace Gui { class AutoSizedWidget diff --git a/components/widgets/numericeditbox.hpp b/components/widgets/numericeditbox.hpp index 8e5de984c8..39605b67d9 100644 --- a/components/widgets/numericeditbox.hpp +++ b/components/widgets/numericeditbox.hpp @@ -3,7 +3,6 @@ #include - namespace Gui { From 97009f1e23b948ebfaf59dfd53f579810234cfff Mon Sep 17 00:00:00 2001 From: Evil Eye Date: Mon, 7 Aug 2023 17:40:38 +0200 Subject: [PATCH 07/31] 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; From 6e530ebd656fb4d2407231853ccb866324093ce1 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Mon, 7 Aug 2023 21:47:45 +0200 Subject: [PATCH 08/31] make sure we are using our latest libs from daily or staging if doing a transition --- CI/install_debian_deps.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CI/install_debian_deps.sh b/CI/install_debian_deps.sh index 4417a04317..bd767bb173 100755 --- a/CI/install_debian_deps.sh +++ b/CI/install_debian_deps.sh @@ -122,4 +122,6 @@ mkdir -pv "$APT_CACHE_DIR" apt-get update -yqq apt-get -qq -o dir::cache::archives="$APT_CACHE_DIR" install -y --no-install-recommends software-properties-common gnupg >/dev/null add-apt-repository -y ppa:openmw/openmw +add-apt-repository -y ppa:openmw/openmw-daily +add-apt-repository -y ppa:openmw/staging apt-get -qq -o dir::cache::archives="$APT_CACHE_DIR" install -y --no-install-recommends "${deps[@]}" >/dev/null From edc3994384cb2a6dd926e7c30fd27d8dd5e81b85 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Tue, 17 Oct 2023 17:42:51 +0200 Subject: [PATCH 09/31] turn on MYGUI_DONT_USE_OBSOLETE --- extern/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index cf7a3bcf70..6f55e4f1c6 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -68,6 +68,7 @@ if(NOT OPENMW_USE_SYSTEM_MYGUI) set(MYGUI_BUILD_DEMOS OFF CACHE BOOL "") set(MYGUI_BUILD_PLUGINS OFF CACHE BOOL "") set(MYGUI_BUILD_TOOLS OFF CACHE BOOL "") + set(MYGUI_DONT_USE_OBSOLETE ON CACHE BOOL "") if(MYGUI_STATIC) set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE) From 64080b0c25b3b67dec81a596345e3867ce27cabe Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Thu, 19 Oct 2023 12:03:06 +0200 Subject: [PATCH 10/31] bump key for windows --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 27c57fff62..e7dabca6fb 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -590,7 +590,7 @@ macOS13_Xcode14_arm64: - Get-Volume - Copy-Item C:\ProgramData\chocolatey\logs\chocolatey.log cache: - key: ninja-v7 + key: ninja-v8 paths: - ccache - deps @@ -710,7 +710,7 @@ macOS13_Xcode14_arm64: - Get-Volume - Copy-Item C:\ProgramData\chocolatey\logs\chocolatey.log cache: - key: msbuild-v7 + key: msbuild-v8 paths: - ccache - deps From 0748e2094d4af3afa12f2f8ec756449bc3e22228 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Sun, 22 Oct 2023 10:12:31 +0300 Subject: [PATCH 11/31] Read NiParticleBomb --- components/nif/niffile.cpp | 1 + components/nif/particle.cpp | 22 ++++++++++++++++++---- components/nif/particle.hpp | 36 ++++++++++++++++++++++++++++++++---- components/nif/record.hpp | 1 + 4 files changed, 52 insertions(+), 8 deletions(-) diff --git a/components/nif/niffile.cpp b/components/nif/niffile.cpp index 35a9eee787..81a223e095 100644 --- a/components/nif/niffile.cpp +++ b/components/nif/niffile.cpp @@ -308,6 +308,7 @@ namespace Nif // Modifiers, 4.0.0.2 { "NiGravity", &construct }, + { "NiParticleBomb", &construct }, { "NiParticleColorModifier", &construct }, { "NiParticleGrowFade", &construct }, { "NiParticleRotation", &construct }, diff --git a/components/nif/particle.cpp b/components/nif/particle.cpp index d74473f468..0581c5a1d1 100644 --- a/components/nif/particle.cpp +++ b/components/nif/particle.cpp @@ -51,6 +51,20 @@ namespace Nif nif->read(mDirection); } + void NiParticleBomb::read(NIFStream* nif) + { + NiParticleModifier::read(nif); + + nif->read(mRange); + nif->read(mDuration); + nif->read(mStrength); + nif->read(mStartTime); + mDecayType = static_cast(nif->get()); + mSymmetryType = static_cast(nif->get()); + nif->read(mPosition); + nif->read(mDirection); + } + void NiParticleCollider::read(NIFStream* nif) { NiParticleModifier::read(nif); @@ -294,10 +308,10 @@ namespace Nif mBombObject.read(nif); nif->read(mBombAxis); - nif->read(mDecay); - nif->read(mDeltaV); - nif->read(mDecayType); - nif->read(mSymmetryType); + nif->read(mRange); + nif->read(mStrength); + mDecayType = static_cast(nif->get()); + mSymmetryType = static_cast(nif->get()); } void NiPSysBombModifier::post(Reader& nif) diff --git a/components/nif/particle.hpp b/components/nif/particle.hpp index 45b6296891..1bdbd3a94a 100644 --- a/components/nif/particle.hpp +++ b/components/nif/particle.hpp @@ -40,6 +40,20 @@ namespace Nif Point = 1, // Fixed origin }; + enum class DecayType : uint32_t + { + None = 0, // f(Distance) = 1.0 + Linear = 1, // f(Distance) = (Range - Distance) / Range + Exponential = 2, // f(Distance) = exp(-Distance / Range) + }; + + enum class SymmetryType : uint32_t + { + Spherical = 0, + Cylindrical = 1, // Perpendicular to direction axis + Planar = 2, // Parallel to direction axis + }; + struct NiGravity : NiParticleModifier { float mDecay{ 0.f }; @@ -51,6 +65,20 @@ namespace Nif void read(NIFStream* nif) override; }; + struct NiParticleBomb : NiParticleModifier + { + float mRange; + float mDuration; + float mStrength; + float mStartTime; + DecayType mDecayType; + SymmetryType mSymmetryType; + osg::Vec3f mPosition; + osg::Vec3f mDirection; + + void read(NIFStream* nif); + }; + struct NiParticleCollider : NiParticleModifier { float mBounceFactor; @@ -210,10 +238,10 @@ namespace Nif { NiAVObjectPtr mBombObject; osg::Vec3f mBombAxis; - float mDecay; - float mDeltaV; - uint32_t mDecayType; - uint32_t mSymmetryType; + float mRange; + float mStrength; + DecayType mDecayType; + SymmetryType mSymmetryType; void read(NIFStream* nif) override; void post(Reader& nif) override; diff --git a/components/nif/record.hpp b/components/nif/record.hpp index 79958b361d..d2a30b1317 100644 --- a/components/nif/record.hpp +++ b/components/nif/record.hpp @@ -206,6 +206,7 @@ namespace Nif RC_NiMultiTargetTransformController, RC_NiNode, RC_NiPalette, + RC_NiParticleBomb, RC_NiParticleColorModifier, RC_NiParticleGrowFade, RC_NiParticleRotation, From 1bd4860026539941957a5f68a8e68f7104058bb6 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Sun, 22 Oct 2023 11:25:39 +0200 Subject: [PATCH 12/31] no more obsolete mygui shizzle for macos --- CI/before_install.osx.sh | 2 +- apps/openmw/CMakeLists.txt | 2 ++ components/CMakeLists.txt | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CI/before_install.osx.sh b/CI/before_install.osx.sh index 41e6707c45..40210428d0 100755 --- a/CI/before_install.osx.sh +++ b/CI/before_install.osx.sh @@ -34,7 +34,7 @@ qmake --version if [[ "${MACOS_AMD64}" ]]; then curl -fSL -R -J https://gitlab.com/OpenMW/openmw-deps/-/raw/main/macos/openmw-deps-20221113.zip -o ~/openmw-deps.zip else - curl -fSL -R -J https://gitlab.com/OpenMW/openmw-deps/-/raw/main/macos/openmw-deps-20231017_arm64.zip -o ~/openmw-deps.zip + curl -fSL -R -J https://gitlab.com/OpenMW/openmw-deps/-/raw/main/macos/openmw-deps-20231022_arm64.zip -o ~/openmw-deps.zip fi unzip -o ~/openmw-deps.zip -d /tmp > /dev/null diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index 57e2b9d708..a05d20af73 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -183,6 +183,8 @@ if (MSVC) ) endif() +add_definitions(-DMYGUI_DONT_USE_OBSOLETE=ON) + if (ANDROID) target_link_libraries(openmw EGL android log z) endif (ANDROID) diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index b0169cc2c2..36bd74d217 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -287,6 +287,7 @@ add_component_dir (debug debugging debuglog gldebug debugdraw writeflags ) +add_definitions(-DMYGUI_DONT_USE_OBSOLETE=ON) IF(NOT WIN32 AND NOT APPLE) add_definitions(-DGLOBAL_DATA_PATH="${GLOBAL_DATA_PATH}") add_definitions(-DGLOBAL_CONFIG_PATH="${GLOBAL_CONFIG_PATH}") From 6081dcc43cd274f308658ff53a02cbd5bb212d23 Mon Sep 17 00:00:00 2001 From: uramer Date: Sat, 21 Oct 2023 21:40:02 +0200 Subject: [PATCH 13/31] Work around MyGUI bug in a less destructive way --- components/lua_ui/widget.cpp | 20 ++++++++++++-------- components/lua_ui/widget.hpp | 2 ++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/components/lua_ui/widget.cpp b/components/lua_ui/widget.cpp index ff9f4d90a2..767d425453 100644 --- a/components/lua_ui/widget.cpp +++ b/components/lua_ui/widget.cpp @@ -92,15 +92,21 @@ namespace LuaUi w->widget()->detachFromWidget(); } + void WidgetExtension::updateVisible() + { + // workaround for MyGUI bug + // parent visibility doesn't affect added children + MyGUI::Widget* widget = this->widget(); + MyGUI::Widget* parent = widget->getParent(); + bool inheritedVisible = widget->getVisible() && (parent == nullptr || parent->getInheritedVisible()); + widget->setVisible(inheritedVisible); + } + void WidgetExtension::attach(WidgetExtension* ext) { ext->mParent = this; ext->mTemplateChild = false; ext->widget()->attachToWidget(mSlot->widget()); - // workaround for MyGUI bug - // parent visibility doesn't affect added children - ext->widget()->setVisible(!ext->widget()->getVisible()); - ext->widget()->setVisible(!ext->widget()->getVisible()); } void WidgetExtension::attachTemplate(WidgetExtension* ext) @@ -108,10 +114,6 @@ namespace LuaUi ext->mParent = this; ext->mTemplateChild = true; ext->widget()->attachToWidget(widget()); - // workaround for MyGUI bug - // parent visibility doesn't affect added children - ext->widget()->setVisible(!ext->widget()->getVisible()); - ext->widget()->setVisible(!ext->widget()->getVisible()); } WidgetExtension* WidgetExtension::findDeep(std::string_view flagName) @@ -256,6 +258,8 @@ namespace LuaUi void WidgetExtension::updateCoord() { + updateVisible(); + MyGUI::IntCoord oldCoord = mWidget->getCoord(); MyGUI::IntCoord newCoord = calculateCoord(); diff --git a/components/lua_ui/widget.hpp b/components/lua_ui/widget.hpp index 3dbc14b6c3..81698b0479 100644 --- a/components/lua_ui/widget.hpp +++ b/components/lua_ui/widget.hpp @@ -173,6 +173,8 @@ namespace LuaUi void focusLoss(MyGUI::Widget*, MyGUI::Widget*); std::optional> mOnCoordChange; + + void updateVisible(); }; class LuaWidget : public MyGUI::Widget, public WidgetExtension From 76939aae45a72aba52bbcb2237f2c3d186a527c1 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Tue, 3 Oct 2023 01:27:14 +0300 Subject: [PATCH 14/31] Refurbish RigGeometry Restructure/untangle influence data Don't store the input influence data Overall cleanup --- components/sceneutil/riggeometry.cpp | 139 ++++++++------------------- components/sceneutil/riggeometry.hpp | 35 +++---- 2 files changed, 53 insertions(+), 121 deletions(-) diff --git a/components/sceneutil/riggeometry.cpp b/components/sceneutil/riggeometry.cpp index b940fb60ec..1572fab338 100644 --- a/components/sceneutil/riggeometry.cpp +++ b/components/sceneutil/riggeometry.cpp @@ -1,5 +1,7 @@ #include "riggeometry.hpp" +#include + #include #include @@ -10,39 +12,10 @@ #include "skeleton.hpp" #include "util.hpp" -namespace -{ - inline void accumulateMatrix( - const osg::Matrixf& invBindMatrix, const osg::Matrixf& matrix, const float weight, osg::Matrixf& result) - { - osg::Matrixf m = invBindMatrix * matrix; - float* ptr = m.ptr(); - float* ptrresult = result.ptr(); - ptrresult[0] += ptr[0] * weight; - ptrresult[1] += ptr[1] * weight; - ptrresult[2] += ptr[2] * weight; - - ptrresult[4] += ptr[4] * weight; - ptrresult[5] += ptr[5] * weight; - ptrresult[6] += ptr[6] * weight; - - ptrresult[8] += ptr[8] * weight; - ptrresult[9] += ptr[9] * weight; - ptrresult[10] += ptr[10] * weight; - - ptrresult[12] += ptr[12] * weight; - ptrresult[13] += ptr[13] * weight; - ptrresult[14] += ptr[14] * weight; - } -} - namespace SceneUtil { RigGeometry::RigGeometry() - : mSkeleton(nullptr) - , mLastFrameNumber(0) - , mBoundsFirstFrame(true) { setNumChildrenRequiringUpdateTraversal(1); // update done in accept(NodeVisitor&) @@ -50,12 +23,7 @@ namespace SceneUtil RigGeometry::RigGeometry(const RigGeometry& copy, const osg::CopyOp& copyop) : Drawable(copy, copyop) - , mSkeleton(nullptr) - , mInfluenceMap(copy.mInfluenceMap) - , mBone2VertexVector(copy.mBone2VertexVector) - , mBoneSphereVector(copy.mBoneSphereVector) - , mLastFrameNumber(0) - , mBoundsFirstFrame(true) + , mData(copy.mData) { setSourceGeometry(copy.mSourceGeometry); setNumChildrenRequiringUpdateTraversal(1); @@ -151,42 +119,18 @@ namespace SceneUtil return false; } - if (!mInfluenceMap) + if (!mData) { - Log(Debug::Error) << "Error: No InfluenceMap set on RigGeometry"; + Log(Debug::Error) << "Error: No influence data set on RigGeometry"; return false; } - mBoneNodesVector.clear(); - for (auto& bonePair : mBoneSphereVector->mData) + mNodes.clear(); + for (const BoneInfo& info : mData->mBones) { - const std::string& boneName = bonePair.first; - Bone* bone = mSkeleton->getBone(boneName); - if (!bone) - { - mBoneNodesVector.push_back(nullptr); - Log(Debug::Error) << "Error: RigGeometry did not find bone " << boneName; - continue; - } - - mBoneNodesVector.push_back(bone); - } - - for (auto& pair : mBone2VertexVector->mData) - { - for (auto& weight : pair.first) - { - const std::string& boneName = weight.first.first; - Bone* bone = mSkeleton->getBone(boneName); - if (!bone) - { - mBoneNodesVector.push_back(nullptr); - Log(Debug::Error) << "Error: RigGeometry did not find bone " << boneName; - continue; - } - - mBoneNodesVector.push_back(bone); - } + mNodes.push_back(mSkeleton->getBone(info.mName)); + if (!mNodes.back()) + Log(Debug::Error) << "Error: RigGeometry did not find bone " << info.mName; } return true; @@ -226,25 +170,28 @@ namespace SceneUtil osg::Vec3Array* normalDst = static_cast(geom.getNormalArray()); osg::Vec4Array* tangentDst = static_cast(geom.getTexCoordArray(7)); - int index = mBoneSphereVector->mData.size(); - for (auto& pair : mBone2VertexVector->mData) + for (const auto& [influences, vertices] : mData->mInfluences) { osg::Matrixf resultMat(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); - for (auto& weight : pair.first) + for (const auto& [index, weight] : influences) { - Bone* bone = mBoneNodesVector[index]; + const Bone* bone = mNodes[index]; if (bone == nullptr) continue; - accumulateMatrix(weight.first.second, bone->mMatrixInSkeletonSpace, weight.second, resultMat); - index++; + osg::Matrixf boneMat = mData->mBones[index].mInvBindMatrix * bone->mMatrixInSkeletonSpace; + float* boneMatPtr = boneMat.ptr(); + float* resultMatPtr = resultMat.ptr(); + for (int i = 0; i < 16; ++i, ++resultMatPtr, ++boneMatPtr) + if (i % 4 != 3) + *resultMatPtr += *boneMatPtr * weight; } if (mGeomToSkelMatrix) resultMat *= (*mGeomToSkelMatrix); - for (auto& vertex : pair.second) + for (unsigned short vertex : vertices) { (*positionDst)[vertex] = resultMat.preMult((*positionSrc)[vertex]); if (normalDst) @@ -291,15 +238,14 @@ namespace SceneUtil osg::BoundingBox box; - int index = 0; - for (auto& boundPair : mBoneSphereVector->mData) + size_t index = 0; + for (const BoneInfo& info : mData->mBones) { - Bone* bone = mBoneNodesVector[index]; + const Bone* bone = mNodes[index++]; if (bone == nullptr) continue; - index++; - osg::BoundingSpheref bs = boundPair.second; + osg::BoundingSpheref bs = info.mBoundSphere; if (mGeomToSkelMatrix) transformBoundingSphere(bone->mMatrixInSkeletonSpace * (*mGeomToSkelMatrix), bs); else @@ -357,35 +303,26 @@ namespace SceneUtil void RigGeometry::setInfluenceMap(osg::ref_ptr influenceMap) { - mInfluenceMap = influenceMap; + mData = new InfluenceData; + mData->mBones.reserve(influenceMap->mData.size()); - typedef std::map> Vertex2BoneMap; - Vertex2BoneMap vertex2BoneMap; - mBoneSphereVector = new BoneSphereVector; - mBoneSphereVector->mData.reserve(mInfluenceMap->mData.size()); - mBone2VertexVector = new Bone2VertexVector; - for (auto& influencePair : mInfluenceMap->mData) + std::unordered_map> vertexToInfluences; + size_t index = 0; + for (const auto& [boneName, bi] : influenceMap->mData) { - const std::string& boneName = influencePair.first; - const BoneInfluence& bi = influencePair.second; - mBoneSphereVector->mData.emplace_back(boneName, bi.mBoundSphere); + mData->mBones.push_back({ boneName, bi.mBoundSphere, bi.mInvBindMatrix }); - for (auto& weightPair : bi.mWeights) - { - std::vector& vec = vertex2BoneMap[weightPair.first]; - - vec.emplace_back(std::make_pair(boneName, bi.mInvBindMatrix), weightPair.second); - } + for (const auto& [vertex, weight] : bi.mWeights) + vertexToInfluences[vertex].emplace_back(index, weight); + index++; } - Bone2VertexMap bone2VertexMap; - for (auto& vertexPair : vertex2BoneMap) - { - bone2VertexMap[vertexPair.second].emplace_back(vertexPair.first); - } + std::map, VertexList> influencesToVertices; + for (const auto& [vertex, weights] : vertexToInfluences) + influencesToVertices[weights].emplace_back(vertex); - mBone2VertexVector->mData.reserve(bone2VertexMap.size()); - mBone2VertexVector->mData.assign(bone2VertexMap.begin(), bone2VertexMap.end()); + mData->mInfluences.reserve(influencesToVertices.size()); + mData->mInfluences.assign(influencesToVertices.begin(), influencesToVertices.end()); } void RigGeometry::accept(osg::NodeVisitor& nv) diff --git a/components/sceneutil/riggeometry.hpp b/components/sceneutil/riggeometry.hpp index 72e8fcd032..d1c077288d 100644 --- a/components/sceneutil/riggeometry.hpp +++ b/components/sceneutil/riggeometry.hpp @@ -36,6 +36,7 @@ namespace SceneUtil // static parts of the model. void compileGLObjects(osg::RenderInfo& renderInfo) const override {} + // TODO: Make InfluenceMap more similar to InfluenceData struct BoneInfluence { osg::Matrixf mInvBindMatrix; @@ -84,35 +85,29 @@ namespace SceneUtil osg::ref_ptr mSourceGeometry; osg::ref_ptr mSourceTangents; - Skeleton* mSkeleton; + Skeleton* mSkeleton{ nullptr }; osg::ref_ptr mGeomToSkelMatrix; - osg::ref_ptr mInfluenceMap; - - typedef std::pair BoneBindMatrixPair; - - typedef std::pair BoneWeight; - - typedef std::vector VertexList; - - typedef std::map, VertexList> Bone2VertexMap; - - struct Bone2VertexVector : public osg::Referenced + struct BoneInfo { - std::vector, VertexList>> mData; + std::string mName; + osg::BoundingSpheref mBoundSphere; + osg::Matrixf mInvBindMatrix; }; - osg::ref_ptr mBone2VertexVector; - struct BoneSphereVector : public osg::Referenced + using BoneWeight = std::pair; + using VertexList = std::vector; + struct InfluenceData : public osg::Referenced { - std::vector> mData; + std::vector mBones; + std::vector, VertexList>> mInfluences; }; - osg::ref_ptr mBoneSphereVector; - std::vector mBoneNodesVector; + osg::ref_ptr mData; + std::vector mNodes; - unsigned int mLastFrameNumber; - bool mBoundsFirstFrame; + unsigned int mLastFrameNumber{ 0 }; + bool mBoundsFirstFrame{ true }; bool initFromParentSkeleton(osg::NodeVisitor* nv); From 715efe6cb19e24ebb3d33d8b235748cc66bd3f14 Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Sun, 22 Oct 2023 11:03:13 +0300 Subject: [PATCH 15/31] Handle NiParticleBomb (feature #7634) --- CHANGELOG.md | 1 + components/nifosg/nifloader.cpp | 12 +++++ components/nifosg/particle.cpp | 78 ++++++++++++++++++++++++++++++ components/nifosg/particle.hpp | 25 ++++++++++ components/sceneutil/serialize.cpp | 2 +- 5 files changed, 117 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bbc5b5b1b..0f6ed2de6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,6 +107,7 @@ Feature #7546: Start the game on Fredas Feature #7568: Uninterruptable scripted music Feature #7618: Show the player character's health in the save details + Feature #7634: Support NiParticleBomb Task #5896: Do not use deprecated MyGUI properties Task #7113: Move from std::atoi to std::from_char Task #7117: Replace boost::scoped_array with std::vector diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index 3b8c47e071..a5f1032c69 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -1092,6 +1092,18 @@ namespace NifOsg const Nif::NiGravity* gr = static_cast(modifier.getPtr()); program->addOperator(new GravityAffector(gr)); } + else if (modifier->recType == Nif::RC_NiParticleBomb) + { + auto bomb = static_cast(modifier.getPtr()); + osg::ref_ptr bombProgram(new osgParticle::ModularProgram); + attachTo->addChild(bombProgram); + bombProgram->setParticleSystem(partsys); + bombProgram->setReferenceFrame(rf); + bombProgram->setStartTime(bomb->mStartTime); + bombProgram->setLifeTime(bomb->mDuration); + bombProgram->setEndless(false); + bombProgram->addOperator(new ParticleBomb(bomb)); + } else if (modifier->recType == Nif::RC_NiParticleColorModifier) { const Nif::NiParticleColorModifier* cl diff --git a/components/nifosg/particle.cpp b/components/nifosg/particle.cpp index 551cbfeae8..f15678c879 100644 --- a/components/nifosg/particle.cpp +++ b/components/nifosg/particle.cpp @@ -346,6 +346,84 @@ namespace NifOsg } } + ParticleBomb::ParticleBomb(const Nif::NiParticleBomb* bomb) + : mRange(bomb->mRange) + , mStrength(bomb->mStrength) + , mDecayType(bomb->mDecayType) + , mSymmetryType(bomb->mSymmetryType) + , mPosition(bomb->mPosition) + , mDirection(bomb->mDirection) + { + } + + ParticleBomb::ParticleBomb(const ParticleBomb& copy, const osg::CopyOp& copyop) + : osgParticle::Operator(copy, copyop) + { + mRange = copy.mRange; + mStrength = copy.mStrength; + mDecayType = copy.mDecayType; + mSymmetryType = copy.mSymmetryType; + mCachedWorldPosition = copy.mCachedWorldPosition; + mCachedWorldDirection = copy.mCachedWorldDirection; + } + + void ParticleBomb::beginOperate(osgParticle::Program* program) + { + bool absolute = (program->getReferenceFrame() == osgParticle::ParticleProcessor::ABSOLUTE_RF); + + mCachedWorldPosition = absolute ? program->transformLocalToWorld(mPosition) : mPosition; + + // We don't need the direction for Spherical bomb + if (mSymmetryType != Nif::SymmetryType::Spherical) + { + mCachedWorldDirection = absolute ? program->rotateLocalToWorld(mDirection) : mDirection; + mCachedWorldDirection.normalize(); + } + } + + void ParticleBomb::operate(osgParticle::Particle* particle, double dt) + { + float decay = 1.f; + osg::Vec3f explosionDir; + + osg::Vec3f particleDir = particle->getPosition() - mCachedWorldPosition; + float distance = particleDir.length(); + particleDir.normalize(); + + switch (mDecayType) + { + case Nif::DecayType::None: + break; + case Nif::DecayType::Linear: + decay = 1.f - distance / mRange; + break; + case Nif::DecayType::Exponential: + decay = std::exp(-distance / mRange); + break; + } + + if (decay <= 0.f) + return; + + switch (mSymmetryType) + { + case Nif::SymmetryType::Spherical: + explosionDir = particleDir; + break; + case Nif::SymmetryType::Cylindrical: + explosionDir = particleDir - mCachedWorldDirection * (mCachedWorldDirection * particleDir); + explosionDir.normalize(); + break; + case Nif::SymmetryType::Planar: + explosionDir = mCachedWorldDirection; + if (explosionDir * particleDir < 0) + explosionDir = -explosionDir; + break; + } + + particle->addVelocity(explosionDir * mStrength * decay * dt); + } + Emitter::Emitter() : osgParticle::Emitter() , mFlags(0) diff --git a/components/nifosg/particle.hpp b/components/nifosg/particle.hpp index 967531013a..272bc5baed 100644 --- a/components/nifosg/particle.hpp +++ b/components/nifosg/particle.hpp @@ -199,6 +199,31 @@ namespace NifOsg osg::Vec3f mCachedWorldDirection; }; + class ParticleBomb : public osgParticle::Operator + { + public: + ParticleBomb(const Nif::NiParticleBomb* bomb); + ParticleBomb() = default; + ParticleBomb(const ParticleBomb& copy, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY); + + ParticleBomb& operator=(const ParticleBomb&) = delete; + + META_Object(NifOsg, ParticleBomb) + + void operate(osgParticle::Particle* particle, double dt) override; + void beginOperate(osgParticle::Program*) override; + + private: + float mRange{ 0.f }; + float mStrength{ 0.f }; + Nif::DecayType mDecayType{ Nif::DecayType::None }; + Nif::SymmetryType mSymmetryType{ Nif::SymmetryType::Spherical }; + osg::Vec3f mPosition; + osg::Vec3f mDirection; + osg::Vec3f mCachedWorldPosition; + osg::Vec3f mCachedWorldDirection; + }; + // NodeVisitor to find a Group node with the given record index, stored in the node's user data container. // Alternatively, returns the node's parent Group if that node is not a Group (i.e. a leaf node). class FindGroupByRecIndex : public osg::NodeVisitor diff --git a/components/sceneutil/serialize.cpp b/components/sceneutil/serialize.cpp index 066f43d123..784dafafa5 100644 --- a/components/sceneutil/serialize.cpp +++ b/components/sceneutil/serialize.cpp @@ -167,7 +167,7 @@ namespace SceneUtil "SceneUtil::DisableLight", "SceneUtil::MWShadowTechnique", "SceneUtil::TextKeyMapHolder", "Shader::AddedState", "Shader::RemovedAlphaFunc", "NifOsg::FlipController", "NifOsg::KeyframeController", "NifOsg::Emitter", "NifOsg::ParticleColorAffector", - "NifOsg::ParticleSystem", "NifOsg::GravityAffector", "NifOsg::GrowFadeAffector", + "NifOsg::ParticleSystem", "NifOsg::GravityAffector", "NifOsg::ParticleBomb", "NifOsg::GrowFadeAffector", "NifOsg::InverseWorldMatrix", "NifOsg::StaticBoundingBoxCallback", "NifOsg::GeomMorpherController", "NifOsg::UpdateMorphGeometry", "NifOsg::UVController", "NifOsg::VisController", "osgMyGUI::Drawable", "osg::DrawCallback", "osg::UniformBufferObject", "osgOQ::ClearQueriesCallback", From dcf6a1fc3c6f986caf6a825912d0d52ce5606a01 Mon Sep 17 00:00:00 2001 From: Mads Buvik Sandvei Date: Sun, 8 Oct 2023 20:10:53 +0200 Subject: [PATCH 16/31] Refresh mMovementAnimationControlled when refreshing idle animations. --- apps/openmw/mwmechanics/character.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 92bc2d143e..3e242586a0 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -821,6 +821,9 @@ namespace MWMechanics mCurrentIdle = idleGroup; mAnimation->play(mCurrentIdle, priority, MWRender::Animation::BlendMask_All, false, 1.0f, "start", "stop", startPoint, numLoops, true); + + // May still be false after recent turn or jump animations + mMovementAnimationControlled = true; } void CharacterController::refreshCurrentAnims( From 7c280662684465fae747a2c74fc6ff19993ed040 Mon Sep 17 00:00:00 2001 From: Mads Buvik Sandvei Date: Sun, 8 Oct 2023 22:45:03 +0200 Subject: [PATCH 17/31] Changelog entry for 7611 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c01901ae1..3033eb83f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,7 @@ Bug #7603: Scripts menu size is not updated properly Bug #7604: Goblins Grunt becomes idle once injured Bug #7609: ForceGreeting should not open dialogue for werewolves + Bug #7611: Beast races' idle animations slide after turning or jumping in place Bug #7630: Charm can be cast on creatures Feature #3537: Shader-based water ripples Feature #5492: Let rain and snow collide with statics From 45a2b8042df8d3c2d1d269ca6601e00bb86c5409 Mon Sep 17 00:00:00 2001 From: Mads Buvik Sandvei Date: Wed, 11 Oct 2023 11:50:06 +0200 Subject: [PATCH 18/31] Derive the value of MovementAnimationControlled instead of storing it. --- apps/openmw/mwmechanics/character.cpp | 27 ++++++++++++++++----------- apps/openmw/mwmechanics/character.hpp | 3 ++- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 3e242586a0..99c82f2bf7 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -353,6 +353,7 @@ namespace MWMechanics { clearStateAnimation(mCurrentMovement); mMovementState = CharState_None; + mMovementAnimationHasMovement = false; } void CharacterController::resetCurrentIdleState() @@ -705,7 +706,7 @@ namespace MWMechanics if (!mCurrentMovement.empty() && movementAnimName == mCurrentMovement) mAnimation->getInfo(mCurrentMovement, &startpoint); - mMovementAnimationControlled = true; + mMovementAnimationHasMovement = true; clearStateAnimation(mCurrentMovement); mCurrentMovement = movementAnimName; @@ -743,7 +744,7 @@ namespace MWMechanics bool sneaking = mMovementState == CharState_SneakForward || mMovementState == CharState_SneakBack || mMovementState == CharState_SneakLeft || mMovementState == CharState_SneakRight; mMovementAnimSpeed = (sneaking ? 33.5452f : (isRunning() ? 222.857f : 154.064f)); - mMovementAnimationControlled = false; + mMovementAnimationHasMovement = false; } } @@ -821,9 +822,6 @@ namespace MWMechanics mCurrentIdle = idleGroup; mAnimation->play(mCurrentIdle, priority, MWRender::Animation::BlendMask_All, false, 1.0f, "start", "stop", startPoint, numLoops, true); - - // May still be false after recent turn or jump animations - mMovementAnimationControlled = true; } void CharacterController::refreshCurrentAnims( @@ -855,7 +853,6 @@ namespace MWMechanics resetCurrentHitState(); resetCurrentIdleState(); resetCurrentJumpState(); - mMovementAnimationControlled = true; mAnimation->play(mCurrentDeath, Priority_Death, MWRender::Animation::BlendMask_All, false, 1.0f, "start", "stop", startpoint, 0); @@ -2312,9 +2309,6 @@ namespace MWMechanics updateIdleStormState(inwater); } - if (mInJump) - mMovementAnimationControlled = false; - if (isTurning()) { // Adjust animation speed from 1.0 to 1.5 multiplier @@ -2350,7 +2344,7 @@ namespace MWMechanics } } - if (!mMovementAnimationControlled) + if (!isMovementAnimationControlled()) world->queueMovement(mPtr, vec); } @@ -2419,7 +2413,7 @@ namespace MWMechanics } // Update movement - if (mMovementAnimationControlled && mPtr.getClass().isActor()) + if (isMovementAnimationControlled() && mPtr.getClass().isActor()) world->queueMovement(mPtr, moved); mSkipAnim = false; @@ -2580,6 +2574,17 @@ namespace MWMechanics return mAnimation->isPlaying(groupName); } + bool CharacterController::isMovementAnimationControlled() const + { + bool movementAnimationControlled = true; + movementAnimationControlled = mIdleState != CharState_None; + if (mMovementState != CharState_None) + movementAnimationControlled = mMovementAnimationHasMovement; + if (mInJump) + movementAnimationControlled = false; + return movementAnimationControlled; + } + void CharacterController::clearAnimQueue(bool clearPersistAnims) { // Do not interrupt scripted animations, if we want to keep them diff --git a/apps/openmw/mwmechanics/character.hpp b/apps/openmw/mwmechanics/character.hpp index 5a676e3f6d..e4d2d32fb8 100644 --- a/apps/openmw/mwmechanics/character.hpp +++ b/apps/openmw/mwmechanics/character.hpp @@ -147,7 +147,7 @@ namespace MWMechanics std::string mCurrentMovement; float mMovementAnimSpeed{ 0.f }; bool mAdjustMovementAnimSpeed{ false }; - bool mMovementAnimationControlled{ true }; + bool mMovementAnimationHasMovement{ false }; CharacterState mDeathState{ CharState_None }; std::string mCurrentDeath; @@ -272,6 +272,7 @@ namespace MWMechanics bool playGroup(std::string_view groupname, int mode, int count, bool persist = false); void skipAnim(); bool isAnimPlaying(std::string_view groupName) const; + bool isMovementAnimationControlled() const; enum KillResult { From e893767ed055ced9dc20d5c3c25bdbb5b32b1fed Mon Sep 17 00:00:00 2001 From: Mads Buvik Sandvei Date: Sat, 14 Oct 2023 13:56:44 +0200 Subject: [PATCH 19/31] Redundant line --- apps/openmw/mwmechanics/character.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 99c82f2bf7..48abac8b06 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -2576,8 +2576,7 @@ namespace MWMechanics bool CharacterController::isMovementAnimationControlled() const { - bool movementAnimationControlled = true; - movementAnimationControlled = mIdleState != CharState_None; + bool movementAnimationControlled = mIdleState != CharState_None; if (mMovementState != CharState_None) movementAnimationControlled = mMovementAnimationHasMovement; if (mInJump) From 354b028072ff817ea1f7083126d8ba6a455c5bc9 Mon Sep 17 00:00:00 2001 From: Mads Buvik Sandvei Date: Sat, 14 Oct 2023 13:57:29 +0200 Subject: [PATCH 20/31] isMovementAnimationControlled should be private. --- apps/openmw/mwmechanics/character.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/character.hpp b/apps/openmw/mwmechanics/character.hpp index e4d2d32fb8..316a1cff0e 100644 --- a/apps/openmw/mwmechanics/character.hpp +++ b/apps/openmw/mwmechanics/character.hpp @@ -216,6 +216,7 @@ namespace MWMechanics static bool isRandomAttackAnimation(std::string_view group); bool isPersistentAnimPlaying() const; + bool isMovementAnimationControlled() const; void updateAnimQueue(); @@ -272,7 +273,6 @@ namespace MWMechanics bool playGroup(std::string_view groupname, int mode, int count, bool persist = false); void skipAnim(); bool isAnimPlaying(std::string_view groupName) const; - bool isMovementAnimationControlled() const; enum KillResult { From ee80f889b74e1fcad05fd62fcf95471e2f74e9a5 Mon Sep 17 00:00:00 2001 From: Abdu Sharif Date: Mon, 23 Oct 2023 12:35:57 +0000 Subject: [PATCH 21/31] Make Per-Pixel Lighting option description a bit more neutral --- docs/source/reference/modding/settings/shaders.rst | 4 +--- files/settings-default.cfg | 5 ++--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/docs/source/reference/modding/settings/shaders.rst b/docs/source/reference/modding/settings/shaders.rst index b21444b9ef..9ee1cbfaa5 100644 --- a/docs/source/reference/modding/settings/shaders.rst +++ b/docs/source/reference/modding/settings/shaders.rst @@ -23,9 +23,7 @@ force per pixel lighting Force the use of per pixel lighting. By default, only bump mapped objects use per-pixel lighting. Has no effect if the 'force shaders' option is false. -Enabling per-pixel lighting results in visual differences to the original MW engine. -It is not recommended to enable this option when using vanilla Morrowind files, -because certain lights in Morrowind rely on vertex lighting to look as intended. +Enabling per-pixel lighting results in visual differences to the original MW engine as certain lights in Morrowind rely on vertex lighting to look as intended. Note that groundcover shaders ignore this setting. clamp lighting diff --git a/files/settings-default.cfg b/files/settings-default.cfg index d8a101a7a5..ece773a677 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -407,9 +407,8 @@ force shaders = false # Force the use of per pixel lighting. By default, only bump mapped objects use per-pixel lighting. # Has no effect if the 'force shaders' option is false. -# Enabling per-pixel lighting can result in visual differences to the original MW engine. It is not -# recommended to enable this option when using vanilla Morrowind files, because certain lights in Morrowind -# rely on vertex lighting to look as intended. +# Enabling per-pixel lighting can result in visual differences to the original MW engine as +# certain lights in Morrowind rely on vertex lighting to look as intended. force per pixel lighting = false # Restrict the amount of lighting that an object can receive to a maximum of (1,1,1). From 606a0eea8fd8fc234a99eebff64d19f7b5e43d0b Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Mon, 23 Oct 2023 19:28:54 +0000 Subject: [PATCH 22/31] Get rid of obsolete comment The matrix in question was removed by !2682 --- files/shaders/compatibility/shadows_vertex.glsl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/files/shaders/compatibility/shadows_vertex.glsl b/files/shaders/compatibility/shadows_vertex.glsl index 08daf620bf..a99a4a10e6 100644 --- a/files/shaders/compatibility/shadows_vertex.glsl +++ b/files/shaders/compatibility/shadows_vertex.glsl @@ -19,7 +19,6 @@ void setupShadowCoords(vec4 viewPos, vec3 viewNormal) { #if SHADOWS - // This matrix has the opposite handedness to the others used here, so multiplication must have the vector to the left. Alternatively it could be transposed after construction, but that's extra work for the GPU just to make the code look a tiny bit cleaner. vec4 shadowOffset; @foreach shadow_texture_unit_index @shadow_texture_unit_list #if @perspectiveShadowMaps @@ -46,4 +45,4 @@ void setupShadowCoords(vec4 viewPos, vec3 viewNormal) #endif @endforeach #endif // SHADOWS -} \ No newline at end of file +} From 5dd1f0332fcdba651ff959d2df9a6019ee717065 Mon Sep 17 00:00:00 2001 From: Zackhasacat Date: Mon, 23 Oct 2023 23:44:54 -0500 Subject: [PATCH 23/31] Add notes about active effects --- files/lua_api/openmw/core.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/files/lua_api/openmw/core.lua b/files/lua_api/openmw/core.lua index 2c815d6dfc..9cfbb3228f 100644 --- a/files/lua_api/openmw/core.lua +++ b/files/lua_api/openmw/core.lua @@ -674,11 +674,13 @@ --- -- @type ActiveEffect +-- Magic effect that is currently active on an actor. +-- Note that when this effect expires or is removed, it will remain temporarily. Magnitude will be set to 0 for effects that expire. -- @field #string affectedSkill Optional skill ID -- @field #string affectedAttribute Optional attribute ID -- @field #string id Effect id string -- @field #string name Localized name of the effect --- @field #number magnitude +-- @field #number magnitude current magnitude of the effect. Will be set to 0 when effect is removed or expires. -- @field #number magnitudeBase -- @field #number magnitudeModifier From db42a91867e61e64bc4f58c3597ead99e4f1db9b Mon Sep 17 00:00:00 2001 From: Zackhasacat Date: Tue, 24 Oct 2023 09:23:25 +0000 Subject: [PATCH 24/31] Add global variable access to world.mwscript (#7597) --- apps/openmw/mwlua/mwscriptbindings.cpp | 51 ++++++++++++++++++++++++++ files/lua_api/openmw/world.lua | 6 +++ 2 files changed, 57 insertions(+) diff --git a/apps/openmw/mwlua/mwscriptbindings.cpp b/apps/openmw/mwlua/mwscriptbindings.cpp index dbe02a9fed..92957efb71 100644 --- a/apps/openmw/mwlua/mwscriptbindings.cpp +++ b/apps/openmw/mwlua/mwscriptbindings.cpp @@ -7,6 +7,7 @@ #include "../mwbase/scriptmanager.hpp" #include "../mwbase/world.hpp" #include "../mwscript/globalscripts.hpp" +#include "../mwworld/esmstore.hpp" #include "object.hpp" @@ -43,6 +44,10 @@ namespace sol struct is_automagical : std::false_type { }; + template <> + struct is_automagical : std::false_type + { + }; } namespace MWLua @@ -76,6 +81,7 @@ namespace MWLua // api["getGlobalScripts"] = [](std::string_view recordId) -> list of scripts // api["getLocalScripts"] = [](const GObject& obj) -> list of scripts + sol::state_view& lua = context.mLua->sol(); sol::usertype mwscript = context.mLua->sol().new_usertype("MWScript"); sol::usertype mwscriptVars = context.mLua->sol().new_usertype("MWScriptVariables"); @@ -108,6 +114,51 @@ namespace MWLua "No variable \"" + std::string(var) + "\" in mwscript " + s.mRef.mId.toDebugString()); }; + using GlobalStore = MWWorld::Store; + sol::usertype globalStoreT = lua.new_usertype("ESM3_GlobalStore"); + const GlobalStore* globalStore = &MWBase::Environment::get().getWorld()->getStore().get(); + globalStoreT[sol::meta_function::to_string] = [](const GlobalStore& store) { + return "ESM3_GlobalStore{" + std::to_string(store.getSize()) + " globals}"; + }; + globalStoreT[sol::meta_function::length] = [](const GlobalStore& store) { return store.getSize(); }; + globalStoreT[sol::meta_function::index] + = sol::overload([](const GlobalStore& store, std::string_view globalId) -> sol::optional { + auto g = store.search(ESM::RefId::deserializeText(globalId)); + if (g == nullptr) + return sol::nullopt; + char varType = MWBase::Environment::get().getWorld()->getGlobalVariableType(globalId); + if (varType == 's' || varType == 'l') + { + return static_cast(MWBase::Environment::get().getWorld()->getGlobalInt(globalId)); + } + else + { + return MWBase::Environment::get().getWorld()->getGlobalFloat(globalId); + } + }); + globalStoreT[sol::meta_function::new_index] + = sol::overload([](const GlobalStore& store, std::string_view globalId, float val) { + auto g = store.search(ESM::RefId::deserializeText(globalId)); + if (g == nullptr) + return; + char varType = MWBase::Environment::get().getWorld()->getGlobalVariableType(globalId); + if (varType == 's' || varType == 'l') + { + MWBase::Environment::get().getWorld()->setGlobalInt(globalId, static_cast(val)); + } + else + { + MWBase::Environment::get().getWorld()->setGlobalFloat(globalId, val); + } + }); + globalStoreT[sol::meta_function::pairs] = lua["ipairsForArray"].template get(); + globalStoreT[sol::meta_function::ipairs] = lua["ipairsForArray"].template get(); + api["getGlobalVariables"] = [globalStore](sol::optional player) { + if (player.has_value() && player->ptr() != MWBase::Environment::get().getWorld()->getPlayerPtr()) + throw std::runtime_error("First argument must either be a player or be missing"); + + return globalStore; + }; return LuaUtil::makeReadOnly(api); } diff --git a/files/lua_api/openmw/world.lua b/files/lua_api/openmw/world.lua index 90868387e5..13fa75e0ad 100644 --- a/files/lua_api/openmw/world.lua +++ b/files/lua_api/openmw/world.lua @@ -29,6 +29,12 @@ -- @param openmw.core#GameObject player (optional) Will be used in multiplayer mode to get the script if there is a separate instance for each player. Currently has no effect. -- @return #MWScript, #nil +--- +-- Returns mutable global variables. In multiplayer, these may be specific to the provided player. +-- @function [parent=#MWScriptFunctions] getGlobalVariables +-- @param openmw.core#GameObject player (optional) Will be used in multiplayer mode to get the globals if there is a separate instance for each player. Currently has no effect. +-- @return #list<#number> + --- -- Returns global mwscript with given recordId. Returns `nil` if the script doesn't exist or is not started. -- Currently there can be only one instance of each mwscript, but in multiplayer it will be possible to have a separate instance per player. From bc742e9d862b6074994b46e3204aac6925af44de Mon Sep 17 00:00:00 2001 From: Zackhasacat Date: Tue, 24 Oct 2023 08:36:23 -0500 Subject: [PATCH 25/31] Add build.os --- .readthedocs.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index e0b39ec495..544fe56904 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -8,3 +8,5 @@ python: install: - requirements: docs/requirements.txt +build: + os: ubuntu-22.04 \ No newline at end of file From b3eec4ae3266d53c8270b3d0f265921d8eeeaa0b Mon Sep 17 00:00:00 2001 From: Zackhasacat Date: Tue, 24 Oct 2023 08:39:16 -0500 Subject: [PATCH 26/31] Add tools --- .readthedocs.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 544fe56904..ad3758e26d 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -4,9 +4,10 @@ sphinx: configuration: docs/source/conf.py python: - version: 3.8 install: - requirements: docs/requirements.txt build: - os: ubuntu-22.04 \ No newline at end of file + os: ubuntu-22.04 + tools: + python: "3.8" \ No newline at end of file From 22142668c7192b0c1bf90293edfd279411ada0b6 Mon Sep 17 00:00:00 2001 From: Zackhasacat Date: Tue, 24 Oct 2023 08:46:27 -0500 Subject: [PATCH 27/31] Add Newline --- .readthedocs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index ad3758e26d..962b34f516 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -10,4 +10,4 @@ python: build: os: ubuntu-22.04 tools: - python: "3.8" \ No newline at end of file + python: "3.8" From 78e9a1753e449f5680db536bc32d9637a2e2fa0b Mon Sep 17 00:00:00 2001 From: Zackhasacat Date: Tue, 24 Oct 2023 13:55:50 +0000 Subject: [PATCH 28/31] Add lua binding for gameObject globalVariable --- apps/openmw/mwlua/objectbindings.cpp | 7 +++++++ files/lua_api/openmw/core.lua | 1 + 2 files changed, 8 insertions(+) diff --git a/apps/openmw/mwlua/objectbindings.cpp b/apps/openmw/mwlua/objectbindings.cpp index ef25dadfab..7db7877245 100644 --- a/apps/openmw/mwlua/objectbindings.cpp +++ b/apps/openmw/mwlua/objectbindings.cpp @@ -211,6 +211,13 @@ namespace MWLua objectT["isValid"] = [](const ObjectT& o) { return !o.ptrOrEmpty().isEmpty(); }; objectT["recordId"] = sol::readonly_property( [](const ObjectT& o) -> std::string { return o.ptr().getCellRef().getRefId().serializeText(); }); + objectT["globalVariable"] = sol::readonly_property([](const ObjectT& o) -> sol::optional { + std::string globalVariable = o.ptr().getCellRef().getGlobalVariable(); + if (globalVariable.empty()) + return sol::nullopt; + else + return ESM::RefId::stringRefId(globalVariable).serializeText(); + }); objectT["cell"] = sol::readonly_property([](const ObjectT& o) -> sol::optional> { const MWWorld::Ptr& ptr = o.ptr(); MWWorld::WorldModel* wm = MWBase::Environment::get().getWorldModel(); diff --git a/files/lua_api/openmw/core.lua b/files/lua_api/openmw/core.lua index 2c815d6dfc..acfa6a1fc2 100644 --- a/files/lua_api/openmw/core.lua +++ b/files/lua_api/openmw/core.lua @@ -167,6 +167,7 @@ -- @field #any type Type of the object (one of the tables from the package @{openmw.types#types}). -- @field #number count Count (>1 means a stack of objects). -- @field #string recordId Returns record ID of the object in lowercase. +-- @field #string globalVariable Global Variable associated with this object(read only). --- -- Does the object still exist and is available. From ac9cfc782a613663d6f8440a4a06bc3119fcabc9 Mon Sep 17 00:00:00 2001 From: Zackhasacat Date: Wed, 25 Oct 2023 12:34:56 +0000 Subject: [PATCH 29/31] Add functions to lua ui library to toggle HUD visibility, and check current status. --- apps/openmw/mwbase/windowmanager.hpp | 3 ++- apps/openmw/mwgui/windowmanagerimp.cpp | 4 ++-- apps/openmw/mwgui/windowmanagerimp.hpp | 3 ++- apps/openmw/mwinput/actionmanager.cpp | 2 +- apps/openmw/mwlua/uibindings.cpp | 5 ++++- apps/openmw/mwscript/guiextensions.cpp | 3 ++- files/data/scripts/omw/ui.lua | 15 ++++++++++++--- 7 files changed, 25 insertions(+), 10 deletions(-) diff --git a/apps/openmw/mwbase/windowmanager.hpp b/apps/openmw/mwbase/windowmanager.hpp index df6893c1ba..f225ebf24e 100644 --- a/apps/openmw/mwbase/windowmanager.hpp +++ b/apps/openmw/mwbase/windowmanager.hpp @@ -229,7 +229,8 @@ namespace MWBase virtual void unsetSelectedWeapon() = 0; virtual void showCrosshair(bool show) = 0; - virtual bool toggleHud() = 0; + virtual bool setHudVisibility(bool show) = 0; + virtual bool isHudVisible() const = 0; virtual void disallowMouse() = 0; virtual void allowMouse() = 0; diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 94bac9e10e..adb5b186ce 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -1605,9 +1605,9 @@ namespace MWGui mQuickKeysMenu->activateQuickKey(index); } - bool WindowManager::toggleHud() + bool WindowManager::setHudVisibility(bool show) { - mHudEnabled = !mHudEnabled; + mHudEnabled = show; updateVisible(); mMessageBoxManager->setVisible(mHudEnabled); return mHudEnabled; diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index fae3bb1ec9..5cd1aa23e0 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -247,7 +247,8 @@ namespace MWGui void showCrosshair(bool show) override; /// Turn visibility of HUD on or off - bool toggleHud() override; + bool setHudVisibility(bool show) override; + bool isHudVisible() const override { return mHudEnabled; } void disallowMouse() override; void allowMouse() override; diff --git a/apps/openmw/mwinput/actionmanager.cpp b/apps/openmw/mwinput/actionmanager.cpp index 3fac540f5e..eb82c160f9 100644 --- a/apps/openmw/mwinput/actionmanager.cpp +++ b/apps/openmw/mwinput/actionmanager.cpp @@ -118,7 +118,7 @@ namespace MWInput quickKey(10); break; case A_ToggleHUD: - windowManager->toggleHud(); + windowManager->setHudVisibility(!windowManager->isHudVisible()); break; case A_ToggleDebug: windowManager->toggleDebugWindow(); diff --git a/apps/openmw/mwlua/uibindings.cpp b/apps/openmw/mwlua/uibindings.cpp index 04914dd881..79f5fac9a1 100644 --- a/apps/openmw/mwlua/uibindings.cpp +++ b/apps/openmw/mwlua/uibindings.cpp @@ -111,6 +111,10 @@ namespace MWLua }; sol::table api = context.mLua->newTable(); + api["_setHudVisibility"] = [luaManager = context.mLuaManager](bool state) { + luaManager->addAction([state] { MWBase::Environment::get().getWindowManager()->setHudVisibility(state); }); + }; + api["_isHudVisible"] = []() -> bool { return MWBase::Environment::get().getWindowManager()->isHudVisible(); }; api["showMessage"] = [luaManager = context.mLuaManager](std::string_view message) { luaManager->addUIMessage(message); }; api["CONSOLE_COLOR"] = LuaUtil::makeStrictReadOnly(context.mLua->tableFromPairs({ @@ -296,7 +300,6 @@ namespace MWLua }; // TODO - // api["_showHUD"] = [](bool) {}; // api["_showMouseCursor"] = [](bool) {}; return LuaUtil::makeReadOnly(api); diff --git a/apps/openmw/mwscript/guiextensions.cpp b/apps/openmw/mwscript/guiextensions.cpp index c1590941e6..07855f18ef 100644 --- a/apps/openmw/mwscript/guiextensions.cpp +++ b/apps/openmw/mwscript/guiextensions.cpp @@ -192,7 +192,8 @@ namespace MWScript public: void execute(Interpreter::Runtime& runtime) override { - bool state = MWBase::Environment::get().getWindowManager()->toggleHud(); + bool state = MWBase::Environment::get().getWindowManager()->setHudVisibility( + !MWBase::Environment::get().getWindowManager()->isHudVisible()); runtime.getContext().report(state ? "GUI -> On" : "GUI -> Off"); if (!state) diff --git a/files/data/scripts/omw/ui.lua b/files/data/scripts/omw/ui.lua index 6fd80bf394..48412f6a0f 100644 --- a/files/data/scripts/omw/ui.lua +++ b/files/data/scripts/omw/ui.lua @@ -226,12 +226,21 @@ return { -- @function [parent=#UI] setPauseOnMode -- @param #string mode Mode to configure -- @param #boolean shouldPause - setPauseOnMode = function(mode, shouldPause) modePause[mode] = shouldPause end + setPauseOnMode = function(mode, shouldPause) modePause[mode] = shouldPause end, + + --- Set whether the UI should be visible. + -- @function [parent=#UI] setHudVisibility + -- @param #boolean showHud + setHudVisibility = function(showHud) ui._setHudVisibility(showHud) end, + + --- + -- Returns if the player HUD is visible or not + -- @function [parent=#UI] isHudVisible + -- @return #bool + isHudVisible = function() return ui._isHudVisible() end, -- TODO -- registerHudElement = function(name, showFn, hideFn) end, - -- showHud = function(bool) end, - -- isHudVisible = function() end, -- showHudElement = function(name, bool) end, -- hudElements, -- map from element name to its visibility }, From 10dbfe66b3421ff460908393a791ae237acf27d9 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Wed, 25 Oct 2023 17:55:24 +0100 Subject: [PATCH 30/31] Revert "Ditch python in Windows CI - we don't need it" This reverts commit 00c13b8dcd9026ee0200a07380acd5da7075313c. --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e7dabca6fb..44655466ea 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -531,6 +531,7 @@ macOS13_Xcode14_arm64: - choco install ccache -y - choco install vswhere -y - choco install ninja -y + - choco install python -y - choco install awscli -y - refreshenv - | @@ -652,6 +653,7 @@ macOS13_Xcode14_arm64: - choco install 7zip -y - choco install ccache -y - choco install vswhere -y + - choco install python -y - choco install awscli -y - refreshenv - | From 5cb5d2e166d830126808db8f380f0aa856074eac Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Wed, 25 Oct 2023 18:07:26 +0100 Subject: [PATCH 31/31] Add error handling to Store-Symbols.ps1 --- CI/Store-Symbols.ps1 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CI/Store-Symbols.ps1 b/CI/Store-Symbols.ps1 index 8634181432..11938fa4b4 100644 --- a/CI/Store-Symbols.ps1 +++ b/CI/Store-Symbols.ps1 @@ -1,3 +1,5 @@ +$ErrorActionPreference = "Stop" + if (-Not (Test-Path CMakeCache.txt)) { Write-Error "This script must be run from the build directory." @@ -8,6 +10,9 @@ if (-Not (Test-Path .cmake\api\v1\reply\index-*.json) -Or -Not ((Get-Content -Ra Write-Output "Running CMake query..." New-Item -Type File -Force .cmake\api\v1\query\codemodel-v2 cmake . + if ($LASTEXITCODE -ne 0) { + Write-Error "Command exited with code $LASTEXITCODE" + } Write-Output "Done." } @@ -45,13 +50,26 @@ finally if (-not (Test-Path symstore-venv)) { python -m venv symstore-venv + if ($LASTEXITCODE -ne 0) { + Write-Error "Command exited with code $LASTEXITCODE" + } } $symstoreVersion = "0.3.4" if (-not (Test-Path symstore-venv\Scripts\symstore.exe) -or -not ((symstore-venv\Scripts\pip show symstore | Select-String '(?<=Version: ).*').Matches.Value -eq $symstoreVersion)) { symstore-venv\Scripts\pip install symstore==$symstoreVersion + if ($LASTEXITCODE -ne 0) { + Write-Error "Command exited with code $LASTEXITCODE" + } } + $artifacts = $artifacts | Where-Object { Test-Path $_ } + Write-Output "Storing symbols..." + symstore-venv\Scripts\symstore --compress --skip-published .\SymStore @artifacts +if ($LASTEXITCODE -ne 0) { + Write-Error "Command exited with code $LASTEXITCODE" +} + Write-Output "Done."