Explorar el Código

GuiTabBookCtrl.getSelectedPage()

Added get selected page to the tab book.
Peter Robinson hace 4 años
padre
commit
ef5174d116

+ 16 - 0
engine/source/gui/containers/guiTabBookCtrl.cc

@@ -787,6 +787,22 @@ GuiTabPageCtrl *GuiTabBookCtrl::findHitTab( Point2I hitPoint )
    return NULL;
 }
 
+U32 GuiTabBookCtrl::getSelectedPage()
+{
+	U32 index = 0;
+
+	for (U32 i = 0; i < mPages.size(); i++)
+	{
+		if (mActivePage == mPages[i].Page)
+		{
+			index = i;
+			break;
+		}
+	}
+
+	return index;
+}
+
 void GuiTabBookCtrl::selectPage( S32 index )
 {
    if( index < 0 || index >= mPages.size())

+ 2 - 0
engine/source/gui/containers/guiTabBookCtrl.h

@@ -154,6 +154,8 @@ private:
    /// This may change in the future.
    void addNewPage();
 
+   U32 getSelectedPage();
+
    /// Select a tab page based on an index
    /// @param   index   The index in the list that specifies which page to select
    void selectPage( S32 index );

+ 11 - 2
engine/source/gui/containers/guiTabBookCtrl_ScriptBinding.h

@@ -25,7 +25,7 @@ ConsoleMethodGroupBeginWithDocs(GuiTabBookCtrl, GuiControl)
 /*! Selects the active tab by index.
 	@param pageIndex The zero-based index of the tab to make active.
 */
-ConsoleMethodWithDocs(GuiTabBookCtrl, selectPage, void, 3, 3, "(pageIndex)")
+ConsoleMethodWithDocs(GuiTabBookCtrl, selectPage, ConsoleVoid, 3, 3, "(pageIndex)")
 {
 	S32 pageIndex = dAtoi(argv[2]);
 
@@ -34,12 +34,21 @@ ConsoleMethodWithDocs(GuiTabBookCtrl, selectPage, void, 3, 3, "(pageIndex)")
 
 /*! Selects the active tab by name.
 	@param pageName The name that appears on the tab to make active.
+	@return No return value
 */
-ConsoleMethodWithDocs(GuiTabBookCtrl, selectPageName, void, 3, 3, "(pageName)")
+ConsoleMethodWithDocs(GuiTabBookCtrl, selectPageName, ConsoleVoid, 3, 3, "(pageName)")
 {
 	object->selectPage(argv[2]);
 }
 
+/*! Returns the currently selected page index.
+	@return The index of the currently selected page.
+*/
+ConsoleMethodWithDocs(GuiTabBookCtrl, getSelectedPage, ConsoleInt, 2, 2, "()")
+{
+	return object->getSelectedPage();
+}
+
 /*! Sets the currently used TabProfile for the GuiControl
 	@param p The tabprofile you wish to set the control to use
 	@return No return value