factored out the EFFv2 saving into EFFImporter
[gemrb.git] / gemrb / GUIScripts / iwd2 / ImportFile.py
blob987ea70754b717bff7a3dd1c35b912836e6c6c11
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 (GUICG20)
20 import GemRB
21 from GUIDefines import *
23 #import from a character sheet
24 MainWindow = 0
25 PortraitButton = 0
26 ImportWindow = 0
27 TextAreaControl = 0
28 DoneButton = 0
30 def OnLoad():
31 global MainWindow, PortraitButton
32 global ImportWindow, TextAreaControl, DoneButton
34 GemRB.LoadWindowPack("GUICG", 800, 600)
35 MainWindow = GemRB.LoadWindow(0)
36 MainWindow.SetFrame()
38 PortraitButton = MainWindow.GetControl (12)
39 PortraitButton.SetFlags(IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_NO_IMAGE,OP_SET)
41 ImportWindow = GemRB.LoadWindow(20)
43 TextAreaControl = ImportWindow.GetControl(4)
44 TextAreaControl.SetText(10963)
46 TextAreaControl = ImportWindow.GetControl(2)
47 TextAreaControl.SetFlags (IE_GUI_TEXTAREA_SELECTABLE)
48 TextAreaControl.GetCharacters()
50 DoneButton = ImportWindow.GetControl(0)
51 DoneButton.SetText(36789)
52 DoneButton.SetState(IE_GUI_BUTTON_DISABLED)
54 CancelButton = ImportWindow.GetControl(1)
55 CancelButton.SetText(15416)
56 CancelButton.SetFlags (IE_GUI_BUTTON_CANCEL, OP_OR)
58 # disable the three extraneous buttons in the bottom row
59 for i in [16, 13, 15]:
60 TmpButton = MainWindow.GetControl(i)
61 TmpButton.SetState(IE_GUI_BUTTON_DISABLED)
63 DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, DonePress)
64 CancelButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CancelPress)
65 TextAreaControl.SetEvent(IE_GUI_TEXTAREA_ON_CHANGE, SelectFile)
66 MainWindow.SetVisible(WINDOW_VISIBLE)
67 ImportWindow.SetVisible(WINDOW_VISIBLE)
68 return
70 def DonePress():
71 if ImportWindow:
72 ImportWindow.Unload()
73 if MainWindow:
74 MainWindow.Unload()
75 #this part is fuzzy
76 #we don't have the character as an object in the chargen
77 #but we just imported a complete object
78 #either we take the important stats and destroy the object
79 #or start with an object from the beginning
80 #or use a different script here???
81 GemRB.SetNextScript("CharGen7")
82 return
84 def CancelPress():
85 if ImportWindow:
86 ImportWindow.Unload()
87 if MainWindow:
88 MainWindow.Unload()
89 GemRB.SetNextScript(GemRB.GetToken("NextScript"))
90 return
92 def SelectFile():
93 FileName = TextAreaControl.QueryText()
94 Slot = GemRB.GetVar("Slot")
95 GemRB.CreatePlayer(FileName, Slot| 0x8000, 1)
96 Portrait = GemRB.GetPlayerPortrait (Slot,0)
97 PortraitButton.SetPicture (Portrait, "NOPORTLG")
98 ImportWindow.SetVisible(WINDOW_FRONT) #bring it to the front
99 DoneButton.SetState(IE_GUI_BUTTON_ENABLED)
100 return