Some cosmetic code cleanup and some small documentation updates.

This commit is contained in:
Leon Styhre 2020-11-08 22:58:06 +01:00
parent 162d893ea0
commit 2c3b452401
9 changed files with 112 additions and 113 deletions

View file

@ -48,6 +48,7 @@ Many bugs have been fixed, and numerous features that were only partially implem
* GUI-configurable option to sort favorite games above non-favorite games (favorites marked with stars)
* GUI-configurable option to sort folders on top of the gamelists
* Added a gamelist info text field displaying the game count, any applied filters as well as an icon if a folder has been entered
* Expanded the gamelist filter functionality to include completed and broken games as well as the ability to filter on game names (via free text entry)
* Expanded the metadata for folders and made it possible to mark them as favorites
* Added new component GuiComplexTextEditPopup to handle changes to configuration file entries and similar
* Speed improvements and optimizations, the application now starts faster and feels more responsive

View file

@ -647,7 +647,7 @@ This setting enables the 'Y' button for quickly toggling a game as favorite. Alt
**Enable gamelist filters**
Activating or deactivating the ability to filter your gamelists. Can normally be left on.
Activating or deactivating the ability to filter your gamelists. This can normally be left enabled.
**Enable quick system select**
@ -896,6 +896,8 @@ Choosing this entry opens a separate screen where it's possible to apply a filte
The following filters can be applied:
**Text Filter (Game Name)**
**Favorites**
**Genre**
@ -914,9 +916,9 @@ The following filters can be applied:
**Hidden**
All possible filter values are assembled from metadata from the actual gamelist, so if there for instance are no games marked as completed, the Completed filter will only have the selectable option 'False', meaning 'True' will be missing.
With the exception of the text filter, all available filter values are assembled from metadata from the actual gamelist, so if there for instance are no games marked as completed, the Completed filter will only have the selectable option 'False', i.e. 'True' will be missing.
Be aware that although folders can have most of these metadata values set, the filters are only applied to files. So if you for example set a filter to only display your favorite games, any folder that contains a favorite game will be displayed, and other folders which are themselves marked as favorite but that do not contain any favorite games will be hidden.
Be aware that although folders can have most of the metadata values set, the filters are only applied to files (this is also true for the text/game name filter). So if you for example set a filter to only display your favorite games, any folder that contains a favorite game will be displayed, and other folders which are themselves marked as favorites but that do not contain any favorite games will be hidden.
The filters are always applied for the complete game system, including all folder contents.

View file

