mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Merge pull request #28 from joolswills/fix-halt-on-delete
Moved rom deletion to gamelist, fixed halt on removal.
This commit is contained in:
commit
e7cba01be1
|
@ -76,10 +76,7 @@ void GuiGamelistOptions::openMetaDataEd()
|
||||||
p.system = file->getSystem();
|
p.system = file->getSystem();
|
||||||
mWindow->pushGui(new GuiMetaDataEd(mWindow, &file->metadata, file->metadata.getMDD(), p, file->getPath().filename().string(),
|
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] {
|
std::bind(&IGameListView::onFileChanged, getGamelist(), file, FILE_METADATA_CHANGED), [this, file] {
|
||||||
boost::filesystem::remove(file->getPath()); //actually delete the file on the filesystem
|
getGamelist()->remove(file);
|
||||||
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
|
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,28 @@ void BasicGameListView::launch(FileData* game)
|
||||||
ViewController::get()->launch(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> BasicGameListView::getHelpPrompts()
|
||||||
{
|
{
|
||||||
std::vector<HelpPrompt> prompts;
|
std::vector<HelpPrompt> prompts;
|
||||||
|
|
|
@ -23,6 +23,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
virtual void populateList(const std::vector<FileData*>& files) override;
|
virtual void populateList(const std::vector<FileData*>& files) override;
|
||||||
virtual void launch(FileData* game) override;
|
virtual void launch(FileData* game) override;
|
||||||
|
virtual void remove(FileData* game) override;
|
||||||
|
|
||||||
TextListComponent<FileData*> mList;
|
TextListComponent<FileData*> mList;
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
virtual void setCursor(FileData*) = 0;
|
virtual void setCursor(FileData*) = 0;
|
||||||
|
|
||||||
virtual bool input(InputConfig* config, Input input) override;
|
virtual bool input(InputConfig* config, Input input) override;
|
||||||
|
virtual void remove(FileData* game) = 0;
|
||||||
|
|
||||||
virtual const char* getName() const = 0;
|
virtual const char* getName() const = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue