Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/lib/gui/qt/gui_video.cc @ 8721

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

orxonox/trunk: removed stupid included in base_object.h
this should lead to faster compile-times

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