Package fortuneengine :: Module GameEngineConsole
[hide private]
[frames] | no frames]

Source Code for Module fortuneengine.GameEngineConsole

 1  #    FortuneEngine is free software: you can redistribute it and/or modify 
 2  #    it under the terms of the GNU General Public License as published by 
 3  #    the Free Software Foundation, either version 3 of the License, or 
 4  #    (at your option) any later version. 
 5  # 
 6  #    FortuneEngine is distributed in the hope that it will be useful, 
 7  #    but WITHOUT ANY WARRANTY; without even the implied warranty of 
 8  #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 9  #    GNU General Public License for more details. 
10  # 
11  #    You should have received a copy of the GNU General Public License 
12  #    along with the FortuneEngine.  If not, see <http://www.gnu.org/licenses/>. 
13  # 
14  #    Author: Justin Lewis  <jlew.blackout@gmail.com> 
15   
16  from pyconsole.pyconsole import Console 
17   
18   
19 -class GameEngineConsole(Console):
20 """ 21 GameEngineConsole is a class that extends the pyconsole adding 22 in game engine specific functions. 23 """ 24
25 - def __init__(self, gei, pos):
26 """ 27 Init function of the GameEngineConsole 28 29 @param gei: Passing in the Game Engine Instance. 30 @param pos: The position tuple to place the pyconsole 31 (startx, starty, width, height) 32 """ 33 # functions exposed to the console 34 function_list = { 35 "quit": gei.stop_event_loop, 36 37 "list_objects": gei.list_objects, 38 "list_drawcb": gei.list_draw_callbacks, 39 "list_eventcb": gei.list_event_callbacks, 40 "list_timers": gei.list_event_timers, 41 "inspect": gei._inspector.inspect_object, 42 43 "profile_draw":gei.list_draw_time, 44 "profile_event":gei.list_event_time, 45 "profile_timer":gei.list_timer_time, 46 47 "set_str": gei._inspector.set_str, 48 "set_int": gei._inspector.set_int, 49 "set_eval": gei._inspector.set_eval, 50 51 "fps": gei.toggle_fps, 52 } 53 54 # Ctrl + key mappings 55 key_calls = { 56 "d": gei.stop_event_loop, 57 "m": self.console_mode, 58 } 59 60 # Call parent class's init function passing in the 61 # function and key mapping dictionaries 62 Console.__init__(self, gei.screen, pos, 63 functions=function_list, key_calls=key_calls, 64 vars={}, syntax={})
65
66 - def console_mode(self):
67 """ 68 Switches console between console and python interpreter 69 """ 70 # Deactivate Console if showing 71 if self.active: 72 self.set_active() 73 self.setvar("python_mode", 74 not self.getvar("python_mode")) 75 76 self.set_interpreter() 77 self.set_active()
78