Merge pull request #133 from pjft/RetroPie-master-filter-rebase

Fixing whitespaces and indentation (tabs)
This commit is contained in:
Jools Wills 2017-05-18 14:29:03 +01:00 committed by GitHub
commit 7d43c87757
19 changed files with 160 additions and 153 deletions

View file

@ -108,7 +108,7 @@ target_link_libraries(emulationstation ${COMMON_LIBRARIES} es-core)
# special properties for Windows builds # special properties for Windows builds
if(MSVC) if(MSVC)
# Always compile with the "WINDOWS" subsystem to avoid console window flashing at startup # Always compile with the "WINDOWS" subsystem to avoid console window flashing at startup
# when --debug is not set (see es-core/src/main.cpp for explanation). # when --debug is not set (see es-core/src/main.cpp for explanation).
# The console will still be shown if launched with --debug. # The console will still be shown if launched with --debug.
# Note that up to CMake 2.8.10 this feature is broken: http://public.kitware.com/Bug/view.php?id=12566 # Note that up to CMake 2.8.10 this feature is broken: http://public.kitware.com/Bug/view.php?id=12566

View file

@ -82,7 +82,7 @@ const std::string& FileData::getThumbnailPath() const
} }
const std::vector<FileData*>& FileData::getChildrenListToDisplay() { const std::vector<FileData*>& FileData::getChildrenListToDisplay() {
FileFilterIndex* idx = mSystem->getIndex(); FileFilterIndex* idx = mSystem->getIndex();
if (idx->isFiltered()) { if (idx->isFiltered()) {
mFilteredChildren.clear(); mFilteredChildren.clear();
@ -95,7 +95,7 @@ const std::vector<FileData*>& FileData::getChildrenListToDisplay() {
return mFilteredChildren; return mFilteredChildren;
} }
else else
{ {
return mChildren; return mChildren;
} }
@ -123,7 +123,7 @@ std::vector<FileData*> FileData::getFilesRecursive(unsigned int typeMask, bool d
if (!displayedOnly || !idx->isFiltered() || idx->showFile(*it)) if (!displayedOnly || !idx->isFiltered() || idx->showFile(*it))
out.push_back(*it); out.push_back(*it);
} }
if((*it)->getChildren().size() > 0) if((*it)->getChildren().size() > 0)
{ {
std::vector<FileData*> subchildren = (*it)->getFilesRecursive(typeMask, displayedOnly); std::vector<FileData*> subchildren = (*it)->getFilesRecursive(typeMask, displayedOnly);

View file

@ -44,13 +44,13 @@ public:
inline const std::unordered_map<std::string, FileData*>& getChildrenByFilename() const { return mChildrenByFilename; } inline const std::unordered_map<std::string, FileData*>& getChildrenByFilename() const { return mChildrenByFilename; }
inline const std::vector<FileData*>& getChildren() const { return mChildren; } inline const std::vector<FileData*>& getChildren() const { return mChildren; }
inline SystemData* getSystem() const { return mSystem; } inline SystemData* getSystem() const { return mSystem; }
virtual const std::string& getThumbnailPath() const; virtual const std::string& getThumbnailPath() const;
virtual const std::string& getVideoPath() const; virtual const std::string& getVideoPath() const;
virtual const std::string& getMarqueePath() const; virtual const std::string& getMarqueePath() const;
const std::vector<FileData*>& getChildrenListToDisplay(); const std::vector<FileData*>& getChildrenListToDisplay();
std::vector<FileData*> getFilesRecursive(unsigned int typeMask, bool displayedOnly = false) const; std::vector<FileData*> getFilesRecursive(unsigned int typeMask, bool displayedOnly = false) const;
void addChild(FileData* file); // Error if mType != FOLDER void addChild(FileData* file); // Error if mType != FOLDER
void removeChild(FileData* file); //Error if mType != FOLDER void removeChild(FileData* file); //Error if mType != FOLDER
@ -70,7 +70,7 @@ public:
bool ascending; bool ascending;
std::string description; std::string description;
SortType(ComparisonFunction* sortFunction, bool sortAscending, const std::string & sortDescription) SortType(ComparisonFunction* sortFunction, bool sortAscending, const std::string & sortDescription)
: comparisonFunction(sortFunction), ascending(sortAscending), description(sortDescription) {} : comparisonFunction(sortFunction), ascending(sortAscending), description(sortDescription) {}
}; };

View file

@ -3,7 +3,7 @@
#define UNKNOWN_LABEL "UNKNOWN" #define UNKNOWN_LABEL "UNKNOWN"
#define INCLUDE_UNKNOWN false; #define INCLUDE_UNKNOWN false;
FileFilterIndex::FileFilterIndex() FileFilterIndex::FileFilterIndex()
: filterByGenre(false), filterByPlayers(false), filterByPubDev(false), filterByRatings(false) : filterByGenre(false), filterByPlayers(false), filterByPubDev(false), filterByRatings(false)
{ {
FilterDataDecl filterDecls[] = { FilterDataDecl filterDecls[] = {
@ -26,7 +26,7 @@ FileFilterIndex::~FileFilterIndex()
} }
std::vector<FilterDataDecl>& FileFilterIndex::getFilterDataDecls() std::vector<FilterDataDecl>& FileFilterIndex::getFilterDataDecls()
{ {
return filterDataDecl; return filterDataDecl;
} }
@ -34,7 +34,7 @@ std::vector<FilterDataDecl>& FileFilterIndex::getFilterDataDecls()
std::string FileFilterIndex::getIndexableKey(FileData* game, FilterIndexType type, bool getSecondary) std::string FileFilterIndex::getIndexableKey(FileData* game, FilterIndexType type, bool getSecondary)
{ {
std::string key = ""; std::string key = "";
switch(type) switch(type)
{ {
case GENRE_FILTER: case GENRE_FILTER:
{ {
@ -42,24 +42,24 @@ std::string FileFilterIndex::getIndexableKey(FileData* game, FilterIndexType typ
boost::trim(key); boost::trim(key);
if (getSecondary && !key.empty()) { if (getSecondary && !key.empty()) {
std::istringstream f(key); std::istringstream f(key);
std::string newKey; std::string newKey;
getline(f, newKey, '/'); getline(f, newKey, '/');
if (!newKey.empty() && newKey != key) if (!newKey.empty() && newKey != key)
{ {
key = newKey; key = newKey;
} }
else else
{ {
key = std::string(); key = std::string();
} }
} }
break; break;
} }
case PLAYER_FILTER: case PLAYER_FILTER:
{ {
if (getSecondary) if (getSecondary)
break; break;
key = game->metadata.get("players"); key = game->metadata.get("players");
break; break;
} }
@ -77,8 +77,8 @@ std::string FileFilterIndex::getIndexableKey(FileData* game, FilterIndexType typ
case RATINGS_FILTER: case RATINGS_FILTER:
{ {
int ratingNumber = 0; int ratingNumber = 0;
if (!getSecondary) if (!getSecondary)
{ {
std::string ratingString = game->metadata.get("rating"); std::string ratingString = game->metadata.get("rating");
if (!ratingString.empty()) { if (!ratingString.empty()) {
try { try {
@ -87,11 +87,11 @@ std::string FileFilterIndex::getIndexableKey(FileData* game, FilterIndexType typ
ratingNumber = 0; ratingNumber = 0;
key = std::to_string(ratingNumber) + " STARS"; key = std::to_string(ratingNumber) + " STARS";
} }
catch (int e) catch (int e)
{ {
LOG(LogError) << "Error parsing Rating (invalid value, expected decimal): " << ratingString; LOG(LogError) << "Error parsing Rating (invalid value, expected decimal): " << ratingString;
} }
} }
} }
break; break;
@ -120,7 +120,7 @@ void FileFilterIndex::removeFromIndex(FileData* game)
manageRatingsEntryInIndex(game, true); manageRatingsEntryInIndex(game, true);
} }
void FileFilterIndex::setFilter(FilterIndexType type, std::vector<std::string>* values) void FileFilterIndex::setFilter(FilterIndexType type, std::vector<std::string>* values)
{ {
// test if it exists before setting // test if it exists before setting
if(type == NONE) if(type == NONE)
@ -128,7 +128,7 @@ void FileFilterIndex::setFilter(FilterIndexType type, std::vector<std::string>*
clearAllFilters(); clearAllFilters();
} }
else else
{ {
for (std::vector<FilterDataDecl>::iterator it = filterDataDecl.begin(); it != filterDataDecl.end(); ++it ) { for (std::vector<FilterDataDecl>::iterator it = filterDataDecl.begin(); it != filterDataDecl.end(); ++it ) {
if ((*it).type == type) if ((*it).type == type)
{ {
@ -136,20 +136,21 @@ void FileFilterIndex::setFilter(FilterIndexType type, std::vector<std::string>*
*(filterData.filteredByRef) = values->size() > 0; *(filterData.filteredByRef) = values->size() > 0;
filterData.currentFilteredKeys->clear(); filterData.currentFilteredKeys->clear();
for (std::vector<std::string>::iterator vit = values->begin(); vit != values->end(); ++vit ) { for (std::vector<std::string>::iterator vit = values->begin(); vit != values->end(); ++vit ) {
// check if exists // check if exists
if (filterData.allIndexKeys->find(*vit) != filterData.allIndexKeys->end()) { if (filterData.allIndexKeys->find(*vit) != filterData.allIndexKeys->end()) {
filterData.currentFilteredKeys->push_back(std::string(*vit)); filterData.currentFilteredKeys->push_back(std::string(*vit));
} }
} }
} }
} }
} }
return; return;
} }
void FileFilterIndex::clearAllFilters() void FileFilterIndex::clearAllFilters()
{ {
for (std::vector<FilterDataDecl>::iterator it = filterDataDecl.begin(); it != filterDataDecl.end(); ++it ) { for (std::vector<FilterDataDecl>::iterator it = filterDataDecl.begin(); it != filterDataDecl.end(); ++it )
{
FilterDataDecl filterData = (*it); FilterDataDecl filterData = (*it);
*(filterData.filteredByRef) = false; *(filterData.filteredByRef) = false;
filterData.currentFilteredKeys->clear(); filterData.currentFilteredKeys->clear();
@ -157,36 +158,36 @@ void FileFilterIndex::clearAllFilters()
return; return;
} }
void FileFilterIndex::debugPrintIndexes() void FileFilterIndex::debugPrintIndexes()
{ {
LOG(LogInfo) << "Printing Indexes..."; LOG(LogInfo) << "Printing Indexes...";
for (auto x: playersIndexAllKeys) { for (auto x: playersIndexAllKeys) {
LOG(LogInfo) << "Multiplayer Index: " << x.first << ": " << x.second; LOG(LogInfo) << "Multiplayer Index: " << x.first << ": " << x.second;
} }
for (auto x: genreIndexAllKeys) { for (auto x: genreIndexAllKeys) {
LOG(LogInfo) << "Genre Index: " << x.first << ": " << x.second; LOG(LogInfo) << "Genre Index: " << x.first << ": " << x.second;
} }
for (auto x: ratingsIndexAllKeys) { for (auto x: ratingsIndexAllKeys) {
LOG(LogInfo) << "Ratings Index: " << x.first << ": " << x.second; LOG(LogInfo) << "Ratings Index: " << x.first << ": " << x.second;
} }
for (auto x: pubDevIndexAllKeys) { for (auto x: pubDevIndexAllKeys) {
LOG(LogInfo) << "PubDev Index: " << x.first << ": " << x.second; LOG(LogInfo) << "PubDev Index: " << x.first << ": " << x.second;
} }
} }
bool FileFilterIndex::showFile(FileData* game) bool FileFilterIndex::showFile(FileData* game)
{ {
// this shouldn't happen, but just in case let's get it out of the way // this shouldn't happen, but just in case let's get it out of the way
if (!isFiltered()) if (!isFiltered())
return true; return true;
// if folder, needs further inspection - i.e. see if folder contains at least one element // if folder, needs further inspection - i.e. see if folder contains at least one element
// that should be shown // that should be shown
if (game->getType() == FOLDER) { if (game->getType() == FOLDER) {
std::vector<FileData*> children = game->getChildren(); std::vector<FileData*> children = game->getChildren();
// iterate through all of the children, until there's a match // iterate through all of the children, until there's a match
for (std::vector<FileData*>::iterator it = children.begin(); it != children.end(); ++it ) { for (std::vector<FileData*>::iterator it = children.begin(); it != children.end(); ++it ) {
if (showFile(*it)) if (showFile(*it))
{ {
return true; return true;
@ -199,47 +200,53 @@ bool FileFilterIndex::showFile(FileData* game)
for (std::vector<FilterDataDecl>::iterator it = filterDataDecl.begin(); it != filterDataDecl.end(); ++it ) { for (std::vector<FilterDataDecl>::iterator it = filterDataDecl.begin(); it != filterDataDecl.end(); ++it ) {
FilterDataDecl filterData = (*it); FilterDataDecl filterData = (*it);
if(*(filterData.filteredByRef)) { if(*(filterData.filteredByRef))
{
// try to find a match // try to find a match
std::string key = getIndexableKey(game, filterData.type, false); std::string key = getIndexableKey(game, filterData.type, false);
keepGoing = isKeyBeingFilteredBy(key, filterData.type); keepGoing = isKeyBeingFilteredBy(key, filterData.type);
// if we didn't find a match, try for secondary keys - i.e. publisher and dev, or first genre // if we didn't find a match, try for secondary keys - i.e. publisher and dev, or first genre
if (!keepGoing) { if (!keepGoing)
if (!filterData.hasSecondaryKey) {
{ if (!filterData.hasSecondaryKey)
return false; {
} return false;
std::string secKey = getIndexableKey(game, filterData.type, true); }
if (secKey != UNKNOWN_LABEL) std::string secKey = getIndexableKey(game, filterData.type, true);
{ if (secKey != UNKNOWN_LABEL)
keepGoing = isKeyBeingFilteredBy(secKey, filterData.type); {
} keepGoing = isKeyBeingFilteredBy(secKey, filterData.type);
} }
// if still nothing, then it's not a match }
if (!keepGoing) // if still nothing, then it's not a match
if (!keepGoing)
return false; return false;
} }
} }
return keepGoing; return keepGoing;
} }
bool FileFilterIndex::isKeyBeingFilteredBy(std::string key, FilterIndexType type) { bool FileFilterIndex::isKeyBeingFilteredBy(std::string key, FilterIndexType type)
{
const FilterIndexType filterTypes[4] = { PLAYER_FILTER, RATINGS_FILTER, GENRE_FILTER, PUBDEV_FILTER }; const FilterIndexType filterTypes[4] = { PLAYER_FILTER, RATINGS_FILTER, GENRE_FILTER, PUBDEV_FILTER };
std::vector<std::string> filterKeysList[4] = { playersIndexFilteredKeys, ratingsIndexFilteredKeys, genreIndexFilteredKeys, pubDevIndexFilteredKeys }; std::vector<std::string> filterKeysList[4] = { playersIndexFilteredKeys, ratingsIndexFilteredKeys, genreIndexFilteredKeys, pubDevIndexFilteredKeys };
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++)
if (filterTypes[i] == type) { {
for (std::vector<std::string>::iterator it = filterKeysList[i].begin(); it != filterKeysList[i].end(); ++it ) { if (filterTypes[i] == type)
if (key == (*it)) {
for (std::vector<std::string>::iterator it = filterKeysList[i].begin(); it != filterKeysList[i].end(); ++it )
{
if (key == (*it))
{ {
return true; return true;
} }
} }
return false; return false;
} }
} }
@ -258,7 +265,7 @@ void FileFilterIndex::manageGenreEntryInIndex(FileData* game, bool remove)
if (!includeUnknown && (key == UNKNOWN_LABEL || key == "BIOS")) { if (!includeUnknown && (key == UNKNOWN_LABEL || key == "BIOS")) {
// no valid genre info found // no valid genre info found
return; return;
} }
manageIndexEntry(&genreIndexAllKeys, key, remove); manageIndexEntry(&genreIndexAllKeys, key, remove);
@ -279,7 +286,7 @@ void FileFilterIndex::managePlayerEntryInIndex(FileData* game, bool remove)
if (!includeUnknown && key == UNKNOWN_LABEL) { if (!includeUnknown && key == UNKNOWN_LABEL) {
// no valid player info found // no valid player info found
return; return;
} }
manageIndexEntry(&playersIndexAllKeys, key, remove); manageIndexEntry(&playersIndexAllKeys, key, remove);
} }
@ -304,13 +311,13 @@ void FileFilterIndex::managePubDevEntryInIndex(FileData* game, bool remove)
if (!includeUnknown && unknownDev && unknownPub) { if (!includeUnknown && unknownDev && unknownPub) {
// no valid rating info found // no valid rating info found
return; return;
} }
if (unknownDev && unknownPub) { if (unknownDev && unknownPub) {
// if no info at all // if no info at all
manageIndexEntry(&pubDevIndexAllKeys, pub, remove); manageIndexEntry(&pubDevIndexAllKeys, pub, remove);
} }
else else
{ {
if (!unknownDev) { if (!unknownDev) {
// if no info at all // if no info at all
@ -333,7 +340,7 @@ void FileFilterIndex::manageRatingsEntryInIndex(FileData* game, bool remove)
if (!includeUnknown && key == UNKNOWN_LABEL) { if (!includeUnknown && key == UNKNOWN_LABEL) {
// no valid rating info found // no valid rating info found
return; return;
} }
manageIndexEntry(&ratingsIndexAllKeys, key, remove); manageIndexEntry(&ratingsIndexAllKeys, key, remove);
} }
@ -348,7 +355,7 @@ void FileFilterIndex::manageIndexEntry(std::map<std::string, int>* index, std::s
{ {
// this shouldn't happen // this shouldn't happen
LOG(LogError) << "Couldn't find entry in index! " << key; LOG(LogError) << "Couldn't find entry in index! " << key;
} }
else else
{ {
(index->at(key))--; (index->at(key))--;
@ -356,22 +363,22 @@ void FileFilterIndex::manageIndexEntry(std::map<std::string, int>* index, std::s
index->erase(key); index->erase(key);
} }
} }
} }
else else
{ {
// adding entry // adding entry
if (index->find(key) == index->end()) if (index->find(key) == index->end())
{ {
(*index)[key] = 1; (*index)[key] = 1;
} }
else else
{ {
(index->at(key))++; (index->at(key))++;
} }
} }
} }
void FileFilterIndex::clearIndex(std::map<std::string, int> indexMap) void FileFilterIndex::clearIndex(std::map<std::string, int> indexMap)
{ {
indexMap.clear(); indexMap.clear();
} }

View file

@ -38,7 +38,7 @@ public:
void addToIndex(FileData* game); void addToIndex(FileData* game);
void removeFromIndex(FileData* game); void removeFromIndex(FileData* game);
void setFilter(FilterIndexType type, std::vector<std::string>* values); void setFilter(FilterIndexType type, std::vector<std::string>* values);
void clearAllFilters(); void clearAllFilters();
void debugPrintIndexes(); void debugPrintIndexes();
bool showFile(FileData* game); bool showFile(FileData* game);
bool isFiltered() { return (filterByGenre || filterByPlayers || filterByPubDev || filterByRatings); }; bool isFiltered() { return (filterByGenre || filterByPlayers || filterByPubDev || filterByRatings); };
@ -49,7 +49,7 @@ public:
private: private:
std::vector<FilterDataDecl> filterDataDecl; std::vector<FilterDataDecl> filterDataDecl;
std::string getIndexableKey(FileData* game, FilterIndexType type, bool getSecondary); std::string getIndexableKey(FileData* game, FilterIndexType type, bool getSecondary);
void manageGenreEntryInIndex(FileData* game, bool remove = false); void manageGenreEntryInIndex(FileData* game, bool remove = false);
void managePlayerEntryInIndex(FileData* game, bool remove = false); void managePlayerEntryInIndex(FileData* game, bool remove = false);
void managePubDevEntryInIndex(FileData* game, bool remove = false); void managePubDevEntryInIndex(FileData* game, bool remove = false);

View file

@ -68,7 +68,7 @@ FileData* findOrCreateFile(SystemData* system, const boost::filesystem::path& pa
LOG(LogWarning) << "gameList: folder doesn't already exist, won't create"; LOG(LogWarning) << "gameList: folder doesn't already exist, won't create";
return NULL; return NULL;
} }
// create missing folder // create missing folder
FileData* folder = new FileData(FOLDER, treeNode->getPath().stem() / *path_it, system); FileData* folder = new FileData(FOLDER, treeNode->getPath().stem() / *path_it, system);
treeNode->addChild(folder); treeNode->addChild(folder);
@ -118,7 +118,7 @@ void parseGamelist(SystemData* system)
for(pugi::xml_node fileNode = root.child(tag); fileNode; fileNode = fileNode.next_sibling(tag)) for(pugi::xml_node fileNode = root.child(tag); fileNode; fileNode = fileNode.next_sibling(tag))
{ {
fs::path path = resolvePath(fileNode.child("path").text().get(), relativeTo, false); fs::path path = resolvePath(fileNode.child("path").text().get(), relativeTo, false);
if(!trustGamelist && !boost::filesystem::exists(path)) if(!trustGamelist && !boost::filesystem::exists(path))
{ {
LOG(LogWarning) << "File \"" << path << "\" does not exist! Ignoring."; LOG(LogWarning) << "File \"" << path << "\" does not exist! Ignoring.";
@ -160,7 +160,7 @@ void addFileDataNode(pugi::xml_node& parent, const FileData* file, const char* t
//write metadata //write metadata
file->metadata.appendToXML(newNode, true, system->getStartPath()); file->metadata.appendToXML(newNode, true, system->getStartPath());
if(newNode.children().begin() == newNode.child("name") //first element is name if(newNode.children().begin() == newNode.child("name") //first element is name
&& ++newNode.children().begin() == newNode.children().end() //theres only one element && ++newNode.children().begin() == newNode.children().end() //theres only one element
&& newNode.child("name").text().get() == file->getDisplayName()) //the name is the default && newNode.child("name").text().get() == file->getDisplayName()) //the name is the default
@ -194,7 +194,7 @@ void updateGamelist(SystemData* system)
{ {
//parse an existing file first //parse an existing file first
pugi::xml_parse_result result = doc.load_file(xmlReadPath.c_str()); pugi::xml_parse_result result = doc.load_file(xmlReadPath.c_str());
if(!result) if(!result)
{ {
LOG(LogError) << "Error parsing XML file \"" << xmlReadPath << "\"!\n " << result.description(); LOG(LogError) << "Error parsing XML file \"" << xmlReadPath << "\"!\n " << result.description();

View file

@ -17,7 +17,7 @@ std::vector<SystemData*> SystemData::sSystemVector;
namespace fs = boost::filesystem; namespace fs = boost::filesystem;
SystemData::SystemData(const std::string& name, const std::string& fullName, const std::string& startPath, const std::vector<std::string>& extensions, SystemData::SystemData(const std::string& name, const std::string& fullName, const std::string& startPath, const std::vector<std::string>& extensions,
const std::string& command, const std::vector<PlatformIds::PlatformId>& platformIds, const std::string& themeFolder) const std::string& command, const std::vector<PlatformIds::PlatformId>& platformIds, const std::string& themeFolder)
{ {
mName = name; mName = name;
@ -70,7 +70,7 @@ std::string strreplace(std::string str, const std::string& replace, const std::s
size_t pos; size_t pos;
while((pos = str.find(replace)) != std::string::npos) while((pos = str.find(replace)) != std::string::npos)
str = str.replace(pos, replace.length(), with.c_str(), with.length()); str = str.replace(pos, replace.length(), with.c_str(), with.length());
return str; return str;
} }
@ -182,7 +182,7 @@ void SystemData::populateFolder(FileData* folder)
//this is a little complicated because we allow a list of extensions to be defined (delimited with a space) //this is a little complicated because we allow a list of extensions to be defined (delimited with a space)
//we first get the extension of the file itself: //we first get the extension of the file itself:
extension = filePath.extension().string(); extension = filePath.extension().string();
//fyi, folders *can* also match the extension and be added as games - this is mostly just to support higan //fyi, folders *can* also match the extension and be added as games - this is mostly just to support higan
//see issue #75: https://github.com/Aloshi/EmulationStation/issues/75 //see issue #75: https://github.com/Aloshi/EmulationStation/issues/75
@ -283,7 +283,7 @@ bool SystemData::loadConfig()
{ {
const char* str = it->c_str(); const char* str = it->c_str();
PlatformIds::PlatformId platformId = PlatformIds::getPlatformId(str); PlatformIds::PlatformId platformId = PlatformIds::getPlatformId(str);
if(platformId == PlatformIds::PLATFORM_IGNORE) if(platformId == PlatformIds::PLATFORM_IGNORE)
{ {
// when platform is ignore, do not allow other platforms // when platform is ignore, do not allow other platforms

View file

@ -12,7 +12,7 @@
class SystemData class SystemData
{ {
public: public:
SystemData(const std::string& name, const std::string& fullName, const std::string& startPath, const std::vector<std::string>& extensions, SystemData(const std::string& name, const std::string& fullName, const std::string& startPath, const std::vector<std::string>& extensions,
const std::string& command, const std::vector<PlatformIds::PlatformId>& platformIds, const std::string& themeFolder); const std::string& command, const std::vector<PlatformIds::PlatformId>& platformIds, const std::string& themeFolder);
~SystemData(); ~SystemData();
@ -31,7 +31,7 @@ public:
std::string getGamelistPath(bool forWrite) const; std::string getGamelistPath(bool forWrite) const;
bool hasGamelist() const; bool hasGamelist() const;
std::string getThemePath() const; std::string getThemePath() const;
unsigned int getGameCount() const; unsigned int getGameCount() const;
unsigned int getDisplayedGameCount() const; unsigned int getDisplayedGameCount() const;
@ -46,7 +46,7 @@ public:
inline std::vector<SystemData*>::const_iterator getIterator() const { return std::find(sSystemVector.begin(), sSystemVector.end(), this); }; inline std::vector<SystemData*>::const_iterator getIterator() const { return std::find(sSystemVector.begin(), sSystemVector.end(), this); };
inline std::vector<SystemData*>::const_reverse_iterator getRevIterator() const { return std::find(sSystemVector.rbegin(), sSystemVector.rend(), this); }; inline std::vector<SystemData*>::const_reverse_iterator getRevIterator() const { return std::find(sSystemVector.rbegin(), sSystemVector.rend(), this); };
inline SystemData* getNext() const inline SystemData* getNext() const
{ {
auto it = getIterator(); auto it = getIterator();

View file

@ -10,11 +10,11 @@ GuiGamelistFilter::GuiGamelistFilter(Window* window, SystemData* system) : GuiCo
initializeMenu(); initializeMenu();
} }
void GuiGamelistFilter::initializeMenu() void GuiGamelistFilter::initializeMenu()
{ {
addChild(&mMenu); addChild(&mMenu);
// get filters from system // get filters from system
mFilterIndex = mSystem->getIndex(); mFilterIndex = mSystem->getIndex();
@ -45,10 +45,10 @@ void GuiGamelistFilter::resetAllFilters()
GuiGamelistFilter::~GuiGamelistFilter() GuiGamelistFilter::~GuiGamelistFilter()
{ {
mFilterOptions.clear(); mFilterOptions.clear();
} }
void GuiGamelistFilter::addFiltersToMenu() void GuiGamelistFilter::addFiltersToMenu()
{ {
std::vector<FilterDataDecl> decls = mFilterIndex->getFilterDataDecls(); std::vector<FilterDataDecl> decls = mFilterIndex->getFilterDataDecls();
for (std::vector<FilterDataDecl>::iterator it = decls.begin(); it != decls.end(); ++it ) { for (std::vector<FilterDataDecl>::iterator it = decls.begin(); it != decls.end(); ++it ) {
@ -59,9 +59,9 @@ void GuiGamelistFilter::addFiltersToMenu()
std::string menuLabel = (*it).menuLabel; // text to show in menu std::string menuLabel = (*it).menuLabel; // text to show in menu
std::shared_ptr< OptionListComponent<std::string> > optionList; std::shared_ptr< OptionListComponent<std::string> > optionList;
// add filters (with first one selected) // add filters (with first one selected)
ComponentListRow row; ComponentListRow row;
// add genres // add genres
optionList = std::make_shared< OptionListComponent<std::string> >(mWindow, menuLabel, true); optionList = std::make_shared< OptionListComponent<std::string> >(mWindow, menuLabel, true);
@ -72,7 +72,7 @@ void GuiGamelistFilter::addFiltersToMenu()
if (allKeys->size() > 0) if (allKeys->size() > 0)
mMenu.addWithLabel(menuLabel, optionList); mMenu.addWithLabel(menuLabel, optionList);
mFilterOptions[type] = optionList; mFilterOptions[type] = optionList;
} }
} }
@ -86,7 +86,7 @@ void GuiGamelistFilter::applyFilters()
} }
delete this; delete this;
} }
bool GuiGamelistFilter::input(InputConfig* config, Input input) bool GuiGamelistFilter::input(InputConfig* config, Input input)

View file

@ -25,7 +25,7 @@ private:
void applyFilters(); void applyFilters();
void resetAllFilters(); void resetAllFilters();
void addFiltersToMenu(); void addFiltersToMenu();
std::map<FilterIndexType, std::shared_ptr< OptionListComponent<std::string> >> mFilterOptions; std::map<FilterIndexType, std::shared_ptr< OptionListComponent<std::string> >> mFilterOptions;
MenuComponent mMenu; MenuComponent mMenu;

View file

@ -3,7 +3,7 @@
#include "views/gamelist/IGameListView.h" #include "views/gamelist/IGameListView.h"
#include "views/ViewController.h" #include "views/ViewController.h"
GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) : GuiComponent(window), GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) : GuiComponent(window),
mSystem(system), mMenu(window, "OPTIONS"), fromPlaceholder(false), mFiltersChanged(false) mSystem(system), mMenu(window, "OPTIONS"), fromPlaceholder(false), mFiltersChanged(false)
{ {
addChild(&mMenu); addChild(&mMenu);
@ -95,8 +95,8 @@ GuiGamelistOptions::~GuiGamelistOptions()
// notify that the root folder was sorted // notify that the root folder was sorted
getGamelist()->onFileChanged(root, FILE_SORTED); getGamelist()->onFileChanged(root, FILE_SORTED);
} }
if (mFiltersChanged) if (mFiltersChanged)
{ {
if (!fromPlaceholder) { if (!fromPlaceholder) {
FileData* root = getGamelist()->getCursor()->getSystem()->getRootFolder(); FileData* root = getGamelist()->getCursor()->getSystem()->getRootFolder();
@ -108,7 +108,7 @@ GuiGamelistOptions::~GuiGamelistOptions()
// as we need to re-display the remaining elements for whatever new // as we need to re-display the remaining elements for whatever new
// game is selected // game is selected
ViewController::get()->reloadGameListView(mSystem); ViewController::get()->reloadGameListView(mSystem);
} }
} }
} }
@ -117,7 +117,7 @@ void GuiGamelistOptions::openGamelistFilter()
mFiltersChanged = true; mFiltersChanged = true;
GuiGamelistFilter* ggf = new GuiGamelistFilter(mWindow, mSystem); GuiGamelistFilter* ggf = new GuiGamelistFilter(mWindow, mSystem);
mWindow->pushGui(ggf); mWindow->pushGui(ggf);
} }
void GuiGamelistOptions::openMetaDataEd() void GuiGamelistOptions::openMetaDataEd()
{ {
@ -140,7 +140,7 @@ void GuiGamelistOptions::openMetaDataEd()
}; };
} }
mWindow->pushGui(new GuiMetaDataEd(mWindow, &file->metadata, file->metadata.getMDD(), p, file->getPath().filename().string(), mWindow->pushGui(new GuiMetaDataEd(mWindow, &file->metadata, file->metadata.getMDD(), p, file->getPath().filename().string(),
std::bind(&IGameListView::onFileChanged, getGamelist(), file, FILE_METADATA_CHANGED), deleteBtnFunc)); std::bind(&IGameListView::onFileChanged, getGamelist(), file, FILE_METADATA_CHANGED), deleteBtnFunc));
} }
@ -151,7 +151,7 @@ void GuiGamelistOptions::jumpToLetter()
// this is a really shitty way to get a list of files // this is a really shitty way to get a list of files
const std::vector<FileData*>& files = gamelist->getCursor()->getParent()->getChildren(); const std::vector<FileData*>& files = gamelist->getCursor()->getParent()->getChildren();
long min = 0; long min = 0;
long max = files.size() - 1; long max = files.size() - 1;
long mid = 0; long mid = 0;

View file

@ -19,7 +19,7 @@ private:
void openGamelistFilter(); void openGamelistFilter();
void openMetaDataEd(); void openMetaDataEd();
void jumpToLetter(); void jumpToLetter();
MenuComponent mMenu; MenuComponent mMenu;
typedef OptionListComponent<char> LetterList; typedef OptionListComponent<char> LetterList;
@ -27,7 +27,7 @@ private:
typedef OptionListComponent<const FileData::SortType*> SortList; typedef OptionListComponent<const FileData::SortType*> SortList;
std::shared_ptr<SortList> mListSort; std::shared_ptr<SortList> mListSort;
SystemData* mSystem; SystemData* mSystem;
IGameListView* getGamelist(); IGameListView* getGamelist();
bool fromPlaceholder; bool fromPlaceholder;

View file

@ -15,24 +15,24 @@
using namespace Eigen; using namespace Eigen;
GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector<MetaDataDecl>& mdd, ScraperSearchParams scraperParams, GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector<MetaDataDecl>& mdd, ScraperSearchParams scraperParams,
const std::string& header, std::function<void()> saveCallback, std::function<void()> deleteFunc) : GuiComponent(window), const std::string& header, std::function<void()> saveCallback, std::function<void()> deleteFunc) : GuiComponent(window),
mScraperParams(scraperParams), mScraperParams(scraperParams),
mBackground(window, ":/frame.png"), mBackground(window, ":/frame.png"),
mGrid(window, Vector2i(1, 3)), mGrid(window, Vector2i(1, 3)),
mMetaDataDecl(mdd), mMetaDataDecl(mdd),
mMetaData(md), mMetaData(md),
mSavedCallback(saveCallback), mDeleteFunc(deleteFunc) mSavedCallback(saveCallback), mDeleteFunc(deleteFunc)
{ {
addChild(&mBackground); addChild(&mBackground);
addChild(&mGrid); addChild(&mGrid);
mHeaderGrid = std::make_shared<ComponentGrid>(mWindow, Vector2i(1, 5)); mHeaderGrid = std::make_shared<ComponentGrid>(mWindow, Vector2i(1, 5));
mTitle = std::make_shared<TextComponent>(mWindow, "EDIT METADATA", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER); mTitle = std::make_shared<TextComponent>(mWindow, "EDIT METADATA", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER);
mSubtitle = std::make_shared<TextComponent>(mWindow, strToUpper(scraperParams.game->getPath().filename().generic_string()), mSubtitle = std::make_shared<TextComponent>(mWindow, strToUpper(scraperParams.game->getPath().filename().generic_string()),
Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER); Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER);
mHeaderGrid->setEntry(mTitle, Vector2i(0, 1), false, true); mHeaderGrid->setEntry(mTitle, Vector2i(0, 1), false, true);
mHeaderGrid->setEntry(mSubtitle, Vector2i(0, 3), false, true); mHeaderGrid->setEntry(mSubtitle, Vector2i(0, 3), false, true);
@ -101,7 +101,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector
// MD_STRING // MD_STRING
ed = std::make_shared<TextComponent>(window, "", Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), 0x777777FF, ALIGN_RIGHT); ed = std::make_shared<TextComponent>(window, "", Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), 0x777777FF, ALIGN_RIGHT);
row.addElement(ed, true); row.addElement(ed, true);
auto spacer = std::make_shared<GuiComponent>(mWindow); auto spacer = std::make_shared<GuiComponent>(mWindow);
spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0); spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0);
row.addElement(spacer, false); row.addElement(spacer, false);
@ -236,7 +236,7 @@ void GuiMetaDataEd::close(bool closeAllWindows)
if(dirty) if(dirty)
{ {
// changes were made, ask if the user wants to save them // changes were made, ask if the user wants to save them
mWindow->pushGui(new GuiMsgBox(mWindow, mWindow->pushGui(new GuiMsgBox(mWindow,
"SAVE CHANGES?", "SAVE CHANGES?",
"YES", [this, closeFunc] { save(); closeFunc(); }, "YES", [this, closeFunc] { save(); closeFunc(); },
"NO", closeFunc "NO", closeFunc

View file

@ -127,10 +127,10 @@ void ViewController::goToRandomGame()
if ((*it)->getName() != "retropie") if ((*it)->getName() != "retropie")
total += (*it)->getDisplayedGameCount(); total += (*it)->getDisplayedGameCount();
} }
// get random number in range // get random number in range
int target = std::round(((double)std::rand() / (double)RAND_MAX) * total); int target = std::round(((double)std::rand() / (double)RAND_MAX) * total);
for (auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); it++) for (auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); it++)
{ {
if ((*it)->getName() != "retropie") if ((*it)->getName() != "retropie")
@ -153,7 +153,7 @@ void ViewController::goToRandomGame()
void ViewController::playViewTransition() void ViewController::playViewTransition()
{ {
Eigen::Vector3f target(Eigen::Vector3f::Identity()); Eigen::Vector3f target(Eigen::Vector3f::Identity());
if(mCurrentView) if(mCurrentView)
target = mCurrentView->getPosition(); target = mCurrentView->getPosition();
// no need to animate, we're not going anywhere (probably goToNextGamelist() or goToPrevGamelist() when there's only 1 system) // no need to animate, we're not going anywhere (probably goToNextGamelist() or goToPrevGamelist() when there's only 1 system)
@ -238,7 +238,7 @@ void ViewController::launch(FileData* game, Eigen::Vector3f center)
}); });
}else{ }else{
// move camera to zoom in on center + fade out, launch game, come back in // move camera to zoom in on center + fade out, launch game, come back in
setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 1500), 0, [this, origCamera, center, game] setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 1500), 0, [this, origCamera, center, game]
{ {
game->getSystem()->launchGame(mWindow, game); game->getSystem()->launchGame(mWindow, game);
mCamera = origCamera; mCamera = origCamera;
@ -372,7 +372,7 @@ void ViewController::render(const Eigen::Affine3f& parentTrans)
// draw systemview // draw systemview
getSystemListView()->render(trans); getSystemListView()->render(trans);
// draw gamelists // draw gamelists
for(auto it = mGameListViews.begin(); it != mGameListViews.end(); it++) for(auto it = mGameListViews.begin(); it != mGameListViews.end(); it++)
{ {
@ -477,7 +477,7 @@ std::vector<HelpPrompt> ViewController::getHelpPrompts()
std::vector<HelpPrompt> prompts; std::vector<HelpPrompt> prompts;
if(!mCurrentView) if(!mCurrentView)
return prompts; return prompts;
prompts = mCurrentView->getHelpPrompts(); prompts = mCurrentView->getHelpPrompts();
prompts.push_back(HelpPrompt("start", "menu")); prompts.push_back(HelpPrompt("start", "menu"));

View file

@ -80,7 +80,7 @@ void BasicGameListView::setCursor(FileData* cursor)
tmp.push(ptr); tmp.push(ptr);
ptr = ptr->getParent(); ptr = ptr->getParent();
} }
// flip the stack and put it in mCursorStack // flip the stack and put it in mCursorStack
mCursorStack = std::stack<FileData*>(); mCursorStack = std::stack<FileData*>();
while(!tmp.empty()) while(!tmp.empty())

View file

@ -12,7 +12,7 @@ ISimpleGameListView::ISimpleGameListView(Window* window, FileData* root) : IGame
mHeaderText.setSize(mSize.x(), 0); mHeaderText.setSize(mSize.x(), 0);
mHeaderText.setPosition(0, 0); mHeaderText.setPosition(0, 0);
mHeaderText.setAlignment(ALIGN_CENTER); mHeaderText.setAlignment(ALIGN_CENTER);
mHeaderImage.setResize(0, mSize.y() * 0.185f); mHeaderImage.setResize(0, mSize.y() * 0.185f);
mHeaderImage.setOrigin(0.5f, 0.0f); mHeaderImage.setOrigin(0.5f, 0.0f);
mHeaderImage.setPosition(mSize.x() / 2, 0); mHeaderImage.setPosition(mSize.x() / 2, 0);
@ -51,7 +51,7 @@ void ISimpleGameListView::onFileChanged(FileData* file, FileChangeType change)
populateList(cursor->getParent()->getChildrenListToDisplay()); populateList(cursor->getParent()->getChildrenListToDisplay());
setCursor(cursor); setCursor(cursor);
} }
else else
{ {
populateList(mRoot->getChildrenListToDisplay()); populateList(mRoot->getChildrenListToDisplay());
setCursor(cursor); setCursor(cursor);
@ -77,7 +77,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
populateList(cursor->getChildrenListToDisplay()); populateList(cursor->getChildrenListToDisplay());
} }
} }
return true; return true;
}else if(config->isMappedTo("b", input)) }else if(config->isMappedTo("b", input))
{ {

View file

@ -6,17 +6,17 @@
#include <fcntl.h> #include <fcntl.h>
VideoGameListView::VideoGameListView(Window* window, FileData* root) : VideoGameListView::VideoGameListView(Window* window, FileData* root) :
BasicGameListView(window, root), BasicGameListView(window, root),
mDescContainer(window), mDescription(window), mDescContainer(window), mDescription(window),
mMarquee(window), mMarquee(window),
mImage(window), mImage(window),
mVideo(window), mVideo(window),
mVideoPlaying(false), mVideoPlaying(false),
mLblRating(window), mLblReleaseDate(window), mLblDeveloper(window), mLblPublisher(window), mLblRating(window), mLblReleaseDate(window), mLblDeveloper(window), mLblPublisher(window),
mLblGenre(window), mLblPlayers(window), mLblLastPlayed(window), mLblPlayCount(window), mLblGenre(window), mLblPlayers(window), mLblLastPlayed(window), mLblPlayCount(window),
mRating(window), mReleaseDate(window), mDeveloper(window), mPublisher(window), mRating(window), mReleaseDate(window), mDeveloper(window), mPublisher(window),
mGenre(window), mPlayers(window), mLastPlayed(window), mPlayCount(window) mGenre(window), mPlayers(window), mLastPlayed(window), mPlayCount(window)
{ {
const float padding = 0.01f; const float padding = 0.01f;
@ -151,7 +151,7 @@ void VideoGameListView::initMDLabels()
const unsigned int rowCount = components.size() / 2; const unsigned int rowCount = components.size() / 2;
Vector3f start(mSize.x() * 0.01f, mSize.y() * 0.625f, 0.0f); Vector3f start(mSize.x() * 0.01f, mSize.y() * 0.625f, 0.0f);
const float colSize = (mSize.x() * 0.48f) / colCount; const float colSize = (mSize.x() * 0.48f) / colCount;
const float rowPadding = 0.01f * mSize.y(); const float rowPadding = 0.01f * mSize.y();
@ -266,13 +266,13 @@ void VideoGameListView::updateInfoPanel()
mPublisher.setValue(file->metadata.get("publisher")); mPublisher.setValue(file->metadata.get("publisher"));
mGenre.setValue(file->metadata.get("genre")); mGenre.setValue(file->metadata.get("genre"));
mPlayers.setValue(file->metadata.get("players")); mPlayers.setValue(file->metadata.get("players"));
if(file->getType() == GAME) if(file->getType() == GAME)
{ {
mLastPlayed.setValue(file->metadata.get("lastplayed")); mLastPlayed.setValue(file->metadata.get("lastplayed"));
mPlayCount.setValue(file->metadata.get("playcount")); mPlayCount.setValue(file->metadata.get("playcount"));
} }
fadingOut = false; fadingOut = false;
} }
@ -291,7 +291,7 @@ void VideoGameListView::updateInfoPanel()
// then animate if reverse != fadingOut // then animate if reverse != fadingOut
// an animation is not playing // an animation is not playing
// then animate if opacity != our target opacity // then animate if opacity != our target opacity
if((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) || if((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) ||
(!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) (!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255)))
{ {
auto func = [comp](float t) auto func = [comp](float t)

View file

@ -121,7 +121,7 @@ void ComponentList::onCursorChanged(const CursorState& state)
{ {
for(auto it = mEntries.begin(); it != mEntries.end(); it++) for(auto it = mEntries.begin(); it != mEntries.end(); it++)
it->data.elements.back().component->onFocusLost(); it->data.elements.back().component->onFocusLost();
mEntries.at(mCursor).data.elements.back().component->onFocusGained(); mEntries.at(mCursor).data.elements.back().component->onFocusGained();
} }
@ -167,7 +167,7 @@ void ComponentList::render(const Eigen::Affine3f& parentTrans)
// clip everything to be inside our bounds // clip everything to be inside our bounds
Eigen::Vector3f dim(mSize.x(), mSize.y(), 0); Eigen::Vector3f dim(mSize.x(), mSize.y(), 0);
dim = trans * dim - trans.translation(); dim = trans * dim - trans.translation();
Renderer::pushClipRect(Eigen::Vector2i((int)trans.translation().x(), (int)trans.translation().y()), Renderer::pushClipRect(Eigen::Vector2i((int)trans.translation().x(), (int)trans.translation().y()),
Eigen::Vector2i((int)round(dim.x()), (int)round(dim.y() + 1))); Eigen::Vector2i((int)round(dim.x()), (int)round(dim.y() + 1)));
// scroll the camera // scroll the camera
@ -201,20 +201,20 @@ void ComponentList::render(const Eigen::Affine3f& parentTrans)
// need a function that goes roughly 0x777777 -> 0xFFFFFF // need a function that goes roughly 0x777777 -> 0xFFFFFF
// and 0xFFFFFF -> 0x777777 // and 0xFFFFFF -> 0x777777
// (1 - dst) + 0x77 // (1 - dst) + 0x77
const float selectedRowHeight = getRowHeight(mEntries.at(mCursor).data); const float selectedRowHeight = getRowHeight(mEntries.at(mCursor).data);
Renderer::drawRect(0.0f, mSelectorBarOffset, mSize.x(), selectedRowHeight, 0xFFFFFFFF, Renderer::drawRect(0.0f, mSelectorBarOffset, mSize.x(), selectedRowHeight, 0xFFFFFFFF,
GL_ONE_MINUS_DST_COLOR, GL_ZERO); GL_ONE_MINUS_DST_COLOR, GL_ZERO);
Renderer::drawRect(0.0f, mSelectorBarOffset, mSize.x(), selectedRowHeight, 0x777777FF, Renderer::drawRect(0.0f, mSelectorBarOffset, mSize.x(), selectedRowHeight, 0x777777FF,
GL_ONE, GL_ONE); GL_ONE, GL_ONE);
// hack to draw 2px dark on left/right of the bar // hack to draw 2px dark on left/right of the bar
Renderer::drawRect(0.0f, mSelectorBarOffset, 2.0f, selectedRowHeight, 0x878787FF); Renderer::drawRect(0.0f, mSelectorBarOffset, 2.0f, selectedRowHeight, 0x878787FF);
Renderer::drawRect(mSize.x() - 2.0f, mSelectorBarOffset, 2.0f, selectedRowHeight, 0x878787FF); Renderer::drawRect(mSize.x() - 2.0f, mSelectorBarOffset, 2.0f, selectedRowHeight, 0x878787FF);
for(auto it = drawAfterCursor.begin(); it != drawAfterCursor.end(); it++) for(auto it = drawAfterCursor.begin(); it != drawAfterCursor.end(); it++)
(*it)->render(trans); (*it)->render(trans);
// reset matrix if one of these components changed it // reset matrix if one of these components changed it
if(drawAfterCursor.size()) if(drawAfterCursor.size())
Renderer::setMatrix(trans); Renderer::setMatrix(trans);
@ -335,7 +335,7 @@ std::vector<HelpPrompt> ComponentList::getHelpPrompts()
bool ComponentList::moveCursor(int amt) bool ComponentList::moveCursor(int amt)
{ {
bool ret = listInput(amt); bool ret = listInput(amt);
listInput(0); listInput(0);
return ret; return ret;
} }

View file

@ -138,7 +138,7 @@ private:
}; };
public: public:
OptionListComponent(Window* window, const std::string& name, bool multiSelect = false) : GuiComponent(window), mMultiSelect(multiSelect), mName(name), OptionListComponent(Window* window, const std::string& name, bool multiSelect = false) : GuiComponent(window), mMultiSelect(multiSelect), mName(name),
mText(window), mLeftArrow(window), mRightArrow(window) mText(window), mLeftArrow(window), mRightArrow(window)
{ {
auto font = Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT); auto font = Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT);
@ -251,20 +251,20 @@ public:
onSelectedChanged(); onSelectedChanged();
} }
void selectAll() void selectAll()
{ {
for(unsigned int i = 0; i < mEntries.size(); i++) for(unsigned int i = 0; i < mEntries.size(); i++)
{ {
mEntries.at(i).selected = true; mEntries.at(i).selected = true;
} }
onSelectedChanged(); onSelectedChanged();
} }
void selectNone() void selectNone()
{ {
for(unsigned int i = 0; i < mEntries.size(); i++) for(unsigned int i = 0; i < mEntries.size(); i++)
{ {
mEntries.at(i).selected = false; mEntries.at(i).selected = false;
} }
onSelectedChanged(); onSelectedChanged();
} }
@ -322,7 +322,7 @@ private:
std::vector<HelpPrompt> prompts; std::vector<HelpPrompt> prompts;
if(!mMultiSelect) if(!mMultiSelect)
prompts.push_back(HelpPrompt("left/right", "change")); prompts.push_back(HelpPrompt("left/right", "change"));
prompts.push_back(HelpPrompt("a", "select")); prompts.push_back(HelpPrompt("a", "select"));
return prompts; return prompts;
} }