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.h" |
---|
29 | #include "orxonox_gui_video.h" |
---|
30 | #include "orxonox_gui_audio.h" |
---|
31 | #include "orxonox_gui_exec.h" |
---|
32 | #include "orxonox_gui_flags.h" |
---|
33 | #include "orxonox_gui_banner.h" |
---|
34 | #include "orxonox_gui_keys.h" |
---|
35 | #include "orxonox_gui_update.h" |
---|
36 | |
---|
37 | Window* orxonoxGUI = NULL; |
---|
38 | OrxonoxGuiVideo* video = NULL; |
---|
39 | OrxonoxGuiAudio* audio = NULL; |
---|
40 | OrxonoxGuiExec* exec = NULL; |
---|
41 | OrxonoxGuiFlags* flags = NULL; |
---|
42 | OrxonoxGuiBanner* banner = NULL; |
---|
43 | OrxonoxGuiKeys* keys = NULL; |
---|
44 | OrxonoxGuiUpdate* update = NULL; |
---|
45 | int verbose = 4; |
---|
46 | |
---|
47 | /* ORXONOXGUI */ |
---|
48 | |
---|
49 | /** |
---|
50 | \brief Initializes the Gui |
---|
51 | */ |
---|
52 | OrxonoxGui::OrxonoxGui(int argc, char *argv[]) |
---|
53 | { |
---|
54 | initGUI(argc, argv); |
---|
55 | |
---|
56 | orxonoxGUI = new Window( "grafical orxonox loader, "PACKAGE_VERSION); |
---|
57 | |
---|
58 | Box* windowBox = new Box ('h'); |
---|
59 | |
---|
60 | banner = new OrxonoxGuiBanner(); |
---|
61 | windowBox->fill (banner->getWidget()); |
---|
62 | |
---|
63 | Box* optionBoxL = new Box('v'); |
---|
64 | Box* optionBoxR = new Box('v'); |
---|
65 | |
---|
66 | Box* avBox = new Box('h'); |
---|
67 | |
---|
68 | video = new OrxonoxGuiVideo(); |
---|
69 | avBox->fill(video->getWidget()); |
---|
70 | audio = new OrxonoxGuiAudio(); |
---|
71 | avBox->fill(audio->getWidget()); |
---|
72 | |
---|
73 | optionBoxL->fill(avBox); |
---|
74 | |
---|
75 | keys = new OrxonoxGuiKeys(); |
---|
76 | optionBoxL->fill(keys->getWidget()); |
---|
77 | windowBox->fill(optionBoxL); |
---|
78 | |
---|
79 | exec = new OrxonoxGuiExec(); |
---|
80 | optionBoxR->fill(exec->getWidget()); |
---|
81 | |
---|
82 | flags = new OrxonoxGuiFlags(); |
---|
83 | |
---|
84 | optionBoxR->fill(flags->getWidget()); |
---|
85 | |
---|
86 | update = new OrxonoxGuiUpdate(); |
---|
87 | optionBoxR->fill(update->getWidget()); |
---|
88 | windowBox->fill(optionBoxR); |
---|
89 | |
---|
90 | orxonoxGUI->fill(windowBox); |
---|
91 | |
---|
92 | // Reading Values from File |
---|
93 | exec->setConfFile("~/.orxonox/orxonox.conf"); |
---|
94 | exec->readFromFile(orxonoxGUI); |
---|
95 | // Merging changes to the Options from appended flags. |
---|
96 | for (int optCount = 1; optCount < argc; optCount++) |
---|
97 | orxonoxGUI->walkThrough(Widget::flagCheck, argv[optCount], 0); |
---|
98 | |
---|
99 | flags->setTextFromFlags(orxonoxGUI); |
---|
100 | orxonoxGUI->showall(); |
---|
101 | |
---|
102 | //// Handling special Cases. /// |
---|
103 | |
---|
104 | // case update // |
---|
105 | #ifdef HAVE_CURL |
---|
106 | if (static_cast<Option*>(orxonoxGUI->findWidgetByName("auto update", 0))->value == 1) |
---|
107 | { |
---|
108 | update->checkForUpdates(); |
---|
109 | } |
---|
110 | #endif /* HAVE_CURL */ |
---|
111 | |
---|
112 | // case start-with-gui. |
---|
113 | if (!access(exec->getConfigFile(), F_OK) && static_cast<Option*>(orxonoxGUI->findWidgetByName("Always Show this Menu", 0))->value == 0) |
---|
114 | OrxonoxGuiExec::startOrxonox(NULL, exec); |
---|
115 | else |
---|
116 | { |
---|
117 | mainloopGUI(); |
---|
118 | } |
---|
119 | |
---|
120 | } |
---|
121 | |
---|
122 | |
---|
123 | /** |
---|
124 | \brief Destructor. |
---|
125 | */ |
---|
126 | OrxonoxGui::~OrxonoxGui(void) |
---|
127 | { |
---|
128 | delete video; |
---|
129 | delete audio; |
---|
130 | delete exec; |
---|
131 | delete flags; |
---|
132 | delete banner; |
---|
133 | delete keys; |
---|
134 | delete update; |
---|
135 | } |
---|