mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-05 15:55:45 +00:00
Use page terminology for script settings
This commit is contained in:
parent
e78b8402fa
commit
a005f25c4b
@ -741,12 +741,12 @@ namespace MWGui
|
||||
auto flags = std::regex_constants::icase;
|
||||
std::regex filterRegex(filter, flags);
|
||||
|
||||
auto scriptSettings = LuaUi::scriptSettings();
|
||||
auto scriptSettings = LuaUi::scriptSettingsPages();
|
||||
for (size_t i = 0; i < scriptSettings.size(); ++i)
|
||||
{
|
||||
LuaUi::ScriptSettings script = scriptSettings[i];
|
||||
if (std::regex_match(script.mName, filterRegex) || std::regex_match(script.mSearchHints, filterRegex))
|
||||
mScriptList->addItem(script.mName, i);
|
||||
LuaUi::ScriptSettingsPage page = scriptSettings[i];
|
||||
if (std::regex_match(page.mName, filterRegex) || std::regex_match(page.mSearchHints, filterRegex))
|
||||
mScriptList->addItem(page.mName, i);
|
||||
}
|
||||
|
||||
// Hide script settings tab when the game world isn't loaded and scripts couldn't add their settings
|
||||
|
@ -239,18 +239,18 @@ namespace MWLua
|
||||
typeTable.set(it.second, it.first);
|
||||
api["TYPE"] = LuaUtil::makeReadOnly(typeTable);
|
||||
|
||||
api["registerSettings"] = [](sol::table options)
|
||||
api["registerSettingsPage"] = [](sol::table options)
|
||||
{
|
||||
LuaUi::ScriptSettings script;
|
||||
script.mName = options.get_or("name", std::string());
|
||||
if (script.mName.empty())
|
||||
throw std::logic_error("No name provided for script settings");
|
||||
script.mSearchHints = options.get_or("searchHints", std::string());
|
||||
LuaUi::ScriptSettingsPage page;
|
||||
page.mName = options.get_or("name", std::string());
|
||||
if (page.mName.empty())
|
||||
throw std::logic_error("No name provided for the settings page");
|
||||
page.mSearchHints = options.get_or("searchHints", std::string());
|
||||
auto element = options.get_or<std::shared_ptr<LuaUi::Element>>("element", nullptr);
|
||||
if (!element)
|
||||
throw std::logic_error("No UI element provided for script settings");
|
||||
script.mElement = element.get();
|
||||
LuaUi::registerSettings(script);
|
||||
throw std::logic_error("No UI element provided for the settings page");
|
||||
page.mElement = element.get();
|
||||
LuaUi::registerSettingsPage(page);
|
||||
};
|
||||
|
||||
return LuaUtil::makeReadOnly(api);
|
||||
|
@ -8,27 +8,27 @@ namespace LuaUi
|
||||
{
|
||||
namespace
|
||||
{
|
||||
std::vector<ScriptSettings> allSettings;
|
||||
std::vector<ScriptSettingsPage> allPages;
|
||||
}
|
||||
|
||||
const std::vector<ScriptSettings>& scriptSettings()
|
||||
const std::vector<ScriptSettingsPage>& scriptSettingsPages()
|
||||
{
|
||||
return allSettings;
|
||||
return allPages;
|
||||
}
|
||||
|
||||
void registerSettings(const ScriptSettings& script)
|
||||
void registerSettingsPage(const ScriptSettingsPage& page)
|
||||
{
|
||||
allSettings.push_back(script);
|
||||
allPages.push_back(page);
|
||||
}
|
||||
|
||||
void clearSettings()
|
||||
{
|
||||
allSettings.clear();
|
||||
allPages.clear();
|
||||
}
|
||||
|
||||
void attachToWidget(size_t index, MyGUI::Widget* widget)
|
||||
{
|
||||
if (index < allSettings.size())
|
||||
allSettings[index].mElement->attachToWidget(widget);
|
||||
if (index < allPages.size())
|
||||
allPages[index].mElement->attachToWidget(widget);
|
||||
}
|
||||
}
|
||||
|
@ -10,14 +10,14 @@
|
||||
namespace LuaUi
|
||||
{
|
||||
struct Element;
|
||||
struct ScriptSettings
|
||||
struct ScriptSettingsPage
|
||||
{
|
||||
std::string mName;
|
||||
std::string mSearchHints;
|
||||
Element* mElement; // TODO: figure out if this can lead to use after free
|
||||
};
|
||||
const std::vector<ScriptSettings>& scriptSettings();
|
||||
void registerSettings(const ScriptSettings& script);
|
||||
const std::vector<ScriptSettingsPage>& scriptSettingsPages();
|
||||
void registerSettingsPage(const ScriptSettingsPage& page);
|
||||
void clearSettings();
|
||||
void attachToWidget(size_t index, MyGUI::Widget* widget = nullptr);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user