mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-04-06 10:53:07 +02:00
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:
@@ -855,3 +855,10 @@ void Page::launchExit()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Page::resetMenuItems()
|
||||||
|
{
|
||||||
|
activeMenu_->deallocateSpritePoints();
|
||||||
|
activeMenu_->allocateSpritePoints();
|
||||||
|
}
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ public:
|
|||||||
float getMinShowTime();
|
float getMinShowTime();
|
||||||
void addPlaylist();
|
void addPlaylist();
|
||||||
void removePlaylist();
|
void removePlaylist();
|
||||||
|
void resetMenuItems();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void highlightEnter();
|
void highlightEnter();
|
||||||
|
|||||||
@@ -70,14 +70,22 @@ PageBuilder::~PageBuilder()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Page *PageBuilder::buildPage()
|
Page *PageBuilder::buildPage( std::string collectionName )
|
||||||
{
|
{
|
||||||
Page *page = NULL;
|
Page *page = NULL;
|
||||||
|
|
||||||
std::string layoutFile;
|
std::string layoutFile;
|
||||||
std::string layoutName = layoutKey;
|
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");
|
layoutFile = Utils::combinePath(layoutPath, layoutPage + ".xml");
|
||||||
|
|
||||||
Logger::write(Logger::ZONE_INFO, "Layout", "Initializing " + layoutFile);
|
Logger::write(Logger::ZONE_INFO, "Layout", "Initializing " + layoutFile);
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class PageBuilder
|
|||||||
public:
|
public:
|
||||||
PageBuilder(std::string layoutKey, std::string layoutPage, Configuration &c, FontCache *fc);
|
PageBuilder(std::string layoutKey, std::string layoutPage, Configuration &c, FontCache *fc);
|
||||||
virtual ~PageBuilder();
|
virtual ~PageBuilder();
|
||||||
Page *buildPage();
|
Page *buildPage( std::string collectionName = "" );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string layoutKey;
|
std::string layoutKey;
|
||||||
|
|||||||
@@ -342,11 +342,25 @@ void RetroFE::run()
|
|||||||
case RETROFE_NEXT_PAGE_MENU_EXIT:
|
case RETROFE_NEXT_PAGE_MENU_EXIT:
|
||||||
if(currentPage_->isIdle())
|
if(currentPage_->isIdle())
|
||||||
{
|
{
|
||||||
bool menuSort = true;
|
// Load new layout if available
|
||||||
config_.setProperty("currentCollection", nextPageItem_->name);
|
std::string layoutName;
|
||||||
config_.getProperty("collections." + nextPageItem_->name + ".list.menuSort", menuSort);
|
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;
|
MenuParser mp;
|
||||||
mp.buildMenuItems(info, menuSort);
|
mp.buildMenuItems(info, menuSort);
|
||||||
@@ -355,9 +369,9 @@ void RetroFE::run()
|
|||||||
bool rememberMenu = false;
|
bool rememberMenu = false;
|
||||||
config_.getProperty("rememberMenu", rememberMenu);
|
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;
|
bool autoFavorites = true;
|
||||||
@@ -388,7 +402,14 @@ void RetroFE::run()
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case RETROFE_BACK_REQUEST:
|
case RETROFE_BACK_REQUEST:
|
||||||
currentPage_->exitMenu();
|
if (currentPage_->getMenuDepth() == 1 )
|
||||||
|
{
|
||||||
|
currentPage_->stop();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
currentPage_->exitMenu();
|
||||||
|
}
|
||||||
state = RETROFE_BACK_MENU_EXIT;
|
state = RETROFE_BACK_MENU_EXIT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -396,8 +417,20 @@ void RetroFE::run()
|
|||||||
if(currentPage_->isIdle())
|
if(currentPage_->isIdle())
|
||||||
{
|
{
|
||||||
lastMenuOffsets_[currentPage_->getCollectionName()] = currentPage_->getScrollOffsetIndex();
|
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());
|
config_.setProperty("currentCollection", currentPage_->getCollectionName());
|
||||||
|
currentPage_->resetMenuItems();
|
||||||
currentPage_->setNewItemSelected();
|
currentPage_->setNewItemSelected();
|
||||||
currentPage_->enterMenu();
|
currentPage_->enterMenu();
|
||||||
state = RETROFE_BACK_MENU_ENTER;
|
state = RETROFE_BACK_MENU_ENTER;
|
||||||
@@ -468,7 +501,7 @@ bool RetroFE::back(bool &exit)
|
|||||||
config_.getProperty("exitOnFirstPageBack", exitOnBack);
|
config_.getProperty("exitOnFirstPageBack", exitOnBack);
|
||||||
exit = false;
|
exit = false;
|
||||||
|
|
||||||
if(currentPage_->getMenuDepth() <= 1)
|
if(currentPage_->getMenuDepth() <= 1 && pages_.empty())
|
||||||
{
|
{
|
||||||
exit = exitOnBack;
|
exit = exitOnBack;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include "Video/VideoFactory.h"
|
#include "Video/VideoFactory.h"
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <vector>
|
#include <stack>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
class CollectionInfo;
|
class CollectionInfo;
|
||||||
@@ -80,6 +80,7 @@ private:
|
|||||||
MetadataDatabase *metadb_;
|
MetadataDatabase *metadb_;
|
||||||
UserInput input_;
|
UserInput input_;
|
||||||
Page *currentPage_;
|
Page *currentPage_;
|
||||||
|
std::stack<Page *> pages_;
|
||||||
float keyInputDisable_;
|
float keyInputDisable_;
|
||||||
float currentTime_;
|
float currentTime_;
|
||||||
float lastLaunchReturnTime_;
|
float lastLaunchReturnTime_;
|
||||||
|
|||||||
Reference in New Issue
Block a user