TickHook: Fix crash when TickHook isn't set.
[gemrb.git] / gemrb / GUIScripts / bg2 / ExportFile.py
blob0a631126ec72e78d32e8017945775747dbe9b110
1 # GemRB - Infinity Engine Emulator
2 # Copyright (C) 2003 The GemRB Project
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #character generation, import (GUICG24)
20 import GemRB
22 #import from a character sheet
23 ImportWindow = 0
24 TextAreaControl = 0
26 def OnLoad():
27 global ImportWindow, TextAreaControl
29 GemRB.LoadWindowPack ("GUICG",640,480)
30 ImportWindow = GemRB.LoadWindow (21)
32 TextAreaControl = ImportWindow.GetControl (4)
33 TextAreaControl.SetText (10962)
35 TextAreaControl = ImportWindow.GetControl (2)
36 TextAreaControl.SetFlags (IE_GUI_TEXTAREA_SELECTABLE)
37 TextAreaControl.GetCharacters ()
39 DoneButton = ImportWindow.GetControl (0)
40 DoneButton.SetText (2610)
41 DoneButton.SetState (IE_GUI_BUTTON_DISABLED)
42 DoneButton.SetFlags (IE_GUI_BUTTON_DEFAULT, OP_OR)
44 CancelButton = ImportWindow.GetControl (1)
45 CancelButton.SetText (15416)
46 CancelButton.SetFlags (IE_GUI_BUTTON_CANCEL, OP_OR)
48 DoneButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, DonePress)
49 CancelButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, CancelPress)
50 TextAreaControl.SetEvent (IE_GUI_TEXTAREA_ON_CHANGE, SelectPress)
51 ImportWindow.SetVisible (WINDOW_VISIBLE)
52 return
54 def SelectPress ():
55 DoneButton = ImportWindow.GetControl (0)
56 DoneButton.SetState (IE_GUI_BUTTON_ENABLED)
57 return
59 def DonePress ():
60 FileName = TextAreaControl.QueryText ()
61 Slot = GemRB.GetVar ("Slot")
62 GemRB.SaveCharacter (Slot, FileName)
63 if ImportWindow:
64 ImportWindow.Unload ()
65 GemRB.SetNextScript (GemRB.GetToken("NextScript"))
66 return
68 def CancelPress ():
69 if ImportWindow:
70 ImportWindow.Unload ()
71 GemRB.SetNextScript (GemRB.GetToken("NextScript"))
72 return