Merge pull request #133 from pjft/RetroPie-master-filter-rebase

Fixing whitespaces and indentation (tabs)
This commit is contained in:
Jools Wills 2017-05-18 14:29:03 +01:00 committed by GitHub
commit 7d43c87757
19 changed files with 160 additions and 153 deletions

View file

@ -108,7 +108,7 @@ target_link_libraries(emulationstation ${COMMON_LIBRARIES} es-core)
# special properties for Windows builds
if(MSVC)
# Always compile with the "WINDOWS" subsystem to avoid console window flashing at startup
# Always compile with the "WINDOWS" subsystem to avoid console window flashing at startup
# when --debug is not set (see es-core/src/main.cpp for explanation).
# The console will still be shown if launched with --debug.
# Note that up to CMake 2.8.10 this feature is broken: http://public.kitware.com/Bug/view.php?id=12566

View file

@ -82,7 +82,7 @@ const std::string& FileData::getThumbnailPath() const
}
const std::vector<FileData*>& FileData::getChildrenListToDisplay() {
FileFilterIndex* idx = mSystem->getIndex();
if (idx->isFiltered()) {
mFilteredChildren.clear();
@ -95,7 +95,7 @@ const std::vector<FileData*>& FileData::getChildrenListToDisplay() {
return mFilteredChildren;
}
else
else
{
return mChildren;
}
@ -123,7 +123,7 @@ std::vector<FileData*> FileData::getFilesRecursive(unsigned int typeMask, bool d
if (!displayedOnly || !idx->isFiltered() || idx->showFile(*it))
out.push_back(*it);
}
if((*it)->getChildren().size() > 0)
{
std::vector<FileData*> subchildren = (*it)->getFilesRecursive(typeMask, displayedOnly);

View file

@ -44,13 +44,13 @@ public:
inline const std::unordered_map<std::string, FileData*>& getChildrenByFilename() const { return mChildrenByFilename; }
inline const std::vector<FileData*>& getChildren() const { return mChildren; }
inline SystemData* getSystem() const { return mSystem; }
virtual const std::string& getThumbnailPath() const;
virtual const std::string& getVideoPath() const;
virtual const std::string& getMarqueePath() const;
const std::vector<FileData*>& getChildrenListToDisplay();
std::vector<FileData*> getFilesRecursive(unsigned int typeMask, bool displayedOnly = false) const;
std::vector<FileData*> getFilesRecursive(unsigned int typeMask, bool displayedOnly = false) const;
void addChild(FileData* file); // Error if mType != FOLDER
void removeChild(FileData* file); //Error if mType != FOLDER
@ -70,7 +70,7 @@ public:
bool ascending;
std::string description;
SortType(ComparisonFunction* sortFunction, bool sortAscending, const std::string & sortDescription)
SortType(ComparisonFunction* sortFunction, bool sortAscending, const std::string & sortDescription)
: comparisonFunction(sortFunction), ascending(sortAscending), description(sortDescription) {}
};

View file

@ -3,7 +3,7 @@
#define UNKNOWN_LABEL "UNKNOWN"
#define INCLUDE_UNKNOWN false;
FileFilterIndex::FileFilterIndex()
FileFilterIndex::FileFilterIndex()
: filterByGenre(false), filterByPlayers(false), filterByPubDev(false), filterByRatings(false)
{
FilterDataDecl filterDecls[] = {
@ -26,7 +26,7 @@ FileFilterIndex::~FileFilterIndex()
}
std::vector<FilterDataDecl>& FileFilterIndex::getFilterDataDecls()
std::vector<FilterDataDecl>& FileFilterIndex::getFilterDataDecls()
{
return filterDataDecl;
}
@ -34,7 +34,7 @@ std::vector<FilterDataDecl>& FileFilterIndex::getFilterDataDecls()
std::string FileFilterIndex::getIndexableKey(FileData* game, FilterIndexType type, bool getSecondary)
{
std::string key = "";
switch(type)
switch(type)
{
case GENRE_FILTER:
{
@ -42,24 +42,24 @@ std::string FileFilterIndex::getIndexableKey(FileData* game, FilterIndexType typ
boost::trim(key);
if (getSecondary && !key.empty()) {
std::istringstream f(key);
std::string newKey;
getline(f, newKey, '/');
if (!newKey.empty() && newKey != key)
{
key = newKey;
}
else
{
key = std::string();
}
}
std::string newKey;
getline(f, newKey, '/');
if (!newKey.empty() && newKey != key)
{
key = newKey;
}
else
{
key = std::string();
}
}
break;
}
case PLAYER_FILTER:
{
if (getSecondary)
break;
key = game->metadata.get("players");
break;
}
@ -77,8 +77,8 @@ std::string FileFilterIndex::getIndexableKey(FileData* game, FilterIndexType typ
case RATINGS_FILTER:
{
int ratingNumber = 0;
if (!getSecondary)
{
if (!getSecondary)
{
std::string ratingString = game->metadata.get("rating");
if (!ratingString.empty()) {
try {
@ -87,11 +87,11 @@ std::string FileFilterIndex::getIndexableKey(FileData* game, FilterIndexType typ
ratingNumber = 0;
key = std::to_string(ratingNumber) + " STARS";
}
catch (int e)
}
catch (int e)
{
LOG(LogError) << "Error parsing Rating (invalid value, expected decimal): " << ratingString;
}
}
}
}
break;
@ -120,7 +120,7 @@ void FileFilterIndex::removeFromIndex(FileData* game)
manageRatingsEntryInIndex(game, true);
}
void FileFilterIndex::setFilter(FilterIndexType type, std::vector<std::string>* values)
void FileFilterIndex::setFilter(FilterIndexType type, std::vector<std::string>* values)
{
// test if it exists before setting
if(type == NONE)
@ -128,7 +128,7 @@ void FileFilterIndex::setFilter(FilterIndexType type, std::vector<std::string>*
clearAllFilters();
}
else
{
{
for (std::vector<FilterDataDecl>::iterator it = filterDataDecl.begin(); it != filterDataDecl.end(); ++it ) {
if ((*it).type == type)
{
@ -136,20 +136,21 @@ void FileFilterIndex::setFilter(FilterIndexType type, std::vector<std::string>*
*(filterData.filteredByRef) = values->size() > 0;
filterData.currentFilteredKeys->clear();
for (std::vector<std::string>::iterator vit = values->begin(); vit != values->end(); ++vit ) {
// check if exists
if (filterData.allIndexKeys->find(*vit) != filterData.allIndexKeys->end()) {
filterData.currentFilteredKeys->push_back(std::string(*vit));
}
}
// check if exists
if (filterData.allIndexKeys->find(*vit) != filterData.allIndexKeys->end()) {
filterData.currentFilteredKeys->push_back(std::string(*vit));
}
}
}
}
}
return;
}
void FileFilterIndex::clearAllFilters()
void FileFilterIndex::clearAllFilters()
{
for (std::vector<FilterDataDecl>::iterator it = filterDataDecl.begin(); it != filterDataDecl.end(); ++it ) {
for (std::vector<FilterDataDecl>::iterator it = filterDataDecl.begin(); it != filterDataDecl.end(); ++it )
{
FilterDataDecl filterData = (*it);
*(filterData.filteredByRef) = false;
filterData.currentFilteredKeys->clear();
@ -157,36 +158,36 @@ void FileFilterIndex::clearAllFilters()
return;
}
void FileFilterIndex::debugPrintIndexes()
void FileFilterIndex::debugPrintIndexes()
{
LOG(LogInfo) << "Printing Indexes...";
for (auto x: playersIndexAllKeys) {
LOG(LogInfo) << "Multiplayer Index: " << x.first << ": " << x.second;
LOG(LogInfo) << "Multiplayer Index: " << x.first << ": " << x.second;
}
for (auto x: genreIndexAllKeys) {
LOG(LogInfo) << "Genre Index: " << x.first << ": " << x.second;
LOG(LogInfo) << "Genre Index: " << x.first << ": " << x.second;
}
for (auto x: ratingsIndexAllKeys) {
LOG(LogInfo) << "Ratings Index: " << x.first << ": " << x.second;
LOG(LogInfo) << "Ratings Index: " << x.first << ": " << x.second;
}
for (auto x: pubDevIndexAllKeys) {
LOG(LogInfo) << "PubDev Index: " << x.first << ": " << x.second;
LOG(LogInfo) << "PubDev Index: " << x.first << ": " << x.second;
}
}
bool FileFilterIndex::showFile(FileData* game)
{
{
// this shouldn't happen, but just in case let's get it out of the way
if (!isFiltered())
return true;
// if folder, needs further inspection - i.e. see if folder contains at least one element
// that should be shown
if (game->getType() == FOLDER) {
if (game->getType() == FOLDER) {
std::vector<FileData*> children = game->getChildren();
// iterate through all of the children, until there's a match
for (std::vector<FileData*>::iterator it = children.begin(); it != children.end(); ++it ) {
for (std::vector<FileData*>::iterator it = children.begin(); it != children.end(); ++it ) {
if (showFile(*it))
{
return true;
@ -199,47 +200,53 @@ bool FileFilterIndex::showFile(FileData* game)
for (std::vector<FilterDataDecl>::iterator it = filterDataDecl.begin(); it != filterDataDecl.end(); ++it ) {
FilterDataDecl filterData = (*it);
if(*(filterData.filteredByRef)) {
if(*(filterData.filteredByRef))
{
// try to find a match
std::string key = getIndexableKey(game, filterData.type, false);
keepGoing = isKeyBeingFilteredBy(key, filterData.type);
std::string key = getIndexableKey(game, filterData.type, false);
keepGoing = isKeyBeingFilteredBy(key, filterData.type);
// if we didn't find a match, try for secondary keys - i.e. publisher and dev, or first genre
if (!keepGoing) {
if (!filterData.hasSecondaryKey)
{
return false;
}
std::string secKey = getIndexableKey(game, filterData.type, true);
if (secKey != UNKNOWN_LABEL)
{
keepGoing = isKeyBeingFilteredBy(secKey, filterData.type);
}
}
// if still nothing, then it's not a match
if (!keepGoing)
if (!keepGoing)
{
if (!filterData.hasSecondaryKey)
{
return false;
}
std::string secKey = getIndexableKey(game, filterData.type, true);
if (secKey != UNKNOWN_LABEL)
{
keepGoing = isKeyBeingFilteredBy(secKey, filterData.type);
}
}
// if still nothing, then it's not a match
if (!keepGoing)
return false;
}
}
return keepGoing;
}
bool FileFilterIndex::isKeyBeingFilteredBy(std::string key, FilterIndexType type) {
bool FileFilterIndex::isKeyBeingFilteredBy(std::string key, FilterIndexType type)
{
const FilterIndexType filterTypes[4] = { PLAYER_FILTER, RATINGS_FILTER, GENRE_FILTER, PUBDEV_FILTER };
std::vector<std::string> filterKeysList[4] = { playersIndexFilteredKeys, ratingsIndexFilteredKeys, genreIndexFilteredKeys, pubDevIndexFilteredKeys };
for (int i = 0; i < 4; i++) {
if (filterTypes[i] == type) {
for (std::vector<std::string>::iterator it = filterKeysList[i].begin(); it != filterKeysList[i].end(); ++it ) {
if (key == (*it))
for (int i = 0; i < 4; i++)
{
if (filterTypes[i] == type)
{
for (std::vector<std::string>::iterator it = filterKeysList[i].begin(); it != filterKeysList[i].end(); ++it )
{
if (key == (*it))
{
return true;
}
}
return false;
}
return false;
}
}
@ -258,7 +265,7 @@ void FileFilterIndex::manageGenreEntryInIndex(FileData* game, bool remove)
if (!includeUnknown && (key == UNKNOWN_LABEL || key == "BIOS")) {
// no valid genre info found
return;
}
}
manageIndexEntry(&genreIndexAllKeys, key, remove);
@ -279,7 +286,7 @@ void FileFilterIndex::managePlayerEntryInIndex(FileData* game, bool remove)
if (!includeUnknown && key == UNKNOWN_LABEL) {
// no valid player info found
return;
}
}
manageIndexEntry(&playersIndexAllKeys, key, remove);
}
@ -304,13 +311,13 @@ void FileFilterIndex::managePubDevEntryInIndex(FileData* game, bool remove)
if (!includeUnknown && unknownDev && unknownPub) {
// no valid rating info found
return;
}
}
if (unknownDev && unknownPub) {
// if no info at all
manageIndexEntry(&pubDevIndexAllKeys, pub, remove);
}
else
else
{
if (!unknownDev) {
// if no info at all
@ -333,7 +340,7 @@ void FileFilterIndex::manageRatingsEntryInIndex(FileData* game, bool remove)
if (!includeUnknown && key == UNKNOWN_LABEL) {
// no valid rating info found
return;
}
}
manageIndexEntry(&ratingsIndexAllKeys, key, remove);
}
@ -348,7 +355,7 @@ void FileFilterIndex::manageIndexEntry(std::map<std::string, int>* index, std::s
{
// this shouldn't happen
LOG(LogError) << "Couldn't find entry in index! " << key;
}
}
else
{
(index->at(key))--;
@ -356,22 +363,22 @@ void FileFilterIndex::manageIndexEntry(std::map<std::string, int>* index, std::s
index->erase(key);
}
}
}
else
}
else
{
// adding entry
if (index->find(key) == index->end())
{
(*index)[key] = 1;
}
}
else
{
(index->at(key))++;
}
}
}
}
void FileFilterIndex::clearIndex(std::map<std::string, int> indexMap)
{
indexMap.clear();
indexMap.clear();
}

View file

@ -38,7 +38,7 @@ public:
void addToIndex(FileData* game);
void removeFromIndex(FileData* game);
void setFilter(FilterIndexType type, std::vector<std::string>* values);
void clearAllFilters();
void clearAllFilters();
void debugPrintIndexes();
bool showFile(FileData* game);
bool isFiltered() { return (filterByGenre || filterByPlayers || filterByPubDev || filterByRatings); };
@ -49,7 +49,7 @@ public:
private:
std::vector<FilterDataDecl> filterDataDecl;
std::string getIndexableKey(FileData* game, FilterIndexType type, bool getSecondary);
void manageGenreEntryInIndex(FileData* game, bool remove = false);
void managePlayerEntryInIndex(FileData* game, bool remove = false);
void managePubDevEntryInIndex(FileData* game, bool remove = false);

View file

@ -68,7 +68,7 @@ FileData* findOrCreateFile(SystemData* system, const boost::filesystem::path& pa
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);
@ -118,7 +118,7 @@ void parseGamelist(SystemData* system)
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(!trustGamelist && !boost::filesystem::exists(path))
{
LOG(LogWarning) << "File \"" << path << "\" does not exist! Ignoring.";
@ -160,7 +160,7 @@ void addFileDataNode(pugi::xml_node& parent, const FileData* file, const char* t
//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->getDisplayName()) //the name is the default
@ -194,7 +194,7 @@ void updateGamelist(SystemData* system)
{
//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();

View file

@ -17,7 +17,7 @@ std::vector<SystemData*> SystemData::sSystemVector;
namespace fs = boost::filesystem;
SystemData::SystemData(const std::string& name, const std::string& fullName, const std::string& startPath, const std::vector<std::string>& extensions,
SystemData::SystemData(const std::string& name, const std::string& fullName, const std::string& startPath, const std::vector<std::string>& extensions,
const std::string& command, const std::vector<PlatformIds::PlatformId>& platformIds, const std::string& themeFolder)
{
mName = name;
@ -70,7 +70,7 @@ std::string strreplace(std::string str, const std::string& replace, const std::s
size_t pos;
while((pos = str.find(replace)) != std::string::npos)
str = str.replace(pos, replace.length(), with.c_str(), with.length());
return str;
}
@ -182,7 +182,7 @@ void SystemData::populateFolder(FileData* folder)
//this is a little complicated because we allow a list of extensions to be defined (delimited with a space)
//we first get the extension of the file itself:
extension = filePath.extension().string();
//fyi, folders *can* also match the extension and be added as games - this is mostly just to support higan
//see issue #75: https://github.com/Aloshi/EmulationStation/issues/75
@ -283,7 +283,7 @@ bool SystemData::loadConfig()
{
const char* str = it->c_str();
PlatformIds::PlatformId platformId = PlatformIds::getPlatformId(str);
if(platformId == PlatformIds::PLATFORM_IGNORE)
{
// when platform is ignore, do not allow other platforms

View file

@ -12,7 +12,7 @@
class SystemData
{
public:
SystemData(const std::string& name, const std::string& fullName, const std::string& startPath, const std::vector<std::string>& extensions,
SystemData(const std::string& name, const std::string& fullName, const std::string& startPath, const std::vector<std::string>& extensions,
const std::string& command, const std::vector<PlatformIds::PlatformId>& platformIds, const std::string& themeFolder);
~SystemData();
@ -31,7 +31,7 @@ public:
std::string getGamelistPath(bool forWrite) const;
bool hasGamelist() const;
std::string getThemePath() const;
unsigned int getGameCount() const;
unsigned int getDisplayedGameCount() const;
@ -46,7 +46,7 @@ public:
inline std::vector<SystemData*>::const_iterator getIterator() const { return std::find(sSystemVector.begin(), sSystemVector.end(), this); };
inline std::vector<SystemData*>::const_reverse_iterator getRevIterator() const { return std::find(sSystemVector.rbegin(), sSystemVector.rend(), this); };
inline SystemData* getNext() const
{
auto it = getIterator();

View file

@ -10,11 +10,11 @@ GuiGamelistFilter::GuiGamelistFilter(Window* window, SystemData* system) : GuiCo
initializeMenu();
}
void GuiGamelistFilter::initializeMenu()
void GuiGamelistFilter::initializeMenu()
{
addChild(&mMenu);
// get filters from system
// get filters from system
mFilterIndex = mSystem->getIndex();
@ -45,10 +45,10 @@ void GuiGamelistFilter::resetAllFilters()
GuiGamelistFilter::~GuiGamelistFilter()
{
mFilterOptions.clear();
mFilterOptions.clear();
}
void GuiGamelistFilter::addFiltersToMenu()
void GuiGamelistFilter::addFiltersToMenu()
{
std::vector<FilterDataDecl> decls = mFilterIndex->getFilterDataDecls();
for (std::vector<FilterDataDecl>::iterator it = decls.begin(); it != decls.end(); ++it ) {
@ -59,9 +59,9 @@ void GuiGamelistFilter::addFiltersToMenu()
std::string menuLabel = (*it).menuLabel; // text to show in menu
std::shared_ptr< OptionListComponent<std::string> > optionList;
// add filters (with first one selected)
ComponentListRow row;
ComponentListRow row;
// add genres
optionList = std::make_shared< OptionListComponent<std::string> >(mWindow, menuLabel, true);
@ -72,7 +72,7 @@ void GuiGamelistFilter::addFiltersToMenu()
if (allKeys->size() > 0)
mMenu.addWithLabel(menuLabel, optionList);
mFilterOptions[type] = optionList;
mFilterOptions[type] = optionList;
}
}
@ -86,7 +86,7 @@ void GuiGamelistFilter::applyFilters()
}
delete this;
}
bool GuiGamelistFilter::input(InputConfig* config, Input input)

View file

@ -25,7 +25,7 @@ private:
void applyFilters();
void resetAllFilters();
void addFiltersToMenu();
std::map<FilterIndexType, std::shared_ptr< OptionListComponent<std::string> >> mFilterOptions;
MenuComponent mMenu;

View file

@ -3,7 +3,7 @@
#include "views/gamelist/IGameListView.h"
#include "views/ViewController.h"
GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) : GuiComponent(window),
GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) : GuiComponent(window),
mSystem(system), mMenu(window, "OPTIONS"), fromPlaceholder(false), mFiltersChanged(false)
{
addChild(&mMenu);
@ -95,8 +95,8 @@ GuiGamelistOptions::~GuiGamelistOptions()
// notify that the root folder was sorted
getGamelist()->onFileChanged(root, FILE_SORTED);
}
if (mFiltersChanged)
}
if (mFiltersChanged)
{
if (!fromPlaceholder) {
FileData* root = getGamelist()->getCursor()->getSystem()->getRootFolder();
@ -108,7 +108,7 @@ GuiGamelistOptions::~GuiGamelistOptions()
// as we need to re-display the remaining elements for whatever new
// game is selected
ViewController::get()->reloadGameListView(mSystem);
}
}
}
}
@ -117,7 +117,7 @@ void GuiGamelistOptions::openGamelistFilter()
mFiltersChanged = true;
GuiGamelistFilter* ggf = new GuiGamelistFilter(mWindow, mSystem);
mWindow->pushGui(ggf);
}
}
void GuiGamelistOptions::openMetaDataEd()
{
@ -140,7 +140,7 @@ void GuiGamelistOptions::openMetaDataEd()
};
}
mWindow->pushGui(new GuiMetaDataEd(mWindow, &file->metadata, file->metadata.getMDD(), p, file->getPath().filename().string(),
mWindow->pushGui(new GuiMetaDataEd(mWindow, &file->metadata, file->metadata.getMDD(), p, file->getPath().filename().string(),
std::bind(&IGameListView::onFileChanged, getGamelist(), file, FILE_METADATA_CHANGED), deleteBtnFunc));
}
@ -151,7 +151,7 @@ void GuiGamelistOptions::jumpToLetter()
// this is a really shitty way to get a list of files
const std::vector<FileData*>& files = gamelist->getCursor()->getParent()->getChildren();
long min = 0;
long max = files.size() - 1;
long mid = 0;

View file

@ -19,7 +19,7 @@ private:
void openGamelistFilter();
void openMetaDataEd();
void jumpToLetter();
MenuComponent mMenu;
typedef OptionListComponent<char> LetterList;
@ -27,7 +27,7 @@ private:
typedef OptionListComponent<const FileData::SortType*> SortList;
std::shared_ptr<SortList> mListSort;
SystemData* mSystem;
IGameListView* getGamelist();
bool fromPlaceholder;

View file

@ -15,24 +15,24 @@
using namespace Eigen;
GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector<MetaDataDecl>& mdd, ScraperSearchParams scraperParams,
const std::string& header, std::function<void()> saveCallback, std::function<void()> deleteFunc) : GuiComponent(window),
mScraperParams(scraperParams),
GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector<MetaDataDecl>& mdd, ScraperSearchParams scraperParams,
const std::string& header, std::function<void()> saveCallback, std::function<void()> deleteFunc) : GuiComponent(window),
mScraperParams(scraperParams),
mBackground(window, ":/frame.png"),
mBackground(window, ":/frame.png"),
mGrid(window, Vector2i(1, 3)),
mMetaDataDecl(mdd),
mMetaData(md),
mMetaDataDecl(mdd),
mMetaData(md),
mSavedCallback(saveCallback), mDeleteFunc(deleteFunc)
{
addChild(&mBackground);
addChild(&mGrid);
mHeaderGrid = std::make_shared<ComponentGrid>(mWindow, Vector2i(1, 5));
mTitle = std::make_shared<TextComponent>(mWindow, "EDIT METADATA", Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER);
mSubtitle = std::make_shared<TextComponent>(mWindow, strToUpper(scraperParams.game->getPath().filename().generic_string()),
mSubtitle = std::make_shared<TextComponent>(mWindow, strToUpper(scraperParams.game->getPath().filename().generic_string()),
Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER);
mHeaderGrid->setEntry(mTitle, Vector2i(0, 1), false, true);
mHeaderGrid->setEntry(mSubtitle, Vector2i(0, 3), false, true);
@ -101,7 +101,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector
// MD_STRING
ed = std::make_shared<TextComponent>(window, "", Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT), 0x777777FF, ALIGN_RIGHT);
row.addElement(ed, true);
auto spacer = std::make_shared<GuiComponent>(mWindow);
spacer->setSize(Renderer::getScreenWidth() * 0.005f, 0);
row.addElement(spacer, false);
@ -236,7 +236,7 @@ void GuiMetaDataEd::close(bool closeAllWindows)
if(dirty)
{
// changes were made, ask if the user wants to save them
mWindow->pushGui(new GuiMsgBox(mWindow,
mWindow->pushGui(new GuiMsgBox(mWindow,
"SAVE CHANGES?",
"YES", [this, closeFunc] { save(); closeFunc(); },
"NO", closeFunc

View file

@ -127,10 +127,10 @@ void ViewController::goToRandomGame()
if ((*it)->getName() != "retropie")
total += (*it)->getDisplayedGameCount();
}
// get random number in range
int target = std::round(((double)std::rand() / (double)RAND_MAX) * total);
for (auto it = SystemData::sSystemVector.begin(); it != SystemData::sSystemVector.end(); it++)
{
if ((*it)->getName() != "retropie")
@ -153,7 +153,7 @@ void ViewController::goToRandomGame()
void ViewController::playViewTransition()
{
Eigen::Vector3f target(Eigen::Vector3f::Identity());
if(mCurrentView)
if(mCurrentView)
target = mCurrentView->getPosition();
// no need to animate, we're not going anywhere (probably goToNextGamelist() or goToPrevGamelist() when there's only 1 system)
@ -238,7 +238,7 @@ void ViewController::launch(FileData* game, Eigen::Vector3f center)
});
}else{
// move camera to zoom in on center + fade out, launch game, come back in
setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 1500), 0, [this, origCamera, center, game]
setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 1500), 0, [this, origCamera, center, game]
{
game->getSystem()->launchGame(mWindow, game);
mCamera = origCamera;
@ -372,7 +372,7 @@ void ViewController::render(const Eigen::Affine3f& parentTrans)
// draw systemview
getSystemListView()->render(trans);
// draw gamelists
for(auto it = mGameListViews.begin(); it != mGameListViews.end(); it++)
{
@ -477,7 +477,7 @@ std::vector<HelpPrompt> ViewController::getHelpPrompts()
std::vector<HelpPrompt> prompts;
if(!mCurrentView)
return prompts;
prompts = mCurrentView->getHelpPrompts();
prompts.push_back(HelpPrompt("start", "menu"));

View file

@ -80,7 +80,7 @@ void BasicGameListView::setCursor(FileData* cursor)
tmp.push(ptr);
ptr = ptr->getParent();
}
// flip the stack and put it in mCursorStack
mCursorStack = std::stack<FileData*>();
while(!tmp.empty())

View file

@ -12,7 +12,7 @@ ISimpleGameListView::ISimpleGameListView(Window* window, FileData* root) : IGame
mHeaderText.setSize(mSize.x(), 0);
mHeaderText.setPosition(0, 0);
mHeaderText.setAlignment(ALIGN_CENTER);
mHeaderImage.setResize(0, mSize.y() * 0.185f);
mHeaderImage.setOrigin(0.5f, 0.0f);
mHeaderImage.setPosition(mSize.x() / 2, 0);
@ -51,7 +51,7 @@ void ISimpleGameListView::onFileChanged(FileData* file, FileChangeType change)
populateList(cursor->getParent()->getChildrenListToDisplay());
setCursor(cursor);
}
else
else
{
populateList(mRoot->getChildrenListToDisplay());
setCursor(cursor);
@ -77,7 +77,7 @@ bool ISimpleGameListView::input(InputConfig* config, Input input)
populateList(cursor->getChildrenListToDisplay());
}
}
return true;
}else if(config->isMappedTo("b", input))
{

View file

@ -6,17 +6,17 @@
#include <fcntl.h>
VideoGameListView::VideoGameListView(Window* window, FileData* root) :
BasicGameListView(window, root),
mDescContainer(window), mDescription(window),
BasicGameListView(window, root),
mDescContainer(window), mDescription(window),
mMarquee(window),
mImage(window),
mVideo(window),
mVideoPlaying(false),
mLblRating(window), mLblReleaseDate(window), mLblDeveloper(window), mLblPublisher(window),
mLblRating(window), mLblReleaseDate(window), mLblDeveloper(window), mLblPublisher(window),
mLblGenre(window), mLblPlayers(window), mLblLastPlayed(window), mLblPlayCount(window),
mRating(window), mReleaseDate(window), mDeveloper(window), mPublisher(window),
mRating(window), mReleaseDate(window), mDeveloper(window), mPublisher(window),
mGenre(window), mPlayers(window), mLastPlayed(window), mPlayCount(window)
{
const float padding = 0.01f;
@ -151,7 +151,7 @@ void VideoGameListView::initMDLabels()
const unsigned int rowCount = components.size() / 2;
Vector3f start(mSize.x() * 0.01f, mSize.y() * 0.625f, 0.0f);
const float colSize = (mSize.x() * 0.48f) / colCount;
const float rowPadding = 0.01f * mSize.y();
@ -266,13 +266,13 @@ void VideoGameListView::updateInfoPanel()
mPublisher.setValue(file->metadata.get("publisher"));
mGenre.setValue(file->metadata.get("genre"));
mPlayers.setValue(file->metadata.get("players"));
if(file->getType() == GAME)
{
mLastPlayed.setValue(file->metadata.get("lastplayed"));
mPlayCount.setValue(file->metadata.get("playcount"));
}
fadingOut = false;
}
@ -291,7 +291,7 @@ void VideoGameListView::updateInfoPanel()
// then animate if reverse != fadingOut
// an animation is not playing
// then animate if opacity != our target opacity
if((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) ||
if((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) ||
(!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255)))
{
auto func = [comp](float t)

View file

@ -121,7 +121,7 @@ void ComponentList::onCursorChanged(const CursorState& state)
{
for(auto it = mEntries.begin(); it != mEntries.end(); it++)
it->data.elements.back().component->onFocusLost();
mEntries.at(mCursor).data.elements.back().component->onFocusGained();
}
@ -167,7 +167,7 @@ void ComponentList::render(const Eigen::Affine3f& parentTrans)
// clip everything to be inside our bounds
Eigen::Vector3f dim(mSize.x(), mSize.y(), 0);
dim = trans * dim - trans.translation();
Renderer::pushClipRect(Eigen::Vector2i((int)trans.translation().x(), (int)trans.translation().y()),
Renderer::pushClipRect(Eigen::Vector2i((int)trans.translation().x(), (int)trans.translation().y()),
Eigen::Vector2i((int)round(dim.x()), (int)round(dim.y() + 1)));
// scroll the camera
@ -201,20 +201,20 @@ void ComponentList::render(const Eigen::Affine3f& parentTrans)
// need a function that goes roughly 0x777777 -> 0xFFFFFF
// and 0xFFFFFF -> 0x777777
// (1 - dst) + 0x77
const float selectedRowHeight = getRowHeight(mEntries.at(mCursor).data);
Renderer::drawRect(0.0f, mSelectorBarOffset, mSize.x(), selectedRowHeight, 0xFFFFFFFF,
GL_ONE_MINUS_DST_COLOR, GL_ZERO);
Renderer::drawRect(0.0f, mSelectorBarOffset, mSize.x(), selectedRowHeight, 0x777777FF,
GL_ONE, GL_ONE);
// hack to draw 2px dark on left/right of the bar
Renderer::drawRect(0.0f, mSelectorBarOffset, 2.0f, selectedRowHeight, 0x878787FF);
Renderer::drawRect(mSize.x() - 2.0f, mSelectorBarOffset, 2.0f, selectedRowHeight, 0x878787FF);
for(auto it = drawAfterCursor.begin(); it != drawAfterCursor.end(); it++)
(*it)->render(trans);
// reset matrix if one of these components changed it
if(drawAfterCursor.size())
Renderer::setMatrix(trans);
@ -335,7 +335,7 @@ std::vector<HelpPrompt> ComponentList::getHelpPrompts()
bool ComponentList::moveCursor(int amt)
{
bool ret = listInput(amt);
listInput(0);
bool ret = listInput(amt);
listInput(0);
return ret;
}

View file

@ -138,7 +138,7 @@ private:
};
public:
OptionListComponent(Window* window, const std::string& name, bool multiSelect = false) : GuiComponent(window), mMultiSelect(multiSelect), mName(name),
OptionListComponent(Window* window, const std::string& name, bool multiSelect = false) : GuiComponent(window), mMultiSelect(multiSelect), mName(name),
mText(window), mLeftArrow(window), mRightArrow(window)
{
auto font = Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT);
@ -251,20 +251,20 @@ public:
onSelectedChanged();
}
void selectAll()
void selectAll()
{
for(unsigned int i = 0; i < mEntries.size(); i++)
{
mEntries.at(i).selected = true;
mEntries.at(i).selected = true;
}
onSelectedChanged();
}
void selectNone()
void selectNone()
{
for(unsigned int i = 0; i < mEntries.size(); i++)
{
mEntries.at(i).selected = false;
mEntries.at(i).selected = false;
}
onSelectedChanged();
}
@ -322,7 +322,7 @@ private:
std::vector<HelpPrompt> prompts;
if(!mMultiSelect)
prompts.push_back(HelpPrompt("left/right", "change"));
prompts.push_back(HelpPrompt("a", "select"));
return prompts;
}