Added support for layouts per collection. When switching collections,

RetroFE will look for layout.xml and corresponding art in the
collections/<collection name>/layout/ subdirectory of your chosen layout,
and load that layout if it is available.
This commit is contained in:
Pieter Hulshoff 2016-06-10 08:58:41 +02:00
parent 1157096f55
commit 537322f9c0
6 changed files with 63 additions and 13 deletions

View File

@ -855,3 +855,10 @@ void Page::launchExit()
}
}
}
void Page::resetMenuItems()
{
activeMenu_->deallocateSpritePoints();
activeMenu_->allocateSpritePoints();
}

View File

@ -89,6 +89,7 @@ public:
float getMinShowTime();
void addPlaylist();
void removePlaylist();
void resetMenuItems();
private:
void highlightEnter();

View File

@ -70,14 +70,22 @@ PageBuilder::~PageBuilder()
{
}
Page *PageBuilder::buildPage()
Page *PageBuilder::buildPage( std::string collectionName )
{
Page *page = NULL;
std::string layoutFile;
std::string layoutName = layoutKey;
layoutPath = Utils::combinePath(Configuration::absolutePath, "layouts", layoutName);
if ( collectionName == "" )
{
layoutPath = Utils::combinePath(Configuration::absolutePath, "layouts", layoutName);
}
else
{
layoutPath = Utils::combinePath(Configuration::absolutePath, "layouts", layoutName, "collections", collectionName);
layoutPath = Utils::combinePath(layoutPath, "layout");
}
layoutFile = Utils::combinePath(layoutPath, layoutPage + ".xml");
Logger::write(Logger::ZONE_INFO, "Layout", "Initializing " + layoutFile);

View File

@ -33,7 +33,7 @@ class PageBuilder
public:
PageBuilder(std::string layoutKey, std::string layoutPage, Configuration &c, FontCache *fc);
virtual ~PageBuilder();
Page *buildPage();
Page *buildPage( std::string collectionName = "" );
private:
std::string layoutKey;

View File

@ -342,11 +342,25 @@ void RetroFE::run()
case RETROFE_NEXT_PAGE_MENU_EXIT:
if(currentPage_->isIdle())
{
bool menuSort = true;
config_.setProperty("currentCollection", nextPageItem_->name);
config_.getProperty("collections." + nextPageItem_->name + ".list.menuSort", menuSort);
// Load new layout if available
std::string layoutName;
config_.getProperty("layout", layoutName);
PageBuilder pb(layoutName, "layout", config_, &fontcache_);
Page *page = pb.buildPage( nextPageItem_->name);
std::string nextPageName = nextPageItem_->name;
if(page)
{
currentPage_->freeGraphicsMemory();
pages_.push( currentPage_ );
currentPage_ = page;
currentPage_->start();
}
CollectionInfo *info = getCollection(nextPageItem_->name);
bool menuSort = true;
config_.setProperty("currentCollection", nextPageName);
config_.getProperty("collections." + nextPageName + ".list.menuSort", menuSort);
CollectionInfo *info = getCollection(nextPageName);
MenuParser mp;
mp.buildMenuItems(info, menuSort);
@ -355,9 +369,9 @@ void RetroFE::run()
bool rememberMenu = false;
config_.getProperty("rememberMenu", rememberMenu);
if(rememberMenu && lastMenuOffsets_.find(nextPageItem_->name) != lastMenuOffsets_.end())
if(rememberMenu && lastMenuOffsets_.find(nextPageName) != lastMenuOffsets_.end())
{
currentPage_->setScrollOffsetIndex(lastMenuOffsets_[nextPageItem_->name]);
currentPage_->setScrollOffsetIndex(lastMenuOffsets_[nextPageName]);
}
bool autoFavorites = true;
@ -388,7 +402,14 @@ void RetroFE::run()
break;
case RETROFE_BACK_REQUEST:
currentPage_->exitMenu();
if (currentPage_->getMenuDepth() == 1 )
{
currentPage_->stop();
}
else
{
currentPage_->exitMenu();
}
state = RETROFE_BACK_MENU_EXIT;
break;
@ -396,8 +417,20 @@ void RetroFE::run()
if(currentPage_->isIdle())
{
lastMenuOffsets_[currentPage_->getCollectionName()] = currentPage_->getScrollOffsetIndex();
currentPage_->popCollection();
if (currentPage_->getMenuDepth() == 1)
{
currentPage_->DeInitialize();
delete currentPage_;
currentPage_ = pages_.top();
pages_.pop();
currentPage_->allocateGraphicsMemory();
}
else
{
currentPage_->popCollection();
}
config_.setProperty("currentCollection", currentPage_->getCollectionName());
currentPage_->resetMenuItems();
currentPage_->setNewItemSelected();
currentPage_->enterMenu();
state = RETROFE_BACK_MENU_ENTER;
@ -468,7 +501,7 @@ bool RetroFE::back(bool &exit)
config_.getProperty("exitOnFirstPageBack", exitOnBack);
exit = false;
if(currentPage_->getMenuDepth() <= 1)
if(currentPage_->getMenuDepth() <= 1 && pages_.empty())
{
exit = exitOnBack;
}

View File

@ -25,7 +25,7 @@
#include "Video/VideoFactory.h"
#include <SDL2/SDL.h>
#include <list>
#include <vector>
#include <stack>
#include <map>
class CollectionInfo;
@ -80,6 +80,7 @@ private:
MetadataDatabase *metadb_;
UserInput input_;
Page *currentPage_;
std::stack<Page *> pages_;
float keyInputDisable_;
float currentTime_;
float lastLaunchReturnTime_;