File: talk.py

package info (click to toggle)
adonthell-data 0.3.5%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 14,776 kB
  • ctags: 389
  • sloc: python: 4,667; sh: 3,327; makefile: 362; sed: 16
file content (67 lines) | stat: -rwxr-xr-x 2,437 bytes parent folder | download | duplicates (4)
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
#
#  $Id: talk.py,v 1.9 2004/12/13 08:54:34 ksterker Exp $
#
#  (C) Copyright 2001/2003 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
#

# -- mapcharacter Action Event to launch a dialogue with the requester.


import adonthell

class talk:

    def __init__ (self, mapcharacterinstance):
        self.myself = mapcharacterinstance

    def restore_schedule (self, retval, args):
        # -- activate the characters' schedules
        # player isn't event-driven yet
        args[2].set_schedule_active (1)
        if not args[0]: args[2].resume ()
        if not args[1]: args[3].resume ()

        if adonthell.gamedata_get_quest ("demo").get_val ("the_end") != 1:
            adonthell.gamedata_engine ().set_control_active (1)

    def run (self, requester):
        if requester.get_name() == adonthell.gamedata_player ().get_name():
            # -- get characters' current state
            player_state = requester.is_paused ()
            npc_state = self.myself.is_paused ()
            
            # -- deactivate the schedule of the characters involved
            self.myself.pause ()
            requester.pause ()
            # player isn't event-driven yet
            requester.set_schedule_active (0)

            # -- don't allow access to main menu and stuff
            adonthell.gamedata_engine ().set_control_active (0)

            # -- look into the player's face
            self.myself.look_invert (requester.currentmove ())

            # -- init the dialogue engine
            dlg = adonthell.dialog_screen (self.myself, self.myself.get_dialogue (), 0)

            # -- make sure the engine isn't deleted when we leave the script
            dlg.thisown = 0

            # -- attach the callback
            dlg.py_signal_connect (self.restore_schedule, adonthell.win_event_CLOSE, (player_state, npc_state, requester, self.myself))

            # -- add the dialogue window to the win_manager
            adonthell.win_manager_get_active ().add (dlg)
            adonthell.win_manager_get_active ().set_focus (dlg)

            # -- start the dialogue
            dlg.run ()