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