From a005f25c4b0d3e4beef00df534f42295b920a325 Mon Sep 17 00:00:00 2001 From: uramer Date: Sat, 29 Jan 2022 13:22:08 +0100 Subject: [PATCH] Use page terminology for script settings --- apps/openmw/mwgui/settingswindow.cpp | 8 ++++---- apps/openmw/mwlua/uibindings.cpp | 18 +++++++++--------- components/lua_ui/scriptsettings.cpp | 16 ++++++++-------- components/lua_ui/scriptsettings.hpp | 6 +++--- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/apps/openmw/mwgui/settingswindow.cpp b/apps/openmw/mwgui/settingswindow.cpp index f5d35bc13f..646fe0d19b 100644 --- a/apps/openmw/mwgui/settingswindow.cpp +++ b/apps/openmw/mwgui/settingswindow.cpp @@ -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 diff --git a/apps/openmw/mwlua/uibindings.cpp b/apps/openmw/mwlua/uibindings.cpp index 5fe54a4d35..7737f36ec4 100644 --- a/apps/openmw/mwlua/uibindings.cpp +++ b/apps/openmw/mwlua/uibindings.cpp @@ -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>("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); diff --git a/components/lua_ui/scriptsettings.cpp b/components/lua_ui/scriptsettings.cpp index 1bc93f4e84..1a016381cd 100644 --- a/components/lua_ui/scriptsettings.cpp +++ b/components/lua_ui/scriptsettings.cpp @@ -8,27 +8,27 @@ namespace LuaUi { namespace { - std::vector allSettings; + std::vector allPages; } - const std::vector& scriptSettings() + const std::vector& 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); } } diff --git a/components/lua_ui/scriptsettings.hpp b/components/lua_ui/scriptsettings.hpp index 7075a3b189..852e0df1ec 100644 --- a/components/lua_ui/scriptsettings.hpp +++ b/components/lua_ui/scriptsettings.hpp @@ -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(); - void registerSettings(const ScriptSettings& script); + const std::vector& scriptSettingsPages(); + void registerSettingsPage(const ScriptSettingsPage& page); void clearSettings(); void attachToWidget(size_t index, MyGUI::Widget* widget = nullptr); }