Added selectedOffset tag to support preloading and rendering of items not selected

This commit is contained in:
emb
2015-10-23 23:00:30 -05:00
parent a5ef2bdcbc
commit 6ff4acbd30
25 changed files with 120 additions and 79 deletions

View File

@@ -19,10 +19,10 @@
#include "../../Utility/Log.h" #include "../../Utility/Log.h"
#include "../../SDL.h" #include "../../SDL.h"
Component::Component() Component::Component(Page &p)
: page(p)
{ {
tweens_ = NULL; tweens_ = NULL;
selectedItem_ = NULL;
newItemSelectedSinceEnter = false; newItemSelectedSinceEnter = false;
backgroundTexture_ = NULL; backgroundTexture_ = NULL;
freeGraphicsMemory(); freeGraphicsMemory();
@@ -30,9 +30,9 @@ Component::Component()
} }
Component::Component(const Component &copy) Component::Component(const Component &copy)
: page(copy.page)
{ {
tweens_ = NULL; tweens_ = NULL;
selectedItem_ = NULL;
newItemSelectedSinceEnter = false; newItemSelectedSinceEnter = false;
backgroundTexture_ = NULL; backgroundTexture_ = NULL;
freeGraphicsMemory(); freeGraphicsMemory();
@@ -98,11 +98,6 @@ void Component::allocateGraphicsMemory()
} }
} }
Item *Component::getSelectedItem()
{
return selectedItem_;
}
void Component::triggerEnterEvent() void Component::triggerEnterEvent()
{ {
enterRequested = true; enterRequested = true;
@@ -132,10 +127,9 @@ void Component::triggerMenuExitEvent(int menuIndex)
menuExitRequested = true; menuExitRequested = true;
menuExitIndex = menuIndex; menuExitIndex = menuIndex;
} }
void Component::triggerHighlightEvent(Item *selectedItem) void Component::triggerHighlightEvent()
{ {
newItemSelected = true; newItemSelected = true;
this->selectedItem_ = selectedItem;
} }
void Component::triggerPlaylistChangeEvent(std::string name) void Component::triggerPlaylistChangeEvent(std::string name)

View File

