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

DB Backend PR #12

Open
wants to merge 80 commits into
base: db-backend
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
bc2dfc9
Added SQLite3 to the project.
Aloshi Nov 26, 2014
b20b3eb
Initial work for the SQLite database replacement.
Aloshi Nov 28, 2014
02e91a3
Merge branch 'unstable' into gamelistdb
Aloshi Dec 6, 2014
6ae49e9
Refactored SystemData into SystemData + SystemManager.
Aloshi Dec 22, 2014
1449ab1
Redesigned GamelistDB to store all data in a single table.
Aloshi Dec 27, 2014
0abae19
GamelistDB now handles metadata format changes automatically (e.g. wh…
Aloshi Dec 27, 2014
c0bc2ea
GamelistDB starting to be integrated into SystemManager.
Aloshi Dec 27, 2014
2013215
Added Boost.Regex dependency.
Aloshi Dec 28, 2014
60a52e6
THE GREAT FILEDATA REWRITE OF CHRISTMAS 2014
Aloshi Dec 29, 2014
e501450
Sort support.
Aloshi Jan 8, 2015
35370a4
Fixed FileType/MetaDataListType confusions.
Aloshi Jan 8, 2015
68348ed
Added "IMPORT XML" option to the "SCRAPER" menu.
Aloshi Jan 8, 2015
a99b2e2
Fixed another metadatalisttype/filetype test.
Aloshi Jan 8, 2015
3e50413
Fixed updateExists(system) not actually working.
Aloshi Jan 8, 2015
52ed0ea
Specify FileType in FileData constructor.
Aloshi Jan 9, 2015
bb303c1
Merge branch 'unstable' into gamelistdb
Aloshi Jan 11, 2015
7150e8d
Merge branch 'master' into gamelistdb
Aloshi Jan 15, 2015
4c4fb5e
Fix build errors on Linux.
Aloshi Jan 17, 2015
c0e0f4d
Merge branch 'master' into gamelistdb
Aloshi Feb 10, 2015
44fd9d6
Merge branch 'master' into gamelistdb
Aloshi Mar 3, 2015
c52fcb1
Added automatic gamelist.xml import prompt.
Aloshi Mar 3, 2015
10a59b4
Merge branch 'master' into gamelistdb
Aloshi Mar 3, 2015
1a5b916
Added time conversion for import/export XML.
Aloshi Mar 4, 2015
7635f11
Merge branch 'master' into gamelistdb
Aloshi Mar 6, 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
Prev Previous commit
Next Next commit
THE GREAT FILEDATA REWRITE OF CHRISTMAS 2014
FileData now basically works as a key in the GamelistDB "files" table.

Still not quite done (lots of places marked TODO), but semi-functional.

Removed Boost.Regex dependency, didn't need it after all.
Aloshi committed Dec 29, 2014
commit 60a52e6634fa3426eb8ac48f6fbcf199034fde35
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ endif()
find_package(Freetype REQUIRED)
find_package(FreeImage REQUIRED)
find_package(SDL2 REQUIRED)
find_package(Boost REQUIRED COMPONENTS system filesystem date_time locale regex)
find_package(Boost REQUIRED COMPONENTS system filesystem date_time locale)
find_package(Eigen3 REQUIRED)
find_package(CURL REQUIRED)

4 changes: 0 additions & 4 deletions es-app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@ set(ES_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/EmulationStation.h
${CMAKE_CURRENT_SOURCE_DIR}/src/ESException.h
${CMAKE_CURRENT_SOURCE_DIR}/src/FileData.h
${CMAKE_CURRENT_SOURCE_DIR}/src/FileSorts.h
${CMAKE_CURRENT_SOURCE_DIR}/src/MetaData.h
${CMAKE_CURRENT_SOURCE_DIR}/src/PlatformId.h
${CMAKE_CURRENT_SOURCE_DIR}/src/SystemData.h
@@ -19,7 +18,6 @@ set(ES_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/components/TextListComponent.h

# Guis
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiFastSelect.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMetaDataEd.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGameScraper.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGamelistOptions.h
@@ -49,7 +47,6 @@ set(ES_HEADERS

set(ES_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/FileData.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/FileSorts.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/MameNameMap.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/MetaData.cpp
@@ -65,7 +62,6 @@ set(ES_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/components/ScraperSearchComponent.cpp

# Guis
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiFastSelect.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMetaDataEd.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGameScraper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiGamelistOptions.cpp
111 changes: 43 additions & 68 deletions es-app/src/FileData.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "FileData.h"
#include "SystemData.h"
#include "SystemManager.h"

namespace fs = boost::filesystem;

@@ -42,103 +43,77 @@ std::string removeParenthesis(const std::string& str)
return ret;
}


FileData::FileData(FileType type, const fs::path& path, SystemData* system)
: mType(type), mPath(path), mSystem(system), mParent(NULL), metadata(type == GAME ? GAME_METADATA : FOLDER_METADATA) // metadata is REALLY set in the constructor!
std::string getCleanGameName(const std::string& str, const SystemData* system)
{
// metadata needs at least a name field (since that's what getName() will return)
if(metadata.get<std::string>("name").empty())
metadata.set("name", getCleanName());
fs::path path(str);
std::string stem = path.stem().generic_string();
if(system && system->hasPlatformId(PlatformIds::ARCADE) || system->hasPlatformId(PlatformIds::NEOGEO))
stem = PlatformIds::getCleanMameName(stem.c_str());

return removeParenthesis(stem);
}

FileData::~FileData()
FileData::FileData(const std::string& fileID, SystemData* system, const std::string& nameCache)
: mFileID(fileID), mSystem(system), mNameCache(nameCache), mTypeCache((FileType)0)
{
if(mParent)
mParent->removeChild(this);

while(mChildren.size())
delete mChildren.back();
}

std::string FileData::getCleanName() const
FileData::FileData() : FileData("", NULL)
{
std::string stem = mPath.stem().generic_string();
if(mSystem && mSystem->hasPlatformId(PlatformIds::ARCADE) || mSystem->hasPlatformId(PlatformIds::NEOGEO))
stem = PlatformIds::getCleanMameName(stem.c_str());

return removeParenthesis(stem);
}

const std::string FileData::getThumbnailPath() const
FileData::FileData(const std::string& fileID, const std::string& systemID) :
FileData(fileID, SystemManager::getInstance()->getSystemByName(systemID))
{
if(!metadata.get<std::string>("thumbnail").empty())
return metadata.get<std::string>("thumbnail");
else
return metadata.get<std::string>("image");
}

const std::string& FileData::getSystemID() const
{
return mSystem->getName();
}

std::vector<FileData*> FileData::getFilesRecursive(unsigned int typeMask) const
const std::string& FileData::getName() const
{
std::vector<FileData*> out;
// try and cache what's in the DB
if(mNameCache.empty())
mNameCache = get_metadata().get<std::string>("name");

for(auto it = mChildren.begin(); it != mChildren.end(); it++)
{
if((*it)->getType() & typeMask)
out.push_back(*it);

if((*it)->getChildren().size() > 0)
{
std::vector<FileData*> subchildren = (*it)->getFilesRecursive(typeMask);
out.insert(out.end(), subchildren.cbegin(), subchildren.cend());
}
}
// nothing was in the DB...use the clean version of our path
if(mNameCache.empty())
mNameCache = getCleanName();

return out;
return mNameCache;
}

void FileData::addChild(FileData* file)
fs::path FileData::getPath() const
{
assert(mType == FOLDER);
assert(file->getParent() == NULL);

mChildren.push_back(file);
file->mParent = this;
return fileIDToPath(mFileID, mSystem);
}

void FileData::removeChild(FileData* file)
FileType FileData::getType() const
{
assert(mType == FOLDER);
assert(file->getParent() == this);

for(auto it = mChildren.begin(); it != mChildren.end(); it++)
{
if(*it == file)
{
mChildren.erase(it);
return;
}
}
if(mTypeCache == 0)
mTypeCache = (get_metadata().getType() == GAME_METADATA ? GAME : FOLDER);

// File somehow wasn't in our children.
assert(false);
return mTypeCache;
}

void FileData::sort(ComparisonFunction& comparator, bool ascending)
MetaDataMap FileData::get_metadata() const
{
std::sort(mChildren.begin(), mChildren.end(), comparator);
return SystemManager::getInstance()->database().getFileData(mFileID, mSystem->getName());
}

for(auto it = mChildren.begin(); it != mChildren.end(); it++)
{
if((*it)->getChildren().size() > 0)
(*it)->sort(comparator, ascending);
}
void FileData::set_metadata(const MetaDataMap& metadata)
{
SystemManager::getInstance()->database().setFileData(mFileID, mSystem->getName(), metadata);
}

if(!ascending)
std::reverse(mChildren.begin(), mChildren.end());
std::vector<FileData> FileData::getChildren() const
{
return SystemManager::getInstance()->database().getChildrenOf(mFileID, mSystem, true, true);
}

void FileData::sort(const SortType& type)
std::vector<FileData> FileData::getChildrenRecursive(bool includeFolders) const
{
sort(*type.comparisonFunction, type.ascending);
return SystemManager::getInstance()->database().getChildrenOf(mFileID, mSystem, false, includeFolders);
}
55 changes: 22 additions & 33 deletions es-app/src/FileData.h
Original file line number Diff line number Diff line change
@@ -28,50 +28,39 @@ FileType stringToFileType(const char* str);
// Remove (.*) and [.*] from str
std::string removeParenthesis(const std::string& str);

// A tree node that holds information for a file.
std::string getCleanGameName(const std::string& str, const SystemData* system);

class FileData
{
public:
FileData(FileType type, const boost::filesystem::path& path, SystemData* system);
virtual ~FileData();

inline const std::string getName() const { return metadata.get<std::string>("name"); }
inline FileType getType() const { return mType; }
inline const boost::filesystem::path& getPath() const { return mPath; }
inline FileData* getParent() const { return mParent; }
inline const std::vector<FileData*>& getChildren() const { return mChildren; }
inline SystemData* getSystem() const { return mSystem; }

const std::string getThumbnailPath() const;
FileData();
FileData(const std::string& fileID, SystemData* system, const std::string& nameCache = "");
FileData(const std::string& fileID, const std::string& systemID);

std::vector<FileData*> getFilesRecursive(unsigned int typeMask) const;
inline bool operator==(const FileData& rhs) const { return (mFileID == rhs.mFileID && mSystem == rhs.mSystem); }
inline bool operator!=(const FileData& rhs) const { return !(*this == rhs); }

void addChild(FileData* file); // Error if mType != FOLDER
void removeChild(FileData* file); //Error if mType != FOLDER
MetaDataMap get_metadata() const;
void set_metadata(const MetaDataMap& metadata);

// Returns our best guess at the "real" name for this file (will strip parenthesis and attempt to perform MAME name translation)
std::string getCleanName() const;
const std::string& getName() const;
FileType getType() const;

typedef bool ComparisonFunction(const FileData* a, const FileData* b);
struct SortType
{
ComparisonFunction* comparisonFunction;
bool ascending;
std::string description;
boost::filesystem::path getPath() const;

SortType(ComparisonFunction* sortFunction, bool sortAscending, const std::string & sortDescription)
: comparisonFunction(sortFunction), ascending(sortAscending), description(sortDescription) {}
};
inline const std::string& getFileID() const { return mFileID; }
const std::string& getSystemID() const;
SystemData* getSystem() const { return mSystem; }

void sort(ComparisonFunction& comparator, bool ascending = true);
void sort(const SortType& type);
std::vector<FileData> getChildren() const;
std::vector<FileData> getChildrenRecursive(bool includeFolders) const;

MetaDataMap metadata;
inline std::string getCleanName() const { return getCleanGameName(mFileID, mSystem); }

private:
FileType mType;
boost::filesystem::path mPath;
std::string mFileID;
SystemData* mSystem;
FileData* mParent;
std::vector<FileData*> mChildren;

mutable std::string mNameCache;
mutable FileType mTypeCache;
};
72 changes: 0 additions & 72 deletions es-app/src/FileSorts.cpp

This file was deleted.

14 changes: 0 additions & 14 deletions es-app/src/FileSorts.h

This file was deleted.

Loading