mirror of https://github.com/stella-emu/stella.git
More conversions from normal for to range-based for. Yes, I really love
range-based for that much. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3070 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
e352b3a6bb
commit
49eadb7463
|
@ -50,10 +50,8 @@ class Cheat
|
||||||
static uInt16 unhex(const string& hex)
|
static uInt16 unhex(const string& hex)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
for(char c: hex)
|
||||||
for(unsigned int i = 0; i < hex.size(); ++i) {
|
{
|
||||||
char c = hex[i];
|
|
||||||
|
|
||||||
ret *= 16;
|
ret *= 16;
|
||||||
if(c >= '0' && c <= '9')
|
if(c >= '0' && c <= '9')
|
||||||
ret += c - '0';
|
ret += c - '0';
|
||||||
|
|
|
@ -111,10 +111,10 @@ void CheatCodeDialog::loadConfig()
|
||||||
BoolArray b;
|
BoolArray b;
|
||||||
|
|
||||||
const CheatList& list = instance().cheat().list();
|
const CheatList& list = instance().cheat().list();
|
||||||
for(unsigned int i = 0; i < list.size(); ++i)
|
for(const auto& c: list)
|
||||||
{
|
{
|
||||||
l.push_back(list[i]->name());
|
l.push_back(c->name());
|
||||||
b.push_back(bool(list[i]->enabled()));
|
b.push_back(bool(c->enabled()));
|
||||||
}
|
}
|
||||||
myCheatList->setList(l, b);
|
myCheatList->setList(l, b);
|
||||||
|
|
||||||
|
|
|
@ -892,9 +892,8 @@ string PromptWidget::getCompletionPrefix(const StringList& completions, string p
|
||||||
// of the strings we're dealing with, it's probably not worth it
|
// of the strings we're dealing with, it's probably not worth it
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
for(uInt32 i = 0; i < completions.size(); ++i)
|
for(const auto& s: completions)
|
||||||
{
|
{
|
||||||
const string& s = completions[i];
|
|
||||||
if(s.length() < prefix.length())
|
if(s.length() < prefix.length())
|
||||||
return prefix; // current prefix is the best we're going to get
|
return prefix; // current prefix is the best we're going to get
|
||||||
else if(!BSPF_startsWithIgnoreCase(s, prefix))
|
else if(!BSPF_startsWithIgnoreCase(s, prefix))
|
||||||
|
|
|
@ -504,9 +504,9 @@ void Settings::saveConfig()
|
||||||
// Do a quick scan of the internal settings to see if any have
|
// Do a quick scan of the internal settings to see if any have
|
||||||
// changed. If not, we don't need to save them at all.
|
// changed. If not, we don't need to save them at all.
|
||||||
bool settingsChanged = false;
|
bool settingsChanged = false;
|
||||||
for(unsigned int i = 0; i < myInternalSettings.size(); ++i)
|
for(const auto& s: myInternalSettings)
|
||||||
{
|
{
|
||||||
if(myInternalSettings[i].value != myInternalSettings[i].initialValue)
|
if(s.value != s.initialValue)
|
||||||
{
|
{
|
||||||
settingsChanged = true;
|
settingsChanged = true;
|
||||||
break;
|
break;
|
||||||
|
@ -539,11 +539,8 @@ void Settings::saveConfig()
|
||||||
<< ";" << endl;
|
<< ";" << endl;
|
||||||
|
|
||||||
// Write out each of the key and value pairs
|
// Write out each of the key and value pairs
|
||||||
for(unsigned int i = 0; i < myInternalSettings.size(); ++i)
|
for(const auto& s: myInternalSettings)
|
||||||
{
|
out << s.key << " = " << s.value << endl;
|
||||||
out << myInternalSettings[i].key << " = " <<
|
|
||||||
myInternalSettings[i].value << endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,8 +59,8 @@ ComboDialog::ComboDialog(GuiObject* boss, const GUI::Font& font,
|
||||||
|
|
||||||
// Get maximum width of popupwidget
|
// Get maximum width of popupwidget
|
||||||
int pwidth = 0;
|
int pwidth = 0;
|
||||||
for(uInt32 i = 0; i < combolist.size(); ++i)
|
for(const auto& s: combolist)
|
||||||
pwidth = BSPF_max(font.getStringWidth(combolist[i].first), pwidth);
|
pwidth = BSPF_max(font.getStringWidth(s.first), pwidth);
|
||||||
|
|
||||||
// Label for dialog, indicating which combo is being changed
|
// Label for dialog, indicating which combo is being changed
|
||||||
myComboName = new StaticTextWidget(this, font, xpos, ypos, _w - xpos - 10,
|
myComboName = new StaticTextWidget(this, font, xpos, ypos, _w - xpos - 10,
|
||||||
|
|
|
@ -60,12 +60,8 @@ void ContextMenu::addItems(const VariantList& items)
|
||||||
|
|
||||||
// Resize to largest string
|
// Resize to largest string
|
||||||
int maxwidth = 0;
|
int maxwidth = 0;
|
||||||
for(unsigned int i = 0; i < _entries.size(); ++i)
|
for(const auto& e: _entries)
|
||||||
{
|
maxwidth = BSPF_max(maxwidth, _font.getStringWidth(e.first));
|
||||||
int length = _font.getStringWidth(_entries[i].first);
|
|
||||||
if(length > maxwidth)
|
|
||||||
maxwidth = length;
|
|
||||||
}
|
|
||||||
|
|
||||||
_x = _y = 0;
|
_x = _y = 0;
|
||||||
_w = maxwidth + 10;
|
_w = maxwidth + 10;
|
||||||
|
|
|
@ -145,8 +145,8 @@ void Dialog::addFocusWidget(Widget* w)
|
||||||
void Dialog::addToFocusList(WidgetArray& list)
|
void Dialog::addToFocusList(WidgetArray& list)
|
||||||
{
|
{
|
||||||
// All focusable widgets should retain focus
|
// All focusable widgets should retain focus
|
||||||
for(uInt32 i = 0; i < list.size(); ++i)
|
for(const auto& w: list)
|
||||||
list[i]->setFlags(WIDGET_RETAIN_FOCUS);
|
w->setFlags(WIDGET_RETAIN_FOCUS);
|
||||||
|
|
||||||
Vec::append(_myFocus.list, list);
|
Vec::append(_myFocus.list, list);
|
||||||
_focusList = _myFocus.list;
|
_focusList = _myFocus.list;
|
||||||
|
@ -165,8 +165,8 @@ void Dialog::addToFocusList(WidgetArray& list, TabWidget* w, int tabId)
|
||||||
assert(w == _myTabList[w->getID()].widget);
|
assert(w == _myTabList[w->getID()].widget);
|
||||||
|
|
||||||
// All focusable widgets should retain focus
|
// All focusable widgets should retain focus
|
||||||
for(uInt32 i = 0; i < list.size(); ++i)
|
for(const auto& w: list)
|
||||||
list[i]->setFlags(WIDGET_RETAIN_FOCUS);
|
w->setFlags(WIDGET_RETAIN_FOCUS);
|
||||||
|
|
||||||
// First get the appropriate focus list
|
// First get the appropriate focus list
|
||||||
FocusList& focus = _myTabList[w->getID()].focus;
|
FocusList& focus = _myTabList[w->getID()].focus;
|
||||||
|
|
|
@ -63,22 +63,22 @@ void FileListWidget::setLocation(const FilesystemNode& node, string select)
|
||||||
_gameList.appendGame(" [..]", _node.getParent().getPath(), "", true);
|
_gameList.appendGame(" [..]", _node.getParent().getPath(), "", true);
|
||||||
|
|
||||||
// Now add the directory entries
|
// Now add the directory entries
|
||||||
for(unsigned int idx = 0; idx < content.size(); idx++)
|
for(const auto& file: content)
|
||||||
{
|
{
|
||||||
string name = content[idx].getName();
|
string name = file.getName();
|
||||||
bool isDir = content[idx].isDirectory();
|
bool isDir = file.isDirectory();
|
||||||
if(isDir)
|
if(isDir)
|
||||||
name = " [" + name + "]";
|
name = " [" + name + "]";
|
||||||
else if(!BSPF_endsWithIgnoreCase(name, _extension))
|
else if(!BSPF_endsWithIgnoreCase(name, _extension))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
_gameList.appendGame(name, content[idx].getPath(), "", isDir);
|
_gameList.appendGame(name, file.getPath(), "", isDir);
|
||||||
}
|
}
|
||||||
_gameList.sortByName();
|
_gameList.sortByName();
|
||||||
|
|
||||||
// Now fill the list widget with the contents of the GameList
|
// Now fill the list widget with the contents of the GameList
|
||||||
StringList l;
|
StringList l;
|
||||||
for (int i = 0; i < (int) _gameList.size(); ++i)
|
for(int i = 0; i < (int) _gameList.size(); ++i)
|
||||||
l.push_back(_gameList.name(i));
|
l.push_back(_gameList.name(i));
|
||||||
|
|
||||||
setList(l);
|
setList(l);
|
||||||
|
|
|
@ -57,9 +57,8 @@ int Font::getStringWidth(const string& str) const
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int space = 0;
|
int space = 0;
|
||||||
|
for(auto c: str)
|
||||||
for(unsigned int i = 0; i < str.size(); ++i)
|
space += getCharWidth(c);
|
||||||
space += getCharWidth(str[i]);
|
|
||||||
|
|
||||||
return space;
|
return space;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ GameList::GameList()
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
GameList::~GameList()
|
GameList::~GameList()
|
||||||
{
|
{
|
||||||
clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
|
@ -307,11 +307,10 @@ void LauncherDialog::loadDirListing()
|
||||||
|
|
||||||
// Now add the directory entries
|
// Now add the directory entries
|
||||||
bool domatch = myPattern && myPattern->getText() != "";
|
bool domatch = myPattern && myPattern->getText() != "";
|
||||||
for(unsigned int idx = 0; idx < files.size(); idx++)
|
for(const auto& f: files)
|
||||||
{
|
{
|
||||||
bool isDir = files[idx].isDirectory();
|
bool isDir = f.isDirectory();
|
||||||
const string& name = isDir ? (" [" + files[idx].getName() + "]")
|
const string& name = isDir ? (" [" + f.getName() + "]") : f.getName();
|
||||||
: files[idx].getName();
|
|
||||||
|
|
||||||
// Honour the filtering settings
|
// Honour the filtering settings
|
||||||
// Showing only certain ROM extensions is determined by the extension
|
// Showing only certain ROM extensions is determined by the extension
|
||||||
|
@ -328,7 +327,7 @@ void LauncherDialog::loadDirListing()
|
||||||
if(domatch && !isDir && !matchPattern(name, myPattern->getText()))
|
if(domatch && !isDir && !matchPattern(name, myPattern->getText()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
myGameList->appendGame(name, files[idx].getPath(), "", isDir);
|
myGameList->appendGame(name, f.getPath(), "", isDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the list by rom name (since that's what we see in the listview)
|
// Sort the list by rom name (since that's what we see in the listview)
|
||||||
|
|
|
@ -130,8 +130,8 @@ bool LauncherFilterDialog::isValidRomName(const string& name,
|
||||||
{
|
{
|
||||||
const char* ext = name.c_str() + idx + 1;
|
const char* ext = name.c_str() + idx + 1;
|
||||||
|
|
||||||
for(uInt32 i = 0; i < exts.size(); ++i)
|
for(const auto& s: exts)
|
||||||
if(BSPF_equalsIgnoreCase(ext, exts[i]))
|
if(BSPF_equalsIgnoreCase(ext, s))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,16 +73,16 @@ void MessageBox::addText(const GUI::Font& font, const StringList& text)
|
||||||
|
|
||||||
// Set real dimensions
|
// Set real dimensions
|
||||||
int str_w = 0;
|
int str_w = 0;
|
||||||
for(uInt32 i = 0; i < text.size(); ++i)
|
for(const auto& s: text)
|
||||||
str_w = BSPF_max((int)text[i].length(), str_w);
|
str_w = BSPF_max((int)s.length(), str_w);
|
||||||
_w = BSPF_min(str_w * fontWidth + 20, _w);
|
_w = BSPF_min(str_w * fontWidth + 20, _w);
|
||||||
_h = BSPF_min((uInt32)((text.size() + 2) * lineHeight + 20), (uInt32)_h);
|
_h = BSPF_min((uInt32)((text.size() + 2) * lineHeight + 20), (uInt32)_h);
|
||||||
|
|
||||||
xpos = 10; ypos = 10;
|
xpos = 10; ypos = 10;
|
||||||
for(uInt32 i = 0; i < text.size(); ++i)
|
for(const auto& s: text)
|
||||||
{
|
{
|
||||||
new StaticTextWidget(this, font, xpos, ypos, _w - 20,
|
new StaticTextWidget(this, font, xpos, ypos, _w - 20,
|
||||||
fontHeight, text[i], kTextAlignLeft);
|
fontHeight, s, kTextAlignLeft);
|
||||||
ypos += fontHeight;
|
ypos += fontHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,9 +37,9 @@ struct Point
|
||||||
int x; //!< The horizontal part of the point
|
int x; //!< The horizontal part of the point
|
||||||
int y; //!< The vertical part of the point
|
int y; //!< The vertical part of the point
|
||||||
|
|
||||||
Point() : x(0), y(0) {};
|
Point() : x(0), y(0) { };
|
||||||
Point(const Point& p) : x(p.x), y(p.y) {};
|
Point(const Point& p) : x(p.x), y(p.y) { };
|
||||||
explicit Point(int x1, int y1) : x(x1), y(y1) {};
|
explicit Point(int x1, int y1) : x(x1), y(y1) { };
|
||||||
Point(const string& p) {
|
Point(const string& p) {
|
||||||
char c = '\0';
|
char c = '\0';
|
||||||
x = y = -1;
|
x = y = -1;
|
||||||
|
@ -48,7 +48,7 @@ struct Point
|
||||||
if(c != 'x')
|
if(c != 'x')
|
||||||
x = y = 0;
|
x = y = 0;
|
||||||
}
|
}
|
||||||
Point & operator=(const Point & p) { x = p.x; y = p.y; return *this; };
|
Point& operator=(const Point & p) { x = p.x; y = p.y; return *this; };
|
||||||
bool operator==(const Point & p) const { return x == p.x && y == p.y; };
|
bool operator==(const Point & p) const { return x == p.x && y == p.y; };
|
||||||
bool operator!=(const Point & p) const { return x != p.x || y != p.y; };
|
bool operator!=(const Point & p) const { return x != p.x || y != p.y; };
|
||||||
|
|
||||||
|
@ -63,9 +63,9 @@ struct Size
|
||||||
uInt32 w; //!< The width part of the size
|
uInt32 w; //!< The width part of the size
|
||||||
uInt32 h; //!< The height part of the size
|
uInt32 h; //!< The height part of the size
|
||||||
|
|
||||||
Size() : w(0), h(0) {};
|
Size() : w(0), h(0) { };
|
||||||
Size(const Size& s) : w(s.w), h(s.h) {};
|
Size(const Size& s) : w(s.w), h(s.h) { };
|
||||||
explicit Size(uInt32 w1, uInt32 h1) : w(w1), h(h1) {};
|
explicit Size(uInt32 w1, uInt32 h1) : w(w1), h(h1) { };
|
||||||
Size(const string& s) {
|
Size(const string& s) {
|
||||||
char c = '\0';
|
char c = '\0';
|
||||||
w = h = 0;
|
w = h = 0;
|
||||||
|
@ -112,10 +112,10 @@ struct Rect
|
||||||
uInt32 top, left; //!< The point at the top left of the rectangle (part of the rect).
|
uInt32 top, left; //!< The point at the top left of the rectangle (part of the rect).
|
||||||
uInt32 bottom, right; //!< The point at the bottom right of the rectangle (not part of the rect).
|
uInt32 bottom, right; //!< The point at the bottom right of the rectangle (not part of the rect).
|
||||||
|
|
||||||
Rect() : top(0), left(0), bottom(0), right(0) {}
|
Rect() : top(0), left(0), bottom(0), right(0) { }
|
||||||
Rect(const Rect& s) : top(s.top), left(s.left), bottom(s.bottom), right(s.right) {}
|
Rect(const Rect& s) : top(s.top), left(s.left), bottom(s.bottom), right(s.right) { }
|
||||||
Rect(uInt32 w, uInt32 h) : top(0), left(0), bottom(h), right(w) {}
|
Rect(uInt32 w, uInt32 h) : top(0), left(0), bottom(h), right(w) { }
|
||||||
Rect(const Point& p, uInt32 w, uInt32 h) : top(p.y), left(p.x), bottom(h), right(w) {}
|
Rect(const Point& p, uInt32 w, uInt32 h) : top(p.y), left(p.x), bottom(h), right(w) { }
|
||||||
Rect(uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2) : top(y1), left(x1), bottom(y2), right(x2)
|
Rect(uInt32 x1, uInt32 y1, uInt32 x2, uInt32 y2) : top(y1), left(x1), bottom(y2), right(x2)
|
||||||
{
|
{
|
||||||
assert(valid());
|
assert(valid());
|
||||||
|
|
|
@ -169,9 +169,9 @@ void RomInfoWidget::drawWidget(bool hilite)
|
||||||
}
|
}
|
||||||
|
|
||||||
int xpos = _x + 5, ypos = _y + yoff + 10;
|
int xpos = _x + 5, ypos = _y + yoff + 10;
|
||||||
for(unsigned int i = 0; i < myRomInfo.size(); ++i)
|
for(const auto& info: myRomInfo)
|
||||||
{
|
{
|
||||||
s.drawString(_font, myRomInfo[i], xpos, ypos, _w - 10, _textcolor);
|
s.drawString(_font, info, xpos, ypos, _w - 10, _textcolor);
|
||||||
ypos += _font.getLineHeight();
|
ypos += _font.getLineHeight();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,10 +50,10 @@ TabWidget::TabWidget(GuiObject* boss, const GUI::Font& font,
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
TabWidget::~TabWidget()
|
TabWidget::~TabWidget()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < _tabs.size(); ++i)
|
for(auto& tab: _tabs)
|
||||||
{
|
{
|
||||||
delete _tabs[i].firstWidget;
|
delete tab.firstWidget;
|
||||||
_tabs[i].firstWidget = 0;
|
tab.firstWidget = nullptr;
|
||||||
// _tabs[i].parentWidget is deleted elsewhere
|
// _tabs[i].parentWidget is deleted elsewhere
|
||||||
}
|
}
|
||||||
_tabs.clear();
|
_tabs.clear();
|
||||||
|
|
|
@ -192,8 +192,8 @@ bool Widget::isWidgetInChain(Widget* w, Widget* find)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool Widget::isWidgetInChain(WidgetArray& list, Widget* find)
|
bool Widget::isWidgetInChain(WidgetArray& list, Widget* find)
|
||||||
{
|
{
|
||||||
for(int i = 0; i < (int)list.size(); ++i)
|
for(const auto& w: list)
|
||||||
if(list[i] == find)
|
if(w == find)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -56,9 +56,8 @@ void SettingsMACOSX::loadConfig()
|
||||||
void SettingsMACOSX::saveConfig()
|
void SettingsMACOSX::saveConfig()
|
||||||
{
|
{
|
||||||
// Write out each of the key and value pairs
|
// Write out each of the key and value pairs
|
||||||
const SettingsArray& settings = getInternalSettings();
|
for(const auto& s: getInternalSettings())
|
||||||
for(unsigned int i = 0; i < settings.size(); ++i)
|
prefsSetString(s.key.c_str(), s.value.toCString());
|
||||||
prefsSetString(settings[i].key.c_str(), settings[i].value.toCString());
|
|
||||||
|
|
||||||
prefsSave();
|
prefsSave();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue