23 #include "demo.h" |
23 #include "demo.h" |
24 #include "misc.h" |
24 #include "misc.h" |
25 #include "ui_demoprompt.h" |
25 #include "ui_demoprompt.h" |
26 #include "prompts.h" |
26 #include "prompts.h" |
27 |
27 |
|
28 EXTERN_CONFIG (Map, binaryPaths) |
|
29 EXTERN_CONFIG (List, wadpaths) |
|
30 EXTERN_CONFIG (Bool, noprompt) |
|
31 |
28 static const uint32 g_demoSignature = makeByteID ('Z', 'C', 'L', 'D'); |
32 static const uint32 g_demoSignature = makeByteID ('Z', 'C', 'L', 'D'); |
29 |
33 |
30 // ============================================================================= |
34 // ============================================================================= |
31 // ----------------------------------------------------------------------------- |
35 // ----------------------------------------------------------------------------- |
32 str uncolorize (const str& in) { |
36 str uncolorize (const str& in) { |
61 } |
65 } |
62 |
66 |
63 // ============================================================================= |
67 // ============================================================================= |
64 // ----------------------------------------------------------------------------- |
68 // ----------------------------------------------------------------------------- |
65 static bool isKnownVersion (str ver) { |
69 static bool isKnownVersion (str ver) { |
66 QSettings cfg; |
70 for (const var& it : getVersions()) |
67 list<var> versions = getVersionsList(); |
|
68 |
|
69 for (const var& it : versions) |
|
70 if (it.toString() == ver || it.toString() + 'M' == ver) |
71 if (it.toString() == ver || it.toString() + 'M' == ver) |
71 return true; |
72 return true; |
72 |
73 |
73 return false; |
74 return false; |
74 } |
75 } |
75 |
76 |
76 // ============================================================================= |
77 // ============================================================================= |
77 // ----------------------------------------------------------------------------- |
78 // ----------------------------------------------------------------------------- |
78 static str findWAD (str name) { |
79 static str findWAD (str name) { |
79 QSettings cfg; |
80 if (cfg::wadpaths.size() == 0) { |
80 list<var> paths = cfg.value ("wads/paths", list<var>()).toList(); |
|
81 |
|
82 if (paths.size() == 0) { |
|
83 error (tr ("No WAD paths configured!")); |
81 error (tr ("No WAD paths configured!")); |
84 |
82 |
85 // Cannot just return an empty string here since that'd trigger |
83 // Cannot just return an empty string here since that'd trigger |
86 // another error prompt - skip ahead and exit. |
84 // another error prompt - skip ahead and exit. |
87 exit (9); |
85 exit (9); |
88 } |
86 } |
89 |
87 |
90 for (const var& it : paths) { |
88 for (const var& it : cfg::wadpaths) { |
91 str fullpath = fmt ("%1/%2", it.toString(), name); |
89 str fullpath = fmt ("%1/%2", it.toString(), name); |
92 QFile f (fullpath); |
90 QFile f (fullpath); |
93 |
91 |
94 if (f.exists()) |
92 if (f.exists()) |
95 return fullpath; |
93 return fullpath; |
229 error (tr ("Failure in configuration! This shouldn't happen.")); |
227 error (tr ("Failure in configuration! This shouldn't happen.")); |
230 return 6; |
228 return 6; |
231 } |
229 } |
232 } |
230 } |
233 |
231 |
234 QSettings cfg; |
232 str binarypath = cfg::binaryPaths [zanversion].toString(); |
235 str binarypath = cfg.value (binaryConfigName (zanversion)).toString(); |
|
236 |
233 |
237 if (binarypath.isEmpty()) { |
234 if (binarypath.isEmpty()) { |
238 error (fmt (tr ("No binary path specified for Zandronum version %1!"), zanversion)); |
235 error (fmt (tr ("No binary path specified for Zandronum version %1!"), zanversion)); |
239 return 7; |
236 return 7; |
240 } |
237 } |