[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 | |
---|
[3296] | 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" |
---|
[3251] | 35 | #include "orxonox_gui_update.h" |
---|
[2018] | 36 | |
---|
| 37 | Window* orxonoxGUI; |
---|
| 38 | OrxonoxGuiVideo* video; |
---|
| 39 | OrxonoxGuiAudio* audio; |
---|
| 40 | OrxonoxGuiExec* exec; |
---|
[2580] | 41 | OrxonoxGuiFlags* flags; |
---|
| 42 | OrxonoxGuiBanner* banner; |
---|
[2613] | 43 | OrxonoxGuiKeys* keys; |
---|
[3251] | 44 | OrxonoxGuiUpdate* update; |
---|
[3263] | 45 | int verbose = 4; |
---|
[2018] | 46 | |
---|
| 47 | int main( int argc, char *argv[] ) |
---|
| 48 | { |
---|
| 49 | OrxonoxGui* orxonoxgui = new OrxonoxGui(argc, argv); |
---|
| 50 | return 0; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | /* ORXONOXGUI */ |
---|
| 54 | |
---|
[2588] | 55 | /** |
---|
[2623] | 56 | \brief Initializes the Gui |
---|
[2588] | 57 | */ |
---|
[2018] | 58 | OrxonoxGui::OrxonoxGui (int argc, char *argv[]) |
---|
| 59 | { |
---|
[3305] | 60 | initGUI(argc, argv); |
---|
[3263] | 61 | |
---|
[2740] | 62 | orxonoxGUI = new Window( "Grafical OrxOnoX loader, "PACKAGE_VERSION); |
---|
[2018] | 63 | |
---|
[2024] | 64 | Box* windowBox = new Box ('h'); |
---|
| 65 | |
---|
[2580] | 66 | banner = new OrxonoxGuiBanner(); |
---|
[2595] | 67 | windowBox->fill (banner->getWidget()); |
---|
[2580] | 68 | |
---|
[2024] | 69 | Box* optionBox = new Box ('v'); |
---|
[2018] | 70 | |
---|
| 71 | Box* avBox = new Box ('h'); |
---|
| 72 | |
---|
| 73 | video = new OrxonoxGuiVideo (); |
---|
[2595] | 74 | avBox->fill (video->getWidget ()); |
---|
[2018] | 75 | audio = new OrxonoxGuiAudio (); |
---|
[2595] | 76 | avBox->fill (audio->getWidget ()); |
---|
[2018] | 77 | |
---|
[2024] | 78 | optionBox->fill (avBox); |
---|
[2613] | 79 | |
---|
| 80 | keys = new OrxonoxGuiKeys (); |
---|
| 81 | optionBox->fill (keys->getWidget ()); |
---|
| 82 | |
---|
[2018] | 83 | exec = new OrxonoxGuiExec (orxonoxGUI); |
---|
[2595] | 84 | optionBox->fill (exec->getWidget ()); |
---|
[2018] | 85 | |
---|
| 86 | flags = new OrxonoxGuiFlags (orxonoxGUI); |
---|
[2024] | 87 | |
---|
[2595] | 88 | optionBox->fill (flags->getWidget ()); |
---|
[2024] | 89 | windowBox->fill (optionBox); |
---|
[3251] | 90 | |
---|
| 91 | update = new OrxonoxGuiUpdate (); |
---|
[3252] | 92 | optionBox->fill(update->getWidget()); |
---|
[2018] | 93 | |
---|
| 94 | orxonoxGUI->fill (windowBox); |
---|
| 95 | flags->setTextFromFlags (orxonoxGUI); |
---|
| 96 | |
---|
[3296] | 97 | // Reading Values from File |
---|
[2018] | 98 | exec->setFilename ("~/.orxonox.conf"); |
---|
| 99 | exec->readFromFile (orxonoxGUI); |
---|
[3296] | 100 | // Merging changes to the Options from appended flags. |
---|
[3295] | 101 | for (int optCount = 1; optCount < argc; optCount++) |
---|
| 102 | orxonoxGUI->walkThrough(Widget::flagCheck, argv[optCount], 0); |
---|
[3251] | 103 | |
---|
[3300] | 104 | |
---|
[2018] | 105 | orxonoxGUI->showall (); |
---|
| 106 | |
---|
[3298] | 107 | //// Handling special Cases. /// |
---|
| 108 | |
---|
| 109 | // case update // |
---|
| 110 | #ifdef HAVE_CURL |
---|
| 111 | if (static_cast<Option*>(orxonoxGUI->findWidgetByName("auto update", 0))->value == 1) |
---|
| 112 | { |
---|
| 113 | update->checkForUpdates(); |
---|
| 114 | } |
---|
| 115 | #endif /* HAVE_CURL */ |
---|
| 116 | |
---|
| 117 | // case start-with-gui. |
---|
[3296] | 118 | if (!access(exec->getConfigFile(), F_OK) && static_cast<Option*>(orxonoxGUI->findWidgetByName("Always Show this Menu", 0))->value == 0) |
---|
[3303] | 119 | OrxonoxGuiExec::startOrxonox(NULL, exec); |
---|
[3296] | 120 | else |
---|
[3305] | 121 | { |
---|
[3303] | 122 | #ifdef HAVE_GTK2 |
---|
[3305] | 123 | mainloopGUI(); |
---|
[3166] | 124 | #else /* HAVE_GTK2 */ |
---|
[3305] | 125 | char boolAns = 'y'; |
---|
| 126 | char ans[10]; |
---|
| 127 | while(true) |
---|
| 128 | { |
---|
| 129 | PRINT(0)(" Listing all the Orxonox Options: \n"); |
---|
| 130 | PRINT(0)(" #############################\n"); |
---|
| 131 | Window::mainWindow->walkThrough(Widget::listOptionsAndGroups, 1); |
---|
| 132 | |
---|
| 133 | PRINT(0)("\nDo you want change any of the above values now? [Yn] "); |
---|
| 134 | cin >>boolAns ; |
---|
| 135 | if (boolAns =='n' || boolAns=='N') |
---|
| 136 | break; |
---|
[3166] | 137 | |
---|
[3305] | 138 | PRINT(0)("\n Listing all groups\n"); |
---|
| 139 | PRINT(0)(" #################\n"); |
---|
| 140 | int groupCount = 0; |
---|
| 141 | Window::mainWindow->walkThrough(Widget::listGroups, &groupCount, 1); |
---|
| 142 | |
---|
| 143 | PRINT(0)("\nIn which Group? [1-%d] ", groupCount); |
---|
| 144 | Packer* group; |
---|
| 145 | while(true) |
---|
| 146 | { |
---|
| 147 | cin >> ans; |
---|
| 148 | int ansIp = atoi(ans); |
---|
| 149 | if (ansIp <= groupCount) |
---|
| 150 | { |
---|
| 151 | group = static_cast<Packer*>(Window::mainWindow->findGroupByNumber(&ansIp, 1)); |
---|
| 152 | break; |
---|
| 153 | } |
---|
| 154 | else |
---|
| 155 | PRINT(0)("\nChoose a smaler Number please: [1-%d] ", groupCount); |
---|
| 156 | } |
---|
| 157 | PRINT(0)("\n\nGroup: [%s]\n\n", group->groupName); |
---|
| 158 | int optionCount = 0; |
---|
| 159 | group->walkThrough(Widget::listOptions, &optionCount, 0); |
---|
| 160 | PRINT(0)("\nWhich Option? [1-%d] ", optionCount); |
---|
| 161 | Option* option; |
---|
| 162 | while(true) |
---|
| 163 | { |
---|
| 164 | cin >> ans; |
---|
| 165 | int ansIp = atoi(ans); |
---|
| 166 | if (ansIp <= groupCount) |
---|
| 167 | { |
---|
| 168 | option = static_cast<Option*>(group->findOptionByNumber(&ansIp, 0)); |
---|
| 169 | break; |
---|
| 170 | } |
---|
| 171 | else |
---|
| 172 | PRINT(0)("\nChoose a smaler Number please: [1-%d] ", optionCount); |
---|
| 173 | } |
---|
| 174 | PRINT(0)("\n\n:: %s ::\n", option->title); |
---|
| 175 | |
---|
| 176 | // here follows the rest.... this will be nasty. |
---|
| 177 | //! \todo move this into the gui-gtk-file |
---|
| 178 | //! \todo finish it. |
---|
| 179 | } |
---|
| 180 | } |
---|
| 181 | |
---|
[3166] | 182 | #endif /* HAVE_GTK2 */ |
---|
[2018] | 183 | } |
---|