mirror of
https://github.com/FunKey-Project/RetroFE.git
synced 2026-01-27 02:05:06 +01:00
playlist support - crashes
This commit is contained in:
parent
2cc15babf9
commit
8bd246818c
@ -6,6 +6,7 @@ pageUp = A
|
||||
pageDown = B
|
||||
letterUp = N
|
||||
letterDown = M
|
||||
nextPlaylist = P
|
||||
select = Space
|
||||
back = Escape
|
||||
quit = Q
|
||||
|
||||
@ -37,11 +37,17 @@ CollectionInfo::~CollectionInfo()
|
||||
{
|
||||
// remove items from the subcollections so their destructors do not
|
||||
// delete the items since the parent collection will delete them.
|
||||
std::vector<CollectionInfo *>::iterator subit;
|
||||
for (subit != subcollections_.begin(); subit != subcollections_.end(); subit++)
|
||||
std::vector<CollectionInfo *>::iterator subit = subcollections_.begin();
|
||||
while (subit != subcollections_.end())
|
||||
{
|
||||
CollectionInfo *info = *subit;
|
||||
info->items.clear();
|
||||
subcollections_.erase(subit);
|
||||
|
||||
if(info != this)
|
||||
{
|
||||
delete info;
|
||||
}
|
||||
subit = subcollections_.begin();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
class Item;
|
||||
|
||||
@ -36,6 +37,9 @@ public:
|
||||
std::string launcher;
|
||||
std::vector<Item *> items;
|
||||
|
||||
typedef std::map<std::string, std::vector <Item *> > Playlists_T;
|
||||
Playlists_T playlists;
|
||||
|
||||
private:
|
||||
std::vector<CollectionInfo *> subcollections_;
|
||||
std::string metadataPath_;
|
||||
|
||||
@ -242,8 +242,10 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info, std::string me
|
||||
struct dirent *dirp;
|
||||
std::string path = info->listpath;
|
||||
std::map<std::string, Item *> includeFilter;
|
||||
std::map<std::string, Item *> favoritesFilter;
|
||||
std::map<std::string, Item *> excludeFilter;
|
||||
std::string includeFile = Utils::combinePath(Configuration::absolutePath, "collections", info->name, "include.txt");
|
||||
std::string favoritesFile = Utils::combinePath(Configuration::absolutePath, "collections", info->name, "favorites.txt");
|
||||
std::string excludeFile = Utils::combinePath(Configuration::absolutePath, "collections", info->name, "exclude.txt");
|
||||
|
||||
std::string launcher;
|
||||
@ -269,6 +271,7 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info, std::string me
|
||||
{
|
||||
Logger::write(Logger::ZONE_INFO, "CollectionInfoBuilder", "Checking for \"" + includeFile + "\"");
|
||||
ImportBasicList(info, includeFile, includeFilter);
|
||||
ImportBasicList(info, favoritesFile, favoritesFilter);
|
||||
ImportBasicList(info, excludeFile, excludeFilter);
|
||||
}
|
||||
|
||||
@ -297,6 +300,10 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info, std::string me
|
||||
}
|
||||
}
|
||||
}
|
||||
for(std::map<std::string, Item *>::iterator it = favoritesFilter.begin(); it != favoritesFilter.end(); it++)
|
||||
{
|
||||
info->playlists["favorites"].push_back(it->second);
|
||||
}
|
||||
|
||||
while((dirp = readdir(dp)) != NULL)
|
||||
{
|
||||
@ -327,6 +334,7 @@ bool CollectionInfoBuilder::ImportDirectory(CollectionInfo *info, std::string me
|
||||
i->collectionInfo = info;
|
||||
|
||||
info->items.push_back(i);
|
||||
info->playlists["include"].push_back(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,6 +67,7 @@ bool UserInput::initialize()
|
||||
retVal = MapKey("select", KeyCodeSelect) && retVal;
|
||||
retVal = MapKey("back", KeyCodeBack) && retVal;
|
||||
retVal = MapKey("quit", KeyCodeQuit) && retVal;
|
||||
MapKey("nextPlaylist", KeyCodeNextPlaylist);
|
||||
// these features will need to be implemented at a later time
|
||||
// retVal = MapKey("admin", KeyCodeAdminMode) && retVal;
|
||||
// retVal = MapKey("remove", KeyCodeHideItem) && retVal;
|
||||
|
||||
@ -38,6 +38,7 @@ public:
|
||||
KeyCodePageUp,
|
||||
KeyCodeLetterDown,
|
||||
KeyCodeLetterUp,
|
||||
KeyCodeNextPlaylist,
|
||||
KeyCodeAdminMode,
|
||||
KeyCodeHideItem,
|
||||
KeyCodeQuit,
|
||||
|
||||
@ -125,6 +125,7 @@ ScrollingList::~ScrollingList()
|
||||
destroyItems();
|
||||
}
|
||||
|
||||
|
||||
void ScrollingList::setItems(std::vector<ComponentItemBinding *> *spriteList)
|
||||
{
|
||||
notifyAllRequested_ = true;
|
||||
@ -227,6 +228,7 @@ void ScrollingList::destroyItems()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<ComponentItemBinding *>::iterator it = spriteList_->begin();
|
||||
|
||||
while(it != spriteList_->end())
|
||||
@ -235,11 +237,7 @@ void ScrollingList::destroyItems()
|
||||
{
|
||||
deallocateTexture(*it);
|
||||
|
||||
if((*it)->item)
|
||||
{
|
||||
delete (*it)->item;
|
||||
}
|
||||
|
||||
// items are destroyed when collections are destroyed
|
||||
delete *it;
|
||||
}
|
||||
|
||||
|
||||
@ -438,6 +438,7 @@ bool Page::pushCollection(CollectionInfo *collection)
|
||||
activeMenu_->destroyItems();
|
||||
activeMenu_->setItems(sprites);
|
||||
activeMenu_->triggerMenuEnterEvent();
|
||||
playlist_ = collection->playlists.begin();
|
||||
|
||||
if(menuDepth_ < menus_.size())
|
||||
{
|
||||
@ -514,9 +515,26 @@ bool Page::popCollection()
|
||||
}
|
||||
}
|
||||
|
||||
if(collection)
|
||||
{
|
||||
delete collection;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Page::nextPlaylist()
|
||||
{
|
||||
CollectionInfo *collection = collections_.back();
|
||||
playlist_++;
|
||||
if(playlist_ == collection->playlists.end()) playlist_ = collection->playlists.begin();
|
||||
|
||||
std::vector<ComponentItemBinding *> *sprites = ComponentItemBindingBuilder::buildCollectionItems(&playlist_->second);
|
||||
|
||||
activeMenu_->destroyItems();
|
||||
activeMenu_->setItems(sprites);
|
||||
activeMenu_->triggerMenuEnterEvent();
|
||||
}
|
||||
|
||||
void Page::update(float dt)
|
||||
{
|
||||
|
||||
@ -16,13 +16,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "MenuNotifierInterface.h"
|
||||
#include "../Collection/CollectionInfo.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
class CollectionInfo;
|
||||
class Component;
|
||||
class Configuration;
|
||||
class ScrollingList;
|
||||
@ -46,6 +46,7 @@ public:
|
||||
virtual void onNewItemSelected(Item *);
|
||||
bool pushCollection(CollectionInfo *collection);
|
||||
bool popCollection();
|
||||
void nextPlaylist();
|
||||
void pushMenu(ScrollingList *s);
|
||||
bool isMenusFull();
|
||||
void setLoadSound(Sound *chunk);
|
||||
@ -105,6 +106,7 @@ private:
|
||||
Sound *selectSoundChunk_;
|
||||
float minShowTime_;
|
||||
float elapsedTime_;
|
||||
CollectionInfo::Playlists_T::iterator playlist_;
|
||||
|
||||
|
||||
};
|
||||
|
||||
@ -489,7 +489,10 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput(Page *page)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(input_.keystate(UserInput::KeyCodeNextPlaylist) && page->isMenuIdle())
|
||||
{
|
||||
page->nextPlaylist();
|
||||
}
|
||||
if (input_.keystate(UserInput::KeyCodeBack) && page->isMenuIdle())
|
||||
{
|
||||
if(back(exit) || exit)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user