mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2025-12-15 11:18:53 +01:00
Move collection retrieval in RetroFE class to helper method.
This commit is contained in:
parent
df3fe6f314
commit
7f0e4e4a38
@ -445,43 +445,43 @@ Page *RetroFE::LoadPage(std::string collectionName)
|
|||||||
Logger::Write(Logger::ZONE_INFO, "RetroFE", "Creating page for collection " + collectionName);
|
Logger::Write(Logger::ZONE_INFO, "RetroFE", "Creating page for collection " + collectionName);
|
||||||
|
|
||||||
Page *page = NULL;
|
Page *page = NULL;
|
||||||
|
|
||||||
|
std::vector<Item *> *collection = GetCollection(collectionName);
|
||||||
|
std::string layoutName = GetLayout(collectionName);
|
||||||
|
|
||||||
|
if(PageChain.size() > 0)
|
||||||
|
{
|
||||||
|
Page *oldPage = PageChain.back();
|
||||||
|
oldPage->FreeGraphicsMemory();
|
||||||
|
}
|
||||||
|
|
||||||
|
PageBuilder pb(layoutName, collectionName, Config, &FC);
|
||||||
|
page = pb.BuildPage();
|
||||||
|
page->SetItems(collection);
|
||||||
|
page->Start();
|
||||||
|
|
||||||
|
if(page)
|
||||||
|
{
|
||||||
|
PageChain.push_back(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
return page;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Item *> *RetroFE::GetCollection(std::string collectionName)
|
||||||
|
{
|
||||||
std::vector<Item *> *collection = new std::vector<Item *>(); // the page will deallocate this once its done
|
std::vector<Item *> *collection = new std::vector<Item *>(); // the page will deallocate this once its done
|
||||||
MenuParser mp;
|
MenuParser mp;
|
||||||
|
|
||||||
mp.GetMenuItems(&CollectionDB, collectionName, *collection);
|
mp.GetMenuItems(&CollectionDB, collectionName, *collection);
|
||||||
CollectionDB.GetCollection(collectionName, *collection);
|
CollectionDB.GetCollection(collectionName, *collection);
|
||||||
|
|
||||||
//todo: handle this in a more esthetically pleasing way instead of crashing
|
|
||||||
if(collection->size() == 0)
|
if(collection->size() == 0)
|
||||||
{
|
{
|
||||||
Logger::Write(Logger::ZONE_WARNING, "RetroFE", "No list items found for collection " + collectionName);
|
Logger::Write(Logger::ZONE_WARNING, "RetroFE", "No list items found for collection " + collectionName);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
std::string layoutName = GetLayout(collectionName);
|
|
||||||
|
|
||||||
if(PageChain.size() > 0)
|
return collection;
|
||||||
{
|
|
||||||
Page *oldPage = PageChain.back();
|
|
||||||
|
|
||||||
if(oldPage)
|
|
||||||
{
|
|
||||||
oldPage->FreeGraphicsMemory();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PageBuilder pb(layoutName, collectionName, Config, &FC);
|
|
||||||
page = pb.BuildPage();
|
|
||||||
page->SetItems(collection);
|
|
||||||
page->Start();
|
|
||||||
|
|
||||||
if(page)
|
|
||||||
{
|
|
||||||
PageChain.push_back(page);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return page;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string RetroFE::GetLayout(std::string collectionName)
|
std::string RetroFE::GetLayout(std::string collectionName)
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
#include "Video/IVideo.h"
|
#include "Video/IVideo.h"
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class CollectionDatabase;
|
class CollectionDatabase;
|
||||||
class Configuration;
|
class Configuration;
|
||||||
@ -48,7 +49,7 @@ private:
|
|||||||
RETROFE_STATE ProcessUserInput();
|
RETROFE_STATE ProcessUserInput();
|
||||||
void Update(float dt, bool scrollActive);
|
void Update(float dt, bool scrollActive);
|
||||||
std::string GetLayout(std::string collectionName);
|
std::string GetLayout(std::string collectionName);
|
||||||
|
std::vector<Item *> *GetCollection(std::string collectionName);
|
||||||
Configuration &Config;
|
Configuration &Config;
|
||||||
CollectionDatabase &CollectionDB;
|
CollectionDatabase &CollectionDB;
|
||||||
UserInput Input;
|
UserInput Input;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user