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

Add a menu option to rotate video for gpd win/gpd win2 #791

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 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
2bd9062
Create a GamesDB scraper using hashing to fetch by ID.
sselph Jan 19, 2015
68a77d1
Fixed to build on Windows (VS2012).
Aloshi Jan 20, 2015
7450822
Fixed to build on Windows (VS2012).
Aloshi Jan 20, 2015
d3f23a9
Fix for issue #356.
Aloshi Jan 21, 2015
8a01f71
Merge branch 'master' into unstable
Aloshi Jan 21, 2015
b5eb65e
Merge branch 'unstable' of https://github.com/Aloshi/EmulationStation…
Aloshi Jan 24, 2015
b4402b3
Merge branch 'master' into unstable
Aloshi Jan 25, 2015
abba195
Merge branch 'master' into unstable
Aloshi Feb 10, 2015
c0e0f4d
Merge branch 'master' into gamelistdb
Aloshi Feb 10, 2015
69bb3e0
Merge branch 'master' into unstable
Aloshi Mar 3, 2015
44fd9d6
Merge branch 'master' into gamelistdb
Aloshi Mar 3, 2015
c52fcb1
Added automatic gamelist.xml import prompt.
Aloshi Mar 3, 2015
b3df00a
Merge branch 'master' into unstable
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
0047bd5
Merge branch 'master' into unstable
Aloshi Mar 6, 2015
7635f11
Merge branch 'master' into gamelistdb
Aloshi Mar 6, 2015
1d129cd
Merge branch 'gamelistdb' into unstable
Aloshi Mar 6, 2015
a9a8d0d
Fixed merge issue with new FileData scheme.
Aloshi Mar 6, 2015
584a466
Fixed regression with Settings (boost::lexical_cast was adding commas…
Aloshi Mar 6, 2015
915cb37
Merge branch 'master' into unstable
Aloshi Mar 12, 2015
566e8ca
Added FFMPEG dependency to CMake.
Aloshi Mar 19, 2015
26a553c
Add libswscale to dependencies.
Aloshi Mar 27, 2015
01bc5d9
Refactored ImageComponent into MediaComponent and ImageComponent.
Aloshi Mar 28, 2015
207a387
VideoResource and VideoComponent.
Aloshi Mar 28, 2015
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ RelWithDebInfo
CMakeCache.txt
CMakeFiles
cmake_install.cmake
CPackConfig.cmake
CPackSourceConfig.cmake
Makefile
87 changes: 87 additions & 0 deletions CMake/Packages/FindFFMPEG.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# - Try to find ffmpeg libraries (libavcodec, libavformat, libavutil, and swscale)
# Once done this will define
#
# FFMPEG_FOUND - system has ffmpeg or libav
# FFMPEG_INCLUDE_DIR - the ffmpeg include directory
# FFMPEG_LIBRARIES - Link these to use ffmpeg
# FFMPEG_LIBAVCODEC
# FFMPEG_LIBAVFORMAT
# FFMPEG_LIBAVUTIL
# FFMPEG_SWSCALE
#
# Copyright (c) 2008 Andreas Schneider <mail@cynapses.org>
# Modified for other libraries by Lasse Kärkkäinen <tronic>
# Modified for Hedgewars by Stepik777
# Modified to add swscale for EmulationStation by Aloshi
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
#

if (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
# in cache already
set(FFMPEG_FOUND TRUE)
else (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(_FFMPEG_AVCODEC libavcodec)
pkg_check_modules(_FFMPEG_AVFORMAT libavformat)
pkg_check_modules(_FFMPEG_AVUTIL libavutil)
pkg_check_modules(_FFMPEG_AVUTIL libswscale)
endif (PKG_CONFIG_FOUND)

find_path(FFMPEG_AVCODEC_INCLUDE_DIR
NAMES libavcodec/avcodec.h
PATHS ${_FFMPEG_AVCODEC_INCLUDE_DIRS} /usr/include /usr/local/include /opt/local/include /sw/include
PATH_SUFFIXES ffmpeg libav
)

find_library(FFMPEG_LIBAVCODEC
NAMES avcodec
PATHS ${_FFMPEG_AVCODEC_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
)

find_library(FFMPEG_LIBAVFORMAT
NAMES avformat
PATHS ${_FFMPEG_AVFORMAT_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
)

find_library(FFMPEG_LIBAVUTIL
NAMES avutil
PATHS ${_FFMPEG_AVUTIL_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
)

find_library(FFMPEG_LIBSWSCALE
NAMES swscale
PATHS ${_FFMPEG_SWSCALE_LIBRARY_DIRS} /usr/lib /usr/local/lib /opt/local/lib /sw/lib
)

if (FFMPEG_LIBAVCODEC AND FFMPEG_LIBAVFORMAT)
set(FFMPEG_FOUND TRUE)
endif()

if (FFMPEG_FOUND)
set(FFMPEG_INCLUDE_DIR ${FFMPEG_AVCODEC_INCLUDE_DIR})

set(FFMPEG_LIBRARIES
${FFMPEG_LIBAVCODEC}
${FFMPEG_LIBAVFORMAT}
${FFMPEG_LIBAVUTIL}
${FFMPEG_LIBSWSCALE}
)

endif (FFMPEG_FOUND)

if (FFMPEG_FOUND)
if (NOT FFMPEG_FIND_QUIETLY)
message(STATUS "Found FFMPEG or Libav: ${FFMPEG_LIBRARIES}, ${FFMPEG_INCLUDE_DIR}")
endif (NOT FFMPEG_FIND_QUIETLY)
else (FFMPEG_FOUND)
if (FFMPEG_FIND_REQUIRED)
message(FATAL_ERROR "Could not find libavcodec or libavformat or libavutil or libswscale")
endif (FFMPEG_FIND_REQUIRED)
endif (FFMPEG_FOUND)

endif (FFMPEG_LIBRARIES AND FFMPEG_INCLUDE_DIR)
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ find_package(SDL2 REQUIRED)
find_package(Boost REQUIRED COMPONENTS system filesystem date_time locale)
find_package(Eigen3 REQUIRED)
find_package(CURL REQUIRED)
find_package(FFMPEG REQUIRED)

#add ALSA for Linux
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
Expand Down Expand Up @@ -99,6 +100,7 @@ set(COMMON_INCLUDE_DIRS
${Boost_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
${CURL_INCLUDE_DIR}
${FFMPEG_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/external
${CMAKE_CURRENT_SOURCE_DIR}/es-core/src
)
Expand Down Expand Up @@ -148,8 +150,10 @@ set(COMMON_LIBRARIES
${FreeImage_LIBRARIES}
${SDL2_LIBRARY}
${CURL_LIBRARIES}
${FFMPEG_LIBRARIES}
pugixml
nanosvg
sqlite3
)

#add ALSA for Linux
Expand Down
17 changes: 9 additions & 8 deletions es-app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ project("emulationstation")

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/ScraperCmdLine.h
${CMAKE_CURRENT_SOURCE_DIR}/src/SystemData.h
${CMAKE_CURRENT_SOURCE_DIR}/src/SystemManager.h
${CMAKE_CURRENT_SOURCE_DIR}/src/VolumeControl.h
${CMAKE_CURRENT_SOURCE_DIR}/src/Gamelist.h
${CMAKE_CURRENT_SOURCE_DIR}/src/GamelistDB.h

# GuiComponents
${CMAKE_CURRENT_SOURCE_DIR}/src/components/AsyncReqComponent.h
Expand All @@ -18,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
Expand All @@ -28,8 +27,10 @@ set(ES_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiScraperStart.h

# Scrapers
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/ROMHasher.h
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/Scraper.h
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/GamesDBScraper.h
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/GamesDBShaScraper.h
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/TheArchiveScraper.h

# Views
Expand All @@ -48,23 +49,21 @@ 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
${CMAKE_CURRENT_SOURCE_DIR}/src/PlatformId.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/ScraperCmdLine.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/SystemData.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/SystemManager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/VolumeControl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Gamelist.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/GamelistDB.cpp

# GuiComponents
${CMAKE_CURRENT_SOURCE_DIR}/src/components/AsyncReqComponent.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/components/RatingComponent.cpp
${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
Expand All @@ -74,8 +73,10 @@ set(ES_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiScraperStart.cpp

# Scrapers
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/ROMHasher.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/Scraper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/GamesDBScraper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/GamesDBShaScraper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/TheArchiveScraper.cpp

# Views
Expand Down
41 changes: 41 additions & 0 deletions es-app/src/ESException.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#pragma once

#include <exception>
#include <sstream>

class ESException : public std::exception
{
public:
const char* what() const throw() override
{
return mMsg.c_str();
}

template<typename T>
friend ESException& operator<<(ESException& e, const T& msg);

// for some reason gcc claims that "ESException()" has the type
// "ESException", but not the type "ESException&", so...this.
template<typename T>
friend ESException operator<<(ESException e, const T& msg);
private:
std::string mMsg;
};

template<typename T>
ESException& operator<<(ESException& e, const T& appendMsg)
{
std::stringstream ss;
ss << e.mMsg << appendMsg;
e.mMsg = ss.str();
return e;
}

template<typename T>
ESException operator<<(ESException e, const T& appendMsg)
{
std::stringstream ss;
ss << e.mMsg << appendMsg;
e.mMsg = ss.str();
return e;
}
115 changes: 47 additions & 68 deletions es-app/src/FileData.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "FileData.h"
#include "SystemData.h"
#include "SystemManager.h"
#include "Settings.h"

namespace fs = boost::filesystem;

Expand Down Expand Up @@ -42,103 +44,80 @@ 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("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, FileType type, const std::string& nameCache)
: mFileID(fileID), mSystem(system), mType(type), mNameCache(nameCache)
{
if(mParent)
mParent->removeChild(this);

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

std::string FileData::getCleanName() const
FileData::FileData() : FileData("", NULL, (FileType)0)
{
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, FileType type) :
FileData(fileID, SystemManager::getInstance()->getSystemByName(systemID), type)
{
if(!metadata.get("thumbnail").empty())
return metadata.get("thumbnail");
else
return metadata.get("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;
}
}
return mType;
}

// File somehow wasn't in our children.
assert(false);
MetaDataMap FileData::get_metadata() const
{
return SystemManager::getInstance()->database().getFileData(mFileID, mSystem->getName());
}

void FileData::sort(ComparisonFunction& comparator, bool ascending)
void FileData::set_metadata(const MetaDataMap& metadata)
{
std::sort(mChildren.begin(), mChildren.end(), comparator);
SystemManager::getInstance()->database().setFileData(mFileID, getSystemID(), mType, metadata);
}

for(auto it = mChildren.begin(); it != mChildren.end(); it++)
{
if((*it)->getChildren().size() > 0)
(*it)->sort(comparator, ascending);
}
std::vector<FileData> FileData::getChildren(const FileSort* sort) const
{
if(sort == NULL)
sort = &getFileSorts().at(Settings::getInstance()->getInt("SortTypeIndex"));

if(!ascending)
std::reverse(mChildren.begin(), mChildren.end());
return SystemManager::getInstance()->database().getChildrenOf(mFileID, mSystem, true, true, sort);
}

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

return SystemManager::getInstance()->database().getChildrenOf(mFileID, mSystem, false, includeFolders, sort);
}
Loading