Merge pull request #164 from kyzentun/get_metric_group

Added THEME:GetMetricNamesInGroup and THEME:GetStringNamesInGroup.
This commit is contained in:
AJ Kelly
2014-05-08 14:41:15 -05:00
3 changed files with 44 additions and 0 deletions
+2
View File
@@ -1596,6 +1596,7 @@
<Function name='GetCurThemeName'/>
<Function name='GetCurrentThemeDirectory'/>
<Function name='GetMetric'/>
<Function name='GetMetricNamesInGroup'/>
<Function name='GetNumSelectableThemes'/>
<Function name='GetPathB'/>
<Function name='GetPathF'/>
@@ -1605,6 +1606,7 @@
<Function name='GetPathS'/>
<Function name='GetSelectableThemeNames'/>
<Function name='GetString'/>
<Function name='GetStringNamesInGroup'/>
<Function name='GetThemeAuthor'/>
<Function name='GetThemeDisplayName'/>
<Function name='HasMetric'/>
+6
View File
@@ -4424,6 +4424,9 @@ save yourself some time, copy this for undocumented things:
<Function name='GetMetric' return='string' arguments='string ClassName, string Element'>
Returns the value of <code>Element</code> in <code>Class</code> from metrics.ini.
</Function>
<Function name='GetMetricNamesInGroup' return='{string}' arguments='string ClassName'>
Returns the names of all elements in <code>Class</code> from metrics.ini.
</Function>
<Function name='GetNumSelectableThemes' return='int' arguments=''>
Returns the number of selectable themes.
</Function>
@@ -4451,6 +4454,9 @@ save yourself some time, copy this for undocumented things:
<Function name='GetString' return='string' arguments='string ClassName, string Element'>
Returns the value of <code>Element</code> in <code>Class</code> for the currently loaded language.
</Function>
<Function name='GetStringNamesInGroup' return='{string}' arguments='string ClassName'>
Returns the names of all elements in <code>Class</code> for the currently loaded language.
</Function>
<Function name='GetThemeAuthor' return='string' arguments=''>
Returns the author of the current theme or "[unknown author]".
</Function>
+36
View File
@@ -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 );
}
};