Enable the grid view for developers

- Add the remove function to GridGameListView
- Enable the grid view in ViewController
- The grid view will not be available in the menu yet, but can be enable by tweaking es_settings.cfg
This commit is contained in:
Koerty 2018-03-22 08:03:12 +01:00
parent 99cc97680d
commit b4feb69980
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("basic");
styles.push_back("detailed"); styles.push_back("detailed");
styles.push_back("video"); 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++) for (auto it = styles.cbegin(); it != styles.cend(); it++)
gamelist_style->add(*it, *it, Settings::getInstance()->getString("GamelistViewStyle") == *it); gamelist_style->add(*it, *it, Settings::getInstance()->getString("GamelistViewStyle") == *it);
s->addWithLabel("GAMELIST VIEW STYLE", gamelist_style); s->addWithLabel("GAMELIST VIEW STYLE", gamelist_style);

View file

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

View file

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

View file

@ -1,6 +1,7 @@
#include "views/gamelist/GridGameListView.h" #include "views/gamelist/GridGameListView.h"
#include "views/ViewController.h" #include "views/ViewController.h"
#include "SystemData.h"
GridGameListView::GridGameListView(Window* window, FileData* root) : ISimpleGameListView(window, root), GridGameListView::GridGameListView(Window* window, FileData* root) : ISimpleGameListView(window, root),
mGrid(window) 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) void GridGameListView::launch(FileData* game)
{ {
ViewController::get()->launch(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> GridGameListView::getHelpPrompts()
{ {
std::vector<HelpPrompt> prompts; std::vector<HelpPrompt> prompts;

View file

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

View file

@ -9,7 +9,7 @@
#include <pugixml/src/pugixml.hpp> #include <pugixml/src/pugixml.hpp>
#include <algorithm> #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::vector<std::string> ThemeData::sSupportedFeatures { { "video" }, { "carousel" }, { "z-index" } };
std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>> ThemeData::sElementMap { std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>> ThemeData::sElementMap {