void GuiGameList::onInput(InputManager::InputButton button, bool keyDown) { if(button == InputManager::BUTTON1 && mFolder->getFileCount() > 0) { if(!keyDown) { FileData* file = mList->getSelectedObject(); if(file->isFolder()) { //set current directory to this or something mFolderStack.push(mFolder); mFolder = (FolderData*)file; updateList(); }else{ mSystem->launchGame((GameData*)file); } } } if(button == InputManager::BUTTON2 && keyDown && mFolderStack.size()) { mFolder = mFolderStack.top(); mFolderStack.pop(); updateList(); } if(button == InputManager::RIGHT && keyDown) { setSystemId(mSystemId + 1); } if(button == InputManager::LEFT && keyDown) { setSystemId(mSystemId - 1); } if(button == InputManager::MENU && keyDown) { new GuiMenu(this); } if(mDetailed) { if(!keyDown && (button == InputManager::UP || button == InputManager::DOWN)) { if(mList->getSelectedObject() && !mList->getSelectedObject()->isFolder()) { mScreenshot->setImage(((GameData*)mList->getSelectedObject())->getImagePath()); }else{ mScreenshot->setImage(""); } } } }
void GuiGameList::updateList() { if(mDetailed) mScreenshot->setImage(""); mList->clear(); for(unsigned int i = 0; i < mFolder->getFileCount(); i++) { FileData* file = mFolder->getFile(i); if(file->isFolder()) mList->addObject(file->getName(), file, 0x00C000); else mList->addObject(file->getName(), file); } }
void GuiGameList::input(InputConfig* config, Input input) { mList->input(config, input); if(config->isMappedTo("a", input) && mFolder->getFileCount() > 0 && input.value != 0) { //play select sound mTheme->getSound("menuSelect")->play(); FileData* file = mList->getSelectedObject(); if(file->isFolder()) //if you selected a folder, add this directory to the stack, and use the selected one { mFolderStack.push(mFolder); mFolder = (FolderData*)file; updateList(); }else{ mList->stopScrolling(); //wait for the sound to finish or we'll never hear it... while(mTheme->getSound("menuSelect")->isPlaying()); mSystem->launchGame(mWindow, (GameData*)file); return; } } //if there's something on the directory stack, return to it if(config->isMappedTo("b", input) && input.value != 0 && mFolderStack.size()) { mFolder = mFolderStack.top(); mFolderStack.pop(); updateList(); updateDetailData(); //play the back sound mTheme->getSound("menuBack")->play(); } //only allow switching systems if more than one exists (otherwise it'll reset your position when you switch and it's annoying) if(SystemData::sSystemVector.size() > 1 && input.value != 0) { if(config->isMappedTo("right", input)) { setSystemId(mSystemId + 1); } if(config->isMappedTo("left", input)) { setSystemId(mSystemId - 1); } } //open the "start menu" if(config->isMappedTo("menu", input) && input.value != 0) { mWindow->pushGui(new GuiMenu(mWindow, this)); } //open the fast select menu if(config->isMappedTo("select", input) && input.value != 0) { mWindow->pushGui(new GuiFastSelect(mWindow, this, mList, mList->getSelectedObject()->getName()[0], mTheme->getBoxData(), mTheme->getColor("fastSelect"), mTheme->getSound("menuScroll"), mTheme->getFastSelectFont())); } if(mDetailed) { if(config->isMappedTo("up", input) || config->isMappedTo("down", input) || config->isMappedTo("pageup", input) || config->isMappedTo("pagedown", input)) { if(input.value == 0) updateDetailData(); else clearDetailData(); } } }