mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-08 11:51:23 -04:00
Replace onUpdate with onFrame for menu scripts
This commit is contained in:
parent
2107bbc01d
commit
82a125fb6a
@ -243,7 +243,7 @@ namespace MWLua
|
|||||||
? 0.0
|
? 0.0
|
||||||
: MWBase::Environment::get().getFrameDuration();
|
: MWBase::Environment::get().getFrameDuration();
|
||||||
mInputActions.update(frameDuration);
|
mInputActions.update(frameDuration);
|
||||||
mMenuScripts.update(0);
|
mMenuScripts.onFrame(frameDuration);
|
||||||
if (playerScripts)
|
if (playerScripts)
|
||||||
playerScripts->onFrame(frameDuration);
|
playerScripts->onFrame(frameDuration);
|
||||||
mProcessingInputEvents = false;
|
mProcessingInputEvents = false;
|
||||||
|
@ -24,7 +24,7 @@ namespace MWLua
|
|||||||
: LuaUtil::ScriptsContainer(lua, "Menu")
|
: LuaUtil::ScriptsContainer(lua, "Menu")
|
||||||
, mInputProcessor(this)
|
, mInputProcessor(this)
|
||||||
{
|
{
|
||||||
registerEngineHandlers({ &mStateChanged, &mConsoleCommandHandlers, &mUiModeChanged });
|
registerEngineHandlers({ &mOnFrameHandlers, &mStateChanged, &mConsoleCommandHandlers, &mUiModeChanged });
|
||||||
}
|
}
|
||||||
|
|
||||||
void processInputEvent(const MWBase::LuaManager::InputEvent& event)
|
void processInputEvent(const MWBase::LuaManager::InputEvent& event)
|
||||||
@ -32,6 +32,8 @@ namespace MWLua
|
|||||||
mInputProcessor.processInputEvent(event);
|
mInputProcessor.processInputEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onFrame(float dt) { callEngineHandlers(mOnFrameHandlers, dt); }
|
||||||
|
|
||||||
void stateChanged() { callEngineHandlers(mStateChanged); }
|
void stateChanged() { callEngineHandlers(mStateChanged); }
|
||||||
|
|
||||||
bool consoleCommand(const std::string& consoleMode, const std::string& command)
|
bool consoleCommand(const std::string& consoleMode, const std::string& command)
|
||||||
@ -44,6 +46,7 @@ namespace MWLua
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
MWLua::InputProcessor mInputProcessor;
|
MWLua::InputProcessor mInputProcessor;
|
||||||
|
EngineHandlerList mOnFrameHandlers{ "onFrame" };
|
||||||
EngineHandlerList mStateChanged{ "onStateChanged" };
|
EngineHandlerList mStateChanged{ "onStateChanged" };
|
||||||
EngineHandlerList mConsoleCommandHandlers{ "onConsoleCommand" };
|
EngineHandlerList mConsoleCommandHandlers{ "onConsoleCommand" };
|
||||||
EngineHandlerList mUiModeChanged{ "_onUiModeChanged" };
|
EngineHandlerList mUiModeChanged{ "_onUiModeChanged" };
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "../mwbase/environment.hpp"
|
#include "../mwbase/environment.hpp"
|
||||||
#include "../mwbase/soundmanager.hpp"
|
#include "../mwbase/soundmanager.hpp"
|
||||||
|
#include "../mwbase/statemanager.hpp"
|
||||||
#include "../mwbase/windowmanager.hpp"
|
#include "../mwbase/windowmanager.hpp"
|
||||||
#include "../mwbase/world.hpp"
|
#include "../mwbase/world.hpp"
|
||||||
|
|
||||||
@ -263,8 +264,9 @@ namespace MWWorld
|
|||||||
|
|
||||||
void DateTimeManager::updateIsPaused()
|
void DateTimeManager::updateIsPaused()
|
||||||
{
|
{
|
||||||
|
auto stateManager = MWBase::Environment::get().getStateManager();
|
||||||
auto wm = MWBase::Environment::get().getWindowManager();
|
auto wm = MWBase::Environment::get().getWindowManager();
|
||||||
mPaused = !mPausedTags.empty() || wm->isConsoleMode() || wm->isPostProcessorHudVisible()
|
mPaused = !mPausedTags.empty() || wm->isConsoleMode() || wm->isPostProcessorHudVisible()
|
||||||
|| wm->isInteractiveMessageBoxActive();
|
|| wm->isInteractiveMessageBoxActive() || stateManager->getState() == MWBase::StateManager::State_NoGame;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,16 @@ Engine handlers reference
|
|||||||
|
|
||||||
Engine handler is a function defined by a script, that can be called by the engine.
|
Engine handler is a function defined by a script, that can be called by the engine.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
**Can be defined by any script**
|
**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 non-menu script**
|
||||||
|
|
||||||
.. list-table::
|
.. list-table::
|
||||||
:widths: 20 80
|
: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.
|
| 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
|
| If a script did not exist when a game was saved onLoad will not be
|
||||||
| called, but ``onInit`` will.
|
| 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**
|
**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::
|
.. list-table::
|
||||||
:widths: 20 80
|
:widths: 20 80
|
||||||
|
* - onFrame(dt)
|
||||||
* - onKeyPress(key)
|
- | 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.
|
- | `Key <openmw_input.html##(KeyboardEvent)>`_ is pressed.
|
||||||
| Usage example:
|
| Usage example:
|
||||||
| ``if key.symbol == 'z' and key.withShift then ...``
|
| ``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::
|
.. list-table::
|
||||||
:widths: 20 80
|
: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)
|
* - onKeyPress(key)
|
||||||
- | `Key <openmw_input.html##(KeyboardEvent)>`_ is pressed.
|
- | `Key <openmw_input.html##(KeyboardEvent)>`_ is pressed.
|
||||||
| Usage example:
|
| Usage example:
|
||||||
| ``if key.symbol == 'z' and key.withShift then ...``
|
| ``if key.symbol == 'z' and key.withShift then ...``
|
||||||
* - onQuestUpdate(questId, stage)
|
* - onQuestUpdate(questId, stage)
|
||||||
- | Called when a quest is updated.
|
- | Called when a quest is updated.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
**Only for menu scripts**
|
**Only for menu scripts**
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user