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, class (GUICG2)
21 from GUIDefines
import *
33 global HasSubClass
, ClassID
35 Class
= GemRB
.GetVar("Class")-1
36 TextAreaControl
.SetText(CommonTables
.Classes
.GetValue(Class
,1) )
37 ClassName
= CommonTables
.Classes
.GetRowName(Class
)
38 ClassID
= CommonTables
.Classes
.GetValue(ClassName
, "ID")
39 #determining if this class has any subclasses
41 for i
in range(1, ClassCount
):
42 ClassName
= CommonTables
.Classes
.GetRowName(i
-1)
43 #determining if this is a kit or class
44 Allowed
= CommonTables
.Classes
.GetValue(ClassName
, "CLASS")
45 if Allowed
!= ClassID
:
51 DoneButton
.SetState(IE_GUI_BUTTON_ENABLED
)
53 DoneButton
.SetState(IE_GUI_BUTTON_DISABLED
)
57 global ClassWindow
, TextAreaControl
, DoneButton
, BackButton
60 GemRB
.LoadWindowPack("GUICG", 800, 600)
61 #this replaces help02.2da for class restrictions
62 ClassCount
= CommonTables
.Classes
.GetRowCount()+1
63 ClassWindow
= GemRB
.LoadWindow(2)
64 rid
= CommonTables
.Races
.FindValue(3, GemRB
.GetVar('BaseRace'))
65 RaceName
= CommonTables
.Races
.GetRowName(rid
)
67 #radiobutton groups must be set up before doing anything else to them
69 for i
in range(1,ClassCount
):
70 ClassName
= CommonTables
.Classes
.GetRowName(i
-1)
71 Allowed
= CommonTables
.Classes
.GetValue(ClassName
, "CLASS")
74 Button
= ClassWindow
.GetControl(j
+2)
76 Button
.SetFlags(IE_GUI_BUTTON_RADIOBUTTON
, OP_SET
)
77 Button
.SetState(IE_GUI_BUTTON_DISABLED
)
80 for i
in range(1,ClassCount
):
81 ClassName
= CommonTables
.Classes
.GetRowName(i
-1)
82 #determining if this is a kit or class
83 Allowed
= CommonTables
.Classes
.GetValue(ClassName
, "CLASS")
86 Allowed
= CommonTables
.Classes
.GetValue(ClassName
, RaceName
)
87 Button
= ClassWindow
.GetControl(j
+2)
89 t
= CommonTables
.Classes
.GetValue(ClassName
, "NAME_REF")
94 Button
.SetState(IE_GUI_BUTTON_ENABLED
)
95 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, ClassPress
)
96 Button
.SetVarAssoc("Class", i
)
98 BackButton
= ClassWindow
.GetControl(17)
99 BackButton
.SetText(15416)
100 BackButton
.SetFlags(IE_GUI_BUTTON_CANCEL
,OP_OR
)
102 DoneButton
= ClassWindow
.GetControl(0)
103 DoneButton
.SetText(36789)
104 DoneButton
.SetFlags(IE_GUI_BUTTON_DEFAULT
,OP_OR
)
106 ScrollBarControl
= ClassWindow
.GetControl(15)
108 TextAreaControl
= ClassWindow
.GetControl(16)
110 Class
= GemRB
.GetVar("Class")-1
112 TextAreaControl
.SetText(17242)
113 DoneButton
.SetState(IE_GUI_BUTTON_DISABLED
)
117 DoneButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, NextPress
)
118 BackButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, BackPress
)
119 ClassWindow
.SetVisible(WINDOW_VISIBLE
)
129 DoneButton
.SetState(IE_GUI_BUTTON_DISABLED
)
131 for i
in range(1,ClassCount
):
132 ClassName
= CommonTables
.Classes
.GetRowName(i
-1)
133 Allowed
= CommonTables
.Classes
.GetValue(ClassName
, "CLASS")
136 Button
= ClassWindow
.GetControl(j
+2)
138 Button
.SetFlags(IE_GUI_BUTTON_RADIOBUTTON
, OP_SET
)
139 Button
.SetState(IE_GUI_BUTTON_DISABLED
)
143 for i
in range(1, ClassCount
):
144 ClassName
= CommonTables
.Classes
.GetRowName(i
-1)
145 #determining if this is a kit or class
146 Allowed
= CommonTables
.Classes
.GetValue(ClassName
, "CLASS")
147 if Allowed
!= ClassID
:
149 Button
= ClassWindow
.GetControl(j
+2)
151 t
= CommonTables
.Classes
.GetValue(ClassName
, "NAME_REF")
153 Button
.SetState(IE_GUI_BUTTON_ENABLED
)
154 Button
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, ClassPress2
)
155 Button
.SetVarAssoc("Class", i
)
157 BackButton
.SetEvent(IE_GUI_BUTTON_ON_PRESS
, BackPress2
)
161 Class
= GemRB
.GetVar("Class")-1
162 TextAreaControl
.SetText(CommonTables
.Classes
.GetValue(Class
,1) )
163 DoneButton
.SetState(IE_GUI_BUTTON_ENABLED
)
167 DoneButton
.SetState(IE_GUI_BUTTON_DISABLED
)
176 GemRB
.SetNextScript("CharGen3")
177 GemRB
.SetVar("Class",0) #scrapping the class value
178 MyChar
= GemRB
.GetVar("Slot")
179 GemRB
.SetPlayerStat (IE_CLASS
, 0)
183 #classcolumn is base class
184 Class
= GemRB
.GetVar("Class")
185 ClassColumn
= CommonTables
.Classes
.GetValue(Class
- 1, 3)
186 if ClassColumn
<= 0: #it was already a base class
188 GemRB
.SetVar("BaseClass", ClassColumn
)
191 GemRB
.SetNextScript("CharGen4") #alignment