SuperTuxKart
options_screen_display.hpp
1 // SuperTuxKart - a fun racing game with go-kart
2 // Copyright (C) 2009-2015 Marianne Gagnon
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 3
7 // of the License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 
18 #ifndef SERVER_ONLY // No GUI files in server builds
19 #ifndef __HEADER_OPTIONS_SCREEN_DISPLAY_HPP__
20 #define __HEADER_OPTIONS_SCREEN_DISPLAY_HPP__
21 
22 #include <string>
23 
24 #include "guiengine/screen.hpp"
25 
26 namespace GUIEngine { class Widget; }
27 
28 struct Resolution
29 {
30  int width;
31  int height;
32  bool fullscreen;
33 
34  Resolution()
35  {
36  width = 0;
37  height = 0;
38  }
39 
40  Resolution(int w, int h)
41  {
42  width = w;
43  height = h;
44  }
45 
46  bool operator< (Resolution r) const
47  {
48  return width < r.width || (width == r.width && height < r.height);
49  }
50 
51  float getRatio() const
52  {
53  return (float) width / height;
54  }
55 };
56 
61 class OptionsScreenDisplay : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<OptionsScreenDisplay>
62 {
63 private:
64  static bool m_fullscreen_checkbox_focus;
66  bool m_inited;
67  std::vector<Resolution> m_resolutions;
68 
69  void updateResolutionsList();
70  void configResolutionsList();
71 
72  static void onScrollResolutionsList(void* data);
73 public:
75 
77  virtual void loadedFromFile() OVERRIDE;
78 
80  virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name,
81  const int playerID) OVERRIDE;
82 
84  virtual void init() OVERRIDE;
85 
87  virtual void tearDown() OVERRIDE;
88 
90  virtual void unloaded() OVERRIDE;
91 
92  virtual bool onEscapePressed() OVERRIDE;
93 
94  virtual void onResize() OVERRIDE;
95 
96  void updateCamera();
97 };
98 
99 #endif
100 #endif // ifndef SERVER_ONLY
Declares a class to be a singleton.
Definition: screen.hpp:59
Represents a single GUI screen.
Definition: screen.hpp:94
The nearly-abstract base of all widgets (not fully abstract since a bare Widget can be created for th...
Definition: widget.hpp:147
Display options screen.
Definition: options_screen_display.hpp:62
virtual bool onEscapePressed() OVERRIDE
Called when escape is pressed.
Definition: options_screen_display.cpp:505
virtual void init() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: options_screen_display.cpp:84
virtual void eventCallback(GUIEngine::Widget *widget, const std::string &name, const int playerID) OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: options_screen_display.cpp:372
virtual void tearDown() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: options_screen_display.cpp:496
virtual void unloaded() OVERRIDE
implement optional callback from parent class GUIEngine::Screen
Definition: options_screen_display.cpp:513
virtual void onResize() OVERRIDE
optional callback you can override to be notified at every resize.
Definition: options_screen_display.cpp:159
virtual void loadedFromFile() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: options_screen_display.cpp:50
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33
Definition: options_screen_display.hpp:29