added confirm dialog when erasing the whole EEPROM

This commit is contained in:
thrust26 2017-10-05 08:26:11 +02:00
parent 9fc8b9fcc0
commit e2844f566f
2 changed files with 37 additions and 7 deletions

View File

@ -36,7 +36,11 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
InputDialog::InputDialog(OSystem& osystem, DialogContainer& parent,
const GUI::Font& font, int max_w, int max_h)
: Dialog(osystem, parent)
: Dialog(osystem, parent),
myConfirmMsg(nullptr),
myMaxWidth(max_w),
myMaxHeight(max_h)
{
const int lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth(),
@ -519,6 +523,24 @@ void InputDialog::handleCommand(CommandSender* sender, int cmd,
break;
case kEEButtonPressed:
if(!myConfirmMsg)
{
StringList msg;
msg.push_back("This operation cannot be undone.");
msg.push_back("All data stored on your AtariVox");
msg.push_back("or SaveKey will be erased!");
msg.push_back("");
msg.push_back("If you are sure you want to erase");
msg.push_back("the data, click 'OK', otherwise ");
msg.push_back("click 'Cancel'.");
myConfirmMsg = make_unique<GUI::MessageBox>
(this, instance().frameBuffer().font(), msg,
myMaxWidth, myMaxHeight, kConfirmEEEraseCmd);
}
myConfirmMsg->show();
break;
case kConfirmEEEraseCmd:
eraseEEPROM();
break;

View File

@ -30,6 +30,7 @@ class StaticTextWidget;
#include "Dialog.hxx"
#include "JoystickDialog.hxx"
#include "MessageBox.hxx"
#include "bspf.hxx"
class InputDialog : public Dialog
@ -56,12 +57,13 @@ class InputDialog : public Dialog
private:
enum {
kDeadzoneChanged = 'DZch',
kDPSpeedChanged = 'PDch',
kMPSpeedChanged = 'PMch',
kTBSpeedChanged = 'TBch',
kDBButtonPressed = 'DBbp',
kEEButtonPressed = 'EEbp'
kDeadzoneChanged = 'DZch',
kDPSpeedChanged = 'PDch',
kMPSpeedChanged = 'PMch',
kTBSpeedChanged = 'TBch',
kDBButtonPressed = 'DBbp',
kEEButtonPressed = 'EEbp',
kConfirmEEEraseCmd = 'EEcf'
};
TabWidget* myTab;
@ -93,6 +95,12 @@ class InputDialog : public Dialog
// Show the list of joysticks that the eventhandler knows about
unique_ptr<JoystickDialog> myJoyDialog;
// Show a message about the dangers of using this function
unique_ptr<GUI::MessageBox> myConfirmMsg;
// Maximum width and height for this dialog
int myMaxWidth, myMaxHeight;
private:
// Following constructors and assignment operators not supported
InputDialog() = delete;