Skip to content

Commit

Permalink
always land on a song object (if available) during song search
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed May 1, 2017
1 parent 26d0f3a commit 0b063d9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/MusicWheel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ void MusicWheel::ReloadSongList(bool searching, RString findme)
{
int songIdxToPreserve = m_iSelection;
// Remove the song from any sorting caches:
FOREACH_ENUM( SortOrder, so )
m_WheelItemDatasStatus[so]=INVALID;
FOREACH_ENUM(SortOrder, so)
m_WheelItemDatasStatus[so] = INVALID;
// rebuild the info associated with this sort order
readyWheelItemsData(GAMESTATE->m_SortOrder, searching, findme);
// re-open the section to refresh song counts, etc.
Expand All @@ -275,7 +275,32 @@ void MusicWheel::ReloadSongList(bool searching, RString findme)
m_iSelection = songIdxToPreserve;
RebuildWheelItems();
// refresh the song preview
SCREENMAN->PostMessageToTopScreen( SM_SongChanged, 0 );
SCREENMAN->PostMessageToTopScreen(SM_SongChanged, 0);

// when searching, automatically land on the first search result available -mina & dadbearcop
if (findme != "") {
Song *pSong = GAMESTATE->m_pCurSong;
if (pSong) {
RString curSongTitle = pSong->GetDisplayMainTitle();
if (GetSelectedSection() != NULL && curSongTitle != prevSongTitle) {
prevSongTitle = curSongTitle;
SelectSongAfterSearch();
}
}
else {
SelectSongAfterSearch();
}
}
else {
SetOpenSection("");
}
}

void MusicWheel::SelectSongAfterSearch() {
vector<MusicWheelItemData*> &from = getWheelItemsData(GAMESTATE->m_SortOrder);
SelectSection(from[0]->m_sText);
SetOpenSection(from[0]->m_sText);
ChangeMusic(1);
}

/* If a song or course is set in GAMESTATE and available, select it. Otherwise, choose the
Expand Down
2 changes: 2 additions & 0 deletions src/MusicWheel.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ class MusicWheel : public WheelBase

void BuildWheelItemDatas( vector<MusicWheelItemData *> &arrayWheelItems, SortOrder so, bool searching, RString findme );
void FilterWheelItemDatas(vector<MusicWheelItemData*>& aUnFilteredDatas, vector<MusicWheelItemData*>& aFilteredData, SortOrder so);
void SelectSongAfterSearch();
RString prevSongTitle;
};

#endif
Expand Down

0 comments on commit 0b063d9

Please sign in to comment.