check activateable() before allowing clicks (oops)
[openc2e.git] / main.cpp
blobfdae8cb1c77fe5d21780c1d79bfc4c7d3ac2d1f1
1 /*
2 * main.cpp
3 * openc2e
5 * Created by Alyssa Milburn on Wed 02 Jun 2004.
6 * Copyright (c) 2004-2008 Alyssa Milburn. All rights reserved.
7 * Copyright (c) 2005-2008 Bryan Donlan. All rights reserved.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
21 #include "openc2e.h"
22 #include <iostream>
23 #include "Engine.h"
24 #include "SDLBackend.h"
25 #ifdef OPENAL_SUPPORT
26 #include "OpenALBackend.h"
27 #endif
28 #ifdef QT_SUPPORT
29 #include "qtgui/QtBackend.h"
30 #endif
32 #ifdef _WIN32
33 #include <windows.h>
34 #endif
36 // SDL tries stealing main on some platforms, which we don't want.
37 #undef main
39 extern "C" int main(int argc, char *argv[]) {
40 try {
41 std::cout << "openc2e (development build), built " __DATE__ " " __TIME__ "\nCopyright (c) 2004-2008 Alyssa Milburn and others\n\n";
43 engine.addPossibleBackend("sdl", shared_ptr<Backend>(new SDLBackend()));
44 #ifdef QT_SUPPORT
45 boost::shared_ptr<QtBackend> qtbackend = boost::shared_ptr<QtBackend>(new QtBackend());
46 boost::shared_ptr<Backend> qtbackend_generic = boost::dynamic_pointer_cast<class Backend, class QtBackend>(qtbackend);
47 engine.addPossibleBackend("qt", qtbackend_generic); // last-added backend is default
48 #endif
49 #ifdef OPENAL_SUPPORT
50 engine.addPossibleAudioBackend("openal", shared_ptr<AudioBackend>(new OpenALBackend()));
51 #endif
53 // pass command-line flags to the engine, but do no other setup
54 if (!engine.parseCommandLine(argc, argv)) return 1;
56 // get the engine to do all the startup (read catalogue, loading world, etc)
57 if (!engine.initialSetup()) return 0;
59 int ret = engine.backend->run(argc, argv);
61 // we're done, be sure to shut stuff down
62 engine.shutdown();
64 return ret;
65 } catch (std::exception &e) {
66 #ifdef _WIN32
67 MessageBox(NULL, e.what(), "openc2e - Fatal exception encountered:", MB_ICONERROR);
68 #else
69 std::cerr << "Fatal exception encountered: " << e.what() << "\n";
70 #endif
71 return 1;
75 /* vim: set noet: */