Add Explicit Gamelist Type selection to GUI menu.

Currently supports Basic, Detailed, Video, and Automatic types. The Automatic type checks for the availability of first video's, then screenshots, defaulting to Basic view if none are present.
This commit is contained in:
D. Polders 2017-03-24 20:30:20 +01:00
parent bf1c0b841b
commit 003d9edbf9
4 changed files with 69 additions and 23 deletions

View file

@ -160,6 +160,24 @@ GuiMenu::GuiMenu(Window* window) : GuiComponent(window), mMenu(window, "MAIN MEN
});
}
// GameList view style
auto gamelist_style = std::make_shared< OptionListComponent<std::string> >(mWindow, "GAMELIST VIEW STYLE", false);
std::vector<std::string> styles;
styles.push_back("automatic");
styles.push_back("basic");
styles.push_back("detailed");
styles.push_back("video");
for (auto it = styles.begin(); it != styles.end(); it++)
gamelist_style->add(*it, *it, Settings::getInstance()->getString("GamelistViewStyle") == *it);
s->addWithLabel("GAMELIST VIEW STYLE", gamelist_style);
s->addSaveFunc([gamelist_style] {
bool needReload = false;
if (Settings::getInstance()->getString("GamelistViewStyle") != gamelist_style->getSelected())
needReload = true;
Settings::getInstance()->setString("GamelistViewStyle", gamelist_style->getSelected());
if (needReload)
ViewController::get()->reloadAll();
});
mWindow->pushGui(s);
});

View file

@ -231,33 +231,51 @@ std::shared_ptr<IGameListView> ViewController::getGameListView(SystemData* syste
bool themeHasVideoView = system->getTheme()->hasView("video");
//decide type
bool detailed = false;
bool video = false;
std::vector<FileData*> files = system->getRootFolder()->getFilesRecursive(GAME | FOLDER);
for(auto it = files.begin(); it != files.end(); it++)
GameListViewType selectedViewType = AUTOMATIC;
std::string viewPreference = Settings::getInstance()->getString("GamelistViewStyle");
if (viewPreference.compare("basic") == 0)
selectedViewType = BASIC;
if (viewPreference.compare("detailed") == 0)
selectedViewType = DETAILED;
if (viewPreference.compare("video") == 0)
selectedViewType = VIDEO;
if (selectedViewType == AUTOMATIC)
{
if(themeHasVideoView && !(*it)->getVideoPath().empty())
std::vector<FileData*> files = system->getRootFolder()->getFilesRecursive(GAME | FOLDER);
for (auto it = files.begin(); it != files.end(); it++)
{
video = true;
break;
}
else if(!(*it)->getThumbnailPath().empty())
{
detailed = true;
// Don't break out in case any subsequent files have video
if (themeHasVideoView && !(*it)->getVideoPath().empty())
{
selectedViewType = VIDEO;
break;
}
else if (!(*it)->getThumbnailPath().empty())
{
selectedViewType = DETAILED;
// Don't break out in case any subsequent files have video
}
}
}
if (video)
// Create the view
view = std::shared_ptr<IGameListView>(new VideoGameListView(mWindow, system->getRootFolder()));
else if(detailed)
view = std::shared_ptr<IGameListView>(new DetailedGameListView(mWindow, system->getRootFolder()));
else
view = std::shared_ptr<IGameListView>(new BasicGameListView(mWindow, system->getRootFolder()));
// uncomment for experimental "image grid" view
//view = std::shared_ptr<IGameListView>(new GridGameListView(mWindow, system->getRootFolder()));
// Create the view
switch (selectedViewType)
{
case VIDEO:
view = std::shared_ptr<IGameListView>(new VideoGameListView(mWindow, system->getRootFolder()));
break;
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 BASIC:
default:
view = std::shared_ptr<IGameListView>(new BasicGameListView(mWindow, system->getRootFolder()));
break;
}
view->setTheme(system->getTheme());

View file

@ -49,6 +49,15 @@ public:
GAME_LIST
};
enum GameListViewType
{
AUTOMATIC,
BASIC,
DETAILED,
VIDEO
// GRID TODO!
};
struct State
{
ViewMode viewing;

View file

@ -75,6 +75,7 @@ void Settings::setDefaults()
mStringMap["ThemeSet"] = "";
mStringMap["ScreenSaverBehavior"] = "dim";
mStringMap["Scraper"] = "TheGamesDB";
mStringMap["GamelistViewStyle"] = "automatic";
}
template <typename K, typename V>