display of building yields in city screen

davidlallen

Deity
Joined
Apr 28, 2008
Messages
4,743
Location
California
I have partially implemented a modcomp which allows buildings to generate yield and commerce based on the number of a resource controlled. For example, "+2 production per coal resource controlled" or "+0.75 food per rice resource controlled". You can view this as "Lightweight Corporations". The effect is similar, but there is no maintenance, no spread, and no executives. Please see this thread for additional design discussion.

I have implemented the schema, data load, calculations, and part of the display. I am stuck on the other part of the display. In vanilla, when you build a shrine, its effects depend on the number of other cities following the religion. In the city screen, when you look at the building list on the left, you see a line like "Church of the Nativity +8 gold +4 culture". Also, when you hover over the name, the hover help gives the static effect ("+1 gold per city") and also the current dynamic result ("+8 gold") on the first line.

The hover help is controlled by CvGameTextMgr::setBuildingHelp() and I have added my code to that. However, I am not able to find where the values are computed for the line in the building list. As a result, my hover help is right, but the building list data is wrong. Please see attached screenshot. The text next to the palace should also indicate the huge commerce bonus, even if all the text does not fit.

attachment.php


Does anybody know where the text in each line of the building list is created?
 

Attachments

  • building-help.gif
    building-help.gif
    42 KB · Views: 178
Hey! :)

It's done in CvMainInterface.py. Check out szRightBuffer in line 6047-6130 (DW 1.6.4):
Spoiler :

Code:
for i in range( gc.getNumBuildingInfos() ):
	if (pHeadSelectedCity.getNumBuilding(i) > 0):

		for k in range(pHeadSelectedCity.getNumBuilding(i)):
							
			szLeftBuffer = gc.getBuildingInfo(i).getDescription()
			szRightBuffer = u""
			bFirst = True
							
			if (pHeadSelectedCity.getNumActiveBuilding(i) > 0):
				iHealth = pHeadSelectedCity.getBuildingHealth(i)

				if (iHealth != 0):
					if ( bFirst == False ):
						szRightBuffer = szRightBuffer + ", "
					else:
						bFirst = False
										
					if ( iHealth > 0 ):
						szTempBuffer = u"+%d%c" %( iHealth, CyGame().getSymbolID(FontSymbols.HEALTHY_CHAR) )
						szRightBuffer = szRightBuffer + szTempBuffer
					else:
						szTempBuffer = u"+%d%c" %( -(iHealth), CyGame().getSymbolID(FontSymbols.UNHEALTHY_CHAR) )
						szRightBuffer = szRightBuffer + szTempBuffer

				iHappiness = pHeadSelectedCity.getBuildingHappiness(i)

				if (iHappiness != 0):
					if ( bFirst == False ):
						szRightBuffer = szRightBuffer + ", "
					else:
						bFirst = False
										
					if ( iHappiness > 0 ):
						szTempBuffer = u"+%d%c" %(iHappiness, CyGame().getSymbolID(FontSymbols.HAPPY_CHAR) )
						szRightBuffer = szRightBuffer + szTempBuffer
					else:
						szTempBuffer = u"+%d%c" %( -(iHappiness), CyGame().getSymbolID(FontSymbols.UNHAPPY_CHAR) )
						szRightBuffer = szRightBuffer + szTempBuffer

				for j in range( YieldTypes.NUM_YIELD_TYPES):
					iYield = gc.getBuildingInfo(i).getYieldChange(j) + pHeadSelectedCity.getNumBuilding(i) * pHeadSelectedCity.getBuildingYieldChange(gc.getBuildingInfo(i).getBuildingClassType(), j)

					if (iYield != 0):
						if ( bFirst == False ):
							szRightBuffer = szRightBuffer + ", "
						else:
							bFirst = False
											
						if ( iYield > 0 ):
							szTempBuffer = u"%s%d%c" %( "+", iYield, gc.getYieldInfo(j).getChar() )
							szRightBuffer = szRightBuffer + szTempBuffer
						else:
							szTempBuffer = u"%s%d%c" %( "", iYield, gc.getYieldInfo(j).getChar() )
							szRightBuffer = szRightBuffer + szTempBuffer
										
# BUG - Raw Yields - start
						self.yields.addBuilding(j, iYield)
# BUG - Raw Yields - end

			for j in range(CommerceTypes.NUM_COMMERCE_TYPES):
				iCommerce = pHeadSelectedCity.getBuildingCommerceByBuilding(j, i) / pHeadSelectedCity.getNumBuilding(i)
	
				if (iCommerce != 0):
					if ( bFirst == False ):
						szRightBuffer = szRightBuffer + ", "
					else:
						bFirst = False
										
					if ( iCommerce > 0 ):
						szTempBuffer = u"%s%d%c" %( "+", iCommerce, gc.getCommerceInfo(j).getChar() )
						szRightBuffer = szRightBuffer + szTempBuffer
					else:
						szTempBuffer = u"%s%d%c" %( "", iCommerce, gc.getCommerceInfo(j).getChar() )
						szRightBuffer = szRightBuffer + szTempBuffer
	
			szBuffer = szLeftBuffer + "  " + szRightBuffer
							
			screen.appendTableRow( "BuildingListTable" )
			screen.setTableText( "BuildingListTable", 0, iNumBuildings, "<font=1>" + szLeftBuffer + "</font>", "", WidgetTypes.WIDGET_HELP_BUILDING, i, -1, CvUtil.FONT_LEFT_JUSTIFY )
			screen.setTableText( "BuildingListTable", 1, iNumBuildings, "<font=1>" + szRightBuffer + "</font>", "", WidgetTypes.WIDGET_HELP_BUILDING, i, -1, CvUtil.FONT_RIGHT_JUSTIFY )
 
Back
Top Bottom