mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-18 07:05:39 +00:00
Merge pull request #108 from zigurana/SelectGamelistViewType
Add Explicit Gamelist Type selection to GUI menu.
This commit is contained in:
commit
006e716e64
|
@ -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);
|
||||
});
|
||||
|
||||
|
|
|
@ -262,33 +262,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());
|
||||
|
||||
|
|
|
@ -50,6 +50,15 @@ public:
|
|||
GAME_LIST
|
||||
};
|
||||
|
||||
enum GameListViewType
|
||||
{
|
||||
AUTOMATIC,
|
||||
BASIC,
|
||||
DETAILED,
|
||||
VIDEO
|
||||
// GRID TODO!
|
||||
};
|
||||
|
||||
struct State
|
||||
{
|
||||
ViewMode viewing;
|
||||
|
|
|
@ -75,6 +75,7 @@ void Settings::setDefaults()
|
|||
mStringMap["ThemeSet"] = "";
|
||||
mStringMap["ScreenSaverBehavior"] = "dim";
|
||||
mStringMap["Scraper"] = "TheGamesDB";
|
||||
mStringMap["GamelistViewStyle"] = "automatic";
|
||||
}
|
||||
|
||||
template <typename K, typename V>
|
||||
|
|
Loading…
Reference in a new issue