1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-05 15:55:45 +00:00

Test Lua widgets for text inputs correctly

This commit is contained in:
uramer 2024-01-10 22:05:33 +01:00
parent c2b8e318cf
commit 1afc7ecd58
6 changed files with 18 additions and 3 deletions

View File

@ -51,6 +51,7 @@
#include <components/l10n/manager.hpp>
#include <components/lua_ui/util.hpp>
#include <components/lua_ui/widget.hpp>
#include <components/settings/values.hpp>
@ -1676,7 +1677,10 @@ namespace MWGui
void WindowManager::onKeyFocusChanged(MyGUI::Widget* widget)
{
if (widget && widget->castType<MyGUI::EditBox>(false))
bool isEditBox = widget && widget->castType<MyGUI::EditBox>(false);
LuaUi::WidgetExtension* luaWidget = dynamic_cast<LuaUi::WidgetExtension*>(widget);
bool capturesInput = luaWidget ? luaWidget->isTextInput() : isEditBox;
if (widget && capturesInput)
SDL_StartTextInput();
else
SDL_StopTextInput();

View File

@ -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<PlayerScripts*>(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

View File

@ -179,6 +179,7 @@ namespace MWLua
LuaEvents mLuaEvents{ mGlobalScripts, mMenuScripts };
EngineEvents mEngineEvents{ mGlobalScripts };
std::vector<MWBase::LuaManager::InputEvent> mInputEvents;
std::vector<MWBase::LuaManager::InputEvent> mMenuInputEvents;
std::unique_ptr<LuaUtil::UserdataSerializer> mGlobalSerializer;
std::unique_ptr<LuaUtil::UserdataSerializer> mLocalSerializer;

View File

@ -51,7 +51,6 @@ namespace MWLua
EngineHandlerList mConsoleCommandHandlers{ "onConsoleCommand" };
EngineHandlerList mUiModeChanged{ "_onUiModeChanged" };
};
}
#endif // MWLUA_GLOBALSCRIPTS_H

View File

@ -11,6 +11,9 @@ namespace LuaUi
{
MYGUI_RTTI_DERIVED(LuaTextEdit)
public:
bool isTextInput() override { return mEditBox->getEditStatic(); }
protected:
void initialize() override;
void deinitialize() override;

View File

@ -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);