mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-26 16:15:39 +00:00
Added a prompt when you try to close GuiMetaDataEd with unsaved changes.
This commit is contained in:
parent
f8355ef8b3
commit
b8ebbc84bb
|
@ -9,7 +9,7 @@ MetaDataDecl gameDecls[] = {
|
|||
{"image", MD_IMAGE_PATH, "", false, "image", "enter path to image"},
|
||||
{"thumbnail", MD_IMAGE_PATH, "", false, "thumbnail", "enter path to thumbnail"},
|
||||
{"rating", MD_RATING, "0", false, "rating", "enter rating"},
|
||||
{"releasedate", MD_DATE, "0", false, "release date", "enter release date"},
|
||||
{"releasedate", MD_DATE, "not-a-date-time", false, "release date", "enter release date"},
|
||||
{"developer", MD_STRING, "unknown", false, "developer", "enter game developer"},
|
||||
{"publisher", MD_STRING, "unknown", false, "publisher", "enter game publisher"},
|
||||
{"genre", MD_STRING, "unknown", false, "genre", "enter game genre"},
|
||||
|
|
|
@ -195,15 +195,41 @@ void GuiMetaDataEd::fetchDone(const ScraperSearchResult& result)
|
|||
}
|
||||
}
|
||||
|
||||
void GuiMetaDataEd::close()
|
||||
{
|
||||
// find out if the user made any changes
|
||||
bool dirty = false;
|
||||
for(unsigned int i = 0; i < mEditors.size(); i++)
|
||||
{
|
||||
const std::string& key = mMetaDataDecl.at(i).key;
|
||||
if(mMetaData->get(key) != mEditors.at(i)->getValue())
|
||||
{
|
||||
dirty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(dirty)
|
||||
{
|
||||
// changes were made, ask if the user wants to save them
|
||||
mWindow->pushGui(new GuiMsgBox(mWindow,
|
||||
"SAVE CHANGES?",
|
||||
"YES", [&] { save(); delete this; },
|
||||
"NO", [&] { delete this; }
|
||||
));
|
||||
}else{
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
bool GuiMetaDataEd::input(InputConfig* config, Input input)
|
||||
{
|
||||
if(GuiComponent::input(config, input))
|
||||
return true;
|
||||
|
||||
if(input.value != 0 && config->isMappedTo("b", input))
|
||||
if(input.value != 0 && (config->isMappedTo("b", input) || config->isMappedTo("start", input)))
|
||||
{
|
||||
delete this;
|
||||
close();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -213,7 +239,7 @@ bool GuiMetaDataEd::input(InputConfig* config, Input input)
|
|||
std::vector<HelpPrompt> GuiMetaDataEd::getHelpPrompts()
|
||||
{
|
||||
std::vector<HelpPrompt> prompts = mGrid.getHelpPrompts();
|
||||
prompts.push_back(HelpPrompt("b", "discard"));
|
||||
prompts.push_back(HelpPrompt("b", "close"));
|
||||
prompts.push_back(HelpPrompt("start", "close"));
|
||||
return prompts;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ private:
|
|||
void save();
|
||||
void fetch();
|
||||
void fetchDone(const ScraperSearchResult& result);
|
||||
void close();
|
||||
|
||||
NinePatchComponent mBackground;
|
||||
ComponentGrid mGrid;
|
||||
|
|
Loading…
Reference in a new issue