2 # GemRB - Infinity Engine Emulator
3 # Copyright (C) 2003-2009 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.
21 # GUIREC.py - scripts to control stats/records windows from the GUIREC winpack
22 ###################################################
24 import GUICommonWindows
25 from GUIDefines
import *
26 from ie_stats
import *
27 from ie_restype
import *
28 from GUICommon
import *
29 from LUCommon
import CanLevelUp
, GetNextLevelExp
30 from GUICommonWindows
import *
31 from GUIWORLD
import OpenReformPartyWindow
32 from GUICG19
import NextSound
34 ###################################################
36 InformationWindow
= None
37 BiographyWindow
= None
39 CustomizeWindow
= None
40 OldOptionsWindow
= None
41 ExportDoneButton
= None
48 SelectedTextArea
= None
50 # the available sounds
51 SoundSequence
= [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', \
52 'm', 's', 't', 'u', 'v', '_', 'x', 'y', 'z', '0', '1', '2', \
53 '3', '4', '5', '6', '7', '8', '9']
56 ###################################################
57 def OpenRecordsWindow ():
58 global RecordsWindow
, OptionsWindow
59 global OldOptionsWindow
61 if CloseOtherWindow (OpenRecordsWindow
):
62 if InformationWindow
: OpenInformationWindow ()
65 RecordsWindow
.Unload ()
67 OptionsWindow
.Unload ()
69 GemRB
.SetVar ("OtherWindow", -1)
70 GameWindow
.SetVisible(WINDOW_VISIBLE
)
72 GUICommonWindows
.OptionsWindow
= OldOptionsWindow
73 OldOptionsWindow
= None
74 SetSelectionChangeHandler (None)
78 GameWindow
.SetVisible(WINDOW_INVISIBLE
)
80 GemRB
.LoadWindowPack ("GUIREC")
81 RecordsWindow
= Window
= GemRB
.LoadWindow (2)
82 GemRB
.SetVar ("OtherWindow", RecordsWindow
.ID
)
83 # saving the original portrait window
84 OldOptionsWindow
= GUICommonWindows
.OptionsWindow
85 OptionsWindow
= GemRB
.LoadWindow (0)
86 SetupMenuWindowControls (OptionsWindow
, 0, "OpenRecordsWindow")
87 OptionsWindow
.SetFrame ()
90 Button
= Window
.GetControl (0)
92 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "DualClassWindow")
95 Button
= Window
.GetControl (37)
97 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "OpenLevelUpWindow")
100 Button
= Window
.GetControl (1)
101 Button
.SetText (11946)
102 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "OpenInformationWindow")
105 Button
= Window
.GetControl (51)
106 Button
.SetText (16559)
107 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "OpenRecReformPartyWindow")
110 Button
= Window
.GetControl (50)
111 Button
.SetText (10645)
112 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "OpenCustomizeWindow")
115 Button
= Window
.GetControl (36)
116 Button
.SetText (13956)
117 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "OpenExportWindow")
120 ## Button = Window.GetControl (52)
121 ## Button.SetText (61265)
122 ## Button.SetEventByName (IE_GUI_BUTTON_ON_PRESS, "KitInfoWindow")
124 SetSelectionChangeHandler (UpdateRecordsWindow
)
125 UpdateRecordsWindow ()
127 OptionsWindow
.SetVisible (WINDOW_VISIBLE
)
128 Window
.SetVisible (WINDOW_VISIBLE
)
129 GUICommonWindows
.PortraitWindow
.SetVisible (WINDOW_VISIBLE
)
132 #original returns to game before continuing...
133 def OpenRecReformPartyWindow ():
135 GemRB
.SetTimedEventByName ("OpenReformPartyWindow", 1)
138 def UpdateRecordsWindow ():
139 global stats_overview
, alignment_help
141 Window
= RecordsWindow
142 if not RecordsWindow
:
143 print "SelectionChange handler points to non existing window\n"
146 pc
= GemRB
.GameGetSelectedPCSingle ()
149 Button
= Window
.GetControl (36)
150 if GemRB
.GetPlayerStat (pc
, IE_MC_FLAGS
)&MC_EXPORTABLE
:
151 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
153 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
156 Button
= Window
.GetControl (0)
157 if CanDualClass (pc
):
158 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
160 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
163 Button
= Window
.GetControl (37)
165 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
167 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
170 Label
= Window
.GetControl (0x1000000e)
171 Label
.SetText (GemRB
.GetPlayerName (pc
, 0))
174 Button
= Window
.GetControl (2)
175 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE | IE_GUI_BUTTON_PICTURE
, OP_SET
)
176 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
177 Button
.SetPicture (GemRB
.GetPlayerPortrait (pc
,0), "NOPORTLG")
180 Label
= Window
.GetControl (0x10000028)
181 ac
= GemRB
.GetPlayerStat (pc
, IE_ARMORCLASS
)
182 ac
+= GemRB
.GetAbilityBonus (IE_DEX
, 2, GemRB
.GetPlayerStat (pc
, IE_DEX
) )
183 Label
.SetText (str (ac
))
184 Label
.SetTooltip (17183)
187 Label
= Window
.GetControl (0x10000029)
188 Label
.SetText (str (GemRB
.GetPlayerStat (pc
, IE_HITPOINTS
)))
189 Label
.SetTooltip (17184)
192 Label
= Window
.GetControl (0x1000002a)
193 Label
.SetText (str (GemRB
.GetPlayerStat (pc
, IE_MAXHITPOINTS
)))
194 Label
.SetTooltip (17378)
198 sstr
= GemRB
.GetPlayerStat (pc
, IE_STR
)
199 sstrx
= GemRB
.GetPlayerStat (pc
, IE_STREXTRA
)
200 cstr
= GetStatColor (pc
, IE_STR
)
201 if sstrx
> 0 and sstr
==18:
202 sstr
= "%d/%02d" %(sstr
, sstrx
% 100)
206 sint
= str (GemRB
.GetPlayerStat (pc
, IE_INT
))
207 cint
= GetStatColor (pc
, IE_INT
)
208 swis
= str (GemRB
.GetPlayerStat (pc
, IE_WIS
))
209 cwis
= GetStatColor (pc
, IE_WIS
)
210 sdex
= str (GemRB
.GetPlayerStat (pc
, IE_DEX
))
211 cdex
= GetStatColor (pc
, IE_DEX
)
212 scon
= str (GemRB
.GetPlayerStat (pc
, IE_CON
))
213 ccon
= GetStatColor (pc
, IE_CON
)
214 schr
= str (GemRB
.GetPlayerStat (pc
, IE_CHR
))
215 cchr
= GetStatColor (pc
, IE_CHR
)
217 Label
= Window
.GetControl (0x1000002f)
219 Label
.SetTextColor (cstr
[0], cstr
[1], cstr
[2])
221 Label
= Window
.GetControl (0x10000009)
223 Label
.SetTextColor (cdex
[0], cdex
[1], cdex
[2])
225 Label
= Window
.GetControl (0x1000000a)
227 Label
.SetTextColor (ccon
[0], ccon
[1], ccon
[2])
229 Label
= Window
.GetControl (0x1000000b)
231 Label
.SetTextColor (cint
[0], cint
[1], cint
[2])
233 Label
= Window
.GetControl (0x1000000c)
235 Label
.SetTextColor (cwis
[0], cwis
[1], cwis
[2])
237 Label
= Window
.GetControl (0x1000000d)
239 Label
.SetTextColor (cchr
[0], cchr
[1], cchr
[2])
242 ClassTitle
= GetActorClassTitle (pc
)
243 Label
= Window
.GetControl (0x10000030)
244 Label
.SetText (ClassTitle
)
247 text
= RaceTable
.GetValue (RaceTable
.FindValue (3, GemRB
.GetPlayerStat (pc
, IE_RACE
)) ,
250 Label
= Window
.GetControl (0x1000000f)
253 Table
= GemRB
.LoadTable ("aligns")
255 text
= Table
.GetValue (Table
.FindValue ( 3, GemRB
.GetPlayerStat (pc
, IE_ALIGNMENT
) ), 0)
256 Label
= Window
.GetControl (0x10000010)
259 Label
= Window
.GetControl (0x10000011)
260 if GemRB
.GetPlayerStat (pc
, IE_SEX
) == 1:
265 # help, info textarea
266 stats_overview
= GetStatOverview (pc
)
267 Text
= Window
.GetControl (45)
268 Text
.SetText (stats_overview
)
269 #TODO: making window visible/shaded depending on the pc's state
270 Window
.SetVisible (WINDOW_VISIBLE
)
273 def GetStatColor (pc
, stat
):
274 a
= GemRB
.GetPlayerStat (pc
, stat
)
275 b
= GemRB
.GetPlayerStat (pc
, stat
, 1)
282 # GemRB.GetPlayerStat wrapper that only returns nonnegative values
284 val
= GemRB
.GetPlayerStat (pc
, stat
)
290 # LevelDiff is used only from the level up code and holds the level
291 # difference for each class
292 def GetStatOverview (pc
, LevelDiff
=[0,0,0]):
293 StateTable
= GemRB
.LoadTable ("statdesc")
295 GS
= lambda s
, pc
=pc
: GemRB
.GetPlayerStat (pc
, s
)
296 GA
= lambda s
, col
, pc
=pc
: GemRB
.GetAbilityBonus (s
, col
, GS (s
) )
300 # 16480 <CLASS>: Level <LEVEL>
301 # Experience: <EXPERIENCE>
302 # Next Level: <NEXTLEVEL>
304 # collecting tokens for stat overview
305 ClassTitle
= GetActorClassTitle (pc
)
306 GemRB
.SetToken ("CLASS", ClassTitle
)
307 Class
= GemRB
.GetPlayerStat (pc
, IE_CLASS
)
308 Class
= ClassTable
.FindValue (5, Class
)
309 Class
= ClassTable
.GetRowName (Class
)
310 Dual
= IsDualClassed (pc
, 1)
311 Multi
= IsMultiClassed (pc
, 1)
312 XP
= GemRB
.GetPlayerStat (pc
, IE_XP
)
313 LevelDrain
= GS (IE_LEVELDRAIN
)
315 if Multi
[0] > 1: # we're multiclassed
316 print "\tMulticlassed"
317 Levels
= [GemRB
.GetPlayerStat (pc
, IE_LEVEL
), GemRB
.GetPlayerStat (pc
, IE_LEVEL2
), GemRB
.GetPlayerStat (pc
, IE_LEVEL3
)]
319 stats
.append ( (19721,1,'c') )
321 for i
in range (Multi
[0]):
322 ClassIndex
= ClassTable
.FindValue (5, Multi
[i
+1])
323 ClassTitle
= GemRB
.GetString (ClassTable
.GetValue (ClassIndex
, 2))
324 GemRB
.SetToken ("CLASS", ClassTitle
)
325 Class
= ClassTable
.GetRowName (ClassIndex
)
326 GemRB
.SetToken ("LEVEL", str (Levels
[i
]+LevelDiff
[i
]-int(LevelDrain
/Multi
[0])) )
327 GemRB
.SetToken ("EXPERIENCE", str (XP
/Multi
[0]) )
329 stats
.append ( (GemRB
.GetString (19720),1,'d') )
330 stats
.append ( (GemRB
.GetString (57435),1,'d') ) # LEVEL DRAINED
332 GemRB
.SetToken ("NEXTLEVEL", GetNextLevelExp (Levels
[i
]+LevelDiff
[i
], Class
) )
333 stats
.append ( (GemRB
.GetString (16480),"",'d') )
335 print "\t\tClass (Level):",Class
,"(",Levels
[i
],")"
337 elif Dual
[0] > 0: # dual classed; first show the new class
338 print "\tDual classed"
339 stats
.append ( (19722,1,'c') )
342 Levels
= [GemRB
.GetPlayerStat (pc
, IE_LEVEL
), GemRB
.GetPlayerStat (pc
, IE_LEVEL2
), GemRB
.GetPlayerStat (pc
, IE_LEVEL3
)]
344 # the levels are stored in the class order (eg. FIGHTER_MAGE)
345 # the current active class does not matter!
347 Levels
= [Levels
[1], Levels
[0], Levels
[2]]
349 Levels
[0] += LevelDiff
[0]
351 ClassTitle
= GemRB
.GetString (ClassTable
.GetValue (Dual
[2], 2))
352 GemRB
.SetToken ("CLASS", ClassTitle
)
353 GemRB
.SetToken ("LEVEL", str (Levels
[0]-LevelDrain
))
354 Class
= ClassTable
.GetRowName (Dual
[2])
355 XP2
= GemRB
.GetPlayerStat (pc
, IE_XP
)
356 GemRB
.SetToken ("EXPERIENCE", str (XP2
) )
358 stats
.append ( (GemRB
.GetString (19720),1,'d') )
359 stats
.append ( (GemRB
.GetString (57435),1,'d') ) # LEVEL DRAINED
361 GemRB
.SetToken ("NEXTLEVEL", GetNextLevelExp (Levels
[0], Class
) )
362 stats
.append ( (GemRB
.GetString (16480),"",'d') )
364 # the first class (shown second)
366 ClassTitle
= GemRB
.GetString (KitListTable
.GetValue (Dual
[1], 2))
368 ClassTitle
= GemRB
.GetString (ClassTable
.GetValue (Dual
[1], 2))
369 GemRB
.SetToken ("CLASS", ClassTitle
)
370 GemRB
.SetToken ("LEVEL", str (Levels
[1]) )
372 # the xp table contains only classes, so we have to determine the base class for kits
374 BaseClass
= ClassTable
.GetRowName (Dual
[1])
376 BaseClass
= GetKitIndex (pc
)
377 BaseClass
= KitListTable
.GetValue (BaseClass
, 7)
378 BaseClass
= ClassTable
.FindValue (5, BaseClass
)
379 BaseClass
= ClassTable
.GetRowName (BaseClass
)
380 # the first class' XP is discarded and set to the minimum level
381 # requirement, so if you don't dual class right after a levelup,
382 # the game would eat some of your XP
383 XP1
= NextLevelTable
.GetValue (BaseClass
, str (Levels
[1]))
384 GemRB
.SetToken ("EXPERIENCE", str (XP1
) )
386 # inactive until the new class SURPASSES the former
387 if Levels
[0] <= Levels
[1]:
389 stats
.append ( (19719,1,'c') )
391 stats
.append ( (19720,1,'c') )
393 else: # single classed
394 print "\tSingle classed"
395 Level
= GemRB
.GetPlayerStat (pc
, IE_LEVEL
) + LevelDiff
[0]
396 GemRB
.SetToken ("LEVEL", str (Level
-LevelDrain
))
397 GemRB
.SetToken ("EXPERIENCE", str (XP
) )
399 stats
.append ( (19720,1,'c') )
400 stats
.append ( (57435,1,'c') ) # LEVEL DRAINED
402 GemRB
.SetToken ("NEXTLEVEL", GetNextLevelExp (Level
, Class
) )
403 stats
.append ( (16480,1,'c') )
405 print "\t\tClass (Level):",Class
,"(",Level
,")"
407 # check to see if we have a level diff anywhere
408 if sum (LevelDiff
) == 0:
409 effects
= GemRB
.GetPlayerStates (pc
)
412 tmp
= StateTable
.GetValue (ord(c
)-66, 0)
413 stats
.append ( (tmp
,c
,'a') )
419 stats
.append ( (8442,1,'c') )
421 stats
.append ( (9457, str(GS (IE_TOHIT
))+" ("+str(GemRB
.GetCombatDetails(pc
, 0)["ToHit"])+")", '0') )
422 tmp
= GS (IE_NUMBEROFATTACKS
)
424 tmp2
= str (tmp
/2) + chr (188)
427 stats
.append ( (9458, tmp2
, '') )
428 stats
.append ( (9459, GSNN (pc
, IE_LORE
), '0') )
429 stats
.append ( (19224, GS (IE_RESISTMAGIC
), '') )
432 reptxt
= GetReputation (GemRB
.GameGetReputation ()/10)
433 stats
.append ( (9465, reptxt
, '') )
434 stats
.append ( (9460, GSNN (pc
, IE_LOCKPICKING
), '') )
435 stats
.append ( (9462, GSNN (pc
, IE_TRAPS
), '') )
436 stats
.append ( (9463, GSNN (pc
, IE_PICKPOCKET
), '') )
437 stats
.append ( (9461, GSNN (pc
, IE_STEALTH
), '') )
438 HatedRace
= GS (IE_HATEDRACE
)
440 HateTable
= GemRB
.LoadTable ("haterace")
441 Racist
= HateTable
.FindValue (1, HatedRace
)
443 HatedRace
= HateTable
.GetValue (Racist
, 0)
444 stats
.append ( (15982, GemRB
.GetString (HatedRace
), '') )
446 #stats.append ( (34120, GSNN (pc, IE_HIDEINSHADOWS), '') )
447 #stats.append ( (34121, GSNN (pc, IE_DETECTILLUSIONS), '') )
448 #stats.append ( (34122, GSNN (pc, IE_SETTRAPS), '') )
449 stats
.append ( (12128, GS (IE_BACKSTABDAMAGEMULTIPLIER
), 'x') )
450 stats
.append ( (12126, GS (IE_TURNUNDEADLEVEL
), '') )
452 #this hack only displays LOH if we know the spell
453 #TODO: the core should just not set LOH if the paladin can't learn it
454 if (HasSpell (pc
, IE_SPELL_TYPE_INNATE
, 0, "SPCL211") >= 0):
455 stats
.append ( (12127, GS (IE_LAYONHANDSAMOUNT
), '') )
458 aiscript
= GemRB
.GetPlayerScript (pc
)
459 stats
.append ( (2078, aiscript
, '') )
462 # 17379 Saving throws
464 # 17380 Paralyze/Poison/Death
465 stats
.append ( (17380, GS (IE_SAVEVSDEATH
), '0') )
466 # 17381 Rod/Staff/Wand
467 stats
.append ( (17381, GS (IE_SAVEVSWANDS
), '0') )
468 # 17382 Petrify/Polymorph
469 stats
.append ( (17382, GS (IE_SAVEVSPOLY
), '0') )
470 # 17383 Breath weapon
471 stats
.append ( (17383, GS (IE_SAVEVSBREATH
), '0') )
473 stats
.append ( (17384, GS (IE_SAVEVSSPELL
), '0') )
476 # 9466 Weapon proficiencies
478 table
= GemRB
.LoadTable ("weapprof")
479 RowCount
= table
.GetRowCount ()
480 for i
in range (RowCount
):
481 text
= table
.GetValue (i
, 1)
482 stat
= table
.GetValue (i
, 0) + IE_PROFICIENCYBASTARDSWORD
483 stats
.append ( (text
, GS (stat
)&0x07, '+') )
488 # 11770 AC vs. Crushing
489 stats
.append ((11770, GS (IE_ACCRUSHINGMOD
), ''))
490 # 11767 AC vs. Missile
491 stats
.append ((11767, GS (IE_ACMISSILEMOD
), ''))
492 # 11769 AC vs. Piercing
493 stats
.append ((11769, GS (IE_ACPIERCINGMOD
), ''))
494 # 11768 AC vs. Slashing
495 stats
.append ((11768, GS (IE_ACSLASHINGMOD
), ''))
498 # 10315 Ability bonuses
500 value
= GemRB
.GetPlayerStat (pc
, IE_STR
)
501 ex
= GemRB
.GetPlayerStat (pc
, IE_STREXTRA
)
503 stats
.append ( (10332, GemRB
.GetAbilityBonus (IE_STR
,0,value
,ex
), '0') )
505 stats
.append ( (10336, GemRB
.GetAbilityBonus (IE_STR
,1,value
,ex
), '0') )
506 # 10337 open doors (bend bars lift gates)
507 stats
.append ( (10337, GemRB
.GetAbilityBonus (IE_STR
,2,value
,ex
), '0') )
508 # 10338 weight allowance
509 stats
.append ( (10338, GemRB
.GetAbilityBonus (IE_STR
,3,value
,ex
), '0') )
511 stats
.append ( (10339, GA (IE_DEX
,2), '0') )
512 # 10340 Missile adjustment
513 stats
.append ( (10340, GA (IE_DEX
,1), '0') )
514 # 10341 Reaction adjustment
515 stats
.append ( (10341, GA (IE_DEX
,0), '0') )
516 # 10342 CON HP Bonus/Level
517 stats
.append ( (10342, GA (IE_CON
,0), '0') )
518 # 10343 Chance To Learn spell
519 if GemRB
.GetMemorizableSpellsCount (pc
, IE_SPELL_TYPE_WIZARD
, 0, 0)>0:
520 stats
.append ( (10343, GA (IE_INT
,0), '%' ) )
522 stats
.append ( (10347, GA (IE_REPUTATION
,0), '0') )
525 # 10344 Bonus Priest spells
526 if GemRB
.GetMemorizableSpellsCount (pc
, IE_SPELL_TYPE_PRIEST
, 0, 0)>0:
528 for level
in range (7):
529 GemRB
.SetToken ("SPELLLEVEL", str (level
+1) )
530 #get the bonus spell count
531 base
= GemRB
.GetMemorizableSpellsCount (pc
, IE_SPELL_TYPE_PRIEST
, level
, 0)
533 count
= GemRB
.GetMemorizableSpellsCount (pc
, IE_SPELL_TYPE_PRIEST
, level
)
534 stats
.append ( (GemRB
.GetString (10345), count
-base
, 'b') )
541 strref
, val
, type = s
542 if val
== 0 and type != '0':
544 if type == '+': #pluses
545 res
.append ("[capital=0]"+GemRB
.GetString (strref
) + ' '+ '+' * val
)
546 elif type == 'x': #x character before value
547 res
.append ("[capital=0]"+GemRB
.GetString (strref
) +': x' + str (val
) )
548 elif type == 'a': #value (portrait icon) + string
549 res
.append ("[capital=2]"+val
+" "+GemRB
.GetString (strref
))
550 elif type == 'b': #strref is an already resolved string
551 res
.append ("[capital=0]"+strref
+": "+str (val
))
552 elif type == 'c': #normal string
553 res
.append ("[capital=0]"+GemRB
.GetString (strref
))
554 elif type == 'd': #strref is an already resolved string
555 res
.append ("[capital=0]"+strref
)
556 elif type == '0': #normal value
557 res
.append (GemRB
.GetString (strref
) + ': ' + str (val
))
558 else: #normal value + type character, for example percent sign
559 res
.append ("[capital=0]"+GemRB
.GetString (strref
) + ': ' + str (val
) + type)
563 res
.append ( GemRB
.GetString (s
) )
570 return "\n".join (res
)
572 def GetReputation (repvalue
):
573 table
= GemRB
.LoadTable ("reptxt")
576 txt
= GemRB
.GetString (table
.GetValue (repvalue
, 0) )
577 return txt
+"("+str (repvalue
)+")"
579 def OpenInformationWindow ():
580 global InformationWindow
582 if InformationWindow
!= None:
583 if BiographyWindow
: OpenBiographyWindow ()
587 InformationWindow
= Window
= GemRB
.LoadWindow (4)
590 Button
= Window
.GetControl (26)
591 Button
.SetText (18003)
592 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "OpenBiographyWindow")
595 Button
= Window
.GetControl (24)
596 Button
.SetText (11973)
597 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "CloseInformationWindow")
603 for i
in range (1, GemRB
.GetPartySize () + 1):
604 stat
= GemRB
.GetPCStats(i
)
605 TotalPartyExp
= TotalPartyExp
+ stat
['KillsTotalXP']
606 ChapterPartyExp
= ChapterPartyExp
+ stat
['KillsChapterXP']
607 TotalCount
= TotalCount
+ stat
['KillsTotalCount']
608 ChapterCount
= ChapterCount
+ stat
['KillsChapterCount']
610 # These are used to get the stats
611 pc
= GemRB
.GameGetSelectedPCSingle ()
612 stat
= GemRB
.GetPCStats (pc
)
614 Label
= Window
.GetControl (0x10000000)
615 Label
.SetText (GemRB
.GetPlayerName (pc
, 1))
617 ClassTitle
= GetActorClassTitle (pc
)
618 Label
= Window
.GetControl (0x10000018)
619 Label
.SetText (ClassTitle
)
621 #most powerful vanquished
622 Label
= Window
.GetControl (0x10000005)
623 #we need getstring, so -1 will translate to empty string
624 Label
.SetText (GemRB
.GetString (stat
['BestKilledName']))
626 # NOTE: currentTime is in seconds, joinTime is in seconds * 15
627 # (script updates???). In each case, there are 60 seconds
628 # in a minute, 24 hours in a day, but ONLY 5 minutes in an hour!!
629 # Hence currentTime (and joinTime after div by 15) has
630 # 7200 secs a day (60 * 5 * 24)
631 currentTime
= GemRB
.GetGameTime ()
632 joinTime
= stat
['JoinDate'] - stat
['AwayTime']
634 party_time
= currentTime
- (joinTime
/ 15)
635 days
= party_time
/ 7200
636 hours
= (party_time
% 7200) / 300
638 GemRB
.SetToken ('GAMEDAYS', str (days
))
639 GemRB
.SetToken ('HOUR', str (hours
))
640 Label
= Window
.GetControl (0x10000006)
641 #actually it is 16043 <DURATION>, but duration is translated to
642 #16041, hopefully this won't cause problem with international version
643 Label
.SetText (16041)
646 Label
= Window
.GetControl (0x10000007)
647 Label
.SetText (stat
['FavouriteSpell'])
650 Label
= Window
.GetControl (0x10000008)
651 #actually it is 10479 <WEAPONNAME>, but weaponname is translated to
652 #the real weapon name (which we should set using SetToken)
653 #there are other strings like bow+wname/xbow+wname/sling+wname
655 Label
.SetText (stat
['FavouriteWeapon'])
658 Label
= Window
.GetControl (0x1000000f)
659 if TotalPartyExp
!= 0:
660 PartyExp
= int ((stat
['KillsTotalXP'] * 100) / TotalPartyExp
)
661 Label
.SetText (str (PartyExp
) + '%')
665 Label
= Window
.GetControl (0x10000013)
666 if ChapterPartyExp
!= 0:
667 PartyExp
= int ((stat
['KillsChapterXP'] * 100) / ChapterPartyExp
)
668 Label
.SetText (str (PartyExp
) + '%')
673 Label
= Window
.GetControl (0x10000010)
675 PartyExp
= int ((stat
['KillsTotalCount'] * 100) / TotalCount
)
676 Label
.SetText (str (PartyExp
) + '%')
680 Label
= Window
.GetControl (0x10000014)
681 if ChapterCount
!= 0:
682 PartyExp
= int ((stat
['KillsChapterCount'] * 100) / ChapterCount
)
683 Label
.SetText (str (PartyExp
) + '%')
687 Label
= Window
.GetControl (0x10000011)
688 Label
.SetText (str (stat
['KillsChapterXP']))
689 Label
= Window
.GetControl (0x10000015)
690 Label
.SetText (str (stat
['KillsTotalXP']))
692 #count of kills in chapter/game
693 Label
= Window
.GetControl (0x10000012)
694 Label
.SetText (str (stat
['KillsChapterCount']))
695 Label
= Window
.GetControl (0x10000016)
696 Label
.SetText (str (stat
['KillsTotalCount']))
698 Window
.ShowModal (MODAL_SHADOW_GRAY
)
701 def CloseInformationWindow ():
702 global InformationWindow
704 if InformationWindow
:
705 InformationWindow
.Unload ()
706 InformationWindow
= None
707 OptionsWindow
.SetVisible (WINDOW_VISIBLE
)
708 RecordsWindow
.SetVisible (WINDOW_VISIBLE
)
709 GUICommonWindows
.PortraitWindow
.SetVisible (WINDOW_VISIBLE
)
712 def OpenBiographyWindow ():
713 global BiographyWindow
715 if BiographyWindow
!= None:
718 BiographyWindow
= Window
= GemRB
.LoadWindow (12)
719 GemRB
.SetVar ("FloatWindow", BiographyWindow
.ID
)
721 TextArea
= Window
.GetControl (0)
722 pc
= GemRB
.GameGetSelectedPCSingle ()
723 TextArea
.SetText (GemRB
.GetPlayerString (pc
, 74) )
726 Button
= Window
.GetControl (2)
727 Button
.SetText (11973)
728 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "CloseBiographyWindow")
730 Window
.ShowModal (MODAL_SHADOW_GRAY
)
733 def CloseBiographyWindow ():
734 global BiographyWindow
737 BiographyWindow
.Unload ()
738 BiographyWindow
= None
739 InformationWindow
.SetVisible (WINDOW_VISIBLE
)
742 def OpenExportWindow ():
743 global ExportWindow
, NameField
, ExportDoneButton
745 ExportWindow
= GemRB
.LoadWindow (13)
747 TextArea
= ExportWindow
.GetControl (2)
748 TextArea
.SetText (10962)
750 TextArea
= ExportWindow
.GetControl (0)
751 TextArea
.GetCharacters ()
753 ExportDoneButton
= ExportWindow
.GetControl (4)
754 ExportDoneButton
.SetText (11973)
755 ExportDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
757 CancelButton
= ExportWindow
.GetControl (5)
758 CancelButton
.SetText (13727)
759 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
761 NameField
= ExportWindow
.GetControl (6)
763 ExportDoneButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "ExportDonePress")
764 CancelButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "ExportCancelPress")
765 NameField
.SetEventByName (IE_GUI_EDIT_ON_CHANGE
, "ExportEditChanged")
766 ExportWindow
.ShowModal (MODAL_SHADOW_GRAY
)
767 NameField
.SetStatus (IE_GUI_CONTROL_FOCUSED
)
770 def ExportDonePress():
772 ExportWindow
.Unload()
773 #save file under name from EditControl
776 def ExportCancelPress():
778 ExportWindow
.Unload()
781 def ExportEditChanged():
782 ExportFileName
= NameField
.QueryText ()
783 if ExportFileName
== "":
784 ExportDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
786 ExportDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
789 def OpenCustomizeWindow ():
790 global CustomizeWindow
791 global PortraitsTable
, ScriptsTable
, ColorTable
793 pc
= GemRB
.GameGetSelectedPCSingle ()
794 if GemRB
.GetPlayerStat (pc
, IE_MC_FLAGS
)&MC_EXPORTABLE
:
799 PortraitsTable
= GemRB
.LoadTable ("PICTURES")
800 ScriptsTable
= GemRB
.LoadTable ("SCRPDESC")
801 ColorTable
= GemRB
.LoadTable ("CLOWNCOL")
802 CustomizeWindow
= GemRB
.LoadWindow (17)
804 PortraitSelectButton
= CustomizeWindow
.GetControl (0)
805 PortraitSelectButton
.SetText (11961)
807 PortraitSelectButton
.SetState (IE_GUI_BUTTON_DISABLED
)
809 SoundButton
= CustomizeWindow
.GetControl (1)
810 SoundButton
.SetText (10647)
812 SoundButton
.SetState (IE_GUI_BUTTON_DISABLED
)
814 ColorButton
= CustomizeWindow
.GetControl (2)
815 ColorButton
.SetText (10646)
817 ColorButton
.SetState (IE_GUI_BUTTON_DISABLED
)
819 ScriptButton
= CustomizeWindow
.GetControl (3)
820 ScriptButton
.SetText (17111)
822 #This button exists only in bg2/iwd, theoretically we could create it here
823 #BiographyButton = CustomizeWindow.GetControl (9)
824 #BiographyButton.SetText (18003)
826 # BiographyButton.SetState (IE_GUI_BUTTON_DISABLED)
828 TextArea
= CustomizeWindow
.GetControl (5)
829 TextArea
.SetText (11327)
831 CustomizeDoneButton
= CustomizeWindow
.GetControl (7)
832 CustomizeDoneButton
.SetText (11973)
833 CustomizeDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
835 CancelButton
= CustomizeWindow
.GetControl (8);
836 CancelButton
.SetText (13727)
837 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
839 PortraitSelectButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "OpenPortraitSelectWindow")
840 SoundButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "OpenSoundWindow")
841 ColorButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "OpenColorWindow")
842 ScriptButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "OpenScriptWindow")
843 #BiographyButton.SetEventByName (IE_GUI_BUTTON_ON_PRESS, "OpenBiographyEditWindow")
844 CustomizeDoneButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "CustomizeDonePress")
845 CancelButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "CustomizeCancelPress")
847 CustomizeWindow
.ShowModal (MODAL_SHADOW_GRAY
)
850 def CustomizeDonePress ():
851 CloseCustomizeWindow ()
852 UpdateRecordsWindow ()
855 def CustomizeCancelPress ():
856 CloseCustomizeWindow ()
857 UpdateRecordsWindow ()
860 def CloseCustomizeWindow ():
861 global CustomizeWindow
864 CustomizeWindow
.Unload ()
865 CustomizeWindow
= None
868 def OpenPortraitSelectWindow ():
869 global SubCustomizeWindow
870 global PortraitButton
871 global Gender
, LastPortrait
873 SubCustomizeWindow
= GemRB
.LoadWindow (18)
874 pc
= GemRB
.GameGetSelectedPCSingle ()
875 Gender
= GemRB
.GetPlayerStat (pc
, IE_SEX
, 1)
876 PortraitName
= GemRB
.GetPlayerPortrait (pc
, 0)
877 LastPortrait
= PortraitsTable
.GetRowIndex (PortraitName
[0:len(PortraitName
)-1])
879 PortraitButton
= SubCustomizeWindow
.GetControl (0)
880 PortraitButton
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_NO_IMAGE
,OP_SET
)
881 PortraitButton
.SetState (IE_GUI_BUTTON_LOCKED
)
883 LeftButton
= SubCustomizeWindow
.GetControl (1)
884 RightButton
= SubCustomizeWindow
.GetControl (2)
886 DoneButton
= SubCustomizeWindow
.GetControl (3)
887 DoneButton
.SetText (11973)
888 DoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
890 CancelButton
= SubCustomizeWindow
.GetControl (4)
891 CancelButton
.SetText (13727)
892 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
894 CustomPortraitButton
= SubCustomizeWindow
.GetControl (5)
895 CustomPortraitButton
.SetText (17545)
897 LeftButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "PortraitLeftPress")
898 RightButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "PortraitRightPress")
899 DoneButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "PortraitDonePress")
900 CancelButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "CloseSubCustomizeWindow")
901 CustomPortraitButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "OpenCustomPortraitWindow")
902 SubCustomizeWindow
.ShowModal (MODAL_SHADOW_GRAY
)
905 if PortraitsTable
.GetValue (LastPortrait
, 0) == Gender
:
908 LastPortrait
= LastPortrait
+ 1
912 def PortraitDonePress ():
913 pc
= GemRB
.GameGetSelectedPCSingle ()
914 Name
= PortraitsTable
.GetRowName (LastPortrait
)
915 GemRB
.FillPlayerInfo (pc
, Name
+ "L", Name
+ "S")
916 CloseSubCustomizeWindow ()
919 def PortraitRightPress():
923 LastPortrait
= LastPortrait
+ 1
924 if LastPortrait
>= PortraitsTable
.GetRowCount ():
926 if PortraitsTable
.GetValue (LastPortrait
, 0) == Gender
:
932 def PortraitLeftPress():
936 LastPortrait
= LastPortrait
- 1
938 LastPortrait
= PortraitsTable
.GetRowCount ()-1
939 if PortraitsTable
.GetValue (LastPortrait
, 0) == Gender
:
945 def UpdatePortrait ():
946 PortraitName
= PortraitsTable
.GetRowName (LastPortrait
)+"G"
947 PortraitButton
.SetPicture (PortraitName
, "NOPORTLG")
950 def OpenCustomPortraitWindow ():
951 global SubSubCustomizeWindow
952 global PortraitList1
, PortraitList2
953 global RowCount1
, RowCount2
955 SubSubCustomizeWindow
= GemRB
.LoadWindow (19)
957 SmallPortraitButton
= SubSubCustomizeWindow
.GetControl (1)
958 SmallPortraitButton
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_NO_IMAGE
,OP_SET
)
960 LargePortraitButton
= SubSubCustomizeWindow
.GetControl (0)
961 LargePortraitButton
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_NO_IMAGE
,OP_SET
)
963 DoneButton
= SubSubCustomizeWindow
.GetControl (10)
964 DoneButton
.SetText (11973)
965 DoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
966 DoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
968 CancelButton
= SubSubCustomizeWindow
.GetControl (11)
969 CancelButton
.SetText (13727)
970 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
972 # Portrait List Large
973 PortraitList1
= SubSubCustomizeWindow
.GetControl (2)
974 RowCount1
= PortraitList1
.GetPortraits (0)
975 PortraitList1
.SetEventByName (IE_GUI_TEXTAREA_ON_CHANGE
, "LargeCustomPortrait")
976 GemRB
.SetVar ("Row1", RowCount1
)
977 PortraitList1
.SetVarAssoc ("Row1",RowCount1
)
979 # Portrait List Small
980 PortraitList2
= SubSubCustomizeWindow
.GetControl (3)
981 RowCount2
= PortraitList2
.GetPortraits (1)
982 PortraitList2
.SetEventByName (IE_GUI_TEXTAREA_ON_CHANGE
, "SmallCustomPortrait")
983 GemRB
.SetVar ("Row2", RowCount2
)
984 PortraitList2
.SetVarAssoc ("Row2",RowCount2
)
986 DoneButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "CustomPortraitDonePress")
987 CancelButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "CloseSubSubCustomizeWindow")
989 SubSubCustomizeWindow
.ShowModal (MODAL_SHADOW_GRAY
)
992 def CustomPortraitDonePress ():
993 pc
= GemRB
.GameGetSelectedPCSingle ()
994 GemRB
.FillPlayerInfo (pc
, PortraitList1
.QueryText () , PortraitList2
.QueryText ())
996 CloseSubSubCustomizeWindow ()
997 #closing the generic portraits, because we just set a custom one
998 CloseSubCustomizeWindow ()
1001 def LargeCustomPortrait ():
1002 Window
= SubSubCustomizeWindow
1004 Portrait
= PortraitList1
.QueryText ()
1006 if GemRB
.GetVar ("Row1") == RowCount1
:
1009 Label
= Window
.GetControl (0x10000007)
1010 Label
.SetText (Portrait
)
1012 Button
= Window
.GetControl (10)
1014 Portrait
= "NOPORTMD"
1015 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
1017 if PortraitList2
.QueryText ()!="":
1018 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
1020 Button
= Window
.GetControl (0)
1021 Button
.SetPicture (Portrait
, "NOPORTMD")
1024 def SmallCustomPortrait ():
1025 Window
= SubSubCustomizeWindow
1027 Portrait
= PortraitList2
.QueryText ()
1029 if GemRB
.GetVar ("Row2") == RowCount2
:
1032 Label
= Window
.GetControl (0x10000008)
1033 Label
.SetText (Portrait
)
1035 Button
= Window
.GetControl (10)
1037 Portrait
= "NOPORTSM"
1038 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
1040 if PortraitList1
.QueryText ()!="":
1041 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
1043 Button
= Window
.GetControl (1)
1044 Button
.SetPicture (Portrait
, "NOPORTSM")
1047 def OpenSoundWindow ():
1048 global SubCustomizeWindow
1052 SubCustomizeWindow
= GemRB
.LoadWindow (20)
1054 VoiceList
= SubCustomizeWindow
.GetControl (5)
1055 VoiceList
.SetFlags (IE_GUI_TEXTAREA_SELECTABLE
)
1056 pc
= GemRB
.GameGetSelectedPCSingle ()
1057 Gender
= GemRB
.GetPlayerStat (pc
, IE_SEX
, 1)
1059 VoiceList
.SetVarAssoc ("Selected", 0)
1060 RowCount
=VoiceList
.GetCharSounds()
1062 PlayButton
= SubCustomizeWindow
.GetControl (7)
1063 PlayButton
.SetText (17318)
1065 TextArea
= SubCustomizeWindow
.GetControl (8)
1066 TextArea
.SetText (11315)
1068 DoneButton
= SubCustomizeWindow
.GetControl (10)
1069 DoneButton
.SetText (11973)
1070 DoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1072 CancelButton
= SubCustomizeWindow
.GetControl (11)
1073 CancelButton
.SetText (13727)
1074 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
1076 PlayButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "PlaySoundPressed")
1077 DoneButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "DoneSoundWindow")
1078 CancelButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "CloseSubCustomizeWindow")
1080 SubCustomizeWindow
.ShowModal (MODAL_SHADOW_GRAY
)
1083 def DoneSoundWindow ():
1084 pc
= GemRB
.GameGetSelectedPCSingle ()
1085 CharSound
= VoiceList
.QueryText ()
1086 GemRB
.SetPlayerSound (pc
, CharSound
)
1088 CloseSubCustomizeWindow ()
1091 def PlaySoundPressed():
1092 global CharSoundWindow
, SoundIndex
, SoundSequence
1094 CharSound
= VoiceList
.QueryText ()
1095 while (not GemRB
.HasResource (CharSound
+ SoundSequence
[SoundIndex
], RES_WAV
)):
1097 GemRB
.PlaySound (CharSound
+ SoundSequence
[SoundIndex
], 0, 0, 4)
1100 def OpenColorWindow ():
1101 global SubCustomizeWindow
1102 global PortraitWindow
1103 global PortraitButton
1104 global HairButton
, SkinButton
, MajorButton
, MinorButton
1105 global HairColor
, SkinColor
, MajorColor
, MinorColor
1107 pc
= GemRB
.GameGetSelectedPCSingle ()
1108 MinorColor
= GemRB
.GetPlayerStat (pc
, IE_MINOR_COLOR
)
1109 MajorColor
= GemRB
.GetPlayerStat (pc
, IE_MAJOR_COLOR
)
1110 SkinColor
= GemRB
.GetPlayerStat (pc
, IE_SKIN_COLOR
)
1111 HairColor
= GemRB
.GetPlayerStat (pc
, IE_HAIR_COLOR
)
1112 SubCustomizeWindow
= GemRB
.LoadWindow (21)
1114 PortraitButton
= SubCustomizeWindow
.GetControl (0)
1115 PortraitButton
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_NO_IMAGE
,OP_SET
)
1116 PortraitButton
.SetState (IE_GUI_BUTTON_LOCKED
)
1118 HairButton
= SubCustomizeWindow
.GetControl (3)
1119 SkinButton
= SubCustomizeWindow
.GetControl (4)
1120 MajorButton
= SubCustomizeWindow
.GetControl (5)
1121 MinorButton
= SubCustomizeWindow
.GetControl (6)
1123 DoneButton
= SubCustomizeWindow
.GetControl (12)
1124 DoneButton
.SetText (11973)
1125 DoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1127 CancelButton
= SubCustomizeWindow
.GetControl (13)
1128 CancelButton
.SetText (13727)
1129 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
1131 HairButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "SetHairColor")
1132 SkinButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "SetSkinColor")
1133 MajorButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "SetMajorColor")
1134 MinorButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "SetMinorColor")
1135 DoneButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "DoneColorWindow")
1136 CancelButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "CloseSubCustomizeWindow")
1139 SubCustomizeWindow
.ShowModal (MODAL_SHADOW_GRAY
)
1142 def DoneColorWindow ():
1143 pc
= GemRB
.GameGetSelectedPCSingle ()
1144 GemRB
.SetPlayerStat (pc
, IE_MINOR_COLOR
, MinorColor
)
1145 GemRB
.SetPlayerStat (pc
, IE_MAJOR_COLOR
, MajorColor
)
1146 GemRB
.SetPlayerStat (pc
, IE_SKIN_COLOR
, SkinColor
)
1147 GemRB
.SetPlayerStat (pc
, IE_HAIR_COLOR
, HairColor
)
1148 CloseSubCustomizeWindow ()
1151 def UpdatePaperDoll ():
1152 pc
= GemRB
.GameGetSelectedPCSingle ()
1153 Color1
= GemRB
.GetPlayerStat (pc
, IE_METAL_COLOR
)
1154 MinorButton
.SetBAM ("COLGRAD", 0, 0, MinorColor
&0xff)
1155 MajorButton
.SetBAM ("COLGRAD", 0, 0, MajorColor
&0xff)
1156 SkinButton
.SetBAM ("COLGRAD", 0, 0, SkinColor
&0xff)
1157 Color5
= GemRB
.GetPlayerStat (pc
, IE_LEATHER_COLOR
)
1158 Color6
= GemRB
.GetPlayerStat (pc
, IE_ARMOR_COLOR
)
1159 HairButton
.SetBAM ("COLGRAD", 0, 0, HairColor
&0xff)
1160 PortraitButton
.SetPLT (GetActorPaperDoll (pc
),
1161 Color1
, MinorColor
, MajorColor
, SkinColor
, Color5
, Color6
, HairColor
, 0, 0)
1164 def SetHairColor ():
1165 global ColorIndex
, PickedColor
1168 PickedColor
= HairColor
1172 def SetSkinColor ():
1173 global ColorIndex
, PickedColor
1176 PickedColor
= SkinColor
1180 def SetMinorColor ():
1181 global ColorIndex
, PickedColor
1184 PickedColor
= MinorColor
1188 def SetMajorColor ():
1189 global ColorIndex
, PickedColor
1192 PickedColor
= MajorColor
1196 def OpenColorPicker ():
1197 global SubSubCustomizeWindow
1200 SubSubCustomizeWindow
= GemRB
.LoadWindow (22)
1202 GemRB
.SetVar ("Selected",-1)
1203 for i
in range (1,35):
1204 Button
= SubSubCustomizeWindow
.GetControl (i
)
1205 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
1206 Button
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_RADIOBUTTON
,OP_OR
)
1209 for i
in range (34):
1210 MyColor
= ColorTable
.GetValue (ColorIndex
, i
)
1213 Button
= SubSubCustomizeWindow
.GetControl (i
+1)
1214 Button
.SetBAM("COLGRAD", 2, 0, MyColor
)
1215 if PickedColor
== MyColor
:
1216 GemRB
.SetVar ("Selected",i
)
1218 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
1219 Button
.SetVarAssoc("Selected",i
)
1220 Button
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "DonePress")
1222 SubSubCustomizeWindow
.ShowModal (MODAL_SHADOW_GRAY
)
1226 global HairColor
, SkinColor
, MajorColor
, MinorColor
1229 CloseSubSubCustomizeWindow ()
1230 PickedColor
=ColorTable
.GetValue (ColorIndex
, GemRB
.GetVar ("Selected"))
1232 HairColor
=PickedColor
1236 SkinColor
=PickedColor
1240 MinorColor
=PickedColor
1244 MajorColor
=PickedColor
1248 def OpenScriptWindow ():
1249 global SubCustomizeWindow
1250 global ScriptTextArea
, SelectedTextArea
1252 SubCustomizeWindow
= GemRB
.LoadWindow (11)
1254 ScriptTextArea
= SubCustomizeWindow
.GetControl (2)
1255 ScriptTextArea
.SetFlags (IE_GUI_TEXTAREA_SELECTABLE
)
1257 pc
= GemRB
.GameGetSelectedPCSingle ()
1258 script
= GemRB
.GetPlayerScript (pc
)
1259 scriptindex
= ScriptsTable
.GetRowIndex (script
)
1260 GemRB
.SetVar ("Selected", scriptindex
)
1261 ScriptTextArea
.SetVarAssoc ("Selected", scriptindex
)
1263 SelectedTextArea
= SubCustomizeWindow
.GetControl (4)
1264 UpdateScriptSelection ()
1266 DoneButton
= SubCustomizeWindow
.GetControl (5)
1267 DoneButton
.SetText (11973)
1268 DoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1270 CancelButton
= SubCustomizeWindow
.GetControl (6)
1271 CancelButton
.SetText (13727)
1272 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
1274 DoneButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "DoneScriptWindow")
1275 CancelButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "CloseSubCustomizeWindow")
1276 ScriptTextArea
.SetEventByName (IE_GUI_TEXTAREA_ON_CHANGE
, "UpdateScriptSelection")
1278 SubCustomizeWindow
.ShowModal (MODAL_SHADOW_GRAY
)
1281 def FillScriptList ():
1282 ScriptTextArea
.Clear ()
1283 row
= ScriptsTable
.GetRowCount ()
1284 for i
in range (row
):
1285 GemRB
.SetToken ("script", ScriptsTable
.GetRowName (i
) )
1286 title
= ScriptsTable
.GetValue (i
,0)
1288 desc
= ScriptsTable
.GetValue (i
,1)
1289 txt
= GemRB
.GetString (title
)
1292 txt
+= GemRB
.GetString (desc
)
1294 ScriptTextArea
.Append (txt
+"\n", -1)
1297 ScriptTextArea
.Append (ScriptsTable
.GetRowName (i
)+"\n" ,-1)
1301 def DoneScriptWindow ():
1302 pc
= GemRB
.GameGetSelectedPCSingle ()
1303 script
= ScriptsTable
.GetRowName (GemRB
.GetVar ("Selected") )
1304 GemRB
.SetPlayerScript (pc
, script
)
1305 CloseSubCustomizeWindow ()
1308 def UpdateScriptSelection():
1309 text
= ScriptTextArea
.QueryText ()
1310 SelectedTextArea
.SetText (text
)
1313 def OpenBiographyEditWindow ():
1314 global SubCustomizeWindow
1319 pc
= GemRB
.GameGetSelectedPCSingle ()
1320 BioStrRef
= GemRB
.GetPlayerString (pc
, 74)
1321 if BioStrRef
!= 33347:
1324 SubCustomizeWindow
= GemRB
.LoadWindow (23)
1326 ClearButton
= SubCustomizeWindow
.GetControl (5)
1327 ClearButton
.SetText (34881)
1329 DoneButton
= SubCustomizeWindow
.GetControl (1)
1330 DoneButton
.SetText (11973)
1331 DoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1333 RevertButton
= SubCustomizeWindow
.GetControl (3)
1334 RevertButton
.SetText (2240)
1336 RevertButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1338 CancelButton
= SubCustomizeWindow
.GetControl (2)
1339 CancelButton
.SetText (13727)
1340 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
1342 TextArea
= SubCustomizeWindow
.GetControl (4)
1343 TextArea
.SetBufferLength (65535)
1344 TextArea
.SetText (BioStrRef
)
1346 ClearButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "ClearBiography")
1347 DoneButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "DoneBiographyWindow")
1348 RevertButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "RevertBiography")
1349 CancelButton
.SetEventByName (IE_GUI_BUTTON_ON_PRESS
, "CloseSubCustomizeWindow")
1351 SubCustomizeWindow
.ShowModal (MODAL_SHADOW_GRAY
)
1354 def ClearBiography():
1355 pc
= GemRB
.GameGetSelectedPCSingle ()
1356 BioStrRef
= 62015+pc
1357 #GemRB.CreateString (BioStrRef, "")
1358 TextArea
.SetText ("")
1361 def DoneBiographyWindow ():
1365 pc
= GemRB
.GameGetSelectedPCSingle ()
1367 BioStrRef
= 62015+pc
1368 GemRB
.CreateString (BioStrRef
, TextArea
.QueryText())
1369 GemRB
.SetPlayerString (pc
, 74, BioStrRef
)
1370 CloseSubCustomizeWindow ()
1373 def RevertBiography():
1377 TextArea
.SetText (33347)
1380 def CloseSubCustomizeWindow ():
1381 global SubCustomizeWindow
1383 if SubCustomizeWindow
:
1384 SubCustomizeWindow
.Unload ()
1385 SubCustomizeWindow
= None
1388 def CloseSubSubCustomizeWindow ():
1389 global SubSubCustomizeWindow
1391 if SubSubCustomizeWindow
:
1392 SubSubCustomizeWindow
.Unload ()
1393 SubSubCustomizeWindow
= None
1396 ###################################################
1397 # End of file GUIREC.py