mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 06:05:38 +00:00
Code cleanup and code documentation
This commit is contained in:
parent
ac91da6995
commit
672026632d
|
@ -18,11 +18,12 @@ Some key points:
|
||||||
* Comments should be proper sentences, starting with a capital letter and ending with a dot
|
* Comments should be proper sentences, starting with a capital letter and ending with a dot
|
||||||
* Use K&R placements of braces, read the Linux Kernel coding style document for clarifications
|
* Use K&R placements of braces, read the Linux Kernel coding style document for clarifications
|
||||||
* Always use spaces between keywords and opening brackets, i.e. `if ()`, `for ()`, `while ()` etc.
|
* Always use spaces between keywords and opening brackets, i.e. `if ()`, `for ()`, `while ()` etc.
|
||||||
* Use `std::string` instead of `char *` or `char []` unless there is a very specific reason not to
|
* Use `std::string` instead of `char *` or `char []` unless there is a very specific reason requiring the latter
|
||||||
* If the arguments (and initializer list) for a function or class exceeds 4 items, arrange them vertically to make the code easier to read
|
* If the arguments (and initializer list) for a function or class exceeds 4 items, arrange them vertically to make the code easier to read
|
||||||
* Always declare one variable per line, never combine multiple declarations of the same type
|
* Always declare one variable per line, never combine multiple declarations of the same type
|
||||||
* Name local variables with the first word in small letters and the proceeding words starting with capital letters, e.g. myExampleVariable
|
* Name local variables with the first word in small letters and the proceeding words starting with capital letters, e.g. myExampleVariable
|
||||||
* Name member variables starting with a small 'm', e.g. mMyMemberVariable
|
* Name member variables starting with a small 'm', e.g. mMyMemberVariable
|
||||||
|
* Don't pad variable declarations with spaces to make them align in columns, I'm sure it's well intended but it looks terrible
|
||||||
* Use the same naming convention for functions as for local variables, e.g. someFunction()
|
* Use the same naming convention for functions as for local variables, e.g. someFunction()
|
||||||
* Inline functions can be used but don't overdo it by using them for functions that won't be called very frequently
|
* Inline functions can be used but don't overdo it by using them for functions that won't be called very frequently
|
||||||
* Never put more than one statement on a single line, except for lambda expressions
|
* Never put more than one statement on a single line, except for lambda expressions
|
||||||
|
|
1
NEWS.md
1
NEWS.md
|
@ -31,4 +31,5 @@ v1.0.0
|
||||||
* Game images were sometimes scaled incorrectly
|
* Game images were sometimes scaled incorrectly
|
||||||
* Non-transparent favorite icons were not rendered correctly
|
* Non-transparent favorite icons were not rendered correctly
|
||||||
* Restart and power-off menu entries not working (i.e. on a desktop OS)
|
* Restart and power-off menu entries not working (i.e. on a desktop OS)
|
||||||
|
* Toggling the screensaver didn't work as expected
|
||||||
* Lots and lots of small bugs and inconsistencies fixed
|
* Lots and lots of small bugs and inconsistencies fixed
|
||||||
|
|
14
README.md
14
README.md
|
@ -3,26 +3,22 @@ EmulationStation Desktop Edition
|
||||||
|
|
||||||
EmulationStation Desktop Edition is a cross-platform graphical front-end for emulators with controller and keyboard navigation.
|
EmulationStation Desktop Edition is a cross-platform graphical front-end for emulators with controller and keyboard navigation.
|
||||||
|
|
||||||
This is a fork intended for use primarily on desktop computers where EmulationStation is not the primary interface for the computer.
|
This is a fork intended for use primarily on desktop computers where EmulationStation is not the primary interface for the computer. As such, this software will not provide full control over emulator settings or emulator button mappings or provide system utility functions and similar. Instead it's assumed that the emulators and the overall environment has been properly configured upfront.
|
||||||
|
|
||||||
As such, this fork will not provide full control over emulator settings or emulator button mappings or provide system utility functions and similar. Instead it's assumed that the emulators and the overall environment has been properly configured upfront.
|
|
||||||
|
|
||||||
The software comes preconfigured for use primarily with [RetroArch](https://www.retroarch.com), although this can certainly be changed as all emulator settings are fully configurable, even on a per-game basis.
|
The software comes preconfigured for use primarily with [RetroArch](https://www.retroarch.com), although this can certainly be changed as all emulator settings are fully configurable, even on a per-game basis.
|
||||||
|
|
||||||
** Help needed: **
|
**Help needed:**
|
||||||
|
|
||||||
Apart from code commits, help is especially needed for thorough testing of the software and for working on the RBSimple-DE theme.
|
Apart from code commits, help is especially needed for thorough testing of the software and for working on the RBSimple-DE theme.
|
||||||
|
|
||||||
It's impossible for me to test every game system (RBSimple-DE has support for almost a 100 different systems!) so it would be especially useful to hear about any issues with starting games using the default es_systems.cfg configuration file and also if there are any issues regarding scraping for certain systems.
|
It's impossible for me to test every game system (RBSimple-DE has support for almost a 100 different systems!) so it would be especially useful to hear about any issues with starting games using the default es_systems.cfg configuration file and also if there are any issues regarding scraping for certain systems.
|
||||||
|
|
||||||
In general, a review of the es_systems.cfg file including the supported file extensions would be great:
|
In general, a review of the [es_systems.cfg](resources/templates/es_systems.cfg_unix) file including the supported file extensions would be great.
|
||||||
|
|
||||||
[es_systems.cfg_unix](resources/templates/es_systems.cfg_unix
|
|
||||||
|
|
||||||
As for RBSimple-DE there are quite some missing graphic files and other customizations for a number of game systems. \
|
As for RBSimple-DE there are quite some missing graphic files and other customizations for a number of game systems. \
|
||||||
Check out [MISSING.md](themes/rbsimple-DE/MISSING.md) for more details of what needs to be added.
|
Check out [MISSING.md](themes/rbsimple-DE/MISSING.md) for more details of what needs to be added.
|
||||||
|
|
||||||
Finally, if someone could make a proper port to the Macintosh Operating System, that would be great as then all of the three major desktop operating systems would be supported! There is some code present specifically for macOS but I've been unable to test it.
|
Finally, if someone could make a proper port to the Macintosh Operating System, that would be great as then all of the three major desktop operating systems would be supported. There is some code present specifically for macOS but I've been unable to test it.
|
||||||
|
|
||||||
|
|
||||||
General information
|
General information
|
||||||
|
@ -34,8 +30,6 @@ General information
|
||||||
|
|
||||||
[DEVNOTES.md](DEVNOTES.md) is the place to go if you're interested in participating in the development of EmulationStation Desktop Edition.
|
[DEVNOTES.md](DEVNOTES.md) is the place to go if you're interested in participating in the development of EmulationStation Desktop Edition.
|
||||||
|
|
||||||
Or just go ahead and browse the repository for additional information, or maybe more important, to see the actual source code :)
|
|
||||||
|
|
||||||
|
|
||||||
What it can do
|
What it can do
|
||||||
==============
|
==============
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
//
|
||||||
|
// FileFilterIndex.cpp
|
||||||
|
//
|
||||||
|
// Gamelist filters.
|
||||||
|
//
|
||||||
|
|
||||||
#include "FileFilterIndex.h"
|
#include "FileFilterIndex.h"
|
||||||
|
|
||||||
#include "utils/StringUtil.h"
|
#include "utils/StringUtil.h"
|
||||||
|
@ -10,528 +16,499 @@
|
||||||
#define INCLUDE_UNKNOWN false;
|
#define INCLUDE_UNKNOWN false;
|
||||||
|
|
||||||
FileFilterIndex::FileFilterIndex()
|
FileFilterIndex::FileFilterIndex()
|
||||||
: filterByFavorites(false), filterByGenre(false), filterByHidden(false), filterByKidGame(false), filterByPlayers(false), filterByPubDev(false), filterByRatings(false)
|
: filterByFavorites(false),
|
||||||
|
filterByGenre(false),
|
||||||
|
filterByHidden(false),
|
||||||
|
filterByKidGame(false),
|
||||||
|
filterByPlayers(false),
|
||||||
|
filterByPubDev(false),
|
||||||
|
filterByRatings(false)
|
||||||
{
|
{
|
||||||
clearAllFilters();
|
clearAllFilters();
|
||||||
FilterDataDecl filterDecls[] = {
|
|
||||||
//type //allKeys //filteredBy //filteredKeys //primaryKey //hasSecondaryKey //secondaryKey //menuLabel
|
|
||||||
{ FAVORITES_FILTER, &favoritesIndexAllKeys, &filterByFavorites, &favoritesIndexFilteredKeys,"favorite", false, "", "FAVORITES" },
|
|
||||||
{ GENRE_FILTER, &genreIndexAllKeys, &filterByGenre, &genreIndexFilteredKeys, "genre", true, "genre", "GENRE" },
|
|
||||||
{ PLAYER_FILTER, &playersIndexAllKeys, &filterByPlayers, &playersIndexFilteredKeys, "players", false, "", "PLAYERS" },
|
|
||||||
{ PUBDEV_FILTER, &pubDevIndexAllKeys, &filterByPubDev, &pubDevIndexFilteredKeys, "developer", true, "publisher", "PUBLISHER / DEVELOPER" },
|
|
||||||
{ RATINGS_FILTER, &ratingsIndexAllKeys, &filterByRatings, &ratingsIndexFilteredKeys, "rating", false, "", "RATING" },
|
|
||||||
{ KIDGAME_FILTER, &kidGameIndexAllKeys, &filterByKidGame, &kidGameIndexFilteredKeys, "kidgame", false, "", "KIDGAME" },
|
|
||||||
{ HIDDEN_FILTER, &hiddenIndexAllKeys, &filterByHidden, &hiddenIndexFilteredKeys, "hidden", false, "", "HIDDEN" }
|
|
||||||
};
|
|
||||||
|
|
||||||
filterDataDecl = std::vector<FilterDataDecl>(filterDecls, filterDecls + sizeof(filterDecls) / sizeof(filterDecls[0]));
|
FilterDataDecl filterDecls[] = {
|
||||||
|
//type //allKeys //filteredBy //filteredKeys //primaryKey //hasSecondaryKey //secondaryKey //menuLabel
|
||||||
|
{ FAVORITES_FILTER, &favoritesIndexAllKeys, &filterByFavorites, &favoritesIndexFilteredKeys,"favorite", false, "", "FAVORITES" },
|
||||||
|
{ GENRE_FILTER, &genreIndexAllKeys, &filterByGenre, &genreIndexFilteredKeys, "genre", true, "genre", "GENRE" },
|
||||||
|
{ PLAYER_FILTER, &playersIndexAllKeys, &filterByPlayers, &playersIndexFilteredKeys, "players", false, "", "PLAYERS" },
|
||||||
|
{ PUBDEV_FILTER, &pubDevIndexAllKeys, &filterByPubDev, &pubDevIndexFilteredKeys, "developer", true, "publisher", "PUBLISHER / DEVELOPER" },
|
||||||
|
{ RATINGS_FILTER, &ratingsIndexAllKeys, &filterByRatings, &ratingsIndexFilteredKeys, "rating", false, "", "RATING" },
|
||||||
|
{ KIDGAME_FILTER, &kidGameIndexAllKeys, &filterByKidGame, &kidGameIndexFilteredKeys, "kidgame", false, "", "KIDGAME" },
|
||||||
|
{ HIDDEN_FILTER, &hiddenIndexAllKeys, &filterByHidden, &hiddenIndexFilteredKeys, "hidden", false, "", "HIDDEN" }
|
||||||
|
};
|
||||||
|
|
||||||
|
filterDataDecl = std::vector<FilterDataDecl>(filterDecls, filterDecls +
|
||||||
|
sizeof(filterDecls) / sizeof(filterDecls[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
FileFilterIndex::~FileFilterIndex()
|
FileFilterIndex::~FileFilterIndex()
|
||||||
{
|
{
|
||||||
resetIndex();
|
resetIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<FilterDataDecl>& FileFilterIndex::getFilterDataDecls()
|
std::vector<FilterDataDecl>& FileFilterIndex::getFilterDataDecls()
|
||||||
{
|
{
|
||||||
return filterDataDecl;
|
return filterDataDecl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::importIndex(FileFilterIndex* indexToImport)
|
void FileFilterIndex::importIndex(FileFilterIndex* indexToImport)
|
||||||
{
|
{
|
||||||
struct IndexImportStructure
|
struct IndexImportStructure {
|
||||||
{
|
std::map<std::string, int>* destinationIndex;
|
||||||
std::map<std::string, int>* destinationIndex;
|
std::map<std::string, int>* sourceIndex;
|
||||||
std::map<std::string, int>* sourceIndex;
|
};
|
||||||
};
|
|
||||||
|
|
||||||
IndexImportStructure indexStructDecls[] = {
|
IndexImportStructure indexStructDecls[] = {
|
||||||
{ &genreIndexAllKeys, &(indexToImport->genreIndexAllKeys) },
|
{ &genreIndexAllKeys, &(indexToImport->genreIndexAllKeys) },
|
||||||
{ &playersIndexAllKeys, &(indexToImport->playersIndexAllKeys) },
|
{ &playersIndexAllKeys, &(indexToImport->playersIndexAllKeys) },
|
||||||
{ &pubDevIndexAllKeys, &(indexToImport->pubDevIndexAllKeys) },
|
{ &pubDevIndexAllKeys, &(indexToImport->pubDevIndexAllKeys) },
|
||||||
{ &ratingsIndexAllKeys, &(indexToImport->ratingsIndexAllKeys) },
|
{ &ratingsIndexAllKeys, &(indexToImport->ratingsIndexAllKeys) },
|
||||||
{ &favoritesIndexAllKeys, &(indexToImport->favoritesIndexAllKeys) },
|
{ &favoritesIndexAllKeys, &(indexToImport->favoritesIndexAllKeys) },
|
||||||
{ &hiddenIndexAllKeys, &(indexToImport->hiddenIndexAllKeys) },
|
{ &hiddenIndexAllKeys, &(indexToImport->hiddenIndexAllKeys) },
|
||||||
{ &kidGameIndexAllKeys, &(indexToImport->kidGameIndexAllKeys) },
|
{ &kidGameIndexAllKeys, &(indexToImport->kidGameIndexAllKeys) },
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<IndexImportStructure> indexImportDecl = std::vector<IndexImportStructure>(indexStructDecls, indexStructDecls + sizeof(indexStructDecls) / sizeof(indexStructDecls[0]));
|
std::vector<IndexImportStructure> indexImportDecl =
|
||||||
|
std::vector<IndexImportStructure>(indexStructDecls, indexStructDecls +
|
||||||
|
sizeof(indexStructDecls) / sizeof(indexStructDecls[0]));
|
||||||
|
|
||||||
for (std::vector<IndexImportStructure>::const_iterator indexesIt = indexImportDecl.cbegin(); indexesIt != indexImportDecl.cend(); ++indexesIt )
|
for (std::vector<IndexImportStructure>::const_iterator indexesIt =
|
||||||
{
|
indexImportDecl.cbegin(); indexesIt != indexImportDecl.cend(); ++indexesIt )
|
||||||
for (std::map<std::string, int>::const_iterator sourceIt = (*indexesIt).sourceIndex->cbegin(); sourceIt != (*indexesIt).sourceIndex->cend(); ++sourceIt )
|
{
|
||||||
{
|
for (std::map<std::string, int>::const_iterator sourceIt =
|
||||||
if ((*indexesIt).destinationIndex->find((*sourceIt).first) == (*indexesIt).destinationIndex->cend())
|
(*indexesIt).sourceIndex->cbegin(); sourceIt !=
|
||||||
{
|
(*indexesIt).sourceIndex->cend(); ++sourceIt ) {
|
||||||
// entry doesn't exist
|
if ((*indexesIt).destinationIndex->find((*sourceIt).first) ==
|
||||||
(*((*indexesIt).destinationIndex))[(*sourceIt).first] = (*sourceIt).second;
|
(*indexesIt).destinationIndex->cend())
|
||||||
}
|
// Entry doesn't exist.
|
||||||
else
|
(*((*indexesIt).destinationIndex))[(*sourceIt).first] = (*sourceIt).second;
|
||||||
{
|
else
|
||||||
(*((*indexesIt).destinationIndex))[(*sourceIt).first] += (*sourceIt).second;
|
(*((*indexesIt).destinationIndex))[(*sourceIt).first] += (*sourceIt).second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::resetIndex()
|
void FileFilterIndex::resetIndex()
|
||||||
{
|
{
|
||||||
clearAllFilters();
|
clearAllFilters();
|
||||||
clearIndex(genreIndexAllKeys);
|
clearIndex(genreIndexAllKeys);
|
||||||
clearIndex(playersIndexAllKeys);
|
clearIndex(playersIndexAllKeys);
|
||||||
clearIndex(pubDevIndexAllKeys);
|
clearIndex(pubDevIndexAllKeys);
|
||||||
clearIndex(ratingsIndexAllKeys);
|
clearIndex(ratingsIndexAllKeys);
|
||||||
clearIndex(favoritesIndexAllKeys);
|
clearIndex(favoritesIndexAllKeys);
|
||||||
clearIndex(hiddenIndexAllKeys);
|
clearIndex(hiddenIndexAllKeys);
|
||||||
clearIndex(kidGameIndexAllKeys);
|
clearIndex(kidGameIndexAllKeys);
|
||||||
}
|
}
|
||||||
|
|
||||||
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:
|
key = Utils::String::toUpper(game->metadata.get("genre"));
|
||||||
{
|
key = Utils::String::trim(key);
|
||||||
key = Utils::String::toUpper(game->metadata.get("genre"));
|
if (getSecondary && !key.empty()) {
|
||||||
key = Utils::String::trim(key);
|
std::istringstream f(key);
|
||||||
if (getSecondary && !key.empty()) {
|
std::string newKey;
|
||||||
std::istringstream f(key);
|
getline(f, newKey, '/');
|
||||||
std::string newKey;
|
if (!newKey.empty() && newKey != key)
|
||||||
getline(f, newKey, '/');
|
key = newKey;
|
||||||
if (!newKey.empty() && newKey != key)
|
else
|
||||||
{
|
key = std::string();
|
||||||
key = newKey;
|
}
|
||||||
}
|
break;
|
||||||
else
|
}
|
||||||
{
|
case PLAYER_FILTER: {
|
||||||
key = std::string();
|
if (getSecondary)
|
||||||
}
|
break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case PLAYER_FILTER:
|
|
||||||
{
|
|
||||||
if (getSecondary)
|
|
||||||
break;
|
|
||||||
|
|
||||||
key = game->metadata.get("players");
|
key = game->metadata.get("players");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PUBDEV_FILTER:
|
case PUBDEV_FILTER: {
|
||||||
{
|
key = Utils::String::toUpper(game->metadata.get("publisher"));
|
||||||
key = Utils::String::toUpper(game->metadata.get("publisher"));
|
key = Utils::String::trim(key);
|
||||||
key = Utils::String::trim(key);
|
|
||||||
|
|
||||||
if ((getSecondary && !key.empty()) || (!getSecondary && key.empty()))
|
if ((getSecondary && !key.empty()) || (!getSecondary && key.empty()))
|
||||||
key = Utils::String::toUpper(game->metadata.get("developer"));
|
key = Utils::String::toUpper(game->metadata.get("developer"));
|
||||||
else
|
else
|
||||||
key = Utils::String::toUpper(game->metadata.get("publisher"));
|
key = Utils::String::toUpper(game->metadata.get("publisher"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case RATINGS_FILTER:
|
case RATINGS_FILTER: {
|
||||||
{
|
int ratingNumber = 0;
|
||||||
int ratingNumber = 0;
|
if (!getSecondary) {
|
||||||
if (!getSecondary)
|
std::string ratingString = game->metadata.get("rating");
|
||||||
{
|
if (!ratingString.empty()) {
|
||||||
std::string ratingString = game->metadata.get("rating");
|
try {
|
||||||
if (!ratingString.empty()) {
|
ratingNumber = (int)((std::stod(ratingString)*5)+0.5);
|
||||||
try {
|
if (ratingNumber < 0)
|
||||||
ratingNumber = (int)((std::stod(ratingString)*5)+0.5);
|
ratingNumber = 0;
|
||||||
if (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, exception nr.): " <<
|
||||||
LOG(LogError) << "Error parsing Rating (invalid value, exception nr.): " << ratingString << ", " << e;
|
ratingString << ", " << e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FAVORITES_FILTER:
|
case FAVORITES_FILTER: {
|
||||||
{
|
if (game->getType() != GAME)
|
||||||
if (game->getType() != GAME)
|
return "FALSE";
|
||||||
return "FALSE";
|
key = Utils::String::toUpper(game->metadata.get("favorite"));
|
||||||
key = Utils::String::toUpper(game->metadata.get("favorite"));
|
break;
|
||||||
break;
|
}
|
||||||
}
|
case HIDDEN_FILTER: {
|
||||||
case HIDDEN_FILTER:
|
if (game->getType() != GAME)
|
||||||
{
|
return "FALSE";
|
||||||
if (game->getType() != GAME)
|
key = Utils::String::toUpper(game->metadata.get("hidden"));
|
||||||
return "FALSE";
|
break;
|
||||||
key = Utils::String::toUpper(game->metadata.get("hidden"));
|
}
|
||||||
break;
|
case KIDGAME_FILTER: {
|
||||||
}
|
if (game->getType() != GAME)
|
||||||
case KIDGAME_FILTER:
|
return "FALSE";
|
||||||
{
|
key = Utils::String::toUpper(game->metadata.get("kidgame"));
|
||||||
if (game->getType() != GAME)
|
break;
|
||||||
return "FALSE";
|
}
|
||||||
key = Utils::String::toUpper(game->metadata.get("kidgame"));
|
}
|
||||||
break;
|
key = Utils::String::trim(key);
|
||||||
}
|
if (key.empty() || (type == RATINGS_FILTER && key == "0 STARS")) {
|
||||||
}
|
key = UNKNOWN_LABEL;
|
||||||
key = Utils::String::trim(key);
|
}
|
||||||
if (key.empty() || (type == RATINGS_FILTER && key == "0 STARS")) {
|
return key;
|
||||||
key = UNKNOWN_LABEL;
|
|
||||||
}
|
|
||||||
return key;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::addToIndex(FileData* game)
|
void FileFilterIndex::addToIndex(FileData* game)
|
||||||
{
|
{
|
||||||
manageGenreEntryInIndex(game);
|
manageGenreEntryInIndex(game);
|
||||||
managePlayerEntryInIndex(game);
|
managePlayerEntryInIndex(game);
|
||||||
managePubDevEntryInIndex(game);
|
managePubDevEntryInIndex(game);
|
||||||
manageRatingsEntryInIndex(game);
|
manageRatingsEntryInIndex(game);
|
||||||
manageFavoritesEntryInIndex(game);
|
manageFavoritesEntryInIndex(game);
|
||||||
manageHiddenEntryInIndex(game);
|
manageHiddenEntryInIndex(game);
|
||||||
manageKidGameEntryInIndex(game);
|
manageKidGameEntryInIndex(game);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::removeFromIndex(FileData* game)
|
void FileFilterIndex::removeFromIndex(FileData* game)
|
||||||
{
|
{
|
||||||
manageGenreEntryInIndex(game, true);
|
manageGenreEntryInIndex(game, true);
|
||||||
managePlayerEntryInIndex(game, true);
|
managePlayerEntryInIndex(game, true);
|
||||||
managePubDevEntryInIndex(game, true);
|
managePubDevEntryInIndex(game, true);
|
||||||
manageRatingsEntryInIndex(game, true);
|
manageRatingsEntryInIndex(game, true);
|
||||||
manageFavoritesEntryInIndex(game, true);
|
manageFavoritesEntryInIndex(game, true);
|
||||||
manageHiddenEntryInIndex(game, true);
|
manageHiddenEntryInIndex(game, true);
|
||||||
manageKidGameEntryInIndex(game, true);
|
manageKidGameEntryInIndex(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) {
|
||||||
{
|
clearAllFilters();
|
||||||
clearAllFilters();
|
}
|
||||||
}
|
else {
|
||||||
else
|
for (std::vector<FilterDataDecl>::const_iterator it = filterDataDecl.cbegin();
|
||||||
{
|
it != filterDataDecl.cend(); ++it ) {
|
||||||
for (std::vector<FilterDataDecl>::const_iterator it = filterDataDecl.cbegin(); it != filterDataDecl.cend(); ++it ) {
|
if ((*it).type == type) {
|
||||||
if ((*it).type == type)
|
FilterDataDecl filterData = (*it);
|
||||||
{
|
*(filterData.filteredByRef) = values->size() > 0;
|
||||||
FilterDataDecl filterData = (*it);
|
filterData.currentFilteredKeys->clear();
|
||||||
*(filterData.filteredByRef) = values->size() > 0;
|
for (std::vector<std::string>::const_iterator vit =
|
||||||
filterData.currentFilteredKeys->clear();
|
values->cbegin(); vit != values->cend(); ++vit ) {
|
||||||
for (std::vector<std::string>::const_iterator vit = values->cbegin(); vit != values->cend(); ++vit ) {
|
// Check if exists.
|
||||||
// check if exists
|
if (filterData.allIndexKeys->find(*vit) != filterData.allIndexKeys->cend()) {
|
||||||
if (filterData.allIndexKeys->find(*vit) != filterData.allIndexKeys->cend()) {
|
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>::const_iterator it = filterDataDecl.cbegin(); it != filterDataDecl.cend(); ++it )
|
for (std::vector<FilterDataDecl>::const_iterator it = filterDataDecl.cbegin();
|
||||||
{
|
it != filterDataDecl.cend(); ++it ) {
|
||||||
FilterDataDecl filterData = (*it);
|
FilterDataDecl filterData = (*it);
|
||||||
*(filterData.filteredByRef) = false;
|
*(filterData.filteredByRef) = false;
|
||||||
filterData.currentFilteredKeys->clear();
|
filterData.currentFilteredKeys->clear();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::resetFilters()
|
void FileFilterIndex::resetFilters()
|
||||||
{
|
{
|
||||||
clearAllFilters();
|
clearAllFilters();
|
||||||
setUIModeFilters();
|
setUIModeFilters();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::setUIModeFilters()
|
void FileFilterIndex::setUIModeFilters()
|
||||||
{
|
{
|
||||||
if(!Settings::getInstance()->getBool("ForceDisableFilters")){
|
if (!Settings::getInstance()->getBool("ForceDisableFilters")){
|
||||||
if (UIModeController::getInstance()->isUIModeKiosk())
|
if (UIModeController::getInstance()->isUIModeKiosk()) {
|
||||||
{
|
filterByHidden = true;
|
||||||
filterByHidden = true;
|
std::vector<std::string> val = { "FALSE" };
|
||||||
std::vector<std::string> val = { "FALSE" };
|
setFilter(HIDDEN_FILTER, &val);
|
||||||
setFilter(HIDDEN_FILTER, &val);
|
}
|
||||||
}
|
if (UIModeController::getInstance()->isUIModeKid()) {
|
||||||
if (UIModeController::getInstance()->isUIModeKid())
|
filterByKidGame = true;
|
||||||
{
|
std::vector<std::string> val = { "TRUE" };
|
||||||
filterByKidGame = true;
|
setFilter(KIDGAME_FILTER, &val);
|
||||||
std::vector<std::string> val = { "TRUE" };
|
}
|
||||||
setFilter(KIDGAME_FILTER, &val);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
for (auto x: favoritesIndexAllKeys) {
|
for (auto x: favoritesIndexAllKeys) {
|
||||||
LOG(LogInfo) << "Favorites Index: " << x.first << ": " << x.second;
|
LOG(LogInfo) << "Favorites Index: " << x.first << ": " << x.second;
|
||||||
}
|
}
|
||||||
for (auto x : hiddenIndexAllKeys) {
|
for (auto x : hiddenIndexAllKeys) {
|
||||||
LOG(LogInfo) << "Hidden Index: " << x.first << ": " << x.second;
|
LOG(LogInfo) << "Hidden Index: " << x.first << ": " << x.second;
|
||||||
}
|
}
|
||||||
for (auto x : kidGameIndexAllKeys) {
|
for (auto x : kidGameIndexAllKeys) {
|
||||||
LOG(LogInfo) << "KidGames Index: " << x.first << ": " << x.second;
|
LOG(LogInfo) << "KidGames 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*>::const_iterator it = children.cbegin();
|
||||||
|
it != children.cend(); ++it ) {
|
||||||
|
if (showFile(*it))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (std::vector<FileData*>::const_iterator it = children.cbegin(); it != children.cend(); ++it ) {
|
bool keepGoing = false;
|
||||||
if (showFile(*it))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool keepGoing = false;
|
for (std::vector<FilterDataDecl>::const_iterator it = filterDataDecl.cbegin();
|
||||||
|
it != filterDataDecl.cend(); ++it ) {
|
||||||
|
FilterDataDecl filterData = (*it);
|
||||||
|
if (*(filterData.filteredByRef)) {
|
||||||
|
// Try to find a match.
|
||||||
|
std::string key = getIndexableKey(game, filterData.type, false);
|
||||||
|
keepGoing = isKeyBeingFilteredBy(key, filterData.type);
|
||||||
|
|
||||||
for (std::vector<FilterDataDecl>::const_iterator it = filterDataDecl.cbegin(); it != filterDataDecl.cend(); ++it ) {
|
// If we didn't find a match, try for secondary keys - i.e.
|
||||||
FilterDataDecl filterData = (*it);
|
// publisher and dev, or first genre.
|
||||||
if(*(filterData.filteredByRef))
|
if (!keepGoing) {
|
||||||
{
|
if (!filterData.hasSecondaryKey)
|
||||||
// try to find a match
|
return false;
|
||||||
std::string key = getIndexableKey(game, filterData.type, false);
|
std::string secKey = getIndexableKey(game, filterData.type, true);
|
||||||
keepGoing = isKeyBeingFilteredBy(key, filterData.type);
|
if (secKey != UNKNOWN_LABEL)
|
||||||
|
keepGoing = isKeyBeingFilteredBy(secKey, filterData.type);
|
||||||
// if we didn't find a match, try for secondary keys - i.e. publisher and dev, or first genre
|
}
|
||||||
if (!keepGoing)
|
// If still nothing, then it's not a match.
|
||||||
{
|
if (!keepGoing)
|
||||||
if (!filterData.hasSecondaryKey)
|
return false;
|
||||||
{
|
}
|
||||||
return false;
|
}
|
||||||
}
|
return keepGoing;
|
||||||
std::string secKey = getIndexableKey(game, filterData.type, true);
|
|
||||||
if (secKey != UNKNOWN_LABEL)
|
|
||||||
{
|
|
||||||
keepGoing = isKeyBeingFilteredBy(secKey, filterData.type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if still nothing, then it's not a match
|
|
||||||
if (!keepGoing)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return keepGoing;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileFilterIndex::isKeyBeingFilteredBy(std::string key, FilterIndexType type)
|
bool FileFilterIndex::isKeyBeingFilteredBy(std::string key, FilterIndexType type)
|
||||||
{
|
{
|
||||||
const FilterIndexType filterTypes[7] = { FAVORITES_FILTER, GENRE_FILTER, PLAYER_FILTER, PUBDEV_FILTER, RATINGS_FILTER,HIDDEN_FILTER, KIDGAME_FILTER };
|
const FilterIndexType filterTypes[7] = { FAVORITES_FILTER, GENRE_FILTER,
|
||||||
std::vector<std::string> filterKeysList[7] = { favoritesIndexFilteredKeys, genreIndexFilteredKeys, playersIndexFilteredKeys, pubDevIndexFilteredKeys, ratingsIndexFilteredKeys, hiddenIndexFilteredKeys, kidGameIndexFilteredKeys };
|
PLAYER_FILTER, PUBDEV_FILTER, RATINGS_FILTER,HIDDEN_FILTER, KIDGAME_FILTER };
|
||||||
|
std::vector<std::string> filterKeysList[7] = { favoritesIndexFilteredKeys,
|
||||||
|
genreIndexFilteredKeys, playersIndexFilteredKeys, pubDevIndexFilteredKeys,
|
||||||
|
ratingsIndexFilteredKeys, hiddenIndexFilteredKeys, kidGameIndexFilteredKeys };
|
||||||
|
|
||||||
for (int i = 0; i < 7; i++)
|
for (int i = 0; i < 7; i++) {
|
||||||
{
|
if (filterTypes[i] == type) {
|
||||||
if (filterTypes[i] == type)
|
for (std::vector<std::string>::const_iterator it = filterKeysList[i].cbegin();
|
||||||
{
|
it != filterKeysList[i].cend(); ++it ) {
|
||||||
for (std::vector<std::string>::const_iterator it = filterKeysList[i].cbegin(); it != filterKeysList[i].cend(); ++it )
|
if (key == (*it))
|
||||||
{
|
return true;
|
||||||
if (key == (*it))
|
}
|
||||||
{
|
return false;
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
}
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::manageGenreEntryInIndex(FileData* game, bool remove)
|
void FileFilterIndex::manageGenreEntryInIndex(FileData* game, bool remove)
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string key = getIndexableKey(game, GENRE_FILTER, false);
|
std::string key = getIndexableKey(game, GENRE_FILTER, false);
|
||||||
|
|
||||||
// flag for including unknowns
|
// Flag for including unknowns.
|
||||||
bool includeUnknown = INCLUDE_UNKNOWN;
|
bool includeUnknown = INCLUDE_UNKNOWN;
|
||||||
|
|
||||||
// only add unknown in pubdev IF both dev and pub are empty
|
// Only add unknown in pubdev IF both dev and pub are empty.
|
||||||
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);
|
||||||
|
|
||||||
key = getIndexableKey(game, GENRE_FILTER, true);
|
key = getIndexableKey(game, GENRE_FILTER, true);
|
||||||
if (!includeUnknown && key == UNKNOWN_LABEL)
|
if (!includeUnknown && key == UNKNOWN_LABEL)
|
||||||
{
|
manageIndexEntry(&genreIndexAllKeys, key, remove);
|
||||||
manageIndexEntry(&genreIndexAllKeys, key, remove);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::managePlayerEntryInIndex(FileData* game, bool remove)
|
void FileFilterIndex::managePlayerEntryInIndex(FileData* game, bool remove)
|
||||||
{
|
{
|
||||||
// flag for including unknowns
|
// Flag for including unknowns.
|
||||||
bool includeUnknown = INCLUDE_UNKNOWN;
|
bool includeUnknown = INCLUDE_UNKNOWN;
|
||||||
std::string key = getIndexableKey(game, PLAYER_FILTER, false);
|
std::string key = getIndexableKey(game, PLAYER_FILTER, false);
|
||||||
|
|
||||||
// only add unknown in pubdev IF both dev and pub are empty
|
// Only add unknown in pubdev IF both dev and pub are empty.
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::managePubDevEntryInIndex(FileData* game, bool remove)
|
void FileFilterIndex::managePubDevEntryInIndex(FileData* game, bool remove)
|
||||||
{
|
{
|
||||||
std::string pub = getIndexableKey(game, PUBDEV_FILTER, false);
|
std::string pub = getIndexableKey(game, PUBDEV_FILTER, false);
|
||||||
std::string dev = getIndexableKey(game, PUBDEV_FILTER, true);
|
std::string dev = getIndexableKey(game, PUBDEV_FILTER, true);
|
||||||
|
|
||||||
// flag for including unknowns
|
// Flag for including unknowns.
|
||||||
bool includeUnknown = INCLUDE_UNKNOWN;
|
bool includeUnknown = INCLUDE_UNKNOWN;
|
||||||
bool unknownPub = false;
|
bool unknownPub = false;
|
||||||
bool unknownDev = false;
|
bool unknownDev = false;
|
||||||
|
|
||||||
if (pub == UNKNOWN_LABEL) {
|
if (pub == UNKNOWN_LABEL)
|
||||||
unknownPub = true;
|
unknownPub = true;
|
||||||
}
|
|
||||||
if (dev == UNKNOWN_LABEL) {
|
|
||||||
unknownDev = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!includeUnknown && unknownDev && unknownPub) {
|
if (dev == UNKNOWN_LABEL)
|
||||||
// no valid rating info found
|
unknownDev = true;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (unknownDev && unknownPub) {
|
if (!includeUnknown && unknownDev && unknownPub)
|
||||||
// if no info at all
|
// No valid rating info found.
|
||||||
manageIndexEntry(&pubDevIndexAllKeys, pub, remove);
|
return;
|
||||||
}
|
|
||||||
else
|
if (unknownDev && unknownPub) {
|
||||||
{
|
// If no info at all.
|
||||||
if (!unknownDev) {
|
manageIndexEntry(&pubDevIndexAllKeys, pub, remove);
|
||||||
// if no info at all
|
}
|
||||||
manageIndexEntry(&pubDevIndexAllKeys, dev, remove);
|
else {
|
||||||
}
|
if (!unknownDev) {
|
||||||
if (!unknownPub) {
|
// If no info at all.
|
||||||
// if no info at all
|
manageIndexEntry(&pubDevIndexAllKeys, dev, remove);
|
||||||
manageIndexEntry(&pubDevIndexAllKeys, pub, remove);
|
}
|
||||||
}
|
if (!unknownPub) {
|
||||||
}
|
// If no info at all.
|
||||||
|
manageIndexEntry(&pubDevIndexAllKeys, pub, remove);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::manageRatingsEntryInIndex(FileData* game, bool remove)
|
void FileFilterIndex::manageRatingsEntryInIndex(FileData* game, bool remove)
|
||||||
{
|
{
|
||||||
std::string key = getIndexableKey(game, RATINGS_FILTER, false);
|
std::string key = getIndexableKey(game, RATINGS_FILTER, false);
|
||||||
|
|
||||||
// flag for including unknowns
|
// Flag for including unknowns.
|
||||||
bool includeUnknown = INCLUDE_UNKNOWN;
|
bool includeUnknown = INCLUDE_UNKNOWN;
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::manageFavoritesEntryInIndex(FileData* game, bool remove)
|
void FileFilterIndex::manageFavoritesEntryInIndex(FileData* game, bool remove)
|
||||||
{
|
{
|
||||||
// flag for including unknowns
|
// Flag for including unknowns.
|
||||||
bool includeUnknown = INCLUDE_UNKNOWN;
|
bool includeUnknown = INCLUDE_UNKNOWN;
|
||||||
std::string key = getIndexableKey(game, FAVORITES_FILTER, false);
|
std::string key = getIndexableKey(game, FAVORITES_FILTER, false);
|
||||||
if (!includeUnknown && key == UNKNOWN_LABEL) {
|
|
||||||
// no valid favorites info found
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
manageIndexEntry(&favoritesIndexAllKeys, key, remove);
|
if (!includeUnknown && key == UNKNOWN_LABEL)
|
||||||
|
// No valid favorites info found.
|
||||||
|
return;
|
||||||
|
|
||||||
|
manageIndexEntry(&favoritesIndexAllKeys, key, remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::manageHiddenEntryInIndex(FileData* game, bool remove)
|
void FileFilterIndex::manageHiddenEntryInIndex(FileData* game, bool remove)
|
||||||
{
|
{
|
||||||
// flag for including unknowns
|
// Flag for including unknowns.
|
||||||
bool includeUnknown = INCLUDE_UNKNOWN;
|
bool includeUnknown = INCLUDE_UNKNOWN;
|
||||||
std::string key = getIndexableKey(game, HIDDEN_FILTER, false);
|
std::string key = getIndexableKey(game, HIDDEN_FILTER, false);
|
||||||
if (!includeUnknown && key == UNKNOWN_LABEL) {
|
|
||||||
// no valid hidden info found
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
manageIndexEntry(&hiddenIndexAllKeys, key, remove);
|
if (!includeUnknown && key == UNKNOWN_LABEL)
|
||||||
|
// No valid hidden info found.
|
||||||
|
return;
|
||||||
|
|
||||||
|
manageIndexEntry(&hiddenIndexAllKeys, key, remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::manageKidGameEntryInIndex(FileData* game, bool remove)
|
void FileFilterIndex::manageKidGameEntryInIndex(FileData* game, bool remove)
|
||||||
{
|
{
|
||||||
// flag for including unknowns
|
// Flag for including unknowns.
|
||||||
bool includeUnknown = INCLUDE_UNKNOWN;
|
bool includeUnknown = INCLUDE_UNKNOWN;
|
||||||
std::string key = getIndexableKey(game, KIDGAME_FILTER, false);
|
std::string key = getIndexableKey(game, KIDGAME_FILTER, false);
|
||||||
if (!includeUnknown && key == UNKNOWN_LABEL) {
|
|
||||||
// no valid kidgame info found
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
manageIndexEntry(&kidGameIndexAllKeys, key, remove);
|
if (!includeUnknown && key == UNKNOWN_LABEL)
|
||||||
|
// No valid kidgame info found.
|
||||||
|
return;
|
||||||
|
|
||||||
|
manageIndexEntry(&kidGameIndexAllKeys, key, remove);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileFilterIndex::manageIndexEntry(std::map<std::string, int>* index, std::string key, bool remove) {
|
void FileFilterIndex::manageIndexEntry(std::map<std::string, int>* index,
|
||||||
bool includeUnknown = INCLUDE_UNKNOWN;
|
std::string key, bool remove)
|
||||||
if (!includeUnknown && key == UNKNOWN_LABEL)
|
{
|
||||||
return;
|
bool includeUnknown = INCLUDE_UNKNOWN;
|
||||||
if (remove) {
|
if (!includeUnknown && key == UNKNOWN_LABEL)
|
||||||
// removing entry
|
return;
|
||||||
if (index->find(key) == index->cend())
|
|
||||||
{
|
if (remove) {
|
||||||
// this shouldn't happen
|
// Removing entry.
|
||||||
LOG(LogInfo) << "Couldn't find entry in index! " << key;
|
if (index->find(key) == index->cend()) {
|
||||||
}
|
// This shouldn't happen.
|
||||||
else
|
LOG(LogInfo) << "Couldn't find entry in index! " << key;
|
||||||
{
|
}
|
||||||
(index->at(key))--;
|
else {
|
||||||
if(index->at(key) <= 0) {
|
(index->at(key))--;
|
||||||
index->erase(key);
|
if (index->at(key) <= 0) {
|
||||||
}
|
index->erase(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
{
|
else {
|
||||||
// adding entry
|
// Adding entry.
|
||||||
if (index->find(key) == index->cend())
|
if (index->find(key) == index->cend())
|
||||||
{
|
(*index)[key] = 1;
|
||||||
(*index)[key] = 1;
|
else
|
||||||
}
|
(index->at(key))++;
|
||||||
else
|
}
|
||||||
{
|
|
||||||
(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();
|
||||||
}
|
}
|
|
@ -1,3 +1,9 @@
|
||||||
|
//
|
||||||
|
// FileFilterIndex.h
|
||||||
|
//
|
||||||
|
// Gamelist filters.
|
||||||
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#ifndef ES_APP_FILE_FILTER_INDEX_H
|
#ifndef ES_APP_FILE_FILTER_INDEX_H
|
||||||
#define ES_APP_FILE_FILTER_INDEX_H
|
#define ES_APP_FILE_FILTER_INDEX_H
|
||||||
|
@ -7,91 +13,90 @@
|
||||||
|
|
||||||
class FileData;
|
class FileData;
|
||||||
|
|
||||||
enum FilterIndexType
|
enum FilterIndexType {
|
||||||
{
|
NONE,
|
||||||
NONE,
|
GENRE_FILTER,
|
||||||
GENRE_FILTER,
|
PLAYER_FILTER,
|
||||||
PLAYER_FILTER,
|
PUBDEV_FILTER,
|
||||||
PUBDEV_FILTER,
|
RATINGS_FILTER,
|
||||||
RATINGS_FILTER,
|
FAVORITES_FILTER,
|
||||||
FAVORITES_FILTER,
|
HIDDEN_FILTER,
|
||||||
HIDDEN_FILTER,
|
KIDGAME_FILTER
|
||||||
KIDGAME_FILTER
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FilterDataDecl
|
struct FilterDataDecl {
|
||||||
{
|
FilterIndexType type; // Type of filter.
|
||||||
FilterIndexType type; // type of filter
|
std::map<std::string, int>* allIndexKeys; // All possible filters for this type.
|
||||||
std::map<std::string, int>* allIndexKeys; // all possible filters for this type
|
bool* filteredByRef; // Is it filtered by this type?
|
||||||
bool* filteredByRef; // is it filtered by this type
|
std::vector<std::string>* currentFilteredKeys; // Current keys being filtered for.
|
||||||
std::vector<std::string>* currentFilteredKeys; // current keys being filtered for
|
std::string primaryKey; // Primary key in metadata.
|
||||||
std::string primaryKey; // primary key in metadata
|
bool hasSecondaryKey; // Has secondary key for comparison.
|
||||||
bool hasSecondaryKey; // has secondary key for comparison
|
std::string secondaryKey; // What's the secondary key.
|
||||||
std::string secondaryKey; // what's the secondary key
|
std::string menuLabel; // Text to show in menu.
|
||||||
std::string menuLabel; // text to show in menu
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class FileFilterIndex
|
class FileFilterIndex
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileFilterIndex();
|
FileFilterIndex();
|
||||||
~FileFilterIndex();
|
~FileFilterIndex();
|
||||||
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 || filterByFavorites || filterByHidden || filterByKidGame); };
|
bool isFiltered() { return (filterByGenre || filterByPlayers || filterByPubDev ||
|
||||||
bool isKeyBeingFilteredBy(std::string key, FilterIndexType type);
|
filterByRatings || filterByFavorites || filterByHidden || filterByKidGame); };
|
||||||
std::vector<FilterDataDecl>& getFilterDataDecls();
|
bool isKeyBeingFilteredBy(std::string key, FilterIndexType type);
|
||||||
|
std::vector<FilterDataDecl>& getFilterDataDecls();
|
||||||
|
|
||||||
void importIndex(FileFilterIndex* indexToImport);
|
void importIndex(FileFilterIndex* indexToImport);
|
||||||
void resetIndex();
|
void resetIndex();
|
||||||
void resetFilters();
|
void resetFilters();
|
||||||
void setUIModeFilters();
|
void setUIModeFilters();
|
||||||
|
|
||||||
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);
|
||||||
void manageRatingsEntryInIndex(FileData* game, bool remove = false);
|
void manageRatingsEntryInIndex(FileData* game, bool remove = false);
|
||||||
void manageFavoritesEntryInIndex(FileData* game, bool remove = false);
|
void manageFavoritesEntryInIndex(FileData* game, bool remove = false);
|
||||||
void manageHiddenEntryInIndex(FileData* game, bool remove = false);
|
void manageHiddenEntryInIndex(FileData* game, bool remove = false);
|
||||||
void manageKidGameEntryInIndex(FileData* game, bool remove = false);
|
void manageKidGameEntryInIndex(FileData* game, bool remove = false);
|
||||||
|
|
||||||
void manageIndexEntry(std::map<std::string, int>* index, std::string key, bool remove);
|
void manageIndexEntry(std::map<std::string, int>* index, std::string key, bool remove);
|
||||||
|
|
||||||
void clearIndex(std::map<std::string, int> indexMap);
|
void clearIndex(std::map<std::string, int> indexMap);
|
||||||
|
|
||||||
bool filterByGenre;
|
bool filterByGenre;
|
||||||
bool filterByPlayers;
|
bool filterByPlayers;
|
||||||
bool filterByPubDev;
|
bool filterByPubDev;
|
||||||
bool filterByRatings;
|
bool filterByRatings;
|
||||||
bool filterByFavorites;
|
bool filterByFavorites;
|
||||||
bool filterByHidden;
|
bool filterByHidden;
|
||||||
bool filterByKidGame;
|
bool filterByKidGame;
|
||||||
|
|
||||||
std::map<std::string, int> genreIndexAllKeys;
|
std::map<std::string, int> genreIndexAllKeys;
|
||||||
std::map<std::string, int> playersIndexAllKeys;
|
std::map<std::string, int> playersIndexAllKeys;
|
||||||
std::map<std::string, int> pubDevIndexAllKeys;
|
std::map<std::string, int> pubDevIndexAllKeys;
|
||||||
std::map<std::string, int> ratingsIndexAllKeys;
|
std::map<std::string, int> ratingsIndexAllKeys;
|
||||||
std::map<std::string, int> favoritesIndexAllKeys;
|
std::map<std::string, int> favoritesIndexAllKeys;
|
||||||
std::map<std::string, int> hiddenIndexAllKeys;
|
std::map<std::string, int> hiddenIndexAllKeys;
|
||||||
std::map<std::string, int> kidGameIndexAllKeys;
|
std::map<std::string, int> kidGameIndexAllKeys;
|
||||||
|
|
||||||
std::vector<std::string> genreIndexFilteredKeys;
|
std::vector<std::string> genreIndexFilteredKeys;
|
||||||
std::vector<std::string> playersIndexFilteredKeys;
|
std::vector<std::string> playersIndexFilteredKeys;
|
||||||
std::vector<std::string> pubDevIndexFilteredKeys;
|
std::vector<std::string> pubDevIndexFilteredKeys;
|
||||||
std::vector<std::string> ratingsIndexFilteredKeys;
|
std::vector<std::string> ratingsIndexFilteredKeys;
|
||||||
std::vector<std::string> favoritesIndexFilteredKeys;
|
std::vector<std::string> favoritesIndexFilteredKeys;
|
||||||
std::vector<std::string> hiddenIndexFilteredKeys;
|
std::vector<std::string> hiddenIndexFilteredKeys;
|
||||||
std::vector<std::string> kidGameIndexFilteredKeys;
|
std::vector<std::string> kidGameIndexFilteredKeys;
|
||||||
|
|
||||||
FileData* mRootFolder;
|
FileData* mRootFolder;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,118 +1,125 @@
|
||||||
|
//
|
||||||
|
// FileSorts.cpp
|
||||||
|
//
|
||||||
|
// Gamelist sorting functions.
|
||||||
|
// Actual sorting takes place in FileData.
|
||||||
|
//
|
||||||
|
|
||||||
#include "FileSorts.h"
|
#include "FileSorts.h"
|
||||||
|
|
||||||
#include "utils/StringUtil.h"
|
#include "utils/StringUtil.h"
|
||||||
|
|
||||||
namespace FileSorts
|
namespace FileSorts
|
||||||
{
|
{
|
||||||
const FileData::SortType typesArr[] = {
|
const FileData::SortType typesArr[] = {
|
||||||
FileData::SortType(&compareName, true, "filename, ascending"),
|
FileData::SortType(&compareName, true, "filename, ascending"),
|
||||||
FileData::SortType(&compareName, false, "filename, descending"),
|
FileData::SortType(&compareName, false, "filename, descending"),
|
||||||
|
|
||||||
FileData::SortType(&compareRating, true, "rating, ascending"),
|
FileData::SortType(&compareRating, true, "rating, ascending"),
|
||||||
FileData::SortType(&compareRating, false, "rating, descending"),
|
FileData::SortType(&compareRating, false, "rating, descending"),
|
||||||
|
|
||||||
FileData::SortType(&compareTimesPlayed, true, "times played, ascending"),
|
FileData::SortType(&compareTimesPlayed, true, "times played, ascending"),
|
||||||
FileData::SortType(&compareTimesPlayed, false, "times played, descending"),
|
FileData::SortType(&compareTimesPlayed, false, "times played, descending"),
|
||||||
|
|
||||||
FileData::SortType(&compareLastPlayed, true, "last played, ascending"),
|
FileData::SortType(&compareLastPlayed, true, "last played, ascending"),
|
||||||
FileData::SortType(&compareLastPlayed, false, "last played, descending"),
|
FileData::SortType(&compareLastPlayed, false, "last played, descending"),
|
||||||
|
|
||||||
FileData::SortType(&compareNumPlayers, true, "number players, ascending"),
|
FileData::SortType(&compareNumPlayers, true, "number players, ascending"),
|
||||||
FileData::SortType(&compareNumPlayers, false, "number players, descending"),
|
FileData::SortType(&compareNumPlayers, false, "number players, descending"),
|
||||||
|
|
||||||
FileData::SortType(&compareReleaseDate, true, "release date, ascending"),
|
FileData::SortType(&compareReleaseDate, true, "release date, ascending"),
|
||||||
FileData::SortType(&compareReleaseDate, false, "release date, descending"),
|
FileData::SortType(&compareReleaseDate, false, "release date, descending"),
|
||||||
|
|
||||||
FileData::SortType(&compareGenre, true, "genre, ascending"),
|
FileData::SortType(&compareGenre, true, "genre, ascending"),
|
||||||
FileData::SortType(&compareGenre, false, "genre, descending"),
|
FileData::SortType(&compareGenre, false, "genre, descending"),
|
||||||
|
|
||||||
FileData::SortType(&compareDeveloper, true, "developer, ascending"),
|
FileData::SortType(&compareDeveloper, true, "developer, ascending"),
|
||||||
FileData::SortType(&compareDeveloper, false, "developer, descending"),
|
FileData::SortType(&compareDeveloper, false, "developer, descending"),
|
||||||
|
|
||||||
FileData::SortType(&comparePublisher, true, "publisher, ascending"),
|
FileData::SortType(&comparePublisher, true, "publisher, ascending"),
|
||||||
FileData::SortType(&comparePublisher, false, "publisher, descending"),
|
FileData::SortType(&comparePublisher, false, "publisher, descending"),
|
||||||
|
|
||||||
FileData::SortType(&compareSystem, true, "system, ascending"),
|
FileData::SortType(&compareSystem, true, "system, ascending"),
|
||||||
FileData::SortType(&compareSystem, false, "system, descending")
|
FileData::SortType(&compareSystem, false, "system, descending")
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::vector<FileData::SortType> SortTypes(typesArr, typesArr + sizeof(typesArr)/sizeof(typesArr[0]));
|
const std::vector<FileData::SortType> SortTypes(typesArr, typesArr +
|
||||||
|
sizeof(typesArr)/sizeof(typesArr[0]));
|
||||||
|
|
||||||
//returns if file1 should come before file2
|
// Returns if file1 should come before file2.
|
||||||
bool compareName(const FileData* file1, const FileData* file2)
|
bool compareName(const FileData* file1, const FileData* file2)
|
||||||
{
|
{
|
||||||
// we compare the actual metadata name, as collection files have the system appended which messes up the order
|
// We compare the actual metadata name, as collection files have the system
|
||||||
std::string name1 = Utils::String::toUpper(file1->metadata.get("sortname"));
|
// appended which messes up the order.
|
||||||
std::string name2 = Utils::String::toUpper(file2->metadata.get("sortname"));
|
std::string name1 = Utils::String::toUpper(file1->metadata.get("sortname"));
|
||||||
if(name1.empty()){
|
std::string name2 = Utils::String::toUpper(file2->metadata.get("sortname"));
|
||||||
name1 = Utils::String::toUpper(file1->metadata.get("name"));
|
if(name1.empty()){
|
||||||
}
|
name1 = Utils::String::toUpper(file1->metadata.get("name"));
|
||||||
if(name2.empty()){
|
}
|
||||||
name2 = Utils::String::toUpper(file2->metadata.get("name"));
|
if(name2.empty()){
|
||||||
}
|
name2 = Utils::String::toUpper(file2->metadata.get("name"));
|
||||||
return name1.compare(name2) < 0;
|
}
|
||||||
}
|
return name1.compare(name2) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
bool compareRating(const FileData* file1, const FileData* file2)
|
bool compareRating(const FileData* file1, const FileData* file2)
|
||||||
{
|
{
|
||||||
return file1->metadata.getFloat("rating") < file2->metadata.getFloat("rating");
|
return file1->metadata.getFloat("rating") < file2->metadata.getFloat("rating");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool compareTimesPlayed(const FileData* file1, const FileData* file2)
|
bool compareTimesPlayed(const FileData* file1, const FileData* file2)
|
||||||
{
|
{
|
||||||
//only games have playcount metadata
|
//only games have playcount metadata
|
||||||
if(file1->metadata.getType() == GAME_METADATA && file2->metadata.getType() == GAME_METADATA)
|
if(file1->metadata.getType() == GAME_METADATA && file2->metadata.getType() == GAME_METADATA)
|
||||||
{
|
return (file1)->metadata.getInt("playcount") < (file2)->metadata.getInt("playcount");
|
||||||
return (file1)->metadata.getInt("playcount") < (file2)->metadata.getInt("playcount");
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool compareLastPlayed(const FileData* file1, const FileData* file2)
|
bool compareLastPlayed(const FileData* file1, const FileData* file2)
|
||||||
{
|
{
|
||||||
// since it's stored as an ISO string (YYYYMMDDTHHMMSS), we can compare as a string
|
// Since it's stored as an ISO string (YYYYMMDDTHHMMSS), we can compare as a string
|
||||||
// as it's a lot faster than the time casts and then time comparisons
|
// which is a lot faster than the time casts and the time comparisons.
|
||||||
return (file1)->metadata.get("lastplayed") < (file2)->metadata.get("lastplayed");
|
return (file1)->metadata.get("lastplayed") < (file2)->metadata.get("lastplayed");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool compareNumPlayers(const FileData* file1, const FileData* file2)
|
bool compareNumPlayers(const FileData* file1, const FileData* file2)
|
||||||
{
|
{
|
||||||
return (file1)->metadata.getInt("players") < (file2)->metadata.getInt("players");
|
return (file1)->metadata.getInt("players") < (file2)->metadata.getInt("players");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool compareReleaseDate(const FileData* file1, const FileData* file2)
|
bool compareReleaseDate(const FileData* file1, const FileData* file2)
|
||||||
{
|
{
|
||||||
// since it's stored as an ISO string (YYYYMMDDTHHMMSS), we can compare as a string
|
// Since it's stored as an ISO string (YYYYMMDDTHHMMSS), we can compare as a string
|
||||||
// as it's a lot faster than the time casts and then time comparisons
|
// which is a lot faster than the time casts and the time comparisons.
|
||||||
return (file1)->metadata.get("releasedate") < (file2)->metadata.get("releasedate");
|
return (file1)->metadata.get("releasedate") < (file2)->metadata.get("releasedate");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool compareGenre(const FileData* file1, const FileData* file2)
|
bool compareGenre(const FileData* file1, const FileData* file2)
|
||||||
{
|
{
|
||||||
std::string genre1 = Utils::String::toUpper(file1->metadata.get("genre"));
|
std::string genre1 = Utils::String::toUpper(file1->metadata.get("genre"));
|
||||||
std::string genre2 = Utils::String::toUpper(file2->metadata.get("genre"));
|
std::string genre2 = Utils::String::toUpper(file2->metadata.get("genre"));
|
||||||
return genre1.compare(genre2) < 0;
|
return genre1.compare(genre2) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool compareDeveloper(const FileData* file1, const FileData* file2)
|
bool compareDeveloper(const FileData* file1, const FileData* file2)
|
||||||
{
|
{
|
||||||
std::string developer1 = Utils::String::toUpper(file1->metadata.get("developer"));
|
std::string developer1 = Utils::String::toUpper(file1->metadata.get("developer"));
|
||||||
std::string developer2 = Utils::String::toUpper(file2->metadata.get("developer"));
|
std::string developer2 = Utils::String::toUpper(file2->metadata.get("developer"));
|
||||||
return developer1.compare(developer2) < 0;
|
return developer1.compare(developer2) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool comparePublisher(const FileData* file1, const FileData* file2)
|
bool comparePublisher(const FileData* file1, const FileData* file2)
|
||||||
{
|
{
|
||||||
std::string publisher1 = Utils::String::toUpper(file1->metadata.get("publisher"));
|
std::string publisher1 = Utils::String::toUpper(file1->metadata.get("publisher"));
|
||||||
std::string publisher2 = Utils::String::toUpper(file2->metadata.get("publisher"));
|
std::string publisher2 = Utils::String::toUpper(file2->metadata.get("publisher"));
|
||||||
return publisher1.compare(publisher2) < 0;
|
return publisher1.compare(publisher2) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool compareSystem(const FileData* file1, const FileData* file2)
|
bool compareSystem(const FileData* file1, const FileData* file2)
|
||||||
{
|
{
|
||||||
std::string system1 = Utils::String::toUpper(file1->getSystemName());
|
std::string system1 = Utils::String::toUpper(file1->getSystemName());
|
||||||
std::string system2 = Utils::String::toUpper(file2->getSystemName());
|
std::string system2 = Utils::String::toUpper(file2->getSystemName());
|
||||||
return system1.compare(system2) < 0;
|
return system1.compare(system2) < 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
//
|
||||||
|
// FileSorts.h
|
||||||
|
//
|
||||||
|
// Gamelist sorting functions.
|
||||||
|
// Actual sorting takes place in FileData.
|
||||||
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#ifndef ES_APP_FILE_SORTS_H
|
#ifndef ES_APP_FILE_SORTS_H
|
||||||
#define ES_APP_FILE_SORTS_H
|
#define ES_APP_FILE_SORTS_H
|
||||||
|
@ -7,18 +14,18 @@
|
||||||
|
|
||||||
namespace FileSorts
|
namespace FileSorts
|
||||||
{
|
{
|
||||||
bool compareName(const FileData* file1, const FileData* file2);
|
bool compareName(const FileData* file1, const FileData* file2);
|
||||||
bool compareRating(const FileData* file1, const FileData* file2);
|
bool compareRating(const FileData* file1, const FileData* file2);
|
||||||
bool compareTimesPlayed(const FileData* file1, const FileData* fil2);
|
bool compareTimesPlayed(const FileData* file1, const FileData* fil2);
|
||||||
bool compareLastPlayed(const FileData* file1, const FileData* file2);
|
bool compareLastPlayed(const FileData* file1, const FileData* file2);
|
||||||
bool compareNumPlayers(const FileData* file1, const FileData* file2);
|
bool compareNumPlayers(const FileData* file1, const FileData* file2);
|
||||||
bool compareReleaseDate(const FileData* file1, const FileData* file2);
|
bool compareReleaseDate(const FileData* file1, const FileData* file2);
|
||||||
bool compareGenre(const FileData* file1, const FileData* file2);
|
bool compareGenre(const FileData* file1, const FileData* file2);
|
||||||
bool compareDeveloper(const FileData* file1, const FileData* file2);
|
bool compareDeveloper(const FileData* file1, const FileData* file2);
|
||||||
bool comparePublisher(const FileData* file1, const FileData* file2);
|
bool comparePublisher(const FileData* file1, const FileData* file2);
|
||||||
bool compareSystem(const FileData* file1, const FileData* file2);
|
bool compareSystem(const FileData* file1, const FileData* file2);
|
||||||
|
|
||||||
extern const std::vector<FileData::SortType> SortTypes;
|
extern const std::vector<FileData::SortType> SortTypes;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ES_APP_FILE_SORTS_H
|
#endif // ES_APP_FILE_SORTS_H
|
||||||
|
|
|
@ -88,7 +88,6 @@ MetaDataList MetaDataList::createFromXML(MetaDataListType type,
|
||||||
mdl.set(iter->key, iter->defaultValue);
|
mdl.set(iter->key, iter->defaultValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return mdl;
|
return mdl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,6 @@ public:
|
||||||
// An example will be written if the file doesn't exist.
|
// An example will be written if the file doesn't exist.
|
||||||
static bool loadConfig();
|
static bool loadConfig();
|
||||||
static void writeExampleConfig(const std::string& path);
|
static void writeExampleConfig(const std::string& path);
|
||||||
// If forWrite, will only return ~/.emulationstation/es_systems.cfg,
|
|
||||||
// never /etc/emulationstation/es_systems.cfg.
|
|
||||||
static std::string getConfigPath(bool forWrite);
|
static std::string getConfigPath(bool forWrite);
|
||||||
|
|
||||||
static std::vector<SystemData*> sSystemVector;
|
static std::vector<SystemData*> sSystemVector;
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
//
|
||||||
|
// GuiCollectionSystemsOptions.cpp
|
||||||
|
//
|
||||||
|
// User interface for the game collection settings.
|
||||||
|
// Submenu to the GuiMenu main menu.
|
||||||
|
//
|
||||||
|
|
||||||
#include "guis/GuiCollectionSystemsOptions.h"
|
#include "guis/GuiCollectionSystemsOptions.h"
|
||||||
|
|
||||||
#include "components/OptionListComponent.h"
|
#include "components/OptionListComponent.h"
|
||||||
|
@ -10,228 +17,237 @@
|
||||||
#include "SystemData.h"
|
#include "SystemData.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
|
||||||
GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window) : GuiComponent(window), mMenu(window, "GAME COLLECTION SETTINGS")
|
GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window)
|
||||||
|
: GuiComponent(window), mMenu(window, "GAME COLLECTION SETTINGS")
|
||||||
{
|
{
|
||||||
initializeMenu();
|
initializeMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiCollectionSystemsOptions::initializeMenu()
|
void GuiCollectionSystemsOptions::initializeMenu()
|
||||||
{
|
{
|
||||||
addChild(&mMenu);
|
addChild(&mMenu);
|
||||||
|
|
||||||
// get collections
|
// Get collections.
|
||||||
|
addSystemsToMenu();
|
||||||
|
|
||||||
addSystemsToMenu();
|
// Add "Create New Custom Collection from Theme".
|
||||||
|
std::vector<std::string> unusedFolders =
|
||||||
|
CollectionSystemManager::get()->getUnusedSystemsFromTheme();
|
||||||
|
if (unusedFolders.size() > 0) {
|
||||||
|
addEntry("CREATE NEW CUSTOM COLLECTION FROM THEME", 0x777777FF, true,
|
||||||
|
[this, unusedFolders] {
|
||||||
|
auto s = new GuiSettings(mWindow, "SELECT THEME FOLDER");
|
||||||
|
std::shared_ptr< OptionListComponent<std::string>>
|
||||||
|
folderThemes = std::make_shared< OptionListComponent<std::string>>
|
||||||
|
(mWindow, getHelpStyle(), "SELECT THEME FOLDER", true);
|
||||||
|
|
||||||
// add "Create New Custom Collection from Theme"
|
// Add custom systems.
|
||||||
|
for(auto it = unusedFolders.cbegin() ; it != unusedFolders.cend() ; it++ ) {
|
||||||
|
ComponentListRow row;
|
||||||
|
std::string name = *it;
|
||||||
|
|
||||||
std::vector<std::string> unusedFolders = CollectionSystemManager::get()->getUnusedSystemsFromTheme();
|
std::function<void()> createCollectionCall = [name, this, s] {
|
||||||
if (unusedFolders.size() > 0)
|
createCollection(name);
|
||||||
{
|
};
|
||||||
addEntry("CREATE NEW CUSTOM COLLECTION FROM THEME", 0x777777FF, true,
|
row.makeAcceptInputHandler(createCollectionCall);
|
||||||
[this, unusedFolders] {
|
|
||||||
auto s = new GuiSettings(mWindow, "SELECT THEME FOLDER");
|
|
||||||
std::shared_ptr< OptionListComponent<std::string>>
|
|
||||||
folderThemes = std::make_shared< OptionListComponent<std::string>>
|
|
||||||
(mWindow, getHelpStyle(), "SELECT THEME FOLDER", true);
|
|
||||||
|
|
||||||
// add Custom Systems
|
auto themeFolder = std::make_shared<TextComponent>(mWindow,
|
||||||
for(auto it = unusedFolders.cbegin() ; it != unusedFolders.cend() ; it++ )
|
Utils::String::toUpper(name), Font::get(FONT_SIZE_SMALL), 0x777777FF);
|
||||||
{
|
row.addElement(themeFolder, true);
|
||||||
ComponentListRow row;
|
s->addRow(row);
|
||||||
std::string name = *it;
|
}
|
||||||
|
mWindow->pushGui(s);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
std::function<void()> createCollectionCall = [name, this, s] {
|
ComponentListRow row;
|
||||||
createCollection(name);
|
row.addElement(std::make_shared<TextComponent>(mWindow,
|
||||||
};
|
"CREATE NEW CUSTOM COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
||||||
row.makeAcceptInputHandler(createCollectionCall);
|
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
||||||
|
bracket->setImage(":/graphics/arrow.svg");
|
||||||
|
bracket->setResize(Vector2f(0, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()));
|
||||||
|
row.addElement(bracket, false);
|
||||||
|
auto createCustomCollection = [this](const std::string& newVal) {
|
||||||
|
std::string name = newVal;
|
||||||
|
// We need to store the first GUI and remove it, as it'll
|
||||||
|
// be deleted by the actual GUI.
|
||||||
|
Window* window = mWindow;
|
||||||
|
GuiComponent* topGui = window->peekGui();
|
||||||
|
window->removeGui(topGui);
|
||||||
|
createCollection(name);
|
||||||
|
};
|
||||||
|
row.makeAcceptInputHandler([this, createCustomCollection] {
|
||||||
|
mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(),
|
||||||
|
"New Collection Name", "", createCustomCollection, false, "SAVE"));
|
||||||
|
});
|
||||||
|
|
||||||
auto themeFolder = std::make_shared<TextComponent>(mWindow, Utils::String::toUpper(name), Font::get(FONT_SIZE_SMALL), 0x777777FF);
|
mMenu.addRow(row);
|
||||||
row.addElement(themeFolder, true);
|
|
||||||
s->addRow(row);
|
|
||||||
}
|
|
||||||
mWindow->pushGui(s);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
ComponentListRow row;
|
sortFavFirstCustomSwitch = std::make_shared<SwitchComponent>(mWindow);
|
||||||
row.addElement(std::make_shared<TextComponent>(mWindow, "CREATE NEW CUSTOM COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
sortFavFirstCustomSwitch->setState(Settings::getInstance()->getBool("FavFirstCustom"));
|
||||||
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
mMenu.addWithLabel("SORT FAVORITES ON TOP FOR CUSTOM COLLECTIONS", sortFavFirstCustomSwitch);
|
||||||
bracket->setImage(":/graphics/arrow.svg");
|
|
||||||
bracket->setResize(Vector2f(0, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()));
|
|
||||||
row.addElement(bracket, false);
|
|
||||||
auto createCustomCollection = [this](const std::string& newVal) {
|
|
||||||
std::string name = newVal;
|
|
||||||
// we need to store the first Gui and remove it, as it'll be deleted by the actual Gui
|
|
||||||
Window* window = mWindow;
|
|
||||||
GuiComponent* topGui = window->peekGui();
|
|
||||||
window->removeGui(topGui);
|
|
||||||
createCollection(name);
|
|
||||||
};
|
|
||||||
row.makeAcceptInputHandler([this, createCustomCollection] {
|
|
||||||
mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), "New Collection Name", "", createCustomCollection, false, "SAVE"));
|
|
||||||
});
|
|
||||||
|
|
||||||
mMenu.addRow(row);
|
bundleCustomCollections = std::make_shared<SwitchComponent>(mWindow);
|
||||||
|
bundleCustomCollections->setState(Settings::getInstance()->
|
||||||
|
getBool("UseCustomCollectionsSystem"));
|
||||||
|
mMenu.addWithLabel("GROUP UNTHEMED CUSTOM COLLECTIONS", bundleCustomCollections);
|
||||||
|
|
||||||
sortFavFirstCustomSwitch = std::make_shared<SwitchComponent>(mWindow);
|
toggleSystemNameInCollections = std::make_shared<SwitchComponent>(mWindow);
|
||||||
sortFavFirstCustomSwitch->setState(Settings::getInstance()->getBool("FavFirstCustom"));
|
toggleSystemNameInCollections->setState(Settings::getInstance()->
|
||||||
mMenu.addWithLabel("SORT FAVORITES ON TOP FOR CUSTOM COLLECTIONS", sortFavFirstCustomSwitch);
|
getBool("CollectionShowSystemInfo"));
|
||||||
|
mMenu.addWithLabel("SHOW SYSTEM NAMES IN COLLECTIONS", toggleSystemNameInCollections);
|
||||||
|
|
||||||
bundleCustomCollections = std::make_shared<SwitchComponent>(mWindow);
|
if(CollectionSystemManager::get()->isEditing()) {
|
||||||
bundleCustomCollections->setState(Settings::getInstance()->getBool("UseCustomCollectionsSystem"));
|
row.elements.clear();
|
||||||
mMenu.addWithLabel("GROUP UNTHEMED CUSTOM COLLECTIONS", bundleCustomCollections);
|
row.addElement(std::make_shared<TextComponent>(mWindow, "FINISH EDITING '" +
|
||||||
|
Utils::String::toUpper(CollectionSystemManager::get()->getEditingCollection()) +
|
||||||
|
"' COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
||||||
|
row.makeAcceptInputHandler(std::bind(&GuiCollectionSystemsOptions::exitEditMode, this));
|
||||||
|
mMenu.addRow(row);
|
||||||
|
}
|
||||||
|
|
||||||
toggleSystemNameInCollections = std::make_shared<SwitchComponent>(mWindow);
|
mMenu.addButton("BACK", "back", std::bind(&GuiCollectionSystemsOptions::applySettings, this));
|
||||||
toggleSystemNameInCollections->setState(Settings::getInstance()->getBool("CollectionShowSystemInfo"));
|
mMenu.setPosition((Renderer::getScreenWidth() - mMenu.getSize().x()) / 2,
|
||||||
mMenu.addWithLabel("SHOW SYSTEM NAMES IN COLLECTIONS", toggleSystemNameInCollections);
|
Renderer::getScreenHeight() * 0.15f);
|
||||||
|
|
||||||
if(CollectionSystemManager::get()->isEditing())
|
|
||||||
{
|
|
||||||
row.elements.clear();
|
|
||||||
row.addElement(std::make_shared<TextComponent>(mWindow, "FINISH EDITING '" + Utils::String::toUpper(CollectionSystemManager::get()->getEditingCollection()) + "' COLLECTION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
|
||||||
row.makeAcceptInputHandler(std::bind(&GuiCollectionSystemsOptions::exitEditMode, this));
|
|
||||||
mMenu.addRow(row);
|
|
||||||
}
|
|
||||||
|
|
||||||
mMenu.addButton("BACK", "back", std::bind(&GuiCollectionSystemsOptions::applySettings, this));
|
|
||||||
|
|
||||||
mMenu.setPosition((Renderer::getScreenWidth() - mMenu.getSize().x()) / 2, Renderer::getScreenHeight() * 0.15f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiCollectionSystemsOptions::addEntry(const char* name, unsigned int color, bool add_arrow, const std::function<void()>& func)
|
void GuiCollectionSystemsOptions::addEntry(const char* name, unsigned int color,
|
||||||
|
bool add_arrow, const std::function<void()>& func)
|
||||||
{
|
{
|
||||||
std::shared_ptr<Font> font = Font::get(FONT_SIZE_MEDIUM);
|
std::shared_ptr<Font> font = Font::get(FONT_SIZE_MEDIUM);
|
||||||
|
|
||||||
// populate the list
|
// Populate the list.
|
||||||
ComponentListRow row;
|
ComponentListRow row;
|
||||||
row.addElement(std::make_shared<TextComponent>(mWindow, name, font, color), true);
|
row.addElement(std::make_shared<TextComponent>(mWindow, name, font, color), true);
|
||||||
|
|
||||||
if(add_arrow)
|
if(add_arrow) {
|
||||||
{
|
std::shared_ptr<ImageComponent> bracket = makeArrow(mWindow);
|
||||||
std::shared_ptr<ImageComponent> bracket = makeArrow(mWindow);
|
row.addElement(bracket, false);
|
||||||
row.addElement(bracket, false);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
row.makeAcceptInputHandler(func);
|
row.makeAcceptInputHandler(func);
|
||||||
|
mMenu.addRow(row);
|
||||||
mMenu.addRow(row);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiCollectionSystemsOptions::createCollection(std::string inName) {
|
void GuiCollectionSystemsOptions::createCollection(std::string inName) {
|
||||||
std::string name = CollectionSystemManager::get()->getValidNewCollectionName(inName);
|
std::string name = CollectionSystemManager::get()->getValidNewCollectionName(inName);
|
||||||
SystemData* newSys = CollectionSystemManager::get()->addNewCustomCollection(name);
|
SystemData* newSys = CollectionSystemManager::get()->addNewCustomCollection(name);
|
||||||
customOptionList->add(name, name, true);
|
customOptionList->add(name, name, true);
|
||||||
std::string outAuto = Utils::String::vectorToCommaString(autoOptionList->getSelectedObjects());
|
std::string outAuto = Utils::String::vectorToCommaString(
|
||||||
std::string outCustom = Utils::String::vectorToCommaString(customOptionList->getSelectedObjects());
|
autoOptionList->getSelectedObjects());
|
||||||
updateSettings(outAuto, outCustom);
|
std::string outCustom = Utils::String::vectorToCommaString(
|
||||||
ViewController::get()->goToSystemView(newSys);
|
customOptionList->getSelectedObjects());
|
||||||
|
updateSettings(outAuto, outCustom);
|
||||||
|
ViewController::get()->goToSystemView(newSys);
|
||||||
|
|
||||||
Window* window = mWindow;
|
Window* window = mWindow;
|
||||||
CollectionSystemManager::get()->setEditMode(name);
|
CollectionSystemManager::get()->setEditMode(name);
|
||||||
while(window->peekGui() && window->peekGui() != ViewController::get())
|
while(window->peekGui() && window->peekGui() != ViewController::get())
|
||||||
delete window->peekGui();
|
delete window->peekGui();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiCollectionSystemsOptions::exitEditMode()
|
void GuiCollectionSystemsOptions::exitEditMode()
|
||||||
{
|
{
|
||||||
CollectionSystemManager::get()->exitEditMode();
|
CollectionSystemManager::get()->exitEditMode();
|
||||||
applySettings();
|
applySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiCollectionSystemsOptions::~GuiCollectionSystemsOptions()
|
GuiCollectionSystemsOptions::~GuiCollectionSystemsOptions()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiCollectionSystemsOptions::addSystemsToMenu()
|
void GuiCollectionSystemsOptions::addSystemsToMenu()
|
||||||
{
|
{
|
||||||
|
std::map<std::string, CollectionSystemData> autoSystems =
|
||||||
|
CollectionSystemManager::get()->getAutoCollectionSystems();
|
||||||
|
|
||||||
std::map<std::string, CollectionSystemData> autoSystems = CollectionSystemManager::get()->getAutoCollectionSystems();
|
autoOptionList = std::make_shared<OptionListComponent<std::string>>
|
||||||
|
(mWindow, getHelpStyle(), "SELECT COLLECTIONS", true);
|
||||||
|
|
||||||
autoOptionList = std::make_shared< OptionListComponent<std::string> >(mWindow, getHelpStyle(), "SELECT COLLECTIONS", true);
|
// Add automatic systems.
|
||||||
|
for(std::map<std::string, CollectionSystemData>::const_iterator it = autoSystems.cbegin();
|
||||||
|
it != autoSystems.cend() ; it++ )
|
||||||
|
autoOptionList->add(it->second.decl.longName, it->second.decl.name, it->second.isEnabled);
|
||||||
|
mMenu.addWithLabel("AUTOMATIC GAME COLLECTIONS", autoOptionList);
|
||||||
|
|
||||||
// add Auto Systems
|
std::map<std::string, CollectionSystemData> customSystems =
|
||||||
for(std::map<std::string, CollectionSystemData>::const_iterator it = autoSystems.cbegin() ; it != autoSystems.cend() ; it++ )
|
CollectionSystemManager::get()->getCustomCollectionSystems();
|
||||||
{
|
|
||||||
autoOptionList->add(it->second.decl.longName, it->second.decl.name, it->second.isEnabled);
|
|
||||||
}
|
|
||||||
mMenu.addWithLabel("AUTOMATIC GAME COLLECTIONS", autoOptionList);
|
|
||||||
|
|
||||||
std::map<std::string, CollectionSystemData> customSystems = CollectionSystemManager::get()->getCustomCollectionSystems();
|
customOptionList = std::make_shared<OptionListComponent<std::string>>
|
||||||
|
(mWindow, getHelpStyle(), "SELECT COLLECTIONS", true);
|
||||||
|
|
||||||
customOptionList = std::make_shared< OptionListComponent<std::string> >(mWindow, getHelpStyle(), "SELECT COLLECTIONS", true);
|
// Add custom systems.
|
||||||
|
for(std::map<std::string, CollectionSystemData>::const_iterator it = customSystems.cbegin();
|
||||||
// add Custom Systems
|
it != customSystems.cend() ; it++ )
|
||||||
for(std::map<std::string, CollectionSystemData>::const_iterator it = customSystems.cbegin() ; it != customSystems.cend() ; it++ )
|
customOptionList->add(it->second.decl.longName, it->second.decl.name, it->second.isEnabled);
|
||||||
{
|
mMenu.addWithLabel("CUSTOM GAME COLLECTIONS", customOptionList);
|
||||||
customOptionList->add(it->second.decl.longName, it->second.decl.name, it->second.isEnabled);
|
|
||||||
}
|
|
||||||
mMenu.addWithLabel("CUSTOM GAME COLLECTIONS", customOptionList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiCollectionSystemsOptions::applySettings()
|
void GuiCollectionSystemsOptions::applySettings()
|
||||||
{
|
{
|
||||||
std::string outAuto = Utils::String::vectorToCommaString(autoOptionList->getSelectedObjects());
|
std::string outAuto = Utils::String::vectorToCommaString(
|
||||||
std::string prevAuto = Settings::getInstance()->getString("CollectionSystemsAuto");
|
autoOptionList->getSelectedObjects());
|
||||||
std::string outCustom = Utils::String::vectorToCommaString(customOptionList->getSelectedObjects());
|
std::string prevAuto = Settings::getInstance()->getString("CollectionSystemsAuto");
|
||||||
std::string prevCustom = Settings::getInstance()->getString("CollectionSystemsCustom");
|
std::string outCustom = Utils::String::vectorToCommaString(
|
||||||
bool outSort = sortFavFirstCustomSwitch->getState();
|
customOptionList->getSelectedObjects());
|
||||||
bool prevSort = Settings::getInstance()->getBool("FavFirstCustom");
|
std::string prevCustom = Settings::getInstance()->getString("CollectionSystemsCustom");
|
||||||
bool outBundle = bundleCustomCollections->getState();
|
bool outSort = sortFavFirstCustomSwitch->getState();
|
||||||
bool prevBundle = Settings::getInstance()->getBool("UseCustomCollectionsSystem");
|
bool prevSort = Settings::getInstance()->getBool("FavFirstCustom");
|
||||||
bool prevShow = Settings::getInstance()->getBool("CollectionShowSystemInfo");
|
bool outBundle = bundleCustomCollections->getState();
|
||||||
bool outShow = toggleSystemNameInCollections->getState();
|
bool prevBundle = Settings::getInstance()->getBool("UseCustomCollectionsSystem");
|
||||||
bool needUpdateSettings = prevAuto != outAuto || prevCustom != outCustom || outSort != prevSort || outBundle != prevBundle || prevShow != outShow ;
|
bool prevShow = Settings::getInstance()->getBool("CollectionShowSystemInfo");
|
||||||
if (needUpdateSettings)
|
bool outShow = toggleSystemNameInCollections->getState();
|
||||||
{
|
bool needUpdateSettings = prevAuto != outAuto || prevCustom != outCustom || outSort !=
|
||||||
updateSettings(outAuto, outCustom);
|
prevSort || outBundle != prevBundle || prevShow != outShow ;
|
||||||
}
|
|
||||||
|
|
||||||
delete this;
|
if (needUpdateSettings)
|
||||||
|
updateSettings(outAuto, outCustom);
|
||||||
|
|
||||||
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiCollectionSystemsOptions::updateSettings(std::string newAutoSettings, std::string newCustomSettings)
|
void GuiCollectionSystemsOptions::updateSettings(std::string newAutoSettings,
|
||||||
|
std::string newCustomSettings)
|
||||||
{
|
{
|
||||||
Settings::getInstance()->setString("CollectionSystemsAuto", newAutoSettings);
|
Settings::getInstance()->setString("CollectionSystemsAuto", newAutoSettings);
|
||||||
Settings::getInstance()->setString("CollectionSystemsCustom", newCustomSettings);
|
Settings::getInstance()->setString("CollectionSystemsCustom", newCustomSettings);
|
||||||
Settings::getInstance()->setBool("FavFirstCustom", sortFavFirstCustomSwitch->getState());
|
Settings::getInstance()->setBool("FavFirstCustom", sortFavFirstCustomSwitch->getState());
|
||||||
Settings::getInstance()->setBool("UseCustomCollectionsSystem", bundleCustomCollections->getState());
|
Settings::getInstance()->setBool("UseCustomCollectionsSystem",
|
||||||
Settings::getInstance()->setBool("CollectionShowSystemInfo", toggleSystemNameInCollections->getState());
|
bundleCustomCollections->getState());
|
||||||
Settings::getInstance()->saveFile();
|
Settings::getInstance()->setBool("CollectionShowSystemInfo",
|
||||||
CollectionSystemManager::get()->loadEnabledListFromSettings();
|
toggleSystemNameInCollections->getState());
|
||||||
CollectionSystemManager::get()->updateSystemsList();
|
Settings::getInstance()->saveFile();
|
||||||
ViewController::get()->goToStart();
|
CollectionSystemManager::get()->loadEnabledListFromSettings();
|
||||||
ViewController::get()->reloadAll();
|
CollectionSystemManager::get()->updateSystemsList();
|
||||||
|
ViewController::get()->goToStart();
|
||||||
|
ViewController::get()->reloadAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GuiCollectionSystemsOptions::input(InputConfig* config, Input input)
|
bool GuiCollectionSystemsOptions::input(InputConfig* config, Input input)
|
||||||
{
|
{
|
||||||
bool consumed = GuiComponent::input(config, input);
|
bool consumed = GuiComponent::input(config, input);
|
||||||
if(consumed)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if(config->isMappedTo("b", input) && input.value != 0)
|
if(consumed)
|
||||||
{
|
return true;
|
||||||
applySettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(config->isMappedTo("b", input) && input.value != 0)
|
||||||
|
applySettings();
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<HelpPrompt> GuiCollectionSystemsOptions::getHelpPrompts()
|
std::vector<HelpPrompt> GuiCollectionSystemsOptions::getHelpPrompts()
|
||||||
{
|
{
|
||||||
std::vector<HelpPrompt> prompts = mMenu.getHelpPrompts();
|
std::vector<HelpPrompt> prompts = mMenu.getHelpPrompts();
|
||||||
prompts.push_back(HelpPrompt("a", "select"));
|
prompts.push_back(HelpPrompt("a", "select"));
|
||||||
prompts.push_back(HelpPrompt("b", "back"));
|
prompts.push_back(HelpPrompt("b", "back"));
|
||||||
return prompts;
|
return prompts;
|
||||||
}
|
}
|
||||||
|
|
||||||
HelpStyle GuiCollectionSystemsOptions::getHelpStyle()
|
HelpStyle GuiCollectionSystemsOptions::getHelpStyle()
|
||||||
{
|
{
|
||||||
HelpStyle style = HelpStyle();
|
HelpStyle style = HelpStyle();
|
||||||
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system");
|
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system");
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,10 @@
|
||||||
|
//
|
||||||
|
// GuiCollectionSystemsOptions.h
|
||||||
|
//
|
||||||
|
// User interface for the game collection settings.
|
||||||
|
// Submenu to the GuiMenu main menu.
|
||||||
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#ifndef ES_APP_GUIS_GUI_COLLECTION_SYSTEM_OPTIONS_H
|
#ifndef ES_APP_GUIS_GUI_COLLECTION_SYSTEM_OPTIONS_H
|
||||||
#define ES_APP_GUIS_GUI_COLLECTION_SYSTEM_OPTIONS_H
|
#define ES_APP_GUIS_GUI_COLLECTION_SYSTEM_OPTIONS_H
|
||||||
|
@ -12,28 +19,29 @@ class SystemData;
|
||||||
class GuiCollectionSystemsOptions : public GuiComponent
|
class GuiCollectionSystemsOptions : public GuiComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GuiCollectionSystemsOptions(Window* window);
|
GuiCollectionSystemsOptions(Window* window);
|
||||||
~GuiCollectionSystemsOptions();
|
~GuiCollectionSystemsOptions();
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
|
|
||||||
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
||||||
HelpStyle getHelpStyle() override;
|
HelpStyle getHelpStyle() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initializeMenu();
|
void initializeMenu();
|
||||||
void applySettings();
|
void applySettings();
|
||||||
void addSystemsToMenu();
|
void addSystemsToMenu();
|
||||||
void addEntry(const char* name, unsigned int color, bool add_arrow, const std::function<void()>& func);
|
void addEntry(const char* name, unsigned int color,
|
||||||
void updateSettings(std::string newAutoSettings, std::string newCustomSettings);
|
bool add_arrow, const std::function<void()>& func);
|
||||||
void createCollection(std::string inName);
|
void updateSettings(std::string newAutoSettings, std::string newCustomSettings);
|
||||||
void exitEditMode();
|
void createCollection(std::string inName);
|
||||||
std::shared_ptr< OptionListComponent<std::string> > autoOptionList;
|
void exitEditMode();
|
||||||
std::shared_ptr< OptionListComponent<std::string> > customOptionList;
|
std::shared_ptr< OptionListComponent<std::string> > autoOptionList;
|
||||||
std::shared_ptr<SwitchComponent> bundleCustomCollections;
|
std::shared_ptr< OptionListComponent<std::string> > customOptionList;
|
||||||
std::shared_ptr<SwitchComponent> sortFavFirstCustomSwitch;
|
std::shared_ptr<SwitchComponent> bundleCustomCollections;
|
||||||
std::shared_ptr<SwitchComponent> toggleSystemNameInCollections;
|
std::shared_ptr<SwitchComponent> sortFavFirstCustomSwitch;
|
||||||
MenuComponent mMenu;
|
std::shared_ptr<SwitchComponent> toggleSystemNameInCollections;
|
||||||
SystemData* mSystem;
|
MenuComponent mMenu;
|
||||||
|
SystemData* mSystem;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ES_APP_GUIS_GUI_COLLECTION_SYSTEM_OPTIONS_H
|
#endif // ES_APP_GUIS_GUI_COLLECTION_SYSTEM_OPTIONS_H
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
//
|
||||||
|
// GuiGeneralScreensaverOptions.cpp
|
||||||
|
//
|
||||||
|
// User interface for the screensaver options.
|
||||||
|
// Based on the GuiScreenSaverOptions template.
|
||||||
|
// Submenu to the GuiMenu main menu.
|
||||||
|
//
|
||||||
|
|
||||||
#include "guis/GuiGeneralScreensaverOptions.h"
|
#include "guis/GuiGeneralScreensaverOptions.h"
|
||||||
|
|
||||||
#include "components/OptionListComponent.h"
|
#include "components/OptionListComponent.h"
|
||||||
|
@ -8,58 +16,73 @@
|
||||||
#include "guis/GuiVideoScreensaverOptions.h"
|
#include "guis/GuiVideoScreensaverOptions.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
|
||||||
GuiGeneralScreensaverOptions::GuiGeneralScreensaverOptions(Window* window, const char* title) : GuiScreensaverOptions(window, title)
|
GuiGeneralScreensaverOptions::GuiGeneralScreensaverOptions(Window* window, const char* title)
|
||||||
|
: GuiScreensaverOptions(window, title)
|
||||||
{
|
{
|
||||||
// screensaver time
|
// Screensaver time.
|
||||||
auto screensaver_time = std::make_shared<SliderComponent>(mWindow, 0.f, 30.f, 1.f, "m");
|
auto screensaver_time = std::make_shared<SliderComponent>(mWindow, 0.f, 30.f, 1.f, "m");
|
||||||
screensaver_time->setValue((float)(Settings::getInstance()->getInt("ScreenSaverTime") / (1000 * 60)));
|
screensaver_time->setValue((float)(Settings::getInstance()->
|
||||||
addWithLabel("SCREENSAVER AFTER", screensaver_time);
|
getInt("ScreenSaverTime") / (1000 * 60)));
|
||||||
addSaveFunc([screensaver_time] {
|
addWithLabel("SCREENSAVER AFTER", screensaver_time);
|
||||||
Settings::getInstance()->setInt("ScreenSaverTime", (int)Math::round(screensaver_time->getValue()) * (1000 * 60));
|
addSaveFunc([screensaver_time] {
|
||||||
PowerSaver::updateTimeouts();
|
Settings::getInstance()->setInt("ScreenSaverTime",
|
||||||
});
|
(int)Math::round(screensaver_time->getValue()) * (1000 * 60));
|
||||||
|
PowerSaver::updateTimeouts();
|
||||||
|
});
|
||||||
|
|
||||||
// Allow ScreenSaver Controls - ScreenSaverControls
|
// Allow ScreenSaver Controls - ScreenSaverControls.
|
||||||
auto ss_controls = std::make_shared<SwitchComponent>(mWindow);
|
auto ss_controls = std::make_shared<SwitchComponent>(mWindow);
|
||||||
ss_controls->setState(Settings::getInstance()->getBool("ScreenSaverControls"));
|
ss_controls->setState(Settings::getInstance()->getBool("ScreenSaverControls"));
|
||||||
addWithLabel("SCREENSAVER CONTROLS", ss_controls);
|
addWithLabel("SCREENSAVER CONTROLS", ss_controls);
|
||||||
addSaveFunc([ss_controls] { Settings::getInstance()->setBool("ScreenSaverControls", ss_controls->getState()); });
|
addSaveFunc([ss_controls] { Settings::getInstance()->setBool("ScreenSaverControls",
|
||||||
|
ss_controls->getState()); });
|
||||||
|
|
||||||
// screensaver behavior
|
// Screensaver behavior.
|
||||||
auto screensaver_behavior = std::make_shared< OptionListComponent<std::string> >(mWindow, getHelpStyle(), "SCREENSAVER BEHAVIOR", false);
|
auto screensaver_behavior = std::make_shared<OptionListComponent<std::string>>
|
||||||
std::vector<std::string> screensavers;
|
(mWindow, getHelpStyle(), "SCREENSAVER BEHAVIOR", false);
|
||||||
screensavers.push_back("dim");
|
std::vector<std::string> screensavers;
|
||||||
screensavers.push_back("black");
|
screensavers.push_back("dim");
|
||||||
screensavers.push_back("random video");
|
screensavers.push_back("black");
|
||||||
screensavers.push_back("slideshow");
|
screensavers.push_back("random video");
|
||||||
for(auto it = screensavers.cbegin(); it != screensavers.cend(); it++)
|
screensavers.push_back("slideshow");
|
||||||
screensaver_behavior->add(*it, *it, Settings::getInstance()->getString("ScreenSaverBehavior") == *it);
|
for(auto it = screensavers.cbegin(); it != screensavers.cend(); it++)
|
||||||
addWithLabel("SCREENSAVER BEHAVIOR", screensaver_behavior);
|
screensaver_behavior->add(*it, *it, Settings::getInstance()->
|
||||||
addSaveFunc([this, screensaver_behavior] {
|
getString("ScreenSaverBehavior") == *it);
|
||||||
if (Settings::getInstance()->getString("ScreenSaverBehavior") != "random video" && screensaver_behavior->getSelected() == "random video") {
|
addWithLabel("SCREENSAVER BEHAVIOR", screensaver_behavior);
|
||||||
// if before it wasn't risky but now there's a risk of problems, show warning
|
addSaveFunc([this, screensaver_behavior] {
|
||||||
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(),
|
if (Settings::getInstance()->getString("ScreenSaverBehavior") !=
|
||||||
"The \"Random Video\" screensaver shows videos from your gamelist.\n\nIf you do not have videos, or if in several consecutive attempts the games it selects don't have videos it will default to black.\n\nMore options in the \"UI Settings\" > \"Video Screensaver\" menu.",
|
"random video" && screensaver_behavior->getSelected() == "random video") {
|
||||||
"OK", [] { return; }));
|
// If before it wasn't risky but now there's a risk of problems, show warning.
|
||||||
}
|
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(),
|
||||||
Settings::getInstance()->setString("ScreenSaverBehavior", screensaver_behavior->getSelected());
|
"THE \"RANDOM VIDEO\" SCREENSAVER SHOWS\nVIDEOS FROM YOUR GAMELISTS.\n\nIF YOU DO NOT "
|
||||||
PowerSaver::updateTimeouts();
|
"HAVE ANY VIDEOS, THE SCREENSAVER\nWILL DEFAULT TO \"BLACK\".\n\nSEE MORE "
|
||||||
});
|
"OPTIONS IN THE MENU \"UI SETTINGS\" >\n\"SCREENSAVER SETTINGS\" > "
|
||||||
|
"\"VIDEO SCREENSAVER SETTINGS\".",
|
||||||
|
"OK", [] { return; }));
|
||||||
|
}
|
||||||
|
Settings::getInstance()->setString("ScreenSaverBehavior",
|
||||||
|
screensaver_behavior->getSelected());
|
||||||
|
PowerSaver::updateTimeouts();
|
||||||
|
});
|
||||||
|
|
||||||
ComponentListRow row;
|
ComponentListRow row;
|
||||||
|
|
||||||
// show filtered menu
|
// Show filtered menu.
|
||||||
row.elements.clear();
|
row.elements.clear();
|
||||||
row.addElement(std::make_shared<TextComponent>(mWindow, "VIDEO SCREENSAVER SETTINGS", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
row.addElement(std::make_shared<TextComponent>(mWindow,
|
||||||
row.addElement(makeArrow(mWindow), false);
|
"VIDEO SCREENSAVER SETTINGS", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
||||||
row.makeAcceptInputHandler(std::bind(&GuiGeneralScreensaverOptions::openVideoScreensaverOptions, this));
|
row.addElement(makeArrow(mWindow), false);
|
||||||
addRow(row);
|
row.makeAcceptInputHandler(std::bind(
|
||||||
|
&GuiGeneralScreensaverOptions::openVideoScreensaverOptions, this));
|
||||||
|
addRow(row);
|
||||||
|
|
||||||
row.elements.clear();
|
row.elements.clear();
|
||||||
row.addElement(std::make_shared<TextComponent>(mWindow, "SLIDESHOW SCREENSAVER SETTINGS", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
row.addElement(std::make_shared<TextComponent>(mWindow,
|
||||||
row.addElement(makeArrow(mWindow), false);
|
"SLIDESHOW SCREENSAVER SETTINGS", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
|
||||||
row.makeAcceptInputHandler(std::bind(&GuiGeneralScreensaverOptions::openSlideshowScreensaverOptions, this));
|
row.addElement(makeArrow(mWindow), false);
|
||||||
addRow(row);
|
row.makeAcceptInputHandler(std::bind(
|
||||||
|
&GuiGeneralScreensaverOptions::openSlideshowScreensaverOptions, this));
|
||||||
|
addRow(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiGeneralScreensaverOptions::~GuiGeneralScreensaverOptions()
|
GuiGeneralScreensaverOptions::~GuiGeneralScreensaverOptions()
|
||||||
|
@ -67,10 +90,9 @@ GuiGeneralScreensaverOptions::~GuiGeneralScreensaverOptions()
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiGeneralScreensaverOptions::openVideoScreensaverOptions() {
|
void GuiGeneralScreensaverOptions::openVideoScreensaverOptions() {
|
||||||
mWindow->pushGui(new GuiVideoScreensaverOptions(mWindow, "VIDEO SCREENSAVER"));
|
mWindow->pushGui(new GuiVideoScreensaverOptions(mWindow, "VIDEO SCREENSAVER"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiGeneralScreensaverOptions::openSlideshowScreensaverOptions() {
|
void GuiGeneralScreensaverOptions::openSlideshowScreensaverOptions() {
|
||||||
mWindow->pushGui(new GuiSlideshowScreensaverOptions(mWindow, "SLIDESHOW SCREENSAVER"));
|
mWindow->pushGui(new GuiSlideshowScreensaverOptions(mWindow, "SLIDESHOW SCREENSAVER"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,11 @@
|
||||||
|
//
|
||||||
|
// GuiGeneralScreensaverOptions.h
|
||||||
|
//
|
||||||
|
// User interface for the screensaver options.
|
||||||
|
// Based on the GuiScreenSaverOptions template.
|
||||||
|
// Submenu to the GuiMenu main menu.
|
||||||
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#ifndef ES_APP_GUIS_GUI_GENERAL_SCREENSAVER_OPTIONS_H
|
#ifndef ES_APP_GUIS_GUI_GENERAL_SCREENSAVER_OPTIONS_H
|
||||||
#define ES_APP_GUIS_GUI_GENERAL_SCREENSAVER_OPTIONS_H
|
#define ES_APP_GUIS_GUI_GENERAL_SCREENSAVER_OPTIONS_H
|
||||||
|
@ -7,12 +15,12 @@
|
||||||
class GuiGeneralScreensaverOptions : public GuiScreensaverOptions
|
class GuiGeneralScreensaverOptions : public GuiScreensaverOptions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GuiGeneralScreensaverOptions(Window* window, const char* title);
|
GuiGeneralScreensaverOptions(Window* window, const char* title);
|
||||||
virtual ~GuiGeneralScreensaverOptions();
|
virtual ~GuiGeneralScreensaverOptions();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void openVideoScreensaverOptions();
|
void openVideoScreensaverOptions();
|
||||||
void openSlideshowScreensaverOptions();
|
void openSlideshowScreensaverOptions();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ES_APP_GUIS_GUI_GENERAL_SCREENSAVER_OPTIONS_H
|
#endif // ES_APP_GUIS_GUI_GENERAL_SCREENSAVER_OPTIONS_H
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
//
|
||||||
|
// GuiInfoPopup.cpp
|
||||||
|
//
|
||||||
|
// Popup window used for user notifications.
|
||||||
|
//
|
||||||
|
|
||||||
#include "guis/GuiInfoPopup.h"
|
#include "guis/GuiInfoPopup.h"
|
||||||
|
|
||||||
#include "components/ComponentGrid.h"
|
#include "components/ComponentGrid.h"
|
||||||
|
@ -5,112 +11,108 @@
|
||||||
#include "components/TextComponent.h"
|
#include "components/TextComponent.h"
|
||||||
#include <SDL_timer.h>
|
#include <SDL_timer.h>
|
||||||
|
|
||||||
GuiInfoPopup::GuiInfoPopup(Window* window, std::string message, int duration) :
|
GuiInfoPopup::GuiInfoPopup(
|
||||||
GuiComponent(window), mMessage(message), mDuration(duration), running(true)
|
Window* window,
|
||||||
|
std::string message,
|
||||||
|
int duration)
|
||||||
|
: GuiComponent(window),
|
||||||
|
mMessage(message),
|
||||||
|
mDuration(duration),
|
||||||
|
running(true)
|
||||||
{
|
{
|
||||||
mFrame = new NinePatchComponent(window);
|
mFrame = new NinePatchComponent(window);
|
||||||
float maxWidth = Renderer::getScreenWidth() * 0.9f;
|
float maxWidth = Renderer::getScreenWidth() * 0.9f;
|
||||||
float maxHeight = Renderer::getScreenHeight() * 0.2f;
|
float maxHeight = Renderer::getScreenHeight() * 0.2f;
|
||||||
|
|
||||||
std::shared_ptr<TextComponent> s = std::make_shared<TextComponent>(mWindow,
|
std::shared_ptr<TextComponent> s = std::make_shared<TextComponent>(mWindow, "",
|
||||||
"",
|
Font::get(FONT_SIZE_MINI), 0x444444FF, ALIGN_CENTER);
|
||||||
Font::get(FONT_SIZE_MINI),
|
|
||||||
0x444444FF,
|
|
||||||
ALIGN_CENTER);
|
|
||||||
|
|
||||||
// we do this to force the text container to resize and return an actual expected popup size
|
// We do this to force the text container to resize and return the actual expected popup size.
|
||||||
s->setSize(0,0);
|
s->setSize(0,0);
|
||||||
s->setText(message);
|
s->setText(message);
|
||||||
mSize = s->getSize();
|
mSize = s->getSize();
|
||||||
|
|
||||||
// confirm the size isn't larger than the screen width, otherwise cap it
|
// Confirm that the size isn't larger than the screen width, otherwise cap it.
|
||||||
if (mSize.x() > maxWidth) {
|
if (mSize.x() > maxWidth) {
|
||||||
s->setSize(maxWidth, mSize[1]);
|
s->setSize(maxWidth, mSize[1]);
|
||||||
mSize[0] = maxWidth;
|
mSize[0] = maxWidth;
|
||||||
}
|
}
|
||||||
if (mSize.y() > maxHeight) {
|
if (mSize.y() > maxHeight) {
|
||||||
s->setSize(mSize[0], maxHeight);
|
s->setSize(mSize[0], maxHeight);
|
||||||
mSize[1] = maxHeight;
|
mSize[1] = maxHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
// add a padding to the box
|
// Add a padding to the box.
|
||||||
int paddingX = (int) (Renderer::getScreenWidth() * 0.03f);
|
int paddingX = (int) (Renderer::getScreenWidth() * 0.03f);
|
||||||
int paddingY = (int) (Renderer::getScreenHeight() * 0.02f);
|
int paddingY = (int) (Renderer::getScreenHeight() * 0.02f);
|
||||||
mSize[0] = mSize.x() + paddingX;
|
mSize[0] = mSize.x() + paddingX;
|
||||||
mSize[1] = mSize.y() + paddingY;
|
mSize[1] = mSize.y() + paddingY;
|
||||||
|
|
||||||
float posX = Renderer::getScreenWidth()*0.5f - mSize.x()*0.5f;
|
float posX = Renderer::getScreenWidth()*0.5f - mSize.x()*0.5f;
|
||||||
float posY = Renderer::getScreenHeight() * 0.02f;
|
float posY = Renderer::getScreenHeight() * 0.02f;
|
||||||
|
|
||||||
setPosition(posX, posY, 0);
|
setPosition(posX, posY, 0);
|
||||||
|
|
||||||
mFrame->setImagePath(":/graphics/frame.png");
|
mFrame->setImagePath(":/graphics/frame.png");
|
||||||
mFrame->fitTo(mSize, Vector3f::Zero(), Vector2f(-32, -32));
|
mFrame->fitTo(mSize, Vector3f::Zero(), Vector2f(-32, -32));
|
||||||
addChild(mFrame);
|
addChild(mFrame);
|
||||||
|
|
||||||
// we only init the actual time when we first start to render
|
// We only initialize the actual time when we first start to render.
|
||||||
mStartTime = 0;
|
mStartTime = 0;
|
||||||
|
|
||||||
mGrid = new ComponentGrid(window, Vector2i(1, 3));
|
mGrid = new ComponentGrid(window, Vector2i(1, 3));
|
||||||
mGrid->setSize(mSize);
|
mGrid->setSize(mSize);
|
||||||
mGrid->setEntry(s, Vector2i(0, 1), false, true);
|
mGrid->setEntry(s, Vector2i(0, 1), false, true);
|
||||||
addChild(mGrid);
|
addChild(mGrid);
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiInfoPopup::~GuiInfoPopup()
|
GuiInfoPopup::~GuiInfoPopup()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiInfoPopup::render(const Transform4x4f& /*parentTrans*/)
|
void GuiInfoPopup::render(const Transform4x4f& /*parentTrans*/)
|
||||||
{
|
{
|
||||||
// we use identity as we want to render on a specific window position, not on the view
|
// We use Identity() as we want to render on a specific window position, not on the view.
|
||||||
Transform4x4f trans = getTransform() * Transform4x4f::Identity();
|
Transform4x4f trans = getTransform() * Transform4x4f::Identity();
|
||||||
if(running && updateState())
|
if (running && updateState()) {
|
||||||
{
|
// If we're still supposed to be rendering it.
|
||||||
// if we're still supposed to be rendering it
|
Renderer::setMatrix(trans);
|
||||||
Renderer::setMatrix(trans);
|
renderChildren(trans);
|
||||||
renderChildren(trans);
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GuiInfoPopup::updateState()
|
bool GuiInfoPopup::updateState()
|
||||||
{
|
{
|
||||||
int curTime = SDL_GetTicks();
|
int curTime = SDL_GetTicks();
|
||||||
|
|
||||||
// we only init the actual time when we first start to render
|
// We only initialize the actual time when we first start to render.
|
||||||
if(mStartTime == 0)
|
if (mStartTime == 0)
|
||||||
{
|
mStartTime = curTime;
|
||||||
mStartTime = curTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
// compute fade in effect
|
// Compute fade-in effect.
|
||||||
if (curTime - mStartTime > mDuration)
|
if (curTime - mStartTime > mDuration) {
|
||||||
{
|
// We're past the popup duration, no need to render.
|
||||||
// we're past the popup duration, no need to render
|
running = false;
|
||||||
running = false;
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
else if (curTime < mStartTime) {
|
||||||
else if (curTime < mStartTime) {
|
// If SDL reset.
|
||||||
// if SDL reset
|
running = false;
|
||||||
running = false;
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
else if (curTime - mStartTime <= 500) {
|
||||||
else if (curTime - mStartTime <= 500) {
|
alpha = ((curTime - mStartTime)*255/500);
|
||||||
alpha = ((curTime - mStartTime)*255/500);
|
}
|
||||||
}
|
else if (curTime - mStartTime < mDuration - 500) {
|
||||||
else if (curTime - mStartTime < mDuration - 500)
|
alpha = 255;
|
||||||
{
|
}
|
||||||
alpha = 255;
|
else {
|
||||||
}
|
alpha = ((-(curTime - mStartTime - mDuration)*255)/500);
|
||||||
else
|
}
|
||||||
{
|
mGrid->setOpacity((unsigned char)alpha);
|
||||||
alpha = ((-(curTime - mStartTime - mDuration)*255)/500);
|
|
||||||
}
|
|
||||||
mGrid->setOpacity((unsigned char)alpha);
|
|
||||||
|
|
||||||
// apply fade in effect to popup frame
|
// Apply fade-in effect to popup frame.
|
||||||
mFrame->setEdgeColor(0xFFFFFF00 | (unsigned char)(alpha));
|
mFrame->setEdgeColor(0xFFFFFF00 | (unsigned char)(alpha));
|
||||||
mFrame->setCenterColor(0xFFFFFF00 | (unsigned char)(alpha));
|
mFrame->setCenterColor(0xFFFFFF00 | (unsigned char)(alpha));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
|
@ -1,3 +1,9 @@
|
||||||
|
//
|
||||||
|
// GuiInfoPopup.h
|
||||||
|
//
|
||||||
|
// Popup window used for user notifications.
|
||||||
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#ifndef ES_APP_GUIS_GUI_INFO_POPUP_H
|
#ifndef ES_APP_GUIS_GUI_INFO_POPUP_H
|
||||||
#define ES_APP_GUIS_GUI_INFO_POPUP_H
|
#define ES_APP_GUIS_GUI_INFO_POPUP_H
|
||||||
|
@ -11,19 +17,20 @@ class NinePatchComponent;
|
||||||
class GuiInfoPopup : public GuiComponent, public Window::InfoPopup
|
class GuiInfoPopup : public GuiComponent, public Window::InfoPopup
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GuiInfoPopup(Window* window, std::string message, int duration);
|
GuiInfoPopup(Window* window, std::string message, int duration);
|
||||||
~GuiInfoPopup();
|
~GuiInfoPopup();
|
||||||
void render(const Transform4x4f& parentTrans) override;
|
void render(const Transform4x4f& parentTrans) override;
|
||||||
inline void stop() { running = false; };
|
inline void stop() { running = false; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string mMessage;
|
std::string mMessage;
|
||||||
int mDuration;
|
int mDuration;
|
||||||
int alpha;
|
int alpha;
|
||||||
bool updateState();
|
bool updateState();
|
||||||
int mStartTime;
|
int mStartTime;
|
||||||
ComponentGrid* mGrid;
|
ComponentGrid* mGrid;
|
||||||
NinePatchComponent* mFrame;
|
NinePatchComponent* mFrame;
|
||||||
bool running;
|
bool running;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ES_APP_GUIS_GUI_INFO_POPUP_H
|
#endif // ES_APP_GUIS_GUI_INFO_POPUP_H
|
||||||
|
|
|
@ -299,12 +299,12 @@ void GuiMenu::openUISettings()
|
||||||
s->addSaveFunc([ UImodeSelection, window, this] {
|
s->addSaveFunc([ UImodeSelection, window, this] {
|
||||||
std::string selectedMode = UImodeSelection->getSelected();
|
std::string selectedMode = UImodeSelection->getSelected();
|
||||||
if (selectedMode != "Full") {
|
if (selectedMode != "Full") {
|
||||||
std::string msg = "You are changing the UI to a restricted mode:\n" +
|
std::string msg = "YOU ARE CHANGING THE UI TO A RESTRICTED MODE:\n\"" +
|
||||||
selectedMode + "\n";
|
Utils::String::toUpper(selectedMode) + "\"\n";
|
||||||
msg += "This will hide most menu-options to prevent changes to the system.\n";
|
msg += "THIS WILL HIDE MOST MENU OPTIONS TO PREVENT CHANGES TO THE SYSTEM.\n";
|
||||||
msg += "To unlock and return to the full UI, enter this code: \n";
|
msg += "TO UNLOCK AND RETURN TO THE FULL UI, ENTER THIS CODE: \n";
|
||||||
msg += "\"" + UIModeController::getInstance()->getFormattedPassKeyStr() + "\"\n\n";
|
msg += "\"" + UIModeController::getInstance()->getFormattedPassKeyStr() + "\"\n\n";
|
||||||
msg += "Do you want to proceed?";
|
msg += "DO YOU WANT TO PROCEED?";
|
||||||
window->pushGui(new GuiMsgBox(window, this->getHelpStyle(), msg,
|
window->pushGui(new GuiMsgBox(window, this->getHelpStyle(), msg,
|
||||||
"YES", [selectedMode] {
|
"YES", [selectedMode] {
|
||||||
LOG(LogDebug) << "Setting UI mode to " << selectedMode;
|
LOG(LogDebug) << "Setting UI mode to " << selectedMode;
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
//
|
||||||
|
// GuiScreensaverOptions.cpp
|
||||||
|
//
|
||||||
|
// User interface template for the screensaver option GUIs.
|
||||||
|
//
|
||||||
|
|
||||||
#include "guis/GuiScreensaverOptions.h"
|
#include "guis/GuiScreensaverOptions.h"
|
||||||
|
|
||||||
#include "guis/GuiTextEditPopup.h"
|
#include "guis/GuiTextEditPopup.h"
|
||||||
|
@ -6,83 +12,87 @@
|
||||||
#include "SystemData.h"
|
#include "SystemData.h"
|
||||||
#include "Window.h"
|
#include "Window.h"
|
||||||
|
|
||||||
GuiScreensaverOptions::GuiScreensaverOptions(Window* window, const char* title) : GuiComponent(window), mMenu(window, title)
|
GuiScreensaverOptions::GuiScreensaverOptions(Window* window, const char* title)
|
||||||
|
: GuiComponent(window), mMenu(window, title)
|
||||||
{
|
{
|
||||||
addChild(&mMenu);
|
addChild(&mMenu);
|
||||||
|
mMenu.addButton("BACK", "back", [this] { delete this; });
|
||||||
|
|
||||||
mMenu.addButton("BACK", "back", [this] { delete this; });
|
setSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
|
||||||
|
mMenu.setPosition((mSize.x() - mMenu.getSize().x()) / 2, Renderer::getScreenHeight() * 0.15f);
|
||||||
setSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
|
|
||||||
mMenu.setPosition((mSize.x() - mMenu.getSize().x()) / 2, Renderer::getScreenHeight() * 0.15f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GuiScreensaverOptions::~GuiScreensaverOptions()
|
GuiScreensaverOptions::~GuiScreensaverOptions()
|
||||||
{
|
{
|
||||||
save();
|
save();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiScreensaverOptions::save()
|
void GuiScreensaverOptions::save()
|
||||||
{
|
{
|
||||||
if(!mSaveFuncs.size())
|
if(!mSaveFuncs.size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for(auto it = mSaveFuncs.cbegin(); it != mSaveFuncs.cend(); it++)
|
for(auto it = mSaveFuncs.cbegin(); it != mSaveFuncs.cend(); it++)
|
||||||
(*it)();
|
(*it)();
|
||||||
|
|
||||||
Settings::getInstance()->saveFile();
|
Settings::getInstance()->saveFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GuiScreensaverOptions::input(InputConfig* config, Input input)
|
bool GuiScreensaverOptions::input(InputConfig* config, Input input)
|
||||||
{
|
{
|
||||||
if (GuiComponent::input(config, input))
|
if (GuiComponent::input(config, input))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (config->isMappedTo("b", input) &&
|
if (config->isMappedTo("b", input) &&
|
||||||
input.value != 0) {
|
input.value != 0) {
|
||||||
delete this;
|
delete this;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
HelpStyle GuiScreensaverOptions::getHelpStyle()
|
HelpStyle GuiScreensaverOptions::getHelpStyle()
|
||||||
{
|
{
|
||||||
HelpStyle style = HelpStyle();
|
HelpStyle style = HelpStyle();
|
||||||
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system");
|
style.applyTheme(ViewController::get()->getState().getSystem()->getTheme(), "system");
|
||||||
return style;
|
return style;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<HelpPrompt> GuiScreensaverOptions::getHelpPrompts()
|
std::vector<HelpPrompt> GuiScreensaverOptions::getHelpPrompts()
|
||||||
{
|
{
|
||||||
std::vector<HelpPrompt> prompts = mMenu.getHelpPrompts();
|
std::vector<HelpPrompt> prompts = mMenu.getHelpPrompts();
|
||||||
prompts.push_back(HelpPrompt("b", "back"));
|
prompts.push_back(HelpPrompt("b", "back"));
|
||||||
return prompts;
|
return prompts;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiScreensaverOptions::addEditableTextComponent(ComponentListRow row, const std::string label, std::shared_ptr<GuiComponent> ed, std::string value)
|
void GuiScreensaverOptions::addEditableTextComponent(ComponentListRow row,
|
||||||
|
const std::string label, std::shared_ptr<GuiComponent> ed, std::string value)
|
||||||
{
|
{
|
||||||
row.elements.clear();
|
row.elements.clear();
|
||||||
|
|
||||||
auto lbl = std::make_shared<TextComponent>(mWindow, Utils::String::toUpper(label), Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
|
auto lbl = std::make_shared<TextComponent>(mWindow, Utils::String::toUpper(label),
|
||||||
row.addElement(lbl, true); // label
|
Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
|
||||||
|
row.addElement(lbl, true); // Label.
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
||||||
bracket->setImage(":/graphics/arrow.svg");
|
bracket->setImage(":/graphics/arrow.svg");
|
||||||
bracket->setResize(Vector2f(0, lbl->getFont()->getLetterHeight()));
|
bracket->setResize(Vector2f(0, lbl->getFont()->getLetterHeight()));
|
||||||
row.addElement(bracket, false);
|
row.addElement(bracket, false);
|
||||||
|
|
||||||
auto updateVal = [ed](const std::string& newVal) { ed->setValue(newVal); }; // ok callback (apply new value to ed)
|
// OK callback (apply new value to ed).
|
||||||
row.makeAcceptInputHandler([this, label, ed, updateVal] {
|
auto updateVal = [ed](const std::string& newVal) { ed->setValue(newVal); };
|
||||||
mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), label, ed->getValue(), updateVal, false));
|
row.makeAcceptInputHandler([this, label, ed, updateVal] {
|
||||||
});
|
mWindow->pushGui(new GuiTextEditPopup(mWindow, getHelpStyle(), label,
|
||||||
assert(ed);
|
ed->getValue(), updateVal, false));
|
||||||
addRow(row);
|
});
|
||||||
ed->setValue(value);
|
assert(ed);
|
||||||
|
addRow(row);
|
||||||
|
ed->setValue(value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
//
|
||||||
|
// GuiScreensaverOptions.h
|
||||||
|
//
|
||||||
|
// User interface template for the screensaver option GUIs.
|
||||||
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#ifndef ES_APP_GUIS_GUI_SCREENSAVER_OPTIONS_H
|
#ifndef ES_APP_GUIS_GUI_SCREENSAVER_OPTIONS_H
|
||||||
#define ES_APP_GUIS_GUI_SCREENSAVER_OPTIONS_H
|
#define ES_APP_GUIS_GUI_SCREENSAVER_OPTIONS_H
|
||||||
|
@ -8,22 +14,24 @@
|
||||||
class GuiScreensaverOptions : public GuiComponent
|
class GuiScreensaverOptions : public GuiComponent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GuiScreensaverOptions(Window* window, const char* title);
|
GuiScreensaverOptions(Window* window, const char* title);
|
||||||
virtual ~GuiScreensaverOptions(); // just calls save();
|
virtual ~GuiScreensaverOptions(); // Just calls save()
|
||||||
|
|
||||||
virtual void save();
|
virtual void save();
|
||||||
inline void addRow(const ComponentListRow& row) { mMenu.addRow(row); };
|
inline void addRow(const ComponentListRow& row) { mMenu.addRow(row); };
|
||||||
inline void addWithLabel(const std::string& label, const std::shared_ptr<GuiComponent>& comp) { mMenu.addWithLabel(label, comp); };
|
inline void addWithLabel(const std::string& label,
|
||||||
inline void addSaveFunc(const std::function<void()>& func) { mSaveFuncs.push_back(func); };
|
const std::shared_ptr<GuiComponent>& comp) { mMenu.addWithLabel(label, comp); };
|
||||||
void addEditableTextComponent(ComponentListRow row, const std::string label, std::shared_ptr<GuiComponent> ed, std::string value);
|
inline void addSaveFunc(const std::function<void()>& func) { mSaveFuncs.push_back(func); };
|
||||||
|
void addEditableTextComponent(ComponentListRow row,
|
||||||
|
const std::string label, std::shared_ptr<GuiComponent> ed, std::string value);
|
||||||
|
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
std::vector<HelpPrompt> getHelpPrompts() override;
|
std::vector<HelpPrompt> getHelpPrompts() override;
|
||||||
HelpStyle getHelpStyle() override;
|
HelpStyle getHelpStyle() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MenuComponent mMenu;
|
MenuComponent mMenu;
|
||||||
std::vector< std::function<void()> > mSaveFuncs;
|
std::vector< std::function<void()> > mSaveFuncs;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ES_APP_GUIS_GUI_SCREENSAVER_OPTIONS_H
|
#endif // ES_APP_GUIS_GUI_SCREENSAVER_OPTIONS_H
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
//
|
||||||
|
// Scripting.cpp
|
||||||
|
//
|
||||||
|
// Executes custom scripts for various events in EmulationStation.
|
||||||
|
// By calling fireEvent() the scripts inside the directory corresponding to the
|
||||||
|
// argument 'eventName' will be executed with arg1 and arg2 as the script arguments.
|
||||||
|
//
|
||||||
|
// The scripts are searched for in $HOME/.emulationstation/scripts/<eventName>.
|
||||||
|
// For example, if the event is called 'game-start', all scripts inside the directory
|
||||||
|
// $HOME/.emulationstation/scripts/game-start/ will be executed.
|
||||||
|
//
|
||||||
|
|
||||||
#include "Scripting.h"
|
#include "Scripting.h"
|
||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Platform.h"
|
#include "Platform.h"
|
||||||
|
@ -12,25 +24,21 @@ namespace Scripting
|
||||||
std::list<std::string> scriptDirList;
|
std::list<std::string> scriptDirList;
|
||||||
std::string test;
|
std::string test;
|
||||||
|
|
||||||
// check in exepath
|
// Check in homepath.
|
||||||
test = Utils::FileSystem::getExePath() + "/scripts/" + eventName;
|
|
||||||
if(Utils::FileSystem::exists(test))
|
|
||||||
scriptDirList.push_back(test);
|
|
||||||
|
|
||||||
// check in homepath
|
|
||||||
test = Utils::FileSystem::getHomePath() + "/.emulationstation/scripts/" + eventName;
|
test = Utils::FileSystem::getHomePath() + "/.emulationstation/scripts/" + eventName;
|
||||||
if(Utils::FileSystem::exists(test))
|
if(Utils::FileSystem::exists(test))
|
||||||
scriptDirList.push_back(test);
|
scriptDirList.push_back(test);
|
||||||
|
|
||||||
for(std::list<std::string>::const_iterator dirIt = scriptDirList.cbegin(); dirIt != scriptDirList.cend(); ++dirIt) {
|
for(std::list<std::string>::const_iterator dirIt = scriptDirList.cbegin();
|
||||||
|
dirIt != scriptDirList.cend(); ++dirIt) {
|
||||||
std::list<std::string> scripts = Utils::FileSystem::getDirContent(*dirIt);
|
std::list<std::string> scripts = Utils::FileSystem::getDirContent(*dirIt);
|
||||||
for (std::list<std::string>::const_iterator it = scripts.cbegin(); it != scripts.cend(); ++it) {
|
for (std::list<std::string>::const_iterator it = scripts.cbegin();
|
||||||
// append folder to path
|
it != scripts.cend(); ++it) {
|
||||||
|
// Append folder to path.
|
||||||
std::string script = *it + " \"" + arg1 + "\" \"" + arg2 + "\"";
|
std::string script = *it + " \"" + arg1 + "\" \"" + arg2 + "\"";
|
||||||
LOG(LogDebug) << " executing: " << script;
|
LOG(LogDebug) << " executing: " << script;
|
||||||
runSystemCommand(script);
|
runSystemCommand(script);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} // Scripting::
|
|
||||||
|
|
|
@ -1,3 +1,15 @@
|
||||||
|
//
|
||||||
|
// Scripting.h
|
||||||
|
//
|
||||||
|
// Executes custom scripts for various events in EmulationStation.
|
||||||
|
// By calling fireEvent() the scripts inside the directory corresponding to the
|
||||||
|
// argument 'eventName' will be executed with arg1 and arg2 as the script arguments.
|
||||||
|
//
|
||||||
|
// The scripts are searched for in $HOME/.emulationstation/scripts/<eventName>.
|
||||||
|
// For example, if the event is called 'game-start', all scripts inside the directory
|
||||||
|
// $HOME/.emulationstation/scripts/game-start/ will be executed.
|
||||||
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#ifndef ES_CORE_SCRIPTING_H
|
#ifndef ES_CORE_SCRIPTING_H
|
||||||
#define ES_CORE_SCRIPTING_H
|
#define ES_CORE_SCRIPTING_H
|
||||||
|
@ -6,7 +18,8 @@
|
||||||
|
|
||||||
namespace Scripting
|
namespace Scripting
|
||||||
{
|
{
|
||||||
void fireEvent(const std::string& eventName, const std::string& arg1="", const std::string& arg2="");
|
void fireEvent(const std::string& eventName,
|
||||||
} // Scripting::
|
const std::string& arg1="", const std::string& arg2="");
|
||||||
|
}
|
||||||
|
|
||||||
#endif //ES_CORE_SCRIPTING_H
|
#endif //ES_CORE_SCRIPTING_H
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
//
|
//
|
||||||
// ThemeData.cpp
|
// ThemeData.cpp
|
||||||
//
|
//
|
||||||
// Theme handling.
|
// Finds available themes on the file system and loads these,
|
||||||
|
// including the parsing of individual theme components
|
||||||
|
// (includes, features, variables, views, elements).
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "ThemeData.h"
|
#include "ThemeData.h"
|
||||||
|
@ -417,7 +419,6 @@ void ThemeData::parseView(const pugi::xml_node& root, ThemeView& view)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ThemeData::parseElement(const pugi::xml_node& root,
|
void ThemeData::parseElement(const pugi::xml_node& root,
|
||||||
const std::map<std::string, ElementPropertyType>& typeMap, ThemeElement& element)
|
const std::map<std::string, ElementPropertyType>& typeMap, ThemeElement& element)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
//
|
//
|
||||||
// ThemeData.h
|
// ThemeData.h
|
||||||
//
|
//
|
||||||
// Theme handling.
|
// Finds available themes on the file system and loads these,
|
||||||
|
// including the parsing of individual theme components
|
||||||
|
// (includes, features, variables, views, elements).
|
||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -148,7 +150,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ThemeData();
|
ThemeData();
|
||||||
|
|
||||||
// Throws ThemeException.
|
// Throws ThemeException.
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,3 +1,9 @@
|
||||||
|
//
|
||||||
|
// FileSystemUtil.h
|
||||||
|
//
|
||||||
|
// Low-level filesystem functions.
|
||||||
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#ifndef ES_CORE_UTILS_FILE_SYSTEM_UTIL_H
|
#ifndef ES_CORE_UTILS_FILE_SYSTEM_UTIL_H
|
||||||
#define ES_CORE_UTILS_FILE_SYSTEM_UTIL_H
|
#define ES_CORE_UTILS_FILE_SYSTEM_UTIL_H
|
||||||
|
@ -7,42 +13,45 @@
|
||||||
|
|
||||||
namespace Utils
|
namespace Utils
|
||||||
{
|
{
|
||||||
namespace FileSystem
|
namespace FileSystem
|
||||||
{
|
{
|
||||||
typedef std::list<std::string> stringList;
|
typedef std::list<std::string> stringList;
|
||||||
|
|
||||||
stringList getDirContent (const std::string& _path, const bool _recursive = false);
|
stringList getDirContent(const std::string& _path,
|
||||||
stringList getPathList (const std::string& _path);
|
const bool _recursive = false);
|
||||||
void setHomePath (const std::string& _path);
|
stringList getPathList(const std::string& _path);
|
||||||
std::string getHomePath ();
|
void setHomePath(const std::string& _path);
|
||||||
std::string getCWDPath ();
|
std::string getHomePath();
|
||||||
void setExePath (const std::string& _path);
|
std::string getCWDPath();
|
||||||
std::string getExePath ();
|
void setExePath(const std::string& _path);
|
||||||
std::string getInstallPrefixPath ();
|
std::string getExePath();
|
||||||
std::string getPreferredPath (const std::string& _path);
|
std::string getInstallPrefixPath ();
|
||||||
std::string getGenericPath (const std::string& _path);
|
std::string getPreferredPath(const std::string& _path);
|
||||||
std::string getEscapedPath (const std::string& _path);
|
std::string getGenericPath(const std::string& _path);
|
||||||
std::string getCanonicalPath (const std::string& _path);
|
std::string getEscapedPath(const std::string& _path);
|
||||||
std::string getAbsolutePath (const std::string& _path, const std::string& _base = getCWDPath());
|
std::string getCanonicalPath(const std::string& _path);
|
||||||
std::string getParent (const std::string& _path);
|
std::string getAbsolutePath(const std::string& _path,
|
||||||
std::string getFileName (const std::string& _path);
|
const std::string& _base = getCWDPath());
|
||||||
std::string getStem (const std::string& _path);
|
std::string getParent(const std::string& _path);
|
||||||
std::string getExtension (const std::string& _path);
|
std::string getFileName(const std::string& _path);
|
||||||
std::string resolveRelativePath(const std::string& _path, const std::string& _relativeTo, const bool _allowHome);
|
std::string getStem(const std::string& _path);
|
||||||
std::string createRelativePath (const std::string& _path, const std::string& _relativeTo, const bool _allowHome);
|
std::string getExtension(const std::string& _path);
|
||||||
std::string removeCommonPath (const std::string& _path, const std::string& _common, bool& _contains);
|
std::string resolveRelativePath(const std::string& _path,
|
||||||
std::string resolveSymlink (const std::string& _path);
|
const std::string& _relativeTo, const bool _allowHome);
|
||||||
bool removeFile (const std::string& _path);
|
std::string createRelativePath(const std::string& _path,
|
||||||
bool createDirectory (const std::string& _path);
|
const std::string& _relativeTo, const bool _allowHome);
|
||||||
bool exists (const std::string& _path);
|
std::string removeCommonPath(const std::string& _path,
|
||||||
bool isAbsolute (const std::string& _path);
|
const std::string& _common, bool& _contains);
|
||||||
bool isRegularFile (const std::string& _path);
|
std::string resolveSymlink(const std::string& _path);
|
||||||
bool isDirectory (const std::string& _path);
|
bool removeFile(const std::string& _path);
|
||||||
bool isSymlink (const std::string& _path);
|
bool createDirectory(const std::string& _path);
|
||||||
bool isHidden (const std::string& _path);
|
bool exists(const std::string& _path);
|
||||||
|
bool isAbsolute(const std::string& _path);
|
||||||
} // FileSystem::
|
bool isRegularFile(const std::string& _path);
|
||||||
|
bool isDirectory(const std::string& _path);
|
||||||
} // Utils::
|
bool isSymlink(const std::string& _path);
|
||||||
|
bool isHidden(const std::string& _path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // ES_CORE_UTILS_FILE_SYSTEM_UTIL_H
|
#endif // ES_CORE_UTILS_FILE_SYSTEM_UTIL_H
|
||||||
|
|
Loading…
Reference in a new issue