[2581] | 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 | */ |
---|
[3166] | 25 | |
---|
[3423] | 26 | #include <unistd.h> |
---|
| 27 | |
---|
[4047] | 28 | #include "gui_gtk.h" |
---|
| 29 | #include "gui.h" |
---|
| 30 | #include "gui_video.h" |
---|
| 31 | #include "gui_audio.h" |
---|
| 32 | #include "gui_exec.h" |
---|
| 33 | #include "gui_flags.h" |
---|
| 34 | #include "gui_banner.h" |
---|
| 35 | #include "gui_keys.h" |
---|
| 36 | #include "gui_update.h" |
---|
[2018] | 37 | |
---|
[4046] | 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; |
---|
[2018] | 46 | |
---|
| 47 | /* ORXONOXGUI */ |
---|
| 48 | |
---|
[2588] | 49 | /** |
---|
[2623] | 50 | \brief Initializes the Gui |
---|
[2588] | 51 | */ |
---|
[3423] | 52 | OrxonoxGui::OrxonoxGui(int argc, char *argv[]) |
---|
[2018] | 53 | { |
---|
[4046] | 54 | Window* orxonoxGUI = NULL; |
---|
| 55 | |
---|
[3423] | 56 | initGUI(argc, argv); |
---|
| 57 | |
---|
| 58 | orxonoxGUI = new Window( "grafical orxonox loader, "PACKAGE_VERSION); |
---|
[4046] | 59 | { |
---|
| 60 | Box* windowBox = new Box ('h'); |
---|
| 61 | { |
---|
| 62 | banner = new OrxonoxGuiBanner(); |
---|
| 63 | windowBox->fill (banner->getWidget()); |
---|
[2018] | 64 | |
---|
[4046] | 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); |
---|
[2613] | 75 | |
---|
[4046] | 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 | } |
---|
[3423] | 96 | // Reading Values from File |
---|
[4051] | 97 | exec->setConfDir(GUI_DEFAULT_CONF_DIR); |
---|
| 98 | exec->setConfFile(GUI_DEFAULT_CONF_FILE); |
---|
[4046] | 99 | exec->readFromFile(Window::mainWindow); |
---|
[3423] | 100 | // Merging changes to the Options from appended flags. |
---|
| 101 | for (int optCount = 1; optCount < argc; optCount++) |
---|
| 102 | orxonoxGUI->walkThrough(Widget::flagCheck, argv[optCount], 0); |
---|
[2018] | 103 | |
---|
[4046] | 104 | flags->setTextFromFlags(Window::mainWindow); |
---|
[3423] | 105 | orxonoxGUI->showall(); |
---|
[2018] | 106 | |
---|
[3423] | 107 | //// Handling special Cases. /// |
---|
[3166] | 108 | |
---|
[3423] | 109 | // case update // |
---|
| 110 | #ifdef HAVE_CURL |
---|
[4046] | 111 | if (static_cast<Option*>(Window::mainWindow->findWidgetByName("auto update", 0))->value == 1) |
---|
[3423] | 112 | { |
---|
| 113 | update->checkForUpdates(); |
---|
| 114 | } |
---|
| 115 | #endif /* HAVE_CURL */ |
---|
[3166] | 116 | |
---|
[3423] | 117 | // case start-with-gui. |
---|
[4046] | 118 | if (!access(exec->getConfigFile(), F_OK) && |
---|
| 119 | static_cast<Option*>(orxonoxGUI->findWidgetByName("Always Show this Menu", 0))->value == 0) |
---|
[3423] | 120 | OrxonoxGuiExec::startOrxonox(NULL, exec); |
---|
| 121 | else |
---|
| 122 | { |
---|
| 123 | mainloopGUI(); |
---|
| 124 | } |
---|
| 125 | |
---|
[2018] | 126 | } |
---|
[3423] | 127 | |
---|
[4051] | 128 | bool OrxonoxGui::startOrxonox = false; |
---|
[3423] | 129 | |
---|
| 130 | /** |
---|
| 131 | \brief Destructor. |
---|
| 132 | */ |
---|
| 133 | OrxonoxGui::~OrxonoxGui(void) |
---|
| 134 | { |
---|
| 135 | delete video; |
---|
| 136 | delete audio; |
---|
| 137 | delete exec; |
---|
| 138 | delete flags; |
---|
| 139 | delete banner; |
---|
| 140 | delete keys; |
---|
| 141 | delete update; |
---|
| 142 | } |
---|