Add track searching to network track screen
This commit is contained in:
parent
c26b3c989b
commit
dfd1912c33
@ -36,11 +36,13 @@
|
||||
</box>
|
||||
</div>
|
||||
<div id="vote" x="63%" y="1%" width="36%" height="88%" layout="vertical-row">
|
||||
<div width="100%" proportion="2" layout="horizontal-row">
|
||||
<div width="100%" height="92%" layout="horizontal-row">
|
||||
<box proportion="2" height="100%" layout="vertical-row">
|
||||
<list id="vote-list" width="100%" height="100%" word_wrap="true"/>
|
||||
</box>
|
||||
</div>
|
||||
<spacer height="1%"/>
|
||||
<textbox id="search_track" width="100%" height="fit"/>
|
||||
</div>
|
||||
<progressbar x="2%" y="93%" id="timer" height="1f" width="96%"></progressbar>
|
||||
</stkgui>
|
||||
|
@ -219,6 +219,7 @@ void TracksScreen::beforeAddingWidget()
|
||||
Screen::init();
|
||||
|
||||
m_selected_track = NULL;
|
||||
m_search_track = NULL;
|
||||
m_timer = getWidget<GUIEngine::ProgressBarWidget>("timer");
|
||||
m_timer->showLabel(false);
|
||||
|
||||
@ -367,7 +368,14 @@ void TracksScreen::beforeAddingWidget()
|
||||
void TracksScreen::init()
|
||||
{
|
||||
if (m_network_tracks)
|
||||
{
|
||||
m_search_track = getWidget<TextBoxWidget>("search_track");
|
||||
m_search_track->setText(L"");
|
||||
// Add listener for incremental update when search text is changed
|
||||
m_search_track->clearListeners();
|
||||
m_search_track->addListener(this);
|
||||
updateProgressBarText();
|
||||
}
|
||||
|
||||
// change the back button image (because it makes the game quit)
|
||||
if (m_quit_server)
|
||||
@ -563,6 +571,15 @@ void TracksScreen::buildTrackList()
|
||||
for (int n = 0; n < track_amount; n++)
|
||||
{
|
||||
Track* curr = track_manager->getTrack(n);
|
||||
core::stringw search_text;
|
||||
if (m_search_track)
|
||||
{
|
||||
search_text = m_search_track->getText();
|
||||
search_text.make_lower();
|
||||
}
|
||||
if (!search_text.empty() &&
|
||||
curr->getName().make_lower().find(search_text.c_str()) == -1)
|
||||
continue;
|
||||
if (RaceManager::get()->getMinorMode() == RaceManager::MINOR_MODE_EASTER_EGG
|
||||
&& !curr->hasEasterEggs())
|
||||
continue;
|
||||
|
@ -19,6 +19,7 @@
|
||||
#define HEADER_TRACKS_SCREEN_HPP
|
||||
|
||||
#include "guiengine/screen.hpp"
|
||||
#include "guiengine/widgets/text_box_widget.hpp"
|
||||
|
||||
#include <deque>
|
||||
#include <limits>
|
||||
@ -50,7 +51,8 @@ namespace irr
|
||||
* \ingroup states_screens
|
||||
*/
|
||||
class TracksScreen : public GUIEngine::Screen,
|
||||
public GUIEngine::ScreenSingleton<TracksScreen>
|
||||
public GUIEngine::ScreenSingleton<TracksScreen>,
|
||||
public GUIEngine::ITextBoxWidgetListener
|
||||
{
|
||||
friend class GUIEngine::ScreenSingleton<TracksScreen>;
|
||||
|
||||
@ -60,6 +62,7 @@ private:
|
||||
GUIEngine::CheckBoxWidget* m_reversed;
|
||||
GUIEngine::SpinnerWidget* m_laps;
|
||||
GUIEngine::ListWidget* m_vote_list;
|
||||
GUIEngine::TextBoxWidget* m_search_track;
|
||||
|
||||
/** Pointer to progress bar widget which is used as a timer
|
||||
* (going backwards). */
|
||||
@ -147,6 +150,11 @@ public:
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
void updatePlayerVotes();
|
||||
// ------------------------------------------------------------------------
|
||||
virtual void onTextUpdated() OVERRIDE
|
||||
{
|
||||
eventCallback(m_search_track, "trackgroups", 0);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user