void GridGameListView::updateInfoPanel() { FileData* file = (mGrid.size() == 0 || mGrid.isScrolling()) ? NULL : mGrid.getSelected(); bool fadingOut; if(file == NULL) { //mDescription.setText(""); fadingOut = true; }else{ mDescription.setText(file->metadata.get("desc")); mDescContainer.reset(); mRating.setValue(file->metadata.get("rating")); mReleaseDate.setValue(file->metadata.get("releasedate")); mDeveloper.setValue(file->metadata.get("developer")); mPublisher.setValue(file->metadata.get("publisher")); mGenre.setValue(file->metadata.get("genre")); mPlayers.setValue(file->metadata.get("players")); mName.setValue(file->metadata.get("name")); if(file->getType() == GAME) { mLastPlayed.setValue(file->metadata.get("lastplayed")); mPlayCount.setValue(file->metadata.get("playcount")); } fadingOut = false; } std::vector<GuiComponent*> comps = getMDValues(); comps.push_back(&mDescription); comps.push_back(&mName); std::vector<TextComponent*> labels = getMDLabels(); comps.insert(comps.cend(), labels.cbegin(), labels.cend()); for(auto it = comps.cbegin(); it != comps.cend(); it++) { GuiComponent* comp = *it; // an animation is playing // then animate if reverse != fadingOut // an animation is not playing // then animate if opacity != our target opacity if((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) || (!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) { auto func = [comp](float t) { comp->setOpacity((unsigned char)(Math::lerp(0.0f, 1.0f, t)*255)); }; comp->setAnimation(new LambdaAnimation(func, 150), 0, nullptr, fadingOut); } } }
void VideoGameListView::updateInfoPanel() { FileData* file = (mList.size() == 0 || mList.isScrolling()) ? NULL : mList.getSelected(); boost::filesystem::remove(getTitlePath().c_str()); bool fadingOut; if(file == NULL) { mVideo->setVideo(""); mVideo->setImage(""); mVideoPlaying = false; //mMarquee.setImage(""); //mDescription.setText(""); fadingOut = true; }else{ std::string video_path; std::string marquee_path; std::string thumbnail_path; video_path = file->getVideoPath(); marquee_path = file->getMarqueePath(); thumbnail_path = file->getThumbnailPath(); if (!video_path.empty() && (video_path[0] == '~')) { video_path.erase(0, 1); video_path.insert(0, getHomePath()); } if (!marquee_path.empty() && (marquee_path[0] == '~')) { marquee_path.erase(0, 1); marquee_path.insert(0, getHomePath()); } if (!thumbnail_path.empty() && (thumbnail_path[0] == '~')) { thumbnail_path.erase(0, 1); thumbnail_path.insert(0, getHomePath()); } if (!mVideo->setVideo(video_path)) { mVideo->setDefaultVideo(); } mVideoPlaying = true; mVideo->setImage(thumbnail_path); mMarquee.setImage(marquee_path); mImage.setImage(thumbnail_path); mDescription.setText(file->metadata.get("desc")); mDescContainer.reset(); mRating.setValue(file->metadata.get("rating")); mReleaseDate.setValue(file->metadata.get("releasedate")); mDeveloper.setValue(file->metadata.get("developer")); mPublisher.setValue(file->metadata.get("publisher")); mGenre.setValue(file->metadata.get("genre")); mPlayers.setValue(file->metadata.get("players")); if(file->getType() == GAME) { mLastPlayed.setValue(file->metadata.get("lastplayed")); mPlayCount.setValue(file->metadata.get("playcount")); } fadingOut = false; } std::vector<GuiComponent*> comps = getMDValues(); comps.push_back(&mMarquee); comps.push_back(mVideo); comps.push_back(&mDescription); comps.push_back(&mImage); std::vector<TextComponent*> labels = getMDLabels(); comps.insert(comps.end(), labels.begin(), labels.end()); for(auto it = comps.begin(); it != comps.end(); it++) { GuiComponent* comp = *it; // an animation is playing // then animate if reverse != fadingOut // an animation is not playing // then animate if opacity != our target opacity if((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) || (!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) { auto func = [comp](float t) { comp->setOpacity((unsigned char)(lerp<float>(0.0f, 1.0f, t)*255)); }; comp->setAnimation(new LambdaAnimation(func, 150), 0, nullptr, fadingOut); } } }