mirror of https://github.com/stella-emu/stella.git
make 'Cancel' work in command dialogs
This commit is contained in:
parent
951b13ed97
commit
39d3eefcef
|
@ -101,6 +101,10 @@ CommandDialog::CommandDialog(OSystem& osystem, DialogContainer& parent)
|
|||
wid.push_back(bw);
|
||||
|
||||
addToFocusList(wid);
|
||||
|
||||
// We don't have a close/cancel button, but we still want the cancel
|
||||
// event to be processed
|
||||
processCancelWithoutWidget(true);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -233,6 +237,12 @@ void CommandDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
instance().eventHandler().handleEvent(event);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CommandDialog::processCancel()
|
||||
{
|
||||
instance().eventHandler().leaveMenuMode();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CommandDialog::updateSlot(int slot)
|
||||
{
|
||||
|
|
|
@ -37,6 +37,7 @@ class CommandDialog : public Dialog
|
|||
void updateSlot(int slot);
|
||||
void updateTVFormat();
|
||||
void updatePalette();
|
||||
void processCancel() override;
|
||||
|
||||
// column 0
|
||||
ButtonWidget* myColorButton;
|
||||
|
|
|
@ -722,7 +722,7 @@ bool Dialog::handleNavEvent(Event::Type e)
|
|||
{
|
||||
// Some dialogs want the ability to cancel without actually having
|
||||
// a corresponding cancel button
|
||||
close();
|
||||
processCancel();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -159,6 +159,7 @@ class Dialog : public GuiObject
|
|||
bool focusOKButton = true);
|
||||
|
||||
void processCancelWithoutWidget(bool state) { _processCancel = state; }
|
||||
virtual void processCancel() { close(); }
|
||||
|
||||
/** Define the size (allowed) for the dialog. */
|
||||
void setSize(uInt32 w, uInt32 h, uInt32 max_w, uInt32 max_h);
|
||||
|
|
|
@ -104,6 +104,10 @@ MinUICommandDialog::MinUICommandDialog(OSystem& osystem, DialogContainer& parent
|
|||
wid.push_back(bw);
|
||||
|
||||
addToFocusList(wid);
|
||||
|
||||
// We don't have a close/cancel button, but we still want the cancel
|
||||
// event to be processed
|
||||
processCancelWithoutWidget(true);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -248,6 +252,12 @@ void MinUICommandDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
instance().eventHandler().handleEvent(event);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void MinUICommandDialog::processCancel()
|
||||
{
|
||||
instance().eventHandler().leaveMenuMode();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void MinUICommandDialog::updateSlot(int slot)
|
||||
{
|
||||
|
|
|
@ -30,63 +30,64 @@ class OptionsDialog;
|
|||
class MinUICommandDialog : public Dialog
|
||||
{
|
||||
public:
|
||||
MinUICommandDialog(OSystem& osystem, DialogContainer& parent);
|
||||
virtual ~MinUICommandDialog() = default;
|
||||
MinUICommandDialog(OSystem& osystem, DialogContainer& parent);
|
||||
virtual ~MinUICommandDialog() = default;
|
||||
|
||||
protected:
|
||||
void loadConfig() override;
|
||||
void handleKeyDown(StellaKey key, StellaMod mod) override;
|
||||
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
||||
void updateSlot(int slot);
|
||||
void updateWinds();
|
||||
void updateTVFormat();
|
||||
void openSettings();
|
||||
void loadConfig() override;
|
||||
void handleKeyDown(StellaKey key, StellaMod mod) override;
|
||||
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
||||
void updateSlot(int slot);
|
||||
void updateWinds();
|
||||
void updateTVFormat();
|
||||
void openSettings();
|
||||
void processCancel() override;
|
||||
|
||||
// column 0
|
||||
ButtonWidget* myColorButton;
|
||||
ButtonWidget* myLeftDiffButton;
|
||||
ButtonWidget* myRightDiffButton;
|
||||
// column 1
|
||||
ButtonWidget* mySaveStateButton;
|
||||
ButtonWidget* myStateSlotButton;
|
||||
ButtonWidget* myLoadStateButton;
|
||||
ButtonWidget* myRewindButton;
|
||||
ButtonWidget* myUnwindButton;
|
||||
// column 2
|
||||
ButtonWidget* myTVFormatButton;
|
||||
ButtonWidget* myStretchButton;
|
||||
ButtonWidget* myPhosphorButton;
|
||||
// column 0
|
||||
ButtonWidget* myColorButton;
|
||||
ButtonWidget* myLeftDiffButton;
|
||||
ButtonWidget* myRightDiffButton;
|
||||
// column 1
|
||||
ButtonWidget* mySaveStateButton;
|
||||
ButtonWidget* myStateSlotButton;
|
||||
ButtonWidget* myLoadStateButton;
|
||||
ButtonWidget* myRewindButton;
|
||||
ButtonWidget* myUnwindButton;
|
||||
// column 2
|
||||
ButtonWidget* myTVFormatButton;
|
||||
ButtonWidget* myStretchButton;
|
||||
ButtonWidget* myPhosphorButton;
|
||||
|
||||
unique_ptr<StellaSettingsDialog> myStellaSettingsDialog;
|
||||
unique_ptr<OptionsDialog> myOptionsDialog;
|
||||
unique_ptr<StellaSettingsDialog> myStellaSettingsDialog;
|
||||
unique_ptr<OptionsDialog> myOptionsDialog;
|
||||
|
||||
enum
|
||||
{
|
||||
kSelectCmd = 'Csel',
|
||||
kResetCmd = 'Cres',
|
||||
kColorCmd = 'Ccol',
|
||||
kLeftDiffCmd = 'Cldf',
|
||||
kRightDiffCmd = 'Crdf',
|
||||
kSaveStateCmd = 'Csst',
|
||||
kStateSlotCmd = 'Ccst',
|
||||
kLoadStateCmd = 'Clst',
|
||||
kSnapshotCmd = 'Csnp',
|
||||
kRewindCmd = 'Crew',
|
||||
kUnwindCmd = 'Cunw',
|
||||
kFormatCmd = 'Cfmt',
|
||||
kStretchCmd = 'Cstr',
|
||||
kPhosphorCmd = 'Cpho',
|
||||
kSettings = 'Cscn',
|
||||
kExitGameCmd = 'Cext',
|
||||
};
|
||||
enum
|
||||
{
|
||||
kSelectCmd = 'Csel',
|
||||
kResetCmd = 'Cres',
|
||||
kColorCmd = 'Ccol',
|
||||
kLeftDiffCmd = 'Cldf',
|
||||
kRightDiffCmd = 'Crdf',
|
||||
kSaveStateCmd = 'Csst',
|
||||
kStateSlotCmd = 'Ccst',
|
||||
kLoadStateCmd = 'Clst',
|
||||
kSnapshotCmd = 'Csnp',
|
||||
kRewindCmd = 'Crew',
|
||||
kUnwindCmd = 'Cunw',
|
||||
kFormatCmd = 'Cfmt',
|
||||
kStretchCmd = 'Cstr',
|
||||
kPhosphorCmd = 'Cpho',
|
||||
kSettings = 'Cscn',
|
||||
kExitGameCmd = 'Cext',
|
||||
};
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
MinUICommandDialog() = delete;
|
||||
MinUICommandDialog(const MinUICommandDialog&) = delete;
|
||||
MinUICommandDialog(MinUICommandDialog&&) = delete;
|
||||
MinUICommandDialog& operator=(const MinUICommandDialog&) = delete;
|
||||
MinUICommandDialog& operator=(MinUICommandDialog&&) = delete;
|
||||
// Following constructors and assignment operators not supported
|
||||
MinUICommandDialog() = delete;
|
||||
MinUICommandDialog(const MinUICommandDialog&) = delete;
|
||||
MinUICommandDialog(MinUICommandDialog&&) = delete;
|
||||
MinUICommandDialog& operator=(const MinUICommandDialog&) = delete;
|
||||
MinUICommandDialog& operator=(MinUICommandDialog&&) = delete;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue