Changeset 446


Ignore:
Timestamp:
12/13/09 16:23:00 (10 years ago)
Author:
eliedebrauwer
Message:

Ticket #186: Patch by eliedebrauwer. Added possibility to pause/unpause the game. Pausing can be triggered now by pressing the pause button (hey it's there for a reason, let's use it). I also added a pause command in the console and updated the help strings to reflect this. Btw, this makes use of the get|setTimeMultiplier calls which FIFE map objects offers, these can also be used to speed up/slow down the game. fixes[s:trac, t:186]

Location:
trunk/game/scripts
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/scripts/console.py

    r416 r446  
    2424        @param appListener: ApplicationListener object providing a link with 
    2525        the engine, the world and the model""" 
    26         exit_help = "Terminate application" 
    27         grid_help = "Toggle grid display" 
    28         run_help = "Toggle player run/walk" 
    29         help_help = "Show this help string" 
    30         load_help = "load directory file" 
     26        exit_help   = "Terminate application" 
     27        grid_help   = "Toggle grid display" 
     28        run_help    = "Toggle player run/walk" 
     29        help_help   = "Show this help string" 
     30        load_help   = "Usage: load directory file" 
    3131        python_help = "Run some python code" 
    32         quit_help = "Terminate application" 
    33         save_help = "save directory file" 
     32        quit_help   = "Terminate application" 
     33        save_help   = "Usage: save directory file" 
     34        pause_help  = "Pause/Unpause the game" 
    3435 
    3536        self.commands = [ 
    3637            {"cmd":"exit"  ,"callback":self.handleQuit  ,"help": exit_help}, 
    3738            {"cmd":"grid"  ,"callback":self.handleGrid  ,"help": grid_help}, 
    38             {"cmd":"run"   ,"callback":self.handleRun   ,"help": run_help}, 
    3939            {"cmd":"help"  ,"callback":self.handleHelp  ,"help": help_help}, 
    4040            {"cmd":"load"  ,"callback":self.handleLoad  ,"help": load_help}, 
     41            {"cmd":"pause" ,"callback":self.handlePause ,"help": pause_help}, 
    4142            {"cmd":"python","callback":self.handlePython,"help": python_help}, 
     43            {"cmd":"run"   ,"callback":self.handleRun   ,"help": run_help}, 
     44            {"cmd":"save"  ,"callback":self.handleSave  ,"help": save_help}, 
    4245            {"cmd":"quit"  ,"callback":self.handleQuit  ,"help": quit_help}, 
    43             {"cmd":"save"  ,"callback":self.handleSave  ,"help": save_help}, 
    4446        ] 
    4547        self.app_listener = app_listener 
     
    5860        return "Terminating ..." 
    5961 
     62    def handlePause(self, command): 
     63        """ 
     64        Implements the pause console command 
     65        @type command: string 
     66        @param command: The command to run 
     67        @return: The resultstring""" 
     68         
     69        self.world.togglePause() 
     70        return "Game (un)paused" 
     71     
    6072    def handleGrid(self, command): 
    6173        """  
  • trunk/game/scripts/gui/hud.py

    r445 r446  
    211211        k_text += "[br] F5 : Take a screenshot" 
    212212        k_text += "[br]      (saves to <parpg>/screenshots/)" 
     213        k_text += "[br] F10 : Toggle console" 
     214        k_text += "[br] PAUSE : (Un)Pause the game" 
    213215        k_text += "[br] Q : Quit the game" 
    214216        self.help_dialog.distributeInitialData({ 
  • trunk/game/scripts/map.py

    r412 r446  
    147147        # Make World aware that this is now the active map. 
    148148        self.data.view.active_map = self 
     149 
    149150                 
    150151    def addPC(self): 
     
    168169        renderer.setEnabled(not renderer.isEnabled()) 
    169170 
     171    def togglePause(self): 
     172        """ Pause/Unpause the game. 
     173            @return: nothing"""         
     174         
     175        # Time multiplier is a float, never do equals on floats 
     176        if self.map.getTimeMultiplier() >= 1.0: 
     177            self.map.setTimeMultiplier(0.0) 
     178        else: 
     179            self.map.setTimeMultiplier(1.0) 
  • trunk/game/scripts/world.py

    r424 r446  
    9494    def quitGame(self): 
    9595        """Quits the game 
    96         @return: None""" 
     96           @return: None""" 
    9797        self.quitFunction() 
    9898 
     
    188188        if(key_val == key.M): 
    189189            self.sounds.toggleMusic() 
     190        if(key_val == key.PAUSE): 
     191            # Pause pause/unpause the game  
     192            self.togglePause() 
    190193 
    191194    def mouseReleased(self, evt): 
     
    341344        return location 
    342345 
     346    def togglePause(self): 
     347        """ Pause/Unpause the game. 
     348            @return: nothing""" 
     349         
     350        self.active_map.togglePause() 
     351     
    343352    def deleteMaps(self): 
    344353        """Clear all currently loaded maps from FIFE as well as clear our 
Note: See TracChangeset for help on using the changeset viewer.