X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui%2Fapp.cpp;h=6abfe15cddce199d28d6f4f2ec2ce1000c6e849b;hb=d9abe1a157bbd35e8b282927489b687f56048ce6;hp=264a79a6f54050ec5e0b238ce5deab0df74a5f22;hpb=68e8886a9aaf48fcc130334d8cf4fe35a4534a02;p=virtualjaguar diff --git a/src/gui/app.cpp b/src/gui/app.cpp index 264a79a..6abfe15 100644 --- a/src/gui/app.cpp +++ b/src/gui/app.cpp @@ -1,46 +1,103 @@ // // app.cpp - Qt-based GUI for Virtual Jaguar // -// by James L. Hammons +// by James Hammons // (C) 2010 Underground Software // -// JLH = James L. Hammons +// JLH = James Hammons // // Who When What // --- ---------- ------------------------------------------------------------- // JLH 12/23/2009 Created this file +// JLH 01/21/2011 Added SDL initialization +// JLH 06/26/2011 Added fix to keep SDL from hijacking main() on win32 // #include "app.h" +#include #include #include "log.h" #include "mainwin.h" +#include "settings.h" #include "types.h" +#ifdef __GCCWIN32__ +// Apparently on win32, SDL is hijacking main from Qt. So let's do this: +#undef main +#endif + +//hm. :-/ +// This is stuff we pass into the mainWindow... +bool noUntunedTankPlease = false; + // Here's the main application loop--short and simple... int main(int argc, char * argv[]) { + // Normally, this would be read in from the settings module... :-P + vjs.hardwareTypeAlpine = false; + // This is stuff we pass into the mainWindow... +// noUntunedTankPlease = false; + if (argc > 1) { - if (strcmp(argv[1], "--help") == 0) + if ((strcmp(argv[1], "--help") == 0) || (strcmp(argv[1], "-h") == 0) + || (strcmp(argv[1], "-?") == 0)) { printf("Virtual Jaguar 2.0.0 help\n"); printf("\n"); - printf("This is an experimental branch of Virtual Jaguar, how did you get it?\n"); + printf("Command line interface is mostly non-functional ATM, but may return if\n" + "there is enough demand for it. :-)\n"); return 0; } + + if (strcmp(argv[1], "--yarrr") == 0) + { + printf("\n"); + printf("Shiver me timbers!\n"); + printf("\n"); + return 0; + } + + if ((strcmp(argv[1], "--alpine") == 0) || (strcmp(argv[1], "-a") == 0)) + { + printf("Alpine Mode enabled.\n"); + vjs.hardwareTypeAlpine = true; + } + + if (strcmp(argv[1], "--please-dont-kill-my-computer") == 0) + { + noUntunedTankPlease = true; + } } - Q_INIT_RESOURCE(vj); // This must the same name as the exe filename + Q_INIT_RESOURCE(virtualjaguar); // This must the same name as the exe filename //or is it the .qrc filename??? // This is so we can pass this stuff using signal/slot mechanism... //ick int id = qRegisterMetaType(); - LogInit("vj.log"); // Init logfile - App app(argc, argv); // Declare an instance of the application + bool success = (bool)LogInit("virtualjaguar.log"); // Init logfile + int retVal = -1; // Default is failure + + if (!success) + printf("Failed to open virtualjaguar.log for writing!\n"); + + // Set up SDL library + if (SDL_Init(SDL_INIT_JOYSTICK | SDL_INIT_AUDIO) < 0) + { + WriteLog("VJ: Could not initialize the SDL library: %s\n", SDL_GetError()); + } + else + { + WriteLog("VJ: SDL (joystick, audio) successfully initialized.\n"); + App app(argc, argv); // Declare an instance of the application + retVal = app.exec(); // And run it! + + // Free SDL components last...! + SDL_QuitSubSystem(SDL_INIT_JOYSTICK | SDL_INIT_AUDIO); + SDL_Quit(); + } - int retVal = app.exec(); // And run it! LogDone(); // Close logfile return retVal; } @@ -50,5 +107,6 @@ int main(int argc, char * argv[]) App::App(int argc, char * argv[]): QApplication(argc, argv) { mainWindow = new MainWin(); + mainWindow->plzDontKillMyComputer = noUntunedTankPlease; mainWindow->show(); }