Renamed folders to match their projects properly.

This commit is contained in:
Aloshi 2014-06-20 20:03:05 -05:00
parent c30fbdd6ba
commit dbdbcde6cd
155 changed files with 48 additions and 37979 deletions

View file

@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
project(emulationstation) project(emulationstation-all)
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
#add local find scripts to CMAKE path #add local find scripts to CMAKE path
@ -90,7 +90,7 @@ set(COMMON_INCLUDE_DIRS
${EIGEN3_INCLUDE_DIR} ${EIGEN3_INCLUDE_DIR}
${CURL_INCLUDE_DIR} ${CURL_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/external ${CMAKE_CURRENT_SOURCE_DIR}/external
${CMAKE_CURRENT_SOURCE_DIR}/core/src ${CMAKE_CURRENT_SOURCE_DIR}/es-core/src
) )
#add ALSA for Linux #add ALSA for Linux
@ -184,5 +184,5 @@ set(LIBRARY_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE)
# add each component # add each component
add_subdirectory("external") add_subdirectory("external")
add_subdirectory("core") add_subdirectory("es-core")
add_subdirectory("es") add_subdirectory("emulationstation")

View file

@ -54,6 +54,9 @@ set(CORE_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/resources/ResourceManager.h ${CMAKE_CURRENT_SOURCE_DIR}/src/resources/ResourceManager.h
${CMAKE_CURRENT_SOURCE_DIR}/src/resources/SVGResource.h ${CMAKE_CURRENT_SOURCE_DIR}/src/resources/SVGResource.h
${CMAKE_CURRENT_SOURCE_DIR}/src/resources/TextureResource.h ${CMAKE_CURRENT_SOURCE_DIR}/src/resources/TextureResource.h
# Embedded assets (needed by ResourceManager)
${emulationstation-all_SOURCE_DIR}/data/Resources.h
) )
set(CORE_SOURCES set(CORE_SOURCES
@ -106,56 +109,53 @@ set(CORE_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/resources/ResourceManager.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/resources/ResourceManager.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/resources/SVGResource.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/resources/SVGResource.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/resources/TextureResource.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/resources/TextureResource.cpp
# Embedded assets (needed by ResourceManager)
${emulationstation_SOURCE_DIR}/data/Resources.h
) )
set(EMBEDDED_ASSET_SOURCES set(EMBEDDED_ASSET_SOURCES
${emulationstation_SOURCE_DIR}/data/ResourceUtil.cpp ${emulationstation-all_SOURCE_DIR}/data/ResourceUtil.cpp
${emulationstation_SOURCE_DIR}/data/converted/splash_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/splash_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/window_icon_256_png.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/window_icon_256_png.cpp
${emulationstation_SOURCE_DIR}/data/converted/button_png.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/button_png.cpp
${emulationstation_SOURCE_DIR}/data/converted/button_filled_png.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/button_filled_png.cpp
${emulationstation_SOURCE_DIR}/data/converted/textinput_ninepatch_png.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/textinput_ninepatch_png.cpp
${emulationstation_SOURCE_DIR}/data/converted/textinput_ninepatch_active_png.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/textinput_ninepatch_active_png.cpp
${emulationstation_SOURCE_DIR}/data/converted/frame_png.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/frame_png.cpp
${emulationstation_SOURCE_DIR}/data/converted/scroll_gradient_png.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/scroll_gradient_png.cpp
${emulationstation_SOURCE_DIR}/data/converted/help_button_a_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/help_button_a_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/help_button_b_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/help_button_b_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/help_button_x_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/help_button_x_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/help_button_y_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/help_button_y_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/help_button_l_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/help_button_l_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/help_button_r_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/help_button_r_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/help_button_start_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/help_button_start_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/help_button_select_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/help_button_select_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/help_dpad_up_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/help_dpad_up_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/help_dpad_down_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/help_dpad_down_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/help_dpad_left_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/help_dpad_left_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/help_dpad_right_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/help_dpad_right_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/help_dpad_updown_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/help_dpad_updown_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/help_dpad_leftright_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/help_dpad_leftright_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/help_dpad_all_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/help_dpad_all_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/opensans_hebrew_condensed_regular_ttf.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/opensans_hebrew_condensed_regular_ttf.cpp
${emulationstation_SOURCE_DIR}/data/converted/opensans_hebrew_condensed_light_ttf.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/opensans_hebrew_condensed_light_ttf.cpp
${emulationstation_SOURCE_DIR}/data/converted/arrow_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/arrow_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/option_arrow_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/option_arrow_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/checkbox_checked_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/checkbox_checked_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/checkbox_unchecked_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/checkbox_unchecked_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/star_filled_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/star_filled_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/star_unfilled_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/star_unfilled_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/on_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/on_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/off_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/off_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/fav_add_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/fav_add_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/fav_remove_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/fav_remove_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/slider_knob_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/slider_knob_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/busy_0_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/busy_0_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/busy_1_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/busy_1_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/busy_2_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/busy_2_svg.cpp
${emulationstation_SOURCE_DIR}/data/converted/busy_3_svg.cpp ${emulationstation-all_SOURCE_DIR}/data/converted/busy_3_svg.cpp
) )
list(APPEND CORE_SOURCES ${EMBEDDED_ASSET_SOURCES}) list(APPEND CORE_SOURCES ${EMBEDDED_ASSET_SOURCES})

View file

@ -1,149 +0,0 @@
project("es-app")
set(ES_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/src/EmulationStation.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/VolumeControl.h
${CMAKE_CURRENT_SOURCE_DIR}/src/Gamelist.h
# GuiComponents
${CMAKE_CURRENT_SOURCE_DIR}/src/components/AsyncReqComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/src/components/RatingComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/src/components/ScraperSearchComponent.h
${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
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMenu.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiSettings.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiScraperMulti.h
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiScraperStart.h
# Scrapers
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/Scraper.h
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/GamesDBScraper.h
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/TheArchiveScraper.h
# Views
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/BasicGameListView.h
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/DetailedGameListView.h
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/IGameListView.h
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/ISimpleGameListView.h
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/GridGameListView.h
${CMAKE_CURRENT_SOURCE_DIR}/src/views/SystemView.h
${CMAKE_CURRENT_SOURCE_DIR}/src/views/ViewController.h
# Animations
${CMAKE_CURRENT_SOURCE_DIR}/src/animations/LaunchAnimation.h
${CMAKE_CURRENT_SOURCE_DIR}/src/animations/MoveCameraAnimation.h
)
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/VolumeControl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Gamelist.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
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiMenu.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiSettings.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiScraperMulti.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/guis/GuiScraperStart.cpp
# Scrapers
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/Scraper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/GamesDBScraper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/TheArchiveScraper.cpp
# Views
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/BasicGameListView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/DetailedGameListView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/IGameListView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/ISimpleGameListView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/GridGameListView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/views/SystemView.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/views/ViewController.cpp
)
#-------------------------------------------------------------------------------
# define OS specific sources and headers
if(MSVC)
LIST(APPEND ES_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/EmulationStation.rc
)
endif()
#-------------------------------------------------------------------------------
# define target
include_directories(${COMMON_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/src)
add_executable(emulationstation ${ES_SOURCES} ${ES_HEADERS})
target_link_libraries(emulationstation ${COMMON_LIBRARIES} es-core)
# special properties for Windows builds
if(MSVC)
#show console in debug builds, but not in proper release builds
#Note that up to CMake 2.8.10 this feature is broken: http://public.kitware.com/Bug/view.php?id=12566
set_target_properties(emulationstation PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
set_target_properties(emulationstation PROPERTIES COMPILE_DEFINITIONS_DEBUG "_CONSOLE")
set_target_properties(emulationstation PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE")
set_target_properties(emulationstation PROPERTIES COMPILE_DEFINITIONS_RELWITHDEBINFO "_CONSOLE")
set_target_properties(emulationstation PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
set_target_properties(emulationstation PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS")
endif()
#-------------------------------------------------------------------------------
# set up CPack install stuff so `make install` does something useful
install(TARGETS emulationstation
RUNTIME
DESTINATION bin)
INCLUDE(InstallRequiredSystemLibraries)
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A flexible graphical emulator front-end")
SET(CPACK_PACKAGE_DESCRIPTION "EmulationStation is a flexible, graphical front-end designed for keyboardless navigation of your multi-platform retro game collection.")
SET(CPACK_RESOURCE_FILE LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.md")
SET(CPACK_RESOURCE_FILE README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Alec Lofquist <allofquist@yahoo.com>")
SET(CPACK_DEBIAN_PACKAGE_SECTION "misc")
SET(CPACK_DEBIAN_PACKAGE_PRIORITY "extra")
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libsdl2-2.0-0, libboost-system1.54.0, libboost-filesystem1.54.0, libfreeimage3, libfreetype6, libcurl3, libasound2")
SET(CPACK_DEBIAN_PACKAGE_BUILDS_DEPENDS "debhelper (>= 8.0.0), cmake, g++ (>= 4.8), libsdl2-dev, libboost-system-dev, libboost-filesystem-dev, libboost-date-time-dev, libfreeimage-dev, libfreetype6-dev, libeigen3-dev, libcurl4-openssl-dev, libasound2-dev, libgl1-mesa-dev")
SET(CPACK_PACKAGE_VENDOR "emulationstation.org")
SET(CPACK_PACKAGE_VERSION "2.0.0~rc1")
SET(CPACK_PACKAGE_VERSION_MAJOR "2")
SET(CPACK_PACKAGE_VERSION_MINOR "0")
SET(CPACK_PACKAGE_VERSION_PATCH "0")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "emulationstation_${CMAKE_PACKAGE_VERSION}")
SET(CPACK_PACKAGE_EXECUTABLES "emulationstation" "emulationstation")
SET(CPACK_GENERATOR "TGZ;DEB")
INCLUDE(CPack)

Binary file not shown.

View file

@ -1,13 +0,0 @@
#pragma once
// These numbers and strings need to be manually updated for a new version.
// Do this version number update as the very last commit for the new release version.
#define PROGRAM_VERSION_MAJOR 2
#define PROGRAM_VERSION_MINOR 0
#define PROGRAM_VERSION_MAINTENANCE 0
#define PROGRAM_VERSION_STRING "2.0.0-rc1"
#define PROGRAM_BUILT_STRING __DATE__ " - " __TIME__
#define RESOURCE_VERSION_STRING "2,0,0\0"
#define RESOURCE_VERSION PROGRAM_VERSION_MAJOR,PROGRAM_VERSION_MINOR,PROGRAM_VERSION_MAINTENANCE

View file

@ -1,39 +0,0 @@
#include "EmulationStation.h"
#include "windows.h"
VS_VERSION_INFO VERSIONINFO
FILEVERSION RESOURCE_VERSION
PRODUCTVERSION RESOURCE_VERSION
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904E4"
BEGIN
VALUE "Comments", "\0"
VALUE "FileDescription", "EmulationStation - emulator frontend\0"
VALUE "FileVersion", RESOURCE_VERSION_STRING
VALUE "InternalName", "emulationstation.exe\0"
VALUE "LegalCopyright", "\0"
VALUE "LegalTrademarks", "\0"
VALUE "OriginalFilename", "emulationstation.exe\0"
VALUE "ProductName", "EmulationStation\0"
VALUE "ProductVersion", PROGRAM_VERSION_STRING
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
IDI_ES_LOGO ICON DISCARDABLE "../data/es_icon.ico"

View file

@ -1,144 +0,0 @@
#include "FileData.h"
#include "SystemData.h"
namespace fs = boost::filesystem;
std::string removeParenthesis(const std::string& str)
{
// remove anything in parenthesis or brackets
// should be roughly equivalent to the regex replace "\((.*)\)|\[(.*)\]" with ""
// I would love to just use regex, but it's not worth pulling in another boost lib for one function that is used once
std::string ret = str;
size_t start, end;
static const int NUM_TO_REPLACE = 2;
static const char toReplace[NUM_TO_REPLACE*2] = { '(', ')', '[', ']' };
bool done = false;
while(!done)
{
done = true;
for(int i = 0; i < NUM_TO_REPLACE; i++)
{
end = ret.find_first_of(toReplace[i*2+1]);
start = ret.find_last_of(toReplace[i*2], end);
if(start != std::string::npos && end != std::string::npos)
{
ret.erase(start, end - start + 1);
done = false;
}
}
}
// also strip whitespace
end = ret.find_last_not_of(' ');
if(end != std::string::npos)
end++;
ret = ret.substr(0, end);
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!
{
// metadata needs at least a name field (since that's what getName() will return)
if(metadata.get("name").empty())
metadata.set("name", getCleanName());
}
FileData::~FileData()
{
if(mParent)
mParent->removeChild(this);
while(mChildren.size())
delete mChildren.back();
}
std::string FileData::getCleanName() const
{
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
{
if(!metadata.get("thumbnail").empty())
return metadata.get("thumbnail");
else
return metadata.get("image");
}
std::vector<FileData*> FileData::getFilesRecursive(unsigned int typeMask) const
{
std::vector<FileData*> out;
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());
}
}
return out;
}
void FileData::addChild(FileData* file)
{
assert(mType == FOLDER);
assert(file->getParent() == NULL);
mChildren.push_back(file);
file->mParent = this;
}
void FileData::removeChild(FileData* file)
{
assert(mType == FOLDER);
assert(file->getParent() == this);
for(auto it = mChildren.begin(); it != mChildren.end(); it++)
{
if(*it == file)
{
mChildren.erase(it);
return;
}
}
// File somehow wasn't in our children.
assert(false);
}
void FileData::sort(ComparisonFunction& comparator, bool ascending)
{
std::sort(mChildren.begin(), mChildren.end(), comparator);
for(auto it = mChildren.begin(); it != mChildren.end(); it++)
{
if((*it)->getChildren().size() > 0)
(*it)->sort(comparator, ascending);
}
if(!ascending)
std::reverse(mChildren.begin(), mChildren.end());
}
void FileData::sort(const SortType& type)
{
sort(*type.comparisonFunction, type.ascending);
}

View file

@ -1,77 +0,0 @@
#pragma once
#include <vector>
#include <string>
#include <boost/filesystem.hpp>
#include "MetaData.h"
class SystemData;
enum FileType
{
GAME = 1, // Cannot have children.
FOLDER = 2
};
enum FileChangeType
{
FILE_ADDED,
FILE_METADATA_CHANGED,
FILE_REMOVED,
FILE_SORTED
};
// Used for loading/saving gamelist.xml.
const char* fileTypeToString(FileType type);
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.
class FileData
{
public:
FileData(FileType type, const boost::filesystem::path& path, SystemData* system);
virtual ~FileData();
inline const std::string& getName() const { return metadata.get("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; }
virtual const std::string& getThumbnailPath() const;
std::vector<FileData*> getFilesRecursive(unsigned int typeMask) const;
void addChild(FileData* file); // Error if mType != FOLDER
void removeChild(FileData* file); //Error if mType != FOLDER
// 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;
typedef bool ComparisonFunction(const FileData* a, const FileData* b);
struct SortType
{
ComparisonFunction* comparisonFunction;
bool ascending;
std::string description;
SortType(ComparisonFunction* sortFunction, bool sortAscending, const std::string & sortDescription)
: comparisonFunction(sortFunction), ascending(sortAscending), description(sortDescription) {}
};
void sort(ComparisonFunction& comparator, bool ascending = true);
void sort(const SortType& type);
MetaDataList metadata;
private:
FileType mType;
boost::filesystem::path mPath;
SystemData* mSystem;
FileData* mParent;
std::vector<FileData*> mChildren;
};

View file

@ -1,72 +0,0 @@
#include "FileSorts.h"
namespace FileSorts
{
const FileData::SortType typesArr[] = {
FileData::SortType(&compareFileName, true, "filename, ascending"),
FileData::SortType(&compareFileName, false, "filename, descending"),
FileData::SortType(&compareRating, true, "rating, ascending"),
FileData::SortType(&compareRating, false, "rating, descending"),
FileData::SortType(&compareTimesPlayed, true, "times played, ascending"),
FileData::SortType(&compareTimesPlayed, false, "times played, descending"),
FileData::SortType(&compareLastPlayed, true, "last played, ascending"),
FileData::SortType(&compareLastPlayed, false, "last played, descending")
};
const std::vector<FileData::SortType> SortTypes(typesArr, typesArr + sizeof(typesArr)/sizeof(typesArr[0]));
//returns if file1 should come before file2
bool compareFileName(const FileData* file1, const FileData* file2)
{
std::string name1 = file1->getName();
std::string name2 = file2->getName();
//min of name1/name2 .length()s
unsigned int count = name1.length() > name2.length() ? name2.length() : name1.length();
for(unsigned int i = 0; i < count; i++)
{
if(toupper(name1[i]) != toupper(name2[i]))
{
return toupper(name1[i]) < toupper(name2[i]);
}
}
return name1.length() < name2.length();
}
bool compareRating(const FileData* file1, const FileData* file2)
{
//only games have rating metadata
if(file1->metadata.getType() == GAME_METADATA && file2->metadata.getType() == GAME_METADATA)
{
return file1->metadata.getFloat("rating") < file2->metadata.getFloat("rating");
}
return false;
}
bool compareTimesPlayed(const FileData* file1, const FileData* file2)
{
//only games have playcount metadata
if(file1->metadata.getType() == GAME_METADATA && file2->metadata.getType() == GAME_METADATA)
{
return (file1)->metadata.getInt("playcount") < (file2)->metadata.getInt("playcount");
}
return false;
}
bool compareLastPlayed(const FileData* file1, const FileData* file2)
{
//only games have lastplayed metadata
if(file1->metadata.getType() == GAME_METADATA && file2->metadata.getType() == GAME_METADATA)
{
return (file1)->metadata.getTime("lastplayed") < (file2)->metadata.getTime("lastplayed");
}
return false;
}
};

View file

@ -1,14 +0,0 @@
#pragma once
#include <vector>
#include "FileData.h"
namespace FileSorts
{
bool compareFileName(const FileData* file1, const FileData* file2);
bool compareRating(const FileData* file1, const FileData* file2);
bool compareTimesPlayed(const FileData* file1, const FileData* fil2);
bool compareLastPlayed(const FileData* file1, const FileData* file2);
extern const std::vector<FileData::SortType> SortTypes;
};

View file

@ -1,252 +0,0 @@
#include "Gamelist.h"
#include "SystemData.h"
#include "pugixml/pugixml.hpp"
#include <boost/filesystem.hpp>
#include "Log.h"
#include "Settings.h"
#include "Util.h"
namespace fs = boost::filesystem;
FileData* findOrCreateFile(SystemData* system, const boost::filesystem::path& path, FileType type)
{
// first, verify that path is within the system's root folder
FileData* root = system->getRootFolder();
bool contains = false;
fs::path relative = removeCommonPath(path, root->getPath(), contains);
if(!contains)
{
LOG(LogError) << "File path \"" << path << "\" is outside system path \"" << system->getStartPath() << "\"";
return NULL;
}
auto path_it = relative.begin();
FileData* treeNode = root;
bool found = false;
while(path_it != relative.end())
{
const std::vector<FileData*>& children = treeNode->getChildren();
found = false;
for(auto child_it = children.begin(); child_it != children.end(); child_it++)
{
if((*child_it)->getPath().filename() == *path_it)
{
treeNode = *child_it;
found = true;
break;
}
}
// this is the end
if(path_it == --relative.end())
{
if(found)
return treeNode;
if(type == FOLDER)
{
LOG(LogWarning) << "gameList: folder doesn't already exist, won't create";
return NULL;
}
FileData* file = new FileData(type, path, system);
treeNode->addChild(file);
return file;
}
if(!found)
{
// don't create folders unless it's leading up to a game
// if type is a folder it's gonna be empty, so don't bother
if(type == FOLDER)
{
LOG(LogWarning) << "gameList: folder doesn't already exist, won't create";
return NULL;
}
// create missing folder
FileData* folder = new FileData(FOLDER, treeNode->getPath().stem() / *path_it, system);
treeNode->addChild(folder);
treeNode = folder;
}
path_it++;
}
return NULL;
}
void parseGamelist(SystemData* system)
{
std::string xmlpath = system->getGamelistPath(false);
if(!boost::filesystem::exists(xmlpath))
return;
LOG(LogInfo) << "Parsing XML file \"" << xmlpath << "\"...";
pugi::xml_document doc;
pugi::xml_parse_result result = doc.load_file(xmlpath.c_str());
if(!result)
{
LOG(LogError) << "Error parsing XML file \"" << xmlpath << "\"!\n " << result.description();
return;
}
pugi::xml_node root = doc.child("gameList");
if(!root)
{
LOG(LogError) << "Could not find <gameList> node in gamelist \"" << xmlpath << "\"!";
return;
}
fs::path relativeTo = system->getStartPath();
const char* tagList[2] = { "game", "folder" };
FileType typeList[2] = { GAME, FOLDER };
for(int i = 0; i < 2; i++)
{
const char* tag = tagList[i];
FileType type = typeList[i];
for(pugi::xml_node fileNode = root.child(tag); fileNode; fileNode = fileNode.next_sibling(tag))
{
fs::path path = resolvePath(fileNode.child("path").text().get(), relativeTo, false);
if(!boost::filesystem::exists(path))
{
LOG(LogWarning) << "File \"" << path << "\" does not exist! Ignoring.";
continue;
}
FileData* file = findOrCreateFile(system, path, type);
if(!file)
{
LOG(LogError) << "Error finding/creating FileData for \"" << path << "\", skipping.";
continue;
}
//load the metadata
std::string defaultName = file->metadata.get("name");
file->metadata = MetaDataList::createFromXML(GAME_METADATA, fileNode, relativeTo);
//make sure name gets set if one didn't exist
if(file->metadata.get("name").empty())
file->metadata.set("name", defaultName);
}
}
}
void addFileDataNode(pugi::xml_node& parent, const FileData* file, const char* tag, SystemData* system)
{
//create game and add to parent node
pugi::xml_node newNode = parent.append_child(tag);
//write metadata
file->metadata.appendToXML(newNode, true, system->getStartPath());
if(newNode.children().begin() == newNode.child("name") //first element is name
&& ++newNode.children().begin() == newNode.children().end() //theres only one element
&& newNode.child("name").text().get() == file->getCleanName()) //the name is the default
{
//if the only info is the default name, don't bother with this node
//delete it and ultimately do nothing
parent.remove_child(newNode);
}else{
//there's something useful in there so we'll keep the node, add the path
// try and make the path relative if we can so things still work if we change the rom folder location in the future
newNode.prepend_child("path").text().set(makeRelativePath(file->getPath(), system->getStartPath(), false).generic_string().c_str());
}
}
void updateGamelist(SystemData* system)
{
//We do this by reading the XML again, adding changes and then writing it back,
//because there might be information missing in our systemdata which would then miss in the new XML.
//We have the complete information for every game though, so we can simply remove a game
//we already have in the system from the XML, and then add it back from its GameData information...
if(Settings::getInstance()->getBool("IgnoreGamelist"))
return;
pugi::xml_document doc;
pugi::xml_node root;
std::string xmlReadPath = system->getGamelistPath(false);
if(boost::filesystem::exists(xmlReadPath))
{
//parse an existing file first
pugi::xml_parse_result result = doc.load_file(xmlReadPath.c_str());
if(!result)
{
LOG(LogError) << "Error parsing XML file \"" << xmlReadPath << "\"!\n " << result.description();
return;
}
root = doc.child("gameList");
if(!root)
{
LOG(LogError) << "Could not find <gameList> node in gamelist \"" << xmlReadPath << "\"!";
return;
}
}else{
//set up an empty gamelist to append to
root = doc.append_child("gameList");
}
//now we have all the information from the XML. now iterate through all our games and add information from there
FileData* rootFolder = system->getRootFolder();
if (rootFolder != nullptr)
{
//get only files, no folders
std::vector<FileData*> files = rootFolder->getFilesRecursive(GAME | FOLDER);
//iterate through all files, checking if they're already in the XML
std::vector<FileData*>::const_iterator fit = files.cbegin();
while(fit != files.cend())
{
const char* tag = ((*fit)->getType() == GAME) ? "game" : "folder";
// check if the file already exists in the XML
// if it does, remove it before adding
for(pugi::xml_node fileNode = root.child(tag); fileNode; fileNode = fileNode.next_sibling(tag))
{
pugi::xml_node pathNode = fileNode.child("path");
if(!pathNode)
{
LOG(LogError) << "<" << tag << "> node contains no <path> child!";
continue;
}
fs::path nodePath = resolvePath(pathNode.text().get(), system->getStartPath(), true);
fs::path gamePath((*fit)->getPath());
if(nodePath == gamePath || (fs::exists(nodePath) && fs::exists(gamePath) && fs::equivalent(nodePath, gamePath)))
{
// found it
root.remove_child(fileNode);
break;
}
}
// it was either removed or never existed to begin with; either way, we can add it now
addFileDataNode(root, *fit, tag, system);
++fit;
}
//now write the file
//make sure the folders leading up to this path exist (or the write will fail)
boost::filesystem::path xmlWritePath(system->getGamelistPath(true));
boost::filesystem::create_directories(xmlWritePath.parent_path());
if (!doc.save_file(xmlWritePath.c_str())) {
LOG(LogError) << "Error saving gamelist.xml to \"" << xmlWritePath << "\" (for system " << system->getName() << ")!";
}
}else{
LOG(LogError) << "Found no root folder for system \"" << system->getName() << "\"!";
}
}

View file

@ -1,9 +0,0 @@
#pragma once
class SystemData;
// Loads gamelist.xml data into a SystemData.
void parseGamelist(SystemData* system);
// Writes currently loaded metadata for a SystemData to gamelist.xml.
void updateGamelist(SystemData* system);

File diff suppressed because it is too large Load diff

View file

@ -1,135 +0,0 @@
#include "MetaData.h"
#include "components/TextComponent.h"
#include "Log.h"
#include "Util.h"
namespace fs = boost::filesystem;
MetaDataDecl gameDecls[] = {
// key, type, default, statistic, name in GuiMetaDataEd, prompt in GuiMetaDataEd
{"name", MD_STRING, "", false, "name", "enter game name"},
{"desc", MD_MULTILINE_STRING, "", false, "description", "enter description"},
{"image", MD_IMAGE_PATH, "", false, "image", "enter path to image"},
{"thumbnail", MD_IMAGE_PATH, "", false, "thumbnail", "enter path to thumbnail"},
{"rating", MD_RATING, "0.000000", false, "rating", "enter rating"},
{"releasedate", MD_DATE, "not-a-date-time", false, "release date", "enter release date"},
{"developer", MD_STRING, "unknown", false, "developer", "enter game developer"},
{"publisher", MD_STRING, "unknown", false, "publisher", "enter game publisher"},
{"genre", MD_STRING, "unknown", false, "genre", "enter game genre"},
{"players", MD_INT, "1", false, "players", "enter number of players"},
{"playcount", MD_INT, "0", true, "play count", "enter number of times played"},
{"lastplayed", MD_TIME, "0", true, "last played", "enter last played date"}
};
const std::vector<MetaDataDecl> gameMDD(gameDecls, gameDecls + sizeof(gameDecls) / sizeof(gameDecls[0]));
MetaDataDecl folderDecls[] = {
{"name", MD_STRING, "", false},
{"desc", MD_MULTILINE_STRING, "", false},
{"image", MD_IMAGE_PATH, "", false},
{"thumbnail", MD_IMAGE_PATH, "", false},
};
const std::vector<MetaDataDecl> folderMDD(folderDecls, folderDecls + sizeof(folderDecls) / sizeof(folderDecls[0]));
const std::vector<MetaDataDecl>& getMDDByType(MetaDataListType type)
{
switch(type)
{
case GAME_METADATA:
return gameMDD;
case FOLDER_METADATA:
return folderMDD;
}
LOG(LogError) << "Invalid MDD type";
return gameMDD;
}
MetaDataList::MetaDataList(MetaDataListType type)
: mType(type)
{
const std::vector<MetaDataDecl>& mdd = getMDD();
for(auto iter = mdd.begin(); iter != mdd.end(); iter++)
set(iter->key, iter->defaultValue);
}
MetaDataList MetaDataList::createFromXML(MetaDataListType type, pugi::xml_node node, const fs::path& relativeTo)
{
MetaDataList mdl(type);
const std::vector<MetaDataDecl>& mdd = mdl.getMDD();
for(auto iter = mdd.begin(); iter != mdd.end(); iter++)
{
pugi::xml_node md = node.child(iter->key.c_str());
if(md)
{
// if it's a path, resolve relative paths
std::string value = md.text().get();
if(iter->type == MD_IMAGE_PATH)
value = resolvePath(value, relativeTo, true).generic_string();
mdl.set(iter->key, value);
}else{
mdl.set(iter->key, iter->defaultValue);
}
}
return mdl;
}
void MetaDataList::appendToXML(pugi::xml_node parent, bool ignoreDefaults, const fs::path& relativeTo) const
{
const std::vector<MetaDataDecl>& mdd = getMDD();
for(auto mddIter = mdd.begin(); mddIter != mdd.end(); mddIter++)
{
auto mapIter = mMap.find(mddIter->key);
if(mapIter != mMap.end())
{
// we have this value!
// if it's just the default (and we ignore defaults), don't write it
if(ignoreDefaults && mapIter->second == mddIter->defaultValue)
continue;
// try and make paths relative if we can
std::string value = mapIter->second;
if(mddIter->type == MD_IMAGE_PATH)
value = makeRelativePath(value, relativeTo, true).generic_string();
parent.append_child(mapIter->first.c_str()).text().set(value.c_str());
}
}
}
void MetaDataList::set(const std::string& key, const std::string& value)
{
mMap[key] = value;
}
void MetaDataList::setTime(const std::string& key, const boost::posix_time::ptime& time)
{
mMap[key] = boost::posix_time::to_iso_string(time);
}
const std::string& MetaDataList::get(const std::string& key) const
{
return mMap.at(key);
}
int MetaDataList::getInt(const std::string& key) const
{
return atoi(get(key).c_str());
}
float MetaDataList::getFloat(const std::string& key) const
{
return (float)atof(get(key).c_str());
}
boost::posix_time::ptime MetaDataList::getTime(const std::string& key) const
{
return string_to_ptime(get(key), "%Y%m%dT%H%M%S%F%q");
}

Some files were not shown because too many files have changed in this diff Show more