Adding button to add to playlists (does not yet save favorites.txt yet)

This commit is contained in:
Don Honerbrink 2015-08-07 11:21:04 -05:00
parent bf1286653a
commit 24d4b37cf7
9 changed files with 56 additions and 13 deletions

View File

@ -7,6 +7,7 @@ pageDown = B
letterUp = N letterUp = N
letterDown = M letterDown = M
nextPlaylist = P nextPlaylist = P
addPlaylist = O
random = R random = R
select = Space select = Space
back = Escape back = Escape

View File

@ -12,7 +12,7 @@
<!-----------------MAIN MENU Section-----------------> <!-----------------MAIN MENU Section----------------->
<!-- This is the title text that shows at the bottom of the main menu list. --> <!-- This is the title text that shows at the bottom of the main menu list. -->
<reloadableText type="title" x="center" y="center" xOrigin="center" yOrigin="center" yOffset="394" fontSize="48" layer="5"> <reloadableText type="playlist" x="center" y="center" xOrigin="center" yOrigin="center" yOffset="394" fontSize="48" layer="5">
<onMenuEnter menuIndex="0"> <onMenuEnter menuIndex="0">
<set duration=".2"> <set duration=".2">
<animate type="alpha" from="0" to="1" algorithm="easeinquadratic"/> <animate type="alpha" from="0" to="1" algorithm="easeinquadratic"/>

View File

@ -66,15 +66,17 @@ bool UserInput::initialize()
retVal = MapKey("down", KeyCodeRight) && retVal; retVal = MapKey("down", KeyCodeRight) && retVal;
} }
retVal = MapKey("pageDown", KeyCodePageDown) && retVal;
retVal = MapKey("pageUp", KeyCodePageUp) && retVal;
MapKey("letterDown", KeyCodeLetterDown);
MapKey("letterUp", KeyCodeLetterUp);
retVal = MapKey("select", KeyCodeSelect) && retVal; retVal = MapKey("select", KeyCodeSelect) && retVal;
retVal = MapKey("back", KeyCodeBack) && retVal; retVal = MapKey("back", KeyCodeBack) && retVal;
retVal = MapKey("quit", KeyCodeQuit) && retVal; retVal = MapKey("quit", KeyCodeQuit) && retVal;
MapKey("nextPlaylist", KeyCodeNextPlaylist); retVal = MapKey("pageDown", KeyCodePageDown);
MapKey("random", KeyCodeRandom); retVal = MapKey("pageUp", KeyCodePageUp);
MapKey("letterDown", KeyCodeLetterDown, false);
MapKey("letterUp", KeyCodeLetterUp, false);
MapKey("nextPlaylist", KeyCodeNextPlaylist, false);
MapKey("addPlaylist", KeyCodeAddPlaylist, false);
MapKey("random", KeyCodeRandom, false);
// these features will need to be implemented at a later time // these features will need to be implemented at a later time
// retVal = MapKey("admin", KeyCodeAdminMode) && retVal; // retVal = MapKey("admin", KeyCodeAdminMode) && retVal;
// retVal = MapKey("remove", KeyCodeHideItem) && retVal; // retVal = MapKey("remove", KeyCodeHideItem) && retVal;
@ -89,6 +91,11 @@ bool UserInput::initialize()
} }
bool UserInput::MapKey(std::string keyDescription, KeyCode_E key) bool UserInput::MapKey(std::string keyDescription, KeyCode_E key)
{
return MapKey(keyDescription, key, true);
}
bool UserInput::MapKey(std::string keyDescription, KeyCode_E key, bool required)
{ {
SDL_Scancode scanCode; SDL_Scancode scanCode;
std::string description; std::string description;
@ -97,7 +104,8 @@ bool UserInput::MapKey(std::string keyDescription, KeyCode_E key)
if(!config_.getProperty(configKey, description)) if(!config_.getProperty(configKey, description))
{ {
Logger::write(Logger::ZONE_ERROR, "Input", "Missing property " + configKey); Logger::Zone zone = (required) ? Logger::ZONE_ERROR : Logger::ZONE_INFO;
Logger::write(zone, "Input", "Missing property " + configKey);
return false; return false;
} }

View File

@ -41,6 +41,7 @@ public:
KeyCodeLetterUp, KeyCodeLetterUp,
KeyCodeNextPlaylist, KeyCodeNextPlaylist,
KeyCodeRandom, KeyCodeRandom,
KeyCodeAddPlaylist,
KeyCodeAdminMode, KeyCodeAdminMode,
KeyCodeHideItem, KeyCodeHideItem,
KeyCodeQuit, KeyCodeQuit,
@ -56,6 +57,7 @@ public:
private: private:
bool MapKey(std::string keyDescription, KeyCode_E key); bool MapKey(std::string keyDescription, KeyCode_E key);
bool MapKey(std::string keyDescription, KeyCode_E key, bool required);
Configuration &config_; Configuration &config_;
std::vector<SDL_Joystick *> joysticks_; std::vector<SDL_Joystick *> joysticks_;
InputHandler *keyHandlers_[KeyCodeMax]; InputHandler *keyHandlers_[KeyCodeMax];

View File

@ -129,12 +129,14 @@ void ScrollingList::setItems(std::vector<Item *> *items)
deallocateSpritePoints(); deallocateSpritePoints();
items_ = items; items_ = items;
itemIndex_ = 0; if(items_)
{
itemIndex_ = loopDecrement(0, selectedOffsetIndex_, items_->size());
}
allocateSpritePoints(); allocateSpritePoints();
notifyAllRequested_ = true; notifyAllRequested_ = true;
} }
unsigned int ScrollingList::loopIncrement(unsigned int offset, unsigned int i, unsigned int size) unsigned int ScrollingList::loopIncrement(unsigned int offset, unsigned int i, unsigned int size)
@ -215,6 +217,11 @@ void ScrollingList::setPoints(std::vector<ViewInfo *> *scrollPoints, std::vector
if(scrollPoints) size = scrollPoints_->size(); if(scrollPoints) size = scrollPoints_->size();
components_.resize(size); components_.resize(size);
if(items_)
{
itemIndex_ = loopDecrement(0, selectedOffsetIndex_, items_->size());
}
allocateSpritePoints(); allocateSpritePoints();
} }

