diff --git a/es-app/src/guis/GuiGamelistOptions.cpp b/es-app/src/guis/GuiGamelistOptions.cpp index fc419ea1f..710df7e3d 100644 --- a/es-app/src/guis/GuiGamelistOptions.cpp +++ b/es-app/src/guis/GuiGamelistOptions.cpp @@ -18,39 +18,53 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) : Gui // check it's not a placeholder folder - if it is, only show "Filter Options" FileData* file = getGamelist()->getCursor(); fromPlaceholder = file->isPlaceHolder(); - bool isFiltered = system->getIndex()->isFiltered(); ComponentListRow row; if (!fromPlaceholder) { + // jump to letter + row.elements.clear(); - if (!isFiltered) { - // jump to letter - row.elements.clear(); - char curChar = toupper(getGamelist()->getCursor()->getName()[0]); - if(curChar < 'A' || curChar > 'Z') - curChar = 'A'; + // define supported character range + // this range includes all numbers, capital letters, and most reasonable symbols + char startChar = '!'; + char endChar = '_'; - mJumpToLetterList = std::make_shared(mWindow, "JUMP TO LETTER", false); - for(char c = 'A'; c <= 'Z'; c++) - mJumpToLetterList->add(std::string(1, c), c, c == curChar); + char curChar = toupper(getGamelist()->getCursor()->getName()[0]); + if(curChar < startChar || curChar > endChar) + curChar = startChar; - row.addElement(std::make_shared(mWindow, "JUMP TO LETTER", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); - row.addElement(mJumpToLetterList, false); - row.input_handler = [&](InputConfig* config, Input input) { - if(config->isMappedTo("a", input) && input.value) + mJumpToLetterList = std::make_shared(mWindow, "JUMP TO...", false); + for (char c = startChar; c <= endChar; c++) + { + // check if c is a valid first letter in current list + const std::vector& files = getGamelist()->getCursor()->getParent()->getChildrenListToDisplay(); + for (auto file : files) + { + char candidate = toupper(file->getName()[0]); + if (c == candidate) { - jumpToLetter(); - return true; + mJumpToLetterList->add(std::string(1, c), c, c == curChar); + break; } - else if(mJumpToLetterList->input(config, input)) - { - return true; - } - return false; - }; - mMenu.addRow(row); + } } + row.addElement(std::make_shared(mWindow, "JUMP TO...", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); + row.addElement(mJumpToLetterList, false); + row.input_handler = [&](InputConfig* config, Input input) { + if(config->isMappedTo("a", input) && input.value) + { + jumpToLetter(); + return true; + } + else if(mJumpToLetterList->input(config, input)) + { + return true; + } + return false; + }; + mMenu.addRow(row); + // sort list by mListSort = std::make_shared(mWindow, "SORT GAMES BY", false); for(unsigned int i = 0; i < FileSorts::SortTypes.size(); i++) @@ -189,7 +203,7 @@ void GuiGamelistOptions::jumpToLetter() IGameListView* gamelist = getGamelist(); // this is a really shitty way to get a list of files - const std::vector& files = gamelist->getCursor()->getParent()->getChildren(); + const std::vector& files = gamelist->getCursor()->getParent()->getChildrenListToDisplay(); long min = 0; long max = files.size() - 1;