parameters: ()
return_statement: return
docstring: Updates all of the portraits.
docstring_summary: Updates all of the portraits.
docstring_tokens: Updates all of the portraits .
function: def UpdatePortraitWindow ():
  	"""Updates all of the portraits."""
  
  	Window = GemRB.GetView("PORTWIN")
  	Window.Focus(None)
  
  	pc = GemRB.GameGetSelectedPCSingle ()
  	Inventory = GemRB.GetVar ("Inventory")
  	GSFlags = GemRB.GetGUIFlags()
  	indialog = GSFlags & GS_DIALOG
  
  	PortraitButtons = GetPortraitButtonPairs (Window)
  	for i, Button in PortraitButtons.items():
  		pcID = i + 1
  		if indialog:
  			Button.SetHotKey(None)
  		if (pcID <= GemRB.GetPartySize()):
  			Button.SetAction(lambda btn, pc=pcID: GemRB.GameControlLocateActor(pc), IE_ACT_MOUSE_ENTER);
  			Button.SetAction(lambda: GemRB.GameControlLocateActor(-1), IE_ACT_MOUSE_LEAVE);
  			if (i < 6 and not indialog):
  				Button.SetHotKey(chr(ord('1') + i), 0, True)
  
  		if GameCheck.IsPST():
  			UpdateAnimatedPortrait(Window, i)
  			continue
  
  		Portrait = GemRB.GetPlayerPortrait (pcID, 1)
  		pic = Portrait["Sprite"]
  		Hide = False
  		if Inventory and pc != pcID:
  			Hide = True
  
  		if pic and GemRB.GetPlayerStat(pcID, IE_STATE_ID) & STATE_DEAD:
  			import GUISTORE
  			# dead pcs are hidden in all stores but temples
  			if GUISTORE.StoreWindow and not GUISTORE.StoreHealWindow:
  				Hide = True
  
  		if Hide or (not pic and not Portrait["ResRef"]):
  			Button.SetFlags (IE_GUI_BUTTON_NO_IMAGE, OP_SET)
  			Button.SetState (IE_GUI_BUTTON_DISABLED)
  			Button.SetText ("")
  			Button.SetTooltip ("")
  			continue
  
  		portraitFlags = IE_GUI_BUTTON_PORTRAIT | IE_GUI_BUTTON_HORIZONTAL | IE_GUI_BUTTON_ALIGN_LEFT | IE_GUI_BUTTON_ALIGN_BOTTOM
  
  		if GameCheck.IsIWD2():
  			Button.SetEvent (IE_GUI_BUTTON_ON_RIGHT_PRESS, OpenInventoryWindowClick)
  			Button.SetEvent (IE_GUI_BUTTON_ON_PRESS, PortraitButtonOnPress)
  
  		Button.SetFlags (portraitFlags, OP_SET)
  
  		Button.SetState (IE_GUI_BUTTON_LOCKED)
  		if pic == None:
  			pic = ""
  		Button.SetPicture (pic, "NOPORTSM")
  		ratio_str, color = GUICommon.SetupDamageInfo (pcID, Button, Window)
  
  		# character - 1 == bam cycle, sometimes
  		# only frames have all the glyphs
  		# only bg2 and iwds have a proper blank glyph
  		# so avoid using blanks except in bg2
  		flag = blank = bytearray([33])
  		if GameCheck.IsBG2():
  			# only BG2 has icons for talk or store
  			flag = blank = bytearray([238])
  			talk = bytearray([154]) # dialog icon
  			store = bytearray([155]) # shopping icon
  
  			if pc == pcID and GemRB.GetStore() != None:
  				flag = store
  			# talk icon
  			elif GemRB.GameGetSelectedPCSingle(1) == pcID:
  				flag = talk
  
  		if LUCommon.CanLevelUp (pcID):
  			if GameCheck.IsBG2():
  				flag = flag + blank + bytearray([255])
  			else:
  				flag = bytearray([255])
  		else:
  			if GameCheck.IsBG2():
  				flag = flag + blank + blank
  			else:
  				flag = ""
  			if GameCheck.IsIWD1() or GameCheck.IsIWD2():
  				HPLabel = Window.GetControl (100+i)
  				HPLabel.SetText (ratio_str)
  				HPLabel.SetColor (color)
  			
  		FlagLabel = Window.GetControl (200 + i)
  		FlagLabel.SetText(flag)
  
  		#add effects on the portrait
  		effects = GemRB.GetPlayerStates (pcID)
  
  		numCols = 4 if GameCheck.IsIWD2() else 3
  		numEffects = len(effects)
  
  		# calculate the partial row
  		idx = numEffects % numCols
  		states = bytearray(effects[0:idx])
  		# now do any rows that are full
  		for x in range(idx, numEffects):
  			if (x - idx) % numCols == 0:
  				states.append(ord('\n'))
  			states.append(effects[x])
  
  		Button.SetText(states)
  	return
function_tokens: def UpdatePortraitWindow ( ) : Window = GemRB . GetView ( "PORTWIN" ) Window . Focus ( None ) pc = GemRB . GameGetSelectedPCSingle ( ) Inventory = GemRB . GetVar ( "Inventory" ) GSFlags = GemRB . GetGUIFlags ( ) indialog = GSFlags & GS_DIALOG PortraitButtons = GetPortraitButtonPairs ( Window ) for i , Button in PortraitButtons . items ( ) : pcID = i + 1 if indialog : Button . SetHotKey ( None ) if ( pcID <= GemRB . GetPartySize ( ) ) : Button . SetAction ( lambda btn , pc = pcID : GemRB . GameControlLocateActor ( pc ) , IE_ACT_MOUSE_ENTER ) Button . SetAction ( lambda : GemRB . GameControlLocateActor ( - 1 ) , IE_ACT_MOUSE_LEAVE ) if ( i < 6 and not indialog ) : Button . SetHotKey ( chr ( ord ( '1' ) + i ) , 0 , True ) if GameCheck . IsPST ( ) : UpdateAnimatedPortrait ( Window , i ) continue Portrait = GemRB . GetPlayerPortrait ( pcID , 1 ) pic = Portrait [ "Sprite" ] Hide = False if Inventory and pc != pcID : Hide = True if pic and GemRB . GetPlayerStat ( pcID , IE_STATE_ID ) & STATE_DEAD : import GUISTORE # dead pcs are hidden in all stores but temples if GUISTORE . StoreWindow and not GUISTORE . StoreHealWindow : Hide = True if Hide or ( not pic and not Portrait [ "ResRef" ] ) : Button . SetFlags ( IE_GUI_BUTTON_NO_IMAGE , OP_SET ) Button . SetState ( IE_GUI_BUTTON_DISABLED ) Button . SetText ( "" ) Button . SetTooltip ( "" ) continue portraitFlags = IE_GUI_BUTTON_PORTRAIT | IE_GUI_BUTTON_HORIZONTAL | IE_GUI_BUTTON_ALIGN_LEFT | IE_GUI_BUTTON_ALIGN_BOTTOM if GameCheck . IsIWD2 ( ) : Button . SetEvent ( IE_GUI_BUTTON_ON_RIGHT_PRESS , OpenInventoryWindowClick ) Button . SetEvent ( IE_GUI_BUTTON_ON_PRESS , PortraitButtonOnPress ) Button . SetFlags ( portraitFlags , OP_SET ) Button . SetState ( IE_GUI_BUTTON_LOCKED ) if pic == None : pic = "" Button . SetPicture ( pic , "NOPORTSM" ) ratio_str , color = GUICommon . SetupDamageInfo ( pcID , Button , Window ) # character - 1 == bam cycle, sometimes # only frames have all the glyphs # only bg2 and iwds have a proper blank glyph # so avoid using blanks except in bg2 flag = blank = bytearray ( [ 33 ] ) if GameCheck . IsBG2 ( ) : # only BG2 has icons for talk or store flag = blank = bytearray ( [ 238 ] ) talk = bytearray ( [ 154 ] ) # dialog icon store = bytearray ( [ 155 ] ) # shopping icon if pc == pcID and GemRB . GetStore ( ) != None : flag = store # talk icon elif GemRB . GameGetSelectedPCSingle ( 1 ) == pcID : flag = talk if LUCommon . CanLevelUp ( pcID ) : if GameCheck . IsBG2 ( ) : flag = flag + blank + bytearray ( [ 255 ] ) else : flag = bytearray ( [ 255 ] ) else : if GameCheck . IsBG2 ( ) : flag = flag + blank + blank else : flag = "" if GameCheck . IsIWD1 ( ) or GameCheck . IsIWD2 ( ) : HPLabel = Window . GetControl ( 100 + i ) HPLabel . SetText ( ratio_str ) HPLabel . SetColor ( color ) FlagLabel = Window . GetControl ( 200 + i ) FlagLabel . SetText ( flag ) #add effects on the portrait effects = GemRB . GetPlayerStates ( pcID ) numCols = 4 if GameCheck . IsIWD2 ( ) else 3 numEffects = len ( effects ) # calculate the partial row idx = numEffects % numCols states = bytearray ( effects [ 0 : idx ] ) # now do any rows that are full for x in range ( idx , numEffects ) : if ( x - idx ) % numCols == 0 : states . append ( ord ( '\n' ) ) states . append ( effects [ x ] ) Button . SetText ( states ) return