Replace onUpdate with onFrame for menu scripts

ini_importer_tests
uramer 4 months ago
parent 2107bbc01d
commit 82a125fb6a

@ -243,7 +243,7 @@ namespace MWLua
? 0.0
: MWBase::Environment::get().getFrameDuration();
mInputActions.update(frameDuration);
mMenuScripts.update(0);
mMenuScripts.onFrame(frameDuration);
if (playerScripts)
playerScripts->onFrame(frameDuration);
mProcessingInputEvents = false;

@ -24,7 +24,7 @@ namespace MWLua
: LuaUtil::ScriptsContainer(lua, "Menu")
, mInputProcessor(this)
{
registerEngineHandlers({ &mStateChanged, &mConsoleCommandHandlers, &mUiModeChanged });
registerEngineHandlers({ &mOnFrameHandlers, &mStateChanged, &mConsoleCommandHandlers, &mUiModeChanged });
}
void processInputEvent(const MWBase::LuaManager::InputEvent& event)
@ -32,6 +32,8 @@ namespace MWLua
mInputProcessor.processInputEvent(event);
}
void onFrame(float dt) { callEngineHandlers(mOnFrameHandlers, dt); }
void stateChanged() { callEngineHandlers(mStateChanged); }
bool consoleCommand(const std::string& consoleMode, const std::string& command)
@ -44,6 +46,7 @@ namespace MWLua
private:
MWLua::InputProcessor mInputProcessor;
EngineHandlerList mOnFrameHandlers{ "onFrame" };
EngineHandlerList mStateChanged{ "onStateChanged" };
EngineHandlerList mConsoleCommandHandlers{ "onConsoleCommand" };
EngineHandlerList mUiModeChanged{ "_onUiModeChanged" };

@ -4,6 +4,7 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/statemanager.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp"
@ -263,8 +264,9 @@ namespace MWWorld
void DateTimeManager::updateIsPaused()
{
auto stateManager = MWBase::Environment::get().getStateManager();
auto wm = MWBase::Environment::get().getWindowManager();
mPaused = !mPausedTags.empty() || wm->isConsoleMode() || wm->isPostProcessorHudVisible()
|| wm->isInteractiveMessageBoxActive();
|| wm->isInteractiveMessageBoxActive() || stateManager->getState() == MWBase::StateManager::State_NoGame;
}
}

@ -5,9 +5,15 @@ Engine handlers reference
Engine handler is a function defined by a script, that can be called by the engine.
**Can be defined by any script**
.. list-table::
:widths: 20 80
* - onInterfaceOverride(base)
- | Called if the current script has an interface and overrides an interface
| (``base``) of another script.
**Can be defined by any script**
**Can be defined by any non-menu script**
.. list-table::
:widths: 20 80
@ -29,9 +35,6 @@ Engine handler is a function defined by a script, that can be called by the engi
| Note that ``onLoad`` means loading a script rather than loading a game.
| If a script did not exist when a game was saved onLoad will not be
| called, but ``onInit`` will.
* - onInterfaceOverride(base)
- | Called if the current script has an interface and overrides an interface
| (``base``) of another script.
**Only for global scripts**
@ -84,8 +87,12 @@ Engine handler is a function defined by a script, that can be called by the engi
.. list-table::
:widths: 20 80
* - onKeyPress(key)
* - onFrame(dt)
- | Called every frame (even if the game is paused) right after
| processing user input. Use it only for latency-critical stuff
| and for UI that should work on pause.
| `dt` is simulation time delta (0 when on pause).
* - onKeyPress(key)
- | `Key <openmw_input.html##(KeyboardEvent)>`_ is pressed.
| Usage example:
| ``if key.symbol == 'z' and key.withShift then ...``
@ -124,19 +131,12 @@ Engine handler is a function defined by a script, that can be called by the engi
.. list-table::
:widths: 20 80
* - onFrame(dt)
- | Called every frame (even if the game is paused) right after
| processing user input. Use it only for latency-critical stuff
| and for UI that should work on pause.
| `dt` is simulation time delta (0 when on pause).
* - onKeyPress(key)
- | `Key <openmw_input.html##(KeyboardEvent)>`_ is pressed.
| Usage example:
| ``if key.symbol == 'z' and key.withShift then ...``
* - onQuestUpdate(questId, stage)
- | Called when a quest is updated.
**Only for menu scripts**

Loading…
Cancel
Save