Replaced #define'd macros with lambdas where possible. Did I mention

I also love lambdas?

Minor cleanups to other parts of the code (missing virtual, cleanup
d'tors, move methods from public to private, etc).


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3071 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2014-11-10 23:35:24 +00:00
parent 49eadb7463
commit 4544f59b53
27 changed files with 103 additions and 136 deletions

View File

@ -114,18 +114,6 @@ CartDebug::CartDebug(Debugger& dbg, Console& console, const OSystem& osystem)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartDebug::~CartDebug() CartDebug::~CartDebug()
{ {
myUserLabels.clear();
myUserAddresses.clear();
myUserCLabels.clear();
// myUserCAddresses.clear();
mySystemAddresses.clear();
for(uInt32 i = 0; i < myBankInfo.size(); ++i)
{
myBankInfo[i].addressList.clear();
myBankInfo[i].directiveList.clear();
}
myBankInfo.clear();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -62,14 +62,6 @@ DebuggerParser::DebuggerParser(Debugger& d, Settings& s)
{ {
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DebuggerParser::~DebuggerParser()
{
args.clear();
argStrings.clear();
watches.clear();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// main entry point: PromptWidget calls this method. // main entry point: PromptWidget calls this method.
string DebuggerParser::run(const string& command) string DebuggerParser::run(const string& command)

View File

@ -34,7 +34,6 @@ class DebuggerParser
{ {
public: public:
DebuggerParser(Debugger& debugger, Settings& settings); DebuggerParser(Debugger& debugger, Settings& settings);
~DebuggerParser();
/** Run the given command, and return the result */ /** Run the given command, and return the result */
string run(const string& command); string run(const string& command);

View File

@ -51,7 +51,7 @@ class DebuggerDialog : public Dialog
DebuggerDialog(OSystem& osystem, DialogContainer& parent, DebuggerDialog(OSystem& osystem, DialogContainer& parent,
int x, int y, int w, int h); int x, int y, int w, int h);
~DebuggerDialog(); virtual ~DebuggerDialog();
const GUI::Font& lfont() const { return *myLFont; } const GUI::Font& lfont() const { return *myLFont; }
const GUI::Font& nfont() const { return *myNFont; } const GUI::Font& nfont() const { return *myNFont; }

View File

@ -40,17 +40,6 @@
#include "RiotWidget.hxx" #include "RiotWidget.hxx"
#define CREATE_IO_REGS(desc, bits, bitsID, editable) \
t = new StaticTextWidget(boss, lfont, xpos, ypos+2, lwidth, fontHeight,\
desc, kTextAlignLeft); \
xpos += t->getWidth() + 5; \
bits = new ToggleBitWidget(boss, nfont, xpos, ypos, 8, 1); \
bits->setTarget(this); \
bits->setID(bitsID); \
if(editable) addFocusWidget(bits); else bits->setEditable(false); \
xpos += bits->getWidth() + 5; \
bits->setList(off, on);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont, RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont,
const GUI::Font& nfont, const GUI::Font& nfont,
@ -74,6 +63,17 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont,
on.push_back("1"); on.push_back("1");
} }
#define CREATE_IO_REGS(desc, bits, bitsID, editable) \
t = new StaticTextWidget(boss, lfont, xpos, ypos+2, lwidth, fontHeight,\
desc, kTextAlignLeft); \
xpos += t->getWidth() + 5; \
bits = new ToggleBitWidget(boss, nfont, xpos, ypos, 8, 1); \
bits->setTarget(this); \
bits->setID(bitsID); \
if(editable) addFocusWidget(bits); else bits->setEditable(false); \
xpos += bits->getWidth() + 5; \
bits->setList(off, on);
// SWCHA bits in 'poke' mode // SWCHA bits in 'poke' mode
CREATE_IO_REGS("SWCHA(W):", mySWCHAWriteBits, kSWCHABitsID, true); CREATE_IO_REGS("SWCHA(W):", mySWCHAWriteBits, kSWCHABitsID, true);
col = xpos + 20; // remember this for adding widgets to the second column col = xpos + 20; // remember this for adding widgets to the second column

View File

@ -473,10 +473,6 @@ void OSystem::logMessage(const string& message, uInt8 level)
unique_ptr<Console> OSystem::openConsole(const FilesystemNode& romfile, unique_ptr<Console> OSystem::openConsole(const FilesystemNode& romfile,
string& md5, string& type, string& id) string& md5, string& type, string& id)
{ {
#define CMDLINE_PROPS_UPDATE(cl_name, prop_name) \
s = mySettings->getString(cl_name); \
if(s != "") props.set(prop_name, s);
unique_ptr<Console> console; unique_ptr<Console> console;
// Open the cartridge image and read it in // Open the cartridge image and read it in
@ -488,7 +484,13 @@ unique_ptr<Console> OSystem::openConsole(const FilesystemNode& romfile,
// For initial creation of the Cart, we're only concerned with the BS type // For initial creation of the Cart, we're only concerned with the BS type
Properties props; Properties props;
myPropSet->getMD5(md5, props); myPropSet->getMD5(md5, props);
string s;
auto CMDLINE_PROPS_UPDATE = [&](const string& name, PropertyType prop)
{
const string& s = mySettings->getString(name);
if(s != "") props.set(prop, s);
};
CMDLINE_PROPS_UPDATE("bs", Cartridge_Type); CMDLINE_PROPS_UPDATE("bs", Cartridge_Type);
CMDLINE_PROPS_UPDATE("type", Cartridge_Type); CMDLINE_PROPS_UPDATE("type", Cartridge_Type);
@ -518,7 +520,7 @@ unique_ptr<Console> OSystem::openConsole(const FilesystemNode& romfile,
CMDLINE_PROPS_UPDATE("sp", Console_SwapPorts); CMDLINE_PROPS_UPDATE("sp", Console_SwapPorts);
CMDLINE_PROPS_UPDATE("lc", Controller_Left); CMDLINE_PROPS_UPDATE("lc", Controller_Left);
CMDLINE_PROPS_UPDATE("rc", Controller_Right); CMDLINE_PROPS_UPDATE("rc", Controller_Right);
s = mySettings->getString("bc"); const string& s = mySettings->getString("bc");
if(s != "") { props.set(Controller_Left, s); props.set(Controller_Right, s); } if(s != "") { props.set(Controller_Left, s); props.set(Controller_Right, s); }
CMDLINE_PROPS_UPDATE("cp", Controller_SwapPaddles); CMDLINE_PROPS_UPDATE("cp", Controller_SwapPaddles);
CMDLINE_PROPS_UPDATE("ma", Controller_MouseAxis); CMDLINE_PROPS_UPDATE("ma", Controller_MouseAxis);

View File

@ -34,13 +34,6 @@ PropertiesSet::PropertiesSet(const string& propsfile)
load(propsfile); load(propsfile);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertiesSet::~PropertiesSet()
{
myExternalProps.clear();
myTempProps.clear();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PropertiesSet::load(const string& filename) void PropertiesSet::load(const string& filename)
{ {
@ -98,7 +91,7 @@ bool PropertiesSet::getMD5(const string& md5, Properties& properties,
if(!useDefaults) if(!useDefaults)
{ {
// Check external list // Check external list
const auto ext = myExternalProps.find(md5); auto ext = myExternalProps.find(md5);
if(ext != myExternalProps.end()) if(ext != myExternalProps.end())
{ {
properties = ext->second; properties = ext->second;
@ -106,7 +99,7 @@ bool PropertiesSet::getMD5(const string& md5, Properties& properties,
} }
else // Search temp list else // Search temp list
{ {
const auto tmp = myTempProps.find(md5); auto tmp = myTempProps.find(md5);
if(tmp != myTempProps.end()) if(tmp != myTempProps.end())
{ {
properties = tmp->second; properties = tmp->second;

View File

@ -46,11 +46,6 @@ class PropertiesSet
*/ */
PropertiesSet(const string& propsfile); PropertiesSet(const string& propsfile);
/**
Destructor
*/
~PropertiesSet();
public: public:
/** /**
Load properties from the specified file, and create an internal Load properties from the specified file, and create an internal

View File

@ -157,8 +157,6 @@ Settings::Settings(OSystem& osystem)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Settings::~Settings() Settings::~Settings()
{ {
myInternalSettings.clear();
myExternalSettings.clear();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -86,7 +86,6 @@ AboutDialog::AboutDialog(OSystem& osystem, DialogContainer& parent,
AboutDialog::~AboutDialog() AboutDialog::~AboutDialog()
{ {
myDesc.clear(); myDesc.clear();
myDescStr.clear();
} }
// The following commands can be put at the start of a line (all subject to change): // The following commands can be put at the start of a line (all subject to change):
@ -101,10 +100,10 @@ AboutDialog::~AboutDialog()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AboutDialog::updateStrings(int page, int lines, string& title) void AboutDialog::updateStrings(int page, int lines, string& title)
{ {
#define ADD_ATEXT(d) do { myDescStr[i] = d; i++; } while(0)
#define ADD_ALINE ADD_ATEXT("")
int i = 0; int i = 0;
auto ADD_ATEXT = [&](const string& d) { myDescStr[i] = d; i++; };
auto ADD_ALINE = [&]() { ADD_ATEXT(""); };
switch(page) switch(page)
{ {
case 1: case 1:
@ -112,13 +111,13 @@ void AboutDialog::updateStrings(int page, int lines, string& title)
ADD_ATEXT("\\CA multi-platform Atari 2600 VCS emulator"); ADD_ATEXT("\\CA multi-platform Atari 2600 VCS emulator");
ADD_ATEXT(string("\\C\\c2Features: ") + instance().features()); ADD_ATEXT(string("\\C\\c2Features: ") + instance().features());
ADD_ATEXT(string("\\C\\c2") + instance().buildInfo()); ADD_ATEXT(string("\\C\\c2") + instance().buildInfo());
ADD_ALINE; ADD_ALINE();
ADD_ATEXT("\\CCopyright (C) 1995-2014 The Stella Team"); ADD_ATEXT("\\CCopyright (C) 1995-2014 The Stella Team");
ADD_ATEXT("\\C(http://stella.sf.net)"); ADD_ATEXT("\\C(http://stella.sf.net)");
ADD_ALINE; ADD_ALINE();
ADD_ATEXT("\\CStella is now DonationWare!"); ADD_ATEXT("\\CStella is now DonationWare!");
ADD_ATEXT("\\C(http://stella.sf.net/donations.php)"); ADD_ATEXT("\\C(http://stella.sf.net/donations.php)");
ADD_ALINE; ADD_ALINE();
ADD_ATEXT("\\CStella is free software released under the GNU GPL"); ADD_ATEXT("\\CStella is free software released under the GNU GPL");
ADD_ATEXT("\\CSee manual for further details"); ADD_ATEXT("\\CSee manual for further details");
break; break;
@ -139,9 +138,9 @@ void AboutDialog::updateStrings(int page, int lines, string& title)
title = "Contributors"; title = "Contributors";
ADD_ATEXT("\\L\\c0"" See http://stella.sf.net/credits.php for"); ADD_ATEXT("\\L\\c0"" See http://stella.sf.net/credits.php for");
ADD_ATEXT("\\L\\c0"" people that have contributed to Stella"); ADD_ATEXT("\\L\\c0"" people that have contributed to Stella");
ADD_ALINE; ADD_ALINE();
ADD_ATEXT("\\L\\c0"" Thanks to the ScummVM project for the GUI code"); ADD_ATEXT("\\L\\c0"" Thanks to the ScummVM project for the GUI code");
ADD_ALINE; ADD_ALINE();
ADD_ATEXT("\\L\\c0"" Thanks to Ian Bogost and the Georgia Tech"); ADD_ATEXT("\\L\\c0"" Thanks to Ian Bogost and the Georgia Tech");
ADD_ATEXT("\\L\\c0"" Atari Team for the CRT Simulation effects"); ADD_ATEXT("\\L\\c0"" Atari Team for the CRT Simulation effects");
break; break;
@ -151,7 +150,7 @@ void AboutDialog::updateStrings(int page, int lines, string& title)
ADD_ATEXT("\\L\\c0""Special thanks to AtariAge for introducing the"); ADD_ATEXT("\\L\\c0""Special thanks to AtariAge for introducing the");
ADD_ATEXT("\\L\\c0""Atari 2600 to a whole new generation"); ADD_ATEXT("\\L\\c0""Atari 2600 to a whole new generation");
ADD_ATEXT("\\L\\c2"" http://www.atariage.com"); ADD_ATEXT("\\L\\c2"" http://www.atariage.com");
ADD_ALINE; ADD_ALINE();
ADD_ATEXT("\\L\\c0""Finally, a huge thanks to the original Atari 2600"); ADD_ATEXT("\\L\\c0""Finally, a huge thanks to the original Atari 2600");
ADD_ATEXT("\\L\\c0""VCS team for giving us the magic, and to the"); ADD_ATEXT("\\L\\c0""VCS team for giving us the magic, and to the");
ADD_ATEXT("\\L\\c0""homebrew developers for keeping the magic alive"); ADD_ATEXT("\\L\\c0""homebrew developers for keeping the magic alive");
@ -159,7 +158,7 @@ void AboutDialog::updateStrings(int page, int lines, string& title)
} }
while(i < lines) while(i < lines)
ADD_ALINE; ADD_ALINE();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -69,7 +69,6 @@ AudioDialog::AudioDialog(OSystem& osystem, DialogContainer& parent,
ypos += lineHeight + 4; ypos += lineHeight + 4;
// Fragment size // Fragment size
items.clear();
VList::push_back(items, "128 bytes", "128"); VList::push_back(items, "128 bytes", "128");
VList::push_back(items, "256 bytes", "256"); VList::push_back(items, "256 bytes", "256");
VList::push_back(items, "512 bytes", "512"); VList::push_back(items, "512 bytes", "512");

View File

@ -38,12 +38,6 @@ ComboDialog::ComboDialog(GuiObject* boss, const GUI::Font& font,
: Dialog(boss->instance(), boss->parent()), : Dialog(boss->instance(), boss->parent()),
myComboEvent(Event::NoType) myComboEvent(Event::NoType)
{ {
#define ADD_EVENT_POPUP(IDX, LABEL) \
myEvents[IDX] = new PopUpWidget(this, font, xpos, ypos, \
pwidth, lineHeight, combolist, LABEL); \
wid.push_back(myEvents[IDX]); \
ypos += lineHeight + 4;
const int lineHeight = font.getLineHeight(), const int lineHeight = font.getLineHeight(),
fontWidth = font.getMaxCharWidth(), fontWidth = font.getMaxCharWidth(),
fontHeight = font.getFontHeight(), fontHeight = font.getFontHeight(),
@ -68,6 +62,14 @@ ComboDialog::ComboDialog(GuiObject* boss, const GUI::Font& font,
ypos += (lineHeight + 4) + 5; ypos += (lineHeight + 4) + 5;
// Add event popup for 8 events // Add event popup for 8 events
auto ADD_EVENT_POPUP = [&](int idx, const string& label)
{
myEvents[idx] = new PopUpWidget(this, font, xpos, ypos,
pwidth, lineHeight, combolist, label);
wid.push_back(myEvents[idx]);
ypos += lineHeight + 4;
};
xpos = 10; xpos = 10;
ADD_EVENT_POPUP(0, "Event 1: "); ADD_EVENT_POPUP(0, "Event 1: ");
ADD_EVENT_POPUP(1, "Event 2: "); ADD_EVENT_POPUP(1, "Event 2: ");

View File

@ -27,9 +27,6 @@
#include "Widget.hxx" #include "Widget.hxx"
#include "CommandDialog.hxx" #include "CommandDialog.hxx"
#define addCDButton(label, cmd) \
new ButtonWidget(this, font, xoffset, yoffset, buttonWidth, buttonHeight, label, cmd); xoffset += buttonWidth + 6
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CommandDialog::CommandDialog(OSystem& osystem, DialogContainer& parent) CommandDialog::CommandDialog(OSystem& osystem, DialogContainer& parent)
: Dialog(osystem, parent, 0, 0, 16, 16) : Dialog(osystem, parent, 0, 0, 16, 16)
@ -45,42 +42,50 @@ CommandDialog::CommandDialog(OSystem& osystem, DialogContainer& parent)
WidgetArray wid; WidgetArray wid;
ButtonWidget* b[16]; ButtonWidget* b[16];
int xoffset = 10, yoffset = 10;
auto ADD_CD_BUTTON = [&](const string& label, int cmd)
{
ButtonWidget* b = new ButtonWidget(this, font, xoffset, yoffset,
buttonWidth, buttonHeight, label, cmd);
xoffset += buttonWidth + 6;
return b;
};
// Row 1 // Row 1
int xoffset = 10, yoffset = 10; b[0] = ADD_CD_BUTTON("Select", kSelectCmd);
b[0] = addCDButton("Select", kSelectCmd); b[4] = ADD_CD_BUTTON("Left Diff A", kLeftDiffACmd);
b[4] = addCDButton("Left Diff A", kLeftDiffACmd); b[8] = ADD_CD_BUTTON("Save State", kSaveStateCmd);
b[8] = addCDButton("Save State", kSaveStateCmd);
// Row 2 // Row 2
xoffset = 10; yoffset += buttonHeight + 3; xoffset = 10; yoffset += buttonHeight + 3;
b[1] = addCDButton("Reset", kResetCmd); b[1] = ADD_CD_BUTTON("Reset", kResetCmd);
b[5] = addCDButton("Left Diff B", kLeftDiffBCmd); b[5] = ADD_CD_BUTTON("Left Diff B", kLeftDiffBCmd);
b[9] = addCDButton("State Slot", kStateSlotCmd); b[9] = ADD_CD_BUTTON("State Slot", kStateSlotCmd);
// Row 3 // Row 3
xoffset = 10; yoffset += buttonHeight + 3; xoffset = 10; yoffset += buttonHeight + 3;
b[2] = addCDButton("Color TV", kColorCmd); b[2] = ADD_CD_BUTTON("Color TV", kColorCmd);
b[6] = addCDButton("Right Diff A", kRightDiffACmd); b[6] = ADD_CD_BUTTON("Right Diff A", kRightDiffACmd);
b[10] = addCDButton("Load State", kLoadStateCmd); b[10] = ADD_CD_BUTTON("Load State", kLoadStateCmd);
// Row 4 // Row 4
xoffset = 10; yoffset += buttonHeight + 3; xoffset = 10; yoffset += buttonHeight + 3;
b[3] = addCDButton("B/W TV", kBWCmd); b[3] = ADD_CD_BUTTON("B/W TV", kBWCmd);
b[7] = addCDButton("Right Diff B", kRightDiffBCmd); b[7] = ADD_CD_BUTTON("Right Diff B", kRightDiffBCmd);
b[11] = addCDButton("Snapshot", kSnapshotCmd); b[11] = ADD_CD_BUTTON("Snapshot", kSnapshotCmd);
// Row 5 // Row 5
xoffset = 10; yoffset += buttonHeight + 3; xoffset = 10; yoffset += buttonHeight + 3;
b[12] = addCDButton("NTSC/PAL", kFormatCmd); b[12] = ADD_CD_BUTTON("NTSC/PAL", kFormatCmd);
b[13] = addCDButton("Palette", kPaletteCmd); b[13] = ADD_CD_BUTTON("Palette", kPaletteCmd);
b[14] = addCDButton("Reload ROM", kReloadRomCmd); b[14] = ADD_CD_BUTTON("Reload ROM", kReloadRomCmd);
// Row 6 // Row 6
xoffset = 10 + buttonWidth + 6; yoffset += buttonHeight + 3; xoffset = 10 + buttonWidth + 6; yoffset += buttonHeight + 3;
b[15] = addCDButton("Exit Game", kExitCmd); b[15] = ADD_CD_BUTTON("Exit Game", kExitCmd);
for(uInt8 i = 0; i < 16; ++i) for(int i = 0; i < 16; ++i)
wid.push_back(b[i]); wid.push_back(b[i]);
addToFocusList(wid); addToFocusList(wid);

View File

@ -31,7 +31,7 @@ class CommandDialog : public Dialog
{ {
public: public:
CommandDialog(OSystem& osystem, DialogContainer& parent); CommandDialog(OSystem& osystem, DialogContainer& parent);
~CommandDialog(); virtual ~CommandDialog();
protected: protected:
void handleCommand(CommandSender* sender, int cmd, int data, int id); void handleCommand(CommandSender* sender, int cmd, int data, int id);

View File

@ -49,7 +49,6 @@ ContextMenu::ContextMenu(GuiObject* boss, const GUI::Font& font,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ContextMenu::~ContextMenu() ContextMenu::~ContextMenu()
{ {
_entries.clear();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -703,7 +703,6 @@ Dialog::Focus::Focus(Widget* w)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Dialog::Focus::~Focus() Dialog::Focus::~Focus()
{ {
list.clear();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -716,7 +715,6 @@ Dialog::TabFocus::TabFocus(TabWidget* w)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Dialog::TabFocus::~TabFocus() Dialog::TabFocus::~TabFocus()
{ {
focus.clear();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -741,5 +739,5 @@ Widget* Dialog::TabFocus::getNewFocus()
{ {
currentTab = widget->getActiveTab(); currentTab = widget->getActiveTab();
return (currentTab < focus.size()) ? focus[currentTab].widget : 0; return (currentTab < focus.size()) ? focus[currentTab].widget : nullptr;
} }

View File

@ -63,7 +63,6 @@ GameInfoDialog::GameInfoDialog(
addTabWidget(myTab); addTabWidget(myTab);
// 1) Cartridge properties // 1) Cartridge properties
wid.clear();
tabID = myTab->addTab("Cartridge"); tabID = myTab->addTab("Cartridge");
xpos = 10; xpos = 10;

View File

@ -23,7 +23,6 @@
#ifndef GAME_LIST_HXX #ifndef GAME_LIST_HXX
#define GAME_LIST_HXX #define GAME_LIST_HXX
#include <vector>
#include "bspf.hxx" #include "bspf.hxx"
/** /**

View File

@ -56,7 +56,6 @@ GlobalPropsDialog::GlobalPropsDialog(GuiObject* boss, const GUI::Font& font)
// Bankswitch type // Bankswitch type
new StaticTextWidget(this, font, xpos, ypos+1, lwidth, fontHeight, new StaticTextWidget(this, font, xpos, ypos+1, lwidth, fontHeight,
"Bankswitch type:", kTextAlignLeft); "Bankswitch type:", kTextAlignLeft);
items.clear();
for(int i = 0; i < Cartridge::ourNumBSTypes; ++i) for(int i = 0; i < Cartridge::ourNumBSTypes; ++i)
VList::push_back(items, Cartridge::ourBSList[i].desc, Cartridge::ourBSList[i].type); VList::push_back(items, Cartridge::ourBSList[i].desc, Cartridge::ourBSList[i].type);
myBSType = new PopUpWidget(this, font, xpos+lwidth, ypos, myBSType = new PopUpWidget(this, font, xpos+lwidth, ypos,

View File

@ -93,16 +93,20 @@ HelpDialog::~HelpDialog()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void HelpDialog::updateStrings(uInt8 page, uInt8 lines, string& title) void HelpDialog::updateStrings(uInt8 page, uInt8 lines, string& title)
{ {
#define ADD_BIND(k,d) do { myKeyStr[i] = k; myDescStr[i] = d; i++; } while(0)
#define ADD_TEXT(d) ADD_BIND("",d)
#define ADD_LINE ADD_BIND("","")
#ifdef BSPF_MAC_OSX #ifdef BSPF_MAC_OSX
#define ALT_ "Cmd" #define ALT_ "Cmd"
#else #else
#define ALT_ "Alt" #define ALT_ "Alt"
#endif #endif
uInt8 i = 0; int i = 0;
auto ADD_BIND = [&](const string& k, const string& d)
{
myKeyStr[i] = k; myDescStr[i] = d; i++;
};
auto ADD_TEXT = [&](const string& d) { ADD_BIND("", d); };
auto ADD_LINE = [&]() { ADD_BIND("", ""); };
switch(page) switch(page)
{ {
case 1: case 1:
@ -129,7 +133,7 @@ void HelpDialog::updateStrings(uInt8 page, uInt8 lines, string& title)
ADD_BIND("Ctrl f", "Switch between NTSC/PAL/SECAM"); ADD_BIND("Ctrl f", "Switch between NTSC/PAL/SECAM");
ADD_BIND("Ctrl s", "Save game properties"); ADD_BIND("Ctrl s", "Save game properties");
ADD_BIND("", " to a new file"); ADD_BIND("", " to a new file");
ADD_LINE; ADD_LINE();
ADD_BIND("Ctrl 0", "Toggle controller for Mouse"); ADD_BIND("Ctrl 0", "Toggle controller for Mouse");
ADD_BIND("Ctrl 1", "Toggle Stelladaptor left/right"); ADD_BIND("Ctrl 1", "Toggle Stelladaptor left/right");
break; break;
@ -151,7 +155,7 @@ void HelpDialog::updateStrings(uInt8 page, uInt8 lines, string& title)
case 4: case 4:
title = "Developer commands:"; title = "Developer commands:";
ADD_BIND("~", "Enter/exit debugger"); ADD_BIND("~", "Enter/exit debugger");
ADD_LINE; ADD_LINE();
ADD_BIND(ALT_" PgUp", "Increase Display.YStart"); ADD_BIND(ALT_" PgUp", "Increase Display.YStart");
ADD_BIND(ALT_" PgDn", "Decrease Display.YStart"); ADD_BIND(ALT_" PgDn", "Decrease Display.YStart");
ADD_BIND("Ctrl PgUp", "Increase Display.Height"); ADD_BIND("Ctrl PgUp", "Increase Display.Height");
@ -160,7 +164,7 @@ void HelpDialog::updateStrings(uInt8 page, uInt8 lines, string& title)
case 5: case 5:
title = "All other commands:"; title = "All other commands:";
ADD_LINE; ADD_LINE();
ADD_BIND("Remapped Events", ""); ADD_BIND("Remapped Events", "");
ADD_TEXT("Most other commands can be"); ADD_TEXT("Most other commands can be");
ADD_TEXT("remapped. Please consult the"); ADD_TEXT("remapped. Please consult the");
@ -170,7 +174,7 @@ void HelpDialog::updateStrings(uInt8 page, uInt8 lines, string& title)
} }
while(i < lines) while(i < lines)
ADD_LINE; ADD_LINE();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -43,7 +43,6 @@ InputDialog::InputDialog(OSystem& osystem, DialogContainer& parent,
buttonHeight = font.getLineHeight() + 4; buttonHeight = font.getLineHeight() + 4;
const int vBorder = 4; const int vBorder = 4;
int xpos, ypos, tabID; int xpos, ypos, tabID;
WidgetArray wid;
StringList actions; StringList actions;
// Set real dimensions // Set real dimensions
@ -83,7 +82,7 @@ InputDialog::InputDialog(OSystem& osystem, DialogContainer& parent,
myTab->setActiveTab(0); myTab->setActiveTab(0);
// Add Defaults, OK and Cancel buttons // Add Defaults, OK and Cancel buttons
wid.clear(); WidgetArray wid;
ButtonWidget* b; ButtonWidget* b;
b = new ButtonWidget(this, font, 10, _h - buttonHeight - 10, b = new ButtonWidget(this, font, 10, _h - buttonHeight - 10,
buttonWidth, buttonHeight, "Defaults", kDefaultsCmd); buttonWidth, buttonHeight, "Defaults", kDefaultsCmd);
@ -115,7 +114,6 @@ void InputDialog::addDevicePortTab(const GUI::Font& font)
lwidth = font.getStringWidth("Use mouse as a controller: "); lwidth = font.getStringWidth("Use mouse as a controller: ");
pwidth = font.getStringWidth("Analog devices"); pwidth = font.getStringWidth("Analog devices");
items.clear();
VList::push_back(items, "Left / Right", "lr"); VList::push_back(items, "Left / Right", "lr");
VList::push_back(items, "Right / Left", "rl"); VList::push_back(items, "Right / Left", "rl");
mySAPort = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight, items, mySAPort = new PopUpWidget(myTab, font, xpos, ypos, pwidth, lineHeight, items,

View File

@ -58,7 +58,6 @@ InputTextDialog::InputTextDialog(GuiObject* boss, const GUI::Font& lfont,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
InputTextDialog::~InputTextDialog() InputTextDialog::~InputTextDialog()
{ {
myInput.clear();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -42,9 +42,6 @@
#include "bspf.hxx" #include "bspf.hxx"
#define addODButton(label, cmd) \
new ButtonWidget(this, font, xoffset, yoffset, buttonWidth, buttonHeight, label, cmd); yoffset += rowHeight
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent, OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent,
GuiObject* boss, int max_w, int max_h, bool global) GuiObject* boss, int max_w, int max_h, bool global)
@ -63,52 +60,60 @@ OptionsDialog::OptionsDialog(OSystem& osystem, DialogContainer& parent,
WidgetArray wid; WidgetArray wid;
ButtonWidget* b = nullptr; ButtonWidget* b = nullptr;
b = addODButton("Video Settings", kVidCmd); auto ADD_OD_BUTTON = [&](const string& label, int cmd)
{
ButtonWidget* b = new ButtonWidget(this, font, xoffset, yoffset,
buttonWidth, buttonHeight, label, cmd);
yoffset += rowHeight;
return b;
};
b = ADD_OD_BUTTON("Video Settings", kVidCmd);
wid.push_back(b); wid.push_back(b);
b = addODButton("Audio Settings", kAudCmd); b = ADD_OD_BUTTON("Audio Settings", kAudCmd);
#ifndef SOUND_SUPPORT #ifndef SOUND_SUPPORT
b->clearFlags(WIDGET_ENABLED); b->clearFlags(WIDGET_ENABLED);
#endif #endif
wid.push_back(b); wid.push_back(b);
b = addODButton("Input Settings", kInptCmd); b = ADD_OD_BUTTON("Input Settings", kInptCmd);
wid.push_back(b); wid.push_back(b);
b = addODButton("UI Settings", kUsrIfaceCmd); b = ADD_OD_BUTTON("UI Settings", kUsrIfaceCmd);
wid.push_back(b); wid.push_back(b);
b = addODButton("Snapshot Settings", kSnapCmd); b = ADD_OD_BUTTON("Snapshot Settings", kSnapCmd);
wid.push_back(b); wid.push_back(b);
b = addODButton("Config Paths", kCfgPathsCmd); b = ADD_OD_BUTTON("Config Paths", kCfgPathsCmd);
wid.push_back(b); wid.push_back(b);
myRomAuditButton = addODButton("Audit ROMs", kAuditCmd); myRomAuditButton = ADD_OD_BUTTON("Audit ROMs", kAuditCmd);
wid.push_back(myRomAuditButton); wid.push_back(myRomAuditButton);
// Move to second column // Move to second column
xoffset += buttonWidth + 10; yoffset = 10; xoffset += buttonWidth + 10; yoffset = 10;
myGameInfoButton = addODButton("Game Properties", kInfoCmd); myGameInfoButton = ADD_OD_BUTTON("Game Properties", kInfoCmd);
wid.push_back(myGameInfoButton); wid.push_back(myGameInfoButton);
myCheatCodeButton = addODButton("Cheat Code", kCheatCmd); myCheatCodeButton = ADD_OD_BUTTON("Cheat Code", kCheatCmd);
#ifndef CHEATCODE_SUPPORT #ifndef CHEATCODE_SUPPORT
myCheatCodeButton->clearFlags(WIDGET_ENABLED); myCheatCodeButton->clearFlags(WIDGET_ENABLED);
#endif #endif
wid.push_back(myCheatCodeButton); wid.push_back(myCheatCodeButton);
b = addODButton("System Logs", kLoggerCmd); b = ADD_OD_BUTTON("System Logs", kLoggerCmd);
wid.push_back(b); wid.push_back(b);
b = addODButton("Help", kHelpCmd); b = ADD_OD_BUTTON("Help", kHelpCmd);
wid.push_back(b); wid.push_back(b);
b = addODButton("About", kAboutCmd); b = ADD_OD_BUTTON("About", kAboutCmd);
wid.push_back(b); wid.push_back(b);
b = addODButton("Exit Menu", kExitCmd); b = ADD_OD_BUTTON("Exit Menu", kExitCmd);
wid.push_back(b); wid.push_back(b);
addCancelWidget(b); addCancelWidget(b);

View File

@ -39,13 +39,12 @@ class RomAuditDialog : public Dialog
const GUI::Font& font, int max_w, int max_h); const GUI::Font& font, int max_w, int max_h);
virtual ~RomAuditDialog(); virtual ~RomAuditDialog();
void handleCommand(CommandSender* sender, int cmd, int data, int id);
private: private:
void loadConfig(); void loadConfig();
void auditRoms(); void auditRoms();
void openBrowser(const string& title, const string& startpath, void openBrowser(const string& title, const string& startpath,
FilesystemNode::ListMode mode, int cmd); FilesystemNode::ListMode mode, int cmd);
void handleCommand(CommandSender* sender, int cmd, int data, int id);
private: private:
enum { enum {

View File

@ -40,7 +40,6 @@ RomInfoWidget::RomInfoWidget(GuiObject* boss, const GUI::Font& font,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RomInfoWidget::~RomInfoWidget() RomInfoWidget::~RomInfoWidget()
{ {
myRomInfo.clear();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -65,7 +65,6 @@ UIDialog::UIDialog(OSystem& osystem, DialogContainer& parent,
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
// 1) Launcher options // 1) Launcher options
wid.clear();
tabID = myTab->addTab(" Launcher "); tabID = myTab->addTab(" Launcher ");
lwidth = font.getStringWidth("Exit to Launcher: "); lwidth = font.getStringWidth("Exit to Launcher: ");

View File

@ -63,7 +63,6 @@ VideoDialog::VideoDialog(OSystem& osystem, DialogContainer& parent,
////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////
// 1) General options // 1) General options
wid.clear();
tabID = myTab->addTab(" General "); tabID = myTab->addTab(" General ");
// Video renderer // Video renderer
@ -74,7 +73,6 @@ VideoDialog::VideoDialog(OSystem& osystem, DialogContainer& parent,
ypos += lineHeight + 4; ypos += lineHeight + 4;
// TIA filters (will be dynamically filled later) // TIA filters (will be dynamically filled later)
items.clear();
myTIAZoom = new PopUpWidget(myTab, font, xpos, ypos, pwidth, myTIAZoom = new PopUpWidget(myTab, font, xpos, ypos, pwidth,
lineHeight, items, "TIA Zoom: ", lwidth); lineHeight, items, "TIA Zoom: ", lwidth);
wid.push_back(myTIAZoom); wid.push_back(myTIAZoom);