SuperTuxKart
options_screen_ui.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_UI_HPP__
20 #define __HEADER_OPTIONS_SCREEN_UI_HPP__
21 
22 #include <memory>
23 #include <string>
24 
25 #include "guiengine/screen.hpp"
26 
27 namespace GUIEngine { class Widget; }
28 
33 class OptionsScreenUI : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<OptionsScreenUI>
34 {
35  struct ReloadOption
36  {
37  bool m_reload_font;
38  bool m_reload_skin;
39  std::string m_focus_name;
40  bool m_focus_right;
41  };
42 
43  struct SkinID
44  {
45  core::stringw m_base_theme_name;
46  core::stringw m_variant_name;
47  std::string m_folder_name;
48  };
49  std::unique_ptr<ReloadOption> m_reload_option;
51  bool m_inited;
52 
53  std::vector<SkinID> m_skins;
54  std::vector<core::stringw> m_base_skins;
55  std::vector<core::stringw> m_current_skin_variants;
56  core::stringw m_active_base_skin;
57 
58  GUIEngine::SpinnerWidget* m_base_skin_selector;
59  GUIEngine::SpinnerWidget* m_variant_skin_selector;
60 
61  void updateCamera();
62 
63  void loadSkins(const std::set<std::string>& files, bool addon);
65  int getBaseID(SkinID skin);
66  int getVariantID(SkinID skin);
67  std::string getCurrentSpinnerSkin();
68  void onSkinChange(bool is_variant);
69 public:
71 
73  virtual void loadedFromFile() OVERRIDE;
74 
76  virtual void eventCallback(GUIEngine::Widget* widget, const std::string& name,
77  const int playerID) OVERRIDE;
78 
80  virtual void init() OVERRIDE;
81 
83  virtual void tearDown() OVERRIDE;
84 
86  virtual void unloaded() OVERRIDE;
87 
88  void updateCameraPresetSpinner();
89 
90  virtual void onUpdate(float delta) OVERRIDE;
91 
92  void reloadGUIEngine();
93 };
94 
95 #endif
96 #endif // ifndef SERVER_ONLY
Declares a class to be a singleton.
Definition: screen.hpp:59
Represents a single GUI screen.
Definition: screen.hpp:94
A spinner or gauge widget (to select numbers / percentages).
Definition: spinner_widget.hpp:44
Graphics options screen.
Definition: options_screen_ui.hpp:34
virtual void loadedFromFile() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: options_screen_ui.cpp:47
int getVariantID(SkinID skin)
Returns the spinner value matching the given name.
Definition: options_screen_ui.cpp:381
std::string getCurrentSpinnerSkin()
Returns the folder name of the current skin based on the spinners.
Definition: options_screen_ui.cpp:393
virtual void unloaded() OVERRIDE
implement optional callback from parent class GUIEngine::Screen
Definition: options_screen_ui.cpp:598
virtual void tearDown() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: options_screen_ui.cpp:589
virtual void init() OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: options_screen_ui.cpp:131
virtual void eventCallback(GUIEngine::Widget *widget, const std::string &name, const int playerID) OVERRIDE
implement callback from parent class GUIEngine::Screen
Definition: options_screen_ui.cpp:405
virtual void onUpdate(float delta) OVERRIDE
optional callback you can override to be notified at every frame.
Definition: options_screen_ui.cpp:511
void loadCurrentSkinVariants()
Set up the variant spinner with the appropriate values based on the current base skin.
Definition: options_screen_ui.cpp:332
int getBaseID(SkinID skin)
Returns the spinner value matching the given name.
Definition: options_screen_ui.cpp:369
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33
Definition: options_screen_ui.hpp:36
Definition: options_screen_ui.hpp:44