How to show Unit promotions in Popup list

OrionVeteran

Deity
Joined
Dec 25, 2003
Messages
2,443
Location
Newport News VA
I have a small issue that I would like to fix on a python popup. The popup I have currently, (see image), lists all the units on a specified plot and displays two attributes for each unit: The button image of the unit and the Name of the Unit. Here are the specific lines:

Code:
xUnitName = gc.getUnitInfo(xUnitType).getDescription()
xUnitButton = gc.getUnitInfo(xUnitType).getButton()

popupInfo.addPythonButton([B]xUnitName[/B], [B]xUnitButton[/B])


What I want to do is show a third attribute to the popup line: The promotions. Does anyone know how to change the popup line to include the images of all the promotions the unit may have?
 

Attachments

  • DiplomacyMenu.JPG
    DiplomacyMenu.JPG
    17.5 KB · Views: 96
I actually have no idea what can "xUnitType" variable do, but i tried to ignore that part. ;)
You should try the following code:
xUnitPromotion = gc.getPromotionInfo(xUnitType).getButton()

popupInfo.addPythonButton(xUnitName, xUnitButton, xUnitPromotion)

The above code will ONLY display the units promotions' buttons, and no info about them.
I'm sorry if that won't work. I know Python well, but not Civ 4 python. I just think it's logical above.
The only thing I'm not sure is the part in red. I think a good programmer should confirm it, if I'm right, or tell us if i were wrong.
Anyway, try it out, and tell me if works. :)
 
I actually have no idea what can "xUnitType" variable do, but i tried to ignore that part. ;)
You should try the following code:


The above code will ONLY display the units promotions' buttons, and no info about them.
I'm sorry if that won't work. I know Python well, but not Civ 4 python. I just think it's logical above.
The only thing I'm not sure is the part in red. I think a good programmer should confirm it, if I'm right, or tell us if i were wrong.
Anyway, try it out, and tell me if works. :)

Thanks for the reply and I'll let you know the results.
 
Nope. It blew up. I think the solution will involve getting a list of promotions for the unit and then adding that list the the popup line.

This line won't work, as it is only a single promotion.

Code:
xUnitPromotion = gc.getPromotionInfo(iPromotion).getButton()

Code:
PromoList = [] 

for iPromotion in range(gc.getNumPromotionInfos()):					
	if xUnit.isHasPromotion(iPromotion):
		xUnitPromotion = gc.getPromotionInfo(iPromotion).getButton()
		PromoList.append(iPromotion)

I'm not sure how to do it.
 
I'm not sure, but I think that the popup text doesn't support the fancy tags, including the <img ...> tags which are needed for the promotions images.

I remember trying something like this once, and getting to this conclusion. But I could be mistaken :dunno:
 
Back
Top Bottom