src/main.cpp

Mon, 15 Jul 2013 14:43:29 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Mon, 15 Jul 2013 14:43:29 +0300
changeset 381
241f65769a57
parent 379
f5f3faac60cd
child 388
7ff483614aa1
permissions
-rw-r--r--

restructure; removed g_BBox

183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
1 /*
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
2 * LDForge: LDraw parts authoring CAD
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2013 Santeri Piippo
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
4 *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or modify
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
6 * it under the terms of the GNU General Public License as published by
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
8 * (at your option) any later version.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
9 *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful,
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
13 * GNU General Public License for more details.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
14 *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
17 */
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
18
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include <QApplication>
237
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
20 #include <QMessageBox>
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
21 #include <QAbstractButton>
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 271
diff changeset
22 #include <qfile.h>
287
3fcccd8c3357 Added a File type that wraps around QFile and provides stuff like a null file and range-for-iterating
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
23 #include <QTextStream>
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 #include "gui.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 #include "file.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 #include "misc.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27 #include "config.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
28 #include "colors.h"
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 #include "types.h"
292
4779ca562d5e Moved primitive handling to new code files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 290
diff changeset
30 #include "primitives.h"
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31
232
4e44c92e21dd Renamed the OpenFile class to LDOpenFile as MinGW doesn't appear to like the former name
Santeri Piippo <crimsondusk64@gmail.com>
parents: 229
diff changeset
32 vector<LDOpenFile*> g_loadedFiles;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 ForgeWindow* g_win = null;
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
34 const QApplication* g_app = null;
287
3fcccd8c3357 Added a File type that wraps around QFile and provides stuff like a null file and range-for-iterating
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
35 File g_file_stdout (stdout, File::Write);
3fcccd8c3357 Added a File type that wraps around QFile and provides stuff like a null file and range-for-iterating
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
36 File g_file_stderr (stderr, File::Write);
381
241f65769a57 restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
37 static str g_versionString, g_fullVersionString;
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
39 const vertex g_origin (0.0f, 0.0f, 0.0f);
191
9bb6a17305ad Readded BFC red-green view, although determining inversion isn't always correct and it cannot handle CW-certified files...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 189
diff changeset
40 const matrix g_identity ({1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f});
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41
287
3fcccd8c3357 Added a File type that wraps around QFile and provides stuff like a null file and range-for-iterating
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
42 void doPrint (File& f, initlist<StringFormatArg> args) {
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 271
diff changeset
43 str msg = DoFormat (args);
287
3fcccd8c3357 Added a File type that wraps around QFile and provides stuff like a null file and range-for-iterating
Santeri Piippo <crimsondusk64@gmail.com>
parents: 286
diff changeset
44 f.write (msg.toUtf8 ());
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 271
diff changeset
45 f.flush ();
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 271
diff changeset
46 }
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 271
diff changeset
47
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 271
diff changeset
48 void doPrint (FILE* fp, initlist<StringFormatArg> args) {
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 271
diff changeset
49 if (fp == stdout)
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 271
diff changeset
50 doPrint (g_file_stdout, args);
319
d0f41342ef51 Show values in file opening prompt
Santeri Piippo <crimsondusk64@gmail.com>
parents: 297
diff changeset
51 elif (fp == stderr)
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 271
diff changeset
52 doPrint (g_file_stderr, args);
373
91bea18bd77a Fixed compilation under windows/qt5
Santeri Piippo <crimsondusk64@gmail.com>
parents: 322
diff changeset
53 else
91bea18bd77a Fixed compilation under windows/qt5
Santeri Piippo <crimsondusk64@gmail.com>
parents: 322
diff changeset
54 fatal ("unknown FILE* argument");
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 271
diff changeset
55 }
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 271
diff changeset
56
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 // =============================================================================
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 int main (int argc, char* argv[]) {
261
c4ad4e3c6839 Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 247
diff changeset
61 const QApplication app (argc, argv);
271
d5ec224c1879 Laid down the foundations of the new history system
Santeri Piippo <crimsondusk64@gmail.com>
parents: 261
diff changeset
62 g_app = &app;
379
f5f3faac60cd Made the pointer to current file a private member of an anonymous shell class, thus getting accessors
Santeri Piippo <crimsondusk64@gmail.com>
parents: 373
diff changeset
63 setCurrentFile (null);
261
c4ad4e3c6839 Added ability to snap to pre-existing vertices while drawing, added changelog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 247
diff changeset
64
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
65 // Load or create the configuration
189
ac2d3e8dd110 Rewrote the string class with a simpler version. The old one was more than probably leaking water like a boat with an elephant on board...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
66 if (!config::load ()) {
288
2980d7fd948e Converted from C-style fopen to the new File class
Santeri Piippo <crimsondusk64@gmail.com>
parents: 287
diff changeset
67 print ("Creating configuration file...\n");
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
68 if (config::save ())
288
2980d7fd948e Converted from C-style fopen to the new File class
Santeri Piippo <crimsondusk64@gmail.com>
parents: 287
diff changeset
69 print ("Configuration file successfully created.\n");
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
70 else
288
2980d7fd948e Converted from C-style fopen to the new File class
Santeri Piippo <crimsondusk64@gmail.com>
parents: 287
diff changeset
71 print ("failed to create configuration file!\n");
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
72 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
73
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
74 LDPaths::initPaths ();
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
75 initColors ();
292
4779ca562d5e Moved primitive handling to new code files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 290
diff changeset
76
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
77 ForgeWindow* win = new ForgeWindow;
292
4779ca562d5e Moved primitive handling to new code files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 290
diff changeset
78
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
79 newFile ();
292
4779ca562d5e Moved primitive handling to new code files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 290
diff changeset
80 loadPrimitives ();
290
be0c367e7420 Added primitive scanning, replaced parts list in subfile add dialog with it
Santeri Piippo <crimsondusk64@gmail.com>
parents: 289
diff changeset
81
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
82 win->show ();
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
83 return app.exec ();
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
84 }
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
85
189
ac2d3e8dd110 Rewrote the string class with a simpler version. The old one was more than probably leaking water like a boat with an elephant on board...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
86 void doDevf (const char* func, const char* fmtstr, ...) {
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
87 va_list va;
189
ac2d3e8dd110 Rewrote the string class with a simpler version. The old one was more than probably leaking water like a boat with an elephant on board...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
88
ac2d3e8dd110 Rewrote the string class with a simpler version. The old one was more than probably leaking water like a boat with an elephant on board...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
89 printf ("%s: ", func);
ac2d3e8dd110 Rewrote the string class with a simpler version. The old one was more than probably leaking water like a boat with an elephant on board...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
90
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
91 va_start (va, fmtstr);
189
ac2d3e8dd110 Rewrote the string class with a simpler version. The old one was more than probably leaking water like a boat with an elephant on board...
Santeri Piippo <crimsondusk64@gmail.com>
parents: 183
diff changeset
92 vprintf (fmtstr, va);
183
f1b8cb53d2a2 Moved source files to src/, removed zz_ prefix off dialog files.
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93 va_end (va);
229
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
94 }
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
95
381
241f65769a57 restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
96 const char* versionString () {
241f65769a57 restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
97 if (g_versionString.length() == 0) {
229
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
98 #if VERSION_PATCH == 0
381
241f65769a57 restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
99 g_versionString = fmt ("%1.%2", VERSION_MAJOR, VERSION_MINOR);
229
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
100 #else
381
241f65769a57 restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
101 g_versionString = fmt ("%1.%2.%3", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
229
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
102 #endif // VERSION_PATCH
381
241f65769a57 restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
103 }
241f65769a57 restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
104
241f65769a57 restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
105 return g_versionString.toStdString().c_str();
229
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
106 }
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
107
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
108 const char* versionMoniker () {
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
109 #if BUILD_ID == BUILD_INTERNAL
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
110 return " Internal";
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
111 #elif BUILD_ID == BUILD_ALPHA
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
112 return " Alpha";
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
113 #elif BUILD_ID == BUILD_BETA
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
114 return " Beta";
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
115 #elif BUILD_ID == BUILD_RC
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
116 return " RC";
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
117 #else
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
118 return "";
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
119 #endif // BUILD_ID
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
120 }
b9e101b76eb3 Show the version info in the about dialog properly
Santeri Piippo <crimsondusk64@gmail.com>
parents: 191
diff changeset
121
381
241f65769a57 restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
122 const char* fullVersionString () {
241f65769a57 restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
123 if (g_fullVersionString.length() == 0)
241f65769a57 restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
124 g_fullVersionString = fmt ("v%1%2", versionString (), versionMoniker ());
241f65769a57 restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
125
241f65769a57 restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
126 return g_fullVersionString.toStdString().c_str();
237
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
127 }
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
128
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
129 static void bombBox (str msg) {
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
130 msg.replace ("\n", "<br />");
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
131
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
132 QMessageBox box (null);
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
133 const QMessageBox::StandardButton btn = QMessageBox::Close;
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
134 box.setWindowTitle ("Fatal Error");
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
135 box.setIconPixmap (getIcon ("bomb"));
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
136 box.setWindowIcon (getIcon ("ldforge"));
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
137 box.setText (msg);
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
138 box.addButton (btn);
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
139 box.button (btn)->setText ("Damn it");
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
140 box.setDefaultButton (btn);
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
141 box.exec ();
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
142 }
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
143
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
144 void assertionFailure (const char* file, const ulong line, const char* funcname, const char* expr) {
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 271
diff changeset
145 str errmsg = fmt ("File: %1\nLine: %2:\nFunction %3:\n\nAssertion `%4' failed",
237
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
146 file, line, funcname, expr);
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
147
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
148 #if BUILD_ID == BUILD_INTERNAL
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
149 errmsg += ", aborting.";
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
150 #else
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
151 errmsg += ".";
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
152 #endif
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
153
381
241f65769a57 restructure; removed g_BBox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 379
diff changeset
154 printf ("%s\n", errmsg.toStdString().c_str());
237
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
155
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
156 #if BUILD_ID == BUILD_INTERNAL
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
157 if (g_win)
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
158 g_win->deleteLater ();
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
159
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
160 bombBox (errmsg);
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
161 abort ();
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
162 #endif
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
163 }
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
164
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
165 void fatalError (const char* file, const ulong line, const char* funcname, str msg) {
286
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 271
diff changeset
166 str errmsg = fmt ("Aborting over a call to fatal():\nFile: %1\nLine: %2\nFunction: %3\n\n%4",
7a562bf3d829 Converted to 16-bit strings.. again
Santeri Piippo <crimsondusk64@gmail.com>
parents: 271
diff changeset
167 file, line, funcname, msg);
237
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
168
292
4779ca562d5e Moved primitive handling to new code files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 290
diff changeset
169 print ("%1\n", errmsg);
237
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
170
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
171 if (g_win)
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
172 g_win->deleteLater ();
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
173
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
174 bombBox (errmsg);
ec77f6e9a19f Added fatal error message box for the.. fatal stuff. Windows isn't really good at conveying error messages, converted actions into a C-style array because I've had a ton of problems with the vector approach (it gets zeroed when it shouldn't be..)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 232
diff changeset
175 abort ();
297
2cbd8ac8293b Added license header to primitives.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 292
diff changeset
176 }

mercurial