Labyrinth
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
splashwindow.hpp
1 //////////////////////////////
2 //
3 // File: lxs/windowing/splashwindow.hpp
4 // Author: Maciej Kaminski
5 // E-mail: maciej.a.kaminski@gmail.com
6 // Website: maciejkaminski.pl
7 //
8 // File creation date: Oct 24 2012
9 // This file is part of Project Labyrinth
10 // This file is going to be released under terms of GNU GPL in near future
11 //
12 //////////////////////////////
13 
14 #ifndef __LXS_SPLASH_WINDOW__
15 #define __LXS_SPLASH_WINDOW__
16 #include "lxs/windowing/window.hpp"
17 #include "lxs/system/configuration.hpp"
18 
19 namespace LxS
20 {
21  namespace CoreGraphics
22  {
23  class Circle;
24  class Font;
25  }
26  namespace Windowing
27  {
28  class Rectangle2D;
29  //! for splashscreens, preloaders and transitions
30  class SplashWindow: public Window
31  {
32  LxS::CoreGraphics::Font * DefaultFont;
33  Window * successor;
34  float splash_time_remaining;
35  float splash_fade_down; //!< fade down rate (how long does it take)
36  float splash_fade_in; //!< fade in rate
37  std::string bitmap;
38  float splash_fade_down_remaining;
39  Rectangle2D * Splash;
40  LxS::CoreGraphics::Circle * progress_indicator;
41  void MaximizeSquareSplash();
42  bool successor_shown;
43  bool continue_after_click;
44  std::string message;
45  public:
46  SplashWindow();
47  ~SplashWindow();
48  //! by default successor is shown immediately after it is loaded;
49  //! setting continue_after_click dusplays message until any key is pressed;
51  {
52  continue_after_click=true;
53  }
54  //! set message to be displayed
55  void SetMessage(std::string s) {message.assign(s);}
56  virtual void Initialize();
57  virtual void AttachChild(Window * child){child->SetParent(GetParent());}
58  virtual void ReplaceChild(Window * old_child, Window * new_child)
59  {new_child->SetParent(GetParent());}
60  private:
61  void ReplaceSelfForSuccessor();
62  public:
63  virtual void Animate(float dt);
64  virtual void Render(Rendermode mode);
65  //! set background bitmap
66  void SetBitmap(const std::string & bitmap)
67  {
68  this->bitmap=bitmap;
69  }
70  //! set window that will be displayed after the splash screen.
71  void SetSuccessor(Window *s);
72  //! return window to be displayed after splash screen
73  Window * GetSuccessor() { return successor;}
75  {if (Splash) MaximizeSquareSplash();}
76  virtual void UnloadResources();
77  virtual void Released(float x, float y)
78  {
79  // if (successor_shown)
80  // {
81  // ReplaceSelfForSuccessor();
82  // successor->Released(x,y);
83  // }
84  }
85  virtual void Clicked(float x, float y);
86  // within interface
87  virtual void Dragged(float x, float y)
88  {
89  // if (successor_shown)
90  // {
91  // ReplaceSelfForSuccessor();
92  // successor->Dragged(x,y);
93  // }
94  }
95  // as degrees given current camera angle!
96  virtual void DraggedAngle(float x, float y)
97  {
98  // if (successor_shown)
99  // {
100  // ReplaceSelfForSuccessor();
101  // successor->DraggedAngle(x,y);
102  // }
103  }
104  unsigned long GetTexelsCount();
105  unsigned long GetFacesCount();
106  };
107  }
108 }
109 #endif