mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 07:35:38 +00:00
Added FolderData::removeFileRecursive(FileData* f).
Fixed ButtonComponent crashing when pressed with no press func set.
This commit is contained in:
parent
f2689f49a6
commit
e55e0f3da7
|
@ -184,3 +184,24 @@ std::vector<FileData*> FolderData::getFilesRecursive(bool onlyFiles) const
|
|||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
void FolderData::removeFileRecursive(FileData* f)
|
||||
{
|
||||
auto iter = mFileVector.begin();
|
||||
while(iter != mFileVector.end())
|
||||
{
|
||||
if(*iter == f)
|
||||
{
|
||||
iter = mFileVector.erase(iter);
|
||||
}else{
|
||||
|
||||
FolderData* folder = dynamic_cast<FolderData*>(*iter);
|
||||
if(folder)
|
||||
{
|
||||
folder->removeFileRecursive(f);
|
||||
}
|
||||
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,6 +39,8 @@ public:
|
|||
std::vector<FileData*> getFiles(bool onlyFiles = false) const;
|
||||
std::vector<FileData*> getFilesRecursive(bool onlyFiles = false) const;
|
||||
|
||||
void removeFileRecursive(FileData* file);
|
||||
|
||||
void pushFileData(FileData* file);
|
||||
|
||||
void sort(ComparisonFunction & comparisonFunction = compareFileName, bool ascending = true);
|
||||
|
|
|
@ -22,7 +22,8 @@ bool ButtonComponent::input(InputConfig* config, Input input)
|
|||
{
|
||||
if(config->isMappedTo("a", input))
|
||||
{
|
||||
mPressedFunc();
|
||||
if(mPressedFunc)
|
||||
mPressedFunc();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,10 +31,12 @@ GuiGameEd::GuiGameEd(Window* window, GameData* game, const std::vector<MetaDataD
|
|||
|
||||
//initialize buttons
|
||||
mDeleteButton.setText("DELETE", 0x555555FF);
|
||||
mDeleteButton.setPressedFunc([&] { deleteGame(); delete this; });
|
||||
|
||||
mFetchButton.setText("FETCH", 0x555555FF);
|
||||
|
||||
mSaveButton.setText("SAVE", 0x0000FFFF);
|
||||
mSaveButton.setPressedFunc([&] { save(); delete this; });
|
||||
mSaveButton.setPressedFunc([&] { saveGame(); delete this; });
|
||||
|
||||
//initialize metadata list
|
||||
addChild(&mList);
|
||||
|
@ -90,10 +92,17 @@ void GuiGameEd::populateList(const std::vector<MetaDataDecl>& mdd)
|
|||
mList.setEntry(Vector2i(0, y), Vector2i(2, 1), &mSaveButton, true, ComponentListComponent::AlignCenter);
|
||||
}
|
||||
|
||||
void GuiGameEd::save()
|
||||
void GuiGameEd::saveGame()
|
||||
{
|
||||
for(unsigned int i = 0; i < mLabels.size(); i++)
|
||||
{
|
||||
mGame->metadata()->set(mLabels.at(i)->getValue(), mEditors.at(i)->getValue());
|
||||
}
|
||||
}
|
||||
|
||||
void GuiGameEd::deleteGame()
|
||||
{
|
||||
//mSystem->getRootFolder()->removeFileRecursive(mGame);
|
||||
//delete mGame;
|
||||
//mGame = NULL;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@ public:
|
|||
virtual ~GuiGameEd();
|
||||
|
||||
private:
|
||||
void save();
|
||||
void saveGame();
|
||||
void deleteGame();
|
||||
|
||||
void populateList(const std::vector<MetaDataDecl>& mdd);
|
||||
|
||||
|
|
|
@ -125,7 +125,9 @@ bool GuiGameList::input(InputConfig* config, Input input)
|
|||
|
||||
if(input.id == SDLK_F3)
|
||||
{
|
||||
mWindow->pushGui(new GuiGameEd(mWindow, (GameData*)mSystem->getRootFolder()->getFile(0), MetaDataList::getDefaultGameMDD()));
|
||||
GameData* game = dynamic_cast<GameData*>(mList.getSelectedObject());
|
||||
if(game)
|
||||
mWindow->pushGui(new GuiGameEd(mWindow, game, MetaDataList::getDefaultGameMDD()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ void ResourceManager::unloadAll()
|
|||
iter->lock()->unload(*this);
|
||||
iter++;
|
||||
}else{
|
||||
mReloadables.erase(iter++);
|
||||
iter = mReloadables.erase(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ void ResourceManager::reloadAll()
|
|||
iter->lock()->reload(*this);
|
||||
iter++;
|
||||
}else{
|
||||
mReloadables.erase(iter++);
|
||||
iter = mReloadables.erase(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue