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 ###################################################
26 from GUIDefines
import *
27 from ie_stats
import *
28 from ie_restype
import *
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 import GUICommonWindows
59 global RecordsWindow
, OptionsWindow
60 global OldOptionsWindow
62 if GUICommon
.CloseOtherWindow (OpenRecordsWindow
):
63 if InformationWindow
: OpenInformationWindow ()
66 RecordsWindow
.Unload ()
68 OptionsWindow
.Unload ()
70 GemRB
.SetVar ("OtherWindow", -1)
71 GUICommon
.GameWindow
.SetVisible(WINDOW_VISIBLE
)
73 GUICommonWindows
.OptionsWindow
= OldOptionsWindow
74 OldOptionsWindow
= None
75 GUICommonWindows
.SetSelectionChangeHandler (None)
79 GUICommon
.GameWindow
.SetVisible(WINDOW_INVISIBLE
)
81 GemRB
.LoadWindowPack ("GUIREC")
82 RecordsWindow
= Window
= GemRB
.LoadWindow (2)
83 GemRB
.SetVar ("OtherWindow", RecordsWindow
.ID
)
84 # saving the original portrait window
85 OldOptionsWindow
= GUICommonWindows
.OptionsWindow
86 OptionsWindow
= GemRB
.LoadWindow (0)
87 GUICommonWindows
.SetupMenuWindowControls (OptionsWindow
, 0, OpenRecordsWindow
)
88 OptionsWindow
.SetFrame ()
91 Button
= Window
.GetControl (0)
93 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, DualClass
.DualClassWindow
)
96 Button
= Window
.GetControl (37)
98 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, LevelUp
.OpenLevelUpWindow
)
101 Button
= Window
.GetControl (1)
102 Button
.SetText (11946)
103 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, OpenInformationWindow
)
106 Button
= Window
.GetControl (51)
107 Button
.SetText (16559)
108 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, OpenRecReformPartyWindow
)
111 Button
= Window
.GetControl (50)
112 Button
.SetText (10645)
113 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, OpenCustomizeWindow
)
116 Button
= Window
.GetControl (36)
117 Button
.SetText (13956)
118 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, OpenExportWindow
)
121 ## Button = Window.GetControl (52)
122 ## Button.SetText (61265)
123 ## Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, KitInfoWindow)
125 GUICommonWindows
.SetSelectionChangeHandler (UpdateRecordsWindow
)
126 UpdateRecordsWindow ()
128 OptionsWindow
.SetVisible (WINDOW_VISIBLE
)
129 Window
.SetVisible (WINDOW_VISIBLE
)
130 GUICommonWindows
.PortraitWindow
.SetVisible (WINDOW_VISIBLE
)
133 #original returns to game before continuing...
134 def OpenRecReformPartyWindow ():
136 GemRB
.SetTimedEvent (GUIWORLD
.OpenReformPartyWindow
, 1)
139 def UpdateRecordsWindow ():
140 global stats_overview
, alignment_help
142 Window
= RecordsWindow
143 if not RecordsWindow
:
144 print "SelectionChange handler points to non existing window\n"
147 pc
= GemRB
.GameGetSelectedPCSingle ()
150 Button
= Window
.GetControl (36)
151 if GemRB
.GetPlayerStat (pc
, IE_MC_FLAGS
)&MC_EXPORTABLE
:
152 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
154 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
157 Button
= Window
.GetControl (0)
158 if GUICommon
.CanDualClass (pc
):
159 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
161 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
164 Button
= Window
.GetControl (37)
165 if LUCommon
.CanLevelUp (pc
):
166 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
168 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
171 Label
= Window
.GetControl (0x1000000e)
172 Label
.SetText (GemRB
.GetPlayerName (pc
, 0))
175 Button
= Window
.GetControl (2)
176 Button
.SetFlags (IE_GUI_BUTTON_NO_IMAGE | IE_GUI_BUTTON_PICTURE
, OP_SET
)
177 Button
.SetState (IE_GUI_BUTTON_LOCKED
)
178 Button
.SetPicture (GemRB
.GetPlayerPortrait (pc
,0), "NOPORTLG")
181 Label
= Window
.GetControl (0x10000028)
182 ac
= GemRB
.GetPlayerStat (pc
, IE_ARMORCLASS
)
183 ac
+= GemRB
.GetAbilityBonus (IE_DEX
, 2, GemRB
.GetPlayerStat (pc
, IE_DEX
) )
184 Label
.SetText (str (ac
))
185 Label
.SetTooltip (17183)
188 Label
= Window
.GetControl (0x10000029)
189 Label
.SetText (str (GemRB
.GetPlayerStat (pc
, IE_HITPOINTS
)))
190 Label
.SetTooltip (17184)
193 Label
= Window
.GetControl (0x1000002a)
194 Label
.SetText (str (GemRB
.GetPlayerStat (pc
, IE_MAXHITPOINTS
)))
195 Label
.SetTooltip (17378)
199 sstr
= GemRB
.GetPlayerStat (pc
, IE_STR
)
200 sstrx
= GemRB
.GetPlayerStat (pc
, IE_STREXTRA
)
201 cstr
= GetStatColor (pc
, IE_STR
)
202 if sstrx
> 0 and sstr
==18:
203 sstr
= "%d/%02d" %(sstr
, sstrx
% 100)
207 sint
= str (GemRB
.GetPlayerStat (pc
, IE_INT
))
208 cint
= GetStatColor (pc
, IE_INT
)
209 swis
= str (GemRB
.GetPlayerStat (pc
, IE_WIS
))
210 cwis
= GetStatColor (pc
, IE_WIS
)
211 sdex
= str (GemRB
.GetPlayerStat (pc
, IE_DEX
))
212 cdex
= GetStatColor (pc
, IE_DEX
)
213 scon
= str (GemRB
.GetPlayerStat (pc
, IE_CON
))
214 ccon
= GetStatColor (pc
, IE_CON
)
215 schr
= str (GemRB
.GetPlayerStat (pc
, IE_CHR
))
216 cchr
= GetStatColor (pc
, IE_CHR
)
218 Label
= Window
.GetControl (0x1000002f)
220 Label
.SetTextColor (cstr
[0], cstr
[1], cstr
[2])
222 Label
= Window
.GetControl (0x10000009)
224 Label
.SetTextColor (cdex
[0], cdex
[1], cdex
[2])
226 Label
= Window
.GetControl (0x1000000a)
228 Label
.SetTextColor (ccon
[0], ccon
[1], ccon
[2])
230 Label
= Window
.GetControl (0x1000000b)
232 Label
.SetTextColor (cint
[0], cint
[1], cint
[2])
234 Label
= Window
.GetControl (0x1000000c)
236 Label
.SetTextColor (cwis
[0], cwis
[1], cwis
[2])
238 Label
= Window
.GetControl (0x1000000d)
240 Label
.SetTextColor (cchr
[0], cchr
[1], cchr
[2])
243 ClassTitle
= GUICommon
.GetActorClassTitle (pc
)
244 Label
= Window
.GetControl (0x10000030)
245 Label
.SetText (ClassTitle
)
248 text
= CommonTables
.Races
.GetValue (CommonTables
.Races
.FindValue (3, GemRB
.GetPlayerStat (pc
, IE_RACE
)) ,
251 Label
= Window
.GetControl (0x1000000f)
254 Table
= GemRB
.LoadTable ("aligns")
256 text
= Table
.GetValue (Table
.FindValue ( 3, GemRB
.GetPlayerStat (pc
, IE_ALIGNMENT
) ), 0)
257 Label
= Window
.GetControl (0x10000010)
260 Label
= Window
.GetControl (0x10000011)
261 if GemRB
.GetPlayerStat (pc
, IE_SEX
) == 1:
266 # help, info textarea
267 stats_overview
= GetStatOverview (pc
)
268 Text
= Window
.GetControl (45)
269 Text
.SetText (stats_overview
)
270 #TODO: making window visible/shaded depending on the pc's state
271 Window
.SetVisible (WINDOW_VISIBLE
)
274 def GetStatColor (pc
, stat
):
275 a
= GemRB
.GetPlayerStat (pc
, stat
)
276 b
= GemRB
.GetPlayerStat (pc
, stat
, 1)
283 # GemRB.GetPlayerStat wrapper that only returns nonnegative values
285 val
= GemRB
.GetPlayerStat (pc
, stat
)
291 # LevelDiff is used only from the level up code and holds the level
292 # difference for each class
293 def GetStatOverview (pc
, LevelDiff
=[0,0,0]):
294 StateTable
= GemRB
.LoadTable ("statdesc")
296 GS
= lambda s
, pc
=pc
: GemRB
.GetPlayerStat (pc
, s
)
297 GB
= lambda s
, pc
=pc
: GemRB
.GetPlayerStat (pc
, s
, 1)
298 GA
= lambda s
, col
, pc
=pc
: GemRB
.GetAbilityBonus (s
, col
, GS (s
) )
302 # 16480 <CLASS>: Level <LEVEL>
303 # Experience: <EXPERIENCE>
304 # Next Level: <NEXTLEVEL>
306 # collecting tokens for stat overview
307 ClassTitle
= GUICommon
.GetActorClassTitle (pc
)
308 GemRB
.SetToken ("CLASS", ClassTitle
)
309 Class
= GemRB
.GetPlayerStat (pc
, IE_CLASS
)
310 Class
= CommonTables
.Classes
.FindValue (5, Class
)
311 Class
= CommonTables
.Classes
.GetRowName (Class
)
312 Dual
= GUICommon
.IsDualClassed (pc
, 1)
313 Multi
= GUICommon
.IsMultiClassed (pc
, 1)
314 XP
= GemRB
.GetPlayerStat (pc
, IE_XP
)
315 LevelDrain
= GS (IE_LEVELDRAIN
)
317 if GS (IE_STATE_ID
) & STATE_DEAD
:
318 stats
.append ( (11829,1,'c') ) # DEAD
321 if Multi
[0] > 1: # we're multiclassed
322 print "\tMulticlassed"
323 Levels
= [GemRB
.GetPlayerStat (pc
, IE_LEVEL
), GemRB
.GetPlayerStat (pc
, IE_LEVEL2
), GemRB
.GetPlayerStat (pc
, IE_LEVEL3
)]
325 stats
.append ( (19721,1,'c') )
327 for i
in range (Multi
[0]):
328 ClassIndex
= CommonTables
.Classes
.FindValue (5, Multi
[i
+1])
329 ClassTitle
= GemRB
.GetString (CommonTables
.Classes
.GetValue (ClassIndex
, 2))
330 GemRB
.SetToken ("CLASS", ClassTitle
)
331 Class
= CommonTables
.Classes
.GetRowName (ClassIndex
)
332 GemRB
.SetToken ("LEVEL", str (Levels
[i
]+LevelDiff
[i
]-int(LevelDrain
/Multi
[0])) )
333 GemRB
.SetToken ("EXPERIENCE", str (XP
/Multi
[0]) )
335 stats
.append ( (GemRB
.GetString (19720),1,'d') )
336 stats
.append ( (GemRB
.GetString (57435),1,'d') ) # LEVEL DRAINED
338 GemRB
.SetToken ("NEXTLEVEL", LUCommon
.GetNextLevelExp (Levels
[i
]+LevelDiff
[i
], Class
) )
339 stats
.append ( (GemRB
.GetString (16480),"",'d') )
341 print "\t\tClass (Level):",Class
,"(",Levels
[i
],")"
343 elif Dual
[0] > 0: # dual classed; first show the new class
344 print "\tDual classed"
345 stats
.append ( (19722,1,'c') )
348 Levels
= [GemRB
.GetPlayerStat (pc
, IE_LEVEL
), GemRB
.GetPlayerStat (pc
, IE_LEVEL2
), GemRB
.GetPlayerStat (pc
, IE_LEVEL3
)]
350 # the levels are stored in the class order (eg. FIGHTER_MAGE)
351 # the current active class does not matter!
352 if GUICommon
.IsDualSwap (pc
):
353 Levels
= [Levels
[1], Levels
[0], Levels
[2]]
355 Levels
[0] += LevelDiff
[0]
357 ClassTitle
= GemRB
.GetString (CommonTables
.Classes
.GetValue (Dual
[2], 2))
358 GemRB
.SetToken ("CLASS", ClassTitle
)
359 GemRB
.SetToken ("LEVEL", str (Levels
[0]-LevelDrain
))
360 Class
= CommonTables
.Classes
.GetRowName (Dual
[2])
361 XP2
= GemRB
.GetPlayerStat (pc
, IE_XP
)
362 GemRB
.SetToken ("EXPERIENCE", str (XP2
) )
364 stats
.append ( (GemRB
.GetString (19720),1,'d') )
365 stats
.append ( (GemRB
.GetString (57435),1,'d') ) # LEVEL DRAINED
367 GemRB
.SetToken ("NEXTLEVEL", LUCommon
.GetNextLevelExp (Levels
[0], Class
) )
368 stats
.append ( (GemRB
.GetString (16480),"",'d') )
370 # the first class (shown second)
372 ClassTitle
= GemRB
.GetString (CommonTables
.KitList
.GetValue (Dual
[1], 2))
374 ClassTitle
= GemRB
.GetString (CommonTables
.Classes
.GetValue (Dual
[1], 2))
375 GemRB
.SetToken ("CLASS", ClassTitle
)
376 GemRB
.SetToken ("LEVEL", str (Levels
[1]) )
378 # the xp table contains only classes, so we have to determine the base class for kits
380 BaseClass
= CommonTables
.Classes
.GetRowName (Dual
[1])
382 BaseClass
= GUICommon
.GetKitIndex (pc
)
383 BaseClass
= CommonTables
.KitList
.GetValue (BaseClass
, 7)
384 BaseClass
= CommonTables
.Classes
.FindValue (5, BaseClass
)
385 BaseClass
= CommonTables
.Classes
.GetRowName (BaseClass
)
386 # the first class' XP is discarded and set to the minimum level
387 # requirement, so if you don't dual class right after a levelup,
388 # the game would eat some of your XP
389 XP1
= CommonTables
.NextLevel
.GetValue (BaseClass
, str (Levels
[1]))
390 GemRB
.SetToken ("EXPERIENCE", str (XP1
) )
392 # inactive until the new class SURPASSES the former
393 if Levels
[0] <= Levels
[1]:
395 stats
.append ( (19719,1,'c') )
397 stats
.append ( (19720,1,'c') )
399 else: # single classed
400 print "\tSingle classed"
401 Level
= GemRB
.GetPlayerStat (pc
, IE_LEVEL
) + LevelDiff
[0]
402 GemRB
.SetToken ("LEVEL", str (Level
-LevelDrain
))
403 GemRB
.SetToken ("EXPERIENCE", str (XP
) )
405 stats
.append ( (19720,1,'c') )
406 stats
.append ( (57435,1,'c') ) # LEVEL DRAINED
408 GemRB
.SetToken ("NEXTLEVEL", LUCommon
.GetNextLevelExp (Level
, Class
) )
409 stats
.append ( (16480,1,'c') )
411 print "\t\tClass (Level):",Class
,"(",Level
,")"
413 # check to see if we have a level diff anywhere
414 if sum (LevelDiff
) == 0:
415 effects
= GemRB
.GetPlayerStates (pc
)
418 tmp
= StateTable
.GetValue (ord(c
)-66, 0)
419 stats
.append ( (tmp
,c
,'a') )
425 stats
.append ( (8442,1,'c') )
427 stats
.append ( (9457, str(GS (IE_TOHIT
))+" ("+str(GemRB
.GetCombatDetails(pc
, 0)["ToHit"])+")", '0') )
428 tmp
= GS (IE_NUMBEROFATTACKS
)
430 tmp2
= str (tmp
/2) + chr (188)
433 stats
.append ( (9458, tmp2
, '') )
434 stats
.append ( (9459, GSNN (pc
, IE_LORE
), '0') )
435 stats
.append ( (19224, GS (IE_RESISTMAGIC
), '') )
438 reptxt
= GetReputation (GemRB
.GameGetReputation ()/10)
439 stats
.append ( (9465, reptxt
, '') )
440 stats
.append ( (9460, GSNN (pc
, IE_LOCKPICKING
), '') )
441 stats
.append ( (9462, GSNN (pc
, IE_TRAPS
), '') )
442 stats
.append ( (9463, GSNN (pc
, IE_PICKPOCKET
), '') )
443 stats
.append ( (9461, GSNN (pc
, IE_STEALTH
), '') )
444 HatedRace
= GS (IE_HATEDRACE
)
446 HateTable
= GemRB
.LoadTable ("haterace")
447 Racist
= HateTable
.FindValue (1, HatedRace
)
449 HatedRace
= HateTable
.GetValue (Racist
, 0)
450 stats
.append ( (15982, GemRB
.GetString (HatedRace
), '') )
452 #stats.append ( (34120, GSNN (pc, IE_HIDEINSHADOWS), '') )
453 #stats.append ( (34121, GSNN (pc, IE_DETECTILLUSIONS), '') )
454 #stats.append ( (34122, GSNN (pc, IE_SETTRAPS), '') )
455 stats
.append ( (12128, GS (IE_BACKSTABDAMAGEMULTIPLIER
), 'x') )
456 stats
.append ( (12126, GS (IE_TURNUNDEADLEVEL
), '') )
458 #this hack only displays LOH if we know the spell
459 #TODO: the core should just not set LOH if the paladin can't learn it
460 if (GUICommon
.HasSpell (pc
, IE_SPELL_TYPE_INNATE
, 0, "SPCL211") >= 0):
461 stats
.append ( (12127, GS (IE_LAYONHANDSAMOUNT
), '') )
464 aiscript
= GemRB
.GetPlayerScript (pc
)
465 stats
.append ( (2078, aiscript
, '') )
468 # 17379 Saving throws
470 # 17380 Paralyze/Poison/Death
471 stats
.append ( (17380, IE_SAVEVSDEATH
, 's') )
472 # 17381 Rod/Staff/Wand
473 stats
.append ( (17381, IE_SAVEVSWANDS
, 's') )
474 # 17382 Petrify/Polymorph
475 stats
.append ( (17382, IE_SAVEVSPOLY
, 's') )
476 # 17383 Breath weapon
477 stats
.append ( (17383, IE_SAVEVSBREATH
, 's') )
479 stats
.append ( (17384, IE_SAVEVSSPELL
, 's') )
482 # 9466 Weapon proficiencies
484 table
= GemRB
.LoadTable ("weapprof")
485 RowCount
= table
.GetRowCount ()
486 for i
in range (RowCount
):
487 text
= table
.GetValue (i
, 1)
488 stat
= table
.GetValue (i
, 0) + IE_PROFICIENCYBASTARDSWORD
489 stats
.append ( (text
, GS (stat
)&0x07, '+') )
494 # 11770 AC vs. Crushing
495 stats
.append ((11770, GS (IE_ACCRUSHINGMOD
), ''))
496 # 11767 AC vs. Missile
497 stats
.append ((11767, GS (IE_ACMISSILEMOD
), ''))
498 # 11769 AC vs. Piercing
499 stats
.append ((11769, GS (IE_ACPIERCINGMOD
), ''))
500 # 11768 AC vs. Slashing
501 stats
.append ((11768, GS (IE_ACSLASHINGMOD
), ''))
504 # 10315 Ability bonuses
506 value
= GemRB
.GetPlayerStat (pc
, IE_STR
)
507 ex
= GemRB
.GetPlayerStat (pc
, IE_STREXTRA
)
509 stats
.append ( (10332, GemRB
.GetAbilityBonus (IE_STR
,0,value
,ex
), '0') )
511 stats
.append ( (10336, GemRB
.GetAbilityBonus (IE_STR
,1,value
,ex
), '0') )
512 # 10337 open doors (bend bars lift gates)
513 stats
.append ( (10337, GemRB
.GetAbilityBonus (IE_STR
,2,value
,ex
), '0') )
514 # 10338 weight allowance
515 stats
.append ( (10338, GemRB
.GetAbilityBonus (IE_STR
,3,value
,ex
), '0') )
517 stats
.append ( (10339, GA (IE_DEX
,2), '0') )
518 # 10340 Missile adjustment
519 stats
.append ( (10340, GA (IE_DEX
,1), '0') )
520 # 10341 Reaction adjustment
521 stats
.append ( (10341, GA (IE_DEX
,0), '0') )
522 # 10342 CON HP Bonus/Level
523 stats
.append ( (10342, GA (IE_CON
,0), 'p') )
524 # 10343 Chance To Learn spell
525 if GemRB
.GetMemorizableSpellsCount (pc
, IE_SPELL_TYPE_WIZARD
, 0, 0)>0:
526 stats
.append ( (10343, GA (IE_INT
,0), '%' ) )
528 stats
.append ( (10347, GA (IE_REPUTATION
,0), '0') )
531 # 10344 Bonus Priest spells
532 if GemRB
.GetMemorizableSpellsCount (pc
, IE_SPELL_TYPE_PRIEST
, 0, 0)>0:
534 for level
in range (7):
535 GemRB
.SetToken ("SPELLLEVEL", str (level
+1) )
536 #get the bonus spell count
537 base
= GemRB
.GetMemorizableSpellsCount (pc
, IE_SPELL_TYPE_PRIEST
, level
, 0)
539 count
= GemRB
.GetMemorizableSpellsCount (pc
, IE_SPELL_TYPE_PRIEST
, level
)
540 stats
.append ( (GemRB
.GetString (10345), count
-base
, 'b') )
547 strref
, val
, type = s
548 if val
== 0 and type != '0':
550 if type == '+': #pluses
551 res
.append ("[capital=0]"+GemRB
.GetString (strref
) + ' '+ '+' * val
)
552 elif type == 'p': #a plus prefix if positive
554 res
.append ("[capital=0]" + GemRB
.GetString (strref
) + ' +' + str (val
) )
556 res
.append ("[capital=0]" + GemRB
.GetString (strref
) + ' ' + str (val
) )
557 elif type == 's': #both base and (modified) stat, but only if they differ
558 base
= str (GB (val
))
559 stat
= str (GS (val
))
561 res
.append ("[capital=0]" + GemRB
.GetString (strref
) + ': ' + base
)
563 res
.append ("[capital=0]" + GemRB
.GetString (strref
) + ': ' + base
+ " (" + stat
+ ")")
564 elif type == 'x': #x character before value
565 res
.append ("[capital=0]"+GemRB
.GetString (strref
) +': x' + str (val
) )
566 elif type == 'a': #value (portrait icon) + string
567 res
.append ("[capital=2]"+val
+" "+GemRB
.GetString (strref
))
568 elif type == 'b': #strref is an already resolved string
569 res
.append ("[capital=0]"+strref
+": "+str (val
))
570 elif type == 'c': #normal string
571 res
.append ("[capital=0]"+GemRB
.GetString (strref
))
572 elif type == 'd': #strref is an already resolved string
573 res
.append ("[capital=0]"+strref
)
574 elif type == '0': #normal value
575 res
.append (GemRB
.GetString (strref
) + ': ' + str (val
))
576 else: #normal value + type character, for example percent sign
577 res
.append ("[capital=0]"+GemRB
.GetString (strref
) + ': ' + str (val
) + type)
581 res
.append ( GemRB
.GetString (s
) )
588 return "\n".join (res
)
590 def GetReputation (repvalue
):
591 table
= GemRB
.LoadTable ("reptxt")
594 txt
= GemRB
.GetString (table
.GetValue (repvalue
, 0) )
595 return txt
+"("+str (repvalue
)+")"
597 def OpenInformationWindow ():
598 global InformationWindow
600 if InformationWindow
!= None:
601 if BiographyWindow
: OpenBiographyWindow ()
605 InformationWindow
= Window
= GemRB
.LoadWindow (4)
608 Button
= Window
.GetControl (26)
609 Button
.SetText (18003)
610 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, OpenBiographyWindow
)
613 Button
= Window
.GetControl (24)
614 Button
.SetText (11973)
615 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CloseInformationWindow
)
621 for i
in range (1, GemRB
.GetPartySize () + 1):
622 stat
= GemRB
.GetPCStats(i
)
623 TotalPartyExp
= TotalPartyExp
+ stat
['KillsTotalXP']
624 ChapterPartyExp
= ChapterPartyExp
+ stat
['KillsChapterXP']
625 TotalCount
= TotalCount
+ stat
['KillsTotalCount']
626 ChapterCount
= ChapterCount
+ stat
['KillsChapterCount']
628 # These are used to get the stats
629 pc
= GemRB
.GameGetSelectedPCSingle ()
630 stat
= GemRB
.GetPCStats (pc
)
632 Label
= Window
.GetControl (0x10000000)
633 Label
.SetText (GemRB
.GetPlayerName (pc
, 1))
635 ClassTitle
= GUICommon
.GetActorClassTitle (pc
)
636 Label
= Window
.GetControl (0x10000018)
637 Label
.SetText (ClassTitle
)
639 #most powerful vanquished
640 Label
= Window
.GetControl (0x10000005)
641 #we need getstring, so -1 will translate to empty string
642 Label
.SetText (GemRB
.GetString (stat
['BestKilledName']))
644 # NOTE: currentTime is in seconds, joinTime is in seconds * 15
645 # (script updates???). In each case, there are 60 seconds
646 # in a minute, 24 hours in a day, but ONLY 5 minutes in an hour!!
647 # Hence currentTime (and joinTime after div by 15) has
648 # 7200 secs a day (60 * 5 * 24)
649 currentTime
= GemRB
.GetGameTime ()
650 joinTime
= stat
['JoinDate'] - stat
['AwayTime']
652 party_time
= currentTime
- (joinTime
/ 15)
653 days
= party_time
/ 7200
654 hours
= (party_time
% 7200) / 300
656 GemRB
.SetToken ('GAMEDAYS', str (days
))
657 GemRB
.SetToken ('HOUR', str (hours
))
658 Label
= Window
.GetControl (0x10000006)
659 #actually it is 16043 <DURATION>, but duration is translated to
660 #16041, hopefully this won't cause problem with international version
661 Label
.SetText (16041)
664 Label
= Window
.GetControl (0x10000007)
665 Label
.SetText (stat
['FavouriteSpell'])
668 Label
= Window
.GetControl (0x10000008)
669 #actually it is 10479 <WEAPONNAME>, but weaponname is translated to
670 #the real weapon name (which we should set using SetToken)
671 #there are other strings like bow+wname/xbow+wname/sling+wname
673 Label
.SetText (stat
['FavouriteWeapon'])
676 Label
= Window
.GetControl (0x10000013)
677 if TotalPartyExp
!= 0:
678 PartyExp
= int ((stat
['KillsTotalXP'] * 100) / TotalPartyExp
)
679 Label
.SetText (str (PartyExp
) + '%')
684 Label
= Window
.GetControl (0x1000000f)
685 if ChapterPartyExp
!= 0:
686 PartyExp
= int ((stat
['KillsChapterXP'] * 100) / ChapterPartyExp
)
687 Label
.SetText (str (PartyExp
) + '%')
692 Label
= Window
.GetControl (0x10000014)
694 PartyExp
= int ((stat
['KillsTotalCount'] * 100) / TotalCount
)
695 Label
.SetText (str (PartyExp
) + '%')
700 Label
= Window
.GetControl (0x10000010)
701 if ChapterCount
!= 0:
702 PartyExp
= int ((stat
['KillsChapterCount'] * 100) / ChapterCount
)
703 Label
.SetText (str (PartyExp
) + '%')
707 Label
= Window
.GetControl (0x10000011)
708 Label
.SetText (str (stat
['KillsChapterXP']))
709 Label
= Window
.GetControl (0x10000015)
710 Label
.SetText (str (stat
['KillsTotalXP']))
712 #count of kills in chapter/game
713 Label
= Window
.GetControl (0x10000012)
714 Label
.SetText (str (stat
['KillsChapterCount']))
715 Label
= Window
.GetControl (0x10000016)
716 Label
.SetText (str (stat
['KillsTotalCount']))
718 Window
.ShowModal (MODAL_SHADOW_GRAY
)
721 def CloseInformationWindow ():
722 import GUICommonWindows
723 global InformationWindow
725 if InformationWindow
:
726 InformationWindow
.Unload ()
727 InformationWindow
= None
728 OptionsWindow
.SetVisible (WINDOW_VISIBLE
)
729 RecordsWindow
.SetVisible (WINDOW_VISIBLE
)
730 GUICommonWindows
.PortraitWindow
.SetVisible (WINDOW_VISIBLE
)
733 def OpenBiographyWindow ():
734 global BiographyWindow
736 if BiographyWindow
!= None:
739 BiographyWindow
= Window
= GemRB
.LoadWindow (12)
740 GemRB
.SetVar ("FloatWindow", BiographyWindow
.ID
)
742 TextArea
= Window
.GetControl (0)
743 pc
= GemRB
.GameGetSelectedPCSingle ()
744 TextArea
.SetText (GemRB
.GetPlayerString (pc
, 74) )
747 Button
= Window
.GetControl (2)
748 Button
.SetText (11973)
749 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CloseBiographyWindow
)
751 Window
.ShowModal (MODAL_SHADOW_GRAY
)
754 def CloseBiographyWindow ():
755 global BiographyWindow
758 BiographyWindow
.Unload ()
759 BiographyWindow
= None
760 InformationWindow
.SetVisible (WINDOW_VISIBLE
)
763 def OpenExportWindow ():
764 global ExportWindow
, NameField
, ExportDoneButton
766 ExportWindow
= GemRB
.LoadWindow (13)
768 TextArea
= ExportWindow
.GetControl (2)
769 TextArea
.SetText (10962)
771 TextArea
= ExportWindow
.GetControl (0)
772 TextArea
.GetCharacters ()
774 ExportDoneButton
= ExportWindow
.GetControl (4)
775 ExportDoneButton
.SetText (11973)
776 ExportDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
778 CancelButton
= ExportWindow
.GetControl (5)
779 CancelButton
.SetText (13727)
780 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
782 NameField
= ExportWindow
.GetControl (6)
784 ExportDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ExportDonePress
)
785 CancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ExportCancelPress
)
786 NameField
.SetEvent (IE_GUI_EDIT_ON_CHANGE
, ExportEditChanged
)
787 ExportWindow
.ShowModal (MODAL_SHADOW_GRAY
)
788 NameField
.SetStatus (IE_GUI_CONTROL_FOCUSED
)
791 def ExportDonePress():
793 ExportWindow
.Unload()
794 #save file under name from EditControl
797 def ExportCancelPress():
799 ExportWindow
.Unload()
802 def ExportEditChanged():
803 ExportFileName
= NameField
.QueryText ()
804 if ExportFileName
== "":
805 ExportDoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
807 ExportDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
810 def OpenCustomizeWindow ():
811 global CustomizeWindow
812 global PortraitsTable
, ScriptsTable
, ColorTable
814 pc
= GemRB
.GameGetSelectedPCSingle ()
815 if GemRB
.GetPlayerStat (pc
, IE_MC_FLAGS
)&MC_EXPORTABLE
:
820 PortraitsTable
= GemRB
.LoadTable ("PICTURES")
821 ScriptsTable
= GemRB
.LoadTable ("SCRPDESC")
822 ColorTable
= GemRB
.LoadTable ("CLOWNCOL")
823 CustomizeWindow
= GemRB
.LoadWindow (17)
825 PortraitSelectButton
= CustomizeWindow
.GetControl (0)
826 PortraitSelectButton
.SetText (11961)
828 PortraitSelectButton
.SetState (IE_GUI_BUTTON_DISABLED
)
830 SoundButton
= CustomizeWindow
.GetControl (1)
831 SoundButton
.SetText (10647)
833 SoundButton
.SetState (IE_GUI_BUTTON_DISABLED
)
835 ColorButton
= CustomizeWindow
.GetControl (2)
836 ColorButton
.SetText (10646)
838 ColorButton
.SetState (IE_GUI_BUTTON_DISABLED
)
840 ScriptButton
= CustomizeWindow
.GetControl (3)
841 ScriptButton
.SetText (17111)
843 #This button exists only in bg2/iwd, theoretically we could create it here
844 #BiographyButton = CustomizeWindow.GetControl (9)
845 #BiographyButton.SetText (18003)
847 # BiographyButton.SetState (IE_GUI_BUTTON_DISABLED)
849 TextArea
= CustomizeWindow
.GetControl (5)
850 TextArea
.SetText (11327)
852 CustomizeDoneButton
= CustomizeWindow
.GetControl (7)
853 CustomizeDoneButton
.SetText (11973)
854 CustomizeDoneButton
.SetState (IE_GUI_BUTTON_ENABLED
)
856 CancelButton
= CustomizeWindow
.GetControl (8);
857 CancelButton
.SetText (13727)
858 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
860 PortraitSelectButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, OpenPortraitSelectWindow
)
861 SoundButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, OpenSoundWindow
)
862 ColorButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, OpenColorWindow
)
863 ScriptButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, OpenScriptWindow
)
864 #BiographyButton.SetEvent (IE_GUI_BUTTON_ON_PRESS, OpenBiographyEditWindow)
865 CustomizeDoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CustomizeDonePress
)
866 CancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CustomizeCancelPress
)
868 CustomizeWindow
.ShowModal (MODAL_SHADOW_GRAY
)
871 def CustomizeDonePress ():
872 CloseCustomizeWindow ()
873 UpdateRecordsWindow ()
876 def CustomizeCancelPress ():
877 CloseCustomizeWindow ()
878 UpdateRecordsWindow ()
881 def CloseCustomizeWindow ():
882 global CustomizeWindow
885 CustomizeWindow
.Unload ()
886 CustomizeWindow
= None
889 def OpenPortraitSelectWindow ():
890 global SubCustomizeWindow
891 global PortraitButton
892 global Gender
, LastPortrait
894 SubCustomizeWindow
= GemRB
.LoadWindow (18)
895 pc
= GemRB
.GameGetSelectedPCSingle ()
896 Gender
= GemRB
.GetPlayerStat (pc
, IE_SEX
, 1)
897 PortraitName
= GemRB
.GetPlayerPortrait (pc
, 0)
898 LastPortrait
= PortraitsTable
.GetRowIndex (PortraitName
[0:len(PortraitName
)-1])
900 PortraitButton
= SubCustomizeWindow
.GetControl (0)
901 PortraitButton
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_NO_IMAGE
,OP_SET
)
902 PortraitButton
.SetState (IE_GUI_BUTTON_LOCKED
)
904 LeftButton
= SubCustomizeWindow
.GetControl (1)
905 RightButton
= SubCustomizeWindow
.GetControl (2)
907 DoneButton
= SubCustomizeWindow
.GetControl (3)
908 DoneButton
.SetText (11973)
909 DoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
911 CancelButton
= SubCustomizeWindow
.GetControl (4)
912 CancelButton
.SetText (13727)
913 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
915 CustomPortraitButton
= SubCustomizeWindow
.GetControl (5)
916 CustomPortraitButton
.SetText (17545)
918 LeftButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, PortraitLeftPress
)
919 RightButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, PortraitRightPress
)
920 DoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, PortraitDonePress
)
921 CancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CloseSubCustomizeWindow
)
922 CustomPortraitButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, OpenCustomPortraitWindow
)
923 SubCustomizeWindow
.ShowModal (MODAL_SHADOW_GRAY
)
926 if PortraitsTable
.GetValue (LastPortrait
, 0) == Gender
:
929 LastPortrait
= LastPortrait
+ 1
933 def PortraitDonePress ():
934 pc
= GemRB
.GameGetSelectedPCSingle ()
935 Name
= PortraitsTable
.GetRowName (LastPortrait
)
936 GemRB
.FillPlayerInfo (pc
, Name
+ "L", Name
+ "S")
937 CloseSubCustomizeWindow ()
940 def PortraitRightPress():
944 LastPortrait
= LastPortrait
+ 1
945 if LastPortrait
>= PortraitsTable
.GetRowCount ():
947 if PortraitsTable
.GetValue (LastPortrait
, 0) == Gender
:
953 def PortraitLeftPress():
957 LastPortrait
= LastPortrait
- 1
959 LastPortrait
= PortraitsTable
.GetRowCount ()-1
960 if PortraitsTable
.GetValue (LastPortrait
, 0) == Gender
:
966 def UpdatePortrait ():
967 PortraitName
= PortraitsTable
.GetRowName (LastPortrait
)+"G"
968 PortraitButton
.SetPicture (PortraitName
, "NOPORTLG")
971 def OpenCustomPortraitWindow ():
972 global SubSubCustomizeWindow
973 global PortraitList1
, PortraitList2
974 global RowCount1
, RowCount2
976 SubSubCustomizeWindow
= GemRB
.LoadWindow (19)
978 SmallPortraitButton
= SubSubCustomizeWindow
.GetControl (1)
979 SmallPortraitButton
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_NO_IMAGE
,OP_SET
)
981 LargePortraitButton
= SubSubCustomizeWindow
.GetControl (0)
982 LargePortraitButton
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_NO_IMAGE
,OP_SET
)
984 DoneButton
= SubSubCustomizeWindow
.GetControl (10)
985 DoneButton
.SetText (11973)
986 DoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
987 DoneButton
.SetState (IE_GUI_BUTTON_DISABLED
)
989 CancelButton
= SubSubCustomizeWindow
.GetControl (11)
990 CancelButton
.SetText (13727)
991 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
993 # Portrait List Large
994 PortraitList1
= SubSubCustomizeWindow
.GetControl (2)
995 RowCount1
= PortraitList1
.GetPortraits (0)
996 PortraitList1
.SetEvent (IE_GUI_TEXTAREA_ON_CHANGE
, LargeCustomPortrait
)
997 GemRB
.SetVar ("Row1", RowCount1
)
998 PortraitList1
.SetVarAssoc ("Row1",RowCount1
)
1000 # Portrait List Small
1001 PortraitList2
= SubSubCustomizeWindow
.GetControl (3)
1002 RowCount2
= PortraitList2
.GetPortraits (1)
1003 PortraitList2
.SetEvent (IE_GUI_TEXTAREA_ON_CHANGE
, SmallCustomPortrait
)
1004 GemRB
.SetVar ("Row2", RowCount2
)
1005 PortraitList2
.SetVarAssoc ("Row2",RowCount2
)
1007 DoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CustomPortraitDonePress
)
1008 CancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CloseSubSubCustomizeWindow
)
1010 SubSubCustomizeWindow
.ShowModal (MODAL_SHADOW_GRAY
)
1013 def CustomPortraitDonePress ():
1014 pc
= GemRB
.GameGetSelectedPCSingle ()
1015 GemRB
.FillPlayerInfo (pc
, PortraitList1
.QueryText () , PortraitList2
.QueryText ())
1017 CloseSubSubCustomizeWindow ()
1018 #closing the generic portraits, because we just set a custom one
1019 CloseSubCustomizeWindow ()
1022 def LargeCustomPortrait ():
1023 Window
= SubSubCustomizeWindow
1025 Portrait
= PortraitList1
.QueryText ()
1027 if GemRB
.GetVar ("Row1") == RowCount1
:
1030 Label
= Window
.GetControl (0x10000007)
1031 Label
.SetText (Portrait
)
1033 Button
= Window
.GetControl (10)
1035 Portrait
= "NOPORTMD"
1036 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
1038 if PortraitList2
.QueryText ()!="":
1039 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
1041 Button
= Window
.GetControl (0)
1042 Button
.SetPicture (Portrait
, "NOPORTMD")
1045 def SmallCustomPortrait ():
1046 Window
= SubSubCustomizeWindow
1048 Portrait
= PortraitList2
.QueryText ()
1050 if GemRB
.GetVar ("Row2") == RowCount2
:
1053 Label
= Window
.GetControl (0x10000008)
1054 Label
.SetText (Portrait
)
1056 Button
= Window
.GetControl (10)
1058 Portrait
= "NOPORTSM"
1059 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
1061 if PortraitList1
.QueryText ()!="":
1062 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
1064 Button
= Window
.GetControl (1)
1065 Button
.SetPicture (Portrait
, "NOPORTSM")
1068 def OpenSoundWindow ():
1069 global SubCustomizeWindow
1073 SubCustomizeWindow
= GemRB
.LoadWindow (20)
1075 VoiceList
= SubCustomizeWindow
.GetControl (5)
1076 VoiceList
.SetFlags (IE_GUI_TEXTAREA_SELECTABLE
)
1077 pc
= GemRB
.GameGetSelectedPCSingle ()
1078 Gender
= GemRB
.GetPlayerStat (pc
, IE_SEX
, 1)
1080 VoiceList
.SetVarAssoc ("Selected", 0)
1081 RowCount
=VoiceList
.GetCharSounds()
1083 PlayButton
= SubCustomizeWindow
.GetControl (7)
1084 PlayButton
.SetText (17318)
1086 TextArea
= SubCustomizeWindow
.GetControl (8)
1087 TextArea
.SetText (11315)
1089 DoneButton
= SubCustomizeWindow
.GetControl (10)
1090 DoneButton
.SetText (11973)
1091 DoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1093 CancelButton
= SubCustomizeWindow
.GetControl (11)
1094 CancelButton
.SetText (13727)
1095 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
1097 PlayButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, PlaySoundPressed
)
1098 DoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, DoneSoundWindow
)
1099 CancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CloseSubCustomizeWindow
)
1101 SubCustomizeWindow
.ShowModal (MODAL_SHADOW_GRAY
)
1104 def DoneSoundWindow ():
1105 pc
= GemRB
.GameGetSelectedPCSingle ()
1106 CharSound
= VoiceList
.QueryText ()
1107 GemRB
.SetPlayerSound (pc
, CharSound
)
1109 CloseSubCustomizeWindow ()
1112 def PlaySoundPressed():
1113 global CharSoundWindow
, SoundIndex
, SoundSequence
1115 CharSound
= VoiceList
.QueryText ()
1116 while (not GemRB
.HasResource (CharSound
+ SoundSequence
[SoundIndex
], RES_WAV
)):
1118 GemRB
.PlaySound (CharSound
+ SoundSequence
[SoundIndex
], 0, 0, 4)
1121 def OpenColorWindow ():
1122 global SubCustomizeWindow
1123 global PortraitWindow
1124 global PortraitButton
1125 global HairButton
, SkinButton
, MajorButton
, MinorButton
1126 global HairColor
, SkinColor
, MajorColor
, MinorColor
1128 pc
= GemRB
.GameGetSelectedPCSingle ()
1129 MinorColor
= GemRB
.GetPlayerStat (pc
, IE_MINOR_COLOR
)
1130 MajorColor
= GemRB
.GetPlayerStat (pc
, IE_MAJOR_COLOR
)
1131 SkinColor
= GemRB
.GetPlayerStat (pc
, IE_SKIN_COLOR
)
1132 HairColor
= GemRB
.GetPlayerStat (pc
, IE_HAIR_COLOR
)
1133 SubCustomizeWindow
= GemRB
.LoadWindow (21)
1135 PortraitButton
= SubCustomizeWindow
.GetControl (0)
1136 PortraitButton
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_NO_IMAGE
,OP_SET
)
1137 PortraitButton
.SetState (IE_GUI_BUTTON_LOCKED
)
1139 HairButton
= SubCustomizeWindow
.GetControl (3)
1140 SkinButton
= SubCustomizeWindow
.GetControl (4)
1141 MajorButton
= SubCustomizeWindow
.GetControl (5)
1142 MinorButton
= SubCustomizeWindow
.GetControl (6)
1144 DoneButton
= SubCustomizeWindow
.GetControl (12)
1145 DoneButton
.SetText (11973)
1146 DoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1148 CancelButton
= SubCustomizeWindow
.GetControl (13)
1149 CancelButton
.SetText (13727)
1150 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
1152 HairButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, SetHairColor
)
1153 SkinButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, SetSkinColor
)
1154 MajorButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, SetMajorColor
)
1155 MinorButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, SetMinorColor
)
1156 DoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, DoneColorWindow
)
1157 CancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CloseSubCustomizeWindow
)
1160 SubCustomizeWindow
.ShowModal (MODAL_SHADOW_GRAY
)
1163 def DoneColorWindow ():
1164 pc
= GemRB
.GameGetSelectedPCSingle ()
1165 GemRB
.SetPlayerStat (pc
, IE_MINOR_COLOR
, MinorColor
)
1166 GemRB
.SetPlayerStat (pc
, IE_MAJOR_COLOR
, MajorColor
)
1167 GemRB
.SetPlayerStat (pc
, IE_SKIN_COLOR
, SkinColor
)
1168 GemRB
.SetPlayerStat (pc
, IE_HAIR_COLOR
, HairColor
)
1169 CloseSubCustomizeWindow ()
1172 def UpdatePaperDoll ():
1173 pc
= GemRB
.GameGetSelectedPCSingle ()
1174 Color1
= GemRB
.GetPlayerStat (pc
, IE_METAL_COLOR
)
1175 MinorButton
.SetBAM ("COLGRAD", 0, 0, MinorColor
&0xff)
1176 MajorButton
.SetBAM ("COLGRAD", 0, 0, MajorColor
&0xff)
1177 SkinButton
.SetBAM ("COLGRAD", 0, 0, SkinColor
&0xff)
1178 Color5
= GemRB
.GetPlayerStat (pc
, IE_LEATHER_COLOR
)
1179 Color6
= GemRB
.GetPlayerStat (pc
, IE_ARMOR_COLOR
)
1180 HairButton
.SetBAM ("COLGRAD", 0, 0, HairColor
&0xff)
1181 PortraitButton
.SetPLT (GUICommon
.GetActorPaperDoll (pc
),
1182 Color1
, MinorColor
, MajorColor
, SkinColor
, Color5
, Color6
, HairColor
, 0, 0)
1185 def SetHairColor ():
1186 global ColorIndex
, PickedColor
1189 PickedColor
= HairColor
1193 def SetSkinColor ():
1194 global ColorIndex
, PickedColor
1197 PickedColor
= SkinColor
1201 def SetMinorColor ():
1202 global ColorIndex
, PickedColor
1205 PickedColor
= MinorColor
1209 def SetMajorColor ():
1210 global ColorIndex
, PickedColor
1213 PickedColor
= MajorColor
1217 def OpenColorPicker ():
1218 global SubSubCustomizeWindow
1221 SubSubCustomizeWindow
= GemRB
.LoadWindow (22)
1223 GemRB
.SetVar ("Selected",-1)
1224 for i
in range (1,35):
1225 Button
= SubSubCustomizeWindow
.GetControl (i
)
1226 Button
.SetState (IE_GUI_BUTTON_DISABLED
)
1227 Button
.SetFlags (IE_GUI_BUTTON_PICTURE|IE_GUI_BUTTON_RADIOBUTTON
,OP_OR
)
1230 for i
in range (34):
1231 MyColor
= ColorTable
.GetValue (ColorIndex
, i
)
1234 Button
= SubSubCustomizeWindow
.GetControl (i
+1)
1235 Button
.SetBAM("COLGRAD", 2, 0, MyColor
)
1236 if PickedColor
== MyColor
:
1237 GemRB
.SetVar ("Selected",i
)
1239 Button
.SetState (IE_GUI_BUTTON_ENABLED
)
1240 Button
.SetVarAssoc("Selected",i
)
1241 Button
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, DonePress
)
1243 SubSubCustomizeWindow
.ShowModal (MODAL_SHADOW_GRAY
)
1247 global HairColor
, SkinColor
, MajorColor
, MinorColor
1250 CloseSubSubCustomizeWindow ()
1251 PickedColor
=ColorTable
.GetValue (ColorIndex
, GemRB
.GetVar ("Selected"))
1253 HairColor
=PickedColor
1257 SkinColor
=PickedColor
1261 MinorColor
=PickedColor
1265 MajorColor
=PickedColor
1269 def OpenScriptWindow ():
1270 global SubCustomizeWindow
1271 global ScriptTextArea
, SelectedTextArea
1273 SubCustomizeWindow
= GemRB
.LoadWindow (11)
1275 ScriptTextArea
= SubCustomizeWindow
.GetControl (2)
1276 ScriptTextArea
.SetFlags (IE_GUI_TEXTAREA_SELECTABLE
)
1278 pc
= GemRB
.GameGetSelectedPCSingle ()
1279 script
= GemRB
.GetPlayerScript (pc
)
1280 scriptindex
= ScriptsTable
.GetRowIndex (script
)
1281 GemRB
.SetVar ("Selected", scriptindex
)
1282 ScriptTextArea
.SetVarAssoc ("Selected", scriptindex
)
1284 SelectedTextArea
= SubCustomizeWindow
.GetControl (4)
1285 UpdateScriptSelection ()
1287 DoneButton
= SubCustomizeWindow
.GetControl (5)
1288 DoneButton
.SetText (11973)
1289 DoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1291 CancelButton
= SubCustomizeWindow
.GetControl (6)
1292 CancelButton
.SetText (13727)
1293 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
1295 DoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, DoneScriptWindow
)
1296 CancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CloseSubCustomizeWindow
)
1297 ScriptTextArea
.SetEvent (IE_GUI_TEXTAREA_ON_CHANGE
, UpdateScriptSelection
)
1299 SubCustomizeWindow
.ShowModal (MODAL_SHADOW_GRAY
)
1302 def FillScriptList ():
1303 ScriptTextArea
.Clear ()
1304 row
= ScriptsTable
.GetRowCount ()
1305 for i
in range (row
):
1306 GemRB
.SetToken ("script", ScriptsTable
.GetRowName (i
) )
1307 title
= ScriptsTable
.GetValue (i
,0)
1309 desc
= ScriptsTable
.GetValue (i
,1)
1310 txt
= GemRB
.GetString (title
)
1313 txt
+= GemRB
.GetString (desc
)
1315 ScriptTextArea
.Append (txt
+"\n", -1)
1318 ScriptTextArea
.Append (ScriptsTable
.GetRowName (i
)+"\n" ,-1)
1322 def DoneScriptWindow ():
1323 pc
= GemRB
.GameGetSelectedPCSingle ()
1324 script
= ScriptsTable
.GetRowName (GemRB
.GetVar ("Selected") )
1325 GemRB
.SetPlayerScript (pc
, script
)
1326 CloseSubCustomizeWindow ()
1329 def UpdateScriptSelection():
1330 text
= ScriptTextArea
.QueryText ()
1331 SelectedTextArea
.SetText (text
)
1334 def OpenBiographyEditWindow ():
1335 global SubCustomizeWindow
1340 pc
= GemRB
.GameGetSelectedPCSingle ()
1341 BioStrRef
= GemRB
.GetPlayerString (pc
, 74)
1342 if BioStrRef
!= 33347:
1345 SubCustomizeWindow
= GemRB
.LoadWindow (23)
1347 ClearButton
= SubCustomizeWindow
.GetControl (5)
1348 ClearButton
.SetText (34881)
1350 DoneButton
= SubCustomizeWindow
.GetControl (1)
1351 DoneButton
.SetText (11973)
1352 DoneButton
.SetFlags (IE_GUI_BUTTON_DEFAULT
, OP_OR
)
1354 RevertButton
= SubCustomizeWindow
.GetControl (3)
1355 RevertButton
.SetText (2240)
1357 RevertButton
.SetState (IE_GUI_BUTTON_DISABLED
)
1359 CancelButton
= SubCustomizeWindow
.GetControl (2)
1360 CancelButton
.SetText (13727)
1361 CancelButton
.SetFlags (IE_GUI_BUTTON_CANCEL
, OP_OR
)
1363 TextArea
= SubCustomizeWindow
.GetControl (4)
1364 TextArea
.SetBufferLength (65535)
1365 TextArea
.SetText (BioStrRef
)
1367 ClearButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, ClearBiography
)
1368 DoneButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, DoneBiographyWindow
)
1369 RevertButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, RevertBiography
)
1370 CancelButton
.SetEvent (IE_GUI_BUTTON_ON_PRESS
, CloseSubCustomizeWindow
)
1372 SubCustomizeWindow
.ShowModal (MODAL_SHADOW_GRAY
)
1375 def ClearBiography():
1376 pc
= GemRB
.GameGetSelectedPCSingle ()
1377 BioStrRef
= 62015+pc
1378 #GemRB.CreateString (BioStrRef, "")
1379 TextArea
.SetText ("")
1382 def DoneBiographyWindow ():
1386 pc
= GemRB
.GameGetSelectedPCSingle ()
1388 BioStrRef
= 62015+pc
1389 GemRB
.CreateString (BioStrRef
, TextArea
.QueryText())
1390 GemRB
.SetPlayerString (pc
, 74, BioStrRef
)
1391 CloseSubCustomizeWindow ()
1394 def RevertBiography():
1398 TextArea
.SetText (33347)
1401 def CloseSubCustomizeWindow ():
1402 global SubCustomizeWindow
1404 if SubCustomizeWindow
:
1405 SubCustomizeWindow
.Unload ()
1406 SubCustomizeWindow
= None
1409 def CloseSubSubCustomizeWindow ():
1410 global SubSubCustomizeWindow
1412 if SubSubCustomizeWindow
:
1413 SubSubCustomizeWindow
.Unload ()
1414 SubSubCustomizeWindow
= None
1417 ###################################################
1418 # End of file GUIREC.py