From afc235e17bca4dd4a7c542b95e044024568388e1 Mon Sep 17 00:00:00 2001 From: Kyzentun Date: Thu, 8 May 2014 03:59:08 -0600 Subject: [PATCH 1/2] Added THEME:GetMetricNamesInGroup and THEME:GetStringNamesInGroup. --- src/ThemeManager.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/ThemeManager.cpp b/src/ThemeManager.cpp index b2cbf5d8ad..69ba477d56 100644 --- a/src/ThemeManager.cpp +++ b/src/ThemeManager.cpp @@ -1298,6 +1298,40 @@ public: DEFINE_METHOD( DoesLanguageExist, DoesLanguageExist(SArg(1)) ); DEFINE_METHOD( GetCurThemeName, GetCurThemeName() ); + static void PushMetricNamesInGroup(IniFile const& ini, lua_State* L) + { + RString group_name= SArg(1); + const XNode* metric_node= ini.GetChild(group_name); + if(metric_node != NULL) + { + // Placed in a table indexed by number, so the order is always the same. + lua_createtable(L, metric_node->m_attrs.size(), 0); + int next_index= 1; + for(XAttrs::const_iterator n= metric_node->m_attrs.begin(); n != metric_node->m_attrs.end(); ++n) + { + LuaHelpers::Push(L, n->first); + lua_rawseti(L, -2, next_index); + ++next_index; + } + } + else + { + lua_pushnil(L); + } + } + + static int GetMetricNamesInGroup(T* p, lua_State* L) + { + PushMetricNamesInGroup(g_pLoadedThemeData->iniMetrics, L); + return 1; + } + + static int GetStringNamesInGroup(T* p, lua_State* L) + { + PushMetricNamesInGroup(g_pLoadedThemeData->iniStrings, L); + return 1; + } + LunaThemeManager() { ADD_METHOD( ReloadMetrics ); @@ -1322,6 +1356,8 @@ public: ADD_METHOD( GetCurThemeName ); ADD_METHOD( HasMetric ); ADD_METHOD( HasString ); + ADD_METHOD( GetMetricNamesInGroup ); + ADD_METHOD( GetStringNamesInGroup ); } }; From c544beaba0f93643b0125262accba98dc4a7270f Mon Sep 17 00:00:00 2001 From: Kyzentun Date: Thu, 8 May 2014 04:05:21 -0600 Subject: [PATCH 2/2] Documentation for THEME:GetMetric/StringNamesInGroup. --- Docs/Luadoc/Lua.xml | 2 ++ Docs/Luadoc/LuaDocumentation.xml | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/Docs/Luadoc/Lua.xml b/Docs/Luadoc/Lua.xml index 681e827a2c..82734843a4 100644 --- a/Docs/Luadoc/Lua.xml +++ b/Docs/Luadoc/Lua.xml @@ -1596,6 +1596,7 @@ + @@ -1605,6 +1606,7 @@ + diff --git a/Docs/Luadoc/LuaDocumentation.xml b/Docs/Luadoc/LuaDocumentation.xml index 3fd0305536..b45c75352a 100644 --- a/Docs/Luadoc/LuaDocumentation.xml +++ b/Docs/Luadoc/LuaDocumentation.xml @@ -4424,6 +4424,9 @@ save yourself some time, copy this for undocumented things: Returns the value of Element in Class from metrics.ini. + + Returns the names of all elements in Class from metrics.ini. + Returns the number of selectable themes. @@ -4451,6 +4454,9 @@ save yourself some time, copy this for undocumented things: Returns the value of Element in Class for the currently loaded language. + + Returns the names of all elements in Class for the currently loaded language. + Returns the author of the current theme or "[unknown author]".