File: control.py

package info (click to toggle)
adonthell-data 0.3.6-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 24,860 kB
  • ctags: 456
  • sloc: python: 5,169; sh: 4,355; makefile: 415; sed: 16
file content (97 lines) | stat: -rw-r--r-- 3,155 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#
#  $Id$
#
#  (C) Copyright 2001/2002 Kai Sterker <kaisterker@linuxgames.com>
#  Part of the Adonthell Project http://adonthell.linuxgames.com
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License.
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY.
#
#  See the COPYING file for more details
#

from adonthell import *

class control(object):

    def run (self):
        # -- bring up the main menu
        if input_has_been_pushed (SDLK_ESCAPE):
            import main_menu

            # -- create main menu without animation, 
            #    with saving and background enabled
            menu = main_menu.main_menu (True, True, True)

            # -- Stop updating the player
            gamedata_player ().set_schedule_active (False)
            gamedata_engine ().set_control_active (False)

            # -- open the main menu
            gamedata_engine ().main (menu, "game_menu")
            
            # -- main menu closed -> see what to do
            if menu.get_result () == 6:
                # -- quit the game
                gamedata_engine ().main_quit ()
            else:
                # -- continue
                gamedata_player ().set_schedule_active (True)
                gamedata_engine ().set_control_active (True)

            win_container.__del__ (menu)


        # -- shortcut to the load screen
        elif input_has_been_pushed (SDLK_l):
            s = data_screen (LOAD_SCREEN)
            s.set_activate (True)	

            # -- Stop updating the player
            gamedata_player ().set_schedule_active (False)
            gamedata_engine ().set_control_active (False)
            
            # -- open the load screen
            gamedata_engine ().main (s, "load_screen")
            
            # -- continue
            gamedata_player ().set_schedule_active (True)
            gamedata_engine ().set_control_active (True)
            

        # -- and to the save screen
        elif input_has_been_pushed (SDLK_s):
            s = data_screen (SAVE_SCREEN)
            s.set_activate (True)	

            # -- Stop updating the player
            gamedata_player ().set_schedule_active (False)
            gamedata_engine ().set_control_active (False)
            
            # -- open the save screen
            gamedata_engine ().main (s, "save_screen")

            # -- continue
            gamedata_player ().set_schedule_active (True)
            gamedata_engine ().set_control_active (True)


        # -- python console
        elif input_has_been_pushed (SDLK_TAB):
            import console

            c = console.console (globals ())
            c.set_activate (True)

            # -- Stop updating the player
            gamedata_player ().set_schedule_active (False)
            gamedata_engine ().set_control_active (False)

            # -- open the console
            gamedata_engine ().main (c, "console")

            # -- continue
            gamedata_player ().set_schedule_active (True)
            gamedata_engine ().set_control_active (True)