zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Widget_Gamestate.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 WIDGET_GAMESTATE_H
31 #define WIDGET_GAMESTATE_H
32 
33 #include <Zeni/Gamestate.h>
34 #include <Zeni/Widget.h>
35 
36 namespace Zeni {
37 
38  class ZENI_REST_DLL Widget_Gamestate : public Gamestate_Base {
40  Widget_Gamestate & operator=(const Widget_Gamestate &);
41 
42  public:
43  Widget_Gamestate(const std::pair<Point2f, Point2f> &virtual_window_, const bool &fix_aspect_ratio_ = true);
44 
45  const std::pair<Point2f, Point2f> & get_virtual_window() const;
46  const bool & fix_aspect_ratio() const;
47 
48  void on_push();
49  void on_pop();
50 
51 #ifndef ANDROID
52  void on_key(const SDL_KeyboardEvent &event);
53  void on_mouse_button(const SDL_MouseButtonEvent &event);
54  void on_mouse_motion(const SDL_MouseMotionEvent &event);
55 #if SDL_VERSION_ATLEAST(2,0,0)
56  void on_mouse_wheel(const SDL_MouseWheelEvent &event);
57 #endif
58 #endif
59  void perform_logic();
60  void render();
61 
62  protected:
64 
65  private:
66 #ifdef _WINDOWS
67 #pragma warning( push )
68 #pragma warning( disable : 4251 )
69 #endif
70  std::pair<Point2i, Point2i> m_viewport;
71  std::pair<Point2f, Point2f> m_virtual_window;
72 #ifdef _WINDOWS
73 #pragma warning( pop )
74 #endif
75  bool m_fix_aspect_ratio;
76 
77  Zeni::Projector2D m_projector;
78 
79  Window::Mouse_State m_mouse_state;
80  bool m_controller_mouse;
81  Color m_clear_color;
82  };
83 
84 }
85 
86 #endif
Gamestate with some helpers for dealing with Widgets.
static void render(const Vertex_Buffer_Macrorenderer &macrorenderer, std::vector< Vertex_Buffer::Vertex_Buffer_Range * > &descriptors)
Keyboard button event structure (event.key.*)
Definition: SDL_events.h:176
The 2D Projector.
Definition: Projector.h:86
A Widget Set.
Definition: Widget.h:1023
Mouse wheel event structure (event.wheel.*)
Definition: SDL_events.h:251
Mouse motion event structure (event.motion.*)
Definition: SDL_events.h:218
Mouse button event structure (event.button.*)
Definition: SDL_events.h:234
The base class for all gamestates.
Definition: Gamestate.h:82
Color.
Definition: Color.h:41
cl_event event
Definition: glew.h:3556