zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Console_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 #if !defined(ANDROID) && !defined(CONSOLE_STATE_H)
31 #define CONSOLE_STATE_H
32 
33 #include <Zeni/Gamestate.h>
34 #include <Zeni/Widget.h>
35 
36 namespace Zeni {
37 
38  class ZENI_REST_DLL Console_State;
39 
40  struct ZENI_REST_DLL Console_Function {
41  virtual ~Console_Function() {}
42 
43  virtual void operator()(Console_State &console,
44  const String &name,
45  const std::vector<String> &args);
46  };
47 
48  class ZENI_REST_DLL Console_State : public Gamestate_Base {
50  Console_State & operator=(const Console_State &);
51 
52  friend class ZENI_REST_DLL Game;
53 
54  private:
55  Console_State();
56  ~Console_State();
57 
58  Gamestate & get_child();
59  void set_child(Gamestate child);
60  void clear_child();
61 
62  public:
63  void write_to_log(const String &text);
64  void clear_log();
65 
66  void give_function(const String &name, Console_Function * const &function);
67 
68  private:
69  void fire_command(const String &text);
70 
71  void on_event(const SDL_Event &event);
72 
73  void on_key(const SDL_KeyboardEvent &event);
74  void on_mouse_button(const SDL_MouseButtonEvent &event);
75  void on_mouse_motion(const SDL_MouseMotionEvent &event);
76 
77  void perform_logic();
78  void prerender();
79  void render();
80 
81 #ifdef _WINDOWS
82 #pragma warning( push )
83 #pragma warning( disable : 4251 )
84 #endif
85  std::pair<Point2f, Point2f> m_virtual_screen;
86 #ifdef _WINDOWS
87 #pragma warning( pop )
88 #endif
89  Projector2D m_projector;
90 
91 #ifdef _WINDOWS
92 #pragma warning( push )
93 #pragma warning( disable : 4251 )
94 #endif
96 #ifdef _WINDOWS
97 #pragma warning( pop )
98 #endif
99  Text_Box m_log;
100  Text_Box m_prompt;
101 
102 #ifdef _WINDOWS
103 #pragma warning( push )
104 #pragma warning( disable : 4251 )
105 #endif
106  std::map<String, Console_Function *> m_functions;
107 #ifdef _WINDOWS
108 #pragma warning( pop )
109 #endif
110  String m_text;
111  bool m_log_dirty;
112 
113  Gamestate * m_child;
114  bool m_handled_event;
115  };
116 
117 }
118 
119 #endif
static void render(const Vertex_Buffer_Macrorenderer &macrorenderer, std::vector< Vertex_Buffer::Vertex_Buffer_Range * > &descriptors)
EGLImageKHR EGLint * name
Definition: eglext.h:284
An Abstraction of a Quadrilateral.
Definition: Quadrilateral.h:37
The Gamestate Stack.
Definition: Game.h:71
A Text_Box.
Definition: Widget.h:816
Keyboard button event structure (event.key.*)
Definition: SDL_events.h:176
A smartpointer for a Gamestate_Base.
Definition: Gamestate.h:169
The 2D Projector.
Definition: Projector.h:86
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
General event structure.
Definition: SDL_events.h:495
Provide a text console to process commands.
Definition: Console_State.h:48
cl_event event
Definition: glew.h:3556