Debian Codegraph @

scripts/actions/talk.py

raw symbols SCIP
1 #
2 # $Id$
3 #
4 # (C) Copyright 2001/2003 Kai Sterker <[email protected]>
5 # Part of the Adonthell Project http://adonthell.linuxgames.com
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY.
11 #
12 # See the COPYING file for more details
13 #
14
15 # -- mapcharacter Action Event to launch a dialogue with the requester.
16
17
18 import adonthell
19
20 class talk(object):
21
22 def __init__ (self, mapcharacterinstance):
23 self.myself = mapcharacterinstance
24
25 def restore_schedule (self, retval, args):
26 # -- activate the characters' schedules
27 # player isn't event-driven yet
28 args[2].set_schedule_active (True)
29 if not args[0]: args[2].resume ()
30 if not args[1]: args[3].resume ()
31
32 if adonthell.gamedata_get_quest ("demo").get_val ("the_end") != 1:
33 adonthell.gamedata_engine ().set_control_active (True)
34
35 def run (self, requester):
36 if requester.get_name() == adonthell.gamedata_player ().get_name():
37 # -- get characters' current state
38 player_state = requester.is_paused ()
39 npc_state = self.myself.is_paused ()
40
41 # -- deactivate the schedule of the characters involved
42 self.myself.pause ()
43 requester.pause ()
44 # player isn't event-driven yet
45 requester.set_schedule_active (False)
46
47 # -- don't allow access to main menu and stuff
48 adonthell.gamedata_engine ().set_control_active (False)
49
50 # -- look into the player's face
51 self.myself.look_invert (requester.currentmove ())
52
53 # -- init the dialogue engine
54 dlg = adonthell.dialog_screen (self.myself, self.myself.get_dialogue (), 0)
55
56 # -- make sure the engine isn't deleted when we leave the script
57 dlg.thisown = 0
58
59 # -- attach the callback
60 dlg.py_signal_connect (self.restore_schedule, adonthell.win_event_CLOSE, (player_state, npc_state, requester, self.myself))
61
62 # -- add the dialogue window to the win_manager
63 adonthell.win_manager_get_active ().add (dlg)
64 adonthell.win_manager_get_active ().set_focus (dlg)
65
66 # -- start the dialogue
67 dlg.run ()