View File

@ -79,12 +79,12 @@ public:
void setScrollAcceleration(float value); void setScrollAcceleration(float value);
void setStartScrollTime(float value); void setStartScrollTime(float value);
bool horizontalScroll; bool horizontalScroll;
void deallocateSpritePoints();
void allocateSpritePoints();
private: private:
void click(double nextScrollTime); void click(double nextScrollTime);
void deallocateSpritePoints();
void allocateSpritePoints();
void resetTweens(Component *c, AnimationEvents *sets, ViewInfo *currentViewInfo, ViewInfo *nextViewInfo, double scrollTime); void resetTweens(Component *c, AnimationEvents *sets, ViewInfo *currentViewInfo, ViewInfo *nextViewInfo, double scrollTime);
unsigned int loopIncrement(unsigned int offset, unsigned int i, unsigned int size); unsigned int loopIncrement(unsigned int offset, unsigned int i, unsigned int size);
unsigned int loopDecrement(unsigned int offset, unsigned int i, unsigned int size); unsigned int loopDecrement(unsigned int offset, unsigned int i, unsigned int size);

View File

@ -645,6 +645,25 @@ void Page::draw()
} }
void Page::addPlaylist()
{
if(!selectedItem_) return;
MenuInfo_S &info = collections_.back();
CollectionInfo *collection = info.collection;
std::vector<Item *> *items = collection->playlists["favorites"];
if(playlist_->first != "favorites" && std::find(items->begin(), items->end(), selectedItem_) == items->end())
{
items->push_back(selectedItem_);
if(activeMenu_)
{
activeMenu_->deallocateSpritePoints();
activeMenu_->allocateSpritePoints();
}
}
}
std::string Page::getCollectionName() std::string Page::getCollectionName()
{ {
if(collections_.size() == 0) return ""; if(collections_.size() == 0) return "";

View File

@ -80,6 +80,7 @@ public:
std::string getCollectionName(); std::string getCollectionName();
void setMinShowTime(float value); void setMinShowTime(float value);
float getMinShowTime(); float getMinShowTime();
void addPlaylist();
private: private:
void highlight(); void highlight();

View File

@ -449,6 +449,7 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput(Page *page)
!input_.keystate(UserInput::KeyCodeLetterUp) && !input_.keystate(UserInput::KeyCodeLetterUp) &&
!input_.keystate(UserInput::KeyCodeLetterDown) && !input_.keystate(UserInput::KeyCodeLetterDown) &&
!input_.keystate(UserInput::KeyCodeNextPlaylist) && !input_.keystate(UserInput::KeyCodeNextPlaylist) &&
!input_.keystate(UserInput::KeyCodeAddPlaylist) &&
!input_.keystate(UserInput::KeyCodeRandom)) !input_.keystate(UserInput::KeyCodeRandom))
{ {
keyLastTime_ = 0; keyLastTime_ = 0;
@ -481,6 +482,10 @@ RetroFE::RETROFE_STATE RetroFE::processUserInput(Page *page)
{ {
page->nextPlaylist(); page->nextPlaylist();
} }
if(input_.keystate(UserInput::KeyCodeAddPlaylist))
{
page->addPlaylist();
}
if(input_.keystate(UserInput::KeyCodeRandom)) if(input_.keystate(UserInput::KeyCodeRandom))
{ {
page->selectRandom(); page->selectRandom();