mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-11 06:06:42 +00:00
Rename mPermanentCallbacks -> mMenuScriptsCallbacks in LuaUtil::Storage
This commit is contained in:
parent
dafe858cb4
commit
f5325e11e3
2 changed files with 14 additions and 11 deletions
|
@ -49,14 +49,14 @@ namespace LuaUtil
|
||||||
return !valid;
|
return !valid;
|
||||||
}),
|
}),
|
||||||
mCallbacks.end());
|
mCallbacks.end());
|
||||||
mPermanentCallbacks.erase(std::remove_if(mPermanentCallbacks.begin(), mPermanentCallbacks.end(),
|
mMenuScriptsCallbacks.erase(std::remove_if(mMenuScriptsCallbacks.begin(), mMenuScriptsCallbacks.end(),
|
||||||
[&](const Callback& callback) {
|
[&](const Callback& callback) {
|
||||||
bool valid = callback.isValid();
|
bool valid = callback.isValid();
|
||||||
if (valid)
|
if (valid)
|
||||||
callback.tryCall(mSectionName, changedKey);
|
callback.tryCall(mSectionName, changedKey);
|
||||||
return !valid;
|
return !valid;
|
||||||
}),
|
}),
|
||||||
mPermanentCallbacks.end());
|
mMenuScriptsCallbacks.end());
|
||||||
mStorage->mRunningCallbacks.erase(this);
|
mStorage->mRunningCallbacks.erase(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ namespace LuaUtil
|
||||||
sview["asTable"] = [](const SectionView& section) { return section.mSection->asTable(); };
|
sview["asTable"] = [](const SectionView& section) { return section.mSection->asTable(); };
|
||||||
sview["subscribe"] = [](const SectionView& section, const sol::table& callback) {
|
sview["subscribe"] = [](const SectionView& section, const sol::table& callback) {
|
||||||
std::vector<Callback>& callbacks
|
std::vector<Callback>& callbacks
|
||||||
= section.mForMenuScripts ? section.mSection->mPermanentCallbacks : section.mSection->mCallbacks;
|
= section.mForMenuScripts ? section.mSection->mMenuScriptsCallbacks : section.mSection->mCallbacks;
|
||||||
if (!callbacks.empty() && callbacks.size() == callbacks.capacity())
|
if (!callbacks.empty() && callbacks.size() == callbacks.capacity())
|
||||||
{
|
{
|
||||||
callbacks.erase(
|
callbacks.erase(
|
||||||
|
@ -191,9 +191,11 @@ namespace LuaUtil
|
||||||
while (it != mData.end())
|
while (it != mData.end())
|
||||||
{
|
{
|
||||||
it->second->mCallbacks.clear();
|
it->second->mCallbacks.clear();
|
||||||
|
// Note that we don't clear menu callbacks for permanent sections
|
||||||
|
// because starting/loading a game doesn't reset menu scripts.
|
||||||
if (!it->second->mPermanent)
|
if (!it->second->mPermanent)
|
||||||
{
|
{
|
||||||
it->second->mPermanentCallbacks.clear();
|
it->second->mMenuScriptsCallbacks.clear();
|
||||||
it->second->mValues.clear();
|
it->second->mValues.clear();
|
||||||
it = mData.erase(it);
|
it = mData.erase(it);
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,8 @@ namespace LuaUtil
|
||||||
std::string mSectionName;
|
std::string mSectionName;
|
||||||
std::map<std::string, Value, std::less<>> mValues;
|
std::map<std::string, Value, std::less<>> mValues;
|
||||||
std::vector<Callback> mCallbacks;
|
std::vector<Callback> mCallbacks;
|
||||||
std::vector<Callback> mPermanentCallbacks;
|
std::vector<Callback> mMenuScriptsCallbacks; // menu callbacks are in a separate vector because we don't
|
||||||
|
// remove them in clear()
|
||||||
bool mPermanent = true;
|
bool mPermanent = true;
|
||||||
static Value sEmpty;
|
static Value sEmpty;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue