Added menuScrollReload attribute for reloadable items to allow reloading of

the art/text while scrolling through the menu. Beta release, since this
functionality is mostly untested at this time.
This commit is contained in:
Pieter Hulshoff 2017-09-29 18:43:35 +02:00
parent eca598ec8d
commit 430480cdb4
9 changed files with 105 additions and 11 deletions

View File

@ -25,8 +25,8 @@ Component::Component(Page &p)
{
tweens_ = NULL;
backgroundTexture_ = NULL;
menuScrollReload_ = false;
freeGraphicsMemory();
}
Component::Component(const Component &copy)
@ -56,6 +56,7 @@ void Component::freeGraphicsMemory()
animationType_ = "";
animationRequested_ = false;
newItemSelected = false;
newScrollItemSelected = false;
menuIndex_ = -1;
currentTweens_ = NULL;
@ -118,6 +119,11 @@ void Component::setNewItemSelected()
newItemSelected = true;
}
void Component::setNewScrollItemSelected()
{
newScrollItemSelected = true;
}
bool Component::isIdle()
{
return (currentTweenComplete_ || animationType_ == "idle" || animationType_ == "menuIdle");
@ -399,3 +405,15 @@ bool Component::isPlaying()
{
return false;
}
void Component::setMenuScrollReload(bool menuScrollReload)
{
menuScrollReload_ = menuScrollReload;
}
bool Component::getMenuScrollReload()
{
return menuScrollReload_;
}

View File

@ -36,9 +36,11 @@ public:
void triggerEvent(std::string event, int menuIndex = -1);
void setPlaylist(std::string name );
void setNewItemSelected();
void setNewScrollItemSelected();
bool isIdle();
bool isMenuScrolling();
bool newItemSelected;
bool newScrollItemSelected;
virtual void update(float dt);
virtual void draw();
@ -46,6 +48,8 @@ public:
virtual bool isPlaying();
ViewInfo baseViewInfo;
std::string collectionName;
void setMenuScrollReload(bool menuScrollReload);
bool getMenuScrollReload();
protected:
Page &page;
@ -67,5 +71,6 @@ private:
std::string animationRequestedType_;
std::string animationType_;
bool animationRequested_;
bool menuScrollReload_;
int menuIndex_;
};

View File

@ -63,11 +63,13 @@ void ReloadableMedia::enableTextFallback_(bool value)
void ReloadableMedia::update(float dt)
{
if (newItemSelected)
if (newItemSelected ||
(newScrollItemSelected && getMenuScrollReload()))
{
reloadTexture();
newItemSelected = false;
newScrollItemSelected = false;
}
if(loadedComponent_)

View File

@ -88,7 +88,8 @@ void ReloadableScrollingText::update(float dt)
}
}
if (newItemSelected)
if (newItemSelected ||
(newScrollItemSelected && getMenuScrollReload()))
{
reloadTexture( );
newItemSelected = false;

View File

@ -56,7 +56,9 @@ ReloadableText::~ReloadableText()
void ReloadableText::update(float dt)
{
if (newItemSelected || type_ == "time")
if (newItemSelected ||
(newScrollItemSelected && getMenuScrollReload()) ||
type_ == "time")
{
ReloadTexture();
newItemSelected = false;

View File

@ -164,6 +164,19 @@ void Page::onNewItemSelected()
}
void Page::onNewScrollItemSelected()
{
if(!(activeMenu_.size() > 0 && activeMenu_[0])) return;
selectedItem_ = activeMenu_[0]->getSelectedItem();
for(std::vector<Component *>::iterator it = LayerComponents.begin(); it != LayerComponents.end(); ++it)
{
(*it)->setNewScrollItemSelected();
}
}
void Page::highlightLoadArt()
{
if(!(activeMenu_.size() > 0 && activeMenu_[0])) return;
@ -1171,6 +1184,7 @@ void Page::scroll(bool forward)
menu->scroll(forward);
}
}
onNewScrollItemSelected();
if(highlightSoundChunk_)
{
highlightSoundChunk_->play();

View File

@ -44,6 +44,7 @@ public:
virtual ~Page();
void deInitialize();
virtual void onNewItemSelected();
virtual void onNewScrollItemSelected();
void highlightLoadArt();
bool pushCollection(CollectionInfo *collection);
bool popCollection();

View File

@ -342,6 +342,13 @@ bool PageBuilder::buildComponents(xml_node<> *layout, Page *page)
for(xml_node<> *componentXml = layout->first_node("container"); componentXml; componentXml = componentXml->next_sibling("container"))
{
Container *c = new Container(*page);
xml_attribute<> *menuScrollReload = componentXml->first_attribute("menuScrollReload");
if (menuScrollReload &&
(Utils::toLower(menuScrollReload->value()) == "true" ||
Utils::toLower(menuScrollReload->value()) == "yes"))
{
c->setMenuScrollReload(true);
}
buildViewInfo(componentXml, c->baseViewInfo);
loadTweens(c, componentXml);
page->addComponent(c);
@ -366,6 +373,13 @@ bool PageBuilder::buildComponents(xml_node<> *layout, Page *page)
altImagePath = Utils::combinePath(Configuration::absolutePath, "layouts", layoutName, std::string(src->value()));
Image *c = new Image(imagePath, altImagePath, *page, scaleX_, scaleY_);
xml_attribute<> *menuScrollReload = componentXml->first_attribute("menuScrollReload");
if (menuScrollReload &&
(Utils::toLower(menuScrollReload->value()) == "true" ||
Utils::toLower(menuScrollReload->value()) == "yes"))
{
c->setMenuScrollReload(true);
}
buildViewInfo(componentXml, c->baseViewInfo);
loadTweens(c, componentXml);
page->addComponent(c);
@ -393,6 +407,13 @@ bool PageBuilder::buildComponents(xml_node<> *layout, Page *page)
int numLoops = numLoopsXml ? Utils::convertInt(numLoopsXml->value()) : 1;
Video *c = new Video(videoPath, altVideoPath, numLoops, *page, scaleX_, scaleY_);
xml_attribute<> *menuScrollReload = componentXml->first_attribute("menuScrollReload");
if (menuScrollReload &&
(Utils::toLower(menuScrollReload->value()) == "true" ||
Utils::toLower(menuScrollReload->value()) == "yes"))
{
c->setMenuScrollReload(true);
}
buildViewInfo(componentXml, c->baseViewInfo);
loadTweens(c, componentXml);
page->addComponent(c);
@ -412,9 +433,14 @@ bool PageBuilder::buildComponents(xml_node<> *layout, Page *page)
{
Font *font = addFont(componentXml, NULL);
Text *c = new Text(value->value(), *page, font, scaleX_, scaleY_);
xml_attribute<> *menuScrollReload = componentXml->first_attribute("menuScrollReload");
if (menuScrollReload &&
(Utils::toLower(menuScrollReload->value()) == "true" ||
Utils::toLower(menuScrollReload->value()) == "yes"))
{
c->setMenuScrollReload(true);
}
buildViewInfo(componentXml, c->baseViewInfo);
loadTweens(c, componentXml);
page->addComponent(c);
}
@ -424,9 +450,14 @@ bool PageBuilder::buildComponents(xml_node<> *layout, Page *page)
{
Font *font = addFont(componentXml, NULL);
Text *c = new Text("", *page, font, scaleX_, scaleY_);
xml_attribute<> *menuScrollReload = componentXml->first_attribute("menuScrollReload");
if (menuScrollReload &&
(Utils::toLower(menuScrollReload->value()) == "true" ||
Utils::toLower(menuScrollReload->value()) == "yes"))
{
c->setMenuScrollReload(true);
}
buildViewInfo(componentXml, c->baseViewInfo);
loadTweens(c, componentXml);
page->addComponent(c);
page->setStatusTextComponent(c);
@ -560,6 +591,13 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName,
pluralPostfix = pluralPostfixXml->value();
}
c = new ReloadableText(type->value(), *page, config_, font, layoutKey, timeFormat, textFormat, singlePrefix, singlePostfix, pluralPrefix, pluralPostfix, scaleX_, scaleY_);
xml_attribute<> *menuScrollReload = componentXml->first_attribute("menuScrollReload");
if (menuScrollReload &&
(Utils::toLower(menuScrollReload->value()) == "true" ||
Utils::toLower(menuScrollReload->value()) == "yes"))
{
c->setMenuScrollReload(true);
}
}
}
else if(tagName == "reloadableScrollingText")
@ -623,14 +661,27 @@ void PageBuilder::loadReloadableImages(xml_node<> *layout, std::string tagName,
pluralPostfix = pluralPostfixXml->value();
}
c = new ReloadableScrollingText(config_, systemMode, layoutMode, type->value(), singlePrefix, singlePostfix, pluralPrefix, pluralPostfix, textFormat, alignment, *page, selectedOffset, font, scaleX_, scaleY_, direction, scrollingSpeed, startPosition, startTime, endTime);
xml_attribute<> *menuScrollReload = componentXml->first_attribute("menuScrollReload");
if (menuScrollReload &&
(Utils::toLower(menuScrollReload->value()) == "true" ||
Utils::toLower(menuScrollReload->value()) == "yes"))
{
c->setMenuScrollReload(true);
}
}
}
else
{
Font *font = addFont(componentXml, NULL);
c = new ReloadableMedia(config_, systemMode, layoutMode, commonMode, type->value(), *page, selectedOffset, (tagName == "reloadableVideo"), font, scaleX_, scaleY_);
xml_attribute<> *menuScrollReload = componentXml->first_attribute("menuScrollReload");
if (menuScrollReload &&
(Utils::toLower(menuScrollReload->value()) == "true" ||
Utils::toLower(menuScrollReload->value()) == "yes"))
{
c->setMenuScrollReload(true);
}
xml_attribute<> *textFallback = componentXml->first_attribute("textFallback");
if(textFallback && Utils::toLower(textFallback->value()) == "true")
{
static_cast<ReloadableMedia *>(c)->enableTextFallback_(true);

View File

@ -21,7 +21,7 @@
std::string retrofe_version_major = "0";
std::string retrofe_version_minor = "8";
std::string retrofe_version_build = "14";
std::string retrofe_version_build = "14b1";
std::string Version::getString( )