zenilib: zenilib/jni/external/zenilib/zeni_rest/Zeni/Title_State.h Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 {
41 Title_State(const Title_State<PLAY_STATE, INSTRUCTIONS_STATE> &);
42 Title_State<PLAY_STATE, INSTRUCTIONS_STATE> & operator=(const Title_State<PLAY_STATE, INSTRUCTIONS_STATE> &);
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:
63 Play_Button()
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
74 class Instructions_Button : public Text_Button {
75 Instructions_Button(const Instructions_Button &);
76 Instructions_Button & operator=(const Instructions_Button &);
77
78 public:
79 Instructions_Button()
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 }
88 } instructions_button;
89
90 #ifndef ANDROID
91 Popup_Menu_State::Configure_Video_Button configure_video_button;
92 #endif
93 Popup_Menu_State::Sound_Check_Box sound_check_box;
94 Popup_Menu_State::Quit_Button quit_button;
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 {
105 m_widgets.lend_Widget(title);
106 m_widgets.lend_Widget(play_button);
107 m_widgets.lend_Widget(instructions_button);
108 #ifndef ANDROID
109 m_widgets.lend_Widget(configure_video_button);
110 #endif
111 m_widgets.lend_Widget(sound_check_box);
112 m_widgets.lend_Widget(quit_button);
113
114 title.set_justify(ZENI_CENTER);
115
116 get_Video().set_clear_Color(get_Colors()["title_bg"]);
117 }
118
119 ~Title_State() {
120 get_Video().set_clear_Color(Color(1.0f, 0.0f, 0.0f, 0.0f));
121 }
122
123 void on_push() {
124 get_Game().controller_mouse.enabled = true;
125 }
126
127 void on_cover() {
128 get_Game().controller_mouse.enabled = false;
129 }
130
131 void on_uncover() {
132 get_Controllers().reset_vibration_all();
133 get_Game().controller_mouse.enabled = true;
134 get_Window().set_mouse_state(Window::MOUSE_NORMAL);
135 }
136
137 #ifndef ANDROID
138 void on_key(const SDL_KeyboardEvent &/*event*/)
139 {
140 }
141 #endif
142
143 void perform_logic() {
144 Widget_Gamestate::perform_logic();
145 get_Video().set_clear_Color(get_Colors()["title_bg"]);
146 }
147
148 };
149
150 }
151
152 #endif
Zeni::get_Controllers
Controllers & get_Controllers()
Get access to the singleton.
Definition: Controllers.cpp:59
Zeni::Title_State::Play_Button::on_accept
void on_accept()
Called when the cursor is released inside the button.
Definition: Title_State.h:69
Zeni::Title_State::Instructions_Button
Definition: Title_State.h:74
Zeni::get_Colors
Colors & get_Colors()
Get access to the singleton.
Definition: Colors.cpp:51
f
GLclampf f
Definition: glew.h:3390
Zeni::Title_State::Instructions_Button::Instructions_Button
Instructions_Button()
Definition: Title_State.h:79
Zeni::Video::set_clear_Color
virtual void set_clear_Color(const Color &color)=0
Set the blank background color.
Definition: Video.cpp:214
Zeni::Title_State::Title::Title
Title(const String &title_)
Definition: Title_State.h:50
Zeni::Widget_Gamestate
Gamestate with some helpers for dealing with Widgets.
Definition: Widget_Gamestate.h:38
Sound_Source_Pool.h
Zeni::Widget_Gamestate::perform_logic
void perform_logic()
Then perform logic. Called by Game as part of the main gameloop.
Definition: Widget_Gamestate.cpp:76
Zeni::Title_State::Title_State
Title_State(const String &title_)
Definition: Title_State.h:96
Zeni::Title_State
Provide a simple title screen for games.
Definition: Title_State.h:40
Zeni::Controllers::reset_vibration_all
void reset_vibration_all()
Set vibration for all controllers to &lt;0,0&gt;
Definition: Controllers.cpp:204
Zeni::Text_Box::give_BG_Renderer
void give_BG_Renderer(Widget_Render_Function *const &renderer)
Set the current Widget_Render_Function, giving the Widget ownership.
Definition: Widget.hxx:612
Zeni::Window::MOUSE_NORMAL
Definition: Window.h:98
Zeni::Title_State::~Title_State
~Title_State()
Definition: Title_State.h:119
Zeni::Title_State::instructions_button
Zeni::Title_State::Instructions_Button instructions_button
Zeni::Window::set_mouse_state
void set_mouse_state(const Mouse_State &mouse_state)
Definition: Window.cpp:478
Zeni::Title_State::Title
Definition: Title_State.h:45
Zeni::Title_State::on_uncover
void on_uncover()
Called when a Gamestate is popped off Game, making this Gamestate on top.
Definition: Title_State.h:131
Zeni::Title_State::Play_Button
Definition: Title_State.h:58
Zeni::get_Game
Game & get_Game()
Get access to the singleton.
Definition: Game.cpp:58
Zeni::ZENI_CENTER
Definition: Font.h:68
Zeni::Title_State::on_key
void on_key(const SDL_KeyboardEvent &)
Override this input callback in your Gamestates. See SDL documentation for details.
Definition: Title_State.h:138
Zeni::String
Definition: String.h:29
Zeni::Title_State::title
Zeni::Title_State::Title title
Zeni::Text_Box
A Text_Box.
Definition: Widget.h:816
SDL_KeyboardEvent
Keyboard button event structure (event.key.*)
Definition: SDL_events.h:176
Zeni::Title_State::on_cover
void on_cover()
Called when a Gamestate is pushed on top of this Gamestate in Game.
Definition: Title_State.h:127
Zeni::Game::controller_mouse
struct Zeni::Game::Controller_Mouse controller_mouse
Zeni::Text_Box::set_justify
void set_justify(const JUSTIFY &justify_)
Definition: Widget.hxx:580
Zeni::Title_State::quit_button
Popup_Menu_State::Quit_Button quit_button
Definition: Title_State.h:94
Zeni::Game::push_state
void push_state(const Gamestate &state)
Push a new Gamestate onto the stack.
Definition: Game.cpp:76
Zeni::Widgets::lend_Widget
void lend_Widget(Widget &widget)
Definition: Widget.hxx:658
Zeni::Title_State::Instructions_Button::on_accept
void on_accept()
Called when the cursor is released inside the button.
Definition: Title_State.h:85
Popup_State.h
Zeni::Title_State::Play_Button::Play_Button
Play_Button()
Definition: Title_State.h:63
Zeni::Title_State::configure_video_button
Popup_Menu_State::Configure_Video_Button configure_video_button
Definition: Title_State.h:91
Zeni::Text_Button
A Text Button Widget.
Definition: Widget.h:492
Zeni::get_Window
Window & get_Window()
Get access to the singleton.
Definition: Window.cpp:392
Zeni::Game::Controller_Mouse::enabled
bool enabled
Definition: Game.h:131
Zeni::Title_State::on_push
void on_push()
Called when the Gamestate is pushed onto the stack in Game.
Definition: Title_State.h:123
Zeni::Title_State::perform_logic
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
Zeni::Title_State::Play_Button play_button
Zeni::get_Video
Video & get_Video()
Get access to the singleton.
Definition: Video.cpp:149
Widget_Gamestate.h
Zeni::Title_State::sound_check_box
Popup_Menu_State::Sound_Check_Box sound_check_box
Definition: Title_State.h:93
Zeni::Point2f
A 2D Point represented with floats.
Definition: Coordinate.h:98
Zeni::Widget_Renderer_Color
Definition: Widget.h:350
Zeni::Widget_Gamestate::m_widgets
Widgets m_widgets
Definition: Widget_Gamestate.h:63
Zeni::Color
Color.
Definition: Color.h:41