@@ -19,15 +19,15 @@
#include "../../SDL.h" #include "../../SDL.h"
#include "../MenuNotifierInterface.h" #include "../MenuNotifierInterface.h"
#include "../Page.h"
#include "../ViewInfo.h" #include "../ViewInfo.h"
#include "../Animate/Tween.h" #include "../Animate/Tween.h"
#include "../Animate/AnimationEvents.h" #include "../Animate/AnimationEvents.h"
#include "../../Collection/Item.h" #include "../../Collection/Item.h"
class Component class Component
{ {
public: public:
Component(); Component(Page &p);
Component(const Component &copy); Component(const Component &copy);
virtual ~Component(); virtual ~Component();
virtual void freeGraphicsMemory(); virtual void freeGraphicsMemory();
@@ -39,7 +39,7 @@ public:
void triggerMenuEnterEvent(int menuIndex = -1); void triggerMenuEnterEvent(int menuIndex = -1);
void triggerMenuExitEvent(int menuIndex = -1); void triggerMenuExitEvent(int menuIndex = -1);
void triggerMenuScrollEvent(); void triggerMenuScrollEvent();
void triggerHighlightEvent(Item *selectedItem); void triggerHighlightEvent();
void triggerPlaylistChangeEvent(std::string name); void triggerPlaylistChangeEvent(std::string name);
bool isIdle(); bool isIdle();
bool isHidden(); bool isHidden();
@@ -55,7 +55,8 @@ public:
bool scrollActive; bool scrollActive;
protected: protected:
Item *getSelectedItem(); Page &page;
enum AnimationState enum AnimationState
{ {
IDLE, IDLE,
@@ -90,7 +91,6 @@ private:
AnimationEvents *tweens_; AnimationEvents *tweens_;
Animation *currentTweens_; Animation *currentTweens_;
Item *selectedItem_;
SDL_Texture *backgroundTexture_; SDL_Texture *backgroundTexture_;
unsigned int currentTweenIndex_; unsigned int currentTweenIndex_;

View File

@@ -18,7 +18,8 @@
#include "../ViewInfo.h" #include "../ViewInfo.h"
#include "../../SDL.h" #include "../../SDL.h"
Container::Container() Container::Container(Page &p)
: Component(p)
{ {
allocateGraphicsMemory(); allocateGraphicsMemory();
} }

View File

@@ -22,7 +22,7 @@
class Container : public Component class Container : public Component
{ {
public: public:
Container(); Container(Page &p);
virtual ~Container(); virtual ~Container();
void freeGraphicsMemory(); void freeGraphicsMemory();
void allocateGraphicsMemory(); void allocateGraphicsMemory();

View File

@@ -19,8 +19,9 @@
#include "../../Utility/Log.h" #include "../../Utility/Log.h"
#include <SDL2/SDL_image.h> #include <SDL2/SDL_image.h>
Image::Image(std::string file, float scaleX, float scaleY) Image::Image(std::string file, Page &p, float scaleX, float scaleY)
: texture_(NULL) : Component(p)
, texture_(NULL)
, file_(file) , file_(file)
, scaleX_(scaleX) , scaleX_(scaleX)
, scaleY_(scaleY) , scaleY_(scaleY)

View File

@@ -22,7 +22,7 @@
class Image : public Component class Image : public Component
{ {
public: public:
Image(std::string file, float scaleX, float scaleY); Image(std::string file, Page &p, float scaleX, float scaleY);
virtual ~Image(); virtual ~Image();
void freeGraphicsMemory(); void freeGraphicsMemory();
void allocateGraphicsMemory(); void allocateGraphicsMemory();

View File

@@ -18,7 +18,7 @@
#include "../../Utility/Log.h" #include "../../Utility/Log.h"
#include <fstream> #include <fstream>
Image * ImageBuilder::CreateImage(std::string path, std::string name, float scaleX, float scaleY) Image * ImageBuilder::CreateImage(std::string path, Page &p, std::string name, float scaleX, float scaleY)
{ {
Image *image = NULL; Image *image = NULL;
std::vector<std::string> extensions; std::vector<std::string> extensions;
@@ -35,7 +35,7 @@ Image * ImageBuilder::CreateImage(std::string path, std::string name, float scal
if(Utils::findMatchingFile(prefix, extensions, file)) if(Utils::findMatchingFile(prefix, extensions, file))
{ {
image = new Image(file, scaleX, scaleY); image = new Image(file, p, scaleX, scaleY);
} }
return image; return image;

View File

@@ -15,6 +15,7 @@
*/ */
#pragma once #pragma once
#include "../Page.h"
#include "Image.h" #include "Image.h"
#include "VideoComponent.h" #include "VideoComponent.h"
#include "../../Video/VideoFactory.h" #include "../../Video/VideoFactory.h"
@@ -23,5 +24,5 @@
class ImageBuilder class ImageBuilder
{ {
public: public:
Image * CreateImage(std::string path, std::string name, float scaleX, float scaleY); Image * CreateImage(std::string path, Page &p, std::string name, float scaleX, float scaleY);
}; };

View File

@@ -28,8 +28,9 @@
#include <vector> #include <vector>
#include <iostream> #include <iostream>
ReloadableMedia::ReloadableMedia(Configuration &config, bool systemMode, std::string type, bool isVideo, Font *font, float scaleX, float scaleY) ReloadableMedia::ReloadableMedia(Configuration &config, bool systemMode, std::string type, Page &p, int displayOffset, bool isVideo, Font *font, float scaleX, float scaleY)
: config_(config) : Component(p)
, config_(config)
, systemMode_(systemMode) , systemMode_(systemMode)
, loadedComponent_(NULL) , loadedComponent_(NULL)
, reloadRequested_(false) , reloadRequested_(false)
@@ -41,6 +42,8 @@ ReloadableMedia::ReloadableMedia(Configuration &config, bool systemMode, std::st
, type_(type) , type_(type)
, scaleX_(scaleX) , scaleX_(scaleX)
, scaleY_(scaleY) , scaleY_(scaleY)
, displayOffset_(displayOffset)
{ {
allocateGraphicsMemory(); allocateGraphicsMemory();
} }
@@ -145,7 +148,7 @@ void ReloadableMedia::reloadTexture()
loadedComponent_ = NULL; loadedComponent_ = NULL;
} }
Item *selectedItem = getSelectedItem(); Item *selectedItem = page.getSelectedItem(displayOffset_);
if(!selectedItem) return; if(!selectedItem) return;
config_.getProperty("currentCollection", currentCollection_); config_.getProperty("currentCollection", currentCollection_);
@@ -324,7 +327,7 @@ void ReloadableMedia::reloadTexture()
// if image and artwork was not specified, fall back to displaying text // if image and artwork was not specified, fall back to displaying text
if(!loadedComponent_ && textFallback_) if(!loadedComponent_ && textFallback_)
{ {
loadedComponent_ = new Text(selectedItem->fullTitle, FfntInst_, scaleX_, scaleY_); loadedComponent_ = new Text(selectedItem->fullTitle, page, FfntInst_, scaleX_, scaleY_);
baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth; baseViewInfo.ImageWidth = loadedComponent_->baseViewInfo.ImageWidth;
baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight; baseViewInfo.ImageHeight = loadedComponent_->baseViewInfo.ImageHeight;
} }
@@ -343,11 +346,11 @@ Component *ReloadableMedia::findComponent(std::string collection, std::string ty
if(type == "video") if(type == "video")
{ {
component = videoBuild.createVideo(imagePath, basename, scaleX_, scaleY_); component = videoBuild.createVideo(imagePath, page, basename, scaleX_, scaleY_);
} }
else else
{ {
component = imageBuild.CreateImage(imagePath, basename, scaleX_, scaleY_); component = imageBuild.CreateImage(imagePath, page, basename, scaleX_, scaleY_);
} }
return component; return component;

View File

@@ -27,7 +27,7 @@ class Image;
class ReloadableMedia : public Component class ReloadableMedia : public Component
{ {
public: public:
ReloadableMedia(Configuration &config, bool systemMode, std::string type, bool isVideo, Font *font, float scaleX, float scaleY); ReloadableMedia(Configuration &config, bool systemMode, std::string type, Page &page, int displayOffset, bool isVideo, Font *font, float scaleX, float scaleY);
virtual ~ReloadableMedia(); virtual ~ReloadableMedia();
void update(float dt); void update(float dt);
void draw(); void draw();
@@ -54,4 +54,6 @@ private:
float scaleX_; float scaleX_;
float scaleY_; float scaleY_;
std::string currentCollection_; std::string currentCollection_;
Page *page_;
int displayOffset_;
}; };

View File

@@ -23,9 +23,9 @@
#include <vector> #include <vector>
#include <iostream> #include <iostream>
ReloadableText::ReloadableText(std::string type, Page *page, Font *font, std::string layoutKey, float scaleX, float scaleY) ReloadableText::ReloadableText(std::string type, Page &page, Font *font, std::string layoutKey, float scaleX, float scaleY)
: imageInst_(NULL) : Component(page)
, page_(page) , imageInst_(NULL)
, layoutKey_(layoutKey) , layoutKey_(layoutKey)
, reloadRequested_(false) , reloadRequested_(false)
, firstLoad_(true) , firstLoad_(true)
@@ -145,7 +145,7 @@ void ReloadableText::ReloadTexture()
imageInst_ = NULL; imageInst_ = NULL;
} }
Item *selectedItem = getSelectedItem(); Item *selectedItem = page.getSelectedItem();
if (selectedItem != NULL) if (selectedItem != NULL)
{ {
@@ -175,26 +175,20 @@ void ReloadableText::ReloadTexture()
ss << playlistName; ss << playlistName;
break; break;
case TextTypeCollectionName: case TextTypeCollectionName:
if (page_ != NULL) { ss << page.getCollectionName();
ss << page_->getCollectionName();
}
break; break;
case TextTypeCollectionSize: case TextTypeCollectionSize:
if (page_ != NULL) { ss << page.getCollectionSize();
ss << page_->getCollectionSize();
}
break; break;
case TextTypeCollectionIndex: case TextTypeCollectionIndex:
if (page_ != NULL) { ss << (1+page.getSelectedIndex());
ss << (1+page_->getSelectedIndex());
}
break; break;
default: default:
break; break;
} }
imageInst_ = new Text(ss.str(), fontInst_, scaleX_, scaleY_); imageInst_ = new Text(ss.str(), page, fontInst_, scaleX_, scaleY_);
} }
} }

View File

@@ -25,7 +25,7 @@
class ReloadableText : public Component class ReloadableText : public Component
{ {
public: public:
ReloadableText(std::string type, Page *page, Font *font, std::string layoutKey, float scaleX, float scaleY); ReloadableText(std::string type, Page &page, Font *font, std::string layoutKey, float scaleX, float scaleY);
virtual ~ReloadableText(); virtual ~ReloadableText();
void update(float dt); void update(float dt);
void draw(); void draw();
@@ -54,7 +54,6 @@ private:
Text *imageInst_; Text *imageInst_;
TextType type_; TextType type_;
Page *page_;
std::string layoutKey_; std::string layoutKey_;
bool reloadRequested_; bool reloadRequested_;
bool firstLoad_; bool firstLoad_;

View File

@@ -14,13 +14,13 @@
* along with RetroFE. If not, see <http://www.gnu.org/licenses/>. * along with RetroFE. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "ScrollingList.h"
#include "../Animate/Tween.h" #include "../Animate/Tween.h"
#include "../Animate/TweenSet.h" #include "../Animate/TweenSet.h"
#include "../Animate/Animation.h" #include "../Animate/Animation.h"
#include "../Animate/AnimationEvents.h" #include "../Animate/AnimationEvents.h"
#include "../Animate/TweenTypes.h" #include "../Animate/TweenTypes.h"
#include "../Font.h" #include "../Font.h"
#include "ScrollingList.h"
#include "ImageBuilder.h" #include "ImageBuilder.h"
#include "VideoBuilder.h" #include "VideoBuilder.h"
#include "VideoComponent.h" #include "VideoComponent.h"
@@ -40,12 +40,14 @@
//todo: remove coupling from configuration data (if possible) //todo: remove coupling from configuration data (if possible)
ScrollingList::ScrollingList(Configuration &c, ScrollingList::ScrollingList(Configuration &c,
Page &p,
float scaleX, float scaleX,
float scaleY, float scaleY,
Font *font, Font *font,
std::string layoutKey, std::string layoutKey,
std::string imageType) std::string imageType)
: horizontalScroll(false) : Component(p)
, horizontalScroll(false)
, spriteList_(NULL) , spriteList_(NULL)
, scrollPoints_(NULL) , scrollPoints_(NULL)
, tweenPoints_(NULL) , tweenPoints_(NULL)
@@ -226,6 +228,20 @@ void ScrollingList::setSelectedIndex(int selectedIndex)
selectedOffsetIndex_ = selectedIndex; selectedOffsetIndex_ = selectedIndex;
} }
Item *ScrollingList::getItemByOffset(int offset)
{
if(!items_ || items_->size() == 0) return NULL;
unsigned int index = getSelectedIndex();
if(offset > 0) {
index = loopIncrement(index, offset, items_->size());
}
else if(offset < 0) {
index = loopDecrement(index, offset*-1, items_->size());
}
return items_->at(index);
}
void ScrollingList::click(double nextScrollTime) void ScrollingList::click(double nextScrollTime)
{ {
if(currentScrollDirection_ == ScrollDirectionBack) if(currentScrollDirection_ == ScrollDirectionBack)
@@ -569,53 +585,53 @@ bool ScrollingList::allocateTexture(unsigned int index, Item *item)
// check collection path for art based on gamename // check collection path for art based on gamename
config_.getMediaPropertyAbsolutePath(collectionName, imageType_, false, imagePath); config_.getMediaPropertyAbsolutePath(collectionName, imageType_, false, imagePath);
t = imageBuild.CreateImage(imagePath, item->name, scaleX_, scaleY_); t = imageBuild.CreateImage(imagePath, page, item->name, scaleX_, scaleY_);
// check sub-collection path for art based on gamename // check sub-collection path for art based on gamename
if(!t) if(!t)
{ {
config_.getMediaPropertyAbsolutePath(item->collectionInfo->name, imageType_, false, imagePath); config_.getMediaPropertyAbsolutePath(item->collectionInfo->name, imageType_, false, imagePath);
t = imageBuild.CreateImage(imagePath, item->name, scaleX_, scaleY_); t = imageBuild.CreateImage(imagePath, page, item->name, scaleX_, scaleY_);
} }
// check collection path for art based on game name (full title) // check collection path for art based on game name (full title)
if(!t && item->title != item->fullTitle) if(!t && item->title != item->fullTitle)
{ {
config_.getMediaPropertyAbsolutePath(collectionName, imageType_, false, imagePath); config_.getMediaPropertyAbsolutePath(collectionName, imageType_, false, imagePath);
t = imageBuild.CreateImage(imagePath, item->fullTitle, scaleX_, scaleY_); t = imageBuild.CreateImage(imagePath, page, item->fullTitle, scaleX_, scaleY_);
} }
// check sub-collection path for art based on game name (full title) // check sub-collection path for art based on game name (full title)
if(!t && item->title != item->fullTitle) if(!t && item->title != item->fullTitle)
{ {
config_.getMediaPropertyAbsolutePath(item->collectionInfo->name, imageType_, false, imagePath); config_.getMediaPropertyAbsolutePath(item->collectionInfo->name, imageType_, false, imagePath);
t = imageBuild.CreateImage(imagePath, item->fullTitle, scaleX_, scaleY_); t = imageBuild.CreateImage(imagePath, page, item->fullTitle, scaleX_, scaleY_);
} }
// check collection path for art based on parent game name // check collection path for art based on parent game name
if(!t && item->cloneof != "") if(!t && item->cloneof != "")
{ {
config_.getMediaPropertyAbsolutePath(collectionName, imageType_, false, imagePath); config_.getMediaPropertyAbsolutePath(collectionName, imageType_, false, imagePath);
t = imageBuild.CreateImage(imagePath, item->cloneof, scaleX_, scaleY_); t = imageBuild.CreateImage(imagePath, page, item->cloneof, scaleX_, scaleY_);
} }
// check sub-collection path for art based on parent game name // check sub-collection path for art based on parent game name
if(!t && item->cloneof != "") if(!t && item->cloneof != "")
{ {
config_.getMediaPropertyAbsolutePath(item->collectionInfo->name, imageType_, false, imagePath); config_.getMediaPropertyAbsolutePath(item->collectionInfo->name, imageType_, false, imagePath);
t = imageBuild.CreateImage(imagePath, item->cloneof, scaleX_, scaleY_); t = imageBuild.CreateImage(imagePath, page, item->cloneof, scaleX_, scaleY_);
} }
// check collection path for art based on system name // check collection path for art based on system name
if(!t) if(!t)
{ {
config_.getMediaPropertyAbsolutePath(item->name, imageType_, true, imagePath); config_.getMediaPropertyAbsolutePath(item->name, imageType_, true, imagePath);
t = imageBuild.CreateImage(imagePath, imageType_, scaleX_, scaleY_); t = imageBuild.CreateImage(imagePath, page, imageType_, scaleX_, scaleY_);
} }
if (!t) if (!t)
{ {
t = new Text(item->title, fontInst_, scaleX_, scaleY_); t = new Text(item->title, page, fontInst_, scaleX_, scaleY_);
} }
if(t) if(t)

View File

@@ -18,6 +18,7 @@
#include <vector> #include <vector>
#include "Component.h" #include "Component.h"
#include "../Animate/Tween.h" #include "../Animate/Tween.h"
#include "../Page.h"
#include "../MenuNotifierInterface.h" #include "../MenuNotifierInterface.h"
#include "../ViewInfo.h" #include "../ViewInfo.h"
#include "../../Database/Configuration.h" #include "../../Database/Configuration.h"
@@ -43,6 +44,7 @@ public:
}; };
ScrollingList(Configuration &c, ScrollingList(Configuration &c,
Page &p,
float scaleX, float scaleX,
float scaleY, float scaleY,
Font *font, Font *font,
@@ -72,6 +74,7 @@ public:
unsigned int getScrollOffsetIndex(); unsigned int getScrollOffsetIndex();
void setScrollOffsetIndex(unsigned int index); void setScrollOffsetIndex(unsigned int index);
void setSelectedIndex(int selectedIndex); void setSelectedIndex(int selectedIndex);
Item *getItemByOffset(int offset);
void addComponentForNotifications(MenuNotifierInterface *c); void addComponentForNotifications(MenuNotifierInterface *c);
void removeComponentForNotifications(MenuNotifierInterface *c); void removeComponentForNotifications(MenuNotifierInterface *c);
void freeGraphicsMemory(); void freeGraphicsMemory();

View File

@@ -20,8 +20,9 @@
#include "../Font.h" #include "../Font.h"
#include <sstream> #include <sstream>
Text::Text(std::string text, Font *font, float scaleX, float scaleY) Text::Text(std::string text, Page &p, Font *font, float scaleX, float scaleY)
: textData_(text) : Component(p)
, textData_(text)
, fontInst_(font) , fontInst_(font)
, scaleX_(scaleX) , scaleX_(scaleX)
, scaleY_(scaleY) , scaleY_(scaleY)

View File

@@ -16,7 +16,7 @@
#pragma once #pragma once
#include "Component.h" #include "Component.h"
#include "../Page.h"
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
#include <vector> #include <vector>
@@ -26,7 +26,7 @@ class Text : public Component
{ {
public: public:
//todo: should have a Font flass that references fontcache, pass that in as an argument //todo: should have a Font flass that references fontcache, pass that in as an argument
Text(std::string text, Font *font, float scaleX, float scaleY); Text(std::string text, Page &p, Font *font, float scaleX, float scaleY);
virtual ~Text(); virtual ~Text();
void setText(std::string text); void setText(std::string text);
void allocateGraphicsMemory(); void allocateGraphicsMemory();

View File

@@ -21,7 +21,7 @@
#include <fstream> #include <fstream>
VideoComponent * VideoBuilder::createVideo(std::string path, std::string name, float scaleX, float scaleY) VideoComponent * VideoBuilder::createVideo(std::string path, Page &page, std::string name, float scaleX, float scaleY)
{ {
VideoComponent *component = NULL; VideoComponent *component = NULL;
std::vector<std::string> extensions; std::vector<std::string> extensions;
@@ -40,7 +40,7 @@ VideoComponent * VideoBuilder::createVideo(std::string path, std::string name, f
if(video) if(video)
{ {
component = new VideoComponent(video, file, scaleX, scaleY); component = new VideoComponent(video, page, file, scaleX, scaleY);
} }
} }

View File

@@ -17,13 +17,14 @@
#include "Image.h" #include "Image.h"
#include "VideoComponent.h" #include "VideoComponent.h"
#include "../Page.h"
#include "../../Video/VideoFactory.h" #include "../../Video/VideoFactory.h"
//todo: this is more of a factory than a builder //todo: this is more of a factory than a builder
class VideoBuilder class VideoBuilder
{ {
public: public:
VideoComponent * createVideo(std::string path, std::string name, float scaleX, float scaleY); VideoComponent * createVideo(std::string path, Page &page, std::string name, float scaleX, float scaleY);
private: private:
VideoFactory factory_; VideoFactory factory_;

View File

@@ -20,8 +20,9 @@
#include "../../Utility/Log.h" #include "../../Utility/Log.h"
#include "../../SDL.h" #include "../../SDL.h"
VideoComponent::VideoComponent(IVideo *videoInst, std::string videoFile, float scaleX, float scaleY) VideoComponent::VideoComponent(IVideo *videoInst, Page &p, std::string videoFile, float scaleX, float scaleY)
: videoFile_(videoFile) : Component(p)
, videoFile_(videoFile)
, videoInst_(videoInst) , videoInst_(videoInst)
, scaleX_(scaleX) , scaleX_(scaleX)
, scaleY_(scaleY) , scaleY_(scaleY)

View File

@@ -16,6 +16,7 @@
#pragma once #pragma once
#include "Component.h" #include "Component.h"
#include "Image.h" #include "Image.h"
#include "../Page.h"
#include "../../Collection/Item.h" #include "../../Collection/Item.h"
#include "../../Video/IVideo.h" #include "../../Video/IVideo.h"
#include <SDL2/SDL.h> #include <SDL2/SDL.h>
@@ -24,7 +25,7 @@
class VideoComponent : public Component class VideoComponent : public Component
{ {
public: public:
VideoComponent(IVideo *videoInst, std::string videoFile, float scaleX, float scaleY); VideoComponent(IVideo *videoInst, Page &p, std::string videoFile, float scaleX, float scaleY);
virtual ~VideoComponent(); virtual ~VideoComponent();
void update(float dt); void update(float dt);
void draw(); void draw();

View File

@@ -44,6 +44,11 @@ Page::Page(Configuration &config)
} }
Page::~Page() Page::~Page()
{
}
void Page::DeInitialize()
{ {
MenuVector_T::iterator it = menus_.begin(); MenuVector_T::iterator it = menus_.begin();
while(it != menus_.end()) while(it != menus_.end())
@@ -292,6 +297,12 @@ Item *Page::getSelectedItem()
return selectedItem_; return selectedItem_;
} }
Item *Page::getSelectedItem(int offset)
{
return activeMenu_->getItemByOffset(offset);
}
void Page::removeSelectedItem() void Page::removeSelectedItem()
{ {
/* /*
@@ -352,7 +363,7 @@ void Page::highlight()
if(!item) return; if(!item) return;
if(activeMenu_) if(activeMenu_)
{ {
activeMenu_->triggerHighlightEvent(item); activeMenu_->triggerHighlightEvent();
activeMenu_->scrollActive = scrollActive_; activeMenu_->scrollActive = scrollActive_;
} }
@@ -360,7 +371,7 @@ void Page::highlight()
{ {
for(std::vector<Component *>::iterator it = LayerComponents[i].begin(); it != LayerComponents[i].end(); ++it) for(std::vector<Component *>::iterator it = LayerComponents[i].begin(); it != LayerComponents[i].end(); ++it)
{ {
(*it)->triggerHighlightEvent(item); (*it)->triggerHighlightEvent();
(*it)->scrollActive = scrollActive_; (*it)->scrollActive = scrollActive_;
} }
} }

View File

@@ -43,6 +43,7 @@ public:
Page(Configuration &c); Page(Configuration &c);
virtual ~Page(); virtual ~Page();
void DeInitialize();
virtual void onNewItemSelected(Item *); virtual void onNewItemSelected(Item *);
bool pushCollection(CollectionInfo *collection); bool pushCollection(CollectionInfo *collection);
bool popCollection(); bool popCollection();
@@ -66,6 +67,7 @@ public:
bool isHorizontalScroll(); bool isHorizontalScroll();
unsigned int getMenuDepth(); unsigned int getMenuDepth();
Item *getSelectedItem(); Item *getSelectedItem();
Item *getSelectedItem(int offset);
void removeSelectedItem(); void removeSelectedItem();
void setScrollOffsetIndex(unsigned int i); void setScrollOffsetIndex(unsigned int i);
unsigned int getScrollOffsetIndex(); unsigned int getScrollOffsetIndex();

View File

@@ -320,13 +320,13 @@ bool PageBuilder::buildComponents(xml_node<> *layout, Page *page)
{ {
for(xml_node<> *componentXml = layout->first_node("menu"); componentXml; componentXml = componentXml->next_sibling("menu")) for(xml_node<> *componentXml = layout->first_node("menu"); componentXml; componentXml = componentXml->next_sibling("menu"))
{ {
ScrollingList *scrollingList = buildMenu(componentXml); ScrollingList *scrollingList = buildMenu(componentXml,*page);
page->pushMenu(scrollingList); page->pushMenu(scrollingList);
} }
for(xml_node<> *componentXml = layout->first_node("container"); componentXml; componentXml = componentXml->next_sibling("container")) for(xml_node<> *componentXml = layout->first_node("container"); componentXml; componentXml = componentXml->next_sibling("container"))
{ {
Container *c = new Container(); Container *c = new Container(*page);
buildViewInfo(componentXml, c->baseViewInfo); buildViewInfo(componentXml, c->baseViewInfo);
loadTweens(c, componentXml); loadTweens(c, componentXml);
page->addComponent(c); page->addComponent(c);
@@ -346,7 +346,7 @@ bool PageBuilder::buildComponents(xml_node<> *layout, Page *page)
std::string imagePath; std::string imagePath;
imagePath = Utils::combinePath(Configuration::convertToAbsolutePath(layoutPath, imagePath), std::string(src->value())); imagePath = Utils::combinePath(Configuration::convertToAbsolutePath(layoutPath, imagePath), std::string(src->value()));
Image *c = new Image(imagePath, scaleX_, scaleY_); Image *c = new Image(imagePath, *page, scaleX_, scaleY_);
buildViewInfo(componentXml, c->baseViewInfo); buildViewInfo(componentXml, c->baseViewInfo);
loadTweens(c, componentXml); loadTweens(c, componentXml);
page->addComponent(c); page->addComponent(c);
@@ -365,7 +365,7 @@ bool PageBuilder::buildComponents(xml_node<> *layout, Page *page)
else else
{ {
Font *font = addFont(componentXml, NULL); Font *font = addFont(componentXml, NULL);
Text *c = new Text(value->value(), font, scaleX_, scaleY_); Text *c = new Text(value->value(), *page, font, scaleX_, scaleY_);
buildViewInfo(componentXml, c->baseViewInfo); buildViewInfo(componentXml, c->baseViewInfo);
@@ -377,7 +377,7 @@ bool PageBuilder::buildComponents(xml_node<> *layout, Page *page)
for(xml_node<> *componentXml = layout->first_node("statusText"); componentXml; componentXml = componentXml->next_sibling("statusText")) for(xml_node<> *componentXml = layout->first_node("statusText"); componentXml; componentXml = componentXml->next_sibling("statusText"))
{ {
Font *font = addFont(componentXml, NULL); Font *font = addFont(componentXml, NULL);
Text *c = new Text("", font, scaleX_, scaleY_); Text *c = new Text("", *page, font, scaleX_, scaleY_);
buildViewInfo(componentXml, c->baseViewInfo); buildViewInfo(componentXml, c->baseViewInfo);
@@ -403,8 +403,9 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName,
std::string reloadableVideoPath; std::string reloadableVideoPath;
xml_attribute<> *type = componentXml->first_attribute("type"); xml_attribute<> *type = componentXml->first_attribute("type");
xml_attribute<> *mode = componentXml->first_attribute("mode"); xml_attribute<> *mode = componentXml->first_attribute("mode");
xml_attribute<> *selectedOffsetXml = componentXml->first_attribute("selectedOffset");
bool systemMode = false; bool systemMode = false;
int selectedOffset = 0;
if(tagName == "reloadableVideo") if(tagName == "reloadableVideo")
{ {
type = componentXml->first_attribute("imageType"); type = componentXml->first_attribute("imageType");
@@ -430,6 +431,13 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName,
} }
} }
if(selectedOffsetXml)
{
std::stringstream ss;
ss << selectedOffsetXml->value();
ss >> selectedOffset;
}
Component *c = NULL; Component *c = NULL;
@@ -438,13 +446,13 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName,
if(type) if(type)
{ {
Font *font = addFont(componentXml, NULL); Font *font = addFont(componentXml, NULL);
c = new ReloadableText(type->value(), page, font, layoutKey, scaleX_, scaleY_); c = new ReloadableText(type->value(), *page, font, layoutKey, scaleX_, scaleY_);
} }
} }
else else
{ {
Font *font = addFont(componentXml, NULL); Font *font = addFont(componentXml, NULL);
c = new ReloadableMedia(config_, systemMode, type->value(), (tagName == "reloadableVideo"), font, scaleX_, scaleY_); c = new ReloadableMedia(config_, systemMode, type->value(), *page, selectedOffset, (tagName == "reloadableVideo"), font, scaleX_, scaleY_);
xml_attribute<> *textFallback = componentXml->first_attribute("textFallback"); xml_attribute<> *textFallback = componentXml->first_attribute("textFallback");
if(textFallback && Utils::toLower(textFallback->value()) == "true") if(textFallback && Utils::toLower(textFallback->value()) == "true")
@@ -564,7 +572,7 @@ void PageBuilder::buildTweenSet(AnimationEvents *tweens, xml_node<> *componentXm
} }
ScrollingList * PageBuilder::buildMenu(xml_node<> *menuXml) ScrollingList * PageBuilder::buildMenu(xml_node<> *menuXml, Page &page)
{ {
ScrollingList *menu = NULL; ScrollingList *menu = NULL;
std::string menuType = "vertical"; std::string menuType = "vertical";
@@ -596,7 +604,7 @@ ScrollingList * PageBuilder::buildMenu(xml_node<> *menuXml)
// on default, text will be rendered to the menu. Preload it into cache. // on default, text will be rendered to the menu. Preload it into cache.
Font *font = addFont(itemDefaults, NULL); Font *font = addFont(itemDefaults, NULL);
menu = new ScrollingList(config_, scaleX_, scaleY_, font, layoutKey, imageType); menu = new ScrollingList(config_, page, scaleX_, scaleY_, font, layoutKey, imageType);
if(scrollTimeXml) if(scrollTimeXml)
{ {

View File

@@ -58,7 +58,7 @@ private:
void loadTweens(Component *c, rapidxml::xml_node<> *componentXml); void loadTweens(Component *c, rapidxml::xml_node<> *componentXml);
AnimationEvents *createTweenInstance(rapidxml::xml_node<> *componentXml); AnimationEvents *createTweenInstance(rapidxml::xml_node<> *componentXml);
void buildTweenSet(AnimationEvents *tweens, rapidxml::xml_node<> *componentXml, std::string tagName, std::string tweenName); void buildTweenSet(AnimationEvents *tweens, rapidxml::xml_node<> *componentXml, std::string tagName, std::string tweenName);
ScrollingList * buildMenu(rapidxml::xml_node<> *menuXml); ScrollingList * buildMenu(rapidxml::xml_node<> *menuXml, Page &p);
void buildCustomMenu(ScrollingList *menu, rapidxml::xml_node<> *menuXml, rapidxml::xml_node<> *itemDefaults); void buildCustomMenu(ScrollingList *menu, rapidxml::xml_node<> *menuXml, rapidxml::xml_node<> *itemDefaults);
void buildVerticalMenu(ScrollingList *menu, rapidxml::xml_node<> *menuXml, rapidxml::xml_node<> *itemDefaults); void buildVerticalMenu(ScrollingList *menu, rapidxml::xml_node<> *menuXml, rapidxml::xml_node<> *itemDefaults);
int parseMenuPosition(std::string strIndex); int parseMenuPosition(std::string strIndex);

View File

@@ -178,6 +178,7 @@ bool RetroFE::deInitialize()
if(currentPage_) if(currentPage_)
{ {
currentPage_->DeInitialize();
delete currentPage_; delete currentPage_;
currentPage_ = NULL; currentPage_ = NULL;
} }
@@ -288,6 +289,7 @@ void RetroFE::run()
} }
// delete the splash screen and use the standard menu // delete the splash screen and use the standard menu
currentPage_->DeInitialize();
delete currentPage_; delete currentPage_;
currentPage_ = loadPage(); currentPage_ = loadPage();