src/main.cpp

changeset 37
c82a86ea87be
parent 30
6b82f6a3ad53
child 38
db677d321cf4
equal deleted inserted replaced
36:b8fa9171be6e 37:c82a86ea87be
1 /* 1 /*
2 * ZCinema: Zandronum demo launcher 2 * ZCinema: Zandronum demo launcher
3 * Copyright (C) 2013 Santeri Piippo 3 * Copyright (C) 2013-2015 Teemu Piippo
4 * 4 *
5 * This program is free software: you can redistribute it and/or modify 5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by 6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or 7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version. 8 * (at your option) any later version.
20 #include "config.h" 20 #include "config.h"
21 #include "types.h" 21 #include "types.h"
22 #include "demo.h" 22 #include "demo.h"
23 #include "prompts.h" 23 #include "prompts.h"
24 24
25 // ============================================================================= 25 //
26 // ----------------------------------------------------------------------------- 26 // -------------------------------------------------------------------------------------------------
27 int main (int argc, char* argv[]) { 27 //
28
29 int main (int argc, char* argv[])
30 {
28 QApplication app (argc, argv); 31 QApplication app (argc, argv);
29 app.setApplicationName (UNIXNAME); 32 app.setApplicationName (UNIXNAME);
30 app.setOrganizationName (UNIXNAME); 33 app.setOrganizationName (UNIXNAME);
31 app.setApplicationVersion (versionString()); 34 app.setApplicationVersion (versionString());
32 35
33 cfg::load(); 36 for (int i = 1; i < argc; ++i)
34 37 {
35 for (int i = 1; i < argc; ++i) { 38 QString arg = argv[i];
36 str arg = argv[i];
37 39
38 if (arg == "--config") { 40 if (arg == "--config")
39 ConfigBox dlg; 41 {
42 ConfigWindow dlg;
40 return dlg.exec(); 43 return dlg.exec();
41 } 44 }
42 } 45 }
43 46
44 if (argc != 2) { 47 if (argc > 1)
45 FindFilePrompt* dlg = new FindFilePrompt (null); 48 {
46 if (!dlg->exec()) 49 return launchDemo (argv[1]);
47 return 255; 50 }
48 51 else
52 {
53 FindFilePrompt* dlg = new FindFilePrompt (NULL);
54
55 if (not dlg->exec())
56 return 0;
57
49 return launchDemo (dlg->path()); 58 return launchDemo (dlg->path());
50 } 59 }
51
52 return launchDemo (argv[1]);
53 } 60 }
54 61
55 // ============================================================================= 62 //
56 // ----------------------------------------------------------------------------- 63 // -------------------------------------------------------------------------------------------------
57 str versionString() { 64 //
58 str text = fmt ("v%1.%2", VERSION_MAJOR, VERSION_MINOR); 65
59 #if VERSION_PATCH != 0 66 QString versionString()
60 text += fmt (".%1", VERSION_PATCH); 67 {
61 #endif 68 return VERSION_STRING;
62
63 #if BUILD_ID == BUILD_INTERNAL
64 text += "-intern";
65 #elif BUILD_ID == BUILD_ALPHA
66 text += "-alpha";
67 #elif BUILD_ID == BUILD_BETA
68 text += "-beta";
69 #elif BUILD_ID == BUILD_RC
70 text += fmt ("-rc%1", RC_ID);
71 #elif BUILD_ID == BUILD_RELEASE
72 text += "-rel";
73 #else
74 # error Invalid build code!
75 #endif // BUILD_ID
76
77 return text;
78 } 69 }
79 70
80 QString versionSignature() { 71 //
72 // -------------------------------------------------------------------------------------------------
73 //
74
75 QString versionSignature()
76 {
81 return QString (APPNAME) + " " + versionString(); 77 return QString (APPNAME) + " " + versionString();
82 } 78 }

mercurial