mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Added a clear button to the metadata editor.
This commit is contained in:
parent
08a2602fe2
commit
0946988fdb
|
@ -265,49 +265,45 @@ void GuiGamelistOptions::openMetaDataEd()
|
||||||
p.game = file;
|
p.game = file;
|
||||||
p.system = file->getSystem();
|
p.system = file->getSystem();
|
||||||
|
|
||||||
|
std::function<void()> clearGameBtnFunc;
|
||||||
std::function<void()> deleteGameBtnFunc;
|
std::function<void()> deleteGameBtnFunc;
|
||||||
std::function<void()> deleteMediaBtnFunc;
|
|
||||||
|
|
||||||
deleteMediaBtnFunc = [this, file] {
|
clearGameBtnFunc = [this, file] {
|
||||||
LOG(LogInfo) << "Deleting all game media files for '" << file->getFullPath() << "'.";
|
if (file->getType() == FOLDER) {
|
||||||
ViewController::get()->getGameListView(
|
|
||||||
file->getSystem()).get()->removeMedia(file);
|
|
||||||
};
|
|
||||||
|
|
||||||
if (file->getType() == FOLDER) {
|
|
||||||
deleteGameBtnFunc = [this, file] {
|
|
||||||
LOG(LogInfo) << "Deleting the media files and gamelist.xml entry for the folder '" <<
|
LOG(LogInfo) << "Deleting the media files and gamelist.xml entry for the folder '" <<
|
||||||
file->getFullPath() << "'";
|
file->getFullPath() << "'";
|
||||||
ViewController::get()->getGameListView(
|
}
|
||||||
file->getSystem()).get()->removeMedia(file);
|
else {
|
||||||
|
LOG(LogInfo) << "Deleting the media files and gamelist.xml entry for the file '" <<
|
||||||
|
file->getFullPath() << "'";
|
||||||
|
}
|
||||||
|
ViewController::get()->getGameListView(file->getSystem()).get()->removeMedia(file);
|
||||||
|
|
||||||
// Manually reset all the metadata values, set the name to the actual folder name.
|
// Manually reset all the metadata values, set the name to the actual file/folder name.
|
||||||
const std::vector<MetaDataDecl>& mdd = file->metadata.getMDD();
|
const std::vector<MetaDataDecl>& mdd = file->metadata.getMDD();
|
||||||
for (auto it = mdd.cbegin(); it != mdd.cend(); it++) {
|
for (auto it = mdd.cbegin(); it != mdd.cend(); it++) {
|
||||||
if (it->key == "name") {
|
if (it->key == "name") {
|
||||||
file->metadata.set(it->key, file->getDisplayName());
|
file->metadata.set(it->key, file->getDisplayName());
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
file->metadata.set(it->key, it->defaultValue);
|
|
||||||
}
|
}
|
||||||
|
file->metadata.set(it->key, it->defaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
ViewController::get()->reloadGameListView(file->getParent()->getSystem());
|
ViewController::get()->reloadGameListView(file->getParent()->getSystem());
|
||||||
// Remove the folder entry from the gamelist.xml file.
|
// Remove the folder entry from the gamelist.xml file.
|
||||||
file->setDeletionFlag();
|
file->setDeletionFlag();
|
||||||
file->getParent()->getSystem()->writeMetaData();
|
file->getParent()->getSystem()->writeMetaData();
|
||||||
};
|
};
|
||||||
}
|
|
||||||
else {
|
deleteGameBtnFunc = [this, file] {
|
||||||
deleteGameBtnFunc = [this, file] {
|
LOG(LogInfo) << "Deleting the game file '" << file->getFullPath() <<
|
||||||
LOG(LogInfo) << "Deleting the game file '" << file->getFullPath() <<
|
"', all its media files and its gamelist.xml entry.";
|
||||||
"', all its media files and its gamelist.xml entry.";
|
CollectionSystemManager::get()->deleteCollectionFiles(file);
|
||||||
CollectionSystemManager::get()->deleteCollectionFiles(file);
|
ViewController::get()->getGameListView(
|
||||||
ViewController::get()->getGameListView(
|
file->getSystem()).get()->removeMedia(file);
|
||||||
file->getSystem()).get()->removeMedia(file);
|
ViewController::get()->getGameListView(
|
||||||
ViewController::get()->getGameListView(
|
file->getSystem()).get()->remove(file, true);
|
||||||
file->getSystem()).get()->remove(file, true);
|
};
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (file->getType() == FOLDER) {
|
if (file->getType() == FOLDER) {
|
||||||
mWindow->pushGui(new GuiMetaDataEd(mWindow, &file->metadata,
|
mWindow->pushGui(new GuiMetaDataEd(mWindow, &file->metadata,
|
||||||
|
@ -315,7 +311,7 @@ void GuiGamelistOptions::openMetaDataEd()
|
||||||
Utils::FileSystem::getFileName(file->getPath()), std::bind(
|
Utils::FileSystem::getFileName(file->getPath()), std::bind(
|
||||||
&IGameListView::onFileChanged, ViewController::get()->getGameListView(
|
&IGameListView::onFileChanged, ViewController::get()->getGameListView(
|
||||||
file->getSystem()).get(), file, FILE_METADATA_CHANGED),
|
file->getSystem()).get(), file, FILE_METADATA_CHANGED),
|
||||||
deleteGameBtnFunc, deleteMediaBtnFunc));
|
clearGameBtnFunc, deleteGameBtnFunc));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mWindow->pushGui(new GuiMetaDataEd(mWindow, &file->metadata,
|
mWindow->pushGui(new GuiMetaDataEd(mWindow, &file->metadata,
|
||||||
|
@ -323,7 +319,7 @@ void GuiGamelistOptions::openMetaDataEd()
|
||||||
Utils::FileSystem::getFileName(file->getPath()), std::bind(
|
Utils::FileSystem::getFileName(file->getPath()), std::bind(
|
||||||
&IGameListView::onFileChanged, ViewController::get()->getGameListView(
|
&IGameListView::onFileChanged, ViewController::get()->getGameListView(
|
||||||
file->getSystem()).get(), file, FILE_METADATA_CHANGED),
|
file->getSystem()).get(), file, FILE_METADATA_CHANGED),
|
||||||
deleteGameBtnFunc, deleteMediaBtnFunc));
|
clearGameBtnFunc, deleteGameBtnFunc));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@ GuiMetaDataEd::GuiMetaDataEd(
|
||||||
ScraperSearchParams scraperParams,
|
ScraperSearchParams scraperParams,
|
||||||
const std::string& /*header*/,
|
const std::string& /*header*/,
|
||||||
std::function<void()> saveCallback,
|
std::function<void()> saveCallback,
|
||||||
std::function<void()> deleteGameFunc,
|
std::function<void()> clearGameFunc,
|
||||||
std::function<void()> deleteMediaFunc)
|
std::function<void()> deleteGameFunc)
|
||||||
: GuiComponent(window),
|
: GuiComponent(window),
|
||||||
mScraperParams(scraperParams),
|
mScraperParams(scraperParams),
|
||||||
mBackground(window, ":/graphics/frame.png"),
|
mBackground(window, ":/graphics/frame.png"),
|
||||||
|
@ -48,8 +48,8 @@ GuiMetaDataEd::GuiMetaDataEd(
|
||||||
mMetaDataDecl(mdd),
|
mMetaDataDecl(mdd),
|
||||||
mMetaData(md),
|
mMetaData(md),
|
||||||
mSavedCallback(saveCallback),
|
mSavedCallback(saveCallback),
|
||||||
mDeleteGameFunc(deleteGameFunc),
|
mClearGameFunc(clearGameFunc),
|
||||||
mDeleteMediaFunc(deleteMediaFunc)
|
mDeleteGameFunc(deleteGameFunc)
|
||||||
{
|
{
|
||||||
addChild(&mBackground);
|
addChild(&mBackground);
|
||||||
addChild(&mGrid);
|
addChild(&mGrid);
|
||||||
|
@ -254,34 +254,35 @@ GuiMetaDataEd::GuiMetaDataEd(
|
||||||
[&] { delete this; }));
|
[&] { delete this; }));
|
||||||
|
|
||||||
if (scraperParams.game->getType() == FOLDER) {
|
if (scraperParams.game->getType() == FOLDER) {
|
||||||
if (mDeleteGameFunc) {
|
if (mClearGameFunc) {
|
||||||
auto deleteFilesAndSelf = [&] { mDeleteGameFunc(); delete this; };
|
auto clearSelf = [&] { mClearGameFunc(); delete this; };
|
||||||
auto deleteGameBtnFunc = [this, deleteFilesAndSelf] {
|
auto clearSelfBtnFunc = [this, clearSelf] {
|
||||||
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(),
|
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(),
|
||||||
"THIS WILL DELETE THE MEDIA FILES AND\n"
|
"THIS WILL DELETE ANY MEDIA FILES AND\n"
|
||||||
"THE GAMELIST.XML ENTRY FOR THIS FOLDER.\n"
|
"THE GAMELIST.XML ENTRY FOR THIS FOLDER,\n"
|
||||||
"HOWEVER NEITHER THE FOLDER ITSELF OR\n"
|
"BUT NEITHER THE FOLDER ITSELF OR ANY\n"
|
||||||
"ANY DATA FOR THE FILES INSIDE THE FOLDER\n"
|
"DATA FOR THE FILES INSIDE THE FOLDER\n"
|
||||||
"WILL BE DELETED. ARE YOU SURE?",
|
"WILL BE DELETED. ARE YOU SURE?",
|
||||||
"YES", deleteFilesAndSelf, "NO", nullptr)); };
|
"YES", clearSelf, "NO", nullptr)); };
|
||||||
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "DELETE",
|
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "CLEAR",
|
||||||
"delete game", deleteGameBtnFunc));
|
"clear folder", clearSelfBtnFunc));
|
||||||
}
|
|
||||||
|
|
||||||
if (mDeleteMediaFunc) {
|
|
||||||
auto deleteFilesAndSelf = [&] { mDeleteMediaFunc(); delete this; };
|
|
||||||
auto deleteMediaBtnFunc = [this, deleteFilesAndSelf] {
|
|
||||||
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(),
|
|
||||||
"THIS WILL DELETE ALL THE MEDIA FILES\n"
|
|
||||||
"FOR THE ACTUAL FOLDER, BUT NO MEDIA\n"
|
|
||||||
"FOR ANY FILES INSIDE THE FOLDER WILL\n"
|
|
||||||
"BE DELETED. ARE YOU SURE?",
|
|
||||||
"YES", deleteFilesAndSelf, "NO", nullptr)); };
|
|
||||||
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "DELETE MEDIA",
|
|
||||||
"delete game", deleteMediaBtnFunc));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (mClearGameFunc) {
|
||||||
|
auto clearSelf = [&] { mClearGameFunc(); delete this; };
|
||||||
|
auto clearSelfBtnFunc = [this, clearSelf] {
|
||||||
|
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(),
|
||||||
|
"THIS WILL DELETE ANY MEDIA FILES\n"
|
||||||
|
"AND THE GAMELIST.XML ENTRY FOR\n"
|
||||||
|
"THIS GAME FILE, BUT THE FILE ITSELF\n"
|
||||||
|
"WILL NOT BE REMOVED.\n"
|
||||||
|
"ARE YOU SURE?",
|
||||||
|
"YES", clearSelf, "NO", nullptr)); };
|
||||||
|
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "CLEAR",
|
||||||
|
"clear file", clearSelfBtnFunc));
|
||||||
|
}
|
||||||
|
|
||||||
if (mDeleteGameFunc) {
|
if (mDeleteGameFunc) {
|
||||||
auto deleteFilesAndSelf = [&] { mDeleteGameFunc(); delete this; };
|
auto deleteFilesAndSelf = [&] { mDeleteGameFunc(); delete this; };
|
||||||
auto deleteGameBtnFunc = [this, deleteFilesAndSelf] {
|
auto deleteGameBtnFunc = [this, deleteFilesAndSelf] {
|
||||||
|
@ -294,20 +295,6 @@ GuiMetaDataEd::GuiMetaDataEd(
|
||||||
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "DELETE",
|
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "DELETE",
|
||||||
"delete game", deleteGameBtnFunc));
|
"delete game", deleteGameBtnFunc));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mDeleteMediaFunc) {
|
|
||||||
auto deleteFilesAndSelf = [&] { mDeleteMediaFunc(); delete this; };
|
|
||||||
auto deleteMediaBtnFunc = [this, deleteFilesAndSelf] {
|
|
||||||
mWindow->pushGui(new GuiMsgBox(mWindow, getHelpStyle(),
|
|
||||||
"THIS WILL DELETE ALL GAME\n"
|
|
||||||
"MEDIA FILES, BUT WILL KEEP\n"
|
|
||||||
"THE ACTUAL GAME FILE AND\n"
|
|
||||||
"THE GAMELIST.XML ENTRY.\n"
|
|
||||||
"ARE YOU SURE?",
|
|
||||||
"YES", deleteFilesAndSelf, "NO", nullptr)); };
|
|
||||||
buttons.push_back(std::make_shared<ButtonComponent>(mWindow, "DELETE MEDIA",
|
|
||||||
"delete game", deleteMediaBtnFunc));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mButtons = makeButtonGrid(mWindow, buttons);
|
mButtons = makeButtonGrid(mWindow, buttons);
|
||||||
|
|
|
@ -30,8 +30,8 @@ public:
|
||||||
ScraperSearchParams params,
|
ScraperSearchParams params,
|
||||||
const std::string& header,
|
const std::string& header,
|
||||||
std::function<void()> savedCallback,
|
std::function<void()> savedCallback,
|
||||||
std::function<void()> deleteGameFunc,
|
std::function<void()> clearGameFunc,
|
||||||
std::function<void()> deleteMediaFunc);
|
std::function<void()> deleteGameFunc);
|
||||||
|
|
||||||
bool input(InputConfig* config, Input input) override;
|
bool input(InputConfig* config, Input input) override;
|
||||||
void onSizeChanged() override;
|
void onSizeChanged() override;
|
||||||
|
@ -61,8 +61,8 @@ private:
|
||||||
std::vector<MetaDataDecl> mMetaDataDecl;
|
std::vector<MetaDataDecl> mMetaDataDecl;
|
||||||
MetaDataList* mMetaData;
|
MetaDataList* mMetaData;
|
||||||
std::function<void()> mSavedCallback;
|
std::function<void()> mSavedCallback;
|
||||||
|
std::function<void()> mClearGameFunc;
|
||||||
std::function<void()> mDeleteGameFunc;
|
std::function<void()> mDeleteGameFunc;
|
||||||
std::function<void()> mDeleteMediaFunc;
|
|
||||||
|
|
||||||
bool mMediaFilesUpdated;
|
bool mMediaFilesUpdated;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue