zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Title_State.h
Go to the documentation of this file.
1 /* This file is part of the Zenipex Library (zenilib).
2  * Copyright (C) 2011 Mitchell Keith Bloch (bazald).
3  *
4  * zenilib is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * zenilib 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 Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with zenilib. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
30 #ifndef TITLE_STATE_H
31 #define TITLE_STATE_H
32 
33 #include <Zeni/Popup_State.h>
34 #include <Zeni/Sound_Source_Pool.h>
35 #include <Zeni/Widget_Gamestate.h>
36 
37 namespace Zeni {
38 
39  template <typename PLAY_STATE, typename INSTRUCTIONS_STATE>
40  class Title_State : public Widget_Gamestate {
43 
44  public:
45  class Title : public Text_Box {
46  Title(const Title &);
47  Title & operator=(const Title &);
48 
49  public:
50  Title(const String &title_)
51  : Text_Box(Point2f(000.0f, 50.0f), Point2f(800.0f, 250.0f),
52  "title", title_, get_Colors()["title_text"])
53  {
54  give_BG_Renderer(new Widget_Renderer_Color(Color(0.0f, 0.0f, 0.0f, 0.0f)));
55  }
56  } title;
57 
58  class Play_Button : public Text_Button {
59  Play_Button(const Play_Button &);
60  Play_Button & operator=(const Play_Button &);
61 
62  public:
64  : Text_Button(Point2f(200.0f, 250.0f), Point2f(600.0f, 310.0f),
65  "system_36_800x600", "Play")
66  {
67  }
68 
69  void on_accept() {
70  get_Game().push_state(new PLAY_STATE());
71  }
72  } play_button;
73 
76  Instructions_Button & operator=(const Instructions_Button &);
77 
78  public:
80  : Text_Button(Point2f(200.0f, 330.0f), Point2f(600.0f, 390.0f),
81  "system_36_800x600", "Instructions")
82  {
83  }
84 
85  void on_accept() {
86  get_Game().push_state(new INSTRUCTIONS_STATE());
87  }
89 
90 #ifndef ANDROID
92 #endif
95 
96  Title_State(const String &title_)
97  : Widget_Gamestate(std::make_pair(Point2f(0.0f, 0.0f), Point2f(800.0f, 600.0f))),
98  title(title_),
99 #ifndef ANDROID
100  configure_video_button(Point2f(200.0f, 410.0f), Point2f(600.0f, 470.0f)),
101 #endif
102  sound_check_box(Point2f(200.0f, 490.0f), Point2f(260.0f, 550.0f)),
103  quit_button(Point2f(400.0f, 490.0f), Point2f(600.0f, 550.0f))
104  {
108 #ifndef ANDROID
110 #endif
113 
115 
116  get_Video().set_clear_Color(get_Colors()["title_bg"]);
117  }
118 
120  get_Video().set_clear_Color(Color(1.0f, 0.0f, 0.0f, 0.0f));
121  }
122 
123  void on_push() {
125  }
126 
127  void on_cover() {
129  }
130 
131  void on_uncover() {
135  }
136 
137 #ifndef ANDROID
138  void on_key(const SDL_KeyboardEvent &/*event*/)
139  {
140  }
141 #endif
142 
143  void perform_logic() {
145  get_Video().set_clear_Color(get_Colors()["title_bg"]);
146  }
147 
148  };
149 
150 }
151 
152 #endif
Controllers & get_Controllers()
Get access to the singleton.
Definition: Controllers.cpp:59
void on_accept()
Called when the cursor is released inside the button.
Definition: Title_State.h:69
Colors & get_Colors()
Get access to the singleton.
Definition: Colors.cpp:51
GLclampf f
Definition: glew.h:3390
virtual void set_clear_Color(const Color &color)=0
Set the blank background color.
Definition: Video.cpp:214
Title(const String &title_)
Definition: Title_State.h:50
Gamestate with some helpers for dealing with Widgets.
void perform_logic()
Then perform logic. Called by Game as part of the main gameloop.
Title_State(const String &title_)
Definition: Title_State.h:96
Provide a simple title screen for games.
Definition: Title_State.h:40
void reset_vibration_all()
Set vibration for all controllers to &lt;0,0&gt;
void give_BG_Renderer(Widget_Render_Function *const &renderer)
Set the current Widget_Render_Function, giving the Widget ownership.
Definition: Widget.hxx:612
Zeni::Title_State::Instructions_Button instructions_button
void set_mouse_state(const Mouse_State &mouse_state)
Definition: Window.cpp:478
void on_uncover()
Called when a Gamestate is popped off Game, making this Gamestate on top.
Definition: Title_State.h:131
Game & get_Game()
Get access to the singleton.
Definition: Game.cpp:58
void on_key(const SDL_KeyboardEvent &)
Override this input callback in your Gamestates. See SDL documentation for details.
Definition: Title_State.h:138
Zeni::Title_State::Title title
A Text_Box.
Definition: Widget.h:816
Keyboard button event structure (event.key.*)
Definition: SDL_events.h:176
void on_cover()
Called when a Gamestate is pushed on top of this Gamestate in Game.
Definition: Title_State.h:127
struct Zeni::Game::Controller_Mouse controller_mouse
void set_justify(const JUSTIFY &justify_)
Definition: Widget.hxx:580
Popup_Menu_State::Quit_Button quit_button
Definition: Title_State.h:94
void push_state(const Gamestate &state)
Push a new Gamestate onto the stack.
Definition: Game.cpp:76
void lend_Widget(Widget &widget)
Definition: Widget.hxx:658
void on_accept()
Called when the cursor is released inside the button.
Definition: Title_State.h:85
Popup_Menu_State::Configure_Video_Button configure_video_button
Definition: Title_State.h:91
A Text Button Widget.
Definition: Widget.h:492
Window & get_Window()
Get access to the singleton.
Definition: Window.cpp:392
void on_push()
Called when the Gamestate is pushed onto the stack in Game.
Definition: Title_State.h:123
void perform_logic()
Then perform logic. Called by Game as part of the main gameloop.
Definition: Title_State.h:143
Zeni::Title_State::Play_Button play_button
Video & get_Video()
Get access to the singleton.
Definition: Video.cpp:149
Popup_Menu_State::Sound_Check_Box sound_check_box
Definition: Title_State.h:93
A 2D Point represented with floats.
Definition: Coordinate.h:98
Color.
Definition: Color.h:41