factored out the EFFv2 saving into EFFImporter
[gemrb.git] / gemrb / GUIScripts / bg1 / GUICG5.py
blob3a4a8ce56ca016f34396ffbbc67fa383f1465fd0
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, name (GUICG5)
20 import GemRB
21 from GUIDefines import *
23 import CharGenCommon
24 import GUICommon
27 NameWindow = 0
28 NameField = 0
29 DoneButton = 0
31 def OnLoad():
32 global NameWindow, NameField, DoneButton
34 if GUICommon.CloseOtherWindow (OnLoad):
35 if(NameWindow):
36 NameWindow.Unload()
37 NameWindow = None
38 return
40 GemRB.LoadWindowPack("GUICG")
41 NameWindow = GemRB.LoadWindow(5)
43 BackButton = NameWindow.GetControl(3)
44 BackButton.SetText(15416)
46 DoneButton = NameWindow.GetControl(0)
47 DoneButton.SetText(11973)
48 DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT,OP_OR)
49 DoneButton.SetState(IE_GUI_BUTTON_DISABLED)
51 NameField = NameWindow.GetControl(2)
53 DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress)
54 BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CharGenCommon.BackPress)
55 NameField.SetEvent(IE_GUI_EDIT_ON_CHANGE, EditChange)
56 NameWindow.ShowModal(MODAL_SHADOW_NONE)
57 NameField.SetStatus(IE_GUI_CONTROL_FOCUSED)
58 return
60 def NextPress():
61 Name = NameField.QueryText()
62 #check length?
63 #seems like a good idea to store it here for the time being
64 MyChar = GemRB.GetVar ("Slot")
65 GemRB.SetPlayerName (MyChar, Name, 0)
66 CharGenCommon.next()
67 return
69 def EditChange():
70 Name = NameField.QueryText()
71 if len(Name)==0:
72 DoneButton.SetState(IE_GUI_BUTTON_DISABLED)
73 else:
74 DoneButton.SetState(IE_GUI_BUTTON_ENABLED)
75 return