Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/qt_gui/src/lib/gui/qt_gui/gui_video.cc @ 7633

Last change on this file since 7633 was 7633, checked in by bensch, 18 years ago

better default values

File size: 4.7 KB
Line 
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 "globals.h"
31#include "debug.h"
32
33#include "qt_gui_elements.h"
34
35namespace OrxGui
36{
37  /**
38   *  Creates the Video-Option-Frame
39  */
40  GuiVideo::GuiVideo(OrxGui::Gui* gui)
41  : Element(CONFIG_SECTION_VIDEO, gui), QGroupBox()
42  {
43    QGridLayout* layout = new QGridLayout(this);
44
45    {
46      QtGuiCheckBox* fullscreen = new QtGuiCheckBox(CONFIG_NAME_FULLSCREEN, this, false);
47      //fullscreen->setName();
48      layout->addWidget(fullscreen, 0, 0);
49
50      QtGuiCheckBox* wireframe = new QtGuiCheckBox(CONFIG_NAME_WIREFRAME, this, false);
51      layout->addWidget(wireframe, 1, 0);
52
53      {
54        QComboBox* resolution = new QtGuiComboBox(CONFIG_NAME_RESOLUTION, this, "640x480");
55        layout->addWidget(resolution, 2, 0);
56        std::vector<QString> resolutions;
57        this->getResolutions(resolutions);
58        for (unsigned int i = 0; i < resolutions.size(); ++i)
59          resolution->addItem(resolutions[i]);
60      }
61
62
63      QGroupBox* advanced = new GuiAdvancedVideo(gui);
64
65
66      layout->addWidget(advanced, 0, 2, 4, 1);
67
68    }
69  }
70
71  /**
72   *  Destructs the Video-stuff
73  */
74  GuiVideo::~GuiVideo()
75  {
76    // nothing to do here.
77  }
78
79  /**
80   *  sets all resolutions to the menu
81   * @param menu the Menu to set The resolutions to.
82  */
83  void GuiVideo::getResolutions(std::vector<QString>& resolutionList)
84  {
85    SDL_Init(SDL_INIT_VIDEO);
86    SDL_Rect **modes;
87    int i;
88    int x = 0,y =0; // check for difference
89    char tmpChar[100];
90
91    /* Get available fullscreen/hardware modes */
92    modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
93
94    /* Check is there are any modes available */
95    if(modes == (SDL_Rect **)0)
96    {
97      PRINTF(2)("No video-modes available!\n");
98      exit(-1);
99    }
100
101    /* Check if our resolution is restricted */
102    if(modes == (SDL_Rect **)-1)
103    {
104      PRINTF(2)("All resolutions available.\n");
105    }
106    else
107    {
108      /* Print valid modes */
109      PRINT(5)("Available Modes\n");
110      for(i = 0; modes[i] ;++i)
111      {
112        if (x != modes[i]->w || y != modes[i]->h)
113        {
114          PRINTF(5)("  %d x %d\n", modes[i]->w, modes[i]->h);
115          sprintf(tmpChar, "%dx%d", modes[i]->w, modes[i]->h);
116          resolutionList.push_back(QString(tmpChar));
117          x = modes[i]->w; y = modes[i]->h;
118        }
119      }
120    }
121    SDL_QuitSubSystem(SDL_INIT_VIDEO);
122    SDL_Quit();
123  }
124
125
126
127  GuiAdvancedVideo::GuiAdvancedVideo(OrxGui::Gui* gui)
128  : Element(CONFIG_SECTION_VIDEO_ADVANCED ,gui)
129  {
130    {
131      QGridLayout* advLayout = new QGridLayout(this);              //!< Advanced Layout
132      {
133        QtGuiCheckBox* shadows = new QtGuiCheckBox(CONFIG_NAME_SHADOWS, this, true);         //!< CheckBox for shadows
134        advLayout->addWidget(shadows, 0,0);
135        QtGuiCheckBox* fog = new QtGuiCheckBox(CONFIG_NAME_FOG, this, true);                 //!< CheckBox for fog.
136        advLayout->addWidget(fog, 1,0);
137        QtGuiCheckBox* reflections = new QtGuiCheckBox(CONFIG_NAME_REFLECTIONS, this, true);  //!< CheckBox for reflections
138        advLayout->addWidget(reflections, 2, 0);
139        QtGuiCheckBox* textures = new QtGuiCheckBox(CONFIG_NAME_TEXTURES, this, true);       //!< CheckBox for textures
140        advLayout->addWidget(textures, 3, 0);
141          /*
142        Menu* textureDetail;      //!< Menu for the Texture-Detail.
143        Label* modelDetailLabel;  //!< Label for model-detail.
144        Menu* modelDetail;        //!< model-detail.
145        CheckBox* particles;   //!< If the Particles should be enabled
146        Label* antiAliasingLabel; //!< Label for the anti-aliasing mode.
147        Menu* antiAliasing;       //!< Menu for the Antialiasing-mode.
148        Label* filterMethodLabel; //!< Label for filtering-Method.
149        Menu* filterMethod;       //!< Menu for filtering Method.
150        Button* closeButton;      //!< A Button to close the Advanced-settingsWindow.
151          */
152      }
153    }
154  }
155
156  GuiAdvancedVideo::~GuiAdvancedVideo()
157  {
158  }
159
160}
Note: See TracBrowser for help on using the repository browser.