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 | |
---|
27 | #include "gui_video.h" |
---|
28 | |
---|
29 | #include "gui_gtk.h" |
---|
30 | #include "glincl.h" |
---|
31 | #include <stdlib.h> |
---|
32 | |
---|
33 | /** |
---|
34 | \brief Creates the Video-Option-Frame |
---|
35 | */ |
---|
36 | GuiVideo::GuiVideo(void) |
---|
37 | { |
---|
38 | Frame* videoFrame; //!< The Frame that holds the video options. |
---|
39 | |
---|
40 | videoFrame = new Frame("Video-Options:"); |
---|
41 | videoFrame->setGroupName("video"); |
---|
42 | { |
---|
43 | Box* videoBox; //!< The Box that holds the video options. |
---|
44 | |
---|
45 | videoBox = new Box('v'); |
---|
46 | { |
---|
47 | CheckButton* fullscreen; //!< CheckButton for fullscreen-mode |
---|
48 | Menu* resolution; //!< Menu for the resolution |
---|
49 | CheckButton* wireframe; //!< CheckButton for wireframe Mode. |
---|
50 | |
---|
51 | fullscreen = new CheckButton(CONFIG_NAME_FULLSCREEN); |
---|
52 | fullscreen->setFlagName("windowed", "q", 1); |
---|
53 | fullscreen->saveability(); |
---|
54 | videoBox->fill(fullscreen); |
---|
55 | resolution = new Menu(CONFIG_NAME_RESOLUTION); |
---|
56 | getResolutions(resolution); |
---|
57 | resolution->saveability(); |
---|
58 | resolution->setFlagName("resolution", "r", 0); |
---|
59 | videoBox->fill(resolution); |
---|
60 | wireframe = new CheckButton(CONFIG_NAME_WIREFRAME); |
---|
61 | wireframe->setFlagName("wireframe", "w", 0); |
---|
62 | wireframe->saveability(); |
---|
63 | videoBox->fill(wireframe); |
---|
64 | |
---|
65 | videoBox->fill(advancedWindowCreate()); |
---|
66 | } |
---|
67 | videoFrame->fill(videoBox); |
---|
68 | } |
---|
69 | setMainWidget(videoFrame); |
---|
70 | } |
---|
71 | |
---|
72 | /** |
---|
73 | \brief Destructs the Video-stuff |
---|
74 | */ |
---|
75 | GuiVideo::~GuiVideo(void) |
---|
76 | { |
---|
77 | // nothing to do here. |
---|
78 | } |
---|
79 | |
---|
80 | /** |
---|
81 | \brief Creates a window, and all it contains for the Source-update. |
---|
82 | */ |
---|
83 | Widget* GuiVideo::advancedWindowCreate(void) |
---|
84 | { |
---|
85 | // advanced-Performance-Options |
---|
86 | Window* advancedWindow; //!< A Window to display advanced options. |
---|
87 | Button* advancedButton; //!< A Button to open the Advanced Video Performance Window. |
---|
88 | // the button, that opens this Window. |
---|
89 | advancedButton = new Button("advanced"); |
---|
90 | |
---|
91 | // the Window itself |
---|
92 | advancedWindow = new Window("Advanced Video Options"); |
---|
93 | advancedWindow->setGroupName(CONFIG_SECTION_VIDEO_ADVANCED); |
---|
94 | { |
---|
95 | Box* advancedBox; //!< A Box to pack the options into. |
---|
96 | |
---|
97 | advancedBox = new Box('v'); |
---|
98 | { |
---|
99 | CheckButton* shadows; //!< CheckButton for shadows |
---|
100 | CheckButton* fog; //!< CheckButton for fog. |
---|
101 | CheckButton* reflections; //!< CheckButton for reflections |
---|
102 | CheckButton* textures; //!< CheckButton for textures |
---|
103 | Menu* textureDetail; //!< Menu for the Texture-Detail. |
---|
104 | Label* modelDetailLabel; //!< Label for model-detail. |
---|
105 | Menu* modelDetail; //!< model-detail. |
---|
106 | CheckButton* particles; //!< If the Particles should be enabled |
---|
107 | Label* antiAliasingLabel; //!< Label for the anti-aliasing mode. |
---|
108 | Menu* antiAliasing; //!< Menu for the Antialiasing-mode. |
---|
109 | Label* filterMethodLabel; //!< Label for filtering-Method. |
---|
110 | Menu* filterMethod; //!< Menu for filtering Method. |
---|
111 | Button* closeButton; //!< A Button to close the Advanced-settingsWindow. |
---|
112 | |
---|
113 | // Advanced Performance Options |
---|
114 | shadows = new CheckButton(CONFIG_NAME_SHADOWS); |
---|
115 | shadows->saveability(); |
---|
116 | advancedBox->fill(shadows); |
---|
117 | |
---|
118 | fog = new CheckButton(CONFIG_NAME_FOG); |
---|
119 | fog->saveability(); |
---|
120 | advancedBox->fill(fog); |
---|
121 | |
---|
122 | reflections = new CheckButton(CONFIG_NAME_REFLECTIONS); |
---|
123 | reflections->saveability(); |
---|
124 | advancedBox->fill(reflections); |
---|
125 | |
---|
126 | textures = new CheckButton(CONFIG_NAME_TEXTURES); |
---|
127 | textures->saveability(); |
---|
128 | advancedBox->fill(textures); |
---|
129 | |
---|
130 | textureDetail = new Menu(CONFIG_NAME_TEXTURE_DETAIL, "low", "medium", "high", "lastItem"); |
---|
131 | textureDetail->setDefaultValue(1); |
---|
132 | textureDetail->saveability(); |
---|
133 | advancedBox->fill(textureDetail); |
---|
134 | |
---|
135 | modelDetailLabel = new Label(CONFIG_NAME_MODEL_DETAIL); |
---|
136 | advancedBox->fill(modelDetailLabel); |
---|
137 | modelDetail = new Menu(CONFIG_NAME_MODEL_DETAIL, "low", "high", "lastItem"); |
---|
138 | modelDetail->setDefaultValue(1); |
---|
139 | modelDetail->saveability(); |
---|
140 | advancedBox->fill(modelDetail); |
---|
141 | |
---|
142 | particles = new CheckButton(CONFIG_NAME_PARTICLES_ENABLED); |
---|
143 | particles->saveability(); |
---|
144 | particles->setDefaultValue(1); |
---|
145 | advancedBox->fill(particles); |
---|
146 | |
---|
147 | antiAliasingLabel = new Label("Anti-Aliasing-depth:"); |
---|
148 | advancedBox->fill(antiAliasingLabel); |
---|
149 | antiAliasing = new Menu(CONFIG_NAME_ANTI_ALIASING, "0", "1", "2", "4", "8", "lastItem"); |
---|
150 | antiAliasing->setDefaultValue(2); |
---|
151 | antiAliasing->saveability(); |
---|
152 | advancedBox->fill(antiAliasing); |
---|
153 | |
---|
154 | filterMethodLabel = new Label("Filtering Method:"); |
---|
155 | advancedBox->fill(filterMethodLabel); |
---|
156 | filterMethod = new Menu(CONFIG_NAME_FILTER_METHOD, "none", "linear", "bilinear", "trilinear", "anisortopic", "lastItem"); |
---|
157 | filterMethod->setDefaultValue(1); |
---|
158 | filterMethod->saveability(); |
---|
159 | advancedBox->fill(filterMethod); |
---|
160 | |
---|
161 | |
---|
162 | |
---|
163 | closeButton = new Button("close"); |
---|
164 | #ifdef HAVE_GTK2 |
---|
165 | closeButton->connectSignal("button_press_event", advancedWindow, Window::windowClose); |
---|
166 | #endif /* HAVE_GTK2 */ |
---|
167 | |
---|
168 | advancedBox->fill(closeButton); |
---|
169 | } |
---|
170 | advancedWindow->fill(advancedBox); |
---|
171 | } |
---|
172 | #ifdef HAVE_GTK2 |
---|
173 | advancedButton->connectSignal("button_press_event", advancedWindow, Window::windowOpen); |
---|
174 | advancedWindow->connectSignal("destroy", advancedWindow, Window::windowClose); |
---|
175 | advancedWindow->connectSignal("delete_event", advancedWindow, Window::windowClose); |
---|
176 | #endif /* HAVE_GTK2 */ |
---|
177 | Window::addWindow(advancedWindow); |
---|
178 | |
---|
179 | return advancedButton; |
---|
180 | } |
---|
181 | |
---|
182 | /** |
---|
183 | \brief sets all resolutions to the menu |
---|
184 | \param menu the Menu to set The resolutions to. |
---|
185 | */ |
---|
186 | void GuiVideo::getResolutions(Menu* menu) |
---|
187 | { |
---|
188 | SDL_Init(SDL_INIT_VIDEO); |
---|
189 | SDL_Rect **modes; |
---|
190 | int i; |
---|
191 | int x = 0,y =0; // check for difference |
---|
192 | char tmpChar[100]; |
---|
193 | |
---|
194 | /* Get available fullscreen/hardware modes */ |
---|
195 | modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE); |
---|
196 | |
---|
197 | /* Check is there are any modes available */ |
---|
198 | if(modes == (SDL_Rect **)0){ |
---|
199 | PRINTF(2)("No video-modes available!\n"); |
---|
200 | exit(-1); |
---|
201 | } |
---|
202 | |
---|
203 | /* Check if our resolution is restricted */ |
---|
204 | if(modes == (SDL_Rect **)-1){ |
---|
205 | PRINTF(2)("All resolutions available.\n"); |
---|
206 | } |
---|
207 | else{ |
---|
208 | /* Print valid modes */ |
---|
209 | PRINT(4)("Available Modes\n"); |
---|
210 | for(i = 0; modes[i] ;++i) |
---|
211 | { |
---|
212 | if (x != modes[i]->w || y != modes[i]->h) |
---|
213 | { |
---|
214 | PRINT(4)(" %d x %d\n", modes[i]->w, modes[i]->h); |
---|
215 | sprintf(tmpChar, "%dx%d", modes[i]->w, modes[i]->h); |
---|
216 | menu->addItem(tmpChar); |
---|
217 | x = modes[i]->w; y = modes[i]->h; |
---|
218 | } |
---|
219 | } |
---|
220 | } |
---|
221 | SDL_Quit(); |
---|
222 | } |
---|