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