launcher/demo.cpp

changeset 48
e121ea9dba93
parent 46
07578e081ae8
child 51
5e4bd3b212ce
equal deleted inserted replaced
47:4a0ad0a08ea1 48:e121ea9dba93
18 18
19 #include <QFile> 19 #include <QFile>
20 #include <QDataStream> 20 #include <QDataStream>
21 #include <QMessageBox> 21 #include <QMessageBox>
22 #include <QProcess> 22 #include <QProcess>
23 #include <errno.h>
23 #include <commonlib/misc.h> 24 #include <commonlib/misc.h>
24 #include <commonlib/config.h> 25 #include <commonlib/config.h>
25 #include <commonlib/version.h> 26 #include <commonlib/version.h>
26 #include "demo.h" 27 #include "demo.h"
27 #include "prompts.h" 28 #include "prompts.h"
35 { 36 {
36 // TODO: Handle long-form colors like \c[Red] 37 // TODO: Handle long-form colors like \c[Red]
37 QString out; 38 QString out;
38 int skip = 0; 39 int skip = 0;
39 40
40 for (QChar c : in) 41 for (int i = 0; i < in.length(); ++i)
41 { 42 {
42 if (skip-- > 0) 43 if (skip-- > 0)
43 continue; 44 continue;
44 45
45 if (c == QChar ('\034')) 46 QChar ch = in[i];
47
48 if (ch == QChar ('\034'))
46 { 49 {
47 skip = 1; 50 skip = 1;
48 continue; 51 continue;
49 } 52 }
50 53
51 out += c; 54 out += ch;
52 } 55 }
53 56
54 return out; 57 return out;
55 } 58 }
56 59
303 306
304 QString iwadpath; 307 QString iwadpath;
305 QStringList pwadpaths; 308 QStringList pwadpaths;
306 309
307 // Find the WADs 310 // Find the WADs
308 for (const QString& wad : wads) 311 for (int i = 0; i < wads.size(); ++i)
309 { 312 {
313 const QString& wad = wads[i];
310 QString path = findWAD (wad); 314 QString path = findWAD (wad);
311 315
312 // WAD names are case-sensitive under non-Windows and they can appear in uppercase 316 // WAD names are case-sensitive under non-Windows and they can appear in uppercase
313 // so we need to test that too. 317 // so we need to test that too.
314 if (path.isEmpty()) 318 if (path.isEmpty())
328 332
329 if (not Config::get ("noprompt").toBool()) 333 if (not Config::get ("noprompt").toBool())
330 { 334 {
331 QString pwadtext; 335 QString pwadtext;
332 336
333 for (const QString& wad : wads) 337 for (int i = 0; i < wads.size(); ++i)
334 { 338 {
335 if (&wad == &wads.first()) 339 if (i == 0)
336 continue; // skip the IWAD 340 continue; // skip the IWAD
337 341
338 if (not pwadtext.isEmpty()) 342 if (not pwadtext.isEmpty())
339 pwadtext += "<br />"; 343 pwadtext += "<br />";
340 344
341 pwadtext += wad; 345 pwadtext += wads[i];
342 } 346 }
343 347
344 QDialog* dlg = new QDialog; 348 QDialog* dlg = new QDialog;
345 Ui_DemoPrompt ui; 349 Ui_DemoPrompt ui;
346 ui.setupUi (dlg); 350 ui.setupUi (dlg);

mercurial