Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/branches/updater/src/gui/orxonox_gui.cc @ 3298

Last change on this file since 3298 was 3298, checked in by bensch, 19 years ago

orxonox/branches/updater: autoupdate at beginning works partly

File size: 3.8 KB
Line 
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;
38  OrxonoxGuiVideo* video;
39  OrxonoxGuiAudio* audio;
40  OrxonoxGuiExec* exec;
41  OrxonoxGuiFlags* flags;
42  OrxonoxGuiBanner* banner;
43  OrxonoxGuiKeys* keys;
44  OrxonoxGuiUpdate* update;
45int verbose = 4;
46
47int main( int argc, char *argv[] )
48{
49  OrxonoxGui* orxonoxgui = new OrxonoxGui(argc, argv);
50  return 0;
51}
52
53/* ORXONOXGUI */
54
55/**
56   \brief Initializes the Gui
57*/
58OrxonoxGui::OrxonoxGui (int argc, char *argv[])
59{
60#ifdef HAVE_GTK2
61  initGTK(argc, argv);
62#endif /* HAVE_GTK2 */
63
64  orxonoxGUI = new Window( "Grafical OrxOnoX loader, "PACKAGE_VERSION);
65#ifdef HAVE_GTK2
66  orxonoxGUI->connectSignal ("destroy", orxonoxGUI->orxonox_gui_quit);
67  orxonoxGUI->connectSignal ("delete_event", orxonoxGUI->orxonox_gui_quit);
68#endif /* HAVE_GTK2 */
69 
70  Box* windowBox = new Box ('h');
71
72  banner = new OrxonoxGuiBanner();
73  windowBox->fill (banner->getWidget());
74 
75  Box* optionBox = new Box ('v');
76 
77  Box* avBox = new Box ('h');
78
79  video = new OrxonoxGuiVideo ();
80  avBox->fill (video->getWidget ());
81  audio = new OrxonoxGuiAudio ();
82  avBox->fill (audio->getWidget ());
83     
84  optionBox->fill (avBox);
85
86  keys = new OrxonoxGuiKeys ();
87  optionBox->fill (keys->getWidget ());
88
89  exec = new OrxonoxGuiExec (orxonoxGUI);
90  optionBox->fill (exec->getWidget ());
91
92  flags = new OrxonoxGuiFlags (orxonoxGUI);
93
94  optionBox->fill (flags->getWidget ());
95  windowBox->fill (optionBox);
96
97  update = new OrxonoxGuiUpdate ();
98  optionBox->fill(update->getWidget());
99 
100  orxonoxGUI->fill (windowBox);
101  flags->setTextFromFlags (orxonoxGUI);
102
103  // Reading Values from File
104  exec->setFilename ("~/.orxonox.conf");
105  exec->readFromFile (orxonoxGUI);
106  // Merging changes to the Options from appended flags.
107  for (int optCount = 1; optCount < argc; optCount++)
108    orxonoxGUI->walkThrough(Widget::flagCheck, argv[optCount], 0);
109
110  orxonoxGUI->showall ();
111
112  //// Handling special Cases. ///
113
114  // case update //
115#ifdef HAVE_CURL
116  if (static_cast<Option*>(orxonoxGUI->findWidgetByName("auto update", 0))->value == 1)
117    {
118      update->checkForUpdates();
119    }
120#endif /* HAVE_CURL */
121
122  // case start-with-gui.
123  if (!access(exec->getConfigFile(), F_OK) && static_cast<Option*>(orxonoxGUI->findWidgetByName("Always Show this Menu", 0))->value == 0)
124    OrxonoxGuiExec::startOrxonox(NULL, NULL);
125  else
126    {
127#ifdef HAVE_GTK2
128  mainloopGTK();
129#else /* HAVE_GTK2 */
130  PRINT(0)(" Listing all the Orxonox Options: \n");
131  PRINT(0)("  #############################\n");
132  orxonoxGUI->walkThrough(orxonoxGUI->listOptions, 0);
133
134  PRINT(0)("\nDo you want me to save the the above values now? [Yn] ");
135  char c = getchar();
136  if ((c == 'y' || c == 'Y' || c== 10) && exec->shouldsave())
137    exec->writeToFile (Window::mainWindow);
138   
139#endif /* HAVE_GTK2 */
140    }
141}
Note: See TracBrowser for help on using the repository browser.