]> Shamusworld >> Repos - virtualjaguar/blob - src/gui/app.cpp
82a4010160e8503f2969ff4c732ddccff2aa02cd
[virtualjaguar] / src / gui / app.cpp
1 //
2 // app.cpp - Qt-based GUI for Virtual Jaguar
3 //
4 // by James L. Hammons
5 // (C) 2010 Underground Software
6 //
7 // JLH = James L. Hammons <jlhamm@acm.org>
8 //
9 // Who  When        What
10 // ---  ----------  -------------------------------------------------------------
11 // JLH  12/23/2009  Created this file
12 // JLH  01/21/2011  Added SDL initialization
13 //
14
15 #include "app.h"
16
17 #include <SDL.h>
18 #include <QApplication>
19 #include "log.h"
20 #include "mainwin.h"
21 #include "types.h"
22
23 #ifdef __GCCWIN32__
24 // Apparently on win32, SDL is hijacking main from Qt. So let's do this:
25 #undef main
26 #endif
27
28 // Here's the main application loop--short and simple...
29 int main(int argc, char * argv[])
30 {
31         if (argc > 1)
32         {
33                 if (strcmp(argv[1], "--help") == 0)
34                 {
35                         printf("Virtual Jaguar 2.0.0 help\n");
36                         printf("\n");
37                         printf("This is an experimental branch of Virtual Jaguar, how did you get it?\n");
38                         return 0;
39                 }
40         }
41
42         Q_INIT_RESOURCE(virtualjaguar); // This must the same name as the exe filename
43 //or is it the .qrc filename???
44         // This is so we can pass this stuff using signal/slot mechanism...
45 //ick   int id = qRegisterMetaType<uint32>();
46
47         LogInit("virtualjaguar.log");                           // Init logfile
48         int retVal = -1;                                                        // Default is failure
49
50         // Set up SDL library
51         if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_AUDIO) < 0)
52         {
53                 WriteLog("VJ: Could not initialize the SDL library: %s\n", SDL_GetError());
54         }
55         else
56         {
57                 WriteLog("VJ: SDL (joystick, audio) successfully initialized.\n");
58                 App app(argc, argv);                                    // Declare an instance of the application
59                 retVal = app.exec();                                    // And run it!
60         }
61
62         LogDone();                                                                      // Close logfile
63         return retVal;
64 }
65
66 // Main app constructor--we stick globally accessible stuff here...
67
68 App::App(int argc, char * argv[]): QApplication(argc, argv)
69 {
70         mainWindow = new MainWin();
71         mainWindow->show();
72 }