SuperTuxKart
credits.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 
19 #ifndef HEADER_CREDITS_HPP
20 #define HEADER_CREDITS_HPP
21 
22 #include <rect.h>
23 namespace irr
24 {
25  namespace video { class IVideoDriver; }
26 }
27 
28 using namespace irr;
29 
30 #include "audio/music_manager.hpp"
31 #include "guiengine/screen.hpp"
32 #include "utils/ptr_vector.hpp"
33 
34 
35 class CreditsSection;
36 
42  public GUIEngine::ScreenSingleton<CreditsScreen>
43 {
44  // ----------------------------------------------------------------------------------------
47  {
48  SECTION_FADE_IN = 0,
49  ELEMENTS_DISPLAY = 1,
50  SECTION_FADE_OUT = 2,
51  PAUSE_BETWEEN_SECTIONS = 3
52  };
53 
55  CreditsSection* getCurrentSection();
56 
57  int m_x, m_y, m_w, m_h;
58  core::rect< s32 > m_section_rect;
59 
60  int m_curr_section;
61  int m_curr_element;
62 
63  CreditStage m_current_stage;
64 
65  float m_time_til_next_step;
66 
68  CreditsScreen();
69  bool getLineAsWide(std::ifstream& file, core::stringw* out);
70  float displayTimeForElement(int element_id);
71  void drawEntries();
72 
73  bool m_is_victory_music;
74  void updateAreaSize();
75 public:
76 
77 
78  void setArea(const int x, const int y, const int w, const int h);
79 
80  // start from beginning again
81  void reset();
82 
84  virtual void loadedFromFile() OVERRIDE;
85 
88  void onDraw(float dt) OVERRIDE;
89 
91  void init() OVERRIDE;
92 
94  void eventCallback(GUIEngine::Widget* widget, const std::string& name,
95  const int playerID) OVERRIDE;
96 
97  void setVictoryMusic(bool isVictory) { m_is_victory_music = isVictory; }
98 
99  virtual MusicInformation* getMusic() const OVERRIDE
100  {
101  if (m_is_victory_music)
102  return music_manager->getMusicInformation("win_theme.music");
103  else
104  return stk_config->m_title_music;
105  }
106 
107  virtual void onResize() OVERRIDE
108  {
110  updateAreaSize();
111  }
112 };
113 
114 #endif
Screen where STK credits are shown.
Definition: credits.hpp:43
virtual void onResize() OVERRIDE
optional callback you can override to be notified at every resize.
Definition: credits.hpp:107
virtual MusicInformation * getMusic() const OVERRIDE
Definition: credits.hpp:99
CreditStage
Used to track the current stage of credit display.
Definition: credits.hpp:47
Definition: credits.cpp:62
Declares a class to be a singleton.
Definition: screen.hpp:59
Represents a single GUI screen.
Definition: screen.hpp:94
virtual void onResize()
optional callback you can override to be notified at every resize.
Definition: screen.cpp:233
Wrapper around an instance of the Music interface Adds information like composer, song title,...
Definition: music_information.hpp:43
MusicInformation * getMusicInformation(const std::string &filename)
Definition: music_manager.cpp:284
MusicInformation * m_title_music
Filename of the title music to play.
Definition: stk_config.hpp:170
Contains all GUI engine related classes and functions.
Definition: abstract_state_manager.hpp:33