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)
21 from GUIDefines
import *
22 from ie_stats
import *
34 global AlignmentWindow
, TextAreaControl
, DoneButton
37 if GUICommon
.CloseOtherWindow (OnLoad
):
39 AlignmentWindow
.Unload()
40 AlignmentWindow
= None
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)
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
68 Button
= AlignmentWindow
.GetControl(i
+2)
69 if AlignmentOk
.GetValue(KitName
, AlignmentTable
.GetValue(i
, 4) ) != 0:
70 Button
.SetState(IE_GUI_BUTTON_ENABLED
)
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
)
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) )
100 MyChar
= GemRB
.GetVar ("Slot")
101 Alignment
= GemRB
.GetVar ("Alignment")
102 GemRB
.SetPlayerStat (MyChar
, IE_ALIGNMENT
, Alignment
)