Save scrollbar position when opening server info dialog

This commit is contained in:
Benau 2021-09-03 22:02:54 +08:00
parent b6ca771a0e
commit e2118c89c3
2 changed files with 14 additions and 0 deletions

View File

@ -20,6 +20,7 @@
#include "io/file_manager.hpp"
#include "graphics/irr_driver.hpp"
#include "guiengine/engine.hpp"
#include "guiengine/widgets/CGUISTKListBox.hpp"
#include "guiengine/widgets/icon_button_widget.hpp"
#include "guiengine/widgets/label_widget.hpp"
#include "guiengine/widgets/list_widget.hpp"
@ -280,7 +281,17 @@ void ServerInfoDialog::updateBookmarkStatus(bool change_bookmark)
m_bookmark_widget->setImage(m_remove_icon);
}
}
GUIEngine::ListWidget* w =
ServerSelection::getInstance()->getServerList();
CGUISTKListBox* box = NULL;
if (w)
box = w->getIrrlichtElement<CGUISTKListBox>();
int old_pos = -1;
if (box)
old_pos = box->getScrollBar()->getPos();
ServerSelection::getInstance()->copyFromServerList();
if (box)
box->getScrollBar()->setPos(old_pos);
} // updateBookmarkStatus
// -----------------------------------------------------------------------------

View File

@ -122,6 +122,9 @@ public:
{ return false; }
void copyFromServerList();
GUIEngine::ListWidget* getServerList() const
{ return m_server_list_widget; }
}; // ServerSelection
#endif