@ -463,16 +463,6 @@ void CollectionSystemManager::updateCollectionSystem(FileData* file, CollectionS
}
}
void CollectionSystemManager::trimCollectionCount(FileData* rootFolder, int limit)
{
SystemData* curSys = rootFolder->getSystem();
while (static_cast<int>(rootFolder->getChildrenListToDisplay().size()) > limit) {
CollectionFileData* gameToRemove =
(CollectionFileData*)rootFolder->getChildrenListToDisplay().back();
ViewController::get()->getGameListView(curSys).get()->remove(gameToRemove, false);
}
}
// Delete all collection files from collection systems related to the source file.
void CollectionSystemManager::deleteCollectionFiles(FileData* file)
{
@ -742,22 +732,6 @@ SystemData* CollectionSystemManager::getSystemToView(SystemData* sys)
return systemToView;
}
// Functions below to Handle loading of collection systems, creating empty ones,
// and populating on demand.
// Loads Automatic Collection systems (All, Favorites, Last Played).
void CollectionSystemManager::initAutoCollectionSystems()
{
for (std::map<std::string, CollectionSystemDecl, stringComparator>::const_iterator
it = mCollectionSystemDeclsIndex.cbegin();
it != mCollectionSystemDeclsIndex.cend() ; it++ ) {
CollectionSystemDecl sysDecl = it->second;
if (!sysDecl.isCustom)
createNewCollectionEntry(sysDecl.name, sysDecl);
}
}
// Used to generate a description of the collection, all other metadata fields are hidden.
FileData* CollectionSystemManager::updateCollectionFolderMetadata(SystemData* sys)
{
@ -846,6 +820,59 @@ FileData* CollectionSystemManager::updateCollectionFolderMetadata(SystemData* sy
return nullptr;
}
// Return the unused folders from current theme path.
std::vector<std::string> CollectionSystemManager::getUnusedSystemsFromTheme()
{
// Get used systems in es_systems.cfg.
std::vector<std::string> systemsInUse = getSystemsFromConfig();
// Get available folders in theme.
std::vector<std::string> themeSys = getSystemsFromTheme();
// Get folders assigned to custom collections.
std::vector<std::string> autoSys = getCollectionThemeFolders(false);
// Get folder assigned to custom collections.
std::vector<std::string> customSys = getCollectionThemeFolders(true);
// Get folders assigned to user collections.
std::vector<std::string> userSys = getUserCollectionThemeFolders();
// Add them all to the list of systems in use.
systemsInUse.insert(systemsInUse.cend(), autoSys.cbegin(), autoSys.cend());
systemsInUse.insert(systemsInUse.cend(), customSys.cbegin(), customSys.cend());
systemsInUse.insert(systemsInUse.cend(), userSys.cbegin(), userSys.cend());
for (auto sysIt = themeSys.cbegin(); sysIt != themeSys.cend(); ) {
if (std::find(systemsInUse.cbegin(), systemsInUse.cend(), *sysIt) != systemsInUse.cend())
sysIt = themeSys.erase(sysIt);
else
sysIt++;
}
return themeSys;
}
SystemData* CollectionSystemManager::addNewCustomCollection(std::string name)
{
CollectionSystemDecl decl = mCollectionSystemDeclsIndex[myCollectionsName];
decl.themeFolder = name;
decl.name = name;
decl.longName = name;
return createNewCollectionEntry(name, decl, true, true);
}
// Functions below to Handle loading of collection systems, creating empty ones,
// and populating on demand.
// Loads Automatic Collection systems (All, Favorites, Last Played).
void CollectionSystemManager::initAutoCollectionSystems()
{
for (std::map<std::string, CollectionSystemDecl, stringComparator>::const_iterator
it = mCollectionSystemDeclsIndex.cbegin();
it != mCollectionSystemDeclsIndex.cend() ; it++ ) {
CollectionSystemDecl sysDecl = it->second;
if (!sysDecl.isCustom)
createNewCollectionEntry(sysDecl.name, sysDecl);
}
}
void CollectionSystemManager::initCustomCollectionSystems()
{
std::vector<std::string> systems = getCollectionsFromConfigFolder();
@ -863,16 +890,6 @@ SystemData* CollectionSystemManager::getAllGamesCollection()
return allSysData->system;
}
SystemData* CollectionSystemManager::addNewCustomCollection(std::string name)
{
CollectionSystemDecl decl = mCollectionSystemDeclsIndex[myCollectionsName];
decl.themeFolder = name;
decl.name = name;
decl.longName = name;
return createNewCollectionEntry(name, decl, true, true);
}
// Create a new empty collection system based on the name and declaration.
SystemData* CollectionSystemManager::createNewCollectionEntry(
std::string name, CollectionSystemDecl sysDecl, bool index, bool custom)
@ -1156,33 +1173,6 @@ std::vector<std::string> CollectionSystemManager::getSystemsFromTheme()
return systems;
}
// Return the unused folders from current theme path.
std::vector<std::string> CollectionSystemManager::getUnusedSystemsFromTheme()
{
// Get used systems in es_systems.cfg.
std::vector<std::string> systemsInUse = getSystemsFromConfig();
// Get available folders in theme.
std::vector<std::string> themeSys = getSystemsFromTheme();
// Get folders assigned to custom collections.
std::vector<std::string> autoSys = getCollectionThemeFolders(false);
// Get folder assigned to custom collections.
std::vector<std::string> customSys = getCollectionThemeFolders(true);
// Get folders assigned to user collections.
std::vector<std::string> userSys = getUserCollectionThemeFolders();
// Add them all to the list of systems in use.
systemsInUse.insert(systemsInUse.cend(), autoSys.cbegin(), autoSys.cend());
systemsInUse.insert(systemsInUse.cend(), customSys.cbegin(), customSys.cend());
systemsInUse.insert(systemsInUse.cend(), userSys.cbegin(), userSys.cend());
for (auto sysIt = themeSys.cbegin(); sysIt != themeSys.cend(); ) {
if (std::find(systemsInUse.cbegin(), systemsInUse.cend(), *sysIt) != systemsInUse.cend())
sysIt = themeSys.erase(sysIt);
else
sysIt++;
}
return themeSys;
}
// Return which collection config files exist in the user folder.
std::vector<std::string> CollectionSystemManager::getCollectionsFromConfigFolder()
{
@ -1240,6 +1230,16 @@ std::vector<std::string> CollectionSystemManager::getUserCollectionThemeFolders(
return systems;
}
void CollectionSystemManager::trimCollectionCount(FileData* rootFolder, int limit)
{
SystemData* curSys = rootFolder->getSystem();
while (static_cast<int>(rootFolder->getChildrenListToDisplay().size()) > limit) {
CollectionFileData* gameToRemove =
(CollectionFileData*)rootFolder->getChildrenListToDisplay().back();
ViewController::get()->getGameListView(curSys).get()->remove(gameToRemove, false);
}
}
// Return whether a specific folder exists in the theme.
bool CollectionSystemManager::themeFolderExists(std::string folder)
{

View file

@ -86,8 +86,8 @@ public:
inline std::map<std::string, CollectionSystemData, stringComparator>
getCustomCollectionSystems() { return mCustomCollectionSystemsData; };
inline SystemData* getCustomCollectionsBundle() { return mCustomCollectionsBundle; };
std::vector<std::string> getUnusedSystemsFromTheme();
SystemData* addNewCustomCollection(std::string name);
inline bool isEditing() { return mIsEditingCustom; };
inline std::string getEditingCollection() { return mEditingCollection; };
bool isThemeGenericCollectionCompatible(bool genericCustomCollections);
bool isThemeCustomCollectionCompatible(std::vector<std::string> stringVector);
@ -95,13 +95,14 @@ public:
void setEditMode(std::string collectionName);
void exitEditMode();
inline bool isEditing() { return mIsEditingCustom; };
inline std::string getEditingCollection() { return mEditingCollection; };
bool inCustomCollection(const std::string& collectionName, FileData* gameFile);
bool toggleGameInCollection(FileData* file);
SystemData* getSystemToView(SystemData* sys);
FileData* updateCollectionFolderMetadata(SystemData* sys);
std::vector<std::string> getUnusedSystemsFromTheme();
SystemData* addNewCustomCollection(std::string name);
private:
static CollectionSystemManager* sInstance;

View file

@ -18,26 +18,17 @@
#include "Settings.h"
#include "SystemData.h"
#include <rapidjson/document.h>
#include <rapidjson/error/en.h>
#include <exception>
#include <map>
#include <pugixml.hpp>
// When raspbian will get an up to date version of rapidjson we'll be
// able to have it throw in case of error with the following:
//ifndef RAPIDJSON_ASSERT
//#define RAPIDJSON_ASSERT(x) \
// if (!(x)) { \
// throw std::runtime_error("rapidjson internal assertion failure: " #x); \
// }
//#endif // RAPIDJSON_ASSERT
#include <rapidjson/document.h>
#include <rapidjson/error/en.h>
using namespace PlatformIds;
using namespace rapidjson;
namespace {
namespace
{
TheGamesDBJSONRequestResources resources;
}
@ -117,8 +108,7 @@ const std::map<PlatformId, std::string> gamesdb_new_platformid_map {
{ TANDY, "4941" },
};
void thegamesdb_generate_json_scraper_requests(
const ScraperSearchParams& params,
void thegamesdb_generate_json_scraper_requests(const ScraperSearchParams& params,
std::queue<std::unique_ptr<ScraperRequest>>& requests,
std::vector<ScraperSearchResult>& results)
{
@ -242,7 +232,7 @@ std::string getDeveloperString(const Value& v)
std::string out = "";
bool first = true;
for (int i = 0; i < (int)v.Size(); ++i) {
for (int i = 0; i < static_cast<int>(v.Size()); ++i) {
auto mapIt = resources.gamesdb_new_developers_map.find(getIntOrThrow(v[i]));
if (mapIt == resources.gamesdb_new_developers_map.cend())
@ -264,7 +254,7 @@ std::string getPublisherString(const Value& v)
std::string out = "";
bool first = true;
for (int i = 0; i < (int)v.Size(); ++i) {
for (int i = 0; i < static_cast<int>(v.Size()); ++i) {
auto mapIt = resources.gamesdb_new_publishers_map.find(getIntOrThrow(v[i]));
if (mapIt == resources.gamesdb_new_publishers_map.cend())
@ -286,8 +276,9 @@ std::string getGenreString(const Value& v)
std::string out = "";
bool first = true;
for (int i = 0; i < (int)v.Size(); ++i) {
for (int i = 0; i < static_cast<int>(v.Size()); ++i) {
auto mapIt = resources.gamesdb_new_genres_map.find(getIntOrThrow(v[i]));
if (mapIt == resources.gamesdb_new_genres_map.cend())
continue;
@ -457,7 +448,7 @@ void TheGamesDBJSONRequest::process(const std::unique_ptr<HttpReq>& req,
const Value& games = doc["data"]["games"];
resources.ensureResources();
for (int i = 0; i < (int)games.Size(); ++i) {
for (int i = 0; i < static_cast<int>(games.Size()); ++i) {
auto& v = games[i];
try {
processGame(v, results);

View file

@ -16,20 +16,18 @@ namespace pugi {
class xml_document;
}
void thegamesdb_generate_json_scraper_requests(
const ScraperSearchParams& params,
void thegamesdb_generate_json_scraper_requests(const ScraperSearchParams& params,
std::queue<std::unique_ptr<ScraperRequest>>& requests,
std::vector<ScraperSearchResult>& results);
void thegamesdb_generate_json_scraper_requests(
const std::string& gameIDs,
void thegamesdb_generate_json_scraper_requests(const std::string& gameIDs,
std::queue<std::unique_ptr<ScraperRequest>>& requests,
std::vector<ScraperSearchResult>& results);
class TheGamesDBJSONRequest : public ScraperHttpRequest
{
public:
// ctor for a GetGameList request.
// Constructor for a GetGameList request.
TheGamesDBJSONRequest(
std::queue<std::unique_ptr<ScraperRequest>>& requestsWrite,
std::vector<ScraperSearchResult>& resultsWrite,
@ -38,18 +36,13 @@ class TheGamesDBJSONRequest : public ScraperHttpRequest
mRequestQueue(&requestsWrite)
{
}
// ctor for a GetGame request
TheGamesDBJSONRequest(
std::vector<ScraperSearchResult>& resultsWrite,
const std::string& url)
: ScraperHttpRequest(resultsWrite, url),
mRequestQueue(nullptr)
// Constructior for a GetGame request
TheGamesDBJSONRequest(std::vector<ScraperSearchResult>& resultsWrite, const std::string& url)
: ScraperHttpRequest(resultsWrite, url), mRequestQueue(nullptr)
{
}
protected:
//void retrieveMediaURLs()
void process(const std::unique_ptr<HttpReq>& req,
std::vector<ScraperSearchResult>& results) override;
bool isGameRequest() { return !mRequestQueue; }

View file

@ -23,7 +23,6 @@ namespace GridFlags
enum Border : unsigned int {
BORDER_NONE = 0,
BORDER_TOP = 1,
BORDER_BOTTOM = 2,
BORDER_LEFT = 4,
@ -96,11 +95,22 @@ private:
GridFlags::UpdateType updateType;
unsigned int border;
GridEntry(const Vector2i& p = Vector2i::Zero(), const Vector2i& d = Vector2i::Zero(),
const std::shared_ptr<GuiComponent>& cmp = nullptr, bool f = false, bool r = true,
GridFlags::UpdateType u = GridFlags::UPDATE_ALWAYS, unsigned int b =
GridFlags::BORDER_NONE) :
pos(p), dim(d), component(cmp), canFocus(f), resize(r), updateType(u), border(b)
GridEntry(
const Vector2i& p = Vector2i::Zero(),
const Vector2i& d = Vector2i::Zero(),
const std::shared_ptr<GuiComponent>& cmp = nullptr,
bool f = false,
bool r = true,
GridFlags::UpdateType u = GridFlags::UPDATE_ALWAYS,
unsigned int b =
GridFlags::BORDER_NONE)
: pos(p),
dim(d),
component(cmp),
canFocus(f),
resize(r),
updateType(u),
border(b)
{};
operator bool() const

View file

@ -141,7 +141,7 @@ void ImageComponent::resize()
mSize[0] = Math::round(mSize.x());
mSize[1] = Math::round(mSize.y());
// mSize.y() should already be rounded.
mTexture->rasterizeAt((size_t)mSize.x(), (size_t)mSize.y());
mTexture->rasterizeAt(static_cast<size_t>(mSize.x()), static_cast<size_t>(mSize.y()));
onSizeChanged();
}
@ -461,7 +461,8 @@ void ImageComponent::applyTheme(const std::shared_ptr<ThemeData>& theme, const s
if (elem->has("colorEnd"))
setColorShiftEnd(elem->get<unsigned int>("colorEnd"));
if (elem->has("gradientType"))
setColorGradientHorizontal(!(elem->get<std::string>("gradientType").compare("horizontal")));
setColorGradientHorizontal(!(elem->
get<std::string>("gradientType").compare("horizontal")));
}
}

View file

@ -9,8 +9,8 @@
#ifndef ES_CORE_COMPONENTS_IMAGE_COMPONENT_H
#define ES_CORE_COMPONENTS_IMAGE_COMPONENT_H
#include "renderers/Renderer.h"
#include "math/Vector2i.h"
#include "renderers/Renderer.h"
#include "GuiComponent.h"
class TextureResource;