factored out the EFFv2 saving into EFFImporter
[gemrb.git] / gemrb / GUIScripts / bg1 / ExportFile.py
blob60bf7964a0cca180433e4d5a0fac47671c17c37d
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, export (GUICG21)
20 import GemRB
21 from GUIDefines import *
22 import GUICommon
23 import CharGenCommon
25 #import from a character sheet
26 ExportWindow = 0
27 TextAreaControl = 0
29 def OnLoad():
30 global ExportWindow, TextAreaControl
32 GemRB.LoadWindowPack ("GUICG")
33 ExportWindow = GemRB.LoadWindow (21)
35 GUICommon.CloseOtherWindow(ExportWindow.Unload)
37 TextAreaControl = ExportWindow.GetControl (4)
38 TextAreaControl.SetText (10962)
40 TextAreaControl = ExportWindow.GetControl (2)
41 TextAreaControl.SetFlags (IE_GUI_TEXTAREA_SELECTABLE)
42 TextAreaControl.GetCharacters ()
44 FileNameEditBox = ExportWindow.GetControl (7)
45 FileNameEditBox.SetEvent (IE_GUI_EDIT_ON_CHANGE, FileNameChange)
47 DoneButton = ExportWindow.GetControl (0)
48 DoneButton.SetText (11973)
49 DoneButton.SetState (IE_GUI_BUTTON_DISABLED)
50 DoneButton.SetFlags (IE_GUI_BUTTON_DEFAULT, OP_OR)
52 CancelButton = ExportWindow.GetControl (1)
53 CancelButton.SetText (13727)
54 #CancelButton.SetFlags (IE_GUI_BUTTON_CANCEL, OP_OR)
56 DoneButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, DonePress)
57 CancelButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, CancelPress)
58 TextAreaControl.SetEvent (IE_GUI_TEXTAREA_ON_CHANGE, SelectPress)
59 ExportWindow.ShowModal(MODAL_SHADOW_NONE)
60 FileNameEditBox.SetStatus(IE_GUI_CONTROL_FOCUSED)
61 return
63 def SelectPress ():
64 FileNameEditBox = ExportWindow.GetControl (7)
65 FileName = TextAreaControl.QueryText ()
66 FileNameEditBox.SetText(FileName)
67 FileNameChange()
68 return
70 def FileNameChange ():
71 DoneButton = ExportWindow.GetControl (0)
72 DoneButton.SetState (IE_GUI_BUTTON_ENABLED)
73 return
75 def DonePress ():
76 FileNameEditBox = ExportWindow.GetControl (7)
77 FileName = FileNameEditBox.QueryText ()
78 Slot = GemRB.GetVar ("Slot")
79 GemRB.SaveCharacter (Slot, FileName)
80 GUICommon.CloseOtherWindow(None)
81 CharGenCommon.close()
82 GemRB.SetNextScript ("Start")
83 return
85 def CancelPress ():
86 CharGenCommon.jumpTo("accept")
87 return