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 <QtGui/QLayout> |
---|
30 | #include "sdlincl.h" |
---|
31 | #include "debug.h" |
---|
32 | |
---|
33 | |
---|
34 | #include <QtGui/QPushButton> |
---|
35 | #include <QtGui/QCheckBox> |
---|
36 | #include <QtGui/QComboBox> |
---|
37 | |
---|
38 | namespace OrxGui |
---|
39 | { |
---|
40 | /** |
---|
41 | * Creates the Video-Option-Frame |
---|
42 | */ |
---|
43 | GuiVideo::GuiVideo(QWidget* parent) |
---|
44 | : Element("Video"), QGroupBox(parent) |
---|
45 | { |
---|
46 | QGridLayout* layout = new QGridLayout(this); |
---|
47 | |
---|
48 | { |
---|
49 | QCheckBox* fullscreen = new QCheckBox(QString("FullScreen"), this); |
---|
50 | //fullscreen->setName(); |
---|
51 | layout->addWidget(fullscreen, 0, 0); |
---|
52 | |
---|
53 | QCheckBox* wireframe = new QCheckBox("Wireframe mode", this); |
---|
54 | layout->addWidget(wireframe, 1, 0); |
---|
55 | |
---|
56 | { |
---|
57 | QComboBox* resolution = new QComboBox(); |
---|
58 | layout->addWidget(resolution, 2, 0); |
---|
59 | std::vector<QString> resolutions; |
---|
60 | this->getResolutions(resolutions); |
---|
61 | for (unsigned int i = 0; i < resolutions.size(); ++i) |
---|
62 | resolution->addItem(resolutions[i]); |
---|
63 | } |
---|
64 | |
---|
65 | } |
---|
66 | |
---|
67 | |
---|
68 | |
---|
69 | /* Frame* videoFrame; //!< The Frame that holds the video options. |
---|
70 | |
---|
71 | videoFrame = new Frame("Video-Options:"); |
---|
72 | videoFrame->setGroupName("video"); |
---|
73 | { |
---|
74 | Box* videoBox; //!< The Box that holds the video options. |
---|
75 | |
---|
76 | videoBox = new Box('v'); |
---|
77 | { |
---|
78 | CheckButton* fullscreen; //!< CheckButton for fullscreen-mode |
---|
79 | Menu* resolution; //!< Menu for the resolution |
---|
80 | CheckButton* wireframe; //!< CheckButton for wireframe Mode. |
---|
81 | |
---|
82 | fullscreen = new CheckButton(CONFIG_NAME_FULLSCREEN); |
---|
83 | fullscreen->setFlagName("windowed", "q", 1); |
---|
84 | fullscreen->setDescription("Starts orxonox in windowed mode"); |
---|
85 | fullscreen->saveability(); |
---|
86 | videoBox->fill(fullscreen); |
---|
87 | resolution = new Menu(CONFIG_NAME_RESOLUTION); |
---|
88 | getResolutions(resolution); |
---|
89 | resolution->saveability(); |
---|
90 | resolution->setFlagName("resolution", "r", 0); |
---|
91 | resolution->setDescription("Sets the resolution of orxonox"); |
---|
92 | videoBox->fill(resolution); |
---|
93 | wireframe = new CheckButton(CONFIG_NAME_WIREFRAME); |
---|
94 | wireframe->setFlagName("wireframe", "w", 0); |
---|
95 | wireframe->setDescription("Starts orxonox in wireframe mode"); |
---|
96 | wireframe->saveability(); |
---|
97 | videoBox->fill(wireframe); |
---|
98 | |
---|
99 | videoBox->fill(advancedWindowCreate()); |
---|
100 | } |
---|
101 | videoFrame->fill(videoBox); |
---|
102 | } |
---|
103 | setMainWidget(videoFrame);*/ |
---|
104 | } |
---|
105 | |
---|
106 | /** |
---|
107 | * Destructs the Video-stuff |
---|
108 | */ |
---|
109 | GuiVideo::~GuiVideo() |
---|
110 | { |
---|
111 | // nothing to do here. |
---|
112 | } |
---|
113 | |
---|
114 | /** |
---|
115 | * sets all resolutions to the menu |
---|
116 | * @param menu the Menu to set The resolutions to. |
---|
117 | */ |
---|
118 | void GuiVideo::getResolutions(std::vector<QString>& resolutionList) |
---|
119 | { |
---|
120 | SDL_Init(SDL_INIT_VIDEO); |
---|
121 | SDL_Rect **modes; |
---|
122 | int i; |
---|
123 | int x = 0,y =0; // check for difference |
---|
124 | char tmpChar[100]; |
---|
125 | |
---|
126 | /* Get available fullscreen/hardware modes */ |
---|
127 | modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE); |
---|
128 | |
---|
129 | /* Check is there are any modes available */ |
---|
130 | if(modes == (SDL_Rect **)0) |
---|
131 | { |
---|
132 | PRINTF(2)("No video-modes available!\n"); |
---|
133 | exit(-1); |
---|
134 | } |
---|
135 | |
---|
136 | /* Check if our resolution is restricted */ |
---|
137 | if(modes == (SDL_Rect **)-1) |
---|
138 | { |
---|
139 | PRINTF(2)("All resolutions available.\n"); |
---|
140 | } |
---|
141 | else |
---|
142 | { |
---|
143 | /* Print valid modes */ |
---|
144 | PRINT(5)("Available Modes\n"); |
---|
145 | for(i = 0; modes[i] ;++i) |
---|
146 | { |
---|
147 | if (x != modes[i]->w || y != modes[i]->h) |
---|
148 | { |
---|
149 | PRINTF(5)(" %d x %d\n", modes[i]->w, modes[i]->h); |
---|
150 | sprintf(tmpChar, "%dx%d", modes[i]->w, modes[i]->h); |
---|
151 | resolutionList.push_back(QString(tmpChar)); |
---|
152 | x = modes[i]->w; y = modes[i]->h; |
---|
153 | } |
---|
154 | } |
---|
155 | } |
---|
156 | SDL_QuitSubSystem(SDL_INIT_VIDEO); |
---|
157 | SDL_Quit(); |
---|
158 | } |
---|
159 | |
---|
160 | } |
---|