2 # GemRB - Infinity Engine Emulator
3 # Copyright (C) 2003-2005 The GemRB Project
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 ###################################################
26 from GUIDefines
import *
27 from ie_stats
import *
28 from ie_spells
import LS_MEMO
31 import LUSkillsSelection
46 PortraitPortraitButton
= 0
59 ClassMultiTextArea
= 0
60 ClassMultiDoneButton
= 0
71 AlignmentDoneButton
= 0
76 AbilitiesRaceAddTable
= 0
77 AbilitiesRaceReqTable
= 0
78 AbilitiesClassReqTable
= 0
83 AbilitiesRecallButton
= 0
84 AbilitiesDoneButton
= 0
97 RacialEnemyTextArea
= 0
98 RacialEnemyDoneButton
= 0
100 ProficienciesWindow
= 0
101 ProficienciesTable
= 0
103 ProficienciesTextArea
= 0
104 ProficienciesDoneButton
= 0
105 ProficienciesPointsLeft
= 0
108 MageSpellsTextArea
= 0
109 MageSpellsDoneButton
= 0
110 MageSpellsSelectPointsLeft
= 0
112 MageMemorizeWindow
= 0
113 MageMemorizeTextArea
= 0
114 MageMemorizeDoneButton
= 0
115 MageMemorizePointsLeft
= 0
117 PriestMemorizeWindow
= 0
118 PriestMemorizeTextArea
= 0
119 PriestMemorizeDoneButton
= 0
120 PriestMemorizePointsLeft
= 0
125 AppearanceAvatarButton
= 0
126 AppearanceHairButton
= 0
127 AppearanceSkinButton
= 0
128 AppearanceMajorButton
= 0
129 AppearanceMinorButton
= 0
149 VerbalConstants
= None
154 global CharGenWindow
, CharGenState
, TextArea
, PortraitButton
, AcceptButton
155 global GenderButton
, RaceButton
, ClassButton
, AlignmentButton
156 global AbilitiesButton
, SkillsButton
, AppearanceButton
, BiographyButton
, NameButton
157 global KitTable
, ProficienciesTable
, AlignmentTable
, RacialEnemyTable
158 global AbilitiesTable
, SkillsTable
, PortraitsTable
161 KitTable
= GemRB
.LoadTable ("magesch")
162 ProficienciesTable
= GemRB
.LoadTable ("weapprof")
163 AlignmentTable
= GemRB
.LoadTable ("aligns")
164 RacialEnemyTable
= GemRB
.LoadTable ("haterace")
165 AbilitiesTable
= GemRB
.LoadTable ("ability")
166 SkillsTable
= GemRB
.LoadTable ("skills")
167 PortraitsTable
= GemRB
.LoadTable ("pictures")
168 GemRB
.LoadWindowPack ("GUICG", 640, 480)
169 CharGenWindow
= GemRB
.LoadWindow (0)
170 CharGenWindow
.SetFrame ()
172 MyChar
= GemRB
.GetVar ("Slot")
174 GenderButton
= CharGenWindow
.GetControl (0)
175 GenderButton
.SetState (IE_GUI_BUTTON_ENABLED
)
176 GenderButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
177 GenderButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GenderPress
)
178 GenderButton
.SetText (11956)
180 RaceButton
= CharGenWindow
.GetControl (1)
181 RaceButton
.SetState (IE_GUI_BUTTON_DISABLED
)
182 RaceButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, RacePress
)
183 RaceButton
.SetText (11957)
185 ClassButton
= CharGenWindow
.GetControl (2)
186 ClassButton
.SetState (IE_GUI_BUTTON_DISABLED
)
187 ClassButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ClassPress
)
188 ClassButton
.SetText (11959)
190 AlignmentButton
= CharGenWindow
.GetControl (3)
191 AlignmentButton
.SetState (IE_GUI_BUTTON_DISABLED
)
192 AlignmentButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AlignmentPress
)
193 AlignmentButton
.SetText (11958)
195 AbilitiesButton
= CharGenWindow
.GetControl (4)
196 AbilitiesButton
.SetState (IE_GUI_BUTTON_DISABLED
)
197 AbilitiesButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AbilitiesPress
)
198 AbilitiesButton
.SetText (11960)
200 SkillsButton
= CharGenWindow
.GetControl (5)
201 SkillsButton
.SetState (IE_GUI_BUTTON_DISABLED
)
202 SkillsButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, SkillsPress
)
203 SkillsButton
.SetText (11983)
205 AppearanceButton
= CharGenWindow
.GetControl (6)
206 AppearanceButton
.SetState (IE_GUI_BUTTON_DISABLED
)
207 AppearanceButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AppearancePress
)
208 AppearanceButton
.SetText (11961)
210 BiographyButton
= CharGenWindow
.GetControl (16)
211 BiographyButton
.SetState (IE_GUI_BUTTON_DISABLED
)
212 BiographyButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, BiographyPress
)
213 BiographyButton
.SetText (18003)
215 NameButton
= CharGenWindow
.GetControl (7)
216 NameButton
.SetState (IE_GUI_BUTTON_DISABLED
)
217 NameButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, NamePress
)
218 NameButton
.SetText (11963)
220 BackButton
= CharGenWindow
.GetControl (11)
221 BackButton
.SetState (IE_GUI_BUTTON_ENABLED
)
222 BackButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, BackPress
)
223 BackButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
225 PortraitButton
= CharGenWindow
.GetControl (12)
226 PortraitButton
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_NO_IMAGE
, OP_SET
)
227 PortraitButton
.SetState (IE_GUI_BUTTON_LOCKED
)
229 ImportButton
= CharGenWindow
.GetControl (13)
230 ImportButton
.SetState (IE_GUI_BUTTON_ENABLED
)
231 ImportButton
.SetText (13955)
232 ImportButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ImportPress
)
234 CancelButton
= CharGenWindow
.GetControl (15)
235 CancelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
236 CancelButton
.SetText (13727)
237 CancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CancelPress
)
239 AcceptButton
= CharGenWindow
.GetControl (8)
240 AcceptButton
.SetState (IE_GUI_BUTTON_DISABLED
)
241 AcceptButton
.SetText (11962)
242 AcceptButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AcceptPress
)
244 TextArea
= CharGenWindow
.GetControl (9)
245 TextArea
.SetText (16575)
247 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
251 global CharGenWindow
, CharGenState
, SkillsState
252 global GenderButton
, RaceButton
, ClassButton
, AlignmentButton
, AbilitiesButton
, SkillsButton
, AppearanceButton
, BiographyButton
, NameButton
255 CharGenState
= CharGenState
- 1
262 GemRB
.SetToken ("CHARNAME","")
264 if CharGenState
== 0:
265 RaceButton
.SetState (IE_GUI_BUTTON_DISABLED
)
266 RaceButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_NAND
)
267 GenderButton
.SetState (IE_GUI_BUTTON_ENABLED
)
268 GenderButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
269 elif CharGenState
== 1:
270 ClassButton
.SetState (IE_GUI_BUTTON_DISABLED
)
271 ClassButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_NAND
)
272 RaceButton
.SetState (IE_GUI_BUTTON_ENABLED
)
273 RaceButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
274 elif CharGenState
== 2:
275 AlignmentButton
.SetState (IE_GUI_BUTTON_DISABLED
)
276 AlignmentButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_NAND
)
277 ClassButton
.SetState (IE_GUI_BUTTON_ENABLED
)
278 ClassButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
279 elif CharGenState
== 3:
280 AbilitiesButton
.SetState (IE_GUI_BUTTON_DISABLED
)
281 AbilitiesButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_NAND
)
282 AlignmentButton
.SetState (IE_GUI_BUTTON_ENABLED
)
283 AlignmentButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
284 elif CharGenState
== 4:
285 SkillsButton
.SetState (IE_GUI_BUTTON_DISABLED
)
286 SkillsButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_NAND
)
287 AbilitiesButton
.SetState (IE_GUI_BUTTON_ENABLED
)
288 AbilitiesButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
289 elif CharGenState
== 5:
290 AppearanceButton
.SetState (IE_GUI_BUTTON_DISABLED
)
291 SkillsButton
.SetState (IE_GUI_BUTTON_ENABLED
)
292 SkillsButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
294 elif CharGenState
== 6:
295 NameButton
.SetState (IE_GUI_BUTTON_DISABLED
)
296 BiographyButton
.SetState (IE_GUI_BUTTON_DISABLED
)
297 AppearanceButton
.SetState (IE_GUI_BUTTON_ENABLED
)
299 AcceptButton
.SetState (IE_GUI_BUTTON_DISABLED
)
300 SetCharacterDescription()
307 CharGenWindow
.Unload ()
308 GemRB
.CreatePlayer ("", MyChar |
0x8000 )
309 GemRB
.SetNextScript ("PartyFormation")
314 Kit
= GemRB
.GetPlayerStat (MyChar
, IE_KIT
)
315 KitIndex
= KitTable
.FindValue (3, Kit
)
316 Class
= GemRB
.GetPlayerStat (MyChar
, IE_CLASS
)
317 t
= GemRB
.GetPlayerStat (MyChar
, IE_ALIGNMENT
)
318 TableName
= CommonTables
.ClassSkills
.GetValue (Class
, 2, 0)
320 #todo: set up ALL spell levels not just level 1
321 GUICommon
.SetupSpellLevels (MyChar
, TableName
, IE_SPELL_TYPE_WIZARD
, 1)
322 Learnable
= GUICommon
.GetLearnableMageSpells (KitIndex
, t
, 1)
323 SpellBook
= GemRB
.GetVar ("MageSpellBook")
324 MemoBook
= GemRB
.GetVar ("MageMemorized")
326 for i
in range (len(Learnable
) ):
332 GemRB
.LearnSpell (MyChar
, Learnable
[i
], memorize
)
336 TableName
= CommonTables
.ClassSkills
.GetValue (Class
, 1, 0)
338 if TableName
== "MXSPLPRS" or TableName
== "MXSPLPAL":
340 elif TableName
== "MXSPLDRU":
341 #there is no separate druid table, falling back to priest
342 TableName
= "MXSPLPRS"
344 elif TableName
== "MXSPLRAN":
348 #todo: set up ALL spell levels not just level 1
349 GUICommon
.SetupSpellLevels (MyChar
, TableName
, IE_SPELL_TYPE_PRIEST
, 1)
350 Learnable
= GUICommon
.GetLearnablePriestSpells (ClassFlag
, t
, 1)
351 for i
in range (len(Learnable
) ):
352 GemRB
.LearnSpell (MyChar
, Learnable
[i
], 0)
354 # ranger tracking is a hardcoded innate
355 if GUICommon
.HasHOW():
356 if CommonTables
.ClassSkills
.GetValue (GemRB
.GetPlayerStat (MyChar
, IE_CLASS
), 0) != "*":
357 GemRB
.LearnSpell (MyChar
, "spin139", LS_MEMO
)
359 # save all the skills
360 LUSkillsSelection
.SkillsSave (MyChar
)
362 TmpTable
= GemRB
.LoadTable ("repstart")
363 t
= AlignmentTable
.FindValue (3, t
)
364 t
= TmpTable
.GetValue (t
, 0) * 10
365 GemRB
.SetPlayerStat (MyChar
, IE_REPUTATION
, t
)
366 # set the party rep if this in the main char
368 GemRB
.GameSetReputation (t
)
370 print "Reputation", t
371 TmpTable
= GemRB
.LoadTable ("strtgold")
372 a
= TmpTable
.GetValue (Class
, 1) #number of dice
373 b
= TmpTable
.GetValue (Class
, 0) #size
374 c
= TmpTable
.GetValue (Class
, 2) #adjustment
375 d
= TmpTable
.GetValue (Class
, 3) #external multiplier
376 e
= TmpTable
.GetValue (Class
, 4) #level bonus rate
377 t
= GemRB
.GetPlayerStat (MyChar
, IE_LEVEL
) #FIXME: calculate multiclass average
382 t
= GemRB
.Roll (a
,b
,c
)*d
+e
383 GemRB
.SetPlayerStat (MyChar
, IE_GOLD
, t
)
384 GemRB
.SetPlayerStat (MyChar
, IE_EA
, 2 )
385 #GemRB.SetPlayerStat (MyChar, IE_HATEDRACE, GemRB.GetVar ("HatedRace") )
386 #Str = GemRB.GetVar ("Ability1")
387 #GemRB.SetPlayerStat (MyChar, IE_STR, Str)
389 # GemRB.SetPlayerStat (MyChar, IE_STREXTRA, GemRB.GetVar ("StrExtra"))
391 # GemRB.SetPlayerStat (MyChar, IE_STREXTRA, 0)
393 #GemRB.SetPlayerStat (MyChar, IE_DEX, GemRB.GetVar ("Ability2"))
394 #GemRB.SetPlayerStat (MyChar, IE_CON, GemRB.GetVar ("Ability3"))
395 #GemRB.SetPlayerStat (MyChar, IE_INT, GemRB.GetVar ("Ability4"))
396 #GemRB.SetPlayerStat (MyChar, IE_WIS, GemRB.GetVar ("Ability5"))
397 #GemRB.SetPlayerStat (MyChar, IE_CHR, GemRB.GetVar ("Ability6"))
399 GemRB
.SetPlayerName (MyChar
, GemRB
.GetToken ("CHARNAME"), 0)
400 GemRB
.SetToken ("CHARNAME","")
401 GemRB
.SetPlayerStat (MyChar
, IE_XP
, CommonTables
.ClassSkills
.GetValue (Class
, 3) )
403 GUICommon
.SetColorStat (MyChar
, IE_SKIN_COLOR
, GemRB
.GetVar ("SkinColor") )
404 GUICommon
.SetColorStat (MyChar
, IE_HAIR_COLOR
, GemRB
.GetVar ("HairColor") )
405 GUICommon
.SetColorStat (MyChar
, IE_MAJOR_COLOR
, GemRB
.GetVar ("MajorColor") )
406 GUICommon
.SetColorStat (MyChar
, IE_MINOR_COLOR
, GemRB
.GetVar ("MinorColor") )
407 GUICommon
.SetColorStat (MyChar
, IE_METAL_COLOR
, 0x1B )
408 GUICommon
.SetColorStat (MyChar
, IE_LEATHER_COLOR
, 0x16 )
409 GUICommon
.SetColorStat (MyChar
, IE_ARMOR_COLOR
, 0x17 )
412 LargePortrait
= GemRB
.GetToken ("LargePortrait")
413 SmallPortrait
= GemRB
.GetToken ("SmallPortrait")
414 GemRB
.FillPlayerInfo (MyChar
, LargePortrait
, SmallPortrait
)
416 #10 is a weapon slot (see slottype.2da row 10)
417 GemRB
.CreateItem (MyChar
, "staf01", 10, 1, 0, 0)
418 GemRB
.SetEquippedQuickSlot (MyChar
, 0)
421 CharGenWindow
.Unload ()
422 GemRB
.SetNextScript ("PartyFormation")
425 def SetCharacterDescription():
426 global CharGenWindow
, TextArea
, CharGenState
, ClassFlag
431 TextArea
.Append (1047)
432 TextArea
.Append (": ")
433 TextArea
.Append (GemRB
.GetToken ("CHARNAME"))
434 TextArea
.Append ("", -1)
436 TextArea
.Append (12135)
437 TextArea
.Append (": ")
438 if GemRB
.GetPlayerStat (MyChar
, IE_SEX
) == 1:
439 TextArea
.Append (1050)
441 TextArea
.Append (1051)
443 Class
= CommonTables
.Classes
.FindValue (5, GemRB
.GetPlayerStat (MyChar
, IE_CLASS
) )
444 TextArea
.Append (12136, -1)
445 TextArea
.Append (": ")
446 #this is only mage school in iwd
447 Kit
= GemRB
.GetPlayerStat (MyChar
, IE_KIT
)
448 KitIndex
= KitTable
.FindValue (3, Kit
)
450 ClassTitle
= CommonTables
.Classes
.GetValue (Class
, 2)
452 ClassTitle
= KitTable
.GetValue (KitIndex
, 2)
453 TextArea
.Append (ClassTitle
)
456 TextArea
.Append (1048, -1)
457 TextArea
.Append (": ")
458 Race
= GemRB
.GetPlayerStat (MyChar
, IE_RACE
)
459 Race
= CommonTables
.Races
.FindValue (3, GemRB
.GetPlayerStat (MyChar
, IE_RACE
) )
460 TextArea
.Append (CommonTables
.Races
.GetValue (Race
, 2) )
462 TextArea
.Append (1049, -1)
463 TextArea
.Append (": ")
464 Alignment
= AlignmentTable
.FindValue (3, GemRB
.GetPlayerStat(MyChar
, IE_ALIGNMENT
) )
465 TextArea
.Append (AlignmentTable
.GetValue (Alignment
, 2) )
467 strextra
= GemRB
.GetPlayerStat (MyChar
, IE_STREXTRA
)
468 TextArea
.Append ("", -1)
470 TextArea
.Append (AbilitiesTable
.GetValue (i
, 2), -1)
471 TextArea
.Append (": " )
472 StatID
= AbilitiesTable
.GetValue (i
, 3)
473 stat
= GemRB
.GetPlayerStat (MyChar
, StatID
)
474 if (i
== 0) and HasStrExtra
and (stat
==18):
475 TextArea
.Append (str(stat
) + "/" + str(strextra
) )
477 TextArea
.Append (str(stat
) )
479 ClassName
= CommonTables
.Classes
.GetRowName (Class
)
480 Row
= CommonTables
.Classes
.GetValue (Class
, 5)
481 IsRanger
= CommonTables
.ClassSkills
.GetValue (Row
, 0)
482 IsArcane
= CommonTables
.ClassSkills
.GetValue (Row
, 1)
483 IsMage
= CommonTables
.ClassSkills
.GetValue (Row
, 2)
484 IsBard
= CommonTables
.ClassSkills
.GetValue (Row
, 4)
485 IsThief
= CommonTables
.ClassSkills
.GetValue (Row
, 5)
488 TextArea
.Append ("", -1)
489 TextArea
.Append (8442, -1)
491 TextArea
.Append (SkillsTable
.GetValue (i
+2, 2), -1)
492 StatID
= SkillsTable
.GetValue (i
+2, 3)
493 TextArea
.Append (": " )
494 TextArea
.Append (str(GemRB
.GetPlayerStat (MyChar
, StatID
)) )
495 TextArea
.Append ("%" )
497 TextArea
.Append ("", -1)
498 TextArea
.Append (8442, -1)
500 StatID
= SkillsTable
.GetValue (i
+2, 3)
501 Stat
= GemRB
.GetPlayerStat (MyChar
, StatID
)
503 TextArea
.Append (SkillsTable
.GetValue (i
+2, 2), -1)
504 TextArea
.Append (": " )
505 TextArea
.Append (str(Stat
) )
506 TextArea
.Append ("%" )
507 TextArea
.Append ("", -1)
508 TextArea
.Append (15982, -1)
509 TextArea
.Append (": " )
510 RacialEnemy
= GemRB
.GetVar ("RacialEnemyIndex") + GemRB
.GetVar ("RacialEnemy") - 1
511 TextArea
.Append (RacialEnemyTable
.GetValue (RacialEnemy
, 3) )
513 TextArea
.Append ("", -1)
514 TextArea
.Append (8442, -1)
516 StatID
= SkillsTable
.GetValue (i
+2, 3)
517 Stat
= GemRB
.GetPlayerStat (MyChar
, StatID
)
519 TextArea
.Append (SkillsTable
.GetValue (i
+2, 2), -1)
520 TextArea
.Append (": " )
521 TextArea
.Append (str(Stat
) )
522 TextArea
.Append ("%" )
524 TextArea
.Append ("", -1)
525 TextArea
.Append (9466, -1)
527 StatID
= ProficienciesTable
.GetValue (i
, 0)
528 ProficiencyValue
= GemRB
.GetPlayerStat (MyChar
, StatID
)
529 if ProficiencyValue
> 0:
530 TextArea
.Append (ProficienciesTable
.GetValue (i
, 3), -1)
531 TextArea
.Append (" ")
533 while j
< ProficiencyValue
:
534 TextArea
.Append ("+")
538 TextArea
.Append ("", -1)
539 TextArea
.Append (11027, -1)
540 TextArea
.Append (": " )
541 t
= GemRB
.GetPlayerStat (MyChar
, IE_ALIGNMENT
)
542 Learnable
= GUICommon
.GetLearnableMageSpells (GemRB
.GetPlayerStat (MyChar
, IE_KIT
), t
,1)
543 MageSpellBook
= GemRB
.GetVar ("MageSpellBook")
544 MageMemorized
= GemRB
.GetVar ("MageMemorized")
545 for i
in range (len(Learnable
)):
546 if (1 << i
) & MageSpellBook
:
547 Spell
= GemRB
.GetSpell (Learnable
[i
])
548 TextArea
.Append (Spell
["SpellName"], -1)
549 if (1 << i
) & MageMemorized
:
550 TextArea
.Append (" +")
551 TextArea
.Append (" ")
554 TextArea
.Append ("", -1)
555 TextArea
.Append (11028, -1)
556 TextArea
.Append (": " )
557 t
= GemRB
.GetPlayerStat (MyChar
, IE_ALIGNMENT
)
558 if IsArcane
== "MXSPLPRS" or IsArcane
== "MXSPLPAL":
560 elif IsArcane
== "MXSPLDRU" or IsArcane
== "MXSPLRAN":
565 Learnable
= GUICommon
.GetLearnablePriestSpells( ClassFlag
, t
, 1)
566 PriestMemorized
= GemRB
.GetVar ("PriestMemorized")
567 for i
in range (len(Learnable
)):
568 if (1 << i
) & PriestMemorized
:
569 Spell
= GemRB
.GetSpell (Learnable
[i
])
570 TextArea
.Append (Spell
["SpellName"], -1)
571 TextArea
.Append (" +")
578 global CharGenWindow
, GenderWindow
, GenderDoneButton
, GenderTextArea
581 CharGenWindow
.SetVisible (WINDOW_INVISIBLE
)
582 GenderWindow
= GemRB
.LoadWindow (1)
583 GemRB
.SetVar ("Gender", 0)
584 GemRB
.CreatePlayer ("charbase", MyChar |
0x8000 )
586 MaleButton
= GenderWindow
.GetControl (2)
587 MaleButton
.SetState (IE_GUI_BUTTON_ENABLED
)
588 MaleButton
.SetFlags (IE_GUI_BUTTON_RADIOBUTTON
,OP_OR
)
589 MaleButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, MalePress
)
591 FemaleButton
= GenderWindow
.GetControl (3)
592 FemaleButton
.SetState (IE_GUI_BUTTON_ENABLED
)
593 FemaleButton
.SetFlags (IE_GUI_BUTTON_RADIOBUTTON
,OP_OR
)
594 FemaleButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, FemalePress
)
596 MaleButton
.SetVarAssoc ("Gender", 1)
597 FemaleButton
.SetVarAssoc ("Gender", 2)
599 GenderTextArea
= GenderWindow
.GetControl (5)
600 GenderTextArea
.SetText (17236)
602 GenderDoneButton
= GenderWindow
.GetControl (0)
603 GenderDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
604 GenderDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GenderDonePress
)
605 GenderDoneButton
.SetText (11973)
606 GenderDoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
608 GenderCancelButton
= GenderWindow
.GetControl (6)
609 GenderCancelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
610 GenderCancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, GenderCancelPress
)
611 GenderCancelButton
.SetText (13727)
612 GenderCancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
614 GenderWindow
.SetVisible (WINDOW_VISIBLE
)
618 global GenderWindow
, GenderDoneButton
, GenderTextArea
620 GenderTextArea
.SetText (13083)
621 GenderDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
625 global GenderWindow
, GenderDoneButton
, GenderTextArea
627 GenderTextArea
.SetText (13084)
628 GenderDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
631 def GenderDonePress():
632 global CharGenWindow
, GenderWindow
636 GenderWindow
.Unload ()
637 Gender
= GemRB
.GetVar ("Gender")
638 GemRB
.SetPlayerStat (MyChar
, IE_SEX
, Gender
)
640 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
644 def GenderCancelPress():
645 global CharGenWindow
, GenderWindow
648 GemRB
.SetVar ("Gender", 0)
649 GemRB
.SetPlayerStat (MyChar
, IE_SEX
, 0)
651 GenderWindow
.Unload ()
652 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
655 def PortraitSelect():
656 global CharGenWindow
, PortraitWindow
, Portrait
, PortraitPortraitButton
659 CharGenWindow
.SetVisible (WINDOW_INVISIBLE
)
660 PortraitWindow
= GemRB
.LoadWindow (11)
662 # this is not the correct one, but I don't know which is
665 PortraitPortraitButton
= PortraitWindow
.GetControl (1)
666 PortraitPortraitButton
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_NO_IMAGE
, OP_SET
)
668 PortraitLeftButton
= PortraitWindow
.GetControl (2)
669 PortraitLeftButton
.SetState (IE_GUI_BUTTON_ENABLED
)
670 PortraitLeftButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CGPortraitLeftPress
)
671 PortraitLeftButton
.SetFlags (IE_GUI_BUTTON_RADIOBUTTON
, OP_OR
)
673 PortraitRightButton
= PortraitWindow
.GetControl (3)
674 PortraitRightButton
.SetState (IE_GUI_BUTTON_ENABLED
)
675 PortraitRightButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CGPortraitRightPress
)
676 PortraitRightButton
.SetFlags (IE_GUI_BUTTON_RADIOBUTTON
, OP_OR
)
678 PortraitCustomButton
= PortraitWindow
.GetControl (6)
679 PortraitCustomButton
.SetState (IE_GUI_BUTTON_ENABLED
)
680 PortraitCustomButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, PortraitCustomPress
)
681 PortraitCustomButton
.SetText (17545)
683 PortraitDoneButton
= PortraitWindow
.GetControl (0)
684 PortraitDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
685 PortraitDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CGPortraitDonePress
)
686 PortraitDoneButton
.SetText (11973)
687 PortraitDoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
689 PortraitCancelButton
= PortraitWindow
.GetControl (5)
690 PortraitCancelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
691 PortraitCancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CGPortraitCancelPress
)
692 PortraitCancelButton
.SetText (13727)
693 PortraitCancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
695 while PortraitsTable
.GetValue (Portrait
, 0) != GemRB
.GetPlayerStat (MyChar
, IE_SEX
):
696 Portrait
= Portrait
+ 1
697 PortraitPortraitButton
.SetPicture (PortraitsTable
.GetRowName (Portrait
) + "G")
699 PortraitWindow
.SetVisible (WINDOW_VISIBLE
)
702 def CGPortraitLeftPress():
703 global PortraitWindow
, Portrait
, PortraitPortraitButton
707 Portrait
= Portrait
- 1
709 Portrait
= PortraitsTable
.GetRowCount () - 1
710 if PortraitsTable
.GetValue (Portrait
, 0) == GemRB
.GetPlayerStat(MyChar
, IE_SEX
):
711 PortraitPortraitButton
.SetPicture (PortraitsTable
.GetRowName (Portrait
) + "G")
714 def CGPortraitRightPress():
715 global PortraitWindow
, Portrait
, PortraitPortraitButton
719 Portrait
= Portrait
+ 1
720 if Portrait
== PortraitsTable
.GetRowCount():
722 if PortraitsTable
.GetValue (Portrait
, 0) == GemRB
.GetPlayerStat(MyChar
, IE_SEX
):
723 PortraitPortraitButton
.SetPicture (PortraitsTable
.GetRowName (Portrait
) + "G")
727 global CharGenWindow
, PortraitWindow
728 global PortraitButton
, GenderButton
, RaceButton
729 global CharGenState
, Portrait
731 Window
= CustomWindow
733 PortraitName
= PortraitList2
.QueryText ()
734 GemRB
.SetToken ("SmallPortrait", PortraitName
)
735 PortraitName
= PortraitList1
.QueryText ()
736 GemRB
.SetToken ("LargePortrait", PortraitName
)
741 PortraitWindow
.Unload ()
742 PortraitButton
.SetPicture(PortraitName
)
743 GenderButton
.SetState (IE_GUI_BUTTON_DISABLED
)
744 GenderButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_NAND
)
745 RaceButton
.SetState (IE_GUI_BUTTON_ENABLED
)
746 RaceButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
749 SetCharacterDescription()
750 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
755 CustomWindow
.Unload ()
758 def CGLargeCustomPortrait():
759 Window
= CustomWindow
761 Portrait
= PortraitList1
.QueryText ()
763 if GemRB
.GetVar ("Row1") == RowCount1
:
766 Label
= Window
.GetControl (0x10000007)
767 Label
.SetText (Portrait
)
769 Button
= Window
.GetControl (6)
771 Portrait
= "NOPORTMD"
772 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
774 if PortraitList2
.QueryText ()!="":
775 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
777 Button
= Window
.GetControl (0)
778 Button
.SetPicture (Portrait
, "NOPORTMD")
781 def CGSmallCustomPortrait():
782 Window
= CustomWindow
784 Portrait
= PortraitList2
.QueryText ()
786 if GemRB
.GetVar ("Row2") == RowCount2
:
789 Label
= Window
.GetControl (0x10000008)
790 Label
.SetText (Portrait
)
792 Button
= Window
.GetControl (6)
794 Portrait
= "NOPORTSM"
795 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
797 if PortraitList1
.QueryText ()!="":
798 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
800 Button
= Window
.GetControl (1)
801 Button
.SetPicture (Portrait
, "NOPORTSM")
804 def PortraitCustomPress():
805 global PortraitList1
, PortraitList2
806 global RowCount1
, RowCount2
809 CustomWindow
= Window
= GemRB
.LoadWindow (18)
810 PortraitList1
= Window
.GetControl (2)
811 RowCount1
= PortraitList1
.GetPortraits (0)
812 PortraitList1
.SetEvent (IE_GUI_TEXTAREA_ON_CHANGE
, CGLargeCustomPortrait
)
813 GemRB
.SetVar ("Row1", RowCount1
)
814 PortraitList1
.SetVarAssoc ("Row1",RowCount1
)
816 PortraitList2
= Window
.GetControl (4)
817 RowCount2
= PortraitList2
.GetPortraits (1)
818 PortraitList2
.SetEvent (IE_GUI_TEXTAREA_ON_CHANGE
, CGSmallCustomPortrait
)
819 GemRB
.SetVar ("Row2", RowCount2
)
820 PortraitList2
.SetVarAssoc ("Row2",RowCount2
)
822 Button
= Window
.GetControl (6)
823 Button
.SetText (11973)
824 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CustomDone
)
825 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
827 Button
= Window
.GetControl (7)
828 Button
.SetText (13727)
829 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CustomAbort
)
831 Button
= Window
.GetControl (0)
832 PortraitName
= PortraitsTable
.GetRowName (Portrait
)+"L"
833 Button
.SetPicture (PortraitName
, "NOPORTMD")
834 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
836 Button
= Window
.GetControl (1)
837 PortraitName
= PortraitsTable
.GetRowName (Portrait
)+"S"
838 Button
.SetPicture (PortraitName
, "NOPORTSM")
839 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
841 Window
.ShowModal (MODAL_SHADOW_NONE
)
844 def CGPortraitDonePress():
845 global CharGenWindow
, PortraitWindow
, PortraitButton
, GenderButton
, RaceButton
846 global CharGenState
, Portrait
848 PortraitName
= PortraitsTable
.GetRowName (Portrait
)
849 GemRB
.SetToken ("SmallPortrait", PortraitName
+"S")
850 GemRB
.SetToken ("LargePortrait", PortraitName
+"L")
851 PortraitButton
.SetPicture(PortraitsTable
.GetRowName (Portrait
) + "L")
852 GenderButton
.SetState (IE_GUI_BUTTON_DISABLED
)
853 GenderButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_NAND
)
854 RaceButton
.SetState (IE_GUI_BUTTON_ENABLED
)
855 RaceButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
857 SetCharacterDescription()
858 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
860 PortraitWindow
.Unload ()
863 def CGPortraitCancelPress():
864 global CharGenWindow
, PortraitWindow
867 PortraitWindow
.Unload ()
868 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
874 global CharGenWindow
, RaceWindow
, RaceDoneButton
, RaceTextArea
876 CharGenWindow
.SetVisible (WINDOW_INVISIBLE
)
877 RaceWindow
= GemRB
.LoadWindow (8)
878 GemRB
.SetVar ("Race", 0)
880 for i
in range (2, 8):
881 RaceSelectButton
= RaceWindow
.GetControl (i
)
882 RaceSelectButton
.SetFlags (IE_GUI_BUTTON_RADIOBUTTON
, OP_OR
)
884 for i
in range (2, 8):
885 RaceSelectButton
= RaceWindow
.GetControl (i
)
886 RaceSelectButton
.SetState (IE_GUI_BUTTON_ENABLED
)
887 RaceSelectButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, RaceSelectPress
)
888 RaceSelectButton
.SetText (CommonTables
.Races
.GetValue (i
- 2, 0))
889 RaceSelectButton
.SetVarAssoc ("Race", i
- 1)
891 RaceTextArea
= RaceWindow
.GetControl (8)
892 RaceTextArea
.SetText (17237)
894 RaceDoneButton
= RaceWindow
.GetControl (0)
895 RaceDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
896 RaceDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, RaceDonePress
)
897 RaceDoneButton
.SetText (11973)
898 RaceDoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
900 RaceCancelButton
= RaceWindow
.GetControl (10)
901 RaceCancelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
902 RaceCancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, RaceCancelPress
)
903 RaceCancelButton
.SetText (13727)
904 RaceCancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
906 RaceWindow
.SetVisible (WINDOW_VISIBLE
)
909 def RaceSelectPress():
910 global RaceWindow
, RaceDoneButton
, RaceTextArea
912 Race
= GemRB
.GetVar ("Race") - 1
913 RaceTextArea
.SetText (CommonTables
.Races
.GetValue (Race
, 1) )
914 RaceDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
918 global CharGenWindow
, CharGenState
, RaceWindow
, RaceButton
, ClassButton
922 RaceButton
.SetState (IE_GUI_BUTTON_DISABLED
)
923 RaceButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_NAND
)
924 ClassButton
.SetState (IE_GUI_BUTTON_ENABLED
)
925 ClassButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
928 Race
= GemRB
.GetVar ("Race")-1
929 Race
= CommonTables
.Races
.GetValue (Race
, 3)
930 GemRB
.SetPlayerStat (MyChar
, IE_RACE
, Race
)
931 SetCharacterDescription()
932 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
935 def RaceCancelPress():
936 global CharGenWindow
, RaceWindow
940 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
946 global CharGenWindow
, ClassWindow
, ClassTextArea
, ClassDoneButton
948 CharGenWindow
.SetVisible (WINDOW_INVISIBLE
)
949 ClassWindow
= GemRB
.LoadWindow (2)
950 ClassCount
= CommonTables
.Classes
.GetRowCount ()
951 RaceRow
= CommonTables
.Races
.FindValue (3, GemRB
.GetPlayerStat (MyChar
, IE_RACE
) )
952 RaceName
= CommonTables
.Races
.GetRowName (RaceRow
)
953 GemRB
.SetVar ("Class", 0)
954 GemRB
.SetVar ("Class Kit", 0)
955 GemRB
.SetVar ("MAGESCHOOL", 0)
957 for i
in range (2, 10):
958 ClassSelectButton
= ClassWindow
.GetControl (i
)
959 ClassSelectButton
.SetFlags (IE_GUI_BUTTON_RADIOBUTTON
, OP_SET
)
963 for i
in range (ClassCount
):
964 Allowed
= CommonTables
.Classes
.GetValue (CommonTables
.Classes
.GetRowName (i
), RaceName
)
965 if CommonTables
.Classes
.GetValue (i
, 4):
969 ClassSelectButton
= ClassWindow
.GetControl (j
)
972 ClassSelectButton
.SetState (IE_GUI_BUTTON_ENABLED
)
974 ClassSelectButton
.SetState (IE_GUI_BUTTON_DISABLED
)
975 ClassSelectButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ClassSelectPress
)
976 ClassSelectButton
.SetText (CommonTables
.Classes
.GetValue (i
, 0) )
977 ClassSelectButton
.SetVarAssoc ("Class", i
+ 1)
979 ClassMultiButton
= ClassWindow
.GetControl (10)
981 ClassMultiButton
.SetState (IE_GUI_BUTTON_DISABLED
)
983 ClassMultiButton
.SetState (IE_GUI_BUTTON_ENABLED
)
984 ClassMultiButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ClassMultiPress
)
985 ClassMultiButton
.SetText (11993)
987 KitButton
= ClassWindow
.GetControl (11)
988 #only the mage class has schools
989 Allowed
= CommonTables
.Classes
.GetValue ("MAGE", RaceName
)
991 KitButton
.SetState (IE_GUI_BUTTON_ENABLED
)
993 KitButton
.SetState (IE_GUI_BUTTON_DISABLED
)
994 KitButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, KitPress
)
995 KitButton
.SetText (11994)
997 ClassTextArea
= ClassWindow
.GetControl (13)
998 ClassTextArea
.SetText (17242)
1000 ClassDoneButton
= ClassWindow
.GetControl (0)
1001 ClassDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1002 ClassDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ClassDonePress
)
1003 ClassDoneButton
.SetText (11973)
1004 ClassDoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1006 ClassCancelButton
= ClassWindow
.GetControl (14)
1007 ClassCancelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1008 ClassCancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ClassCancelPress
)
1009 ClassCancelButton
.SetText (13727)
1010 ClassCancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
1012 ClassWindow
.SetVisible (WINDOW_VISIBLE
)
1015 def ClassSelectPress():
1016 global ClassWindow
, ClassTextArea
, ClassDoneButton
1018 Class
= GemRB
.GetVar ("Class") - 1
1019 ClassTextArea
.SetText (CommonTables
.Classes
.GetValue (Class
, 1) )
1020 ClassDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1023 def ClassMultiPress():
1024 global ClassWindow
, ClassMultiWindow
, ClassMultiTextArea
, ClassMultiDoneButton
1026 ClassWindow
.SetVisible (WINDOW_INVISIBLE
)
1027 ClassMultiWindow
= GemRB
.LoadWindow (10)
1028 ClassCount
= CommonTables
.Classes
.GetRowCount ()
1029 RaceRow
= CommonTables
.Races
.FindValue (3, GemRB
.GetPlayerStat (MyChar
, IE_RACE
) )
1030 RaceName
= CommonTables
.Races
.GetRowName (RaceRow
)
1032 print "Multi racename:", RaceName
1033 for i
in range (2, 10):
1034 ClassMultiSelectButton
= ClassMultiWindow
.GetControl (i
)
1035 ClassMultiSelectButton
.SetFlags (IE_GUI_BUTTON_RADIOBUTTON
, OP_SET
)
1038 for i
in range (ClassCount
):
1039 ClassName
= CommonTables
.Classes
.GetRowName (i
)
1040 if (CommonTables
.Classes
.GetValue (ClassName
, "MULTI") > 0):
1041 ClassMultiSelectButton
= ClassMultiWindow
.GetControl (j
)
1043 if (CommonTables
.Classes
.GetValue (ClassName
, RaceName
) > 0):
1044 ClassMultiSelectButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1046 ClassMultiSelectButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1047 ClassMultiSelectButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ClassMultiSelectPress
)
1048 ClassMultiSelectButton
.SetText (CommonTables
.Classes
.GetValue (i
, 0) )
1049 ClassMultiSelectButton
.SetVarAssoc ("Class", i
+ 1)
1051 ClassMultiTextArea
= ClassMultiWindow
.GetControl (12)
1052 ClassMultiTextArea
.SetText (17244)
1054 ClassMultiDoneButton
= ClassMultiWindow
.GetControl (0)
1055 ClassMultiDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1056 ClassMultiDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ClassMultiDonePress
)
1057 ClassMultiDoneButton
.SetText (11973)
1058 ClassMultiDoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1060 ClassMultiCancelButton
= ClassMultiWindow
.GetControl (14)
1061 ClassMultiCancelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1062 ClassMultiCancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ClassMultiCancelPress
)
1063 ClassMultiCancelButton
.SetText (13727)
1064 ClassMultiCancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
1066 ClassMultiWindow
.SetVisible (WINDOW_VISIBLE
)
1069 def ClassMultiSelectPress():
1070 global ClassMultiWindow
, ClassMultiTextArea
, ClassMultiDoneButton
1072 Class
= GemRB
.GetVar ("Class") - 1
1073 ClassMultiTextArea
.SetText (CommonTables
.Classes
.GetValue (Class
, 1) )
1074 ClassMultiDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1077 def ClassMultiDonePress():
1078 global ClassMultiWindow
1080 if ClassMultiWindow
:
1081 ClassMultiWindow
.Unload ()
1085 def ClassMultiCancelPress():
1086 global ClassWindow
, ClassMultiWindow
1088 if ClassMultiWindow
:
1089 ClassMultiWindow
.Unload ()
1090 ClassWindow
.SetVisible (WINDOW_VISIBLE
)
1094 global ClassWindow
, KitWindow
, KitTextArea
, KitDoneButton
1096 ClassWindow
.SetVisible (WINDOW_INVISIBLE
)
1097 KitWindow
= GemRB
.LoadWindow (12)
1099 #only mage class (1) has schools. It is the sixth button
1100 GemRB
.SetVar ("Class", 6)
1101 GemRB
.SetVar ("Class Kit",0)
1102 GemRB
.SetVar ("MAGESCHOOL",0)
1105 Button
= KitWindow
.GetControl (i
+2)
1106 Button
.SetFlags (IE_GUI_BUTTON_RADIOBUTTON
, OP_OR
)
1107 Button
.SetText (KitTable
.GetValue (i
+1, 0) )
1108 Button
.SetVarAssoc ("MAGESCHOOL", i
+1)
1109 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, KitSelectPress
)
1111 KitTextArea
= KitWindow
.GetControl (11)
1112 KitTextArea
.SetText (17245)
1114 KitDoneButton
= KitWindow
.GetControl (0)
1115 KitDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1116 KitDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, KitDonePress
)
1117 KitDoneButton
.SetText (11973)
1118 KitDoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1120 KitCancelButton
= KitWindow
.GetControl (12)
1121 KitCancelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1122 KitCancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, KitCancelPress
)
1123 KitCancelButton
.SetText (13727)
1124 KitCancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
1126 KitWindow
.SetVisible (WINDOW_VISIBLE
)
1129 def KitSelectPress():
1130 global KitWindow
, KitTextArea
1132 Kit
= GemRB
.GetVar ("MAGESCHOOL")
1133 KitTextArea
.SetText (KitTable
.GetValue (Kit
, 1))
1134 KitDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1145 def KitCancelPress():
1146 global ClassWindow
, KitWindow
1150 ClassWindow
.SetVisible (WINDOW_VISIBLE
)
1153 def ClassDonePress():
1154 global CharGenWindow
, CharGenState
, ClassWindow
, ClassButton
, AlignmentButton
1158 ClassWindow
.Unload ()
1159 ClassButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1160 ClassButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_NAND
)
1161 AlignmentButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1162 AlignmentButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1164 ClassIndex
= GemRB
.GetVar ("Class")-1
1165 Class
= CommonTables
.Classes
.GetValue (ClassIndex
, 5)
1166 GemRB
.SetPlayerStat (MyChar
, IE_CLASS
, Class
)
1168 Kit
= KitTable
.GetValue (GemRB
.GetVar ("MAGESCHOOL"), 3 )
1172 GemRB
.SetPlayerStat (MyChar
, IE_KIT
, Kit
)
1175 SetCharacterDescription()
1176 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
1179 def ClassCancelPress():
1180 global CharGenWindow
, ClassWindow
1183 ClassWindow
.Unload ()
1184 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
1187 # Alignment Selection
1189 def AlignmentPress():
1190 global CharGenWindow
, AlignmentWindow
, AlignmentTextArea
, AlignmentDoneButton
1192 CharGenWindow
.SetVisible (WINDOW_INVISIBLE
)
1193 AlignmentWindow
= GemRB
.LoadWindow (3)
1194 ClassAlignmentTable
= GemRB
.LoadTable ("alignmnt")
1195 Class
= GemRB
.GetPlayerStat (MyChar
, IE_CLASS
)
1196 ClassIndex
= CommonTables
.Classes
.FindValue (5, Class
)
1197 ClassName
= CommonTables
.Classes
.GetRowName (ClassIndex
)
1198 GemRB
.SetVar ("Alignment", 0)
1200 for i
in range (2, 11):
1201 AlignmentSelectButton
= AlignmentWindow
.GetControl (i
)
1202 AlignmentSelectButton
.SetFlags (IE_GUI_BUTTON_RADIOBUTTON
, OP_OR
)
1205 AlignmentSelectButton
= AlignmentWindow
.GetControl (i
+ 2)
1206 if ClassAlignmentTable
.GetValue (ClassName
, AlignmentTable
.GetValue(i
, 4)) == 0:
1207 AlignmentSelectButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1209 AlignmentSelectButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1210 AlignmentSelectButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AlignmentSelectPress
)
1211 AlignmentSelectButton
.SetText (AlignmentTable
.GetValue (i
, 0) )
1212 AlignmentSelectButton
.SetVarAssoc ("Alignment", i
+ 1)
1214 AlignmentTextArea
= AlignmentWindow
.GetControl (11)
1215 AlignmentTextArea
.SetText (9602)
1217 AlignmentDoneButton
= AlignmentWindow
.GetControl (0)
1218 AlignmentDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1219 AlignmentDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AlignmentDonePress
)
1220 AlignmentDoneButton
.SetText (11973)
1221 AlignmentDoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1223 AlignmentCancelButton
= AlignmentWindow
.GetControl (13)
1224 AlignmentCancelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1225 AlignmentCancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AlignmentCancelPress
)
1226 AlignmentCancelButton
.SetText (13727)
1227 AlignmentCancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
1229 AlignmentWindow
.SetVisible (WINDOW_VISIBLE
)
1232 def AlignmentSelectPress():
1233 global AlignmentWindow
, AlignmentTextArea
, AlignmentDoneButton
1235 Alignment
= GemRB
.GetVar ("Alignment") - 1
1236 AlignmentTextArea
.SetText (AlignmentTable
.GetValue (Alignment
, 1))
1237 AlignmentDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1240 def AlignmentDonePress():
1241 global CharGenWindow
, CharGenState
, AlignmentWindow
, AlignmentButton
, AbilitiesButton
1245 AlignmentWindow
.Unload ()
1246 AlignmentButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1247 AlignmentButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_NAND
)
1248 AbilitiesButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1249 AbilitiesButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1251 Alignment
= AlignmentTable
.GetValue (GemRB
.GetVar ("Alignment")-1, 3)
1252 GemRB
.SetPlayerStat (MyChar
, IE_ALIGNMENT
, Alignment
)
1255 SetCharacterDescription()
1256 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
1259 def AlignmentCancelPress():
1260 global CharGenWindow
, AlignmentWindow
1263 AlignmentWindow
.Unload ()
1264 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
1267 # Abilities Selection
1269 def AbilitiesPress():
1270 global CharGenWindow
, AbilitiesWindow
1271 global AbilitiesTextArea
, AbilitiesRecallButton
, AbilitiesDoneButton
1272 global AbilitiesRaceAddTable
, AbilitiesRaceReqTable
, AbilitiesClassReqTable
1275 GemRB
.SetRepeatClickFlags(GEM_RK_DISABLE
, OP_NAND
)
1276 CharGenWindow
.SetVisible (WINDOW_INVISIBLE
)
1277 AbilitiesWindow
= GemRB
.LoadWindow (4)
1278 AbilitiesRaceAddTable
= GemRB
.LoadTable ("ABRACEAD")
1279 AbilitiesRaceReqTable
= GemRB
.LoadTable ("ABRACERQ")
1280 AbilitiesClassReqTable
= GemRB
.LoadTable ("ABCLASRQ")
1282 PointsLeftLabel
= AbilitiesWindow
.GetControl (0x10000002)
1283 PointsLeftLabel
.SetUseRGB (1)
1285 Class
= GemRB
.GetPlayerStat (MyChar
, IE_CLASS
)
1286 Class
= CommonTables
.Classes
.FindValue (5, Class
)
1287 HasStrExtra
= CommonTables
.Classes
.GetValue (Class
, 3)=="SAVEWAR"
1290 AbilitiesLabelButton
= AbilitiesWindow
.GetControl (30 + i
)
1291 AbilitiesLabelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1292 AbilitiesLabelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AbilitiesLabelPress
)
1293 AbilitiesLabelButton
.SetVarAssoc ("AbilityIndex", i
+ 1)
1295 AbilitiesPlusButton
= AbilitiesWindow
.GetControl (16 + i
* 2)
1296 AbilitiesPlusButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1297 AbilitiesPlusButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AbilitiesPlusPress
)
1298 AbilitiesPlusButton
.SetVarAssoc ("AbilityIndex", i
+ 1)
1300 AbilitiesMinusButton
= AbilitiesWindow
.GetControl (17 + i
* 2)
1301 AbilitiesMinusButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1302 AbilitiesMinusButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AbilitiesMinusPress
)
1303 AbilitiesMinusButton
.SetVarAssoc ("AbilityIndex", i
+ 1)
1305 AbilityLabel
= AbilitiesWindow
.GetControl (0x10000003 + i
)
1306 AbilityLabel
.SetUseRGB (1)
1308 AbilitiesStoreButton
= AbilitiesWindow
.GetControl (37)
1309 AbilitiesStoreButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1310 AbilitiesStoreButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AbilitiesStorePress
)
1311 AbilitiesStoreButton
.SetText (17373)
1313 AbilitiesRecallButton
= AbilitiesWindow
.GetControl (38)
1314 AbilitiesRecallButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1315 AbilitiesRecallButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AbilitiesRecallPress
)
1316 AbilitiesRecallButton
.SetText (17374)
1318 AbilitiesRerollButton
= AbilitiesWindow
.GetControl (2)
1319 AbilitiesRerollButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1320 AbilitiesRerollButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AbilitiesRerollPress
)
1321 AbilitiesRerollButton
.SetText (11982)
1323 AbilitiesTextArea
= AbilitiesWindow
.GetControl (29)
1324 AbilitiesTextArea
.SetText (17247)
1326 AbilitiesDoneButton
= AbilitiesWindow
.GetControl (0)
1327 AbilitiesDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1328 AbilitiesDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AbilitiesDonePress
)
1329 AbilitiesDoneButton
.SetText (11973)
1330 AbilitiesDoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1332 AbilitiesCancelButton
= AbilitiesWindow
.GetControl (36)
1333 AbilitiesCancelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1334 AbilitiesCancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AbilitiesCancelPress
)
1335 AbilitiesCancelButton
.SetText (13727)
1336 AbilitiesCancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
1338 AbilitiesRerollPress()
1340 AbilitiesWindow
.SetVisible (WINDOW_VISIBLE
)
1343 def AbilitiesCalcLimits(Index
):
1344 global AbilitiesRaceReqTable
, AbilitiesRaceAddTable
, AbilitiesClassReqTable
1345 global AbilitiesMinimum
, AbilitiesMaximum
, AbilitiesModifier
1347 RaceName
= CommonTables
.Races
.GetRowName (GemRB
.GetPlayerStat (MyChar
, IE_RACE
) - 1)
1348 Race
= AbilitiesRaceReqTable
.GetRowIndex (RaceName
)
1349 AbilitiesMinimum
= AbilitiesRaceReqTable
.GetValue (Race
, Index
* 2)
1350 AbilitiesMaximum
= AbilitiesRaceReqTable
.GetValue (Race
, Index
* 2 + 1)
1351 AbilitiesModifier
= AbilitiesRaceAddTable
.GetValue (Race
, Index
)
1353 Class
= CommonTables
.Classes
.FindValue (5, GemRB
.GetPlayerStat (MyChar
, IE_CLASS
) )
1354 ClassName
= CommonTables
.Classes
.GetRowName (Class
)
1355 ClassIndex
= AbilitiesClassReqTable
.GetRowIndex (ClassName
)
1356 Min
= AbilitiesClassReqTable
.GetValue (ClassIndex
, Index
)
1357 if Min
> 0 and AbilitiesMinimum
< Min
:
1358 AbilitiesMinimum
= Min
1360 AbilitiesMinimum
= AbilitiesMinimum
+ AbilitiesModifier
1361 AbilitiesMaximum
= AbilitiesMaximum
+ AbilitiesModifier
1364 def AbilitiesLabelPress():
1365 global AbilitiesWindow
, AbilitiesTextArea
1367 AbilityIndex
= GemRB
.GetVar ("AbilityIndex") - 1
1368 AbilitiesCalcLimits(AbilityIndex
)
1369 GemRB
.SetToken ("MINIMUM", str(AbilitiesMinimum
) )
1370 GemRB
.SetToken ("MAXIMUM", str(AbilitiesMaximum
) )
1371 AbilitiesTextArea
.SetText (AbilitiesTable
.GetValue (AbilityIndex
, 1) )
1374 def AbilitiesPlusPress():
1375 global AbilitiesWindow
, AbilitiesTextArea
1376 global AbilitiesMinimum
, AbilitiesMaximum
1378 Abidx
= GemRB
.GetVar ("AbilityIndex") - 1
1379 AbilitiesCalcLimits(Abidx
)
1380 GemRB
.SetToken ("MINIMUM", str(AbilitiesMinimum
) )
1381 GemRB
.SetToken ("MAXIMUM", str(AbilitiesMaximum
) )
1382 AbilitiesTextArea
.SetText (AbilitiesTable
.GetValue (Abidx
, 1) )
1383 PointsLeft
= GemRB
.GetVar ("Ability0")
1384 Ability
= GemRB
.GetVar ("Ability" + str(Abidx
+ 1) )
1385 if PointsLeft
> 0 and Ability
< AbilitiesMaximum
:
1386 PointsLeft
= PointsLeft
- 1
1387 GemRB
.SetVar ("Ability0", PointsLeft
)
1388 PointsLeftLabel
= AbilitiesWindow
.GetControl (0x10000002)
1389 PointsLeftLabel
.SetText (str(PointsLeft
) )
1390 Ability
= Ability
+ 1
1391 GemRB
.SetVar ("Ability" + str(Abidx
+ 1), Ability
)
1392 Label
= AbilitiesWindow
.GetControl (0x10000003 + Abidx
)
1393 StrExtra
= GemRB
.GetVar("StrExtra")
1394 if Abidx
==0 and Ability
==18 and HasStrExtra
:
1395 Label
.SetText("18/"+str(StrExtra
) )
1397 Label
.SetText(str(Ability
) )
1400 AbilitiesDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1403 def AbilitiesMinusPress():
1404 global AbilitiesWindow
, AbilitiesTextArea
1405 global AbilitiesMinimum
, AbilitiesMaximum
1407 Abidx
= GemRB
.GetVar ("AbilityIndex") - 1
1408 AbilitiesCalcLimits(Abidx
)
1409 GemRB
.SetToken ("MINIMUM", str(AbilitiesMinimum
) )
1410 GemRB
.SetToken ("MAXIMUM", str(AbilitiesMaximum
) )
1411 AbilitiesTextArea
.SetText (AbilitiesTable
.GetValue (Abidx
, 1) )
1412 PointsLeft
= GemRB
.GetVar ("Ability0")
1413 Ability
= GemRB
.GetVar ("Ability" + str(Abidx
+ 1) )
1414 if Ability
> AbilitiesMinimum
:
1415 Ability
= Ability
- 1
1416 GemRB
.SetVar ("Ability" + str(Abidx
+ 1), Ability
)
1417 Label
= AbilitiesWindow
.GetControl (0x10000003 + Abidx
)
1418 StrExtra
= GemRB
.GetVar("StrExtra")
1419 if Abidx
==0 and Ability
==18 and HasStrExtra
:
1420 Label
.SetText("18/"+str(StrExtra
) )
1422 Label
.SetText(str(Ability
) )
1424 PointsLeft
= PointsLeft
+ 1
1425 GemRB
.SetVar ("Ability0", PointsLeft
)
1426 PointsLeftLabel
= AbilitiesWindow
.GetControl (0x10000002)
1427 PointsLeftLabel
.SetText (str(PointsLeft
) )
1428 AbilitiesDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1431 def AbilitiesStorePress():
1432 global AbilitiesWindow
, AbilitiesRecallButton
1434 GemRB
.SetVar("StoredStrExtra", GemRB
.GetVar ("StrExtra") )
1436 GemRB
.SetVar ("Stored" + str(i
), GemRB
.GetVar ("Ability" + str(i
)))
1437 AbilitiesRecallButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1440 def AbilitiesRecallPress():
1441 global AbilitiesWindow
1443 AbilitiesWindow
.Invalidate ()
1444 e
=GemRB
.GetVar("StoredStrExtra")
1445 GemRB
.SetVar("StrExtra",e
)
1447 v
= GemRB
.GetVar ("Stored" + str(i
))
1448 GemRB
.SetVar ("Ability" + str(i
), v
)
1449 Label
= AbilitiesWindow
.GetControl (0x10000002 + i
)
1450 if i
==0 and v
==18 and HasStrExtra
==1:
1451 Label
.SetText("18/"+str(e
) )
1453 Label
.SetText(str(v
) )
1455 PointsLeft
= GemRB
.GetVar("Ability0")
1457 AbilitiesDoneButton
.SetState(IE_GUI_BUTTON_ENABLED
)
1459 AbilitiesDoneButton
.SetState(IE_GUI_BUTTON_DISABLED
)
1462 def AbilitiesRerollPress():
1463 global AbilitiesWindow
, AbilitiesMinimum
, AbilitiesMaximum
, AbilitiesModifier
1465 AbilitiesWindow
.Invalidate ()
1466 GemRB
.SetVar ("Ability0", 0)
1467 PointsLeftLabel
= AbilitiesWindow
.GetControl (0x10000002)
1468 PointsLeftLabel
.SetText ("0")
1472 #roll strextra even when the current stat is not 18
1474 e
= GemRB
.Roll (1,100,0)
1477 GemRB
.SetVar("StrExtra", e
)
1479 AbilitiesCalcLimits(i
)
1480 Value
= GemRB
.Roll (Dices
, Sides
, AbilitiesModifier
+3)
1481 if Value
< AbilitiesMinimum
:
1482 Value
= AbilitiesMinimum
1483 if Value
> AbilitiesMaximum
:
1484 Value
= AbilitiesMaximum
1485 GemRB
.SetVar ("Ability" + str(i
+ 1), Value
)
1486 Label
= AbilitiesWindow
.GetControl (0x10000003 + i
)
1488 if i
==0 and HasStrExtra
and Value
==18:
1489 Label
.SetText("18/"+str(e
) )
1491 Label
.SetText(str(Value
) )
1493 AbilitiesDoneButton
.SetState(IE_GUI_BUTTON_ENABLED
)
1496 def AbilitiesDonePress():
1497 global CharGenWindow
, CharGenState
, AbilitiesWindow
, AbilitiesButton
, SkillsButton
, SkillsState
1500 AbilitiesWindow
.Unload ()
1501 AbilitiesButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1502 AbilitiesButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_NAND
)
1503 SkillsButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1504 SkillsButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1506 Str
= GemRB
.GetVar ("Ability1")
1507 GemRB
.SetPlayerStat (MyChar
, IE_STR
, Str
)
1509 GemRB
.SetPlayerStat (MyChar
, IE_STREXTRA
, GemRB
.GetVar ("StrExtra"))
1511 GemRB
.SetPlayerStat (MyChar
, IE_STREXTRA
, 0)
1513 GemRB
.SetPlayerStat (MyChar
, IE_DEX
, GemRB
.GetVar ("Ability2"))
1514 GemRB
.SetPlayerStat (MyChar
, IE_CON
, GemRB
.GetVar ("Ability3"))
1515 GemRB
.SetPlayerStat (MyChar
, IE_INT
, GemRB
.GetVar ("Ability4"))
1516 GemRB
.SetPlayerStat (MyChar
, IE_WIS
, GemRB
.GetVar ("Ability5"))
1517 GemRB
.SetPlayerStat (MyChar
, IE_CHR
, GemRB
.GetVar ("Ability6"))
1521 SetCharacterDescription()
1522 GemRB
.SetRepeatClickFlags(GEM_RK_DISABLE
, OP_OR
)
1523 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
1526 def AbilitiesCancelPress():
1527 global CharGenWindow
, AbilitiesWindow
1530 AbilitiesWindow
.Unload ()
1531 GemRB
.SetRepeatClickFlags(GEM_RK_DISABLE
, OP_OR
)
1532 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
1538 global CharGenWindow
, AppearanceButton
1539 global SkillsState
, SkillsButton
, CharGenState
, ClassFlag
1543 Class
= GemRB
.GetPlayerStat (MyChar
, IE_CLASS
)
1544 IsRanger
= CommonTables
.ClassSkills
.GetValue (Class
, 0)
1545 IsArcane
= CommonTables
.ClassSkills
.GetValue (Class
, 1)
1546 IsMage
= CommonTables
.ClassSkills
.GetValue (Class
, 2)
1547 IsBard
= CommonTables
.ClassSkills
.GetValue (Class
, 4)
1548 IsThief
= CommonTables
.ClassSkills
.GetValue (Class
, 5)
1550 if SkillsState
== 0:
1551 GemRB
.SetVar ("HatedRace", 0)
1552 RaceName
= CommonTables
.Races
.GetRowName (GemRB
.GetPlayerStat (MyChar
, IE_RACE
) - 1)
1556 SkillRaceTable
= GemRB
.LoadTable ("SKILLRAC")
1557 SkillDexterityTable
= GemRB
.LoadTable ("SKILLDEX")
1558 Dexterity
= str(GemRB
.GetPlayerStat (MyChar
, IE_DEX
) )
1559 Skill
= SkillRaceTable
.GetValue (RaceName
, "STEALTH")
1560 Skill
= Skill
+ SkillDexterityTable
.GetValue(Dexterity
, "STEALTH")
1561 Skill
= Skill
+ GemRB
.LoadTable("SKILLRNG").GetValue(str(Level
), "STEALTH")
1562 GemRB
.SetPlayerStat (MyChar
, IE_STEALTH
, Skill
)
1565 SkillRaceTable
= GemRB
.LoadTable ("SKILLRAC")
1566 SkillDexterityTable
= GemRB
.LoadTable ("SKILLDEX")
1567 Dexterity
= str(GemRB
.GetPlayerStat (MyChar
, IE_DEX
) )
1568 Skill
= SkillRaceTable
.GetValue (RaceName
, "PICK_POCKETS")
1569 Skill
= Skill
+ SkillDexterityTable
.GetValue(Dexterity
, "PICK_POCKETS")
1570 Skill
= Skill
+ GemRB
.LoadTable(IsBard
).GetValue(str(Level
), "PICK_POCKETS")
1571 GemRB
.SetPlayerStat (MyChar
, IE_PICKPOCKET
, Skill
)
1576 if SkillsState
== 1:
1577 ProficienciesSelect()
1579 if SkillsState
== 2:
1581 MageSpellsSelect(IsMage
, Level
, SpellLevel
)
1585 if SkillsState
== 3:
1587 MageSpellsMemorize(IsMage
, Level
, SpellLevel
)
1591 if SkillsState
== 4:
1592 if IsArcane
=="MXSPLPRS" or IsArcane
=="MXSPLPAL":
1594 PriestSpellsMemorize(IsArcane
, Level
, SpellLevel
)
1595 elif IsArcane
=="MXSPLDRU" or IsArcane
=="MXSPLRAN":
1596 #no separate spell progression
1597 if IsArcane
== "MXSPLDRU":
1598 IsArcane
= "MXSPLPRS"
1600 PriestSpellsMemorize(IsArcane
, Level
, SpellLevel
)
1604 if SkillsState
== 5:
1605 SkillsButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1606 SkillsButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_NAND
)
1607 AppearanceButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1608 AppearanceButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1610 Race
= GemRB
.GetVar ("HatedRace")
1611 GemRB
.SetPlayerStat (MyChar
, IE_HATEDRACE
, Race
)
1613 ProfCount
= ProficienciesTable
.GetRowCount ()
1614 for i
in range(ProfCount
):
1615 StatID
= ProficienciesTable
.GetValue (i
, 0)
1616 Value
= GemRB
.GetVar ("Proficiency"+str(i
) )
1617 GemRB
.SetPlayerStat (MyChar
, StatID
, Value
)
1620 SetCharacterDescription()
1624 global CharGenWindow
, SkillsWindow
, SkillsTextArea
, SkillsDoneButton
, SkillsPointsLeft
1626 CharGenWindow
.SetVisible (WINDOW_INVISIBLE
)
1627 SkillsWindow
= GemRB
.LoadWindow (6)
1628 RaceName
= CommonTables
.Races
.GetRowName (GemRB
.GetPlayerStat (MyChar
, IE_RACE
) - 1)
1629 Dexterity
= str(GetPlayerStat (MyChar
, IE_DEX
) )
1630 SkillRaceTable
= GemRB
.LoadTable ("SKILLRAC")
1631 SkillDexterityTable
= GemRB
.LoadTable ("SKILLDEX")
1633 Levels
= [GemRB
.GetPlayerStat (MyChar
, IE_LEVEL
), \
1634 GemRB
.GetPlayerStat (MyChar
, IE_LEVEL2
), \
1635 GemRB
.GetPlayerStat (MyChar
, IE_LEVEL3
)]
1637 LUSkillsSelection
.SetupSkillsWindow (MyChar
, \
1638 LUSkillsSelection
.LUSKILLS_TYPE_CHARGEN
, SkillsWindow
, RedrawSkills
, [0,0,0], Levels
, 0, False)
1640 SkillsPointsLeft
= GemRB
.GetVar ("SkillPointsLeft")
1641 if SkillsPointsLeft
<=0:
1645 SkillsDoneButton
= SkillsWindow
.GetControl (0)
1646 SkillsDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1647 SkillsDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, SkillsDonePress
)
1648 SkillsDoneButton
.SetText (11973)
1649 SkillsDoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1651 SkillsCancelButton
= SkillsWindow
.GetControl (25)
1652 SkillsCancelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1653 SkillsCancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, SkillsCancelPress
)
1654 SkillsCancelButton
.SetText (13727)
1655 SkillsCancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
1656 GemRB
.SetRepeatClickFlags(GEM_RK_DISABLE
, OP_NAND
)
1659 SkillsWindow
.SetVisible (WINDOW_VISIBLE
)
1663 PointsLeft
= GemRB
.GetVar ("SkillPointsLeft")
1665 SkillsDoneButton
.SetState(IE_GUI_BUTTON_ENABLED
)
1667 SkillsDoneButton
.SetState(IE_GUI_BUTTON_DISABLED
)
1670 def SkillsDonePress():
1671 global CharGenWindow
, SkillsWindow
, SkillsState
1674 SkillsWindow
.Unload ()
1676 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
1680 def SkillsCancelPress():
1681 global CharGenWindow
, SkillsWindow
, SkillsState
1684 SkillsWindow
.Unload ()
1686 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
1689 # Racial Enemy Selection
1691 def RacialEnemySelect():
1692 global CharGenWindow
, RacialEnemyWindow
, RacialEnemyTextArea
, RacialEnemyDoneButton
1694 CharGenWindow
.SetVisible (WINDOW_INVISIBLE
)
1695 RacialEnemyWindow
= GemRB
.LoadWindow (15)
1696 RacialEnemyCount
= RacialEnemyTable
.GetRowCount ()
1698 for i
in range (2, 8):
1699 RacialEnemySelectButton
= RacialEnemyWindow
.GetControl (i
)
1700 RacialEnemySelectButton
.SetFlags (IE_GUI_BUTTON_RADIOBUTTON
, OP_OR
)
1702 for i
in range (2, 8):
1703 RacialEnemySelectButton
= RacialEnemyWindow
.GetControl (i
)
1704 RacialEnemySelectButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1705 RacialEnemySelectButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, RacialEnemySelectPress
)
1706 RacialEnemySelectButton
.SetVarAssoc ("RacialEnemy", i
- 1)
1708 GemRB
.SetVar ("RacialEnemyIndex", 0)
1709 GemRB
.SetVar ("HatedRace", 0)
1710 RacialEnemyScrollBar
= RacialEnemyWindow
.GetControl (1)
1711 RacialEnemyScrollBar
.SetVarAssoc ("RacialEnemyIndex", RacialEnemyCount
- 5)
1712 RacialEnemyScrollBar
.SetEvent (IE_GUI_SCROLLBAR_ON_CHANGE
, DisplayRacialEnemies
)
1714 RacialEnemyTextArea
= RacialEnemyWindow
.GetControl (8)
1715 RacialEnemyTextArea
.SetText (17256)
1717 RacialEnemyDoneButton
= RacialEnemyWindow
.GetControl (11)
1718 RacialEnemyDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1719 RacialEnemyDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, RacialEnemyDonePress
)
1720 RacialEnemyDoneButton
.SetText (11973)
1721 RacialEnemyDoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1723 RacialEnemyCancelButton
= RacialEnemyWindow
.GetControl (10)
1724 RacialEnemyCancelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1725 RacialEnemyCancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, RacialEnemyCancelPress
)
1726 RacialEnemyCancelButton
.SetText (13727)
1727 RacialEnemyCancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
1729 DisplayRacialEnemies()
1730 RacialEnemyWindow
.SetVisible (WINDOW_VISIBLE
)
1733 def DisplayRacialEnemies():
1734 global RacialEnemyWindow
1736 RacialEnemyIndex
= GemRB
.GetVar ("RacialEnemyIndex")
1737 for i
in range (2, 8):
1738 RacialEnemySelectButton
= RacialEnemyWindow
.GetControl (i
)
1739 RacialEnemySelectButton
.SetText (RacialEnemyTable
.GetValue (RacialEnemyIndex
+ i
- 2, 0))
1742 def RacialEnemySelectPress():
1743 global RacialEnemyWindow
, RacialEnemyDoneButton
, RacialEnemyTextArea
1745 RacialEnemy
= GemRB
.GetVar ("RacialEnemyIndex") + GemRB
.GetVar ("RacialEnemy") - 1
1746 RacialEnemyTextArea
.SetText (RacialEnemyTable
.GetValue (RacialEnemy
, 2) )
1747 GemRB
.SetVar ("HatedRace", RacialEnemyTable
.GetValue (RacialEnemy
, 1) )
1748 RacialEnemyDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1751 def RacialEnemyDonePress():
1752 global CharGenWindow
, RacialEnemyWindow
, SkillsState
1754 if RacialEnemyWindow
:
1755 RacialEnemyWindow
.Unload ()
1758 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
1762 def RacialEnemyCancelPress():
1763 global CharGenWindow
, RacialEnemyWindow
, SkillsState
1765 if RacialEnemyWindow
:
1766 RacialEnemyWindow
.Unload ()
1768 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
1772 # Weapon Proficiencies Selection
1774 def ProficienciesSelect():
1775 global CharGenWindow
, ProficienciesWindow
, ProficienciesTextArea
1776 global ProficienciesPointsLeft
, ProficienciesDoneButton
, ProfsMaxTable
1778 CharGenWindow
.SetVisible (WINDOW_INVISIBLE
)
1779 ProficienciesWindow
= GemRB
.LoadWindow (9)
1780 ProfsTable
= GemRB
.LoadTable ("profs")
1781 ProfsMaxTable
= GemRB
.LoadTable ("profsmax")
1782 ClassWeaponsTable
= GemRB
.LoadTable ("clasweap")
1784 Class
= GemRB
.GetPlayerStat (MyChar
, IE_CLASS
)
1785 ClassIndex
= CommonTables
.Classes
.FindValue (5, Class
)
1786 ClassName
= CommonTables
.Classes
.GetRowName (ClassIndex
)
1787 Class
= ProfsTable
.GetRowIndex (ClassName
)
1788 ProficienciesPointsLeft
= ProfsTable
.GetValue (Class
, 0)
1789 PointsLeftLabel
= ProficienciesWindow
.GetControl (0x10000009)
1790 PointsLeftLabel
.SetUseRGB (1)
1791 PointsLeftLabel
.SetText (str(ProficienciesPointsLeft
))
1794 ProficienciesLabel
= ProficienciesWindow
.GetControl (69 + i
)
1795 ProficienciesLabel
.SetState (IE_GUI_BUTTON_ENABLED
)
1796 ProficienciesLabel
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ProficienciesLabelPress
)
1797 ProficienciesLabel
.SetVarAssoc ("ProficienciesIndex", i
+ 1)
1800 ProficienciesMark
= ProficienciesWindow
.GetControl (27 + i
* 5 + j
)
1801 ProficienciesMark
.SetSprites("GUIPFC", 0, 0, 0, 0, 0)
1802 ProficienciesMark
.SetState (IE_GUI_BUTTON_DISABLED
)
1803 ProficienciesMark
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_OR
)
1805 Allowed
= ClassWeaponsTable
.GetValue (ClassName
, ProficienciesTable
.GetRowName (i
))
1807 ProficienciesPlusButton
= ProficienciesWindow
.GetControl (11 + i
* 2)
1809 ProficienciesPlusButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1810 ProficienciesPlusButton
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_OR
)
1812 ProficienciesPlusButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1813 ProficienciesPlusButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ProficienciesPlusPress
)
1814 ProficienciesPlusButton
.SetVarAssoc ("ProficienciesIndex", i
+ 1)
1816 ProficienciesMinusButton
= ProficienciesWindow
.GetControl (12 + i
* 2)
1818 ProficienciesMinusButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1819 ProficienciesMinusButton
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_OR
)
1821 ProficienciesMinusButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1822 ProficienciesMinusButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ProficienciesMinusPress
)
1823 ProficienciesMinusButton
.SetVarAssoc ("ProficienciesIndex", i
+ 1)
1826 ProficienciesLabel
= ProficienciesWindow
.GetControl (85 + i
)
1827 ProficienciesLabel
.SetState (IE_GUI_BUTTON_ENABLED
)
1828 ProficienciesLabel
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ProficienciesLabelPress
)
1829 ProficienciesLabel
.SetVarAssoc ("ProficienciesIndex", i
+ 9)
1832 ProficienciesMark
= ProficienciesWindow
.GetControl (92 + i
* 5 + j
)
1833 ProficienciesMark
.SetSprites("GUIPFC", 0, 0, 0, 0, 0)
1834 ProficienciesMark
.SetState (IE_GUI_BUTTON_DISABLED
)
1835 ProficienciesMark
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_OR
)
1837 Allowed
= ClassWeaponsTable
.GetValue (ClassName
, ProficienciesTable
.GetRowName (i
+ 8))
1839 ProficienciesPlusButton
= ProficienciesWindow
.GetControl (127 + i
* 2)
1841 ProficienciesPlusButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1842 ProficienciesPlusButton
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_OR
)
1844 ProficienciesPlusButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1845 ProficienciesPlusButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ProficienciesPlusPress
)
1846 ProficienciesPlusButton
.SetVarAssoc ("ProficienciesIndex", i
+ 9)
1848 ProficienciesMinusButton
= ProficienciesWindow
.GetControl (128 + i
* 2)
1850 ProficienciesMinusButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1851 ProficienciesMinusButton
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_OR
)
1853 ProficienciesMinusButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1854 ProficienciesMinusButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ProficienciesMinusPress
)
1855 ProficienciesMinusButton
.SetVarAssoc ("ProficienciesIndex", i
+ 9)
1857 for i
in range (15):
1858 GemRB
.SetVar ("Proficiency" + str(i
), 0)
1860 GemRB
.SetToken ("number", str(ProficienciesPointsLeft
) )
1861 ProficienciesTextArea
= ProficienciesWindow
.GetControl (68)
1862 ProficienciesTextArea
.SetText (9588)
1864 ProficienciesDoneButton
= ProficienciesWindow
.GetControl (0)
1865 ProficienciesDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1866 ProficienciesDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ProficienciesDonePress
)
1867 ProficienciesDoneButton
.SetText (11973)
1868 ProficienciesDoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1870 ProficienciesCancelButton
= ProficienciesWindow
.GetControl (77)
1871 ProficienciesCancelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1872 ProficienciesCancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ProficienciesCancelPress
)
1873 ProficienciesCancelButton
.SetText (13727)
1874 ProficienciesCancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
1876 ProficienciesWindow
.SetVisible (WINDOW_VISIBLE
)
1879 def ProficienciesLabelPress():
1880 global ProficienciesWindow
, ProficienciesTextArea
1882 ProficienciesIndex
= GemRB
.GetVar ("ProficienciesIndex") - 1
1883 ProficienciesTextArea
.SetText (ProficienciesTable
.GetValue (ProficienciesIndex
, 2) )
1886 def ProficienciesPlusPress():
1887 global ProficienciesWindow
, ProficienciesTextArea
1888 global ProficienciesPointsLeft
, ProfsMaxTable
1890 ProficienciesIndex
= GemRB
.GetVar ("ProficienciesIndex") - 1
1891 ProficienciesValue
= GemRB
.GetVar ("Proficiency" + str(ProficienciesIndex
) )
1892 Class
= GemRB
.GetPlayerStat (MyChar
, IE_CLASS
)
1893 ClassIndex
= CommonTables
.Classes
.FindValue (5, Class
)
1894 ClassName
= CommonTables
.Classes
.GetRowName (ClassIndex
)
1895 Class
= ProfsMaxTable
.GetRowIndex (ClassName
)
1896 if ProficienciesPointsLeft
> 0 and ProficienciesValue
< ProfsMaxTable
.GetValue (Class
, 0):
1897 ProficienciesPointsLeft
= ProficienciesPointsLeft
- 1
1898 PointsLeftLabel
= ProficienciesWindow
.GetControl (0x10000009)
1899 PointsLeftLabel
.SetText (str(ProficienciesPointsLeft
))
1900 if ProficienciesPointsLeft
== 0:
1901 ProficienciesDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1903 ProficienciesValue
= ProficienciesValue
+ 1
1904 GemRB
.SetVar ("Proficiency" + str(ProficienciesIndex
), ProficienciesValue
)
1905 if ProficienciesIndex
< 8:
1906 ControlID
= 26 + ProficienciesIndex
* 5 + ProficienciesValue
1908 ControlID
= 51 + ProficienciesIndex
* 5 + ProficienciesValue
1909 ProficienciesMark
= ProficienciesWindow
.GetControl (ControlID
)
1910 ProficienciesMark
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_NAND
)
1912 ProficienciesTextArea
.SetText (ProficienciesTable
.GetValue (ProficienciesIndex
, 2) )
1915 def ProficienciesMinusPress():
1916 global ProficienciesWindow
, ProficienciesTextArea
, ProficienciesPointsLeft
1918 ProficienciesIndex
= GemRB
.GetVar ("ProficienciesIndex") - 1
1919 ProficienciesValue
= GemRB
.GetVar ("Proficiency" + str(ProficienciesIndex
) )
1920 if ProficienciesValue
> 0:
1921 ProficienciesValue
= ProficienciesValue
- 1
1922 GemRB
.SetVar ("Proficiency" + str(ProficienciesIndex
), ProficienciesValue
)
1923 if ProficienciesIndex
< 8:
1924 ControlID
= 27 + ProficienciesIndex
* 5 + ProficienciesValue
1926 ControlID
= 52 + ProficienciesIndex
* 5 + ProficienciesValue
1927 ProficienciesMark
= ProficienciesWindow
.GetControl (ControlID
)
1928 ProficienciesMark
.SetFlags (IE_GUI_BUTTON_NO_IMAGE
, OP_OR
)
1930 ProficienciesPointsLeft
= ProficienciesPointsLeft
+ 1
1931 PointsLeftLabel
= ProficienciesWindow
.GetControl (0x10000009)
1932 PointsLeftLabel
.SetText (str(ProficienciesPointsLeft
))
1933 ProficienciesDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1935 ProficienciesTextArea
.SetText (ProficienciesTable
.GetValue (ProficienciesIndex
, 2) )
1938 def ProficienciesDonePress():
1939 global CharGenWindow
, ProficienciesWindow
, SkillsState
1941 if ProficienciesWindow
:
1942 ProficienciesWindow
.Unload ()
1944 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
1948 def ProficienciesCancelPress():
1949 global CharGenWindow
, ProficienciesWindow
, SkillsState
1951 if ProficienciesWindow
:
1952 ProficienciesWindow
.Unload ()
1954 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
1959 def MageSpellsSelect(SpellTable
, Level
, SpellLevel
):
1960 global CharGenWindow
, MageSpellsWindow
, MageSpellsTextArea
, MageSpellsDoneButton
, MageSpellsSelectPointsLeft
, Learnable
1962 CharGenWindow
.SetVisible (WINDOW_INVISIBLE
)
1963 MageSpellsWindow
= GemRB
.LoadWindow (7)
1964 #kit (school), alignment, level
1965 k
= GemRB
.GetPlayerStat (MyChar
, IE_KIT
)
1966 t
= GemRB
.GetPlayerStat (MyChar
, IE_ALIGNMENT
)
1967 Learnable
= GUICommon
.GetLearnableMageSpells(k
, t
, SpellLevel
)
1968 GemRB
.SetVar ("MageSpellBook", 0)
1969 GemRB
.SetVar ("SpellMask", 0)
1971 if len(Learnable
)<1:
1972 MageSpellsDonePress()
1976 MageSpellsSelectPointsLeft
= 3
1978 MageSpellsSelectPointsLeft
= 2
1979 PointsLeftLabel
= MageSpellsWindow
.GetControl (0x1000001b)
1980 PointsLeftLabel
.SetUseRGB (1)
1981 PointsLeftLabel
.SetText (str(MageSpellsSelectPointsLeft
))
1983 for i
in range (24):
1984 SpellButton
= MageSpellsWindow
.GetControl (i
+ 2)
1985 SpellButton
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_CHECKBOX
, OP_OR
)
1986 if i
< len(Learnable
):
1987 Spell
= GemRB
.GetSpell (Learnable
[i
])
1988 SpellButton
.SetSpellIcon(Learnable
[i
], 1)
1989 SpellButton
.SetState (IE_GUI_BUTTON_ENABLED
)
1990 SpellButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, MageSpellsSelectPress
)
1991 SpellButton
.SetVarAssoc ("SpellMask", 1 << i
)
1992 SpellButton
.SetTooltip(Spell
["SpellName"])
1994 SpellButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1996 GemRB
.SetToken ("number", str(MageSpellsSelectPointsLeft
))
1997 MageSpellsTextArea
= MageSpellsWindow
.GetControl (27)
1998 MageSpellsTextArea
.SetText (17250)
2000 MageSpellsDoneButton
= MageSpellsWindow
.GetControl (0)
2001 MageSpellsDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
2002 MageSpellsDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, MageSpellsDonePress
)
2003 MageSpellsDoneButton
.SetText (11973)
2004 MageSpellsDoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
2006 MageSpellsCancelButton
= MageSpellsWindow
.GetControl (29)
2007 MageSpellsCancelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2008 MageSpellsCancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, MageSpellsCancelPress
)
2009 MageSpellsCancelButton
.SetText (13727)
2010 MageSpellsCancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
2012 MageSpellsWindow
.SetVisible (WINDOW_VISIBLE
)
2015 def MageSpellsSelectPress():
2016 global MageSpellsWindow
, MageSpellsTextArea
, MageSpellsDoneButton
, MageSpellsSelectPointsLeft
, Learnable
2018 MageSpellBook
= GemRB
.GetVar ("MageSpellBook")
2019 SpellMask
= GemRB
.GetVar ("SpellMask")
2021 #getting the bit index
2022 Spell
= abs(MageSpellBook
- SpellMask
)
2028 Spell
= GemRB
.GetSpell (Learnable
[i
])
2029 MageSpellsTextArea
.SetText (Spell
["SpellDesc"])
2031 if SpellMask
< MageSpellBook
:
2032 MageSpellsSelectPointsLeft
= MageSpellsSelectPointsLeft
+ 1
2034 if MageSpellsSelectPointsLeft
==0:
2035 SpellMask
= MageSpellBook
2036 GemRB
.SetVar ("SpellMask", SpellMask
)
2038 MageSpellsSelectPointsLeft
= MageSpellsSelectPointsLeft
- 1
2040 if MageSpellsSelectPointsLeft
== 0:
2041 MageSpellsDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2043 MageSpellsDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
2045 for i
in range (len(Learnable
)):
2046 SpellButton
= MageSpellsWindow
.GetControl (i
+ 2)
2047 if ((1 << i
) & SpellMask
) == 0:
2048 SpellButton
.SetState (IE_GUI_BUTTON_LOCKED
)
2050 PointsLeftLabel
= MageSpellsWindow
.GetControl (0x1000001b)
2051 PointsLeftLabel
.SetText (str(MageSpellsSelectPointsLeft
))
2052 GemRB
.SetVar ("MageSpellBook", SpellMask
)
2055 def MageSpellsDonePress():
2056 global CharGenWindow
, MageSpellsWindow
, SkillsState
2058 if MageSpellsWindow
:
2059 MageSpellsWindow
.Unload ()
2061 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
2065 def MageSpellsCancelPress():
2066 global CharGenWindow
, MageSpellsWindow
, SkillsState
2068 if MageSpellsWindow
:
2069 MageSpellsWindow
.Unload ()
2071 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
2075 # Mage Spells Memorize
2077 def MageSpellsMemorize(SpellTable
, Level
, SpellLevel
):
2078 global CharGenWindow
, MageMemorizeWindow
, MageMemorizeTextArea
, MageMemorizeDoneButton
, MageMemorizePointsLeft
2080 CharGenWindow
.SetVisible (WINDOW_INVISIBLE
)
2081 MageMemorizeWindow
= GemRB
.LoadWindow (16)
2082 MaxSpellsMageTable
= GemRB
.LoadTable (SpellTable
)
2083 MageSpellBook
= GemRB
.GetVar ("MageSpellBook")
2084 GemRB
.SetVar ("MageMemorized", 0)
2085 GemRB
.SetVar ("SpellMask", 0)
2087 MageMemorizePointsLeft
= MaxSpellsMageTable
.GetValue (str(Level
), str(SpellLevel
) )
2088 if MageMemorizePointsLeft
<1 or len(Learnable
)<1:
2089 MageMemorizeDonePress()
2092 PointsLeftLabel
= MageMemorizeWindow
.GetControl (0x1000001b)
2093 PointsLeftLabel
.SetUseRGB (1)
2094 PointsLeftLabel
.SetText (str(MageMemorizePointsLeft
))
2097 for i
in range (12):
2098 SpellButton
= MageMemorizeWindow
.GetControl (i
+ 2)
2099 SpellButton
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_CHECKBOX
, OP_OR
)
2100 while (j
< len(Learnable
)) and (((1 << j
) & MageSpellBook
) == 0):
2102 if j
< len(Learnable
):
2103 Spell
= GemRB
.GetSpell (Learnable
[j
])
2104 SpellButton
.SetTooltip(Spell
["SpellName"])
2105 SpellButton
.SetSpellIcon(Learnable
[j
], 1)
2106 SpellButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2107 SpellButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, MageMemorizeSelectPress
)
2108 SpellButton
.SetVarAssoc ("SpellMask", 1 << j
)
2111 SpellButton
.SetState (IE_GUI_BUTTON_DISABLED
)
2113 GemRB
.SetToken ("number", str(MageMemorizePointsLeft
))
2114 MageMemorizeTextArea
= MageMemorizeWindow
.GetControl (27)
2115 MageMemorizeTextArea
.SetText (17253)
2117 MageMemorizeDoneButton
= MageMemorizeWindow
.GetControl (0)
2118 MageMemorizeDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
2119 MageMemorizeDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, MageMemorizeDonePress
)
2120 MageMemorizeDoneButton
.SetText (11973)
2121 MageMemorizeDoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
2123 MageMemorizeCancelButton
= MageMemorizeWindow
.GetControl (29)
2124 MageMemorizeCancelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2125 MageMemorizeCancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, MageMemorizeCancelPress
)
2126 MageMemorizeCancelButton
.SetText (13727)
2127 MageMemorizeCancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
2129 MageMemorizeWindow
.SetVisible (WINDOW_VISIBLE
)
2132 def MageMemorizeSelectPress():
2133 global MageMemorizeWindow
, MageMemorizeTextArea
, MageMemorizeDoneButton
, MageMemorizePointsLeft
, Learnable
2135 MageSpellBook
= GemRB
.GetVar ("MageSpellBook")
2136 MageMemorized
= GemRB
.GetVar ("MageMemorized")
2137 SpellMask
= GemRB
.GetVar ("SpellMask")
2139 Spell
= abs(MageMemorized
- SpellMask
)
2145 Spell
= GemRB
.GetSpell (Learnable
[i
])
2146 MageMemorizeTextArea
.SetText (Spell
["SpellDesc"])
2148 if SpellMask
< MageMemorized
:
2149 MageMemorizePointsLeft
= MageMemorizePointsLeft
+ 1
2151 for i
in range (12):
2152 SpellButton
= MageMemorizeWindow
.GetControl (i
+ 2)
2153 while (j
< len(Learnable
) ) and (((1 << j
) & MageSpellBook
) == 0):
2155 if j
< len(Learnable
):
2156 SpellButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2158 MageMemorizeDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
2160 MageMemorizePointsLeft
= MageMemorizePointsLeft
- 1
2161 if MageMemorizePointsLeft
== 0:
2163 for i
in range (12):
2164 SpellButton
= MageMemorizeWindow
.GetControl (i
+ 2)
2165 while (j
< len(Learnable
) ) and (((1 << j
) & MageSpellBook
) == 0):
2167 if j
< len(Learnable
):
2168 if ((1 << j
) & SpellMask
) == 0:
2169 SpellButton
.SetState (IE_GUI_BUTTON_DISABLED
)
2171 MageMemorizeDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2173 PointsLeftLabel
= MageMemorizeWindow
.GetControl (0x1000001b)
2174 PointsLeftLabel
.SetText (str(MageMemorizePointsLeft
))
2175 GemRB
.SetVar ("MageMemorized", SpellMask
)
2178 def MageMemorizeDonePress():
2179 global CharGenWindow
, MageMemorizeWindow
, SkillsState
2181 if MageMemorizeWindow
:
2182 MageMemorizeWindow
.Unload ()
2184 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
2188 def MageMemorizeCancelPress():
2189 global CharGenWindow
, MageMemorizeWindow
, SkillsState
2191 if MageMemorizeWindow
:
2192 MageMemorizeWindow
.Unload ()
2194 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
2197 # Priest Spells Memorize
2199 def PriestSpellsMemorize(SpellTable
, Level
, SpellLevel
):
2200 global CharGenWindow
, PriestMemorizeWindow
, Learnable
, ClassFlag
2201 global PriestMemorizeTextArea
, PriestMemorizeDoneButton
, PriestMemorizePointsLeft
2203 CharGenWindow
.SetVisible (WINDOW_INVISIBLE
)
2204 PriestMemorizeWindow
= GemRB
.LoadWindow (17)
2205 t
= AlignmentTable
.GetValue ( GemRB
.GetVar ("Alignment")-1, 3)
2206 Learnable
= GUICommon
.GetLearnablePriestSpells( ClassFlag
, t
, SpellLevel
)
2208 MaxSpellsPriestTable
= GemRB
.LoadTable (SpellTable
)
2209 GemRB
.SetVar ("PriestMemorized", 0)
2210 GemRB
.SetVar ("SpellMask", 0)
2212 PriestMemorizePointsLeft
= MaxSpellsPriestTable
.GetValue (str(Level
), str(SpellLevel
) )
2213 if PriestMemorizePointsLeft
<1 or len(Learnable
)<1:
2214 PriestMemorizeDonePress()
2217 PointsLeftLabel
= PriestMemorizeWindow
.GetControl (0x1000001b)
2218 PointsLeftLabel
.SetUseRGB (1)
2219 PointsLeftLabel
.SetText (str(PriestMemorizePointsLeft
))
2221 for i
in range (12):
2222 SpellButton
= PriestMemorizeWindow
.GetControl (i
+ 2)
2223 SpellButton
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_CHECKBOX
, OP_OR
)
2224 if i
< len(Learnable
):
2225 Spell
= GemRB
.GetSpell (Learnable
[i
])
2226 SpellButton
.SetTooltip(Spell
["SpellName"])
2227 SpellButton
.SetSpellIcon(Learnable
[i
], 1)
2228 SpellButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2229 SpellButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, PriestMemorizeSelectPress
)
2230 SpellButton
.SetVarAssoc ("SpellMask", 1 << i
)
2232 SpellButton
.SetState (IE_GUI_BUTTON_DISABLED
)
2234 GemRB
.SetToken ("number", str(PriestMemorizePointsLeft
))
2235 PriestMemorizeTextArea
= PriestMemorizeWindow
.GetControl (27)
2236 PriestMemorizeTextArea
.SetText (17253)
2238 PriestMemorizeDoneButton
= PriestMemorizeWindow
.GetControl (0)
2239 PriestMemorizeDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
2240 PriestMemorizeDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, PriestMemorizeDonePress
)
2241 PriestMemorizeDoneButton
.SetText (11973)
2242 PriestMemorizeDoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
2244 PriestMemorizeCancelButton
= PriestMemorizeWindow
.GetControl (29)
2245 PriestMemorizeCancelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2246 PriestMemorizeCancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, PriestMemorizeCancelPress
)
2247 PriestMemorizeCancelButton
.SetText (13727)
2248 PriestMemorizeCancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
2250 PriestMemorizeWindow
.SetVisible (WINDOW_VISIBLE
)
2253 def PriestMemorizeSelectPress():
2254 global PriestMemorizeWindow
, Learnable
, PriestMemorizeTextArea
, PriestMemorizeDoneButton
, PriestMemorizePointsLeft
2256 PriestMemorized
= GemRB
.GetVar ("PriestMemorized")
2257 SpellMask
= GemRB
.GetVar ("SpellMask")
2258 Spell
= abs(PriestMemorized
- SpellMask
)
2265 Spell
=GemRB
.GetSpell (Learnable
[i
])
2266 PriestMemorizeTextArea
.SetText (Spell
["SpellDesc"])
2268 if SpellMask
< PriestMemorized
:
2269 PriestMemorizePointsLeft
= PriestMemorizePointsLeft
+ 1
2270 for i
in range (len(Learnable
)):
2271 SpellButton
= PriestMemorizeWindow
.GetControl (i
+ 2)
2272 if (((1 << i
) & SpellMask
) == 0):
2273 SpellButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2274 PriestMemorizeDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
2276 PriestMemorizePointsLeft
= PriestMemorizePointsLeft
- 1
2277 if PriestMemorizePointsLeft
== 0:
2278 for i
in range (len(Learnable
)):
2279 SpellButton
= PriestMemorizeWindow
.GetControl (i
+ 2)
2280 if ((1 << i
) & SpellMask
) == 0:
2281 SpellButton
.SetState (IE_GUI_BUTTON_DISABLED
)
2282 PriestMemorizeDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2284 PointsLeftLabel
= PriestMemorizeWindow
.GetControl (0x1000001b)
2285 PointsLeftLabel
.SetText (str(PriestMemorizePointsLeft
))
2286 GemRB
.SetVar ("PriestMemorized", SpellMask
)
2289 def PriestMemorizeDonePress():
2290 global CharGenWindow
, PriestMemorizeWindow
, SkillsState
2292 if PriestMemorizeWindow
:
2293 PriestMemorizeWindow
.Unload ()
2295 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
2299 def PriestMemorizeCancelPress():
2300 global CharGenWindow
, PriestMemorizeWindow
, SkillsState
2302 if PriestMemorizeWindow
:
2303 PriestMemorizeWindow
.Unload ()
2305 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
2308 # Appearance Selection
2310 def AppearancePress():
2311 global CharGenWindow
, AppearanceWindow
, AppearanceTable
2312 global Portrait
, AppearanceAvatarButton
, PortraitName
2313 global AppearanceHairButton
, AppearanceSkinButton
2314 global AppearanceMajorButton
, AppearanceMinorButton
2315 global HairColor
, SkinColor
, MajorColor
, MinorColor
2317 CharGenWindow
.SetVisible (WINDOW_INVISIBLE
)
2318 AppearanceWindow
= GemRB
.LoadWindow (13)
2319 AppearanceTable
= GemRB
.LoadTable ("PORTCOLR")
2324 PortraitName
= PortraitsTable
.GetRowName (Portrait
)
2325 PortraitIndex
= AppearanceTable
.GetRowIndex (PortraitName
+ "L")
2327 HairColor
= AppearanceTable
.GetValue (PortraitIndex
, 1)
2328 GemRB
.SetVar ("HairColor", HairColor
)
2329 SkinColor
= AppearanceTable
.GetValue (PortraitIndex
, 0)
2330 GemRB
.SetVar ("SkinColor", SkinColor
)
2331 MajorColor
= AppearanceTable
.GetValue (PortraitIndex
, 2)
2332 GemRB
.SetVar ("MajorColor", MajorColor
)
2333 MinorColor
= AppearanceTable
.GetValue (PortraitIndex
, 3)
2334 GemRB
.SetVar ("MinorColor", MinorColor
)
2336 AppearanceAvatarButton
= AppearanceWindow
.GetControl (1)
2337 AppearanceAvatarButton
.SetState (IE_GUI_BUTTON_LOCKED
)
2338 AppearanceAvatarButton
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_ANIMATED
, OP_OR
)
2341 AppearanceHairButton
= AppearanceWindow
.GetControl (2)
2342 AppearanceHairButton
.SetFlags (IE_GUI_BUTTON_PICTURE
, OP_OR
)
2343 AppearanceHairButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2344 AppearanceHairButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AppearanceHairPress
)
2345 AppearanceHairButton
.SetBAM ("COLGRAD", 0, 0, HairColor
)
2347 AppearanceSkinButton
= AppearanceWindow
.GetControl (3)
2348 AppearanceSkinButton
.SetFlags (IE_GUI_BUTTON_PICTURE
, OP_OR
)
2349 AppearanceSkinButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2350 AppearanceSkinButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AppearanceSkinPress
)
2351 AppearanceSkinButton
.SetBAM ("COLGRAD", 0, 0, SkinColor
)
2353 AppearanceMajorButton
= AppearanceWindow
.GetControl (4)
2354 AppearanceMajorButton
.SetFlags (IE_GUI_BUTTON_PICTURE
, OP_OR
)
2355 AppearanceMajorButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2356 AppearanceMajorButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AppearanceMajorPress
)
2357 AppearanceMajorButton
.SetBAM ("COLGRAD", 0, 0, MajorColor
)
2359 AppearanceMinorButton
= AppearanceWindow
.GetControl (5)
2360 AppearanceMinorButton
.SetFlags (IE_GUI_BUTTON_PICTURE
, OP_OR
)
2361 AppearanceMinorButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2362 AppearanceMinorButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AppearanceMinorPress
)
2363 AppearanceMinorButton
.SetBAM ("COLGRAD", 0, 0, MinorColor
)
2365 AppearanceDoneButton
= AppearanceWindow
.GetControl (0)
2366 AppearanceDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2367 AppearanceDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AppearanceDonePress
)
2368 AppearanceDoneButton
.SetText (11973)
2369 AppearanceDoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
2371 AppearanceCancelButton
= AppearanceWindow
.GetControl (13)
2372 AppearanceCancelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2373 AppearanceCancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AppearanceCancelPress
)
2374 AppearanceCancelButton
.SetText (13727)
2375 AppearanceCancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
2377 AppearanceWindow
.SetVisible (WINDOW_VISIBLE
)
2381 global AppearanceAvatarButton
2385 table
= GemRB
.LoadTable ("avprefr")
2386 lookup
= CommonTables
.Races
.FindValue (3, GemRB
.GetPlayerStat(MyChar
, IE_RACE
))
2387 lookup
= CommonTables
.Races
.GetRowName (lookup
)
2388 AvatarID
= AvatarID
+table
.GetValue (lookup
, "RACE")
2389 table
= GemRB
.LoadTable ("avprefc")
2390 lookup
= CommonTables
.Classes
.FindValue (5, GemRB
.GetPlayerStat(MyChar
, IE_CLASS
))
2391 lookup
= CommonTables
.Classes
.GetRowName (lookup
)
2392 AvatarID
= AvatarID
+table
.GetValue (lookup
, "PREFIX")
2393 table
= GemRB
.LoadTable ("avprefg")
2394 AvatarID
= AvatarID
+table
.GetValue (GemRB
.GetPlayerStat(MyChar
,IE_SEX
),0)
2396 AvatarRef
= CommonTables
.Pdolls
.GetValue (hex(AvatarID
), "LEVEL1")
2397 AppearanceAvatarButton
.SetPLT(AvatarRef
, 0, MinorColor
, MajorColor
, SkinColor
, 0, 0, HairColor
, 0)
2401 def AppearanceHairPress():
2402 GemRB
.SetVar ("ColorType", 0)
2403 AppearanceColorChoice (GemRB
.GetVar ("HairColor"))
2406 def AppearanceSkinPress():
2407 GemRB
.SetVar ("ColorType", 1)
2408 AppearanceColorChoice (GemRB
.GetVar ("SkinColor"))
2411 def AppearanceMajorPress():
2412 GemRB
.SetVar ("ColorType", 2)
2413 AppearanceColorChoice (GemRB
.GetVar ("MajorColor"))
2416 def AppearanceMinorPress():
2417 GemRB
.SetVar ("ColorType", 3)
2418 AppearanceColorChoice (GemRB
.GetVar ("MinorColor"))
2421 def AppearanceColorChoice (CurrentColor
):
2422 global AppearanceWindow
, AppearanceColorWindow
2424 AppearanceWindow
.SetVisible (WINDOW_INVISIBLE
)
2425 AppearanceColorWindow
= GemRB
.LoadWindow (14)
2426 AppearanceColorTable
= GemRB
.LoadTable ("clowncol")
2427 ColorType
= GemRB
.GetVar ("ColorType")
2428 GemRB
.SetVar ("SelectedColor", CurrentColor
)
2430 for i
in range (34):
2431 ColorButton
= AppearanceColorWindow
.GetControl (i
)
2432 ColorButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2433 ColorButton
.SetFlags (IE_GUI_BUTTON_PICTURE
, OP_OR
)
2435 for i
in range (34):
2436 Color
= AppearanceColorTable
.GetValue (ColorType
, i
)
2438 ColorButton
= AppearanceColorWindow
.GetControl (i
)
2439 ColorButton
.SetBAM ("COLGRAD", 0, 0, Color
)
2440 ColorButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, AppearanceColorSelected
)
2441 ColorButton
.SetVarAssoc ("SelectedColor", Color
)
2443 AppearanceColorWindow
.SetVisible (WINDOW_VISIBLE
)
2446 def AppearanceColorSelected():
2447 global HairColor
, SkinColor
, MajorColor
, MinorColor
2448 global AppearanceWindow
, AppearanceColorWindow
2449 global AppearanceHairButton
, AppearanceSkinButton
2450 global AppearanceMajorButton
, AppearanceMinorButton
2452 if AppearanceColorWindow
:
2453 AppearanceColorWindow
.Unload ()
2454 ColorType
= GemRB
.GetVar ("ColorType")
2456 HairColor
= GemRB
.GetVar ("SelectedColor")
2457 GemRB
.SetVar ("HairColor", HairColor
)
2458 AppearanceHairButton
.SetBAM ("COLGRAD", 0, 0, HairColor
)
2459 elif ColorType
== 1:
2460 SkinColor
= GemRB
.GetVar ("SelectedColor")
2461 GemRB
.SetVar ("SkinColor", SkinColor
)
2462 AppearanceSkinButton
.SetBAM ("COLGRAD", 0, 0, SkinColor
)
2463 elif ColorType
== 2:
2464 MajorColor
= GemRB
.GetVar ("SelectedColor")
2465 GemRB
.SetVar ("MajorColor", MajorColor
)
2466 AppearanceMajorButton
.SetBAM ("COLGRAD", 0, 0, MajorColor
)
2467 elif ColorType
== 3:
2468 MinorColor
= GemRB
.GetVar ("SelectedColor")
2469 GemRB
.SetVar ("MinorColor", MinorColor
)
2470 AppearanceMinorButton
.SetBAM ("COLGRAD", 0, 0, MinorColor
)
2472 AppearanceWindow
.SetVisible (WINDOW_VISIBLE
)
2475 def AppearanceDonePress():
2476 global CharGenWindow
, AppearanceWindow
2478 if AppearanceWindow
:
2479 AppearanceWindow
.Unload ()
2480 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
2484 def AppearanceCancelPress():
2485 global CharGenWindow
, AppearanceWindow
2487 if AppearanceWindow
:
2488 AppearanceWindow
.Unload ()
2489 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
2492 def CharSoundSelect():
2493 global CharGenWindow
, CharSoundWindow
, CharSoundTable
, CharSoundStrings
2494 global CharSoundVoiceList
, VerbalConstants
2496 CharGenWindow
.SetVisible (WINDOW_INVISIBLE
)
2497 CharSoundWindow
= GemRB
.LoadWindow (19)
2498 CharSoundTable
= GemRB
.LoadTable ("CHARSND")
2499 CharSoundStrings
= GemRB
.LoadTable ("CHARSTR")
2501 VerbalConstants
= [CharSoundTable
.GetRowName(i
) for i
in range(CharSoundTable
.GetRowCount())]
2502 CharSoundVoiceList
= CharSoundWindow
.GetControl (45)
2503 CharSoundVoiceList
.SetFlags (IE_GUI_TEXTAREA_SELECTABLE
)
2504 RowCount
=CharSoundVoiceList
.GetCharSounds()
2506 CharSoundPlayButton
= CharSoundWindow
.GetControl (47)
2507 CharSoundPlayButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2508 CharSoundPlayButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CharSoundPlayPress
)
2509 CharSoundPlayButton
.SetText (17318)
2511 CharSoundTextArea
= CharSoundWindow
.GetControl (50)
2512 CharSoundTextArea
.SetText (11315)
2514 CharSoundDoneButton
= CharSoundWindow
.GetControl (0)
2515 CharSoundDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2516 CharSoundDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CharSoundDonePress
)
2517 CharSoundDoneButton
.SetText (11973)
2518 CharSoundDoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
2520 CharSoundCancelButton
= CharSoundWindow
.GetControl (10)
2521 CharSoundCancelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2522 CharSoundCancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CharSoundCancelPress
)
2523 CharSoundCancelButton
.SetText (13727)
2524 CharSoundCancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
2526 CharSoundWindow
.SetVisible (WINDOW_VISIBLE
)
2529 def CharSoundPlayPress():
2530 global CharGenWindow
, CharSoundWindow
, CharSoundTable
, CharSoundStrings
2531 global CharSoundVoiceList
, SoundIndex
, VerbalConstants
2533 row
= CharSoundVoiceList
.QueryText ()
2535 GemRB
.SetPlayerSound (MyChar
, row
)
2537 #play sound as sound slot
2538 GemRB
.VerbalConstant (MyChar
, int(VerbalConstants
[SoundIndex
]))
2541 if SoundIndex
>= len(VerbalConstants
):
2545 def CharSoundDonePress():
2546 global CharGenWindow
, CharSoundWindow
, AppearanceButton
, BiographyButton
, NameButton
, CharGenState
2549 CharSoundWindow
.Unload ()
2550 AppearanceButton
.SetState (IE_GUI_BUTTON_DISABLED
)
2551 AppearanceButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_NAND
)
2552 BiographyButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2553 NameButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2554 NameButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
2556 SetCharacterDescription()
2557 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
2560 def CharSoundCancelPress():
2561 global CharGenWindow
, CharSoundWindow
2564 CharSoundWindow
.Unload ()
2565 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
2568 # Biography Selection
2570 def BiographyPress():
2571 global CharGenWindow
, BiographyWindow
, BiographyField
2573 CharGenWindow
.SetVisible (WINDOW_INVISIBLE
)
2574 BiographyWindow
= GemRB
.LoadWindow (51)
2576 BiographyField
= BiographyWindow
.GetControl (4)
2577 BiographyField
.SetText (19423)
2579 BiographyClearButton
= BiographyWindow
.GetControl (5)
2580 BiographyClearButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2581 BiographyClearButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, BiographyClearPress
)
2582 BiographyClearButton
.SetText (18622)
2584 BiographyCancelButton
= BiographyWindow
.GetControl (2)
2585 BiographyCancelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2586 BiographyCancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, BiographyCancelPress
)
2587 BiographyCancelButton
.SetText (13727)
2588 BiographyCancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
2590 BiographyDoneButton
= BiographyWindow
.GetControl (1)
2591 BiographyDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2592 BiographyDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, BiographyDonePress
)
2593 BiographyDoneButton
.SetText (11973)
2594 BiographyDoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
2596 BiographyWindow
.SetVisible (WINDOW_VISIBLE
)
2599 def BiographyClearPress():
2600 global BiographyWindow
, BiographyField
2602 BiographyField
.SetText ("")
2605 def BiographyCancelPress():
2606 global CharGenWindow
, BiographyWindow
2609 BiographyWindow
.Unload ()
2610 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
2613 def BiographyDonePress():
2614 global CharGenWindow
, BiographyWindow
, BiographyField
2616 GemRB
.SetToken ("Biography", BiographyField
.QueryText () )
2618 BiographyWindow
.Unload ()
2619 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
2625 global CharGenWindow
, NameWindow
, NameDoneButton
, NameField
2627 CharGenWindow
.SetVisible (WINDOW_INVISIBLE
)
2628 NameWindow
= GemRB
.LoadWindow (5)
2630 NameDoneButton
= NameWindow
.GetControl (0)
2631 NameDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
2632 NameDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, NameDonePress
)
2633 NameDoneButton
.SetText (11973)
2634 NameDoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
2636 NameCancelButton
= NameWindow
.GetControl (3)
2637 NameCancelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2638 NameCancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, NameCancelPress
)
2639 NameCancelButton
.SetText (13727)
2640 NameCancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
2642 NameField
= NameWindow
.GetControl (2)
2643 NameField
.SetEvent (IE_GUI_EDIT_ON_CHANGE
, NameEditChange
)
2644 NameField
.SetText (GemRB
.GetToken ("CHARNAME") )
2645 NameField
.SetStatus (IE_GUI_CONTROL_FOCUSED
)
2647 NameWindow
.SetVisible (WINDOW_VISIBLE
)
2651 def NameEditChange():
2654 if NameField
.QueryText () == "":
2655 NameDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
2657 NameDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2660 def NameDonePress():
2661 global CharGenWindow
, CharGenState
, NameWindow
, NameField
, AcceptButton
2663 GemRB
.SetToken ("CHARNAME", NameField
.QueryText () )
2665 NameWindow
.Unload ()
2667 AcceptButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2668 AcceptButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
2669 SetCharacterDescription()
2670 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
2673 def NameCancelPress():
2674 global CharGenWindow
, NameWindow
2676 GemRB
.SetToken ("CHARNAME", "")
2678 NameWindow
.Unload ()
2679 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
2685 global CharGenWindow
, ImportWindow
2686 global CharImportList
2688 CharGenWindow
.SetVisible (WINDOW_INVISIBLE
)
2689 ImportWindow
= GemRB
.LoadWindow (20)
2691 TextAreaControl
= ImportWindow
.GetControl(4)
2692 TextAreaControl
.SetText(10963)
2694 GemRB
.SetVar ("Selected", 0)
2695 CharImportList
= ImportWindow
.GetControl(2)
2696 CharImportList
.SetFlags (IE_GUI_TEXTAREA_SELECTABLE
)
2697 CharImportList
.SetVarAssoc ("Selected",0)
2698 CharImportList
.GetCharacters()
2700 ImportDoneButton
= ImportWindow
.GetControl (0)
2701 ImportDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2702 ImportDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ImportDonePress
)
2703 ImportDoneButton
.SetText (11973)
2704 ImportDoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
2706 ImportCancelButton
= ImportWindow
.GetControl (1)
2707 ImportCancelButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2708 ImportCancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ImportCancelPress
)
2709 ImportCancelButton
.SetText (13727)
2710 ImportCancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
2712 ImportWindow
.SetVisible (WINDOW_VISIBLE
)
2715 def ImportDonePress():
2716 global CharGenWindow
, ImportWindow
, CharImportList
2717 global CharGenState
, SkillsState
, Portrait
2719 # Import the character from the chosen name
2720 GemRB
.CreatePlayer (CharImportList
.QueryText(), MyChar|
0x8000, 1)
2722 GemRB
.SetToken ("CHARNAME", GemRB
.GetPlayerName (MyChar
) )
2723 GemRB
.SetToken ("SmallPortrait", GemRB
.GetPlayerPortrait (MyChar
, 1) )
2724 PortraitName
= GemRB
.GetPlayerPortrait (MyChar
, 0)
2725 GemRB
.SetToken ("LargePortrait", PortraitName
)
2726 PortraitButton
.SetPicture (PortraitName
)
2731 SetCharacterDescription ()
2732 GenderButton
.SetState (IE_GUI_BUTTON_DISABLED
)
2733 GenderButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_NAND
)
2734 RaceButton
.SetState (IE_GUI_BUTTON_DISABLED
)
2735 RaceButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_NAND
)
2736 ClassButton
.SetState (IE_GUI_BUTTON_DISABLED
)
2737 ClassButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_NAND
)
2738 AlignmentButton
.SetState (IE_GUI_BUTTON_DISABLED
)
2739 AlignmentButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_NAND
)
2740 AbilitiesButton
.SetState (IE_GUI_BUTTON_DISABLED
)
2741 AbilitiesButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_NAND
)
2742 SkillsButton
.SetState (IE_GUI_BUTTON_DISABLED
)
2743 SkillsButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_NAND
)
2744 AppearanceButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2745 AppearanceButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
2746 BiographyButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2747 BiographyButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
2748 NameButton
.SetState (IE_GUI_BUTTON_ENABLED
)
2749 NameButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
2750 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)
2752 ImportWindow
.Unload ()
2755 def ImportCancelPress():
2756 global CharGenWindow
, ImportWindow
2759 ImportWindow
.Unload ()
2760 CharGenWindow
.SetVisible (WINDOW_VISIBLE
)