diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index c6b729332a..e463443b0c 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -51,6 +51,7 @@ #include #include +#include #include @@ -1676,7 +1677,10 @@ namespace MWGui void WindowManager::onKeyFocusChanged(MyGUI::Widget* widget) { - if (widget && widget->castType(false)) + bool isEditBox = widget && widget->castType(false); + LuaUi::WidgetExtension* luaWidget = dynamic_cast(widget); + bool capturesInput = luaWidget ? luaWidget->isTextInput() : isEditBox; + if (widget && capturesInput) SDL_StartTextInput(); else SDL_StopTextInput(); diff --git a/apps/openmw/mwlua/luamanagerimp.cpp b/apps/openmw/mwlua/luamanagerimp.cpp index e7f7fa9dde..df1e97b885 100644 --- a/apps/openmw/mwlua/luamanagerimp.cpp +++ b/apps/openmw/mwlua/luamanagerimp.cpp @@ -118,6 +118,7 @@ namespace MWLua = LuaUtil::LuaStorage::initPlayerPackage(mLua.sol(), &mGlobalStorage, &mPlayerStorage); mPlayerStorage.setActive(true); + mGlobalStorage.setActive(false); initConfiguration(); mInitialized = true; @@ -126,6 +127,8 @@ namespace MWLua void LuaManager::loadPermanentStorage(const std::filesystem::path& userConfigPath) { + mPlayerStorage.setActive(true); + mGlobalStorage.setActive(true); const auto globalPath = userConfigPath / "global_storage.bin"; const auto playerPath = userConfigPath / "player_storage.bin"; if (std::filesystem::exists(globalPath)) @@ -236,8 +239,9 @@ namespace MWLua = mPlayer.isEmpty() ? nullptr : dynamic_cast(mPlayer.getRefData().getLuaScripts()); MWBase::WindowManager* windowManager = MWBase::Environment::get().getWindowManager(); - for (const auto& event : mInputEvents) + for (const auto& event : mMenuInputEvents) mMenuScripts.processInputEvent(event); + mMenuInputEvents.clear(); if (playerScripts && !windowManager->containsMode(MWGui::GM_MainMenu)) { for (const auto& event : mInputEvents) @@ -300,6 +304,7 @@ namespace MWLua mLuaEvents.clear(); mEngineEvents.clear(); mInputEvents.clear(); + mMenuInputEvents.clear(); mObjectLists.clear(); mGlobalScripts.removeAllScripts(); mGlobalScriptsStarted = false; @@ -432,6 +437,7 @@ namespace MWLua { mInputEvents.push_back(event); } + mMenuInputEvents.push_back(event); } MWBase::LuaManager::ActorControls* LuaManager::getActorControls(const MWWorld::Ptr& ptr) const diff --git a/apps/openmw/mwlua/luamanagerimp.hpp b/apps/openmw/mwlua/luamanagerimp.hpp index 56a30f24e0..8ae83308d4 100644 --- a/apps/openmw/mwlua/luamanagerimp.hpp +++ b/apps/openmw/mwlua/luamanagerimp.hpp @@ -179,6 +179,7 @@ namespace MWLua LuaEvents mLuaEvents{ mGlobalScripts, mMenuScripts }; EngineEvents mEngineEvents{ mGlobalScripts }; std::vector mInputEvents; + std::vector mMenuInputEvents; std::unique_ptr mGlobalSerializer; std::unique_ptr mLocalSerializer; diff --git a/apps/openmw/mwlua/menuscripts.hpp b/apps/openmw/mwlua/menuscripts.hpp index a010317f47..befa76a3b2 100644 --- a/apps/openmw/mwlua/menuscripts.hpp +++ b/apps/openmw/mwlua/menuscripts.hpp @@ -51,7 +51,6 @@ namespace MWLua EngineHandlerList mConsoleCommandHandlers{ "onConsoleCommand" }; EngineHandlerList mUiModeChanged{ "_onUiModeChanged" }; }; - } #endif // MWLUA_GLOBALSCRIPTS_H diff --git a/components/lua_ui/textedit.hpp b/components/lua_ui/textedit.hpp index 3492a315bc..8f23b51746 100644 --- a/components/lua_ui/textedit.hpp +++ b/components/lua_ui/textedit.hpp @@ -11,6 +11,9 @@ namespace LuaUi { MYGUI_RTTI_DERIVED(LuaTextEdit) + public: + bool isTextInput() override { return mEditBox->getEditStatic(); } + protected: void initialize() override; void deinitialize() override; diff --git a/components/lua_ui/widget.hpp b/components/lua_ui/widget.hpp index c72b64ae3b..591c885ce9 100644 --- a/components/lua_ui/widget.hpp +++ b/components/lua_ui/widget.hpp @@ -73,6 +73,8 @@ namespace LuaUi virtual MyGUI::IntPoint calculatePosition(const MyGUI::IntSize& size); MyGUI::IntCoord calculateCoord(); + virtual bool isTextInput() { return false; } + protected: virtual void initialize(); void registerEvents(MyGUI::Widget* w);