Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore database power #546

Open
wants to merge 58 commits into
base: gamelistdb
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
da86b61
Quick fix for the stack overflow with DateTimeComponents in a Compone…
Aloshi Mar 6, 2015
646bede
Update version to 2.0.1a.
Aloshi Mar 8, 2015
ccbf432
Prevent stripping parentheses
jgeumlek Dec 24, 2015
8ec3c0a
switch to gamelistdb
jgeumlek Dec 24, 2015
59a170d
Make DateTimeComponent match time format stored in the database
jgeumlek Dec 25, 2015
c58afe1
Clip the text list selector bar
jgeumlek Dec 25, 2015
11dce75
Pop up text list if selection overflows the boundary
jgeumlek Dec 25, 2015
5e7c53d
Revert clipping box due to bug with slide animation
jgeumlek Dec 25, 2015
44e631e
Quick/Dirty case insensitive sort.
jgeumlek Dec 25, 2015
f9264bc
Combine the two menus roughly for now. Let "start" also start games.
jgeumlek Dec 26, 2015
68924d0
Make Menus cyclic, only slightly hackish
jgeumlek Dec 26, 2015
7a2c65f
Comment out access to the commented out Jump-To-Letter feature
jgeumlek Dec 26, 2015
6b193b4
Fix saving folder metadata to database
jgeumlek Dec 26, 2015
56dcbf3
Restructure the combined contextual/global menu, including quick acce…
jgeumlek Dec 27, 2015
871f506
Make file system scans a menu action rather than automatic, shortenin…
jgeumlek Dec 27, 2015
60fd82c
Make prompt more consistent
jgeumlek Dec 27, 2015
048082a
Store invalid times as NULLs in the database
jgeumlek Dec 28, 2015
1f63858
Improve sorting options
jgeumlek Dec 28, 2015
78c33df
Update details appropriately when on a non-game entry
jgeumlek Dec 28, 2015
497ac8d
More spacing on datetime in metadata editor. Workaround for DateTimeC…
jgeumlek Dec 28, 2015
80b5fbf
Add a little feedback to the database scan
jgeumlek Dec 28, 2015
2caabc3
Make Scraper more consistent with Database menu
jgeumlek Dec 28, 2015
d39b660
Add virtual boy platform id + scraping
jgeumlek Dec 28, 2015
fccdd44
Make rating component go up by half stars
jgeumlek Dec 28, 2015
b1c8962
Add ability to remove an entry from the database without deleting the…
jgeumlek Dec 28, 2015
28087e5
Improve sorting options
jgeumlek Dec 28, 2015
a18e491
Initial support for having filters
jgeumlek Dec 29, 2015
9b7c3b6
Make game details update on list creation, like when entering a folde…
jgeumlek Dec 29, 2015
8d3ed08
minor string fixes
jgeumlek Dec 29, 2015
f9db04c
Add rough UI for creating a filter
jgeumlek Dec 29, 2015
5f0c52d
Switch fully to the SQLite date time string format
jgeumlek Dec 29, 2015
2615bbf
Remove fractional seconds to macth sqlite native date time
jgeumlek Dec 29, 2015
8ca8070
Make filtering games by year of release easier
jgeumlek Dec 29, 2015
90c42ab
Add in construction of tags table
jgeumlek Dec 29, 2015
a65ab54
Update sqlite so that we may successfully create the useful tags view
jgeumlek Dec 29, 2015
ddb71fb
Add a quick terrible UI for adding/removing tags in the metadata editor
jgeumlek Dec 29, 2015
7aa3bb1
Add some rough behavior on empty list viewing
jgeumlek Dec 29, 2015
49cb4ec
whoops
jgeumlek Dec 29, 2015
6582811
fix the addition of a folders-first setting
jgeumlek Dec 29, 2015
d9a9ab6
Continue unwinding even if we somehow get back to the root
jgeumlek Dec 29, 2015
7671d2a
Add a setting for whether folders/filters should float to the top
jgeumlek Dec 29, 2015
0ebaef2
Add secret setting "MakeCombinedSystem" to show the true power of the…
jgeumlek Dec 29, 2015
bef2083
Add default value for MakeCombinedSystem
jgeumlek Dec 29, 2015
dee6d8b
Fix some database silliness
jgeumlek Dec 29, 2015
359eb18
Refactor some more computations as queries
jgeumlek Dec 30, 2015
fd38659
Missed an ORDER BY
jgeumlek Dec 30, 2015
4f2207d
Add a random sort for fun.
jgeumlek Dec 31, 2015
0356f7d
Change the default filter name to something slightly more reasonable
jgeumlek Dec 31, 2015
08665ef
Make RatingComponent avoid introducing spurious changes
jgeumlek Dec 31, 2015
3174edc
Make single-line text edits a little more intuitive
jgeumlek Dec 31, 2015
12e65a2
Add some metadata cache. Might need tweaking on systems of limited me…
jgeumlek Dec 31, 2015
88c2f48
Make gamelists slide animation wrap around like the system select does
jgeumlek Jan 2, 2016
9ab8bfb
Make FileData cache the metadata from the database, ensure it gets cl…
jgeumlek Jan 2, 2016
a13d5a0
Hard set some values just in case an aborted slide launch left us wei…
jgeumlek Jan 2, 2016
99ef2e8
Add floating point fuzz to rating component half-star updates, and ce…
jgeumlek Jan 2, 2016
9cac5c5
Rearrange editing menu
jgeumlek Jan 4, 2016
251195a
Replace hidden MakeCombinedSystem with ability to put filters on systems
jgeumlek Feb 21, 2016
eb4de84
quick DB bug fixes
jgeumlek Mar 10, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
359 changes: 244 additions & 115 deletions data/converted/star_filled_svg.cpp

