mirror of
https://github.com/OpenMW/openmw.git
synced 2025-12-24 09:53:08 +00:00
Merge branch 'menu_fixes' into 'master'
Follow up fixes for Lua Menu MR !3464 See merge request OpenMW/openmw!3834
This commit is contained in:
commit
a5d88d489b
7 changed files with 26 additions and 8 deletions
|
|
@ -56,6 +56,7 @@ namespace MWBase
|
||||||
virtual void newGameStarted() = 0;
|
virtual void newGameStarted() = 0;
|
||||||
virtual void gameLoaded() = 0;
|
virtual void gameLoaded() = 0;
|
||||||
virtual void gameEnded() = 0;
|
virtual void gameEnded() = 0;
|
||||||
|
virtual void noGame() = 0;
|
||||||
virtual void objectAddedToScene(const MWWorld::Ptr& ptr) = 0;
|
virtual void objectAddedToScene(const MWWorld::Ptr& ptr) = 0;
|
||||||
virtual void objectRemovedFromScene(const MWWorld::Ptr& ptr) = 0;
|
virtual void objectRemovedFromScene(const MWWorld::Ptr& ptr) = 0;
|
||||||
virtual void objectTeleported(const MWWorld::Ptr& ptr) = 0;
|
virtual void objectTeleported(const MWWorld::Ptr& ptr) = 0;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "corebindings.hpp"
|
#include "corebindings.hpp"
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
#include <components/esm3/loadfact.hpp>
|
#include <components/esm3/loadfact.hpp>
|
||||||
|
|
@ -133,7 +134,14 @@ namespace MWLua
|
||||||
sol::table api(context.mLua->sol(), sol::create);
|
sol::table api(context.mLua->sol(), sol::create);
|
||||||
for (auto& [k, v] : LuaUtil::getMutableFromReadOnly(initCorePackage(context)))
|
for (auto& [k, v] : LuaUtil::getMutableFromReadOnly(initCorePackage(context)))
|
||||||
api[k] = v;
|
api[k] = v;
|
||||||
api["sendGlobalEvent"] = sol::nil;
|
api["sendGlobalEvent"] = [context](std::string eventName, const sol::object& eventData) {
|
||||||
|
if (MWBase::Environment::get().getStateManager()->getState() == MWBase::StateManager::State_NoGame)
|
||||||
|
{
|
||||||
|
throw std::logic_error("Can't send global events when no game is loaded");
|
||||||
|
}
|
||||||
|
context.mLuaEvents->addGlobalEvent(
|
||||||
|
{ std::move(eventName), LuaUtil::serialize(eventData, context.mSerializer) });
|
||||||
|
};
|
||||||
api["sound"] = sol::nil;
|
api["sound"] = sol::nil;
|
||||||
api["vfx"] = sol::nil;
|
api["vfx"] = sol::nil;
|
||||||
return LuaUtil::makeReadOnly(api);
|
return LuaUtil::makeReadOnly(api);
|
||||||
|
|
|
||||||
|
|
@ -379,6 +379,12 @@ namespace MWLua
|
||||||
mMenuScripts.stateChanged();
|
mMenuScripts.stateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LuaManager::noGame()
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
mMenuScripts.stateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void LuaManager::uiModeChanged(const MWWorld::Ptr& arg)
|
void LuaManager::uiModeChanged(const MWWorld::Ptr& arg)
|
||||||
{
|
{
|
||||||
if (mPlayer.isEmpty())
|
if (mPlayer.isEmpty())
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ namespace MWLua
|
||||||
void newGameStarted() override;
|
void newGameStarted() override;
|
||||||
void gameLoaded() override;
|
void gameLoaded() override;
|
||||||
void gameEnded() override;
|
void gameEnded() override;
|
||||||
|
void noGame() override;
|
||||||
void objectAddedToScene(const MWWorld::Ptr& ptr) override;
|
void objectAddedToScene(const MWWorld::Ptr& ptr) override;
|
||||||
void objectRemovedFromScene(const MWWorld::Ptr& ptr) override;
|
void objectRemovedFromScene(const MWWorld::Ptr& ptr) override;
|
||||||
void inputEvent(const InputEvent& event) override;
|
void inputEvent(const InputEvent& event) override;
|
||||||
|
|
|
||||||
|
|
@ -62,16 +62,19 @@ void MWState::StateManager::cleanup(bool force)
|
||||||
MWBase::Environment::get().getInputManager()->clear();
|
MWBase::Environment::get().getInputManager()->clear();
|
||||||
MWBase::Environment::get().getMechanicsManager()->clear();
|
MWBase::Environment::get().getMechanicsManager()->clear();
|
||||||
|
|
||||||
mState = State_NoGame;
|
|
||||||
mCharacterManager.setCurrentCharacter(nullptr);
|
mCharacterManager.setCurrentCharacter(nullptr);
|
||||||
mTimePlayed = 0;
|
mTimePlayed = 0;
|
||||||
mLastSavegame.clear();
|
mLastSavegame.clear();
|
||||||
|
|
||||||
MWMechanics::CreatureStats::cleanup();
|
MWMechanics::CreatureStats::cleanup();
|
||||||
|
|
||||||
endGame();
|
mState = State_NoGame;
|
||||||
|
MWBase::Environment::get().getLuaManager()->noGame();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TODO: do we need this cleanup?
|
||||||
|
MWBase::Environment::get().getLuaManager()->clear();
|
||||||
}
|
}
|
||||||
MWBase::Environment::get().getLuaManager()->clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<int, int> MWState::StateManager::buildContentFileIndexMap(const ESM::ESMReader& reader) const
|
std::map<int, int> MWState::StateManager::buildContentFileIndexMap(const ESM::ESMReader& reader) const
|
||||||
|
|
|
||||||
|
|
@ -421,7 +421,6 @@ local menuGroups = {}
|
||||||
local menuPages = {}
|
local menuPages = {}
|
||||||
|
|
||||||
local function resetPlayerGroups()
|
local function resetPlayerGroups()
|
||||||
print('MENU reset player groups')
|
|
||||||
local playerGroupsSection = storage.playerSection(common.groupSectionKey)
|
local playerGroupsSection = storage.playerSection(common.groupSectionKey)
|
||||||
for pageKey, page in pairs(groups) do
|
for pageKey, page in pairs(groups) do
|
||||||
for groupKey, group in pairs(page) do
|
for groupKey, group in pairs(page) do
|
||||||
|
|
@ -503,7 +502,7 @@ return {
|
||||||
if menu.getState() == menu.STATE.Running then
|
if menu.getState() == menu.STATE.Running then
|
||||||
updatePlayerGroups()
|
updatePlayerGroups()
|
||||||
updateGlobalGroups()
|
updateGlobalGroups()
|
||||||
else
|
elseif menu.getState() == menu.STATE.NoGame then
|
||||||
resetPlayerGroups()
|
resetPlayerGroups()
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
-- @function [parent=#core] quit
|
-- @function [parent=#core] quit
|
||||||
|
|
||||||
---
|
---
|
||||||
-- Send an event to global scripts.
|
-- Send an event to global scripts. Note: in menu scripts, errors if the game is not running (check @{openmw.menu#menu.getState})
|
||||||
-- @function [parent=#core] sendGlobalEvent
|
-- @function [parent=#core] sendGlobalEvent
|
||||||
-- @param #string eventName
|
-- @param #string eventName
|
||||||
-- @param eventData
|
-- @param eventData
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue