factored out the EFFv2 saving into EFFImporter
[gemrb.git] / gemrb / GUIScripts / bg1 / GUICG3.py
blob786dab93f0fb6f2a38abe7d1b479cdf2fe561882
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, alignment (GUICG3)
20 import GemRB
21 from GUIDefines import *
22 from ie_stats import *
23 import CharGenCommon
24 import GUICommon
25 import CommonTables
28 AlignmentWindow = 0
29 TextAreaControl = 0
30 DoneButton = 0
31 AlignmentTable = 0
33 def OnLoad():
34 global AlignmentWindow, TextAreaControl, DoneButton
35 global AlignmentTable
37 if GUICommon.CloseOtherWindow (OnLoad):
38 if(AlignmentWindow):
39 AlignmentWindow.Unload()
40 AlignmentWindow = None
41 return
43 MyChar = GemRB.GetVar ("Slot")
45 GemRB.SetVar("Alignment",-1)
47 Class = GemRB.GetPlayerStat (MyChar, IE_CLASS)
48 ClassRow = CommonTables.Classes.FindValue(5,Class)
49 KitName = CommonTables.Classes.GetRowName(ClassRow)
51 AlignmentOk = GemRB.LoadTable("ALIGNMNT")
53 GemRB.LoadWindowPack("GUICG")
54 AlignmentTable = GemRB.LoadTable("aligns")
55 AlignmentWindow = GemRB.LoadWindow(3)
57 for i in range(9):
58 Button = AlignmentWindow.GetControl(i+2)
59 Button.SetFlags(IE_GUI_BUTTON_RADIOBUTTON,OP_OR)
60 Button.SetState(IE_GUI_BUTTON_DISABLED)
61 Button.SetText(AlignmentTable.GetValue(i,0) )
63 # This section enables or disables different alignment selections
64 # based on Class, and depends on the ALIGNMNT.2DA table
66 # For now, we just enable all buttons
67 for i in range(9):
68 Button = AlignmentWindow.GetControl(i+2)
69 if AlignmentOk.GetValue(KitName, AlignmentTable.GetValue(i, 4) ) != 0:
70 Button.SetState(IE_GUI_BUTTON_ENABLED)
71 else:
72 Button.SetState(IE_GUI_BUTTON_DISABLED)
73 Button.SetEvent(IE_GUI_BUTTON_ON_PRESS, AlignmentPress)
74 Button.SetVarAssoc("Alignment", i)
76 BackButton = AlignmentWindow.GetControl(13)
77 BackButton.SetText(15416)
78 DoneButton = AlignmentWindow.GetControl(0)
79 DoneButton.SetText(11973)
80 DoneButton.SetFlags(IE_GUI_BUTTON_DEFAULT,OP_OR)
83 TextAreaControl = AlignmentWindow.GetControl(11)
84 TextAreaControl.SetText(9602)
86 DoneButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, NextPress)
87 BackButton.SetEvent(IE_GUI_BUTTON_ON_PRESS, CharGenCommon.BackPress)
88 DoneButton.SetState(IE_GUI_BUTTON_DISABLED)
89 AlignmentWindow.ShowModal(MODAL_SHADOW_NONE)
90 return
92 def AlignmentPress():
93 Alignment = GemRB.GetVar("Alignment")
94 TextAreaControl.SetText(AlignmentTable.GetValue(Alignment,1) )
95 DoneButton.SetState(IE_GUI_BUTTON_ENABLED)
96 GemRB.SetVar("Alignment",AlignmentTable.GetValue(Alignment,3) )
97 return
99 def NextPress():
100 MyChar = GemRB.GetVar ("Slot")
101 Alignment = GemRB.GetVar ("Alignment")
102 GemRB.SetPlayerStat (MyChar, IE_ALIGNMENT, Alignment)
103 CharGenCommon.next()