initial commit, lordsawar source, slightly modified
[lordsawar] / src / editor / main.cpp
1 //  Copyright (C) 2007 Ole Laursen
2 //  Copyright (C) 2007, 2008, 2009 Ben Asselstine
3 //
4 //  This program is free software; you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation; either version 3 of the License, or
7 //  (at your option) any later version.
8 //
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU Library General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program; if not, write to the Free Software
16 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
17 //  02110-1301, USA.
18
19 #ifdef HAVE_CONFIG_H
20 #include <config.h>
21 #endif
22
23 #include <iostream>
24 #include <stdlib.h>
25 #include <time.h>
26 #include <gtkmm.h>
27
28 #include "Configuration.h"
29 #include "File.h"
30 #include "GraphicsCache.h"
31 #include "timing.h"
32 #include "armyset.h"
33
34 #include "main-window.h"
35
36
37 sigc::connection on_timer_registered(Timing::timer_slot s, int msecs_interval)
38 {
39     return Glib::signal_timeout().connect(s, msecs_interval);
40 }
41
42 int max_vector_width;
43 int main(int argc, char* argv[])
44 {
45     srand(time(NULL));         // set the random seed
46
47     initialize_configuration();
48     Vector<int>::setMaximumWidth(1000);
49
50     setlocale(LC_ALL, Configuration::s_lang.c_str());
51     textdomain ("lordsawar");
52
53     // Check if armysets are in the path (otherwise exit)
54     Armyset::scanSystemCollection();
55
56     // init GUI stuff
57     g_set_application_name(_("LordsAWar! Scenario Editor"));
58     Timing::instance().timer_registered.connect(
59         sigc::ptr_fun(on_timer_registered));
60
61         
62     MainWindow* main_window = NULL;
63     try
64     {
65         Gtk::Main kit(argc, argv);
66
67         MainWindow* main_window;
68         if (argc > 1)
69           main_window = new MainWindow (argv[1]);
70         else
71           main_window = new MainWindow;
72         main_window->show();
73         
74         main_window->init();
75         kit.run(main_window->get_window());
76     }
77     catch (const Glib::Error &ex) {
78         std::cerr << ex.what() << std::endl;
79     }
80     delete main_window;
81     
82     return EXIT_SUCCESS;
83 }