mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-17 22:55:38 +00:00
Fixed crash when gamelist view gets recreated while GuiGamelistOptions is open.
Ugly hack to fix it, but it will probably get rewritten in the future anyway.
This commit is contained in:
parent
cf2294380a
commit
2f02ebeada
|
@ -1,9 +1,10 @@
|
|||
#include "GuiGamelistOptions.h"
|
||||
#include "GuiMetaDataEd.h"
|
||||
#include "../views/gamelist/IGameListView.h"
|
||||
#include "../views/ViewController.h"
|
||||
|
||||
GuiGamelistOptions::GuiGamelistOptions(Window* window, IGameListView* gamelist) : GuiComponent(window),
|
||||
mGamelist(gamelist),
|
||||
GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system) : GuiComponent(window),
|
||||
mSystem(system),
|
||||
mMenu(window, "OPTIONS")
|
||||
{
|
||||
addChild(&mMenu);
|
||||
|
@ -33,25 +34,25 @@ GuiGamelistOptions::GuiGamelistOptions(Window* window, IGameListView* gamelist)
|
|||
GuiGamelistOptions::~GuiGamelistOptions()
|
||||
{
|
||||
// apply sort
|
||||
FileData* root = mGamelist->getCursor()->getSystem()->getRootFolder();
|
||||
FileData* root = getGamelist()->getCursor()->getSystem()->getRootFolder();
|
||||
root->sort(*mListSort->getSelected()); // will also recursively sort children
|
||||
|
||||
// notify that the root folder was sorted
|
||||
mGamelist->onFileChanged(root, FILE_SORTED);
|
||||
getGamelist()->onFileChanged(root, FILE_SORTED);
|
||||
}
|
||||
|
||||
void GuiGamelistOptions::openMetaDataEd()
|
||||
{
|
||||
// open metadata editor
|
||||
FileData* file = mGamelist->getCursor();
|
||||
FileData* file = getGamelist()->getCursor();
|
||||
ScraperSearchParams p;
|
||||
p.game = file;
|
||||
p.system = file->getSystem();
|
||||
mWindow->pushGui(new GuiMetaDataEd(mWindow, &file->metadata, file->metadata.getMDD(), p, file->getPath().filename().string(),
|
||||
std::bind(&IGameListView::onFileChanged, mGamelist, 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
|
||||
file->getParent()->removeChild(file); //unlink it so list repopulations triggered from onFileChanged won't see it
|
||||
mGamelist->onFileChanged(file, FILE_REMOVED); //tell the view
|
||||
getGamelist()->onFileChanged(file, FILE_REMOVED); //tell the view
|
||||
delete file; //free it
|
||||
}));
|
||||
}
|
||||
|
@ -73,3 +74,8 @@ std::vector<HelpPrompt> GuiGamelistOptions::getHelpPrompts()
|
|||
prompts.push_back(HelpPrompt("b", "close"));
|
||||
return prompts;
|
||||
}
|
||||
|
||||
IGameListView* GuiGamelistOptions::getGamelist()
|
||||
{
|
||||
return mWindow->getViewController()->getGameListView(mSystem).get();
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ class IGameListView;
|
|||
class GuiGamelistOptions : public GuiComponent
|
||||
{
|
||||
public:
|
||||
GuiGamelistOptions(Window* window, IGameListView* gamelist);
|
||||
GuiGamelistOptions(Window* window, SystemData* system);
|
||||
virtual ~GuiGamelistOptions();
|
||||
|
||||
virtual bool input(InputConfig* config, Input input) override;
|
||||
|
@ -23,5 +23,6 @@ private:
|
|||
typedef OptionListComponent<const FileData::SortType*> SortList;
|
||||
std::shared_ptr<SortList> mListSort;
|
||||
|
||||
IGameListView* mGamelist;
|
||||
SystemData* mSystem;
|
||||
IGameListView* getGamelist();
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@ SystemView::SystemView(Window* window) : IList<SystemViewData, SystemData*>(wind
|
|||
|
||||
setSize((float)Renderer::getScreenWidth(), (float)Renderer::getScreenHeight());
|
||||
|
||||
mSystemInfo.setSize(mSize.x(), mSystemInfo.getSize().y() * 2.f);
|
||||
mSystemInfo.setSize(mSize.x(), mSystemInfo.getSize().y() * 1.333f);
|
||||
mSystemInfo.setPosition(0, (mSize.y() + BAND_HEIGHT) / 2);
|
||||
|
||||
populate();
|
||||
|
|
|
@ -61,12 +61,12 @@ public:
|
|||
|
||||
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
||||
|
||||
std::shared_ptr<IGameListView> getGameListView(SystemData* system);
|
||||
std::shared_ptr<SystemView> getSystemListView();
|
||||
|
||||
private:
|
||||
void playViewTransition();
|
||||
int getSystemId(SystemData* system);
|
||||
|
||||
std::shared_ptr<IGameListView> getGameListView(SystemData* system);
|
||||
std::shared_ptr<SystemView> getSystemListView();
|
||||
|
||||
std::shared_ptr<GuiComponent> mCurrentView;
|
||||
std::map< SystemData*, std::shared_ptr<IGameListView> > mGameListViews;
|
||||
|
|
|
@ -10,16 +10,11 @@
|
|||
|
||||
bool IGameListView::input(InputConfig* config, Input input)
|
||||
{
|
||||
// F3 to open metadata editor
|
||||
if(config->getDeviceId() == DEVICE_KEYBOARD && input.id == SDLK_F3 && input.value != 0)
|
||||
{
|
||||
|
||||
|
||||
// select to open GuiGamelistOptions
|
||||
}else if(config->isMappedTo("select", input) && input.value)
|
||||
if(config->isMappedTo("select", input) && input.value)
|
||||
{
|
||||
Sound::getFromTheme(mTheme, getName(), "menuOpen")->play();
|
||||
mWindow->pushGui(new GuiGamelistOptions(mWindow, this));
|
||||
mWindow->pushGui(new GuiGamelistOptions(mWindow, this->mRoot->getSystem()));
|
||||
return true;
|
||||
|
||||
// Ctrl-R to reload a view when debugging
|
||||
|
|
Loading…
Reference in a new issue