preliminary extra buttons for CommandDialog

This commit is contained in:
thrust26 2019-01-03 09:53:13 +01:00
parent 9e81ad4c13
commit 9a8afd5e7b
2 changed files with 61 additions and 26 deletions

View File

@ -24,6 +24,9 @@
#include "StateManager.hxx" #include "StateManager.hxx"
#include "OSystem.hxx" #include "OSystem.hxx"
#include "Widget.hxx" #include "Widget.hxx"
#include "AudioSettings.hxx"
#include "Sound.hxx"
#include "TIASurface.hxx"
#include "CommandDialog.hxx" #include "CommandDialog.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -34,7 +37,7 @@ CommandDialog::CommandDialog(OSystem& osystem, DialogContainer& parent)
const int VBORDER = 10; const int VBORDER = 10;
const int HGAP = 8; const int HGAP = 8;
const int VGAP = 4; const int VGAP = 4;
const int buttonWidth = _font.getStringWidth("Stella Palette") + 16, const int buttonWidth = _font.getStringWidth("Time Machine On") + 16,
buttonHeight = _font.getLineHeight() + 6, buttonHeight = _font.getLineHeight() + 6,
rowHeight = buttonHeight + VGAP; rowHeight = buttonHeight + VGAP;
@ -77,8 +80,8 @@ CommandDialog::CommandDialog(OSystem& osystem, DialogContainer& parent)
wid.push_back(myLoadStateButton); wid.push_back(myLoadStateButton);
bw = ADD_CD_BUTTON("Snapshot", kSnapshotCmd); bw = ADD_CD_BUTTON("Snapshot", kSnapshotCmd);
wid.push_back(bw); wid.push_back(bw);
bw = ADD_CD_BUTTON("TODO", 0); myTimeMachineButton = ADD_CD_BUTTON("", kTimeMachineCmd);
wid.push_back(bw); wid.push_back(myTimeMachineButton);
bw = ADD_CD_BUTTON("Exit Game", kExitCmd); bw = ADD_CD_BUTTON("Exit Game", kExitCmd);
wid.push_back(bw); wid.push_back(bw);
@ -90,10 +93,10 @@ CommandDialog::CommandDialog(OSystem& osystem, DialogContainer& parent)
wid.push_back(myTVFormatButton); wid.push_back(myTVFormatButton);
myPaletteButton = ADD_CD_BUTTON("", kPaletteCmd); myPaletteButton = ADD_CD_BUTTON("", kPaletteCmd);
wid.push_back(myPaletteButton); wid.push_back(myPaletteButton);
bw = ADD_CD_BUTTON("TODO", 0); myPhosphorButton = ADD_CD_BUTTON("", kPhosphorCmd);
wid.push_back(bw); wid.push_back(myPhosphorButton);
bw = ADD_CD_BUTTON("TODO", 0); mySoundButton = ADD_CD_BUTTON("", kSoundCmd);
wid.push_back(bw); wid.push_back(mySoundButton);
bw = ADD_CD_BUTTON("Reload ROM", kReloadRomCmd); bw = ADD_CD_BUTTON("Reload ROM", kReloadRomCmd);
wid.push_back(bw); wid.push_back(bw);
@ -103,12 +106,15 @@ CommandDialog::CommandDialog(OSystem& osystem, DialogContainer& parent)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CommandDialog::loadConfig() void CommandDialog::loadConfig()
{ {
// Column 1
myColorButton->setLabel(instance().console().switches().tvColor() ? "Color Mode" : "B/W Mode"); myColorButton->setLabel(instance().console().switches().tvColor() ? "Color Mode" : "B/W Mode");
myLeftDiffButton->setLabel(instance().console().switches().leftDifficultyA() ? "Left Diff A" : "Left Diff B"); myLeftDiffButton->setLabel(instance().console().switches().leftDifficultyA() ? "Left Diff A" : "Left Diff B");
myRightDiffButton->setLabel(instance().console().switches().rightDifficultyA() ? "Right Diff A" : "Right Diff B"); myRightDiffButton->setLabel(instance().console().switches().rightDifficultyA() ? "Right Diff A" : "Right Diff B");
// Column 2
updateSlot(instance().state().currentSlot()); updateSlot(instance().state().currentSlot());
myTimeMachineButton->setLabel(instance().state().mode() == StateManager::Mode::TimeMachine ?
"Time Machine On" : "No Time Machine");
// Column 3
myTVFormatButton->setLabel(instance().console().getFormatString() + " Mode"); myTVFormatButton->setLabel(instance().console().getFormatString() + " Mode");
string palette, label; string palette, label;
palette = instance().settings().getString("palette"); palette = instance().settings().getString("palette");
@ -119,6 +125,8 @@ void CommandDialog::loadConfig()
else else
label = "User Palette"; label = "User Palette";
myPaletteButton->setLabel(label); myPaletteButton->setLabel(label);
myPhosphorButton->setLabel(instance().frameBuffer().tiaSurface().phosphorEnabled() ? "Phosphor On" : "Phosphor Off");
mySoundButton->setLabel(instance().audioSettings().enabled() ? "Sound On" : "Sound Off");
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -130,6 +138,7 @@ void CommandDialog::handleCommand(CommandSender* sender, int cmd,
switch(cmd) switch(cmd)
{ {
// Column 1
case kSelectCmd: case kSelectCmd:
event = Event::ConsoleSelect; event = Event::ConsoleSelect;
consoleCmd = true; consoleCmd = true;
@ -155,6 +164,7 @@ void CommandDialog::handleCommand(CommandSender* sender, int cmd,
consoleCmd = true; consoleCmd = true;
break; break;
// Column 2
case kSaveStateCmd: case kSaveStateCmd:
event = Event::SaveState; event = Event::SaveState;
consoleCmd = true; consoleCmd = true;
@ -178,6 +188,16 @@ void CommandDialog::handleCommand(CommandSender* sender, int cmd,
instance().eventHandler().handleEvent(Event::TakeSnapshot, 1); instance().eventHandler().handleEvent(Event::TakeSnapshot, 1);
break; break;
case kTimeMachineCmd:
instance().eventHandler().leaveMenuMode();
instance().state().toggleTimeMachine();
break;
case kExitCmd:
instance().eventHandler().handleEvent(Event::LauncherMode, 1);
break;
// Column 3
case kFormatCmd: case kFormatCmd:
instance().eventHandler().leaveMenuMode(); instance().eventHandler().leaveMenuMode();
instance().console().toggleFormat(); instance().console().toggleFormat();
@ -188,14 +208,23 @@ void CommandDialog::handleCommand(CommandSender* sender, int cmd,
instance().console().togglePalette(); instance().console().togglePalette();
break; break;
case kPhosphorCmd:
instance().eventHandler().leaveMenuMode();
instance().console().togglePhosphor();
break;
case kSoundCmd:
{
instance().eventHandler().leaveMenuMode();
bool enabled = instance().audioSettings().enabled();
instance().audioSettings().setEnabled(!enabled);
instance().console().initializeAudio();
break;
}
case kReloadRomCmd: case kReloadRomCmd:
instance().eventHandler().leaveMenuMode(); instance().eventHandler().leaveMenuMode();
instance().reloadConsole(); instance().reloadConsole();
break; break;
case kExitCmd:
instance().eventHandler().handleEvent(Event::LauncherMode, 1);
break;
} }
// Console commands show be performed right away, after leaving the menu // Console commands show be performed right away, after leaving the menu

View File

@ -44,24 +44,30 @@ class CommandDialog : public Dialog
ButtonWidget* mySaveStateButton; ButtonWidget* mySaveStateButton;
ButtonWidget* myStateSlotButton; ButtonWidget* myStateSlotButton;
ButtonWidget* myLoadStateButton; ButtonWidget* myLoadStateButton;
ButtonWidget* myTimeMachineButton;
// column 2 // column 2
ButtonWidget* myTVFormatButton; ButtonWidget* myTVFormatButton;
ButtonWidget* myPaletteButton; ButtonWidget* myPaletteButton;
ButtonWidget* myPhosphorButton;
ButtonWidget* mySoundButton;
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',
kFormatCmd = 'Cfmt', kTimeMachineCmd = 'Ctim',
kPaletteCmd = 'Cpal', kFormatCmd = 'Cfmt',
kReloadRomCmd = 'Crom', kPaletteCmd = 'Cpal',
kExitCmd = 'Clex' kPhosphorCmd = 'Cpho',
kSoundCmd = 'Csnd',
kReloadRomCmd = 'Crom',
kExitCmd = 'Clex'
}; };
private: private: