Merge pull request #392 from Koerty/grid-enable-for-developers

[GRID 2] Enable the grid for developers
This commit is contained in:
John Rassa 2018-03-27 16:39:31 -07:00 committed by GitHub
commit 9382507e17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 52 additions and 5 deletions

View file

@ -273,6 +273,11 @@ void GuiMenu::openUISettings()
styles.push_back("basic");
styles.push_back("detailed");
styles.push_back("video");
// Temporary "hack" so ES don't crash when leaving this menu after he enabled the grid by tweaking config file
if (Settings::getInstance()->getString("GamelistViewStyle") == "grid")
styles.push_back("grid");
for (auto it = styles.cbegin(); it != styles.cend(); it++)
gamelist_style->add(*it, *it, Settings::getInstance()->getString("GamelistViewStyle") == *it);
s->addWithLabel("GAMELIST VIEW STYLE", gamelist_style);

View file

@ -7,6 +7,7 @@
#include "guis/GuiMenu.h"
#include "views/gamelist/DetailedGameListView.h"
#include "views/gamelist/IGameListView.h"
#include "views/gamelist/GridGameListView.h"
#include "views/gamelist/VideoGameListView.h"
#include "views/SystemView.h"
#include "views/UIModeController.h"
@ -283,6 +284,8 @@ std::shared_ptr<IGameListView> ViewController::getGameListView(SystemData* syste
selectedViewType = BASIC;
if (viewPreference.compare("detailed") == 0)
selectedViewType = DETAILED;
if (viewPreference.compare("grid") == 0)
selectedViewType = GRID;
if (viewPreference.compare("video") == 0)
selectedViewType = VIDEO;
@ -313,9 +316,9 @@ std::shared_ptr<IGameListView> ViewController::getGameListView(SystemData* syste
case DETAILED:
view = std::shared_ptr<IGameListView>(new DetailedGameListView(mWindow, system->getRootFolder()));
break;
// case GRID placeholder for future implementation.
// view = std::shared_ptr<IGameListView>(new GridGameListView(mWindow, system->getRootFolder()));
// break;
case GRID:
view = std::shared_ptr<IGameListView>(new GridGameListView(mWindow, system->getRootFolder()));
break;
case BASIC:
default:
view = std::shared_ptr<IGameListView>(new BasicGameListView(mWindow, system->getRootFolder()));

View file

@ -61,8 +61,8 @@ public:
AUTOMATIC,
BASIC,
DETAILED,
GRID,
VIDEO
// GRID TODO!
};
struct State

View file

@ -1,6 +1,7 @@
#include "views/gamelist/GridGameListView.h"
#include "views/ViewController.h"
#include "SystemData.h"
GridGameListView::GridGameListView(Window* window, FileData* root) : ISimpleGameListView(window, root),
mGrid(window)
@ -43,11 +44,47 @@ void GridGameListView::populateList(const std::vector<FileData*>& files)
}
}
void GridGameListView::addPlaceholder()
{
// empty grid - add a placeholder
FileData* placeholder = new FileData(PLACEHOLDER, "<No Entries Found>", this->mRoot->getSystem()->getSystemEnvData(), this->mRoot->getSystem());
mGrid.add(placeholder->getName(), "", placeholder);
}
void GridGameListView::launch(FileData* game)
{
ViewController::get()->launch(game);
}
void GridGameListView::remove(FileData *game, bool deleteFile)
{
if (deleteFile)
Utils::FileSystem::removeFile(game->getPath()); // actually delete the file on the filesystem
FileData* parent = game->getParent();
if (getCursor() == game) // Select next element in list, or prev if none
{
std::vector<FileData*> siblings = parent->getChildrenListToDisplay();
auto gameIter = std::find(siblings.cbegin(), siblings.cend(), game);
int gamePos = (int)std::distance(siblings.cbegin(), gameIter);
if (gameIter != siblings.cend())
{
if ((gamePos + 1) < siblings.size())
{
setCursor(siblings.at(gamePos + 1));
} else if ((gamePos - 1) > 0) {
setCursor(siblings.at(gamePos - 1));
}
}
}
mGrid.remove(game);
if(mGrid.size() == 0)
{
addPlaceholder();
}
delete game; // remove before repopulating (removes from parent)
onFileChanged(parent, FILE_REMOVED); // update the view, with game removed
}
std::vector<HelpPrompt> GridGameListView::getHelpPrompts()
{
std::vector<HelpPrompt> prompts;

View file

@ -24,6 +24,8 @@ public:
protected:
virtual void populateList(const std::vector<FileData*>& files) override;
virtual void remove(FileData* game, bool deleteFile) override;
virtual void addPlaceholder();
ImageGridComponent<FileData*> mGrid;
};

View file

@ -9,7 +9,7 @@
#include <pugixml/src/pugixml.hpp>
#include <algorithm>
std::vector<std::string> ThemeData::sSupportedViews { { "system" }, { "basic" }, { "detailed" }, { "video" } };
std::vector<std::string> ThemeData::sSupportedViews { { "system" }, { "basic" }, { "detailed" }, { "grid" }, { "video" } };
std::vector<std::string> ThemeData::sSupportedFeatures { { "video" }, { "carousel" }, { "z-index" } };
std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>> ThemeData::sElementMap {