Large diffs are not rendered by default.

509 changes: 323 additions & 186 deletions data/converted/star_unfilled_svg.cpp

Large diffs are not rendered by default.

59 changes: 48 additions & 11 deletions data/resources/star_filled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 48 additions & 17 deletions data/resources/star_unfilled.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions es-app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ set(ES_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiSettings.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiScraperMulti.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiScraperStart.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiRefreshDatabase.h

# Scrapers
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/Scraper.h
Expand Down Expand Up @@ -69,6 +70,7 @@ set(ES_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiSettings.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiScraperMulti.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiScraperStart.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiRefreshDatabase.cpp

# Scrapers
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/Scraper.cpp
Expand Down
2 changes: 1 addition & 1 deletion es-app/src/EmulationStation.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#define PROGRAM_VERSION_MAJOR 2
#define PROGRAM_VERSION_MINOR 0
#define PROGRAM_VERSION_MAINTENANCE 1
#define PROGRAM_VERSION_STRING "2.0.1"
#define PROGRAM_VERSION_STRING "2.0.1a"

#define PROGRAM_BUILT_STRING __DATE__ " - " __TIME__

Expand Down
54 changes: 48 additions & 6 deletions es-app/src/FileData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@

namespace fs = boost::filesystem;

MetaDataListType fileTypeToMetaDataType(FileType type)
{
switch(type)
{
case GAME:
return GAME_METADATA;
case FOLDER:
return FOLDER_METADATA;
case FILTER:
return FILTER_METADATA;
}

return GAME_METADATA;
}

std::string removeParenthesis(const std::string& str)
{
// remove anything in parenthesis or brackets
Expand Down Expand Up @@ -51,16 +66,17 @@ std::string getCleanGameName(const std::string& str, const SystemData* system)
if(system && system->hasPlatformId(PlatformIds::ARCADE) || system->hasPlatformId(PlatformIds::NEOGEO))
stem = PlatformIds::getCleanMameName(stem.c_str());

return removeParenthesis(stem);
return stem;
}

FileData::FileData(const std::string& fileID, SystemData* system, FileType type, const std::string& nameCache)
: mFileID(fileID), mSystem(system), mType(type), mNameCache(nameCache)
: mFileID(fileID), mSystem(system), mType(type), mNameCache(nameCache), mMetaDataCache(fileTypeToMetaDataType(type), false)
{
}

FileData::FileData() : FileData("", NULL, (FileType)0)
{

}

FileData::FileData(const std::string& fileID, const std::string& systemID, FileType type) :
Expand Down Expand Up @@ -98,11 +114,17 @@ FileType FileData::getType() const

MetaDataMap FileData::get_metadata() const
{
return SystemManager::getInstance()->database().getFileData(mFileID, mSystem->getName());
if(mValidMetaDataCache) return mMetaDataCache;
mMetaDataCache = SystemManager::getInstance()->database().getFileData(mFileID, mSystem->getName());
mValidMetaDataCache = true;
return mMetaDataCache;
}

void FileData::set_metadata(const MetaDataMap& metadata)
void FileData::set_metadata(const MetaDataMap& metadata) const
{
// The database round trip might alter some values.
// Setting metadata should be fairly infrequent, so this should be fine.
mValidMetaDataCache = false;
SystemManager::getInstance()->database().setFileData(mFileID, getSystemID(), mType, metadata);
}

Expand All @@ -111,13 +133,33 @@ std::vector<FileData> FileData::getChildren(const FileSort* sort) const
if(sort == NULL)
sort = &getFileSorts().at(Settings::getInstance()->getInt("SortTypeIndex"));

return SystemManager::getInstance()->database().getChildrenOf(mFileID, mSystem, true, true, sort);
bool foldersFirst = Settings::getInstance()->getBool("SortFoldersFirst");

if(mType == FILTER)
{
MetaDataMap metadata = get_metadata();
//Sorry about abusing columns for other purposes.
std::string filter_matches = mMetaDataCache.get("genre");
int limit = mMetaDataCache.get<int>("players");
//TODO: Let a filter also specify ability to match filters/folders
std::string orderby = mMetaDataCache.get("developer");
FileSort filterSort("Filter given sort",orderby.c_str());
if(!orderby.empty())
sort = &filterSort;
return SystemManager::getInstance()->database().getChildrenOfFilter(mFileID, mSystem, false, filter_matches, limit, foldersFirst, sort);
}

return SystemManager::getInstance()->database().getChildrenOf(mFileID, mSystem, true, true, foldersFirst, sort);
}

std::vector<FileData> FileData::getChildrenRecursive(bool includeFolders, const FileSort* sort) const
{
if(sort == NULL)
sort = &getFileSorts().at(Settings::getInstance()->getInt("SortTypeIndex"));

return SystemManager::getInstance()->database().getChildrenOf(mFileID, mSystem, false, includeFolders, sort);
bool foldersFirst = Settings::getInstance()->getBool("SortFoldersFirst");

if(mType == FILTER)
return getChildren(sort);
return SystemManager::getInstance()->database().getChildrenOf(mFileID, mSystem, false, includeFolders, foldersFirst, sort);
}
9 changes: 7 additions & 2 deletions es-app/src/FileData.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ struct FileSort;
enum FileType
{
GAME = 1,
FOLDER = 2
FOLDER = 2,
FILTER = 3
};

// Used for loading/saving gamelist.xml.
const char* fileTypeToString(FileType type);
FileType stringToFileType(const char* str);

MetaDataListType fileTypeToMetaDataType(FileType type);

// Remove (.*) and [.*] from str
std::string removeParenthesis(const std::string& str);

Expand All @@ -34,7 +37,7 @@ class FileData
inline bool operator!=(const FileData& rhs) const { return !(*this == rhs); }

MetaDataMap get_metadata() const;
void set_metadata(const MetaDataMap& metadata);
void set_metadata(const MetaDataMap& metadata) const;

const std::string& getName() const;
FileType getType() const;
Expand All @@ -56,4 +59,6 @@ class FileData
FileType mType;

mutable std::string mNameCache;
mutable MetaDataMap mMetaDataCache;
mutable bool mValidMetaDataCache = false;
};
Loading