factored out the EFFv2 saving into EFFImporter
[gemrb.git] / gemrb / GUIScripts / iwd2 / Name.py
blob4cd33fac51dea77c2ac124b3b8589084d13ad0cb
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 NameWindow = 0
24 NameField = 0
25 DoneButton = 0
27 def OnLoad():
28 global NameWindow, NameField, DoneButton
30 GemRB.LoadWindowPack("GUICG", 800, 600)
31 NameWindow = GemRB.LoadWindow(5)
33 BackButton = NameWindow.GetControl(3)
34 BackButton.SetText(15416)
35 BackButton.SetFlags(IE_GUI_BUTTON_CANCEL,OP_OR)
37 DoneButton = NameWindow.GetControl(0)
38 DoneButton.SetText(11973)
39 DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT,OP_OR)
40 DoneButton.SetState(IE_GUI_BUTTON_DISABLED)
42 NameField = NameWindow.GetControl(2)
44 DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress)
45 BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, BackPress)
46 NameField.SetEvent(IE_GUI_EDIT_ON_CHANGE, EditChange)
47 NameWindow.SetVisible(WINDOW_VISIBLE)
48 NameField.SetStatus(IE_GUI_CONTROL_FOCUSED)
49 return
51 def BackPress():
52 if NameWindow:
53 NameWindow.Unload()
54 GemRB.SetNextScript("CharGen8")
55 return
57 def NextPress():
58 Name = NameField.QueryText()
59 #check length?
60 #seems like a good idea to store it here for the time being
61 GemRB.SetToken("CHARNAME",Name)
62 if NameWindow:
63 NameWindow.Unload()
64 GemRB.SetNextScript("CharGen9")
65 return
67 def EditChange():
68 Name = NameField.QueryText()
69 if len(Name)==0:
70 DoneButton.SetState(IE_GUI_BUTTON_DISABLED)
71 else:
72 DoneButton.SetState(IE_GUI_BUTTON_ENABLED)
73 return