diff --git a/Docs/Changelog_sm5.txt b/Docs/Changelog_sm5.txt
index 12dad16fa2..8fd94002bf 100644
--- a/Docs/Changelog_sm5.txt
+++ b/Docs/Changelog_sm5.txt
@@ -4,6 +4,10 @@ The StepMania 5 Changelog covers all post-sm-ssc changes. For a list of changes
from StepMania 4 alpha 5 to sm-ssc v1.2.5, see Changelog_sm-ssc.txt.
________________________________________________________________________________
+2015/01/12
+----------
+* [ScreenOptions] GetNumRows function added. [kyzentun]
+
2015/01/09
----------
* [Sprite] SetStateProperties function added. [kyzentun]
diff --git a/Docs/Luadoc/Lua.xml b/Docs/Luadoc/Lua.xml
index 460157091c..cef9509db7 100644
--- a/Docs/Luadoc/Lua.xml
+++ b/Docs/Luadoc/Lua.xml
@@ -1442,6 +1442,7 @@
+
diff --git a/Docs/Luadoc/LuaDocumentation.xml b/Docs/Luadoc/LuaDocumentation.xml
index 9627c6f155..1bbfa2c490 100644
--- a/Docs/Luadoc/LuaDocumentation.xml
+++ b/Docs/Luadoc/LuaDocumentation.xml
@@ -4185,6 +4185,9 @@ save yourself some time, copy this for undocumented things:
Returns the current row that player pn is on. (Was previously GetCurrentRow.)
+
+ Returns the number of rows on the screen.
+
Returns the specified OptionRow.
diff --git a/src/ScreenOptions.cpp b/src/ScreenOptions.cpp
index 72bedd4007..176d96f80e 100644
--- a/src/ScreenOptions.cpp
+++ b/src/ScreenOptions.cpp
@@ -1352,13 +1352,21 @@ public:
static int FocusedItemEndsScreen( T* p, lua_State *L ) { lua_pushboolean( L, p->FocusedItemEndsScreen(Enum::Check(L, 1)) ); return 1; }
static int GetCurrentRowIndex( T* p, lua_State *L ) { lua_pushnumber( L, p->GetCurrentRow(Enum::Check(L, 1)) ); return 1; }
static int GetOptionRow( T* p, lua_State *L ) {
- OptionRow* pOptRow = p->GetRow( IArg(1) );
+ int row_index= IArg(1);
+ // TODO: Change row indices to be 1-indexed when breaking compatibility
+ // is allowed. -Kyz
+ if(row_index < 0 || row_index >= p->GetNumRows())
+ {
+ luaL_error(L, "Row index %d is invalid.", row_index);
+ }
+ OptionRow* pOptRow = p->GetRow(row_index);
if( pOptRow )
pOptRow->PushSelf(L);
else
lua_pushnil( L );
return 1;
}
+ DEFINE_METHOD(GetNumRows, GetNumRows());
//static int SetOptionRowFromName( T* p, lua_State *L ) { p->SetOptionRowFromName( SArg(1) ); return 0; }
LunaScreenOptions()
@@ -1367,6 +1375,7 @@ public:
ADD_METHOD( FocusedItemEndsScreen );
ADD_METHOD( GetCurrentRowIndex );
ADD_METHOD( GetOptionRow );
+ ADD_METHOD( GetNumRows );
//ADD_METHOD( SetOptionRowFromName );
}
};
diff --git a/src/ScreenOptions.h b/src/ScreenOptions.h
index 0fe23143f1..ca4e632af2 100644
--- a/src/ScreenOptions.h
+++ b/src/ScreenOptions.h
@@ -98,6 +98,7 @@ protected:
bool AllAreOnLastRow() const;
OptionRow* GetRow( int iRow ) const { return m_pRows[iRow]; }
//void SetOptionRowFromName( const RString& nombre );
+ int GetNumRows() const { return static_cast(m_pRows.size()); }
protected: // derived classes need access to these
enum Navigation { NAV_THREE_KEY, NAV_THREE_KEY_MENU, NAV_THREE_KEY_ALT, NAV_FIVE_KEY, NAV_TOGGLE_THREE_KEY, NAV_TOGGLE_FIVE_KEY };