mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-26 08:05:38 +00:00
Added support for jumping to favorites in the 'Jump to...' quick selector
This commit is contained in:
parent
c01d1491e6
commit
fc6183d918
|
@ -35,6 +35,26 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) : Gui
|
||||||
curChar = startChar;
|
curChar = startChar;
|
||||||
|
|
||||||
mJumpToLetterList = std::make_shared<LetterList>(mWindow, "JUMP TO...", false);
|
mJumpToLetterList = std::make_shared<LetterList>(mWindow, "JUMP TO...", false);
|
||||||
|
|
||||||
|
if(Settings::getInstance()->getBool("FavoritesFirst") && system->getName() != "favorites" && system->getName() != "recent")
|
||||||
|
{
|
||||||
|
// set firstFavorite to the numerical entry of the first favorite game in the list
|
||||||
|
// if no favorites are found set it to -1
|
||||||
|
findFirstFavorite();
|
||||||
|
|
||||||
|
// if the currently selected game is a favorite, set curChar to 0 so we don't get two current positions
|
||||||
|
if(getGamelist()->getCursor()->getFavorite())
|
||||||
|
curChar = 0;
|
||||||
|
|
||||||
|
if (firstFavorite != -1)
|
||||||
|
{
|
||||||
|
if (getGamelist()->getCursor()->getFavorite())
|
||||||
|
mJumpToLetterList->add(std::string(1, FAV_CHAR), FAV_CHAR, 1);
|
||||||
|
else
|
||||||
|
mJumpToLetterList->add(std::string(1, FAV_CHAR), FAV_CHAR, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (char c = startChar; c <= endChar; c++)
|
for (char c = startChar; c <= endChar; c++)
|
||||||
{
|
{
|
||||||
// check if c is a valid first letter in current list
|
// check if c is a valid first letter in current list
|
||||||
|
@ -44,6 +64,10 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) : Gui
|
||||||
char candidate = (char)toupper(file->getSortName()[0]);
|
char candidate = (char)toupper(file->getSortName()[0]);
|
||||||
if (c == candidate)
|
if (c == candidate)
|
||||||
{
|
{
|
||||||
|
// if the game is a favorite, continue to the next entry in the list
|
||||||
|
if (firstFavorite != -1 && file->getFavorite())
|
||||||
|
continue;
|
||||||
|
|
||||||
mJumpToLetterList->add(std::string(1, c), c, c == curChar);
|
mJumpToLetterList->add(std::string(1, c), c, c == curChar);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -55,6 +79,11 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) : Gui
|
||||||
row.input_handler = [&](InputConfig* config, Input input) {
|
row.input_handler = [&](InputConfig* config, Input input) {
|
||||||
if(config->isMappedTo("a", input) && input.value)
|
if(config->isMappedTo("a", input) && input.value)
|
||||||
{
|
{
|
||||||
|
if(mJumpToLetterList->getSelected() == FAV_CHAR)
|
||||||
|
{
|
||||||
|
jumpToFirstFavorite();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
jumpToLetter();
|
jumpToLetter();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -228,7 +257,16 @@ void GuiGamelistOptions::jumpToLetter()
|
||||||
else if(checkLetter > letter || (mid > 0 && (letter == toupper(files.at(mid - 1)->getSortName()[0]))))
|
else if(checkLetter > letter || (mid > 0 && (letter == toupper(files.at(mid - 1)->getSortName()[0]))))
|
||||||
max = mid - 1;
|
max = mid - 1;
|
||||||
else
|
else
|
||||||
break; //exact match found
|
{
|
||||||
|
// exact match found
|
||||||
|
// step through games to exclude favorites
|
||||||
|
if (firstFavorite != -1)
|
||||||
|
{
|
||||||
|
while(files[mid]->getFavorite())
|
||||||
|
mid++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gamelist->setCursor(files.at(mid));
|
gamelist->setCursor(files.at(mid));
|
||||||
|
@ -236,6 +274,42 @@ void GuiGamelistOptions::jumpToLetter()
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GuiGamelistOptions::findFirstFavorite()
|
||||||
|
{
|
||||||
|
IGameListView* gamelist = getGamelist();
|
||||||
|
|
||||||
|
// this is a really shitty way to get a list of files
|
||||||
|
const std::vector<FileData*>& files = gamelist->getCursor()->getParent()->getChildrenListToDisplay();
|
||||||
|
|
||||||
|
long loop = 0;
|
||||||
|
long max = (long)files.size() - 1;
|
||||||
|
|
||||||
|
// Loop through the game list looking for the first game marked as a favorite
|
||||||
|
while (!files[loop]->getFavorite() and loop < max)
|
||||||
|
loop++;
|
||||||
|
|
||||||
|
// if the last entry in the game list was not a favorite then there were none for this system
|
||||||
|
if (!files[loop]->getFavorite())
|
||||||
|
{
|
||||||
|
firstFavorite = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
firstFavorite = loop;
|
||||||
|
}
|
||||||
|
|
||||||
|
void GuiGamelistOptions::jumpToFirstFavorite()
|
||||||
|
{
|
||||||
|
IGameListView* gamelist = getGamelist();
|
||||||
|
|
||||||
|
// this is a really shitty way to get a list of files
|
||||||
|
const std::vector<FileData*>& files = gamelist->getCursor()->getParent()->getChildrenListToDisplay();
|
||||||
|
|
||||||
|
gamelist->setCursor(files.at(firstFavorite));
|
||||||
|
|
||||||
|
delete this;
|
||||||
|
}
|
||||||
|
|
||||||
bool GuiGamelistOptions::input(InputConfig* config, Input input)
|
bool GuiGamelistOptions::input(InputConfig* config, Input input)
|
||||||
{
|
{
|
||||||
if((config->isMappedTo("b", input) || config->isMappedTo("select", input)) && input.value)
|
if((config->isMappedTo("b", input) || config->isMappedTo("select", input)) && input.value)
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
#ifndef ES_APP_GUIS_GUI_GAME_LIST_OPTIONS_H
|
#ifndef ES_APP_GUIS_GUI_GAME_LIST_OPTIONS_H
|
||||||
#define ES_APP_GUIS_GUI_GAME_LIST_OPTIONS_H
|
#define ES_APP_GUIS_GUI_GAME_LIST_OPTIONS_H
|
||||||
|
|
||||||
|
#define FAV_CHAR '*'
|
||||||
|
|
||||||
#include "components/MenuComponent.h"
|
#include "components/MenuComponent.h"
|
||||||
#include "components/OptionListComponent.h"
|
#include "components/OptionListComponent.h"
|
||||||
#include "FileData.h"
|
#include "FileData.h"
|
||||||
|
@ -26,6 +28,10 @@ private:
|
||||||
void startEditMode();
|
void startEditMode();
|
||||||
void exitEditMode();
|
void exitEditMode();
|
||||||
void jumpToLetter();
|
void jumpToLetter();
|
||||||
|
void findFirstFavorite();
|
||||||
|
void jumpToFirstFavorite();
|
||||||
|
|
||||||
|
long firstFavorite = -1;
|
||||||
|
|
||||||
MenuComponent mMenu;
|
MenuComponent mMenu;
|
||||||
|
|
||||||
|
|
|
@ -526,11 +526,11 @@ void SystemView::renderCarousel(const Transform4x4f& trans)
|
||||||
|
|
||||||
float distance = i - mCamOffset;
|
float distance = i - mCamOffset;
|
||||||
|
|
||||||
float scale = 1.0f + ((mCarousel.logoScale - 1.0f) * (1.0f - fabs(distance)));
|
float scale = 1.0f + ((mCarousel.logoScale - 1.0f) * (1.0f - abs(distance)));
|
||||||
scale = Math::min(mCarousel.logoScale, Math::max(1.0f, scale));
|
scale = Math::min(mCarousel.logoScale, Math::max(1.0f, scale));
|
||||||
scale /= mCarousel.logoScale;
|
scale /= mCarousel.logoScale;
|
||||||
|
|
||||||
int opacity = (int)Math::round(0x80 + ((0xFF - 0x80) * (1.0f - fabs(distance))));
|
int opacity = (int)Math::round(0x80 + ((0xFF - 0x80) * (1.0f - abs(distance))));
|
||||||
opacity = Math::max((int) 0x80, opacity);
|
opacity = Math::max((int) 0x80, opacity);
|
||||||
|
|
||||||
const std::shared_ptr<GuiComponent> &comp = mEntries.at(index).data.logo;
|
const std::shared_ptr<GuiComponent> &comp = mEntries.at(index).data.logo;
|
||||||
|
|
Loading…
Reference in a new issue