diff --git a/src/FolderData.cpp b/src/FolderData.cpp index f6caea59a..a94c7d47b 100644 --- a/src/FolderData.cpp +++ b/src/FolderData.cpp @@ -180,6 +180,7 @@ void FolderData::removeFileRecursive(FileData* f) { if(*iter == f) { + delete *iter; iter = mFileVector.erase(iter); }else{ diff --git a/src/components/GuiGameList.cpp b/src/components/GuiGameList.cpp index 3ef3746cf..c7c5a6baa 100644 --- a/src/components/GuiGameList.cpp +++ b/src/components/GuiGameList.cpp @@ -151,8 +151,11 @@ bool GuiGameList::input(InputConfig* config, Input input) searchParams.system = mSystem; mWindow->pushGui(new GuiMetaDataEd(mWindow, game->metadata(), mSystem->getGameMDD(), searchParams, game->getBaseName(), [&] { updateDetailData(); }, - [game, root, this] { root->removeFileRecursive(game); updateList(); } - )); + [game, root, this] { + boost::filesystem::remove(game->getPath()); + root->removeFileRecursive(game); + updateList(); + })); } return true; } diff --git a/src/components/GuiGameScraper.cpp b/src/components/GuiGameScraper.cpp index 55a10ef07..973110d9b 100644 --- a/src/components/GuiGameScraper.cpp +++ b/src/components/GuiGameScraper.cpp @@ -120,6 +120,9 @@ void GuiGameScraper::onSearchDone(std::vector results) mList.setEntry(Eigen::Vector2i(0, 6 + i), Eigen::Vector2i(1, 1), &mResultNames.at(i), true, ComponentListComponent::AlignLeft); } } + + mList.resetCursor(); + mList.moveCursor(Eigen::Vector2i(0, 1)); //move cursor to first game if there is one } int GuiGameScraper::getSelectedIndex() diff --git a/src/components/GuiMetaDataEd.cpp b/src/components/GuiMetaDataEd.cpp index 61246dd06..f3f7d7b39 100644 --- a/src/components/GuiMetaDataEd.cpp +++ b/src/components/GuiMetaDataEd.cpp @@ -5,6 +5,7 @@ #include "../Settings.h" #include "GuiGameScraper.h" #include +#include "GuiMsgBoxYesNo.h" #define MDED_RESERVED_ROWS 3 @@ -30,7 +31,11 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window, MetaDataList* md, const std::vector //initialize buttons mDeleteButton.setText("DELETE", mDeleteFunc ? 0xFF0000FF : 0x555555FF); if(mDeleteFunc) - mDeleteButton.setPressedFunc([&] { mDeleteFunc(); delete this; }); + { + std::function deleteFileAndSelf = [&] { mDeleteFunc(); delete this; }; + std::function pressedFunc = [this, deleteFileAndSelf] { mWindow->pushGui(new GuiMsgBoxYesNo(mWindow, "This will delete a file!\nAre you sure?", deleteFileAndSelf)); }; + mDeleteButton.setPressedFunc(pressedFunc); + } mFetchButton.setText("FETCH", 0x00FF00FF); mFetchButton.setPressedFunc(std::bind(&GuiMetaDataEd::fetch, this)); @@ -164,3 +169,18 @@ void GuiMetaDataEd::fetchDone(MetaDataList result) mEditors.at(i)->setValue(result.get(key)); } } + + +bool GuiMetaDataEd::input(InputConfig* config, Input input) +{ + if(GuiComponent::input(config, input)) + return true; + + if(input.value != 0 && config->isMappedTo("b", input)) + { + delete this; + return true; + } + + return false; +} diff --git a/src/components/GuiMetaDataEd.h b/src/components/GuiMetaDataEd.h index 7ce136ac1..1c33394f5 100644 --- a/src/components/GuiMetaDataEd.h +++ b/src/components/GuiMetaDataEd.h @@ -17,6 +17,8 @@ public: const std::string& header, std::function savedCallback, std::function deleteFunc); virtual ~GuiMetaDataEd(); + bool input(InputConfig* config, Input input) override; + private: void save(); void fetch();