void GridGameListView::initMDLabels() { std::vector<TextComponent*> components = getMDLabels(); const unsigned int colCount = 2; const unsigned int rowCount = (int)(components.size() / 2); Vector3f start(mSize.x() * 0.01f, mSize.y() * 0.625f, 0.0f); const float colSize = (mSize.x() * 0.48f) / colCount; const float rowPadding = 0.01f * mSize.y(); for(unsigned int i = 0; i < components.size(); i++) { const unsigned int row = i % rowCount; Vector3f pos(0.0f, 0.0f, 0.0f); if(row == 0) { pos = start + Vector3f(colSize * (i / rowCount), 0, 0); }else{ // work from the last component GuiComponent* lc = components[i-1]; pos = lc->getPosition() + Vector3f(0, lc->getSize().y() + rowPadding, 0); } components[i]->setFont(Font::get(FONT_SIZE_SMALL)); components[i]->setPosition(pos); components[i]->setDefaultZIndex(40); } }
void GuiSingleLineText::Render(GuiComponent& obj, const TMatrix4x4f& pViewMatrix) { Unlock(); if (pGlyphArr && !bNeedAutosize) { obj.SetViewMatrix(pViewMatrix*mAdjMatrix); obj.DrawText(pGlyphArr, vboTextVertex, vboTextTexCoord, &pFont.GetObj(), cFontColor); } }
// Draw background extras void SystemView::renderExtras(const Transform4x4f& trans, float lower, float upper) { int extrasCenter = (int)mExtrasCamOffset; // Adding texture loading buffers depending on scrolling speed and status int bufferIndex = getScrollingVelocity() + 1; Renderer::pushClipRect(Vector2i::Zero(), Vector2i((int)mSize.x(), (int)mSize.y())); for (int i = extrasCenter + logoBuffersLeft[bufferIndex]; i <= extrasCenter + logoBuffersRight[bufferIndex]; i++) { int index = i; while (index < 0) index += (int)mEntries.size(); while (index >= (int)mEntries.size()) index -= (int)mEntries.size(); //Only render selected system when not showing if (mShowing || index == mCursor) { Transform4x4f extrasTrans = trans; if (mCarousel.type == HORIZONTAL || mCarousel.type == HORIZONTAL_WHEEL) extrasTrans.translate(Vector3f((i - mExtrasCamOffset) * mSize.x(), 0, 0)); else extrasTrans.translate(Vector3f(0, (i - mExtrasCamOffset) * mSize.y(), 0)); Renderer::pushClipRect(Vector2i((int)extrasTrans.translation()[0], (int)extrasTrans.translation()[1]), Vector2i((int)mSize.x(), (int)mSize.y())); SystemViewData data = mEntries.at(index).data; for (unsigned int j = 0; j < data.backgroundExtras.size(); j++) { GuiComponent *extra = data.backgroundExtras[j]; if (extra->getZIndex() >= lower && extra->getZIndex() < upper) { extra->render(extrasTrans); } } Renderer::popClipRect(); } } Renderer::popClipRect(); }
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); } } }