bool ISimpleGameListView::input(InputConfig* config, Input input) { if(input.value != 0) { if(config->isMappedTo("a", input)) { FileData* cursor = getCursor(); if(cursor->getType() == GAME) { Sound::getFromTheme(getTheme(), getName(), "launch")->play(); launch(cursor); }else{ // it's a folder if(cursor->getChildren().size() > 0) { mCursorStack.push(cursor); populateList(cursor->getChildren()); } } return true; }else if(config->isMappedTo("b", input)) { if(mCursorStack.size()) { populateList(mCursorStack.top()->getParent()->getChildren()); setCursor(mCursorStack.top()); mCursorStack.pop(); Sound::getFromTheme(getTheme(), getName(), "back")->play(); }else{ onFocusLost(); ViewController::get()->goToSystemView(getCursor()->getSystem()); } return true; }else if(config->isMappedTo("right", input) || config->isMappedTo("righttop", input)) { if(Settings::getInstance()->getBool("QuickSystemSelect")) { onFocusLost(); ViewController::get()->goToNextGameList(); return true; } }else if(config->isMappedTo("left", input) || config->isMappedTo("lefttop", input)) { if(Settings::getInstance()->getBool("QuickSystemSelect")) { onFocusLost(); ViewController::get()->goToPrevGameList(); return true; } } } return IGameListView::input(config, input); }
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 BasicGameListView::populateList(const std::vector<FileData*>& files) { mList.clear(); if (files.size() > 0) { mHeaderText.setText(files.at(0)->getSystem()->getFullName()); for(auto it = files.begin(); it != files.end(); it++) { mList.add((*it)->getName(), *it, ((*it)->getType() == FOLDER)); } } else { // empty list - add a placeholder FileData* placeholder = new FileData(PLACEHOLDER, "<No Results Found for Current Filter Criteria>", this->mRoot->getSystem()); mList.add(placeholder->getName(), placeholder, (placeholder->getType() == PLACEHOLDER)); } }
void ViewController::launch(FileData& game, Eigen::Vector3f center) { if(game.getType() != GAME) { LOG(LogError) << "Tried to launch something that isn't a game!"; return; } Eigen::Affine3f origCamera = mCamera; origCamera.translation() = -mCurrentView->getPosition(); center += mCurrentView->getPosition(); stopAnimation(1); // make sure the fade in isn't still playing mLockInput = true; if(Settings::getInstance()->getString("TransitionStyle") == "fade") { // fade out, launch game, fade back in auto fadeFunc = [this](float t) { //t -= 1; //mFadeOpacity = lerp<float>(0.0f, 1.0f, t*t*t + 1); mFadeOpacity = lerp<float>(0.0f, 1.0f, t); }; setAnimation(new LambdaAnimation(fadeFunc, 800), 0, [this, game, fadeFunc] { game.getSystem()->launchGame(mWindow, game); mLockInput = false; setAnimation(new LambdaAnimation(fadeFunc, 800), 0, nullptr, true); this->onMetaDataChanged(game.getSystem(), game); }); }else{ // move camera to zoom in on center + fade out, launch game, come back in setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 1500), 0, [this, origCamera, center, game] { game.getSystem()->launchGame(mWindow, game); mCamera = origCamera; mLockInput = false; setAnimation(new LaunchAnimation(mCamera, mFadeOpacity, center, 600), 0, nullptr, true); this->onMetaDataChanged(game.getSystem(), game); }); } }
bool ISimpleGameListView::input(InputConfig* config, Input input) { if(input.value != 0) { if(config->isMappedTo("a", input)) { LOG(LogDebug) << "ISimpleGameListView::input(): a detected!"; FileData* cursor = getCursor(); if(cursor->getType() == GAME) { Sound::getFromTheme(getTheme(), getName(), "launch")->play(); launch(cursor); }else{ // it's a folder if(cursor->getChildren().size() > 0) { mCursorStack.push(cursor); populateList(cursor->getChildren()); } } return true; }else if(config->isMappedTo("b", input)) { LOG(LogDebug) << "ISimpleGameListView::input(): b detected!"; if(mCursorStack.size()) { populateList(mCursorStack.top()->getParent()->getChildren()); setCursor(mCursorStack.top()); mCursorStack.pop(); Sound::getFromTheme(getTheme(), getName(), "back")->play(); }else{ onFocusLost(); if (mFavoriteChange || mKidGameChange) { ViewController::get()->setInvalidGamesList(getCursor()->getSystem()); mFavoriteChange = false; mKidGameChange = false; } ViewController::get()->goToSystemView(getCursor()->getSystem()); } return true; }else if (config->isMappedTo("x", input)) { FileData* cursor = getCursor(); LOG(LogDebug) << "ISimpleGameListView::input(): x detected!"; if (cursor->getSystem()->getHasFavorites()) { if (cursor->getType() == GAME) { mFavoriteChange = true; MetaDataList* md = &cursor->metadata; std::string value = md->get("favorite"); LOG(LogDebug) << "Favorite = "<< value; if (value.compare("false") == 0) { md->set("favorite", "true"); }else { md->set("favorite", "false"); } LOG(LogDebug) << "New Favorite value set to: "<< md->get("favorite"); updateInfoPanel(); } } }else if (config->isMappedTo("y", input)) { LOG(LogDebug) << "ISimpleGameListView::input(): y detected!"; FileData* cursor = getCursor(); if (cursor->getSystem()->getHasKidGames() && !mFilterHidden) // only when kidgames are supported by system+theme, and when in UImode=full { if (cursor->getType() == GAME) { mKidGameChange = true; MetaDataList* md = &cursor->metadata; std::string value = md->get("kidgame"); LOG(LogDebug) << "kidgame = "<< value; if (value.compare("false") == 0) { md->set("kidgame", "true"); } else { md->set("kidgame", "false"); } LOG(LogDebug) << "New kidgame value set to: "<< md->get("kidgame"); updateInfoPanel(); } } }else if(config->isMappedTo("right", input)) { if(Settings::getInstance()->getBool("QuickSystemSelect")) { onFocusLost(); if (mFavoriteChange || mKidGameChange) { ViewController::get()->setInvalidGamesList(getCursor()->getSystem()); mFavoriteChange = false; mKidGameChange = false; } ViewController::get()->goToNextGameList(mFilterHidden, mFilterFav, mFilterKid); return true; } }else if(config->isMappedTo("left", input)) { if(Settings::getInstance()->getBool("QuickSystemSelect")) { onFocusLost(); if (mFavoriteChange || mKidGameChange) { ViewController::get()->setInvalidGamesList(getCursor()->getSystem()); mFavoriteChange = false; mKidGameChange = false; } ViewController::get()->goToPrevGameList(mFilterHidden, mFilterFav, mFilterKid); return true; } } } return IGameListView::input(config, input); }
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); } } }
//Handles the input for the game views. bool ISimpleGameListView::input(InputConfig* config, Input input) { if (input.value != 0) //Redirect input if keyboard is open. { if (config->isMappedTo("a", input) && !mKeyboard->isOpen()) { FileData* cursor = getCursor(); if(cursor->getType() == GAME) { Sound::getFromTheme(getTheme(), getName(), "launch")->play(); launch(cursor); }else{ // it's a folder if(cursor->getChildren().size() > 0) { mCursorStack.push(cursor); populateList(cursor->getChildren()); } } return true; }else if(config->isMappedTo("b", input) && !mKeyboard->isOpen()) { if(mCursorStack.size()) { populateList(mCursorStack.top()->getParent()->getChildren()); setCursor(mCursorStack.top()); mCursorStack.pop(); Sound::getFromTheme(getTheme(), getName(), "back")->play(); }else{ onFocusLost(); ViewController::get()->goToSystemView(getCursor()->getSystem()); } return true; } else if (config->isMappedTo("y", input)) //User has opened up the keyboard. { mKeyboard->setKeyboardIsOpen(true); return true; //Return like other inputs. } else if(config->isMappedTo("right", input)) { if(Settings::getInstance()->getBool("QuickSystemSelect")) { onFocusLost(); ViewController::get()->goToNextGameList(); return true; } }else if(config->isMappedTo("left", input)) { if(Settings::getInstance()->getBool("QuickSystemSelect")) { onFocusLost(); ViewController::get()->goToPrevGameList(); return true; } } } //Redirect input to keyboard. //There needs to be a sleep timer on the y option. //THERE IS ALREADY A JUMP TO LETTER FUNCTION IN GUIGAMELISTOPTIONS.cpp if (mKeyboard->isOpen()) { //Close keyboard. if (config->isMappedTo("b", input) && input.value || config->isMappedTo("y", input) && input.value) { mKeyboard->setKeyboardIsOpen(false); } else if (config->isMappedTo("left", input) && input.value) { mKeyboard->iterateLeft(); mKeyboardText.setText(mKeyboard->getKeys()); } else if (config->isMappedTo("right", input) && input.value) { mKeyboard->iterateRight(); mKeyboardText.setText(mKeyboard->getKeys()); } else if (config->isMappedTo("a", input) && input.value) { if (mKeyboard->goToKey(mRoot) && mKeyboard->getPrevChoice() != getCursor()->getCleanName()[0]) { //Not nullptr setCursor(mKeyboard->goToKey(mRoot)); } else { FileData* cursor = getCursor(); if (cursor->getType() == GAME) { Sound::getFromTheme(getTheme(), getName(), "launch")->play(); launch(cursor); } else{ // it's a folder if (cursor->getChildren().size() > 0) { mCursorStack.push(cursor); populateList(cursor->getChildren()); } } } } } return IGameListView::input(config, input); }
bool ISimpleGameListView::input(InputConfig* config, Input input) { if(input.value != 0) { if(config->isMappedTo("a", input)) { FileData* cursor = getCursor(); if(cursor->getType() == GAME) { //Sound::getFromTheme(getTheme(), getName(), "launch")->play(); launch(cursor); }else{ // it's a folder if(cursor->getChildren().size() > 0) { mCursorStack.push(cursor); populateList(cursor->getChildren()); } } return true; }else if(config->isMappedTo("b", input)) { if(mCursorStack.size()) { populateList(mCursorStack.top()->getParent()->getChildren()); setCursor(mCursorStack.top()); mCursorStack.pop(); //Sound::getFromTheme(getTheme(), getName(), "back")->play(); }else{ onFocusLost(); if (mFavoriteChange) { ViewController::get()->setInvalidGamesList(getCursor()->getSystem()); mFavoriteChange = false; } ViewController::get()->goToSystemView(getCursor()->getSystem()); } return true; }else if (config->isMappedTo("y", input)) { FileData* cursor = getCursor(); if (cursor->getSystem()->getHasFavorites()) { if (cursor->getType() == GAME) { mFavoriteChange = true; MetaDataList* md = &cursor->metadata; std::string value = md->get("favorite"); if (value.compare("no") == 0) { md->set("favorite", "yes"); } else { md->set("favorite", "no"); } FileData* cursor = getCursor(); populateList(cursor->getParent()->getChildren()); setCursor(cursor); updateInfoPanel(); } } }else if(config->isMappedTo("right", input)) { if(Settings::getInstance()->getBool("QuickSystemSelect")) { onFocusLost(); if (mFavoriteChange) { ViewController::get()->setInvalidGamesList(getCursor()->getSystem()); mFavoriteChange = false; } ViewController::get()->goToNextGameList(); return true; } }else if(config->isMappedTo("left", input)) { if(Settings::getInstance()->getBool("QuickSystemSelect")) { onFocusLost(); if (mFavoriteChange) { ViewController::get()->setInvalidGamesList(getCursor()->getSystem()); mFavoriteChange = false; } ViewController::get()->goToPrevGameList(); return true; } } } return IGameListView::input(config, input); }