mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
Moved rom deletion to gamelist, fixed halt on removal.
This commit is contained in:
parent
c8d62cf881
commit
196449e5c3
|
@ -75,10 +75,7 @@ void GuiGamelistOptions::openMetaDataEd()
|
|||
p.system = file->getSystem();
|
||||
mWindow->pushGui(new GuiMetaDataEd(mWindow, &file->metadata, file->metadata.getMDD(), p, file->getPath().filename().string(),
|
||||
std::bind(&IGameListView::onFileChanged, getGamelist(), file, FILE_METADATA_CHANGED), [this, file] {
|
||||
boost::filesystem::remove(file->getPath()); //actually delete the file on the filesystem
|
||||
file->getParent()->removeChild(file); //unlink it so list repopulations triggered from onFileChanged won't see it
|
||||
getGamelist()->onFileChanged(file, FILE_REMOVED); //tell the view
|
||||
delete file; //free it
|
||||
getGamelist()->remove(file);
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -86,6 +86,28 @@ void BasicGameListView::launch(FileData* game)
|
|||
ViewController::get()->launch(game);
|
||||
}
|
||||
|
||||
void BasicGameListView::remove(FileData *game)
|
||||
{
|
||||
boost::filesystem::remove(game->getPath()); // actually delete the file on the filesystem
|
||||
if (getCursor() == game) // Select next element in list, or prev if none
|
||||
{
|
||||
std::vector<FileData*> siblings = game->getParent()->getChildren();
|
||||
auto gameIter = std::find(siblings.begin(), siblings.end(), game);
|
||||
auto gamePos = std::distance(siblings.begin(), gameIter);
|
||||
if (gameIter != siblings.end())
|
||||
{
|
||||
if ((gamePos + 1) < siblings.size())
|
||||
{
|
||||
setCursor(siblings.at(gamePos + 1));
|
||||
} else if ((gamePos - 1) > 0) {
|
||||
setCursor(siblings.at(gamePos - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
delete game; // remove before repopulating (removes from parent)
|
||||
onFileChanged(game, FILE_REMOVED); // update the view, with game removed
|
||||
}
|
||||
|
||||
std::vector<HelpPrompt> BasicGameListView::getHelpPrompts()
|
||||
{
|
||||
std::vector<HelpPrompt> prompts;
|
||||
|
|
|
@ -23,6 +23,7 @@ public:
|
|||
protected:
|
||||
virtual void populateList(const std::vector<FileData*>& files) override;
|
||||
virtual void launch(FileData* game) override;
|
||||
virtual void remove(FileData* game) override;
|
||||
|
||||
TextListComponent<FileData*> mList;
|
||||
};
|
||||
|
|
|
@ -32,6 +32,7 @@ public:
|
|||
virtual void setCursor(FileData*) = 0;
|
||||
|
||||
virtual bool input(InputConfig* config, Input input) override;
|
||||
virtual void remove(FileData* game) = 0;
|
||||
|
||||
virtual const char* getName() const = 0;
|
||||
|
||||
|
|
Loading…
Reference in a new issue