mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 12:58:00 +03:00
Keep MENU-registered input actions between games
This commit is contained in:
parent
07cc2a72bb
commit
3a98b945a8
5 changed files with 72 additions and 38 deletions
|
@ -239,6 +239,29 @@ namespace LuaUtil
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Registry::clear(bool force)
|
||||
{
|
||||
std::vector<Info> infoToKeep;
|
||||
if (!force)
|
||||
{
|
||||
for (const Info& info : mInfo)
|
||||
if (info.mPersistent)
|
||||
infoToKeep.push_back(info);
|
||||
}
|
||||
mKeys.clear();
|
||||
mIds.clear();
|
||||
mInfo.clear();
|
||||
mHandlers.clear();
|
||||
mBindings.clear();
|
||||
mValues.clear();
|
||||
mBindingTree.clear();
|
||||
if (!force)
|
||||
{
|
||||
for (const Info& i : infoToKeep)
|
||||
insert(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace InputTrigger
|
||||
|
@ -292,5 +315,24 @@ namespace LuaUtil
|
|||
}),
|
||||
handlers.end());
|
||||
}
|
||||
|
||||
void Registry::clear(bool force)
|
||||
{
|
||||
std::vector<Info> infoToKeep;
|
||||
if (!force)
|
||||
{
|
||||
for (const Info& info : mInfo)
|
||||
if (info.mPersistent)
|
||||
infoToKeep.push_back(info);
|
||||
}
|
||||
mInfo.clear();
|
||||
mHandlers.clear();
|
||||
mIds.clear();
|
||||
if (!force)
|
||||
{
|
||||
for (const Info& i : infoToKeep)
|
||||
insert(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ namespace LuaUtil::InputAction
|
|||
std::string mName;
|
||||
std::string mDescription;
|
||||
sol::main_object mDefaultValue;
|
||||
bool mPersistent;
|
||||
};
|
||||
|
||||
class MultiTree
|
||||
|
@ -73,16 +74,7 @@ namespace LuaUtil::InputAction
|
|||
{
|
||||
mHandlers[safeIdByKey(key)].push_back(handler);
|
||||
}
|
||||
void clear()
|
||||
{
|
||||
mKeys.clear();
|
||||
mIds.clear();
|
||||
mInfo.clear();
|
||||
mHandlers.clear();
|
||||
mBindings.clear();
|
||||
mValues.clear();
|
||||
mBindingTree.clear();
|
||||
}
|
||||
void clear(bool force = false);
|
||||
|
||||
private:
|
||||
using Id = MultiTree::Node;
|
||||
|
@ -110,6 +102,7 @@ namespace LuaUtil::InputTrigger
|
|||
std::string mL10n;
|
||||
std::string mName;
|
||||
std::string mDescription;
|
||||
bool mPersistent;
|
||||
};
|
||||
|
||||
class Registry
|
||||
|
@ -130,12 +123,7 @@ namespace LuaUtil::InputTrigger
|
|||
void insert(const Info& info);
|
||||
void registerHandler(std::string_view key, const LuaUtil::Callback& callback);
|
||||
void activate(std::string_view key);
|
||||
void clear()
|
||||
{
|
||||
mInfo.clear();
|
||||
mHandlers.clear();
|
||||
mIds.clear();
|
||||
}
|
||||
void clear(bool force = false);
|
||||
|
||||
private:
|
||||
using Id = size_t;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue