Skip to content

Commit 01146ee

Browse files
committed
Improve gui_boot.cpp readability for c++14
1 parent 6beda82 commit 01146ee

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

client/gui/gui_boot.cpp

+20-21
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ typedef std::vector<scannedIWAD_t> scannedIWADs_t;
5656
typedef std::vector<scannedPWAD_t> scannedPWADs_t;
5757
typedef std::vector<scannedPWAD_t*> scannedPWADPtrs_t;
5858

59+
// display strings for options tab and their corresponding command line arguments
60+
const std::vector<std::pair<std::string, std::string> > OPTIONS_LIST = {
61+
{"No Monsters", "-nomonsters"},
62+
{"Fast Monsters", "-fast"},
63+
{"Respawn Monsters", "-respawn"},
64+
{"Pistol Start", "-pistolstart"}
65+
};
66+
5967
/**
6068
* @brief Find the PWAD pointer in the scanned WAD array.
6169
*/
@@ -115,17 +123,11 @@ class BootWindow : public Fl_Window
115123
Fl_Check_Browser* m_gameOptionsBrowser;
116124
StringTokens m_WADDirs;
117125
Fl_Hold_Browser* m_WADDirList;
118-
// display strings for options tab and their corresponding command line arguments
119-
std::vector<std::pair<std::string, std::string> > OPTIONS_LIST;
120126

121127
public:
122128
BootWindow(int X, int Y, int W, int H, const char* L)
123129
: Fl_Window(X, Y, W, H, L), m_IWADs()
124130
{
125-
OPTIONS_LIST.push_back(std::make_pair("No Monsters", "-nomonsters"));
126-
OPTIONS_LIST.push_back(std::make_pair("Fast Monsters", "-fast"));
127-
OPTIONS_LIST.push_back(std::make_pair("Respawn Monsters", "-respawn"));
128-
OPTIONS_LIST.push_back(std::make_pair("Pistol Start", "-pistolstart"));
129131
{
130132
Fl_Tabs* tabs = new Fl_Tabs(0, 0, 425, 200);
131133
{
@@ -185,10 +187,9 @@ class BootWindow : public Fl_Window
185187
} // Fl_Box* o
186188
{
187189
m_gameOptionsBrowser = new Fl_Check_Browser(10, 65, 405, 125);
188-
for (std::vector<std::pair<std::string, std::string> >::const_iterator it = OPTIONS_LIST.begin();
189-
it != OPTIONS_LIST.end(); ++it)
190+
for (const auto& option : OPTIONS_LIST)
190191
{
191-
m_gameOptionsBrowser->add((*it).first.c_str());
192+
m_gameOptionsBrowser->add(option.first.c_str());
192193
}
193194
}
194195
tabGameOptions->end();
@@ -437,9 +438,9 @@ class BootWindow : public Fl_Window
437438
{
438439
m_IWADBrowser->clear();
439440
m_IWADs = M_ScanIWADs();
440-
for (size_t i = 0; i < m_IWADs.size(); i++)
441+
for (const auto& iwad : m_IWADs)
441442
{
442-
m_IWADBrowser->add(m_IWADs[i].id->mNiceName.c_str(), (void*)m_IWADs[i].id);
443+
m_IWADBrowser->add(iwad.id->mNiceName.c_str(), (void*)iwad.id);
443444
}
444445
m_genWaddirs = ::waddirs.str();
445446
}
@@ -448,9 +449,9 @@ class BootWindow : public Fl_Window
448449
{
449450
m_PWADSelectBrowser->clear();
450451
m_PWADs = M_ScanPWADs();
451-
for (scannedPWADs_t::iterator it = m_PWADs.begin(); it != m_PWADs.end(); ++it)
452+
for (const auto& pwad : m_PWADs)
452453
{
453-
m_PWADSelectBrowser->add(it->filename.c_str());
454+
m_PWADSelectBrowser->add(pwad.filename.c_str());
454455
}
455456
m_genWaddirs = ::waddirs.str();
456457

@@ -491,10 +492,9 @@ class BootWindow : public Fl_Window
491492
{
492493
const int val = m_PWADOrderBrowser->value();
493494
m_PWADOrderBrowser->clear();
494-
for (scannedPWADPtrs_t::iterator it = m_selectedPWADs.begin();
495-
it != m_selectedPWADs.end(); ++it)
495+
for (const auto& pwad : m_selectedPWADs)
496496
{
497-
m_PWADOrderBrowser->add((*it)->filename.c_str());
497+
m_PWADOrderBrowser->add(pwad->filename.c_str());
498498
}
499499
m_PWADOrderBrowser->value(val);
500500
}
@@ -520,10 +520,9 @@ class BootWindow : public Fl_Window
520520
g_SelectedWADs.iwad = m_IWADs[value - 1].path;
521521

522522
// PWADs
523-
for (scannedPWADPtrs_t::iterator it = m_selectedPWADs.begin();
524-
it != m_selectedPWADs.end(); ++it)
523+
for (const auto& pwad : m_selectedPWADs)
525524
{
526-
g_SelectedWADs.pwads.push_back((*it)->path);
525+
g_SelectedWADs.pwads.push_back(pwad->path);
527526
}
528527
}
529528

@@ -542,9 +541,9 @@ class BootWindow : public Fl_Window
542541
{
543542
const int val = m_WADDirList->value();
544543
m_WADDirList->clear();
545-
for (StringTokens::iterator it = m_WADDirs.begin(); it != m_WADDirs.end(); ++it)
544+
for (const auto& waddir : m_WADDirs)
546545
{
547-
m_WADDirList->add(it->c_str());
546+
m_WADDirList->add(waddir.c_str());
548547
}
549548
m_WADDirList->value(val);
550549
}

0 commit comments

Comments
 (0)