]> Shamusworld >> Repos - virtualjaguar/blob - src/gui/app.cpp
Fixed OP scaling bug for sizes of 7.0 and up.
[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 // JLH  06/26/2011  Added fix to keep SDL from hijacking main() on win32
14 //
15
16 #include "app.h"
17
18 #include <SDL.h>
19 #include <QApplication>
20 #include "log.h"
21 #include "mainwin.h"
22 #include "types.h"
23
24 #ifdef __GCCWIN32__
25 // Apparently on win32, SDL is hijacking main from Qt. So let's do this:
26 #undef main
27 #endif
28
29 // Here's the main application loop--short and simple...
30 int main(int argc, char * argv[])
31 {
32         if (argc > 1)
33         {
34                 if ((strcmp(argv[1], "--help") == 0) || (strcmp(argv[1], "-h") == 0)
35                         || (strcmp(argv[1], "-?") == 0))
36                 {
37                         printf("Virtual Jaguar 2.0.0 help\n");
38                         printf("\n");
39                         printf("Command line interface is non-functional ATM, but may return if there is\n"
40                                 "enough demand for it. :-)\n");
41                         return 0;
42                 }
43         }
44
45         Q_INIT_RESOURCE(virtualjaguar); // This must the same name as the exe filename
46 //or is it the .qrc filename???
47         // This is so we can pass this stuff using signal/slot mechanism...
48 //ick   int id = qRegisterMetaType<uint32>();
49
50         LogInit("virtualjaguar.log");                           // Init logfile
51         int retVal = -1;                                                        // Default is failure
52
53         // Set up SDL library
54         if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_AUDIO) < 0)
55         {
56                 WriteLog("VJ: Could not initialize the SDL library: %s\n", SDL_GetError());
57         }
58         else
59         {
60                 WriteLog("VJ: SDL (joystick, audio) successfully initialized.\n");
61                 App app(argc, argv);                                    // Declare an instance of the application
62                 retVal = app.exec();                                    // And run it!
63
64                 // Free SDL components last...!
65                 SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_AUDIO);
66                 SDL_Quit();
67         }
68
69         LogDone();                                                                      // Close logfile
70         return retVal;
71 }
72
73 // Main app constructor--we stick globally accessible stuff here...
74
75 App::App(int argc, char * argv[]): QApplication(argc, argv)
76 {
77         mainWindow = new MainWin();
78         mainWindow->show();
79 }