src/main.cpp

changeset 287
3fcccd8c3357
parent 286
7a562bf3d829
child 288
2980d7fd948e
equal deleted inserted replaced
286:7a562bf3d829 287:3fcccd8c3357
18 18
19 #include <QApplication> 19 #include <QApplication>
20 #include <QMessageBox> 20 #include <QMessageBox>
21 #include <QAbstractButton> 21 #include <QAbstractButton>
22 #include <qfile.h> 22 #include <qfile.h>
23 #include <QTextStream>
23 #include "gui.h" 24 #include "gui.h"
24 #include "file.h" 25 #include "file.h"
25 #include "bbox.h" 26 #include "bbox.h"
26 #include "misc.h" 27 #include "misc.h"
27 #include "config.h" 28 #include "config.h"
31 vector<LDOpenFile*> g_loadedFiles; 32 vector<LDOpenFile*> g_loadedFiles;
32 LDOpenFile* g_curfile = null; 33 LDOpenFile* g_curfile = null;
33 ForgeWindow* g_win = null; 34 ForgeWindow* g_win = null;
34 bbox g_BBox; 35 bbox g_BBox;
35 const QApplication* g_app = null; 36 const QApplication* g_app = null;
36 QFile g_file_stdout, g_file_stderr; 37 File g_file_stdout (stdout, File::Write);
38 File g_file_stderr (stderr, File::Write);
37 39
38 const vertex g_origin (0.0f, 0.0f, 0.0f); 40 const vertex g_origin (0.0f, 0.0f, 0.0f);
39 const matrix g_identity ({1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f}); 41 const matrix g_identity ({1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f});
40 42
41 void doPrint (QFile& f, initlist<StringFormatArg> args) { 43 void doPrint (File& f, initlist<StringFormatArg> args) {
42 str msg = DoFormat (args); 44 str msg = DoFormat (args);
43 f.write (msg.toUtf8 (), msg.length ()); 45 f.write (msg.toUtf8 ());
44 f.flush (); 46 f.flush ();
45 } 47 }
46 48
47 void doPrint (FILE* fp, initlist<StringFormatArg> args) { 49 void doPrint (FILE* fp, initlist<StringFormatArg> args) {
48 if (fp == stdout) 50 if (fp == stdout)
55 57
56 // ============================================================================= 58 // =============================================================================
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 59 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
58 // ============================================================================= 60 // =============================================================================
59 int main (int argc, char* argv[]) { 61 int main (int argc, char* argv[]) {
60 g_file_stdout.open (stdout, QIODevice::WriteOnly);
61 g_file_stderr.open (stderr, QIODevice::WriteOnly);
62
63 const QApplication app (argc, argv); 62 const QApplication app (argc, argv);
64 g_app = &app; 63 g_app = &app;
65 g_curfile = NULL; 64 g_curfile = null;
66 65
67 // Load or create the configuration 66 // Load or create the configuration
68 if (!config::load ()) { 67 if (!config::load ()) {
69 printf ("Creating configuration file...\n"); 68 printf ("Creating configuration file...\n");
70 if (config::save ()) 69 if (config::save ())

mercurial