Fix #260: when returning from addons_loading, select the
previous selected list element again, so that the user is still at the same entry on the list. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@8803 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
a66accd21c
commit
9c3eacc0cc
@ -35,7 +35,8 @@ DEFINE_SCREEN_SINGLETON( AddonsScreen );
|
||||
|
||||
AddonsScreen::AddonsScreen() : Screen("addons_screen.stkgui")
|
||||
{
|
||||
}
|
||||
m_selected_index = -1;
|
||||
} // AddonsScreen
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -166,6 +167,7 @@ void AddonsScreen::onColumnClicked(int column_id)
|
||||
} // switch
|
||||
loadList();
|
||||
} // onColumnClicked
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
void AddonsScreen::eventCallback(GUIEngine::Widget* widget,
|
||||
const std::string& name, const int playerID)
|
||||
@ -189,6 +191,7 @@ void AddonsScreen::eventCallback(GUIEngine::Widget* widget,
|
||||
|
||||
if (!id.empty())
|
||||
{
|
||||
m_selected_index = list->getSelectionID();
|
||||
new AddonsLoading(0.8f, 0.8f, id);
|
||||
}
|
||||
}
|
||||
@ -211,3 +214,20 @@ void AddonsScreen::eventCallback(GUIEngine::Widget* widget,
|
||||
} // eventCallback
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Selects the last selected item on the list (which is the item that
|
||||
* is just being installed) again. This function is used from the
|
||||
* addons_loading screen: when it is closed, it will reset the
|
||||
* select item so that people can keep on installing from that
|
||||
* point on.
|
||||
*/
|
||||
void AddonsScreen::setLastSelected()
|
||||
{
|
||||
if(m_selected_index>-1)
|
||||
{
|
||||
GUIEngine::ListWidget* list =
|
||||
getWidget<GUIEngine::ListWidget>("list_addons");
|
||||
list->setSelectionID(m_selected_index);
|
||||
}
|
||||
} // setLastSelected
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -52,9 +52,14 @@ private:
|
||||
*m_icon_bank;
|
||||
GUIEngine::LabelWidget
|
||||
*m_update_status;
|
||||
|
||||
/** Currently selected type. */
|
||||
std::string m_type;
|
||||
|
||||
/** The currently selected index, used to re-select this item after
|
||||
* addons_loading is being displayed. */
|
||||
int m_selected_index;
|
||||
|
||||
public:
|
||||
|
||||
/** Load the addons into the main list.*/
|
||||
@ -70,7 +75,7 @@ public:
|
||||
|
||||
virtual void init();
|
||||
|
||||
friend void *startInstall(void *);
|
||||
void setLastSelected();
|
||||
|
||||
};
|
||||
|
||||
|
@ -36,6 +36,8 @@ using namespace GUIEngine;
|
||||
using namespace irr::gui;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Creates a modal dialog with given percentage of screen width and height
|
||||
*/
|
||||
|
||||
AddonsLoading::AddonsLoading(const float w, const float h,
|
||||
const std::string &id)
|
||||
@ -64,6 +66,16 @@ AddonsLoading::AddonsLoading(const float w, const float h,
|
||||
} // if isInstalled
|
||||
} // AddonsLoading
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Destructor.
|
||||
*/
|
||||
AddonsLoading::~AddonsLoading()
|
||||
{
|
||||
// Select the last selected item in the addons_screen, so that
|
||||
// users can keep on installing from the last selected item.
|
||||
AddonsScreen::getInstance()->setLastSelected();
|
||||
} // AddonsLoading
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void AddonsLoading::beforeAddingWidgets()
|
||||
|
@ -54,12 +54,11 @@ private:
|
||||
Request *m_download_request;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Creates a modal dialog with given percentage of screen width and height
|
||||
*/
|
||||
AddonsLoading(const float percent_width, const float percent_height,
|
||||
const std::string &addon_name);
|
||||
AddonsLoading(const float percent_width,
|
||||
const float percent_height,
|
||||
const std::string &addon_name);
|
||||
|
||||
~AddonsLoading();
|
||||
virtual GUIEngine::EventPropagation processEvent(const std::string& event_source);
|
||||
|
||||
virtual void beforeAddingWidgets();
|
||||
|
Loading…
x
Reference in New Issue
Block a user