1 | /* |
---|
2 | orxonox - the future of 3D-vertical-scrollers |
---|
3 | |
---|
4 | Copyright (C) 2004 orx |
---|
5 | |
---|
6 | This program is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; either version 2, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | This program is distributed in the hope that it will be useful, |
---|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | GNU General Public License for more details. |
---|
15 | |
---|
16 | You should have received a copy of the GNU General Public License |
---|
17 | along with this program; if not, write to the Free Software Foundation, |
---|
18 | Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
19 | |
---|
20 | |
---|
21 | ### File Specific: |
---|
22 | main-programmer: Benjamin Grauer |
---|
23 | |
---|
24 | */ |
---|
25 | |
---|
26 | #include <unistd.h> |
---|
27 | |
---|
28 | #include "orxonox_gui_gtk.h" |
---|
29 | #include "orxonox_gui.h" |
---|
30 | #include "orxonox_gui_video.h" |
---|
31 | #include "orxonox_gui_audio.h" |
---|
32 | #include "orxonox_gui_exec.h" |
---|
33 | #include "orxonox_gui_flags.h" |
---|
34 | #include "orxonox_gui_banner.h" |
---|
35 | #include "orxonox_gui_keys.h" |
---|
36 | #include "orxonox_gui_update.h" |
---|
37 | |
---|
38 | // GUI-modules |
---|
39 | OrxonoxGuiFlags* flags = NULL; |
---|
40 | OrxonoxGuiVideo* video = NULL; |
---|
41 | OrxonoxGuiAudio* audio = NULL; |
---|
42 | OrxonoxGuiExec* exec = NULL; |
---|
43 | OrxonoxGuiBanner* banner = NULL; |
---|
44 | OrxonoxGuiKeys* keys = NULL; |
---|
45 | OrxonoxGuiUpdate* update = NULL; |
---|
46 | |
---|
47 | /* ORXONOXGUI */ |
---|
48 | |
---|
49 | /** |
---|
50 | \brief Initializes the Gui |
---|
51 | */ |
---|
52 | OrxonoxGui::OrxonoxGui(int argc, char *argv[]) |
---|
53 | { |
---|
54 | Window* orxonoxGUI = NULL; |
---|
55 | |
---|
56 | initGUI(argc, argv); |
---|
57 | |
---|
58 | orxonoxGUI = new Window( "grafical orxonox loader, "PACKAGE_VERSION); |
---|
59 | { |
---|
60 | Box* windowBox = new Box ('h'); |
---|
61 | { |
---|
62 | banner = new OrxonoxGuiBanner(); |
---|
63 | windowBox->fill (banner->getWidget()); |
---|
64 | |
---|
65 | Box* optionBoxL = new Box('v'); |
---|
66 | { |
---|
67 | Box* avBox = new Box('h'); |
---|
68 | |
---|
69 | video = new OrxonoxGuiVideo(); |
---|
70 | avBox->fill(video->getWidget()); |
---|
71 | audio = new OrxonoxGuiAudio(); |
---|
72 | avBox->fill(audio->getWidget()); |
---|
73 | |
---|
74 | optionBoxL->fill(avBox); |
---|
75 | |
---|
76 | keys = new OrxonoxGuiKeys(); |
---|
77 | optionBoxL->fill(keys->getWidget()); |
---|
78 | windowBox->fill(optionBoxL); |
---|
79 | } |
---|
80 | Box* optionBoxR = new Box('v'); |
---|
81 | { |
---|
82 | exec = new OrxonoxGuiExec(); |
---|
83 | optionBoxR->fill(exec->getWidget()); |
---|
84 | |
---|
85 | flags = new OrxonoxGuiFlags(); |
---|
86 | |
---|
87 | optionBoxR->fill(flags->getWidget()); |
---|
88 | |
---|
89 | update = new OrxonoxGuiUpdate(); |
---|
90 | optionBoxR->fill(update->getWidget()); |
---|
91 | } |
---|
92 | windowBox->fill(optionBoxR); |
---|
93 | } |
---|
94 | orxonoxGUI->fill(windowBox); |
---|
95 | } |
---|
96 | // Reading Values from File |
---|
97 | exec->setConfFile(ORXONOX_GUI_DEFAULT_CONFIG_FILE); |
---|
98 | exec->readFromFile(Window::mainWindow); |
---|
99 | // Merging changes to the Options from appended flags. |
---|
100 | for (int optCount = 1; optCount < argc; optCount++) |
---|
101 | orxonoxGUI->walkThrough(Widget::flagCheck, argv[optCount], 0); |
---|
102 | |
---|
103 | flags->setTextFromFlags(Window::mainWindow); |
---|
104 | orxonoxGUI->showall(); |
---|
105 | |
---|
106 | //// Handling special Cases. /// |
---|
107 | |
---|
108 | // case update // |
---|
109 | #ifdef HAVE_CURL |
---|
110 | if (static_cast<Option*>(Window::mainWindow->findWidgetByName("auto update", 0))->value == 1) |
---|
111 | { |
---|
112 | update->checkForUpdates(); |
---|
113 | } |
---|
114 | #endif /* HAVE_CURL */ |
---|
115 | |
---|
116 | // case start-with-gui. |
---|
117 | if (!access(exec->getConfigFile(), F_OK) && |
---|
118 | static_cast<Option*>(orxonoxGUI->findWidgetByName("Always Show this Menu", 0))->value == 0) |
---|
119 | OrxonoxGuiExec::startOrxonox(NULL, exec); |
---|
120 | else |
---|
121 | { |
---|
122 | mainloopGUI(); |
---|
123 | } |
---|
124 | |
---|
125 | } |
---|
126 | |
---|
127 | |
---|
128 | /** |
---|
129 | \brief Destructor. |
---|
130 | */ |
---|
131 | OrxonoxGui::~OrxonoxGui(void) |
---|
132 | { |
---|
133 | delete video; |
---|
134 | delete audio; |
---|
135 | delete exec; |
---|
136 | delete flags; |
---|
137 | delete banner; |
---|
138 | delete keys; |
---|
139 | delete update; |
---|
140 | } |
---|